akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

using namespace std;

int main(int argc, const char * argv[]) {
    
    // source code
    long long A,B;
    cin >> A >> B;
    long long tmp;
    int i,j;

    std::vector<long long> AVec, BVec, resVec;

    long long numA = A;
    long long numB = B;

    bool divFlag;

    for (i = 2; i <= (long long)(sqrt(A))+2; i++) {
        divFlag = false;
        while (numA % i == 0) { // 素数で割り切れなくなるまで割っていく
            if(divFlag == false){
                AVec.push_back(i);
                divFlag = true;
            }
            numA /= i;
        }
    }
    if(numA>1){
        AVec.push_back(numA);
    }

//    for(i=0;i<AVec.size();i++){
//        cout << AVec.at(i) << " ";
//    }
//    cout << endl;


    for (i = 2; i <= (long long)(sqrt(B))+2; i++) {
        divFlag = false;
        while (numB % i == 0) { // 素数で割り切れなくなるまで割っていく
            if(divFlag == false){
                BVec.push_back(i);
                divFlag = true;
            }
            numB /= i;
        }
    }
    if(numB>1){
        BVec.push_back(numB);
    }

    i=0;
    j=0;
    int count = 1;
    while(i<AVec.size() && j<BVec.size()){
        if(AVec.at(i)==BVec.at(j)){
            count++;
            i++;
            j++;
        }else{
            if(AVec.at(i)>BVec.at(j)){
                j++;
            }else{
                i++;
            }
        }
    }

    cout << count;
    return 0;
}



Measured memory_bytes: 256
def main():
    n, c = map(int, input().split())
    xv = [list(map(int, input().split())) for _ in range(n)]
    v, left_max, right_max = 0, 0, 0
    gl = [None]*n
    gr = [None]*n
    _2oas = [None]*(n+1)
    _2obs = [None]*(n+1)
    _2oas[0], _2obs[0] = 0, 0
    ans = 0
    for i, (xi, vi) in enumerate(xv, 1):
        v = v + vi
        left = v - xi
        if left_max < left:
            left_max = left
        gl[n-i] = left_max
        _2oas[i] = v - 2*xi
    v = 0
    for i, (xi, vi) in enumerate(xv[::-1], 1):
        v = v + vi
        right = v - c + xi
        if right_max < right:
            right_max = right
        gr[n-i] = right_max
        _2obs[i] = v - 2*(c - xi)
    for oa, _2ob, ob, _2oa in zip(gl, _2obs[:n], gr, _2oas[:n]):
        ans = max(ans, _2oa+ob, _2ob+oa)
    print(ans)
        
if __name__ == "__main__":
    main()

Measured memory_bytes: 73176
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
typedef long long ll;
#define MOD 1000000007
using namespace std;
long long extGCD(long long a, long long b, long long &x, long long &y) {
    if(b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x); // 再帰的に解く
    y -= a / b * x;
    return d;
}

// 負の数にも対応した mod (a = -11 とかでも OK)
inline long long mod(long long a, long long m = MOD) { return (a % m + m) % m; }

// 逆元計算 (ここでは a と m が互いに素であることが必要)
long long modinv(long long a, long long m = MOD) {
    long long x, y;
    extGCD(a, m, x, y);
    return mod(x, m); // 気持ち的には x % m だが、x が負かもしれないので
}
ll modpow(ll a, ll n, ll mod = MOD) {
    ll res = 1;
    while(n > 0) {
        if(n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
vector<ll> dp;
vector<vector<int>> edge;
vector<vector<int>> bk;
int n;
ll dfs(int now, int prev) {
    if(dp[now] != -1) {
        return dp[now];
    } else {
        ll tmp = 0;
        ll add = 0;
        for(auto next : edge[now]) {
            if(next != prev) {
                add = dfs(next, now);
                bk[now].push_back(add);
                tmp += add;
            }
        }
        if(n - 1 - tmp != 0) {
            bk[now].push_back(n - 1 - tmp);
        }
        return dp[now] = tmp + 1;
    }
}
int main() {
    cin >> n;
    dp.resize(n, -1);
    edge.resize(n);
    bk.resize(n);
    for(int i = 0; i < n - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        edge[a].push_back(b);
        edge[b].push_back(a);
    }
    ll ans = 0;
    dp[0] = dfs(0, -1);
    for(int i = 0; i < n; i++) {
        ans += modpow(2, n - 1);
        ll sub = 0;
        for(auto e : bk[i]) {
            sub += modpow(2, e) - 1;
            sub %= MOD;
        }
        ans = (ans - sub - 1 + MOD) % MOD;
    }

    ans = ans * modinv(modpow(2, n)) % MOD;
    cout << ans << endl;
}

Measured memory_bytes: 42220
# -*- coding: utf-8 -*-
n1 = int(input()) - 1
d = list(map(int, input().strip().split()))
mod = 998244353
if d[0] != 0 or 0 in d[1:]:
    print(0)
else:
    max_path = max(d)
    flag = True
    v = [0 for i in range(max_path)]
    for i in d[1:]:
        v[i-1] += 1

    if 0 in v:
        flag = False

    if flag:
        num = 1
        hh = 1

        for h in v:
            num *= hh ** h
            num = num % mod
            hh = h

        print(num)

    else:
        print(0)


Measured memory_bytes: 56812
# -*- coding: utf-8 -*-

import sys
import math


debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        for line in sys.stdin:
            lines.append(line.strip())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]

    n = int(lines[0])
    ss = lines[1:]

    return (n, ss)


def solve(n, ss):


    d = dict()
    for i in range(n):
        s = ss[i]
        cnt = d.get(s, 0)
        cnt = cnt + 1
        d[s] = cnt

    result = []
    for e in ['AC', 'WA', 'TLE', 'RE']:
        result.append("%s x %d " % (e, d.get(e, 0)))
    
    return result    


def main():
    # 出力
    result = solve(*parse_input())
    if isinstance(result, list):
        for r in result:
            print("%s" % r, sep='')
    else:
        print("%s" % result, sep='')

if __name__ == '__main__':

    main()
	

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

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

//prime factorization
vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; i++) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while (n%i == 0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
}


int main() {
    ll a, b;
    cin >> a >> b;
    ll n = gcd(a, b);
    auto f = factorize(n);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}

  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
typedef long long ll;

using namespace std;

int x[100001];
int y[100001];
int t[100001];
//bool dp[100001][100001][100001];
int main()
{
	int n;
	int ans=0;
	int move;
	bool f=true;
	
	cin>>n;
	t[0]=0;
	x[0]=0;
	y[0]=0;
	for(int i=1;i<n+1;i++)
	{
		cin>>t[i]>>x[i]>>y[i];
	}
	for(int i=1;i<n+1;i++)
	{
		//cerr<<"loop "<<i<<endl;
		move=abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(move>t[i]-t[i-1])
		{
			f=false;
			break;
		}else{
			move = move - (t[i]-t[i-1]);
			if(move%2!=0)
			{
				f=false;
				break;
			}
		}
	}
	if(f==true)
	{
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
#include<cstdlib>
#include<cmath>
using namespace std;
int main(){
  int N; int M; cin>>N>>M;
  vector<int> A(N);
  int S=0;
  for(int i=0 ;i<N; i++){
    cin>>A.at(i);
    S+=A.at(i);
  }
  sort(A.begin(),A.end());
  reverse(A.begin(), A.end());
  int K=0;
  for(int i=0; i<N; i++){
    if(S%(4*M)==0){
    if(A.at(i)>=S/(4*M))
      K++;
      else break;
    }
    else{
      if(A.at(i)>=S/(4*M)+1)
        K++;
      else break;
    }
  }
  if(K>=M)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
int main(void)
{
    int n, m, c, a[20][20], b[20], i, cnt=0, j, sum=0;

    scanf("%d%d%d", &n, &m, &c);

    for(i=0;i<m;i++){
        scanf("%d", &b[i]);
    }
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            scanf("%d", &a[i][j]);
        }
    }
    
    for(i=0;i<n;i++){
        sum=0;
        for(j=0;j<m;j++){
            sum=sum+a[i][j]*b[j];
        }
        if(sum+c>0) cnt++;
    }

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


Measured memory_bytes: 128
class UnionFind
  def initialize(n)
    @n = n
    @par = Array.new(@n, -1)
    @dif = Array.new(@n, 0)
  end
  def find(x)
    @par[x] < 0 ? [x, 0] : (a, b = find(@par[x]); [@par[x] = a, @dif[x] += b])
  end
  def union(a, b, d)
    (pa, da), (pb, db) = find(a), find(b)
    return true if pa == pb && db-da == d
    return false if pa == pb
    if pa < pb then
      @par[pa] += @par[pb]
      @par[pb] = pa
      @dif[pb] += da-db+d
    else
      @par[pb] += @par[pa]
      @par[pa] = pb
      @dif[pa] += db-da-d
    end
    true
  end
end

N, M = gets.chomp.split(" ").map(&:to_i)
P = Array.new(M).map{gets.chomp.split(" ").map(&:to_i)}

uf = UnionFind.new(N)
ans = 'Yes'
P.each{|l, r, d|
  (ans = 'No'; break) if not uf.union(l-1, r-1, d)
}

puts ans


Measured memory_bytes: 33612
#include <iostream>
using namespace std;
int main ()
{
	string s;
	bool flag1 = false,flag2 = false;
	cin >> s;
	for (int i = 0;i<=s.length()-1;i++)
	{
		if (s[i] == 'C')
		{
			flag1 = true;
		}
		if (s[i] == 'F'&&flag1)
		{
			flag2=true;
		}
	}
	if (flag1&&flag2)
	{
		cout << "Yes";
		return 0;
	}
	else
	{
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

class Edge
{
public:
    int to, cost;
    Edge(){};
    Edge(int to0, int cost0){to = to0; cost = cost0;}
};

void shortestPath(const vector<vector<Edge> >& edges, const vector<int>& start, vector<int>& dist)
{
    dist.assign(edges.size(), INT_MAX);
    priority_queue<pair<int,int> ,vector<pair<int,int> >, greater<pair<int,int> > > q;
    for(unsigned i=0; i<start.size(); ++i){
        dist[start[i]] = 0;
        q.push(make_pair(0, start[i]));
    }

    while(!q.empty()){
        pair<int, int> p = q.top();
        q.pop();
        int v = p.second;
        if(dist[v] < p.first)
            continue;
        for(unsigned i=0; i<edges[v].size(); ++i){
            Edge e = edges[v][i];
            if(dist[v] + e.cost < dist[e.to]){
                dist[e.to] = dist[v] + e.cost;
                q.push(make_pair(dist[e.to], e.to));
            }
        }
    }

    replace(dist.begin(), dist.end(), INT_MAX, -1);
}

int main()
{
    int n, m, k;
    cin >> n >> m >> k;

    vector<vector<Edge> > edges(n);
    while(--m >= 0){
        int a, b, l;
        cin >> a >> b >> l;
        edges[a-1].push_back(Edge(b-1, l));
        edges[b-1].push_back(Edge(a-1, l));
    }

    vector<int> start(k);
    for(int i=0; i<k; ++i){
        cin >> start[i];
        -- start[i];
    }

    vector<int> dist;
    shortestPath(edges, start, dist);

    int ret = 0;
    for(int i=0; i<n; ++i){
        for(unsigned j=0; j<edges[i].size(); ++j){
            int a = dist[i];
            int b = dist[edges[i][j].to];
            int x = edges[i][j].cost - a + b;
            if(x < 0 || x > edges[i][j].cost * 2)
                continue;
            ret = max(ret, a + (x+1) / 2);
        }
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 3656
#include<math.h>
#include<stdio.h>
#include <stdlib.h>
int main()
{   int x,y,z,cnt=0;
    scanf("%d%d%d",&x,&y,&z);
    x-=z;
    while(x>=y+z){
        x-=(y+z);
        cnt++;
    }
    printf("%d",cnt);
    return 0;
}


Measured memory_bytes: 128
# Date [ 2020-08-29 21:01:08 ]
# Problem [ b.py ]
# Author Koki_tkg

import sys
# import math
# import bisect
# import numpy as np
# from decimal import Decimal
# from numba import njit, i8, u1, b1 #JIT compiler
# from itertools import combinations, product
# from collections import Counter, deque, defaultdict

# sys.setrecursionlimit(10 ** 6)
MOD = 10 ** 9 + 7
INF = 10 ** 9
PI = 3.14159265358979323846

def read_str():      return sys.stdin.readline().strip()
def read_int():      return int(sys.stdin.readline().strip())
def read_ints():     return map(int, sys.stdin.readline().strip().split())
def read_ints2(x):   return map(lambda num: int(num) - x, sys.stdin.readline().strip().split())
def read_str_list(): return list(sys.stdin.readline().strip().split())
def read_int_list(): return list(map(int, sys.stdin.readline().strip().split()))
def GCD(a: int, b: int) -> int: return b if a%b==0 else GCD(b, a%b)
def LCM(a: int, b: int) -> int: return (a * b) // GCD(a, b)

def Main():
    s = list(read_str())
    t = list(read_str())
    ans = INF

    for i in range(len(s) - len(t) + 1):
        tmp = 0
        for j in range(i, len(t) + i):
            if s[j] != t[j-i]:
                tmp += 1
        ans = min(ans, tmp)
    
    print(ans)
        

if __name__ == '__main__':
    Main()

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
int main() {
  int N;
  cin >> N;
  vector<int> P(N);
  rep(i, N) cin >> P.at(i);
  int Pmin = N;
  int ans = 0;
  rep(i, N) {
    Pmin = min(Pmin, P.at(i));
    if (Pmin >= P.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

		public static void main(String[] args) {

			Scanner sc = new Scanner(System.in);

			int a = sc.nextInt();
			int b = sc.nextInt();
			int c = sc.nextInt();

			int ans = b/a;

			if(ans >= c) {
				System.out.println(c);
			}else {
				System.out.println(ans);
			}

	}
}



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

#define int long long
#define pb push_back
#define range(v) v.begin(),v.end()
#define mod (int)(1e9 + 7)
#define inf (int)(1e15)
#define N (int)(2e5 + 10)

using namespace std;

void solve() {
	int n;
	cin >> n;
	vector<int> f(n + 1);

	for (int i = 1; i <= 100; i++) {
		for (int j = 1; j <= 100; j++) {
			for (int k = 1; k <= 100; k++) {
				int val = (i * (i + j)) + (j * (j + k)) + (k * (k + i));
				if (val <= n) f[val]++;
			}
		}
	}

	for (int i = 1; i <= n; i++) cout << f[i] << endl;
}

int32_t main() {
	ios_base::sync_with_stdio(false), cin.tie(nullptr), cin.tie(nullptr);
	int t_c = 1;
//	cin >> t_c;
	while (t_c--)
		solve();
}

Measured memory_bytes: 3564
#include <stdio.h>
int main(){
  int n, i, j, All=196471 , Y, M, D, sum;
  scanf("%d",&n);
  for(j = 0 ,sum = 0 ; j < n ; j++ , sum = 0){
  scanf("%d %d %d",&Y, &M, &D);

  for(i = 1 ; i < Y ; i++){
    if(i % 3 == 0){
      sum+=200;
    }else{
      sum+=195;
    }
  }

    for(i = 1 ; i < M ; i++){
      if(Y % 3 == 0|| i % 2 == 1){
	sum+=20;
      }else{
	sum+=19;
      }
    }
  
    sum+=D;
    printf("%d\n",All-sum);
  }
  
  return 0;
}

Measured memory_bytes: 596
N=int(input())
A=list(map(int,input().split()))
A.sort()
if A[0]!=0:
    ans=1
    for i in range(N):
        ans=ans*A[i]
        if ans>pow(10,18):
            ans='-1'
            break
else:
    ans=0
print(ans)

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

using namespace std;



int main () {

	int N;
	scanf("%d", &N);

	vector<int> A(N);

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

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

	int B = A[N / 2];

	long long ans = 0;

	for (int i = 0; i < N; ++i) {
		ans += abs(A[i] - B);
	} 

	printf("%lld\n", ans);

	return 0;
}
 

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

enum Color{WHITE, GRAY, BLACK};
struct edge{
        int v,c;
        edge(int v, int c): v(v), c(c){}
};

int n;
vector<vector<edge>> a;
int *r;

void shortestPath(){
        int tmpcost[n];
        Color color[n];
        for(int i=0;i<n;i++) tmpcost[i]=INT_MAX;
        for(int i=0;i<n;i++) color[i]=WHITE;
        tmpcost[0] = 0;
        color[0] = GRAY;
        while(1){
                int mincost=INT_MAX, argmin=-1;
                for(int i=0;i<n;i++){
                        if(color[i]!=GRAY) continue;
                        if(mincost>tmpcost[i]){
                                mincost = tmpcost[i];
                                argmin = i;
                        }
                }
                if(argmin==-1) break;
                color[argmin] = BLACK;
                r[argmin] = mincost;

                for(int i=0;i<a[argmin].size();i++){
                        edge e = a[argmin][i];
                        if(color[e.v]==BLACK) continue;
                        color[e.v] = GRAY;
                        tmpcost[e.v] = tmpcost[e.v]<(mincost+e.c)? tmpcost[e.v] : (mincost+e.c);
                }

        }

}
int main(){
        int u,k,v,c;
        cin>>n;
        a = vector<vector<edge>>(n);
        r = new int [n];
        for(int i=0;i<n;i++){
                cin>>u>>k;
                for(int j=0;j<k;j++){
                        cin>>v>>c;
                        a[u].emplace_back(edge(v,c));
                }
        }

        shortestPath();

        for(int i=0;i<n;i++)
                cout<<i<<" "<<r[i]<<endl;
        return 0;
}




Measured memory_bytes: 3144
#include <algorithm>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;

#define REP(i, b, e) for (auto i = b; i < e; ++i)

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

    int ans = 0;

    REP(i, 0, n) {
        if (s[i] == 'x') {
            if (i - 1 >= 0 && s[i - 1] == 'x') {
                break;
            }
        }

        ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3340
s=input()

for i in range(2**3):
    st=s[0]
    cost=int(s[0])
    for j in range(3):
        if (i>>j)&1:
            cost=cost+int(s[j+1])
            st=st+"+"+s[j+1]
        else:
            cost=cost-int(s[j+1])
            st=st+"-"+s[j+1]
    if cost==7:
        print(st+"=7")
        break


Measured memory_bytes: 38384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author mikit
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATrain solver = new ATrain();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATrain {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            out.println(in.nextInt() - in.nextInt() + 1);
        }

    }
}



Measured memory_bytes: 23252
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, a[100000], b[100000], ta = 0, mu = 0, rin = 0;
vector<int> wa = {};

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		ta += a[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		mu += b[i];
	}
	if (ta < mu) {
		cout << -1 << endl;
		return 0;
	}
	rin = ta - mu;
	ta = 0;
	for (int i = 0; i < n; i++) {
		if (a[i] >= b[i])wa.push_back(a[i] - b[i]);
	}
	sort(wa.begin(), wa.end());
	for (int i = 0; i < wa.size(); i++) {
		rin -= wa[i];
		if (rin < 0)break;
		ta++;
	}
	cout << n - ta << endl;
	getchar(); getchar();
	return 0;
}

Measured memory_bytes: 2936
// {{{
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
// }}}

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

static constexpr int mod = (int)1e9 + 7;
static constexpr int inf = 100100100;
static constexpr ll linf = 1e18;
static constexpr double eps = 1e-9;
static constexpr double pi = 3.14159265359;

#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rrep(i, n) for (ll i = n; i >= 0; --i)
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define pb push_back
#define ist insert
#define fst first
#define snd second

ll N, K;
double prob(ll x, double n) {
    if (x <= K - 1) {
        return prob(x * 2, n / 2);
    }
    return n;
}

int main() {
    // cin.tie(0);
    // ios_base::sync_with_stdio(false);
    cin >> N >> K;
    double ans = 0;
    rep (i, N) {
        ans += prob(i + 1, 1) / N;
    }
    printf("%.16lf\n", ans);
}


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

ans = float('inf')
for way in 1, -1:
    b = 1
    t = a[0]
    for aa in a:
        if way == 1:
            if aa < t:
                b += 1
                way = 0
        elif way == -1:
            if aa > t:
                b += 1
                way = 0
        else:
            if aa < t:
                way = -1
            elif aa == t:
                way = 0
            else:
                # aa > t:
                way = 1
        t = aa
    ans = min(ans, b)
print(ans)


Measured memory_bytes: 14228
n, k = map(int, input().split())
l = [0] * n
a = []

for i in range(1,k+1):
    d = int(input())
    a.append(input().split())

res = [ flatten for inner in a for flatten in inner ]

for j in range(0, len(res)):
    l[int(res[j])-1]+=1

cnt = 0
for k in range(0, len(l)):
    if(l[k]==0):
        cnt+=1

print(cnt)

Measured memory_bytes: 68132
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;

void main()
{
	int[int] cnt;
	int[int] flag;
	bool f;
	foreach (line; stdin.byLine) {
		if (!line.length) {
			f = 1;
			continue;
		}
		auto key = line.split(",").map!(to!int)[0];
		cnt[key]++;
		if (!f) {
			flag[key] = 1;
		} else if (flag.get(key, 0)) {
			flag[key] = 2;
		} else {
			flag[key] = 0;
		}
	}
	foreach (key; cnt.keys.sort) {
		if (cnt[key] < 2 || flag[key] != 2) continue;
		writeln(key, " ", cnt[key]);
	}
}

Measured memory_bytes: 1084
#include <bits/stdc++.h>
#pragma GCC optimize("O3")

using namespace std;
typedef long long ll;

#define f first
#define s second

int k, x;

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0); cout.tie(0);
  cin >> k >> x;
  if (k *500 >= x)
    cout << "Yes";
  else
    cout << "No";

  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
#define FOR(i, c) \
  \ for (__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef vector<VB> VBB;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp

int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=1,Min=1e9+1;
  string s,t;
  bool ok = false;
  ll a,b;
  cin >> n >> a >> b;

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

  x = a+b;
  y = n/x;
  ans += y*a;
  z = n-(x * y);
  
  if(z < a){
    cout << ans + z << endl;
  }
  else
    cout << ans + a << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a1 = a[::2]
a2 = a[1::2]

from collections import Counter
c = Counter(a1)
c1 = []
for i in c:
    c1.append([c[i],i])
c1.sort(reverse = True)

c = Counter(a2)
c2 = []
for i in c:
    c2.append([c[i],i])
c2.sort(reverse = True)

ans = n
if c1[0][1] != c2[0][1]:
    ans -= c1[0][0]
    ans -= c2[0][0]
else:
    buf1 = 0
    buf1 += c1[0][0]
    if len(c2) > 1: buf1 += c2[1][0]
    buf2 = 0
    buf2 += c2[0][0]
    if len(c1) > 1: buf2 += c1[1][0]
    ans -= max(buf1,buf2)
print(ans)

Measured memory_bytes: 27292
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;

/*
<url:https://arc084.contest.atcoder.jp/tasks/arc084_a>
問題文============================================================
 今年もすぬけ祭の季節がやってきました。
 りんごさんは、まず手始めにすぬけ君召喚の儀式を執り行おうと思っています。
 儀式には祭壇が必要で、祭壇は上部、中部、下部の 3 つのカテゴリーのパーツ 1 つずつからなります。
 
 祭壇の 3 カテゴリーのパーツがそれぞれ N 個ずつあります。
 i 個目の上部のパーツのサイズは Ai 、i 個目の中部のパーツのサイズは Bi 、i 個目の下部のパーツのサイズは Ci です。
 
 祭壇を作るにあたっては、中部のパーツのサイズは上部のパーツのサイズより真に大きく、
 下部のパーツのサイズは中部のパーツのサイズより 真に大きくなければなりません。
 逆に、この条件を満たす任意の 3 つのピースを組み合わせて祭壇を作ることができます。
 
 りんごさんが作ることのできる祭壇は何種類あるでしょうか。
 ただし、2 つの祭壇が異なるとは、上部、中部、下部に使われるピースのうち 少なくとも 1 つが異なることを言います。
 
=================================================================

解説=============================================================

================================================================
*/
int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
    ll N; cin >> N;
    vector<ll> A(N),B(N),C(N);
    for(auto& in:A) cin >> in;
    for(auto& in:B) cin >> in;
    for(auto& in:C) cin >> in;
    sort(A.begin(),A.end()); sort(B.begin(),B.end()); sort(C.begin(),C.end());
    ll ans = 0;
    for(int i = 0; i < N;i++){
        auto ue = lower_bound(A.begin(),A.end(),B[i]);
        auto sita = upper_bound(C.begin(),C.end(),B[i]);
        if(ue == A.begin()) continue;
        ans += (ue - A.begin()) * (C.end() - sita);
    }
    cout << ans << endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
	int h,w;
	char a[100][100];
	cin>>h>>w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
		}
	}
	for(int i=0;i<h*2;i++){
		for(int j=0;j<w;j++){
			cout<<a[i/2][j];
		}
		cout<<endl;
	}
	return 0;
}


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

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define fi first
#define se second

#define INF 2147483600

int dp[1500][1500];

int main(){
  int h,w;
  cin>>h>>w;

  rep(i,h)rep(j,w) scanf("%d", &dp[i][j]);

  rep(i,h) rep(j,w){
    if(i==0 || j==0){
      dp[i][j] = !dp[i][j];
      continue;
    }
    if(dp[i][j]==0) dp[i][j] = min(dp[i-1][j], min(dp[i-1][j-1], dp[i][j-1])) + 1;
    else dp[i][j] = 0;
  }

  int res=0;
  rep(i,h)rep(j,w) res = max(res, dp[i][j]);

  cout<<res*res<<endl;

  return 0;
}

Measured memory_bytes: 11348
S = input()
A = [int(S[i]) for i in range(len(S))]
X = [0]
Y = [1]
for i in range(len(S)-1):
  if X[i] == 0:
    X.append(1)
  elif X[i] == 1:
    X.append(0)
for i in range(len(S)-1):
  if Y[i] == 0:
    Y.append(1)
  elif Y[i] == 1:
    Y.append(0)
B = 0
C = 0
for k in range(len(S)):
  if A[k] == X[k]:
    B += 0
  else:
    B += 1
for l in range(len(S)):
  if A[l] == Y[l]:
    C += 0
  else:
    C += 1
print(min(B,C))

Measured memory_bytes: 5628
n, m = map(int, raw_input().split())
P = [map(int, raw_input().split()) for i in xrange(n)]
C = [map(int, raw_input().split()) for i in xrange(m)]
for a, b in P:
    idx = -1; mi = ()
    for i, (c, d) in enumerate(C):
        di = abs(a-c) + abs(b-d)
        if di < mi:
            mi = di
            idx = i
    print idx+1


Measured memory_bytes: 2568
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def read_a_int(): return int(read())


def read_ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_tuple(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_matrix(H):
    '''H is number of rows'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations, accumulate
from bisect import bisect_left, bisect_right  # , insort_left, insort_right


# 根からなるべく早く分岐していたほうが有利 (だけど作りすぎるとダメ)
# 分岐できる最大値まで分岐させるのが良いのでは？
# 分岐できる最大値は？
#
# 累積和じゃね？

# 数は求められそうになった→存在しない場合はどういうとき？
# →その場で作ることのできる葉の数を越したとき

# 二倍二倍でシミュレーション化(必要な数を超えては行けない)


N = read_a_int()
A = read_ints()

# i番目以下に必要な葉の数
n_leaves_under = list(reversed(list(accumulate(reversed(A))))) + [0]

# 頂点数をシミュレーションしていく
# 頂点数はn_leaves_underを超えては行けない
# なるべく葉の数を引いてからなるべく2倍にするほうが良い
# A[i]が現在作れる葉の数よりも大きかったら強制終了

now = 1  # 頂点の数
ans = 0
for i in range(N + 1):
    # print(now, n_leaves_under[i + 1])
    if A[i] > now:
        print(-1)
        exit()
    ans += now
    now -= A[i]
    now = min(now * 2, n_leaves_under[i + 1])

print(ans)


Measured memory_bytes: 87832
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <time.h>

using namespace std;
typedef long long ll;
#define pl pair<ll,ll>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin(); itr!=c.end(); itr++)
#define dbg(x) cout << #x"="<< (x) << endl
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back(a) 
#define in(x) cin >> x;
#define all(x) (x).begin(), (x).end()
#define INF 2147483600
#define fi first
#define se second

int main(){
	ll n,odd=0;
	cin>>n;
	vector<ll> a(n);
	rep(i,n)cin>>a[i];
	rep(i,n)if(a[i]%2)odd++;	
	odd%=2;
	cout<<((odd!=1)?"YES":"NO")<<endl;
    return 0;
}

Measured memory_bytes: 1024
N = int(input())
s = input()
num_reds = [0] * N
num_whites = [0] * N
num_reds[0] += 1 if s[0] == 'R' else 0
num_whites[0] += 1 if s[0] == 'W' else 0
for i in range(1, N):
    if s[i] == 'R':
        num_reds[i] += 1
    else:
        num_whites[i] += 1
    num_reds[i] += num_reds[i - 1]
    num_whites[i] += num_whites[i - 1]

ans = N
for n in range(1, N):
    # x = (n - num_reds[n - 1]) + ((N - n) - (num_whites[N - 1] - num_whites[n - 1]))
    a = n - num_reds[n - 1]
    b = (N - n) - (num_whites[N - 1] - num_whites[n - 1])
    x = a + b - min(a, b)
    ans = min(ans, x)
ans = min(ans, num_reds[N - 1])
ans = min(ans, num_whites[N - 1])
print(ans)

Measured memory_bytes: 24828
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};

#[fastout]
fn main() {
    input! {//
        n:usize,
        k:usize,
        a:[i32;n],
    }
    let mut ans = vec![];
    for i in k..n {
        if a[i - k] < a[i] {
            ans.push(true);
        } else {
            ans.push(false);
        }
    }
    for &x in ans.iter() {
        yn(x);
    }
}
pub fn yn(ans: bool) {
    if ans {
        println!("Yes");
    } else {
        println!("No");
    }
}


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

int main(){
  int A,B,K;
  cin>>A>>B>>K;
  while(A%B!=0){
    int tmp=A%B;
    A=B;
    B=tmp;
  }
  int num=0;
  for(int i=1;i<=B;i++){
    if(B%i==0){
      num++;
    }
    if(num==K){
      cout<<B/i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
  
int main()
{
  ll N;
  cin >> N;

  vector<ll> H(N);
  REP(i, N) cin >> H[i];

  int flag = 0;
  int a = 0;
  int flag2 = 0;
  REP(i,N-1){
    if(flag == 0&&H.at(i) > H.at(i+1)){
      a = H.at(i);
      flag = 1;
    }else if(flag == 1&&H.at(i) < H.at(i+1)){
      if(a-H.at(i)>=2){
        flag2 = 1;
      }
      flag = 0;
    }
    if(flag == 1&&i == N-2&&H.at(i)>=H.at(i+1)){
      if(a-H.at(i+1)>=2){
        flag2 = 1;
      }
      flag = 0;
    }
  }


  if(flag2 == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
} 

Measured memory_bytes: 4020
#include <stdio.h>

int main()
{
	long int	N;		/* ユーザー入力のN */
	long int	result;		/* 計算結果を格納する */
	long int	five;		/* 5の累乗を計算する */
	char		line[100];	/* ユーザーの入力行 */
	
	fgets(line, sizeof(line), stdin);
	sscanf(line, "%ld", &N);
	result = 0;
	five = 1;
	
	/* 奇数であれば0を出力して終了 */
	if((N % 2) == 1){
		printf("0\n");
		return (0);
	}
	/* Nを半分にする */
	N = N / 2;

	for(five = 1; (five * 5) <= N;){
		five *= 5;
		result += N / five;
	}

	printf("%ld\n", result);
	return 0;
}

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

using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

vector<P> makev(){
  ll m;
  cin>>m;
  vector<P> v(m);
  FOR(i,0,m){
    cin>>v[i].first>>v[i].second;
  }
  return v;
}

vector<P> rotate(vector<P> v){
  FOR(i,0,v.size()){
    ll x=v[i].first;
    ll y=v[i].second;
    v[i]=P(y,-x);
  }
  return v;
}

P difp(P a, P b){
  return P(a.first-b.first,a.second-b.second);
}

bool cmp(vector<P> a, vector<P> b){
  if(a.size()!=b.size()) return false;
  vector<P> b1,b2,b3;
  b1=rotate(b);
  b2=rotate(b1);
  b3=rotate(b2);
  ll f1=1,f2=1,f3=1,f4=1;
  FOR(i,1,a.size()){
    if(difp(a[i],a[i-1])!=difp(b[i],b[i-1]))f1=0;
    if(difp(a[i],a[i-1])!=difp(b1[i],b1[i-1]))f2=0;
    if(difp(a[i],a[i-1])!=difp(b2[i],b2[i-1]))f3=0;
    if(difp(a[i],a[i-1])!=difp(b3[i],b3[i-1]))f4=0;

  }
  if(f1+f2+f3+f4>=1)return true;
  else return false;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;
  cin>>n;
  while(n!=0){
    vector<P> v;
    v=makev();
    FOR(i,0,n){
      vector<P> v0,v1;
      v0=makev();
      v1=v0;
      reverse(v1.begin(),v1.end());
      if(cmp(v,v0)||cmp(v,v1))cout<<i+1<<endl;

    }
    cout<<"+++++"<<endl;
    cin>>n;
  }
}



Measured memory_bytes: 3104
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

cost_list = [a, b, c, d, e]

min_val = 100
idx = 0
for i, cost in enumerate(cost_list):
    val = cost % 10
    if val == 0:
        continue

    if val < min_val:
        min_val = val
        idx = i

ans = cost_list[idx]
for i, cost in enumerate(cost_list):
    if i == idx:
        continue

    wait_next_order = 0
    if cost_list[i]%10 != 0:
        wait_next_order = 10 - cost_list[i]%10

    ans += cost_list[i] + wait_next_order

print(ans)

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

int main(){
    ll N; cin >> N;
    if(N%2!=0){
        cout << 0;
        return 0;
    }
    else{
        ll ans=0;
        for (ll i=10; i<=N; i*=5){
            ans+=N/i;
        }
        cout << ans;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define ALL(a) (a).begin(),(a).end()
#define YESNO(i) puts((i)?"YES":"NO");
#define YesNo(i) puts((i)?"Yes":"No");
#define yesno(i) puts((i)?"yes":"no");
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s,t;cin>>s>>t;
  YesNo(s==t.substr(0,t.length()-1));
  return 0;
}

Measured memory_bytes: 3612
/*
A Reward for a Carpenter(https://onlinejudge.u-aizu.ac.jp/problems/0117)
右
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <cmath>
#include <complex>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cassert>
#include <iomanip>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define put(x) cout << x;
#define putsp(x) cout << x << ' ';
#define putln(x) cout << x << endl;
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;
typedef complex<double> comp;
typedef vector <int> vec;
typedef vector <ll> vecll;
typedef vector <double> vecd;
typedef vector <vec> mat;
typedef vector <vecll> matll;
typedef vector <vecll> matd;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

const int MAX = 32;
const int INF = 1<<29;

int wf[MAX][MAX];

void solve(void){
	int N, M, s, g, V, P;
	char cc;
	cin >> N >> M;

	//初期化
	rep(N, i) rep(N, j) wf[i][j] = INF;


	rep(M, i)
	{
		char cc;
		int a, b, c, d;
		cin >> a >> cc >> b >> cc >> c >> cc >> d;

		//cout << a << b << c << d << endl;

		a--, b--;
		wf[a][b] = c;
		wf[b][a] = d;
	}

	//WF
	rep(N, k) rep(N, i) rep(N, j) wf[i][j] = min(wf[i][j], wf[i][k] + wf[k][j]);

	cin >> s >> cc >> g >> cc >> V >> cc >> P;
	s--, g--;

	/*Debug
	rep(N, i) rep(N, j)
	{
		cout << wf[i][j] << ' ';
		if (j == N-1) cout << endl;
	}
	*/


	//往復の交通費と柱代を差し引いたものが答え
	cout << V - P - wf[s][g] - wf[g][s] << endl;

}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3112
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong();
    int k=sc.nextInt();
    for(int i=0;i<k;i++) {
    	if(i%2==0) {
	    	if(a%2!=0)a--;
			a=a/2;
			b+=a;
    	}else {
			if(b%2!=0)b--;
			b=b/2;
			a+=b;
    	}
    }
    System.out.println(a+" "+b);
  }
}


Measured memory_bytes: 21716
/*
これを入れて実行
g++ code.cpp
./a.out
 */

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}

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

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

ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}

//-----------------------ここから-----------

int main(void){
    int x;
    cin >> x;
    if(x < 1200){
        cout << "ABC" << endl;
    } else {
        cout << "ARC" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n,c;
    cin >> n >> c;
    Vi x(n),v(n);
    rp(i,n) cin >> x.at(i) >> v.at(i);
    Vi sum(n),revsum(n);
    Vi d_sum(n),d_revsum(n);
    rp(i,n){
        if(i==0){
            sum.at(0)=v.at(0)-x.at(0);
            d_sum.at(0)=v.at(0)-2*x.at(0);
            continue;
        }
        sum.at(i)=sum.at(i-1)+v.at(i)-x.at(i)+x.at(i-1);
        d_sum.at(i)=d_sum.at(i-1)+v.at(i)-2*(x.at(i)-x.at(i-1));
    }
    rp(i,n){
        if(i==0){
            revsum.at(0)=v.at(n-1)-(c-x.at(n-1));
            d_revsum.at(0)=v.at(n-1)-2*(c-x.at(n-1));
            continue;
        }
        revsum.at(i)=revsum.at(i-1)+v.at(n-1-i)-(x.at(n-i)-x.at(n-1-i));
        d_revsum.at(i)=d_revsum.at(i-1)+v.at(n-1-i)-2*(x.at(n-i)-x.at(n-1-i));
    }
    Vi summax(n),revsummax(n);
    rp(i,n){
        if(i==0){
            summax.at(0)=max(0ll,sum.at(0));
            continue;
        }
        summax.at(i)=max(summax.at(i-1),sum.at(i));
    }
    rp(i,n){
        if(i==0){
            revsummax.at(0)=max(0ll,revsum.at(0));
            continue;
        }
        revsummax.at(i)=max(revsummax.at(i-1),revsum.at(i));
    }
    ll ans=0;
    rp(i,n-1){
        chmax(ans,d_sum.at(i)+revsummax.at(n-2-i));
    }
    rp(i,n-1){
        chmax(ans,d_revsum.at(i)+summax.at(n-2-i));
    }
    Sort(sum);
    Sort(revsum);
    chmax(ans,sum[0]);
    chmax(ans,revsum[0]);
    print(ans);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}


Measured memory_bytes: 6528
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  char a, b;
  cin >> a >> b;
  if(a == b) cout << "H" << endl;
  else cout << "D" << endl;
  return 0;
}
//templete by private_yusuke

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

int selectionSort(int A[],int N){
	int minj=0,i,j,ans1=0,tmp=0;
	for(i=0;i<N;i++){
		minj=i;
		for(j=i;j<N;j++){
			if(A[j]<A[minj]){
				minj=j;
			}
		}
		if(i!=minj){
		tmp=A[i];A[i]=A[minj];
		A[minj]=tmp;
		ans1++;
		}
	}
	return ans1;
}

int main(){
	ios::sync_with_stdio(false);
	int A[100]={0},N,ans=0;
	cin>>N;
	for(int ii=0;ii<N;ii++){
		cin>>A[ii];
	}
	ans=selectionSort(A,N);
	for(int ii=0;ii<N;ii++){
		if(ii!=N-1){cout<<A[ii]<<" ";
		}
		else {cout<<A[ii]<<endl;
		}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> pii;
typedef long long ll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int n;
    cin >> n;
    string s;
    cin >> s;
    int ans = 0;
    for (int i=0; i<=n-3; i++) {
        if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
    }
    cout << ans << "\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 256
N=int(input())
sp=[]
for _ in range(N):
    sp.append([i for i in input().split()])

for i in range(N):
    sp[i][1]=-int(sp[i][1])

sp2=sorted(sp)

for i in range(N):
    s=sp2[i]
    print(sp.index(s)+1)

Measured memory_bytes: 3060