akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int n, m;
vector<int>a[305];
int main(int args, const char * argv[]) {
    scanf("%d %d", &n, &m);
    int x;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j < m; ++j) {
            scanf("%d", &x);
            a[i].push_back(x);
        }
    }
    int ans = 1000000000;
    for(int t = 1; t <= m; ++t) {
        int cnt[305] = {0};
        bool ot = false;
        for(int i = 0; i < n; ++i) {
            if(a[i].empty()) {
                ot = true;
                break;
            }
            cnt[a[i][0]] ++;
        }
        if(ot) break;
        int mx = 0, mid = 0;
        for(int i = 1; i <= m; ++i) {
            if(mx < cnt[i]) {
                mx = cnt[i];
                mid = i;
            }
        }
        ans = min(ans, mx);
        for(int i = 0; i < n; ++i) {
            for(int j = 0; j <= m-t; ++j) {
                if(a[i][j] == mid) {
                    a[i].erase(a[i].begin()+j);
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 896
#include <iostream>

using namespace std;

int main(){
    int S;
    cin >> S;
    if(0 < S/100 && S/100 < 13){
        if(0 < S%100 && S%100 < 13){
            cout << "AMBIGUOUS" <<endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(0 < S%100 && S%100 < 13){
            cout << "YYMM" <<endl;
        }else{
            cout << "NA" << endl;
        }
    }
}

Measured memory_bytes: 256
#include<functional>
#include<algorithm>
#include<iostream>
#include<iomanip>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<string>
#include<cstdio>
#include<vector>
#include<bitset>
#include<cmath>
#include<ctime>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,K=200005,mod=1000000007;
const long long llinf=9223372036854775807ll;
//int & long long
int a;
string s;
int main(){
	cin>>a>>s;
	if(a<3200)
		cout<<"red";
	else
		cout<<s;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int dsu[200000+10], siz[200000+10];

int root(int i) {
	while(i != dsu[i]) {
		dsu[i] = dsu[dsu[i]];
		i = dsu[i];
	}
	return i;
}

void setUnion(int a, int b) {
	int r1 = root(a);
	int r2 = root(b);
	if(r1 != r2) {
		if(siz[r1] > siz[r2]) {
			siz[r1] += siz[r2];
			dsu[r2] = r1;
		}
		else {
			siz[r2] += siz[r1];
			dsu[r1] = r2;
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n,m;
		cin>>n>>m;
		for(int i=1; i<=n; i++) {
			dsu[i] = i;
			siz[i] = 1;
		}
		f(i,m) {
			int u,v;
			cin>>u>>v;
			setUnion(u,v);
		}
		int ans = 0;
		for(int i=1; i<=n; i++) {
//			cout<<siz[i]<<" ";
			ans = max(ans,siz[i]);
		}
		cout<<ans<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 5180
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    priority_queue<int> pq;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        pq.push(a);
    }
    for(int i = 0; i < m; i++){
        int e = pq.top(); pq.pop();
        pq.push(e / 2);
    }
    ll ans = 0;
    for(int i = 0; i < n; i++){
        ans += pq.top(); pq.pop();
    }
    cout << ans << '\n';
}


Measured memory_bytes: 892
def inpl(): return list(map(int, input().split()))
H, W = inpl()
S = [[0]*(W+2) for _ in range(H+2)]
for h in range(H):
    s = input()
    for w in range(W):
        S[h+1][w+1] = int(s[w] == ".")

WG1 = [[0]*(W+2) for _ in range(H+2)]
HG1 = [[0]*(W+2) for _ in range(H+2)]
WG2 = [[0]*(W+2) for _ in range(H+2)]
HG2 = [[0]*(W+2) for _ in range(H+2)]


for h in range(1, H+1):
    for w in range(1, W+1):
        WG1[h][w] = (WG1[h][w-1] + 1)*S[h][w]
for w in range(1, W+1):
    for h in range(1, H+1):
        HG1[h][w] = (HG1[h-1][w] + 1)*S[h][w]

for h in range(H, 0, -1):
    for w in range(W, 0, -1):
        WG2[h][w] = max(WG2[h][w+1], WG1[h][w])*S[h][w]

for w in range(W, 0, -1):
    for h in range(H, 0, -1):
        HG2[h][w] = max(HG2[h+1][w], HG1[h][w])*S[h][w]

ans = 0
for h in range(1, H+1):
    for w in range(1, W+1):
        ans = max(ans, WG2[h][w] + HG2[h][w])
print(ans-1)

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

void turn(string a,string b,string c,int counta,int countb,int countc,char x){
  char y ;
  if (counta==0 && x=='a'){
    y = 'A';
    cout<<y<<endl;
    return;
  }
  if (countb==0 && x == 'b'){
    y = 'B';
    cout <<y<<endl;
    return;
  }
  if (countc==0 && x == 'c'){
    y ='C';
    cout<< y<<endl;
    return;
  }
  if(x=='a'){
    y =a.at(a.size()-counta);
    counta--;
  }
  if(x=='b'){
    y =b.at(b.size()-countb);
    countb--;
  }
  if(x=='c'){
    y =c.at(c.size()-countc);
    countc--;
  }
  turn(a,b,c,counta,countb,countc,y);
}

int main(){
  string a,b,c;
  cin >>a>>b>>c;
  int counta=a.size(),countb=b.size(),countc=c.size();
  turn(a,b,c,counta,countb,countc,'a');
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int A,op,B,i;
	scanf("%d %s %d",&A,&op,&B);
	if(op=='+'){
		i=A+B;
		printf("%d\n",i);
	}
	else{
		i=A-B;
		printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

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

    int ans = INT_MAX;
    for(int i=0; i<n; ++i){
        int c, x;
        cin >> c >> x;
        if(x <= t)
            ans = min(ans, c);
    }

    if(ans < INT_MAX)
        cout << ans << endl;
    else
        cout << "TLE" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int bubbleSort(int a[], int n)
{
    bool flag = true;
    for (int i = 0; flag; i++)
    {
        flag = false;
        for (int j = n - 1; j >= i + 1; j--)
        {
            if (a[j - 1] > a[j])
            {
                swap(a[j - 1], a[j]);
                flag = true;
            }
        }
    }
}

int main()
{
    int a[5];
    cin >> a[0] >> a[1] >> a[2];

    bubbleSort(a, 3);
    for (int i = 0; i < 3; i++){
        cout << a[i];
        if (i < 2)
            cout << " ";
        else
            cout << endl;
    }
}


Measured memory_bytes: 3080
N=int(input())
A=input()
B=input()
C=input()

ans=0
for i in range(N):
  if A[i]==B[i]==C[i]:
    ans=ans
  elif A[i]!=B[i]!=C[i]!=A[i]:
    ans=ans+2
  else:
    ans=ans+1

print(ans)

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

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

using namespace std;

const int INF=1<<29;

int main(){
	int n,ma,mb; cin>>n>>ma>>mb;
	vector<int> a(n),b(n),c(n); rep(i,n) cin>>a[i]>>b[i]>>c[i];

	int dp[401][401];
	rep(y,401) rep(x,401) dp[y][x]=INF;
	dp[0][0]=0;
	rep(i,n){
		for(int y=400;y>=b[i];y--) for(int x=400;x>=a[i];x--) {
			dp[y][x]=min(dp[y][x],dp[y-b[i]][x-a[i]]+c[i]);
		}
	}

	int ans=INF;
	rep(y,401) rep(x,401) if(y>0 && x>0 && y*ma==x*mb) ans=min(ans,dp[y][x]);
	printf("%d\n",ans<INF?ans:-1);

	return 0;
}


Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int n = in.nextInt();
        int sum = 0;
        for (int i = 1; i <= n; i++){
            sum += i;
        }
        System.out.println(sum);
    }
}

Measured memory_bytes: 21972
//
//  main.cpp
//  CoderProj
//
//  Created by Minoru Hayashi on 2020/03/12.
//  Copyright © 2020 Minoru Hayashi. All rights reserved.
//
//
//
//

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

#define REP(i,n) for (int i=0; i<(n); i++)
#define REP2(i,x,n) for (int i=x; i<(n); i++)
#define ALL(n) begin(n), end(n)

using ll = long long;

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

//const ll INF = 1LL<<60;
// const int INF = 1<<29;
// const ll MOD = 1000000007;

//#define __DBG__

void solve(void){
  
  int A, B;
  
  cin >> A >> B;
  
  int ans = A-2*B;
  
  if(ans<=0){
    ans=0;
  }
  
  cout << ans << endl;

  return;
   
}


int main(int argc, const char * argv[]) {

    cin.tie(0);
    ios::sync_with_stdio(false);

    solve();
 
    return 0;
}


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

using namespace std;

typedef long long ll;

int n;
vector <int> ms[100005];
ll dp[100005][2];
const ll mod = (ll)1e9 + 7;

void dfs(int x, int p){
	dp[x][0] = dp[x][1] = 1;
	for(vector <int>::iterator i = ms[x].begin() ; i != ms[x].end() ; ++i){
		int o = *i;
		if(o == p)
			continue;
		dfs(o, x);
		dp[x][0] = (dp[x][0] * ((dp[o][0] + dp[o][1]) % mod)) % mod;
		dp[x][1] = (dp[x][1] * dp[o][0]) % mod;
	}
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> n;
for(int i = 0 ; i < n - 1 ; ++i){
	int x, y;
	cin >> x >> y;
	ms[x].push_back(y);
	ms[y].push_back(x);
}
dfs(1, -1);
cout << (dp[1][0] + dp[1][1]) % mod << endl;

return 0;
}



Measured memory_bytes: 14208
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;

using namespace std;

int inputValue(){
    int a;
    cin >> a;
    return a;
};

template<typename T>
void inputArray(T* p, int a){
    rep(i, a){
        cin >> p[i];
    }
};

void inputVector(vector<int> * p, int a){
    rep(i, a){
        int input;
        cin >> input;
        p -> push_back(input);
    }
}

template <typename T>
void output(T a, int precision = 0) {
    if(precision > 0){
        cout << setprecision(precision)  << a << "\n";
    }
    else{
        cout << a << "\n";
    }
}

#define Max 100
#define Bl '#'
#define Wh '.'

char S[Max][Max];
int c[Max][Max];
int H, W;

int count_around(int i, int j) {
    if (S[i][j] == Wh) return 0;

    int count = 1;
    if (i != 0) {
        if (S[i-1][j] == Bl) count += 1;
    }
    if (i != H - 1) {
        if (S[i+1][j] == Bl) count += 1;
    }
    if (j != 0) {
        if (S[i][j-1] == Bl) count += 1;
    }
    if (j != W - 1) {
        if (S[i][j+1] == Bl) count += 1;
    }
    return count;
}

int check(int i, int j) {
    if (S[i][j] == Wh) return 1;
    if (c[i][j] >= 2) return 1;
    if (i != 0) {
        if (c[i-1][j] >= 2) return 1;
    }
    if (i != H - 1) {
        if (c[i+1][j] >= 2) return 1;
    }
    if (j != 0) {
        if (c[i][j-1] >= 2) return 1;
    }
    if (j != W - 1) {
        if (c[i][j+1] >= 2) return 1;
    }
    return 0;
}

int main(int argc, const char * argv[]) {
    H = inputValue();
    W = inputValue();
    rep(i, H) {
        inputArray(S[i], W);
    }
    rep(i, H) {
        rep(j, W) {
            c[i][j] = count_around(i, j);
        }
    }


    int res = 1;
    rep(i, H) {
        rep(j, W) {
            res &= check(i, j);
        }
    }

    if (res) output("Yes");
    else output("No");

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  while(1){
    cin>>n;
    if(n==0)break;
    queue<int> que;
    vi a(n),b(n),c(n),d(n);
    rep(i,n)cin>>a[i]>>b[i]>>c[i]>>d[i];
    int p,q,r,cal;
    cin>>p>>q>>r>>cal;
    rep(i,n){
      int s=b[i]*4+c[i]*9+d[i]*4;
      if(b[i]<=p && c[i]<=q && d[i]<=r && s<=cal)
        que.push(a[i]);
    }
    if(que.size()==0)cout<<"NA"<<endl;
    while(que.size()){
      cout<<que.front()<<endl;
      que.pop();
    }
  }
}

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

int main() {
	int X,A,B;
	cin>>X>>A>>B;
	string ans="delicious";
	if(0<B-A&&B-A<=X)ans="safe";
	else if(B-A>X)ans="dangerous";
	cout<<ans<<endl;
}

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

int main(){
  int t; cin >> t;
  while(t--){
    vector<pair<int,char> > nc(9);
    int cnt[3][9]={};
    for(int i=0;i<9;++i) cin >> nc[i].first;
    for(int i=0;i<9;++i) cin >> nc[i].second;
    for(int i=0;i<9;++i)
      cnt[(nc[i].second=='R'?0:(nc[i].second=='G'?1:2))][nc[i].first-1]++;
    int flag=0;
    for(int i=0;i<3;++i){
      for(int j=0;j<9;++j){
	if(cnt[i][j]>=3) cnt[i][j]-=3,flag++;
	if(j<7){
	  while(cnt[i][j] && cnt[i][j+1] && cnt[i][j+2]) {
	    cnt[i][j]--; cnt[i][j+1]--; cnt[i][j+2]--;
	    flag++;
	  }
	}
      }
    }
    cout << (flag>=3?1:0) << endl;
  }
  
  return 0;
}



Measured memory_bytes: 3008
#include <stdio.h>
#include <algorithm>
#include <vector>
using namespace std;
#define PB push_back
constexpr int kN = int(3E3 + 10);
typedef long long int ll;
ll s[kN];
ll cal(ll &from, ll a, ll st, ll t, ll to) {
	//printf("cal(%lld, %lld, %lld, %lld, %lld)", from, a, st, t, to);
	ll ans = 0;
	if (from + (t - st) / a < to) {
		from += (t - st) / a + 1;
		ans = (t - st) / a + 1;
		//printf("(a)");
	}
	else {
		//printf("(b)");
		ans = to - from;
		from = to;
	}
	//printf(" = %lld\n", ans);
	return ans;
}
int main() {
	ll n, a, b, c, t, m, k, ans = 0, now, lst, cnt;
	vector<ll> v;
	scanf("%lld%lld%lld%lld%lld%lld%lld", &n, &m, &k, &a, &b, &c, &t);
	k -= m;
	for (int i = 1; i <= m; i++) scanf("%lld", &s[i]);
	m++;
	s[m] = n + 1;
	for (int i = 1; i < m; i++) if (b * (s[i] - 1) <= t) {
		lst = s[i];
		ans += cal(s[i], a, b * (s[i] - 1), t, s[i + 1]);
		now = b * (lst - 1) + c * (s[i] - lst);
		cnt = k;
		while (s[i] < s[i + 1] && now <= t && cnt--) {
			lst = s[i];
			v.PB(cal(s[i], a, now, t, s[i + 1]));
			now += c * (s[i] - lst);
		}
	} else break;
	sort(v.begin(), v.end());
	reverse(v.begin(), v.end());
	v.resize(k);
	//printf("v :"); for (int i = 0; i < k; i++) printf(" %lld", i); printf("\n");
	for (int i = 0; i < k; i++) if (v[i] > 0) ans += v[i];
	printf("%lld\n", ans - 1);
}



Measured memory_bytes: 6504
//******* It's LEVI_17 ***************

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

#define ff first
#define ss second
#define MP make_pair
#define mset(x,a) memset(x,a,sizeof(x))
#define max3(x,y,z) max(x,max(y,z))
#define min3(x,y,z) min(x,min(y,z))
#define sqr(a) (a)*(a)
#define all(x) (x).begin(), (x).end()
#define f(i, n) for (int i = 0; i < n; i++)
#define f1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define vvll vector<vector<ll>>  
#define vll vector<ll> 
#define pll pair<ll,ll>
#define vpll vector<pll>
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define cases ll t;cin >> t;while(t--)
#define rr return 0
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

#define deb(a)			std::cerr<<#a<<"="<<(a)<<"\n"
#define deb2(a,b)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<"\n"
#define deb3(a,b,c)		std::cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
const int MOD = 1000 * 1000 * 1000 + 7;

//syntax for priority queue
// max queue -> priority_queue<ll>
// min queue -> priority_queue<ll,vector<ll>,greater<ll>>

//##############################################################################################

ll getRes(ll arr[], ll n)
{
    ll dp[n+ 1] = { 0 };
    dp[0] = 0;
    dp[1] = 0;
    dp[2] = abs(arr[1] - arr[0]);
    for (ll i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(arr[i - 1] - arr[i - 2]), dp[i - 2] + abs(arr[i - 1] - arr[i - 3]));
    }

    return dp[n];
}

void solve()
{
    ll n;
    cin >> n;
    ll arr[100001];
    f(i, n)
        cin >> arr[i];
    if (n < 2)
    {
        cout << 0 << "\n";
        return;
    }
    //cout << n << " ";
    ll res = getRes(arr, n);
    cout << res << "\n";
}

//###############################################################################################

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


//Watashi wa tsuyoku modotte kimasu

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

void solve() {
  VAR(int, N);
  VAR(string, S);

  map<char, ll> mp;
  rep(i, 0, N) {
    mp[S[i]]++;
  }

  ll ans = mp['R'] * mp['G'] * mp['B'];

  rep(i, 1, N) {
    rep(j, 0, N) {
      if (j + i * 2 > N - 1) {
        break;
      }
      char si = S[j];
      char sj = S[j + i];
      char sk = S[j + i * 2];
      if (si != sj && sj != sk && si != sk) {
        ans--;
      }
    }
  }

  print(ans);
}


Measured memory_bytes: 3660
use std::io;


fn read_line() -> String {
    let mut line = String::new();

    io::stdin().read_line(&mut line)
        .expect("Failed to read line");
    return line;
}
fn to_i(s: &str) -> i64 {
    return s.trim().parse()
        .expect("Please type a number!");
}
fn read_nums() -> Vec<i64>
{
    let line = read_line();
    let items: Vec<&str> = line.split(' ').collect();

    let mut nums: Vec<i64> = Vec::new();

    for item in items {
        nums.push(to_i(item));
    }
    return nums;
}


fn main() {

     let ab = read_nums();
    let a = ab[0];
    let b = ab[1];

    let  ret;
    if a==b {
        ret = 2*a;
    } else if a>b {
        ret = 2*a-1;
    } else {
        ret = 2*b-1;
    }

    print!("{}", ret);
}   

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

const int MAX_SIZE = 100;

int calc(int a, int y, int n, int soc[], double air[], int aoc[]) {
  int r = 0;
  for (int i = 0; i < n; ++i) {
    int A = a;
    if (soc[i] == 0) {
      int interest = 0;
      for (int j = 0; j < y; ++j) {
        interest += A * air[i];
        A -= aoc[i];
      }
      A += interest;
    } else {
      for (int j = 0; j < y; ++j) {
        A += A * air[i] - aoc[i];
      }
    }
    r = max(r, A);
  }
  return r;
}

int main() {
  int a, n, m, y;
  int soc[MAX_SIZE], aoc[MAX_SIZE];
  double air[MAX_SIZE];
  cin >> m;
  for (int i = 0; i < m; ++i) {
    cin >> a >> y >> n;
    for (int j = 0; j < n; ++j) {
      cin >> soc[j] >> air[j] >> aoc[j];
    }
    cout << calc(a, y, n, soc, air, aoc) << endl;
  }
}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
// #define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};
 
struct Solver {
  long n, m;
  std::vector<std::array<long, 2>> xs;
  Solver() {
    S002 reader;
    reader >= n >= m >m>= xs;
  }
  void solve() {
    std::vector<long> ys(n, 0);
    for(auto x : xs) {
      ys[x[0]-1] += 1;
      ys[x[1]-1] += 1;
    }
    for(auto y : ys) {
      printf("%ld\n", y);
    }
  }
  ~Solver() { fprintf(stderr, "--end--\n"); }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}
 

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <sstream>
#include <queue> 
#include <list>
#include <stack>
#include <unordered_map>
#include <algorithm> 
#include <numeric>  
#include <functional>
#include <cassert>
#include <bitset>
#include <cctype>  
#include <iomanip> 
#include <limits>  
#include <regex>
// std::numeric_limits<int>::max(), min()
// std::setprecision(X)
// std::islower(), std::isupper(), std::tolower, std::toupper
// std::accumulate(m.begin(), m.end(), 0LL);
// std::sort(begin(),end()) // 0, 1, 2, 3 ,4 (default, less);
// std::priority_queue<int, vector<int>, less<int>> que; // 4, 3, 2, 1 (defualt, less) : 
// if ( std::regex_match(S, std::regex("(dream|dreamer|erase|eraser)*")) ) std::cout << "YES" << std::endl;
 
#define rep(i, n) for(int i = 0; i < (int)(n);    i++)
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;

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


int main (void) {
  std::cin.tie(0);  std::ios::sync_with_stdio(false);
  int N, K; std::cin >> N >> K;
  
  ll ans = K;
  for(int i=0; i<N-1; i++) ans *= (K-1);
  std::cout << ans << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    string s; cin>>s;
    ll l=0,r=sz(s)-1,ans=0;
    while(l<=r){
        if(s[l]!=s[r]){
            if(s[l]=='x') l++;
            else if(s[r]=='x'){
                r--;
            }
            else{
                cout<<-1<<endl;
                return 0;
            }
            ans++;
        }
        else{
            l++;
            r--;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3772
import sys
input = sys.stdin.readline
N,M = map(int,input().split())
A = [int(x) for x in input().split()]
import heapq
heap = []
for value in A:
    heapq.heappush(heap, -value)
for i in range(M):
    disc = heapq.heappop(heap)
    disc = -disc //2
    heapq.heappush(heap, -disc)
print(-sum(heap))

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

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

  long long ans = 0;
  while (true) {
    sort(a, a + n);
    if (a[n-1] < n) {
      break;
    }
    long long cnt = (a[n-1] -  n) / n + 1;
    ans += cnt;
    a[n-1] -= cnt * n;
    bool ok = true;
    for (int i=0; i<n-1; i++) {
      a[i] += cnt;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,l,n) for(int i = l; i < (n); i++)
using namespace std;
using ll = long long;
int func(int n, int k) {
  rep(i,0,101) {
    if(n >= k) return i;
    n *= 2;
  }
}
int main() {
  int n,k;
  double ans = 0;
  scanf("%d %d",&n,&k);
  double t = pow(n,-1);
  rep(i,1,n+1) {
    int tmp = func(i,k);
    ans += t*pow(pow(2,tmp),-1);
  }
  printf("%.12f\n",ans);
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0)
        printf("Possible\n");
    else
        printf("Impossible\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int main (void)
{
	int n, a[110];
	int i;

	scanf("%d",&n);
	for(i=0; i<n; i++) scanf("%d",&a[i]);
	
	for(i=n-1; i>=0; i--){
		if(i != 0) printf("%d ",a[i]);
		else printf("%d\n",a[i]);
	}

	return 0;

}

Measured memory_bytes: 596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		try (Scanner scn = new Scanner(System.in)) {
			int A = scn.nextInt();
			int B = scn.nextInt();
			int C = scn.nextInt();
			int K = scn.nextInt();

			int result = 0;
			boolean flg = false;

			if(K <= A) {
				result = K;
				flg = true;
			} else {
				result = A;
				K -= A;
			}

			if(!flg) {
				if(K <= B) {
					flg = true;
				} else {
					K -= B;
					result = result - K;
				}
			}
			System.out.println(result);
		}
	}
}

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

int zettaichi(int n)
{
	if (n < 0)
	{
		return -n;
	}
	else
	{
		return n;
	}
}

int main()
{
	int N,L,taste;
	cin >> N >> L;
	int ans = 0;
	int small = 1000000;
	int Zsmall = 1000000;
	for (int i = 0; i < N; ++i)
	{
		taste = L + i;
		if (zettaichi(taste) < Zsmall)
		{
			small = taste;
			Zsmall = zettaichi(taste);
		}
		ans += taste;
	}
	ans -= small;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#ifdef Prateek
  #include "Prateek.h"
#else
  #include <bits/stdc++.h>
  using namespace std;
  #define debug(...) 42
#endif
#define F first
#define S second
#define pb push_back
#define f(i,x,n) for(int i=x;i<n;i++)
#define all(c) c.begin(),c.end()
#define int ll
using ll = long long;
const int MOD = 998244353, N = 2e5 + 10; 

int dp[N];
int pre[N];

// dp[2] = dp[2-1]
// dp[2] = dp[2-1];
// dp[5] = dp[5-1]+dp[5-3]+dp[5-4]
// dp[5] = dp[4]+dp[2]+dp[1];

int32_t main(){
   ios::sync_with_stdio(false);
   cin.tie(NULL);
   int n,k;
   cin >> n >> k;
   vector<pair<int, int>> A(k);   
   for(int i = 0; i < k; i++){
      int x,y;
      cin >> x >> y;
      A[i] = {x,y};
   }
   sort(all(A));
   memset(dp,0,sizeof dp);
   pre[1] = dp[1] = 1;
   for(int i = 2; i <= n; ++i){
      for(auto &[l,r] : A){
         if(l > i) break;
         int R = min(i,r);
         // debug(i,l,R);
         if(l == R){
            dp[i] += dp[i-l];
            // debug(i,dp[i],dp[i-l]);
         }else{
            dp[i] += pre[i-l]-pre[i-R-1]+MOD;;
         }
         dp[i] %= MOD;
      }
      // debug(dp[i]);
      pre[i] = pre[i-1]+dp[i];
      pre[i] %= MOD;
   }
   cout << dp[n] << '\n';
   return 0;
} 

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

int main()
{
    string s;
    cin >> s;
    int q;
    cin >> q;
    string t;
    rep(qi, q) {
        int ty;
        cin >> ty;
        if(ty == 1) {
            swap(s,t);
        }
        else {
            int f;
            char c;
            cin >> f >> c;
            if(f == 1) {
                t += c;
            }
            else {
                s += c;
            }
        }
    }
    reverse(t.begin(), t.end());
    t += s;
    cout << t << endl;
    return 0;
}


Measured memory_bytes: 3984
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		int a=scanner.nextInt();
		int b=scanner.nextInt();
		int k=scanner.nextInt();
		Set<Integer>set=new TreeSet<>();
		
		for(int i=0;i<k;i++) {
			int tar=a+i;
			if(tar<=b)set.add(tar);
			else break;
		}
		
		for(int i=k;i>0;i--) {
			int tar=b-i+1;
			if(tar>=a)set.add(tar);
			else break;
		}
		
		for(int i:set) {
			System.out.println(i);
		}
	}
}


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

public class Program
{
    static void Main()
    {
        var s = Console.ReadLine();
        if (s.Substring(0, 1) == "A" && char.IsLower(s[1]))
        {
            var buf = s.Substring(2).ToCharArray();
            if (buf.Last() != 'C' && buf.Where(x => x == 'C').Count() == 1)
            {
                if (buf.Where(x => x != 'C').All(x => char.IsLower(x)))
                {
                    Console.WriteLine("AC");
                    return;
                }
            }
        }

        Console.WriteLine("WA");
    }
}

Measured memory_bytes: 11348
H, W = map(int, input().split())
cost = []
INF = 10**9
for i in range(10):
  cost.append(list(map(int, input().split())))
for i in range(10):
  cost[i][i] = INF
A = []
for i in range(H):
  A.append(list(map(int, input().split())))

d = [INF]*10
used = [False] *10
V = 10
def shortest_path(start = 1):#隣接行列の場合のダイクストラ法
  d[start] = 0
  while True:
    v = -1
    for u in range(V):
      if (not used[u]) and (v == -1 or d[u] < d[v]):v = u
    if v == -1:break
    used[v] = True
    for u in range(V):
      d[u] = min(d[u], d[v] + cost[u][v])
  
def main():
  shortest_path()
  ans = 0
  for i in range(H):
    for j in range(W):
      if A[i][j] != -1:
        ans += d[A[i][j]]
  print(ans)
if __name__ == "__main__":
  main()

Measured memory_bytes: 3444
import sys
import itertools
# import numpy as np
import time

sys.setrecursionlimit(10 ** 7)

from collections import defaultdict

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

n = int(readline())
a = [0 for _ in range(n)]
b = [0 for _ in range(n)]
for i in range(n):
    a[i], b[i] = (map(int, readline().split()))

a = sorted(a)
b = sorted(b)

if n % 2 == 0:
    n = n // 2
    l = (a[n - 1] + a[n])
    r = (b[n - 1] + b[n])
    print(r - l + 1)
else:
    n = n // 2
    l = a[n]
    r = b[n]
    print(r - l + 1)



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

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

    vector<int> A(N);
    int maxA = 0;
    int secondMax = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
        if (maxA <= A[i]) {
            secondMax = maxA;
            maxA = A[i];
        } else if (secondMax < A[i]) {
            secondMax = A[i];
        }
    }

    for (int i = 0; i < N; ++i) {
        int out = maxA;
        if (maxA == A[i]) {
            out = secondMax;
        }
        cout << out << endl;
    }

    return 0;
}



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

int D[4][2] = {{1,0},{0,1},{0,-1},{-1,0}};
int N , M;
bool vu[20][20];
char tab[20][20];
void reset()
{
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			vu[i][j] = false;
		}
	}
}

bool dedans(int x , int y)
{
	if (x < 0 || y < 0 || x >= N || y >= M) return false;
	return true;
}

int main()
{
	cin >> N >> M;
	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ; j < M ; j++)
		{
			cin>>tab[i][j];
		}
	}
	int sol = 0;

	for (int i = 0 ; i < N ; i++)
	{
		for (int j = 0 ;j < M ; j++)
		{
			if (tab[i][j] == '#') continue;
			reset();
			deque<int> enCours;
			enCours.push_back(i);
			enCours.push_back(j);
			enCours.push_back(0);
			int maxi = 0;
			vu[i][j] = true;
			while (!enCours.empty())
			{
				int x = enCours.front(); enCours.pop_front();
				int y = enCours.front(); enCours.pop_front();
				int d = enCours.front(); enCours.pop_front();
				maxi = max(maxi , d);
				for (int k = 0 ; k < 4 ; k++)
				{
					int nx = x + D[k][0];
					int ny = y + D[k][1];
					if (dedans(nx , ny) && tab[nx][ny] == '.' && !vu[nx][ny])
					{
						vu[nx][ny] = true;
						enCours.push_back(nx);
						enCours.push_back(ny);
						enCours.push_back(d + 1);
					}
				}
			}
			sol = max(maxi , sol);
		}
	}
	cout<<sol<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define cina(a, n) for (int i = 0; i < n; ++i){ cin >> a[i]; }
#define ll long long
#define ld long double

using namespace std;

int main () {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ld l;
	cin >> l;
	printf("%.12Lf", powl((ld)l/3.0, 3));

	return 0;
}

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

unsigned long lcm(unsigned long a, unsigned long b) {
  unsigned long long c = a * b;

  if (a < b) {
    swap(a, b);
  }

  unsigned long mod = a % b;
  while (mod != 0) {
    a = b;
    b = mod;
    mod = a % b;
  }

  return c / b;
}

int main() {
  unsigned long long A, B;
  unsigned long C, D;
  cin >> A >> B >> C >> D;

  unsigned long total = B - A + 1;

  unsigned long long c_count = B / C - (A - 1) / C;
  unsigned long long d_count = B / D - (A - 1) / D;

  unsigned long CD = lcm(C, D);
  unsigned long long cd_count = B / CD - (A - 1) / CD;

  unsigned long count = total - (c_count + d_count - cd_count);
  cout << count << endl;
}

Measured memory_bytes: 256
'use strict'
function Main(input) {
  input = input.split("\n")
  let line1 = input[0].split(' ')
  let N = parseInt(line1[0])
  let M = parseInt(line1[1])
  let A = input[1].split(' ')
  let cnt = {}
  let ret = 0
  let cur = 0
  for (let i = 0; i < N; i += 1) {
    cur = (cur + parseInt(A[i])) % M
    if (cur === 0) ret += 1
    if (typeof cnt[cur] === 'undefined') {
      cnt[cur] = 1
    } else {
      ret += cnt[cur]
      cnt[cur] += 1
    }
  }
  console.log(ret)
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"))

Measured memory_bytes: 23412
/*
    In the name of Allah

    MohammadErfan Gooneh

*/
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;

#define endl                        '\n'
#define all(a, n)                   for (int i = 0; i < n; i++) cout << a[i] << " "; cout << endl;
#define IOS                         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);


const ll MAXN = 1e6 + 10;
const ll INF = 8e18;
const ll MOD = 1e9 + 7;
int main() {
    IOS ;
    int a , b  ;
    double c ;
    cin >> a >> b >> c ;
    c+=0.5 ;
    cout << (int)c/a * b ;



























return 0 ;
}


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

int main(){
	string s1,s2;
	cin>>s1>>s2;
	int n1 = s1.length();
	int n2 = s2.length();
	if (n1 = n2 + 1){
		for (int i = 0; i<s1.size(); i++){
			if (s1[i] != s2[i]){
				cout<<"No";
				return 0;
			}
		}
		cout<<"Yes";
	}
	else{
		cout<<"No";
	}
}

Measured memory_bytes: 3624
N, T = map(int, input().split())
t_list = list(map(int, input().split()))

diff_t = [t_list[i+1] - t_list[i] for i in range(N-1)]

ans = 0
for dt in diff_t:
    if dt <= T:
        ans += dt
    else:
        ans += T

ans += T
print(ans)

Measured memory_bytes: 97616
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

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

  vector<int> a(N,0);
  vector<int> packet(N+1,0);

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

  sort(packet.begin(), packet.end(), std::greater<int>());

  int  ans=0;
  for (int i = 0; i < N; ++i) {
    if(i > K-1)
      ans+=packet[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{

    long n;
    string s;
    cin >> n;
    cin >> s;
    vector<long> vec(n, 0);
    for (long i = 0; i < s.size(); i++)
    {
        if (s[i] == 'R')
        {
            vec.at(i) = 1;
        }
    }
    long start = 0;
    long end = s.size() - 1;
    long counter = 0;
    while (true)
    {
        while (true)
        {
            if (start >= end)
            {
                break;
            }
            if (vec.at(start) == 0)
            {
                break;
            }
            start++;
        }
        while (true)
        {
            if (start >= end)
            {
                break;
            }
            if (vec.at(end) == 1)
            {
                break;
            }
            end--;
        }

        if (start >= end)
        {
            break;
        }
        counter++;
        start++;
        end--;
    }
    cout << counter << endl;
    return 0;
}


Measured memory_bytes: 5236
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <map>
#include <functional>
#include <cstring>
#include <queue>
#include <cmath>
#include <deque>
#include <list>
#include <iomanip>
#include <fstream>
#include <string>
#include <iterator>
#include <set>
#include <bitset>
using namespace std;

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const int MAXN = 2007;
const int MOD = 1000000007;
const int INF = 1000000000;
const LL LINF = INF * (LL)INF;
const LD PI = acos(-1.0);

vector <int> G[MAXN];
bool used[MAXN];
int D[MAXN][MAXN], S[MAXN], n, k, ans = INF;

void dfs(int r, int v)
{
	used[v] = true;
	REP(i, SZ(G[v]))
	{
		int to = G[v][i];
		if (!used[to]) 
		{
			D[r][to] = D[r][v] + 1;
			dfs(r, to);
		}
	}
}

int main()
{
	ios_base::sync_with_stdio(0);
	//freopen("In.txt", "r", stdin);
	//freopen("hear.in", "r", stdin);
	//freopen("hear.out", "w", stdout);
	cin >> n >> k;
	REP(i, n - 1)
	{
		int a, b;
		cin >> a >> b;
		--a; --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	REP(i, n)
	{
		memset(used, 0, MAXN);
		D[i][i] = 0;
		dfs(i, i);
	}
	if (k & 1)
	{
		REP(v, n)
		{
			REP(i, SZ(G[v]))
			{
				int u = G[v][i], cur = 0;
				REP(w, n)
					if (D[w][v] <= k / 2 || D[w][u] <= k / 2) ++cur;
				ans = min(ans, n - cur);
			}
		}
	}
	else
	{
		REP(v, n)
		{
			int cur = 0;
			REP(w, n) if (D[w][v] <= k / 2) ++cur;
			ans = min(ans, n - cur);
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 16256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

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

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

    int t = 0, r = 1 << 30;
    for (int i = 0; i < n - 1; i++) {
        t += w[i];
        r = min(r, abs(t - (s - t)));
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int n;
	scanf("%d", &n);
	
	if(n%10==7){
		printf("Yes\n");
	}
	else if((n/10)%10==7){
		printf("Yes\n");
	}
	else if(n/100==7){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	
	return 0;
}

Measured memory_bytes: 1640
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        
        Scanner scan = new Scanner(System.in);
        
        String a = scan.next();
        String b = scan.next();
        
        if (a.equals(b)) {
            System.out.println("H");
        }
        
        else {
           System.out.println("D");
        } 
    }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
#define f first
#define se second
#define pb push_back
#define ms memset
#define MOD 1000000007
#define MOD2 1000000009
#define sp fixed<<setprecision
#define sz(x) (int)(x).size()
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
ll fpow(ll x,ll y,ll p=MOD){x=x%p;ll sum=1;while(y){if(y&1)sum=sum*x;sum%=p;y=y>>1;x=x*x;x%=p;}return sum;}
ll inv(ll a,ll m=MOD){ll c=m;ll y=0,x=1;if(m==1)return 0;while(a>1){ll q=a/m;ll t=m;m=a%m,a=t;t=y;y=x-q*y;x=t;}if(x<0)x+=c;return x;}
ll add(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD + b%MOD + MOD)%MOD;}
ll sub(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return (a%MOD - b%MOD + MOD)%MOD;}
ll mul(ll a, ll b) {if(a<0)a+=MOD; if(b<0)b+=MOD; return ((a%MOD)*(b%MOD) + MOD)%MOD;}
void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if (sz(name)) {
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}
int main(){
    setIO();
    string s;
    cin>>s;
    ll rem=0;
    for(int i=0;i<s.size();i++){
      rem+=(s[i]-'0');
      rem%=9;
    }
    if(rem==0)
      cout<<"Yes\n";
    else
      cout<<"No\n";

}


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

P dp[200005];

int main() {
  string s;
  cin>>s;
  if (s.size()==1) {
    cout<<1<<endl;
    return 0;
  }
  dp[0]={1,1};
  if (s[0]==s[1]) dp[1]={1,2};
  else dp[1]={2,1};
  for (int i=2; i<s.size(); i++) {
    if (!(dp[i-1].second==1&&s[i]==s[i-1])) {
      if (dp[i].first<dp[i-1].first+1) {
	dp[i].first=dp[i-1].first+1;
	dp[i].second=1;
      }
    }
    if (!(dp[i-2].second==2&&(s[i-3]==s[i-1]&&s[i-2]==s[i]))) {
      if (dp[i].first==dp[i-2].first+1) {
	dp[i].second=3;
      }
      if (dp[i].first<dp[i-2].first+1) {
	dp[i].first=dp[i-2].first+1;
	dp[i].second=2;
      }
    }
  }
  cout<<dp[s.size()-1].first<<endl;      
  return 0;
}



Measured memory_bytes: 2180