akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
template<typename T>inline T read(){
	T f=0,x=0;char c=getchar();
	while(!isdigit(c)) f=c=='-',c=getchar();
	while(isdigit(c)) x=x*10+c-48,c=getchar();
	return f?-x:x;
}
namespace run{
	const int N=309,mod=1e9+7;
	inline int add(int x,int y){return x+y>=mod?x-mod+y:x+y;}
	inline int sub(int x,int y){return x>=y?x-y:x+mod-y;}
	inline int qpow(int x,int y){
		int ret=1;
		while(y){
			if(y&1) ret=1LL*x*ret%mod;
			x=1LL*x*x%mod,y>>=1;
		}
		return ret;
	}

	int vis[N*2],n,a[N*2],m,f[N*2][N*2][N*2];
	int main(){
		n=read<int>()*2;
		for(int i=1;i<=n;i++){
			a[i]=read<int>();
			if(~a[i]) vis[a[i]]=1;
			if(~i&1 && ~a[i] && ~a[i-1]) vis[a[i]]=2,vis[a[i-1]]=2;
		}

		for(int i=1;i<=n;i++) if(vis[i]!=2) vis[++m]=vis[i];
		f[m+1][0][0]=1;
		for(int i=m;i>=1;i--){
			for(int j=0;j<=m-i+1;j++)
				for(int k=0;k<=m-i+1-j;k++){
					if(!vis[i]){
						f[i][j][k]=add(f[i+1][j+1][k],f[i][j][k]);
						f[i][j][k]=(1LL*f[i+1][j][k+1]*(k+1)+f[i][j][k])%mod;
						f[i][j][k]=add(f[i+1][j-1][k],f[i][j][k]);
					}else{
						f[i][j][k]=add(f[i+1][j+1][k],f[i][j][k]);
						f[i][j][k]=add(f[i+1][j][k-1],f[i][j][k]);
					}
				}
		}
		int ans=f[1][0][0],sum=0;
		for(int i=1;i<=m;i++) if(vis[i]) sum++;
		for(int i=1;i<=m/2-sum;i++) ans=1LL*i*ans%mod;
		printf("%d\n",ans);
		return 0;
	}
}
int main(){
#ifdef my
	freopen("minimum.in","r",stdin);
	freopen("minimum.out","w",stdout);
#endif
	return run::main();
}

Measured memory_bytes: 441392
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
using namespace std;

const long long MOD = 1000000007;


/* Ref. https://qiita.com/drken/items/3b4fdf0a78e7a138cd9a */
const int MAX = 1100000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

long long nCk_mod(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {
  int X, Y;
  cin >> X >> Y;
  if((X+Y)%3 != 0){
    cout << 0 << endl;
    return 0;
  }

  int n, m;
  n = (2*Y-X)/3;
  m = (2*X-Y)/3;

  if (n< 0 || m <0){
    cout << 0 << endl;
    return 0; 
  }
  COMinit();
  cout << nCk_mod(n+m,n) << endl;

}

Measured memory_bytes: 25984
class Unionfind:

    __slots__ = ['nodes','rank']

    def __init__(self, n):
        self.nodes = list(range(n))
        self.rank = [0]*n

    def root(self, x):
        if self.nodes[x] == x:
            return x
        else:
            root_x = self.root(self.nodes[x])
            self.nodes[x] = root_x
            return root_x

    def unite(self, x, y):
        x = self.root(x); y = self.root(y)
        if x == y:
            return
        if self.rank[x] < self.rank[y]:
            x, y = y, x
        self.rank[x] += self.rank[y]
        self.nodes[y] = x

    def same(self, x, y):
        return self.root(x) == self.root(y)

around = [(0,1),(1,0),(0,-1),(-1,0)]

H,W = map(int,input().split())
grid = [list(input()) for _ in range(H)]
uf = Unionfind(H*W)

for i in range(H):
    for j in range(W):
        for di,dj in around:
            ni = i + di; nj = j + dj
            if not(0 <= ni <= H-1 and 0 <= nj <= W-1):
                continue
            x = W*i+j; y = W*ni+nj
            if grid[i][j] != grid[ni][nj]:
                uf.unite(x,y)

for v in range(H*W):
    uf.root(v)

group = [[0]*2 for _ in range(H*W)]

for i,line in enumerate(grid):
    for j,c in enumerate(line):
        parent = uf.nodes[W*i+j]
        if c == ".":
            group[parent][0] += 1
        if c == "#":
            group[parent][1] += 1

ans = sum([w*b for w,b in group])
print(ans)

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

int main(){
int a = 1;int b = 1;int i = 1;int ii = 1;
for(ii = 1;ii <= 9;ii++){
	b = 1;
	for(i = 1;i <= 9;i++){
	 	cout << a << "x" << b << "=" << a*b << endl;
	 	b = b+1;
		}
	a = a+1;
	}
    return 0;
}

Measured memory_bytes: 1116
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mcpy(a, b) memcpy(a, b, sizeof(a))
using namespace std;
typedef long long LL;
const int MAXN = 200005;
const int MAXM = 400005;
const int INF = 0x3f3f3f3f;

template <typename T> inline void read(T &AKNOI) {
	T x = 0, flag = 1;
	char ch = getchar();
	while (!isdigit(ch)) {
		if (ch == '-') flag = -1;
		ch = getchar();
	}
	while (isdigit(ch)) {
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	AKNOI = flag * x;
}

int S, T, level[MAXN], q[MAXN], head, tail;

struct Edge {
	int v, w, nxt;
} e[MAXM << 1];
int first[MAXN], used[MAXN], eCnt;

inline void AddEdge(int u, int v, int w) {
	e[++eCnt].v = v;
	e[eCnt].w = w;
	e[eCnt].nxt = first[u];
	first[u] = eCnt;
}

inline void Add(int u, int v, int w) {
	AddEdge(u, v, w);
	AddEdge(v, u, 0);
}

inline int Match(int u) {
	for (int i = first[u]; i; i = e[i].nxt) {
		if (e[i].v != T && e[i].w) return e[i].v;
	}
	return 0;
}

bool BFS() {
	for (int i = 1; i <= T; ++i) {
		level[i] = -1;
		used[i] = first[i];
	}
	level[S] = 0;
	q[head = tail = 1] = S;
	while (head <= tail) {
		int u = q[head++];
		if (u == T) return 1;
		for (int i = first[u]; i; i = e[i].nxt) {
			int v = e[i].v;
			if (e[i].w && level[v] == -1) {
				level[v] = level[u] + 1;
				q[++tail] = v;
			}
		}
	}
	return 0;
}

int DFS(int u, int flow) {
	if (u == T) return flow;
	int ret = 0;
	for (int i = used[u]; i; i = e[i].nxt, used[u] = i) {
		int v = e[i].v;
		if (e[i].w && level[v] == level[u] + 1) {
			int tmp = DFS(v, min(flow, e[i].w));
			e[i].w -= tmp;
			e[i ^ 1].w += tmp;
			flow -= tmp;
			ret += tmp;
			if (!flow) break;
		}
	}
	return ret;
}

int Dinic() {
	int ret = 0;
	while (BFS()) {
		ret += DFS(S, INF);
	}
	return ret;
}

int n, son[MAXN], fa[MAXN];
vector<int> ine[MAXN];

void init() {
	read(n);
	eCnt = S = 1, T = n * 2;
	for (int i = 1; i < n; ++i) {
		int siz; read(siz);
		Add(S, n + i, 1);
		for (int j = 1; j <= siz; ++j) {
			int x; read(x);
			ine[x].push_back(i);
			if (x == 1) continue;
			Add(n + i, x, 1);
		}
	}
	for (int i = 2; i <= n; ++i) {
		Add(i, T, 1);
	}
}

void solve() {
	if (Dinic() < n - 1) {
		puts("-1");
		return;
	}
	for (int i = 2; i <= n; ++i) {
		son[Match(i) - n] = i;
	}
	q[head = tail = 1] = 1;
	while (head <= tail) {
		int u = q[head++];
		for (auto v : ine[u]) {
			if (fa[v]) continue;
			fa[v] = u;
			q[++tail] = son[v];
		}
	}
	if (tail < n) {
		puts("-1");
		return;
	}
	for (int i = 1; i < n; ++i) {
		printf("%d %d\n", fa[i], son[i]);
	}
}

int main() {
	init();
	solve();
	return 0;
}


Measured memory_bytes: 24320
import java.util.*;

/**
 * D
 */
public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        int max_v, min_v;
        int n = sc.nextInt();

        int array[] = new int[n];

        for(int i=0; i<n; i++) {
            array[i] = sc.nextInt();
        }

        sc.close();

        max_v = array[1] - array[0];
        min_v = array[0];

        for(int i=1; i<n; i++) {

            if(array[i] - min_v > max_v) {
                max_v = array[i] - min_v;
            }

            if(array[i] < min_v) {
                min_v = array[i];
            }

        }

        System.out.println(max_v);

    }
}


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

void change(int *label, char word)
{
	if (word == 'N')
	{
		int tmp = label[5];

		label[5] = label[1];
		label[1] = label[2];
		label[2] = label[6];
		label[6] = tmp;
	}
	else if (word == 'S')
	{
		int tmp = label[6];

		label[6] = label[2];
		label[2] = label[1];
		label[1] = label[5];
		label[5] = tmp;
	}
	else if (word == 'E')
	{
		int tmp = label[3];

		label[3] = label[1];
		label[1] = label[4];
		label[4] = label[6];
		label[6] = tmp;
	}
	else
	{
		int tmp = label[6];

		label[6] = label[4];
		label[4] = label[1];
		label[1] = label[3];
		label[3] = tmp;
	}
}

void check (int *label, int a, int b)
{
	if (a == 1 && b == 2) cout << label[3] << endl;
	else if (a == 1 && b == 3) cout << label[5] << endl; 
	else if (a == 1 && b == 5) cout << label[4] << endl;
	else if (a == 1 && b == 4) cout << label[2] << endl;

	else if (a == 2 && b == 6) cout << label[3] << endl;
	else if (a == 2 && b == 3) cout << label[1] << endl;
	else if (a == 2 && b == 1) cout << label[4] << endl;
	else if (a == 2 && b == 4) cout << label[6] << endl;

	else if (a == 3 && b == 1) cout << label[2] << endl;
	else if (a == 3 && b == 2) cout << label[6] << endl;
	else if (a == 3 && b == 6) cout << label[5] << endl;
	else if (a == 3 && b == 5) cout << label[1] << endl;

	else if (a == 4 && b == 1) cout << label[5] << endl;
	else if (a == 4 && b == 2) cout << label[1] << endl;
	else if (a == 4 && b == 6) cout << label[2] << endl;
	else if (a == 4 && b == 5) cout << label[6] << endl;

	else if (a == 5 && b == 1) cout << label[3] << endl;
	else if (a == 5 && b == 3) cout << label[6] << endl;
	else if (a == 5 && b == 6) cout << label[4] << endl;
	else if (a == 5 && b == 4) cout << label[1] << endl;

	else if (a == 6 && b == 2) cout << label[4] << endl;
	else if (a == 6 && b == 3) cout << label[2] << endl;
	else if (a == 6 && b == 5) cout << label[3] << endl;
	else if (a == 6 && b == 4) cout << label[5] << endl;
}

int main()
{
	int label[7];
	for (int i = 1; i < 7; i++) cin >> label[i];

	int N;
	cin >> N;

	vector<int> pos1(N);
	vector<int> pos2(N);

	for (int i = 0; i < N; i++)
	{
		int q1, q2;
		cin >> q1 >> q2;

		for (int j = 1; j < 7; j++)
		{
			if (label[j] == q1) pos1[i] = j;
			else if (label[j] == q2) pos2[i] = j;
		}
	}

	for (int i = 0; i < N; i++)
	{
		//cout << pos1[i] << ":" << pos2[i] << endl;
		check(label, pos1[i], pos2[i]);
	}
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const string ln = "\n";
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

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

  int n;
  cin >> n;

  ll ans = 1;

  for (int i = 1; i <= n; i++) {
    ans *= i % MOD;
    ans %= MOD;
  }

  cout << ans << ln;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

    final String s = scanner.nextLine();
    final boolean[] alphabets = new boolean[26];
    for (char c: s.toCharArray()) {
      alphabets[c - 'a'] = !alphabets[c - 'a'];
    }

    for (boolean a: alphabets) {
      if (a) {
        System.out.println("No");
        return;
      }
    }

    System.out.println("Yes");
  }
}

Measured memory_bytes: 23764
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int Dist(int s, int d, int x, int y) {
  int distance = d - s;
  if (d <= x || y <= s) {
    return distance;
  }
  int shortcut = abs(x - s) + 1 + abs(y - d);
  return min(distance, shortcut);
}

int main() {
  int64_t N, X, Y;
  cin >> N >> X >> Y;
  --X; --Y;
  
  map<int, int> dist_cnt;
  
  for (size_t s = 0; s < N - 1; ++s) {
    for (size_t d = s + 1; d < N; ++ d) {
      ++dist_cnt[Dist(s, d, X, Y)];
    }
  }
  for (size_t k = 1; k < N; ++k) {
    cout << dist_cnt[k] << endl;
  }
  
  return 0;
}


Measured memory_bytes: 384
a = list(input())
a = sorted(a)
def count(a):
    b =[]
    for i in range(0,len(a)-2):
        if a[i] != a[i+1]:
            b.append( i+1)
    return b

b = count(a)
b.append(len(a))

for i in reversed(range(0,len(b)-1)):
    b[i+1] =b[i+1] - b[i]

d = 0
for i in range(0,len(b)):
    d = d +b[i]%2

if d ==0:
    print('Yes')
else:
    print('No')

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

struct p{
	int a;
	int b;
};

int ans[51];
p s[51],c[51];
int main(){
	int n,m;
	
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> s[i].a >> s[i].b;
	}
	for(int i = 0;i < m;i++){
		cin >> c[i].a >> c[i].b;
	}
	for(int i = 0;i < n;i++){
		ans[i] = 0;
		for(int j = 1;j < m;j++){
			if(abs(s[i].a-c[j].a)+abs(s[i].b-c[j].b)<abs(s[i].a-c[ans[i]].a)+abs(s[i].b-c[ans[i]].b)){
				ans[i] = j;
			}
		}
	}
	for(int i = 0;i < n;i++){
		cout << ans[i]+1 << endl;
	}
}

Measured memory_bytes: 256
s = input()

l = len(s)

q, r = divmod(l, 2)
hand = "g" * (q + r) + "p" * q

score = 0
for e1, e2 in zip(s, hand):
	if e1 == "g" and e2 == "p":
		score += 1
	elif e1 == "p" and e2 == "g":
		score -= 1

print(score)


Measured memory_bytes: 3316
// Length of largest subarray with 0 Sum
#include<bits/stdc++.h>
using namespace std;
int main() 
{
	long long int n;
	 cin >> n;
	 long long int a[n+1];
	 for(int i=0;i<n;i++)
	 	cin >> a[i];
	 a[n] = 0;
	 int ans = 0;
	 unordered_map<long long int, long long int> mp;
	 sort(a, a+n);
	 for(int i=0;i<n;i++)
	 {
	 	bool flag = true;
	 	if(a[i]==a[i+1])
	 	{
	 		mp[a[i]] = 1;
	 		continue;
	 	}
	 	for(int j=1;j*j<=a[i];j++)
	 	{
	 		if(a[i]%j==0)
	 		{
	 			if(mp.find(j)!=mp.end())
	 			{
	 				mp[a[i]] = 1;
	 				flag = false;
	 				break;
	 			}
	 			if(mp.find(a[i]/j)!=mp.end())
	 			{
	 				mp[a[i]] = 1;
	 				flag = false;
	 				break;
	 			}
	 		}
	 	}
	 	if(flag)
	 	{
	 		ans++;
	 		//cout << a[i] << ' ';
	 		mp[a[i]] = 1;
	 	}
	 }
	 cout << ans;
	return 0;
}

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

int main(){
  int ans = 0;
  int a,b,c;cin >> a >> b >> c;
  for(int i=a;i<=b;++i){
    if(c%i == 0)ans += 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3108
n = int(input())
a = list(map(int, input().split()))
a.insert(0,0)
a_ = a.copy()
s = 0
for i in range(1,n):
    if a_[i+1] < a_[i]:
        a_[i+1] = a_[i]
ans = [a_[i] - a[i] for i in range(len(a))]
print(sum(ans))

Measured memory_bytes: 33160
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    int N;
    cin >> N;
    vector<long long> seq(100005);
    queue<long long> q;
    int k;
    k=0;
    auto add = [&](long long x){
        seq[k] = x;
        k = k+1;
    };
    auto push = [&](long long x){
        if(x%10==0){
            q.push(x*10);
            add(x*10);
            q.push(x*10+1);
            add(x*10+1);
        }else if(x%10==9){
            q.push(x*10+8);
            add(x*10+8);
            q.push(x*10+9);
            add(x*10+9);
        }else{
            q.push(x*10+x%10-1);
            add(x*10+x%10-1);
            q.push(x*10+x%10);
            add(x*10+x%10);
            q.push(x*10+x%10+1);
            add(x*10+x%10+1);
        }
    };

    for(int i=1;i<10;i++){
        q.push(i);
        add(i);
    }
    long long p;
    while(k<100001){
    p = q.front();
    q.pop();
    push(p);
    }
    cout << seq[N-1] << endl;
    return 0;
}

Measured memory_bytes: 1536
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
struct edge{
    ll to,cost;
    edge(ll to,ll cost):to(to),cost(cost) {}
};
vector<vector<edge>> graph;
vector<vector<bool>> used;// 存在する辺はtrue
vector<ll> A;
vector<ll> d1,d2;
ll n,m;
void dij(ll s){
    d1.resize(n);
    for(int i=0;i<n;i++)d1[i]=inf;//訪れていない頂点をinfで初期化
    d1[s]=0;
    priority_queue<P,vector<P>,greater<P>> q;
    q.push(P(0,s));//始点を０で置く
    while(!q.empty()){
        P a=q.top();
        q.pop();
        if(d1[a.se]<a.fi)continue;
        for(auto &e:graph[a.se]){
            if(d1[e.to]>d1[a.se]+e.cost){
                d1[e.to]=d1[a.se]+e.cost;//訪れていないorより低いコストの経路を発見した時、値を更新
                q.push(P(d1[e.to],e.to));//コストの低いところ優先のbfs
            }
        }
    }
}
int main(){
    ll s;
    cin>>n>>m>>s;
    ll node=n;
    n*=2505;
    graph.resize(n);
    for(int i=0;i<m;i++){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        a--;b--;
        for(ll j=0;j<=2500;j++){
            if(j-c>=0){
                graph[a+node*j].emplace_back(b+node*(j-c),d);
                graph[b+node*j].emplace_back(a+node*(j-c),d);
            }
        }
    }
    for(int i=0;i<node;i++){
        ll c,d;
        cin>>c>>d;
        for(ll j=0;j<2500;j++){
            graph[i+node*j].emplace_back(i+node*min(2500ll,j+c),d);
        }
    }
    dij(node*min(2500ll,s));
    for(int i=1;i<node;i++){
        ll ans=inf;
        for(int j=0;j<=2500;j++){
            chmin(ans,d1[i+node*j]);
        }
        cout<<ans<<"\n";
    }
}

Measured memory_bytes: 23716
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

arr = ['Sunny', 'Cloudy', 'Rainy']
S = input()
print(arr[(arr.index(S) + 1) % len(arr)])



Measured memory_bytes: 38256
def main():
    n = int(input())
    a, b = map(int, input().split())
    p_list = list(map(int, input().split()))
    diff_list = [0] * 3

    for p in p_list:
        if p <= a:
            diff_list[0] += 1
        elif a + 1 <= p <= b:
            diff_list[1] += 1
        else:
            diff_list[2] += 1

    print(min(diff_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 61996
/* 実行時間1s制限の場合10^6 1,000,000 : 余裕をもって間に合う10^7
  10,000,000 : おそらく間に合う10^8 100,000,000 : 非常にシンプルな処理
  でないと厳しい
 */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#include <bits/stdc++.h>
#define M_PI 3.14159265358979323846
using namespace std;

typedef long long ll; // long longはデータモデル(LLP64, LP64, ...)によらず64bit.
ll gcd(ll a, ll b) {return b ? gcd(b, a%b) : a;}  // Greatest Common Divisor ユークリッドの互除法（aが長辺）
vector<pair<ll,int>> factorize(ll n) {            // a,bの公約数 = GCD(a, b)の約数
    vector<pair<ll,int>> res;
    for (ll i = 2; i*i <= n; i++) { // √nまで探せばよい
        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); // この時点で1でなかったら、残りは素数.
    return res;
}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}         // Least Commont Multiple オーバーフローしないように先に割る
ll ceil(ll a, ll b) {return (a+b-1)/b;}

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

int main(int argc, char* argv[])
{
#ifdef LOCAL
    // 以降 cin の入力元が 'xxx.txt' になる
    // std::ifstream in(argv[1]);
    //std::cin.rdbuf(in.rdbuf());
    //std::ifstream in(string(argv[0]) + ".txt");
    std::ifstream in("in.txt");
    std::cin.rdbuf(in.rdbuf());
#endif

    double r, g;
    cin >> r >> g;

    cout << 2*g - r;

    return 0;
}

/*
  - 1e9 : 10^9
  - container一般
    - 合計
      accumulate(a.begin(), a.end(), 0LL)  0LLはオーバーフロー用
  - vector
    vector<int> A(N, 0); // 0で初期化(省略可)
    vector<vector<int>> vec(n_rows, vector<int>(n_cols, value));  // 2次元配列初期化
    - loop
      for  (int i = 0; i < A.size(); i++) {}
      for  (int elem : A) {}
    - sort
      std::sort(v.begin(), v.end());  // 昇順
      std::sort(v.begin(), v.end(), std::greater<int>()); //降順
      - vector<vector<int>> cnt(h, vector<int>(w))
    - sort(struct)
        struct st_t {
            string name;
            int p;
            bool operator<(const st_t& another) const {
                if (name == another.name)
                {
                    return p > another.p;
                }
                return name < another.name;
            }
        };
        vector<st_t> st(n);
        sort(st.begin(), st.end());
  - pair
    - pairのソートの定義 : firstが優先的に比較。同じだったらsecond。
    - pair<pair<string,int>,int> p[110];
      std::sort(p,p+a);
        こうすると、first.first -> first.second -> secondの順にソートされる
    - sort
      - sort(a.begin(), cb.end(), greater<pair<int, int>>());
  - map
    - for (auto x : map) {}  // x.first:key  x.second:value.
  - priority_queue<int> q;
    - q.top()に最大値が入っている
  - string
    - loop
      for (char& c : s) {}
 */



Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a,b,wa;
        
        goback:
        while(sc.hasNext()){
            a = sc.nextInt();
            b = sc.nextInt();
            wa = a+b;
            int ue,shita;
            ue = 10;
            shita = 1;
            
            for(int i=1; i<10;i++){
                if((wa<ue)&&(wa>=shita)){
                    System.out.println(i);
                    continue goback;
                }else{
                    ue *=10;
                    shita *=10;
                }
            }
        }
    }
}

Measured memory_bytes: 20424
#include <algorithm>
#include <cmath>
#include <climits>
#include <cstring>
#include <cstdio>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map> //pair is also included in this library
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define REP(i, s, n) for(int i = (int)(s); i < (int)(n); i++)
#define fst first
#define snd second
#define MP make_pair //incase c++11 or later is not available

using namespace std;

typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//prefer define statement
//for reason that const int ver. of INF will raise a silly warning (unused variable)
#define INF (INT_MAX/3)
#define LIM_INF (INT_MAX)
//const int INF = INT_MAX/3;
#define PI = 3.14159265358979323846
/*------------------------------------------------------------------------------*/

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

  int seq[100010] = {};
  REP(i, 0, N){
    int tmp;
    scanf("%d ", &tmp);
    seq[tmp]++;
  }

  int ans = 0;
  if((N % 2) == 0){
    ans = 1;
    REP(i, 0, N){
      if((i % 2 == 0) && seq[i] != 0){
        ans = 0;
      } else if((i % 2 == 1) && seq[i] != 2) {
        ans = 0;
      }
    }
  } else if(seq[0] == 1){
    ans = 1;
    REP(i, 1, N){
      if((i % 2 == 1) && seq[i] != 0){
        ans = 0;
      } else if((i % 2 == 0) && seq[i] != 2){
        ans = 0;
      }
    }
    ans = pow(ans, N / 2);
  } else {
    ans = 0;
  }
  int m = pow(10, 9) + 7;
  REP(i, 0, N/2){
    ans = (ans * 2) % m;
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include<unordered_map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include<bitset>
#include<deque>
#include<string>
#include<list>
#include<iterator>
#include<sstream>
#include <algorithm>
#define lli long long int
#define lower(a) transform(a.begin(),a.end(),a.begin(),::tolower);

using namespace std;

const int N = 3e5 + 500;
const long long mod = 1e9 + 7;
const long long cmod = 998244353 ;
const long long inf = 1LL << 57;
const int M = 1e6 + 500;
const lli ths = 1LL << 40;

lli dp[N];

void solve()
{
    string s;
    cin>>s;
    s = '.' + s;
    bool ok = 1;
    for(int i = 1; i < s.size(); i += 2)
    {
        char x = s[i];
        if(x == 'L')
            ok = 0;
    }
    for(int i = 0; i < s.size(); i += 2)
    {
        char x = s[i];
        if(x == 'R')
            ok = 0;
    }
    if(ok)
        cout<<"Yes";
    else
        cout<<"No";
    return ;
}
/*
7
6 7 4 1 2 11 6
5
1 2 10 4 5
*/

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

    lli t;
    t = 1;
//    cin>>t;
    while(t --)
    {
        solve();
    }
    return 0;
}


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

enum Color{
  R = 0,
  G = 1,
  B = 2
};

signed main(){
  int n;
  cin >> n;
  Color rgbStr[4000];
  int rIndexes[4000];
  int rItr = 0;
  int gIndexes[4000];
  int gItr = 0;
  long counts[3];

  for(int i = 0; i < 3; i++)
    counts[i] = 0;

  for(int i = 0; i < n; i++){
    char rgb;
    cin >> rgb;
    Color col;
    switch(rgb){
      case 'R':
      col = R;
      break;

      case 'G':
      col = G;
      break;

      case 'B':
      col = B;
      break;
    }
    if(col == R){
      rIndexes[rItr] = i;
      rItr++;
    }
    if(col == G){
      gIndexes[gItr] = i;
      gItr++;
    }

    rgbStr[i] = col;
    counts[col]++;
  }
 

  long long allPair = counts[R] * counts[G] * counts[B];
  if(allPair <= 0){
    cout << 0 << endl;
    return 0;
  }

  long long wrongPairs = 0;
  for(int i = 0; i < rItr;i++){
    for(int j = 0; j < gItr; j++){
      int bigger, smaller;
      if(rIndexes[i] > gIndexes[j]){
        bigger = rIndexes[i];
        smaller = gIndexes[j];
      }else{
        bigger = gIndexes[j];
        smaller = rIndexes[i];
      }
      int checkDist = (bigger - smaller);
      int front = bigger + checkDist;
      int back = smaller - checkDist;
      int center = smaller + (checkDist / 2);

      if(front < n && rgbStr[front] == B){
        wrongPairs++;
      }
      if(back >= 0 && rgbStr[back] == B){
        wrongPairs++;
      }
      if(checkDist % 2 == 0 && rgbStr[center] == B){
        wrongPairs++;
      }
    }
  }
  allPair -= wrongPairs;
  if(allPair <= 0){
    cout << 0 << endl;
    return 0;
  }
  cout << allPair << endl;
}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <iomanip>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <tuple>
#include <deque>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#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()
int n;
int a[10000];
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
  	int a;
    cin >> n>>a;
    cout << n*n-a << "\n";
}


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

using namespace std;

int n , k;

int add (int a , int b) {
    a = (a % k + k) % k;
    b = (b % k + k) % k;
    return (a + b) % k;
}

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

    cin >> n >> k;

    vector<int> a(n + 1);
    for (int i = 1 ;i <= n ;i++)
        cin >> a[i];

    map<int , int> mp;
    mp[0]++;

    long long ans = 0;
    vector<int> save(n + 1);
    save[0] = 0;

    int sum = 0;
    for (int i = 1 ;i <= n ;i++) {
        sum = add(sum , a[i]);
        if (i - k >= 0)
            mp[save[i - k]]--;
        ans += mp[add(sum , -i)];
        mp[add(sum , -i)]++;
        save[i] = add(sum , -i);
    }

    cout << ans;
}


Measured memory_bytes: 14268
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const long long INF = 1LL << 60;

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

uintmax_t combination(unsigned int n, unsigned int r) {
  if ( r * 2 > n ) r = n - r;
  uintmax_t dividend = 1;
  uintmax_t divisor  = 1;
  for ( unsigned int i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int main()
{
    double r;
    cin >> r;

    double pi = 3.14159265258979323;

    double ans = 2*r*pi;

    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
#include <cstring>
#include <cctype>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
using namespace std;

#define REP(i, s, e) for (int i = (s); i < (e); i++)
#define REPI(i, s, e) for (int i = (s); i <= (e); i++)
#define rep(i, n) REP(i, 0, n)
#define repi(i, n) REPI(i, 0, n)
#define ALL(v) (v).begin(), (v).end()

#define dump(x) (cout << #x << " = " << x << endl)
#define dump2(x, y) (cout << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl)
#define dump3(x, y, z) (cout << "(" << #x << ", " << #y << ", " << #z << ") = (" << x << ", " << y << ", "<< z << ")" << endl)

typedef long long ll;
typedef pair<int, int> pii;

vector<ll> n2v(ll n)
{
	vector<ll> vs;
	while (n > 0) {
		vs.push_back(n%10);
		n /= 10;
	}
	reverse(ALL(vs));
	return vs;
}

ll v2n(vector<ll> &vs)
{
	ll n = 0;
	rep(i, vs.size())
		n = 10*n + vs[i];
	return n;
}

int main(void)
{
	int n, l;
	while (cin >> n >> l, n|l) {
		vector<ll> ns = n2v(n);
		if (l-ns.size() > 0) {
			reverse(ALL(ns));
			while(ns.size() < l) ns.push_back(0);
			reverse(ALL(ns));
		}

		vector<ll> done;

		ll a = v2n(ns);
		for (;;) {
			done.push_back(a);
			while(ns.size() < l) ns.push_back(0);

			sort(ALL(ns));
			ll mi = v2n(ns);
			reverse(ALL(ns));
			ll ma = v2n(ns);

			a = ma - mi;
			if (find(ALL(done), a) != done.end()) {
				int i, j;
				rep(k, done.size())
					if (done[k] == a) {
						j = k;
						break;
					}
				i = done.size();
				printf("%lld %lld %lld\n", j, a, i-j);
				break;
			}
			ns = n2v(a);
		}
	}
	return 0;
}

Measured memory_bytes: 1204
#include<stdio.h>
#include<math.h>

int main (void){

    int sq_y;
    int i;

    while(scanf("%d",&sq_y)!=EOF){
        int sq_area=0;
        for(i=0;i<600/sq_y;i++){
            sq_area+=pow(i*sq_y,2)*sq_y;
        }
        printf("%d\n",sq_area);

    }


    return 0;
}

Measured memory_bytes: 592
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn = 1005;
int n, k;
int niz[maxn];
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n >> k;
    for(int i=1;i<=n;i++)cin >> niz[i];
    sort(niz + 1, niz + n + 1);
    int rez = 0;
    for(int i=1;i<=k;i++)rez += niz[i];
    cout << rez << endl;
    return 0;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int A[51]; //袋の中に入ったビスケットの数
long long DP[51][2];
int main()
{
  int N,P;
  cin >> N >> P;

  for (int k = 0; k < 50; k++)
    for (int j = 0; j < 50; j++)
      DP[k][j] = 0;
  DP[0][0] = 1;

  for (int i = 1; i < N; i++)
    cin >> A[i];

  //動的計画法
  for (int i = 1; i <= N; i++){
    DP[i][0] += DP[i-1][0];
    DP[i][1] += DP[i-1][1];
    if (A[i]%2 == 0) {
      DP[i][0] += DP[i-1][0];
      DP[i][1] += DP[i-1][1];
    }
    else {
      DP[i][0] += DP[i-1][1];
      DP[i][1] += DP[i-1][0];
    }
  }

  cout << DP[N][P] << endl;
}

//中村　僚宏　j4-170555 https://beta.atcoder.jp/contests/agc017/tasks/agc017_a
//教室での位置　教卓から見て一番後ろの２行目にいた

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
using namespace std;
string add(string a,string b){
	string res;
	int sa=a.size(),sb=b.size(),va,vb,t=0;
	for(int i=1;i<=max(sa,sb);i++){
		if(sa-i<0)va=0;else va=a[sa-i]-'0';
		if(sb-i<0)vb=0;else vb=b[sb-i]-'0';
		if(t)va++;
		t=((va+vb)>9);res=(char)(va+vb-t*10+'0')+res;
	}
	if(t)res="1"+res;
	return res;
}
int main() {
	string a,b;
	int n;
	for(cin>>n;n--;){
		cin>>a>>b;
		a=add(a,b);
		if(a.size()>80){
			cout<<"overflow"<<endl;
		}else{
			cout<<a<<endl;
		}
	}
	return 0;
}

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

ab = [tuple(map(int, input().split())) for i in range(m)]


def connected(E, n):
    V = {i: False for i in range(1, n+1)}
    V[1] = True
    
    queue = []
    queue.append(1)
    while queue:
        i = queue.pop()
        for (a, b) in E:
            if i == a and not V[b]:
                V[b] = True
                queue.append(b)
            if b == i and not V[a]:
                V[a] = True
                queue.append(a)

    for i, b in V.items():
        if not b:
            return False
    return True

def rest(E, e):
    xs = []
    for f in E:
        if f != e:
            xs.append(f)
    return xs


count = 0
for e in ab:
    F = rest(ab, e)
    if not connected(F, n):
        count += 1
print(count)


Measured memory_bytes: 3064
/// Author: Sarfaraz Alam
# include <bits/stdc++.h>
# define pb push_back
# define ll long long
# define fi first
# define se second
# define all(vc) vc.begin(),vc.end()
# define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
# define DEBUG

using namespace std;

const int N = 1e5 + 7;
const int mod = 1e9 + 7;

int n, a[N], ans = 1, x;

int main()
{
    speed;
    #ifdef DEBUGfd
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif // DEBUG

    //Code begins

    ll s, c;
    cin>>s>>c;

    ll mini;
    ll max_c = c/2;
    mini = min(s, max_c);

    ll count = mini;

    c -= mini*2;
    if(c > 0)
    {
     count += c/4;
    }
    cout<<count<<endl;




    return 0;
}


Measured memory_bytes: 256
def check():
    N = int(input())
    H = list(map(int, input().split()))
    for i in range(N-2,-1,-1):
        if H[i]>H[i+1]+1:
            return 'No'
        if H[i]>H[i+1]:
            H[i] -= 1
    return 'Yes'
print(check())

Measured memory_bytes: 20696
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<map>

using namespace std;

#define memset_clear(_) memset(_,0,sizeof(_))
#define memset_clear_tre(_) memset(_,1,sizeof(_))
#define memset_clear_reg(_) memset(_,-1,sizeof(_))
#define memset_clear_max(_) memset(_,0x3f,sizeof(_))
#define memset_clear_min(_) memset(_,0x80,sizeof(_))
#define sqr(_) ((_)*(_))

#define int long long

inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9') {if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}

const int maxn=105;
int n,delta;
char s[maxn];

signed main(){
	scanf("%s",s);
	n=read();
	int len=strlen(s);
	for (int i=0;i<len;i++){
		int now=(s[i]-'0');
		if (now>1) {printf("%lld\n",now);return 0;}
		if (i>=n-1) {printf("%lld\n",now);return 0;}
	}
	return 0;
}

Measured memory_bytes: 256
/*
 
Coded and Decoded by : Yash Kapoor
 
*/
#include <bits/stdc++.h>
using namespace std;
 
#define ll          long long
#define ld          long double
#define pb          push_back
#define pf          push_front
#define mp          make_pair
#define pll         pair<ll,ll>
#define vl          vector<ll>
#define sl          set<ll> 
#define vll         vector<pll>
#define ml          map<ll,ll>
#define mll         map<pll,ll>
#define all(a)      a.begin(),a.end()
#define x           first
#define y           second
#define sz(x)       (ll)x.size()
#define dl          '\n'
#define why         (ll)1000000007
//#define why         (ll)998244353
#define lp(i,a,b)   for(ll i=a;i<b;++i)
#define lpr(i,a,b)  for(ll i=a;i>=b;i--)
#define lpd(i,x)    for(auto i:x)
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll inf = 1e18;
ld pi = 3.141592653589;
ll mod = why;
ll fast_power(ll base,ll power,ll mod){
    ll result=1;
    while(power){
        if(power%2)
        result=(result*base)%mod;
        base=(base*base)%mod;
        power/=2;
    }
    return result;
}
 
ll inverse(ll base,ll mod){
    return fast_power(base,mod-2,mod);
}

ll solve(){
    ll a,b,n; cin>>a>>b>>n;
    ll ans = 0;
    if(b-1 > n or b==1){
        cout<<(a*n)/b - a*(n/b);
        return 0;
    }
    for(ll i = b-1;i<=n;i+=b){
        ans=max(ans,(a*i)/b - a*(i/b));
    }
    cout<<ans;
    return 0;
}

int main(){
    ios
    ll t=1; 
    //cin>>t;
    while(t--){
        solve();
    }
}

Measured memory_bytes: 3612
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


class edge_t {
public:
  edge_t(int vv, int ww) : v(vv), w(ww) {};

public:
  int v;
  int w;
};


int N, a[111111];

std::vector<std::vector<edge_t>> G;

bool visit[111111];


void dfs(int i, int j)
{
  for (const auto& e : G[i]) {
    if (visit[e.v])
      continue;

    visit[e.v] = true;

    int jj = j ^ (e.w & 1);

    dfs(e.v, a[e.v] = jj);
  }
}


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N;

  G.resize(N);

  int u, v, w;

  for (int i = 0; i < N - 1; i ++) {
    std::cin >> u >> v >> w;

    u --;
    v --;

    G[u].emplace_back(v, w);
    G[v].emplace_back(u, w);
  }

  memset(a, -1, sizeof(a));

  a[0] = 0;

  memset(visit, 0, sizeof(visit));

  dfs(0, 0);

  for (int i = 0; i < N; i ++)
    std::cout << a[i] << std::endl;

  return 0;
}


Measured memory_bytes: 7552
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000000007; // 998244353
using ll = long long;
using namespace std;

int n;
vector<int> a;
vector<int> b;

vector<int> memo;
vector<bool> done;

int f( int x ){
	if( x <= 0 ) return 0;
	if( done[x] ) return memo[x];
	done[x] = true;
	int ans = inf;
	for( int i = 0; i < n; ++i ){
		ans = min( ans, f(x-a[i])+b[i] );
	}
	return memo[x] = ans;
}

int main(){
	int h; cin >> h >> n;
	a.resize(n); b.resize(n); memo.resize(h+1, 0); done.resize(h+1, false);
	for( int i = 0; i < n; ++i ) cin >> a[i] >> b[i];
	cout << f(h) << endl;
}

Measured memory_bytes: 768
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

 #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;
ll M;
ll K;

ll ltmp;
string stmp;
double dtmp;

int main(){

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

    cin >> N;

    double odd = N /2 + N%2;

    cout << fixed << setprecision(15) << odd/N << endl;
    

}

Measured memory_bytes: 3792
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <stack>
#include <vector>
#include <math.h>
#include <queue>

using namespace std;

struct Shop{
	bool operator<(const struct Shop &arg) const{ //sort??????????????????????????????????????????
		return location < arg.location;
	};

	int location;
};

void func(int distance){

	int shop_num,order_num;
	scanf("%d",&shop_num);

	Shop shop[shop_num+1];
	shop[0].location = 0;
	shop[shop_num].location = distance;	//?¨?????°????????????????<???????¨???¨???>

	scanf("%d",&order_num);

	for(int i = 1; i < shop_num; i++){
		scanf("%d",&shop[i].location);
	}

	sort(shop,shop+shop_num+1);

	int deli_loc,sum = 0,minimum,left,right,m,tmp;

	for(int loop = 0; loop < order_num; loop++){
		scanf("%d",&deli_loc);

		//2?????¢?´¢
		minimum = distance+1;
		left = 0; right = shop_num;
		m = (left+right)/2;

		while(left <= right){
			tmp = abs(shop[m].location-deli_loc); //?????¢????±???????

			if(tmp < minimum)minimum = tmp; //????°??????¢??´??°

			if(shop[m].location < deli_loc){ //shop[m]??????????????´???
				left = m+1;
			}else if(shop[m].location > deli_loc){ //shop[m]??????????????´???
				right = m-1;
			}else{ //shop[m].location == deli_loc
				break;
			}
			m = (left+right)/2;
		}
		sum += minimum;
	}

	printf("%d\n",sum);
}

int main(){

	int distance;

	while(true){
		scanf("%d",&distance);
		if(distance == 0)break;

		func(distance);
	}

    return 0;
}

Measured memory_bytes: 3564
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
0 0 2
2 0 2

output:
1.00000000 -1.73205080 1.00000000 1.73205080
"""

import sys
from math import pi, sin, cos, atan2, acos


class Circle(object):
    __slots__ = ('centre', 'radius')

    def __init__(self, centre=float('inf'), radius=-1):
        self.centre = complex(centre)
        self.radius = float(radius)


def arg(p_vector):
    return atan2(p_vector.imag, p_vector.real)


def polar(a, r):
    return cos(r) * a + sin(r) * a * 1j


def get_circles_cross_points(c1, c2):
    centre_distance = abs(c1.centre - c2.centre)
    a = acos((pow(c1.radius, 2) + pow(centre_distance, 2) - pow(c2.radius, 2)) /
             (2 * c1.radius * centre_distance))
    t = arg(c2.centre - c1.centre)
    p1, p2 = c1.centre + polar(c1.radius, t + a), c1.centre + polar(c1.radius, t - a)

    if p1.real < p2.real:
        ans = (p1, p2)
    elif p1.real == p2.real:
        if p1.imag < p2.imag:
            ans = (p1, p2)
        else:
            ans = (p2, p1)
    else:
        ans = (p2, p1)
    return ans


def solve(_circle_info):
    for i, circle in enumerate(_circle_info):
        cx, cy, r = map(int, circle)
        circles[i].centre = cx + cy * 1j
        circles[i].radius = r

    cp1, cp2 = get_circles_cross_points(*circles)
    print('{0:.8f} {1:.8f} {2:.8f} {3:.8f}'.format(cp1.real, cp1.imag, cp2.real, cp2.imag))
    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    circle_info = map(lambda x: x.split(), _input)

    circles = [Circle() for _ in range(2)]
    solve(circle_info)

Measured memory_bytes: 8104
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,b,a) for(int i=b;i>=a;i--)
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Forenska(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-x))
#define GREATER(x) x,vector<x>,greater<x>
#define randIn(L,R) (((LL)rand()*rand())%(R-L)+L)
#define __lcm(a,b) ((a)/__gcd(a,b)*(b))
using namespace std;
typedef long long LL;
typedef pair<int,int> pii;
typedef pair<LL,LL> pLL;
typedef vector<int> vec;
typedef vector<LL> vecL;
typedef vector<pii> vecP;
typedef vector<pLL> vecPL;
typedef vector<string> vecS;
typedef vector<vec> mat;
typedef complex<double> point;
const long double PI=3.14159265358979323846264338327950288419716939937510582097;
const LL INFLL=0x3f3f3f3f3f3f3f3f;
const int INF=0x3f3f3f3f;
const long double EPS=1e-10;
int read()
{
    int x=0;
    char ch=' ';
    bool flag=false;
    while(ch<'0' || ch>'9')
    {
        if(ch=='-')flag=true;
        ch=getchar();
    }
    while(ch>='0' && ch<='9')
    {
        x=(x<<3)+(x<<1)+ch-'0';
        ch=getchar();
    }
    return flag?-x:x;
}

int main()
{
	int a,b;
	cin>>a>>b;
	int ans=0;
	For(i,a,b)
	{
		int x=i,res=0;
		while(x)
		{
			res=res*10+x%10;
			x/=10;
		}
		if(res==i)ans++;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.util.*;
import java.util.Map.Entry;

import java.io.*;

public class Main{
static int mod=(int)1e9+7;
static long dp[];
static long score[];
public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int n=scn.nextInt();
		long mat[][]=new long[n][n];
		for(int i=0;i<n;i++){
			for(int j=0;j<n;j++){
				mat[i][j]=scn.nextLong();
			}
		}
		dp=new long[(1<<n)+1];
		Arrays.fill(dp, Integer.MIN_VALUE/2);
		score=new long[(1<<n)+1];
		for(int i=0;i<(1<<n);i++){
			long sc=0;
			for(int j=0;j<n;j++){
				for(int k=j+1;k<n;k++){
					if(((1<<j)&i)!=0 && ((1<<k)&i)!=0){
						sc+=mat[j][k];
					}
				}
			}
			score[i]=sc;
		}
		long ans=solve((1<<n)-1);
		System.out.println(ans);
		
		
		
		
		


	}
private static long solve(int mask) {
	if(mask==0){
		return 0;
	}
	if(dp[mask]!=Integer.MIN_VALUE/2){
		return dp[mask];
	}

	long res=0;

	for(int submask=mask;submask!=0;submask=(submask-1)&mask){
		
		res=Math.max(res, score[submask]+solve(submask^mask));
	}
	
	
	
	return dp[mask]=res;
}

}

Measured memory_bytes: 24788
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<vector<vector<int>>> v3int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef vector<vector<vector<ll>>> v3ll;
typedef list<int> liint;
typedef pair<int, int> pint;
typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, int>> vpll_int;
typedef vector<pair<int, ll>> vpint_ll;
typedef set<pair<int, int>> spint;
typedef set<pair<ll, int>> spll;
typedef unordered_map<int, unordered_set<int>> Graph;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    ll D;
    cin >> N >> D;
    vll X(N), Y(N);
    rep(i, N) cin >> X[i] >> Y[i];
    ll ans = 0;
    rep(i, N) {
        if ((X[i] * X[i] + Y[i] * Y[i]) <= (D * D)) ans++;

    }

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

Measured memory_bytes: 6348
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF 1e18
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define PI (acos(-1))

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

int main() {
    int A, B;
    cin >> A >> B;
    A += B;
    if (A < 10) cout << A << endl;
    else cout << "error" << endl;

    return 0;
}

Measured memory_bytes: 888