akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <queue>
#include <set>
#include <utility>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define mp make_pair

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

struct S {
    int x, y, d;
    S() {}
    S(int x, int y, int d) : x(x), y(y), d(d) {}
};

bool operator<(const S& l, const S& r) {
    if (l.x != r.x) return l.x < r.x;
    if (l.y != r.y) return l.y < r.y;
    return l.d < r.d;
}

int H, W;
char f[16][64];

S forward(int x, int y, int d) {
    for (;;) {
        const int nx = x + dx[d], ny = y + dy[d];
        if (f[nx][ny] == '#') return S(x, y, d);
        x = nx, y = ny;
    }
}

#define PUSH(q, vis, s) { if (!vis.count(s)) vis.insert(s), q.push(s); }
bool reach(const S& s, const S& t) {
    set<S> vis;
    queue<S> q;
    const S st = forward(s.x, s.y, s.d);
    PUSH(q, vis, st);
    while (!q.empty()) {
        const S cur = q.front();
        q.pop();
        if (cur.x == t.x && cur.y == t.y) return true;
        int dd = 1;
        rep (_, 2) {
            const S p = forward(cur.x, cur.y, (cur.d+dd)%4);
            PUSH(q, vis, p);
            dd += 2;
        }
    }
    return false;
}

void push(queue<pair<S, S> >& q, set<pair<S, S> >& vis, const S& l, int x, int y, int d) {
    const int rd = (d+2) % 4;
    if (f[x+dx[d]][y+dy[d]] != '#') return ;
    for (;;) {
        const pair<S, S> ss(l, S(x, y, d));
        PUSH(q, vis, ss);
        const int nx = x + dx[rd], ny = y + dy[rd];
        if (f[nx][ny] == '#') break;
        x = nx, y = ny;
    }
}

bool accomplish(const S& s, const S& t) {
    set<pair<S, S> > vis;
    queue<pair<S, S> > q;
    const S st = forward(s.x, s.y, s.d);
    rep (d, 4) push(q, vis, st, s.x, s.y, d);
    while (!q.empty()) {
        const pair<S, S> vv = q.front();
        q.pop();
        const S cur = vv.first, rev = vv.second;
        if (cur.x == t.x && cur.y == t.y
                && rev.x == t.x && rev.y == t.y && rev.d == t.d) {
            return true;
        }
        int dd = 1;
        rep (_, 2) {
            push(q, vis, forward(cur.x, cur.y, (cur.d+dd)%4),
                    rev.x, rev.y, (rev.d+dd)%4);
            dd += 2;
        }
    }
    return false;
}

void solve() {
    S s(-1, -1, -1), t(-1, -1, -1);
    rep (i, H) rep (j, W) if (f[i][j] == 'K') {
        f[i][j] = '.';
        s.x = i, s.y = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') s.d = d;
    }
    rep (i, H) rep (j, W) if (f[i][j] == 'M') {
        f[i][j] = '.';
        t.x = i, t.y = j;
        rep (d, 4) if (f[i+dx[d]][j+dy[d]] != '#') t.d = d;
    }
    if (!reach(s, t)) puts("He cannot bring tea to his master.");
    else if (!accomplish(s, t)) puts("He cannot return to the kitchen.");
    else puts("He can accomplish his mission.");
}

int main() {
    for (;;) {
        scanf("%d%d", &W, &H);
        if (H == 0) return 0;
        rep (i, H) rep (j, W) scanf(" %c", f[i]+j);
        solve();
    }
}

Measured memory_bytes: 18000
//Night's template
//orzakyrt
#include <bits/stdc++.h>
#define R register
#define LL long long
#ifdef __DEBUG__
	#define Debug (fprintf(stderr,"orzyrt\n"),fflush(stderr))
	#define debug(__a...) (fprintf(stderr,__a),fflush(stderr))
#else
	#define Debug ('orzyrt')
	#define debug(__a...) ('orzyrt')
#endif
inline void Compile(R char *s){
	char com[111];
	sprintf(com,"g++ %s.cpp -lm -o %s",s,s);
	system(com);
}
inline void setfile(R char *s){
	char inname[111],outname[111];
	sprintf(inname,"%s.in",s);
	sprintf(outname,"%s.out",s);
	freopen(inname,"r",stdin);
	freopen(outname,"w",stdout);
}
#ifdef __DEBUG__
	#define setfile(__a) (1)
#endif
template<class TT>inline TT Max(R TT a,R TT b){return a<b?b:a;}
template<class TT>inline TT Min(R TT a,R TT b){return a<b?a:b;}
template<class TT>inline TT Abs(R TT a){return a<0?-a:a;}
template<class TT>inline TT cmin(R TT &a,R TT b){(b<a)&&(a=b);}
template<class TT>inline TT cmax(R TT &a,R TT b){(a<b)&&(a=b);}
using namespace std;
template<class TT>inline void read(R TT &x){
	x=0;R bool f=false;R char c=getchar();
	for(;c<48||c>57;c=getchar())f|=(c=='-');
	for(;c>47&&c<58;c=getchar())x=(x<<1)+(x<<3)+(c^48);
	(f)&&(x=-x);
}
//end template

namespace Night{
	int n,m;
	int ans;
	inline bool check(R int x){
		if(x>=n)return 1;
		else return 0;
	}
	int main(){
		read(n);read(m);
		for(R int i=1;i*i<=m;++i){
			if(m%i)continue;
			if(check(i))cmax(ans,m/i);
			if(check(m/i))cmax(ans,i);
		}
		cout<<ans<<endl;
		return 0;
	}
}
int main(){
	return Night::main();
}


Measured memory_bytes: 256
#include <stdio.h>
int main () {
	int n=1,k,i,sum=0;
	scanf("%d %d",&n,&k);
	int h[100000]={0};
	for (i=0;i<n;i++) {
		scanf("%d",&h[i]);
	}
	for (i=0;i<n;i++) {
		if(h[i]>=k) sum++;
	}
	printf("%d\n",sum);
	return 0;
}



Measured memory_bytes: 512
def prime_decomposition(n):
  i = 2
  d = {}
  while i * i <= n:
    while n % i == 0:
      n /= i
      if i not in d:
          d[i] = 0
      d[i] += 1
    i += 1
  if n > 1:
    if n not in d:
        d[n] = 1
  return d

def egcd(a, b):
    (x, lastx) = (0, 1)
    (y, lasty) = (1, 0)
    while b != 0:
        q = a // b
        (a, b) = (b, a % b)
        (x, lastx) = (lastx - q * x, x)
        (y, lasty) = (lasty - q * y, y)
    return (lastx, lasty, a)

# ax ≡ 1 (mod m)
def modinv(a, m):
    (inv, q, gcd_val) = egcd(a, m)
    return inv % m

def modfact(n,N):
    r = 1
    for i in range(1,n+1):
        r = r % N * i % N
    return r


def modconb(n,r,N):
    p = modfact(n,N)
    q1 = modinv(modfact(r,N),N)
    q2 = modinv(modfact(n-r,N),N)
    return p*q1%N*q2%N


N,M = map(int,input().split())
R = 10**9+7

d = prime_decomposition(M)
ans = 1
for p in d:
    ans *= modconb(d[p]+N-1,N-1,R)
    ans %= R
print(ans)


Measured memory_bytes: 3064
package main

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

const (
	initialBufSize = 1024
	maxBufSize     = 1e6
)

var (
	scanner = bufio.NewScanner(os.Stdin)
)

func main() {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	n := scanInt()
	s := scanText()

	b := []byte(s)
	ans := 0
	var prev byte
	for i := 0; i < n; i++ {
		if b[i] != prev {
			ans++
		}
		prev = b[i]
	}

	fmt.Println(ans)
}

func scanInt() int {
	i, _ := strconv.Atoi(scanText())
	return i
}

func scanInts(size int) []int {
	ints := make([]int, size)
	for i := 0; i < size; i++ {
		ints[i] = scanInt()
	}
	return ints
}

func scanFloat64() float64 {
	f, _ := strconv.ParseFloat(scanText(), 64)
	return f
}

func scanFloat64s(size int) []float64 {
	f := make([]float64, size)
	for i := 0; i < size; i++ {
		f[i] = scanFloat64()
	}
	return f
}

func scanText() string {
	scanner.Scan()
	return scanner.Text()
}

func scanTexts(size int) []string {
	s := make([]string, size)
	for i := 0; i < size; i++ {
		s[i] = scanText()
	}
	return s
}

func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}

func pow(x, y int) int {
	return int(math.Pow(float64(x), float64(y)))
}

// greatest common divisor(最大公約数)
func gcd(a, b int) int {

	if a < b {
		a, b = b, a
	}

	for {
		mod := a % b
		if mod == 0 {
			return b
		}
		a, b = b, mod
	}
}

// latest common multiple(最小公倍数)
func lcm(a, b int) int {
	return (a / gcd(a, b)) * b
}


Measured memory_bytes: 1024
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    print(700 + 100 * (s.count('o')))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 3696
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, a;
  cin >> n >> a;
  int temp = n % 500;
  
  //cout << temp << endl;
  if(a - temp >= 0){
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int32_t main(){
	int n, m;
	cin >> n >> m;
		int a[n+2][m+2];
	memset(a,0,sizeof a);
	
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			char c;
			cin >> c;
			if(c == '.')
				a[i][j] = 1;
		}
	}
	int right[n+2][m+2], down[n+2][m+2], up[n+2][m+2];
	memset(right,0,sizeof right);
	memset(down,0,sizeof down);
	memset(up,0,sizeof up);

	for(int i = 1; i <= n; i++){
		for(int j = m; j >= 1; j--){
			if(a[i][j])
				right[i][j] = 1 + right[i][j+1];
		}
	}
	
	for(int j = 1; j <= m; j++){
		for(int i = n; i >= 1; i--){
			if(a[i][j])
				down[i][j] = 1 + down[i+1][j];
		}
	}
	
	for(int j = 1; j <= m; j++){
		for(int i = 1; i <= n; i++){
			if(a[i][j])
				up[i][j] = 1 + up[i-1][j];
		}
	}
	
	int ans = 0;
	for(int i = 1; i <= n; i++){
		int left = 0;
		for(int j = 1; j <= m; j++){
			if(!a[i][j]){
				left = 0;
				continue;
			}
			left++;
			ans = max(ans,up[i][j]+left+right[i][j]+down[i][j]-3LL);
		}
	}
	cout << ans << endl;
	
	

	return 0;
}



Measured memory_bytes: 125440
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);
constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

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

signed main() {
    INIT;
    cin >> S >> T;
    string res = S + T;
    REP(i, res.size()) {
        if (i & 1)
            res[i] = T[i / 2];
        else
            res[i] = S[i / 2];
    }
    cout << res << endl;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pp pair<pair<ll, ll>,pair<ll, ll>>
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define pdd pair<double,double>
#define vii vector<int>
#define vll vector<ll>
#define mat vector<vector<ll>>
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define eb emplace_back
#define fi first
#define sc second
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define sz(x) (ll) (x).size()
#define pq priority_queue<ll>
#define pqg priority_queue<ll,vector<ll>,greater<ll>>
#define LB(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define UB(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
#define ERASE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end())
#define int ll
// #define ll int
using namespace std;
const ll INF = (1 << 30 ) - 1;
const ll LLINF = (1LL << 60LL);
const ll MOD = 1000000007;
// const ll mod = 998244353;
const ll MAX = 2100000;
const double pi = acos(-1);
const double eps = 1e-10;
ll dx[8] ={1,0,-1,0,1,-1,1,-1};
ll dy[8] ={0,1,0,-1,1,-1,-1,1};
 
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; }


ll n,k;
ll a[5010];
bool dp[5010][5010];

bool ok(ll index){
    rep(i,5010)rep(j,5010) dp[i][j]=0;
    dp[0][0]=1;
    rep(i,n){
        rep(j,k+1){
            if(dp[i][j]==0) continue;
            dp[i+1][j]=dp[i][j];
            if(i==index) continue;
            if(j + a[i] > k) continue;
            dp[i+1][j+a[i]]=1;
        }
    }
    bool can=true;
    // cout<<index<<endl;
    // rep(i,k){
    //     cout<<dp[n][i]<<" ";
    // }
    // cout<<endl;

    rep2(i,max(0ll,k-a[index]),k){
        if(dp[n][i]) can = false;
    }
    return can;
}



void solve() {
    
    cin>>n>>k;
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    ll left=-1, right=n;
    while(left != right - 1){
        ll mid = (left+right)/2;
        if(ok(mid)) left = mid;
        else right = mid;
    }
    // cout<<left<<" "<<right<<endl;
    cout<<left+1<<endl;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);


    solve(); 


    return 0;
}


Measured memory_bytes: 28216
use std::io;

fn main() {
    let mut buf = String::new();
    io::stdin().read_line(&mut buf).ok();
    buf.trim();
    let mut n = 0;
    for c in buf.chars() {
        if c == '1' {
            n += 1;
        }
    }
    println!("{}", n)
}


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

int main() {
	ll n;
	cin >> n;
	ll t_ans = 1;
	ll a_ans = 1;
	for (ll i = 0; i < n; ++i) {
		ll t, a;
		cin >> t >> a;
		ll x = max((t_ans + t - 1) / t, (a_ans + a - 1) / a);
		t_ans = t * x;
		a_ans = a * x;
	}
	cout << t_ans + a_ans << endl;
}

Measured memory_bytes: 256
package main

import (
"fmt"
"strconv"
)

func main() {
	var a, b string
	fmt.Scan(&a, &b)
	new_number, _ := strconv.Atoi(a + b)
	for i := 0; i < new_number / 2; i++ {
		if new_number == i * i {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <map>
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define pb(a) push_back(a)
#define MAX(a, b) ((a < b)?b:a)
#define MIN(a, b) ((a > b)?b:a)
typedef long long int ll;
typedef unsigned long long int ull;
using namespace std;

template<typename T> void cinpb(vector<T>& x) { T n; cin >> n; x.push_back(n); }
ull gcd(ull a, ull b) { return b ? gcd(b, a%b) : a; }
ull lcm(ull m, ull n) {	return ((0 == m) || (0 == n)) ? 0 : ((m / gcd(m, n)) * n); }
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };


int main()
{
	int n;
	vector<int> xori;
	vector<int> x;
	cin >> n;
	rep (i, n)
	{
		int xi;
		cin >> xi;
		x.pb(xi);
		xori.pb(xi);
	}

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

	for (int i = 0; i < n; i++)
	{
		if ( x[n / 2] < xori[i] )
		{
			cout << x[n / 2 - 1] << endl;
		}
		else if ( x[n / 2] > xori[i] )
		{
			cout << x[n / 2] << endl;
		}
		else
		{
			cout << x[n / 2 - 1] << endl;
		}
	}

	return 0;
}


Measured memory_bytes: 3948
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main()
{
    int R[MAX], n;

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

    int maxv = -2000000000;
    int minv = R[0];

    for (int i = 1; i < n; i++) {
        maxv = max(maxv, R[i] - minv);
        minv = min(minv, R[i]);
    }

    cout << maxv << endl;

    return 0;
}



Measured memory_bytes: 3852
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,m,x;
	cin>>n>>m>>x;
	int c[50],a[50][50],sum[50],ans[4097],cnt=0;
	memset(ans,0,sizeof(ans));
	for(int i=1;i<=n;i++)
	{
		cin>>c[i];
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	}
	for(int i=0;i<(1<<n);i++)
	{
		memset(sum,0,sizeof(sum));
		int cost=0;
		for(int j=0;j<n;j++)
			if(i&(1<<j))
			{
				cost+=c[j+1];
				for(int k=1;k<=m;k++)
					sum[k]+=a[j+1][k];
			}
		bool bad=0;
		for(int j=1;j<=m;j++)
			if(sum[j]<x)
			{
				bad=1;
				break;
			}
		if(!bad)
			ans[++cnt]=cost;
	}
	sort(ans+1,ans+cnt+1);
	if(ans[1]==0)
		cout<<-1;
	else
		cout<<ans[1];
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  
  int N,M;
  cin >> N >> M;
  vector<int> sw(N);
  for (int i=0;i<M;i++){
    int K;
    cin >> K;
    for (int j=0;j<K;j++){
      int s;
      cin >> s;
      s --;
      sw[s] |= 1 << i;
    }
  }
  
  // for (int i=0;i<N;i++) cout << sw[i] << endl; //test
  // cout << endl; //test
  
  int P = 0;
  for (int i=0;i<M;i++){
    int x;
    cin >> x;  
    P |= x << i;
  }
  
  // cout << P << endl << endl; //test
  
  int ans = 0;
  
  for (int i=0;i<(1<<N);i++){
    int state = 0;
    for (int j=0;j<N;j++){
      if((i>>j)&1 == 1){
        state ^= sw[j];
      }
    }
    // cout << state << endl; //test
    if (state == P) ans++;
  }
  
  cout << ans << endl;
}

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

using namespace std;

#define lp(i,n) for(int i = 0; i <n;i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define MP make_pair
#define SZ(v) ((int)((v).size()))
typedef long long ll;

const int MOD = 1e9 + 7;
const int OO = (int)1e6;
const int N = (int)1e7;

void init(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}
int n,k;
int vis[N];
int dp[N];
int solve(int idx){
    if(vis[idx])
        return 0;
    if(idx==n)return 1;
    
    if(idx>n)return 0;
    int &ret = dp[idx];

    if(~ret)
        return ret;
    ret =(solve(idx+1)+solve(idx+2))%MOD;
    return  ret;

}
int main() {
	#   ifdef LOCAL_PROJECT
        freopen("in.txt", "r", stdin);
    #   endif
    
    scanf("%d%d",&n,&k);
    int x;
    for(int i=1;i<= k;i++){
        scanf("%d" , &x);
        vis[x] = 1;
    }
    memset(dp , -1 , sizeof(dp));
    printf("%d\n" ,solve(0));
    return 0;
}

Measured memory_bytes: 44288
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int R = nextInt();

		double ans = (double)2*R*Math.PI;

		System.out.printf("%.9f%n",ans);

	}


	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


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

int a[120];

int main(){

    int n, m;
    double sum = 0;
    cin >> n >> m;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }

    int cnt = 0;
    double t = 1/(4.0*m);
    for(int i=0;i<n;i++){
        if(a[i]/sum >= t)
            cnt++;
    }

    if(cnt>=m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;




    return 0;
}


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

int main(){
	int n,W;
	cin>>n>>W;
	long long int v[n+1],w[n+1];
	rep(i,1,n){
		cin>>w[i]>>v[i];
	}
	vector<vector<long long int>> dp(n+1, vector<long long int> (W+1,0));
	rep(i,1,W){
		rep(j,1,n){
			dp[j][i] = dp[j-1][i];
			if(i-w[j]>=0){
				dp[j][i] = max(dp[j][i], v[j]+dp[j-1][i-w[j]]);
			}
		}
	}
	cout<<dp[n][W]<<"\n";
	return 0;
}

Measured memory_bytes: 80256
#include <iostream>
#include <sstream>
using namespace std;
#include <bits/stdc++.h>
#include<utility>
#include <algorithm>
#include<iterator>
#define  go return 0
#define rep(i,n) for(int i=0;i<n;++i)
#define rep(j,m) for(int j=0;j<m;++j)
#define REP(i,n) for(int i=1;i<=n;++i)
#define all(v)   ((v).begin()), ((v).end())
#define len(s)   ((int)s.size())
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef double db;
typedef vector<ll> ve;
typedef vector< vector < int> > vee;
typedef vector<pair<ll,ll> > vepa;
typedef set<int>se;
typedef map<char,int> mpp;
const ll N=1e3+5;
ll arr[N],A[N],cnt[N];
bool visited[N];
bool f,ff;
int main()
{
ios::sync_with_stdio(0);
cin.tie(0);
    int n;
    cin>>n;
    while(n>0)
    {
        if(n%10==7)
        {
            cout<<"Yes";
            go;
        }
        n/=10;
    }
    cout<<"No";
go;
}


Measured memory_bytes: 3636
N=int(input())
if N<=111:
    print(111)
if N>111 and N<=222:
    print(222)
if N>222 and N<=333:
    print(333)
if N>333 and N<=444:
    print(444)
if N>444 and N<=555:
    print(555)
if N>555 and N<=666:
    print(666)
if N>666 and N<=777:
    print(777)
if N>777 and N<=888:
    print(888)
if N>888 and N<=999:
    print(999)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};

int main(void){
	int n,tot=0;
	lld d;
	scanf("%d%lld",&n,&d);
	for(int e=0;e<n;e++){
		lld a,b;
		scanf("%lld%lld",&a,&b);
		if(a*a+b*b<=d*d) tot++;
	}
	printf("%d",tot);
	return 0;
}


Measured memory_bytes: 3820
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
typedef pair<int,int> P;
struct edge{int to,cost;};
#define REP(i,n) for(int i=0;i<(n);i++)
const int INF=100000000000000000;
const int MOD=1000000007;

int N,M;

std::map<int,int> dec2(int n){
	std::map<int,int> m;
	int a=2;
	while(n>=a*a){
		if(n%a==0){
			m[a]++;
			n/=a;
		}
		else{
			a++;
		}
	}
	m[n]++;
	return m;
}

int extgcd(int a,int b,int &x,int &y){
	int g=a;
	x=1,y=0;
	if(b!=0){
		g=extgcd(b,a%b,y,x);
		y-=(a/b)*x;
	}
	return g;
}
 
// 逆元
int mod_inverse(int a,int m){
	int x, y;
	extgcd(a,m,x,y);
	return (m+x%m)%m;
}
 
// 階乗
std::vector<int>fact;
void mod_fact(int n, int m){
	fact.resize(n+1);
	fact[0]=1;
	for(int i=1;i<=n;i++){
		fact[i]=fact[i-1]*i%m;
	}
}
 
// nCk mod p
int mod_nCr(int n, int k, int m){
	if(n<k)return 0;
	return fact[n]*mod_inverse(fact[k]*fact[n-k]%m,m)%m;
}

signed main(){
	cin>>N>>M;
	map<int,int> cnt;
	mod_fact(N+65,MOD);
	cnt=dec2(M);
	DEB(cnt[2])END
	int ans=1;
	for(auto x:cnt){
		if(x.first==1)continue;
		int res=mod_nCr(x.second+N-1,x.second,MOD);
		ans*=res;
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<math.h>
#include<algorithm>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	if (a[a.size()-1] == b[0] && b[b.size()-1] == c[0]){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,n) for(int i=1;i<(int)(n);i++)

typedef long long ll;
using namespace std;
int main()
{
  string s;
  cin>>s;
  ll len=s.length();
  s.erase(len-1);
  len--;

  while(len>1){
    if(s.substr(0,len/2)==s.substr(len/2)){
      cout<<len<<endl;
      return 0;
    }
    s.erase(len-1);
    len--;
  }
  return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
typedef long long int lli;

int main(){
    lli n, m;
    cin >> n >> m;
    vector<pair<lli, lli>> amount_num;
    for(lli i = 0; i < n; ++i){
        pair<lli, lli> amount_num_input;
        cin >> amount_num_input.first >> amount_num_input.second;
        amount_num.push_back(amount_num_input);
    }

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

    lli amount_sum = 0, num_sum = 0;
    for(lli i = 0; num_sum < m; ++i){
        lli num_diff = m - num_sum;
        num_sum += min(num_diff, amount_num[i].second);
        amount_sum += amount_num[i].first * min(num_diff, amount_num[i].second);
    }

    cout << amount_sum << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
//ranker
using namespace std;

#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using pii = pair<int, int>;
using pis = pair<int, string>;
using psi = pair<string, int>;
using D = double;

void merge (int *first1, int *last1, int *first2, int *last2){
    int size1 = last1 - first1;
    int size2 = last2 - first2;
    int *result = new int[size1+size2];
    int i = 0;
    int j = 0;
    int index = 0;
    while (true){
        if (i < size1 && (first1[i] <= first2[j] || j >= size2)){
            result[index] = first1[i];
            ++i; ++index;
        }
        if (j < size2 && (first1[i] > first2[j] || i >= size1)){
            result[index] = first2[j];
            ++j; ++index;
        }
        if (i==size1 && j==size2){
            for (i=0; i<size1; ++i) first1[i] = result[i];
            for (j=0; j<size2; ++j) first2[j] = result[j+size1];
            delete[] result;
            return;
        }
    }
}
void MergeSort (int *first, int *last){
    int size = last - first;
    if(size <= 1) return;
    MergeSort(first, first+size/2);
    MergeSort(first+size/2, last);
    merge(first, first+size/2, first+size/2, last);
}


int gcd(int a, int b)
{
    int c;

    if (a < b) {
        a+=b; b=a-b; a-=b;
    }

    while (b != 0) {
        c = a % b;
        a = b;
        b = c;
    }

    return a;
}

int dx[3]={-1, 0, 1};
int dy[3]={-1, 0, 1};
int W, H;
int  masu[100][100]={0};
int cnt;

//????????????????¨???°?????????
//abs(dx[i]+dy[j])==1??§??????

int dfs(int a, int b){
  masu[a][b] = 2;
  REP(i, 3)REP(j, 3) if(masu[a+dx[i]][b+dy[j]]== 1 && a+dx[i] >= 0 && a+dx[i] < W && b+dx[j] >= 0 && b+dx[j] < H){
    dfs(a+dx[i], b+dy[j]);
  }
  return 1;
}


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

  while(1){
    cin >> W >> H;
    if(W == 0 && H == 0) break;
    REP(j, H)REP(i, W) cin >> masu[i][j];

    cnt = 0;
    REP(j, H) REP(i, W) if(masu[i][j]==1){
      cnt+=dfs(i, j);
    }
    cout << cnt << endl;
  }
    return 0;
}

Measured memory_bytes: 3228
N,K=map(int,input().split())
A=[int(i) for i in input().split()]
#AiをKi回切ると仮定した場合Ai/(Ki+1)
#Kiの総和はK
#つまりKiを動かしたときのmax_i Ai/(Ki+1)を最小化する
#2分探索！
#最小値をmidにするための回数はK回以内でOKか？
#計算量はNlog(maxA)なので通りそう
low=0
high=max(A)+1
#low できない
#high できる
while(high-low>1):
    mid=(high+low)//2
    #ceil(Ai/(Ki+1))=mid
    #ceil(x)-1<x<=ceil(x)
    #x<=ceil(x)<x+1
    #mid-1<Ai/(Ki+1)<=mid
    #Ai/(Ki+1)<=mid<Ai/(Ki+1)+1
    #Ai<=mid*(Ki+1)<Ai+Ki+1
    #Ai/mid<=Ki+1<Ai+Ki+1
    #floor(Ai/mid)<=Ai/mid<floor(Ai/mid)+1
    #Ai/midが整数ならKi=Ai/mid-1
    #Ai/midが整数でないならばKi=Ai/mid
    tmp=0
    for i in range(N):
        tmp+=A[i]//mid
        if A[i]%mid==0:
            tmp-=1
    if tmp<=K:
        high=mid
    else:
        low=mid
print(high)


Measured memory_bytes: 104292
#include<stdio.h>
#include<string.h>
int main(void)
{
	int len,i;
	char str[21];
	scanf("%s",str);
	len=strlen(str);
	for(i=len-1;i>=0;i--){
		printf("%c",str[i]);
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 524
package main

import(
    "fmt"
    "sort"
    "strings"
)



func main() {
    var s string
    fmt.Scan(&s)
    a := make([]int,26)
    b := "abcdefghijklmnopqrstuvwxyz"
    for i:=0;i<len(s);i++{
        a[s[i]-'a']++
    }
    var ans byte
    for i:=0;i<26;i++{
        if a[i]==0{
            ans = b[i]
            break
        }
    }
    if ans == 0{
        fmt.Println("None")
    } else {
        fmt.Printf("%c\n",ans)
    }
}





// Pairsort
type Pair struct {
    first,second int64
}

type By func(p1, p2 *Pair) bool

func (by By) Sort(pairs []Pair) {
    ps := &pairSorter{
            pairs : pairs,
            by: by,
    }
    sort.Sort(ps)
}

type pairSorter struct {
    pairs []Pair
    by func(p1, p2 *Pair) bool
}

func (s *pairSorter) Len() int {
    return len(s.pairs)
}

func (s *pairSorter) Swap(i, j int) {
    s.pairs[i], s.pairs[j] = s.pairs[j], s.pairs[i]
}

func (s *pairSorter) Less(i, j int) bool {
    return s.by(&s.pairs[i], &s.pairs[j])
}

func first (p1, p2 *Pair) bool {
        return p1.first < p2.first
}

func second (p1, p2 *Pair) bool {
        return p1.second < p2.second
}
// end



func abs32(a int) int {
    if a<0{
        return -a
    }
    return a
}

func abs64(a int64) int64 {
    if a<0{
        return -a
    }
    return a
}

func min32(a, b int) int {
    if a >= b {
        return b
    }
    return a
}

func max32(a, b int) int {
    if a >= b {
        return a
    }
    return b
}

func min64(a, b int64) int64 {
    if a >= b {
        return b
    }
    return a
}

func max64(a, b int64) int64 {
    if a >= b {
        return a
    }
    return b
}

func gcd(a, b int64) int64 {
    if a % b == 0 {
        return b
    } else {
        return gcd(b, a%b)
    }
}

func lcm(a, b int64) int64 {
    return a / gcd(a, b) * b
}

func scanNums(len int) (nums []int){
    var num int
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanNums64(len int) (nums []int64){
    var num int64
    for i:=0; i<len; i++{
        fmt.Scan(&num)
        nums = append(nums,num)
    }
    return
}

func scanString(len int) (str []string){
    var s string
    for i:=0; i<len; i++{
        fmt.Scan(&s)
        str = append(str,s)
    }
    return
}

func makeTwoNums(n,m int) ([][]int){
    Nums := make([][]int, n)
    for i:=0; i<n; i++{
        Nums[i] = make([]int, m)
    }
    return Nums
}

func sortString(s string) string{
    t := strings.Split(s, "")
    sort.Strings(t)
    return strings.Join(t, "")
}

func reverseString(s string) string{
    t := []rune(s)
    for i,j := 0, len(s)-1 ; i < j ; i, j = i+1, j-1 {
        t[i], t[j] = t[j], t[i]
    }
    return string(t)
}

func inside(h,w,H,W int) bool{
    if h>=0 && h<H && w>=0 && w<W{
        return true
    }
    return false
}


Measured memory_bytes: 1280
#include<stdio.h>

int main(void){
  char s[5];
  int ima=0;
  scanf("%s",s);
  for(int i=0;i<4;i++){
    if(s[i]=='+') ++ima;
    if(s[i]=='-') --ima;
  }
  printf("%d",ima);
  return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long int ll;

struct SegmentTree
{
  vector< pair< int, int > > lazy;
  int sz, timestamp;
 
  SegmentTree(int n)
  {
    sz = 1;
    while(sz < n) sz <<= 1;
    lazy.assign(2 * sz - 1, {-1, 2147483647});
    timestamp = 0;
  }
 
  void update(int a, int b, int x, int k, int l, int r)
  {
    if(a >= r || b <= l) {
 
    } else if(a <= l && r <= b) {
      lazy[k] = {timestamp, x};
    } else {
      update(a, b, x, 2 * k + 1, l, (l + r) >> 1);
      update(a, b, x, 2 * k + 2, (l + r) >> 1, r);
    }
  }
 
  void update(int a, int b, int x)
  {
    update(a, b, x, 0, 0, sz);
    ++timestamp;
  }
 
  int query(int k)
  {
    k += sz - 1;
    auto ret = lazy[k];
    while(k > 0) {
      k = (k - 1) >> 1;
      ret = max(ret, lazy[k]);
    }
    return (ret.second);
  }
};
 
struct Stop{int s, t, x;};
bool comp(const Stop &a, const Stop &b){
	return a.x < b.x;
}
 
int main(){
	int N, Q;
	cin >> N >> Q;
	vector<Stop> S(N);
	for(int i = 0; i < N; i++){
		cin >> S[i].s >> S[i].t >> S[i].x;
	}
	sort(S.begin(), S.end(), comp);
	reverse(S.begin(), S.end());
	vector<int> D(Q);
	for(int i = 0; i < Q; i++) cin >> D[i];
	SegmentTree Tree(Q);
	for(int i = 0; i < N; i++){
		int start = lower_bound(D.begin(), D.end(), max(0, S[i].s - S[i].x)) - D.begin();
		int end = lower_bound(D.begin(), D.end(), max(0, S[i].t - S[i].x)) - D.begin();
		Tree.update(start, end, S[i].x);
	}
	for(int i = 0; i < Q; i++) cout << (Tree.query(i) == 2147483647 ? -1 : Tree.query(i)) << endl;
	return 0;
}


Measured memory_bytes: 9088
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: usize = input();
    let m: usize = input();
    let r: usize = input();
    let r: Vec<usize> = (0..r).map(|_| input()).collect();
    let abc: Vec<(usize, usize, i64)> = (0..m)
        .map(|_| {
            let a = input();
            let b = input();
            let c = input();
            (a, b, c)
        })
        .collect();

    let mut d = vec![vec![i64::max_value() / 4; n + 1]; n + 1];
    for i in 1..n + 1 {
        d[i][i] = 0;
    }
    for (a, b, c) in abc {
        d[a][b] = c;
        d[b][a] = c;
    }

    for k in 1..n + 1 {
        for i in 1..n + 1 {
            for j in 1..n + 1 {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }

    let mut visited = vec![false; r.len()];
    println!("{}", dfs(&mut visited, 0, 0, &r, &d));
}

fn dfs(visited: &mut Vec<bool>, dist: i64, cur: usize, r: &Vec<usize>, d: &Vec<Vec<i64>>) -> i64 {
    if visited.iter().all(|&b| b) {
        dist
    } else {
        let mut ans = i64::max_value();
        for i in 0..r.len() {
            if visited[i] {
                continue;
            }

            visited[i] = true;
            if cur == 0 {
                ans = std::cmp::min(ans, dfs(visited, 0, r[i], r, d));
            } else {
                ans = std::cmp::min(ans, dfs(visited, dist + d[cur][r[i]], r[i], r, d));
            }
            visited[i] = false;
        }
        ans
    }
}


Measured memory_bytes: 4352
N, X, Y = map(int, input().split())
ans = [0]*(N-1)
for i in range(1, N):
    for j in range(i+1, N+1):
        d = min(j-i, abs(X-i)+abs(j-Y)+1)
        ans[d-1] += 1

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

Measured memory_bytes: 3444
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)

def addc(p,b):
  for i in e[p]:
    if(i == b):
      continue
    c[i] += c[p]
    addc(i,p)

n,q = map(int,input().split())

e = [ [] for i in range(n + 1)]
c = [0]*(n+1)

for i in range(n-1):
  a,b = map(int,input().split())
  e[a].append(b)
  e[b].append(a)

for i in range(q):
  p,x = map(int,input().split())
  c[p] += x

addc(1,-1)

print(*c[1:])

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

//template
#define rep(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
template<typename T>inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T>inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
//end

#include "atcoder/all"
using namespace atcoder;

int main(){
   int n,q; cin>>n>>q;
   dsu uni(n);
   rep(i,0,q){
      int t,u,v; cin>>t>>u>>v;
      if(t)cout<<uni.same(u,v)<<endl;
      else uni.merge(u,v);
   }
   return 0;
}


Measured memory_bytes: 3952
// 物极必反

#include <bits/stdc++.h>

#define append push_back

using namespace std;
using ll = long long;

const int N = 5e5 + 3;
const int M = 1e6 + 7;
const long long MOD = 1e9 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 22, BL = 400;
const double EPS = 1e-9;
const int dx[] = {1, 0, 0, -1, -1, 1, -1, 1};
const int dy[] = {0, 1, -1, 0, -1, 1, 1, -1};

void debug(){
	cerr << "\n";
}
template<typename Type1, typename... Type2>
void debug(Type1 a, Type2... b) {
    cerr << a << " ";
    debug(b...);
}

int main(){
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);

    long long n, k; cin >> n >> k;

    vector<long long> a(n + 2);
    for(long long i = 1; i <= n; i++){
        cin >> a[i];
    }

    while(k--){
        bool flag = false;
        vector<long long> d(n + 2);
        for(long long i = 1; i <= n; i++){
            long long l = max(i - a[i], 1ll), r = min(i + a[i], n);
            d[l]++, d[r + 1]--;
        }
        for(long long i = 1; i <= n; i++){
            d[i] += d[i - 1];
            if(d[i] != a[i]) flag = true;
        }
        a = d;
        if(!flag) break;
    }

    for(long long i = 1; i <= n; i++){
        cout << a[i] << " ";
    }
    return 0;
}


Measured memory_bytes: 6364
#include<stdio.h>
#define NUM 8
#define FREE -1
#define NOT_FREE 1

void printBoard();
void putQueen(int);
void initialized();

int r[NUM],c[NUM],dpos[2*NUM-1],dneg[2*NUM-1];
int a[NUM][NUM];

int main(){
  int i,j,n,row,col;

  initialized();

  for(i=0;i<NUM;i++){
    for(j=0;j<NUM;j++){
      a[i][j]=0;
    }
  }


  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    scanf("%d%d",&row,&col);
    a[row][col]=1;
    
  }

  putQueen(0);


  return 0;
}


void printBoard(){
  int i,j;

  for(i=0;i<NUM;i++){
    for(j=0;j<NUM;j++){
      if(a[i][j]){
	if(r[i]!=j) return;
      }
    } 
  }
  for(i=0;i<NUM;i++){
    for(j=0;j<NUM;j++){
      if(r[i]==j)
	printf("Q");
      else printf(".");
    }
    printf("\n");
  }
  
}

void putQueen(int i){
  int j;

  if(i==NUM){
    printBoard();
    return;
  }

  for(j=0;j<NUM;j++){
    if(c[j]== NOT_FREE || dpos[i+j]==NOT_FREE || dneg[i-j+NUM-1]==NOT_FREE) continue;
    r[i]=j;
    c[j]=dpos[i+j]=dneg[i-j+NUM-1]=NOT_FREE;
  

    putQueen(i+1);
    r[i]=c[j]=dpos[i+j]=dneg[i-j+NUM-1]=FREE;
  }
}

void initialized(){
  int i;

  for(i=0;i<NUM;i++){
    r[i]=FREE;
    c[i]=FREE;
  }

  for(i=0;i<2*NUM-1;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;
  }
}



Measured memory_bytes: 2108
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<vvvi> vvvvi;



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    vi V(n);
    for (int i = 0; i < n; ++i) cin >> V[i];
    vi R(n+2);
    for (int i = n-1; i >= 0; --i) R[V[i]] = 1 + R[V[i]+1];
    int ans = n+2;
    for (int i = 0; i < n-1; ++i) {
        ans = min(ans, i + (n-i-R[i+1]));
    }
    if (n == 1) ans = 0;
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1792
fun main(args: Array<String>) {
    val n = readLine()!!.let { it.substring(it.length-1, it.length) }.toInt()

    println(when (n) {
        2, 4, 5, 7, 9 -> "hon"
        0, 1, 6, 8 -> "pon"
        else -> "bon"
    })
}


Measured memory_bytes: 34428
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

template<class T>inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
template<class T>inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	ll H, W; cin >> H >> W;
	ll ans = 1;
	if (H > 1 && W > 1) {
		ans = W * (H / 2LL);
		if (H % 2 == 1)ans += (W + 1LL) / 2LL;
	}
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256
n,x,y = map(int,input().split())
sc = y - x - 1
nl = [0]*(n-1)
for i in range(1,n+1):
    for j in range(1,n+1):
        if i < j:
            dis = j - i
            if i <= x and j >= y:
                dis -= sc
            elif i >= x and j <= y:
                dis = min(dis,i-x + y-j  +1)
            elif i <= x and j >= x and j <= y:
                dis = min(dis,y-i-sc+y-j)
            elif i >= x and i <= y and j >= y:
                dis = min(dis,j-x-sc+i-x)
            nl[dis-1] += 1
for i in nl:
    print (i)

Measured memory_bytes: 3444
#include<stdio.h>
#include<math.h>
 
 
int main(){
 
  int n, i;
  double x[100], y[100],s[100], max=0, d1=0, d2=0, d3=0,d22,d33;
  scanf("%d", &n);
  for(i=0;i<n;i++) scanf("%lf", &x[i]);
  for(i=0;i<n;i++) scanf("%lf", &y[i]);
 
  for(i=0;i<n;i++){
    s[i]=fabs(x[i]-y[i]);

    d1+=s[i];
    d2+=pow(s[i], 2);
    d3+=pow(s[i], 3);
    if(max<s[i]) max=s[i];
  }
  d22=pow(d2,0.5);
 d33=pow(d3,1.0/3);

  printf("%f\n%f\n%f\n%f\n", d1, d22, d33, max);
 
  return 0;
}


Measured memory_bytes: 2044
def is_prime(num,X):
  flg=0
  for i in range(2,X):
    if(num%i==0):
      flg=1
      break
  if(flg==0):
    return True
  else:
    return False

X=int(input())
i=0
flg=0
while True:
  num=X+i
  if(is_prime(num,X)==True):
    print(num)
    break
  i+=1

Measured memory_bytes: 38608
N = int(input())
T = []

for i in range(N):
  T.append(int(input()))

import math

def lcm(m,n):
  return (m*n)//math.gcd(m,n)

def lcm_list(nums):
  lcm_num = nums[0]
  for i in range(1,len(nums)):
    lcm_num = lcm(lcm_num,nums[i])
  return lcm_num

print(lcm_list(T))

Measured memory_bytes: 9112
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
#define F first
#define S second
using namespace std;
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; }
using ll = long long;
using pi = pair<int,int>;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};


int main()
{
  string s; cin >> s;
  int n = s.size();
  vector<vector<mint>> dp(n+1, vector<mint>(2));
  dp[0][0].x = 1;

  rep(i,n) {
    if(s[i] == '1') {
      dp[i+1][1] += dp[i][1]*(mint)3 + dp[i][0];
      dp[i+1][0] += dp[i][0]*(mint)2;
    }
    else {
      dp[i+1][1] += dp[i][1]*(mint)3;
      dp[i+1][0] += dp[i][0];
    }
  }

  cout << (dp[n][0] + dp[n][1]).x << "\n";
  
  return 0;
}


Measured memory_bytes: 8808
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int w,h,x,y,r;
  cin >>w>>h>>x>>y>>r;
  if(x-r<0 || x+r>w){
    cout<<"No"<<'\n';
  }else if(y-r<0 || y+r>h){
    cout<<"No"<<'\n';
  }else{
    cout<<"Yes"<<'\n';
  }
  return(0);
}



Measured memory_bytes: 3088
//
//  test.cpp
//  AtCoder
//
//  Created by A on 2018/06/01.
//  Copyright © 2018年 A. All rights reserved.
//

#include <iostream>
using namespace std;
#define MAX 500000
#define SENTINEL 2000000000


int L[MAX/2+2], R[MAX/2+2];
int cnt;

void merge(int A[], int n, int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    for(int i=0; i<n1; i++) L[i] = A[left+i];
    for(int i=0; i<n2; i++) R[i] = A[mid+i];
    L[n1] = R[n2] = SENTINEL;
    int i=0, j=0;
    for(int k=left; k<right; k++){
        cnt++;
        if(L[i] <= R[j]){
            A[k] = L[i++];
        } else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(int A[], int n, int left, int right){
    if(left+1 < right){
        int mid = (left+right) / 2;
        
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int main(){
    int A[MAX], n, i;
    cnt = 0;
    
    cin >> n;
    for(i=0; i<n; i++) cin >> A[i];
    
    mergeSort(A, n, 0, n);
    
    for(i=0; i<n; i++){
        if(i) cout << " ";
        cout << A[i];
    }
    cout << endl;
    
    cout << cnt << endl;
    
    return 0;
}



Measured memory_bytes: 6912
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 2e5+10;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

ll t[2*N];
void upd(int x, ll v) {
  t[x+N] = v;
  for (x += N; x > 1; x /= 2) {
    t[x/2] = max(t[x], t[x^1]);
  }
}
ll query(int l, int r) {
  ll ans = 0;
  for (l += N, r += N+1; l < r; l /= 2, r /= 2) {
    if (l%2) ans = max(ans, t[l++]);
    if (r%2) ans = max(ans, t[--r]);
  }
  return ans;
}

int n;
int h[N];
int a[N];
ll dp[N];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n);
  for (int i = 0; i < n; i++) {
    read(h[i]);
  }
  for (int i = 0; i < n; i++) {
    read(a[i]);
  }
  dp[0] = a[0];
  upd(h[0], dp[0]);
  for (int i = 1; i < n; i++) {
    dp[i] = query(0, h[i]) + a[i];
    upd(h[i], dp[i]);
  }
  cout << *max_element(dp, dp + n) << nl;
  return 0;
}


Measured memory_bytes: 6528