akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<queue>
#include<vector>

using namespace std;

vector<long long> lunlun;
queue<long long> lunlun_q;

int k;

int main() {
  scanf("%d", &k);
  for (int i = 1; i < 10; i++) {
    lunlun_q.push(i);
  }
  while(lunlun.size() < k) {
    long long x = lunlun_q.front();
    lunlun_q.pop();
    lunlun.push_back(x);
    switch (x % 10) {
      case 0:
        lunlun_q.push(x * 10);
        lunlun_q.push(x * 10 + 1);
        break;
      case 9:
        lunlun_q.push(x * 10 + 8);
        lunlun_q.push(x * 10 + 9);
        break;
      default:
        lunlun_q.push(x * 10 + x % 10 - 1);
        lunlun_q.push(x * 10 + x % 10);
        lunlun_q.push(x * 10 + x % 10 + 1);
        break;
    }
  }
  printf("%lld\n", lunlun[k - 1]);
}


Measured memory_bytes: 2548
#include <stdio.h>

int main(void)
{
    int i,n,a[100],ali=0,bob=0,j,tmp;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    for (i=0;i<n-1;i++)
    {
        for (j=0;j<n-1;j++) 
        {
            if (a[j+1]>a[j])
            {
                 tmp=a[j];
                 a[j]=a[j+1];
                 a[j+1]=tmp;
            }
        }
    }
    
    for(i=0;i<n;i++)
    {
        if(i%2==0)
        {
            ali=ali+a[i];
        }
        else if(!(i%2==0))
        {
            bob=bob+a[i];
        }

    }
    printf("%d\n",ali-bob);
    return 0;
}


Measured memory_bytes: 128
S = raw_input()
while len(S) > 0:
	if S.startswith("dream"):
		S = S[len("dream"):]
		if S.startswith("er"):
			if S.startswith("erase"):
				continue
			else:
				S = S[len("er"):]
		continue
	elif S.startswith("eraser"):
		S = S[len("eraser"):]
		continue
	elif S.startswith("erase"):
		S = S[len("erase"):]
		continue
	break
if len(S) > 0:
	print("NO")
else:
	print("YES")

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

using namespace std;

int main(){

  string c;
  cin >> c;

  if (c == "a" ||c == "i" ||c == "u" ||c == "e" ||c == "o") {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }

}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	int N;
	cin >> N;
	int arr[N] = {0};
	
	REP(i, 1, N){
		int a;
		cin >> a;
		++arr[a-1];
	}
	
	REP(i, 0, N){
		cout << arr[i] << "\n";
	}

}


Measured memory_bytes: 4416
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#include <sstream>
#include <bitset>
#define ALL(x) (x).begin(), (x).end()
#define sz(a) int(a.size())
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define chu(x) cout<<"["<<#x<<" "<<(x)<<"]"<<endl
#define du3(a,b,c) scanf("%d %d %d",&(a),&(b),&(c))
#define du2(a,b) scanf("%d %d",&(a),&(b))
#define du1(a) scanf("%d",&(a));
using namespace std;
typedef long long ll;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;}
ll powmod(ll a, ll b, ll MOD) { if (a == 0ll) {return 0ll;} a %= MOD; ll ans = 1; while (b) {if (b & 1) {ans = ans * a % MOD;} a = a * a % MOD; b >>= 1;} return ans;}
ll poww(ll a, ll b) { if (a == 0ll) {return 0ll;} ll ans = 1; while (b) {if (b & 1) {ans = ans * a ;} a = a * a ; b >>= 1;} return ans;}
void Pv(const vector<int> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%d", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
void Pvl(const vector<ll> &V) {int Len = sz(V); for (int i = 0; i < Len; ++i) {printf("%lld", V[i] ); if (i != Len - 1) {printf(" ");} else {printf("\n");}}}
inline long long readll() {long long tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
inline int readint() {int tmp = 0, fh = 1; char c = getchar(); while (c < '0' || c > '9') {if (c == '-') fh = -1; c = getchar();} while (c >= '0' && c <= '9') tmp = tmp * 10 + c - 48, c = getchar(); return tmp * fh;}
const int maxn = 1000010;
const int inf = 0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int n;
ll a[maxn];
int k;
const ll mod = 1e9 + 7;
ll fac[maxn], inv[maxn];
void pre()
{
    fac[0] = 1;
    for (int i = 1; i < maxn; i++) fac[i] = fac[i - 1] * i % mod;
    inv[maxn - 1] = powmod(fac[maxn - 1], mod - 2, mod);
    for (int i = maxn - 2; i >= 0; i--) inv[i] = inv[i + 1] * (i + 1) % mod;
}
ll C(int a, int b)
{
    if (b > a || b < 0) return 0;
    return fac[a] * inv[b] % mod * inv[a - b] % mod;
}
int main()
{
    //freopen("D:\\code\\text\\input.txt","r",stdin);
    //freopen("D:\\code\\text\\output.txt","w",stdout);
    pre();
    n = readint();
    k = readint();
    repd(i, 1, n)
    {
        a[i] = readll();
    }
    sort(a + 1, a + 1 + n);
    ll ans = 0ll;
    repd(i, k, n)
    {
        ans += C(i - 1, k - 1) * a[i] % mod;
        ans %= mod;
    }
    repd(i, 1, n - k + 1)
    {
        ans += -C(n - i, k - 1) * a[i] % mod + mod;
        ans %= mod;
    }
    printf("%lld\n", ans );
    return 0;
}




Measured memory_bytes: 18688
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <cmath>
#define LL long long
#define lowbit(x) ((x)&-(x))
using namespace std;
const int MAX = 300010;
struct segment
{
    int l,r;
    bool operator < (const segment&a)
    {
        return r-l < a.r-a.l;
    }
}seg[MAX];
int N,M,v[MAX],s[MAX<<2],lazy[MAX<<2];
void pushup(int rt)
{
    s[rt] = s[rt<<1] + s[rt<<1|1];
}
void pushdown(int rt,int l)
{
    if (lazy[rt])
    {
        s[rt<<1] += lazy[rt]*(l-(l>>1));
        s[rt<<1|1] += lazy[rt]*(l>>1);
        lazy[rt<<1] += lazy[rt];
        lazy[rt<<1|1] += lazy[rt];
        lazy[rt] = 0;
    }
}
void update(int L,int R,int p,int l,int r,int rt)
{
    if (L <= l && r <= R)
    {
        s[rt] += p*(r-l+1);
        lazy[rt] += p;
        return ;
    }
    pushdown(rt,r-l+1);
    int m = (l+r)>>1;
    if (L <= m) update(L,R,p,l,m,rt<<1);
    if (m < R) update(L,R,p,m+1,r,rt<<1|1);
    pushup(rt);
}
int query(int L,int R,int l,int r,int rt)
{
    if (L <= l && r <= R) return s[rt];
    pushdown(rt,r-l+1);
    int m = (l+r)>>1, sum = 0;
    if (L <= m) sum += query(L,R,l,m,rt<<1);
    if (m < R) sum += query(L,R,m+1,r,rt<<1|1);
    return sum;
}
int main(void)
{
    while (~scanf("%d%d",&N,&M))
    {
        for (int i=0;i<N;i++) scanf("%d%d",&seg[i].l,&seg[i].r);
        sort(seg,seg+N);
        //memset(s,0,sizeof(s));
        //memset(v,0,sizeof(v));
        int d, lim = M*sqrt(log2(M)/N);
        //printf("lim = %d\n",lim);
        for (d=1;d<=lim;d++)
        {
            for (int i=0;i<N;i++) if (seg[i].r/d > (seg[i].l-1)/d) v[d]++;
        }
        int i=0;
        for (;d<=M;d++)
        {
            for (;i<N && seg[i].r-seg[i].l+1<=d;i++)
            {
                update(seg[i].l,seg[i].r,1,1,M,1);
                //printf("l = %d, r = %d\n",seg[i].l,seg[i].r);
                //for (int j=1;j<=M;j++) printf("%d ",query(j,j,1,M,1)); puts("");
            }
            for (int j=1;j*d<=M;j++) v[d] += query(j*d,j*d,1,M,1);
            v[d] += N-i;
        }
        for (int i=1;i<=M;i++) printf("%d\n",v[i]);
    }
    return 0;
}


Measured memory_bytes: 5632
package main

import (
	"fmt"
)

func main() {
	var K int
	var N string
	fmt.Scanf("%d", &K)
	fmt.Scanf("%s", &N)

	if len(N) > K {
		fmt.Print(N[0:K])
		fmt.Println("...")
	} else {
		fmt.Println(N)
	}
}


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

int main()
{
    int a = 0;
    string S, T;
    cin >> S >> T;
    size_t size = S.length();

    for (int i = 0; i < size; i++)
    {
        if (S.at(i) != T.at(i))
        {
            a++;
        }
    }

    if (a == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main(void){

	int A, B, C, D, E, F;
	cin >> A >> B >> C >> D >> E >> F;

	cout << A + B + C + D + E + F - min(A, min(B, min(C, D))) - min(E, F) << endl;

	return 0;
}

Measured memory_bytes: 1164
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; ++i)

int main(){
  int N, K;
  cin >> N >> K;
  vector<int> v(N);
  REP(i,N) cin >> v[i];
  partial_sort(v.begin(), v.begin() + K, v.end(), greater<int>());

  int sum = accumulate(v.begin(), v.begin() + K, 0);
  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
const double PI =acos(-1);
double a2(double a,double b){
   return atan2(a,b) *180/PI;
}
int main() {
  double a,b,x,n,h,s;
  cin>> a >> b>>x;
  n=a*a*b;
  if(x>=n/2){
      h=(n-x)/(a*a)*2;
      s= a2(h,a);
  }else{
      h=x/(a*b)*2;
      s= 90 - a2(h,b);
  }
  cout << setprecision(9) << s;
  return 0;
}

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

int main(void){
	int N,p;
	cin>>N;
	int add[N+1];
	rep1(i,N) cin>>p, add[p]=i;
	rep1(i,N-1)cout<<i*N<<" ";
	cout<<N*N<<endl;
	rep1(i,N-1)cout<<N*(N-i)+add[i]<<" ";
	cout<<add[N]<<endl;
	return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define int long long 
using namespace std;
signed main()
{
	int h,a,x,temp=0;
	cin>>h>>a;
	while(a--)
	{
		cin>>x;
		temp=temp+x;
	}
	if(temp>=h)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

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

bool isPalindrome(string s){
	int i = 0;
	int j = s.size() - 1;

	while( i < j){
		if(s[i] == s[j]){
			i++;
			j--;
		}
		else{
			return false;
		}
	}

	return true;
}

int main(){
	string s;
	cin >> s;
	
	int s1Index = ((s.size() - 1) / 2);
	int s2Index = (s.size() + 3) / 2;
	string s1 = s.substr(0 , s1Index);
	string s2 = s.substr(s2Index - 1, s.size());
	// cout << s2 << endl;
	if(isPalindrome(s) && isPalindrome(s1) && isPalindrome(s2)){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}

	return 0;
}

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

int main(void){
  int x1, x2, x3, x4, x5;

  cin >> x1 >> x2 >> x3 >> x4 >> x5;

  if(x1 == 0){
    cout << "1" << endl;
  }
  if(x2 == 0){
    cout << "2" << endl;
  }
  if(x3 == 0){
    cout << "3" << endl;
  }
  if(x4 == 0){
    cout << "4" << endl;
  }
  if(x5 == 0){
    cout << "5" << endl;
  }
}

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


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

  int n;
  cin >> n;

  cout <<(n+1)/2 << endl;
  
  
  return 0;
    

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    int t[n];
    int i;
    int sum=0;
    for(i=0;i<n;i++){
      cin >> t[i];
      sum+=t[i];
    }
    int m,p,x;
    cin >> m;
    for(i=0;i<m;i++){
      cin >> p >> x;
      cout << sum-t[p-1]+x<<endl;
    }
    return 0;
}


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

#define X first
#define Y second
#define N 100010
#define M 400010
typedef long long ll;
typedef pair<int,int> pii;
const int Mod=1000000007;

int n;
int cnt[N];

int main()
{
	//freopen("in.in","r",stdin);
	//freopen("out.out","w",stdout);
	
	scanf("%d",&n); int x,a=0,b=0;
	for (int i=1;i<=n;i++) scanf("%d",&x),cnt[x]++;
	for (int i=1;i<N;i++) 
	{
		if (cnt[i]&1) a++;
		else if (cnt[i]) b++;
	}
	if (b<=1) cout<<a<<endl;
	else if (b&1) cout<<a+b-1<<endl;
	else cout<<a+b<<endl;
	return 0;
}


Measured memory_bytes: 640
a, b, c, x, y = map(int, input().split())

if 0.5 * a + 0.5 * b <= c:
    print(a * x + b * y)
else:
    if x == y:
        print(c * 2 * x)
    elif x > y and a <= c * 2:
        print(c * 2 * y + a * (x-y))
    elif x > y and a * 2 > c:
        print(c * 2 * x )
    elif x < y and b <= c * 2:
        print(c * 2 * x + b * (y-x))
    elif x < y and b * 2 > c:
        print(c * 2 * y )
    

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

using namespace std;

int main(){
	long long int n;
	cin >> n;
	long long int arr[n], store[n];
	for(long long int i=0;i<n;++i)cin >> arr[i];
	memset(store, 0, sizeof(store));
	long long int maxi = arr[0];
	for(long long int i=1;i<n;++i){	
		if(arr[i] < maxi)store[i] = maxi - arr[i];
		else maxi = arr[i];
	}
	long long int sum = 0;
	for(long long int i=0;i<n;++i)sum += store[i];
	cout << sum;
}


Measured memory_bytes: 6652
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define rp(a) while(a--)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
int O[6]={60,80,100,120,140,160};
int W[6]={2,5,10,15,20,25};
int R[6]={600,800,1000,1200,1400,1600};
int main(){
	int n;
	while(cin>>n,n){
		int sum=0;
		rep(i,n){
			int a,b,c,w;
			cin>>a>>b>>c>>w;
			int o=a+b+c;
			rep(i,6)if(o<=O[i]&&w<=W[i]){sum+=R[i];break;}
		}
		cout<<sum<<endl;
	}
}

Measured memory_bytes: 1160
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> ppl;
#define ain(a,n) for(ll i=0;i<(n);++i)  cin>>(a)[i];
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define mp make_pair
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
// #define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
#define BLOCK 555
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 200005;
const long double epsilon = 1e-9;
inline ll myceil(ll a, ll b) { if (a % b == 0)  return (a / b); return (a / b + 1);}
inline ll binlen(ll n) {
    ll c = 0;
    while (n > 0)
        ++c , n /= 2;
    return c;
}
ll binexp(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
ll modinvfermat(ll a, ll m)
{
    return binexp(a, m - 2, m);
}
void task(bool flag)
{
    if (flag)
        cout << "YES\n";
    else
        cout << "NO\n";
}
ll lcm(ll a, ll b)
{
    return ((1LL * a * b) / (__gcd(a, b)));
}



signed main() {
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "r", stdin);
//     freopen("output.txt", "w", stdout);
// #endif
    fast
    ll n;
    cin >> n;
    ll ans = 0, len = 0;
    loop(i, n)
    {
        ll a, b;
        cin >> a >> b;
        if (a == b)
        {
            ++len;
            ans = max(ans, len);
        }
        else
            len = 0;
    }
    if (ans >= 3)
        cout << "Yes";
    else
        cout << "No";



// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
    return 0;
}


Measured memory_bytes: 3652
#include "bits/stdc++.h"
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<string>S(N);
	vector<int>T(N);
	string X;
	vector<pair<string, int>>A(N);
	int time = 0;
	for (int i = 0; i < N; i++) {
		cin >> S.at(i) >> T.at(i);
		time += T.at(i);
	}
	for (int i = 0; i < N; i++) {
		if (i == 0) {
			A.at(i) = make_pair(S.at(i), time - T.at(i));
		}
		else {
			A.at(i) = make_pair(S.at(i), A.at(i - 1).second - T.at(i));
		}
	}
	cin >> X;
	for (int i = 0; i < N; i++) {
		if (A.at(i).first == X) {
			cout << A.at(i).second << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

long double l;

int main() {
    fastio();

    cin >> l;

    long double d = l / 3.0;

    cout << setprecision(20) << d * d * d << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
template <int mod>
struct ModInt {
  int val;
  int trim(int x) const { return x >= mod ? x - mod : x < 0 ? x + mod : x; }
  ModInt(int v = 0) : val(trim(v % mod)) {}
  ModInt(const ModInt &v) : val(v.val) {}
  ModInt(long long v) : val(trim(v % mod)) {}
  ModInt &operator=(int v) { return val = trim(v % mod), *this; }
  ModInt &operator=(const ModInt &oth) { return val = oth.val, *this; }
  ModInt operator+(const ModInt &oth) const { return trim(val + oth.val); }
  ModInt operator-(const ModInt &oth) const { return trim(val - oth.val); }
  ModInt operator*(const ModInt &oth) const { return 1LL * val * oth.val % mod; }
  ModInt operator/(const ModInt &oth) const {
    function<int(int, int, int, int)> modinv = [&](int a, int b, int x, int y) {
      if (b == 0) return trim(x);
      return modinv(b, a - a / b * b, y, x - a / b * y);
    };
    return *this * modinv(oth.val, mod, 1, 0);
  }
  bool operator==(const ModInt &oth) const { return val == oth.val; }
  ModInt operator-() const { return trim(mod - val); }
  template<typename T> ModInt pow(T pw) {
    bool sgn = false;
    if (pw < 0) pw = -pw, sgn = true;
    ModInt ans = 1;
    for (ModInt cur = val; pw; pw >>= 1, cur = cur * cur) {
      if (pw&1) ans = ans * cur;
    }
    return sgn ? ModInt{1} / ans : ans;
  }
};
 
const int MOD = 1e9 + 7;
 
vector<ModInt<MOD>> dp, fac = {1};
vector<pair<int, int>> A;
 
 
 
ModInt<MOD> C(int a, int b) {
  return fac[a] / (fac[b] * fac[a - b]);
}
 
ModInt<MOD> ways(pair<int, int> A, pair<int, int> B) {
  int x, y; tie(x, y) = A;
  int z, w; tie(z, w) = B;
  int dx = z - x, dy = w - y;
  if (dx < 0 or dy < 0) return 0;
  return C(dx + dy, dx);
}
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
  for (int i = 1; i < (1<<20); ++i) fac.emplace_back(fac.back() * i);
  int h, w, n; cin >> h >> w >> n;
  for (int i = 0; i < n; ++i) {
    int u, v; cin >> u >> v;
    --u, --v;
    A.emplace_back(u, v);
  }
  sort(A.begin(), A.end());
  for (int i = 0; i < n; ++i) {
    dp.emplace_back(ways({0, 0}, A[i]));
    for (int j = 0; j < i; ++j) {
      dp[i] = dp[i] - dp[j] * ways(A[j], A[i]);
    }
  }
  ModInt<MOD> ans{ways({0, 0}, {h - 1, w - 1})};
  for (int i = 0; i < n; ++i) ans = ans - dp[i] * ways(A[i], {h - 1, w - 1});
  cout << ans.val << '\n';
}


Measured memory_bytes: 6384
s = input()

n = len(s)
flag = True
for i in range(n):
    if i % 2 == 0:
        if s[i] == 'R' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            flag = False
    elif i % 2 == 1:
        if s[i] == 'L' or s[i] == 'U' or s[i] == 'D':
            continue
        else:
            flag = False

print('Yes' if flag else 'No')


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include<climits>
using namespace std;
const int INF=1e9+5;
int main()
{
  ios_base::sync_with_stdio(false);cin.tie(NULL);
	int n, c, b, k ; cin >> n >> k;
  vector<int> a(n);
	for (int& e : a)cin >> e;
	vector<int> dp(n, INF);
	dp[0] = 0;
	for (int i = 0; i < n; ++i) {
		for (int e = i + 1; e <= i + k; ++e) {
			if (e < n)
				if ((dp[i] + abs(a[e] - a[i])) < dp[e])
					dp[e] = dp[i] + abs(a[e] - a[i]);
		}
	}
	cout << dp[n - 1] << '\n';
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
  static Scanner sc = new Scanner(System.in);

  public static void main(String[] args) {
    int N = sc.nextInt();
    int[] A = new int[N];
    int[] B = new int[N];
    long SA = 0;
    long SB = 0;
    for (int i = 0; i < N; i++) {
      A[i] = sc.nextInt();
      SA += A[i];
    }
    for (int i = 0; i < N; i++) {
      B[i] = sc.nextInt();
      SB += B[i];
    }
    long BC = 0;
    long AC = 0;
    for (int i = 0; i < N; i++) {
      if (A[i] < B[i]) {
        AC += (B[i] - A[i]) / 2;
      } else {
        BC += A[i] - B[i];
      }
    }
    System.out.println(AC >= BC ? "Yes" : "No");
  }

}


Measured memory_bytes: 43336
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    string s; cin>>s;
    if(s[2]==s[3] && s[4]==s[5]) cout<<"Yes\n";
    else cout<<"No\n";
}

signed main() { 
    IO();
    
    int t=1;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=2e7+1000;
typedef long long ll;
int cnt=0;
bool vis[maxn];
int pri[maxn];
int f[maxn];
int p[maxn];
ll sum[maxn];
void init(){
    for(int i=1;i<maxn;i++)f[i]=1;
    cnt=0;
    for(int i=2;i<maxn;i++){
        if(vis[i]==0){
            pri[++cnt]=i;
            f[i]=2;
        }
        for(int j=1;j<=cnt&&pri[j]*i<maxn;j++){
            vis[i*pri[j]]=1;
            if(i%pri[j]==0){
                f[i*pri[j]]=f[i]/2;
                break;
            }
            f[i*pri[j]]=f[i]*2;
        }
    }
    int k=0;
    for(int i=1;i<=cnt;i++){
        if(pri[i]*pri[i]*pri[i]>=maxn) break;
        p[++k]=pri[i]*pri[i]*pri[i];
    }
    for(int i=1;i<maxn;i++){
        for(int j=1;j<=k&&p[j]*i<maxn;j++){
            f[i*p[j]]=0;
            if(i%p[j]==0){
                break;
            }
        }
    }
    for(int i=1;i<maxn;i++){
        sum[i]=sum[i-1]+f[i];
    }
}
int main(){
	int k;
	cin>>k;
	int even;
	int odd;
	if(k%2){
        even=k/2; odd=even+1;
	}
	else{
        even=k/2; odd=even;
	}
	cout<<even*odd<<endl;
	return 0;
}


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

int main() {
  long n,m,ans=1;
  cin >> n >> m;
  vector<long> a(m),b(m);
  vector<bool> ta(n,false);
  vector<set<long>> vs(n,set<long>());
  for(long i=0;i<m;i++) {
    cin >> a[i] >> b[i];
    vs[a[i]-1].insert(b[i]-1);
    vs[b[i]-1].insert(a[i]-1);
  }
  for(long i=0;i<n;i++) {
    if(ta[i]) continue;
    queue<long> q;
    long aaa=0;
    q.push(i);
    ta[i]=true;
    while(q.size()!=0) {
      aaa++;
      for(auto itr=vs[q.front()].begin();itr!=vs[q.front()].end();itr++) {
        if(ta[*itr]) continue;
        ta[*itr]=true;
        q.push(*itr);
      }
      q.pop();
    }
    ans=max(aaa,ans);
  }
  cout << ans << endl;
}

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

int main(void) {
    int N;
    int64_t a;
    int64_t sum = 0;
    cin >> N;
    for(int i=0;i<N;i++) {
        cin >> a;
        sum += a;
    }

    cout << sum - N << endl;
    return 0;
}


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

typedef long long ll;

int main(){
  ll n;  cin >> n;
  vector<ll> a(n), ans(n);
  ll sum = 0;
  for(int i=0; i<n; i++)  {
    cin >> a[i];
    sum += a[i];
  }
  for(int i=1; i<n; i+=2){
    sum -= a[i]*2;
  }
  ans[0] = sum;
  for(int i=1; i<n; i++){
    ans[i] = a[i-1]*2 - ans[i-1];
  }
  for(int i=0; i<n; i++){
    cout << ans[i] << " ";
  }
  cout << endl;
  return 0;
}


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

int main(){
  int n,k;
  cin >> n >> k;
  vector<int> d(n);
  rep(i,k){
    int m;
    cin >> m;
    rep(j,m){
      int a;
      cin >> a;
      d.at(a-1) = 1;
    }
  }
  int ans = 0;
  rep(i,n) if(d[i] == 0) ans++;
  cout << ans << endl;



}


Measured memory_bytes: 3584
from itertools import combinations
N = int(input())
names = {}
for _ in range(N):
    S = input()
    if S[0] in 'MARCH':
        if S[0] not in names:
            names[S[0]] = 1
        else:
            names[S[0]] += 1
comb = len(names)
if comb <= 2:
    print(0)
elif comb == 3:
    ret = 1
    for v in names.values():
        ret *= v
    print(ret)
elif comb == 4:
    tmp = 1
    for v in names.values():
        tmp *= v
    ret = 0
    for v in names.values():
        ret += tmp // v
    print(ret)
else:
    ret = 0
    for comb in combinations('MARCH', 3):
        tmp = 1
        for c in comb:
            tmp *= names[c]
        ret += tmp
    print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define irep(it, stl) for (auto it = stl.begin(); it != stl.end(); it++)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define mes(a) cout << (a) << endl
#define dmes(a, b) cout << (a) << " " << (b) << endl
#define re0 return 0
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define rSort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;


signed main(void) 
{
    ll n;
    cin >>n;
    vll a(n+1), b(n);
    rep(i, n+1) cin >>a[i];
    rep(i, n) cin >>b[i];
    
    ll r = 0;
    rep(i,n) {
        r += min(a[i], b[i]);
        b[i] = max((ll)0, b[i] - a[i]);
        if (b[i] == 0) continue;
        r += min(a[i+1], b[i]);
        a[i+1] = max((ll)0, a[i+1] - b[i]);
    }
    mes (r);
    
    
   
}


Measured memory_bytes: 4844
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
  int h,w,k;
  cin >> h >> w >> k;
  vector<vector<int>> a(w,vector<int>(h));
  rep(i,h){
    string s;
    cin >> s;
    rep(j,w){
      if (s[j]=='0') a[j][i]=0;
      else a[j][i]=1;
    }
  }
  int ans=inf;
  rep(i,pow(2,h-1)){
    vector<int> e(h-1);
    int u=i,p=0;
    rep(j,h-1){
      if (u%2==0) {
        e[j]=1;
        p++;
      }
      else e[j]=0;
      u/=2;
    }
    int o=p;
    vector<int> b(p+1,0);
    rep(j,w){
      int r=0;
      rep(ii,h){
        if (a[j][ii]==1) b[r]++;
        if (e[ii]==1) r++;
      }
      bool t=false;
      rep(ii,p+1){
        if (b[ii]>k) t=true;
      }
      if (t){
        o++;
        rep(ii,p+1) b[ii]=0;
        j--;
      }
      if (o>=w+h-2) break;
    }
    ans=min(ans,o);
  }
  cout << ans << endl;
}


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

long long n, x, y;

string solve();

int main() {
  while(1) {
    cin >> n >> x >> y;
    if(n + x + y == 0) break;
    cout << solve() << endl;
  }
  return 0;
}

string solve() {
  string res;
  --y;
  --x;
  for(int i = 0; i < n; ++i) {
    if((y % 2) ^ (x % 2))
      res += 'R';
    else
      res += 'L';
    if((1LL << (n - i - 1)) > x)
      x = (1LL << (n - i)) - x - 1;
    y >>= 1;
    x %= 1LL << (n - i - 1);
  }
  reverse(res.begin(), res.end());
  return res;
}


Measured memory_bytes: 3140
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

	int N;
	cin >> N;

	vector<int> H(N, 0);

	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}

	for (int i = 1; i < N; i++)
	{
		if (H[i] > H[i - 1])
		{
			H[i]--;
		}
	}

	bool check = true;
	for (int i = 0; i < N - 1; i++)
	{
		if (H[i] > H[i + 1])
		{
			check = false;
			break;
		}
	}

	if (check)
	{
		cout << "Yes";
	}
	else
	{
		cout << "No";
	}

	return 0;
}


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

#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PI acos(-1.0)
#define sq(n) (n)*(n)

using namespace std;
typedef long long ll;

int main() {
    FAST;


            ll n,c=0;
    ll a[101];
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        cin>>a[i];
    }
    for(ll i=0;i<n;i=i+2)
    {
        if(a[i]%2!=0)c++;
    }
    cout<<c<<endl;


    return 0;
}




Measured memory_bytes: 3612
#include <stdio.h>

int cnt;

void insertionSort(int A[], int n, int g)
{
    int i;
    for (i = g; i < n; i++) {
        int v, j;
        v = A[i];
        j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    int i, m = 0;
    int G[10] = {262913, 65921, 16577, 4193, 1073, 281, 77, 23, 8, 1};

    for (i = 0; i < 10; i++) {
        if (G[i] <= n) {
            m++;
            insertionSort(A, n, G[i]);
        }
    }

    printf("%d\n", m);
    
    i = 10 - m;

    printf("%d", G[i]);
    for (i++; i < 10; i++) printf(" %d", G[i]);
    putchar('\n');
}

int main(void)
{
    int n;
    scanf("%d", &n);

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

    shellSort(A, n);

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

    for (i = 0; i < n; i++)
        printf("%d\n", A[i]);

    return 0;
}

Measured memory_bytes: 4508
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

struct UnionFind {
  const int n;
  V<> t; // root ? -sz : par
  UnionFind(int n) : n(n), t(n, -1) {}
  int find(int v) { return t[v] < 0 ? v : t[v] = find(t[v]); }
  void unite(int u, int v) {
    if ((u = find(u)) == (v = find(v))) return;
    if (-t[u] < -t[v]) swap(u, v);
    t[u] += t[v];
    t[v] = u;
  }
  bool same(int u, int v) { return find(u) == find(v); }
  int size(int v) { return -t[find(v)]; }
};

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  int n, k;
  while (cin >> n >> k, n) {
    VV<> a(n, V<>(n));
    for (int j = 0; j < n; ++j) for (int i = 0; i <= j; ++i) {
      cin >> a[i][j];
    }
    auto in = [&](int i, int j) -> bool { return 0 <= i and i <= j and j < n; };
    auto _ = [&](int i, int j) -> int { return i * n + j; };
    auto fn = [&]() -> int {
      UnionFind uf(101);
      auto chk = [](int x, int y) -> bool {
        if (!x or !y) return true;
        return x == y;
      };
      for (int j = 0; j < n; ++j) for (int i = 0; i <= j; ++i) {
        if (in(i, j + 1) and chk(a[i][j], a[i][j + 1])) uf.unite(_(i, j), _(i, j + 1));
        if (in(i + 1, j) and chk(a[i][j], a[i + 1][j])) uf.unite(_(i, j), _(i + 1, j));
        if (in(i + 1, j + 1) and chk(a[i][j], a[i + 1][j + 1])) uf.unite(_(i, j), _(i + 1, j + 1));
        if (!a[i][j]) uf.unite(_(i, j), 100);
      }
      int res = 0;
      for (int j = 0; j < n; ++j) for (int i = 0; i <= j; ++i) if (a[i][j] and uf.find(_(i, j)) == _(i, j)) {
        if (uf.same(_(i, j), 100)) continue;
        if (a[i][j] != k) res += uf.size(_(i, j));
        else res -= uf.size(_(i, j));
      }
      return res;
    };
    int res = -1e9;
    for (int j = 0; j < n; ++j) for (int i = 0; i <= j; ++i) if (!a[i][j]) {
      a[i][j] = k;
      res = max(res, fn());
      a[i][j] = 0;
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
ll a, b, c, k;
int cnt = 0;
int main(){
scanf("%lld %lld %lld %lld", &a, &b, &c, &k);

//k % 2 ? b - a : a - b

if(k % 2 == 0){
	cout << a - b;
}
else{
	cout << b - a;
}
return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

long long modpow(long long a, long long b){ 
  long long r = 1LL;
  while(b){
    if(b & 1LL)r *= a;
    if(r >= MOD)r %= MOD;
    a *= a;
    if(a >= MOD)a %= MOD;
    b >>= 1LL;
  }
  return r%MOD;
}

ll f(ll n, ll a){
  ll ret = 1;
  ll n1 = n;
  rep(i,0,a){
    ret *= n1;
    ret %= MOD;
    n1--;
  }
  rep(i,1,a+1){
    ret *= modpow(i,MOD-2);
    ret %= MOD;
  }
  return ret;
}

int main(){
  ll n,a,b;
  cin>>n>>a>>b;
  ll ans = modpow(2,n);
  ans %= MOD;
  ans += MOD;
  ans--;
  ans %= MOD;
  ans += MOD;
  ans -= f(n,a);
  ans %= MOD;
  ans += MOD;
  ans -= f(n,b);
  ans %=MOD;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using static System.Math;

namespace CSharpSpiral {
	class Program {
		static void Main(string[] args) {
			var sw = new StreamWriter(Console.OpenStandardOutput()) {
				AutoFlush =
#if DEBUG
			true
#else
			false
#endif
			};
			Console.SetOut(sw);
			new Program().Solve(new ConsoleInput(
#if DEBUG
			new StreamReader("../../../inputData.txt")
#else
			Console.In
#endif
			, ' '));
			Console.Out.Flush();
		}
		public void Solve(ConsoleInput cin) {
			var N = cin.ReadInt;
			var S = cin.ReadLine.ToCharArray();
			var Rs = ER(0,N).Count(i=>S[i]=='R');
			var Bs = ER(0,N).Count(i=>S[i]=='B');
			var Gs = ER(0,N).Count(i=>S[i]=='G');
			var Res = 0L;
			Res =(long) Rs * Gs * Bs;
			for(int i = 0; i < N; i++) {
				for(int j = 1; i + 2 * j < N; j++) {
					if(different(S[i], S[i + j], S[i + 2 * j])) Res--;
				}
			}
			Console.WriteLine(Res);
		}
		public IEnumerable<int> ER(int start, int count) => Enumerable.Range(start, count);
		public bool different(char a, char b, char c) => a != b && b != c && c != a;

	}
	static class ExtendClass {
		public static void Swap<T>(this T[] A, int x, int y) {
			var tmp = A[x];
			A[x] = A[y];
			A[y] = tmp;
		}
		public static string Join<T>(this IEnumerable<T> X, string separator = " ") => string.Join(separator, X);
	}
	class ConsoleInput {
		private readonly TextReader _stream;
		private readonly char _separator = ' ';
		private readonly Queue<string> inputStream;
		public ConsoleInput(TextReader stream, char separator = ' ') {
			this._separator = separator;
			this._stream = stream;
			inputStream = new Queue<string>();
		}
		public string Read {
			get {
				if(inputStream.Count != 0) return inputStream.Dequeue();
				string[] tmp = _stream.ReadLine().Split(_separator);
				for(int i = 0; i < tmp.Length; ++i)
					inputStream.Enqueue(tmp[i]);
				return inputStream.Dequeue();
			}
		}
		public string ReadLine { get { return _stream.ReadLine(); } }
		public int ReadInt { get { return int.Parse(Read); } }
		public long ReadLong { get { return long.Parse(Read); } }
		public double ReadDouble { get { return double.Parse(Read); } }
		public string[] ReadStrArray(long N) {
			var ret = new string[N];
			for(long i = 0; i < N; ++i)
				ret[i] = Read;
			return ret;
		}
		public int[] ReadIntArray(long N) { var ret = new int[N]; for(long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
		public long[] ReadLongArray(long N) { var ret = new long[N]; for(long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
		public double[] ReadDoubleArray(long N) { var ret = new double[N]; for(long i = 0; i < N; ++i) ret[i] = ReadDouble; return ret; }
		public bool isEOF {
			get { return _stream.Peek() == -1; }
		}
	}

}


Measured memory_bytes: 28380
import sys
lines = [s.rstrip("\n") for s in sys.stdin.readlines()]
n, l = [int(num) for num in lines.pop(0).split(" ")]
lower = l
upper = l + n - 1
sum = (lower + upper) * n // 2
if lower * upper > 0: # 同じ符号の場合
    if abs(lower) <= abs(upper):
        sum -= lower
    else:
        sum -= upper
print(sum)


Measured memory_bytes: 9100
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n; cin>>n;
    if(n==1) cout<<"Hello World"<<endl;
    else{
        int a,b; cin>>a>>b;
        cout<<a+b<<endl;
    }
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int a[]= new int[n];
		for(int i=0;i<n;i++) {
			a[i]=scan.nextInt();
		}
		scan.close();
		int cnt=0;
		int check=0;
		while(true) {
			for(int i=0;i<n;i++) {
				if(a[i]%2!=0) {
					check=1;
					break;
				}
			}
			if(check==1)break;
			else {
				cnt++;
				for(int i=0;i<n;i++) {
					a[i]/=2;
				}
			}
		}
		System.out.println(cnt);
	}

}

Measured memory_bytes: 21844
(defconstant *n* (read))
(defconstant *m* (read))
(defconstant *x* (read))
(defconstant *y* (read))
(defparameter *xs* (loop repeat *n* collect (read)))
(defparameter *ys* (loop repeat *m* collect (read)))
(setf *xs* (cons *x* *xs*))
(setf *ys* (cons *y* *ys*))
(princ (if (< (reduce #'max *xs*) (reduce #'min *ys*)) "No War" "War"))


Measured memory_bytes: 9184
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(){
    int N,K,ans=0;
    scanf("%d" "%d",&N,&K);
    int h[100010];
    for(int i = 0; i < N; i++){
        scanf("%d",&h[i]);
        if(h[i]>=K)ans++;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h> 
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vl;
typedef pair<ll,ll> pll;
typedef vector<char> vc;
typedef map<long long,long long> mpi;
#define vbi vector<bool> 
#define mod 1000000007
#define all(x) x.begin(),x.end()
#define alr(x) x.rbegin(),x.rend()
#define mp make_pair
#define pb push_back
#define sd second
#define ft first
#define endl '\n'
#define cnl cout<<endl;
#define frr(i,b) for(ll i=0; i<b;i++)
#define fb(i,b) for(ll i=b-1; i>=0; i--)
#define pi  3.141592653589793238
#define ms(x,v) memset(x,v,sizeof(x))
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define deb(x) cout<<#x<<" = "<<x<<"\n";
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
const int N = 2e5 + 5;
ll i,j,k;
void solve(){
  ll n; cin>>n;
  if(n%2){
    cout<<0<<endl;
    return ; 

  }
  n/=2;
   ll ans=0;
   ll five=5;
   while(n/five!=0){
     ans=ans+(n/five);
     five=five*5;
   }
   cout<<ans<<endl;


 return ; 
 
}
signed main(){
  
 //CASET
         solve();
  

 
    return 0;
}



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

int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    ll ans = 0;
    int x = a[0];
    int i = 0;
    while(1){
        if(x%2==0){
            x/=2;
            ans++;
        }else{
            if(i==n-1)break;
            x=a[i+1];
            i++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  ll ans=1;
  vector<int> v(26,1);
  r(i,s.length()){
    v.at(s.at(i)-'a')++;
  }
  r(i,26){
    ans*=v.at(i);
    ans%=1000000007;
  }
  cout << ans-1<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
const int INF = 100000000;
const int MAX_N = 100;
typedef pair<int , int> P;
typedef long long ll;
 
int main () {
  int N, ans;
  ans = 0;
  cin >> N;
  string x;
  set<string>st;
  for (int i = 0; i < N; ++i) {
    cin >> x;
    st.insert(x);
  }
  cout << st.size() << "\n";
  return 0;
}

Measured memory_bytes: 19208
#include <stdio.h>
int main(void){
	int D,L,p,o;
	scanf("%d %d",&D,&L);
	p=D/L;
	o=D%L;
	if(o==0)
	printf("%d\n",p);
	else
	printf("%d\n",o+p);
	return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
    float a,x,b,y,c,f,e,d,y2;
    while(cin>>a>>b>>c>>d>>e>>f){y2=0;y=0;
        
        y2=b*e*y;
              x=(c*e-f*b-y2*2)/(a*e-d*b);
                y=(c-(a*x))/b;
        if(x==0){x=0;}
        
        printf("%.3f %.3f",x,y);cout<<endl;}
    
    return 0;
}

Measured memory_bytes: 3216
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int i = 0; i < N; i++){
			int K = sc.nextInt();
			int P = sc.nextInt();
			if(K < P)
				System.out.println(K);
			else if(K%P == 0)
				System.out.println(P);
			else
				System.out.println(K%P);
		}
	}
}

Measured memory_bytes: 20352
#include <iostream>
using namespace std;
int main()
{
	int inp,f=0,s=0;
	for(int i=0 ; i<3 ; i++){
		cin>>inp;
		if(inp==5) f++;
		else if(inp==7) s++;
	}
	if(f==2 && s==1) cout<<"YES\n";
	else cout<<"NO\n";
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <deque>

using namespace std;

const int MOD = 1e9 + 7;

int f(int i, int j, const vector<vector<char>>& a, vector<vector<int>>& res) {
  if (i < 0 || j < 0) return 0;
  if (i == 0 && j == 0) return 1;

  if (a[i][j] == '#') return 0;

  if (res[i][j] == -1) {
    res[i][j] = f(i - 1, j, a, res) + f(i, j - 1, a, res);
    res[i][j] %= MOD;
  }

  return res[i][j];
}

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

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

  vector<vector<int>> res(n, vector<int>(m, -1));

  cout << f(n - 1, m - 1, a, res) << endl;

  return 0;
}


Measured memory_bytes: 5376
N, A, B, C = map(int, input().split())

lList = []
for _ in range(N):
    lList.append(int(input()))

def dfs(idx, i, j, k):
    if idx == N:
        if min(i,j,k) > 0:
            return abs(A-i) + abs(B- j) + abs(C - k)
        else:
            return 10**9
    re4 = dfs(idx+1, i, j, k)
    re1 = dfs(idx+1, i+lList[idx], j, k)+10
    re2 = dfs(idx+1, i, j+lList[idx], k)+10
    re3 = dfs(idx+1, i, j, k+lList[idx])+10

    return min(re1,re2,re3,re4)

print(dfs(0,0,0,0)-30)

Measured memory_bytes: 3064