akhauriyash/Code-Regression huggingface dataset:
//{
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(i,n) memset(i,n,sizeof i)
#define X first
#define Y second
#define SZ(_a) (int)_a.size()
#define ALL(_a) _a.begin(),_a.end()
#define pb push_back
#ifdef brian
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<" ,";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // brian
//}


const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=ll(1e15);

int main()
{
    IOS();
    string s;
    cin>>s;
    ll tt = 0, t = 0;
    reverse(ALL(s));
    for(char c:s)if(c == 'W')t++;else tt += t;
    cout<<tt<<endl;
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
typedef unsigned long long int ull;
typedef long long int ll;

int a[500005];
int main()
{
    ll n,sum=0,k,m;
    int l,r,d;
    cin>>l>>r>>d;
    for(int i=l;i<=r;i++)
    {
        if(i%d==0)
            sum++;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, l, r) for (int i = l; i <= (int)(r); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define all(v) v.begin(), v.end()
#define MOD (int) (1e9+7)
#define INF (int) 1e9
#define LLINF (ll) 2e18

int main(){
    ll a, b, n;
    cin >> a >> b >> n;

    ll ans = 0;
    if(n >= b-1){
        cout << (b-1)*a/b << endl;    
    }else{
        cout << n*a/b << endl;
    }
    // printf("%d\n", N);
    return 0;
}

Measured memory_bytes: 3596
/*Author: Gautam*/


#include<bits/stdc++.h>
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
#define MODULO 1000000007
#define ull unsigned long long int
#define newline cout<<endl


/* TYPE DEFINITIONS */
typedef		long long		ll;
typedef		vector<int>		vi;
typedef		pair<int,int>	pi;



/* ALGEBRA */
bool isPrime(ull n) 
{ 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (ull i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 

/* MACROS */

#define  all(A)			(A).begin() , (A).end()
#define  arrall(A,n)    (A),((A)+(n))
#define  rall(A)		(A).rbegin() , (A).rend()
#define  sz(A)			(int)(A).size()
#define  pb				push_back
#define  ppb			pop_back
#define  mp				make_pair
#define  ln(X)			(int)(X).length()
#define  square(X)		((X)*(X))
#define  cube(X)		((X)*(X)*(X))
#define  forn(i, n)  for (int i = 0; i < int(n); i++)
#define  forr(i, n)  for (int i = int(n - 1); i >= 0; i--)
#define  fora(i, a, b)  for (int i = int(a); i <= int(b); i++)
#define  forb(i, a, b)  for (int i = int(a); i >= int(b); i--)
#define  fore(it, a)	for(__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++) 
bool painted[10005];
int digCount(int n)
{
    int c=0;
    while(n>0)
    {
        n=n/10;
        c++;
    }
    return c;
}
void solve()
{
    ll a,c=0;
    cin>>a;
    for(int i=1;i<=a;i++)
    {
        if(digCount(i)%2!=0)c++;
    }
    cout<<c<<endl;
}

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

Measured memory_bytes: 256
/*
digu_J - Digvijay Janartha
NIT Hamirpur - INDIA
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")

using namespace std;
using namespace __gnu_pbds;

template < typename T > using ordered_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifdef HOME
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std :: endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
    const char* comma = strchr(names + 1, ',');
    int len = comma - names;
    for (int i = 0; i < len; ++i) {
        cout << names[i];
    }
    cout <<  " : " << arg1 << " | ";
    __f(comma + 1, args...);
}
#else
#define trace(...)
#endif

typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair < ll, ll > pll;
typedef pair < int, int > pii;
typedef vector < ll > vll;
typedef vector < int > vi;
typedef complex < double > com;

#define eb emplace_back
#define pb push_back
#define F first
#define S second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) (sort(x.begin(), x.end()), x.resize(distance(x.begin(), unique(x.begin(), x.end()))))
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)

const ll LINF = LLONG_MAX, base = 1e9, MOD = 1e9 + 7, N = 1e5 + 5, M = 1e3 + 5, LG = 20;
const int INF = INT_MAX;
const db PI = acos(-1), EPS = 1 / db(1e6);
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());

void test() {
    ll n, m;
    cin >> n >> m;
    ll a[n];
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    ll lcm = a[0], g = a[0];
    for (int i = 1; i < n; ++i) {
        ll gg = __gcd(a[i], lcm);
        g = __gcd(a[i], g);
        lcm *= a[i];
        lcm /= gg;
        if (lcm > 2 * m) {
            cout << "0\n";
            return;
        }
    }
    int ev = 0, od = 0;
    for (int i = 0; i < n; ++i) {
        a[i] /= g;
        if (a[i] & 1) {
            ++od;
        } else {
            ++ev;
        }
    }
    if (od and ev) {
        cout << "0\n";
        return;
    }
    m -= lcm / 2;
    if (m < 0) {
        cout << "0\n";
        return;
    }
    cout << m / lcm + 1 << "\n";
}

int main() {
    fast_io();
    #ifdef HOME
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
    cout << fixed << setprecision(15);
    test();
    #ifdef HOME
        cout << "Time: " << (int)(clock() * 1000. / CLOCKS_PER_SEC) << "ms";
    #endif
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long n, k;
    cin >> n >> k;
    vector<int> h(n);
    for(int i = 0; i < n; i++) cin >> h[i];
    sort(h.begin(), h.end());
    long long ans = 0;
    for(int i = 0; i < n-k; i++){
        ans += h[i];
    }
    cout << ans;
    
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define N 1005
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int X,Y,k;
const int dx[]={-1,0,1,0};
const int dy[]={0,1,0,-1};
bool In(int x,int y)
{
	return x>=0 and x<X and y>=0 and y<Y;
}
char s[N][N];
int sx,sy;
int dist[N][N];
int rev_dis[N][N];
struct Node
{
	int x,y,dis;
	Node(){}
	Node(int a,int b,int c)
	{
		x=a;
		y=b;
		dis=c;
	}
};
void Init()
{
	scanf("%d%d%d",&X,&Y,&k);
	for(int i=0;i<X;i++)
	{
		scanf("%s",s[i]);
	}
	for(int i=0;i<X;i++)
	{
		for(int j=0;j<Y;j++)
		{
			if(s[i][j]=='S')
			{
				sx=i;
				sy=j;
				s[i][j]='.';
			}
		}
	}
}
queue <Node> q;
void Solve()
{
	memset(dist,0x3f,sizeof(dist));
	q.push(Node(sx,sy,0));
	while(not q.empty())
	{
		Node t=q.front();
		q.pop();
		if(dist[t.x][t.y]>t.dis)
		{
			dist[t.x][t.y]=t.dis;
			for(int i=0;i<4;i++)
			{
				int xx=t.x+dx[i];
				int yy=t.y+dy[i];
				if(not In(xx,yy))continue;
				if(s[xx][yy]=='#')continue;
				q.push(Node(xx,yy,t.dis+1));
			}
		}
	}
	while(not q.empty())q.pop();
	int res=INF;
	for(int i=0;i<X;i++)
	{
		for(int j=0;j<Y;j++)
		{
			if(dist[i][j]<=k)
			{
				res=min(res,(min(min(i,X-i-1),min(j,Y-j-1))+k-1)/k+1);
			}
		}
	}
	printf("%d\n",res);
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    Init();
    Solve();
	return 0;
}


Measured memory_bytes: 7040
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,avx,avx2")

#include <vector>
#include <stdio.h>
#include <iostream>
#include <unordered_set>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <random>
#include <time.h>
#include <cassert>

#define prev askdnsajd
#define rank asasdmdnasd
#define next lsjndajbs
#define hash asmdklansd
#define index asdklnas
#define right sld
#define left sldl
using namespace std;

typedef long long ll;
typedef long double dbl;

template<class T>
void print(vector<T> s){
    for (T x : s)
        cout << x << " ";
    cout << endl;
}

const int maxn = 10;

bool check[1000000];
int s[maxn][maxn];

int main(){
    srand(17);
    ios_base::sync_with_stdio(0);
    ll l, r;
    cin >> l >> r;
    int x = 2019;
    ll mini = x;
    for (ll i = l; i < min(l + x, r + 1); i++){
    	for (ll j = i + 1; j < min(l + x, r + 1); j++){
    		mini = min(mini, i * j % x);
    	}
    }
    cout << mini << endl;
    return 0;
}


Measured memory_bytes: 256
//インクルード
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <boost/multiprecision/cpp_int.hpp>

//型宣言
typedef long long ll;
typedef unsigned long long ull;
typedef std::string string;
typedef boost::multiprecision::cpp_int answerType;

//変数宣言
ll N;
ll M;
std::vector<string> Ai;
std::vector<string> Bi;
answerType answer;

//関数のプロトタイプ宣言
//入力の取得
void getInput();
//答えを求める
answerType calcAnswer();

//メイン関数
int main() {
	//入力の取得
	getInput();

	//答え
	answerType answer = calcAnswer();

	//答えの出力
	std::cout << answer << std::endl;

	//正常終了
	return EXIT_SUCCESS;
}

//入力の取得
void getInput() {
	std::cin >> N;
}

//答えを求める
answerType calcAnswer() {
	boost::multiprecision::cpp_int temp = 1;
	for(ull i=1; i<=N; ++i) {
		temp *= i;
	}
	return temp % 1000000007;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char[] c = s.toCharArray();
		ArrayList<Character> al = new ArrayList<Character>();

		for (int i = 0; i < c.length; i++) {
			if (c[i] == '0') {
				al.add('0');
			} else if (c[i] == '1') {
				al.add('1');
			} else if (c[i] == 'B' && al.size() != 0) {
				al.remove(al.size() - 1);
			}
		}

		for (int i = 0; i < al.size(); i++) {

			System.out.print(al.get(i));
		}
	}
}

Measured memory_bytes: 21716
n = int(input())
a = list(map(int,input().split()))

right = 0
sum = 0
ans = 0

for left in range(n):
    while right < n and sum^a[right] == sum+a[right]:
        sum += a[right]
        right += 1
    ans += right-left
    if right == left:
        right += 1
    else:
        sum -= a[left]

print(ans)


Measured memory_bytes: 32208
// oh, the less I know the better
// corner cases // int vs ll // cin vs scanf // clear structures // statement // doublesz
#include <bits/stdc++.h>
#define endl '\n'
#define fst first
#define snd second
#define pb push_back
#define sz(x) int(x.size())
#define REP(i,n) for(int i = 0; i < int(n); ++i)
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

int main(){

	fastio;
	int n,k;
	cin >> n >> k;
	vector<int> v1,v2;
	for(int i = 0; i < n; ++i){
		int x;
		cin >> x;
		if(x < 0) v1.pb(-x);
		else v2.pb(x);
	}

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

	int ans = 1e9;
	for(int i = 0; i <= sz(v1); ++i){
		int j = k - i;
		if(j-1 >= sz(v2)) continue;
		int d1 = 0, d2 = 0;
		if(i-1 >= 0) d1 = v1[i-1];
		if(j-1 >= 0) d2 = v2[j-1];
		ans = min(ans, d1 + d2 + min(d1,d2));
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3996
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] ary = new String[sc.nextInt()];
		sc.next();
		for(int i=0;i < ary.length;i++) {
			ary[i] = sc.next();
		}
		Arrays.parallelSort(ary);
		for (String string : ary) {
			System.out.print(string);
		}
		System.out.println();
	}
}

Measured memory_bytes: 22740
using System;

class Program
{
    static void Main()
    {
        String[] arr = Console.ReadLine().Split();
        long N = long.Parse(arr[0]);
        long A = long.Parse(arr[1]);
        long B = long.Parse(arr[2]);
        long dv, rm;
        dv = N / (A + B);
        rm = N % (A + B);
        Console.WriteLine(A * dv + Math.Min(A, rm));
    }
}

Measured memory_bytes: 13268
#include <stdio.h>

long long int gcd(long long int x, long long int y)
{
  while(x > 0 && y > 0) {
    if(x > y) {
      x = x - y;
    }
    else {
      y = y - x;
    }
  }

  if(x == 0) {
    return y;
  }
  else {
    return x;
  }
}

long long int approximate_sqrt(long long int x)
{
  long long int root = x/4;

  if(x <= 3) {
    return 1;
  }
  
  while(1) {
    root = (root + (x / root)) / 2;

    if(root * root <= x && x <= (root+1) * (root+1)) {
      return root;
    }
  }
}

int number_of_factors(long long int x)
{
  long long int root_x = approximate_sqrt(x);
  long long int x_iter = x;
  int num = 0;

  if(x == 1) {
    return 0;
  }

  if(x_iter % 2 == 0) {
    num++;
  }
  while(x_iter % 2 == 0) {
    x_iter = x_iter / 2;
  }

  long long int i = 3;
  while(i <= root_x + 1) {

    if(x_iter % i == 0) {
      num++;

      do {
        x_iter = x_iter / i;
      } while(x_iter % i == 0);
    }

    i += 2;
  }

  if(x_iter > 1) {
    num++;
  }

  return num;
}

int main(void)
{
  long long int a, b;
  scanf("%lld%lld", &a, &b);

  printf("%d\n", 1 + number_of_factors(gcd(a,b)));
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
using namespace std;
using Int = int64_t;
Int solve() {
    Int N, M;
    cin >> N >> M;
    if (N == 1) return M == 1 ? 1 : max((Int)0, M - 2);
    if (M == 1) return max((Int)0, N - 2);
    return (N - 2) * (M - 2);
}
int main() {
    cout << solve() << endl;
}

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

int main() {
    int cnt;
    string name;
    cin >> cnt >> name;

    if(name.size() > cnt) {
        cout << name.substr(0, cnt) << "..." << endl;
    } else {
        cout << name << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

#define FAST ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mp make_pair
#define pb push_back
#define lp(i,s,f) for(ll i = s; i < ll(f); i++)
#define inF freopen("input.in", "r", stdin);
#define outF freopen("output.in", "w", stdout);
#define endl '\n'
#define MOD 1000000007
#define mm(arr) memset(arr, 0, sizeof(arr))
#define int ll

int32_t main(){
    FAST
    int n; cin >> n;
    int arr[n];
    int sum = 0;
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        sum += arr[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++){
        sum -= arr[i];
        int num = (arr[i] * (sum%MOD))%MOD;
        ans = (ans%MOD + num%MOD)%MOD;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5204
n, m = map(int, input().split())
a = [int(input()) for _ in range(m)]

dp = [0] * (n + 10)
dp[0] = 1
mod = 10**9 + 7

ok = [1] * (n + 10)
for i in a:
    ok[i] = 0

if ok[1]:
    dp[1] = 1

for i in range(2, n + 1):
    if ok[i]:
        dp[i] += dp[i - 1]
        dp[i] += dp[i - 2]
        dp[i] %= mod
print(dp[n])


Measured memory_bytes: 8592
#pragma GCC optimize("O2")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,sse,sse2,fma,tune=native")
#include<bits/stdc++.h>
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define pb push_back
#include <x86intrin.h>
#define pb push_back
using namespace std;
using ll = long long;
using pi = pair<int, int>;
using vi = vector<ll>;
using vpi = vector<pi>;
using ld = long double;
const int maxn = 1e5 + 55, mod = 1e9 + 7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define prev asdjfasj
vpi ranges;
int n, k, m;
void gen_ranges() {
	int c = 1;
	while(c <= n) {
		int v = n/c;
		ranges.pb({c, n/v});
		c = n/v + 1;
	}
}
int mul(int i, int j) {
	return i*1ll*j%mod;
}
vi prev, ps, cur;
void process() {
	prev = cur;
	for(int i = 0; i < m; i++) {
		ps[i] = mul(ranges[i].second-ranges[i].first+1, prev[i]);
		if(i) ps[i] = (ps[i-1] + ps[i])%mod;
	}
	cur = vi(m);
}

int get(int p, int a) {
	int ans = 0;
	if(p) ans += ps[p-1];
	ans += mul(a-ranges[p].first+1, prev[p]);
	return ans%mod;
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> k;
	gen_ranges();
	m = ranges.size();
	prev = ps = cur = vi(m, 1);
	vi dp(m);
	for(int i = 0; i < m; i++) dp[i] = upper_bound(all(ranges), pi{n/ranges[i].first, n/ranges[i].first})- ranges.begin() - 1;
	for(int z = 2; z <= k; z++) {
		process();
		for(int i = 0; i < m; i++) {
			cur[i] = get(dp[i], n/ranges[i].first);
		}
	}
	int ans = 0;
	for(int i = 0; i < m; i++) ans = (ans+mul(cur[i], ranges[i].second-ranges[i].first+1))%mod;
	cout << ans;
}


Measured memory_bytes: 3320
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  ll a,v,b,w,t;
  cin >> a >> v >> b >> w >> t;

  if (a == b) {
    cout << "YES" << endl;
    return 0;
  }

  if (w >= v) {
    cout << "NO" << endl;
    return 0;
  }

  ll p = abs(a - b);
  ll pp = abs(v-w);
  ll m = p % pp;
  if (m % 2 == 0) {
    int ans = p / pp;

    if (ans <= t) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  } else {
    int ans = p / pp;
    ans += 1;
    if (ans <= t) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }




}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    vector<int> a(3, 0);
    rep(i,s.size()){
        if(s[i] == 'a') ++a[0];
        else if(s[i] == 'b') ++a[1];
        else ++a[2];
    }
    sort(a.begin(), a.end());
    if(a[2] <= (s.size()+2)/3){
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 512
icase=0
if icase==0:
    s=[]
    h,w=map(int,input().split())
    t=[["#"]*w for i in range(h)]
    s.append(["."]*(w+2))
    for i in range(h):
        si=list("."+input()+".")
        s.append(si)
    s.append(["."]*(w+2))
    for i in range(h):
        for j in range(w):
            if s[i+1][j+1]==".":
                scnt=0
                for jj in range(j,j+3):
                    if s[i][jj]=="#":
                        scnt=scnt+1
                    if s[i+2][jj]=="#":
                        scnt=scnt+1
                if s[i+1][j]=="#":
                    scnt=scnt+1
                if s[i+1][j+2]=="#":
                    scnt=scnt+1
                t[i][j]=str(scnt)
    for i in range(h):
        si=""
        for j in range(w):                    
            si=si+t[i][j]
        print(si)
        

Measured memory_bytes: 3188
#include <bits/stdc++.h>
#define REP(i, n) for (decltype(n) i = 0; i < (n); ++i)
using namespace std;
using int64 = long long;

void solve(int N, int M) {
  vector<pair<int, int>> matches;
  int t0 = N / 2 - (N % 2 == 0);
  int h0 = 0;
  int h1 = N - 1;
  int t1 = h1 - (t0 - 1);
  for (;;) {
    matches.emplace_back(h0, t0);
    h0++;
    t0--;
    if (matches.size() == M) break;
    matches.emplace_back(h1, t1);
    h1--;
    t1++;
    if (matches.size() == M) break;
  }
  REP(i, M) {
    cout << (matches[i].first + 1) << ' ' << (matches[i].second + 1) << '\n';
  }
}

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


Measured memory_bytes: 4144
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main()
    {
        var ABC = ReadLine().Split().Select(int.Parse).ToArray();
        Array.Sort(ABC);
        WriteLine(ABC[0]== ABC[1]&&ABC[0] == ABC[2] ? "Yes" : "No");


    }
}


Measured memory_bytes: 13396
#include <iostream>
#include<vector>

using namespace std;

int main() {
    int a, b, c, index = 1;
    cin >> a >> b >> c;
    vector<bool> df(b-1);

    while (true) {
        int amari = a * index % b;
        //cout << amari << ", " << (bool)df[amari] << endl;
        if (amari == c) {
            cout << "YES" << endl;
            return 0;
        } else if (df[amari]) {
            cout << "NO" << endl;
            return 0;
        } else {
            df[amari] = true;
            index++;
        }
    }
}

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

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    int n = s.size();
    bool ans = true;
    rep(i,n){
        char c = s[i];
        if(i < a && (c < '0' || '9' < c)) ans = false;
        else if(i == a && c != '-') ans = false;
        else if(i > a && (c < '0' || '9' < c)) ans = false;
    }

    if(ans) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
'use strict'
function Main(input){
  input=input.trim().split(/\s+/).map(x=>x-0);
  var result=((input[0]-input[2])*(input[1]-input[2])<0);
  var ans=result?'Yes':'No';
  console.log(ans);
}

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


Measured memory_bytes: 7372
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int N, K;
    cin >> N >> K;
    
    int a[100010];
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
    }
    
    int dp[100010];
    for(int n = 0; n < N; ++n) {
        if (n == 0) {
            dp[0] = 0;
            continue;
        } 
        
        int l = min(K, n);
        int min_num = 10000000000;
        for(int j = 1; j <= l; ++j){
            min_num = min(abs(a[n] - a[n - j]) + dp[n - j], min_num);
        }
        
        dp[n] = min_num;
    
    }
    cout << dp[N - 1] << endl;
    return 0;
}


Measured memory_bytes: 1152
'use strict';

var readline = require('readline');

var rl = readline.createInterface({
  input: process.stdin,
  output: process.stdout,
  terminal: false
});

rl.on('line', function(line) {
  var n = Number(line.trim())
  var debt = calculateDebt(n);
  console.log(debt);
});

function calculateDebt(n) {
  var debtInThousands = 100;

  for (var i = 1; i <= n; i++) {
    debtInThousands = Math.ceil(debtInThousands * 1.05);
  }

  return debtInThousands * 1000;
}

Measured memory_bytes: 15848
//#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <climits>
#include <set>
#include <cassert>

using namespace std;

const int SIZE = 1 << 10;
int pointer = SIZE;
char buffer[SIZE];

char Advance() {
    if (pointer == SIZE) {
        fread(buffer, 1, SIZE, stdin);
        pointer = 0;
    }
    return buffer[pointer++];
}

int Read() {
    int answer = 0, sign = 1;
    char ch = Advance();
    while (!isdigit(ch) && ch != '-')
        ch = Advance();
    if (ch == '-') {
        ch = Advance();
        sign = -1;
    }
    while (isdigit(ch)) {
        answer = answer * 10 + ch - '0';
        ch = Advance();
    }
    return answer * sign;
}

int main() {
    //freopen("tema.in", "r", stdin);
    //freopen("tema.out", "w", stdout);
    long long a = 2, b = 1;
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++) {
        long long c = a + b;
        a = b;
        b = c;
    }
    printf("%lld\n", b);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <queue>
#include <array>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <cassert>
#include <utility>
#include <functional>

using namespace std;
using lli = long long int;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (lli i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> T gabs(const T& x) { return max(x, -x); }
#define abs gabs

lli n;
string s[3];
int main() {
  cin >> n >> s[0] >> s[1] >> s[2];
  lli ans = 0;
  for (lli i=0; i<n; ++i) {
    if (s[0][i] != s[1][i] && s[0][i] != s[2][i] && s[1][i] != s[2][i]) ans += 2;
    else if (!(s[0][i] == s[1][i] && s[0][i] == s[2][i])) ans += 1;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e8;
using namespace std;

#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int k;
	cin >> k;

	char tmp = s[k - 1];


	for (int i = 0;i < n;i++)
	{
		if (tmp == s[i])
		{
			continue;
		}
		else
		{
			s[i] = '*';
		}
	}

	cout << s << endl;

}

Measured memory_bytes: 256
/*
    Code written by Talant I.D.
*/
   
#include <bits/stdc++.h>
   
using namespace std;
   
typedef long long ll;
typedef pair <int, int> pii;
typedef tuple <int, int, int> tiii;
   
#define precision(n) fixed << setprecision(n)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define mod (int)1e9+7
#define eps (double)1e-9
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define do_not_disturb ios::sync_with_stdio(0);cin.tie(0);
#define curMod 998244353

int main(){
		//do_not_disturb
		int n;
		string s;
		cin >> n >> s;
		cout << (n < 3200 ? "red" : s) << endl; 
		
    return 0;
} // What is to be written here?


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

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

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

namespace OnlineJudge
{
    class ITP1_2_C
    {
        static void Main(string[] args)
        {
            var str = Console.ReadLine().Split(' ');
            if (str.Length < 3)
                return;
            
            var list = new List<int>();
            list.Add(int.Parse(str[0]));
            list.Add(int.Parse(str[1]));
            list.Add(int.Parse(str[2]));
            var sorted = list.OrderBy(i => i);

            var isFirst = true;
            foreach(var i in sorted)
            {
                if (!isFirst)
                    Console.Write(' ');
                Console.Write(i);
                isFirst = false;
            }
            Console.WriteLine();
        }
    }
}

Measured memory_bytes: 9980
//	C++ (Clang3.8.0)
#include <iostream>
#include <string>
#include <map>
#include <algorithm>

using namespace std;

int main(){
	int n, *p;
	int ans = 1, minNum;
	
	cin >> n;
	
	p = new int[n];
	cin >> p[0];
	minNum = p[0];
	
	for(int i=1; i<n; ++i){
		cin >> p[i];
		if(min(minNum, p[i]) == p[i]){
			ans++;
			minNum = p[i];
		}
	}
	cout << ans;
	
	delete[] p;
	
	return 0;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    ll A,B,C; cin >> A >> B >> C;
    res = min((B/A),C);
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 256
a,b,c,d = map(int, input().split())

isWin = False
while not isWin:
  if a <= 0 or c <= 0:
    if a <= 0 and c > 0:
      print('No')
      exit()
    else:
      print('Yes')
      exit()
  a -= d
  c -= b


Measured memory_bytes: 9116
fn main(){
	loop{
		let v = read_vec::<usize>();
		let (h, w) = (v[0], v[1]);
		if h == 0 && w == 0 { break; }
		
		let row = repeat_string("#", w);
		let mut row2 = String::from("#");
		row2.push_str(&repeat_string(".", w - 2));
		row2.push_str("#");
		
		println!("{}", row);
		for _ in 0..h - 2 {
			println!("{}", row2)
		}
		println!("{}", row);
		println!("");
	}
}

fn repeat_string(s: &str, n: usize) -> String{
	let mut str = String::new();
	for _ in 0..n {
		str.push_str(s);
	}
	str
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


Measured memory_bytes: 5020
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const N = nextInt()
    let s = []
    let p = []
    let i = 0
    let r = {}
    while(hasNext()){
        i++
        let [s, p] = next().split(" ")
        if(!r[s]) r[s] = [[Number(p),i]]
        else r[s].push([Number(p), i])
    }
    let keys = Object.keys(r)
    keys.sort()
    for(let key of keys){
        let arr = r[key].sort((a,b) => b[0]-a[0])
        for(let el of arr) console.log(el[1])
    }
}
Main()


Measured memory_bytes: 30732
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define int long long
#define inf 1000000007
#define LINF 100000000000000007LL
#define ll long long
using namespace std;
int ka[214514],inv[214514];
void setkaijo(int n){
	ka[0]=1;
	for(int i=1;i<=n;i++){
		ka[i] = ka[i-1] * i;
		ka[i] %= inf;
	}
}
int modpow(int x,int k){
	// x ^ k mod inf
	int res = 1;
	while(k>0){
		if(k%2)res = (res*x)%inf;
		x = (x*x)%inf;
		k >>=1;
	}
	return res;
}
void setinv(int n){
	for(int i=0;i<=n;i++){
		inv[i] = modpow(ka[i],(ll)inf-2);
	}
}
int comb(int n,int k){
	if( k<0 || n<0 || k>n)return 0;
	if(k==0 || k==n)return 1;
	int res = (ka[n] * inv[k]) % inf;
	res = (res*inv[n-k]) % inf;
	return res;
}
int cb[214514];
signed main(){
	int n;
	cin>>n;
	int ans = modpow( 2, n ) - 1;
	int a,b;
	cin>>a>>b;
	cb[0] = 1;
	for(int i=1;i<=b;i++){
		cb[i] = cb[i-1] * (n-i+1);
		cb[i] %= inf;
		if( i >= 2 ) cb[i] *= modpow( i, inf-2 );
		cb[i] %= inf;
	}
	ans += 2*inf - cb[a] - cb[b];
	ans %= inf;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
S = list(input())

N = len(S)
ans = 'Yes'

for i in range(N):
    if S[i]!=S[N-i-1]:
        ans = 'No'
        break

for i in range((N-1)//2):
    if S[i]!=S[(N-1)//2-i-1]:
        ans = 'No'
        break

for i in range((N+3)//2,N):
    if S[i]!=S[N-i-1]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3064
import java.util.*

fun main(args: Array<String>) {
    agc005a()
}

// スタック使ってみる版
fun agc005a() {
    val x = readLine()!!.map { it == 'T' }

    val stack = Stack<Boolean>()
    x.forEach { isT ->
        if (isT) {
            if (stack.isNotEmpty() && !stack.peek()) stack.pop() else stack.push(isT)
        } else {
            stack.push(isT)
        }
    }

    println(stack.size)
}


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

int main()
{
	int x;
	cin >>x;
	if ( x % 7 == 1 ) cout << "fri";
	if ( x % 7 == 2 ) cout << "sat";
	if ( x % 7 == 3 ) cout << "sun";
	if ( x % 7 == 4 ) cout << "mon";
	if ( x % 7 == 5 ) cout << "tue";
	if ( x % 7 == 6 ) cout << "wed";
	if ( x % 7 == 0 ) cout << "thu";
	cout << endl ;
	return 0 ;
}



Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int64_t zero = 0;

int main() {
  int R, C, K;
  cin >> R >> C >> K;
  vector<vector<int64_t>> field(R, vector<int64_t> (C, 0));
  for(int i = 0; i < K; i++) {
    int r, c;
    int64_t v;
    cin >> r >> c >> v;
    field.at(r - 1).at(c - 1) = v;
  }
  // dp.at(i).at(j).at(k) i行j列にいてi行でk個拾った状態での最大値
  vector<vector<vector<int64_t>>> dp(R, vector<vector<int64_t>> (C, vector<int64_t> (4, 0)));
  for(int i = 0; i < R; i++) {
    for(int j = 0; j < C; j++) {
      if(i == 0 && j == 0) {
        dp.at(i).at(j).at(1) = field.at(i).at(j);
      }
      if(j > 0) {
        dp.at(i).at(j).at(0) = dp.at(i).at(j - 1).at(0);
        for(int k = 1; k < 4; k++) {
          dp.at(i).at(j).at(k) = max(dp.at(i).at(j - 1).at(k - 1) + field.at(i).at(j), dp.at(i).at(j - 1).at(k));
        }
      }
      if(i > 0) {
        for(int k = 0; k < 4; k++) {
          dp.at(i).at(j).at(0) = max(dp.at(i).at(j).at(0), dp.at(i - 1).at(j).at(k));
        }  
        if(field.at(i).at(j) != 0) {
          for(int k = 0; k < 4; k++) {
            dp.at(i).at(j).at(1) = max(dp.at(i).at(j).at(1), dp.at(i - 1).at(j).at(k) + field.at(i).at(j));
          }
        }
      }
    }
  }
  int64_t ans = dp.at(R - 1).at(C - 1).at(0);
  for(int k = 1; k < 4; k++) {
    ans = max(ans, dp.at(R- 1).at(C - 1).at(k));
  }
  cout << ans << endl;    
}

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

using namespace std;



int main(){
	int n,k;cin>>n>>k;
	int arr[n],mn = INT_MAX;
	for(int i=0; i<n; i++){
		cin>>arr[i];
		mn = min(arr[i],mn);
	}
	int dp[k+1];
	//0 means losing state
	//1 means winning state;
	for(int i=0; i<mn; i++)dp[i] = 0;
	
	for(int i=mn;i<=k; i++){
		dp[i] = 0;
		for(int j=0; j<n; j++){
//			dp[i] = (dp[i])||(i-arr[j]>=0?dp[i-arr[j]]:0);
			if(i-arr[j]>=0&&dp[i-arr[j]]==0)dp[i]=1;
		}
	}
	if(dp[k]){
		cout<<"First"<<endl;
	}else{
		cout<<"Second"<<endl;
	}
	
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <set>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;

#define Rep(b, e, i) for(int i = b; i <= e; i++)
#define Repr(e, b, i) for(int i = e; i >= b; i--)
#define rep(n, i) Rep(0, n-1, i)
#define repr(n, i) Repr(n-1, 0, i)
#define all(v) (v).begin(), (v).end()
#define pb(v) push_back(v)
#define uniq(v) (v).erase(unique(all(v)),(v).end())
#define bitcnt(x) __builtin_popcount(x)
#define fst first
#define snd second
#define Pqaz(T) priority_queue<T,vector<T>,greater<T>>
#define Pqza(T) priority_queue<T>
#define ENJYU std::ios::sync_with_stdio(false);std::cin.tie(0);

typedef long long ll;
typedef pair<ll, ll> llP;
typedef pair<int, int> intP;

//vector の中身を出力
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

map <int, int> mp;

void solve(void){
	int a, b;
	while (cin >> a >> b) {
		if (a == 0 && b == 0) {
			int f = 1;
			for (intP p : mp) {
				if (p.fst == 1 || p.fst == 2) {
					f &= p.second & 1;
				}
				else f &= !(p.second & 1);
			}
			cout << (f ? "OK" : "NG") << endl;
			mp.clear();
			continue;
		}
		mp[a]++, mp[b]++;
	}
}

int main(void){
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}



Measured memory_bytes: 3096
#include<stdio.h>
typedef long long LL;

LL MX=1000000007;
LL d[105][105][305],fac[105];
int a[105];

int main()
{
    int n,K,i,j,k;
    LL res=0;
    scanf("%d %d", &n, &K);
    for(i=1;i<=n;i++){
        scanf("%d", &a[i]);
    }
    fac[0]=1;
    for(i=1;i<=n;i++){
        fac[i]=(fac[i-1]*i)%MX;
    }
    d[0][0][0]=1;
    for(i=1;i<=n;i++){
        for(j=0;j<=n;j++){
            for(k=0;k<256;k++){
                if(j==0)d[i][j][k]=d[i-1][j][k];
                else d[i][j][k]=(d[i-1][j][k]+d[i-1][j-1][k^a[i]])%MX;
            }
        }
    }
    for(i=1;i<=n;i++){
        res+=(d[n][i][K]*fac[i])%MX;
        res%=MX;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 24704
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

bool dfs(const vector<vector<pair<int64_t, int64_t>>>& links,
         vector<bitset<20>>& bs, int64_t current, int64_t parent, int64_t goal,
         int64_t idx) {
    if (current == goal) {
        return true;
    }

    for (auto link : links[current]) {
        auto v = link.first;
        if (v == parent) {
            continue;
        }

        auto tmp = dfs(links, bs, v, current, goal, idx);
        if (tmp) {
            bs[link.second][idx] = true;
            return true;
        }
    }

    return false;
}

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

    vector<vector<pair<int64_t, int64_t>>> links(n);
    for (auto i : irange(0L, n - 1)) {
        int64_t a, b;
        cin >> a >> b;
        --a;
        --b;
        links[a].emplace_back(b, i);
        links[b].emplace_back(a, i);
    }

    int64_t m;
    cin >> m;

    vector<bitset<20>> paths(n - 1);
    for (auto i : irange(0L, m)) {
        int64_t u, v;
        cin >> u >> v;
        --u;
        --v;

        dfs(links, paths, u, -1, v, i);
    }

    int64_t ans = 1L << (n - 1);
    for (auto k : irange(1uL, 1uL << m)) {
        bitset<20> bs(k);

        int64_t num_white = 0;
        for (auto i : irange(0L, n - 1)) {
            if ((paths[i] & bs).any()) {
                ++num_white;
            }
        }

        int64_t tmp = 1L << (n - 1 - num_white);
        // cerr << bs.to_string() << ":" << tmp << "\n";
        if (bs.count() % 2 == 0) {
            ans += tmp;
        } else {
            ans -= tmp;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int a,b;
  
  cin >> a >> b;
  
  int ans = a + b;
  
  if(ans < a - b){
    ans = a - b;
  }
  
  if(ans < a * b){
    ans = a * b;
  }
  
  cout << ans ;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, N) for (int i=0; i<(int)N; i++)
#define rep1(i, N) for (int i=1; i<(int)N; i++)

using namespace std;

long long int n, k;

int main() {
  cin >> n >> k;
  long long int h[n];
  rep(i, n) {
    cin >> h[i];
  }
  sort(h, h+n, greater<int>());
  
  long long int sum = 0;
  for(int i=k; i < n; i++) {
    sum += h[i];
  }
  
  cout << sum;

}


Measured memory_bytes: 1792
#include <stdio.h>

int main(void) {
	unsigned long long int a,b,n[4096];
	int i,l,w,y,z[4096];
	while(scanf("%d",&l) , l != 0){
		y = 1;
		for(i = 0;i <= 4095;i++){
			n[i] = 0;
			z[i] = 1;
			}
		for(i = 1;i <= l;i++){
			scanf("%d%llu%llu",&w,&a,&b);
			n[w]+=(a*b);
			if(n[w] >= 1000000 && z[w]){
				printf("%d\n",w);
				z[w] = 0;
				y = 0;
				}
		}
		if(y) printf("NA\n");
	}
	return 0;
}

Measured memory_bytes: 664
while set = gets()
  if (set.nil? or set == "\n" or set == "\n\r") then break end
  a, b, c, d, e, f = set.split().map{|x| x.to_f}

  y = (d * c - a * f) / (d * b - a * e)
  x = (c - b * y) / a

  printf("%.3f %.3f\n", x, y)
end

Measured memory_bytes: 6136
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<utility>
#include<vector>


using namespace std;


int main(void){
    int N;
    scanf("%d",&N);
    int A[N];
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
    }
    sort(A,A+N);

    for(int i=1;i<N;i++){
        if(A[i-1]==A[i]){
            printf("NO");
            return 0;
        }
    }
    printf("YES");

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
int n,u,v,ans;
vector<int> adj[100001];
int dist2[100001];
void dfs1(int node,int p,int dist){
    dist2[node]=dist;
    for (auto i:adj[node]){
        if (i==p) continue;
        dfs1(i,node,dist+1);
    }
}
void dfs(int node,int p,int dist){
    if (adj[node].size()==1 && dist>=dist2[node]){
        if (dist2[node]%2!=dist){
            ans=max(ans,dist-1);
        }
        else {
            ans=max(ans,dist-1);
        }
    }
    for (auto i:adj[node]){
        if (i==p) continue;
        dfs(i,node,dist+1);
    }
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n>>u>>v;
    for (int i=0;i<n-1;i++){
        int a,b;
        cin>>a>>b;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    dfs1(u,-1,0);
    dfs(v,-1,0);
    cout<<ans;
}

Measured memory_bytes: 9984
function main(input) {
  input=input.trim();
  const n = parseInt(input.split(" ")[0], 10);
  const d = parseInt(input.split("\n")[1].split(" ")[0], 10);
  const x = parseInt(input.split("\n")[1].split(" ")[1], 10);
  var arrA=[]
  for(var i=0; i<n; i++){
    arrA.push(parseInt(input.split("\n")[2+i], 10))
  }
  var ans=0
  for(var i=0; i<n; i++){
    var t=0
    while(t*arrA[i]+1<=d){
      ans++
      t++
    }
  }
  console.log(ans+x);
}


main(require('fs').readFileSync('/dev/stdin', 'utf8'));


Measured memory_bytes: 7372
#include<iostream>
#include<algorithm>
#include<cmath>
#define N 50000

using namespace std;

int main(){

  int prime[N+1], n;

  fill(prime, prime+N+1, 1);
  prime[0] = 0;
  prime[1] = 0;
  for(int i=2; i<=N; i++){
    if(prime[i] == 1){
      for(int j=2; i*j<=N; j++){
        prime[i*j] = 0;
      }
    }
  }

  int cnt, m;
  while(cin >> n){
    if(n == 0) break;
    cnt = 0;
    m = ceil((double)n / 2);
    for(int i=n-2; i>=m; i--){
      if(prime[i] == 1 && prime[n-i] == 1) cnt++;
    }
    
    cout << cnt << endl;

  }

  return 0;

}

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

bool isPrime(int x) {
  for(int i=2; i < x; i++) {
    if(x%i == 0) return false;
  }
  return true;
}

int main() {
  int x;
  cin >> x;
  while(true) {
    if(isPrime(x)) {cout << x << endl; break;}
    x++;
  }
}


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

int main() {
  int N, K;
  cin >> N >> K;
  
  int a = 0; //操作Aを行なった回数
  int x = 1; //初期値
  
  for (int i = 0; i < N; i++) {
    x *= 2;
    a++;
    if (K <= 2 && i == 0) {
      break;
    }
    else if (K <= 4 && i == 1) {
      break;
    }
    else if (K <= 8 && i == 2) {
      break;
    }
    else if (i == 3) {
      break;
    }
  }
  
  for (int j = 0; j < N - a; j++) {
    x += K;
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

class BipartiteMatching {
    int n;
    vector<vector<int>> G;
    vector<int> match;
    vector<int> used;

    // 増加パスをDFSで探す
    bool dfs(int v) {
        used[v] = true;
        for (int i = 0; i < G[v].size(); i++) {
            int u = G[v][i], w = match[u];
            if (w < 0 || (!used[w] && dfs(w))) {
                match[v] = u;
                match[u] = v;
                return true;
            }
        }
        return false;
    }
public:
    BipartiteMatching(int n) : n(n), G(n), match(n), used(n) {}
    // u と v を結ぶ辺をグラフに追加する
    void add_edge(int u, int v) {
        G[u].push_back(v);
        G[v].push_back(u);
    }
    // マッチングする
    int calc() {
        fill(match.begin(), match.end(), -1);
        int res = 0;
        for (int v = 0; v < n; v++) {
            if (match[v] < 0) {
                fill(used.begin(), used.end(), false);
                if (dfs(v)) res++;
            }
        }
        return res;
    }
    vector<int> get_match(){return match;}
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<pair<int, int>> ab(N);
    vector<pair<int, int>> cd(N);
    for(int i=0; i<N; i++) cin >> ab[i].first >> ab[i].second;
    for(int i=0; i<N; i++) cin >> cd[i].first >> cd[i].second;
    BipartiteMatching bm(2*N);

    for(int i=0; i<N; i++){
        for(int j=0; j<N; j++){
            if(ab[i].first < cd[j].first && ab[i].second < cd[j].second){
                bm.add_edge(i, j+N);
            }
        }
    }
    bm.calc();
    auto v = bm.get_match();
    int ans = 0;
    for(int i=0; i<N; i++)
        if(v[i] != -1) ans += 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++)
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7;

int main(){
  ll n,k; cin>>n>>k;
  double ans=0 ;
  for(int i=1;i<=n;i++){
//  double pro=1/n;
    double pro=1.0/n;
    ll t=i;
    while(t<k){
    t*=2;
      pro/=2;
    }
    ans+=pro;
  }
  cout << fixed << setprecision(10)<<ans<<endl;
//cout<<ans<<endl;
}

Measured memory_bytes: 256