akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

class Direct_Graph {
    public:
    struct Edge { 
        int to; long long cost;
    };
    std::vector<std::vector<Edge>> G;
    int node_num;
    Direct_Graph() {}
    Direct_Graph(const int node_num_in) {
        node_num = node_num_in;
        G.resize(node_num);
    }
    void add_edge(const int from, const int to, const long long cost) {
        Edge edge; edge.to = to; edge.cost = cost;
        G[from].push_back(edge);
    }
    void add_edge_both(const int node1, const int node2, const long long cost) {
        add_edge(node1, node2, cost);
        add_edge(node2, node1, cost);
    }

    std::vector<long long> Dijkstra(int s, const long long dist_inf) {
        std::vector<long long> dist; dist.resize(node_num);
        for (int i = 0; i < dist.size(); i++) {
            dist[i] = dist_inf;
        }
        typedef std::pair<long long, int> Pair;

        std::priority_queue <Pair, std::vector<Pair>, std::greater<Pair>> que;
        dist[s] = 0;
        que.push(Pair(0, s));

        while (!que.empty()) {
            Pair pair = que.top(); que.pop();
            int v = pair.second;
            if (dist[v] < pair.first) { continue; }
            for (Edge edge : G[v]) {
                if (dist[v] + edge.cost < dist[edge.to]) {
                    dist[edge.to] = dist[v] + edge.cost;
                    que.push(Pair(dist[edge.to], edge.to));
                }
            }
        }
        return dist;
    }
};

const long long MAX_K = 100000;
long long K;

Direct_Graph dg = Direct_Graph(MAX_K + 1);

int main(int argc, char **argv) {
    std::cin >> K;

    for (int i = 0; i < K; i++) {
        dg.add_edge(i, i + 1, 1);
    }

    for (int i = 1; i < K; i++) {
        if ((i * 10) % K == 0) {
            dg.add_edge(i, K, 0);
        } else {
            dg.add_edge(i, (i * 10) % K, 0);
        }
    }

    std::vector<long long> dist = dg.Dijkstra(0, MAX_K);

    std::cout << dist[K] << std::endl;

    //return 0;

}


Measured memory_bytes: 9208
from collections import deque

N = int(input())

node = [[] for _ in range(N + 1)]

for u, v, w in [map(int, input().split()) for _ in range(N - 1)]:
    node[u].append((v, w % 2 == 0))
    node[v].append((u, w % 2 == 0))


color = [-1] * (N + 1)
Q = deque()
for n, p in node[1]:
    Q.append((n, p, 1))

color[1] = 0

while Q:
    a, b, cur = Q.popleft()
    if b:
        color[a] = color[cur]
    else:
        color[a] = 1 - color[cur]

    for n, p in node[a]:
        if color[n] == -1:
            Q.append((n, p, a))

print(*color[1:], sep="\n")



Measured memory_bytes: 71660
/**
 * C - Same Integers
 * https://atcoder.jp/contests/abc093/tasks/arc094_a
 **/
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int main() {
    vector<int> ABC(3);
    for(int i=0; i<3; i++) cin >> ABC[i];
    sort(ABC.begin(), ABC.end());
    int ans = 0;
    ans += (ABC[2] - ABC[1]);
    if((ABC[1]-ABC[0])%2==0) {
        ans += (ABC[1]-ABC[0])/2;
    } else {
        ans += (ABC[1]-ABC[0]+1)/2 + 1;
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
using namespace std;
typedef long long ll;

const int INF = 1001001001;

int main() {
    int n; cin >> n;
    vector<double> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }

    vector<vector<double>> load(n, vector<double>(n));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            double dis_x = x[i] - x[j];
            double dis_y = y[i] - y[j];
            load[i][j] = sqrt(dis_x*dis_x+dis_y*dis_y);
        }
    }
    
    vector<int> a(n);
    for (int i = 0; i < n; i++)
    {
        a[i] = i;
    }
    
    double sum = 0;
    do {
        for (int i = 1; i < n; i++)
        {
            sum += load[a[i-1]][a[i]];
        }
        
    } while (next_permutation(a.begin(), a.end()));
    double ans = sum;
    for (int i = 0; i < n; i++)
    {
        ans /= i+1;
    }
    
    printf("%.8lf\n", ans);
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
void chmax(LL& a, LL b) {
	a = max(a, b);
}
void chmin(LL& a, LL b) {
	a = min(a, b);
}
//////////////
vector<LL> cal(LL A) {
	vector<LL> ans;
	for (LL i = 1; i * i <= A; ++i) {
		if (A % i == 0) {
			ans.push_back(i);
			ans.push_back(A/i);
		}
	}
	return ans;
}
int ket(LL A) {
	int ans = 0;
	while (A) {
		++ans;
		A /= 10;
	}
	return ans;
}
void solve() {
	LL N;
	cin >> N;
	vector<LL>A = cal(N);
	int len = A.size();

	LL ans = LINF;
	for (int i = 0; i < len; ++i) {
		LL L, R;
		L = A[i];
		R = N / A[i];
		chmin(ans, max(ket(L), ket(R)));
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>
#include <map>
#include <vector>
#include <list>
#include <cmath>
#include <stack>
#include <queue>
#include <climits>
#include <string.h>
#include <cctype>
#include <set>

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

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

// a と b の最大公約数を返す関数
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}

long long gcd(long long a, long long b)
{
	if (a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

long long lcm(long long a, long long b)
{
	return a * b / gcd(a, b);
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
} comb(2000005);

mint g(int r, int c) {
	return comb(r + c + 2, r + 1) - 1;
}

bool comp(int i, int j) {
	return i > j;
}

bool compare_by_b(pair<int, int> a, pair<int, int> b) {
	return a.second < b.second;
}
vector<vector<int>> dd;

int main()
{
	int n, k;
	cin >> n >> k;
	int okasi[100];
	for (int i = 0; i < n; i++)
	{
		okasi[i] = 0;
	}
	for (int i = 0; i < k; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int dd;
			cin >> dd;
			okasi[dd - 1]++;
		}
	}

	int count = 0;
	for (int i = 0; i < n; i++)
	{
		if (okasi[i] == 0)
		{
			count++;
		}
	}
	cout << count;
}



Measured memory_bytes: 34208
n = gets.chomp.to_i
x_y_arr = n.times.map{gets.chomp.split(" ").map(&:to_i)}

hash = {}
x_y_arr.each_with_index do |(x, y), i|
  x_y_arr.each_with_index do |(x2, y2), i2|
    next if i == i2
    diff_x = x - x2
    diff_y = y - y2
    hash[[diff_x, diff_y]] ||= 0
    hash[[diff_x, diff_y]] += 1
    #hash[[-diff_x, -diff_y]] ||= 0
    #hash[[-diff_x, -diff_y]] += 1
  end
end

if hash.size == 0 then
  puts 1
else
  puts n - hash.values.max
end


Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define mod 1000000007
#define pb push_back
#define ff first
#define ss second
#define ii pair<int,int>
#define vi vector<int>
#define vii vector<ii>
#define lli long long int
#define int long long
#define MAX         2000000000000000000
#define re(i,x,n) for(i=x;i<=n;i++)
typedef long long ll;
using namespace std;
void c_p_c()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
#ifndef  ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
vi graph[200001];
int vis[200001] = {0};
int cost[100001];
int parent = -1;
int costi ;
void dfs(int i)
{
	vis[i] = 1;
	costi = min(cost[i], costi);
	//cout << costi << endl;
	for (auto &it : graph[i])
	{
		if (vis[it] == 0) {

			dfs(it);

		}
	}

}
int pp[100001];
bool isPrime(int n)
{
	int i;
	for (i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
//
int32_t main()
{
	//c_p_c();
	char ch;
	cin >> ch;
	if (isupper(ch))
		cout << "A";
	else
		cout << "a";
}

Measured memory_bytes: 8312
#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 main() {
  ll n;
  int k, ans = 0, h;

  cin>>n>>k;
  for(int i=0; i<n; i++) {
    cin>>h;
    if (h>=k) ans++;
  }
  cout<<ans<<endl;

  return 0;
}

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

using namespace std;

int main()
{
    string S;
    int64_t K;
    cin >> S >> K;
    
    for(size_t i=0; i<S.size(); i++) {
        if(S[i] == 'a') continue;
        if(K >= 'z'-S[i]+1) {
            K -= ('z'-S[i]+1);
            S[i] = 'a';
        }
    }
    if(K > 0) {
        char c = ((S.back() - 'a') + K) % 26;
        S.back() = c+'a';
    }
    cout << S << endl;
}


Measured memory_bytes: 512
<?php

fscanf(STDIN, "%d %d %d %d", $tHp, $tAtt, $aHp, $aAtt);

while (true) {
    $aHp = $aHp - $tAtt;

    if ($aHp <= 0) {
        echo "Yes\n";
        exit;
    }

    $tHp = $tHp - $aAtt;

    if ($tHp <= 0) {
        echo "No\n";
        exit;
    }
}


Measured memory_bytes: 16200
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <climits>
#include <cmath>
#include <map>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++ )
#define repf(i,m,n) for(int (i)=m;(i)<n;(i)++)
#define all(v) (v).begin(), (v).end()
#define ll long long
#define vec(name,num) vector<ll> name((num),0);
#define op(i) cout<<(i)<<endl;
#define ip(i) cin>>(i);
#define opN cout<<"No"<<endl;
#define opY cout<<"Yes"<<endl;
#define opP cout<<"Possible"<<endl;
#define opI cout<<"Impossible"<<endl;
#define mat(name,fnum,snum); vector<vector<ll>> name((fnum),vector<ll>((snum),0));
#define debugP int debug_point; cin>>debug_point;
const ll MOD= 1e9 + 7;
template <typename T>
void putv(vector<T>& V){
	// cout << "The elements in the vector are: " << endl;
	for(auto x: V)
		cout << x << " ";
	cout << endl;
}
template <class T>
vector<T> getv(ll n){
	vector<T> Vector_temp;
	rep(i,n){
		T input;
		cin >> input;
		Vector_temp.emplace_back(input);
	}
	return Vector_temp;
}
ll gcd(ll c,ll b){
    while(1){
        if(c%b!=0){
        ll tmp=b;
        b=c%b;
        c=tmp;
        }else{
            return b;
        }
    }
}
/* <3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3<3*/


int main(){
    ll n;
    cin>>n;
    ll dp[101][4][4][4]={};
    rep(k,4){
            rep(i,4){
                rep(j,4){
                    rep(l,101){
                        dp[l][i][j][k]=0;
                    }
                }
            }
    }
    rep(i,4){
        rep(j,4){
            rep(k,4){
                if((i==0&&j==2&&k==1)||(i==0&&j==1&&k==2)||(i==2&&j==0&&k==1)){
                    continue;
                }
                dp[0][i][j][k]++;
                
            }
        }
    }
    repf(p,1,n-2){
        rep(k,4){
            rep(i,4){
                rep(j,4){
                    rep(l,4){
                        if((i==0&&j==2&&k==1)||(i==0&&j==1&&k==2)||(i==2&&j==0&&k==1)||(l==0&&i==2&&(k==1))||(l==0&&j==2&&k==1)){
                            continue;
                        }
                        dp[p][i][j][k]+=(dp[p-1][l][i][j]%MOD);
                    }
                }
            }
        }
    }
    ll sum=0;
    rep(k,4){
        rep(i,4){
            rep(j,4){
                sum+=dp[n-3][i][j][k];
                sum%=MOD;
            }
        }
    }
    op(sum);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int N;
    cin >> N;
    
    double inv = 0.0;
    for (int i = 0; i < N; i++) {
        int a;
        cin >> a;
        inv += (1.0 / (double)a);
    }
    
    cout << 1.0 /  inv << endl;
    
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    ll K,S,ans=0;
    cin >>K>>S;
    for(int X =0; X <= K; X++){
        for(int Y=0; Y <= K; Y++){
            int Z =S-X-Y;
            if(0<=Z && Z<=K){
                ans++;
                
            }
        }
    }
    cout << ans << endl;
}


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

const string YES = "Yes";
const string NO = "No";

void solve(long long X){
    if(X >= 30) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long X;
    scanf("%lld",&X);
    solve(X);
    return 0;
}


Measured memory_bytes: 3676
#include <bits/stdc++.h>
using namespace std;
int n, a[100005], b[100005], c[100005];
long long dp[100005][5];
int main(){
	scanf("%d", &n);
	for (int i=1;i<=n;i++){
		scanf("%d%d%d", &a[i], &b[i], &c[i]);
	}
	
	for (int i=1;i<=n;i++){
		dp[i][1] = max(dp[i-1][2]+a[i], dp[i-1][3]+a[i]);
		dp[i][2] = max(dp[i-1][1]+b[i], dp[i-1][3]+b[i]);
		dp[i][3] = max(dp[i-1][1]+c[i], dp[i-1][2]+c[i]);
	}
	
	long long ans = max(dp[n][1], max(dp[n][2], dp[n][3]));
	printf("%lld\n", ans);
}

Measured memory_bytes: 5376
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

n = inn()
ab = []
for i in range(n):
    a,b = inm()
    ab.append((a+b,a,b))
ab.sort(reverse=True)
sm = 0
for i in range(n):
    if i%2==0:
        sm += ab[i][1]
    else:
        sm -= ab[i][2]
print(sm)


Measured memory_bytes: 62552
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int main()
{
    int64_t N, M, S;
    cin >> N >> M;
    for (int64_t i = 0; i < M; i++)
    {
        cin >> S;
        N = N - S;
    }

    if (N < 0) {
        cout << "-1" << endl;
    } else {
        cout << N << endl;
    }


    return 0;
}

Measured memory_bytes: 3624
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H = sc.nextInt();
        int W = sc.nextInt();
        int[] num = new int[26];
        for (int i = 0; i < H; i++) {
            String s = sc.next();
            for (int j = 0; j < W; j++) {
                num[s.charAt(j)-'a']++;
            }
        }

        boolean ans = true;
        if (H%2 == 0 && W%2 == 0) {
            for (int i = 0; i < 26; i++) {
                if (num[i] != 0 && num[i]%4 != 0) {
                    ans = false;
                    break;
                }
            }
        } else if (H%2 == 1 && W%2 == 1) {
            int num4 = (H-1)*(W-1)/4;
            for (int i = 0; i < 26; i++) {
                if (num[i] >= 4) {
                    int a = Math.min(num[i]/4, num4);
                    num[i] -= a*4;
                    num4 -= a;
                }
            }
            int num2 = ((H-1)+(W-1))/2;
            for (int i = 0; i < 26; i++) {
                if (num[i] >= 2) {
                    int a = Math.min(num[i]/2, num2);
                    num[i] -= a*2;
                    num2 -= a;
                }
            }
            int others = 0;
            for (int i = 0; i < 26; i++) {
                others += num[i];
            }
            ans = num4 == 0 && num2 == 0 && others == 1;
        } else {
            int odd = H%2 == 1 ? H : W;
            int even = H%2 == 1 ? W : H;

            int num4 = (odd-1)*even/4;
            for (int i = 0; i < 26; i++) {
                if (num[i] >= 4) {
                    int a = Math.min(num[i]/4, num4);
                    num[i] -= a*4;
                    num4 -= a;
                }
            }
            int num2 = even/2;
            for (int i = 0; i < 26; i++) {
                if (num[i] >= 2) {
                    int a = Math.min(num[i]/2, num2);
                    num[i] -= a*2;
                    num2 -= a;
                }
            }
            ans = num4 == 0 && num2 == 0;
        }
        System.out.println(ans ? "Yes" : "No");
    }
}


Measured memory_bytes: 23892
n = int(input())
a = list(map(int, input().split()))
b = [0]*n
for i in range(n):
    if i % 2 == 0:
        b[n//2+i//2] = a[i]
    else:
        b[n//2-i//2-1] = a[i]
        
if n % 2 == 1:
    b = b[::-1]

if len(b) == 1:
    print(b[0])

else:
    for i in range(len(b)-1):
        print(b[i], end=" ")
    print(b[i+1])

Measured memory_bytes: 26180
#include<stdio.h>
#include<math.h>
int D,N;
/*int dis(int y[N][D],int z[N][D]){
  int i,k=0;
  double x;
  for(i=0;i<D;i++)
    x+=pow(y[][i]-z[][i],2);
  x = sqrt(x);
  if(x-(int)x == 0.0)
    return 1;
  else
    return -1;
}*/

int main(){
  int i,j,k=0,N,ans=0;
  double x;
  scanf("%d %d",&N,&D);
  double y[N][D];
  for(i=0;i<N;i++){
    for(j=0;j<D;j++)
      scanf("%lf",&y[i][j]);
  }
  
  for(i=0;i<N;i++){
    for(j=i+1;j<N;j++){
      x=0;
      for(k=0;k<D;k++){
        x+=pow(y[i][k]-y[j][k],2);
      }
      x=sqrt(x);
      //printf("%lf\n",x);
      if(ceil(x) == floor(x))
        ans++;
    }
  }
  
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 128
n  = int(input())

ren = 0

for i in range(n):

     a, b = (int(x) for x in input().split())

     if a == b:
        ren += 1 

     elif ren >= 3:
         continue
    
     else: 
        ren = 0

if ren >= 3:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 8944
#include<bits/stdc++.h>
using namespace std;
#define h first
#define w second
vector<pair<bool,pair<int,int> > >v;
int n,m,p,q,r,i;
void Vp(bool a,int b,int c){v.push_back(make_pair(a,make_pair(b,c)));}
int main(){
	while(cin>>n&&n){
	cin>>m>>p>>q>>r;v.clear();
	Vp(1,1,r);Vp(0,r+1,n);
	while(m--){
		int x,y;cin>>x>>y;
		for(i=0;i<v.size();i++){
			int a=v[i].w.h,b=v[i].w.w;bool c=v[i].h;
			if(a<=x&&x<b){Vp(c,x+1,b);b=x;}
			if(a<=y&&y<b){Vp(c,y+1,b);b=y;}
			if(0<a&&b<=x)a+=n-x,b+=n-x;
			else if(x<a&&b<=y)a+=n-x-y,b+=n-x-y;
			else if(y<a&&b<=n)a-=y,b-=y;
			v[i].w.h=a,v[i].w.w=b;
		}
	}n=0;
	for(i=0;i<v.size();i++)if(v[i].h)n+=max(0,1+min(v[i].w.w,q)-max(v[i].w.h,p));
	cout<<n<<endl;
	}
	return 0;
}

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

#define INF 0x3f3f3f3f
typedef long long ll;
using namespace std;

const int N = 500000 + 105;
set<int>se[30];
int main(){
    int n;
    string s; cin>>n>>s;
    for(int i = 0; i < n; ++i){
        se[s[i] - 'a'].insert(i);
    }
    int m, op, l, r, sum = 0; cin>>m;
    char c;
    for(int i = 1; i <= m; ++i){
        cin>>op;
        if(op == 1){
            cin>>l>>c; --l;
            se[s[l] - 'a'].erase(l);
            se[c - 'a'].insert(l);
            s[l] = c;
        }
        else{
            cin>>l>>r; --l, --r; sum = 0;
            for(int j = 0; j < 26; ++j){
                auto flag = se[j].lower_bound(l);
                if(flag == se[j].end()) continue;
                if(*flag <= r) ++sum;
            }
            printf("%d\n", sum);
        }
    }
    // system("pause");
}

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

#define cn count
#define pb push_back
#define in insert
#define fs first
#define sc second
#define sz size
#define len length
#define forn(i, n) for (ll i = 0; i < (ll) (n); ++i)
#define forni(i, n) for (ll i = 1; i < (ll) (n); ++i)
#define IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

using namespace std;
using ll = long long;
const ll inf = 1e5; 
const double PI =  3.141592653589793;

int main(){
	IO;
	ll k,x;
	cin>>k>>x;
	(k*500<x)?cout<<"No\n":cout<<"Yes\n";
	return 0;
}


// _   .-')                .-. .-')                 .-')                                               
//( '.( OO )_              \  ( OO )               ( OO ).                                             
// ,--.   ,--.).-'),-----. ,--. ,--.  .-'),-----. (_)---\_) ,--. ,--.     .-----.  ,-.-')  .-'),-----. 
// |   `.'   |( OO'  .-.  '|  .'   / ( OO'  .-.  '/    _ |  |  | |  |    '  .--./  |  |OO)( OO'  .-.  '
// |         |/   |  | |  ||      /, /   |  | |  |\  :` `.  |  | | .-')  |  |('-.  |  |  \/   |  | |  |
// |  |'.'|  |\_) |  |\|  ||     ' _)\_) |  |\|  | '..`''.) |  |_|( OO )/_) |OO  ) |  |(_/\_) |  |\|  |
// |  |   |  |  \ |  | |  ||  .   \    \ |  | |  |.-._)   \ |  | | `-' /||  |`-'| ,|  |_.'  \ |  | |  |
// |  |   |  |   `'  '-'  '|  |\   \    `'  '-'  '\       /('  '-'(_.-'(_'  '--'\(_|  |      `'  '-'  '
// """    """     """""""" """  """"      """""""  """""""  """"""""      """"""   """         """""""



Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
int main(){
    string A,B,C;
    cin >> A >>B >>C;
    A[0] = A[0] - 0x20;
    B[0] = B[0] - 0x20;
    C[0] = C[0] - 0x20;
    cout << A[0] << B[0] << C[0] << endl;
}

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

f = 0

for a in range(100):
    for b in range(100):
        x = a + b
        y = 2 * a + 4 * b
        if x == X and y == Y:
            f = 1
            break

    if f == 1:
        break

print(['No', 'Yes'][f])

Measured memory_bytes: 9180
#include <cstdio>
#include <cstring>
#include <climits>
#include <iostream>
#include <utility>
#include <vector>

const int N = 5000;
const int M = 200;

using Stack = std::vector<std::pair<int, int>>;
int n;
long long sum[N], delta[N << 1], maximum[N << 1];
Stack stack[M];

int get_id(int l, int r)
{
    return l + r | l != r;
}

void add(int l, int r, int a, int b, long long c)
{
    if (b < l || r < a) {
        return;
    }
    int id = get_id(l, r);
    if (a <= l && r <= b) {
        delta[id] += c;
        maximum[id] += c;
    } else {
        int m = l + r >> 1;
        add(l, m, a, b, c);
        add(m + 1, r, a, b, c);
        maximum[id] = std::max(maximum[get_id(l, m)], maximum[get_id(m + 1, r)]) + delta[id];
    }
}

void update(Stack& s, int k, int b)
{
    int last = 0;
    while (s.back().first <= b) {
        // printf("+ %d %d %d\n", s.back().second + 1, k, s.back().first - last);
        add(0, n - 1, s.back().second + 1, k, s.back().first - last);
        last = s.back().first;
        s.pop_back();
    }
    // printf("+ %d %d %d\n", s.back().second + 1, k, b - last);
    add(0, n - 1, s.back().second + 1, k, b - last);
    s.emplace_back(b, k);
}

const long long INF = 1000000000000000000LL;

int main()
{
#ifdef LOCAL_JUDGE
    freopen("F.in", "r", stdin);
#endif
    int m;
    while (scanf("%d%d", &n, &m) == 2) {
        sum[0] = 0;
        for (int i = 1; i < n; ++ i) {
            int a;
            scanf("%d", &a);
            sum[i] = sum[i - 1] + a;
        }
        memset(delta,   0, sizeof(delta));
        memset(maximum, 0, sizeof(maximum));
        for (int j = 0; j < m; ++ j) {
            stack[j] = { { INT_MAX, -1 } };
        }
        add(0, n - 1, 0, n - 1, -INF);
        long long result = 0;
        for (int i = 0; i < n; ++ i) {
            for (int j = 0; j < m; ++ j) {
                int b;
                scanf("%d", &b);
                update(stack[j], i, b);
            }
            add(0, n - 1, i, i, INF + sum[i]);
            // printf("%d %lld\n", i, maximum[get_id(0, n - 1)]);
            result = std::max(result, -sum[i] + maximum[get_id(0, n - 1)]);
        }
        std::cout << result << std::endl;
    }
}


Measured memory_bytes: 640
INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    print(n**3/27)
    
if __name__ == '__main__':
    do()

Measured memory_bytes: 3060
import sys
h, w = [int(i) for i in sys.stdin.readline().split()]
s_ls = []
for i in range(h):
    s = [i for i in sys.stdin.readline().strip()]
    s_ls.append(s)

def check(y, x):
    flg = False
    for move_y, move_x in [(0,1), (0,-1), (1,0), (-1,0)]:
        next_y = max(0, min(h-1, y + move_y))
        next_x = max(0, min(w-1, x + move_x))
        flg |= s_ls[next_y][next_x] == "#"
    return flg

flg = True
for i in range(h):
    for j in range(w):
        if s_ls[i][j] == "#":
            flg &= check(i, j)
print("Yes" if flg else "No")

Measured memory_bytes: 41584
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

N = int(input())


def dfs(s):
    if int(s) > N:
        return 0
    if all(s.count(c) > 0 for c in '753'):
        ret = 1
    else:
        ret = 0
    for c in '753':
        ret += dfs(s + c)
    return ret


def main():

    print(dfs('0'))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
#include <iostream>
#include <cstdint>
#include <cmath>

using int64 = std::int64_t;

int main() {
  int64 X, K, D, x; // initial position, time of act, distance per move
  std::cin >> X >> K >> D;

  if(X > 0) x = X;
  else x = -X;

  int64 min_step = x / D;
  if(min_step >= K) min_step = K;
  else if(0 < (x - D * min_step) / 2) min_step++;

  int64 remaining_step = K - min_step;
  x -= D * min_step;

  if(remaining_step % 2 == 1) {
    if(x > 0) x -= D;
     x += D;
  }

  std::cout << std::abs(x) << std::endl;

  return 0;
}


Measured memory_bytes: 3616
#include<cstring>
#include<string>
#include<vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<complex>
#include<sstream>
#include<climits>

#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int MAX_N = 50;
const ll INF = 1e18;
int N;
ll a[MAX_N];

int main() {
  cin >> N;
  rep(i, N) cin >> a[i];

  ll lb = -1, ub = INF, mid;
  while (ub-lb > 1) {
    mid = (ub+lb)/2;
    ll k = 0;
    for (int i = 0; i < N; ++i) {
      k += (a[i]+mid+1)/(N+1);
    }
    if (k <= mid) ub = mid;
    else lb = mid;
  }

  ll ans = ub;
  for (ll i = lb; i >= lb-1e5 && i >= 0; --i) {
    ll k = 0;
    for (int j = 0; j < N; ++j) {
      k += (a[j]+i+1)/(N+1);
    }
    if (k <= i) ans = i;
  }

  cout << ans << endl;

  return 0;
}


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

#define M 1046257
#define NIL (-1)
#define L 14

char H[M][L];

// 文字から数値に変換
int getChar(char ch) 
{
  if ( ch == 'A' ) return 1;
  else if ( ch == 'C' ) return 2;
  else if ( ch == 'G' ) return 3;
  else if ( ch == 'T' ) return 4;
  return 0;
}

// 文字列から数値へ変換して key を生成する
long long getKey(char str[]) 
{
  long long sum =0, p = 1, i;
  for(i=0;i<strlen(str);i++) {
    sum += p*(getChar(str[i]));
    p*= 5;
  }

  return sum;
}

int h1(int key){ return key % M; }
int h2(int key){ return 1 + (key % (M-1)); }

int find(char str[]) 
{
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換

  for(i=0; ;i++)
  {
    h = (h1(key) + i*h2(key)) %M;
    if( strcmp(H[h],str) == 0) return 1;
    else if ( strlen(H[h]) == 0 ) return 0;
  }

  return 0;
}

int insert(char str[]) 
{
  long long key, i, h;
  key = getKey(str); // 文字列を数値に変換
  for(i=0; ; i++) 
    {
    h = (h1(key) + i * h2(key)) %M;
    if(strcmp(H[h],str) == 0) return 1;

    else if(strlen(H[h]) == 0) 
      {
      strcpy(H[h],str);
      return 0;
      }
    }

  return 0;
}

int main(void) 
{
  int i, n;
  char str[L], com[9];
  for(i=0;i<M;i++) H[i][0] = '\0';
  scanf("%d",&n);
  for(i=0;i<n;i++) 
  {
    scanf("%s %s",com,str); // より高速なscanfを使用
    if(com[0] == 'i') 
    {
      insert(str);
    } 
    
    else 
    {
      if(find(str))
      {
        printf("yes\n");
      } 
      
      else 
      {
        printf("no\n");
      }
    }
  }
  
  return 0;
}


Measured memory_bytes: 16092
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner cin = new Scanner(System.in);
		while(true){
			int n = cin.nextInt();
			if(n==0){
				break;
			}
			else if(n==1){
				System.out.println("deficient number");
				continue;
			}
			int sum=1;
			for(int i = 2; i*i <= n; i++){
				if(n%i==0){
					sum+=i;
					if(i != n/i){
						sum+=n/i;
					}
					//System.out.println(i + " " + n/i);
				}
				
			}
			
			if(n>sum){
				System.out.println("deficient number");
			}
			else if(n==sum){
				System.out.println("perfect number");
			}
			else{
				System.out.println("abundant number");
			}
		}
		
	}

}

Measured memory_bytes: 12000
# https://atcoder.jp/contests/abc090/tasks/arc091_b

import itertools
import collections
import bisect


def main():
    N, K = map(int, input().split())
    ans = 0
    for b in range(K+1, N+1):
        p = N // b
        r = N - b * p
        tmp = p * (b - K) + max(0, r - K + 1)
        # print("b = {}, c = {}, p = {}, tmp = {}".format(b, b - K, p, tmp))
        ans += tmp

    if K == 0:
        ans -= N

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3444
n, m = map(int, input().split())
x = list(map(int, input().split()))

if n >= len(x):
    print(0)
else:
    x = sorted(x)
    diff = [x[i + 1] - x[i] for i in range(len(x) - 1)]
    diff = sorted(diff)
    diff = diff[0:len(diff) - n + 1]
    print(sum(diff))

Measured memory_bytes: 13968
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1.19e18+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<lldo>&ar,lldo in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<lldo>&ar,lldo in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int n,i;cin>>n;
	vector<int>aa(n);
	for(i=0;i<n;i++){cin>>aa[i];}
	SO(aa);
	cout<<aa[n-1];
	int aaa=aa[n-1];
	llint sai=big,sre=-1;
	for(i=0;i<n;i++){
		if(sai>abs(aaa-aa[i]-aa[i])){sai=abs(aaa-aa[i]-aa[i]);sre=aa[i];}
	}
	cout<<" "<<sre<<endl;
	return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007

int C[26];
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  string S;
  cin >> S;
  for (char c : S) C[c-'a']++;
  int N = S.length();
  long long s = 1LL*N*(N-1);
  rep(i, 26) s -= 1LL*C[i]*(C[i]-1);
  s /= 2;
  s += 1;
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 720
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using ll = long long;
using namespace std;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int N;
char s;
int main(){
    cin >> N;
    set<char> st;
    rep(i,N) cin >> s, st.insert(s);
    if(sz(st)==4) pr("Four");
    else pr("Three");
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int H,W,i,j;
	while(1){
		scanf("%d %d",&H,&W);
		if(H==0&&W==0){
			break;
		}
		for(i=0;i<H;i++){
			for(j=0;j<W;j++){
				printf("#");
			}
		    printf("\n");
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 572
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;
L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
  d=I->first,!Z[d]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,Z[d]=1,D(d),Z[f]+=Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--*Z,--n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(D(a=0);Z[n];a=H[P[++n]]-n?n:0)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
double dp[325][325][325];

double dfs(int i, int j, int k){
  if(dp[i][j][k] != -1)return dp[i][j][k];
  int rest = i+j+k;
  double p = (double)rest / n;
  dp[i][j][k] = 0.0;
  if(i>0)dp[i][j][k] += (dfs(i-1,j,k)   + 1.0/p) * i / rest;
  if(j>0)dp[i][j][k] += (dfs(i+1,j-1,k) + 1.0/p) * j / rest;
  if(k>0)dp[i][j][k] += (dfs(i,j+1,k-1) + 1.0/p) * k / rest;
  return dp[i][j][k];
}

int main(){
  scanf("%d",&n);
  int a1=0, a2=0, a3=0;
  REP(i,n){
    int a;
    scanf("%d",&a);
    if(a==1)a1++;
    if(a==2)a2++;
    if(a==3)a3++;
  }
  REP(i,n+1)REP(j,n+1)REP(k,n+1)dp[i][j][k] = -1;
  dp[0][0][0] = 0.0;
  printf("%.9f\n",dfs(a1,a2,a3));
  return 0;
}


Measured memory_bytes: 250112
#include <bits/stdc++.h>
using namespace std;
long long run(int x[],int num)
{
	int res;
	res=__gcd(x[0],x[1]);
	for(int i=1;i<=num-1;i++)
		res=__gcd(res,x[i]);
	return res;
}
long long check(int a,int b,int c)
{
	int x[5];
	x[0]=a;
	x[1]=b;
	x[2]=c;
	return run(x,3);
}
int main()
{
	int n,sum=0;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=n;j++)
		{
			for(int k=1;k<=n;k++)
				sum+=check(i,j,k);
		}
	}
	cout<<sum;

	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define pb push_back
#define ALL(obj) (obj).begin(), (obj).end()      //昇順
#define RALL(obj) (obj).rbegin(), (obj).rend()   //降順
#define print(obj) cout << obj << endl
#define scan(obj) cin >> obj

typedef long long ll;

using namespace std;

int main(void){
    int n;
    cin >> n;
    double ans = 0;
    rep(i, n){
        string s;
        double temp;
        cin >> temp >> s;
        if(s == "JPY"){
            ans += temp;
        } else{
            ans += temp * 380000.0;
        }
    }
    print(ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include <set>
#include<algorithm>
#include<string.h>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  long long int a,b,k;
  scanf("%lld%lld%lld",&a,&b,&k);
  for(int i=0;i<k;i++){
    if(i%2==0){
      if(a%2==1){
        a--;
      }
      b += (a/2);
      a /= 2;
    }else{
      if(b%2==1){
        b--;
      }
      a += (b/2);
      b /= 2;
    }
  }
  printf("%lld %lld\n",a,b);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll po(ll k ,ll n,ll ans,ll temp,ll ans1){
    if(n==0)return ans;
    while(temp<=n){
        ans*=ans1;ans%=mod;ans1=ans1*ans1;ans1%=mod;n=n-temp;temp*=2;
    }
    return po(k,n,ans,1,k)%mod;
    //eg. po(2,78,1,1,2);
}
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    //cin>>t;
    t=1;
    while(t--){
        ll x,y;
        cin>>n>>x>>y;
        vector<ll>v[n+1];
        fo1(i,n-1){
            v[i].pb(i+1);
            v[i+1].pb(i);
        }
        v[x].pb(y);
        v[y].pb(x);
        ll ans[n];
        fo(i,n)ans[i]=0;
        fo1(i,n){
            ll ifused[n+1];
            fo(i,n)ifused[i+1]=0;
            queue<pair<ll,ll> >q;
            q.push(mp(i,0));
            ifused[i]=1;
            while(q.size()){
                ll temp=q.front().fi;
                ll dis=q.front().se;
                ans[dis]++;
                q.pop();
                fo(j,v[temp].size()){
                    if(ifused[v[temp][j]]==0){
                        ifused[v[temp][j]]=1;
                        q.push(mp(v[temp][j] , dis +1));
                    }
                }
            }
        }
        fo1(i,n-1)cout<<ans[i]/2<<endl;
    }

    return 0;
}


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

using namespace std;

int main() {
	long n;
	cin >> n;
	vector<long> v(n);
	for (long i=0;i<n;++i) {
		cin >> v[i];
	}
	vector<long> ve(n/2),vo(n/2);
	for (long i=0;i<n;i+=2) {
		ve[i/2] = v[i];
		vo[i/2] = v[i+1];
	}
	vector<long> nve(pow(10,5),0);
	vector<long> nvo(pow(10,5),0);
	for (long i=0;i<n/2;++i) {
		++(nve[ve[i]-1]);
		++(nvo[vo[i]-1]);
	}
	vector<long>::iterator nve_maxIt = max_element(nve.begin(),nve.end());
	size_t nve_maxIdx = distance(nve.begin(),nve_maxIt);
	vector<long>::iterator nvo_maxIt = max_element(nvo.begin(),nvo.end());
	size_t nvo_maxIdx = distance(nvo.begin(),nvo_maxIt);
	if (nve_maxIdx != nvo_maxIdx) {
		cout << n/2-nve[nve_maxIdx]+n/2-nvo[nvo_maxIdx] << endl;
		return 0;
	}
	long mem_biggest_nve_idx = nve_maxIdx;
	long mem_biggest_nve_val = nve[nve_maxIdx];
	long mem_biggest_nvo_idx = nvo_maxIdx;
	long mem_biggest_nvo_val = nvo[nvo_maxIdx];
	nve[nve_maxIdx] = 0;
	vector<long>::iterator next_nve_maxIt = max_element(nve.begin(),nve.end());
	size_t next_nve_maxIdx = distance(nve.begin(),next_nve_maxIt);
	long nve_a = n/2-nve[next_nve_maxIdx]+n/2-nvo[nvo_maxIdx];
	nvo[nvo_maxIdx] = 0;
	vector<long>::iterator next_nvo_maxIt = max_element(nvo.begin(),nvo.end());
	size_t next_nvo_maxIdx = distance(nvo.begin(),next_nvo_maxIt);
	long nvo_a = n/2-mem_biggest_nve_val+n/2-nvo[next_nvo_maxIdx];
	long small_a = nve_a > nvo_a ? nvo_a : nve_a;
	cout << small_a << endl;
	return 0;
}

Measured memory_bytes: 3328
#!/usr/bin/env python3
import sys
try:
    from typing import List
except ImportError:
    pass


def solve(N: int, p: "List[int]"):
    ans = 0
    s = 0
    for i, pi in enumerate(p):
        if i + 1 == pi:
            s = 1 - s
            ans += s
        else:
            s = 0
    print(ans)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    p = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, p)


if __name__ == '__main__':
    main()


Measured memory_bytes: 14452
#include<cstdio>
#include<queue>
#include<climits>
#include<iostream>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<ctype.h>
#include<set>
#include<vector>
#include<map>
#define ff first
#define ss second
using namespace std;
vector <string> a[101];
map<string ,int> m;
map<string ,bool> f;
	string ss,s;
int dfs(int u)  
{  
   int ans = 0;  
   int ll= a[u].size();
   for (int i = 0; i <ll ; i++)  
   {  
       string v = a[u][i];  
       if (f[v] == 1)  
           continue;  
       f[v] = 1;  
       if (m.find(v) != m.end())  
           ans += dfs(m[v]);  
       else  
           ans += 1;    
   }  
   return ans;  
}  
int main()
{
int i,j,T,N,S,W,Q;
while (scanf("%d",&N)&&N)
{

	m.clear();f.clear();
	for (i=0;i<N;i++)
	{
		a[i].clear();
		cin>>ss;  
           bool ff = 1,o=0;
		   int   en,k=0;  
           while (ff)  
           {  
               if (!o)  
                   en = ss.find(':', k);  
               else  
               {  
                   en = ss.find(',', k);  
                   if (en == -1)  
                       {en = ss.size() - 1;ff=0;} 
               }  
               s.assign (ss,k, en - k);
//               cout<<"@"<<s;
				k=en+1;
			if (!o){
				o=1;
				m[s]=i;
				f[s]=0;
			}
			else
			{
				a[i].push_back(s); 
				f[s]=0;
			}
           }  
		/*
		a[i].clear() ;
		string s;
		scanf("%s",ss);
		j=0;
		while (ss[j]!=':') j++;
		ss[j]='\0';
		s=ss;
		m[s]=i;f[s]=0;
		bool ff=1;
		while (ff)
		{
		j++;
		T=j;
		while (ss[j]!=','&&ss[j]!='.') j++;
		if (ss[j]=='.') ff=0;
		ss[j]='\0';
		s=(ss+T);
		f[s]=0;
		a[i].push_back(s);
		
		}*/
	}
    printf("%d\n",dfs(0));
}
}
//freopen("video.in","r",stdin);
//freopen("video.out","w",stdout);

Measured memory_bytes: 1388
n = int(input())
a_list = [int(s) for s in input().split()]
b_list = [int(s) for s in input().split()]
c_list = [int(s) for s in input().split()]

manzokudo = 0
prev_a = 0

for jun in a_list:
    manzokudo = manzokudo + b_list[jun-1]
    if jun > 1:
        if jun == prev_a + 1:
            manzokudo = manzokudo + c_list[prev_a-1]
    prev_a = jun
        
print(manzokudo)


Measured memory_bytes: 3060
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>

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

int main(void) {
  string s;
  cin >> s;

  if(s[0]==s[1] && s[1]==s[2]){
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  }
  return 0;
}


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

int main(){
int n,k,q;
  cin >>n>>k>>q;
  
  vector<int> a(q);
  rep(i,q) cin>>a.at(i);
  sort(a.begin(),a.end());
  a.push_back(0);
  
  for(int i =1;i<=n;i++){
  int cnt =0;
  while(a.at(0)==i){
  cnt ++;
    a.erase(a.begin());
  }
    
    if(k-q+cnt>0)cout <<"Yes"<<endl;
    else cout << "No"<<endl;
  }

}

Measured memory_bytes: 1024
N, A = map(int, input().split())
lst = [int(x) - A for x in input().split()]
dp = [[0] * (100 * N + 1) for _ in range(N + 1)]
dp[0][50 * N] = 1
for i in range(N):
    for j in range(50, 100 * N + 1 - 50):
        dp[i + 1][j] = dp[i][j] + dp[i][j - lst[i]]
print(dp[N][50 * N] - 1)


Measured memory_bytes: 5620
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#define _USE_MATH_DEFINES
#include <cmath>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-8;
const int MOD = 1000000007;
// const int MOD = 998244353;
const int dy[] = {1, 0, -1, 0}, dx[] = {0, -1, 0, 1};
// const int dy[] = {1, 1, 0, -1, -1, -1, 0, 1},
//           dx[] = {0, -1, -1, -1, 0, 1, 1, 1};

struct IOSetup {
  IOSetup() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(10);
  }
} iosetup;
/*-------------------------------------------------*/
int main() {
  vector<string> day{"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
  string s; cin >> s;
  int idx = find(ALL(day), s) - day.begin();
  cout << 7 - idx << '\n';
  return 0;
}


Measured memory_bytes: 256