akhauriyash/Code-Regression huggingface dataset:
//someshsingh22		
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define pb push_back
#define loop(i,n) for(int i = 0 ; i < n; i++)
#define FAST ios_base::sync_with_stdio(false); cin.tie(NULL)
#define inp_int(n,arr) int arr[n]; loop(i,n) cin >> arr[i];
#define inp_ll(n,arr) ll arr[n]; loop(i,n) cin >> arr[i];
#define out_int(n,arr) loop(i,n) printf("%d ",arr[i]);
#define out_ll(n,arr) loop(i,n) printf("%lld ",arr[i]); cout << endl;
#define all(c) c.begin(),c.end()
// Snippets : BFS, DFS, edger, ncr, chef, inverse, sieve, lis-d*, mat_d*, pow

typedef long long ll;
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;


int main ()
{
	FAST;
	int n; cin >> n;
	inp_ll(n,arr);
	int dp[n]={0};
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	for(int i = 2; i<n; i++)
		dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
	cout << dp[n-1];
	return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

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

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
//const ll mod = 1000000007;
ll A, B;
ll g;

ll f(ll x) {
    cerr << x << endl;
    ll ret = 0;
    for(ll j = 2; j * j <= x; j++) {
        if(x % j != 0) continue;
        ret++;
        while(x % j == 0) x /= j;
    }
    if(x != 1) ret++;
    return ret;
}

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> A >> B;
    g = __gcd(A, B);
    cout << f(g) + 1 << endl;
    return 0;
}


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

using namespace std;

#define all(c) (c).begin(), (c).end()
#define sz(c) (static_cast<int>(c.size()))
#define endl "\n"

using ld = long double;
using ll = long long;

inline ll addm(ll __a, ll __b, ll __m);
inline ll subm(ll __a, ll __b, ll __m);
inline ll mulm(ll __a, ll __b, ll __m);
ll powm(ll __a, ll __b, ll __m);
ll inv(ll __x, ll __m);
// }}}

const ll INFL = numeric_limits<ll>::max() / 2;
const ll INF = numeric_limits<int>::max() / 2;
const ll MOD = 1e9+7;

const int N = 100500;
ll mem[N][2];
vector<int> g[N];
ll dp(int v, int s, int p = -1)
{
    ll &ret = mem[v][s];
    if (ret != -1) return ret;
    ret = 1;
    for (int u: g[v]) if (u != p) {
        ret *= (dp(u, 0, v) + ((s) ? 0 : dp(u, 1, v))) % MOD;
        ret %= MOD;
    }
    return ret;
}
void solve()
{
    memset(mem, -1, sizeof(mem));
    int n; cin >> n;
    for (int i = 0; i < n-1; i++) {
        int x, y; cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }
    cout << (dp(1, 0) + dp(1, 1)) % MOD << endl;
}

// main {{{
int main()
{
    cin.sync_with_stdio(0); cin.tie(NULL);
    solve();
    return 0;
}

inline ll addm(ll __a, ll __b, ll __m = MOD) {
    return ((__a+__b)%__m);
}
inline ll subm(ll __a, ll __b, ll __m = MOD) {
    return (((__a-__b)%__m+__m)%__m);
}
inline ll mulm(ll __a, ll __b, ll __m = MOD) {
    return ((__a*__b)%__m);
}
ll powm(ll __a, ll __b, ll __m = MOD) {
    ll ret = (!__b) ? 1 : powm(__a, __b/2, __m);
    return (!__b) ? 1 : mulm(mulm(ret, ret, __m), (__b%2) ? __a : 1, __m);
}
ll inv(ll __x, ll __m = MOD) {
    return powm(__x, __m-2, __m);
}
// }}}


Measured memory_bytes: 15616
n, k = map(int, input().split())
mod = 10**9 + 7

fact = [1] * (n+1)

for i in range(2, n+1):
	fact[i] = fact[i-1] * i


def nck(a,b):
    return fact[a] // (fact[b] * fact[a - b])

for i in range(1, k + 1):
	print((nck(n-k+1,i) * fact[k-1] // (fact[i-1] * fact[k-i])) % mod)


Measured memory_bytes: 45608
<?php
  $not_prime = new SplFixedArray(1000000);
  for($i=0; $i<1000000; $i++) {
    $not_prime[$i]=0;
  }
  for($i=2; $i<1000000; $i++) {
    if($not_prime[$i]==1) {
      continue;
    } 
    for($j=$i*$i; $j<1000000; $j+=$i) {
      $not_prime[$j]=1;
    }  
  } 
  while($n = fgets(STDIN)) {
    $count_prime=0;
    for($i=2; $i<=(int)$n; $i++) {
      if($not_prime[$i]==0) {
        $count_prime++;
      }
    }
    echo $count_prime.PHP_EOL;
  }

Measured memory_bytes: 70812
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN

    ll n;cin >>n;
    map<ll,ll> mp;
    REP(i,n){
        ll nex;
        cin>>nex;
        mp[nex]++;
    }
    ll ans=0;
    for(auto p: mp){
        if (p.second%2!=0) ans++;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
	long n, m;

	cin >> n >> m;

	vector<long> ac(n), wa(n);
	for(long i = 0; i < m; ++i)
	{
		long p;
		string s;
		cin >> p >> s;

		if (s == "AC")
		{
			ac[p - 1] = 1;
		}
		else if (s == "WA" && ac[p - 1] == 0)
		{
			++wa[p - 1];
		}
	}

	long a1 = 0, a2 = 0;
	for (long i = 0; i < n; ++i)
	{
		a1 += ac[i];
		if (ac[i] > 0)
		{
			a2 += wa[i];
		}
	}

	cout << a1 << " " << a2;

}


Measured memory_bytes: 1792
#include <stdio.h>
int main(){
    int i=-1;
   char a[10000];
  do{
   i++;
  scanf("%s",&a[i]);
  }while(a[i]); 
  if(a[i-1]=='s') {
  a[i]='e';
    a[i+1]='s';
  }
  else a[i]='s';
  printf("%s\n",a);
  return 0;
}


Measured memory_bytes: 1668
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;

int main(){
  int total,i,u,a,p,n,m;
  for(;cin>>n,n;){
    map<int,int> school,senbatsu;
    vector< pair< pair<int,int>,int > > v;
    for(total=m=0;m<n;m++){
      cin>>i>>u>>a>>p;
      school[i]=u;
      v.push_back(make_pair(make_pair(-a,p),i));
    }
    sort(v.begin(),v.end());

    for(m=0;m<n;m++){
      if(
        (total<10&&senbatsu[school[v[m].second]]<3) ||
        (total<20&&senbatsu[school[v[m].second]]<2) ||
        (total<26&&senbatsu[school[v[m].second]]<1)
      ){
        senbatsu[school[v[m].second]]++;total++;
        cout<<v[m].second<<endl;
      }
    }
  }
}

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

int main(){
  int n;
  cin >> n;
  vector<double> x(n);
  vector<string> u(n);
  for (int i=0 ; i<n ; i++)
    cin >> x.at(i) >> u.at(i);
  
  double ans = 0, plus;
  for (int i=0 ; i<n ; i++){
    if (u.at(i) == "JPY")
      ans += x.at(i);
    else
      ans += x.at(i) * 380000;
  }
  
  cout << fixed << setprecision(8) << ans << endl;
}

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

using i64 = int64_t;

int main(){
    int n;
    cin >> n;
    int ans = 0;
    for(int i=0;i<n;++i){
        int l, r;
        cin >> l >> r;
        ans += r - l + 1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
X = list(map(int, input().split()))

#A = 0
B = 0
for i in range(N):
  #A += X[i]**2
  B += X[i]

P = round(B/N)
energy = 0
for i in range(N):
  energy += (X[i] - P)**2
  
print(energy)
  

Measured memory_bytes: 3060
from decimal import *
import math
 
getcontext().prec = 50
 
a, b, c = map(int, input().split())
a = Decimal(a)
b = Decimal(b)
c = Decimal(c)
 
a = Decimal.sqrt(a)
b = Decimal.sqrt(b)
c = Decimal.sqrt(c)
 
if a + b < c:
    print("Yes")
else:
    print("No")

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

using namespace std;

#define INF 2000000000

int main() {
    int x, y;
    cin >> x >> y;

    int b, a, ab, ba, bab;

    if (y == -x) {
        b = 1;
    } else b = INF;

    if (y - x > 0) {
        a = y - x;
    } else a = INF;

    if (-x - y + 1 > 0) {
        ab = -x - y + 1;
    } else ab = INF;

    if (x + y + 1 > 0) {
        ba = x + y + 1;
    } else ba = INF;

    if (x - y + 2 > 0) {
        bab = x - y + 2;
    } else bab = INF;

    cout << min({b, a, ab, ba, bab}) << endl;
    return 0;
}

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

int main(void){
    // Your code here!
    int a,b,c,d;
    cin >> d;
    a = d/1000;
    b = d/100%10;
    c = d/10%10;
    d = d%10;
    if(a+b+c+d == 7) cout << a << "+" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a-b+c+d == 7) cout << a << "-" << b << "+" << c << "+" << d << "=7" << endl;
    else if(a+b-c+d == 7) cout << a << "+" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a+b+c-d == 7) cout << a << "+" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a-b-c+d == 7) cout << a << "-" << b << "-" << c << "+" << d << "=7" << endl;
    else if(a-b+c-d == 7) cout << a << "-" << b << "+" << c << "-" << d << "=7" << endl;
    else if(a+b-c-d == 7) cout << a << "+" << b << "-" << c << "-" << d << "=7" << endl;
    else if(a-b-c-d == 7) cout << a << "-" << b << "-" << c << "-" << d << "=7" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main(void)
{
    int n,m,i,a[10],b[10];
	for(i=0;i<10;i++) scanf("%d",&a[i]);
	for(i=0;i<10;i++) scanf("%d",&b[i]);
	sort(a,a+10);
	sort(b,b+10);
	n=a[9]+a[8]+a[7];
	m=b[9]+b[8]+b[7];
	printf("%d %d\n",n,m);
	return 0;
}

Measured memory_bytes: 2668
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

signed main(){
	int n,ans = 0;
	cin >> n;
	map<string,int> strs;
	for(int i = 0;i < n;i++){
		string s;
		cin >> s;
		sort(all(s));
		strs[s]++;
	}
	for(auto it : strs){
		ans += (it.second - 1) * it.second / 2;
	}
	cout << ans << endl;
}

Measured memory_bytes: 11136
#include<iostream>
#include<map>
#include<vector>
using namespace std;
int N,A[1<<17];
main()
{
	cin>>N;
	bool flag=true;
	for(int i=0;i<N;i++)
	{
		cin>>A[i];
		flag&=A[i]==0;
	}
	if(flag)
	{
		cout<<"Yes"<<endl;
		return 0;
	}
	if(N%3!=0)
	{
		cout<<"No"<<endl;
		return 0;
	}
	map<int,int>M;
	for(int i=0;i<N;i++)M[A[i]]++;
	vector<int>B;
	int n=N/3;
	for(map<int,int>::iterator it=M.begin();it!=M.end();it++)
	{
		if(it->second%n!=0)
		{
			cout<<"No"<<endl;
			return 0;
		}
		for(int i=0;i<it->second;i+=n)B.push_back(it->first);
	}
	bool ans=false;
	if(B.size()==3)
	{
		if((B[0]^B[1]^B[2])==0)ans=true;
	}
	cout<<(ans?"Yes":"No")<<endl;
}


Measured memory_bytes: 4224
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>

using namespace std;

char a[55][55],b[55][55];
int n,m;

bool judge(int x,int y)
{
    int i,j;
    for(i=0;i<m;i++)
    {
        for(j=0;j<m;j++)
        {
            if(a[x+i][y+j] != b[i][j])
                return false;
        }
    }
    return true;
}
int main(void)
{
    int i,j;
    while(scanf("%d%d",&n,&m)==2)
    {
        for(i=0;i<n;i++)
            scanf("%s",a[i]);
        for(i=0;i<m;i++)
            scanf("%s",b[i]);
        int f = 0;
        for(i=0;i<n-m+1;i++)
        {
            for(j=0;j<n-m+1;j++)
            {
                if(judge(i,j))
                {
                    f = 1;
                    break;
                }
            }
            if(f == 1)
                break;
        }
        if(f == 1)
            printf("Yes\n");
        else
            printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: ty),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, n: usize, k: usize, a: [usize; n]);
    if a[0] == 1 {
        println!("{}", 1);
        return;
    }
    let mut b = std::collections::HashMap::new();
    let mut c = vec![0; n];
    b.insert(0, 0);
    let mut cur = 0;
    let mut count = 0;
    let mut i = 0;
    let mut j = 0;
    loop {
        let next = a[cur] - 1;
        if b.contains_key(&next) {
            j = count;
            i = b[&next];
            break;
        }
        count += 1;
        b.insert(next, count);
        c[count] = next;
        cur = next;
    }
    if i > k {
        println!("{}", c[k] + 1);
    } else {
        println!("{}", c[(k - i) % (j - i + 1) + i] + 1);
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 12460
#include<stdio.h>

int main(){
  int i,j,v,n;
  int A[100];

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

 
  for(i = 0 ; i < n ; i++){
    v = A[i];
    j = i - 1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    
    for(j = 0 ; j < n ; j++){
      if(j != n-1){
	printf("%d ",A[j]);
      }
      else if(j == n-1){
	printf("%d",A[j]);
      }

    }
    
    printf("\n");
  }

  return 0;
}



Measured memory_bytes: 2064
s = input()
n = len(s)
if s[0] == '<':
    p = []
    cnt = 1
    for i in range(1,n):
        if s[i] == s[i-1]:
            cnt += 1
        else:
            p.append(cnt)
            cnt = 1
    p.append(cnt)
    res = 0
    if len(p)%2 == 0:
        for i in range(len(p)):
            if i%2 == 0:
                a = p[i]
            else:
                b = p[i]
                if b > a:
                    a,b = b,a
                res += a*(a+1)//2 + b*(b-1)//2
    else:
        for i in range(len(p)-1):
            if i%2 == 0:
                a = p[i]
            else:
                b = p[i]
                if b > a:
                    a,b = b,a
                res += a*(a+1)//2 + b*(b-1)//2
        res += p[-1]*(p[-1]+1)//2
    print(res)
else:
    p = []
    cnt = 1
    for i in range(1,n):
        if s[i] == s[i-1]:
            cnt += 1
        else:
            p.append(cnt)
            cnt = 1
    p.append(cnt)
    q = p[0]
    del p[0]
    res = q*(q+1)//2
    if len(p) == 0:
        res *= 1
    elif len(p)%2 == 0:
        for i in range(len(p)):
            if i%2 == 0:
                a = p[i]
            else:
                b = p[i]
                if b > a:
                    a,b = b,a
                res += a*(a+1)//2 + b*(b-1)//2
    else:
        for i in range(len(p)-1):
            if i%2 == 0:
                a = p[i]
            else:
                b = p[i]
                if b > a:
                    a,b = b,a
                res += a*(a+1)//2 + b*(b-1)//2
        res += p[-1]*(p[-1]+1)//2
    print(res)

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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j;
    ll n,m;
    cin >> n >> m;
    if(2*n > m){
        cout << m/2 << endl;
    }else{
        ll ans = n;
        m -= 2*n;
        ans += m/4;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 3600
#include <iostream>
#include <cstdio>
using namespace std;
typedef long long ll;

string s;
ll x, n, lim, d[105][2][5]={1};
int main() {
	ll i, j, k, l;
	cin >> s >> x;
	n = s.size();
	for(i=0; i<n; i++) {
		for(j=0; j<2; j++) {
			lim = (j ? 9 : s[i]-'0');
			for(k=0; k<=x; k++) {
				for(l=0; l<=lim; l++) {
					d[i+1][j||l<lim][k+(l>0)] += d[i][j][k];
				}
			}
		}
	}
	cout << d[n][0][x] + d[n][1][x];
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <set>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>

using namespace std;
long long n, m;
vector<vector<int>> p;
vector<bool> used;
vector<int> bw;

bool dfs(int now, int b) {
  if (used[now])
    return bw[now] == b;
  used[now] = true;
  bw[now] = b;
  bool ret = true;
  for (auto &i : p[now]) {
    if (!dfs(i, 1 - b))
      ret = false;
  }
  return ret;
}

int main() {
  cin >> n >> m;
  p.resize(n);
  used.resize(n);
  bw.resize(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    p[a].push_back(b);
    p[b].push_back(a);
  }
  long long s = 0, bws = 0, other = 0;
  for (int i = 0; i < n; i++)
    if (p[i].size() == 0) {
      s++;
      used[i] = true;
    }
  for (int i = 0; i < n; i++) {
    if (used[i])
      continue;
    if (dfs(i, 0)) {
      bws++;
    } else {
      other++;
    }
  }
  cout << n * n - (n - s) * (n - s) + other * other + (other + bws) * bws * 2
       << endl;
  return 0;
}


Measured memory_bytes: 9984
// 失敗するからこそ そこから立ち向かって行く強さがあってそんな強さが本当の強さだと私は思うから
// ぜったいあきらめない
#include<bits/stdc++.h>
using namespace std;

#if defined(DAIJOBU)
#include "/home/ichigo/debug.hpp"
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
#define FIO {ios::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);}

int main(){
	FIO
		
	int k, s;cin >> k >> s;
	int ans = 0;
	for(int i = 0; i <= k; i++){
		for(int j = 0; j <= k; j++){
			int z = s - i - j;
			if(z >= 0 && z <= k)ans++;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
//const int MAX=;



int main(){
	string S;
	cin>>S;
	int k=sz(S);
	int win=15-k;
	rep(i,k)if(S[i]=='o')win++;
	
	if(win>=8)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}


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

int main() {
    int n ;
    cin >> n ;
    vector<int> list [n] ;
    rep(i, n){
        int v, k;
        cin >> v >> k ;
        v-- ;
        rep(j, k){
            int g ;
            cin >> g  ;
            g-- ;
            list[v].push_back(g) ;
        }
    }
    queue<P> que ;
    vector<int> d (n, -1) ;
    que.push(P(0, 0)) ;
    while(!que.empty()) {
        P st = que.front() ;
        que.pop() ;
        if(d[st.first] > -1){
            continue ;
        }
        else {
            int f = st.first ;
            int e = st.second ;
            d[f] = e ;
            for(int u : list[f]){
                que.push(P(u, e + 1)) ;
            }
        }
 
    }
    rep(i, n){
        cout << i + 1 << " " << d[i] << endl ;
    }
}



Measured memory_bytes: 3128
import java.util.*;
import java.util.stream.*;

class Main{
	public static void main(String[] $){
		//System.err.println();
		Scanner s=new Scanner(System.in);
		int n=s.nextInt(),k=s.nextInt();

		System.out.println(
				IntStream.range(0,n).map(i->s.nextInt()).filter(i->i>=k).count()
				);
	}
}


Measured memory_bytes: 49076
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n, k, r, s, p;
    string t;
    cin >> n >> k >> r >> s >> p;
    cin >> t;
    int ans = 0;
    repi(j, k, 0)
    {
        int sum = 0;
        char prev = ' ';
        int i = j;
        while (i < n)
        {
            if (t.at(i) == 'r')
            {
                if (prev != 'p')
                {
                    sum += p;
                    prev = 'p';
                }
                else
                {
                    if (i + k < n)
                    {
                        prev = t.at(i + k);
                    }
                }
            }
            if (t.at(i) == 's')
            {
                if (prev != 'r')
                {
                    sum += r;
                    prev = 'r';
                }
                else
                {
                    if (i + k < n)
                    {
                        prev = t.at(i + k);
                    }
                }
            }
            if (t.at(i) == 'p')
            {
                if (prev != 's')
                {
                    sum += s;
                    prev = 's';
                }
                else
                {
                    if (i + k < n)
                    {
                        prev = t.at(i + k);
                    }
                }
            }
            i += k;
        }
        ans += sum;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>


using namespace std;

using ll = long long;
using P = pair<int, int>;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)

int main() {
	int h, w;
	cin >> h >> w;
	
	string s[h];
	rep(i , h) {
		cin >> s[i];
	}
	int m[h][w];
	int count_wall = 0;
	rep(y, h) {
		rep(x, w) {
			if (s[y].at(x) == '#') {
				count_wall++;
			}
			m[y][x] = 100000;
		}
	}
	queue< P > q;

	q.push(mp(0,0));
	m[0][0] = 0;

	while(!q.empty()) {
		P p = q.front();
		q.pop();
		const int dx[] = {0,0,1,-1};
		const int dy[] = {1,-1,0,0};
		int x = p.first;
		int y = p.second;
		int dist = m[y][x];
		dist++;	
		rep(i ,4) {
			int nx = x + dx[i];
			int ny = y + dy[i];
			if (ny < 0 || ny >= h || nx < 0 || nx >= w) {
				continue;
			} 
			if (s[ny].at(nx) == '#') {
				continue;
			}
			if (m[ny][nx] > dist) {
				m[ny][nx] = dist;				
				q.push(make_pair(nx, ny));
			}


		} 
	}
	int dist_goal = m[h - 1][w - 1];

	if (dist_goal == 100000) {
		cout << -1 << endl;
		return 0; 
	}

	cout << w * h - count_wall - (m[h - 1][w - 1] + 1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <map>
#include <set>
using namespace std;

#define INF (1ll<<60)

long long M = 1000000007;

int n;

int main(int argc, char const *argv[]) {
    cin>>n;
    int M = 21000;
    vector<long long> dp(M,-1),w(n),v(n),s(n);
    vector<pair<long long,int>> tmp(0);
    dp[0] = 0;
    for(int i=0;i<n;++i){
        cin>>w[i]>>s[i]>>v[i];
        tmp.push_back(pair<long long, int>(w[i]+s[i],i));
    }
    sort(tmp.begin(),tmp.end());
    long long res = 0;
    for(int i=0;i<n;++i){
        int k = tmp[i].second;
        for(int l=M-1;l>-1;--l){
            if(l + w[k] < M && l <= s[k] && dp[l] != -1){
                dp[l + w[k]] = max(dp[l+w[k]], dp[l]+v[k]);
                res = max(res,dp[l + w[k]]);
            }
        }
    }
    cout<<res<<endl;
    return 0;
}

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

int main()
{
  int k;

  while (cin >> k, k){
    int sum = 0, n;
    n = k * (k - 1) / 2;

    for (int i = 0; i < n; i++){
      int num;
      cin >> num;
      sum += num;
    }
    cout << sum / (k - 1) << endl;
  }
}

Measured memory_bytes: 1160
a, b, c  = [int(x) for x in input().strip().split()]

res = {x for seq in [range(a,min(a+c, b)), range(b, max(a,b-c), -1)] for x in seq}

if a==b:
    res = {a}

for x in sorted(list(res)):
    print(x)


Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<sstream>
#include<string>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    ll n;
    cin >> n;
    if ( n % 2 == 1 ) {
        cout << 0 << endl;
        return 0;
    }
    n = n / 2;
    ll ans = 0;
    while(n) {
        ans += n / 5;
        n = n / 5;
    }
    cout << ans << endl;
    return 0;
}


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

int main()
{
    int n,k,num[100];
    int i=0;
    cin>>n>>k;
    while(n>0)
    {

        num[i] = n % k;
        n = n / k;
        i++;
    }
    cout<<i;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstdio>
using namespace std;

int main(){

  int a,b,i = 0,z[100],m,n;
  
  while(1){
    int m = 0,n = 0;

    cin >> a >> b;
    if(a == 0 && b == 0 && i == 0) break;

    z[i] = a + b;
    i++;

    if(i == 5){
      for(i=0;i<5;i++){
	if(m < z[i]){
	  m = z[i];
	  n = i;
	}
      }
      printf("%c %d\n",'A'+n,m);
      i = 0;
    }
  }
}

Measured memory_bytes: 1144
//tt89 ;)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
void testcase(int t) { cout<<"Case #"<<t<<": "; }
void online() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif //ONLINE_JUDGE
}
const int mod= 1e9+7;

int main() {
    fastIO;
    char ch; cin>>ch;
  if(ch>='A' && ch<='Z') cout<<'A';
  else cout<<'a';
    return 0;
}

Measured memory_bytes: 3616
#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>;

int gcd(int a, int b) { return b?gcd(b,a%b):a;}

int main() {
  int n, ans = 1; cin >> n;
  vector<int> a(n); rep(i, n) cin >> a[i];
  vector<int> l(n+1), r(n+1);
  l[1] = a[0], r[n-1] = a[n-1];
  for (int i = 1; i < n; i++)
    l[i+1] = gcd(l[i], a[i]);
  for (int i = n-2; i >= 0; i--)
    r[i] = gcd(r[i+1], a[i]);
  rep(i, n) ans = max(ans, gcd(l[i], r[i+1]));
  cout << ans << endl;
  return 0;
}


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

#define rep(i, n) for (int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

const int MAX = 100000;

struct Process {
  string name;
  int time;
};

Process que[MAX];
int head, tail;

void init() {
  head = 0;
  tail = 0;
}

bool isEmpty() {
  return head == tail;
}

bool isFull() {
  return head == (tail + 1) % MAX;
}

void enqueue(Process v) {
  if (isFull()) {
    cout << "error: queue is full." << endl;
    return;
  }
  que[tail] = v;
  tail = (tail + 1) % MAX;
}

Process dequeue() {
  Process tmp = que[head];
  head = (head + 1) % MAX;
  return tmp;
}

int main() {
  init();
  int n, q;
  cin >> n >> q;
  rep(i, n) cin >> que[i].name >> que[i].time;
  head = 0;
  tail = n;
  int c, elaps = 0;
  Process u;
  while (head != tail) {
    u = dequeue();
    c = min(q, u.time);
    u.time -= c;
    elaps += c;
    if (u.time > 0) enqueue(u);
    else cout << u.name << ' ' << elaps << endl;
  }
  return 0;
}



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


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    long n,i,j;
    cin>>n;
    ll a[n+1];
    unordered_map<ll,ll> c;
    ll ans = 0;

    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        c[a[i]]++;
    }
    vector<ll> po2,vec;
    for(i=1;i<MAXN;i<<=1)
    {
        po2.push_back(i);
        // cout<<i<<" ";
    }
    for(auto it: c)
    {
        vec.push_back(it.first);
    }
    sort(vec.begin(),vec.end());
    for(i=vec.size()-1;i>=0;i--)
    {
        // cout<<c[vec[i]]<<": ";
        if(c[vec[i]]>0)
        {
            for(j=po2.size()-1;j>=0;j--)
            {
                if(po2[j]-vec[i]>=0 && c[po2[j]-vec[i]]>0)
                {
                    // cout<<po2[j]-vec[i]<<endl;
                    if(vec[i]!=po2[j]-vec[i])
                    {
                        ll z = min(c[vec[i]],c[po2[j]-vec[i]]);
                        ans += z;
                        c[vec[i]] -= z;
                        c[po2[j]-vec[i]] -= z;
                        if(c[vec[i]]<=0)
                        break;
                    }
                    else
                    {
                        if(c[vec[i]]>1)
                        {
                            ll z = c[vec[i]]/2;
                            ans += z;
                            c[vec[i]] -= z*2;
                            if(c[vec[i]]<=0)
                            break;
                        }
                    }
                }
            }
        }
        // cout<<endl;
    }
    cout<<ans;
    
    return 0;
}


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

int main()
{
    //ios_base::sync_with_stdio(false); cin.tie(0);
    int n,cur,m,lo,hi,mid,d;
    string s;
    cin >> n; 
    // lo = 0
    cout << 0 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    cur = (s[0] == 'M');
    // hi = n-1
    cout << n-1 << '\n'; cout.flush();
    cin >> s; 
    if(s[0] == 'V')
        return 0;
    // Binary search
    lo = 0; hi = n-1;
    while(lo <= hi)
    {
        mid = lo + (hi-lo)/2;
        cout << mid << '\n'; cout.flush();
        cin >> s; 
        if(s[0] == 'V')
            return 0;
        m = (s[0] == 'M');
        d = mid - lo + 1;
        if((cur != m && d % 2 != 0) || (cur == m && d % 2 == 0))
            hi = mid;
        else
        {
            lo = mid;
            cur = m;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include<iostream>
#include<iomanip>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<string>
#include<queue>
#include<stack>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
const int MAXD=105;
const int MAXA=1005;
const int MAXB=10005;
const int MAXC=1000005;
const int Maxx=0x7fffffff/2;
const int Minn=-0x7fffffff/2;
const int Maxn=0x3f3f3f3f;
const int Minm=-0x3f3f3f3f;
inline void read(ll &oi){
	char ch;ll f=1,res=0;
	while(ch=getchar(),(ch<'0'||ch>'9')&&ch!='-');
	ch=='-'?f=-1:res=ch-'0';
	while(ch=getchar(),ch>='0'&&ch<='9')res=(res<<1)+(res<<3)+ch-'0';
	oi=res*f;
}
int maxxx(int x,int y){return x>y?x:y;}
int minnn(int x,int y){return x<y?x:y;}
ll ans,n;
int main(){
	read(n);
	for(int i=1;i<=n;i++){
		if(i%3==0||i%5==0)continue;
		ans+=i;
	}
	printf("%lld",ans);
	puts("");
	return 0;
}

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

using namespace std;

using ll = long long;
using ld = long double;

typedef pair<ll, ll> P;

#define bit(n) (1LL << (n))

//#define int long long

#define all(v) v.begin(), v.end()
#define sortAl(v) sort(all(v))
#define sortAlr(v)          \
  sort(v.begin(), v.end()); \
  reverse(v.begin(), v.end())

#define cout(n) cout << fixed << setprecision(n)

#define rep(i, n) for (ll i = 0; i < n; i++)
#define REP(i, n) for (ll i = 1; i < n; i++)

#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define FORm(i, m) for (auto i = m.begin(); i != m.end(); i++)

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

#define mod (ll)(1e9 + 7)
#define INF LLONG_MAX

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

  ll n, k;
  cin >> n >> k;

  vector<ll> p(n);
  vector<ld> s(n);
  rep(i, n) {
    cin >> p[i];
    s[i] = (ld)(1 + p[i]) / 2.0;
  }

  vector<ld> sum(n);
  sum[0] = 0;
  rep(i, k) {
    sum[0] += s[i];
  }

  REP(i, n - k + 1) {
    sum[i] += sum[i - 1] + s[i + k - 1] - s[i - 1];
  }

  ld ans = 0;

  rep(i, n) {
    chmax(ans, sum[i]);
  }

  cout(10) << ans << endl;

  return 0;
}


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


int main() {
  int n;
  cin >> n;
  if(n%2 == 0) cout << n << endl;
  else cout << 2*n << endl;
  return 0;
}

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

typedef long long ll;

int n, p, a[2];
ll comb[51][51];

int main()
{
  for(int i = 1; i < 51; i++){
    comb[i][0] = comb[i][i] = 1;
    for(int j = 1; j < i ; j++){
      comb[i][j] = comb[i-1][j] + comb[i-1][j-1];
    }
  }

  cin >> n >> p;
  for(int i = 0; i < n; i++){
    int x;
    cin >> x;
    a[x%2]++;
  }

  ll ans = 0;
  for(int i = p; i <= a[1]; i+=2){
    ans += comb[a[1]][i];
  }
  if(!p and !a[2] and !ans) ans = 1;
  ans *= 1LL << a[0];

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


bool check(ll k, ll a, ll b){
  ll i=max((k-a-1)/2,0LL);
  ll l=a+1+i;
  ll r=k-i;
  ll res=l*r;
 // if((k-a+1)%2!=0){
 //   l++;
 //   r--;
 //   res=min(res,l*r);
 // }


  return res < a * b;
}


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

  ll q;
  cin>>q;
  REP(i,q){
    ll a,b;
    cin>>a>>b;

    if(a>b)swap(a,b);

    ll ng=b;
    ll ok=0;
    while(ng-ok>1){
      ll mid=(ok+ng)/2;
      if (check(mid, a, b))
        ok = mid;
      else
        ng = mid;
    }
    ll ans = ok + a - 1;
    cout << ans << endl;
  }

}



Measured memory_bytes: 3628
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;

struct Point{double x, y;};

void koch(int n, Point p1, Point p2){
    if( n == 0){
        return;
    }
    
    Point s, t, u;
    double arg = M_PI * 60.0/180.0;
    
    s.x = p1.x + (p2.x - p1.x)/3.0;
    s.y = p1.y + (p2.y - p1.y)/3.0;
    
    t.x = p1.x + 2.0*(p2.x - p1.x)/3.0;
    t.y = p1.y + 2.0*(p2.y - p1.y)/3.0;
    
    u.x = (t.x - s.x)*cos(arg) - (t.y - s.y)*sin(arg) + s.x;
    u.y = (t.x - s.x)*sin(arg) + (t.y - s.y)*cos(arg) + s.y;
    
    koch(n-1, p1, s);
    printf("%.8f %.8f\n", s.x, s.y);
    
    koch(n-1, s, u);
    printf("%.8f %.8f\n", u.x, u.y);
    
    koch(n-1, u, t);
    printf("%.8f %.8f\n", t.x, t.y);
    
    koch(n-1, t, p2);
    
}

int main(){
    Point p1, p2;
    int n;
    
    scanf("%d", &n);
    
    p1.x = 0.0;
    p1.y = 0.0;
    
    p2.x = 100.0;
    p2.y = 0.0;
    
    printf("%.8f %.8f\n", p1.x, p1.y);
    
    koch(n, p1, p2);
    
     printf("%.8f %.8f\n", p2.x, p2.y);
    
    
    return 0;
    
}



Measured memory_bytes: 3184
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0208

"""
import sys
from sys import stdin
from bisect import bisect_left
input = stdin.readline


def solve(num):
    ans = []
    o_txt = oct(num)[2:]

    for o in o_txt:
        if int(o) >= 6:
            ans.append(int(o) + 2)
        elif int(o) == 5:
            ans.append(7)
        elif int(o) >= 4:
            ans.append(int(o) + 1)
        else:
            ans.append(int(o))
    return ans


def main(args):
    while True:
        num = int(input())
        if num == 0:
            break
        ans = solve(num)
        print(*ans, sep='')


if __name__ == '__main__':
    main(sys.argv[1:])



Measured memory_bytes: 6932
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <vector>
#include <string>
using namespace std;

#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")

#define DEBUG(x) cout << ">> " << #x << ": " << x << endl;
#define _ ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int MOD = 1000000007;
typedef long long ll;
typedef long double ld;

int main() { _
  int n; cin >> n;
  vector<int> v(n, 0);
  vector<vector<int> > dp(n, vector<int>(2, 0));
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  dp[1][0] = abs(v[0] - v[1]); dp[1][1] = INT32_MAX;
  for (int i = 2; i < n; i++) {
    dp[i][0] = min(dp[i-1][0], dp[i-1][1]) + abs(v[i] - v[i-1]);
    dp[i][1] = min(dp[i-2][0], dp[i-2][1]) + abs(v[i] - v[i-2]);
  }
  cout << min(dp[n-1][0], dp[n-1][1]) << endl;
  return 0;
}

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
using namespace std;


int main(){
	/*input*/
	int n;
	cin >> n ;

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

	/*calc*/
    int ans = 0;
    int max_value = p[0];

    for(int i = 0; i < n; i++){
    	ans += p[i];
		max_value = max(max_value, p[i]);
    }
    ans -= max_value / 2;

    /*output*/
	cout<< ans <<endl;
    return 0;
}


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

typedef long long ll;
typedef long long llong;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;

const ll MOD = 998244353;

ll pw(ll a, ll b) {
	ll ans = 1;
	while (b) {
		while (!(b & 1))
			b >>= 1, a = (a * a) % MOD;
		--b;
		ans = (ans * a) % MOD;
	}
	return ans;
}

string s, t;
const int MX = 51000;
const ll B = 646;

int a, b;
ll fc[MX];
ll bfc[MX];

int rev(int x, int k) {
	int ans = 0;
	for (int i = 0; i < k; ++i) {
		ans = ans * 2 + (x & 1);
		x >>= 1;
	}
	return ans;
}

void fft(ll *a, int k, int inv) {
	int n = (1 << k);
	for (int i = 0; i < n; ++i) {
		int x = rev(i, k);
		if (x > i)
			swap(a[x], a[i]);
	}
	for (int bl = 1; bl < n; bl *= 2) {
		ll wadd = pw(B, (1 << 20) / (bl * 2));
		if (inv)
			wadd = pw(wadd, MOD - 2);
		for (int i = 0; i < n; i += 2 * bl) {
			ll w = 1;
			for (int j = i; j < i + bl; ++j, w = (w * wadd) % MOD) {
				ll u = a[j];
				ll v = a[j + bl] * w % MOD;
				a[j] = (u + v) % MOD;
				a[j + bl] = (u - v + MOD) % MOD;
			}
		}
	}
	if (inv) {
		ll n2 = pw(n, MOD - 2);
		for (int i = 0; i < n; ++i)
			a[i] = (a[i] * n2) % MOD;
	}
}

void add(ll &a, ll b) {
	a += b;
	if (a >= MOD)
		a -= MOD;
}
ll gg[40000];
ll ans[40000];

int main() {
	fc[0] = 1;
	bfc[0] = 1;
	for (int i = 1; i < MX; ++i) {
		fc[i] = (fc[i - 1] * i) % MOD;
		bfc[i] = pw(fc[i], MOD - 2);
	}
	cin >> s >> t;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] == '1') {
			if (t[i] == '1')
				++b;
			else
				++a;
		}
	}
	for (int k = 0; k <= b; ++k)
		gg[k] = bfc[k + 1];
	ans[0] = 1;
	int p = a;
	int sh = 0;
	while ((1 << sh) <= 2 * b)
		++sh;
	while (p) {
		while (!(p & 1)) {
			p >>= 1;
			fft(gg, sh, 0);
			for (int i = 0; i < (1 << sh); ++i)
				gg[i] = (gg[i] * gg[i]) % MOD;
			fft(gg, sh, 1);
			for (int i = b + 1; i < (1 << sh); ++i)
				gg[i] = 0;
		}
		--p;
		fft(gg, sh, 0);
		fft(ans, sh, 0);
		for (int i = 0; i < (1 << sh); ++i)
			ans[i] = (ans[i] * gg[i]) % MOD;
		fft(gg, sh, 1);
		fft(ans, sh, 1);
		for (int i = b + 1; i < (1 << sh); ++i)
			ans[i] = 0;
	}
	/*
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j <= b; ++j) {
			for (int k = 0; k + j <= b; ++k) {
				add(dp[i + 1][k + j], dp[i][j] * fc[b - j] % MOD * bfc[b - j - k] % MOD * bfc[k + 1] % MOD);
			}
		}
	}*/
	ll ans2 = 0;
	for (int i = 0; i <= b; ++i) {
		add(ans2, ans[i] * fc[b - i] % MOD * fc[b] % MOD * bfc[b - i] % MOD);
	}
	ans2 = (ans2 * fc[a] % MOD * fc[a + b]) % MOD;
	cout << ans2 << "\n";
	return 0;
}




Measured memory_bytes: 1664
using System;

namespace ABC088
{
    class A
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int A = int.Parse(Console.ReadLine());
            if (0 <= A - (N % 500)) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=3.14159265359;

int main() {
    double A, B, H, M;
    cin>>A>>B>>H>>M;
    double Atheta, Btheta;
    Btheta = 6*M*PI/180;
    Atheta = (30*H + M/2)*PI/180;
    double theta = abs(Atheta - Btheta);
    double ans = sqrt(A*A+B*B-2*A*B*cos(theta));
    cout<<setprecision(20)<<ans<<endl;
}



Measured memory_bytes: 4224
#include "bits/stdc++.h"

using namespace std;
typedef long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;


int main() {

    double n, m, d; cin >> n >> m >> d;

    double ans = 0;

    if(d == 0){
        ans = n*(m-1) / (n*n);

    }else{
        ans = (2 * (n-d) * (m-1)) / (n*n);
    }

    cout << fixed << setprecision(10) << ans << endl;

}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

	    int x=gi();
	    int y=gi();
	   


        //System.out.println(c);
        if (x+y>=10) {
        	System.out.print("error");
        }else{
            System.out.print(x+y);
        }


	}

	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}

	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}

	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
}

Measured memory_bytes: 35648
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main()
{
  string a,b;
  cin >> a >> b;
  int p = a.length();
  int count = 0;
  for(int i=0;i<p;i++)
  {
    if(a[i] != b[i])
    {
      count++;
    }
  }
  cout << count;
  return 0;
}

Measured memory_bytes: 3860
let () =
    let main () =
        let a, b, x = Scanf.sscanf (read_line ()) "%d %d %d" (fun a b x -> a, b, x) in
        let flag = x * 2 >= a * a * b in
        let a = float a in
        let b = float b in
        let x = float x in
        let x = x /. a in
        let ans = if flag then (
            let m = 2. *. (b -. x /. a) in
            atan2 m a /. 3.141592653589793238 *. 180.
        ) else (
            let m = 2. *. x /. b in
            atan2 b m /. 3.141592653589793238 *. 180.
        )
        in
        Printf.printf "%.10f\n" ans

    in
    main ()

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 0;
  int h;
  rep(i, 0, N) {
    cin >> h;
    if (h >= K) ans++;
  }

  cout << ans << endl;
};


Measured memory_bytes: 256
k, n = map(int, input().split())
a = list(map(int, input().split()))
l = len(a)
dis = [None] * l
for i in range(n - 1):
    dis[i] = a[i + 1] - a[i]
dis[-1] = a[0] - a[-1] + k

ans = sum(dis) - max(dis)
print(ans)

Measured memory_bytes: 25840
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>	
#include <cmath>
#include <string>
#include<math.h>
#include<sstream>//���炵���̂Œ���
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define Cout(s) cout<<s<<endl
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 1, b = 0, c, d, n, k = 0, ans = 0;
string s, t;
int mod = 1000000007;

int main()
{
	int n; cin >> n;
	vector<int> p(n), q(n); rep(i, n)cin >> p[i]; rep(i, n)cin >> q[i];
	vector<int> a(n); rep(i, n)a[i] = i + 1;
	map<vector<int>, int> mp;
	do {
		mp[a] = mp.size();
	} while (next_permutation(all(a)));
	int ans = abs(mp[p] - mp[q]);
	cout << ans << endl;

	return 0;
}


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

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

	for (int i = 1; i <= 9; i++){
		for(int j = 1; j <=9; j++){
			cout << i << "x" << j << "=" << i*j << "\n";
		}
	}

	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
bool arr[100005];
int bolas[100005];
int main()
{
    //freopen("a.in" , "r" , stdin);
    //entrada
    int cant = 0;
    arr[1] = true;
    int N , change; cin >> N >> change;
    for (int i = 1 ; i <= N ;i++) bolas[i] =1;

    //solution
    while(change--)
    {
        int x,y;
        cin >> x >> y;
        //si la bola pudiera estar en esta casilla
        if (arr[x])
        {
            //si es la unica a escoger
            if (bolas[x] == 1) {arr[x]=false;}
            arr[y] = true;
        }
        bolas[y]++;
        bolas[x]--;
    }
    for (int i = 1 ; i<= N;i++) if (arr[i]) cant++;
    cout << cant << endl;
	return 0;
}


Measured memory_bytes: 768