akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    ($ttype:ty) => {
        {
            let mut input = String::new();
            let _= std::io::stdin().read_line(&mut input);
            input.trim().parse::<$ttype>().unwrap()
        }
    };

    ($($ttype:ty),*) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let mut iter = input.trim().split_whitespace();
            (
                $(iter.next().unwrap().parse::<$ttype>().unwrap(),)*
            )
        }
    };

    ($ttype:ty; $x:expr) => {
        {
            use std::io::BufRead;
            let mut input = String::new();
            let stdin = std::io::stdin();
            let _ = stdin.lock().read_line(&mut input);
            let v: Vec<$ttype> = input
                .trim()
                .split_whitespace()
                .map(|x| x.parse().unwrap())
                .collect();
            v
        }
    };

    ($ttype:ty; $x:expr; $y:expr) => {
        {
            use std::io::BufRead;
            let mut matrix = Vec::with_capacity($y);
            for _ in 0..$y {
                let mut input = String::new();
                let stdin = std::io::stdin();
                let _ = stdin.lock().read_line(&mut input);
                let v: Vec<$ttype> = input
                    .trim()
                    .split_whitespace()
                    .map(|x| x.parse().unwrap())
                    .collect();
                matrix.push(v);
            }
            matrix
        }
    };
}

fn main() {
    let n = input!(usize);
    let mut f: Vec<Vec<i64>> = Vec::with_capacity(n);
    let mut p: Vec<Vec<i64>> = Vec::with_capacity(n);

    for _ in 0..n {
        f.push(input!(i64; n));
    }
    for _ in 0..n {
        p.push(input!(i64; n));
    }

    let mut max_benefit: i64 = i64::min_value();
    for i in 1..2_i32.pow(10) {    // 少なくとも1つ出店しないするため1~
        let mut benefit: i64 = 0;
        let mut counter: Vec<i64> = vec![0; n];
        for j in 0..10 {
            if i & (1 << j) > 0 {   // joisinoがjに出店しているとき
                for k in 0..n {
                    if f[k][j] == 1 {    // 店kがjにも出店していたら
                        counter[k] += 1;    // 店kとの重複出店舗数を+1
                    }
                }
            }
        }
        for (k, &cnt) in counter.iter().enumerate() {
            benefit += p[k][cnt as usize];    // 店kとcnt店舗重複しているときの利益
        }
        if benefit > max_benefit {
            max_benefit = benefit;
        }
    }
    println!("{}", max_benefit);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
  int main(){
    int N, A, a, n=50, p;
    cin>>N;
    
    for(int i=1; i<=N; i++){
      cin >> A;
      a=0, p=0;
      for(int j=1; p==0; j++){
        p=A%2;
        A/=2;
        if(p==0)
          a=j;
      }
      if(n>a)
        n=a;
    }
    cout<<n<<endl;
  }

Measured memory_bytes: 256
#dpでできないかな？
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
n=I()
lis=LI()
c=Counter(lis)
nums=[]
for i in c.keys():
    if c[i]>=2:
        nums.append(i)
nums.sort(reverse=True)
#print(nums)
if len(nums)==0:
    print(0)
elif len(nums)==1:
    if c[nums[0]]>=4:
        print(nums[0]**2)
    else:
        print(0)
else:
    if c[nums[0]]>=4:
        print(nums[0]**2)
    else:
        print(nums[0]*nums[1])


Measured memory_bytes: 18504
#include <iostream>
#include <cstring>
using namespace std;
int main()
{
    char a[55];
    char b[55];
    char c[105];
    while(cin >> a >> b)
    {
        int l = strlen(a) + strlen(b);
        int j=0, k=0, i;
        for(i = 0; i < l; i++)
        {
            if(a[j]!='\0' && b[k]!='\0')
            {
                if(i % 2 == 0)
                    c[i] = a[j++];
                else
                    c[i] = b[k++];
            }
            else if(a[j]=='\0')
            {
                c[i] = b[k++];
            }
            else
                c[i] = a[j++];
        }
        c[i] = '\0';
        cout << c << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>

typedef long long ll;
const int MAX_N = 100000;
ll x[MAX_N];
ll v[MAX_N];
ll m[4][MAX_N+1];

ll max(ll a, ll b) {
	return a > b ? a : b;
}
int main() {
	int n;
	ll c;
	scanf("%d %lld", &n, &c);
	for(int i=0;i<n;i++) {
		scanf("%lld %lld", &x[i], &v[i]);
	}
	ll v_sum = 0;
	ll max0 = 0;
	ll max1 = 0;
	m[0][0] = m[1][0] = 0;
	for(int i=1;i<=n;i++) {
		v_sum += v[i-1];
		ll v0 = v_sum - x[i-1];
		ll v1 = v_sum - 2 * x[i-1];
		if(max0 < v0) max0 = v0;
		if(max1 < v1) max1 = v1;
		m[0][i] = max0;
		m[1][i] = max1;
	}
	v_sum = 0;
	ll max2 = 0;
	ll max3 = 0;
	m[2][n] = m[3][n] = 0;
	for(int i=n-1;i>=0;i--) {
		v_sum += v[i];
		ll v2 = v_sum - (c - x[i]);
		ll v3 = v_sum - 2 * (c - x[i]);
		if(max2 < v2) max2 = v2;
		if(max3 < v3) max3 = v3;
		m[2][i] = max2;
		m[3][i] = max3;
	}
	ll ans = 0;
	for(int i=0;i<=n;i++) {
		ll v = max(max(max(m[0][i], m[2][i]), m[0][i]+m[3][i]), m[1][i]+m[2][i]);
		if(ans < v) ans = v;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 4864
#include <algorithm>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <vector>
using namespace std;


enum FACE { NORTH, SOUTH, WEST, EAST, TOP, BOTTOM };

class dice {
private:
	int num[6];

	inline void roll(FACE a, FACE b, FACE c, FACE d) {
		const auto tmp = num[a];
		num[a] = num[b];
		num[b] = num[c];
		num[c] = num[d];
		num[d] = tmp;
	}

public:
	dice() {
		num[TOP] = 1;
		num[BOTTOM] = 6;
		num[NORTH] = 3;
		num[SOUTH] = 4;
		num[EAST] = 5;
		num[WEST] = 2;
	}

	void set(int t, int f) {
		if(num[EAST] == t || num[WEST] == t) west();
		while(num[TOP] != t) north();
		while(num[NORTH] != f) ccw();
	}

	inline const int &operator[](FACE f) const { return num[f]; }

	inline void north() { roll(TOP, SOUTH, BOTTOM, NORTH); }
	inline void east()  { roll(TOP, WEST, BOTTOM, EAST); }
	inline void west()  { roll(TOP, EAST, BOTTOM, WEST); }
	inline void south() { roll(TOP, NORTH, BOTTOM, SOUTH); }

	inline void ccw() { roll(SOUTH, EAST, NORTH, WEST); }
	inline void cw()  { roll(SOUTH, WEST, NORTH, EAST); }
};

constexpr int SIZE = 30;
int cnt[7];
int top[SIZE][SIZE];
int height[SIZE][SIZE];

constexpr int dx[4] = {0, 0, -1, 1};
constexpr int dy[4] = {-1, 1, 0, 0};
void (dice::*func[4])() = {&dice::north, &dice::south, &dice::west, &dice::east};

void drop(int x, int y, dice d) {
	typedef pair<int, FACE> P;

	while(true) {
		vector<P> v{{d[NORTH], NORTH}, {d[SOUTH], SOUTH}, {d[EAST], EAST}, {d[WEST], WEST}};
		sort(begin(v), end(v), greater<P>());

		for(int i = 0; i < 3; ++i) {
			const int num = v[i].first;
			const int dir = v[i].second;

			if(num <= 3) break;

			const int nx = x + dx[dir];
			const int ny = y + dy[dir];
			if(height[y][x] > height[ny][nx]) {
				(d.*func[dir])();
				x = nx;
				y = ny;
				goto next;
			}
		}

		--cnt[top[y][x]];
		++cnt[d[TOP]];
		top[y][x] = d[TOP];
		++height[y][x];
		return;
	next:;
	}
}

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

	constexpr int sx = SIZE / 2, sy = SIZE / 2;
	for(int n; cin >> n, n;) {
		memset(cnt, 0, sizeof(cnt));
		memset(top, 0, sizeof(top));
		memset(height, 0, sizeof(height));

		for(int i = 0; i < n; ++i) {
			int t, f;
			cin >> t >> f;

			dice d;
			d.set(t, f);
			drop(sx, sy, d);
		}

		for(int i = 1; i <= 6; ++i) {
			cout << cnt[i] << (i == 6 ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1212
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define int long long
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
signed main()
{
    SPEED;
    int a,b,g;
    cin>>a>>b;
    g=__gcd(a,b);
    cout<<a*b/g;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

var (
	sc = bufio.NewScanner(os.Stdin)
	bw = bufio.NewWriter(os.Stdout)
)

const inf = 1 << 60
const mod int = 1e9 + 7

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1e7), 1e7)
}

func ri() (n int) {
	sc.Scan()
	for _, v := range sc.Bytes() {
		n = n*10 + int(v-48)
	}
	return
}

func printf(format string, a ...interface{}) {
	_, _ = fmt.Fprintf(bw, format, a...)
	return
}

func fill(a []int, val int) {
	for i := 0; i < len(a); i++ {
		a[i] = val
	}
	return
}

func main() {
	defer bw.Flush()
	n, q := ri(), ri()

	vertex := make([]int, n)
	parent := make([]int, n)
	fill(parent, -1)
	for i := 0; i < n-1; i++ {
		a, b := ri()-1, ri()-1
		parent[b] = a
	}

	for i := 0; i < q; i++ {
		p, x := ri()-1, ri()
		vertex[p] += x
	}

	ans := make([]int, n)
	for i, v := range vertex {
		res := v

		if parent[i] != -1 {
			res += ans[parent[i]]
		}

		ans[i] = res
	}

	for i, v := range ans {
		if i == n-1 {
			printf("%v\n", v)
		} else {
			printf("%v ", v)
		}
	}
}


Measured memory_bytes: 16384
package main

import (
  "fmt"
)

func main() {
  var N, M int
  fmt.Scanf("%d %d\n", &N, &M)
  graph := make(map[int][]int, N)
  var x, y int
  for i:=0;i<=M;i++ {
    fmt.Scanf("%d %d\n", &x, &y)
    if graph[x] == nil {
      graph[x] = make([]int, 0)
    }
    graph[x] = append(graph[x], y)
  }
  fmt.Println(solve(N, graph))
}

func solve(n int, g map[int][]int) int {
  res := 0
  dp := make(map[int]int, n)
  for i:=1;i<=n;i++ {
    res = max(res, dfs(i, g, dp))
  }
  return res
}

// 使用dp[i] 记忆化dfs(i) 减少计算
func dfs(i int, g map[int][]int, dp map[int]int) int {
  if v, ok := dp[i]; ok {
    return v
  }
  temp := 0
  for _, nv := range g[i] {
    temp = max(temp, dfs(nv, g, dp)+1)
  }
  dp[i] = temp
  return temp
}

func max(a, b int) int {
  if a > b {
    return a
  }
  return b
}


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

using namespace std;

char s[201];
int num1[201],num2[201];


int main()
{
	scanf("%s",s);
	int n=strlen(s);
	bool p=false;
	for(int i=1;i<n;i++)
	{
		if(s[i]!=s[i-1])
		{
			p=true;
			break;
		}
	}
	if(p==false)
	{
		cout<<0;
		return 0;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=i-1;j>=0;j--)
		{
			if(s[j]==s[i])break;
			if(s[j]!=s[i])num1[i]+=1;
		}
		for(int j=i+1;j<n;j++)
		{
			if(s[j]!=s[i])num2[i]+=1;
		}
	}
	int ans=9999999;
	for(int i=1;i<=26;i++)
	{
		int ans1=0;
		int ans2=9999999;
		int ansz=0;
		for(int j=0;j<n;j++)
		{
			int z=s[j];
			if(z==97+i-1)
			{
			    ans1=max(ans1,num1[j]);
			    ans2=min(ans2,num2[j]);
			}
		}
		ansz=max(ans1,ans2);
		if(ansz!=0)	ans=min(ans,ansz);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

int n;
const int INF = 1e9;
set<pii> used;

using T = tuple<int, int, int>;
// dis, v, pre

vector<int> dijkstra(int s, vector<vector<pii>> G) {
  priority_queue<T, vector<T>, greater<T>> que;
  vector<int> d(n, INF);
  d[s] = 0;
  que.push(T(0, s, s));

  while(!que.empty()) {
    T p = que.top(); que.pop();
    int dis = get<0>(p);
    int v = get<1>(p);
    int pre = get<2>(p);

    if (d[v] < dis) continue;
    if (v != pre) used.insert(pii(min(v, pre), max(v, pre)));
    for (auto&& e : G[v]) {
      if (d[e.first] > d[v] + e.second) {
        d[e.first] = d[v] + e.second;
        que.push(T(d[e.first], e.first, v));
      }
    }
  }
  return d;
}

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

  int m;
  cin >> n >> m;
  vector<vector<pii>> graph(n);
  rep(i, m) {
    int a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    graph[a].push_back(pii(b, c));
    graph[b].push_back(pii(a, c));
  }

  rep(i, n) {
    dijkstra(i, graph);
  }
  cout << m - used.size() << endl;
}


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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, t) for (int i = (s); i < (int)(t); i++)
typedef long long ll;
const ll mod = 1e9 + 7;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> nl(N + 1);
    vector<pair<int, int>> edges(M);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        nl[a].emplace_back(b);
        nl[b].emplace_back(a);
        edges[i] = make_pair(a, b);
    }

    int cnt = 0;
    for (pair<int, int> &edge: edges) {
        stack<int> st;
        unordered_set<int> seen;
        st.push(1);
        while (!st.empty()) {
            int v = st.top();
            st.pop();
            seen.insert(v);
            for (int &next_v: nl[v]) {
                if ((v == edge.first && next_v == edge.second) || (v == edge.second && next_v == edge.first)) {
                    continue;
                } else if (seen.find(next_v) == seen.end()) {
                    st.push(next_v);
                }
            }
        }
        if (seen.size() < N) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main() {
	int N, D, X;
	int cnt = 0;
	vector<int> A;

	cin >> N >> D >> X;
	for (int i = 0; i < N; i++)
	{
		int a;
		cin >> a;
		A.push_back(a);
	}

	for (int i = 0; i < N; i++)
	{
		cnt += (D / A.at(i));
		if (D % A.at(i)!=0) {
			cnt++;
		}
	}

	cout << cnt + X << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
def input(): return sys.stdin.readline().strip()

def resolve():
    n=int(input())
    l=list(map(int,input().split()))
    ans=1
    if 0 in l:
        print(0)
    else:
        for i in l:
            ans*=i
            if ans>10**18:
                ans=-1
                break
        print(ans)
resolve()

Measured memory_bytes: 21792
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  int x = 1;
  //A:x*=2
  //B:x+=k
  //操作AまたはBをn回行う
  //最小の数値を出力すること
  for(int i=0;i<n;i++){
    if(x*2 < x+k){
      x*=2;
    }else{
      x+=k;
    }
  }
  cout << x << endl;
}


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

int main(){

	int n;
	cin>>n;
	vector<double> A(n);
	//double ans = 0;
	for(int i = 0; i<n; i++){
		cin>>A[i];
		//ans+=1/A[i];
	}
	sort(A.begin(), A.end());
	for(int  i = 0; i<n-1; i++){
		double sum = (A[i]+A[i+1])/2;
		A[i+1] = sum;
	}
	cout<<A[n-1]<<endl;

	return 0; 
}

Measured memory_bytes: 256
#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)


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);

  int N, c[66] = {0};

  long long K, A[111111], Ap = 0, t;

  std::cin >> N >> K;

  for (int i = 0; i < N; i ++) {
    std::cin >> A[i];

    if (A[i] > Ap)
      Ap = A[i];

    t = A[i];

    for (int j = 0; t; t >>= 1, j ++)
      if (t & 1)
        c[j] ++;
  }

  std::reverse(c, c + 55);

  long long dp[66][2];

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

  dp[0][0] = 0;

  for (int i = 0; i < 55; i ++) {
    for (int j = 0; j < 2; j ++)
      if (dp[i][j] >= 0) {
        long long b = 1LL << (55 - i - 1);
      
        int x = j ? 1 : (K & b) ? 1 : 0;
      
        for (int k = 0; k <= x; k ++) {
          int jj = j || k < x;

          dp[i + 1][jj] = std::max((k == 0 ? c[i] : N - c[i]) * b + dp[i][j], dp[i + 1][jj]);
        }
      }
  }

  std::cout << std::max(dp[55][0], dp[55][1]) << std::endl;
    
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,n) for(int i=0;i<(n);i++)
#define P pair<int,int>
#define int long long
#define LONG LLONG_MAX/3;
#define INT INT_MAX/3;
#define mod 1000000007
typedef long long ll;
using namespace std;

pair<P,int> p[100000];
string s[100000];

int keta(int a){
	int b=0;
	while(a){
		a/=10;
		b++;
	}
	return b;
}
int mypow(int a,int b){
	if(b==0)return 1;
	if(b%2)return mypow(a,b-1)*a%mod;
	return mypow(a,b/2)*mypow(a,b/2)%mod;
}
int kaijo(int n){
	int ans=1;
	for(int i=1;i<=n;i++){
		ans*=i;
		ans%=mod;
	}
	return ans;
}
int gcd(int a,int b){
	if(b==0) return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}

signed main(){
	int n,m,x=1;
	cin>>n>>m;
	f(i,m){
		cin>>p[i].first.first>>p[i].first.second;
		p[i].second=i;
	}
	sort(p,p+m);
	f(i,m){
		if(i){
			if(p[i].first.first==p[i-1].first.first) x++;
			else x=1;
		}
		f(j,6-keta(p[i].first.first)) s[p[i].second]+="0";
		s[p[i].second]+=to_string(p[i].first.first);
		f(j,6-keta(x)) s[p[i].second]+="0";
		s[p[i].second]+=to_string(x);
	}
	f(i,m) cout<<s[i]<<endl;
	return 0;
}


Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
#define N 510
#define pb push_back
vector<int> v[N];
int a[N],b[N],vis[N];
int s[10000010];
inline int read() {
    int x=0;
    char ch=getchar();
    while (!isdigit(ch)) ch=getchar();
    while (isdigit(ch)) x=x*10+ch-'0',ch=getchar();
    return x;
}
inline int P(int x) {
    if (x<2) return false;
    for (int i=2;i<=sqrt(x);i++)
        if (x%i==0) return false;
    return true;
}
int mat[N];
inline int dfs(int x) {
    for (auto y:v[x]) {
        if (vis[y]) continue; vis[y]=true;
        if (!mat[y] || dfs(mat[y])) return mat[y]=x,1;
    }
    return false;
}
int main() {
    int n=read(),Max=0,cnta=0,cntb=0,ans=0,res=0;
    for (int i=1;i<=n;i++) s[Max=max(Max,read())]^=1;
    for (int i=1;i<=Max+1;i++) if (s[i]!=s[i-1])
        ((i&1)?(a[++cnta]):(b[++cntb]))=i;
    // cout<<cnta<<endl;
    // cout<<cntb<<endl;
    for (int i=1;i<=cnta;i++)
        for (int j=1;j<=cntb;j++) if (P(abs(a[i]-b[j]))) v[i].pb(j);
    for (int i=1;i<=cnta;i++) {
        for (int j=1;j<=cntb;j++) vis[j]=0; ans+=dfs(i);
    }
    // cout<<ans<<endl;
    res+=(cnta-ans)/2*2;
    res+=(cntb-ans)/2*2;
    res+=ans+((cnta-ans)&1)*3;
    cout<<res<<endl;
    return 0;
}

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

#define int long long
#define ff first
#define ss second
#define endl "\n"
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x.size())
int powmod(int a,int l, int md){a%=md; int res=1;while(l){if(l&1)res=res*a%md;l/=2;a=a*a%md;}return res;}
int binpow(int a,int l){int res=1;while(l){if(l&1)res=res*a;l/=2;a=a*a;}return res;}
int invmod(int a, int md){return powmod(a,md-2,md);}
typedef long long ll; typedef unsigned long long ull; typedef long double ld;
typedef vector<int> vi; typedef pair<int, int> ii; typedef vector< ii > vii;
#define pb push_back
int __set(int b, int i) {return b|(1LL<<i);} //set ith bit
int __unset(int b, int i) {return b&(~(1UL<<i));}
int __check(int b, int i) {return b&(1LL<<i);} //returns 0 if ith bit is 0
int mulmod(int a, int b, int md) {return (((a%md)*(b%md))%md+md)%md;}
int addmod(int a, int b, int md) {return ((a%md+b%md)%md+md)%md;}
int submod(int a, int b, int md) {return (((a%md-b%md)%md)+md)%md;}
int divmod(int a, int b, int md) {return mulmod(a, powmod(b, md-2, md), md);} //if md is prime;
// const ll inf = 0xFFFFFFFFFFFFFFFL; //very large number
// priority_queue<ii, vector<ii>, greater<ii> > pq; //for min priority_queue
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int MOD=1e9+7;

const int MX = 400010;

int f[MX];
int rf[MX];

int C(int l,int k, int md) 
{
    if (k<0||k>l){
        return 0;
    }
    return f[l]*rf[k]%md*rf[l-k]%md;
}

void precfac() {
    f[0]=1;
    for (int i=1;i<MX;i++){
        f[i]=f[i-1]*i%MOD;
    }
    rf[MX-1]=powmod(f[MX-1],MOD-2, MOD);
    for (int i=MX-2;i>=0;i--){
        rf[i]=rf[i+1]*(i+1)%MOD;
    }
}

int n,seen[200010],sub[200010],ch[200010];
vector<vi> g(200010);
void dfs(int u, int root=0) {
	seen[u]=1;
	sub[u]=1;
	for(int v: g[u]) {
		if(!seen[v]) {
			dfs(v,root);
			sub[u]+=sub[v];
		}
	}
	ch[root]*=invmod(sub[u],MOD);
	ch[root]%=MOD;
	// cout<<u+1<<" "<<ch[root]<<endl;
}

void dfs1(int u) {
	seen[u]=1;
	for(int v: g[u]) {
		if(!seen[v]) {
			int oldu=sub[u],oldv=sub[v];
			sub[u]=sub[u]-sub[v],sub[v]=n;
			ch[v]=oldv*invmod(sub[u],MOD);
			ch[v]%=MOD;
			ch[v]*=ch[u];
			ch[v]%=MOD;
			dfs1(v);
			sub[u]=oldu,sub[v]=oldv;
		}
	}
}
signed main(void)
{
	IOS;
	precfac();
	cin>>n;
	for(int i = 0; i < n-1; i++) {
		int u,v; cin>>u>>v;
		g[u-1].pb(v-1);
		g[v-1].pb(u-1);
	}
	ch[0]=1;
	dfs(0);
	// cout<<ch[0]<<endl;
	ch[0] *= f[n-1];
	ch[0] %= MOD;
	ch[0] *= n;
	ch[0] %= MOD;
	memset(seen,0,sizeof(seen));
	dfs1(0);
	for(int i = 0; i < n; i++)
		cout<<ch[i]<<endl;	
	return 0;
}

Measured memory_bytes: 25712
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    max_dist = 0
    A.append(K + A[0])

    for i in range(N):
        max_dist = max(max_dist, A[i+1] - A[i])

    print(K - max_dist)


if __name__ == '__main__':
    main()


Measured memory_bytes: 25448
s = input()
cnt = 0
for i in range(len(s)):
    if i%2==0 and (s[i] == "R" or s[i] == "U" or s[i] == "D"):
        cnt += 1
    elif i%2 == 1 and (s[i]=="L" or s[i] == "U" or s[i]=="D"):
        cnt+=1
if cnt == len(s):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a, b;
		
		while(scanner.hasNext()) {
			a = scanner.nextInt();
			b = scanner.nextInt();
			if (a == 0 && b == 0) {
				System.out.println(1);
			} else {
				System.out.println((int)Math.floor(Math.log10(a + b)) + 1);
			}
		}
	}
}

Measured memory_bytes: 26376
#include <iostream>
#include <vector>
#include <climits>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <string>
#include <bitset>
#include <utility>
#include <numeric>
#include <queue>
#include <stack>

using ll = long long;
using namespace std;

constexpr int MOD = 1e9 + 7;
constexpr ll MOD_LL = ll(1e9) + 7;

int main(void) {
	string s;
	cin >> s;
	
	if( s[2] == s[3] && s[4] == s[5] ) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
#![allow(unused_imports)]
use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    a: [usize; n]
    }
    let mut ans:usize = 1;
    if a.contains(&0){
        println!("0");
        return
    }
    for i in a{
        if let Some(x) = ans.checked_mul(i) {
            ans = x;
        } else {
            println!("-1");
            return
        }
        if ans > 10usize.pow(18){
            println!("-1");
            return
        }
    }
    println!("{}", ans);
}


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

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

using namespace std;
using lint=long long;

class rolling_hash{
	static const long long base=10007,mod1=1e9+7,mod2=1e9+9;
	int len;
	vector<long long> pow1,pow2,h1,h2;
public:
	using hash_type=pair<long long,long long>;
	rolling_hash(){}
	rolling_hash(const string& s):len(s.length()),pow1(len+1),pow2(len+1),h1(len+1),h2(len+1){
		pow1[0]=pow2[0]=1;
		rep(i,len){
			pow1[i+1]=pow1[i]*base%mod1;
			pow2[i+1]=pow2[i]*base%mod2;
			h1[i+1]=(h1[i]*base+s[i])%mod1;
			h2[i+1]=(h2[i]*base+s[i])%mod2;
		}
	}
	template<class T>
	rolling_hash(const vector<T>& a):len(a.size()),pow1(len+1),pow2(len+1),h1(len+1),h2(len+1){
		pow1[0]=pow2[0]=1;
		rep(i,len){
			pow1[i+1]=pow1[i]*base%mod1;
			pow2[i+1]=pow2[i]*base%mod2;
			h1[i+1]=(h1[i]*base+a[i])%mod1;
			h2[i+1]=(h2[i]*base+a[i])%mod2;
		}
	}
	hash_type get_hash(int l,int r)const{
		assert(0<=l && l<=r && r<=len);
		auto res1=(h1[r]-h1[l]*pow1[r-l])%mod1; if(res1<0) res1+=mod1;
		auto res2=(h2[r]-h2[l]*pow2[r-l])%mod2; if(res2<0) res2+=mod2;
		return {res1,res2};
	}
	static hash_type get_hash(const string& s){
		long long res1=0,res2=0;
		rep(i,s.length()){
			res1=(res1*base+s[i])%mod1;
			res2=(res2*base+s[i])%mod2;
		}
		return {res1,res2};
	}
	template<class T>
	static hash_type get_hash(const vector<T>& a){
		long long res1=0,res2=0;
		rep(i,a.size()){
			res1=(res1*base+a[i])%mod1;
			res2=(res2*base+a[i])%mod2;
		}
		return {res1,res2};
	}

	hash_type f(int l,int r,char c){
		auto res1=(h1[r]-h1[l]*pow1[r-l])%mod1; if(res1<0) res1+=mod1;
		auto res2=(h2[r]-h2[l]*pow2[r-l])%mod2; if(res2<0) res2+=mod2;
		res1=(pow1[r-l]*c+res1)%mod1;
		res2=(pow2[r-l]*c+res2)%mod2;
		return {res1,res2};
	}
};

int main(){
	int n; cin>>n;
	vector<string> s(n);
	rep(i,n) cin>>s[i];

	vector<bool> L(1e6+1);
	rep(i,n) L[s[i].length()]=true;

	vector<rolling_hash::hash_type> H;
	rep(i,n){
		int len=s[i].length();

		int freq[128]={};
		rep(j,len) freq[s[i][j]]++;

		rolling_hash R(s[i]);
		for(int j=len;j>=0;j--){
			if(L[len-j+1]){
				for(int c='a';c<='z';c++) if(freq[c]) {
					H.emplace_back(R.f(j,len,c));
				}
			}
			if(j>0) freq[s[i][j-1]]--;
		}
	}

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

	lint ans=0;
	rep(i,n){
		auto p=equal_range(H.begin(),H.end(),rolling_hash::get_hash(s[i]));
		ans+=p.second-p.first-1;
	}
	printf("%lld\n",ans);

	return 0;
}


Measured memory_bytes: 529732
/* Author VS_CODE */

#include<bits/stdc++.h>
#define int long long
#define TCI int t;cin>>t;while(t--)
#define run(n) for(int i=1;i<=n;i++)
#define cinl(n) for(int i=0;i<n;i++)
#define ln "\n"
#define vpair vector< pair <int , int > >
#define fr first
#define sc second
#define pb emplace_back
#define vll vector<int>
#define inf 0x3f3f3f3f3f3f3f3fLL
#define Point complex<int>
using namespace std;

void online()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
/* CODE STARTS HERE */

template<typename T>
void debug(T x)
{
	cout<<x<<ln;
}

const int N = 1e5;

void solve()
{
	int n;
	cin>>n;
	if(n>=30)
		cout<<"Yes";
	else
		cout<<"No";
}


/* CODE ENDS HERE AND MAIN STARTS */

int32_t main()
{

	online();
	//TCI
	solve();
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = 1LL<<59;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

void solve() {
    ll N;
    cin >> N;
    vll A(3*N);
    for(auto &a:A) cin >> a;
    DESC(A);
    ll ans = 0;
    REP(i, N) {
        ans += A[2*i+1];
    }
    out(ans);
}

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

Measured memory_bytes: 2560
<?php
$n=trim(fgets(STDIN));
$a=explode(" ",trim(fgets(STDIN)));
$ans=(int)1000;
$i=1;
while($i<$n){
if($a[$i-1]<$a[$i]){
$k=floor($ans/$a[$i-1]);
$ans+=(int)$k*($a[$i]-$a[$i-1]);
}
++$i;
}
echo $ans;

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

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

int main(void){

    int x;
    rep(i, 5){
        cin >> x;
        if(x == 0) cout << i+1 << endl;
    }

    return 0;
}

Measured memory_bytes: 3548
process.stdin.resume();
process.stdin.setEncoding('utf8');

function Main(input){
    lines = input.split(" ");
    n = parseInt(lines[0]);
    m = parseInt(lines[1]);
    ans = "";
    if (n == m){
        ans = "Yes";
    } else {
        ans = "No";
    }
    console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7500
'use strict'
function Main(input) {
  const ar = input.split("\n").map(x => x.split(" "));
  const N = ar[0][0];
  const [T, A] = ar[1];
  const H = ar[2];
 
  const a = [];
 
  for (let i = 0; i < H.length; i++) {
    a.push([i, Math.abs(T * 1000 - H[i] * 6 - A * 1000)]);
  }
 
  console.log(a.reduce((x, y) => x[1] < y[1] ? x : y)[0] + 1);
 
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

cnt = 0
for i in range(1, n+1):
    if i%2 == 0:
        continue

    cnt_yakusu = 0
    for j in range(1, i+1):
        if j%2 == 0:
            continue
        if i%j == 0:
            cnt_yakusu += 1
    if cnt_yakusu == 8:
        cnt += 1
print(cnt)


Measured memory_bytes: 38896
INFTY = 1<<21
WHITE = 0
GRAY  = 1
BLACK = 2

N = gets.to_i
@a = N.times.map{gets.split.map(&:to_i)}

@m = Array.new(N){Array.new(N){INFTY}}

def dijkstra
  d = Array.new(N){INFTY}
  color = Array.new(N){WHITE}

  d[0] = 0
  color[0] = GRAY

  loop do
    minv = INFTY
    u = -1

    (0...N).each do |i|
      if minv > d[i] && color[i] != BLACK
        u = i
        minv = d[i]
      end
    end

    break if u == -1
    color[u] = BLACK

    (0...N).each do |v|
      if color[v] != BLACK && @m[u][v] != INFTY
        if d[v] > d[u] + @m[u][v]
          d[v] = d[u] + @m[u][v]
          color[v] = GRAY
        end
      end
    end
  end

  (0...N).each do |i|
    puts "#{i} #{d[i] == INFTY ? -1 : d[i]}"
  end
end

(0...N).each do |i|
  u = @a[i][0]
  k = @a[i][1]

  (2...(k * 2 + 2)).each do |j|
    next if j.odd?
    v = @a[i][j]
    c = @a[i][j + 1]
    @m[u][v] = c
  end
end
dijkstra


Measured memory_bytes: 7060
#include <string>
#include <cmath>
#include <iostream>
#include <algorithm>
using namespace std;
/* contest template */

int main()
{
	int n;
	cin >> n;
	int fn = 0;
	int k=n;
	for (int i = 1; i <= 9; i++) {
		fn += k % 10;
		k = k / 10;
	}
	if (n%fn == 0) {
		cout << "Yes\n";
	}
	else {
		cout << "No\n";
	}
	return 0;
}

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

#define rep(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define rrep(i,a,n) for(int (i)=(a);(i)>=(n);(i)--)

#define INF ll 1 << 60
#define MOD 1000000007

typedef  long long ll;

using namespace std;

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

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

int gcd(long long int a,long long int b){
    long long int r;
    if(a < b){
        int tmp;
        tmp = a;
        a = b;
        b = tmp;
    }
    while(r = a % b){
        a = b;
        b = r;
    }
    return a;
}

void Integer_factorization(long long int b,long long int n){
    long long int a = 2;
    long long int count = 0;
    long long int ans = 1;
    long long int ndash = n;
    if(b == 1) cout << n << endl;
    else{
    while(ndash >= a*a){
        if(n % a  == 0){
            count++;
            n/=a;

        if(count % b == 0){
            ans *= a;
        }
        }else{a++;count = 0;}
    }

    cout<<  ans << endl;
    }
}

void ys(){
    cout << "Yes" << endl;
}

void yb(){
    cout << "YES" << endl;
}

void ns(){
    cout << "No" << endl;
}

void nb(){
    cout << "NO" << endl;
}


void solve(void){
    string s,t;
    cin >> s >> t;
    string a = "Yes";
    rep(i,0,s.size()){
        int c = i;
        int index = 0;
        int ans = 0;
        while(true){
            if(s[index] != t[c]) break;
            else ans++;
            if(c+1 < s.size()) c++;
            else c = 0;
            index++;
        }
        if(ans == s.size()){
            ys();
            return;
        }
    }
    ns();
}


   

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int fx4[] = {1 , -1 , 0 , 0};
int fy4[] = {0 , 0 , 1 , -1};
int Kfx[]= {-2,-2,2,2,1,1,-1,-1}; ///knight move x - exis
int Kfy[]= {1,-1,1,-1,2,-2,2,-2}; ///knight move y- exis
int fx8[]= {1,1,1,0,0,-1,-1,-1};
int fy8[]= {0,1,-1,1,-1,0,1,-1};
#define ll long long int
#define pii pair<int,int>
#define llu unsigned long long
#define inf 1<<28
#define gama 0.57721566490
#define PI              acos(-1.0)
#define INF             0x7fffffff
#define MOD             1000000007
#define EPS             1e-7
#define all(r)(r).begin(),(r).end()
/*
bool status[mx];
void sieve(){
   long long int  i,j;
    for(i=2;i<=mx;i++)
    {
        status[i]=0;
    }
    for( i=2;i<=sqrt(mx);i++){
        if(status[i]==0)
        {
            for(j=i*i;j<=mx;j+=i){
                status[j]=1;
            }
        }
    }
}*/
ll BM( ll a , ll b , ll m )
{
    if ( b == 0 ) return 1 ;
    ll x = BM(a,b/2,m);
    x = (( x % m) * (x % m))%m;

    if( b % 2 ) x = (( x % m) * (a %m)) % m ;
    return x ;
}
#define dd double
#define sc scanf
#define pr printf
#define VI vector<int>
#define VS vector<string>
#define VC vector<char>
#define VLL vector<long long int>
#define FILE freopen("input.txt","rt",stdin); freopen("output.txt","w",stdout);
#define p_b push_back
#define mem(x,y) memset(x,y,sizeof(x))
#define F(i,a,b) for(i=a;i<=b;i++)
#define sc1(a) scanf("%d",&a)
#define scL1(a) scanf("%lld",&a)
#define scL2(a,b) scanf("%lld%lld",&a,&b)
#define sc2(a,b) scanf("%d%d",&a,&b)
#define sc3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define scL3(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define fori(N)          for(int i = 0; i<(N); i++)
#define forj(N)         for(int j = 0; j<(N); j++)
#define fork(N)         for(int k = 0; k<(N); k++)
#define forl(N)         for(int l = 0; l<(N); l++)
#define ford(N)         for(int d = 0; d<(N); d++)
#define fori1(N)          for(int i = 1; i<=(N); i++)
#define forj1(N)         for(int j = 1; j<=(N); j++)
#define fork1(N)         for(int k = 1; k<=(N); k++)
#define ford1(N)         for(int d = 1; d<=(N); d++)
#define sqr(x)           (x)*(x)
#define TEST int test,te=0;cin>>test;
#define segment_tree int l=(n*2),r=(n*2)+1,mid=(l+r)/2
#define Mx 100005
#define mx 10005
double avgsum(pair<int,int>p1,pair<int,int>p2){
	dd t1=p1.first-p2.first;
	t1=pow(t1,2);
//	t1=sqrt(t1);
		dd t2=p1.second-p2.second;
	t2=pow(t2,2);
	t1=t1+t2;
	t1=sqrt(t1);
	return t1;
}
int fac(int n){
	if(n==1)return 1;
	else return n*fac(n-1);
}
int main()
{

    int n;
    cin>>n;
    vector<pair<int,int > >vp(n);
    vector<int>v(n);
    fori(n){
    	v[i]=i;
    	cin>>vp[i].first>>vp[i].second;
	}
	double sum=0;
	do{
		for(int i=0;i<n-1;i++){
			sum+=avgsum(vp[v[i]],vp[v[i+1]]);
		}
	}
	while(next_permutation(v.begin(), v.end()));
	printf("%.10lf\n",sum/fac(n));
}


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

using namespace std ;

int main()
{
	long long int n , d , ans  = 0 ;
	cin >> n >> d ;
	long long m = d*d ;
	for(int i = 0 ; i < n ; i++)
	{
		long long int x , y ;
		cin >> x >> y ;
		if(x < 0)
		{
			x *= (-1) ;
		}
		if(y < 0)
		{
			y *= (-1) ;
		}
		long long int z = (x*x) + (y*y) ;
		// cout << z << endl ;
		if(z <= m)
		{
			ans++ ;
		}
	}
	cout << ans << endl ;
}


Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <string>
#include <cstdio>
#include <cmath>
#include <map>
#include <queue>
#include <stack>
using namespace std;

int main(){
	int n;
	stack<int> qu;
	vector<int> v;
	while(cin >> n){
		if(n != 0){
			qu.push(n);
		}else{
			//v = qu.top();
			cout << qu.top() << endl;
			qu.pop();
		}
	}
	/*for (int i = 0; i < v.size(); ++i)
	{
		cout << v[i] << endl;
	}*/

}

Measured memory_bytes: 1200
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
 
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);    
	
	int A, B; cin >> A >> B;
	
	cout << (A < 10 && B < 10 ? A*B : -1) << endl;
	
	
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
  
void solve() {
    // 入力の処理
    int A,B;
    cin >> A >> B;
    int ans = A - 2 * B;
    if (ans > 0) { cout << ans << endl; }
    else { cout << 0 << endl; }
    return;
}
 
int main() {
    solve();
    return 0;
}

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

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

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll H, W, D;
    ll Q;
    vector<pair<ll, ll>> A;
    vector<ll> Ruiseki;
    cin >> H >> W >> D;
    A.resize(H * W + 1);
    Ruiseki.resize(H * W + 1);
    rep(i, H) rep(j, W) {
        ll temp;
        cin >> temp;
        A[temp] = {i, j};
    }
    repi2(i, D + 1, H * W) Ruiseki[i] = Ruiseki[i - D] + abs(A[i].first - A[i - D].first) + abs(A[i].second - A[i - D].second);
    cin >> Q;
    rep(i, Q) {
        ll L, R;
        cin >> L >> R;
        cout << Ruiseki[R] - Ruiseki[L] << endl;
    }
    return 0;
}


Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;

int n;
int x;
int a[100];

int main() {
    cin >> n >> x;
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    int ans = 0;
    rep(i,n) {
        x -= a[i];
        if (x < 0) break;
        ans++;
    }
    if (x > 0) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int a1,a2,a3;
    scanf("%d%d%d",&a1,&a2,&a3);
    if(a1>=a2&&a2>=a3)
        printf("%d",a2-a3+a1-a2);
    else if(a1>=a3&&a3>=a2)
        printf("%d",a3-a2+a1-a3);
    else if(a2>=a1&&a1>=a3)
        printf("%d",a1-a3+a2-a1);
    else if(a2>=a3&&a3>=a1)
        printf("%d",a3-a1+a2-a3);
    else if(a3>=a2&&a2>=a1)
        printf("%d",a2-a1+a3-a2);
    else if(a3>=a1&&a1>=a2)
        printf("%d",a1-a2+a3-a1);
 return 0;
}


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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  char b;
  cin >> b;
  map<char,char> m;
  m['A'] = 'T';
  m['C'] = 'G';
  m['G'] = 'C';
  m['T'] = 'A';
  cout << m[b] << endl;
  return 0;
}


Measured memory_bytes: 256
loop do
  n = gets.chomp.to_i
  break if n==0
  ans = 0
  for i in 0...n
    for j in (i+1)...n
      t = (j*(j+1) - i*(i+1))/2
      if t==n
        ans+=1
      end
      break if t>=n
    end
  end
  puts ans
end

Measured memory_bytes: 6088
#include <utility> // pair make_pair
using std::swap; // c++11
using std::pair;
using std::make_pair;
#include <tuple> // tuple(c++11) make_tuple(c++11)
using std::tuple; // get<address>(variable)
using std::make_tuple;
#include <string> // string stoi(c++11) stoll(c++11) to_string(c++11)
using std::string;
using std::stoi;
using std::stoll;
using std::to_string;
#include <queue> // queue priority_queue
using std::queue;
using std::priority_queue;
#include <stack> // stack
using std::stack;
#include <vector> // vector
using std::vector;
#include <map> // map
using std::map;
#include <set> // set
using std::set; // insert erase find count
#include <algorithm> // min max
using std::sort;
using std::lower_bound; // iterator,  >=
using std::upper_bound; // iterator,  >
using std::min;
using std::max;
using std::min_element; // iterator
using std::max_element; // iterator
#include <complex> // complex
using std::complex; // real imag
#include <iostream> // cin cout
using std::cin;
using std::cout;
using std::endl;
#include <iomanip> // setprecision fixed(manipulator)
using std::setprecision;
using std::fixed;
#include <cmath>
#include <cstdio>

#define lli long long int
#define INF (int)1e09
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define EFOR(i, m, n) for (int i = m; i <= n; i++)
#define RFOR(i, m, n) for (int i = m; i > n; i--)
#define REFOR(i, m, n) for (int i = m; i >= n; i--)
#define VSORT(v) sort((v).begin(), (v).end()) // sort vector
#define VGSORT(v) sort((v).begin(), (v).end(), std::greater<int>()) // sort vector
typedef pair<int, int> PI;
typedef tuple<int, int, int> TI;
template <typename T> using Vec = vector<T>; // c++11

int main(void) {
    int n;
    int m;
    cin >> n >> m;
    int temp;
    Vec<int> table(m);
    FOR (i, 0, m) {
        cin >> table[i] >> temp;
    }
    VGSORT(table);
    int i = 0;
    while (1) {
        if (table[i] >= n) {
            i++;
        } else {
            break;
        }
    }
    /*
    FOR (i, 0, m) {
        cout << table[i] << " ";
    }
    cout << endl;
    cout << i << endl;
    */
    if (i >= m - 1) {
        cout << 0 << endl;
    } else {
        int count = 0;
        FOR (j, i, m - 1) {
            count += (n - table[j]);
        }
        cout << count << endl;
    }

    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define m_p make_pair
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rnf(2106);
const int N = 200005;

int n;
int a[N];

int q[N];

bool solv()
{
    scanf("%d", &n);
    for (int i = 1; i <= n; ++i)
        scanf("%d", &a[i]);
    sort(a + 1, a + n + 1);
    for (int i = 1; i <= n; ++i)
        q[a[i]]++;
    int minu;
    if (a[n] % 2 == 1)
    {
        for (int i = a[n]; i >= (a[n] / 2) + 1; --i)
        {
            if (q[i] < 2)
                return false;
            q[i] -= 2;
        }
        minu = (a[n] / 2) + 2;
    }
    else
    {
        for (int i = a[n]; i >= (a[n] / 2) + 1; --i)
        {
            if (q[i] < 2)
                return false;
            q[i] -= 2;
        }
        if (q[a[n] / 2] < 1)
            return false;
        q[a[n] / 2] -= 1;
        minu = (a[n] / 2) + 1;
    }
    for (int i = 1; i < minu; ++i)
    {
        if (q[i])
            return false;
    }
    return true;
}

int main()
{
    #ifdef SOMETHING
    freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif // SOMETHING
    if (solv())
        printf("Possible\n");
    else
    {
        while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}
        printf("Impossible\n");
    }
    return 0;
}

//while ((double)clock() / CLOCKS_PER_SEC <= 0.9){}


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

X = []

for i in range(N):
    x,y,z = list(map(int,input().split()))
    X.append([x,y,z])

max_score = 0
for i in range(8):
    a = i%2
    j = i//2
    b = j%2
    k = j//2
    c = k%2
    a,b,c = 2*a-1,2*b-1,2*c-1
    Z = []
    for j in range(N):
        Z.append(a*X[j][0]+b*X[j][1]+c*X[j][2])
    Z.sort(reverse=True)
    max_score = max(sum(Z[:M]),max_score)

print(max_score)

Measured memory_bytes: 3188
#include<iostream>
#include<cmath>
#include<map>
#include<deque>
#include<string>
#include<algorithm>
typedef long long ll;

#define all(x) (x).begin(),(x).end()
#define puts(x) cout<< x << endl;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define fore(i,a) for(auto i:a)

using namespace std;
int n;
string s,t,u;
int main(){
  cin>>n>>s>>t;
  rep(i,0,n){
      u=u+s[i];
      u=u+t[i];
  }
  puts(u);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	var A, B int
	scanner.Scan()
	fmt.Sscanf(scanner.Text(), "%d %d", &A, &B)

	h := 100
	w := 100

	// init
	table := make([][]string, h)
	for i := 0; i < len(table); i++ {
		table[i] = make([]string, w)
		for j := 0; j < len(table[i]); j++ {
			if j < w/2 {
				table[i][j] = "#"
			} else {
				table[i][j] = "."
			}
		}
	}

	// for #
	for n := 0; n < (A - 1); n++ {
		table[(n%50)*2][(n/50)*2] = "."
	}
	// for .
	for n := 0; n < (B - 1); n++ {
		table[(n%50)*2][w-1-(n/50)*2] = "#"
	}

	fmt.Println(h, w)
	for i := 0; i < len(table); i++ {
		for j := 0; j < len(table[i]); j++ {
			fmt.Print(table[i][j])
		}
		fmt.Println()
	}
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
 
using namespace std;
 
int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r = 0;
  for (auto c : s)
    if (c == 'R') r++;
    else r--;
  if (r > 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 384