akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define size_t unsigned long long
#define ll long long
#define rep(i,a) for(int i=0;i<(a);i++)
#define repr(i,a) for(int i=(int)(a)-1;i>=0;i--)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORR(i,a,b) for(int i=(int)(b)-1;i>=a;i--)
#define ALL(a) a.begin(), a.end()
using namespace std;
int si() { int x; scanf("%d", &x); return x; }
long long sl() { long long x; scanf("%lld", &x); return x; }
string ss() { string x; cin >> x; return x; }
void pi(int x) { printf("%d ", x); }
void pl(long long x) { printf("%lld ", x); }
void pd(double x) { printf("%.15f ", x); }
void ps(const string &s) { printf("%s ", s.c_str()); }
void br() { putchar('\n'); }

const ll MOD = 1e9 + 7;
const ll INF = 1e9 + 5;

struct mint {
    int n;
    mint(int n_ = 0) : n(n_) {}
};

mint operator+(mint a, mint b) { a.n += b.n; if (a.n >= MOD) a.n -= MOD; return a; }
mint operator-(mint a, mint b) { a.n -= b.n; if (a.n < 0) a.n += MOD; return a; }
mint operator*(mint a, mint b) { return (long long)a.n * b.n % MOD; }
mint &operator+=(mint &a, mint b) { return a = a + b; }
mint &operator-=(mint &a, mint b) { return a = a - b; }
mint &operator*=(mint &a, mint b) { return a = a * b; }

typedef pair<int, int> P;

const ll N = 1e5+5;
string s;
vector<ll> v[N];
ll n;
ll a[N];
ll c[3][N];

ll dp[N];

ll mod(ll a, ll m) {
    return (a % m + m) % m;
}

// a*b/m
ll mul(ll a, ll b, ll m) {
    a = mod(a, m); b = mod(b, m);
    if (b == 0) return 0;
    ll res = mul(mod(a + a, m), b>>1, m);
    if (b & 1) res = mod(res + a, m);
    return res;
}

int main () {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cin >> n;
  rep(i,n) cin >> a[i];
  dp[0] = 1;
  for(int i = 1; i <= n; i++) {
    int count = 0;
    bool flag = false;
    rep(j,3) {
      c[j][i] = c[j][i-1];
      if(c[j][i] == a[i-1]) {
        if(!flag) {
          c[j][i] += 1;
          flag = true;
        }
        count++;
      }
    }
    dp[i] = mul(dp[i-1], count, MOD);
  }
  cout << dp[n] << endl;
}


Measured memory_bytes: 6528
#include<bits/stdc++.h>
#define ll long long
#define gcd(x,y) __gcd(x,y)
#define mp make_pair
#define fi first
#define se second
#define fixed(x) fixed<<setprecision(x)
const ll MOD = (1e9)+7;
const ll mod = 998244353;
const ll inf=(1LL<<62);
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline A abs(A &a) { return (a < 0 ? -a : a); }
using namespace std;
signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  ll h[1000000], dp[1000000];
  cin >> n >> k;
  for (int i = 0; i < n; i++) {
    cin >> h[i];
    dp[i] = inf;
  }

  dp[0] = 0;

  for (int i = 0; i < n; i++) {
    for (int j = 1; j <= k; j++) {
      chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
    }
  }

  cout << dp[n - 1] << "\n";

  return (0);
}


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

int main(){
  int A[3];
  int num_5=0,num_7=0;
  for(int i=0;i<3;i++){
    cin>>A[i];
    if(A[i]==5){
      num_5++;
    }else if(A[i]==7){
      num_7++;
    }
  }

  if(num_5==2&&num_7==1){
    // printf("yes\n");
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int  n;
    cin >> n;
    int s[n];
    rep(i, 0, n) cin >> s[i];
    int q;
    cin >> q;
    int t[q];
    rep(i, 0, q) cin >> t[i];

    int ans = 0;
    rep(i, 0, q) {
        int left = 0;
        int right = n - 1;
        while(left <= right) {
            int mid = (left + right) / 2;
            if (t[i] == s[mid]) {
                ans ++;
                break;
            } else if (t[i] < s[mid]) {
                right = mid - 1;
            } else {
                left = mid + 1;
            }
        }
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3680
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

int main() {
  string s;
  int k;
  cin>>s>>k;
  string a[5]={"zzzzz","zzzzz","zzzzz","zzzzz","zzzzz"};
  for (int i=0; i<s.size(); i++) {
    for (int j=1; j<=k; j++) {
      if (i+j-1>s.size()-1) continue;
      string b=s.substr(i,j);
      for (int l=0; l<k; l++) {
	if (a[l]==b) break;
	if (a[l]>b) {
	  for (int m=k-1; m>l; m--) {
	    a[m]=a[m-1];
	  }
	  a[l]=b;
	  break;
	}
      }
    }
  }
  
  cout<<a[k-1]<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char* argv[])
{
	int N,M;
	cin>>N>>M;

	int i;
	string T;
	for (i=0;i<N;i++){
		T+=" ";
	}
	int s;
	char c;
	for (i=0;i<M;i++){
		cin>>s>>c;
		if (T[s-1]==' '){
			T[s-1]=c;
		}else if (T[s-1]!=c){
			cout<<-1<<endl;
			return 0;
		}
	}
	if (T[0]=='0'){
		if (T.size()==1){
			cout<<T<<endl;
			return 0;
		}else{
			cout<<-1<<endl;
			return 0;
		}
	}
	for (i=0;i<N;i++){
		if (T[i]==' '){
			if (i==0 && N>1){
				T[i]='1';
			}else{
				T[i]='0';
			}
		}
	}
	cout<<T<<endl;
	return 0;
}

Measured memory_bytes: 256
/**
 *     author: qodjf
 *     created: 04.21.2020 00:39:18
 */
#include <bits/stdc++.h>
using namespace std;

string to_string(string s) { return '"' + s + '"'; }

string to_string(const char *s) { return to_string((string)s); }

string to_string(bool b) { return (b ? "true" : "false"); }

template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}

void debug_out() { cerr << endl; }

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}

#ifndef ONLINE_JUDGE
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

#define mst(x, a) memset(x, a, sizeof(x))

using ll = long long;
using P = pair<int, int>;
using T = tuple<int, int, int>;
const int INF = 0x3f3f3f3f;
const ll LLINF = 0x3f3f3f3f3f3f3f3f;
const ll MOD = 1e9 + 7;

int dx[4] = {-1, 1, 0, 0};
int dy[4] = {0, 0, -1, 1};

int main() {
  int N, K, C;
  cin >> N >> K >> C;
  string s;
  cin >> s;
  vector<int> dpleft(N + C + 10, 0), dpright(N + C + 10, 0);
  for (int i = 0; i < N; i++) {
    if (s[i] == 'x') {
      dpleft[i + C + 1] = dpleft[i + C];
    } else {
      dpleft[i + C + 1] = max(dpleft[i + C], 1 + dpleft[i]);
    }
  }
  for (int i = N - 1; i >= 0; i--) {
    if (s[i] == 'x') {
      dpright[i] = dpright[i + 1];
    } else {
      dpright[i] = max(dpright[i + 1], 1 + dpright[i + C + 1]);
    }
  }
  dbg(dpleft, dpright);

  vector<bool> ans(N, true);
  if (C == 0) {
    for (int i = 0; i < N; i++) {
      if (dpleft[i] + dpright[i + 1] >= K) {
        ans[i] = false;
      }
    }
  } else {
    int rightmost = 0;
    for (int i = -C; i < N; i++) {
      if (dpleft[i + C + 1] + dpright[i + C + 1] >= K) {
        for (int j = max(i + 1, rightmost); j < min(N, i + C + 1); j++) {
          if (s[j] == 'o') ans[j] = false;
        }
        rightmost = i + C + 1;
      }
    }
  }

  for (int i = 0; i < N; i++) {
    if (s[i] == 'o' && ans[i]) {
      cout << i + 1 << endl;
    }
  }
}


Measured memory_bytes: 9288
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int mx=3007;


int main()
{

    string s1,s2;
    cin>>s1>>s2;
    int i,j,n1=s1.size(),n2=s2.size();
    int dp[n1+1][n2+1];

    for(i=n1;i>=0;i--)
        for(j=n2;j>=0;j--)
    {
        if(i==n1||j==n2)
            dp[i][j]=0;
        else if(s1[i]==s2[j])
            dp[i][j]=dp[i+1][j+1]+1;
        else
            dp[i][j]=max(dp[i+1][j],dp[i][j+1]);
    }

    i=0;j=0;
    while(i<s1.size()&&j<s2.size())
    {
        if(s1[i]==s2[j])
        {cout<<s1[i];
        i++;j++;}
        else if(dp[i+1][j]>dp[i][j+1])
            i++;
        else
            j++;
    }
    cout<<endl;

    return 0;
}



Measured memory_bytes: 35456
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9+7;

int main(void) {

    ll N; cin>>N;
    ll minimum = 1000000000;
    for (ll i = 1; i*i <= N; ++i) {
        if(N % i == 0){
            ll b = N/i;
            minimum = min(minimum, max(i,b));
        }
    }
    cout<<ll(log10(minimum))+1<<endl;

    return 0;
}


Measured memory_bytes: 640
var
	X:Longint;
function isp(N:Longint):Boolean;
var i:Longint;
begin
	i:=2;
	while i*i<=N do begin
		if N mod i=0 then begin
			isp:=false;
			exit;
		end;
		inc(i);
	end;
	isp:=true;
end;
begin
	read(X);
	while not isp(X)do inc(X);
	writeln(X);
end.


Measured memory_bytes: 128
def BubbleSort(C,N):
    for i in range(N):
        for j in reversed(range(i+1,N)):
            if C[j][1] < C[j-1][1]:
                sw = C[j]
                C[j] = C[j-1]
                C[j-1] = sw
    print(" ".join(C))

def SelectionSort(C,N):
    for i in range(N):
        minj = i
        for j in range(i,N):
            if C[j][1] < C[minj][1]:
                minj = j
        sw = C[i]
        C[i] = C[minj]
        C[minj] = sw
    print(" ".join(C))

n = int(input())
cardlistB = [x for x in input().split()]
cardlistS = []

for c in cardlistB:
    cardlistS.append(c)

BubbleSort(cardlistB,n)

print("Stable")

SelectionSort(cardlistS,n)

if cardlistB == cardlistS:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 5612
#include <bits/stdc++.h>
using namespace std;
#define INF 1000000000
int dp[100005], arr[100005];
bool record[100005];
int solve(int current, int n, int k)
{
	if (current == n)
		return 0;
	if (record[current])
		return dp[current];
	int res = INF;
	for (int i = 1; i <= k; ++i) {
		res = min(res, (current + i <= n)? abs(arr[current] - arr[current + i]) + solve(current + i, n, k): INF);
	}
	record[current] = true;
	return dp[current] = res;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n, k;
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
		cin >> arr[i];
	cout << solve(0, n - 1, k) << '\n';
	return 0;
}

Measured memory_bytes: 8960
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

vl a,b;

ll dfs(ll n,ll k){
	if(!k) return 0;
	if(!n) return 1;
	if(k<=a[n-1]+1) return dfs(n-1,k-1);
	return b[n-1]+1+dfs(n-1,min(a[n-1],k-a[n-1]-2));
}

ll n,k;

int main(){
	cin>>n>>k;
	a=b=vl(n+1);
	a[0]=b[0]=1;
	for(int i=1;i<=n;i++){
		a[i]=2*a[i-1]+3;
		b[i]=2*b[i-1]+1;
	}
	cout<<dfs(n,k)<<endl;
}

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

int main(int argc, const char * argv[]) {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int N, C, K;
    cin >> N >> C >> K;
    vector<int> arrive_at(N);
    for (int i = 0; i < N; i++) {
        cin >> arrive_at.at(i);
    }
    sort(arrive_at.begin(), arrive_at.end());
    
    int cnt = 1;
    int top_time = arrive_at.at(0);
    int occupation = 1;
    for (int i = 1; i < N; i++) {
        if (arrive_at.at(i) <= top_time + K && occupation < C) occupation++;
        else if (arrive_at.at(i) > top_time || occupation >= C) {
            cnt++;
            top_time = arrive_at.at(i);
            occupation = 1;
        }
    }
        
    cout << cnt << endl;
    
    return 0;
}


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

int a, b, cnt = 0, edge[18][18];  // x:2 y:1

void search(int x, int y) {
	if (x == a && y == b) {
		cnt++;
		return;
	}
	switch (edge[x][y]) {
	case 0:
		return;
	case 1:
		search(x, y + 1);
		break;
	case 2:
		search(x + 1, y);
		break;
	case 3:
		search(x, y + 1);
		search(x + 1, y);
		break;
	}
	return;
}



int main() {
	int n, tmpx, tmpy, i, j;
	while (1) {
		cin >> a >> b;
		if (a == 0 && b == 0)break;

		//init
		cnt = 0;
		for (i = 1; i < a; i++) {
			for (j = 1; j < b; j++) {
				edge[i][j] = 3;
			}
		}
		for (i = 1; i < a; i++) {
			edge[i][b] = 2;
		}
		for (j = 1; j < b; j++) {
			edge[a][j] = 1;
		}

		cin >> n;
		for (int i = 0; i < n; i++) {
			cin >> tmpx >> tmpy;
			edge[tmpx - 1][tmpy] = 1;
			edge[tmpx][tmpy - 1] = 2;
			edge[tmpx][tmpy] = 0;
		}

		search(1, 1);

		cout << cnt << endl;

	}






	return 0;
}

Measured memory_bytes: 3044
n,m=map(int,input().split())
inl=list(input())
try:
    for t in range(n):
        int(inl[t])
    for s in range(m):
        int(inl[n+1+s])
    if inl[n]=="-":
        print("Yes")
    else:
        print("No")
except Exception as e:
    print("No")

Measured memory_bytes: 38256
import sys

input_methods=['clipboard','file','key']
using_method=0
input_method=input_methods[using_method]

IN=lambda : map(int, input().split())
mod=1000000007

#+++++

def check(a,b,c):
	#return a+b+2*((ab)**0.5) < c
	if a+b > c:
		return False
	return 4*a*b < (c-a-b)**2

def main():
	a, b , c = IN()
	ret = 'Yes' if check(a,b,c) else 'No'
	print(ret)
	
	
	
#+++++
isTest=False

def pa(v):
	if isTest:
		print(v)
		
def input_clipboard():
	import clipboard
	input_text=clipboard.get()
	input_l=input_text.splitlines()
	for l in input_l:
		yield l

if __name__ == "__main__":
	if sys.platform =='ios':
		if input_method==input_methods[0]:
			ic=input_clipboard()
			input = lambda : ic.__next__()
		elif input_method==input_methods[1]:
			sys.stdin=open('inputFile.txt')
		else:
			pass
		isTest=True
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define LINY "YES\n"
#define Liny "Yes\n"
#define LINN "NO\n"
#define Linn "No\n"
#define umap unordered_map
//std::cout << std::setfill('0') << std::right << std::setw(4) << 12; // "0012"

ll min(ll x,ll y){return (x<y ? x:y);}
ll max(ll x,ll y){return (x>y ? x:y);}
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a*b /gcd(a,b);}

bool check(ll num){
  vector<int> v = {3,5,7};
  bool flag = true;
  for(int a:v){
    bool exist = false;
    int temp = num;
    while(temp>0){
      if(temp%10==a){exist=true;break;}
      temp /= 10;
    }
    if(!exist){flag =false;break;}
  }
  return flag;
}

ll N;
ll dfs(ll num){
  if(num>N){return 0;}
  ll r = check(num);
  vector<int> v = {3,5,7};
  for(int add:v){
    r += dfs(num*10+add);
  }
  return r;
}

int main(){
  cin >> N;
  ll r = dfs(0);
  printf("%Ld\n",r);
}


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

typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> isPair;
using vvll = vector< vector<ll> >;
using vll = vector<ll> ;
#define Pll pair<ll,ll>
#define vpll vector<pll>
#define sll set<ll>
#define mll map<ll,ll>

const ll oo=1e18;
const ll maxs = 3e5+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
#define mp make_pair
#define I insert
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define ff first
#define ss second
#define LB lower_bound
#define UB upper_bound
#define line() cout<<endl;
#define fr(i,a,b) for(int i=a;i<=b;++i)
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fastio(); ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define mst(x,a) memset(x,a,sizeof(x))

int main() 
{
    fastio();
	ll t=1;
    //cin>>t;
    while(t--){
        ll n,k;
        cin>>n>>k;
        ll ANS=0;
        ll i=k;
        while(k<=n)
        {
            k *= i;
            ANS++;
        }
        cout << ANS+1;
    }  
    return 0;
}

Measured memory_bytes: 256
import sys
n,Y=map(int,raw_input().split())
for x in range(n+1):
  for y in range(n+1):
    z=n-x-y
    if z<0:continue
    if 10000*x+5000*y+1000*z==Y:
      print x,y,z
      sys.exit(0)
print -1,-1,-1


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin >> s;
    int n = s.length();
    bool flag = true;
    string str = "";
    REP(i,n) {
        if(i<n-1 && s[i]=='A' && s[i+1]=='A') flag = false;
        if(i<n-1 && s[i]=='K' && s[i+1]=='A') flag = false;
        if(i<n-1 && s[i]=='I' && s[i+1]=='A') flag = false;
        if(s[i]=='A') continue;
        str += s[i];
    }
    bool ans = (flag && str=="KIHBR");
    cout << (ans ? "YES" : "NO") << endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    n = int(input())
    M = 55555
    Int = [i for i in range(M+1)]
    for i in range(2,len(Int)):
        if Int[i]!=0:
            for k in range(2,M//Int[i]):
                Int[i*k] = 0
    prm = []
    for i in Int:
        if i!=0 and i%5==1:
            prm.append(i)
    prm = prm[1:]
    print(' '.join([str(x) for x in prm[0:n]]))

if __name__ == "__main__":
    main()


Measured memory_bytes: 10996
#include<stdio.h>
#include<iostream>
#include<cmath>
#define EPS 0.0000001

using namespace std;

main(){
  int a, b, c, d, e, f;
  double x, y;
  while ( cin >> a >> b >> c >> d >> e >> f ){
    x = 1.0 * ( c*e - b*f ) / ( a*e - b*d ) + EPS;
    y = 1.0 * ( c*d - a*f ) / ( b*d - a*e ) + EPS;
    printf("%.3lf %.3lf\n", x, y);
  }
}

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

int main()
{
	char commma;
	int num;
	string blood;
	int a = 0, b = 0, ab = 0, o = 0;
	while (1) {
		cin >> num >> commma >> blood;
		if (cin.eof())break;//??\????????????????????°break
		if (blood == "A")a++;
		else if (blood == "B")b++;
		else if (blood == "AB")ab++;
		else o++;
	}
	cout << a << endl;
	cout << b << endl;
	cout << ab << endl;
	cout << o << endl;
	return 0;
}

Measured memory_bytes: 3120
//朴素版dijkstra算法 
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>

using namespace std;


int main()
{
//	freopen("input.txt","r",stdin);
	
	string s,t;
	cin>>s>>t;
	int flag=0;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]!=t[i]) flag=1;
	}
	if(flag) printf("No");
	else printf("Yes");
	
	return 0;
}














Measured memory_bytes: 3200
#include<stdio.h>
int main()
{
    int N,B[150],A[150],i,sum=0;
    scanf("%d",&N);
    for(i=0; i<N-1; i++)
    {
        scanf("%d",&B[i]);
    }
    A[0]=B[0];
    A[N-1]=B[N-2];
    for(i=1; i<N-1; i++)
    {
         if(B[i-1]<B[i])
         {
              A[i]=B[i-1];
         }
         else
         {
              A[i]=B[i];
         }
    }
    for(i=0;i<N;i++)
    {
         sum=sum+A[i];
    }
    printf("%d",sum);
    return 0;
}



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

using namespace std;

const long double eps=1e-9;

struct point
{
    long double x,y;
};

long double dist(point a,point b)
{
    return sqrtl((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

long double dist_square(point a,point b)
{
    return ((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
}

long double angle(point a,point b,point c)
{
    return acosl((dist_square(a,b)+dist_square(a,c)-dist_square(b,c))/(2.0*dist(a,b)*dist(a,c)));
}

point segment_bisector(point a,point b)
{
    point p;
    p.x=((a.x+b.x)/2.0);
    p.y=((a.y+b.y)/2.0);
    return p;
}

point circumcentre(point a,point b,point c)
{
    long double alpha=angle(a,b,c);
    long double beta=angle(b,a,c);
    long double gamma=angle(c,a,b);
    point p;
    p.x=((a.x*sinl(2*alpha)+b.x*sinl(2*beta)+c.x*sinl(2*gamma))/(sinl(2*alpha)+sinl(2*beta)+sinl(2*gamma)));
    p.y=((a.y*sinl(2*alpha)+b.y*sinl(2*beta)+c.y*sinl(2*gamma))/(sinl(2*alpha)+sinl(2*beta)+sinl(2*gamma)));
    return p;
}

bool contains(point a,long double r,vector<point> p)
{
    bool ok=1;
    for(point t:p)
    {
        if(dist(a,t)-eps>r) ok=0;
    }
    return ok;
}

int main()
{
    int n;
    cin >> n;
    vector<point> p(n);
    for(int i=0;i<n;i++) cin >> p[i].x >> p[i].y;
    long double res=1e100;
    for(int o=0;o<n;o++)
    {
        for(int i=o+1;i<n;i++)
        {
            point a=segment_bisector(p[o],p[i]);
            long double r=dist(a,p[o]);
            if(contains(a,r,p)) res=min(res,r);
        }
    }
    for(int o=0;o<n;o++)
    {
        for(int i=o+1;i<n;i++)
        {
            for(int j=i+1;j<n;j++)
            {
                point a=circumcentre(p[o],p[i],p[j]);
                long double r=dist(a,p[o]);
                if(contains(a,r,p)) res=min(res,r);
            }
        }
    }
    cout << fixed << setprecision(14) << res << endl;
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	#define f first
	#define s second
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	//int arr[900006]
	int power(int a,int b){
		int res=1;
		while(b){
			if(b&1) res=res*a;
			a=a*a;
			b>>=1;
		}
		return res;
	}
		int32_t main(){
		IOS;
		int n;
		cin>>n;
		int arr[n+1];
		map<int,int>mp;
		int ans=0;
		int left[n+1],right[n+1];
		for(int i=1;i<=n;i++){
			cin>>arr[i];
			ans+=mp[i-arr[i]];
			mp[i+arr[i]]++;
		}
		cout<<ans<<endl;
		
		return 0;
	}



Measured memory_bytes: 27904
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000000;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};

struct STATE
{
	int x, y, d;
	bool operator<(const STATE &t)const{
		return d > t.d;
	}
};

char grid[128][128];
int d[128][128];

bool ingrid(int x, int y, int w, int h)
{
	return x >= 0 && x <= h + 1 && y >= 0 && y <= w + 1;
}

int main()
{
	int w, h;
	while (scanf("%d %d", &w, &h), w + h){
		memset(grid, '.', sizeof(grid));
		for (int i = 0; i < 128; i++){
			for (int j = 0; j < 128; j++){
				d[i][j] = INF;
			}
		}

		int sx, sy;
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				scanf(" %c", &grid[i][j]);
				if (grid[i][j] == '&'){
					sx = i;
					sy = j;
				}
			}
		}
		
		int res = 0;
		priority_queue<STATE> que;
		for (que.push({sx, sy, 0}); !que.empty(); que.pop()){
			STATE st = que.top();
			if (d[st.x][st.y] <= st.d) continue;
			d[st.x][st.y] = st.d;
			if (st.x == 0 || st.y == 0 || st.x == h + 1 || st.y == w + 1){
				res = st.d;
				break;
			}
			for (int dir = 0; dir < 4; dir++){
				int tx = st.x + dx[dir];
				int ty = st.y + dy[dir];
				if (!ingrid(tx, ty, w, h)) continue;
				if (d[tx][ty] > st.d + (grid[st.x][st.y] == '#')){
					que.push({tx, ty, st.d + (grid[st.x][st.y] == '#' && grid[tx][ty] == '.')});
				}
			}
		}
		printf("%d\n", res);
	}
	
	return 0;
}

Measured memory_bytes: 1420
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int n,m;
  	int a;
  	int road[50]={};
  	
  	cin >> n >> m;
  	for(int i=0;i < 2*m;i++){
		cin >> a;
      	road[a-1]++;
    }
  	for(int i=0;i < n;i++){
      cout << road[i] << endl;
    }
  return 0;
}

Measured memory_bytes: 256
from collections import deque
import sys


def main():
    d = deque()
    input()
    for c in sys.stdin:
        if c[0] == "i":
            d.appendleft(c[7:-1])
        elif c[6] == " ":
            if c[7:-1] in d:
                d.remove(c[7:-1])
        elif c[6] == "F":
            d.popleft()
        else:
            d.pop()
    print(" ".join(d))


if '__main__' == __name__:
    main()



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

    string L = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

    char col = 0;
    int axis = 0;

    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            string S;
            cin >> S;
            if (S == "snuke"){
                col = L[j];
                axis = i + 1;
            }
        }  
    }


    cout << col << axis << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <iomanip>
#include <iostream>
#include <limits>
#include <algorithm> 
using namespace std;

int main()
{   
    string T;
    cin >> T;
    int n = T.size();
    for(int i = 0; i < n; i++){
        if(T[i] == '?'){
            T[i] = 'D';
        // if(i !=  n-1 && (T[i-1] == 'D' || T[i-1] == '?')){
        //     T[i] = 'P';
        // }
        // else T[i] = 'D';
        }
    }
    cout << T << endl;
    return 0;
}

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

int main() {
  char c;
  cin >> c;

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

}


Measured memory_bytes: 256
#include<iostream>
#include <cstdlib>
using namespace std;
int main(int argc, char const *argv[])
{
    int D;

    cin>>D;
    if(D==25){
        cout<<"Christmas"<<endl;
    }else if(D==24){
        cout<<"Christmas Eve"<<endl;
    }else if(D==23){
        cout<< "Christmas Eve Eve"<<endl;
    }else if(D==22){
        cout<<" Christmas Eve Eve Eve"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;

int main() {
  int n, r;
  cin >> n >> r;
  if (n < 10)
    cout << r + 100 * (10 - n) << endl;
  else
    cout << r << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include <bits/stdc++.h>
#define FAST_IO  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
#define endl "\n"
#define PI 3.14159265358979323846264338327950288
 
using namespace std ;
using bigint = long long int ;
using vi = vector<int> ;
using vll = vector<long long int> ;

int cnt[2000005] ;
int gcd( int a , int b ){
    if( b == 0 )
        return a ;
    return gcd( b , a % b ) ;
}
int main(){
    FAST_IO ;
    int N ; cin >> N ;
    int G = 0 ;
    bool flag = false ;
    for( int i = 0 ; i < N ; i++ ){
        int x ; cin >> x ;
        G = gcd( G , x ) ;
        cnt[x]++ ;
    }
    if( G != 1 ){
        cout << "not coprime" << endl ;
        return 0 ;
    }
    int ans = 0 ;
   
    for( int i = 2 ; i <= 1000000 ; i++ ){
            ans = 0 ;
            for( int j = i ; j <= 1000000 ; j += i ){
                if( cnt[j] > 0 ){
                    ans += cnt[j] ;
                }
            }
        if( ans > 1 ){
            flag = true ;
            break ;
        }
    }
    if( flag && G == 1 ){
        cout << "setwise coprime" << endl ;
    }
    else
        cout << "pairwise coprime" << endl ;
    return 0 ;
}
 
 

Measured memory_bytes: 7552
#include <iostream>
#include <string>
#include <map>

#define MULT(x,y) ((x*y)%1000000007L)
#define llint long long int
std::string alphabet="abcdefghijklmnopqrstuvwxyz";

int main(void){
  int n;
  std::cin >> n;
  std::string s[n];

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

  std::map<char, int> count;
  for(int j=0; j<s[0].size(); j++){
    if(!count.count(s[0][j])){
      count[s[0][j]] = 1;
    }else{
      count[s[0][j]]++;
    }
  }


  for(int i=1; i<n; i++){
    std::map<char, int> temp_count;
    for(int j=0; j<s[i].size(); j++){
      if(!temp_count.count(s[i][j])){
        temp_count[s[i][j]] = 1;
      }else{
        temp_count[s[i][j]]++;
      }
    }
    for(char elem: alphabet){
      if(count.count(elem) && temp_count.count(elem) && count[elem] > temp_count[elem]){
        count[elem] = temp_count[elem];
      }else if(count.count(elem) && !temp_count.count(elem)){
        count[elem] = 0;
      }
    }
  }

  for(char elem: alphabet){
    for(int i=0; i<count[elem]; i++){
      std::cout << elem;
    }
  }
  std::cout << std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int n;
  cin >> n;
  if (n % 1000) {
    cout << 1000 - (n % 1000) << endl;
  } else {
    cout << 0 << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 3648
#include <iostream>
#include <set>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define INF 1e9+7

int main() {
	set<string> used;
	int n;
	string str;
	cin >> n >> str;
	used.insert(str);
	bool flg = false;
	rep(i, n - 1)
	{
		char b = str.back();
		cin >> str;
		if (b != str.front() || used.count(str) == 1)
			flg = true;
		used.insert(str);
	}
	if (flg)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author KY2001
 */


#include "bits/stdc++.h"
#define int long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(obj) begin(obj), end(obj)
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define LOWER_BOUND(A, key) distance(A.begin(), lower_bound(ALL(A), key))
#define UPPER_BOUND(A, key) distance(A.begin(), upper_bound(ALL(A), key))

using namespace std;
using ll      = long long;
const int MOD = (int)(1e9 + 7);
const int INF = (int)(1e13 + 7);

int bpm(int x, int y) {
  if (x == 0)
    return 0;
  else if (y == 0) {
    return 1;
  }
  int ans = 1;
  x %= MOD;
  int digit = (int)((log((double)y) / log((double)2) / 1 + 1));
  for (int i = 0; i < digit; i++) {
    if (((y >> i) & 1u) == 1) {
      ans *= x;
      ans %= MOD;
    }
    x = x * x;
    x %= MOD;
  }
  return ans;
}
unordered_map<int, int> element_num; //change type if you need
template <class T>
void counter(T container) {
  for (int i = 0; i < container.size(); i++) {
    element_num[container[i]] += 1;
  }
}

class CGoodSequence {
public:
  int solve(std::istream &cin, std::ostream &cout) {
    element_num = {};
    int N;
    cin >> N;
    vector<int> a(N);
    int ans = 0;
    rep(i, N) {
      cin >> a[i];
      if (a[i] > 100000) {
        ans += 1;
      }
    }
    counter(a);
    rep(i, 100001) {
      if (element_num[i]) {
        if (element_num[i] >= i) {
          ans += element_num[i] - i;
        } else {
          ans += element_num[i];
        }
      }
    }
    cout << ans << endl;
  }
};


signed main() {
	CGoodSequence solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 9172
#include <stdio.h>
#include "math.h"

#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) cerr << #x << "=" << static_cast<bitset<16> >(x) << endl;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=x && x<w && 0<=y && y<h)

const int INF = 10000000;
int dx[4]={-1, 0, 1, 0}, dy[4]={0, 1, 0, -1};
using namespace std;
typedef pair<int, int> P;
/** 
 int 了=10;
 **/

/** Problem1180 : ICPCRanking **/
int main()
{
	int a, l;
	while (cin>>a>>l, a||l) {
		map<int, int> s;
		char x[l], y[l];
		int ans=0;
		
		s[a] = 0;
		
		while (1) {
			ans++;

			sprintf(x, "%0*d", l, a);
			sprintf(y, "%0*d", l, a);
			sort(x, x+l);
			sort(y, y+l, greater<int>());

			
			int nx=0, ny=0;
			rep(i, l) {
				nx*=10; nx+=x[i]-'0';
				ny*=10; ny+=y[i]-'0';
			}
		
			int nn = max(nx, ny) - min(nx, ny);

			if (s.find(nn) == s.end()) {
				s[nn] = ans;
				a = nn;
			} else {
				cout << s[nn] << " " << nn << " " << ans-s[nn] << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 1256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
    	if(c == '-') f = -1;
    	c = getchar();
    }
    while(c >= '0' && c <= '9') {
    	res = res * 10 +c - '0';
    	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
    	out(x / 10);
    }
    putchar('0' + x % 10);
}
int N;
multiset<int> to[MAXN];
map<pii,int> zz;
queue<pii > Q;
void insertEdge(int a,int b) {
    if(a == b) return;
    if(a > b) swap(a,b);
    zz[mp(a,b)]++;
    if(zz[mp(a,b)] == 2) Q.push(mp(a,b));
    to[a].insert(b);to[b].insert(a);
}
void Delete(int x,int y) {
    if(x > y) swap(x,y);
    if(zz.count(mp(x,y))) zz.erase(mp(x,y));
}
void Merge(int x,int y) {
    for(auto t : to[y]) {
        Delete(t,y);
        to[t].erase(to[t].find(y));
        insertEdge(t,x);
    }
}
void Solve() {
    read(N);
    int a,b,c,d;
    for(int i = 1 ; i < 2 * N - 1 ; ++i) {
        read(a);read(b);
        insertEdge(a,b);
    }
    for(int i = 1 ; i < N ; ++i) {
        while(1) {
            if(Q.empty()) {puts("NO");return;}
            pii u = Q.front();Q.pop();
            if(zz.count(u)) {
                if(to[u.fi].size() < to[u.se].size()) swap(u.fi,u.se);
                Merge(u.fi,u.se);
                break;
            }
        }
    }
    puts("YES");
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 38272
# coding: UTF-8
import sys
#sys.setrecursionlimit(n)
import heapq
import re
import bisect
import random
import math
import itertools
from collections import defaultdict, deque
from copy import deepcopy
from decimal import *

h, w, k = map(int, input().split())
memo = defaultdict(lambda:defaultdict(int))

def dfs(x, y):
    if y == h:
        if x == k - 1:
            return 1
        else:
            return 0
    if y in memo[x]:
        return memo[x][y]

    ans = 0
    for i in range(1 << w - 1):
        flg = True
        for j in range(w - 2):
            if i & (1 << j) and i & (1 << j + 1):
                flg = False
                break
        if flg:
            nx = x
            if x > 0 and i & (1 << x - 1):
                nx = x - 1
            elif i & (1 << x):
                nx = x + 1
            ans += dfs(nx, y + 1)
            ans %= 1000000000 + 7
    memo[x][y] = ans
    return ans
print(dfs(0, 0))


Measured memory_bytes: 6352
#include <bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

using Graph = vector<vector<int>>;
ll k = -1;
map<P, int> ans;

void dfs(const Graph &G, int v, int p, int e){
    ll now = 1;
    for(auto nv : G[v]){
        if(nv == p)continue;
        if(now == e)now++;
        P p = make_pair(min(v, nv), max(v, nv));
        ans[p] = now;
        k = max(k, now);
        dfs(G, nv, v, now);
        now++;
    }
}

int main() {
    int n;
    cin >> n;
    Graph G(n);
    vector<int> a(n-1), b(n-1);
    rep(i, n-1){
        cin >> a[i] >> b[i];
        a[i]--; b[i]--;
        G[a[i]].push_back(b[i]);
        G[b[i]].push_back(a[i]);
    }
    dfs(G, 0, -1, -1);
    cout << k << endl;
    rep(i, n-1){
        cout << ans[make_pair(a[i], b[i])] << endl;
    }
}


Measured memory_bytes: 14080
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
	int n,q;
	cin >> n >> q;
	vector<ll> a(n);
	for(auto &i:a)cin >> i;

	while(q--)
	{
		ll x;
		cin >> x;
		ll sum = 0;
		queue<ll> Q;
		ll ans = 0;
		for(int i =0;i<n;)
		{
			if(sum+a[i]<=x)
			{
				sum+=a[i];
				Q.push(a[i]);
				ans += Q.size();
				i++;
			}
			else if(Q.size())
			{
				sum-=Q.front();
				Q.pop();
			}
			else
			{
				Q.push(a[i]);
				sum += a[i];
				i++;
			}
		}
		cout<<ans<<'\n';
	}
}


Measured memory_bytes: 4404
#include <iostream>
#include <cmath>
int main()
{
	int n,cnt = 0,tmp1,tmp2;
	std::cin>>n;
	for(int i = 1;i <= n;i++){
		std::cin>>tmp1>>tmp2;
		cnt += std::abs(tmp1 - tmp2) + 1;
	}
	std::cout<<cnt;
	return 0;
}


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

const int inf = 1e9;
const ll linf = 1e18;

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

    int k, x; cin >> k >> x;
    cout << ((500 * k >= x) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    int n,sum,prv,ans;
    while(cin >> n,n!=0){
        sum = 0;
        prv = 1;
        ans = 0;
        for(int i=1;i<n;i++){
            sum += i;
            while(sum > n){
                sum -= prv;
                prv++;
            }
            if(sum == n){
                ans++;
            }
        }
        cout << ans << endl;
    }
    return(0);
}



Measured memory_bytes: 3080
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N + 1);
  for (int i = 0; i < N + 1; i++)
  {
    scanf("%lld", &A[i]);
  }
  std::vector<long long> B(N);
  for (int i = 0; i < N; i++)
  {
    scanf("%lld", &B[i]);
  }
  vector<ll> bb = B, aa = A;
  reverse(bb.begin(), bb.end());
  reverse(aa.begin(), aa.end());
  ll s1 = 0, s2 = 0;
  for (int i = 0; i < N; ++i)
  {
    if (A[i] >= B[i])
    {
      A[i] -= B[i];
      s1 += B[i];
      B[i] = 0;
    }
    else
    {
      B[i] -= A[i];
      s1 += A[i];
      A[i + 1] = 0;
    }
    if (A[i + 1] >= B[i])
    {
      A[i + 1] -= B[i];
      s1 += B[i];
      B[i] = 0;
    }
    else
    {
      B[i] -= A[i + 1];
      s1 += A[i + 1];
      A[i + 1] = 0;
    }
    if (aa[i] >= bb[i])
    {
      aa[i] -= bb[i];
      s2 += bb[i];
      bb[i] = 0;
    }
    else
    {
      bb[i] -= aa[i];
      s2 += aa[i];
      aa[i] = 0;
    }
    if (aa[i + 1] >= bb[i])
    {
      aa[i + 1] -= bb[i];
      s2 += bb[i];
      bb[i] = 0;
    }
    else
    {
      bb[i] -= aa[i + 1];
      s2 += aa[i + 1];
      aa[i + 1] = 0;
    }
  }
  s1 += min(A[N], B[N - 1]);
  s2 += min(aa[N], bb[N - 1]);
  cout << max(s1, s2) << endl;

  return 0;
}


Measured memory_bytes: 3328
n=input()
op_cnt=len(n)-1
for i in range(2**op_cnt):
    s=n[0]
    for j in range(op_cnt):
        if ((i>>j)&1):
            s+="+"
        else:
            s+="-"
        s+=n[j+1]
    if eval(s)==7:
        print(s+"=7")
        exit()

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

using namespace std;

#define ll long long
#define vl vector<ll>
#define pb push_back
#define sz size
#define xx first
#define yy second

#define all(x) begin(x), end(x)

#define FOR(i,start,end) for(ll i=start; i < end; ++i)
#define FORD(i,start,end) for(ll i=start; i < end; --i)

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

  if(x >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    int count =0;
    char[][] A = new char[N][];
    char[][] B = new char[M][];
    for (int i = 0; i <N; i++) A[i] = sc.next().toCharArray();
    for (int i = 0; i <M; i++) B[i] = sc.next().toCharArray();
    for (int i=0; i<N-M+1; i++) {
      L: for (int j=0; j<N-M+1; j++) {
        for (int k=0; k<M; k++) {
          for (int l=0; l<M; l++) {
            if (A[i+k][j+l] != B[k][l]) continue L;
          }
        }
        count =1;
        break;
      } 
    }
    if (count ==1) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 22484
from sys import stdin
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=list(map(int,readline().split()))

    d=dict()
    for i in range(n):
        if a[i] not in d:
            d[a[i]]=1
        else:
            d[a[i]]+=1

    res=0
    for key in d.keys():
        x=d[key]
        if key<=x:
            res+=x-key
        else:
            res+=x

    print(res)

if __name__=="__main__":
    main()

Measured memory_bytes: 17700
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<30;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

int N;
int a[212345];
int ans[212345];

int main() {
	cin >> N;
	REP(i, N) scanf("%d", a + i);
	
	for (int i = N; i >= 1; i--) {
		int cnt = 0;
		for (int j = i; j <= N; j += i) cnt += ans[j - 1];
		ans[i - 1] = (cnt % 2) ^ a[i - 1];
	}
	
	vector<int> out;
	REP(i, N) if (ans[i]) out.push_back(i + 1);
	
	cout << out.size() << endl;
	REP(i, out.size()) printf("%d%c", out[i], i == N - 1 ? '\n' : ' ');
	
	return 0;
}


Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return Console.ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return Console.ReadLine().Split(); }
 
    const int Sheep = 0;
    const int Wolf = 1;
 
    static bool Validate(int p, int[] xs, char reply) {
        int prev = (p - 1 + xs.Length) % xs.Length;
        int next = (p + 1) % xs.Length;
 
        if (xs[p] == Sheep) {
            return reply == 'o' ? xs[prev] == xs[next] : xs[prev] != xs[next];
        }
        else {
            return reply == 'o' ? xs[prev] != xs[next] : xs[prev] == xs[next];
        }
    }
 
    static bool Calc_1(int[] xs, string s) {
 
        Func<int, char, int, int> other = (animal, reply, prev) => {
            if (animal == Sheep) {
                return reply == 'o' ? prev : (prev ^ 1);
            }
            else { // Wolf
                return reply == 'o' ? (prev ^ 1) : prev;
            }
        };
 
        int n = s.Length;
        for (int i = 1; i < n - 1; i++) {
            int prev = xs[i - 1];
            xs[i + 1] = other(xs[i], s[i], prev);
        }
 
        var a = Validate(0, xs, s[0]);
        var b = Validate(n - 1, xs, s[n - 1]);
        var c = Validate(n - 2, xs, s[n - 2]);
        return a && b && c;
    }
 
    static void Calc(string s) {
        int n = s.Length;
 
        bool found = false;
        var xs = new int[n];
        for (int i = 0; i < (1 << 2); i++) {
            // (S, S), (S, W), (W, S), (W, W) の 4 パターン試す
            xs[0] = (i & 2) == 0 ? 0 : 1;
            xs[1] = i & 1;
            if (Calc_1(xs, s)) {
                Console.WriteLine(string.Join("", xs.Select(e => e == Sheep ? "S" : "W")));
                found = true;
                break;
            }
        }
 
        if (!found)
            Console.WriteLine(-1);
    }
 
    static void Main() {
        ReadInt();
        var s = Console.ReadLine();
        Calc(s);
    }
}

Measured memory_bytes: 13400