akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define For(i, l, r) for(register int i = (l), i##end = (int)(r); i <= i##end; ++i)
#define Fordown(i, r, l) for(register int i = (r), i##end = (int)(l); i >= i##end; --i)
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;

inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}

inline int read() {
    int x = 0, fh = 1; char ch = getchar();
    for (; !isdigit(ch); ch = getchar()) if (ch == '-') fh = -1;
    for (; isdigit(ch); ch = getchar()) x = (x << 1) + (x << 3) + (ch ^ 48);
    return x * fh;
}

void File() {
#ifdef zjp_shadow
	freopen ("D.in", "r", stdin);
	freopen ("D.out", "w", stdout);
#endif
}

int n, D[2];
const int N = 1010;

vector<pair<int, int> > Dir;
#define fir first
#define sec second

void Resolve(int id) {
	Dir.clear();
	For (a, 0, sqrt(D[id] + .5)) {
		int b = sqrt(D[id] - a * a);
		if (a * a + b * b == D[id]) {
			Dir.push_back(make_pair(a, b));
			Dir.push_back(make_pair(-a, -b));
			Dir.push_back(make_pair(a, -b));
			Dir.push_back(make_pair(-a, b));
		}
	}
}

int Mat[N][N][2];
bool vis[N][N];
void Color(int id) {
	queue<pair<int, int> > Q;
	Set(vis, false);
	For (i, 1, n) For (j, 1, n) if (!vis[i][j]) {
		vis[i][j] = true;
		Q.push(make_pair(i, j));
		while (!Q.empty()) {
			pair<int, int> u = Q.front(), v; Q.pop();
			For (k, 0, Dir.size() - 1) {
				v = make_pair(u.fir + Dir[k].fir, u.sec + Dir[k].sec);
				if (v.fir <= 0 || v.sec <= 0 || v.fir > n || v.sec > n) continue ;
				if (!vis[v.fir][v.sec]) {
					Mat[v.fir][v.sec][id] = !Mat[u.fir][u.sec][id];
					vis[v.fir][v.sec] = true, Q.push(v);
				}
			}
		}
	}
}

vector<pair<int, int> > tot[4];

#define pow2(x) ((x) * (x))
int main () {
	File();
	n = read() * 2; D[0] = read(); D[1] = read();

	For (i, 0, 1) { Resolve(i); Color(i); }

	For (i, 1, n) For (j, 1, n) {
		tot[Mat[i][j][0] * 2 + Mat[i][j][1]].push_back(make_pair(i, j));
	}

	//For (i, 1, n) For (j, 1, n) printf ("%d%c", Mat[i][j][1], j == jend ? '\n' : ' '); printf ("\n");

	For (i, 0, 3) if (tot[i].size() >= n * n / 4) {
		For (j, 0, min((int)tot[i].size() - 1, n * n / 4 - 1))
			printf ("%d %d\n", tot[i][j].fir - 1, tot[i][j].sec - 1);
		return 0;
	}

    return 0;
}


Measured memory_bytes: 10856
def main():
    """
    a % d + c % d = (a + c) % dだ
    整数の余りを取るのと，整数の各桁の余りを取るのが同じを使うこともあった　→　Digits Parade
    """
    N = int(input())
    X = input()
    t = X.count("1")
    v1, v2 = int(X, 2) % (t+1), int(X, 2) % (t-1) if t != 1 else 0
    for i in range(N):
        ans = 1
        x = 0
        if X[i] == "0":
            # 反転してt+1
            x = v1 + pow(2, N-i-1, t+1)
            x %= t+1
        elif t != 1 and X[i] == "1":
            # 反転してt-1
            x = v2 - pow(2, N-i-1, t-1)
            x %= t-1
        else:
            # t == 1 かつ その"1"を反転するとき
            # 当然X_iは0になる，答えも0
            ans = 0
        while x > 0:
            x %= "{:0b}".format(x).count("1")
            ans += 1
        print(ans)


if __name__ == '__main__':
    main()


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

using namespace std;

const int MaxN = 1e5 + 15;
const int MOD = 1e9 + 7;
const long long INF = 1e18;

int get(vector <int> & a, int l, int r)
{
    int res = a[r];
    if(l >= 1)
        res -= a[l - 1];
    if(res < 0)
        res += MOD;
    return res;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
//    freopen("input.txt", "r", stdin);

    int n, k;
    cin >> n >> k;

    vector <int> dp(k + 1);

    dp[0] = 1;

    for(int i = 1; i <= n; ++i)
    {
        vector <int> sum(k + 1);
        int x;
        cin >> x;

        for(int j = 0; j <= k; ++j)
        {
            sum[j] = dp[j];
            if(j)
            {
                sum[j] += sum[j - 1];
                if(sum[j] >= MOD)
                    sum[j] -= MOD;
            }

            dp[j] = get(sum, j - x, j);
        }

    }

    cout << dp[k] << '\n';

    return 0;
}



Measured memory_bytes: 1024
<?php
$k = trim(fgets(STDIN));

$count=0;
for($i=1; $i<=$k; $i++) {
    if($i%2!=0) continue;
    for($j=1; $j<=$k; $j++) {
        if($j%2==0) continue;
        $count++;
    }
}

echo $count;

Measured memory_bytes: 4604
#include<bits/stdc++.h>
#define maxn 1124291
#define mod 1000000007
using namespace std;
int f[23][maxn],g[23][23],h[maxn][23];
int main(){
  int n,m,k,x,y,z;
  scanf("%d%d%d",&n,&m,&k);
  memset(g,-1,sizeof(g));
  for(int i=1;i<=k;i++)
    scanf("%d%d%d",&x,&y,&z),g[x][y]=z;
  for(int i=0;i<1<<n;i++){
    for(int j=0;j<n-1;j++)
      if(!(i>>j&1)){
	for(k=j+1;k<n-1;k++)
	  if(i>>k&1){h[i][j]=i^(1<<j)^(1<<k);break;}
	if(!h[i][j]) h[i][j]=i^(1<<j);
      }
  } f[n-1][0]=1;
  for(int i=1;i<=m;i++){
    for(int j=0;j<1<<n;j++) f[0][j]=f[n-1][j],f[n-1][j]=0;
    for(int j=0;j<n-1;j++)
      for(k=0;k<1<<n;k++)
	if(f[j][k]){
	  if(g[i][j+1]!=((k>>j&1)^1)) f[j+1][k]=(f[j+1][k]+f[j][k])%mod;
	  if(g[i][j+1] && !(k>>j&1)) f[j+1][h[k][j]]=(f[j+1][h[k][j]]+f[j][k])%mod;
	  f[j][k]=0;
	}
  }
  int ans=0;
  for(int i=0;i<1<<n;i++) ans=(ans+f[n-1][i])%mod;
  printf("%d",ans);
  return 0;
}


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

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

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long> vl;
typedef vector<double> vd;
typedef map<int,int> mii;
typedef pair<int,int> pii;
typedef pair<long,long> pll;

#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,a,n) for(int i=a;i<n;i++)
#define ALL(a) (a).begin(),(a).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

#define pi 3.14159265358979
#define eps 1e-9
#define inf 1<<30
#define MOD 1000000007 // 1e9+7

int B[30];
int main()
{
  int N, M, C;
  cin >> N >> M >> C;

  int ret = 0;
  int A;
  for( int i=0; i<M; i++ ) cin >> B[i];
  for( int i=0; i<N; i++ ){
    int sum = C;
    for( int j=0; j<M; j++ ){
      cin >> A;
      sum += A*B[j];
    }
    if( sum > 0 ) ret++;
  }

  cout << ret << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
using ld  = long double;
template <class Itr> auto Median(Itr first, Itr last) {
    // when value_type is double or long double , you should use "round""
    // function these Iterator must be Random Access Iterator
    typename iterator_traits<Itr>::difference_type n = distance(first, last);
    sort(first, last);
    if (n % 2 == 1) {
        return *(first + n / 2);
    } else {
        return (*(first + n / 2) + *(first + n / 2 - 1)) / 2;
    }
}
int main(){
    Int N; cin >> N;
    vector<ld>A(N);
    vector<ld>B(N);
    for(int i = 0; i < N; ++i)
        cin >> A[i] >> B[i];
    sort(A.begin(),A.end());
    sort(B.begin(),B.end());
    auto Bmed = Median(B.begin(), B.end());
    auto Amed = Median(A.begin(), A.end());
    if(N % 2){
        cout << (Int)Bmed - (Int)Amed + 1 << endl;
    } else {
        cout << (Int)(2 * (Bmed - Amed) + 1) << endl;
    }
    
}


Measured memory_bytes: 9588
N = int(input())
height = list(map(int, input().split()))
total = 0
max_number = height[0]

for i in range(1, height.index(max(height))):
	if height[i] > max_number:
		max_number = height[i]
	else:
		total += (max_number - height[i])

total += (max(height)*(N-1-height.index(max(height)))-sum(height[height.index(max(height))+1:N]))
    
print(total)

Measured memory_bytes: 32224
h, w = (int(i) for i in input().split()) 
s = []

for i in range(h):
  tmp = input()
  s.append(tmp)

#左にいくつあるか
l = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w):
    if s[i][j] == "#":
      l[i][j] = 0
    else:
      if j == 0:
        l[i][j] = 1
        continue
      l[i][j] = l[i][j-1] + 1
#print(l)
      
#上
d = [[0 for i in range(w)] for j in range(h)]

for j in range(w):
  for i in range(h):
    if s[i][j] == "#":
      d[i][j] = 0
    else:
      if i == 0:
        d[i][j] = 1
        continue
      d[i][j] = d[i-1][j] + 1  
#print(d)      

#右にいくつあるか
r = [[0 for i in range(w)] for j in range(h)]

for i in range(h):
  for j in range(w)[::-1]:
#    print(i,j)
    if s[i][j] == "#":
      r[i][j] = 0
    else:
      if j == w-1:
#        print("aa")
        r[i][j] = 1
        continue
      r[i][j] = r[i][j+1] + 1
      
#print(r)

#下
u = [[0 for i in range(w)] for j in range(h)]

for j in range(w):
  for i in range(h)[::-1]:
    if s[i][j] == "#":
      u[i][j] = 0
    else:
      if i == h-1:
        u[i][j] = 1
        continue
      u[i][j] = u[i+1][j] + 1

#print(u)


#足し合わせ
for i in range(h):
  for j in range(w):
    l[i][j] += r[i][j] + u[i][j] + d[i][j] -3

unko = []
for i in range(h):
  mm = max(l[i])
  unko.append(mm)

print(max(unko))

Measured memory_bytes: 185988
#include <cmath>
#include <iostream>
#include <vector>
typedef std::vector <int> vi;
vi PRIMES;
vi prime(int n){
    vi s,p;
    int i,j,x,h;
    for (i=1;i<=n;i+=2) s.push_back(i);
	h=s.size();
    for (i=1;i<=(int)pow(n,0.5);i++)
        if (x=s[i]) for (j=i+x;j<h;j+=x) s[j]=0;
	s[0]=2;
	for (i=0;i<h;i++) if(s[i]!=0) p.push_back(s[i]);
	return p;
}
int main(void){
	int n,s,i;
	PRIMES=prime(105000);
	while (true){
		std::cin>>n; if (n==0) break;
		s=0;
		for (i=0;i<n;i++) s+=PRIMES[i];
		std::cout<<s<<"\n";
	}
} 

Measured memory_bytes: 1384
#include <bits/stdc++.h>
#define pb push_back
#define Int long long
using namespace std;

const int MAXN=500005;
const long MOD=(long)(1e9+7);
vector<int> adj[MAXN];
vector<pair<int,int>> G[MAXN];

Int N,M,K;
Int B,C,H,W;
Int X,Y,Z;
vector<Int> A;

Int ceilS(Int x,Int y){
    return (x+y-1)/y;
}
using D=long double;

Int perform(Int x){
    return (x*(x+1))/2LL;
}

int main()
{
     map<char,int> mp;
     string S;cin>>S;
     for(auto x:S) ++mp[x];
     
     bool ok=true;
     if(mp.size()!=2) ok=false;
     for(auto &itr:mp){
         if(itr.second!=2)  ok=false;
     }
     cout<<(ok ? "Yes\n":"No\n");
}


Measured memory_bytes: 27052
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 998244353;

fn main() {
    input! {
        n: usize,
        s: usize,
        a: [usize; n],
    }

    let mut count = vec![0; 3001];
    let mut ans = 0;
    for i in 0..n {
        if a[i] < s {
            let x = count[s - a[i]];
            ans += (n - i) * x;
        } else if a[i] == s {
            ans += (n - i) * (i + 1);
        }

        ans %= M;

        let mut next_count = vec![0; 3001];
        for j in (0..3001).rev() {
            if j + a[i] > 3000 {
                continue;
            }
            next_count[j + a[i]] = count[j];
        }
        for j in 0..3001 {
            next_count[j] += count[j];
            next_count[j] %= M;
        }
        next_count[a[i]] += i + 1;
        next_count[a[i]] %= M;
        count = next_count;
    }
    println!("{}", ans);
}


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

using namespace std;
using ll = long long;
using ld = long double;
using Vec = vector<int>;

int mod=1000000007;

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}


int main(){

int n;
ll sum=0;
cin>>n;
Vec vec(n);
for(int i=0;i<n;i++){
    cin>>vec[i];
}
for(int i=0;i<n-1;i++){
  if(vec[i]>vec[i+1]){
      sum+=vec[i]-vec[i+1];
      vec[i+1]=vec[i];
  }

}
cout<<sum<<endl;

}


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

int main(){
    string a;
    cin>>a;
    if(a.size()<=3){
        cout<<"No"<<endl;
    }else{
         if (a.at(0)=='Y' && a.at(1)=='A' && a.at(2)=='K' && a.at(3)=='I') {
               cout<<"Yes"<<endl;
           }else{
               cout<<"No"<<endl;
           }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;

typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

constexpr long long MOD = 998244353;

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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}


void solve() {
	ll k, n;
	cin >> k >> n;
	Array a(n + 1);
	REP(i, n)cin >> a[i];
	a[n] = k+a[0];
	ll max = 0;
	ll sum = 0;
	REP(i, n) {
		ll d = a[i + 1] - a[i];
		sum += d;
		chmax(max, d);
	}

	cout << sum - max << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 1792
// #1140935 Solution for 0515: School Road by ryogo 
#include<iostream>
using namespace std;
int dp[20][20];
int main(){
	int a,b;
	while(cin>>a>>b){
		if(a == 0 && b == 0) { break; }
		int n;
		cin>>n;
		for(int i=1;i<=20;i++)for(int j=1;j<=20;j++)dp[i][j]=0;
		for(int i=1;i<=n ;i++){
			int x,y;
			cin>>x>>y;
			dp[y][x]=-1;
		}
		dp[1][1]=1;
		for(int i=1;i<=b;i++){
			for(int j=1;j<=a;j++){
				if(i==1 && j==1)continue;
				if(dp[i][j]!=-1){
					dp[i][j]=dp[i][j-1]+dp[i-1][j];
				}
				else dp[i][j]=0;
			}
		}
 
		cout<<dp[b][a]<<endl;
	}
}


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

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

using namespace std;

// graph
// adjacent list
vector<vector<int>> G; 
// adjacent matrix
const int MAX_N = 100;
int GM[MAX_N][MAX_N];

int main(){
    // input 
    int n; cin >> n;
    G.resize(n);
    rep(i, n){
        int from, edgeNum, to;
        cin >> from >> edgeNum;
        G[from-1].resize(edgeNum);
        rep(j, edgeNum){
            cin >> G[from-1][j];
        }
    }

    // output adjacent matrix
    rep(u, n){
        rep(i, G[u].size()){
            GM[u][G[u][i]-1] = 1; 
        }
    }
    rep(i, n)
        rep(j, n)
            cout << GM[i][j] << (j<n-1? " ": "\n");
}


Measured memory_bytes: 3116
def alsd12a
    n = gets.chomp.to_i
    an = gets.chomp.split(/\s/).map{|x| x.to_i}

    cnt = 0
    flag = true
    while flag
        flag = false
        j = n-1
        until j == 0
            if an[j] < an[j-1]
                tmp = an[j]
                an[j] = an[j-1]
                an[j-1] = tmp
                flag = true
                cnt += 1
            end
            j -= 1
        end
    end

    puts an.join(' ')
    puts cnt
end

alsd12a



Measured memory_bytes: 6872
from sys import stdin
input = stdin.readline

X, K, D = map(int, input().split())

X = abs(X)

m = X % D
l = X // D

if l > K:
    print(abs(X) - D * K)
else:
    if (K - l) % 2 == 0:
        print(m)
    else:
        print(D - m)


Measured memory_bytes: 9160
mod = 1000000007
eps = 10**-9


def main():
    import sys
    from collections import deque
    input = sys.stdin.buffer.readline

    N = int(input())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b, c = map(int, input().split())
        adj[a].append((b, c))
        adj[b].append((a, c))
    Q, root = map(int, input().split())

    que = deque()
    que.append(root)
    seen = [-1] * (N+1)
    seen[root] = 0
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while que:
        v = que.popleft()
        seq.append(v)
        for u, c in adj[v]:
            if seen[u] == -1:
                seen[u] = seen[v] + c
                par[u] = v
                child[v].append(u)
                que.append(u)
    seq.reverse()

    for _ in range(Q):
        x, y = map(int, input().split())
        print(seen[x] + seen[y])


if __name__ == '__main__':
    main()


Measured memory_bytes: 57084
#include<bits/stdc++.h>
#define pb push_back
#define ii pair<int,int>
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define INF 100000000000000000
#define modulo 1000000007
#define int long double
using namespace std;
vector<ii> data;
int dist(ii& a,ii& b){
      return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}
int F(vector<int>&P){
      int ans=0;
      for(int i=1;i<P.size();i++){
            ans+=dist(data[P[i]],data[P[i-1]]);
      }
      return ans;
}
int32_t main(){
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      //freopen("q.gir","r",stdin);
      int n;
      cin>>n;
      vector<int>A;
      for(int i=0;i<n;i++){
            A.pb(i);
      }
      for(int i=0;i<n;i++){
            int x,y;
            cin>>x>>y;
            data.pb({x,y});
      }
      int cnt=0,ans=0;
      do{
            ans+=F(A);
            cnt++;
      }while(next_permutation(all(A)));
      cout<<setprecision(15)<<ans/cnt;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const long long  mod=1e9+7;
int main()
{
  ll n,x,y;
  cin>>n;
  ll arr1[n],arr2[n],arr3[n],arr4[n];
  for(int i=0;i<n;i++)
  {
      cin>>x>>y;
      arr1[i]=x+y;
      arr2[i]=x-y;
      arr3[i]=-x-y;
      arr4[i]=-x+y;
  }
  sort(arr1,arr1+n);
  sort(arr2,arr2+n);
  sort(arr3,arr3+n);
  sort(arr4,arr4+n);
  cout<<max({arr1[n-1]-arr1[0],arr2[n-1]-arr2[0],arr3[n-1]-arr3[0],arr4[n-1]-arr4[0]});
}

Measured memory_bytes: 9876
#include<stdio.h>
int main(){
	int N,i,temp,key=1;
	scanf("%d",&N);
	for(i=0;i<N;i++){
		scanf("%d",&temp);
		if(temp%2==0)
			if(temp%3!=0&&temp%5!=0)
				key=0;
	}
	if(key==1)
		printf("APPROVED");
	else
		printf("DENIED");
	return 0;
}

Measured memory_bytes: 128
#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 mp make_pair
#define pb push_back
#define eb emplace_back
#define pll pair<int ,int >
#define ppll pair < pll , pll >
#define mod 1000000007
unsigned int bp(int n) // built_in_pop_count // 
{ 
    unsigned int count = 0; 
    while (n) { 
        n &= (n - 1); 
        count++; 
    } 
    return count; 
} 
int32_t main(){
    SPEED;
    int n;
    cin >> n;
    int arr[n];
    int ind[100001] = {};
    int res = 0;
    for(int i = 0; i < n; ++i){
        cin >> arr[i];
        res += arr[i];
        ind[arr[i]]++;
    }
    int q;
    cin >> q;
    while(q--){
        int b, c;
        cin >> b >> c;
        int cnt = ind[b];
        ind[b] = 0;
        ind[c] += cnt;
        //cout << ind[b] << " " << ind[c] << endl;
        if(cnt == 0) cout << res << endl;
        else{
            res -= cnt * b;
            res += cnt * c;
            cout << res << endl;
        }
    }
}

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

int main(){
	int n;
	int a[31] = {1,1,2};
	for(int i=3 ; i <= 30 ; i++ ){
		a[i] = a[i-1] + a[i-2] + a[i-3];
	}

	while( cin >> n , n ){
		cout << (a[n]/10/365 + 1) << endl;
	}
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <algorithm>

#include <bits/stdc++.h>
#include <cmath>
#include <limits>

using namespace std;


int main(int argc, char* argv[]){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	long long ans = 0;
	
	cin >> N;
	for(int i=1; i<=N; i++){
		ans += (long long) i;
	}
	
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <algorithm>
#include <string>

void solve(int n, int g, std::string& s) {
	if (n == 0) {
		std::cout << s << "\n";
		return;
	}

	for (int i = 0; i <= g + 1; ++i) {
		s += static_cast<char>('a' + i);
		solve(n - 1, std::max(i, g), s);
		s.pop_back();
	}
}

int main() {
	int n;
	std::cin >> n;

	std::string s;
	s.reserve(n);
	s += 'a';

	solve(n - 1, 0, s);
}

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

// typedef
using ll  = long long;
using str = string;
using PL  = pair<ll, ll>;
using P   = pair<int, int>;
using VL  = vector<ll>;
using vi  = vector<int>;
using vs  = vector<str>;
using vp  = vector<P>;
using VPL = vector<PL>;
using VVL = vector<VL>;
using vvi = vector<vi>;

// const num
const ll INF         = 1e18 + 18;
const ll MAX         = 100005;
const ll MOD         = 1000000007;
const long double PI = acosl(-1.0);

// Loop
#define REP(i, a, b) for(ll(i) = (a); (i) < (b); (i)++)
#define RREP(i, a, b) for(ll(i) = (a); (i) >= (b); (i)--)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) RREP(i, n, 0)

// YesNo
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl

// All
#define ALL(v) v.begin(), v.end()

int main(void) {
	int n, k;
	cin >> n >> k;
	vi p(n);

	rep(i, n) { cin >> p[i]; }

	sort(ALL(p));

	int sum = 0;
	rep(i, k) { sum += p[i]; }
	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 3632
from math import ceil
minutes = [int(input()) for _ in range(5)]

arr = [(x, x%10) for x in minutes if x%10 != 0]
if arr:
    x = min(arr, key=lambda x: x[1])
    minutes.remove(x[0])
    print(sum([ceil(x/10)*10 for x in minutes])+x[0])
else:
    print(sum(minutes))


Measured memory_bytes: 3060
#include <stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a<=8 && b<=8)
    {
        printf("Yay!", a, b);
    }
    else
    {
        printf(":(", a, b);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  ll a[n];
  rep(i,n) R a[i];
  REP(k,-1,n) {
    rep(t,2) {
      ll b[n],x=0,y=0,xx=-1,yy=-1;
      rep(i,n) b[i]=a[i];
      vector<P> ans;
      rep(r,2) {
        if((r+t)%2) {
          rep(i,n) {
            if(b[i]<x) {
              x=b[i];
              xx=i;
            }
          }
          if(k>=0&&xx!=-1) {
            while(b[k]>x) {
              b[k]+=x;
              ans.pb(P(xx+1,k+1));
              if(ans.size()>2*n) goto end;
            }
            if(b[k]<x) {
              x=b[k];
              xx=k;
            }
          }
        } else {
          rep(i,n) {
            if(y<b[i]) {
              y=b[i];
              yy=i;
            }
          }
          if(k+1<n&&yy!=-1) {
            while(b[k+1]<y) {
              b[k+1]+=y;
              ans.pb(P(yy+1,k+2));
              if(ans.size()>2*n) goto end;
            }
            if(y<b[k+1]) {
              y=b[k+1];
              yy=k+1;
            }
          }
        }
      }
      if(k>=0&&xx!=-1) {
        rrep(i,k) {
          while(b[i]>b[i+1]) {
            b[i]+=x;
            ans.pb(P(xx+1,i+1));
            if(ans.size()>2*n) goto end;
          }
          if(b[i]<x) {
            x=b[i];
            xx=i;
          }
        }
      }
      if(k+1<n&&yy!=-1) {
        REP(i,k+2,n) {
          while(b[i]<b[i-1]) {
            b[i]+=y;
            ans.pb(P(yy+1,i+1));
            if(ans.size()>2*n) goto end;
          }
          if(y<b[i]) {
            y=b[i];
            yy=i;
          }
        }
      }
      rep(i,n-1) {
        if(b[i]>b[i+1]) goto end;
      }
      if(ans.size()<=2*n) {
        pr(ans.size());
        rep(i,ans.size()) pr(ans[i].F,ans[i].S);
        return;
      }
    end:;
    }
  }
}

int main(){ios::sync_with_stdio(0);cin.tie(0);Main();return 0;}

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

using namespace std;

typedef long long ll;

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

	ll N;
	cin >> N;

	vector<ll> v(5);
	rep(i, 5) cin >> v[i];

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

	ll mn = v[0];
	cout << (N % mn == 0 ? N / mn : N / mn + 1) + 4;

}


Measured memory_bytes: 256
#067-C
n=int(input())
a=list(map(int,input().split()))
sa=[a[0] for i in range(n)]
for i in range(1,n):
    sa[i]=sa[i-1]+a[i]
mm=float("INF")
for i in range(n-1):
    mm=min(mm,abs(sa[i]-(sa[n-1]-sa[i])))
print(int(mm))

Measured memory_bytes: 24812
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

string T;

int CHECK(string str) {
	int N = str.size();

	for (int i = 0; i < N; i++) {
		if ((str[i] == 'A') || (str[i] == 'G') || (str[i] == 'C') || (str[i] == 'T')) { }
		else { return -1; }
	}

	return 1;
}

int main(void) {

	cin >> T;

	int N = T.size();

	int ans = 0;


	for (int i = 0; i < N; i++) {
		for(int j = i; j < N; j++) {
			if (CHECK(T.substr(i, j - i + 1)) == 1) {  ans = max(ans, j - i + 1); }
		}
	}

	cout << ans << endl;

	//system("pause");
	return 0;
}

Measured memory_bytes: 256
ABCD = input()

A = int(ABCD[0])
B = int(ABCD[1])
C = int(ABCD[2])
D = int(ABCD[3])

o1 = '+'
o2 = '+'
o3 = '+'
flag = False
for j in range(2) :
    if j % 2 == 0 :
        B2 = -B
        o2 = '-'
    else :
        B2 = B
        o2 = '+'
    for k in range(2) :
        if k % 2 == 0 :
            C2 = -C
            o3 = '-'
        else :
            C2 = C
            o3 = '+'
        for l in range(2) :
            if l % 2 == 0 :
                D2 = -D
                o4 = '-'
            else :
                D2 = D
                o4 = '+'
            if A+B2+C2+D2 == 7 :
                #print(B2, C2, D2 , o2, o3 ,o4)
                flag = True
                break
        if flag :
            break
    if flag :
        break
ans = str(A) + o2 + str(B) + o3 + str(C) + o4 + str(D) + '=7'
print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define mod (ll)1000000007
using namespace std;

int main()
{
    int n,k;
    cin>>n>>k;
    double a[n];
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < n; i++){
        a[i] = (a[i]+1)/2.0;
    }

    for(int i = 1; i < n; i++)
        a[i] += a[i-1];
    double ans = a[k-1];
    for(int i = k; i < n; i++){
        ans = max(ans, a[i]-a[i-k]);
    }
    cout<<setprecision(15);
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define inf 0x3f3f3f3f
#define fi first
#define se second
#define pb push_back
#define mkp make_pair
#define pa pair<int,int>
const int N=1e6+10; 
const int mod=998244353;
using namespace std;


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

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int i, n, r, minv, maxv;
  scanf("%d", &n);

  for (i = 0; i < n; i++) {
    if (i == 0)
      scanf("%d", &minv);
    else {
      scanf("%d", &r);
      if (i == 1)
	maxv = r - minv;
      if (maxv < r - minv)
	maxv = r - minv;
      if (r < minv)
	minv = r;
    }
  }

  printf("%d\n", maxv);
  return 0;
}

Measured memory_bytes: 596
def check(x,y,z,i,ops):
    if x == 1 and y == 1 and z == 0 and i < len(ops) - 1:        
        return (ops[i], ops[i+1]) in [("AB", "AC"), ("BC", "AB"), ("AC", "AB")]
    return (x <= y)

A=0
B=1
C=2
nabc = [int(_x) for _x in input().split()]
n = nabc[0]
abc = nabc[1:]
ops = []
for i in range(n):
    ops.append(input())

result = []
for i in range(n):
    op = ops[i]
    if op == "AB":
        (s,t,u) = (A,B,C)
    elif op == "BC":
        (s,t,u) = (B,C,A)
    else:
        (s,t,u) = (A,C,B)
    if check(abc[s],abc[t],abc[u],i,ops):
        result.append(s)
        abc[s] += 1
        abc[t] -= 1
    else:
        result.append(t)
        abc[s] -= 1
        abc[t] += 1
    if abc[s]<0 or abc[t]<0:
        print("No")
        break
else:
    print("Yes")
    for r in result:
        if r==A: print("A")
        if r==B: print("B")
        if r==C: print("C")


Measured memory_bytes: 16924
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


void solve(){
  ll K; cin >>K;
  vector<ll> a(50, 49 + K/50);
  // 全て等しく1減らすには50回必要
  K %= 50;
  // 残りは操作の逆をすれば終わり
  rep(i, K){
    rep(j, 50){
      if (i == j) a[j] += 50;
      else a[j]--;
    }
  }
  cout <<50 <<endl;
  PRINT(a);
}

int main() {
  solve();
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = getMaxDivisor(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}

	/**
	 * @param a
	 * @param b
	 * @return aとbの共通の最大の約数の可能性のある値
	 */
	private static int getMaxDivisor(int a, int b) {
		if (a == b) {
			return a;
		} else if (a > b) {
			if (b > (a - b)) {
				return a - b;
			} else {
				return b;
			}
		} else {
			if (a > (b - a)) {
				return b - a;
			} else {
				return a;
			}
		}
	}
}


Measured memory_bytes: 35516
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Int32;

class Program
{
    static void Main(string[] args)
    {
        var line = Hoge(Parse(ReadLine()));
        WriteLine(line);
    }

    static string Hoge(int num)
    {
        if (num == 0) return "0";
        var list = new List<int>();
        Piyo(num, list);
        var ary = Enumerable.Repeat('0', list[0] + 1).ToArray();
        foreach (var i in list)
        {
            ary[ary.Length - i - 1] = '1';
        }
        return new string(ary);
    }

    static void Piyo(long num, List<int> list)
    {
        if (num == 0) return;

        long abs = Math.Abs(num);
        bool isPlus = 0 < num;
        long beki = isPlus ? 1 : 2;
        int sisu = isPlus ? 0 : 1;
        long ijou = 0;
        while (true)
        {
            ijou += beki;
            if (abs <= ijou) break;
            beki = beki << 2;
            sisu += 2;
        }
        list.Add(sisu);
        if (isPlus) Piyo(num - beki, list);
        else Piyo(num + beki, list);
    }

    //static string ReadLine()
    //{
    //    return _inputs[_inIndex++];
    //}

    //static string[] _inputs = @"3".Split(new string[] { Environment.NewLine }, StringSplitOptions.None);

    //static int _inIndex = 0;
}



Measured memory_bytes: 13268
#include <bits/stdc++.h>
#define LL long long
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int P = 998244353,L = 16384,N = 8050,M = 205;
inline int power(int x,LL y){
	static int r; r = 1; while (y){ if (y&1) r = (LL)r * x % P; x = (LL)x * x % P; y >>= 1; } return r;
}
int fac[N<<1],nfac[N<<1],inv[N<<1];
inline int C(int n,int m){
	return (n<0||m<0||n<m) ? 0 : (LL)fac[n] * nfac[m] % P * nfac[n-m] % P; 
} 
int R[L],rt[30],irt[30];
inline void NTT(int *A,int n){
	register int i,j,k,l,w,w0,x,y;
	for (i = 0; i < n; ++i) if (i < R[i]) swap(A[i],A[R[i]]);
	for (i = l = 1; i < n; i <<= 1,++l)
	for (j = 0,w0 = rt[l]; j < n; j += i << 1)
	for (k = j,w = 1; k < i+j; ++k,w = (LL)w * w0 % P)
		x = A[k],y = (LL)w * A[k+i] % P,A[k] = (x+y>=P)?(x+y-P):(x+y),
		A[k+i] = (x<y)?(x+P-y):(x-y); 
}
inline void iNTT(int *A,int n){
	register int i,j,k,l,w,w0,x,y;
	for (i = 0; i < n; ++i) if (i < R[i]) swap(A[i],A[R[i]]);
	for (i = l = 1; i < n; i <<= 1,++l)
	for (j = 0,w0 = irt[l]; j < n; j += i << 1)
	for (k = j,w = 1; k < i+j; ++k,w = (LL)w * w0 % P)
		x = A[k],y = (LL)w * A[k+i] % P,A[k] = (x+y>=P)?(x+y-P):(x+y),
		A[k+i] = (x<y)?(x+P-y):(x-y);
	for (i = 0,w = power(n,P-2); i < n; ++i) A[i] = (LL)A[i] * w % P;
}
int Lim;
int A[L],B[L];
int Ans;
int f[N],g[N],n;
inline void solve(int m){
	int i;
	for (i = 0; i <= n; ++i) g[i] = 0;
	for (i = 0; i < Lim; ++i) A[i] = B[i] = 0;
	for (i = 0; i <= n; ++i) A[i] = (LL)nfac[i] * f[i] % P,B[i] = nfac[i+2]; B[0] = 0;
	NTT(A,Lim),NTT(B,Lim);
	for (i = 0; i < Lim; ++i) A[i] = (LL)A[i] * B[i] % P;
	iNTT(A,Lim);
	for (i = 0; i <= n; ++i) g[i] = (LL)A[i] * fac[i+2] % P,g[i] = (g[i] + (LL)(1+i+C(i,2)) * f[i]) % P,f[i] = g[i];
}

int main(){
	int i,j;
	for (i = 1,j = 2; i <= 25; ++i,j <<= 1) rt[i] = power(3,(P-1)/j),irt[i] = power(rt[i],P-2);
	inv[0] = fac[0] = nfac[0] = inv[1] = nfac[1] = fac[1] = 1;
	for (i = 2; i <= 16000; ++i){
		fac[i] = (LL)fac[i-1] * i % P;
		inv[i] = (LL)(P-P/i) * inv[P%i] % P;
		nfac[i] = (LL)nfac[i-1] * inv[i] % P; 
	}
	int m; cin >> n >> m; 
	int l = 0; Lim = 1;
	while (Lim <= n*2) Lim<<=1,++l;
	for (i = 0; i < Lim; ++i) R[i] = (R[i>>1]>>1) | ((i&1)<<l-1); 
	f[0] = 1;
	for (i = 1; i <= m; ++i) solve(i);
	for (i = 0; i <= n; ++i) Ans = (Ans + (LL)C(n,i) * f[i]) % P;
	cout << Ans << '\n';
	return 0;
}

Measured memory_bytes: 4048
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

    static int n;
    static int[][] ady;
    static int[] od;

    public static void main(String[] args) throws IOException {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        StringTokenizer st = new StringTokenizer(in.readLine());
        n = Integer.parseInt(st.nextToken());
        int x = Integer.parseInt(st.nextToken())-1;
        int y = Integer.parseInt(st.nextToken())-1;
        ady = new int[n][n];
        od = new int[n];
        for (int i = 0; i < n-1; i++)
        {
            ady[i][od[i]++] = i+1;
            ady[i+1][od[i+1]++] = i;
        }
        ady[x][od[x]++] = y;
        ady[y][od[y]++] = x;
        HashMap<Integer, Integer> pairs = new HashMap<>();
        int[][] dist = new int[n][n];
        for (int i = 0; i < n; i++) {
            dist[i] = bfs(i);
        }
        for (int i = 0; i < n; i++) {
            for (int j = i; j < n; j++) {
                pairs.put(dist[i][j], 1+pairs.getOrDefault(dist[i][j], 0));
            }
        }

        for (int k = 1; k < n; k++) {
            System.out.println(pairs.getOrDefault(k, 0));
        }
    }

    static int[] bfs(int or) {
        LinkedList<Integer> L = new LinkedList<>();
        LinkedList<Integer> at = new LinkedList<>();
        at.offer(or);
        L.offer(0);
        HashSet<Integer> visited = new HashSet<>();
        visited.add(or);
        int[] dist = new int[n];
        while (!at.isEmpty()) {
            int u = at.poll();
            int d = L.poll();
            for (int i = 0; i < od[u]; i++) {
                int v = ady[u][i];
                if (visited.contains(v)) continue;
                visited.add(v);
                dist[v] = d + 1;
                L.offer(d + 1);
                at.offer(v);
            }
        }
        return dist;
    }

}


Measured memory_bytes: 248772
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define ifaxb(a, x, b) if (a < x && x < b)  // 比較は昇順
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define pq priority_queue
#define ipair pair<int, int>
#define spair pair<string, string>
#define lpair pair<LL, LL>
#define MP make_pair
#define MM multimap
#define PB push_back
#define INF 2147483647
#define _INF -2147483647
#define pi 3.1415926536
#define MAXN 100004
using namespace std;
typedef long long ll;

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

  	int K;
    vi cnt(M);
    rep(i, N) {
        cin >> K;
        rep(j, K) {
            int A;
            cin >> A;
            cnt[A - 1]++;
        }
    }

    int ans = 0;
    rep(i, M) {
        if (cnt[i] == N) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())
A = input()
B = input()
C = input()
count = 0
for i in range(N):
    if A[i] != B[i] and B[i] != C[i] and C[i] != A[i]:
        count += 2
    elif A[i] == B[i] and B[i] != C[i] and C[i] != A[i]:
        count += 1
    elif A[i] != B[i] and B[i] == C[i] and C[i] != A[i]:
        count += 1
    elif A[i] != B[i] and B[i] != C[i] and C[i] == A[i]:
        count += 1
    else:
        count += 0
print(count)

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

using namespace std;

typedef long long Int;

#define rep(i, n) for(int i=0; i<n; ++i)
#define srt(A) sort(A.begin(), A.end(), greater<Int>())

int main(){
  Int X, Y, Z, K;
  cin >> X >> Y >> Z >> K;
  vector<Int> A(X), B(Y), C(Z), res;
  rep(i, X) cin >> A[i]; srt(A);
  rep(i, Y) cin >> B[i]; srt(B);
  rep(i, Z) cin >> C[i]; srt(C);
  
  rep(i, X){
    rep(j, Y){
      rep(k, Z){
        if ((i+1)*(j+1)*(k+1) <= K) res.push_back(A[i]+B[j]+C[k]);
        else break;
      }
    }
  }
  srt(res);
  rep(i,K)
    cout << res[i] << endl;
}


Measured memory_bytes: 1404
import sys
input = sys.stdin.readline

def F(N,A,B):
    AB = list(zip(A,B))
    AB = [(a,b) for a,b in AB if a < b] # 有用なやつだけ
    AB.sort(key = lambda x: x[1]/x[0], reverse = True)
    if len(AB) == 0:
        return N
    if len(AB) == 1:
        a,b = AB[0]
        x = N//a
        return N + (b-a) * x
    if len(AB) == 2:
        (a,b),(c,d) = AB
        # 2種類目の硬価はa回未満しか使わない：ac個はa優先なので
        return max(N + (N - i * c) // a * (b-a) + i * (d-c) for i in range(a))
    dp = list(range(N+1))
    for a,b in AB:
        for n in range(a,N+1):
            y = dp[n-a] + b
            if dp[n] < y:
                dp[n] = y
    return dp[N]

N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

answer = F(F(N,A,B),B,A)
print(answer)

Measured memory_bytes: 3316
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

string S;

int dp[310][310][310];

int solve(int a, int b, int r) {
  if (a > b) return 0;
  int& res = dp[a][b][r];
  if (res != -1) return res;
  if (a == b) return (S[a] == S[b] || r > 0) ? 1 : 0;
  res = 0;
  chmax(res, solve(a + 1, b, r));
  chmax(res, solve(a, b - 1, r));
  if (S[a] == S[b]) {
    chmax(res, solve(a + 1, b - 1, r) + 2);
  } else if (r > 0) {
    chmax(res, solve(a + 1, b - 1, r - 1) + 2);
  }
  return res;
}

int main() {
#ifdef DEBUG
  ifstream ifs("in.txt");
  cin.rdbuf(ifs.rdbuf());
#endif
  int K;
  while (cin >> S >> K) {
    memset(dp, -1, sizeof(dp));
    cout << solve(0, S.size() - 1, K) << endl;
  }
  return 0;
}


Measured memory_bytes: 116608
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		int n;
		Scanner scan = new Scanner(System.in);
		n=scan.nextInt();
		
		for(int i = 1;i<=n;i++){
			int x = i;
			if(x%3==0){
				System.out.print(" "+i);
			}
			else{
				while(x!=0){
					if(x%10==3){
						System.out.print(" "+i);
						break;
					}
					x/=10;
				}
			}
		}
		System.out.println();
	}
}


Measured memory_bytes: 28768
N = int(input())
D = list(map(int, input().split()))
M = int(input())
T = list(map(int, input().split()))
D.sort()
T.sort()
i = 0
for t in T:
    while i < N:
        if D[i]==t:
            i+=1
            break
        else:
            i+=1
    else:
        print("NO")
        exit()
print("YES")


Measured memory_bytes: 34024
n=int(input())
s=[input() for _ in range(n)]
 
 
 
count={}
for i in range(n):
    if s[i] not in count:
        count[s[i]] = 1
    else:
        count[s[i]] += 1
 
max = max(count.values())
ans = []
for word in count:
    if count[word] == max:
        ans.append(word)
#ans = [k for k,v in count.items() if v == max]
ans.sort()
for i in ans:
    print(i)


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

vector<int> a1;
vector<int> a2;
int n = 0;
void chmax(int &a, int b) { if (a < b) a = b; }

int dfs(int i, bool isDowned)
{
    if(i == n-1)
    {
        if(isDowned) return a2[i];
        else return a1[i] + a2[i];
    }
    
    int ans = 0;

    if(!isDowned)
    {
        chmax(ans, dfs(i+1, true) + a1[i] + a2[i] );
        chmax(ans, dfs(i+1, isDowned) + a1[i] );
    }
    else chmax(ans, dfs(i+1, isDowned) + a2[i] );

    return ans;
}

int main()
{
    cin >> n;
    vector<int> tmp;
    rep(i,n*2)
    {
        int s;
        cin >> s;
        tmp.push_back(s);
    }
    //rep(i,n) cout << tmp[n+i] << endl;
    rep(i,n) a1.push_back(tmp[i]);
    rep(i,n) a2.push_back(tmp[i+n]);
    //rep(i,n) cout << a1[i] << " " << a2[i] << endl;

    cout << dfs(0, false) << endl;
}


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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define SPEED ios_base::sync_with_stdio(false);cin.tie(nullptr)
#define rep(i,n) for(int i=0; i<(int)(n); 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; }

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

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
constexpr double PI = 3.14159265358979323846;
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  SPEED;
  int n, d; cin >> n >> d;
  auto r = (n+2*d)/(2*d+1);
  cout << r << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a, b, c, d, e;
	scanf("%d", &a);
	for (e = 1; e <= a; e++)
	{
		scanf("%d %d", &b, &c);
		d = b%c;
		if (d == 0)
			printf("%d\n", c);
		else
			printf("%d\n", d);
	}
	return 0;
	
}

Measured memory_bytes: 596