akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = ll(A); I < ll(B); ++I)
#define FORR(I,A,B) for(ll I = ll((B)-1); I >= ll(A); --I)
#define TO(x,t,f) ((x)?(t):(f))
#define SORT(x) (sort(x.begin(),x.end())) // 0 2 2 3 4 5 8 9
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //xi>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //xi>v  x is sorted
#define NUM(x,v) (POSU(x,v)-POSL(x,v))  //x is sorted
#define REV(x) (reverse(x.begin(),x.end())) //reverse
ll gcd_(ll a,ll b){if(a%b==0)return b;return gcd_(b,a%b);}
ll lcm_(ll a,ll b){ll c=gcd_(a,b);return ((a/c)*(b/c)*c);}
#define NEXTP(x) next_permutation(x.begin(),x.end())
const ll INF=ll(1e16)+ll(7);
const ll MOD=1000000007LL;
#define out(a) cout<<fixed<<setprecision((a))
//tie(a,b,c) = make_tuple(10,9,87);
#define pop_(a) __builtin_popcount((a))
ll keta(ll a){ll r=0;while(a){a/=10;r++;}return r;}

template <typename T>
class Lazy_Seg_Tree{
public: // 0-index

  T make_dat_from_buket(T da, T bu, T s){
    return da + bu;
  }
  T buket_to_child(T ch, T pa){
    return ch + pa / 2;
  }
  T buket_update(T bu , T x , T s){
    return bu + x*s;
  }
  T dat_update(T dc1, T dc2){
    return dc1 + dc2;
  }

  vector<T> dat,buket;
  T initial,M;
  int n;
  Lazy_Seg_Tree(int n0_=1,T initial_=1,T M_=1){
    initsize(n0_,initial_,M_);
  }
  void initsize(int n0,T initial_,T M_){
    M = M_;
    initial = initial_;
    int k=1;
    while(k<n0)k*=2;
    n=k;
    dat.resize(2*n-1);
    buket.resize(2*n-1);
    for(int i=0;i<2*n-1;i++)dat[i]=initial;
    for(int i=0;i<2*n-1;i++)buket[i]=initial;
  }
  
  void eval(int k,int l,int r){
    if(buket[k] != initial){
      dat[k] = make_dat_from_buket(dat[k],buket[k],r-l);
      if(r-l>1){
        buket[2*k+1] = buket_to_child(buket[2*k+1],buket[k]);
        buket[2*k+2] = buket_to_child(buket[2*k+2],buket[k]);
      }
      buket[k] = initial;
    }
  }

  void add(int a,int b, T x, int k=0,int l=0, int r=-1){
    if(r<0)r=n;
    eval(k,l,r);
    if(b<=l || r<=a)return;
    if(a<=l && r<=b){
      buket[k] = buket_update(buket[k],x,r-l);
      eval(k,l,r);
    }else{
      add(a,b,x,2*k+1,l,(l+r)/2);
      add(a,b,x,2*k+2,(l+r)/2,r);
      dat[k] = dat_update(dat[2*k+1],dat[2*k+2]);
    }
  }
  T get(int a,int b,int k=0,int l=0,int r=-1){
    if(r<0)r=n;
    if(b<=l || r<=a) return initial;
    eval(k,l,r);
    if(a<=l && r<=b) return dat[k];
    T vl = get(a,b,2*k+1,l,(l+r)/2);
    T vr = get(a,b,2*k+2,(l+r)/2,r);
    return dat_update(vl,vr);
  }
};




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

  Lazy_Seg_Tree<ll> sg(N+4,0,MOD);

  vector<P> e(N);
  FOR(i,0,N-1){
    cin >> e[i].first >> e[i].second;
    e[i].first--;
    e[i].second--;
    if(e[i].second>e[i].first) swap(e[i].first,e[i].second);
  }
  e[N-1] = {MOD,MOD};
  SORT(e);

  ll ans = 0;
  int j = 0;
  FOR(i,0,N){
    while(e[j].first <= i){
      sg.add(e[j].second+1,N+2,1,0,0,-1);
      j++;
    }
    ans += (i+2LL)*(i+1LL)/2LL - j*(i+1) + (sg.get(0,i+1,0,0,-1));
  }
  cout << ans << endl;
}


Measured memory_bytes: 14548
#define  _CRT_SECURE_NO_WARNINGS
#pragma comment (linker, "/STACK:526000000")

#include "bits/stdc++.h"

using namespace std;
typedef string::const_iterator State;
#define eps 1e-11L
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144 * 2LL
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long (a) = 0;(a) < (b);++(a))
#define ALL(x) (x).begin(),(x).end()

unsigned long xor128() {
	static unsigned long x = 123456789, y = 362436069, z = 521288629, w = time(NULL);
	unsigned long t = (x ^ (x << 11));
	x = y; y = z; z = w;
	return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
void init() {
	iostream::sync_with_stdio(false);

}

int seg_tree[seg_size * 4LL];
int seg_find(int now, int n_l, int n_r, int w_l, int w_r) {
	if (w_l <= n_l && n_r <= w_r) return seg_tree[now];
	if (w_r <= n_l || n_r <= w_l) return 0;
	return (seg_find(now * 2, n_l, (n_l + n_r) / 2, w_l, w_r) | seg_find(now * 2 + 1, (n_l + n_r) / 2, n_r, w_l, w_r));
}

int seg_set(int now) {
	seg_tree[now] = seg_tree[now * 2] | seg_tree[now * 2 + 1];
	if (now > 1) seg_set(now / 2);
	return 0;
}

void solve(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	int query;
	cin >> query;
	REP(i, s.length()) {
		seg_tree[i + seg_size] = (1 << (s[i] - 'a'));
		seg_set((i + seg_size) / 2);
	}
	REP(i, query) {
		int a;
		cin >> a;
		if (a == 1) {
			int b;
			cin >> b;
			string c;
			cin >> c;
			b--;
			seg_tree[b + seg_size] = (1 << (c[0] - 'a'));
			seg_set((b + seg_size) / 2);
		}
		else {
			int b, c;
			cin >> b >> c;
			b--;
			int hoge = seg_find(1, 0, seg_size, b, c);
			int ans = 0;
			REP(q, 27) {
				if ((1 << q) & hoge) {
					ans++;
				}
			}
			cout << ans << endl;
		}
	}
}

#undef int

int main() {
	init();
	solve();
}

Measured memory_bytes: 4892
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	switch {
	case n == 1 && m == 1:
		fmt.Println(1)
	case n == 1 || m == 1:
		fmt.Println(max(n, m) - 2)
	default:
		fmt.Println((n - 2) * (m - 2))
	}
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  ll n;
  cin >> n;
  --n;
  ll cur = 1;
  int cnt = 1;
  while (cur * 26 <= n) {
    cnt++;
    cur *= 26;
    n -= cur;
  }

  string ans = string(cnt, 'a');
  for (int i = 0; i < cnt; ++i) {
    ans[i] = 'a' + n % 26;
    n /= 26;
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;


}

Measured memory_bytes: 3624
// https://atcoder.jp/contests/abc151/tasks/abc151_a
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define DIV(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    s[0]++;
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int n,t,f,ans[N];
struct zz{
	int x,y;
}a[N];
int cmp(zz x,zz y){
	if (x.x==y.x) return x.y<y.y;
	else return x.x>y.x;
}
signed main(){
    scanf("%d",&n);
    t=2;f=1;
    for (int i=1;i<=n;i++)scanf("%d",&a[i].x),a[i].y=i;
    sort(a+1,a+n+1,cmp);
    while (t<=n){
        while (a[t].x==a[t-1].x) t++;
        ans[a[f].y]+=(a[f].x-a[t].x)*(t-1);
        if (a[t].y>a[f].y) a[f].x=a[t].x;
        else f=t;
        t++;
    }
    ans[a[f].y]+=a[f].x*n;
    for (int i=1;i<=n;i++)printf("%lld\n",ans[i]);
}

Measured memory_bytes: 3456
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,M;
  cin>>N>>M;
  int A[N];
  REP(i,N)cin>>A[i];
  int S=0;
  REP(i,N)S+=A[i];
  int ans=0;
  REP(i,N)if(4*M*A[i]>=S)ans++;
  cout<<(ans>=M?"Yes":"No")<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define SC scanf
#define PR printf
#define SZ(v) ((int)(v).size())
typedef long long ll;
const int INF=0x3f3f3f3f;
int n;
string s[105];
int a[26],b[26];
int main(){
    ios::sync_with_stdio(false);
	cin>>n;
	for(int i=1;i<=n;i++)cin>>s[i];
	for(int i=0;i<26;i++)a[i]=INF;
	for(int i=1;i<=n;i++){
		memset(b,0,sizeof(b));
		for(int j=0;j<s[i].size();j++){
			b[s[i][j]-'a']++;
		}
		for(int j=0;j<26;j++)a[j]=min(a[j],b[j]);
	}
	for(int i=0;i<26;i++){
		for(int j=1;j<=a[i];j++){
			cout<<(char)(i+'a');
		}
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
using pii = pair<int, int>;
const int MOD = 1e9 + 7;
const int N = 1e3 + 1;
const int INF = 1 << 29;
 
struct IOsetup{
  IOsetup(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout << fixed;
    cout << setprecision(20);
  }
} IO;

int32_t main(){
  string s;
  cin >> s;
  for (int i = 0; i < (int)s.length(); i++)
    cout << "x";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int OO = 1e9;

int main() {
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int a[n];
  for(int i = 0;i < n;i++)
    cin >> a[i];
  sort(a, a + n);
  int mn, mni;
  mn = 1e9;
  for(int i = 0;i < n - 1;i++){
    int x = a[n - 1] / 2;
    if(a[n - 1] & 1){
      if(a[i] <= a[n - 1] / 2 && a[n - 1] / 2 - a[i] < mn){
        mn = a[n - 1] / 2 - a[i];
        mni = i;
      }else if(a[i] > a[n - 1] / 2 && a[i] - a[n - 1] / 2 - 1 < mn){
        mn = a[i] - a[n - 1] / 2 - 1;
        mni = i;
      }
    }else{
      if(abs(a[i] - a[n - 1] / 2) < mn){
        mn = abs(a[i] - a[n - 1] / 2);
        mni = i;
      }
    }
  }
  cout << a[n - 1] << ' ' << a[mni];
  return 0;
}


Measured memory_bytes: 640
def main():
    n = int(input())

    rank1 = n % 10
    if rank1 == 3:
        print("bon")
    elif rank1 == 0 or rank1 == 1 or rank1 == 6 or rank1 == 8:
        print("pon")
    else:
        print("hon")

if __name__ == "__main__":
    main()

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

int gcd(int p,int q){
    if(p%q == 0){
        return q;
    }
        return gcd(q,p%q);
}

int main(){
    int n,k; cin >> n >> k;
    vector<bool> sunuke(n,false);

    for(int i=0;i<k;i++){
        int d; cin >> d;
        for(int j=0;j<d;j++){
            int a; cin >> a;
            sunuke[a-1] = true;
        }
    }

    int cnt = 0;

    rep(i,n){
        if(!sunuke[i]){
            cnt++;
        }
    }

    cout << cnt << endl; 

}

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

int main() {
  ll a, b, n;
  cin >> a >> b >> n;
  ll x = n;
  if (n >= b - 1) x = b - 1;
  ll ans = floor(a * x / b) - a * floor(x / b);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int64_t MOD=1000000007;
const long long INF = 1LL<<60;

int main() {
  int64_t N,ans=0; cin>>N;
  vector<int64_t> S(N);
  rep(i,N) cin>>S.at(i);
  rep(i,N){
    ans+=S.at(i)/2;
    S.at(i)%=2;
    if(i<N-1&&S.at(i)==1&&S.at(i+1)!=0){
      ans++;
      S.at(i+1)--;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 4032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vs = vector<string>;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
#define  red(i,n) for(ll i = (n)-1; i >= 0; --i)
#define  all(a)   begin(a),end(a)
#define  pb(a)    push_back(a)
#define  mp(a,b)  make_pair(a,b)
#define  yn(a)    cout << ( (a)?"Yes\n":"No\n" );
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
const ll INF = 1e9+9, LINF = 1e18;


int main()
{
    ll n,x=0,ans=0;
    cin>>n;
    ll a[n];
    rep(i,n)cin>>a[i],a[i]-=i+1,x+=a[i];
    sort(a,a+n);
    n--;
    ll q=floor(1.*n/2),w=ceil(1.*n/2);
    rep(i,n+1)ans+=abs(a[i]-(ll)((a[q]+a[w])/2.));
    cout<<ans<<endl;
    
    return 0;
}


Measured memory_bytes: 1792
class Main {
    public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
        int N = Integer.parseInt(sc.next());
        int W = Integer.parseInt(sc.next());
        // value, weight
        int[][] m = new int [N+1][2];
        for(int i=1; i<N+1; i++){
            m[i][0] = Integer.parseInt(sc.next());
            m[i][1] = Integer.parseInt(sc.next());
        }

        int[][] dp = new int[N+1][W+1];
        for(int ni=1; ni<N+1; ni++){
            for(int wi=1; wi<W+1; wi++){
                int useNiObject = wi - m[ni][1] >= 0 ? dp[ni][wi - m[ni][1]] + m[ni][0] : -1;
                dp[ni][wi] = Math.max(dp[ni-1][wi], useNiObject );
            }
        }
        System.out.println(dp[N][W]);
        sc.close();
    }
}


Measured memory_bytes: 30720
S = input()

if (S.count("W")>0 and S.count("E")==0) or (S.count("E")>0 and S.count("W")==0) or (S.count("N")>0 and S.count("S")==0) or (S.count("S")>0 and S.count("N")==0):  print("No")
else:
  print("Yes")

Measured memory_bytes: 8960
#include <iostream>

using namespace std;

int main() {
  string s;
  char op[4];
  cin >> s;
  int a,b,c,d;
  // cout << "s:" << s << endl;
  for (int bit = 0; bit < (1<<3); bit++) {
    // cout << bitset<4>(bit) << endl;
    int sum = s[0] - '0';
    for (int i = 0; i < 3; i++) {
      if (bit & (1<<i)) {
        // cout << i << ":on" << endl;
        sum += (s[i+1] - '0');
        op[i] = '+';
      } else {
        // cout << i << ":off" << endl;
        sum -= (s[i+1] - '0');
        op[i] = '-';
      }
      // cout << "i:" << i << "," << s[i+1] << ", sum:" << sum << endl;
    }
    if (sum == 7) {
      cout << s[0] << op[0] << s[1] << op[1] << s[2] << op[2] << s[3] << "=7" << endl;
      return 0;
    }
  }
}


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

Measured memory_bytes: 580
#include <stdio.h>
#include <string.h>
#include <ctype.h>

int main(void)
{
    char t[1000];
    char w[10];
    int i, count;

    scanf("%s", w);

    count = 0;

    while (1){
        scanf("%s", t);

        if (strcmp(t, "END_OF_TEXT") == 0){
            break;
        }  

        for (i = 0; t[i] != '\0'; i++){
            t[i] = tolower(t[i]);          
        }

        if (strcmp(t, w) == 0){
            count++;
        }   
    }

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

    return (0);
}


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

using namespace std;

#define MAX_N 100005

int n, y[MAX_N][3], dp[MAX_N][3];

int f_imp(int, int);

int f(int p, int lkj)
{
	if (dp[p][lkj] == 0)
	{
		dp[p][lkj] = f_imp(p, lkj) + 1;
	}
	return dp[p][lkj] - 1;
}

int f_imp(int p, int lkj)
{
	if (p >= n)
	{
		return 0;
	}
  	int rs = INT_MIN/2;
	for (int i = 0; i < 3; i++)
	{
		if (i == lkj)
			continue;
		rs = max(rs, f(p + 1, i) + y[p][i]);
	}
    return rs;
}

int main() {
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d %d %d", &y[i][0], &y[i][1], &y[i][2]);
	}
	printf("%d\n", f(0, -1));
}


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

int main(){

  int N;
  cin >> N;
  vector<string> S(N);
  rep(i, N) cin >> S.at(i);

  sort(S.begin(), S.end());
  S.erase(unique(S.begin(), S.end()), S.end());

  cout << S.size() << endl;

  return 0;
}

Measured memory_bytes: 9524
#include<bits/stdc++.h>
#define ll      long long
#define pii     pair<int, int>
#define f       first
#define s       second
#define sf(a) scanf("%d", &a)
#define sfl(a) scanf("%lld", &a)
#define pf(a) printf("%d ", a)
#define pfl(a) printf("%lld\n", a)
#define Case(a) printf("Case %d: ", a)

using namespace std;
int main()
{
//    int t;
//    cin>>t;
//
//    for(int tc = 1;tc<=t; tc++){
//
//    }
    int k, n;
    cin>>k>>n;

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

    int ans = a[n-1] - a[0];
    for(int i=1;i<n;i++){
        ans = min(ans, k-a[i] + a[i-1]);
    }
    cout<<ans;
}





Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define reps(i,n) for (int i=1;i<=(n);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rreps(i,n) for (int i=(n);i>0;i--)
#define all(v) (v).begin(),(v).end()
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int>
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;};
typedef long long int ll;
const long long INF = 1LL << 60;

int main(){
  int N; cin >> N;
  vector<vector<int>> t(N);
  map<pii,bool> weight;
  rep(i,N-1) {
    int u, v, w; cin >> u >> v >> w;
    t[u-1].push_back(v-1);
    t[v-1].push_back(u-1);
    if (w%2){
      weight[{u-1, v-1}] = 1;
      weight[{v-1, u-1}] = 1;
    }
  }

  vector<int> c(N,-1);
  queue<int> q;
  q.push(0);
  c[0] = 0;
  while(!q.empty()){
    int now = q.front(); q.pop();
    for (auto n : t[now]){
      if (c[n]!=-1) continue; 
      c[n] = (c[now] + weight[{now, n}])%2;
      q.push(n);
    }
  }
  rep(i,N){
    cout << c[i] << endl;
  }

  // cout << fixed << setprecision(10);
  
  return 0;
}


Measured memory_bytes: 20884
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
  int N,M;
  cin>>N>>M;
  vector<int>a(M);
  vector<int>b(M);
  rep(i,M){
    cin>>a.at(i)>>b.at(i);
  }
  vector<bool>e(N+1);
  vector<bool>f(N+1);
  rep(i,M){
    if(a.at(i)==1){
      e.at(b.at(i))=true;
    }
  }

  rep(i,M){
    if(b.at(i)==N){
      f.at(a.at(i))=true;
    }
  }
  bool ans=false;
  rep(i,N+1){
     if(e.at(i)&&f.at(i)){     
       ans=true;
       break;
     }  
  }

  if(ans){
    cout<<"POSSIBLE"<<endl;
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  
}

Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,t,sum=0;
    cin>>n>>t;
    vector< int >vec(t);
    for(int i=0;i<t;i++){
        cin>>vec[i];
        sum+=vec[i];
    }
    int k=n-sum;
    if(k<0)
        cout<<"-1"<<endl;
    else
        cout<<k<<endl;
    return 0;

}


Measured memory_bytes: 3676
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
int main(){
    long long n,c[5],ans=0;
    cin>>n;
    string s[100000];
    for(int i=0;i<n;i++)cin>>s[i];
    for(int i=0;i<n;i++){
        if(s[i][0]=='M')c[0]++;
        if(s[i][0]=='A')c[1]++;
        if(s[i][0]=='R')c[2]++;
        if(s[i][0]=='C')c[3]++;
        if(s[i][0]=='H')c[4]++;
    }
    for(int i=0;i<3;i++){
        for(int j=i+1;j<4;j++){
            for(int k=j+1;k<5;k++){
                ans+=c[i]*c[j]*c[k];
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

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

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

    long long int ans;
    if(n >= m/2) ans = m/2;
    if(n <  m/2) ans = n + (m - 2*n) / 4;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <utility>
#include <cmath>
using namespace std;

using ll = long long;

int main(){
  int n; cin >> n;
  ll a[n];
  for(int i=0; i<n; i++){
    cin >> a[i];
    a[i] -= i+1;
  }

  sort(a, a+n);
 
  ll m = (n%2 == 0)? (ll)((a[n/2] + a[n/2-1])/2.0 + 0.5): a[n/2];

  ll s = 0;
  for(int i=0; i<n; i++){
    s += abs(a[i]-m);
  }

  cout << s << endl;

  return 0;
}


Measured memory_bytes: 1792
#include <cstdio>

typedef long long LL;
const int MN = 100005;

int N, A[MN], B[MN];
LL Ans;

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d%d", &A[i], &B[i]);
	for (int i = N; i >= 1; --i) Ans += (B[i] - (A[i] + Ans) % B[i]) % B[i];
	printf("%lld\n", Ans);
	return 0;
}

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

int line[2001], raw[2001], m[2001][2001];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    char matrix[h][w];
    int cnt;
    for(int i = 0; i < h; i++){
        cnt = 0;
        for(int j = 0; j < w; j++){
            cin >> matrix[i][j];
            if(matrix[i][j] == '#'){
                cnt = 0;
                line[j] = 0;
            }
            else{
                line[j] = ++cnt;
            }
        }
        for(int j = w-1; j >= 0; j--){
            if(line[j] == 0) cnt = 0;
            else{
                cnt = max(cnt, line[j]);
                m[i][j] = cnt;
            }
        }
    }
    int ans = 0;
    for(int j = 0; j < w; j++){
        cnt = 0;
        for(int i = 0; i < h; i++){
            if(matrix[i][j] == '#'){
                cnt = 0;
                raw[i] = 0;
            }
            else{
                raw[i] = ++cnt;
            }
        }
        for(int i = h-1; i >= 0; i--){
            if(raw[i] == 0) cnt = 0;
            else{
                cnt = max(cnt, raw[i]);
                m[i][j] += cnt;
            }
            ans = max(ans, m[i][j]-1);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 19840
#include <bits/stdc++.h>
#define ll long long int
using namespace std;

int main() {
ll n;
cin>>n;
ll a[n],i;
for(i=0;i<n;i++) cin>>a[i];
ll dp[n];
dp[0]=0;
dp[1]=abs(a[0]-a[1]);
for(i=2;i<n;i++) dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
cout<<dp[n-1];
	// your code goes here
	return 0;
}


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

int main() {
  int n, m;
  cin >> n >> m;
  
  vector<int> s(m);
  
  for(int i=0; i<n; i++) {
    int k;
    cin >> k;
    for(int j=0; j<k; j++) {
      int a;
      cin >> a;
      s.at(a-1) ++;
    }
  }
  
  int count = 0;
  
  for(int i=0; i<m; i++) {
    if(s.at(i) == n)
      count ++;
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
using namespace std;

int main(){
  int N, K, ans=1000000010;
  vector<int> v;
  cin >> N >> K;
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    v.push_back(tmp);
  }
  sort(v.begin(),v.end());
  for(int i=0;i<N-K+1;i++){
    ans=min(ans,v[i+K-1]-v[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define MAX_N 1010
#define MAX_V 1100000
#define mod 1000000007
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define FOR(i, a, b) for(ll i=a; i<b; i++)
#define REP(i, n) for(ll i=0; i<n; i++)
#define REV(i, n) for(ll i=n-1; i>=0; i--)
#define ALL(v) v.begin(), v.end()
#define pb push_back
const ll INF = 9e18;
ll n, a[MAX_N][MAX_N], depth[MAX_V];

vector<ll> G[MAX_V];  // グラフの隣接リスト表現
vector<ll> rG[MAX_V]; // 辺の向きを逆にしたグラフ
vector<ll> vset;         // 頂点集合
vector<ll> vs;        // 帰りがけ順の並び
bool used[MAX_V];     // 既に調べたか
ll cmp[MAX_V];        // 属する強連結成分のトポロジカル順序

void add_edge(ll from, ll to){
  G[from].pb(to);
  rG[to].pb(from);
}

void dfs(ll v){
  used[v] = true;
  for(ll i: G[v]){
    if(!used[i]) dfs(i);
  }
  vs.pb(v);
}

void rdfs(ll v, ll k){
  // cout << v << endl;
  used[v] = true;
  cmp[v] = k;
  for(ll i: rG[v]){
    if(!used[i]) rdfs(i, k);
    depth[v] = max(depth[v], depth[i]+1);
  }
}
ll scc(){
  fill(used, used+MAX_V, false);
  vs.clear();
  for(auto i: vset){
    if(!used[i]) dfs(i);
  }
  // cout << "dfs done" << endl;
  fill(used, used+MAX_V, false);
  ll k = 0;
  for(ll i=vs.size()-1; i>=0; i--){
    if(!used[vs[i]]) rdfs(vs[i], k++);
  }
  // cout << "rdfs done" << endl;
  return k;
}

signed main(){
  cin >> n;
  ll v = n * (n - 1) / 2;
  REP(i, n) REP(j, n-1){ cin >> a[i][j]; a[i][j]--;}
  REP(i, n) REP(j, n-2){
    ll from = min(i, a[i][j]) * n + max(i, a[i][j]);
    ll to = min(i, a[i][j+1]) * n + max(i, a[i][j+1]);
    add_edge(from, to);
  }
  REP(i, n) for(ll j=i+1; j<n; j++) vset.pb(i*n + j);

  ll k = scc();
  // cout << k << endl;
  // for(auto v: vs) cout << v  << " " << cmp[v] << endl;
  // for(auto v: vset){
  //   for(auto e: G[v]) cout << "from:" << v << " to:" << e << " ";
  //   cout << endl;
  // }
  if(k != v) cout << -1 << endl;
  else{
    ll ret = 0;
    for(auto a: vset) ret = max(ret, depth[a]);
    cout << ret + 1 << endl;
  }
  return 0;
}

Measured memory_bytes: 117228
tn = []
tm = []

def check(d):
    for h in range(d + 1):
        for w in range(d + 1):
            mw = len(tm)
            result = True
            for tmh in range(mw):
                row = tn[h + tmh][w:w + mw]
                if row != tm[tmh]:
                    result = False
                    break

            if result:
                return True

    return False

N, M = list(map(int, input().rstrip().split()))
for i in range(N):
    tn.append(list(input().rstrip()))

for i in range(M):
    tm.append(list(input().rstrip()))

d = N - M

print('Yes' if check(d) else 'No')



Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>

using namespace std;

static const int INF = 1 << 28;
static const int dx[] = {0, 0, 1, -1};
static const int dy[] = {-1, 1, 0, 0};

#define MOD 1000000007
#define D(x) cout << x << endl
#define d(x) cout << x

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

int main() { 
  char a, b;
  cin >> a >> b;
  if (a == b) {
    D('H');
  } else {
    D('D');
  }
  return 0;
}


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

using namespace std;

struct DATA{
  int x;
  int y;
};

void North(int, int&, int&, vector<DATA>&);
void South(int, int&, int&, vector<DATA>&);
void East(int, int&, int&, vector<DATA>&);
void West(int, int&, int&, vector<DATA>&);

int main(){
  int i, n, m, x, y, d;
  string s;
  DATA _data;
  vector<DATA> data;

  while(1){
    cin >> n;
    if(n == 0) break;

    for(i=0; i<n; ++i){
      cin >> x >> y;
      _data.x = x;
      _data.y = y;
      data.push_back(_data);
    }

    cin >> m;

    for(i=0, x=10, y=10; i<m; ++i){
      cin >> s >> d;

      if(data.size() != 0){
	if(s == "N") North(d, x, y, data);
	else if(s == "S") South(d, x, y, data);
	else if(s == "E") East(d, x, y, data);
	else if(s == "W") West(d, x, y, data);
      }
    }

    if(data.size() == 0)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;

    data.clear();
  }

  return 0;
}

void North(int d, int& x, int& y, vector<DATA>& data){
  vector<DATA>::iterator i = data.begin();
  while(i != data.end()){
    if(x == (*i).x && y <= (*i).y && y+d >= (*i).y)
      i = data.erase(i);
    else
      ++i;
  }
  y += d;
}

void South(int d, int& x, int& y, vector<DATA>& data){
  vector<DATA>::iterator i = data.begin();
  while(i != data.end()){
    if(x == (*i).x && y-d <= (*i).y && y >= (*i).y)
      i = data.erase(i);
    else
      ++i;
  }
  y -= d;
}

void East(int d, int& x, int& y, vector<DATA>& data){
  vector<DATA>::iterator i = data.begin();
  while(i != data.end()){
    if(y == (*i).y && x <= (*i).x && x+d >= (*i).x)
      i = data.erase(i);
    else
      ++i;
  }
  x += d;
}

void West(int d, int& x, int& y, vector<DATA>& data){
  vector<DATA>::iterator i = data.begin();
  while(i != data.end()){
    if(y == (*i).y && x-d <= (*i).x && x >= (*i).x)
      i = data.erase(i);
    else
      ++i;
  }
  x -= d;
}

Measured memory_bytes: 0
import java.util.*;

class Main{
	static int mod=1000000007;

	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);

		int n=s.nextInt();
		BitSet q=new BitSet(n+1),a=new BitSet(n+1);
		for(int i=1;i<=n;++i)
			q.set(i,s.nextInt()==1);

		for(int i=n;i>0;--i){
			boolean t=q.get(i);
			for(int j=i*2;j<=n;j+=i)
				t^=a.get(j);
			a.set(i,t);
		}
		System.out.println(a.cardinality());
		StringBuilder sb=new StringBuilder();
		for(int i=1;i<=n;++i)
			if(a.get(i))
				sb.append(i).append("\n");
		System.out.println(sb);
	}
}


Measured memory_bytes: 64308
N = int(input())
V = list(map(int, input().split()))
for i in range(N-1):
  min1 = 0
  min2 = 0
  min1 = min(V)
  V.remove(min(V))
  min2 = min(V)
  V.remove(min(V))
  mix = 0
  mix = (min1+min2)/2
  V.append(mix)
print(*V)

Measured memory_bytes: 3064
N,M=map(int,input().split())

S=[]
C=[]

for i in range(N):
  a,b=map(int,input().split())
  S.append([a,b])
for i in range(M):
  a,b=map(int,input().split())
  C.append([a,b])
  
for a,b in S:
  min=M
  man=10**10
  for i in range(M):
    cnt=abs(a-C[i][0])+abs(b-C[i][1])
    if man>cnt:
      man=cnt
      min=i
  print(min+1)

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
using namespace std;
typedef long long ll;

void Main()
{
    int n, m;
    cin >> n >> m;
    pair<int, bool> h[n];
    for (int i = 0; i < n; i++)
    {
        cin >> h[i].first;
        h[i].second = false;
    }

    vector<vector<int>> data(m, vector<int>(2));
    for (int i = 0; i < m; i++)
    {
        for (int j = 0; j < 2; j++)
        {
            cin >> data.at(i).at(j);
        }
    }

    for (int i = 0; i < m; i++)
    {
        if (h[data.at(i).at(0) - 1] > h[data.at(i).at(1) - 1])
        {
            h[data.at(i).at(1) - 1].second = true;
        }
        else if (h[data.at(i).at(0) - 1] < h[data.at(i).at(1) - 1])
        {
            h[data.at(i).at(0) - 1].second = true;
        }
        else
        {
            h[data.at(i).at(1) - 1].second = true;
            h[data.at(i).at(0) - 1].second = true;
        }
    }

    int count = 0;
    for (int i = 0; i < n; i++)
    {
        if (!h[i].second)
        {
            count++;
        }
    }
    cout << count << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 9556
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<utility>
#include<functional>
#include<cassert>
#include<cmath>
#include<math.h>
#include<unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<ll> vint;
typedef vector<vint> vvint;
#define PI 3.1415926535
#define MOD 1000000007
#define rep(i, n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define MAX ((ll)1<<(ll)31)-1

int main(void) {
	string s, t; cin >> s >> t;
	cout << t << s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define dfor(i,a,b) for(int i=(a);i>=(b);i--)
#define ll long long
#define ull unsigned long long

int main() {
	ll k,x;
	cin>>k>>x;
	ll low = x - (k -1);
	ll high = x +( k-1);
	if(low<-1000000) low = -1000000;
	if(high>1000000) high = 1000000;

	FOR(i,low,high){
		cout<<i<<" ";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

// #include <iostream>
// #include <queue>

// using i64 = long long int;
using namespace std;

int main(){
  int k;
  cin >> k;
  const int INF = 100000;
  vector<int> dp(100005,INF);
  priority_queue<
    pair<int,int>,
    vector<pair<int,int>>,
    greater<pair<int,int>> > q;
  q.push(make_pair(1,1));
  dp[1] = 1;
  while(!q.empty()){
    if(dp[0] != INF)break;
    int cc = q.top().first;
    int c = q.top().second;
    // cerr << cc << " " << c << endl;
    q.pop();
    int n1 = (c+1)%k;
    int n2 = (c*10)%k;
    if(dp[c] < cc)continue;
    if(dp[c]+1 < dp[n1]){
      dp[n1]=dp[c]+1;
    //   cerr << "c1" << endl;
      q.push(make_pair(cc+1,n1));
    }
    if(dp[c] < dp[n2]){
      dp[n2]=dp[c];
    //   cerr << "c2" << endl;
      q.push(make_pair(cc,n2));
    }
  }
  cout << dp[0] << endl;
}

Measured memory_bytes: 1276
def c_same_integers(A, B, C):
    # A,B,Cの和と、これらのうち最大のもの(Mとする)の3倍との
    # 偶奇が一致するなら、最終的に3つの整数はMとなる
    # 偶奇が一致しないなら、最終的に3つの整数はM+1となる
    m = max(A, B, C)
    initial_total = A + B + C  # 初期状態での整数の和

    parity = 3 * m % 2 == initial_total % 2
    final_value = m if parity else m + 1  # 整数はこの値で等しくなる
    # 3数の和は1回の操作で2増えるため,ans回の操作が必要
    ans = (3 * final_value - initial_total) // 2
    return ans

A,B,C = [int(i) for i in input().split()]
print(c_same_integers(A, B, C))

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

using namespace std;

#define sz(x) ((int) ((x).size()))
typedef long long ll;
typedef long double ld;

bool v[4];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(10);
  string s;
  cin >> s;
  for (int i = 0; i < sz(s); i++)
    v[s[i] == 'N' ? 0 : (s[i] == 'S' ? 1 : (s[i] == 'E' ? 2 : 3))] = true;
  cout << (v[0] == v[1] && v[2] == v[3] ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char s[4];
  scanf("%s",s);
  if(s[2]=='\0'){
    printf("%s\n",s);
  }else{
    char tmp;
    tmp = s[0];
    s[0] = s[2];
    s[2] = tmp;
    printf("%s\n",s);
  }

  return 0;
}


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

bool check_num(int x) {
  return x % 3 == 0;
}

bool include3(int x) {
  while (x) {
    if (x % 10 == 3) return true;
    else x /= 10;
  }
  return false;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (check_num(i) || include3(i)) cout << " " << i;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
 
#define ll long long
ll MOD = 1000000007;
 
using namespace std;
 
int main() {
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    int changes = 0, ans = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'L' && i > 0 && s[i - 1] == 'L') {
            ans++;
        }
        if (s[i] == 'R' && i < n - 1 && s[i + 1] == 'R') {
            ans++;
        }
        if (i > 0 && s[i] != s[i - 1]) changes++;
    }
    if (ans == n - 1) {
        cout << n - 1;
    }
    else {
        if (k >= ( (changes + 1) / 2 ) ) {
            ans += (((changes + 1) / 2) * 2) - (changes % 2);
        } else {
            ans += (2 * k);
        }
        cout << ans;
    }
    return 0;
}


Measured memory_bytes: 512
/*
.......................
.......................
..... MY CODES ARE ....
... UGLIER THAN YOU ...
.......................
.......................
*/
#define pb push_back
#define ff first
#define ss second
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define maxn 200005
#define mod 1000000007
#include <bits/stdc++.h>
using namespace std;

ll n, r, d, A[maxn], res;
ll sum[(maxn*4)],lazy[(maxn*4)];;
vector< pair<ll, ll> > v;
vector<ll> idx;

void relax(ll node, ll start, ll end){
    sum[node] += (end - start + 1) * lazy[node];
    if(start != end){
        lazy[2*node] += lazy[node];
        lazy[(2*node)+1] += lazy[node];
    }
    lazy[node] = 0;
}

void update(ll node, ll start, ll end, ll i, ll j, ll val){
    if(lazy[node])relax(node,start,end);
    if(start>j || end<i || start>end)return ;
    if(i<=start && end<=j){
        lazy[node] += val;//putting the flag
        relax(node,start,end);
        return;
    }
    ll mid = (start + end) / 2;
    update(node*2, start, mid, i, j, val);
    update((node*2)+1, mid+1, end, i, j, val);
    sum[node] = sum[node*2] + sum[(node*2)+1];
}

ll query(ll node, ll start, ll end, ll i, ll j){
    if(lazy[node])relax(node,start,end);
    if(start>j || end<i || start>end)return 0;//return something avoidalbe
    if(i<=start && end<=j){
        return sum[node];
    }
    ll p,q;
    ll mid = (start+end) / 2;
    p = query(node*2 ,start, mid, i, j);
    q = query((node*2)+1, mid+1, end, i, j);
    return p+q;
}


void build(ll node,ll start, ll end){
    if(start == end){
        sum[node] = A[start];
        return;
    }
    ll mid = (start + end) / 2;
    build(node*2, start, mid);
    build((node*2)+1 , mid+1, end);
    sum[node] = sum[node*2] + sum[(node*2)+1];
}

void solve(){
    v.clear();
    cin >> n >> r >> d;
    for(ll i=1;i<=n;i++){
        ll x, y, bomb;
        cin >> x >> y;
        v.pb({x, y});
    }
    sort(v.begin(), v.end());
    for(ll i=0;i<n;i++) {
        A[i+1] = v[i].ss;
        idx.pb(v[i].ff);
    }
    build(1,1,n);
    for(ll i=1;i<=n;i++){
        if(query(1, 1, n, i, i) <= 0) continue;
        ll cur, nxt;
        cur = idx[i-1];
        nxt = cur + r +  r;
        ll tut = upper_bound(idx.begin(), idx.end(), nxt) - idx.begin();
        //cout << i << " -> "<< tut << endl;
        //cout << cur << " ==  "<< nxt << endl;
        ll q = query(1, 1, n, i, i);
        ll val = (q / d) + (q%d != 0);
        res += val;
        //cout << res << " "<< val << endl;
        val *= d;
        update(1, 1, n, i, tut, -val);
    }
    cout << res << endl;

}


int main() {

    ll tc;
    tc = 1;
    while(tc--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 21228
import math
import string


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]

s = input()
cnt = 0
for i in range(len(s)):
    if s[i] == '1':
        cnt += 1
print(cnt)


Measured memory_bytes: 3832
from sys import stdin

N, K = [int(x) for x in stdin.readline().rstrip().split()]
A = [int(x) for x in stdin.readline().rstrip().split()]
ans = 0
inf = 10 ** 9 + 7

for i in range(N):
    cnt_left = 0
    cnt_right = 0
    for j in range(N):
        if A[j] < A[i]:
            if j < i:
                cnt_left += 1
            else:
                cnt_right += 1
    ans += (cnt_right * (K + 1) * K // 2) % inf
    ans += (cnt_left * (K - 1) * K // 2) % inf

print(ans % inf)


Measured memory_bytes: 42092
#include<iostream>

using namespace std;

int main()
{
	int n, b, f, r, v;
	int data[4][3][10] = {};

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		cin >> b >> f >> r >> v;
		
		data[b-1][f-1][r-1] += v;
	}
	for (int k = 0; k < 4; k++)
	{
	    if(k) cout << "####################" <<endl;
	    
		for (int j = 0; j < 3; j++)
		{
		    for(int h = 0; h < 10;h++)
		    {
		        cout << " " << data[k][j][h];
		    }
		    cout << endl;
		}
	}
	return 0;
}


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

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

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

using ll = long long;
using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using ld = long double;
using str = string;

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

long int M = 1e+9+7;
int inf = 1e+9;

int dif = 26;
ll n;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    while(cin >> n){
        string ans = "";
        ll sa = 1;
        ll cnt = 0;
        while(1){
            cnt++;
            sa *= dif;
            if(sa < n){
                n-=sa;
            }else{
                break;
            }
        }

        n--;
        rep(i,cnt){
            sa/=dif;
            ans += ('a'+n/sa);
            n%=sa;
        }
        cout << ans << endl;

        //cout << solve() << endl;
        //cout << ans << endl;
    }
    return 0;
}

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

#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))

typedef long long LL;

int main(){
  int n,c;
  cin >> n >> c;
  vector<vector<int>> ch(c,vector<int>(100002,0));
  int s,t,x;
  for(int i=0;i<n;i++){
    cin >> s >> t >> x;
    x--;
    ch[x][s-1]++;
    ch[x][t]--;
  }
  for(int i=0;i<c;i++){
    for(int j=1;j<=100000;j++){
      ch[i][j]+=ch[i][j-1];
    }
  }
  int ans=0,count;
  for(int i=1;i<=100000;i++){
    count=0;
    for(int j=0;j<c;j++){
      if(ch[j][i]) count++;
    }
    ans=max(ans,count);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

int main()
{
 	int a,b,c;
  cin >> a >> b >> c;
  int arr[10] = {0};
  arr[a]++;
  arr[b]++;
  arr[c]++;
  if(arr[5] == 2 && arr[7] == 1) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma region template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vld = vector<ld>;
using vvld = vector<vld>;
using vvvld = vector<vvld>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template <typename T>
using pqrev = priority_queue<T, vector<T>, greater<T>>;
#define rep(i, n) for (ll i = 0, i##_end = (n); i < i##_end; i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for (ll i = (a), i##_end = (b); i < i##_end; i++)
#define reprb(i, a, b) for (ll i = (b)-1, i##_end = (a); i >= i##_end; i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
//*
constexpr ll MOD = 1e9 + 7;
/*/
constexpr ll MOD = 998244353;
//*/
constexpr ll INF = 1e+18;
constexpr ld EPS = 1e-12L;
constexpr ld PI = 3.14159265358979323846L;
constexpr ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
constexpr ll LCM(ll a, ll b) { return a / GCD(a, b) * b; }
template <typename S, typename T>
constexpr bool chmax(S &a, const T &b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename S, typename T>
constexpr bool chmin(S &a, const T &b) {
  if (b < a) {
    a = b;
    return 1;
  }
  return 0;
}
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif
template <typename T>
bool print_(const T &a) {
  cout << a;
  return true;
}
template <typename T>
bool print_(const vector<T> &vec) {
  for (auto &a : vec) {
    cout << a;
    if (&a != &vec.back()) {
      cout << " ";
    }
  }
  return false;
}
template <typename T>
bool print_(const vector<vector<T>> &vv) {
  for (auto &v : vv) {
    for (auto &a : v) {
      cout << a;
      if (&a != &v.back()) {
        cout << " ";
      }
    }
    if (&v != &vv.back()) {
      cout << "\n";
    }
  }
  return false;
}
void print() { cout << "\n"; }
template <typename Head, typename... Tail>
void print(Head &&head, Tail &&... tail) {
  bool f = print_(head);
  if (sizeof...(tail) != 0) {
    cout << (f ? " " : "\n");
  }
  print(forward<Tail>(tail)...);
}
#pragma endregion

void Pr(bool f){
  cout << (f ? "Yes" : "No") << "\n";
  exit(0);
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(20);
  ll q;
  cin >> q;
  while(q--){
    ll n, m, a, b;
    cin >> n >> m >> a >> b;
    print(floor_sum(n, m, a, b));
  }
}


Measured memory_bytes: 3632
import queue

N = int(input())
G = [[] for _ in range(N)]
for _ in range(N - 1):
    s, t, w = map(int, input().split())
    G[s].append((t, w))
    G[t].append((s, w))

INF = float('inf')

def dfs(s):
    dist = [INF] * N
    Q = queue.Queue()
    Q.put(s)
    dist[s] = 0
    while not Q.empty():
        u = Q.get()
        for i in range(len(G[u])):
            if dist[G[u][i][0]] == INF:
                dist[G[u][i][0]] = dist[u] + G[u][i][1]
                Q.put(G[u][i][0])
    return dist

dist = dfs(0)
idx = dist.index(max(dist))
dist = dfs(idx)
print(max(dist))



Measured memory_bytes: 46888
/*
t.me/ivanesipovvpered
*/
#pragma ARCENIY_KIRILLOV_POVELITEL_KROKODILOV
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("no-stack-protector")
//#pragma GCC push_options
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC pop_options
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define rng(a) a.begin(), a.end()
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
typedef long long ll;



main(){
    int n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector < vector <int> > g(n);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].pb(b);
        g[b].pb(a);
    }

    int a[n][2];
    for (int i = 0; i < n; i++)
        a[i][0] = a[i][1] = 0;
    for (int v = 0; v < n; v++){
        for (int i = 0; i < g[v].size(); i++){
            int to = g[v][i];
            a[to][s[v]-'A']++;
        }
    }
    stack<int> b;
    for (int i = 0; i < n; i++){
        if (!a[i][0] || !a[i][1]){
            b.push(i);
            a[i][0] = 0;
            a[i][1] = 0;
        }
    }
    int cnt = n;
    while (b.size()){
        int v = b.top();
        b.pop();
        cnt--;
        for (int i = 0; i < g[v].size(); i++){
                int to = g[v][i];
            if (a[to][s[v]-'A'] == 1 && a[to][(s[v]-'A')^1]){
                a[to][s[v]-'A']--;
                b.push(to);
                a[to][(s[v]-'A')^1] = 0;
            }
                a[to][s[v]-'A']--;
        }
    }
    if (cnt == 0){
        cout << "No";
    }else cout << "Yes";
}


Measured memory_bytes: 12164
#include <bits/stdc++.h>
using namespace std;
using VI = vector<int>;

int kakaku[101010];

int main() {
  for (int i = 0; i < 100; i++) {
    kakaku[i * 4] = 1;
  }
  for (int i = 0; i < 100; i++) {
    if (kakaku[i]) {
      for (int j = 0; j < 100; j++) {
        kakaku[i + 7 * j] = 1;
      }
    }
  }
  int n;
  cin >> n;
  if (kakaku[n]) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256