akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

int main() {
	int N,count;
	cin>>N>>count;
	int arr[N];
	for (int i=0; i<N; i++){
		cin>>arr[i];
	}
	long long int sum=0;
    for (int i=1; i<N; i++){
    	if ((arr[i-1]+arr[i])>count){
    		if (arr[i-1]>count){
    			int extra = (arr[i-1]+arr[i]-count);
    			sum += extra;
    			arr[i]=0;
    		}
    		else{
    			int extra=(arr[i-1]+arr[i]-count);
    			sum+=extra;
    			if (arr[i]>extra){
    				arr[i]-=extra;
    			}
    			else{
    				arr[i]=0;
    			}
    		}
    	}
    }
    cout << sum << endl;
}


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

using namespace std;

int main(){
	int v,k,s,ant;
	cin >> v;
	s=0;
	ant=v;
	for(int i=0;i<4;i++){
		cin >> v;
		s+=(v-ant);
		ant=v;
	}
	cin >> k;
	if(s>k) cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}


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

using namespace std;

#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)

main(){
    int N, M, sum;
    int maxL = 0, minR = 100000;
    int L, R;
    int i, j;
    cin >> N >> M;
    FOR(i, 0, M){
        cin >> L >> R;
        if(minR >= R){ minR = R; }
        if(maxL <= L){ maxL = L; }
    }

    sum = minR - maxL + 1;
    
    cout << max(0, sum) << endl;
}

Measured memory_bytes: 256
s = input()
l = len(s)
n = int(s)
ans = 0
import itertools
for li in range(3, l+1):
    for i in itertools.product([7, 5, 3], repeat=li):
        num = int(''.join(map(str, i)))
        if num > n:
            continue
        if len(set(i)) == 3:
            ans += 1
print(ans)

Measured memory_bytes: 3064
/// wa ^3^

#pragma GCC optimize("O3")

#include<bits/stdc++.h>
                           
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
 
using namespace std;
 
using ll = long long;
using pii = pair<int, int>;                                   

const int MOD = 1e9 + 7;
const int INF32 = 1e9 + 1e2;

template<typename T> istream 
&operator>>(istream &a, vector<T> &v) { 
for (auto& x : v) a >> x; return a; }

void stndrtn() {
#ifdef accepted
    freopen(".in", "r", stdin);
#endif        
}

const bool flag = 0;

void maincode() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> cnt;
    for (int& x : a)
        cin >> x, cnt[x]++;
    vector<int> ans;  
    ans = {a[0]};
    cnt[a[0]]--;
    for (int i = 1; i < n; ++i) {
        cnt[a[i]]--;
        if (cnt[a[0] ^ a[i]])
            ans.pb(a[i]), ans.pb(a[0]^a[i]);
        cnt[a[i]]++;
        if (sz(ans) > 1)
            break;
    }
    if (sz(ans) == 1)
        cout << "No", exit(0);
    cnt[ans[1]]--, cnt[ans[2]]--;
    for (int i = 3; i < n; ++i) {
        if (!cnt[ans[i-1]^ans[i-2]])
            cout << "No", exit(0);
        cnt[ans[i-1]^ans[i-2]]--;
        ans.pb(ans[i-1]^ans[i-2]);
    }
    if ((ans[1]^ans[n-1]) != a[0] || (ans[n-2]^ans[0]) != ans[n-1])
        cout << "No", exit(0);
    cout << "Yes";
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr), stndrtn();
    int ts = 1;
    if (flag) 
        cin >> ts;
    while (ts--)
        maincode(); 
    return 0;
}



Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ll a,b,k;
    cin>>k>>a>>b;
    for(ll i=a;i<=b;i++)
    {
        if(i%k==0)
        {
            cout<<"OK"<<endl;
            return 0;
        }
    }
    cout<<"NG"<<endl;
    return 0;
}



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

using namespace std;
typedef long long ll;


int main()
{
    ios_base::sync_with_stdio(0);

    string s;
    cin >> s;

    int cnt = 0;

    if (s[0]==s[1] && s[1]==s[2] && s[2]=='R') cout << 3;
    else if (s[0]==s[1] && s[1]=='R') cout << 2;
    else if (s[1]==s[2] && s[2]=='R') cout << 2;
    else if (s[0]=='R' || s[1]=='R' || s[2]=='R') cout << 1;
    else cout << 0;


    return 0;
}


Measured memory_bytes: 3632
//Heaplax
//别让自己后悔
#include<bits/stdc++.h>
#define N 200005
#define LL long long
#define LOG(x) cerr<<#x<<" = "<<x<<endl
#define add_edge(u,v) nxt[++cnt]=head[u],head[u]=cnt,to[cnt]=v
#define open(x) freopen(#x".in","r",stdin),freopen(#x".out","w",stdout)
char ch;bool fs;void re(int& x)
{
	while(ch=getchar(),ch<33);
	if(ch=='-')fs=1,x=0;else fs=0,x=ch-48;
	while(ch=getchar(),ch>33)x=x*10+ch-48;
	if(fs)x=-x;
}
using namespace std;
const int mod=1000000007;
vector<int> e[N];
int n,l[N],r[N],f[N],s[N];
struct node
{
	int x,v,id;
	bool operator < (const node &i)const
	{
		return v<i.v;
	}
}p[N];
bool cmp(node a,node b)
{
	return a.x<b.x;
}
int main()
{
	re(n);
	for(int i=1;i<=n;++i)
		re(p[i].x),re(p[i].v);
	sort(p+1,p+n+1);
	for(int i=1;i<=n;++i)p[i].id=i;
	sort(p+1,p+n+1,cmp);
	r[1]=p[1].id;
	for(int i=2;i<=n;++i)
		r[i]=max(r[i-1],p[i].id);
	l[n]=p[n].id;
	for(int i=n-1;i;--i)
		l[i]=min(l[i+1],p[i].id);
	for(int i=1;i<=n;++i)
		e[r[i]].push_back(l[i]);
	f[0]=s[0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j:e[i])
			f[i]=(2ll*f[i]+s[i-1]-(j==1?0:s[j-2]))%mod;
		f[i]=(f[i]+mod)%mod;
		s[i]=(s[i-1]+f[i])%mod;
	}
	printf("%d\n",f[n]);
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
    cout.tie(NULL);
    int n,k;
    cin>>n>>k;
    int a[n+2];
    int dp[n+2];
    for(int i=0;i<n;i++){
        cin>>a[i];
        dp[i] = INT_MAX;
    }
    dp[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=1;j<=k;j++)
        if(i+j<n) dp[i+j] = min(dp[i+j] , dp[i] + abs(a[i]-a[i+j]));
    }
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1024
h,w=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(10)]
for k in range(10):
  for i in range(10):
    for j in range(10):
      d[i][j]=min(d[i][j],d[i][k]+d[k][j])
ans=0
for _ in range(h):
  arr=list(map(int,input().split()))
  for i in arr:
    if abs(i)!=1:
      ans+=d[i][1]
print(ans)

Measured memory_bytes: 3064
#include<stdio.h>
int main(){
	long long n,k;
	scanf("%lld %lld",&n,&k);
	long long a=1;
	for(int i=0;i<n;i++){
		if(a*2<a+k){
			a*=2;
		}else{
			a+=k;
		}
	}
	printf("%lld\n",a);
} 

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <list>
#include <math.h>
#include <string.h>
#include <bitset>
#include <queue>
using namespace std;

typedef pair<int, int> P;
#define INF (1LL<<60)
#define int long long
#define ll long long
#define mod 1000000007


signed main(){

	int K, A, B;
	cin >> K >> A >> B;
	int ans;
	if (A + 2 < B){
		if (K <= A) ans = 1 + K;
		else{
			ans = A + (K - (A - 1)) / 2 * (B - A) + (K - (A - 1)) % 2;
		}
	}
	else
		ans = 1 + K;

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int64_t N;
  cin >> N;
  vector<int64_t> data(N+1);  
  
  data.at(0) = 2;
  data.at(1) = 1;
  
  for(int i = 2; i<N+1; i++) {
    data.at(i) = data.at(i-1) + data.at(i-2);
  }
  
  cout << data.at(N) << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <ccomplex>
#include <unordered_map>
#include <cstring>
#include <iostream>
#include <numeric>
#include <sstream>
#include <set>
#include <map>
#include <iomanip>

using namespace std;
#define MAX 1LL << 60
#define MOD 1000000007

typedef long long ll;

#define rep(i, s, e) for(ll i = s; i < e; i++)
#define repR(i, s, e) for(ll i = s; i > e; i--)
#define reft0(i, j) setfill('0') << setw(i) << j
#define fix(i) fixed << setprecision(i)


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; }
template<class T> inline ll gcd(T a, T b){ if (a % b == 0){ return b; } else{ return gcd(b, a%b); } }
template<class T> inline ll lcm(T a, T b){ return a * b / gcd(a, b); }
template<class T> inline ll fact(T a){ if (a <= 1){ return 1; } else{ return a * fact(a - 1); } }
template<class T> inline ll comb(T a, T b){ return a == 0 ? 0 : fact(a) / fact(b) / fact(a - b); }

int main(){
    ll L, R;
    cin >> L >> R;
    if ((L % 2019 == 0) || (R % 2019 == 0)){
        cout << 0 << endl;
        return 0;
    }
    ll temp = (L / 2019 + 1) * 2019;
    if (temp < R){
        cout << 0 << endl;
        return 0;
    }
    ll ans = MAX;
    rep(i, L, R){
        rep(ii, i + 1, R + 1){
            ll tempAns = (i % 2019) * (ii % 2019) % 2019;
            if (tempAns < ans){
                ans = tempAns;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
// ll mod_pow(ll x, ll n, ll mod){//x^n % mod
//     if (n == 0)
//         return 1;
//     ll res = mod_pow(x * x % mod, n / 2, mod);
//     if (n & 1)
//         res = res * x % mod;
//     return res;
// }
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N; cin >> N;
    cout << (N - N/2)/(float)N << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; ++i)
using ll = long long;
using namespace std;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main() {
    int N, A, B;
    cin >> N >> A >> B;

    int cnt[3] = {0};
    rep(i, N) {
        int t;
        cin >> t;

        if (t <= A)
            cnt[0]++;
        else if (t <= B)
            cnt[1]++;
        else
            cnt[2]++;
    }

    cout << min({cnt[0], cnt[1], cnt[2]}) << endl;

    return 0;
}


Measured memory_bytes: 256
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int n;
string s;
const LL mod = 1e9 + 7;
int main(){
    cin >> n;
    cin >> s;
    REP(i, 2 * n){
        if((i + 1) % 2 == 0)continue;
        if(s[i] == 'B')s[i] = 'W';
        else           s[i] = 'B';
    }
    LL ans = 1;
    LL rcnt = 0, lcnt = 0;
    REP(i, 2 * n){
        if(s[i] == 'W')lcnt++;
        else{
            rcnt++;
            (ans *= lcnt) %= mod;
            lcnt--;
        }
    }
    if(rcnt != (2 * n  - rcnt)|| s[2 * n - 1] == 'W'){
        cout << 0 << endl;
        return 0;
    }
    LL fact = 1;
    for(LL i = 1;i <= n;i++)(fact *= i) %= mod;
    cout << (ans * fact) % mod << endl;
}

Measured memory_bytes: 720
n = int(input())
list = []
for i in range(n):
    list += [int(input())]

max_ = max(list)
for i in range(n):
    a = list[i]
    if a == max_:
        del list[i]
        ans = max(list)
        print(ans)
        list.insert(i,a)
        for j in range(n-i-1):
            print(max_)
        break
    else:
        print(max_)

Measured memory_bytes: 12532
#include <iostream>

using namespace std;

int main(void)
{
    int a, b, c;
    cin >> a >> b >> c;
    int cnt = 0;
    int mx = max(max(a, b), c);
    while(a < mx){
        a += 2;
        cnt++;
    }
    if(a > mx) {
        a -= 2;
        cnt--;
    }
    while(b < mx){
        b += 2;
        cnt++;
    }
    if(b > mx){
        b -= 2;
        cnt--;
    }
    while(c < mx){
        c += 2;
        cnt++;
    }
    if(c > mx) {
        c -= 2;
        cnt--;
    }
    if(a == b && b == c){
        cout << cnt << endl;
    }
    else if((mx*3 - a - b - c) == 2){
        cout << cnt + 1 << endl;
    }else{
        cout << cnt + 2 <<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
using ll=long long;
#define rep(i,a,b) for(ll i=a;i<ll(b);i++)
#define repr(i,a,b) for(ll i=a;i>=ll(b);i--)
#define endl "\n"
#define ALL(x) x.begin(),x.end()
#define ALLR(x) x.rbegin(),x.rend()
#define INF 1e9
#define DEBUG(x) cout<<"debug: "<<x<<endl

int s, w;
int main() {
    cin >> s >> w;
    if(w >= s) cout << "unsafe" << endl;
    else cout << "safe" << endl;
    return 0;
}


Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cstring>
#include <deque>
#include <functional>
#include <initializer_list>
#include <math.h>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>

#define FOR(i, a, b) for(int (i) = (a); (i) < (b); ++(i))
#define rFOR(i, a, b) for(int (i) = (b); (i) >= (a); --(i))
#define REP(i, n) FOR(i, 0, n)
#define rREP(i, n) rFOR(i, 0, (n-1))
#define SORT(A) std::sort((A).begin(), (A).end())
#define ALL(A) (A).begin(), (A).end()
// 座標圧縮 (for vector) : ソートしてから使うのが一般的 ; SORT(A) => COORDINATE_COMPRESSION(A)
#define COORDINATE_COMPRESSION(A) (A).erase(unique((A).begin(),(A).end()),(A).end())

using lli = long long int;
using pii = std::pair<int, int>;

void VintOut(std::vector<int>& A){
    const int n = A.size();
    if(n == 0){putchar('\n'); return;}
    printf("%d", A[0]);
    for(int i = 1; i < n; ++i) printf(" %d", A[i]);
    putchar('\n');
}
void VintOut(std::vector<long long int>& A){
    const int n = A.size();
    if(n == 0){ putchar('\n'); return;}
    printf("%lld", A[0]);
    for(int i = 1; i < n; ++i) printf(" %lld", A[i]);
    putchar('\n');
}

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

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

inline bool bitUP(int state, int k){ return (state >> k) & 1; }
inline bool bitUP(long long int state, int k){ return (state >> k) & 1;}


// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~



int main(void){
    int n; std::string S; std::cin >> n >> S;
    int cnt = 0;
    for(int x = 0; x + 2 < n; ++x) if(S[x] == 'A' and S[x+1] == 'B' and S[x+2] == 'C') cnt++;
    std::cout << cnt << '\n';


    return 0;
}

Measured memory_bytes: 888
#include <cstdio>
#include <vector>

using namespace std;

vector<pair<int, int> > g[100001];
int v[100001];
int d[100001];

int f(int x, int y) {
	if (v[x]) return d[x] != y;
	v[x] = 1;
	d[x] = y;
	for (auto t : g[x]) if (f(t.first, y + t.second)) return 1;
	return 0;
}

int main() {
	int i, j, k, n, m;
	scanf("%d%d", &n, &m);
	while (m--) {
		scanf("%d%d%d", &i, &j, &k);
		g[i].emplace_back(j, k);
		g[j].emplace_back(i, -k);
	}
	for (i = 1; i <= n; i++) if (!v[i] && f(i, 0)) {
		puts("No");
		return 0;
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 11392
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl


int main(){
    ll k, a, b;
    cin >> k >> a >> b;
    if(b-a<=2){
        cout << k+1LL << endl;
        return 0;
    }
    ll ans = 0;
    ll rem = k-(a-1);
    if(rem<=1){
        cout << k+1LL << endl;
        return 0;
    }
    ans = a;
    if(rem%2 == 1){
        ans++;
        rem--;
    }
    ans = max((b-a)*(rem/2),rem)+ans;
    cout << ans << endl;
    return 0;

}


Measured memory_bytes: 256
N, W = map(int, input().split())
things = [tuple(map(int, input().split())) for _ in range(N)]

dp = [[0] * (W + 1) for _ in range(N + 1)]

for i, (v, w) in enumerate(things, start=1):
    for j in range(W + 1):
        if j - w >= 0:
            dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w] + v)
        else:
            dp[i][j] = dp[i - 1][j]

print(dp[-1][-1])



Measured memory_bytes: 25504
def round10(n)
  (n / 10.0).ceil * 10
end

def time(ms)
  ms.reduce do |last, duration|
    round10(last) + duration
  end
end

# 1..123
a = gets.to_i
b = gets.to_i
c = gets.to_i
d = gets.to_i
e = gets.to_i

ms = [a, b, c, d, e]
ps = ms.permutation

# 41..643
t, = ps.map { |p| [time(p), p] }.min_by { |t, _| t }
p t


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <map>
#include <numeric>

int main() {
  char buf[128];
  scanf("%s", buf);
  std::string s = buf;
  scanf("%s", buf);
  std::string t = buf;
  printf("%s%s\n", t.c_str(), s.c_str());
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i;
  string s,s3;
  int num;
  int dlt;
  int dltMin=1000;
  
  cin >> s;
  
  for(i=0;i<s.size()-2;i++){
    s3[0] = s[i];
    s3[1] = s[i+1];
    s3[2] = s[i+2];
    dlt = abs(atoi(s3.c_str()) - 753);
    dltMin = min(dltMin,dlt);
    
  }
  cout << dltMin << endl;
  
}

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

int main(){
	
	int a,b;
	cin >> a >> b;
	
	priority_queue<int> q;
	
	q.push(a+b);
	q.push(a-b);
	q.push(a*b);
	
	cout << q.top() << endl;
	return 0;
}

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

typedef complex <long double> com;
const int P = 200003, len = 1 << 19;
int n;
com c[len];
int p[P], seq[len];
void fft(com a[], const char &flag);

int main() {
	for (int i = 2, j = 1; i != 1; i = i << 1 >= P ? (i << 1) - P : i << 1, ++j)
		p[i] = j;
	for (int i = 1; i < len; ++i)
		seq[i] = seq[i >> 1] >> 1 | (i & 1) << 18;
	scanf("%d", &n);
	long long ans = 0;
	for (int i = 0; i < n; ++i) {
		int a; scanf("%d", &a);
		if (a != 0)
			c[p[a]] += 1, ans -= 1ll * a * a % P;
	}
	fft(c, 1);
	for (int i = 0; i < len; ++i)
		c[i] = c[i] * c[i] / (long double)(len);
	fft(c, -1);
	for (int i = 0, j = 1; i < len; ++i, j <<= 1) {
		if (j >= P)
			j -= P;
		ans += j * (long long)(c[i].real() + 0.5);
	}
	printf("%lld\n", ans >> 1);
	return 0;
}

void fft(com a[], const char &flag) {
	for (int i = 0; i < len; ++i)
		if (i < seq[i])
			swap(a[i], a[seq[i]]);
	for (int i = 0; 1 << i < len; ++i) {
		const com wn(cos(M_PI / (1 << i)), flag * sin(M_PI / (1 << i)));
		for (int j = 0; j < len; j += 1 << i + 1) {
			com w(1, 0);
			for (int k = 0; k < 1 << i; ++k, w *= wn) {
				com x = a[j + k], y = w * a[j + k + (1 << i)];
				a[j + k] = x + y;
				a[j + k + (1 << i)] = x - y;
			}
		}
	}
	return;
}



Measured memory_bytes: 23384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => long.Parse(value)).ToList();

			if(firstLine[0] == firstLine[1] || Math.Abs(firstLine[0] - firstLine[1]) == 1)
			{
				Console.WriteLine("Brown");
			}
			else
			{
				Console.WriteLine("Alice");
			}
		}
	}
}

Measured memory_bytes: 13396
import java.util.Scanner;

public class Main {

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

		for (int index = 0; sc.hasNext(); index++) {
			int a = sc.nextInt();
			int b = sc.nextInt();

				if (a == 0 && b == 0) {
					break;
				}
			hasLeapYear(a, b, index);

		}
	sc.close();
	}

	private static void hasLeapYear(int a, int b, int index) {
		boolean hasLeapYear = false;

			if (index > 0) {
				System.out.println();
			}

		for (int i = a; i <= b; i++) {

			boolean res = isLeapYear(i);
				if (res) {
					if (hasLeapYear == false) {
						hasLeapYear = true;
					}
					System.out.println(i);
				}
		}

		if (hasLeapYear == false) {
			System.out.println("NA");
		}

	}

	private static boolean isLeapYear(int i) {
		if (i % 4 == 0) {
			if (i % 100 == 0) {

				if (i % 400 == 0) {
					return true;
				} else {
					return false;
				}

			}
			return true;
		} else {
			return false;
		}
	}
}


Measured memory_bytes: 27412
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int h = sc.nextInt();
		int w = sc.nextInt();
		int[] map=new int[128];
		for(int i = 0; i<h; i++){
			String s = sc.next();
			for(int j = 0; j<w; j++){
				map[s.charAt(j)]++;
			}
		}
		int one=(h%2)*(w%2);
		int two=(h/2)*(w%2)+(h%2)*(w/2);
		int four=(h/2)*(w/2);
		for(int i = 0; i<128; i++){
			four-=map[i]/4;
			map[i]%=4;
			two-=map[i]/2;
			one-=map[i]%2;
		}
		String ans="Yes";
		if(four>0){
			ans="No";
		}
		two+=four*2;
		if(two>0){
			ans="No";
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23380
#!/usr/bin/env python3
#ABC137 C

import sys
import math
import bisect
sys.setrecursionlimit(1000000000)
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
s = [list(input()) for _ in range(n)]
for i in s:
    i.sort()
s = [''.join(i) for i in s]
t = list(Counter(s).items())
ans = 0
for i,j in t:
    if j == 1:
        continue
    else:
        ans += (j)*(j-1)//2
print(ans)


Measured memory_bytes: 121424
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
const int mod=1e9+7;
const int maxn=2e4;
const int inf=1e9;
int n,m;
int w[maxn+5],v[maxn+5];
int dp[maxn+5];
int main()
{

    ios::sync_with_stdio(false);
    cin>>m>>n;
    for(int i=1;i<=n;++i) cin>>w[i]>>v[i];
    for(int i=1;i<=maxn;++i) dp[i]=inf;
    dp[0]=0;
    for(int i=1;i<=n;++i)
        for(int j=w[i];j<=maxn;++j)
            dp[j]=min(dp[j],dp[j-w[i]]+v[i]);
    int ans=inf;
    for(int i=m;i<=maxn;++i) ans=min(ans,dp[i]);
    cout<<ans<<endl;
    return 0;
}

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

int main()
{
    int n, sum = 0;
    cin >> n;
    vector<int> b(n-1);
    rep(i,n-1) cin >> b[i];
    sum = b[0];
    for(int i = 1;i < n-1; i++) {
        sum += min(b[i-1], b[i]);
    }
    sum += b.back();
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = [input() for _ in range(N)]

if len(S) != len(set(S)):
    print("No")
    
else:
    next_s = S[0][0]
    for s in S:
        if next_s != s[0]:
            print("No")
            break
        
        next_s = s[-1]
    else:
        print("Yes")
    


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

using namespace std;

namespace {
    typedef long long ll;

    int N;
    vector<vector<int>> T;
    void input() {
        cin >> N;
        T = vector<vector<int>>(N);
        for (auto i = 0; i < N - 1; i++) {
            int a, b; cin >> a >> b; a--; b--;
            T[a].push_back(b);
            T[b].push_back(a);
        }
    }

    /** output whole vector. ex) vector<int>{1, 2, 3} -> '1 2 3'. */
    template<typename T>
    ostream& operator<<(ostream& os, const vector<T>& xs) {
       if (xs.empty()) return os;
       os << xs[0];
       for (auto i = 1; i < xs.size(); i++) os << ' ' << xs[i];
       return os;
    }


    void solve() {
        vector<int> p0(N, -1), p1(N, -1);
        function<void(int, int, vector<int>&)> dfs = [&](int p, int v, vector<int>& P) {
            P[v] = p;
            for (auto n : T[v]) {
                if (n == p) continue;
                dfs(v, n, P);
            }
        };
        dfs(-1, 0, p0);
        dfs(-1, N - 1, p1);
        queue<tuple<int, int>> Q;
        Q.push(make_tuple(0, N - 1));
        int s = -1, t = -1;
        while (true) {
            int a, b;
            tie(a, b) = Q.front(); Q.pop();
            if (p1[a] == p0[b]) {
                s = p1[a];
                t = b;
                break;
            } else if (p1[a] == b) {
                s = a;
                t = b;
                break;
            } else {
                a = p1[a];
                b = p0[b];
                Q.push(make_tuple(a, b));
            }
        }
        /** 部分木のサイズを計算する. 計算量はキャッシュが揃うまでにO(N logN), キャッシュがあればO(logN). */
        map<pair<int, int>, double> memo;
        function<ll(int, int)> treeSize = [&](int p, int v) -> ll {
            auto key = make_pair(p, v);
            if (memo.count(key)) return memo[key];
            auto rkey = make_pair(v, p);
            if (memo.count(rkey)) return N - memo[rkey];;
            auto& children = T[v];
            ll ans = 1;
            for (auto child : children) {
                if (child == p) continue;
                ans += treeSize(v, child);
            }
            return memo[key] = ans;
        };
        //cout << s + 1 << " " << t + 1 << endl;
        //cout << treeSize(t, s) << " " <<  treeSize(s, t) << endl;
        cout << (treeSize(t, s) > treeSize(s,t ) ? "Fennec" : "Snuke") << endl;
    }
}

int main() {
    input(); solve();
    return 0;
}



Measured memory_bytes: 17408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ‘ ‘
const ll mei = (ll)1e9 + 7;

int main(){
  ll a, b, c, d;
  cin >> a >> b;
  c = 1;
  d = 0;
  while(c < b){
    c = c + a - 1;
    d++;
  }
  cout << d;
  memi;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<int,int>;

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

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


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


int main(){
    double r;
    double pi = 3.1415926535;
    cin >> r;
    cout << fixed << setprecision(15) << r * 2 * pi << endl;
}

Measured memory_bytes: 3824
Imports System.Console
Module Module1
    Dim n As Int64
    Dim ans As Int64
    Sub Main()
        n = ReadLine()
        Dim a As Integer = 1
        Dim w As Int64
        Do Until w + 26 ^ a >= n
            w += 26 ^ a
            a += 1
        Loop
        If a >= 2 Then
            For i = a To 2 Step -1
                n -= 26 ^ (i - 1)
            Next
        End If
        Dim ans As String = ""
        For i = a To 1 Step -1
            Dim d As Double = n / 26 ^ (i - 1)
            Dim s As Integer
            s = Math.Ceiling(d)
            ans &= ToCher(s)
            n -= (s - 1) * (26 ^ (i - 1))
        Next
        WriteLine(ans)
    End Sub
    Function ToCher(ByVal k As Integer) As Char
        Return Chr(96 + k)
    End Function
End Module


Measured memory_bytes: 28800
#include<iostream>
#include<stdio.h>
using namespace std;
int main(){
	int a,b;
	char op;
	for(;;){
	cin>>a>>op>>b;
	if(op=='?'){
	break;
	}
	else if(op=='+'){
	cout<<a+b<<endl;
	}
	else if(op=='-'){
	cout<<a-b<<endl;
	}
	else if(op=='*'){
	cout<<a*b<<endl;
	}
	else if(op=='/'){
	cout<<a/b<<endl;
	}
	}
return 0;
}


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

using namespace std;
typedef long long LL;
const LL maxn = 2e3 + 100, max_val = 4e6 + 10;
LL n, a[maxn], sum;

void read() {
    scanf("%lld", &n);
    for (LL i = 1; i <= n; ++i) {
        scanf("%lld", &a[i]);
        sum += a[i];
    }
}

LL solve() {
    bitset<max_val> bs;
    bs.reset();
    bs.set(0);
    for (LL i = 1; i <= n; ++i)
        bs |= (bs << a[i]);
    for (LL val = sum / 2; val >= 0; --val)
        if (bs.test(val))
            return sum - val;
}

int main() {
    read();
    cout << solve() << endl;
}


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

int main() 
{
    int n, q;

    scanf("%d", &n);

    if(n%2 == 0)
    {
    	q = n/2;
    }
    else
    {
    	q = (n/2)+1;
    }

    printf("%d\n", q);
    
	return 0;
}

Measured memory_bytes: 128
<?php
$n = (int)fgets(STDIN);
$input = explode(" ",trim(fgets(STDIN)));
$sum = 0;

for($i=0; $i < $n; $i++){
    for($j = $i + 1; $j < $n; $j++){
       $sum +=  $input[$i] * $input[$j];
    }
    
}

echo $sum.PHP_EOL;

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

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> L(N);
  for (int i = 0; i < N; ++i) cin >> L[i];
  sort(L.begin(), L.end(), greater<int>());
  int res = 0;
  for (int i = 0; i < K; ++i) res += L[i];
  cout << res << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
	static void Main()
	{
		var groupA = new[] { 1, 3, 5, 7, 8, 10, 12 };

		var n = Array.ConvertAll(Console.ReadLine().Split(new[] { ' ' }), number => int.Parse(number));

		var groups = Array.ConvertAll(n, num => {
			if (num == 2) {
				return 3;
			} else if (groupA.Contains(num)) {
				return 2;
			} else {
				return 1;
			}
		});

		Console.WriteLine(groups[0] == groups[1] ? "Yes" : "No");
	}
}


Measured memory_bytes: 11220
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        CLowElements solver = new CLowElements();
        solver.solve(1, in, out);
        out.close();
    }

    static class CLowElements {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), mn = Integer.MAX_VALUE;
            long ans = 0;
            for (int i = 0; i < n; i++) {
                int x = s.nextInt();
                if (x <= mn) ans++;
                mn = Math.min(mn, x);
            }
            w.print(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(int i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(int i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define uniq(x) (x).erase(unique((x).begin(), (x).end()), (x).end())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    int n, k;
    cin >> n >> k;
    vector<pair<int, int>> ans;
    int mv = (n - 1) * (n - 2) / 2;
    if (mv < k) {
        cout << -1 << endl;
        return 0;
    }
    reps(i, 1, n) {
        ans.emplace_back(0, i);
    }
    int remain = mv - k;
    reps(i, 1, n - 1) {
        reps(ii, i + 1, n) {
            if (remain <= 0) break;
            ans.emplace_back(i, ii);
            remain--;
        }
        if (remain <= 0) break;
    }
    printf("%d\n", sz(ans));
    rep(i, sz(ans)) printf("%d %d\n", ans[i].first + 1, ans[i].second + 1);
    return 0;
}


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

int main() {
	int health, n;
	cin >> health >> n;
	int sum = 0;
	for (int i = 0; i < n; i++) {
		int a_i;
		cin >> a_i;
		sum += a_i;
	}
	
	if (sum >= health) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#pragma region header
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define ts to_string
#define all(v) (v).begin(), (v).end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vs vector <string>
#define vvs vector <vector<string>>
#define pq  priority_queue<int>
using ll = long long;
/* ----------------よく使う数字や配列----------------- */
int dx[] = { 1,0,-1,0 };
int dy[] = { 0,1,0,-1 };
const int INF = 2000000000;
const int MINF=-2000000000;
constexpr ll mod = 1e9 + 7;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */
/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if (b == 0) return a;
    return gcd(b, a % b);
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
bool isprime(ll a)//素数判定、primeならtrue,違うならfalse
{
    if (a < 2) return false;
    else if (a == 2) return true;
    else if (a % 2 == 0) return false;
    double m = sqrt(a);
    for (int i = 3; i <= m; i += 2)
    {
        if (a % i == 0)
        {
            return false;
        }
    }
    // 素数である
    return true;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while (n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
ll kind(vi SYURUI) {//vector<int>型の配列の要素の種類数
    int size = SYURUI.size();
    sort(all(SYURUI));
    int cnt = 1;
    rep(i, size-1) {
        if (SYURUI[i] != SYURUI[i + 1])cnt++;
    }
    return cnt;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    string S; cin >> S;
    cout << S[0] << S[1] << S[2] << endl;
}






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

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  for (int i = 0; i < N; ++i)
    cin >> L[i];
  vector<int> D(N + 1);
  D[0] = 0;
  for (int i = 1; i <= N; ++i)
    D[i] = D[i - 1] + L[i - 1];
  int ans = 0;
  for (int i = 0; i <= N; ++i)
    if (D[i] <= X)
      ++ans;
  cout << ans << endl;
}

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;

  bool flag = false;
  ll x = abs(a-b);
  REP(i, n){
    ll l = x+(n-1)*c;
    ll r = x+(n-1)*d;
    if(l<= (c+d)*i && (c+d)*i<= r)
      flag = true;
  }

  if(flag)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	s := next()
	ok := true
	for i := range s {
		if i%2 == 0 && s[i] == 'L' {
			ok = false
			break
		} else if i%2 == 1 && s[i] == 'R' {
			ok = false
			break
		}
	}
	if ok {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	long long x, d, k;
	cin >> x >> k >> d;
	x = abs(x);
	long long div = x / d;
	if (k >= div)
	{
		k -= div;
		x -= div * d;
		k %= 2;
	}
	cout << abs(x - k * d);
}


Measured memory_bytes: 3616
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <queue>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353;//1000000007;

template<class _T> static void getval(_T& a) {
	std::cin >> a;
}
template<class _T> static void getval(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void getval(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}

template <class _T> static _T tp_modpow(_T a, _T n, _T mod = (_T)1) {
	_T ans = 1;
	while (n > 0) {
		if (n & 1) {
			ans = (ans * a) % mod;
		}
		a = (a * a) % mod;
		n >>= 1;
	}
	return ans;
}

static void exec()
{
	int N;
	getval(N);
	
	int d0;
	getval(d0);

	std::vector<LLONG> count(N, 0);
	for (int i = 1; i < N; i++) {
		int di;
		getval(di);
		count[di]++;
	}

	if (d0 || count[0]) {
		printf("0\n");
		return;
	}
	count[0]++;

	LLONG ans = 1;
	for (int i = 1; i < N; i++) {
		LLONG val = tp_modpow(count[i - 1], count[i], MOD_NUM);
		ans = (ans * val) % MOD_NUM;
	}
	printf("%lld\n", ans);
}


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

int N;

int Linear_Search(int A[],int key){
  for(int i=0;i<N;i++)if(A[i] == key) return 1;
  return 0;
}


int main(){
  int T[100001];
  int q;
  int a;
  int sum=0;
  //cout<<"move"<<endl;
  cin>>N;
  for(int i=0;i<N;i++)cin>>T[i];
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>a;
    sum += Linear_Search(T,a);
  }

  cout<<sum<<endl;

  return 0;

}
  

Measured memory_bytes: 3392
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    string S;
    cin >> S;
    if(S[S.size()-1] !='s') cout << S << "s" << endl;
    else cout << S << "es" << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3656
#include <stdio.h>

void enqueue(int index);
int dequeue(void);

int Q[1001];
int lastQ = 0;

char name[1001][11];
int time[1001];

main(){

  int i, index, n, q, elapsedTime = 0;

  scanf("%d %d",&n,&q);

  for(i=0; i<n; i++){
    scanf("%s %d",name[i],&time[i]);
    enqueue(i);
  }

  while(n!=0){

    index = dequeue();
    time[index] -= q;
    elapsedTime += q;

    if(time[index] <= 0){
      elapsedTime += time[index];
      printf("%s %d\n",name[index],elapsedTime);
      n--;
    }else{
      enqueue(index);
    }

  }

  return 0;

}

void enqueue(int index){
  Q[lastQ++] = index;
}

int dequeue(void){

  int i,tmp = Q[0];

  lastQ--;
  for(i=0; i<lastQ; i++)
    Q[i] = Q[i+1];

  return tmp;

}

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

typedef long long ll;
typedef unsigned long long ull;

int main()
{
    ll N, M, S;
    cin >> N >> M >> S;
    ll Ui, Vi, Ai, Bi, Ci, Di;
    vector<vector<array<ll,3>>> g1(N, vector<array<ll,3>>());
    vector<array<ll,2>> g2(N, array<ll,2>());
    for(int i=0;i<M;i++){
        cin >> Ui >> Vi >> Ai >> Bi;
        Ui--; Vi--;
        g1[Ui].push_back(array<ll,3>{Vi, Ai, Bi});
        g1[Vi].push_back(array<ll,3>{Ui, Ai, Bi});
    }
    for(int i=0;i<N;i++){
        cin >> Ci >> Di;
        g2[i] = array<ll,2>{Ci, Di};
    }

    priority_queue<std::array<ll, 3>> q;
    ll n_s_max = 50 * N;
    std::vector<ll> d(N * n_s_max, numeric_limits<ll>::max());
    S = min(S, n_s_max-1);
    d[0 + S * N] = 0;
    q.push(std::array<ll,3>{0, S, 0}); // minutes, money, index
    while(!q.empty()){
        auto tmp = q.top(); q.pop();
        auto u = tmp[2];
        auto s0 = tmp[1];
        auto d0 = -tmp[0];

        for(size_t i=0; i<g1[u].size(); i++){
            auto v = g1[u][i][0];
            auto s = g1[u][i][1];
            auto w = g1[u][i][2];
            if(s0 < s) continue;
            auto v1 = v + (s0-s) * N;
            auto alt = d0 + w;
            if(alt < d[v1]){
                d[v1] = alt;
                q.push(std::array<ll,3>{-alt, s0 - s, v});
            }
        }
        if(s0 + g2[u][0] == n_s_max) continue;
        s0 += g2[u][0];
        s0 = min(s0, n_s_max-1);
        auto v1 = u + s0 * N;
        auto alt = d0 + g2[u][1];
        if(alt < d[v1]){
            d[v1] = alt;
            q.push(std::array<ll,3>{-(d0 + g2[u][1]), s0, u});
        }
    }
    for(int i=1; i<N; i++){
        ll res = numeric_limits<ll>::max();
        for(int j=0; j<n_s_max; j++){
            res = min(res, d[i + j * N]);
        }
        cout << res << endl;
    }


    return 0;
}

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

const int MAX_N = 200001;
int rows[4*MAX_N];
int cols[4*MAX_N];

void pointUpdate(int* t, int node, int tl, int tr, int index, int val) {
	if(tl == tr)
		t[node] = val;
	else {
		int mid = (tl+tr)/2;
		if(index <= mid)
			pointUpdate(t,2*node,tl,mid,index,val);
		else
			pointUpdate(t,2*node+1,mid+1,tr,index,val);
		
		t[node] = min(t[2*node],t[2*node+1]);
	}
}

int pointQuery(int* t, int node,int tl, int tr, int index) {
	if(tl == tr)
		return t[node];
	
	int mid = (tl+tr)/2;
	if(index <= mid)
		return min(t[node],pointQuery(t,2*node,tl,mid,index));
		
	return min(t[node],pointQuery(t,2*node+1,mid+1,tr,index));
}

void rangeUpdate(int* t, int node, int tl, int tr, int l, int r, int val) {
	if(r < l)
		return;
		
	if((tl == l) && (tr == r)) {
		t[node] = min(t[node],val);
	}
	else {
		int mid = (tl+tr)/2;
		if(r <= mid)
			rangeUpdate(t,2*node,tl,mid,l,r,val);
		else if(l > mid)
			rangeUpdate(t,2*node+1,mid+1,tr,l,r,val);
		else{
			rangeUpdate(t,2*node,tl,mid,l,mid,val);
			rangeUpdate(t,2*node+1,mid+1,tr,mid+1,r,val);
		}
		
		/*t[node] = min(t[node],t[2*node]);
		t[node] = min(t[node],t[2*node+1]);*/
	}
}

int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	for(int i = 0; i < 4*MAX_N; i++) {
		rows[i] = MAX_N+1;
		cols[i] = MAX_N+1;
	}
	
	int n,q;
	cin >> n >> q;
	long long total = (long long)(n-2)*(long long)(n-2);
	
	for(int i = 2; i < n; i++) {
		pointUpdate(rows,1,1,n,i,n);
		pointUpdate(cols,1,1,n,i,n);
	}
	
	//cout << rows[1] << ' ' << cols[1] << '\n';
	
	for(int i = 0; i < q; i++) {
		int query,x;
		cin >> query >> x;
		if(query == 1) {
			int row = pointQuery(cols,1,1,n,x)-1;
			//cout << "1" << ' ' << x << ' ' << row << '\n';
			rangeUpdate(rows,1,1,n,1,row,x);
			total -= (long long)max(0,row-1);
		}
		else {
			int col = pointQuery(rows,1,1,n,x)-1;
			//cout << "2" << ' ' << x << ' ' << col << '\n';
			rangeUpdate(cols,1,1,n,1,col,x);
			total -= (long long)max(0,col-1);
		}
		
	}
	
	cout << total << '\n';
	
	return 0;
}

Measured memory_bytes: 9892