akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
#define endl '\n'
#define max3(a,b,c) max(a,max(b,c))

const int q = 1e9+9;




int main()
{
    int n,b;
    cin>>n>>b;
    cout<<(n-1)*(b-1)<<endl;



    return 0;
}
    // gotcha;


Measured memory_bytes: 384
n, k = map(int, input().split())
P = [int(x)-1 for x in input().split()]
C = [int(x) for x in input().split()]

vis = [0 for i in range(n+1)]
	

res = -10000000000000000000000
for i in range(0,n):
	if vis[i] == 0:
		su = 0
		vis[i] = 1
		v = []
		v.append(C[i])
		su += C[i]
		x = P[i]
		while x != i:
			vis[x] = 1
			su += C[x]
			v.append(C[x])
			x = P[x]
		vs = len(v)
		for ii in range(vs):
			umm = 0
			for j in range(vs):
				x = (ii+j)%vs
				umm += v[x]
				steps = 1+(x-ii+vs)%vs
				if k >= vs:
					if(su > 0):
						r = max((k-steps)//vs,0)
						res = max(res, r*su + umm)
					else:
						res = max(res,umm)
				else:
					if steps <= k:
						res = max(res,umm)


print(res)

Measured memory_bytes: 74572
import math;a = list(map(int,input().split()));b = a[1]//a[0];c = []
for i in range(1,int(math.sqrt(a[1]))+1):
    if a[1]%i==0 and i<=b:
        if a[1] // i <= b:
            c.append(a[1]//i)
        else:
            c.append(i)
c.sort(reverse=True);print(c[0])

Measured memory_bytes: 3060
A=int(input())
B=int(input())
C=int(input())
X=int(input())
cnt=0
for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a+100*b+50*c==X:
                cnt=cnt+1
print(cnt)


Measured memory_bytes: 3060
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	plist := make([]int, n)
	for i := 0; i < n; i++ {
		plist[i] = nextInt()
	}

	cnt := 0
	for i := 1; i < n-1; i++ {
		if plist[i-1] <= plist[i] && plist[i] <= plist[i+1] {
			cnt++
		} else if plist[i-1] >= plist[i] && plist[i] >= plist[i+1] {
			cnt++
		}

	}

	fmt.Println(cnt)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}
func nextIntMat(a int, b int) [][]int {
	mat := make([][]int, a)
	for i := 0; i < a; i++ {
		mat[i] = make([]int, b)
		for j := 0; j < b; j++ {
			mat[i][j] = nextInt()
		}
	}
	return mat
}


Measured memory_bytes: 1776
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define int long long
#define ld long double
#define fi first
#define se second
#define all(uiet) uiet.begin(),uiet.end()
#define read(UIET) for(int i = 0; i < n; ++i) cin >> UIET[i]
#define out(UIET) for(int i = 0; i < n; ++i) cout << UIET[i] << " "
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define vpp vector<pair< int, int > >
#define pll pair<int , int >
#define ppll pair < pll , pll >
#define debug(n1) cout << n1 << endl
#define len(a) ((int) (a).size())
#define endl "\n"
#define mod 1000000007
const int INF=(1LL<<60)-1;
bool isPerfectSquare(long double x) {   
    long double sr = sqrt(x); 
    return ((sr - floor(sr)) == 0); 
} 
bool isPrime(int x){
    for(int i = 2; i * i <= x; ++i){
        if(x % i == 0) return 0;
    }
    return 1;
}
int fun(int n){
    if(n & 1) return 3 * n + 1;
    else return n/2;
}
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    int check = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        if(arr[i] & 1){
            check = 1;
        }
    }
    if(check) cout << 0;
    else{
        for(int i = 1; i <= 10000; ++i){
            for(int j = 0; j < n; ++j){
                arr[j] /= 2;
                if(arr[j] & 1){
                    cout << i;
                    return 0;
                }
            }
        }
    }
}


Measured memory_bytes: 3664
#include <stdio.h>
#include <string.h>
char str[10001];
int len, n;
void turn(void)
{
	for (int i = 0; i < len; i++)
	{
		printf("%c", ((str[i] - 'A') + n) % 26 + 'A');
	}
}
int main(void)
{
	scanf("%d", &n);
	getchar();
	gets(str);
	len = strlen(str);
	turn();
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void) {
	int n, i;
	long int min = 1000001, max = -1000001, s = 0;
	scanf("%d", &n);
	for(i = 0; n > i; i++){
		long int buf;
		scanf("%ld", &buf);
		if(buf < min) min = buf;
		if(buf > max) max = buf;
		s += buf;
	}
	printf("%ld %ld %ld\n", min, max, s);
	return 0;
}

Measured memory_bytes: 600
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter, deque
#from scipy.misc import comb

N = int(input())
G = [[] for _ in range(N)]

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

d_F = [0] + [-1]*(N-1)
d_S = [-1]*(N-1) + [0]

q_F = deque([0])
q_S = deque([N-1])

while len(q_F) > 0:
    u = q_F.popleft()
    for v in G[u]:
        if d_F[v] == -1:
            d_F[v] = d_F[u] + 1
            q_F.append(v)

while len(q_S) > 0:
    u = q_S.popleft()
    for v in G[u]:
        if d_S[v] == -1:
            d_S[v] = d_S[u] + 1
            q_S.append(v)

black = 0
white = 0
for i in range(N):
    if d_F[i] <= d_S[i]: black += 1
    else: white += 1

if black > white:
    print("Fennec")
else:
    print("Snuke")

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

int main() {
  int N, a;
  set<int> A;
  bool isDistinct = true;
  
  cin >> N;
  for(int i = 0; i < N; i++) {
    cin >> a;
    if (A.count(a)) {
      isDistinct = false;
      break;
    }
    A.insert(a);
  }
  
  isDistinct ? cout << "YES" << endl : cout << "NO" << endl; 
}

Measured memory_bytes: 9600
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

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

	int A, B;
	cin >> A >> B;
	ll price = 0;
	while (price * 0.08 < A || price * 0.1 < B) {
		price++;
		if (floor(price * 0.08) == A && floor(price * 0.1) == B) {
			cout << price << "\n";
			return 0;
		}
	}
	cout << "-1\n";
}


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

#define ll long long
#define ull unsigned long long
#define mii make_pair<int, int>
#define mll make_pair<ll, ll>
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define all(v) (v).begin(), (v).end()

ofstream out("debug.txt");

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

    int h, w, k, ans = 0;
    char c;
    cin >> h >> w >> k;
    vvb v(h, vb(w, 0));
    for (int i = 0; i < h; ++i)
        for (int j = 0; j < w; ++j)
        {
            cin >> c;
            if (c == '#')
                v[i][j] = 1;
        }
    int t1 = 1 << h, t2 = 1 << w;
    for (int i = 0; i < t1; ++i)
    {
        for (int j = 0; j < t2; ++j)
        {
            int cnt = 0;
            for (int i2 = 0; i2 < h; ++i2)
                for (int j2 = 0; j2 < w; ++j2)
                    if (v[i2][j2] && !((1 << i2) & i) && !((1 << j2) & j))
                        cnt++;
            if (cnt == k)
                ans++;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3648
#include <set>
#include <map>
#include <list>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)

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

  int n,d[120000];
  cin >> n;
  rep(i, n) cin>>d[i];
  std::sort(d, d+n);
  cout << d[n/2]-d[(n/2)-1] << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
	char ch[104];
	char str[104];
	scanf("%s",&ch);
	scanf("%s",&str);
	int len=strlen(ch);
	int len1=strlen(str);
	int flag=1;
	for(int i=0;i<len;i++)
	{
		if(ch[i]!=str[i])
		{
			flag=-1;
			cout<<"No";
			return 0;
		}
	}
	if(flag==1)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
	return 0;
 } 

Measured memory_bytes: 3764
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int a[N],n;
int main()
{
	scanf("%d",&n);
	for(int i=1,x;i<n;++i){
		scanf("%d",&x);
		++a[x];
	}
	for(int i=1;i<=n;++i){
		printf("%d\n",a[i]);
	}
}

Measured memory_bytes: 4600
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>

using namespace std;

const int N = 200100;

int n, d[N][4];
char s[N];

int main() {

	scanf("%s", s);

	int n = strlen(s);

	for (int i = 0; i <= n; i++) {
		for (int j = 1; j <= 2; j++) {
			d[i][j] = -1;
		}
	}

	for (int i = 1; i <= 2 && i <= n; i++) {
		d[0][i] = 1;
	}

	int res = 0;

	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= 2; j++) {
			if (d[i][j] == -1) {
				continue;
			}
			if (i + j == n) {
				res = max(res, d[i][j]);
			}
			for (int k = 1; k <= 2; k++) {
				int from = i + j;
				int to = from + k - 1;
				if (to >= n) {
					break;
				}
				if (k != j) {
					d[from][k] = max(d[from][k], d[i][j] + 1);
				} else if (j == 1 && s[i] != s[from]) {
					d[from][k] = max(d[from][k], d[i][j] + 1);
				} else if (j == 2 && s[i] != s[from] && s[from - 1] != s[to]) {
					d[from][k] = max(d[from][k], d[i][j] + 1);
				}
			}
		}
	}

	printf("%d\n", res);

	return 0;

}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
constexpr long long MOD = 1000000007;
using ll = long long;
int main() {
    map<ll, bool> cond;
    map<ll, ll> pena;
    ll n, m;
    cin >> n >> m;
    ll p[m];
    string s[m];
    ll ok = 0, ng = 0;
    for (ll i = 0; i < m; i++) {
        cin >> p[i] >> s[i];
        if (s[i] == "AC"){
            if (!cond[p[i]]){
                ok++;
                ng += pena[p[i]];
            }
            cond[p[i]] = true;
        } else {
            if (!cond[p[i]]) pena[p[i]]++;
        }
    }
    cout << ok << " " << ng << endl;
}


Measured memory_bytes: 18944
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  string s;
  cin >> s;
  int K;
  cin >> K;
  int N = s.size();
  set<string> st;
  for (int i = 0; i < N; ++i) {
    for (int j = 1; j <= K; ++j) {
      string tmp = s.substr(i, j);
      st.insert(tmp);
    }
  }
  int cnt = 0;
  for (auto a : st) {
    cnt++;
    if (cnt == K) cout << a << endl;
  }
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define reps(i, n) for (int i = 1, i##_len = (int)(n); i <= i##_len; i++)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define push push_back
#define solve(a) ((a) ? "Yes" : "No")
typedef vector<long long> V;
typedef vector<V> VV;
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;
}
const long long INFLL = 1LL << 62;
const int INF = 1 << 30;
long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
int main()
{
    int n;
    cin >> n;
    vector<ll> t(n, 0LL);
    ll ans = 1LL;
 
    int cr = 0;
    ll bef;
   
    rep(i, n)
    {
        cin >> t[i];
       

    }
    sort(all(t),greater<ll>());
    ans=t[0];
    rep(i,n-1){
        bef = __gcd(ans, t[i + 1]);
        if(t[i+1]!=ans){
            ans *= t[i + 1] / bef;
        }
    
    }

    
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        if (n == 3 || n == 5 || n == 7) {
            System.out.println("YES");
        }else {
            System.out.println("NO");
        }
    }

}

Measured memory_bytes: 22868
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>

typedef long long LL;
using namespace std;
const int maxn = 5010, maxm = 10010, mod = 1e9 + 7;

int read()
{
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) { if(c == '-') f = 0; c = getchar(); }
	while(isdigit(c)) { x = (x << 3) + (x << 1) + (c ^ 48); c = getchar(); }
	return f ? x : -x;
}

int to[maxm], nxt[maxm], head[maxn], e;
int sz[maxn], now, fac[maxn], ifac[maxn], inv[maxn];
int f[2][maxn], n;
vector<int> rt;

void add(int x, int y) 
{ 
	to[++e] = y; nxt[e] = head[x]; head[x] = e; 
	to[++e] = x; nxt[e] = head[y]; head[y] = e;
}

void dfs(int u, int fa)
{
	int Mn = 0; sz[u] = 1;
	for(int i = head[u]; i; i = nxt[i])
	{
		int v = to[i];
		if(v == fa) continue;
		dfs(v, u); sz[u] += sz[v];
		Mn = max(Mn, sz[v]);
	}
	Mn = max(Mn, n - sz[u]);
	if(Mn == now) { rt.push_back(u); }
	else if(Mn < now) { rt.clear(); rt.push_back(u); now = Mn; }
}

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

void Add(int &x, int y) { x += y; x = (x >= mod ? x - mod : x); }

int C(int N, int M)
{
	if(N < M) return 0;
	return (LL)fac[N] * ifac[M] % mod * ifac[N - M] % mod;
}

int main()
{
	
	n = read();
	for(int i = 1; i < n; ++i) add(read(), read());

	init(n);

	now = 0x3f3f3f3f; dfs(1, 0);
	if(rt.size() == 2) { cout << (LL)fac[n / 2] * fac[n / 2] % mod << endl; return 0; }
	else
	{
		int u = rt[0];
		int p = 0, q = 1; f[0][0] = 1;
		for(int i = head[u]; i; i = nxt[i])
		{
			int v = to[i];
			dfs(v, u);
			swap(p, q); for(int j = 0; j <= n; ++j) f[p][j] = 0;
			for(int k = 0; k <= n; ++k) if(f[q][k])
				for(int j = 0; j <= sz[v]; ++j)
					Add(f[p][k + j], (LL)f[q][k] * C(sz[v], j) % mod * fac[j] % mod * C(sz[v], j) % mod);
		}

		int ans = 0, coef = 1;
		for(int i = 0; i <= n; ++i, coef = mod - coef)
			Add(ans, (LL)coef * f[p][i] % mod * fac[n - i] % mod);
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

#define db(x) cerr << #x << " = " << x << endl;
#define ll long long

#define INF 0x3f3f3f3f

int n;
vector<int> height;

vector<int> dp;

vector<int> vis;

int solve(int i)
{
    if(i == n - 1)
        return 0;

    if(i == n - 2)
        return abs(height[i] - height[i + 1]);

    if(vis[i])
        return dp[i];

    vis[i] = 1;

    dp[i] = min(solve(i + 1) + abs(height[i] - height[i + 1]), solve(i + 2) + abs(height[i] - height[i + 2]));

    return dp[i];
}

int main()
{
    scanf("%d", &n);

    dp  = vector<int>(n);
    vis = vector<int>(n);

    for(int i = 0; i < n; i++)
    {
        int aux;
        scanf("%d", &aux);
        height.push_back(aux);
    }

    printf("%d", solve(0));
}


Measured memory_bytes: 3832
#include <iostream>
#include <algorithm>
#include <vector>
#include <tuple>
#include <set>

int main() {
    int N, Q;
    std::cin >> N >> Q;
    std::vector<std::tuple<int, int, int>> events;
    for (int i = 1; i <= N; i++) {
        int S, T, X;
        std::cin >> S >> T >> X;
        events.push_back(std::make_tuple(S - X, 1, X));
        events.push_back(std::make_tuple(T - X, -1, X));
    }
    sort(events.begin(), events.end());
    events.push_back(std::make_tuple(1234567890, 255, 1234567890));
    std::vector<int> D(Q + 1);
    for (int i = 1; i <= Q; i++) {
        std::cin >> D[i];
    }
    std::vector<int> res(Q + 1);
    int idx = 1;
    std::set<int> stop;
    for (int sz = events.size(), i = 0; i < sz - 1; i++) {
        if (std::get<1>(events[i]) == 1)
            stop.insert(std::get<2>(events[i]));
        else
            stop.erase(std::get<2>(events[i]));
        while (std::get<0>(events[i]) <= D[idx] && std::get<0>(events[i + 1]) > D[idx])
            res[idx] = *stop.lower_bound(1), idx++;
    }
    for (int i = 1; i <= Q; i++)
        std::cout << (res[i] == 0 ? -1 : res[i]) << "\n";
    return 0;
}

Measured memory_bytes: 17260
#include <math.h>

#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

int main() {
  int R;
  cin >> R;

  if (R < 1200)
    cout << "ABC" << endl;
  else if (R < 2800)
    cout << "ARC" << endl;
  else
    cout << "AGC" << endl;

  return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()
#define PQ priority_queue<ll, vector<ll>, greater<ll>>

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.first < secondElof.first;
}

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

int main() {
  ll N, M;
  vector<Pair> A;
  cin >> N >> M;
  REP(i, N) {
    ll a, b;
    cin >> a >> b;
    A.push_back(make_pair(a, b));
  }
  sort(ALL(A), pairCompare);
  ll count = 0;
  ll ans = 0;
  REP(i, N) {
    if (count + A[i].second >= M) {
      ans += (M - count) * A[i].first;
      break;
    } else {
      ans += A[i].second * A[i].first;
      count += A[i].second;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2548
#![allow(unused_imports)]
use itertools::Itertools;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
use superslice::*;

fn main() {
    input! {
        a: Chars,
    }

    let n = a.len();

    let mut count: HashMap<char, u64> = HashMap::new();
    for c in a {
        *count.entry(c).or_insert(0) += 1;
    }

    let mut ans = comb(n as u64, 2) + 1;

    for (_, v) in count {
        if v >= 2 {
            ans -= comb(v, 2);
        }
    }

    println!("{}", ans);
}

fn comb(n: u64, k: u64) -> u64 {
    if n < k {
        return 0;
    }

    let mut a = 1;
    let mut b = 1;

    for i in 0..k {
        a *= n - i;
        b *= i + 1;
    }

    a / b
}


Measured memory_bytes: 3032
dx = {"N": 0, "E": 1, "W": -1, "S": 0}
dy = {"N": 1, "E": 0, "W": 0, "S": -1}

while True:
    n = int(input())
    if n == 0:
        break

    jewel = [[False for x in range(21)] for y in range(21)]
    for i in range(n):
        x, y = map(int, input().split())
        jewel[x][y] = True

    m = int(input())
    x = 10
    y = 10
    for i in range(m):
        li = input().split()
        d = li[0]
        l = int(li[1])
        for j in range(l):
            x += dx[d]
            y += dy[d]
            jewel[x][y] = False

    flag = True
    for x in range(21):
        for y in range(21):
            if jewel[x][y]:
                flag = False
        if not flag:
            break

    if flag:
        print("Yes")
    else:
        print("No")


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1<<21;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;

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

    int a = ceil((double)(n/1.08));
    int b = a*1.08;

    if(b == n){
        cout << a << endl;
    }else{
        cout << ":(" << endl;
    }
    return 0;
}

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

const int INF = 1001001001;

int c[10][1005];    // グループ毎の白チョコの数

int main() {
    int h, w, k;
    cin >> h >> w >> k;
    vector<string> s(h);
    rep(i,h) cin >> s[i];
    int ans = INF;
    rep(div, 1<<(h-1)) {
        // 横分割
        vector<int> id(h);   // i行目が何グループ目か
        int g = 0;  // 横分割時のグループ数
        rep(i,h) {
            id[i] = g;
            if (div>>i & 1) g++;
        }
        g++;
        // グループ毎の配列の初期化
        rep(i,g) rep(j,w) c[i][j] = 0;
        // グループ毎の配列の中身を計算(白チョコが何個あるか)
        rep(i,h) rep(j,w) c[id[i]][j] += (s[i][j] - '0');

        // 縦分割
        int num = g-1;
        vector<int> now(g);

        auto add = [&](int j) {
            rep(i,g) now[i] += c[i][j];
            rep(i,g) if (now[i] > k) return false;
            return true;
        };

        rep(j,w) {
            if (!add(j)) {
                num++;
                now = vector<int>(g);
                if (!add(j)) {
                    num = INF;
                    break;
                }
            }
        }
        ans = min(ans, num);
    }
    cout << ans << endl;
    return 0;
}

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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver {
 public:
  int n, a, b;
  Solver(LL n) : n(n){};

  void solve() {
    cin >> a >> b;
    int A = 0, B = a ^ b;

    int cnt_diff = 0;
    for (int i = 0; i < n; ++i) {
      if (((A >> i) & 1) != ((B >> i) & 1)) cnt_diff++;
    }
    if (cnt_diff % 2 == 0) {
      cout << "NO" << endl;
      return;
    }
    cout << "YES" << endl;
    auto ans = calc_path(A, B, 0);
    for (auto x : ans) {
      cout << (x ^ a) << " ";
    }
    cout << endl;
  }

  vector<int> calc_path(int from, int to, int mask) {
    set<int> bits_diff, bits_mask;
    for (int i = 0; i < n; ++i) {
      if (((from >> i) & 1) != ((to >> i) & 1)) {
        bits_diff.insert(i);
      }
      if ((mask >> i) & 1) {
        bits_mask.insert(i);
      }
    }
    if (bits_mask.size() == n - 1) {
      return {from, to};
    }
    DBG(from, to, mask, bits_mask, bits_diff)
    if (bits_diff.size() == 0) {
      exit(0);
    }
    int i = *bits_diff.begin();
    int F = (from & (1 << i));
    int T = (to & (1 << i));
    int bound = 0;
    int tmpcnt = 0;
    vector<int> same0, same1;
    for (int j = 0; j < n; ++j) {
      if (j == i) continue;
      if (bits_mask.count(j)) {
        bound += (from & (1 << j));
      } else if (bits_diff.count(j)) {
        if (tmpcnt == 0) {
          bound += (from & (1 << j));
        } else {
          bound += (to & (1 << j));
        }
        tmpcnt++;
      } else {
        bound += (from & (1 << j));
        same0.push_back(j);
      }
    }
    DBG(bound)
    int cnt_diff = 0;
    for (int j = 0; j < n; ++j) {
      if (((from >> j) & 1) != (((bound + F) >> j) & 1)) {
        cnt_diff++;
      }
    }
    DBG(cnt_diff, same0)
    if (cnt_diff % 2 == 0) {
      bound -= ((((from >> same0[0]) & 1)) << same0[0]);
      bound += ((!((from >> same0[0]) & 1)) << same0[0]);
    }
    vector<int> res1, res2;
    DBG(from, to, mask, bound, F, T)
    res1 = calc_path(from, bound + F, mask | (1 << i));
    res2 = calc_path(bound + T, to, mask | (1 << i));
    for (auto x : res2) {
      res1.push_back(x);
    }
    DBG(from, to, mask, res1)
    return res1;
  }
};

}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0;
  std::cin >> n;

  Problem::Solver sol(n);
  sol.solve();
  return 0;
}


Measured memory_bytes: 1808
def dfs(u):
    global time
    time+=1
    color[u]='gray'
    d[u]+=time
    for v in xrange(n):
        if m[u][v]!=0 and color[v]=="white":
            dfs(v)
    time+=1
    color[u]="black"
    f[u]+=time
    

n=input()
info=[0]*n
color=["white"]*n
m=[[0]*n for _ in xrange(n)]
d=[0]*n
f=[0]*n
for i in xrange(n):
    info[i]=map(int,raw_input().split())
    if info[i][1]==0:
        pass
    else:
        for j in info[i][2:]:
            m[i][j-1]=j
time=0
for i in xrange(n):
    if color[i]=="white":
        dfs(i)
for i in xrange(n):
    print i+1,d[i],f[i]

Measured memory_bytes: 6552
import sys
input = sys.stdin.readline
from collections import deque

n = int(input())
P = [-1]*n
C = [[] for i in range(n)]
D = [[] for i in range(n)]
T = [[] for i in range(n)]
S = [-1]*n
deg = [0]*n
H = [-1]*n

Q1 = deque()
Q2 = deque()

for i in range(n):
  s = [int(i) for i in input().split()]
  id = s[0]
  l = s[1]
  r = s[2]
  C[id] = (l,r)
  if l != -1:
    P[l] = id
    S[l] = r
    deg[id] += 1
  if r != -1:
    P[r] = id
    S[r] = l
    deg[id] += 1
  if deg[id] == 0:
    T[id] = "leaf"
    Q2.append(id)
    H[id] = 0

for i in range(n):
  if P[i] == -1:
    root = i
    T[i] = "root"
  elif T[i] == []:
    T[i] = "internal node"

Q1.append(root)
D[root] = 0

while Q1:
  x = Q1.popleft()
  for nx in C[x]:
    if nx != -1:
      Q1.append(nx)
      D[nx] = D[x] + 1
while Q2:
  x = Q2.popleft()
  nx = P[x]
  if nx != -1:
    Q2.append(nx)
    H[nx] = max(H[x] + 1, H[nx])

for i in range(n):
  print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(i,P[i],S[i],deg[i],D[i],H[i],T[i]))


Measured memory_bytes: 6016
n = int(input())
a = list(map(int, input()))
if n <= 1:
    print(a[0])
    exit()
for i in range(n - 1):
    a[i] = abs(a[i + 1] - a[i])
a.pop()
n -= 1
def bc(u, v):
    return (u & v) == v
def solve(t):
    ans = 0
    for i in range(n):
        if a[i] == 1:
            ans ^= bc(n - 1, i)
    print(ans * t)
if 1 in a:
    solve(1)
else:
    for i in range(n):
        a[i] >>= 1
    solve(2)

Measured memory_bytes: 116388
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
int n,q;

struct BinaryIndexedTree{
	vector<int> data;
	
	BinaryIndexedTree(int sz){
		data.assign(++sz, 0);
	}
	
	void add(int k,int x){
		for(k++;k<=data.size();k+=k&-k) data[k] += x;
	}
	
	int get(int k){
		int ret = 0;
		for(k++;k>0;k-=k&-k) ret += data[k];
		return ret;
	}
	
	int size(){
		return data.size();
	}
};

int main(){
	cin >> n >> q;
	
	BinaryIndexedTree bit(n);
	REP(i,0,q){
		int a,b,c;
		cin >> a >> b >> c;
		if(a == 0) bit.add(b-1,c);
		else if(a == 1) cout << bit.get(c-1) - bit.get(b-2) << endl;
	}
	return 0;
}



Measured memory_bytes: 3144
#include <iostream>
#include <utility>
#include <string>
#include <algorithm>
using namespace std;

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

    char str[11];
    int P;
    pair<pair<string, int>, int> p[N];

    for(int i = 0; i < N; i++) {
        cin >> str >> P;
        string S = str;
        p[i] = make_pair(make_pair(S, -P), i);
    }

    sort(p, p+N);

    for(int i = 0; i < N; i++) {
        cout << p[i].second + 1 << "\n";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
A, B, C, D = map(int, input().split())

turn = 1
while True:

    # 高橋くん
    if turn % 2 != 0:
        C = C - B
        pass
    # 青木くん
    else:
        A = A - D
        pass

    if A <= 0 or C <= 0:
        break
    turn += 1

if turn % 2 != 0:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9172
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <queue>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
#include <stdio.h>
#include <complex>
#include <cstdint>
#include <tuple>
#include <numeric>
#define M_PI       3.14159265358979323846

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FILL(a, x) memset(a, x, sizeof(a))

//repetition
//------------------------------------------
#define FOR(i,s,n) for(int i=s;i<(int)n;++i)
#define REP(i,n) FOR(i,0,n)

const int N = 100;

int idx[N];
int lowlink[N];
bool onstack[N];

struct edge {
	int to;
	edge(int _to) : to(_to){};
};
using node = vector<edge>;
using graph = vector<node>;

void visit(graph &g, int node, VVI &scc, stack<int> &st, vector<bool> &on, VI &lowlink, VI &id, int &cur) {
	lowlink[node] = id[node] = cur++;
	st.push(node);
	on[node] = true;
	for (auto e : g[node]) {
		if (id[e.to] == -1) {
			visit(g, e.to, scc, st, on, lowlink, id, cur);
			lowlink[node] = min(lowlink[node], lowlink[e.to]);
		}
		else if (on[e.to]) {
			lowlink[node] = min(lowlink[node], id[e.to]);
		}
	}
	if (lowlink[node] == id[node] && !st.empty()) {
		scc.PB(VI());
		while (1) {
			int t_node = st.top();
			st.pop();
			on[t_node] = false;
			scc.back().push_back(t_node);
			if (t_node == node)break;
		}
	}
}

VVI scc(graph &g) {
	int n = g.size();
	VI id(n, -1), low(n);
	stack<int> st;
	vector<bool> on(n);
	int cur = 0;
	VVI scc;
	REP(i, n) if (id[i] == -1)visit(g, i, scc, st, on, low, id, cur);
	return scc;
}

void addedge(graph &g, int from, int to) {
	g[from].PB(edge(to));
}

int main() {
	int v, e;
	scanf("%d%d", &v, &e);
	graph g(v);
	REP(i, e) {
		int x, y;
		scanf("%d%d", &x, &y);
		addedge(g, x, y);
	}
	auto SCC = scc(g);
	VI idx(v);
	REP (i, SCC.size()) {
		for (auto x : SCC[i]) {
			idx[x] = i;
		}
	}
	int q;
	scanf("%d", &q);
	REP(i, q) {
		int x,y;
		scanf("%d%d", &x, &y);
		cout << (idx[x] == idx[y]) << endl;
	}
	return 0;
}


Measured memory_bytes: 5256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

char ans[105][105];

int main() {
	int A, B; cin >> A >> B;
	for(int i = 1; i <= 50; ++i) for(int j = 1; j <= 100; ++j) ans[i][j] = '#';
	for(int i = 51; i <= 100; ++i) for(int j = 1; j <= 100; ++j) ans[i][j] = '.';
	int cnt = 0;
	for(int i = 1; i <= 50; i += 2) {
		for(int j = 1; j <= 100; j += 2) {
			if(cnt < A - 1) ans[i][j] = '.', cnt++;
		}
	}
	cnt = 0;
	for(int i = 100; i >= 51; i -= 2) {
		for(int j = 1; j <= 100; j += 2) {
			if(cnt < B - 1) ans[i][j] = '#', cnt++;
		}
	}
	cout<<100<<' '<<100<<endl;
	for(int i = 1; i <= 100; ++i) {
		for(int j = 1; j <= 100; ++j) printf("%c", ans[i][j]);
		cout<<endl;
	}
}

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

using namespace std;

using ll = long long;

int main(){
	string s;

	cin >> s;

	vector<int> ret(s.length());

	int l = 0;
	int r = 0;
	int index = 0;
	for (int i = 0; i < s.length()-1; ++i) {
		if (s[i] == 'R' && s[i+1] == 'L') {
			index = i;
		} else if (s[i] == 'L' && s[i+1] == 'R') {
			r = i;
			int length = r-l+1;
			if (length % 2 == 0) {
				ret[index] = length / 2;
				ret[index+1] = length / 2;
			} else {
				if (index - l + 1> r - index) {
					// 左の方が多い
					if ((r-index) % 2 == 0) {
						ret[index] = length / 2 + 1;
						ret[index+1] = length / 2;
					} else {
						// length % 4 == 3
						ret[index] = length / 2;
						ret[index+1] = length / 2 + 1;
					}
				} else {
					// 右のほうが多い
					if ((index-l+1) % 2 == 0) {
						ret[index] = length / 2;
						ret[index+1] = length / 2 + 1;
					} else {
						// length % 4 == 3
						ret[index] = length / 2 + 1;
						ret[index+1] = length / 2;
					}
				}
			}

			l = i+1;
		}
	}

	int i = s.length() - 1;
	r = i;
	int length = r-l+1;
	if (length % 2 == 0) {
		ret[index] = length / 2;
		ret[index+1] = length / 2;
	} else {
		if (index - l + 1> r - index) {
			// 左の方が多い
			if ((r-index) % 2 == 0) {
				ret[index] = length / 2 + 1;
				ret[index+1] = length / 2;
			} else {
				// length % 4 == 3
				ret[index] = length / 2;
				ret[index+1] = length / 2 + 1;
			}
		} else {
			// 右のほうが多い
			if ((index-l+1) % 2 == 0) {
				ret[index] = length / 2;
				ret[index+1] = length / 2 + 1;
			} else {
				// length % 4 == 3
				ret[index] = length / 2 + 1;
				ret[index+1] = length / 2;
			}
		}
	}
	
	for (auto e : ret) {
		cout << e << " ";
	}
	cout << endl;
	
	return 0;
}

Measured memory_bytes: 1024
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<String, Integer>();
        for (int i = 0; i < N; ++i) {
            String S = sc.next();
            map.put(S, map.getOrDefault(S, 0));
            map.put(S, map.get(S) + 1);
        }
        int M = sc.nextInt();
        for (int i = 0; i < M; ++i) {
            String S = sc.next();
            map.put(S, map.getOrDefault(S, 0));
            map.put(S, map.get(S) - 1);
        }
        sc.close();

        int ans = 0;
        for (Map.Entry<String, Integer> e : map.entrySet()) {
            ans = Math.max(ans, e.getValue());
        }
        System.out.println(ans);
    }
}

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

int main()
{
	int a, b, c;
	cin >> a >> b >> c;

	if (a >= b) {
		if (a >= c) {
			if (c >= b) {
				swap(a, c);
				swap(a, b);
			}
			else {
				swap(a, c);
			}

		} 
		else if (a <= c) {
			swap(a, b);
		}
		else {
			swap(a, c);
			swap(a, b);
		}
	} 
	else if (a <= b) {
		if (a <= c) {
			if (b <= c) {
			}
			else {
				swap(b, c);
			}
		} 
		else if (a >= c) {
			swap(a, c);
			swap(b, c);
		}
	}

	cout << a << " " << b << " " << c << endl;

	return 0;
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, Q;
    string S;
    cin >> N >> S >> Q;
    vector<int> K(Q);
    for (int i = 0; i < Q; i++) cin >> K[i];

    vector<int> sum(N+1);
    for (int k : K) {
        ll D = 0, M = 0, ans = 0;
        ll cntDM = 0;
        for (int i = 0; i < S.size(); i++) {
            if (S[i] == 'D') D++;
            else if (S[i] == 'M') {
                M++;
                cntDM += D;
            }
            else if (S[i] == 'C') {
                int l = max(i - k, 0), r = i + 1;
                ans += cntDM;
            }
            if (i >= k - 1) {
                if (S[i - (k - 1)] == 'D') {
                    D--;
                    cntDM -= M;
                }
                else if (S[i - (k - 1)] == 'M') M--;
            }
        }
        cout << ans << '\n';
    }
}


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

using namespace std;

class node{
public :
    long long x, y;
};

bool comp(node a, node b){
        return a.x < b.x;
}
int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    int n;
    long long k;
    cin >> n >> k;
    node array[n + 1];
    for(int i = 1;i <= n;i++){
        cin >> array[i].x >> array[i].y;
    }
    sort(array + 1, array + n + 1, comp);
    //for(int i = 1;i <= n;i++)
      //cout << array[i].x << " " << array[i].y << "\n";
    long long sum = 0;
    for(int i = 1;i <= n;i++){
        sum += array[i].y;
        if(sum >= k){
            cout << array[i].x;
            return 0;
        }
    }
}


Measured memory_bytes: 1792
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int x = sc.nextInt();
		int y = sc.nextInt();
		int ans = Integer.MAX_VALUE;
		
		ans = Math.min(ans, calc(x, y));
		ans = Math.min(ans, calc(-x, y) + 1);
		ans = Math.min(ans, calc(x, -y) + 1);
		ans = Math.min(ans, calc(-x, -y) + 2);
		System.out.println(ans);		
	}
	
	public static int calc(int xx, int yy){
		if(yy < xx) return 2000000010;	
		return Math.abs(yy - xx);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 22228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define X first
#define Y second
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()


typedef long long ll;

const int maxn = 2e5 + 1337;
const ll mod = 998244353;

int a[maxn * 2];

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n,x,y;
    cin >> n >> x >> y;
    x--;
    y--;
    vector<int> p(n + 1);
    for(int i = 0; i < n; ++i){
        for(int j = i + 1; j < n; ++j){
            int ans = j - i;
            ans = min(ans, abs(x - i) + abs(y - j) + 1);
            ans = min(ans, abs(y - i) + abs(x - j) + 1);
            p[ans]++;
        }
    }
    for(int i = 1; i < n; ++i){
        cout << p[i] << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define MOD (ll)(998244353)
#define MAX (ll)(1e5 + 4)
#define INF (ll)(1e17)
using namespace std;
using ll =  long long;
using ld = long double;

ld sq (ld a) {
	return a * a;
}

int main () {
	int n;
	cin >> n;
	pair<ld, ld> vp[n];
	for (int i = 0; i < n; i++) {
		cin >> vp[i].first >> vp[i].second;
	}
	ld su = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			su += sqrt (sq (vp[i].second - vp[j].second) + sq (vp[i].first - vp[j].first));
		}
	}
	su /= n;
	su *= 2;
	cout << fixed << setprecision (6) <<  su << "\n";
}
	


Measured memory_bytes: 256
N, K = map(int, input().split())
AA = []
ans = 0

for i in range(K):
  d = int(input())
  A = list(map(int, input().split()))
  for k in range(d):
    AA.append(A[k])


for j in range(1,N+1):
  if AA.count(j) == 0:
    ans += 1

print(ans)


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

tmp=''
arr=[]
for x in input()+'0':
    if tmp =='':
        tmp=x
        continue
    if tmp == x:
        tmp=''
        arr.append(2)
    else:
        tmp=x
        arr.append(1)

tmp=arr.pop(0)
ans=tmp*3
for x in arr:
    if tmp == 1:
        ans*=2
    else:
        if x==2:
            ans*=3
    tmp=x
    ans%=1000000007
print(ans)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    int x=0,y=0;
    int t=0;
    int a,b,c;
    for(int i=1;i<=n;i++)
    {
        cin>>c>>a>>b;
        if(abs(x-a)+abs(y-b)>c-t)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==0 &&(c-t)%2==1)
        {
            cout<<"No";
            return 0;
        }
        if((abs(x-a)+abs(y-b))%2==1 &&(c-t)%2==0)
        {
            cout<<"No";
            return 0;
        }
        x=a;y=b;t=c;
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <functional>
#include <math.h>
#include <map>
#include <set>
#include <string>
using namespace std;
#define fio ios::sync_with_stdio(false); cin.tie(NULL);

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> pll;
typedef pair<int, int> pii;

const int INT_INF = 1e9;
const ll LL_INF = 1e18;
const int MAXN = 500003;

typedef struct GE{
	int to;
	ll w;
	GE(){};
}GE;

int n, m;
int A[MAXN];
int main() {
	int A,B;
	scanf("%d %d", &A,&B);
	if(max(A,B)>8) {
		puts(":(");
	}
	else
		puts("Yay!");
	
	return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
N = int(input())
P = list(map(float, input().split()))

dp = defaultdict(float)
dp[(0, 0)] = 1.0

for p in P:
    newDP = defaultdict(float)
    for (X, Y), val in dp.items():
        # 表が出る
        newDP[(X + 1, Y)] += val * p
        # 裏が出る
        newDP[(X, Y + 1)] += val * (1 - p)
    dp = newDP

ans = 0.0
for x in range(N + 1):
    y = N - x
    if x > y:
        ans += dp[(x, y)]

print(ans)

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

typedef long long ll;

int main() {
  ll a, v, b, w, t; cin >> a >> v >> b >> w >> t;
  
  bool can = false;
  if (a <= b) {
    if (b + w*t <= a + v*t) can = true;
  }
  else {
    if (b - w*t >= a - v*t) can = true;
  }
  
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

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

int main()
{
    int N;
    cin >> N;
    int a[N+1],b[N+1],c[N];
    rep(i,N)cin >>a[i];
    rep(i,N)cin >>b[i];
    rep(i,N-1)cin >> c[i];
    int ans=0;
    int tmp=-10;
    rep(i,N){
        ans+=b[a[i]];
        if(a[i]==tmp+1){
            ans+=c[tmp];
        }
        tmp=a[i];
    }
    cout << ans << endl;
}

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

int main(){
    int data[10] = {1,2,4,8,16,32,64,128,256,512};
    int ch[10];
    int mem;
    int sta;
    while(cin >> sta){
        mem = 0;
        memset(ch,0,sizeof(ch));
        for(int i=9;i>=0;i--){
            if(sta >= data[i]){
                if(mem == 0) mem = i;
                sta -= data[i];
                ch[i] = 1;
            }
        }
        for(int i=0;i<10;i++){
            if(mem == i) cout << data[i] << endl;
            else if(ch[i] == 1){
                cout << data[i] << " ";
            }
        }
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstring>
#include <chrono>
#include <complex>
#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second

using namespace std;
int arr[102];
int main()
{
	std::ios::sync_with_stdio(false);
	int T;
	cin>>T;
	int a;
	cin>>a;
	int cnt=0;
	for(int i=0; i<T; i++) {
		cin>>arr[i];
	}
	sort(arr,arr+T);
	int i=0;
	while(a-arr[i]>=0&&i<T) {
		if(i!=T-1) {
			a-=arr[i];
			i++;
			cnt++;
		}
		else{
			if(a==arr[i]) {
				cnt++;

			}
			break;
		}
	}

	cout<<cnt<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <string>
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>

#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    rep(i,n){
        int a;
        cin >> a;
        if(a % 2 == 0){
            if(a % 3 != 0 && a % 5 != 0){
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 3624
import java.util.Scanner;

/**
 * コンソールテスト用Main クラス
 *
 * @author RisaTozawa
 */
public class Main {

	/* コンストラクタ */
	Main() {
	//何もしない
	}

	/**
	 * Atcorder 提出
	 * @return
	 *
	 */

	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		final String a = "a";
		final String e = "e";
		final String i = "i";
		final String o = "o";
		final String u = "u";

		String text = "";

		/* コンソールから文字を受け取る */
		text = scanner.nextLine();

		/* 母音かどうかを検査する */
		switch (text) {
			case a:
				System.out.println("vowel");
				break;

			case e:
				System.out.println("vowel");
				break;

			case i:
				System.out.println("vowel");
				break;

			case o:
				System.out.println("vowel");
				break;

			case u:
				System.out.println("vowel");
				break;

			default:
				System.out.println("consonant");
				break;
		}
	}
}


Measured memory_bytes: 26848