akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
vector<int> v[200100];
int dia=0;
void calc(){
	int t[200100];
	fill(t,t+200100,-1);
	queue<int> q;
	q.push(0);
	t[0]=0;
	int ne=0;
	while(q.size()){
		int u=q.front();q.pop();
		ne=u;
		for(int i=0;i<v[u].size();i++){
			if(t[v[u][i]]!=-1)continue;
			t[v[u][i]]=t[u]+1;
			q.push(v[u][i]);
		}
	}
	fill(t,t+200100,-1);
	q.push(ne);
	t[ne]=0;
	//cout<<ne<<endl;
	ne=0;
	while(q.size()){
		int u=q.front();q.pop();
		for(int i=0;i<v[u].size();i++){
			if(t[v[u][i]]!=-1)continue;
			t[v[u][i]]=t[u]+1;
			ne=max(ne,t[v[u][i]]);
			q.push(v[u][i]);
		}
	}
	dia=ne;
}
int main(){
	cin>>n;
	REP(i,n-1){
		int a,b;
		cin>>a>>b;
		a--,b--;
		v[a].push_back(b);
		v[b].push_back(a);
	}
	calc();
	//cout<<dia<<endl;
	if(dia%3==1){
		cout<<"Second"<<endl;
	}else{
		cout<<"First"<<endl;
	}
	return 0;
}

Measured memory_bytes: 13556
#include <bits/stdc++.h>
using namespace std;
#define int long long

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

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

  int answer = 1000;
  int stock = 0;

  for (int i = 1; i < n; i++) {
    if(a[i] > a[i - 1]) {
      stock = answer / a[i - 1];
      answer -= stock * a[i - 1];
    }
    answer += stock * a[i];
    stock = 0;
  }
  cout << answer << '\n';
  return 0;
}

Measured memory_bytes: 3564
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] M = new long[N];

		for(int i = 0 ; i < N ; i++){
			M[i] = sc.nextLong();
		}
		sc.close();

		long ans = M[0];
		for(int i = 1 ; i < N ; i++){
			ans = gcd(ans,M[i]);
		}

		System.out.println(ans);


	}
	private static long gcd(long m, long n) {
	    if(m < n) return gcd(n, m);
	    if(n == 0) return m;
	    return gcd(n, m % n);
	}
}



Measured memory_bytes: 47824
n = int(input())
l = list(map(int, input().split()))
ans=0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if l[i]!=l[j] and l[j]!=l[k] and l[k]!=l[i] and l[i]+l[j]>l[k] and l[i]+l[k]>l[j] and l[j]+l[k]>l[i]:
                ans += 1
print(ans)

Measured memory_bytes: 9104
import std.stdio, std.conv, std.string;
import std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
string read(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }

int DEBUG_LEVEL = 0;
void print()(){ writeln(""); }
void print(T, A ...)(T t, lazy A a){ write(t), print(a); }
void print(int level, T, A ...)(T t, lazy A a){ if(level <= DEBUG_LEVEL) print(t, a); }

const long mod = 1_000_000_007;

void main(string[] args){
	if(args.length > 1 && args[1] == "-debug"){
		if(args.length > 2 && args[2].isNumeric) DEBUG_LEVEL = args[2].to!int;
		else DEBUG_LEVEL = 1;
	}
	
	long n = read.to!long;
	long q = read.to!long;
	
	string s = readln.chomp;
	
	char[] ts, ds;
	foreach(i; 0 .. q){
		string l = readln.chomp;
		ts ~= l[0];
		ds ~= l[2];
	}
	
	long x = -1;
	foreach_reverse(i; 0 .. q){
		char t = ts[i], d = ds[i];
		if(t == s[x + 1] && d == 'L') x += 1;
		else if(x >= 0 && t == s[x] && d == 'R') x -= 1;
	}
	
	long y = n;
	foreach_reverse(i; 0 .. q){
		char t = ts[i], d = ds[i];
		if(t == s[y - 1] && d == 'R') y -= 1;
		else if(y < n && t == s[y] && d == 'L') y += 1;
	}
	
	print!1("x:", x, " y:", y);
	
	long ans = n - (x - -1) - (n - y);
	ans.writeln;
	
}

/*

左からあふれるものとは
「初期状態でどこかより左のものたち」になる
（追い越すことはできないため）

それがどこであるかをトレースする
後ろから見ていく

xがその限界であるとする
xの右のマスから左に入る指示があれば、x += 1
xから右に出る指示があれば、x -= 1

*/



Measured memory_bytes: 4220
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;


int main ()
{

long long r,d,initial,final,i=10;

cin >> r >> d >> initial;

while(i-->0)
{

final=r*initial-d;
cout << final << endl;
initial=final;

 }

	return 0;
}











Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
typedef pair<ll, int>Pair;
#define MAX 1e9
struct edge { int to, cost; };
typedef pair<int, int>P;
#define MOD 1000000007

int main(){
  string S;
  cin>>S;
  ll N=S.size();
  ll dp[N+1][2];
  rep(i,N+1){dp[i][0]=0ll;dp[i][1]=0ll;}
  dp[0][1]=1ll;
  rep(i,N){
      dp[i+1][0]+=3ll*dp[i][0];
    if(S[i]=='1'){
      dp[i+1][0]+=dp[i][1];
      dp[i+1][1]+=2ll*dp[i][1];
    }
    else{dp[i+1][1]+=dp[i][1];}
    dp[i+1][0]%=MOD;
    dp[i+1][1]%=MOD;
  }
  ll ans=0ll;
  ans+=dp[N][0]+dp[N][1];
  ans%=MOD;
  ans+=MOD;
  ans%=MOD;
  cout<<ans;
}



Measured memory_bytes: 5292
#include <iostream>
using namespace std;
int main(){
    int x=1,y=1;
    while(true){
        
        cin>>x>>y;
        if(x==0&&y==0){
            break;
        }
        if(x<y){
            cout<<x<<" "<<y<<endl;
        }else{
            cout<<y<<" "<<x<<endl;
        }
          }
    return 0;
}
          

Measured memory_bytes: 1160
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ff first
#define ss second
#define ll long long
#define vi vector<int>
#define vii vector<vi>
#define vs vector<string>
#define vss vector<vs>
#define pii pair<int, int>
#define all(x) x.begin(), x.end()
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define repr(i, a, n) for (int i = (n); i >= (a); --i)
using namespace std;
const int INF(1 << 30);
const ll LLINF(1LL << 55LL);
const int pi = 3.1415926536;
const int MOD = 1000000007;
const int MAX = 510000;

void Main() {
  string s;
  cin >> s;
  for (int i = 1; i < s.size() + 1; i += 2) {
    cout << s[i - 1];
  }
}

int main() {
  std::cin.tie(nullptr);                  // 標準入出力高速化
  std::ios_base::sync_with_stdio(false);  // SとS++の入出力出力を非同期
  std::cout << std::fixed << std::setprecision(15);  // 小数を10進数表示
  Main();
}

Measured memory_bytes: 592
N = int(input())
L, R = [], []
for _ in range(N):
    l, r = map(int, input().split())
    L.append(l)
    R.append(r)

L = sorted(L)[::-1]
R = sorted(R)

def calc(k):
    pre = 0
    s = 0
    for i in range(N):
        a = max(pre, L[i//2]) if i % 2 == k else min(pre, R[i//2])
        s += abs(pre - a)
        pre = a
    return s + abs(pre)

print(max(calc(0), calc(1)))

Measured memory_bytes: 60504
program range_set
  implicit none
  integer(8), parameter :: modu = 1000000007
  integer :: n, a, b, i, j
  integer(8) :: x = 1, f(0:5000, 2) = 0, g(0:5000, 2) = 0
  read(*,*) n, a, b
  if (a > b) then
    i = a
    a = b
    b = i
  end if
  g(1, 2) = 1
  do i = 2, b - 1
    g(i, 2) = mod(g(i - 1, 1) + g(i - 1, 2), modu)
    g(i, 1) = mod(sum(g(1:i - a, 2)), modu)
  end do
  f(0, :) = 1
  do i = 1, n - 1
    x = x + x
    if (x > modu) x = x - modu
    f(i, 1) = mod(sum(f(max(i - a + 1, 0):i - 1, 2)), modu)
    if (i < b) then
      do j = 1, i - 1
        f(i, 2) = f(i, 2) + mod(f(i - j, 1) * g(j, 2), modu)
      end do
      f(i, 2) = mod(f(i, 2) + g(j, 1) + g(j, 2), modu)
    else
      do j = 1, b - 1
        if (i == n) f(i, 1) = mod(f(i, 1) + f(i - j, 1) * g(j, 1), modu)
        f(i, 2) = f(i, 2) + mod(f(i - j, 1) * g(j, 2), modu)
      end do
      f(i, 2) = mod(f(i, 2), modu)
    end if
  end do
  x = x + x
  if (x > modu) x = x - modu
  f(n, 1) = mod(sum(f(n - a + 1:n - 1, 2)), modu)
  do j = 1, b - 1
    f(n, 1) = f(n, 1) + mod(f(n - j, 1) * g(j, 1), modu)
    f(n, 2) = f(n, 2) + mod(f(n - j, 1) * g(j, 2), modu)
  end do
  write(*,'(i0)') modulo(x - f(n, 1) - f(n, 2), modu)
end program range_set

Measured memory_bytes: 3088
n = gets.to_i
as = gets.strip.split.map(&:to_i)
while as.size > 1 do
    min_a = as.min
    min_ind = as.index(min_a)
    for i in 0...as.size
        if i == min_ind
            next
        end
        as[i] %= min_a
    end
    as = as.select { |a| a > 0 }
    if as.size == 0
        break
    end
end

puts min_a

Measured memory_bytes: 10244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,t,s;
    while(cin>>a>>b>>c>>d)
    {
        t=a-d;
        s=c-b;
        while(1)
        {
            if(t<=0 || s<=0)
                break;
            t=t-d;
            s=s-b;
        }
        if(s<=0)
            cout<<"Yes"<<endl;
        else if(t<=0)
            cout<<"No"<<endl;

    }
    return 0;
}


Measured memory_bytes: 3596
n=int(input())
d=[list(map(int,input().split())) for _ in range(n)]

ans=cnt=0
for i in range(n):
  for j in range(i+1,n):
    ans+=((d[i][0]-d[j][0])**2+(d[i][1]-d[j][1])**2)**0.5
print(2*ans/n)

Measured memory_bytes: 9416
#include <algorithm>
#include <bitset>
#include <cmath>
#include <ctime>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <stdio.h>
#include <string>
#include <vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(a) a.begin(),a.end()
using namespace std;
// using ll = long long;
// using P = pair<int,int>;
// using vi = vector<int>;
// using vvi = vector<vi>;







template <typename T>
T gcd(T a, T b) {
  if(b == 0) return a;
  else return gcd(b,a%b);
}


const double pi = 3.141592653589793;

int main() {
  double A,B,H,M;
  cin >> A >> B >> H >> M;
  double alfa = 6*M;
  double beta = M/2 + 30*H;
  double ans = A*A + B*B - 2*A*B*cos(abs(alfa-beta)/180 * pi);
  ans = sqrt(ans);
  printf("%.20lf\n",ans);
  return 0;
}





Measured memory_bytes: 3636
package main

import "fmt"

func main() {
	var n int

	fmt.Scan(&n)
	a := make([]int, n)
	b := make([]int, n)
	c := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
		fmt.Scan(&b[i])
		fmt.Scan(&c[i])
	}

	fmt.Println(solve(n, a, b, c))
}

func solve(n int, a, b, c []int) int {
	x, y, z := 0, 0, 0

	for i := 0; i < n; i++ {
		x, y, z = max(y, z)+a[i], max(x, z)+b[i], max(x, y)+c[i]
	}

	return max(x, y, z)
}

func max(a int, rest ...int) int {
	m := a
	for _, x := range rest {
		if x > m {
			m = x
		}
	}

	return m
}


Measured memory_bytes: 5504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MOD 1000000007
#define INF 1e9
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;


int main() {
	string s;
	cin>>s;
	int n=s.size();
	int ans=n;
	for(int i=1;i<n;i++){
		if(s[i]==s[i-1]) continue;
		ans=min(ans,max(i,n-i));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
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();
        sc.close();

        int ans = (a + b + c) + Math.max(a, Math.max(b, c)) * 9;
        System.out.println(ans);
    }

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define lc 2 * v
#define rc 2 * v + 1
#define mid (s + e) / 2
#define ll long long
#define int long long
#define ld long double
#define pii pair <int , int>
#define pll pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);
// #pragma GCC optimize("Ofast")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

const int maxn = 3e5 , N = 1e5 + 5 , SQ = 600 , base = 1999 , mod = 1e9 + 7 , INF = 1e18 , lg = 17;

int n , w , a[maxn][2] , dp[110][maxn];

int32_t main() {
    FAST
    cin >> n >> w;
    for (int i = 0 ; i < n; ++i) {
        cin >> a[i][1] >> a[i][0];
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = 0; j <= w; ++j) {
            if(a[i - 1][1] <= j) {
                dp[i][j] = max(dp[i][j] , dp[i - 1][j - a[i - 1][1]] + a[i - 1][0]);
            }
            dp[i][j] = max(dp[i][j] , dp[i - 1][j]);
        }
    }
    cout << dp[n][w] << '\n';
}


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

#define int long long

#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##_len=(b); i<i##_len; i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(box) box.begin(), box.end()

using namespace std;

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

const long long INF = LLONG_MAX/3;

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

struct UnionFind{
	std::vector<int> par,siz;
	void init(int n){
		par.resize(n);
		for(int i=0;i<n;i++)par[i]=i;
		siz.resize(n,1);
	}
	UnionFind(int n){
		init(n);
	}
	int root(int n){
		if(par[n]==n)return n;
		else return par[n]=root(par[n]);
	}
	bool issame(int x,int y){
		return (root(x)==root(y));
	}
	bool marge(int a,int b){
		if(issame(a,b))return false;
		else{
			a=root(a),b=root(b);
			if(siz[a]<siz[b])swap(a,b);
			siz[a]+=siz[b];
			par[a]=par[b];
			return true;
		}
	}
	int size(int n){
		return siz[root(n)];
	}
};

long long gcd(long long a,long long b){
    if(b==0)return a;
    return gcd(b,a%b);
}
long long lcm(long long i,long long j){
    return i*(j/gcd(i,j));
}

const int MOD=1e9+7;
long long fac[510000], finv[510000], inv[510000];
long long MAX=510000;
bool COMinited=false;
long long COM(int n, int k){
	if(COMinited==false){
		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;
    	}
		COMinited=true;
	}
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

signed main(){
	int n,d,a;
	cin>>n>>d>>a;
	P xh[200010];
	rep(i,n)cin>>xh[i].first>>xh[i].second;
	sort(xh,xh+n);
	int cnt[200010]={};
	int x[200010];
	rep(i,n)x[i]=xh[i].first;
	int h[200010];
	rep(i,n)h[i]=xh[i].second;
	int ans=0;
	int sum=0;
	rep(i,n){
		sum+=cnt[i];
		if(h[i]-a*sum<=0)continue;
		int b=(h[i]-a*sum+a-1)/a;
		int c=upper_bound(x,x+n,x[i]+d*2)-x;
		if(c<n)cnt[c]-=b;
		sum+=b;
		ans+=b;
	}
	cout<<ans<<endl;
}



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

using namespace std;

const int md = 998244353;

inline void add(int &a, int b) {
  a += b;
  if (a >= md) {
    a -= md;
  }
}

inline int mul(int a, int b) {
  return (long long) a * b % md;
}

inline int power(int a, int b) {
  int res = 1;
  while (b > 0) {
    if (b & 1) {
      res = mul(res, a);
    }
    a = mul(a, a);
    b >>= 1;
  }
  return res;
}

inline int inv(int x) {
  return power(x, md - 2);
}

const int N = 2000010;

int fact[N], inv_fact[N];

inline int C(int n, int k) {
  if (k < 0 || k > n) {
    return 0;
  }
  return mul(fact[n], mul(inv_fact[k], inv_fact[n - k]));
}

int main() {
  int n, m;
  scanf("%d %d", &n, &m);
  fact[0] = inv_fact[0] = 1;
  for (int i = 1; i <= n + m; i++) {
    fact[i] = mul(fact[i - 1], i);
    inv_fact[i] = inv(fact[i]);
  }
  int ans = 0;
  int cur = 0;
  int val = C(n + m, n);
  for (int s = 1; s <= n + m; s++) {
    add(cur, val);
    add(ans, mul(cur, inv(s)));
    int x = C(n + m - (s + 1), n - (s + 1) / 2);
    int y = C(n + m - (s + 1), m - (s + 1) / 2);
    int z = C(s - 1, s / 2);
    int ways = mul(z, x + y);
    if (s % 2 == 0) {
      add(val, ways);
    } else {
      add(val, md - ways);
    }
  }
  ans = mul(ans, inv(C(n + m, n)));
  printf("%d\n", ans);
  cerr << "time = " << clock() << " ms" << endl;
  return 0;
}


Measured memory_bytes: 10496
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back
 
typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;
int G[51][51];
int flag[51];
int a[51],b[51];
int N,M;
void dfs(int v){
	if(flag[v])return;
	flag[v]=1;
	rep(i,N){
		if(G[v][i])dfs(i);
	}
}
int main(){
	cin>>N>>M;
	rep(i,M){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		G[a[i]][b[i]]=1;
		G[b[i]][a[i]]=1;
	}
	int ans=0;
	rep(i,M){
		rep(i,N)flag[i]=0;
		G[a[i]][b[i]]=0;
		G[b[i]][a[i]]=0;
		dfs(0);
		int cnt=0;
		rep(i,N){
			if(flag[i]==0)
				break;
			cnt++;
		}
		if(cnt!=N)ans++;
		G[a[i]][b[i]]=1;
		G[b[i]][a[i]]=1;

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;
int main(){
    string s;
    cin >> s;
    if(s[s.size() - 1] == 's'){
        s.push_back('e');
        s.push_back('s');
    }else{
        s.push_back('s');
    }
    println(s);
    return 0;
}

Measured memory_bytes: 3624
N = int(input())
x = [list(map(int, input().split())) for i in range(N)]  # x11 x12
x.sort(key=lambda x: x[1])
limit = 0
for i in range(N):
    limit += x[i][0]
    if limit > x[i][1]:
        print('No')
        exit()
    else:
        pass
else:
    print('Yes')

Measured memory_bytes: 53600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define REV(x) (reverse(x.begin(),x.end())) //reverse
#define TO(x,t,f) ((x)?(t):(f))
#define CLR(mat) memset(mat, 0, sizeof(mat))
#define FILV(x,a) fill(x.begin(),x.end(),a)
#define FILA(ar,N,a) fill(ar,ar+N,a)
#define NEXTP(x) next_permutation(x.begin(),x.end())
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;else return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
#define pb push_back
#define pri(aa) cout<<(aa)<<endl
const ll INF=1e9+7;
const ll N = 100001;
const ll W = 1;
const ll S = 0;
int n,ani[N];
string s;

void animal(int a1,int a2){
	ani[0]=a1;ani[1]=a2;
	FOR(i,2,n){
		if(ani[i-1]==W && s[i-1]=='o'){
			if(ani[i-2]==W)ani[i]=S;
			else ani[i]=W;
		}else if(ani[i-1]==W && s[i-1]=='x'){
			if(ani[i-2]==W)ani[i]=W;
			else ani[i]=S;
		}else if(ani[i-1]==S && s[i-1]=='o'){
			if(ani[i-2]==W)ani[i]=W;
			else ani[i]=S;
		}else if(ani[i-1]==S && s[i-1]=='x'){
			if(ani[i-2]==W)ani[i]=S;
			else ani[i]=W;
		}
	}
}
void priani(){
	FOR(i,0,n){
		if(ani[i]==W)cout<<'W';
		else cout<<'S';
	}
	cout<<endl;
}

bool nop(int x){
	int y=x-1;if(y<0)y=n-1;
	int z=x+1;if(z==n)z=0;
	if(s[x]=='o'&&ani[x]==S){
		if(ani[y]==ani[z])return true;
	}
	if(s[x]=='x'&&ani[x]==S){
		if(ani[y]!=ani[z])return true;
	}
	if(s[x]=='o'&&ani[x]==W){
		if(ani[y]!=ani[z])return true;
	}
	if(s[x]=='x'&&ani[x]==W){
		if(ani[y]==ani[z])return true;
	}
	return false;
}


int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>s;
	animal(W,W);
	if(nop(0)&&nop(n-1)){
		priani();
		return 0;
	}
	animal(W,S);
	if(nop(0)&&nop(n-1)){
		priani();
		return 0;
	}
	animal(S,W);
	if(nop(0)&&nop(n-1)){
		priani();
		return 0;
	}
	animal(S,S);
	if(nop(0)&&nop(n-1)){
		priani();
		return 0;
	}
	pri(-1);
	return 0;
}


Measured memory_bytes: 976
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize ("-O3")
// using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
// typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
// template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
// template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
 
using namespace std;

int main()
{
  int N,M;
  cin>>N>>M;
  
  cout<<N*M<<endl;
  
  return 0;
}

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

int main(){
    long N;
    cin>>N;
    long ans;
    rep(i, N){
        long A; cin>>A;
        if(i == 0) ans = A;
        else ans = __gcd(ans, A);
    }

    cout << ans << endl;
}

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

//問題文より、入力されるデータの最大個数
#define MAXCOUNT 100

//ユークリッド距離を求める
double euclidean_distance(double x[MAXCOUNT], double y[MAXCOUNT], int n, double p);
//ヘェビシェフ距離を求める
double chebyshev_distance(double x[MAXCOUNT], double y[MAXCOUNT], int n);

int main(void)
{
	int i, j, n;
	double x[MAXCOUNT], y[MAXCOUNT];

	//データの個数を入力
	scanf("%d", &n);

	//ベクトルxを入力
	for(i = 0; i < n; i++){
		scanf("%lf", &x[i]);
	}
	//ベクトルyを入力
	for(i = 0; i < n; i++){
		scanf("%lf", &y[i]);
	}

	//p=1、p=2、p=3の結果を出力
	for(i = 1; i <= 3; i++){
		printf("%lf\n", euclidean_distance(x, y, n, (double)i));
	}
	//p=infinityの結果を出力
	printf("%lf\n", chebyshev_distance(x, y, n));

	return 0;
}

//距離 = (Σ[i = 0 → n] abs(x[i] - y[i])^p)^1/p
double euclidean_distance(double x[MAXCOUNT], double y[MAXCOUNT], int n, double p)
{
	int i;
	double ans;

	ans = 0;

	//データの数だけ繰り返す
	for(i = 0; i < n; i++){
		//fabsでdouble型の絶対値を求める
		ans += pow(fabs(x[i] - y[i]), p);
	}

	ans = pow(ans, (1 / p));

	return ans;
}

//距離 = max(Σ[i = 0 → n] abs(x[i] - y[i]))
double chebyshev_distance(double x[MAXCOUNT], double y[MAXCOUNT], int n)
{
	int i;
	double ans;

	ans = 0;

	for(i = 0; i < n; i++){
		//ansに最大値を格納する
		if(ans < fabs(x[i] - y[i])){
			ans = fabs(x[i] - y[i]);
		}
	}

	return ans;
}


Measured memory_bytes: 2112
H, W = map(int, input().split())

a = []
for i in range(H):
    tmp = input()
    if tmp != '.'*len(tmp):
        a.append(tmp)

b = ['' for i in range(len(a))]
for i in range(W):
    check = 0
    for j in range(len(a)):
        if a[j][i] == '#':
            check = 1
            break
    
    if check == 1:
        for j in range(len(a)):
            print()
            b[j] += a[j][i]


for i in range(len(b)):
    print(b[i])

Measured memory_bytes: 40048
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
const long double PI=(acos(-1));
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int k,s;
  cin>>k>>s;
  int ans=0;
  int vec[k];
  for(int i=0;i<k;i++){
    vec[i]=i+1;
  }
  
  for(int i=0;i<=k;i++){
    for(int j=0;j<=k;j++){
      int a=s-i-j;
      if(a>=0&&a<=k){
        ans++;
      }
    }
  }

  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define N 100005
#define MOD 1000000007
int n,m,ans,a[N],b[N],fc[N],invF[N];
bool cmp(int x,int y) {return a[x]==a[y]?x<y:a[x]<a[y];}
int inv(int x) {return x==1?1:1ll*inv(MOD%x)*(MOD-MOD/x)%MOD;}
int C(int x,int y) {return x<y?0:1ll*fc[x]*invF[y]%MOD*invF[x-y]%MOD;} 
int main()
{
	fc[0]=invF[0]=1;scanf("%d %d",&n,&m);
	for(int i=1;i<=n;++i) b[i]=i,scanf("%d",&a[i]);sort(b+1,b+n+1,cmp);
	for(int i=1;i<=n;++i) fc[i]=1ll*fc[i-1]*i%MOD;invF[n]=inv(fc[n]);
	for(int i=n-1;i>=1;--i) invF[i]=1ll*invF[i+1]*(i+1)%MOD;
	for(int i=1;i<=n;++i) ans=(ans+(1ll*(C(i-1,m-1)-C(n-i,m-1))*a[b[i]]%MOD))%MOD;
	printf("%d\n",ans);return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    long long r,D,x;
    cin >> r >> D >> x;

    for(int i=0; i<10; i++){
        x=r*x-D;
        cout << x << endl;
    }
}

Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N; cin>>N;
    vector<ll> D(N+1,0);
    vector<ll> d(N);
    for (ll i = 0; i < N; ++i) {
        d[i]; cin>>d[i];
        D[d[i]]++;
    }

    if(D[0]!=1||d[0]!=0){
        cout<<0<<endl;
        return 0;
    }

    ll ans = 1LL;
    for (ll i = 1; i < N; ++i) {
        for (int j = 0; j < D[i]; ++j) {
            ans *= D[i-1];
            ans %= 998244353;
        }
    }

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


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int h, w, n, a;
    vector<int> b;
    cin >> h >> w >> n;
    fr1(n) {
        cin >> a;
        for (int j = 0; j < a; j++) b.push_back(i);
    }
    fr(h) {
        if (i & 1) for (int j = (i + 1) * w - 1; j >= i * w; j--) cout << b[j] << ' ';
        else for (int j = i * w; j < (i + 1) * w; j++) cout << b[j] << ' ';
        cout << '\n';
    }
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] lines = line.split(" ", 0);
        int d = Integer.parseInt(lines[0]);
        int t = Integer.parseInt(lines[1]);
        int s = Integer.parseInt(lines[2]);

        if (t * s < d) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }

    }
}

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


int main() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i=0; i<n; i++){
  cin >> v.at(i);
  }
  for (int i=0; i<n; i++){
    if (v.at(i) % 2 == 0){
      if (v.at(i) % 3 != 0 && v.at(i) % 5 != 0) {cout << "DENIED"; exit(0);}
    }
  }
  cout << "APPROVED";
  }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rrep(i,n) for (int i = 1; i <= (n); i++)
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;


int main() {
  int N;
  cin >> N;
  std::vector<int> x(N), y(N), h(N);
  rep(i,N) cin >> x[i] >> y[i] >> h[i];

  // [0,100]に座標があるのでMAXを定義する
  int MAX = 101;
  rep(posY,MAX) rep(posX,MAX) {
    //頂上はどれくらいの高さであって欲しいか
    //-1はまだよくわからない時。0以上は確定している時
    //-2はダメだってわかった時
    int needH = -1;
    rep(i,N) {
      if (h[i] > 0) {
        // この頂点からみて、頂上がposY,posXの時に、
        // どれくらいの高さがあって欲しいかを求める
        int tmp = h[i] + abs(posY-y[i]) + abs(posX - x[i]);
        if (needH == -1) {
          needH = tmp;
        } else {
          if (needH != tmp) {
            needH = -2;
            break;
          }
        }
      }
    }
    // ダメだったら別の場所を探す
    if (needH == -2) continue;
    rep(i,N) {
      // 高さが0の場合に矛盾していないか調べる
      if (h[i] == 0) {
        int dist = abs(posY-y[i]) + abs(posX - x[i]);
        // needHの方が大きい場合h[i]は負になってしまう
        if (needH > dist) {
          needH = -2;
          break;
        }
      }
    }
    if (needH == -2) continue;
    cout << posX << " " << posY << " " << needH << endl;
    return 0;
  }
}


Measured memory_bytes: 3644
def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a
  

n = int(input())
np = set(prime_factorize(n))
npl = []
for i in np:
    j = 1
    j *= i
    while j <= n:
        npl.append(j)
        j *= i
npl.sort()

cz = 2
ans = 0
for cz in npl:
    # print(n, cz)
    if cz > n:
        break
    if n % cz == 0:
        ans += 1
        n //= cz
print(ans)

Measured memory_bytes: 62736
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c && a == c) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
mi :: Int
mi = -200

ma :: Int
ma = 200

main = do
  x <-read <$> getLine 
  let (a,b) = solve x
  print a
  print b


ok ::Int -> (Int,Int) -> Bool
ok x (a,b) = a*a*a*a*a-b*b*b*b*b == x

solve :: Int -> (Int,Int)
solve = solve' mi mi

solve' :: Int -> Int -> Int -> (Int,Int)
solve' n m x
  | ok x (n,m) = (n,m)
  | n == ma   = solve' mi (m+1) x
  | m == ma   = (0,0)
  | otherwise  = solve' (n+1) m x

Measured memory_bytes: 3896
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<set>
#include<iomanip>
#define sqr(x)(x)*(x)
#define fz1(i,n) for (i=1;i<=n;i++)
#define fd1(i,n) for (i=n;i>=1;i--)
#define fz0g(i,n) for (i=0;i<=n;i++)
#define fd0g(i,n) for (i=n;i>=0;i--)
#define fz0k(i,n) for (i=0;i<n;i++)
#define fd0k(i,n) for (i=(long long)(n-1);i>=0;i--)
#define fz(i,x,y) for (i=x;i<=y;i++)
#define fd(i,y,x) for (i=y;i>=x;i--)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){char ss[len];scanf("%s",ss);(st)=ss;}
using namespace std;
//struct bit{T_ arr[1000005];int lowbit(int x){return x&(-x);}void add(int x,T_ y){for (int i=x;i<=n;i+=lowbit(i)) arr[i]+=y;}T_ query(int x){T_ s=0;for (int i=x;i>0;i-=lowbit(i)) s+=arr[i];return s;}};
//struct seg{struct treedot{int l,r;T_ sum,add;void update(T_ x){sum+=(r-l+1)*x; add+=x;}}c[800005];void pushdown(int id){if (c[id].add){c[id*2].update(c[id].add);c[id*2+1].update(c[id].add);c[id].add=0;}}void pushup(int id){c[id].sum=c[id*2].sum+c[id*2+1].sum;}void build(int id,int l,int r){if (l>r) return;c[id].l=l;c[id].r=r;c[id].sum=0;c[id].add=0;if (l==r) c[id].sum=0;else{int mid=l+(r-l)/2;build(id*2,l,mid);build(id*2+1,mid+1,r);pushup(id);}}void update(int id,int le,int ri,T_ x){if (le>c[id].r||ri<c[id].l) return;if (le<=c[id].l&&c[id].r<=ri) c[id].update(x);else{pushdown(id);update(id*2,le,ri,x);update(id*2+1,le,ri,x);pushup(id);}}T_ query(int id,int le,int ri){if (ri<c[id].l||c[id].r<le) return 0;if (le<=c[id].l&&c[id].r<=ri) return c[id].sum;T_ ans=0;pushdown(id);ans+=query(id*2,le,ri);ans+=query(id*2+1,le,ri);pushup(id);return ans;}};
int n,m,i,j,a[2005],vis[2005];
vector<int> bi[2005],bi2[2005];
set<int> s;
void dfs(int x)
{
	if (vis[x]) return;
	vis[x]=1;
	ff(bi[x],it)
	{
		if (!vis[*it])
		{
			bi2[x].push_back(*it);
			dfs(*it);
		}
	}
}
int main()
{
	scanf("%d",&n);
	fz1(i,n) scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	fz1(i,n) fz1(j,n)
	{
		if (__gcd(a[i],a[j])!=1) bi[i].push_back(j);
	}
	fz1(i,n) if (!vis[i]) {dfs(i);s.insert(-i);}
	while (!s.empty())
	{
		int x=*s.begin();s.erase(s.begin());
		ff(bi2[-x],it) s.insert(-*it);
		cout<<a[-x]<<' ';
	}
	return 0;
}

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

int main(){
   int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=n-1;i>=0;i--){
        if(i==0){
            cout<<a[i]<<endl;
        }else{
            cout<<a[i]<<" ";
        }
    }
    return(0);
}

Measured memory_bytes: 3080
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024*1024), bufio.MaxScanTokenSize)
}

//func nextString() string {
//	sc.Scan()
//	return sc.Text()
//}

//func nextInt() int {
//	sc.Scan()
//	i, e := strconv.Atoi(sc.Text())
//	if e != nil {
//		panic(e)
//	}
//	return i
//}

func nextInt64() int64 {
	sc.Scan()
	i, e := strconv.ParseInt(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func nextUint64() uint64 {
	sc.Scan()
	i, e := strconv.ParseUint(sc.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

func abs(i int64) int64 {
	if i < 0 {
		return -i
	}
	return i
}

func main() {
	x := nextInt64()
	k := nextInt64()
	d := nextInt64()

	numNeedToMoveToOffset := abs(x / d)
	offset := x % d

	if numNeedToMoveToOffset >= k {
		fmt.Println(abs(x) - d * k)
		return
	}

	remainingMove := k - numNeedToMoveToOffset
	if remainingMove % 2 == 1 {
		fmt.Println(d - abs(offset))
	} else {
		fmt.Println(abs(offset))
	}
	return
}


Measured memory_bytes: 1808
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    vector<ll> sum(N + 1);
    ll s = 0;
    rep(i, N) {
        sum[i + 1] = sum[i] + A[i];
        s += A[i];
    }
    ll res = LINF;
    for(int i = 1; i < N; i++) {
        res = min(abs((s - sum[i]) - sum[i]), res);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3328
import math
n,m,v,p=map(int,input().split())
lists=list(map(int,input().split()))
lists=sorted(lists)
def is_ok(N,m,v,p):
    counter=0
    howadd=0
    not_avoid=0
    judge=lists[N]+m
    for k in range(n-1,-1,-1):
        if k!=N:
            if judge<lists[k]:
                counter+=m
                howadd+=1
                not_avoid+=1
            elif judge==lists[k] and howadd<p-1:
                counter+=m
                howadd+=1
            elif judge==lists[k] and howadd==p-1:
                pass
            elif judge>lists[k] and howadd<p-1:
                howadd+=1
                counter+=m
            elif judge>lists[k] and howadd==p-1:
                counter+=min(judge-lists[k],m)    
    if not_avoid>=p:
            return False
    elif not_avoid<p:
        if counter<(m)*(v-1):
            return False
        elif counter>=(m)*(v-1):
            return True
start=0
end=n-1
for _ in range(17):
    c=(start+end)/2
    if is_ok(math.floor(c),m,v,p):
        end=c
    elif not (is_ok(math.floor(c),m,v,p)):
        start=c       
print(n-math.floor(end))

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

int main() {
  int AB, BC, CA;
  scanf("%d %d %d", &AB, &BC, &CA);

  if (AB > BC && AB > CA) printf("%d\n", BC * CA / 2);
  else if (BC > AB && BC > CA) printf("%d\n", AB * CA / 2);
  else printf("%d\n", AB * BC / 2); 
  
  return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto K = RD;
	auto S = RD;
	long ans;
	foreach (i; 0..K+1)
	{
		foreach (j; 0..K+1)
		{
			auto x = S - cast(long)(i+j);
			if (x < 0) break;
			if (x <= K)
				++ans;
		}
	}
	writeln(ans);
	stdout.flush();
	debug readln();
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
int N;
cin>>N;
vector<int> d;
int tmp;
for(int i=0;i<N;++i){
  cin>>tmp;
  d.push_back(tmp);
}
std::sort(d.begin(), d.end() );
int num=N/2;
cout<<d[num]-d[num-1]<<"\n";

return 0;
}


Measured memory_bytes: 892
#include <iostream>
#include <vector>
using namespace std;
const int MOD = 1000000007;

long long mod(long long a) {
	a %= MOD;
	return a >= 0 ? a : a+MOD;
}

long long pow_mod(long long a, long long n) {
	long long res = 1;
	while (n > 0) {
		if (n & 1) res = (res * a) % MOD;
		n >>= 1;
		a = (a * a) % MOD;
	}
	return res;
}

int main() {
	long long n;
	cin >> n;
	long long ans = mod(pow_mod(10,n) + pow_mod(8, n) - 2 * pow_mod(9, n) % MOD);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3116
#B - Substring 
S = str(input())
T = str(input())
i = 0
j = 0

Slen = len(S)
Tlen = len(T)
change_min = Tlen

for i in range(Slen - Tlen + 1):
    diff = 0
    for j in range(Tlen):
        if T[j] != S[i + j]:
            diff += 1
    change_min = min(change_min,diff)

# 出力
print(change_min)


Measured memory_bytes: 8916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main() {
    ll n, p;
    cin >> n >> p;

    if(n>40){
        cout << 1 << endl;
        return 0;
    }
    vector<ll> a;
    for(int i = 1; i <= (ll)sqrt(p); i++){
        if(p%i == 0){
            a.push_back(i);
            a.push_back(p/i);
        }
    }

    sort(a.begin(),a.end());
    reverse(a.begin(),a.end());

    for(int i = 0; i < a.size(); i++){
        ll tmp = p;
        bool isOK = true;
        for(int j = 0; j < n; j++){
            if(tmp%a[i] == 0){
                tmp /= a[i];
            }else{
                isOK = false;
                break;
            }
        }
        if(isOK){
            cout << a[i] << endl;
            return 0;
        }
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	string s;
	cin>>s;
	ll ans = 0;
	for(ll i=0;i<n-2;i++)
	{
		if (s[i]=='A' and s[i+1]=='B' and s[i+2]=='C')
			ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

ll mpow(ll a, ll b) {
	ll res = 1;
	a %= mod;
	while (b) {
		if (b & 1) res = res * a % mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
}


int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n; cin >> n;
	string s; cin >> s;
	vector<int> dp(n+1,0);
	dp[0] = 1;
	rep(rot, 0, n) {
		vector<int> nxt(n + 1);
		rep(i, 0, n + 1) {
			if (dp[i] > 0) {
				if (i > 0) nxt[i - 1] = (nxt[i - 1] + dp[i]) % mod;
				else nxt[0] = (nxt[0] + dp[0]) % mod;
				if (i < n)nxt[i + 1] = (nxt[i + 1] + dp[i])*2LL % mod;
			}
		}
		swap(dp, nxt);
	}
	printf("%d", (1LL*mpow(mpow(2,s.size()),mod-2)*dp[s.size()])%mod);
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int n,a[500000],kepo=1,ans;
int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        if(a[i]!=a[i+1]){ans+=kepo/2;kepo=0;}

        kepo++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
// 2015/08/05 Tazoe

#include <iostream>
#include <string>
#include <sstream>
using namespace std;

bool is_leap(int y)
{
	return (y%400==0 || (y%4==0 && y%100!=0));
}

int main()
{
	while(true){
		string S;
		cin >> S;

		if(S=="#")
			break;

		int cnt = 0;

		while(true){
			int loc = S.find(".");

			if(loc==string::npos)
				break;

			S.replace(loc, 1, " ");
			cnt++;
		}

		if(cnt==4){
			istringstream is(S);
			int b, ka, t, w, ki;
			is >> b >> ka >> t >> w >> ki;

			int KI = (((b*20+ka)*20+t)*18+w)*20+ki;

			int y = 2012;
			int m = 12;
			int d = 21;

			if(KI<11){
				d += KI;
				KI = 0;
			}
			else{
				y = 2013;
				m = 1;
				d = 1;
				KI -= 11;
			}

			while(true){
				if(is_leap(y) && KI>=366){
					y++;
					KI -= 366;
				}
				else if(!is_leap(y) && KI>=365){
					y++;
					KI -= 365;
				}
				else{
					break;
				}
			}

			while(true){
				if((m==1 || m==3 || m==5 || m==7 || m==8 || m==10) && KI>=31){
					m++;
					KI -= 31;
				}
				else if((m==4 || m==6 || m==9 || m==11) && KI>=30){
					m++;
					KI -= 30;
				}
				else if(m==2 && is_leap(y) && KI>=29){
					m++;
					KI -= 29;
				}
				else if(m==2 && !is_leap(y) && KI>=28){
					m++;
					KI -= 28;
				}
				else{
					break;
				}
			}

			if(KI>0){
				d += KI;
				KI = 0;
			}

			cout << y << '.' << m << '.' << d << endl;
		}
		else if(cnt==2){
			istringstream is(S);
			int y, m, d;
			is >> y >> m >> d;

			long long D = 0;

			if(y==2012&&m==12){
				D = d-21;
			}
			else{
				D = 11;

				for(int i=2013; i<y; i++){
					if(is_leap(i)){
						D += 366;
					}
					else{
						D += 365;
					}
				}

				for(int i=1; i<m; i++){
					if(i==1 || i==3 || i==5 || i==7 || i==8 || i==10){
						D += 31;
					}
					else if(i==4 || i==6 || i==9 || i==11){
						D += 30;
					}
					else if(i==2 && is_leap(y)){
						D += 29;
					}
					else if(i==2 && !is_leap(y)){
						D += 28;
					}
					else{
						break;
					}
				}

				D += (d-1);
			}

			int ki = D%20;
			D /= 20;

			int w = D%18;
			D /= 18;

			int t = D%20;
			D /= 20;

			int ka = D%20;
			D /= 20;

			int b = D%13;

			cout << b << '.' << ka << '.' << t << '.' << w << '.' << ki << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
//long long mo = 1e9 + 7;
typedef long long ll;
typedef pair<int,int> P;

int main(){
    int A,B,C;
    cin >> A >> B >> C;
    bool flag = false;
    if(A == B){
        if(B==C){
            flag = false;
        }else{
            flag = true;
        }
    }else if(B == C){
        if(A == B){
            flag = false;
        }else{
            flag = true;
        }
    }else if(C == A){
        if(B == C){
            flag = false;
        }else{
            flag = true;
        }
    }else{
        flag = false;
    }
    cout << (flag? "Yes":"No") <<endl;

}


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


int main(){
	int a, b, c;
	cin >> a >> b >> c;
	if(a>b) swap(a,b);
	if(b>c) swap(b,c);
	if(a>b) swap(a,b);
	
	cout << a << " " << b << " "  << c << endl;
}



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

typedef long long int ll;

priority_queue <ll, vector<ll>, greater<ll> > pq;

int main()
{
	ll i,j,k,l,m,n;

	cin >> k;

	if(k<10)
	{
		cout << k << '\n';
		return 0;
	}
	for(i=1;i<10;i++)
		pq.push(i);

	j = 0;
	while(j<(k-1))
	{
		l = pq.top();
		pq.pop();

		m = l%10;

		// cout << 10*l+m-1 << '\n';

		if(m == 0)
		{
			pq.push(10*l+m);
			pq.push(10*l+m+1);
		}
		else if(m == 9)
		{
			pq.push(10*l+m);
			pq.push(10*l+m-1);

		}
		else
		{
			pq.push(10*l+m);
			pq.push(10*l+m+1);
			pq.push(10*l+m-1);

		}

		j++;

	}

	cout << pq.top() << '\n';
}

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

#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <vector>

using namespace std;

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

    if(n[n.size()-1]=='3'){
        cout << "bon" << endl;
    }else if(n[n.size()-1]=='0' || n[n.size()-1]=='1' || n[n.size()-1]=='6' || n[n.size()-1]=='8'){
        cout << "pon" << endl;
    }else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3624