akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())


int n, q;
int a[100000];
int x[100000];
long long sumt[100001];
long long sum[100000];


pair<int, int> draw(int x, int k) {
	// 最大の差
	int lb = -1, ub = a[n - 1];
	while (ub - lb > 1) {
		int mid = (lb + ub) / 2;
		int le = lower_bound(a, a + n, x - mid) - a;
		int ri = upper_bound(a, a + n, x + mid) - a;

		if (ri - le >= k)ub = mid;
		else lb = mid;
	}

	int diff = ub;
	int le = lower_bound(a, a + n, x - diff) - a;
	int ri = upper_bound(a, a + n, x + diff) - a;
	if (ri - le > max(1, k) && x - a[le] == a[ri - 1] - x) {
		ri--;
	}
	return make_pair(le, ri); // [le,ri)
}

//にぶたん用軽量版
bool check(int x, int k) {
	if (k == 0)return true;
	int tail = a[n - k];
	int ri = n - k;
	int le = lower_bound(a, a + n, x - abs(tail - x)) - a;
	return le < ri && k <= ri - le;
}

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

	cin >> n >> q;
	rep(i, n)cin >> a[i];
	rep(i, q)cin >> x[i];

	sort(a, a + n);

	rep(i, n)sum[i] = a[i];
	for (int i = 2; i < n; i++)sum[i] += sum[i - 2];

	rep(i, n)sumt[i] = a[i];
	for (int i = n - 2; i >= 0; i--)sumt[i] += sumt[i + 1];

	rep(i, q) {
		int X = x[i];

		int lb = 0, ub = n;
		//高橋君が何枚衝突するまでにとれるか
		while (ub - lb > 1) {
			int mid = (lb + ub) / 2;

			/*auto p = draw(X, mid);

			if (p.second <= n - mid)lb = mid;
			else ub = mid;*/

			if (check(X, mid))lb = mid;
			else ub = mid;
		}

		
		int k = lb;
		long long ans = sumt[n - k];
		auto p = draw(X, k);
		if (p.second == n) {
			ans += sum[n - 1];
		}
		else if (p.second == n - k) {
			if (p.first >= 0)ans += sum[p.first - 1];
		}
		else {
			ans += a[p.second];
			if (p.first >= 2)ans += sum[p.first - 2];
		}
		cout << ans << endl;
	}



	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#include<iostream>
#include<string.h>
#include<climits>

using namespace std;

#define lld long long int
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL);	cout.tie(0);

/* 											CODE:-									*/
														


void IMPLEMENT_CODE(){
	
	lld n;
	cin>>n;

	lld a[n][3];
	for(lld i=0; i<n; i++){
		for(lld j=0; j<3; j++)
			cin>>a[i][j];
	}

	lld dp[n][3];

	for(lld i=0; i<3; i++)
		dp[0][i] = a[0][i];

	for(lld i=1; i<n; i++){
		dp[i][0] = a[i][0] + max(dp[i-1][1], dp[i-1][2]);
		dp[i][1] = a[i][1] + max(dp[i-1][0], dp[i-1][2]);
		dp[i][2] = a[i][2] + max(dp[i-1][0], dp[i-1][1]);
	}

	lld ans = max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
	cout<<ans<<endl;
	
}



int main(){
	
	FASTIO;

	IMPLEMENT_CODE();

	return 0;

}


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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	int cnt = 0;
	bool prime;
 	for(int i = 2; i < 55556; i++){
 	  prime = true;
		for(int j = 2; j < i && prime; j++){
			if(i % j == 0){
				prime = false;
			}
		}	
		if(prime && i % 5 == 1){
	  	cnt++;
			cout << i << " ";
		}
		if(cnt == n) break;
	}
	cout << "\n";
	return 0;
}


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

int main() {
  int e;
  double a,b,d;
  cin >> a  >> b;
  d = (a + b) / 2;
  e = (a + b) / 2;
  if(d - e == 0){
    cout << e << endl;
  }
  else{
    cout << e+1 << endl;
  }
}


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

void solve(std::string S){

    if(S <= "2019/04/30"){
        cout << "Heisei" << endl;
    }else{
        cout << "TBD" << endl;
    }

}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe

readInt = fst . fromJust . BS.readInteger

getInt = readInt <$> BS.getLine
getNLine n = map BS.unpack <$> replicateM (fromIntegral n) BS.getLine

solve :: [Int] -> [String] -> [String]
solve (a:b:c:[d]) [] = ["AC x " <> show a, "WA x " <> show b, "TLE x " <> show c, "RE x " <> show d]
solve (a:b:c:[d]) (x:xs)
  | x == "AC"  = solve [a+1,b,c,d] xs
  | x == "WA"  = solve [a,b+1,c,d] xs
  | x == "TLE" = solve [a,b,c+1,d] xs
  | x == "RE"  = solve [a,b,c,d+1] xs

main = do
  n  <- getInt
  score <- getNLine n
  putStr $ unlines $ solve [0,0,0,0] score


Measured memory_bytes: 22068
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,sqrt
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7
#s=input().rstrip()

alphasm=[chr(i) for i in range(97, 97+26)]
s=input().rstrip()
s=list(s)
u=sorted(list(set(s)))
ans=0
for al in alphasm:
    if not (al in u):
        ans=al
        break
print(ans if ans!=0 else "None")


Measured memory_bytes: 4336
#include <algorithm>
#include <array>
#include <climits> // INT_MAX, LONG_MAX, LLONG_MAX, UINT_MAX, ULONG_MAX, ULLONG_MAX
#include <cmath>
#include <cstdint>
#include <iostream>
#include <map>
#include <string>
#include <vector>

#define INF (INT_MAX >> 1)

using namespace std;

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

    int count = 0;

    for (int i = 1; i <= N; i++) {
        int l, r;
        cin >> l >> r;
        count += r - l + 1;
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M,i;
	cin>>N>>M;
	vector<int> A(N);
	double T=0;
	for (i=0;i<N;i++){
		cin>>A[i];
		T+=A[i];
	}
	T=T/(4*M);
	int ans=0;
	for (i=0;i<N;i++){
		if (A[i]>=T){
			ans++;
		}
	}
	if (ans>=M){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
 
using namespace std;
 
int main()
{
    int n, o, h, t;
    string s;
    cin >> n;
     
    while(n--)
	{
        o = h = t = 0;
        while(o < 3)
		{
            cin >> s;
            if(s == "HIT")
			{
                if(h == 3)
				{
                    t++;
                } 
				else 
				{
                    h++;
                }
            } 
			else if(s == "HOMERUN")
			{
                t = t + h + 1;
                h = 0;
            } 
			else 
			{
                o++;
            }
        }
        cout << t << endl;
    }
     
    return 0;
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll t;
  //cin>>t;
  //while(t--){
    ll a,b=1,c=1,d=0,e=0,f=0,g=0,h=0;
    cin>>a;
  if(a==0){cout<<1<<endl;}
  else{cout<<0<<endl;}

  //}
  }

Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <cmath>
#define rep0(i,n) for (int i = 0; i <= (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
using namespace std;
int main(){
	int a = 0;
	int b = 0;
	int c = 0;
	cin >> c;
	if (c == 2) {
		cin >> a;
		cin >> b;
		cout << a + b << endl;
	}
	else
		cout << "Hello World" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int r, d, x, x2;
	cin >> r >> d >> x;

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

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V) {
 os << "[ "; for(auto v : V) os << v << " "; return os << "]";}
template<class L, class R> ostream& operator<<(ostream &os, pair<L,R> P) {
	return os << "(" << P.first << "," << P.second << ")";}

#define TRACE
#ifdef TRACE
#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, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...) 1
#endif


#define ll long long
#define ld long double
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define I insert 
#define pb push_back
#define F first
#define S second
#define endl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vpii vector< pii >


// int mod=1e9+7;
inline int mul(int a,int b, int mod){return (a*1ll*b)%mod;}
inline int add(int a,int b, int mod){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b, int mod){a-=b;if(a<0)a+=mod;return a;}
inline int power(int a,int b, int mod){int rt=1;while(b>0){if(b&1)rt=mul(rt,a, mod);a=mul(a,a, mod);b>>=1;}return rt;}
inline int inv(int a, int mod){return power(a,mod-2, mod);}

int N,M;
const int MAX = 3005;

int ncr[MAX][MAX];
int dp[MAX][MAX];
int two[MAX], two1[MAX];

void pre(){
	int i,j,k;
	two[0] = two1[0] = 1;
	ncr[0][0] = 1;
	for(i=1;i<MAX;i++){
		two[i] = mul(two[i-1], 2, M);
		two1[i] = mul(two1[i-1], 2, M-1);
		for(j=0;j<MAX;j++){
			if(j==0)ncr[i][j]=1;
			else{
				// trace(i,j);
				ncr[i][j] = add(ncr[i-1][j],ncr[i-1][j-1], M);
			}
		}
	}
	dp[0][0]=1;
	for(i=1;i<MAX;i++){
		for(j=1;j<=i;j++){
			dp[i][j] = add(dp[i-1][j-1], mul(j, dp[i-1][j], M), M);
		}
	}
}

void solve(){
	int ans = 0;
	int i,j,k;
	for(i=0;i<=N;i++){
		int cur = ncr[N][i];
		cur = mul(cur, power(2, two1[N-i], M), M);
		int mt = 0;
		for(k=1;k<=i;k++){
			mt = add(mt, mul(dp[i][k], power(two[N-i], k, M), M), M );
			mt = add(mt, mul( mul(dp[i][k], k, M), power(two[N-i], k-1, M), M), M);
		}
		if(i==0)mt = 1;
		cur = mul(cur, mt, M);
		if(i&1) cur = sub(0, cur, M);

		ans = add(ans, cur, M);
	}
	cout<<ans;
}

int main(){
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	cin>>N>>M;
	pre();
	// cout<<"ok";
	solve();
}


Measured memory_bytes: 69632
mod = pow(10,9)+7
r,c = list(map(int,input().split()))
arr = []
for i in range(r):
    string = input()
    lista = []
    for i in string:
        lista.append(i)
    arr.append(lista)

dp = [ [0 for i in range(c)] for j in range(r)]

for i in range(r):
    if(arr[i][0] == '#'):
        break
    dp[i][0] = 1
for i in range(c):
    if(arr[0][i] == '#'):
        break
    dp[0][i] = 1

for i in range(1,r):
    for j in range(1,c):
        if(arr[i-1][j] == '.'):
            dp[i][j] += dp[i-1][j]
        if(arr[i][j-1] == '.'):
            dp[i][j] += dp[i][j-1]


print(dp[r-1][c-1]%mod)
    


Measured memory_bytes: 166180
/*
    Don’t practice until you get it right. Practice until you can’t get it wrong.
*/

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

#define ll long long
#define ld double
#define pii pair<ll,ll>
#define vl vector<ll>
#define vb vector<bool>
#define vs vector<string>
#define vp vector<pii>
#define pb push_back
#define mp make_pair
#define sc(a) scanf("%lld",&a);
#define sd(a) scanf("%lf",&a);
#define test() ll tt;cin>>tt;for(ll testcase=1;testcase<=tt;testcase++)
#define all(v) v.begin(),v.end()
#define vivek_ghosh ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MAX 1000055
#define mod 1000000007
#define ff first
#define ss second
const int INF=0x3f3f3f3f;
const ll int inf = LLONG_MAX;

ll power(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)
        return power((x*x)%M,n/2,M);
    else
        return (x*power((x*x)%M,(n-1)/2,M))%M;
}

ll modinv(ll a,ll m)
{
    ll g =__gcd(a, m);
    ll res=power(a, m-2, m);
    return res;
}

vb prime(MAX,true);
vl prm;
void sieve()
{
	prime[0] = prime[1] = false;
	for(ll p=2;p*p<MAX;p++)
	{
		if(prime[p])
		{
			for(ll i=p*p;i<MAX;i+=p)
				prime[i] = false;
		}
	}
	for(ll p=2;p<MAX;p++)
	{
		if(prime[p])
			prm.pb(p);
	}
}

ll n,m,t,i,j,k,q,x,y,ans=0,cnt=0,sum=0,mx=-1,mn=INT_MAX;
string s;

int main()
{
    vivek_ghosh;

    ll h,w;
    cin>>h>>w;
    if(h == 1 || w==1)
        ans = 1;
    else
    {
        ans = ((h*w)+1)/2;
    }
    cout<<ans<<endl;
    return 0;
}








Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if((s[0]=='A' && s[1]=='A' && s[2]=='A') || (s[0]=='B' && s[1]=='B' && s[2]=='B'))
        {
            printf("No\n");
            return 0;
        }
        else{
           printf("Yes\n");
           return 0;
        }

    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  int a, b;
  cin >> a >> b;
  for (int i = 1; i <= 1000; i++) {
    if (floor(i * 0.08) == a && floor(i * 0.1) == b) {
        cout << i << endl;
        return 0;
    }
  }
  cout << -1 << endl;
  return 0;
}


Measured memory_bytes: 256
///cREATED bY BERNARB.01
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef priority_queue<int,vector<int>,greater<int>> pqil;
typedef priority_queue<int> pqig;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef priority_queue<pii> pqiig;
typedef vector<pii> vii;
typedef vector<piii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef map<int, int> mii;
#define mid ((l+r)/2)
#define PB push_back
#define PP pop_back
#define PF push_front
#define DF pop_front
#define F first
#define S second
#define MP make_pair
#define C continue
#define B break
#define R return
#define sz(v) (int)(v).size()
#define len(s) (int)(s).length()
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define clr(arr, x) memset((arr), (x), sizeof (arr))
#define loop(n) for(ll i=0; i<(n); i++)
#define jloop(n) for(ll j=0; j<(n); j++)
#define rloop(n) for(ll i=(n)-1; i>=0; i--)
#define sgm(y) (((y)*((y)+1))/2)
const ll INF = 2e17+423;
const ll mod = 1e9+7; //998244353;
const ld pi = acos(-1.0);
const ld cmpf = 1e-9;
//__int128_t
//      -ASCII-
//a -> z | A -> Z | 0 -> 9
//97 122 | 65  90 | 48  57
#define endl '\n'
ll po(ll,ll);



















int main() {
  /*#ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  #endif // ONLINE_JUDGE*/
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  int a[n];
  loop(n) cin >> a[i];
  ll ans = 0;
  sort(a, a+n);
  reverse(a, a+n);
  for(int i=k; i<n; i++){
    ans+=a[i];
  }
  cout << ans << endl;
  R 0;
}
/*

*/




























































ll po(ll x, ll n){
  if(n==0) R 1;
  ll y = po(x, n/2);
  y = ((y)*(y));
  if(n%2) y = (y*(x));
  R y;
}


Measured memory_bytes: 1024
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))

#define INF 1000000000

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)
{
	if (a < b)
		swap(&a, &b);

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

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

void bubble_sort(int* p, int n)
{
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n - i - 1; j++)
		{
			if (p[j] > p[j + 1])
				swap(&p[j], &p[j + 1]);
		}
	}
}

int array_max(int* p, int n)
{
	int max = 0;
	for (int i = 0; i < n; i++)
	{
		if (p[i] > max)
			max = p[i];
	}
	return max;
}

int binary_search(int* p, int key, int n)
{
	int low = 0, high = n - 1;
	int middle;

	while (low <= high)
	{
		middle = (low + high) / 2;

		//printf("low %d  middle %d  high %d\n", low, middle, high);

		//for (int i = 0; i < n; i++)
		//{
		//	if (i == middle)
		//		printf(" ^ ");
		//	else if (i == low)
		//		printf(" [ ");
		//	else if (i == high)
		//		printf(" ] ");
		//	else if (i == middle)
		//		printf(" ^ ");
		//	else
		//		printf("   ");
		//}
		//printf("\n");

		if (key == p[middle])
			return key;
		else if (key < p[middle])
			high = middle - 1;
		else if (key > p[middle])
			low = middle + 1;
	}

	//printf("low %d  middle %d  high %d\n", low, middle, high);
	return -1;
}

int main()
{
	int N, M, C;
	int B[20];
	int A[20][20];
	int count=0, tmp;

	scanf("%d%d%d", &N, &M, &C);

	for (int i = 0; i < M; i++)
		scanf("%d", &B[i]);

	for (int i = 0; i < N; i++)
	{
		tmp = 0;
		for (int j = 0; j < M; j++)
		{
			scanf("%d", &A[i][j]);
			tmp += B[j] * A[i][j];
		}
		if (tmp+C > 0)
			count++;
	}

	printf("%d\n", count);

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

void solve() {
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    REP(i, n) cin >> h[i];
    SORT(h);
    int ans = INF;
    REP(i, n - k + 1) chmin(ans, h[i + k - 1] - h[i]);
    cout << ans << endl;
}



Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << min(a,b) + min(c,d) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

using namespace std;
#define ll long long
#define rep(i,n) for (int i = 0; i < n; i++)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define MOD (1000000007)
#define vi vector<int>
#define vl vector<ll>
#define vb vector<bool>
#define vvi vector<vi>
#define vvl vector<vl>
#define pii pair<int, int>
#define pli pair<ll, int>a
#define pb push_back

#define mp make_pair
#define all(a) (a).begin(),(a).end()

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

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

ll keta(ll n){
  string s = to_string(n);
  ll num = s.size();
  return num;
}

const ll INF = 1LL << 60;

const int dh[4] = {1,0,-1,0};
const int dw[4] = {0,1,0,-1};

struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w){}
};
using Graph = vector<vector<Edge>>;
using P = pair<ll, int>;


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

  int ans = 0, cA = 0, cB = 0, cBA = 0;
  rep(i,n) {
    rep(j,s[i].size()-1) {
      if(s[i][j] == 'A' && s[i][j+1] == 'B'){
        ans++;
      }
    }
    if(s[i][0] == 'B' && s[i].back() == 'A'){
      cBA++;
      continue;
    }
    if(s[i][0] == 'B') cB++;
    if(s[i].back() == 'A') cA++;
  }

  ans += min(cA, cB);
  if(max(cA,cB) == 0) ans += max(cBA-1,0);
  else ans += cBA;

  cout << ans << endl;
}

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

int d[6];
void IDnize(int i){
    for(int p=0; p<6; ++p){
        d[p]=i%10;
        i /= 10;
    }
    for(int p=5; p>=0; --p) cout << d[p];
}
map<int, vector<int>> mp;
int bin_s(int m, int i){
    int left=0, right=mp[m].size()-1;
    while(right>=left){
        int mid=left+(right-left)/2;
        if(mp[m][mid]==i) return mid;
        else if(mp[m][mid]>i) right=mid-1;
        else left=mid+1;
    }
}
int main() {
	int N, M; cin >> N >> M;
	int P[100010], Y[100010];
	for(int i=0; i<M; ++i){
	    cin >> P[i] >> Y[i];
	    mp[P[i]].push_back(Y[i]);
	}
	for(int i=1; i<=N; ++i) if(mp[i].size()>1) sort(mp[i].begin(), mp[i].end());
	int order;
	for(int i=0; i<M; ++i){
	    order=bin_s(P[i], Y[i]);
	    IDnize(P[i]);
	    IDnize(order+1);
	    cout << endl;
	}
	return 0;
}


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

int main() {
  long n,sum,fs,bs,fbs;
  cin >> n;
  sum = n,fs = 0, bs = 0, fbs = 0;
  for (int i = 0; i < n; i++) {
    sum += i;
  }
  for (int i = 3; i <= n; i += 3) {
    fs += i;
  }
  for (int i = 5; i <= n; i += 5) {
    bs += i;
  }
  for (int i = 15; i <= n; i += 15) {
    fbs += i;
  }
  cout << sum-fs-bs+fbs << endl;
}

Measured memory_bytes: 3640
#define TEMPLATE_USED
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
const ll INF=1001001001;
const ll LINF=1001001001001001001;
const ll D4[]={0,1,0,-1,0};
const ll D8[]={0,1,1,0,-1,-1,1,-1,0};
#define _overload3(_1,_2,_3,name,...) name
#define _rep2(i,n) for(ll i=0;i<(n);++i)
#define _rep3(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,_rep3,_rep2)(__VA_ARGS__)
#define _repe2(i,n) for(ll i=0;i<=(ll)(n);++i)
#define _repe3(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define repe(...) _overload3(__VA_ARGS__,_repe3,_repe2)(__VA_ARGS__)
#define _rrep2(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define _rrep3(i,a,b) for(ll i=(ll)(b)-1;i>=(ll)(a);i--)
#define rrep(...) _overload3(__VA_ARGS__,_rrep3,_rrep2)(__VA_ARGS__)
#define _rrepe2(i,n) for(ll i=(ll)(n);i>=0;i--)
#define _rrepe3(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)
#define rrepe(...) _overload3(__VA_ARGS__,_rrepe3,_rrepe2)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
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;}

void solve();

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

void solve(){
    ll n,m;cin>>n>>m;
    vl dp(1<<n,LINF);
    dp[0]=0;

    vl a(m),keys(m);
    rep(i,m){
        cin>>a[i];
        ll b;cin>>b;
        rep(j,b){
            ll c;cin>>c;
            c--;
            keys[i]|=1<<c;
        }
    }

    rep(i,1<<n)rep(j,m){
        chmin(dp[i|keys[j]],dp[i]+a[j]);
    }
    if(dp[(1<<n)-1]==LINF)cout<<-1<<endl;
    else cout<<dp[(1<<n)-1]<<endl;
}


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

typedef long long ll;
typedef pair<int, int> pi;
#define F first
#define S second
#define PB push_back

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

const int MOD = 1000000007;

// int max = *std::max_element(vec.begin(), vec.end());
// int sum = accumulate(list, list + size, 0);

int main()
{
    int n; cin >> n;
    int result = n / 1.08;
    
    if ((int)(result * 1.08) == n) {
        cout << result << endl;
    } else if ((int)((result + 1) * 1.08) == n) {
        cout << ++result << endl;
    } else {
        cout << ":(" << endl;
    }
} 


Measured memory_bytes: 256
n,m=map(int,input().split())
sc=[list(map(int,input().split())) for i in range(m)]
start=10**(n-1)
end=10**n
if n == 1:
    start = 0
for i in range(start,end):
    i=str(i)
    for s,c in sc:
        if i[s-1] != str(c):
            break
    else:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define debug(x) cout << "debug " << x << endl;
const int INF = 100000000;
using namespace std;

int main(){
    int h, w;
    cin >> w >> h;

    char m[100][10000];
    rep(i,h) rep(j,w) cin >> m[i][j];

    int cnt = 0;
    int W[10000], E[10000];
    rep(i,w){
        rep(j,h){
            if(m[j][i] == 'E') cnt++;
        }
        E[i] = cnt;
    }

    cnt = 0;
    for(int i = w - 1; i >= 0; i--){
        rep(j,h){
            if(m[j][i] == 'W') cnt++;
        }
        W[i] = cnt;
    }

    int ans[2];
    ans[0] = INF;

    if(ans[0] > W[0]){
        ans[0] = W[0];
        ans[1] = -1;
    }
    rep(i,w - 1){
        if(ans[0] > E[i] + W[i + 1]){
            ans[0] = E[i] + W[i + 1];
            ans[1] = i;
        }
    }
    if(ans[0] > E[w - 1]){
        ans[0] = E[w - 1];
        ans[1] = w - 1;
    }

    cout << ans[1] + 1 << ' ' << ans[1] + 2 << endl;
}

Measured memory_bytes: 4160
# a = 9
# b = '9 6 3 2 5 8 7 4 1'

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

l = n - 2

r = 0

for i in range(l):
    l2 = p[i:3+i]
    if l2[0] < l2[1]:
        if l2[1] < l2[2]:
            r += 1
    else:
        if l2[1] > l2[2]:
            r += 1

print(r)

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

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

    ll num1 = 0;
    ll tmp = a;

    while(tmp){
        tmp /= 2;
        num1++;
    }

    ll a_xor[num1];
    rep(i, num1){
        if(i == 0){
            if(ll(floor((a - 1) / 2.0)) % 2 == 0){
                a_xor[i] = 1;
            }else{
                a_xor[i] = 0;
            }
        }else{
            if(ll(floor(a / pow(2, i))) % 2 == 1 && a % 2 == 0){
                a_xor[i] = 1;
            }else{
                a_xor[i] = 0;
            }
        }
    }

    tmp = b;

    ll num2 = 0;
    while(tmp){
        tmp /= 2;
        num2++;
    }

    ll b_xor[num2];
    rep(i, num2){
        if(i == 0){
            if(ll(floor((b - 1) / 2.0)) % 2 == 0){
                b_xor[i] = 1;
            }else{
                b_xor[i] = 0;
            }
        }else{
            if(ll(floor(b / pow(2, i))) % 2 == 1 && b % 2 == 0){
                b_xor[i] = 1;
            }else{
                b_xor[i] = 0;
            }
        }
    }

    ll ans[num2];
    rep(i, num2){
        if(i < num1){
            if(a_xor[i] != b_xor[i]){
                ans[i] = 1;
            }else{
                ans[i] = 0;
            }
        }else{
            if(b_xor[i] == 1)
                ans[i] = 1;
            else
                ans[i] = 0;
        }
    }

    ll sum = 0;
    rep(i, num2){
        sum += pow(2, i) * ans[i];
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
INF=1e9
mod=1e9+7
n=int(input())
lit=list(map(int,input().split()))
lit.sort()
ans=0
for i in range(n):
    ans=(ans+lit[i]*(n-i+1)%mod)%mod
for i in range(2*(n-1)):
    ans=ans*2%mod
ans=int(ans)
print(ans)


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

#define _BIGNUM_ 100000000

using namespace std;
typedef long long ll;

const ll mod = 1e9+7;

int main() {
  ll N, ans=0;
  cin >> N;
  vector<ll> h(N);
  for (ll j=0; j < N; ++j) {
    cin >> h[j];
  }
  ll j = 0;
  while (j < N) {
    if (h[j] == 0) {
      j++;
      continue;
    }
    if (j == N-1) {
      ans += h[j];
      break;
    }
    ll r, rmin = h[j];
    for (r = j+1; r < N && h[r] != 0; ++r) {
      rmin = min(rmin, h[r]);
    }
    for (ll k = j; k < r; ++k) {
      h[k] -= rmin;
    }
    ans += rmin;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
int main()
{
	string a;
	int cnt=0;
	cin>>a;
	for(int i=1;i<a.size();i++)
	{
		if(a[i]==a[i-1])
			cnt++;
		else
			cnt=0;
		if(cnt>1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = 1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	cin >>n;
	VI v(n);
	rep(i, n) cin >>v[i];
	sort(all(v));
	double ans = v[0];
	rep(i,  n-1){
		ans = (ans + v[i+1]) /2.0;
	}
	printf("%.8f\n", ans);
	return 0;
	
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES // for C++  
#include "bits/stdc++.h"
#define LL long long
#define NUM 1000000007

using namespace std;

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    vector<int> v(n);
    for (auto& i : v)
    {
        cin >> i;
    }
    sort(v.begin(), v.end());
    for (size_t i = 0; i < k; i++)
    {
        ans += v[v.size() - 1 - i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**5+10)
alp = 'abcdefghij'
N = int(input())
ans = []
def an(i,now,s):
    global ans
    if i == N:
        ans.append(s)
    else:
        for j in range(i+1):
            if j > now+1:
                continue
            an(i+1,max(j,now),s+alp[j])
        
an(0,0,'')
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 12664
import java.util.Scanner;

public class Main {

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

		int a = ac.nextInt();
		int b = ac.nextInt();
		
		if (a < b){
			System.out.println("a < b");
		}else if (a > b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}

	}

}



Measured memory_bytes: 26184
import Control.Monad
import Control.Applicative

solver :: [Int] -> Int -> [String]
solver [] _ = []
solver (x:xs) i
  | x == 0    = []
  | otherwise = ("Case " ++ show i ++ ": " ++ show x) : solver xs (i + 1)

main :: IO()
main = do
  contents <- map (read :: String -> Int) . lines <$> getContents
  mapM_ putStrLn $ solver contents 1

Measured memory_bytes: 5112
#include<bits/stdc++.h>
#define llint long long
using namespace std;
int main(){
	llint n,k;
	cin>>n>>k;
	llint arr[n];
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	llint low=1,high=1000000000;
	while(low!=high){
		llint mid=(low+high)/2;
		llint cnt=0;
		for(int i=0;i<n;i++){
			cnt+=(arr[i]+(mid-1))/mid-1;
		}
		//cout<<cnt<<endl;
		if(cnt>k)low=mid+1;
		else high=mid;
		//cout<<low<<' '<<high<<endl;
	}
	cout<<low<<endl;
}

Measured memory_bytes: 5084
#include<iostream>
using namespace std;
int main()
{
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  while(1)
  {
    c=c-b;
    if(c<=0)
      break;
    a=a-d;
    if(a<=0)
      break;
  }
  if(c<=0) cout<<"Yes";
  if(a<=0) cout<<"No";
  return 0;
}

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

int main(){
  int n;
  cin >> n;
  vector<pair<string,int>> pairs(n);
  vector<pair<string,int>> sub(n);
  string name;
  int score;
  
  for(int i=0;i<n;i++){
    cin >> name >> score;
    pairs[i] = make_pair(name,-1*score);
    sub[i] = make_pair(name,-1*score);
  }
  sort(pairs.begin(),pairs.end());
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      if(pairs[i].first==sub[j].first&&pairs[i].second==sub[j].second){
	cout << j+1 << endl;
	break;
      }
    }
  }
  return 0;
}


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

#define o(output) cout << output << endl;

using namespace std;

string s,t;
int a,b,c,d;

int main(){
  cin >> s>>t;
  reverse(t.begin(),t.end());
  if (s==t){
    o("YES")
  }else{
    o("NO")
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int x,y;
    cin>>x>>y;

    if(x==2){
        cout<<"No";
    }else if(x==4||x==6||x==9||x==11){
        if(y==4||y==6||y==9||y==11)cout<<"Yes";
        else cout<<"No";
    }else{
        if(y==1||y==3||y==5||y==7||y==8||y==10||y==12)cout<<"Yes";
        else cout<<"No";
    }
 
    return 0;
}

Measured memory_bytes: 256
#pragma region template
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD = 1e9+7, MAX = 1e18, larg = 1e5, INF = -1e18;
long long A, B, C, D, E, F, G, H, I, J, K, L, N, M, O, P, Q, R, S, T, U, V, W, x, y, z;
long long max_value = INF, max_index = -1;
long long min_value = MAX, min_index = -1;
typedef long long ll;
typedef pair<ll, ll> Pa;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> m;
#pragma endregion

m func[2000];
void funcinit(int N)
{
	func[0] = 1;
	for (int i = 1; i <= N; i++)
	{
		func[i] = func[i - 1] * i;
	}
}
m comb(m n, m r)
{
	if (n.a <= 0 || n.a < r.a)
	{
		return 0;
	}
	return func[n.a] / (func[r.a] * func[(n - r).a]);
}

int main()
{
	cin >> N >> K;
	funcinit(N);
	if (K == 1) {
		cout << 1;
		return 0;
	}
	for (int i = 1; i <= K; i++) {
		m redcount = N - K;
		cout << (comb(redcount + 1, i) * comb(K - 1, i - 1)).a << endl;
	}
}

Measured memory_bytes: 3672
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
 
const int maxn = 2e3 + 20, inf = 1e9+1;

int n, d, c;


int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int a;
		cin >> a;
		if (a % 4 == 0) c++;
		else if (a % 2 == 0) d++;
	}
	if (c * 2 + d >= n || c * 2 + 1 >= n ) return cout << "Yes" << endl, 0;
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(string, abcd);
  int A = abcd[0] - 48;
  int B = abcd[1] - 48;
  int C = abcd[2] - 48;
  int D = abcd[3] - 48;
  vector<char> op = {'+', '-'};
  each(op1, op) {
    each(op2, op) {
      each(op3, op) {
        int ans = A;
        if (op1 == '+') ans += B;
        else ans -= B;
        if (op2 == '+') ans += C;
        else ans -= C;
        if (op3 == '+') ans += D;
        else ans -= D;
        if (ans == 7) {
          cout << A << op1 << B << op2 << C << op3 << D << "=7" << endl;
          return;
        }
      }
    }
  }
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define all2(a, b) (a).begin(), (a).begin() + (b)
#define debug(vari) cerr << #vari << " = " << (vari) << endl;

int main()
{
    int q;
    cin >> q;
    int N = 100100;
    vector<int> is_prime(N, 1);
    is_prime[0] = 0;
    is_prime[1] = 0;
    rep(i, N)
    {
        if (!is_prime[i])
        {
            continue;
        }
        for (int j = i * 2; j < N; j += i)
        {
            is_prime[j] = 0;
        }
    }

    vector<int> is_2017(N, 0), cum(N + 1, 0);
    for (int i = 1; i < N; i += 2)
    {
        if (is_prime[i] && is_prime[(i + 1) / 2])
        {
            is_2017[i] = 1;
        }
    }
    rep(i, N)
    {
        cum[i + 1] += cum[i] + is_2017[i];
    }
    for (int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        cout << cum[r + 1] - cum[l] << endl;
    }

    return 0;
}

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

int main()
{
    string s;
    cin >> s;
    if(s=="Sunny") cout << "Cloudy" << endl;
    else if(s=="Cloudy") cout << "Rainy" << endl;
    else if(s=="Rainy") cout << "Sunny" << endl;
    return 0;
}

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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define In(vec) rep(i, n) cin>>vec[i];
#define ANS(s) cout << s << endl

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

typedef long long ll;
typedef vector<int> vi;

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

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
int round_int(int a, int b) { return (a + (b - 1)) / b; }


// 4,8方向に探索する際に用いる配列
//int dx[4] = { 0,  0, 1, -1 };
//int dy[4] = { 1, -1, 0,  0 };
int dx[8] = { 1, 0, -1,  0, 1, -1, -1,  1 };
int dy[8] = { 0, 1,  0, -1, 1,  1, -1, -1 };

constexpr auto MAX = 100010;

// ────────────────────────────────────────────────────

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

	map<char, int> a;

	for (int i = 0; i < 4; i++)
	{
		a[s[i]]++;
	}

	int cnt = 0;

	for (int i = 0; i < 4; i++)
	{
		cnt += a[s[i]];
	}

	if (cnt == 8) ANS("Yes");
	else ANS("No");
}

Measured memory_bytes: 256
"use strict";
    
const main = arg => {
    arg = arg.trim().split("\n");
    const N = parseInt(arg[0]);
    const S = arg.slice(1, N + 1).sort();
    
    let list = [];
    let streak = 0;
    let max = 0;
    
    for(let i=0; i<S.length; i++) {
        if(S[i] === S[parseInt(i) + 1]) {
            streak++;
        } else {
            streak = 0;
        }
        
        if(streak > max) {
            max = streak;
            list = [S[i]];
        } else if(streak === max) {
            list.push(S[i]);
        }
    }
    
    console.log(list.join("\n"));
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 49736
N = int(input())
A=[]
for _ in range(N):
    x,l = map(int,input().split())
    A.append([x-l,x+l])
A = sorted(A, key=lambda x:x[1])
now = -10**10
cnt = 0
for x in A:
    if now <= x[0]:
        now = x[1]
        cnt+=1
print(cnt)



Measured memory_bytes: 93324
use std::io;

fn main() {
    let mut input_line:String = String::new();
    io::stdin().read_line(&mut input_line).expect("err");

    let inputs: Vec<&str> = input_line.split_whitespace().collect();

    let a:i64 = inputs[0].parse::<i64>().unwrap();
    let b:i64 = inputs[2].parse::<i64>().unwrap();
    let operand = inputs[1];

    if operand == "+" {
        print!("{}",a+b);
    }else if operand == "-"{
        print!("{}",a-b);
    }
}


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

const char wall = '#';
vector<bool> used;
vector<vector<ll>> dist;
const int dx[4] = {0, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0};

vector<ll> A;
// vectorのリサイズ
// A.resize(N);

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a*b/gcd(a, b);}
vector<ll> history;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  ll ans = 0;
  ll n, k;
  vector<vector<ll>> telepo;
  cin >> n >> k;
  telepo.resize(n);
  used.resize(n, false);
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i]; 
    a[i]--;
  }
  rep(i, n) {
    telepo[i].push_back(a[i]);
  }
  ll index = 0;
  used[index] = true;
  history.push_back(0);
  ll point = 0;
  ll loopLen = 0;
  rep(i, n) {
    ll next = telepo[index][0];
    if (!used[next]) {
      used[next] = true;
      history.push_back(next);
    } else {
      //rep(i,history.size()) {
      //  printf("%lld%c", history[i], (i == history.size()-1)?'\n':' ');
      //}
      rep(j, int(history.size())) {
        if (history[j] == next) {
          point = j;
          loopLen = history.size()-j;
          break;
        }
      }
      //cout << "point: " << point << ", loopLen: " << loopLen<< endl;
      break;
    }
    index = next;
  }
  if (k - point < 0){
    cout << history[k]+1 << endl;
    return 0;
  }
  k -= point;
  ll ans_index = k % loopLen;
  //cout << "point: " << point << ", ans_index: " << ans_index<< endl;
  ans = history[point+ans_index]+1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 17800
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    long N;
    cin >> N;
    long sum=0;
    for (int i=1; i<=N; i++){
        if(i%3==0 && i%5==0){
            continue;
        }else if(i%3==0){
            continue;
        }else if(i%5==0){
            continue;
        }else{
            sum += i;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <cstdio>
#include <algorithm>

const int N = 15;
const int INF = 1 << 25;
int dist[N][N];
void chmin(int &a, int b) {
    a = std::min(a, b);
}

int main() {
    while(1) {
        int M; scanf("%d", &M);
        if(M == 0) break;

        for(int i=0; i<N; i++) {
            for(int j=0; j<N; j++) {
                if(i != j) dist[i][j] = INF;
            }
        }

        int T = 0;
        for(int i=0; i<M; i++) {
            int a, b, c; scanf("%d%d%d", &a, &b, &c);
            chmin(dist[a][b], c);
            chmin(dist[b][a], c);
            T = std::max({T, a+1, b+1});
        }

        for(int k=0; k<T; k++) {
            for(int i=0; i<T; i++) {
                for(int j=0; j<T; j++) {
                    chmin(dist[i][j], dist[i][k] + dist[k][j]);
                }
            }
        }

        int ans = INF, idx = 0;
        for(int i=0; i<T; i++) {
            int sum = 0;
            for(int k=0; k<T; k++) {
                sum += dist[i][k];
            }
            if(ans > sum) {
                ans = sum;
                idx = i;
            }
        }
        printf("%d %d\n", idx, ans);
    }
    return 0;
}


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

long double Plen(int x1,int x2,int y1, int y2){
    return pow((pow(x1-x2,2.0)+pow(y1-y2,2.0)),0.5);
}
long double kaijou(int N){
    if(N==1) return 1;
    return N*kaijou(N-1);
}
int main(){
    int N;
    int x[8];
    int y[8];
    cin >> N;
    for(int i=0;i<N;i++){
        cin >> x[i] >> y[i];
    }
    long double keiro = 0.0;
    for(int i=0;i<N-1;i++){
        for(int j=i+1;j<N;j++){
            keiro += Plen(x[i],x[j],y[i],y[j]);
        }
    }
    printf("%.10LF",2*keiro/N);
    return 0;
}

Measured memory_bytes: 384
H,W=map(int,input().split())
A=[list(map(int,input().split())) for h in range(H)]
x=1
w=0
ans=[]
for h in range(H):
  while 0<=w+x<W:
    if A[h][w]%2==1:
      ans.append([h+1,w+1,h+1,w+x+1])
      A[h][w+x]+=1
    w+=x
  if A[h][w]%2==1 and h+1<H:
    ans.append([h+1,w+1,h+1+1,w+1])
    A[h+1][w]+=1
  x*=-1
print(len(ans))
for _ in ans:
  print(*_)

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

#define F first
#define S second
#define mp make_pair
#define pb push_back        
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

const int N = 2e5 + 123;
const int inf = 1e9 + 1;
const int mod = 1e9 + 7;
const ll infl = 3e18 + 1;
const double pi = acos(-1.0);

inline void boost () {
    ios_base::sync_with_stdio (0);
    cin.tie (0); cout.tie (0);
}
inline void SmartRandom228 () {
	unsigned int key;
	asm ("rdtsc" : "=A"(key));
	srand (key);
}


int main () {
	boost ();
	ll a, b;
	cin >> a >> b;
	if (a <= 0 && 0 <= b) return cout << "Zero", 0;
	if (a > 0) return cout << "Positive", 0;
	if (abs (b - a + 1) % 2 == 1) return cout << "Negative", 0;
	cout << "Positive"; 

return 0;       
}
                                                          

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

std::string S;

int main(int argc, char **argv) {
    std::cin >> S;
    int num1 = 0;
    int num2 = 0;
    for (int i = 0; i < S.size(); i++) {
        if (S[i] == '0') {
            num1++;
        } else {
            num2++;
        }
    }
    std::cout << std::min(num1, num2) * 2 << std::endl;
    
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string st;
    cin>>st;
    
    set<char> s;
    s.insert('A'), s.insert('C'), s.insert('G'), s.insert('T');
    
    int cnt = 0;
    int ans = 0;
    for(int i=0; i<st.size(); i++)
    {
        if(s.find(st[i]) != s.end())
            ans = max(ans, 1 + cnt), cnt += 1;
        else
            cnt = 0;
    }
    cout<<ans;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int a[101][101]={0},b[101][101]={0};
	long c;
	int i,j,k;
	int n,m,l;
	
	
	scanf("%d %d %d",&n,&m,&l);
	
	for(i=0;i<n;i++){
		for(j=0;j<m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	
	for(i=0;i<m;i++){
		for(j=0;j<l;j++){
			scanf("%d",&b[i][j]);
		}
	}
	for(i=0;i<n;i++){
		for(j=0;j<l;j++){
			for(k=c=0;k<m;k++){
				c+=a[i][k]*b[k][j];
			}
			printf("%ld",c);
			if(j!=l-1){
				printf(" ");
			}
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 692