akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Text;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Threading.Tasks;
using System.IO;

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
		Console.SetOut(sw);
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(a[0] - a[1] - a[2] >= 0 ? 0 : a[2] - a[0] + a[1]);


		Console.Out.Flush();
	}
}

Measured memory_bytes: 13396
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#ifdef __GXX_EXPERIMENTAL_CXX0X__
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;


int main ()
{
	double a , b , c ;
	char x;
	while( cin >> a >> x >> b >> x >> c )
	{
		if( b*1. / c / c >= 25 )cout << a << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include <stdio.h>

double j(double,double,double,double,double,double,double,double);

main(){
  double x1, x2, x3, y1, y2, y3, xp, yp;
  double xc, yc;
  int ans;

  while(1){
    ans=0;
    if(scanf("%lf %lf %lf %lf %lf %lf %lf %lf", &x1, &y1, &x2, &y2, &x3, &y3, &xp, &yp)==EOF) break;
    xc=(x1+x2+x3)/3;
    yc=(y1+y2+y3)/3;
    if(j(x1,y1,x2,y2,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(j(x1,y1,x3,y3,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(j(x2,y2,x3,y3,xp,yp,xc,yc)<0.0){
      ans=1;
    }
    if(ans==1) printf("NO\n");
    else if(ans==0) printf("YES\n");
  }
  return 0;
}

double j(double p1x,double p1y,double p2x,double p2y,double p3x,double p3y,double p4x,double p4y){
  double a;
  a=((p1x-p2x)*(p3y-p1y)+(p1y-p2y)*(p1x-p3x))*
    ((p1x-p2x)*(p4y-p1y)+(p1y-p2y)*(p1x-p4x));

  return a;
}

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




string S;
//-----------------------------------------------------------------
int main() {
	cin >> S;
	
	int flag = 0;
	rep(i, 0, S.length()) {
		if (flag == 0 && S[i] == 'C')
			flag = 1;
		else if (flag == 1 && S[i] == 'F')
			flag = 2;
	}

	if (flag == 2)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}

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

int main(){
    int n, x, y;
    cin >> n >> x >> y;

    int d[n] = { 0 };
    for (auto i = 1; i <= n; i++) {
        for (auto j = i + 1; j <= n; j++) {
            int tmp = min(j - i, abs(x - i) + 1 + abs(y - j));
            d[tmp]++;
        }
    }

    for (auto k = 1; k < n; k++) {
        cout << d[k] << endl;
    }

    return 0;
}

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

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

int s[400],l[400],p[400];
int w[400];

int m,n;

int dp[800];

void disp(int i, int j, int arr[]){
    for(int x=i; x<=j; x++)
        cout<<arr[x]<<" ";
    cout<<endl;
}

int main(){
    memset(dp,0,sizeof(dp));
    cin>>n;
    rep(i,n) cin>>s[i]>>l[i]>>p[i];
    rep(i,394){
        rep(j,n){
            loop(len,s[j],l[j]+1) dp[i+len]=max(dp[i]+p[j],dp[i+len]);
        }
        //disp(0,20,dp);
    }
    cin>>m;
    int ans[393];
    rep(i,m){
        int t;cin>>t;
        if(dp[t]==0){
            cout<<-1<<endl;
            return 0;
        } else ans[i]=dp[t];
    }
    rep(i,m)cout<<ans[i]<<endl;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=1e9+7;

int main(){
  int N;
  cin>>N;
  cout<<(N-2)*180<<endl;
  return 0;
}

Measured memory_bytes: 3484
#include <bits/stdc++.h>
#define inp(X) cin >> X
#define out(X) cout << X << endl
#define out16(X) cout << setprecision(16) << X << endl
#define rep(i,n) for(int i=0;i<n;i++ )
#define rep2(i,f,n) for(int i=f;i<n;i++ )
#define MAX(A) *max_element(A.begin(),A.end())
#define MIN(A) *min_element(A.begin(),A.end())
#define SORT(A) sort(A.begin(),A.end())
#define REV(A) reverse(A.begin(),A.end())
typedef long long int ll;
using vi = std::vector<int>;
using vvi = std::vector<std::vector<int>>;
using vd = std::vector<double>;
using vvd = std::vector<std::vector<double>>;
using vll = std::vector<ll>;
using vvll = std::vector<std::vector<ll>>;
using namespace std;
#define MOD 1000000007
#define INF 1000000001
#define LL_INF 1001001001001001001

int main(void) {
	int n,k,q; cin >> n >> k >> q;
	vi a(q); 
	rep(i,q){
		cin >> a[i];
		a[i]--;
	}
	vi sekai(n,0);
	rep(i,q) sekai[a[i]]++;
	rep(i,n){
		if(k-q+sekai[i]<=0) cout << "No" << endl;
		else cout << "Yes" << endl;
	}
}




Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define N 20000000
using namespace std;
typedef long long ll;
bool used[N];

ll SumD(ll a,ll d,ll n){return (n*(2*a+(n-1)*d))/2;}

bool mark(ll n){
  bool res=1;
  for(ll i=1;i*i<=n;i++){
    if(n%i)continue;
    if(i<N)res&=!used[i],used[i]=1;
    if(i!=n/i&&n/i<N)res&=!used[n/i],used[n/i]=1;
  }
  return res;
}

int main(){
  while(1){
    ll n,m,p[21];
    cin>>n>>m;
    if(!n&&!m)break;
    for(int i=0;i<m;i++)cin>>p[i];
    sort(p,p+m);

  
    ll sum=0,cnt=0;
    for(int i=0;i<m;i++){
      sum+=SumD(p[i],p[i],n/p[i]);
      cnt+=n/p[i];
      memset(used,0,sizeof(used));
      for(int j=0;j<i;j++){
	ll gcd=__gcd(p[i],p[j]);
	ll lcm=(p[i]/gcd)*p[j];
	if(!mark(lcm))continue;
	sum-=SumD(lcm,lcm,n/lcm);
	cnt-=n/lcm;
      }
    }
    double ans=1.0*(SumD(1,1,n)-sum)/max(1LL,(n-cnt));
    if(p[0]==1)ans=0;
    printf("%.8f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 22664
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;

	int ans = 0;
	for (int i = 1; i < N; i++){
		if(S[i-1] == S[i]){
			ans++;
		}
	}

	cout << min(N-1, ans + K*2) << endl;
	return 0;
}

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

int S;
int h, m, s;

int main(){
    cin >> S;
    h = S / 3600;
    m = S % 3600 /60;
    s = S % 60;
    
    cout << h << ":" << m << ":" << s << endl;
    
    return 0;
}


Measured memory_bytes: 3116
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
//		int n = Integer.parseInt(sa[0]);
		int a = Integer.parseInt(sa[1]) - 1;
		int b = Integer.parseInt(sa[2]) - 1;
		int c = Integer.parseInt(sa[3]) - 1;
		int d = Integer.parseInt(sa[4]) - 1;
		char[] s = br.readLine().toCharArray();
		br.close();

		for (int i = b + 1; i < d; i++) {
			if (s[i - 1] == '#' && s[i] == '#') {
				System.out.println("No");
				return;
			}
		}
		for (int i = a + 1; i < c; i++) {
			if (s[i - 1] == '#' && s[i] == '#') {
				System.out.println("No");
				return;
			}
		}
		if (c > d) {
			for (int i = b + 1; i <= d + 1; i++) {
				if (s[i - 2] == '.' && s[i - 1] == '.' && s[i] == '.') {
					System.out.println("Yes");
					return;
				}
			}
			System.out.println("No");
			return;
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 25044
#include<bits/stdc++.h>
using namespace std;
#define PI 3.14159265358993238
double circum(double r){
	
	double cir=2*PI*r;
	return cir;
}
int main(){
	
	double r;
	cin>>r;
	cout<<circum(r);
	return 0;
}
	

Measured memory_bytes: 3788
#include <stdio.h>
#include <algorithm>

#define LIM_A 100001

char str[10001];
int N;

int jpy_flag[10];
long long jpy[10];
double btc[10];

void receive_input() {
	fgets(str, sizeof(str), stdin);
	sscanf(str, "%d", &N);

	for (size_t i = 0; i < N; i++) {
		char flag_str[4];
		scanf("%s %s", str, flag_str);

		if (flag_str[0] == 'J') {
			jpy_flag[i] = 1;
			sscanf(str, "%lld", &jpy[i]);
		} else {
			jpy_flag[i] = 0;
			sscanf(str, "%lf", &btc[i]);
		}
	}
}

void initialize() {
	// nop
}

int main(void) {
	receive_input();
	initialize();

	double sum = 0.0;
	for (size_t i = 0; i < N; i++) {
		if (jpy_flag[i]) {
			sum += jpy[i];
		} else {
			sum += btc[i] * 380000;
		}
	}
	printf("%lf\n", sum);

	return 0;
}


Measured memory_bytes: 128
# AOJ 0042 A Thief
# Python3 2018.6.22 bal4u

MAX = 1003

for cno in range(1, 100):
	lim = int(input())
	if lim == 0: break
	print("Case ", cno, ":", sep='')
	N = int(input())
	V = [[0 for j in range(MAX)] for i in range(2)]
	W = [[0 for j in range(MAX)] for i in range(2)]		
	k1, k2 = 0, 1
	for i in range(1, N+1):
		v, w = map(int, input().split(','))
		for j in range(1, w):
			V[k2][j] = V[k1][j]
			W[k2][j] = W[k1][j]
		for j in range(w, lim+1):
			d = j - w
			if V[k1][d] + v >= V[k1][j]:
				V[k2][j] = V[k1][d] + v
				W[k2][j] = W[k1][d] + w
			else:
				V[k2][j] = V[k1][j]
				W[k2][j] = W[k1][j]
		k1, k2 = k2, k1
	print(V[k1][lim], W[k1][lim], sep='\n')


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

// Loops
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
#define _rrep(i, n) rrepi(i, n, 0)
#define rrepi(i, a, b) for (int i = int(a) - 1; i >= int(b); --i)

#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define rrep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(xi, x) for (auto &&xi : x)
// Note: we can use rep(i,N) or rep(i,from,to)

// typedef
template <class T> using vec = vector<T>;
using ll = long long;
using vi = vec<ll>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<ll, ll>;

// Constants

// Shorter repr for frequently used terms
#define pb push_back
#define mp make_pair

// Algorithms
#define all(x) (x).begin(), (x).end()
#define uniq(v) v.erase(unique(all(v)), v.end())
#define perm(c)                                                                \
  sort(all(c));                                                                \
  for (bool c##p = 1; c##p; c##p = next_permutation(all(c)))

template <class T> pair<T, size_t> max(vector<T> &x) {
  auto it = max_element(all(x));
  return mp(*it, it - x.begin());
}
template <class T> pair<T, size_t> min(vector<T> &x) {
  auto it = min_element(all(x));
  return mp(*it, it - x.begin());
}

template <class T> inline bool chmax(T &maxval, const T &newval) {
  if (maxval < newval) {
    maxval = newval;
    return 1;
  }
  return 0;
}
template <class T> inline bool chmin(T &minval, const T &newval) {
  if (minval > newval) {
    minval = newval;
    return 1;
  }
  return 0;
}

// Utilities
// Grid world utilities
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
#define inside(H, W, y, x) 0 <= (x) && (x) < (W) && 0 <= (y) && (y) < (H)

// Debug
#ifdef LOCAL
#include "dump.hpp"
#define debug(x) cerr << #x << ": " << x << '\n'
#else
#define dump(...)
#define debug(x)
#endif

// Yes or No
void yesno(bool ok, string yes = "Yes", string no = "No") {
  cout << (ok ? yes : no) << endl;
}

// Paste snippets here!!

//

void solve(long long K, long long A, long long B) {
  bool ok = false;
  rep(i,A,B+1){
    if(i%K==0) ok = true;
  }
  yesno(ok,"OK","NG");
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false); // Magic for faster cin
  cout.precision(12);
  long long K;
  std::cin >> K;
  long long A;
  std::cin >> A;
  long long B;
  std::cin >> B;
  solve(K, A, B);
  return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#ifdef ENABLE_DEBUG
#define dump(a) cerr<<#a<<"="<<a<<endl
#define dumparr(a,n) cerr<<#a<<"["<<n<<"]="<<a[n]<<endl
#else
#define dump(a) 
#define dumparr(a,n) 
#endif
#define FOR(i, a, b) for(ll i = a;i < b;i++)
#define For(i, a) FOR(i, 0, a)
#define REV(i, a, b) for(ll i = b-1;i >= a;i--)
#define Rev(i, a) REV(i, 0, a)
#define REP(a) For(i, a)
#define SIGN(a) (a==0?0:(a>0?1:-1))

typedef long long int ll;
typedef unsigned long long ull;
typedef unsigned int uint;
typedef pair<ll, ll> pll;
typedef pair<ll,pll> ppll;
typedef vector<ll> vll;

const ll INF=(1LL<<50);
#if __cplusplus<201700L
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
#endif

template<class S,class T>
std::ostream& operator<<(std::ostream& os,pair<S,T> a){
  os << "(" << a.first << "," << a.second << ")";
  return os;
}
template<class T>
std::ostream& operator<<(std::ostream& os,vector<T> a){
  os << "[ ";
  REP(a.size()){
    os<< a[i] << " ";
  }
  os<< " ]";
  return os;
}


void solve(long long N, std::vector<long long> a){
  ll l=-1,r=2*N+10;
  while(l+1<r){
    ll mid=(l+r)/2;
    dump(mid);
    vector<int> x(a.size());
    REP(a.size()){
      if(a[i]>=mid){
        x[i]=1;
      }else{
        x[i]=0;
      }
    }
    ll bl=a.size()/2,br=a.size()/2;
    while(bl>0){
      if(x[bl]==x[bl-1]){
        break;
      }
      --bl;
    }
    while(br<x.size()-1){
      if(x[br]==x[br+1]){
        break;
      }
      ++br;
    }
    dump(br);dump(bl);
    ll tmp;
    if(bl==0&&br==x.size()-1){
      tmp=x[0];
    }else if(a.size()/2-bl<br-a.size()/2){
      tmp=x[bl];
    }else{
      tmp=x[br];
    }
    if(tmp==1){
      l=mid;
    }else{
      r=mid;
    }
  }
  cout<<l<<endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(2*N-1);
    for(int i = 0 ; i < 2*N-1 ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


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

using namespace std;
#define int long long
#define N 1666666
int a[N];
signed main(){
	int n;cin>>n;int s=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		if(i%2&&a[i]%2) s++;
	}cout<<s;
	return 0;
}

Measured memory_bytes: 3620
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
using namespace std;
int main() {
	int ans = 0;
	string S;
	cin >> S;
	int i = 0;
	while (S[i] != '\0') {
		if (S[i] == '0'&&S[i + 1] == '0') {
			ans++;
			S[i + 1] = '1';
		}
		else if (S[i] == '1' && S[i + 1] == '1') {
			ans++;
			S[i + 1] = '0';
		}
		i++;
	//	cout << S << endl;
	}
	cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1<<30
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define RREP(i,a,b) for(ll i=(a); i>=(b); i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> pl;
typedef vector<pair<ll, ll>> vpl;

vpl adj[10005];
ll n;

void dijkstra(){
    priority_queue<pl> pq;
    vl d(105,INF);
    int visit[105] = {};
    d[0] = 0;
    pq.push(make_pair(0,0));
    while(!pq.empty()){
        pl p = pq.top(); pq.pop();
        ll u = p.second;
        visit[u] = 1;
        if(d[u] < p.first * (-1)) continue;
        rep(i,adj[u].size()){
            ll v = adj[u][i].first;
            if(visit[v] == 1) continue;
            if(d[v] > d[u] + adj[u][i].second){
                d[v] = d[u] + adj[u][i].second;
                pq.push(make_pair(d[v]*(-1),v));
            }
        }
    }
    rep(i,n){
        cout << i << " " << ((d[i] == INF) ? -1 : d[i]) << "\n";
    }
}

int main(){
    cin >> n;
    ll k,c,u,v;
    rep(i,n){
        cin >> u >> k;
        rep(j,k){
            cin >> v >> c;
            adj[u].push_back(make_pair(v,c));
        }
    }

    dijkstra();

    return 0;
}



Measured memory_bytes: 3420
#include <bits/stdc++.h>
#define ll long long
#define pll pair<ll,ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define pii pair<int,int>
#define mk make_pair
#define pb push_back
#define eps 1e-12
#define MAXN 200009
using namespace std;
ll mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n,m;
	cin>>n>>m;
	if(abs(n-m)>1)
	{
		cout<<0<<"\n";
		return 0;
	}
	ll ans=1;
	for(ll i=1;i<=n;i++)
	{
		ans=ans*i;
		ans%=mod;
	}
	for(ll i=1;i<=m;i++)
	{
		ans=ans*i;
		ans%=mod;
	}
	if((n+m)%2==0)
	{
		ans=ans*2;
		ans%=mod;
	}
	cout<<ans<<"\n";
}

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

using i8  = int8_t;   /* -128 ~ 127 */
using u8  = uint8_t;  /* 0 ~ 255 */
using i16 = int16_t;  /* -32,768 ~ 32,767 */
using u16 = uint16_t; /* 0 ~ 65,535 */
using i32 = int32_t;  /* -2,147,483,648 ~ 2,147,483,647 */
using u32 = uint32_t; /* 0 ~ 4,294,967,295 */
using i64 = int64_t;  /* -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 */
using u64 = uint64_t; /* 0 ~ 18,446,744,073,709,551,615 */
using f32 = float;    /* (-3.4 * 10^38) ~ (3.4 * 10^38) */
using f64 = double;   /* (-1.7 * 10^308) ~ (1.7 * 10^308) */
using f80 = __float80;
template <class T> using Vec = vector<T>;
constexpr i64 INF = 1010000000000000017;
constexpr i64 MOD = 1e9 + 7;
constexpr f64 EPS = 1e-12;
constexpr f64 PI = 3.14159265358979323846;
#define ALL(v) v.begin(), v.end()
#define YN(a, b, c) ((c)? a : b)
#define GCD(a, b) __gcd(a, b) /* 最大公約数 */
#define LCM(a, b) (i64)(a / (f64)__gcd(a, b) * b) /* 最小公倍数 */

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}

void Main() {
    i64 N;
    cin >> N;
    i64 sum = 0;
    for (i64 i = 1; i <= N; i++) {
        for (i64 j = 1; i * j <= N; j++) {
            if (N - i * j > 0) sum++;
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3656
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;

int main(){
    ll x, y;
    cin >> x >> y;
    ll ret = 500000000000LL;

    if(x==0){
        if(y > 0){
            ret = min(ret, y);
        }else{
            ret = min(ret, abs(y)+1);
        }
    }
    else if(y==0){
        if(x > 0){
            ret = min(ret, x+1);
        }else{
            ret = min(ret, abs(x));
        }
    }
    else if(x>0 && y>0){
        if(x < y){
            ret = min(ret, y-x);
        }else{
            ret = min(ret, x-y+2);
        }
    }
    else if(x<0 && y>0){
        if(abs(x) < abs(y)){
            ret = min(ret, abs(y)-abs(x)+1);
        }else{
            ret = min(ret, abs(x)-abs(y)+1);
        }
    }
    else if(x>0 && y<0){
        if(abs(x) < abs(y)){
            ret = min(ret, abs(y)-abs(x)+1);
        }else{
            ret = min(ret, abs(x)-abs(y)+1);
        }
    }
    else{
        if(abs(x) < abs(y)){
            ret = min(ret, abs(y)-abs(x)+2);
        }else{
            ret = min(ret, abs(x)-abs(y));
        }
    }
    cout << ret << endl;
    return 0;
}


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

#include <iostream>
using namespace std;


int main() {

	int n, k;
	cin >> n >> k;
	int i = -1;
	int x = 0;
	do {
		i++;
		x = pow(k, i);
	} while (x <= n);
	cout << i;
}

Measured memory_bytes: 256
N = int(input())
P = [0.0] + list(map(float, input().split()))

dp = [[0.0 for _ in range(3002)] for _ in range(3002)]
dp[0][0] = 1

for i in range(1, N + 1):
  for j in range(3000):
    dp[i][j] = dp[i - 1][j - 1] * P[i] + dp[i - 1][j] * (1 - P[i])

answer = 0
for  j in range(N // 2 + 1, 3002):
  answer += dp[N][j]

print(answer)

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

int main(){
    int r, g ,b;
    cin >> r >> g >> b;
    if ((10*g + b)%4 == 0 ){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int N = sc.nextInt();
        int res = 0;
        if (N == 0) {
            res = X;
        } else {
            List<Integer> array = new ArrayList<>();
            for (int i = 0; i < N; i++) {
                array.add(sc.nextInt());
            }
            Map<Integer, Integer> absMap = new HashMap<>();
            for (int i = 0; i <= 105; i++) {
                int abs = Math.abs(X - i);
                absMap.put(i, abs);
            }

            int minVal = Integer.MAX_VALUE;
            for (int i : absMap.keySet()) {
                int val = absMap.get(i);
                if (val < minVal && !array.contains(i)) {
                    res = i;
                    minVal = val;
                }
            }
        }
        sc.close();
        System.out.println(res);

    }
}


Measured memory_bytes: 36032
#pragma GCC optimize "-O3"
#pragma GCC target ("avx")
#define _USE_MATH_DEFINES
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define inf (1ll<<60)
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v),greater<int>())
#define SPEED ios::sync_with_stdio(false);cin.tie(0);cout<<fixed<<setprecision(12)
signed gcd(int a, int b){return b?gcd(b,a%b):a;}
signed lcm(int a, int b){return a*b/gcd(a,b);}
//priority_queue<int, vi, greater<int> > que;//昇順

using namespace std;

const int mod=1e9+7;

signed main(){
    SPEED;
    vi bell(3);
    rep(i,3)cin >> bell[i];
    SORT(bell);
    cout << bell[0]+bell[1] << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if (a + b >= c) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }

}


Measured memory_bytes: 21844
#include <cstdio>
using namespace std;
int main() {
	long long a,b,x;
	scanf("%lld %lld %lld",&a,&b,&x);
	if(a==0) printf("%lld\n",b/x+1);
	else printf("%lld\n",b/x-(a-1)/x);
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <vector>
#include <bitset>
#include <queue>
using namespace std;

int main(){
    string s;
    cin >> s;
    int slen = s.length();
    int aindex = 0;
    int zindex = slen;
    for(int i = 0; i < slen; i++){
        if(s[i] == 'A'){
            aindex = i;
            break;
        }
    }
    for(int i = slen-1; i > 0; i--){
        if(s[i] == 'Z'){
            zindex = i;
            break;
        }
    }
    cout << zindex - aindex +1 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <set> 
#include <map>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <iomanip>
#define REP(i,n) for(int i=0; i<(n); ++i)
#define FOR(i,a,b) for(int i=(a); i<(b); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const ll INFLL = 100100100100100100;
const int MOD = (int)1e9 + 7;
const ll MODLL = (ll)1e9 + 7;
const double EPS = 1e-9;

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

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

    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# %%
import numpy as np
# %%
stdin = open(0)

# %%
N, K = map(int, stdin.read().split())

# %%
MOD = 10 ** 9 + 7

# %%


def cumprod(A, MOD=MOD):
    L = len(A); Lsq = int(L**.5 + 1)
    A = np.resize(A, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        A[:, n] *= A[:, n - 1]; A[:, n] %= MOD
    for n in range(1, Lsq):
        A[n] *= A[n - 1, -1]; A[n] %= MOD
    return A.ravel()[:L]


def make_fact(U, MOD=MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD - 2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    fact.flags.writeable = False
    fact_inv.flags.writeable = False
    return fact, fact_inv


# %%
fact, fact_inv = make_fact(N + 10)

# %%
if K >= N:
    K = N - 1
x = fact[N] * fact_inv[0:K + 1] % MOD * fact_inv[N - K:N + 1][::-1] % MOD
y = fact[N - 1] * fact_inv[0:K + 1] % MOD * fact_inv[N - K - 1:N][::-1] % MOD
answer = np.sum(x * y % MOD) % MOD

# %%
print(answer)

# %%


Measured memory_bytes: 24968
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v), end(v)
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
 
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef deque<bool> db;
template<class T> using vv=vector<vector< T > >;

int main() {
  vi a = {1, 2, 4, 8};
  vi ar = {8, 4, 2, 1};
  vll price(4);
  rep (i, 4) {
    cin >> price[i];
  }
  ll n;
  cin >> n;
  n *= 4;

  vector<pair<int, int> > vp(4);
  rep (i, 4) {
    vp[i].first = price[i] * ar[i];
    vp[i].second = i;
  }
  sort(all(vp), [](auto x, auto y) {
      if (x.first == y.first) {
      return x.second >= y.second;
      }
      return x.first < y.first;
      });

  ll ans = 0;
  rep (i, 4) {
    auto b = vp[i];
    int ii = b.second;
    ll kosuu = n / a[ii];
    ans += (ll)price[ii] * kosuu;
    n -= a[ii] * kosuu;
  }
  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 256
# C - いっしょ
def main():
    import math
    _ = int(input())
    a = list(map(int, input().split()))
    t = float('inf')

    for i in range(min(a), max(a)+1):
        cnt = 0
        for j in a:
            cnt += (j-i)**2
        else:
            if cnt < t:
                t = cnt
    else:
        print(t)

    
if __name__ ==  "__main__":
    main()

Measured memory_bytes: 9196
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b,c,n=0;
    cin>>a>>b>>c;
    for(int i=a;i<=b;i++){
        if(c%i==0){
            n++;
            }
        }
    cout<<n<<endl;
}



Measured memory_bytes: 3088
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <cmath>
#include <limits>
#include <sstream>

using namespace std;

int main (void)
{
	for (int i = 0; i < 100; i++)
	{
		int n,a[100][100];
		cin >> n;
		if (n == 0)
		{
			break;
		}

		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < n; k++)
			{
				cin >> a[j][k];
			}
		}
		int co = 0;
		int coo = 0;

		for (int j = 0; j < n; j++)
		{
			for (int k = 0; k < n; k++)
			{
				co += a[j][k];
			}
			a[j][n] = co;
			co = 0;
		}

		for (int k = 0; k < n + 1; k++)
		{
			for (int j = 0; j < n; j++)
			{
				coo += a[j][k];
			}
			a[n][k] = coo;
			coo = 0;
		}



		for (int j = 0; j < n + 1; j++)
		{
			for (int k = 0; k < n + 1; k++)
			{
				ostringstream p;
				string pp;
				p << a[j][k];
				pp = p.str();
				int l = 0;
				l = pp.size();
				if (l == 1)
				{
					cout << "    ";
				}
				else if (l == 2)
				{
					cout << "   ";
				}
				else if (l == 3)
				{
					cout << "  ";
				}
				else if (l == 4)
				{
					cout << " ";
				}
				cout << a[j][k];
			}
			cout << endl;
		}
	}
}


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

int main(void)
{
    int A, B, C, D, E; cin >> A >> B >> C >> D >> E;
    
    int a=((A/10*10+10)-A==10?0:(A/10*10+10)-A);
    int b=((B/10*10+10)-B==10?0:(B/10*10+10)-B);
    int c=((C/10*10+10)-C==10?0:(C/10*10+10)-C);
    int d=((D/10*10+10)-D==10?0:(D/10*10+10)-D);
    int e=((E/10*10+10)-E==10?0:(E/10*10+10)-E);
    int mx=max({a, b, c, d, e});
    
    cout << A + B + C + D + E + a + b + c + d + e - mx << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		int c = Integer.parseInt(a+b);
		boolean heihoukon = false;
		for(int i = 0;i<317;i++) {
			if(i*i == c) {
				heihoukon = true;
			}
		}
		if(heihoukon == true) {
			System.out.println("Yes");
		}else if(heihoukon == false) {
			System.out.println("No");
		}

	}
}

Measured memory_bytes: 21716
import java.util.*;

public class Main{
	public static void main(String[] args){
		int i;
		Scanner sc = new Scanner(System.in);
		PriorityQueue<State>
			a = new PriorityQueue<State>(),
			b = new PriorityQueue<State>(),
			c = new PriorityQueue<State>();

		for(i=0;i<8;i++) a.add(new State(sc.nextInt(),sc.nextDouble()));
		for(i=0;i<8;i++) b.add(new State(sc.nextInt(),sc.nextDouble()));
		for(i=0;i<8;i++) c.add(new State(sc.nextInt(),sc.nextDouble()));

		for(i=0;i<2;i++) System.out.println(a.poll());
		for(i=0;i<2;i++) System.out.println(b.poll());
		for(i=0;i<2;i++) System.out.println(c.poll());

		PriorityQueue<State> pq = new PriorityQueue<State>();
		pq.addAll(a);
		pq.addAll(b);
		pq.addAll(c);

		for(i=0;i<2;i++) System.out.println(pq.poll());
	}
}

class State implements Comparable<State>{
	int n;
	double t;

	State(int n, double t){
		this.n = n;
		this.t = t;
	}

	public int compareTo(State st){
		if(this.t < st.t) return -1;
		else if(this.t == st.t) return 0;
		else return 1;
	}

	public String toString(){
		return String.format("%d %.2f",n,t);
	}
}

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

int main(void){
	int N,M;
	cin >> N >> M;
	int a[N],b[N],c[M],d[M];
	int i,j;
	for(i=0;i<N;i++){
		cin >> a[i] >> b[i];
	}
	for(i=0;i<M;i++){
		cin >> c[i] >> d[i];
	}
	long long ans,ansx,ansy,distance,tempdistance,tempx,tempy;
	for(i=0;i<N;i++){
		ansx= labs(a[i]-c[0]);
		ansy= labs(b[i]-d[0]);
		distance = ansx + ansy;
		ans = 1;
		for(j=0;j<M;j++){
			tempx = labs(a[i]-c[j]);
			tempy = labs(b[i]-d[j]);
			tempdistance = tempx + tempy;
			if(distance>tempdistance){
				distance = tempdistance;
				ans = j+1;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

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

int main(void){
	
	int abc[3];
	for(int i=0;i<3;i++){
		cin>>abc[i];
	}
	int five=0;
	int seven=0;
	for(int i=0;i<3;i++){
		
		switch(abc[i]){
		case 5:
			five++;
			break;
		case 7:
			seven++;
			break;
		default:
			break;
		}
	}
	
	if((five==2)&&(seven==1)){
		cout<<"YES"<<endl;
	}
	else{
		cout<<"NO"<<endl;
	}
	return 0;
}
	
	
	


Measured memory_bytes: 256
from math import factorial

def comb(m, n):
    return factorial(m) // factorial(n) // factorial(m-n)

def solve(n, p, a):
    n_odd = len(list(filter(lambda _:_%2, a)))
    n_even = n - n_odd
    v = 2**n_even
    w = sum([comb(n_odd, k) for k in range(p, n_odd+1, 2)])
    return v * w

n, p = map(int, input().split())
a = list(map(int, input().split()))
print(solve(n, p, a))

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

using namespace std;

#define fi first
#define se second

typedef pair<int, int> ii;

const long long MOD = 1E9 + 7;

int n;
long long ans = 1;
vector<ii> a;

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n;
    for (int j = 0; j < 2; ++j)
        for (int i = 1; i <= n; ++i) {
            int t;
            cin >> t;
            a.push_back({t, j});
        }
    sort(a.begin(), a.end());
    int cnt[2] = {0, 0};
    for (ii i : a) {
        if (cnt[i.se ^ 1] == 0) ++cnt[i.se];
        else (ans *= cnt[i.se ^ 1]--) %= MOD;
    }
    cout << ans << "\n";
    return 0;
}

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

int main() {
  int64_t a,b,c,d;
  cin>>a>>b>>c>>d;
  vector<int64_t> nums(4);
  nums.at(0)=a*c; nums.at(1)=a*d; nums.at(2)=b*c; nums.at(3)=b*d;
  sort(nums.begin(), nums.end());
  cout<<nums.at(3)<<endl;
}

Measured memory_bytes: 3620
def main():
    N, K = map(int, input().split())
    A_list = list(map(str, input().split()))
    use_list = ["0","1","2","3","4","5","6","7","8","9"]
    list_A = list(set(use_list) - set(A_list))
    #print("list_A", list_A)
    for i in range(100000) :
        ans = N + i
        #print("ans", ans)
        ans_str = str(ans)
        frag = 0
        for val in ans_str :
            #print("val", val)
            if str(val) in list_A :
                pass
                #print("frag", frag)
            else :
                frag = 1
                break

        if frag == 0 :
            break
    print(ans)


if __name__ == '__main__':
    main()

Measured memory_bytes: 8980
#include<bits/stdc++.h>
#define INF (1 << 29);
using namespace std;

int main(){
  int n,m;
  int c[20];
  int t[50000+1];
 
  cin >> n >> m;
  for(int i=0;i < m;i++){
    cin >> c[i];
  }

  for(int j=1;j <= n;j++){
      t[j] = INF;
  }
  t[0] = 0;
  
  for(int i=0;i < m;i++){
    for(int j=c[i];j <= n;j++){
      t[j] = min(t[j],t[j - c[i]] + 1);
    }
  }
  cout << t[n] << endl;
  return 0;
}
  


Measured memory_bytes: 3296
# 初期化
b_1 = [[0] * 10 for a in range(3)]
b_2 = [[0] * 10 for a in range(3)]
b_3 = [[0] * 10 for a in range(3)]
b_4 = [[0] * 10 for a in range(3)]

n = int(input())
while n != 0:
    b,f,r,v = input().split()
    b = int(b)
    f = int(f)
    r = int(r)
    v = int(v)
    if b == 1:
        b_1[f-1][r-1] += v
    if b == 2:
        b_2[f-1][r-1] += v
    if b == 3:
        b_3[f-1][r-1] += v
    if b == 4:
        b_4[f-1][r-1] += v
    n -= 1

for a in b_1:
    for i,b in enumerate(a):
        print(' {}'.format(b),end='')
        if i+1 == len(a):
            print('')
print('#'*20)
for a in b_2:
    for i,b in enumerate(a):
        print(' {}'.format(b),end='')
        if i+1 == len(a):
            print('')
print('#'*20)
for a in b_3:
    for i,b in enumerate(a):
        print(' {}'.format(b),end='')
        if i+1 == len(a):
            print('')
print('#'*20)
for a in b_4:
    for i,b in enumerate(a):
        print(' {}'.format(b),end='')
        if i+1 == len(a):
            print('')



Measured memory_bytes: 5628
#include <iostream>
#include <numeric>
#include <queue>

int main() {
  using namespace std;
  int N, M;
  cin >> N >> M;
  priority_queue<long> A;
  for (auto i = 0; i < N; ++i) {
    long e;
    cin >> e;
    A.push(e);
  }
  for (; 0 < M; --M) {
    auto top = A.top();
    A.pop();
    A.push(top / 2);
  }
  auto res = 0L;
  while (!A.empty()) {
    auto top = A.top();
    A.pop();
    res += top;
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 1400
n, m = list(map(int, input().split()))
ab = []

for i in range(n):
    ab.append(list(map(int, input().split())))

ab.sort()

ans = 0
for i in range(n):
    z = min(ab[i][1], m)
    ans += z * ab[i][0]
    m = m - z
    if m == 0:
        break

print(ans)

Measured memory_bytes: 27760
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int ct = 0;
    for (int i = 0; i < n; i++){
        int x;
        scanf("%d",&x);
        if (x == ct+1){
            ct++;
        }
    }
    if (ct == 0){
        printf("-1");
    }
    else printf("%d",n-ct);
}


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

using namespace std;
using ll = long long int;
constexpr ll M = 1e9 + 7;
inline ll sum_1(const ll n) { return ((n * (n + 1)) / 2) % M; }
inline ll sum_2(const ll n) { return ((n * (n + 1) * (2 * n + 1)) / 6) % M; }
inline ll sum_3(const ll n) { return (((n * (n + 1)) / 2) % M * ((n * (n + 1)) / 2) % M) % M; }
inline ll sum_1(const ll i, const ll j) { return (sum_1(j) - sum_1(i - 1) + M) % M; }
inline ll sum_2(const ll i, const ll j) { return (sum_2(j) - sum_2(i - 1) + M) % M; }
inline ll sum_3(const ll i, const ll j) { return (sum_3(j) - sum_3(i - 1) + M) % M; }

void solve() {
    ll x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;

    vector<ll> p(a), q(b), r(c);
    for (auto &i : p) cin >> i;
    for (auto &i : q) cin >> i;
    for (auto &i : r) cin >> i;

    sort(p.begin(), p.end(), greater<ll>());
    sort(q.begin(), q.end(), greater<ll>());
    sort(r.begin(), r.end(), greater<ll>());

    ll sum_red = accumulate(p.begin(), p.begin()+x, 0LL);
    ll sum_green = accumulate(q.begin(), q.begin()+y, 0LL);
    ll total_sum = sum_red + sum_green;

    priority_queue<ll, std::vector<ll>, greater<ll>> red(p.begin(), p.begin()+x);
    priority_queue<ll, std::vector<ll>, greater<ll>> green(q.begin(), q.begin()+y);
    /**
     * dp[i] = color this red
     *             remove least element, add curr element
     *            color this green, remove least ele, add curr elem
     *            leave colorless
     */
    for (int i = 0; i < c; ++i) {
        ll pred = red.top();
        ll pgreen = green.top();
        ll temp = max({
            total_sum - pred + r[i],
            total_sum - pgreen + r[i],
            total_sum
        });
        if (temp == total_sum - pred + r[i]) {
            red.pop();
            red.push(r[i]);
        } else if (temp == total_sum - pgreen + r[i]) {
            green.pop();
            green.push(r[i]);
        }
        total_sum = temp;
    }

    cout << total_sum << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef D_LOCAL
        freopen("in.in", "r", stdin);
        freopen("out.out", "w", stdout);
    #endif

    solve();

    return 0;
}

Measured memory_bytes: 3968
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

#include <bits/stdc++.h>
using namespace std;

const int MAX = 2100000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  for(int i=2;i<MAX;i++){
    fac[i]=fac[i-1]*i%MOD;
    inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
    finv[i]=finv[i-1]*inv[i]%MOD;
  }
}

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

int main() {
  init();
  ll x,y;
  cin>>x>>y;
  
  if((2*x-y)%3!=0 || (2*y-x)%3!=0){
    cout<<0<<endl;
    return 0;
  }
  
  ll a=(2*x-y)/3;
  ll b=(2*y-x)/3;
  cout<<nCr(a+b,a)<<endl;
  
  return 0;
}

Measured memory_bytes: 52868
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<vector>
#include<algorithm>
#include<string.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << x << endl;
using namespace std;

int main(){
    int x, count;

    while(cin >> x, x){
        count = 0;
        while(x != 1){
            if(x % 2 == 0){
                x /= 2;
            }else{
                x = x * 3 + 1;
            }
            count++;
        }
        cout << count << endl;
    }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

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

    ll ans = 0;
    for(ll i=0;i<n;++i){
        ll index = i;
        for(ll j=i;j<n;++j){
            if(a[j] < a[index]){
                index = j;
            }
        }
        swap(a[i], a[index]);
        if(i != index){
            ans++;
        }
    }

    for(ll i=0;i<n;++i){
        if(i != 0){
            cout<<' ';
        }
        cout<<a[i];
    }
    cout<<endl;
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 3092
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>

using namespace std;

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

	vector<int> vec(N);

	for (int i = 0; i < N; i++){
		cin >> vec.at(i);
	}

	sort(vec.begin(), vec.end());
	int count = 0;
	for (int i = 0; i < N - 2; i++) {
		for (int j = i + 1; j < N - 1; j++) {
			for (int k = j + 1; k < N; k++) {
				if (vec.at(k) < vec.at(i) + vec.at(j)) {
					count++;
				}
				else {
					break;
				}
			}
		}
	}

	cout << count << endl;
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
	//ifstream cin("input.txt");

	string S;
	getline(cin, S);

	char currentColor = S[S.length() - 1];
	int countStones = 1;
	int result = 0;
	for (int i = S.length() - 2; i >= 0; --i)
	{
		if (S[i] == currentColor)
			++countStones;
		else
		{
			currentColor = S[i];
			++result;
			countStones += 2;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 512
N, K = map(int, input().split())

throw = [0 for i in range(N)]
times = 0
for i in range(N, 0, -1):

    while K / (i * 2 ** (times)) > 1:
        times += 1
    throw[i-1] = 1/N*pow(1/2, times)


# print(throw)
ans = 0
for i in throw:
    ans += i
print(ans)


Measured memory_bytes: 6296
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    String str = sc.next();
    char[] c = str.toCharArray();
    int sum = 700;

    for (int i = 0 ; i < str.length() ; i++ ) {
      if (c[i] == 'o') {
        sum += 100;
      }
    }
    System.out.println(sum);
  }
}


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

const long long mod=1e9+7;

int main(){
    string s;
    cin>>s;
    long long n=s.size();
    long long a[n]={},c[n]={},q[n]={};
    for(int i=0;i<n;i++){
        if(i){
            a[i]=a[i-1];
            c[i]=c[i-1];
            q[i]=q[i-1];
        }
        if(s[i]=='A') a[i]++;
        if(s[i]=='C') c[i]++;
        if(s[i]=='?') q[i]++;
    }
    long long ans=0;
    long long cc=c[n-1],qq=q[n-1];

    long long p[qq+1];
    p[0]=1;
    for(int i=1;i<=qq;i++){
        p[i]=p[i-1]*3;
        p[i]%=mod;
    }
    for(int i=1;i<n-1;i++){
        if(s[i]=='B'){
            ans+=(a[i-1]*(cc-c[i]))%mod*p[qq]%mod;
            if(qq>0){
                ans+=((a[i-1]*(qq-q[i]))%mod*p[qq-1])%mod;
                ans+=((q[i-1]*(cc-c[i]))%mod*p[qq-1])%mod;
            }
            if(qq>1) ans+=((q[i-1]*(qq-q[i]))%mod*p[qq-2])%mod;
            ans%=mod;
        }
        if(s[i]=='?'){
           if(qq>0) ans+=((a[i-1]*(cc-c[i]))%mod*p[qq-1])%mod;
           if(qq>1){
                ans+=((a[i-1]*(qq-q[i]))%mod*p[qq-2])%mod;
                ans+=((q[i-1]*(cc-c[i]))%mod*p[qq-2])%mod;
           }
            if(qq>2) ans+=((q[i-1]*(qq-q[i]))*p[qq-3])%mod;
            ans%=mod;
        }
    }

    cout<<ans<<endl;
    
}

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

int main(void){
    int a,b,c = 0;
    cin >> a >> b >> c;
    if(a != b && a != c){
        cout << a;
    }else if(b != a && b != c){
        cout << b;
    }else
    {
        cout << c;
    }
    
}

Measured memory_bytes: 256
S=str(input())
N=len(S)
n=round((N-1)/2)
s=S[0:n]
bad=0
for i in range(n):
  if s[i] != s[n-i-1]:
    bad = bad + 1
for i in range(round((N-1)/2)):
  if S[i] != S[N-i-1]:
    bad = bad + 1

if bad<1:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define tarce(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define pb push_back
#define inf 2e18
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
#define mem(a,v) memset(a,v,sizeof(a))
#define pii pair<int,int>
#define mkp make_pair
using namespace std;
#define N 200005


int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        
        int n;
        cin >> n;
        string a,b;
        cin >>a >> b;
        string ans="";
        int i;
        for(i=0; i<n; i++){
            ans+=a[i];
            ans+=b[i];
        }
        cout << ans;
        

}

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


int stringToInt(string str){
	int num = 0;
	for(int i = 0; i < str.length(); i++){
		num += str[i] - '0';
	}
	return num;
} 


int main()
{
	string str;
	cin>>str;
	int num = stringToInt(str);
	while(num != 0){
		cout<<num<<endl;
		cin>>str;
		num = stringToInt(str);
	}
	return 0;
}

Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
//typedef complex<D> P;
#define F first
#define S second
const ll MOD=1000000007;
//const ll MOD=998244353;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){int i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}



int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(12);
  ll N,K;
  cin>>N>>K;
  vector<ll> A(N);
  cin>>A;
  for(auto &I:A){I--;}
  vector<ll> dp=A;
  for(int i=1;i<N;i++){dp[i]+=dp[i-1];}
  ll ans=dp[K-1];
  for(int i=K;i<N;i++){
    ans=max(ans,dp[i]-dp[i-K]);
  }
  cout<<(D)ans/2+K<<endl;


  return 0;
}


Measured memory_bytes: 3456