akhauriyash/Code-Regression huggingface dataset:
def main():
    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
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    d,g = map(int, input().split())
    pc = [list(map(int, input().split())) for _ in range(d)]
    res = 10**10

    #コンプする問題のセット
    for s in range(1<<d):
        total = 0
        n = 0
        #i番目の問題
        for i in range(d):
            if (s>>i) & 1:
                total += 100 *(i+1)*pc[i][0] + pc[i][1]
                n += pc[i][0]

        if total >= g:
            res = min(res, n)
        else:
            for i in range(d-1, -1, -1):
                if ((s>>i) & 1) == 0:
                    if 100*(i+1)*(pc[i][0]-1) >= g-total:
                        res = min(res, n+ceil((g-total)/(100*(i+1))))
                        break
                    else:
                        total += 100*(i+1)*(pc[i][0]-1)
                        n += pc[i][0] - 1
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
def main():
    N, X = (int(i) for i in input().split())
    L = [int(i) for i in input().split()]
    from itertools import accumulate
    S = accumulate([0] + L)
    ans = 0
    for s in S:
        if s <= X:
            ans += 1
        else:
            break
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>
#include <queue>

using namespace std;

int main(void)
{
    int n, q;
    cin >>n >>q;

    vector<vector<int> > path(n+1, vector<int>());
    for(int i = 0; i < n-1; i++){
        int a,b;
        cin >>a >>b;
        path[a].push_back(b);
    }

    vector<long long> nodeSum(n+1, 0);
    for(int i = 0; i < q; i++){
        int p, x;
        cin >>p >>x;
        nodeSum[p] += x;
    }

    vector<long long> nodeAns(n+1, 0);

    queue<int> qu;
    qu.push(1);


    while(!qu.empty()){
        int root = qu.front(); qu.pop();
        nodeAns[root] += nodeSum[root];
        for(int i = 0; i < path[root].size(); i++){
            nodeAns[path[root][i]] += nodeAns[root];
            qu.push(path[root][i]);
        }
    }

    bool first = true;
    for(int i = 1; i <= n; i++){
        if(first){
            printf("%lld", nodeAns[i]);
            first = false;
        }else{
            printf(" %lld", nodeAns[i]);
        }
    }
    printf("\n");

    return 0;
}

Measured memory_bytes: 16512
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

int main() {
  ll n, k;
  scanf("%lld %lld", &n, &k);

  vector<ll> h(n);
  for (ll i = 0; i < n; i++) {
    scanf("%lld", &h[i]);
  }
  sort(h.begin(), h.end());

  ll sum = 0;
  for (ll i = 0; i < (n - k); i++) {
    sum += h[i];
  }

  cout << sum << endl;
}

// 3 1
// 4 1 5


Measured memory_bytes: 1792
n=int(input())
dp=list(range(n+1))
dp[0]=0
a=[]
b=[]
i=1
while True:
  if 6**i>n:break
  a.append(6**i)
  i+=1
i=1
while True:
  if 9**i>n:break
  b.append(9**i)
  i+=1
for i in a:
  for j in range(i,n+1):
    dp[j]=min(dp[j],dp[j-i]+1)
for i in b:
  for j in range(i,n+1):
    dp[j]=min(dp[j],dp[j-i]+1)
print(dp[n])

Measured memory_bytes: 67248
import java.util.ArrayList;
import java.util.List;
import java.util.NavigableMap;
import java.util.Scanner;


public class Main {
    static int sum = 0;
    static void solve() {
        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        if(n >= 30) {
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

//        for (int i = 0; i < n; i++) {
//
//        }

//        int t = scan.nextInt();
//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
//            int[] arr1 = new int[n];
//            for (int j = 0; j < n; j++) {
//                arr1[j] = scan.nextInt();
//            }
////            scase(n, arr1);
//        }


//        long t = scan.nextLong();

//        for (int i = 0; i < t; i++) {
//            int n = scan.nextInt();
////            scase(n);
//        }
    }


    static void solveCase(int t, int x, String s) {

    }

    static void scase(int[] arr1, int[] arr2) {
    }



    public static void main(String[] args)  {
        solve();
    }


    static class TreeNode {
        int val;
        TreeNode left;
        TreeNode right;

        TreeNode(int x) {
            val = x;
        }
    }

    static class ListNode {
        int val;
        ListNode next;

        ListNode() {
        }

        ListNode(int val) {
            this.val = val;
        }

        ListNode(int val, ListNode next) {
            this.val = val;
            this.next = next;
        }
    }
}

Measured memory_bytes: 27036
#include<iostream>
using namespace std;
int main()
{
	long a,b,c,x,y;
	cin>>a;
	cin>>b;
	x=a;
	y=b;
	if(b>a)
	{
		long temp=a;
		a=b;
		b=temp;
	}
    while(1)
	{
		c=a%b;
		if(c==0)
		{
			break;
		}
		a=b;
		b=c;
		}
		long z=(x*y)/b;
		cout<<z;
}

Measured memory_bytes: 256
var
    a,b,c:string;
    i,j:longint;
begin
    readln(a);
    readln(b);
    for i:=1 to length(a)+length(b) do
    begin
        if (i mod 2<>0)and(i<>1) then c:=c+a[(i+1)div 2]
        else if (i mod 2<>0)and(i=1) then c:=c+a[i]
        else if (i mod 2=0) then c:=c+b[i div 2];
    end;
    writeln(c);
end.

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

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

  vector<int> vec(N);

  int sum = 0;  
  for (int i = 0; i < N; i++){
    cin >> vec.at(i);
    sum += vec.at(i);
  }
  
  int pop = 0;
  for (int i = 0; i < N; i++){
    if (vec.at(i) * 4 * M >= sum) pop += 1;
  }

  cout << (pop >= M ? "Yes" : "No") << endl;
}

Measured memory_bytes: 3612
#include <cmath>
#include <iostream>
#include <tuple>
#include <vector>

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

  std::vector<std::tuple<int,int>> c_arr;
  for(int i = 0; i < M; i++){
    int a,b;
    std::cin >> a >> b;
    int t = 0;
    for(int j = 0; j < b; j++){
      int c;
      std::cin >> c;
      t += 1<<(c-1);
    }
    c_arr.emplace_back(a,t);
  }

  int i_inf = 1000000000;
  int memo[4096];
  memo[0] = 0;
  for(int i = 1; i < 4096; i++) memo[i] = i_inf;
  for(int i = 0; i < M; i++){
    for(int j = 0; j < 4096; j++){
      if(memo[j] == i_inf) continue;
      int k = j|std::get<1>(c_arr[i]);
      memo[k] = std::min(memo[k], memo[j]+std::get<0>(c_arr[i]));
    }
  }

  int ans = memo[(1<<N)-1];
  if(ans == i_inf) ans = -1;
  std::cout << ans << std::endl;

  return 0;
}



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

int main() {
  int A , B , C , X ; //A:500円　B:100円 C:50円
  cin >> A >> B >> C >> X ;
  int patturn = 0 ;
  for (int i = 0; i <= A; i++ ){
    
    for (int j = 0; j <= B ; j++ ){
      for (int k = 0 ; k <= C ; k++ ){
        bool just;
        just = ( X == 500*(A-i) + 100*(B-j) + 50*(C-k));
        
        if (just) patturn++;
      }
    }
  }
  cout << patturn << endl;
}



Measured memory_bytes: 256
mod=998244353
n,m,k=map(int, input().split())

framod=[0]*(2*10**5+1)
framod[0]=1
def xframod(n, mod, a=1):
    for i in range(1,n+1):
        a=a * i % mod
        framod[i]=a
xframod(2*10**5,mod)

def combmod(n, k, mod):
    a=framod[n]
    b=framod[k]
    c=framod[n-k]
    return (a * pow(b, mod-2, mod) * pow(c, mod-2, mod)) % mod
ans=0

for i in range(0,k+1):
    tmp=combmod(n-1,i,mod)
    tmp*=m*pow(m-1,n-1-i,mod)
    tmp%=mod
    ans+=tmp
    ans%=mod
print(ans)

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,n) for(int i=(int)(n-1);i>=0;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x"=" << x <<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<int, P> PIP;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;
typedef set<int> S;

#define INF INT_MAX/3

#define MAX_N 1000000001

int main(){
	cin.sync_with_stdio(false);
	int n;
	cin >> n;

	int p = 0, q = 0;
	rep(i, n) {
		int a;
		cin >> a;
		p += a * a;
		q += a;
	}

	int ans;
	if (q >= 0) {
		ans = (((double)q)/n - q/n >= 0.5) ? q / n + 1 : q / n;
	} else {
		ans = (q/n - ((double)q)/n >= 0.5) ? q / n - 1 : q / n;
	}
	cout << n * ans * ans - 2 * q * ans + p << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  rep(i,b){
    if((i*a)%b==c){
      cout<<"YES";
      return 0;
      }
    }
  cout<<"NO";
}


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

const int N = 1e6 + 100;

int par[N];

int P(int u) {
    if(par[u] == u) return u;
    return par[u] = P(par[u]);
}

int Merge(int u, int v) {
    u = P(u), v = P(v);
    if(u == v) return 0;
    par[u] = v;
    return 1;
}

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n, K;
    cin >> n >> K;
    for(int i = 0; i < n; i++) par[i] = i;
    vector<int> p(n), lft(n);
    int stubborn = 0;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
        if(!i or p[i] < p[i-1]) lft[i] = 1;
        else lft[i] = lft[i-1]+1;
        if(lft[i] >= K) stubborn++;
    }
    set<int> s;
    for(int i = 1; i < K; i++) s.insert(p[i]);
    int comp = n-K+1;
    for(int i = K; i < n; i++) {
        bool f = true;
        int mn = *s.begin(), mx = *s.rbegin();
        if(p[i-K] > mn or p[i] < mx) f = false;
        if(lft[i] < K and lft[i-1] < K and f) {
            comp -= Merge(i, i-1);
        }
        s.erase(p[i-K+1]);
        s.insert(p[i]);
    }
    if(!stubborn) cout << comp << endl;
    else cout << comp - stubborn + 1 << endl;
    return 0;
}



Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		
		int n = sc.nextInt();
		
		int cnt = 0;
		
		for (int i = 1; i <= n; i += 2) {
			int tmp = 0;
			for (int j = 1; j * j <= i; j++) {
				if (i % j == 0) {
					if (j * j == i) tmp++;
					else tmp += 2;
				}
			}
			if (tmp == 8) cnt++;
		}
		
		System.out.println(cnt);
		
	}

}


Measured memory_bytes: 21716
#include <cstdio>
#include <iostream> 
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;
using ll = long long;

const ll INF = 1e9;
const ll MOD = 1e9 + 7;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int n, a, b, c, d;

	cin >> n;
	a = n / 1000;
	b = n / 100 % 10;
	c = n / 10 % 10;
	d = n % 10;

	if (a + b + c + d == 7) {
		printf("%d+%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a + b + c - d == 7) {
		printf("%d+%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a + b - c + d == 7) {
		printf("%d+%d-%d+%d=7\n", a, b, c, d);
	}
	else if (a + b - c - d == 7) {
		printf("%d+%d-%d-%d=7\n", a, b, c, d);
	}
	else if (a - b + c + d == 7) {
		printf("%d-%d+%d+%d=7\n", a, b, c, d);
	}
	else if (a - b + c - d == 7) {
		printf("%d-%d+%d-%d=7\n", a, b, c, d);
	}
	else if (a - b - c + d == 7) {
		printf("%d-%d-%d+%d=7\n", a, b, c, d);
	}
	else {
		printf("%d-%d-%d-%d=7\n", a, b, c, d);
	}
}

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

int main(){
    int n,t,a;
    double mi=1000;
    cin>>n>>t>>a;
    vector<double>vec(n),ans(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
        ans[i]=abs(a-(t-vec[i]*0.006));
        mi=min(mi,ans[i]);
    }
    for(int i=0;i<n;i++){
        if(mi==ans[i]){
            cout<<i+1<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import itertools
N = int(input())
P = tuple(map(int,input().split()))
Q = tuple(map(int,input().split()))
l = []
for i in range(1,N+1):
    l.append(i)
tmp = sorted(list(itertools.permutations(l)))

p = tmp.index(P)
q = tmp.index(Q)
print(abs(p-q))

Measured memory_bytes: 14168
#include <string>
#include <iostream>

using namespace std;
int main()
{
  string t = "";
    cin >> t;
  int s = t.length();
  for(int i = 0; i < s; i++){
    if(t.at(i) == '?'){
      t.at(i) = 'D';
    }
    cout << t.at(i);
  }
  cout << endl;
}


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

using namespace std;

int main()
{
    string s1,s2,ans="";
    cin >> s1 >> s2;
    int a=s1.size(),b=s2.size();
    int dp[a+1][b+1];
    for (int i=0;i<a+1;i++)
        dp[i][0]=0;

    for (int i=0;i<b+1;i++)
        dp[0][i]=0;

    for (int i=1;i<a+1;i++){
        for (int j=1;j<b+1;j++){
            if (s1[i-1]==s2[j-1])
                dp[i][j]=dp[i-1][j-1]+1;
            else
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }

//    bool belok=false;
    while((a>0)&&(b>0)){
        if (s1[a-1]==s2[b-1]){
            ans=s1[a-1]+ans;
            a--;
            b--;
        }
        else if(dp[a-1][b]>=dp[a][b-1])
            a--;
        else
            b--;
    }
    cout << ans << endl;

    return 0;
}


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

void swap(int &a, int &b){
	int temp;
	temp=a;
	a=b;
	b=temp;
}

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

Measured memory_bytes: 3060
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)

  val n = sc.nextInt
  val wl = Vector.fill(n)(sc.nextInt)
  val s  = wl.sum

  val res = (1 until n).map{i =>
    val si = wl.take(i).sum
    Math.abs(si - (s - si))
  }.min

  println(res)

}

Measured memory_bytes: 27192
#include <bits/stdc++.h>
using namespace std;
int i,n;
int main(){
  cin>>n;
  vector<int> dp(n+1,100000);
  dp[0]=0;
  for(i=1;i<=n;i++){
    int power=1;
    while(power<=i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power*=6;
    }
    power=1;
    while(power<=i){
      dp[i]=min(dp[i],dp[i-power]+1);
      power*=9;
    }
  }
  cout<<dp[i-1];
}

Measured memory_bytes: 640
n, y = gets.split.map(&:to_i)

for i in 0..n do
  for j in 0..n-i do
    k = n-i-j
    if i*10000 + j*5000 + k*1000 == y
      puts "#{i} #{j} #{k}"
      exit
    end
  end
end

puts "-1 -1 -1"


Measured memory_bytes: 3836
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <math.h>
#include <cmath>
using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];

const int mod = 1000000007;
const int INF = 2000000015;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}
int krag(double xx) {
	return INF - (int)(INF - xx);
}


int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res=res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n, k,ans=0;
	cin >> n >> k;
	if (k % 2 == 0) {
		ans += ((n + k / 2) / k) * ((n + k / 2) / k) * ((n + k / 2) / k);
	}
	ans += (n / k) * (n / k)* (n / k);
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
typedef long long ll;
typedef pair<double, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	int ans = 0;
	for (int i = 1; i <= n; ++i) {
		ans += i;
	}
	cout << ans << endl;
 	return 0;
}


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

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
			
		while (true) {
			int n = stdIn.nextInt();
			if(n == -1) {
				break;
			}
			int[] arr = new int[n];
			for(int i = 0; i < n; i++) {
				arr[i] = stdIn.nextInt();
			}
			int a = 0;
			int b = 0;
			int c = 0;
			int d = 0;
			int e = 0;
			int f = 0;
			int g = 0;
			
			int ta = 0;
			int tb = 0;
			int tc = 0;
			int td = 0;
			int te = 0;
			int tf = 0;
			int tg = 0;
			
			for(int i = 0; i < n; i++) {
				ta = a;
				tb = b;
				tc = c;
				td = d;
				te = e;
				tf = f;
				tg = g;
				switch(arr[i]) {
				case 0:
					a = b = c = d = e = f = 1;
					g = 0;
					break;
				case 1:
					b = c = 1;
					a = d = e = f = g = 0;
					break;
				case 2:
					a = b = d = e = g = 1;
					f = c = 0;
					break;
				case 3:
					a = b = c = d = g = 1;
					e = f = 0;
					break;
				case 4:
					b = c = f = g = 1;
					a = d = e = 0;
					break;
				case 5:
					a = c = d = f = g = 1;
					b = e = 0;
					break;
				case 6:
					a = c = d = e = f = g = 1;
					b = 0;
					break;
				case 7:
					a = b = c = f = 1;
					d = e = g = 0;
					break;
				case 8:
					a = b = c = d = e = f = g = 1;
					break;
				case 9:
					a = b = c = d = f = g = 1;
					e = 0;
					break;
				}
				if(tg == g) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(tf == f) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(te == e) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(td == d) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(tc == c) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(tb == b) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				if(ta == a) {
					System.out.print(0);
				}
				else {
					System.out.print(1);
				}
				System.out.println();
			}
		}
	}
		
}

Measured memory_bytes: 20652
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)




int main() {
	int a, b;
	cin >> a >> b;
	if (a < 2 * b) cout << 0 << endl;
	else cout << a - 2 * b << endl;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using P   = pair<ll, ll>;
using mat = vector<vector<ll>>;

void IOS() { ios::sync_with_stdio(false), cin.tie(0); }

const ll INF = 1e16;
const ll MOD = 1e9 + 7;
const ld EPS = 1e-12;

template <typename T>
void dump(T x) { cout << x << endl; }
void dumpf(ld x, int t) { cout << setprecision(t) << fixed << x << endl; }
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
	fill((T *)array, (T *)(array + N), val);
}
inline ll mod(ll a, ll b) {
	if (a > 0) return a % b;
	if (a % b == 0) return 0;
	ll x = -a / b + 1;
	a += x * b;
	return a % b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

// ll dx[4] = {1, 0, -1, 0};
// ll dy[4] = {0, 1, 0, -1};

template <class Monoid>
class SegTree {
	using OP = std::function<Monoid(Monoid, Monoid)>;

  private:
	int n;
	std::vector<Monoid> dat;
	OP op;
	Monoid e;

  public:
	SegTree(int n_, OP op, Monoid e) : op(op), e(e) {
		n = 1;
		while (n < n_) {
			n *= 2;
		}
		dat.resize(2 * n);
		for (int i = 0; i < 2 * n - 1; i++) {
			dat[i] = e;
		}
	}
	void update(int k, Monoid v) {
		k += n - 1;
		dat[k] = v;
		while (k > 0) {
			k	  = (k - 1) / 2;
			dat[k] = op(dat[2 * k + 1], dat[2 * k + 2]);
		}
	}
	Monoid querySub(int a, int b) const {
		Monoid left  = e;
		Monoid right = e;
		a += n - 1;
		b += n - 1;
		while (a < b) {
			if ((a & 1) == 0) {
				left = op(left, dat[a]);
			}
			if ((b & 1) == 0) {
				right = op(dat[b - 1], right);
			}
			a = a / 2;
			b = (b - 1) / 2;
		}
		return op(left, right);
	}
	Monoid query(int a, int b) const { return querySub(a, b + 1); }
};

int main() {
	IOS();
	ll n;
	cin >> n;

	vector<ll> a(n + 1);
	function<ll(ll, ll)> f = [](ll i, ll j) {
		if (i == 0)
			return j;
		else if (j == 0)
			return i;
		else
			return gcd(i, j);
	};

	SegTree<ll> sg(n + 1, f, 0);
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		sg.update(i, a[i]);
	}
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		ll x   = sg.query(1, i - 1);
		ll y   = sg.query(i + 1, n);
		ll tmp = gcd(x, y);
		ans	= max(tmp, ans);
	}
	dump(ans);
}

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

using namespace std;

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int main() {
  int A, B, X;
  cin >> A >> B >> X;
  if (A + B < X || X < A)
    cout << "NO" << endl;
  else
    cout << "YES" << endl;
}


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

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

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

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

ll N;

int main(int argc, char **argv)
{
	cin >> N;
	vector<ll> A(N);
	REP(i, N) cin >> A[i];
	vector<ll> s;
	REP(i, N)
	{
		ll t = A[i];
		auto itr = lower_bound(s.rbegin(), s.rend(), t);
		if (itr == s.rbegin())
			s.push_back(t);
		else
			*(itr-1) = t;
		
	}
	std::cout << s.size() << std::endl;
}


Measured memory_bytes: 2168
N = int(input())
mylist = []
first=0
second=0
for i in range (N):
  A = int(input())
  if first < A:
    first = A
  elif second < A:
    second = A
  mylist.append(A)
for i in range (N):
  if mylist[i] == first:
    print(second)
  else :
    print(first)

Measured memory_bytes: 12532
n = int(input())
w = input()
s = set([w])
l = w[-1]
for i in range(n-1):
    w = input()
    if w not in s:
        s.add(w)
        if w[0] != l:
            print("No")
            break
        else:
            l = w[-1]
    else:
        print("No")
        break
else:
    print("Yes")

Measured memory_bytes: 9164
using System;
using System.Collections.Generic;
using System.Linq;

namespace AizuOnlineJudge
{
    class Program
    {
        static void Main(string[] args)
        {
            var arr = Enumerable.Range(0, int.Parse(Console.ReadLine()))
                .Select(e => int.Parse(Console.ReadLine())).ToArray();

            ShellSort(ref arr);
            Console.WriteLine(string.Join("\n", arr));
        }

        private static void InsertionSortt<T>(ref T[] arr, int distance, ref int count) where T : IComparable<T>
        {
            //A = arr, n = arr.Length, g = distance?
            for(var i = distance; i <= arr.Length - 1; ++i)
            {
                var v = arr[i];
                var k = i - distance;
                while(k >= 0 && v.CompareTo(arr[k]) < 0)
                {
                    arr[k + distance] = arr[k];
                    k = k - distance;
                    count++;
                }
                arr[k + distance] = v;
            }
        }

        private static void ShellSort<T>(ref T[] arr) where T : IComparable<T>
        {
            var count = 0;
            var gArr = GenerateGArray(arr);
            var m = gArr.Length; //????

            Console.WriteLine(m); //1: m
            Console.WriteLine(string.Join(" ", gArr));

            for (var i = 0; i < m; ++i)
            {
                InsertionSortt(ref arr, gArr[i], ref count);
            }
            Console.WriteLine(count);
        }

        private static int[] GenerateGArray<T>(T[] arr)
        {
            var list = new List<int>();
            var l = arr.Length;
            var h = 0;
            while (h <= l / 9)
            {
                h = 3 * h + 1;
                list.Add(h);
            }
            list.Reverse();
            return list.ToArray();
        }
    }
}


Measured memory_bytes: 65012
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.IO;

namespace AtCoder.XXX.A
{ 
    public class Program
    {
        public static void Main(string[] args)
        {
            var name =r();
            P(name[0].ToString() + name[1] .ToString()+ name[2].ToString());
        }


        private static StreamReader sr;
        public static int[] Ecr()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static string Er()
        {
            if (sr == null)
            {
                sr = new StreamReader("input.txt", Encoding.GetEncoding("UTF-8"));
            }
            return sr.ReadLine();
        }
        public static string r()
        {
            return Console.ReadLine();
        }
        public static  int[] cr()
        {
            return Console.ReadLine().Split().Select(int.Parse).ToArray();
        }
        public static int cri()
        {
            return int.Parse(Console.ReadLine());
        }
        public static void P(string str)
        {
            Console.WriteLine(str);
        }
        public static void P(int num)
        {
            P(num.ToString());
        }
    }
}


Measured memory_bytes: 25892
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
void _dbg(string){cout<<endl;}
template<class H,class... T> void _dbg(string s,H h,T... t){int l=s.find(',');cout<<s.substr(0,l)<<" = "<<h<<", ";_dbg(s.substr(l+1),t...);}
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 1120000000

int main(){
  vector<string> vec(19);
  rep(i,19) cin>>vec[i];
  int n = 0;
  map<pair<int,int>,int> p2i;
  rep(i,19)rep(j,15) if(vec[i][j]=='X'){
    p2i[mp(i,j)] = n++;
  }
  int sx,sy;
  rep(i,19)rep(j,15) if(vec[i][j]=='O') sx=i, sy=j;

  using state = pair<int,pair<int,int>>;

  auto ok = [&](int i, int j){
    return i>=0 && i<19 && j>=0 && j<15;
  };

  set<state> prev;
  prev.insert(mp(0,mp(sx,sy)));

  rep(i,20){
    set<state> nxt;
    for(const state & s : prev){
      int mask = s.fi;
      int x = s.se.fi, y = s.se.se;
      for(int dx=-1; dx<=1; dx++){
        for(int dy=-1; dy<=1; dy++) if(dx*dx+dy*dy>0){
          int nmask = mask;
          int d = 1;
          while(ok(x+dx*d,y+dy*d) && vec[x+dx*d][y+dy*d]=='X'){
            int idx = p2i[mp(x+dx*d, y+dy*d)];
            if(! (mask & (1<<idx)) ){
              nmask |= (1<<idx);
              d++;
            }
            else {
              break;
            }
          }
          if(d==1) continue;
          int nx=x+dx*d, ny=y+dy*d;
          if(nx==19 || (ok(nx,ny) && nx==18)){
            cout << i+1 << endl;
            return 0;
          }
          if(ok(nx,ny)) nxt.insert(mp(nmask,mp(nx,ny)));
        }
      }
    }
    swap(nxt, prev);
  }

  cout << -1 << endl;

  return 0;
}

Measured memory_bytes: 4732
#include <iostream>
#include <string>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
using namespace std;

long cnt,as;
char s,t,b;
const int dy[]={-1,0,1,0};
const int dx[]={0,1,0,-1};
int main(){
  int n,tx,ty;
  long field[2][5][5];
  for(;cin>>n,n;){
    cin.ignore();
    cnt=as=0;
    scanf(" %c %c %c ",&s,&t,&b);
    memset(field,0,sizeof(field));
    int x= s=='A'||s=='D'||s=='G'?1:s=='B'||s=='E'||s=='H'?2:3;
    int y= s=='A'||s=='B'||s=='C'?1:s=='D'||s=='E'||s=='F'?2:3;
    
    int p= t=='A'||t=='D'||t=='G'?1:t=='B'||t=='E'||t=='H'?2:3;
    int q= t=='A'||t=='B'||t=='C'?1:t=='D'||t=='E'||t=='F'?2:3;

    int u= b=='A'||b=='D'||b=='G'?1:b=='B'||b=='E'||b=='H'?2:3;
    int t= b=='A'||b=='B'||b=='C'?1:b=='D'||b=='E'||b=='F'?2:3;

    field[0][y][x]=1;
    field[0][0][0]=field[0][0][1]=field[0][0][2]=field[0][0][3]=field[0][0][4]=1;
    field[0][4][0]=field[0][4][1]=field[0][4][2]=field[0][4][3]=field[0][4][4]=1;
    field[0][1][0]=field[0][2][0]=field[0][3][0]=1;
    field[0][1][4]=field[0][2][4]=field[0][3][4]=1;
    for(int k=0;k<n;k++){
      for(int i=1;i<4;i++){
        for(int j=1;j<4;j++){
          if(i==t && j==u)continue;

          for(int g=0;g<4;g++){
            tx=j+dx[g];
            ty=i+dy[g];
            if(tx<1 || ty<1 || tx>=4 || ty>=4)continue;
            field[1][i][j]+=field[0][ty][tx];
          }
          /*
          if(field[0][i][j]!=0 && (i-1==t&&j==u || i+1==t&&j==u ||
                                   i==t&&j-1==u || i==t&&j+1==u) ){
            field[1][i][j]++;
          }*/
          int uguu=0;
          if(field[0][i][j]>0){
            for(int g=0;g<4;g++){
              tx=j+dx[g];
              ty=i+dy[g];
              if((tx<1 || ty<1 || tx>=4 || ty>=4) || ty==t&&tx==u){
                uguu++;
              }
            }
            
            field[1][i][j]+=field[0][i][j]*uguu;
          }
        }
      }
      /*
      for(int ii=1;ii<4;ii++){
        for(int jj=1;jj<4;jj++){
          printf("%7ld ",field[1][ii][jj]);
        }
        puts("");
      }
      puts("");*/
      for(int i=1;i<4;i++)for(int j=1;j<4;j++)field[0][i][j]=field[1][i][j],field[1][i][j]=0;
    }

    printf("%.8lf\n",(double)field[0][q][p]/pow(4.0,(double)n));
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>

int main(void){
int a,b,c;
scanf("%d %d %d",&a,&b,&c);
if( (a==7&& b==5 && c==5) || (a==5&& b==7 && c==5) || (a==5&& b==5 && c==7) )
printf("YES\n");
else
printf("NO\n");
return 0;
}

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

typedef long long ll;

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

    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
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1LL << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(20);
	}
};
initializer _____;

int N, M, K, T, Q, H, W;
signed main() {
	cin >> N;
	vector< int > A(N), B(N);
	rep(i, N) cin >> A[i];
	rep(i, N) cin >> B[i];
	int ans = 0;
	sort(A.begin(), A.end());
	sort(B.begin(), B.end());
	rep(k, 31) {
		int one = 0;
		vector< int > B2(N);
		rep(i, N) B2[i] = B[i] % (1 << (k + 1));
		sort(B2.begin(), B2.end());
		rep(i, N) {
			int a = A[i] % (1 << (k + 1));
			one += (lower_bound(B2.begin(), B2.end(), (1 << (k + 1)) - a) - lower_bound(B2.begin(), B2.end(), (1 << k) - a));
			one += (B2.end() - lower_bound(B2.begin(), B2.end(), (1 << (k + 1)) + (1 << k) - a));
		}
		if (one & 1)
			ans += (1 << k);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <fstream>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <iomanip>
#include <stdio.h>
#include <string.h>
#include <random>
#include <functional>

using std::cin;
using std::cout;
using std::cerr;
using std::endl;

using std::map;
using std::set;
using std::bitset;
using std::vector;
using std::string;
using std::multimap;
using std::multiset;
using std::deque;
using std::queue;
using std::stack;
using std::pair;
using std::iterator;

using std::sort;
using std::stable_sort;
using std::reverse;
using std::max_element;
using std::min_element;
using std::unique;
using std::ios_base;
using std::swap;
using std::fill;

using std::setprecision;
using std::fixed;

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

ll min(ll a, ll b) {return a < b ? a : b;}
ll min(int a, ll b) {return a < b ? a : b;}
ll min(ll a, int b) {return a < b ? a : b;}
ll min(int a, int b) {return a < b ? a : b;}

ll max(ll a, ll b) {return a > b ? a : b;}
ll max(int a, ll b) {return a > b ? a : b;}
ll max(ll a, int b) {return a > b ? a : b;}
ll max(int a, int b) {return a > b ? a : b;}

namespace MySpace{

};

#define F(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define fi first
#define se second
#define re return
#define all(x) (x).begin(), (x).end()
//#define int long long

const int MOD = 1e9 + 7;
const int INF = 1e9;

int w, h;
string s[500];
int cost[400][400];
int dp[400][400];

signed main()
{
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    cin >> h >> w;
    F(i, h) cin >> s[i];
    int ans = 0;
    for (int i = 0; i + 1 < w; i++)
    {
        for (int a = 0; a <= h; a++)
        {
            for (int b = 0; b <= h; b++)
            {
                dp[a][b] = 1e9;
            }
        }
        dp[h][h] = 0;
        for (int a = 1; a <= h; a++)
        {
            for (int b = 1; b <= h; b++)
            {
                cost[a][b] = cost[a - 1][b - 1] + (s[a - 1][i] == s[b - 1][i + 1]);
            }
        }
        for (int a = h; a >= 0; a--)
        {
            for (int b = h; b >= 0; b--)
            {
                if (a == h && b == h)
                {
                    continue;
                }
                dp[a][b] = min((b < h ? dp[a][b + 1] + cost[a][b + 1] : INF), (a < h ? dp[a + 1][b] + cost[a + 1][b] : INF));
            }
        }
        ans += dp[0][0];
    }
    cout << ans;
}


Measured memory_bytes: 1280
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define INF 1e8
#define EPS 1e-9

#define rep2(i,m,n) for(int i=m;i<n;i++)
#define rep(i,n) rep2(i,0,n)
#define ll long long
#define P pair<int,int>
#define pb push_back

int n,used[100],e[100];
vector<int> v[100];

int f(int from){
	int res=0;
	rep(i,v[from].size()){
		int to=v[from][i];
		if(!used[to]){
			used[to]=1;
			res=max(res,f(to)+1);
			used[to]=0;
		}
	}
	return res;
}

int main(){
	while(cin>>n&&n){
		fill(used,used+100,0);
		fill(e,e+100,0);
		rep(i,100)v[i].clear();
		rep(i,n){
			int a,b;
			cin>>a>>b;a--;b--;
			v[a].pb(b);
			v[b].pb(a);
		}
		rep(i,100)sort(v[i].begin(),v[i].end());
		int done[100];
		fill(done,done+100,0);
		rep(i,100)if(!done[i]){
			int x=0;
			rep(j,100)if(v[i]==v[j]){x++;done[j]=1;}
			if(x>v[i].size()+1){
				int c=0;
				rep(j,100)if(v[i]==v[j]){
					c++;
					if(c>v[i].size()+1)used[j]=1;
				}
			}
			done[i]=1;
		}
		int ans=2;
		rep(i,100)if(!used[i]){
			rep(j,v[i].size())if(!used[v[i][j]]){
				used[i]=used[v[i][j]]=1;
				ans=max(ans,f(v[i][j])+2);
				used[i]=used[v[i][j]]=0;
			}
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 0
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int A = cin.nextInt();
        int B = cin.nextInt();

        int ans = 0;

        if (A >= 13)
        {
            ans = B;
        }
        else if (A >= 6)
        {
            ans = B / 2;
        }
        else
        {

        }

        WriteLine(ans);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


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

int N, K;
int M[110];

int main()
{
    while(cin >> N >> K && N && K)
    {
        bool flag = false;
        for(int i = 0; i < K; i++)cin >> M[i];
        for(int i = 0; i < N; i++)
        {
            for(int j = 0; j < K; j++)
            {
                int m;
                cin >> m;
                M[j] -= m;
                if(M[j] < 0)flag = true;
            }
        }

        if(flag)printf("No\n");
        else printf("Yes\n");
    }

    return 0;
}



Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

int main() {
  LL n; cin >> n;
  vector<LL> a(n);
  map<LL, LL> mp;
  for (int i = 0; i < n; i ++) {
    cin >> a[i];
    mp[a[i]] ++;
  }

  LL sum = 0;
  for (auto x: mp) {
    if (x.second >= 2) {
      sum += x.second * (x.second - 1) / 2;
    }
  }

  for (int i = 0; i < n; i ++) {
    cout << sum - (mp[a[i]] - 1) << endl;
  }
}


Measured memory_bytes: 11008
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

import statistics as st

n = ii()
a = []
b = []
for i in range(n):
    aa,bb = mi()
    a.append(aa)
    b.append(bb)

a.sort()
b.sort()

minmed = st.median(a)
maxmed = st.median(b)

if len(a) %2 == 0:
    ans = maxmed*2 - minmed*2 + 1
else:
    ans = maxmed-minmed+1
print(int(ans) )

Measured memory_bytes: 106104
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair

using ll = long long;
using namespace std;
ll x, y, z, l, m, n, r, q, k;
ll ans=0;
void dfs(ll num){
    if(num>n) return;
    string s = to_string(num);
    int cnt[8] {0};
    for_each(s.begin(), s.end(), [&](char x){
        if(x == '3') cnt[x-'0']++;
        if(x == '5') cnt[x-'0']++;
        if(x == '7') cnt[x-'0']++;
    });
    if(cnt[3] and cnt[5] and cnt[7]) ans++;
    dfs(num*10+3);
    dfs(num*10+5);
    dfs(num*10+7);
    
     
}

void solve() {
    cin>>n;
    dfs(0);
    cout<<ans<<'\n';

}

int main() 
{
    std::ios::sync_with_stdio(false); \
        std::cin.tie(NULL);
    int test;
    test  = 1;
    while (test--) {
        solve();
    }
    return 0;
}

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

int main() {
    int n, a, b;
    cin >> n;
    
    int max_a = -1, min_b = INT_MAX;
    for (int i = 0; i < n; i++) {
        scanf("%d%d",&a, &b);
        max_a = max(max_a, a);
        min_b = min(min_b, b);
    }
    
    cout << max_a + min_b << endl;
}


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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int64_t a,int64_t b){return a/gcd(a, b)*b;}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int64_t a){if(a<=1)return false;for(int64_t i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }



int main()
{
	int n, m, a, b;
	
	cin >> n >> m;
	vector<set<int>> ab(n);
	vector<int> ans(n, -1);
	for (int i = 0; i < m; i++)
	{
		cin >> a >> b;
		ab[a - 1].insert(b - 1);
		ab[b - 1].insert(a - 1);
	}
	queue<int> q;
	q.push(0);
	while (!q.empty())
	{
		int temp = q.front();
		q.pop();
		for (auto v: ab[temp])
		{
			if (ans[v] == -1)
			{
				ans[v] = temp;
				q.push(v);
			}
		}
	}
	bool flag = true;
	for (int i = 1; i < n; i++)
	{
		if (ans[i] == -1)
		{
			flag = false;
			break;
		}
	}
	cout << (flag ? "Yes" : "No") << endl;
	if (flag)
	{
		for (int i = 1; i < n; i++)
		{
			cout << ans[i] + 1 << endl;
		}
	}
}


Measured memory_bytes: 27364
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
using namespace std;

int N;

int main() {
  cin >> N;
  bool h;
  int t = 0;
  int a = 0, b = 0, c = 0;
  int ans = 0;
  for (int i=0; i<=N; i++) {
    int x;
    if (i == N) x = h^1;
    else {
      cin >> x;
      if (i & 1) x ^= 1;
    }
    if (i == 0) h = x ^ 1;
    if (x != h) {
      a = b, b = c, c = t;
      ans = max(ans, a+b+c);
      t = 1, h = x;
    }
    else {
      t++;
    }
  }
  cout << ans << "\n";
  return 0;
}

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

using namespace std;

using ll = long long int;

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    if (B % A == 0){
        cout << A + B << endl;
    }else{
        cout << B - A << endl;
    }
}


Measured memory_bytes: 256
<?php

$default = explode(" ", trim(fgets(STDIN)));

if($default[0] > $default[1]){
	$t = $default[0] % $default[1];
	if($t > $default[1]-$t){
		$ans = $default[1]-$t;
	}else{
		$ans = $t;
	}
}else{
	if($default[0] > $default[1]-$default[0]){
		$ans = $default[1]-$default[0];
	}else{
		$ans = $default[0];
	}
}

echo $ans;

Measured memory_bytes: 3828
#include"bits/stdc++.h"
using namespace std;

int main() {
	string s; cin >> s;
	vector<int> p(s.size());
	int n = s.size() - 1;
	for (int i = 0; i < s.size(); i++)
	{
		p.at(i) = s.at(i) - '0';
	}
	for (int bit = 0; bit < (1<<n); bit++)
	{
		int sum = p.at(0);
		for (int i = 0; i < n; i++)
		{
			if((1<<i)&bit){
				sum += p.at(i + 1);
			}
			else {
				sum -= p.at(i + 1);
			}
		}
		if (sum == 7) {
			cout << p.at(0);
			for (int i = 0; i < n; i++)
			{
				if ((1 << i) & bit) {
					cout << '+' << p.at(i + 1);
				}
				else {
					cout << '-' << p.at(i + 1);
				}
			}
			cout << "=7" << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 3596