akhauriyash/Code-Regression huggingface dataset:
H,N = map(int,input().split())
Magic =[]
A =[]
E =[]
for i in range(N):
    a,b = map(int,input().split())
    Magic.append((a,b))
    A.append(a)
    E.append(a/b)
MAX_A = H+max(A)
E_MIN = min(E)
WORST = int(MAX_A/E_MIN) +2
#print(Magic)
#print(MAX_A)
#print(WORST)
DP = [[WORST] * (MAX_A+1) for i in range(N)]
for i in range(N):
    if i == 0:
        for j in range(1,MAX_A//Magic[0][0]+1):
            DP[0][j*Magic[0][0]] = Magic[0][1]*j
    else:
        for j in range(Magic[i][0]-1):
            DP[i][j] = DP[i-1][j]
        DP[i][Magic[i][0]] = min(DP[i-1][Magic[i][0]],Magic[i][1])
        for j in range(Magic[i][0]+1,(MAX_A+1)):
            DP[i][j]=min(DP[i-1][j],DP[i-1][j-Magic[i][0]]+Magic[i][1],DP[i][j-Magic[i][0]]+Magic[i][1])
            if j % Magic[i][0] == 0:
                DP[i][j]=min(DP[i][j],((j//Magic[i][0]) * Magic[i][1]))
print(min(DP[N-1][H:MAX_A]))

Measured memory_bytes: 126704
import sys
from collections import defaultdict

input = sys.stdin.readline


class AtCoder:
    def main(self):
        H, W = map(int, input().split())
        field = defaultdict(lambda: '#')
        dot_cnt = 0
        for h in range(H):
            for w, c in enumerate(list(input().rstrip())):
                field[str(h + 1) + '-' + str(w + 1)] = c
                if c == '.':
                    dot_cnt += 1

        q = [(1, 1)]
        field['1-1'] = '#'
        moving_range = ((1, 0), (-1, 0), (0, 1), (0, -1))
        moves = 1
        while q:
            if (H, W) in q:
                break

            next_q = []
            for x, y in q:
                for m_x, m_y in moving_range:
                    n_x, n_y = x + m_x, y + m_y
                    if field[str(n_x) + '-' + str(n_y)] == '.':
                        next_q.append((n_x, n_y))
                        field[str(n_x) + '-' + str(n_y)] = '#'
            moves += 1
            q = next_q
            if not q:
                print(-1)
                exit()

        print(dot_cnt - moves)


# Run main
if __name__ == '__main__':
    AtCoder().main()


Measured memory_bytes: 3700
# -*- coding: utf-8 -*-

import sys
import math


sys.setrecursionlimit(10 ** 6)

input_line = input()
inputs = input_line.split(' ')
N, M = list(map(int, inputs))
input_line = input()
inputs = input_line.split(' ')
A = list(map(int, inputs))

a_sum = sum(A)

ans = N - a_sum if N-a_sum >= 0 else -1
print(ans)



Measured memory_bytes: 9912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define IO(x) freopen(x".in", "r", stdin); freopen(x".out", "w", stdout);
const int maxn=1000+7;
int main()
{
  int N,sum=0;
  cin>>N;
  rep(i,0,N)
  {
  	  int a,b;
  	  cin>>a>>b;
  	  sum+=(b-a+1);
  }
  cout<<sum;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

llint L[87];
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);


    L[0] = 2;
    L[1] = 1;
    FOR(i, 2, 87){
        L[i] = L[i-1] + L[i-2];
    }

    int N;
    cin >> N;
    cout << L[N] << "\n";

    return 0;
}

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

int main()
{
    ll k,n,x,maxi=0,d=0,first;
    cin>>k>>n;
    ll a[n+1];
    for(ll i=0; i<n;i++)
    {
        cin>>x;
        if(i==0)
            first=x;
        maxi=max(x-d,maxi);
        d=x;
    }
    maxi=max(k-x+first,maxi);
    cout<<k-maxi<<endl;

}




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

int main() {
  char c;
  int n = 0, your_par = 0;

  vector<bool> yours;

  while( cin >> c ){
    if (c == 'p') {
      your_par++;
    }
    n++;
  }

  int max_par;
  max_par = n / 2;

  cout << (max_par - your_par) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

int main()
{
    ll h;
    cin >> h;
    ll ans =1, num = 1;
    if(h == 1){
        cout << ans << endl;
        return 0;
    }
    do{
        ans += 2*num;
        num *= 2;
        h = h/2;
    }while(h != 1);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m=0,c=0,i,a[1000];
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        if(a[i]%2==0)
        {
            c++;
        }
        if(a[i]%2==0 && a[i]%3==0 || a[i]%2==0 && a[i]%10==0 )
        {
            m++;
        }
    }
    if(c==m)
    {
        cout<<"APPROVED";
    }
    else
    {
        cout<<"DENIED";
    }
}


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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

/*
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;
 */

template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int X;
  cin >> X;
  cout << (X ^ 1) << "\n";
}



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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll N, M;
    cin >> N >> M;
    vector<pair<bool, set<ll>>> edges(N, pair<ll, set<ll>>{true, set<ll>{}});
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        edges[a].second.insert(b);
        edges[b].second.insert(a);
    }
    ll maxi = 0;
    rep(i, N) {
        ll count = 0;
        stack<ll> st;
        st.push(i);
        while(!st.empty()) {
            ll current = st.top();
            st.pop();
            if(edges[current].first) {
                count++;
                edges[current].first = false;
                iter(e, edges[current].second) {
                    st.push(e);
                }
            }
        }
        maxi = max(maxi, count);
    }
    cout << maxi << endl;
    return 0;
}


Measured memory_bytes: 34400
#include<bits/stdc++.h>
#include<string.h>
#define pb push_back
#define all(v) v.begin(),v.end()
#define see(x) cout<<#x<<" : "<<(x)<<endl;
#define ya cout<<"YES"<<endl;
#define no cout<<"NO"<<endl;
#define ff first
#define sc second
typedef long long ll;
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL),cout.tie(NULL);
    //freopen("test.txt","r",stdin);
    ll n,ind=0,i,j,ans=0,ev=0,od=0;
    cin>>n;
    vector<ll>v(n);
    for(auto &ii:v)cin>>ii;
    ll l[n+2];
    ll r[n+2];
    l[0]=r[n+1]=0;
    for(i=1;i<=n;i++)
    {
        l[i]=__gcd(l[i-1],v[i-1]);
    }
    for(i=n-1;i>=0;i--)
    {
        r[i+1]=__gcd(r[i+2],v[i]);
    }
    ans=1;
    for(i=1;i<=n;i++)
    {
        ans=max(__gcd(l[i-1],r[i+1]),ans);
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 5584
# ABC 121 D

from collections import deque

# 0 ~ x で xor を求める
def calc(x):
    if x == 0:
        return 0
    num_numbers = x+1
    num1 = (num_numbers) // 2
    tmp = 0
    if num1 % 2 == 1:
        tmp = 1

    if num_numbers % 2 == 0:
        return tmp
    else:
        return tmp + x

def resolve():
    a, b = map(int, input().split())
    ans = calc(a-1) ^ calc(b)
    print(ans)

if __name__ == "__main__":
    resolve()


Measured memory_bytes: 3316
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = parseInt.(x)

function main()
	n,q = readline() |> split |> parseMap
	e = [Int[] for i in 1:n]
	t = zeros(Int,n)
	t[1] = -1
	for i in 1:n-1
		a,b = readline() |> split |> parseMap
		push!(e[a],b)
		push!(e[b],a)
	end
	stack = Int[1]
	c = zeros(Int,n)
	for i in 1:q
		p,x = readline() |> split |> parseMap
		c[p]+=x
	end
	total = zeros(Int,n)
	while !isempty(stack)
		now = shift!(stack)
		for i in 1:length(e[now])
			if t[e[now][i]] == 0
				t[e[now][i]] = now
				c[e[now][i]] += c[now]
				push!(stack, e[now][i])
			end
		end
	end
	for i in 1:n-1
        print(c[i], " ")
    end
    println(c[n])
end

main()

Measured memory_bytes: 180636
#include <bits/stdc++.h>
#include <fstream>
#include<string>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>


typedef  long long ll;
typedef long double ld;
using namespace std;
using namespace __gnu_pbds;


#define endl "\n"
#define FIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const int N=2e5+5;
ll mod=1e9+7;
ll mul (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a*b)%mod;
}
ll add (ll a, ll b)
{
    a%=mod;
    b%=mod;
    return (a+b+mod)%mod;
}
ll fastpow(ll b, ll p)
{
    if(p==0)
        return 1;
    ll ans=fastpow(b,p/2);
    ans=mul(ans,ans);
    if(p%2)ans=mul(ans,b);
    return ans;
}


int main()
{
    FIO
    ll a,b,x,y;
    cin>>a>>b>>x>>y;
    ld ans=(ld)(a*b)/2.0;
    bool good=((((a)/2)==x)&&((b)/2==y)&&(a%2==0)&&(b%2==0));
    cout<<fixed<<setprecision(12)<<ans<<" ";
    cout<<good<<endl;
    return 0;
}


Measured memory_bytes: 3800
#include<bits/stdc++.h>
using namespace std;
int a,b,c,ab,ac,bc;
int main()
{
    cin>>a>>b>>c;
    ab=a+b;
    ac=a+c;
    bc=b+c;
    cout<<min(ab,min(ac,bc))<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;
vector<int> m(1e6 + 5, 0);
inline void removefromMap(int x) { m[x]--; }
inline void addToMap(int x) { m[x]++; }

int main() {
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  int SZ = 1e6 + 5;
  vector<vector<int>> facs(SZ);
  for (int i = 1; i < SZ; i++)
    facs[i].reserve(20);
  for (int i = 1; i < SZ; i++) {
    for (int j = i; j < SZ; j += i) {
      facs[j].push_back(i);
    }
  }
  int n;
  cin >> n;
  vector<int> v(n);
  for (auto &x : v) {
    cin >> x;
    addToMap(x);
  }
  int ans = 0;
  for (auto x : v) {
    removefromMap(x);
    int tans = 1;
    for (auto f : facs[x]) {
      if (m[f] != 0)
        tans = 0;
    }
    ans += tans;
    addToMap(x);
  }
  cout << ans << "\n";
}

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

template<typename T> class Dijkstra {
public:
  struct edge {
    int to; T cost;
  };
  int V;
  vector<vector<edge>> G;
  vector<T> dist;
  using pti = pair<T,int>;
  Dijkstra(int n) : V(n), G(V), dist(V, numeric_limits<T>::max()) {}
  void add(int u, int v, T cost) {
    G.at(u).push_back((edge) {v, cost});
  }
  void solve(int s) {
    priority_queue<pti, vector<pti>, greater<pti>> Q;
    dist.at(s) = 0;
    Q.push(pti(0, s));
    while (!Q.empty()) {
      pti p = Q.top();
      Q.pop();
      int v = p.second;
      if (dist.at(v) < p.first) continue;
      for (auto &w : G.at(v)) {
        if (dist.at(w.to) > dist.at(v) + w.cost) {
          dist.at(w.to) = dist.at(v) + w.cost;
          Q.push(pti(dist.at(w.to), w.to));
        }
      }
    }
  }
};

int main() {
  int N;
  cin >> N;
  int U, V;
  cin >> U >> V;
  U--, V--;
  Dijkstra<int> D(N);
  for (int i = 0; i < N - 1; i++) {
    int a, b;
    cin >> a >> b;
    a--, b--;
    D.add(a, b, 1);
    D.add(b, a, 1);
  }
  auto DU = D;
  DU.solve(U);
  auto DV = D;
  DV.solve(V);
  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (DU.dist.at(i) < DV.dist.at(i)) ans = max(ans, DV.dist.at(i) - 1);
  }
  cout << ans << "\n";
}

Measured memory_bytes: 22188
#include<stdio.h>

int main(){

    int d[5],k;
    scanf("%d %d %d %d %d %d",&d[0],&d[1],&d[2],&d[3],&d[4],&k);

    if(d[4]-d[0]<=k){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define ls(x) (x<<1)
#define rs(x) (x<<1|1)
#define gc getchar()
#define ll long long
#define int long long
#define ri register int
#define rc register char
#define rb register bool
#define rp(i,x,y) for(ri i=x;i<=y;++i)
#define my(i,x,y) for(ri i=x;i>=y;--i)
using namespace std;
    
ll tr1[1000001], tr2[1000001], tag[1000001],n,q,pre;

il int read()
{
    rc ch=gc;ri x=0;rb y=1;
    while(ch!='-' && (ch>'9' || ch<'0'))ch=gc;
    if(ch=='-')ch=gc,y=0;
    while(ch>='0' && ch<='9')x=(x<<1)+(x<<3)+(ch^'0'),ch=gc;
    return y?x:-x;
}
il void pushdown(int nw) 
{
    if (!tag[nw])return;
    tag[ls(nw)] += tag[nw];
    tag[rs(nw)] += tag[nw];
    tr1[ls(nw)] += tag[nw];
    tr2[ls(nw)] += tag[nw];
    tr1[rs(nw)] += tag[nw];
    tr2[rs(nw)] += tag[nw];
    tag[nw] = 0;
}
void modify(ri nw,ri l,ri r,ri to,ll dat)
{
	if(l==r){tr1[nw]=min(tr1[nw],dat-to),tr2[nw]=min(tr2[nw],dat+to);return;}
	pushdown(nw);ri mid=(l+r)>>1;to<=mid?modify(nw<<1,l,mid,to,dat):modify(nw<<1|1,mid+1,r,to,dat);
	tr1[nw]=min(tr1[nw<<1],tr1[nw<<1|1]);tr2[nw]=min(tr2[nw<<1],tr2[nw<<1|1]);
}
ll query1(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (tr1[nw]);
    int mid = (l + r) >> 1;pushdown(nw);
    if (rl > mid)return (query1(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query1(rl, rr, l, mid, ls(nw)));
    return (min(query1(rl, mid, l, mid, ls(nw)), query1(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query2(int rl, int rr, int l, int r, int nw) 
{
    if (rl == l && rr == r)return (tr2[nw]);
    int mid = (l + r) >> 1;pushdown(nw);
    if (rl > mid)return (query2(rl, rr, mid + 1, r, rs(nw)));
    if (rr <= mid)return (query2(rl, rr, l, mid, ls(nw)));
    return (min(query2(rl, mid, l, mid, ls(nw)), query2(mid + 1, rr, mid + 1, r, rs(nw))));
}
ll query(int l, int r, int nw) 
{
    if (l == r)return (tr1[nw] + l);
    int mid = (l + r) >> 1;pushdown(nw);return (min(query(l, mid, ls(nw)), query(mid + 1, r, rs(nw))));
}
signed main() 
{
//	freopen("2558.in","r",stdin);
    n = read(), q = read(), pre = read();memset(tr1, 63, sizeof(tr1));memset(tr2, 63, sizeof(tr2));modify(1,1,n,read(),0);
    while(q--)
	{
        int nw=read();ll dat=min(query1(1,nw,1,n,1)+nw,query2(nw,n,1,n,1)-nw);
        tag[1]+=abs(nw-pre);tr1[1]+=abs(nw-pre);tr2[1]+=abs(nw-pre);modify(1,1,n,pre,dat);
        pre=nw;
    }
    printf("%lld\n",query(1,n,1));
    return (0);
}

Measured memory_bytes: 23808
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N = int(input())
Network = UnionFind(N)

XYi = []
for i in range(N):
    X,Y = list(map(int,input().split()))
    ind = i
    XYi.append([X,Y,ind])
XYi.sort(key=lambda x:x[0])

import heapq
q = []
heapq.heapify(q)
for i in range(N):
    X,Y,ind = XYi[i]
    minY = Y
    while q and q[0][0] < Y:
        jY, j = heapq.heappop(q)
        minY = min(jY, minY)
        Network.union(ind, j)
    heapq.heappush(q, [minY, Network.find(ind)])
for i in range(N):
    print(Network.size(i))

Measured memory_bytes: 118752
#include <cstdio>
#include <cctype>

#define A_NUM 26
using namespace std;

int main(void) {

	char ch;
	int alpha[A_NUM] = {};

	while (scanf("%c", &ch) != EOF) {
		if (isalpha(ch)) {
			if (isupper(ch)) ch = tolower(ch);
			alpha[(int)(ch - 'a')]++;
		}
	}

	for (int i = 0; i < A_NUM; i++) {
		printf("%c : %d\n", (char)(i + 'a'), alpha[i]);
	}

	return 0;
}

Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, begin, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    ll N, M;
    cin >> N >> M;
    vector<pair<ll, ll>> p(N);
    rep(i, 0, N)
    {
        ll a, b;
        cin >> a >> b;
        p.at(i) = make_pair(a, b);
    }
    sort(all(p));
    ll sum = 0;
    ll ans = 0;
    ll i = 0;
    while (sum != M)
    {
        if (sum + p.at(i).second > M)
        {
            ans += p.at(i).first * (M - sum);
            sum = M;
        }
        else
        {
            ans += p.at(i).first * p.at(i).second;
            sum += p.at(i).second;
        }
        i++;
    }
    cout << ans << endl;
}

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

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

    int d,t,s; cin >> d >> t >> s;
    float tim = (float)d/s;
    if (t >= tim) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.PrintWriter;

public class Main {
    
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new java.io.InputStreamReader(System.in));
        PrintWriter pw = new PrintWriter(System.out);
        
        String S = br.readLine();
        
        if(S.equals("ABC")) {
            pw.println("ARC");
        } else {
            pw.println("ABC");
        }

        br.close();
        pw.close();
    }
}

Measured memory_bytes: 32936
import java.util.*;
class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		while(stdIn.hasNext()) {
			double a = stdIn.nextDouble();
			double y = 4.9*(a/9.8)*(a/9.8);
			
			System.out.println((int)Math.ceil((y + 5.0)/5.0));
		}
		
	}
}

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

int main(void)
{
    string s, t;

    cin >> s >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());

    if(s < t)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
    

    
   

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <chrono>
#include <ctime>
#include <queue>
#include <math.h>
#include <deque>
#include <stack>
#include <iomanip>
#include <assert.h>
#include <stdio.h>
#include <cstring>
#include <random>

using namespace std;
#define int long long
#define ll long long
#define ld long double
#define ull unsigned long long
#define endl '\n'
#define try tr
#define pii pair<int, int>
#define ti tuple <int, int, int>
#define vi vector <int>
#define vpi vector <pii>
#define umap unordered_map
#define uset unordered_set
#define left left11
#define right right11
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define sqr(a) ((a) * (a))
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define fs first
#define sc second

ld TL = 0.25;
bool is_tl = 0;
int CALLS = 0;

inline bool IS() {
    if (++CALLS == 1000) {
        CALLS = 0;
        is_tl |= clock() > (TL - 0.1) * CLOCKS_PER_SEC;
    }
    return is_tl;
}

template<typename T1, typename T2>
inline void amin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void amax(T1 &a, T2 b) { if (a < b) a = b; }

template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> &p) {
    os << p.first << ' ' << p.second << endl;
    return os;
}

template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
    is >> p.first >> p.second;
    return is;
}

template<typename T>
ostream &operator<<(ostream &os, vector<T> &v) {
    for (auto &u : v) os << u << ' ';
    os << endl;
    return os;
}

mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
const ll N = 1e6 + 7, NS = 2e3 + 7, lg = 19, sq = 550, inf = 1e18 + 7, SM = 1e2 + 7;
const ld eps = 1e-9;
int hash_mod[4] = {1000000007, 998244353, 1000000009, 999999937}, mod = hash_mod[rnd() % 4];
int hash_pows[4] = {179, 239, 1007, 2003}, P = hash_pows[rnd() % 4];
void solve() {
    int n;
    cin >> n;
    vi a(3 * n);
    for (int i = 0; i < 3 * n; i++)
        cin >> a[i];
    sort(all(a));
    int ans = 0;
    for (int i = n; i < 3 * n; i+= 2)
        ans += a[i];
    cout << ans;
}

signed main() {
    fast
    solve();
}

Measured memory_bytes: 5600
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int D = sc.nextInt();
        int x2000 = sc.nextInt();

        int xi = x2000;
        for (int i=0; i<10; i++) {
            int xi1 = r * xi - D;
            System.out.println(xi1);
            xi = xi1;
        }

    }
}


Measured memory_bytes: 21588
// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define REP(i,n) for(ll i=0; i<(n); i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define ALL(n) begin(n),end(n)
#define IN(a, x, b) (a<=x && x<b)
#define INIT std::ios::sync_with_stdio(false);std::cin.tie(0);
template<class T> inline T CHMAX(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T CHMIN(T & a, const T b) { return a = (a > b) ? b : a; }

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);
const long long MOD = 1000000007;

ll left_array[200010];
ll right_array[200010];
ll input[200010];
ll ans[200010];

int main(void){
    ll n=0;
    cin >> n;
    REP(i, n){
        ll tmp;
        cin >> tmp;
        input[i] = tmp;
    }

    ll tmp_xor=0;
    REP(i,n){
        tmp_xor ^= input[i];
        left_array[i] = tmp_xor;
    }
    tmp_xor = 0;
    REP(i,n){
        tmp_xor ^= input[n-(i+1)];
        right_array[n-(i+1)] = tmp_xor;
    }
    REP(i,n){
        ll tmp=0;
        if(i==0){
            tmp = right_array[1];
        }else if(i == n-1){
            tmp = left_array[i-1];
        }else{
            tmp = left_array[i-1]^right_array[i+1];
        }
        cout << tmp << " ";
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 7896
#k = int(input())
#s = input()
#a, b = map(int, input().split())
#s, t = map(str, input().split())
#l = list(map(int, input().split()))
#l = [list(map(int,input().split())) for i in range(n)]

n = int(input())
t = list(map(int, input().split()))
m = int(input())
drink = []
for i in range(m):
    p, x = map(int, input().split())
    drink.append([p,x])

#print(drink)
for i in range(m):
    ans = 0
    for j in range(n):
        if (drink[i][0] - 1 == j):
            ans += drink[i][1]
        else:
            ans += t[j]
    print(ans)


Measured memory_bytes: 9188
n = gets.to_s.to_i
L = gets.to_s.split.map { |e| e.to_i }.sort

ans = 0
L.each do |s|
  L.each do |m|
    next if s >= m
    L.each do |l|
      next if (m >= l || s >= l) || (m + s <= l)
      ans += 1
    end
  end
end

puts ans

Measured memory_bytes: 14316
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p)
{
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, N);
    AIN(ll, A, N);
    SORT(A);
    ll M = 1e6;
    // ll M = 25;
    vi c(M + 1);
    FOR(a, A)
    {
        ++c[a];
    }
    vi dp(M + 1, -1);
    FOR(a, A)
    {
        if (dp[a] != -1)
        {
            c[a] = 0;
            continue;
        }
        for (ll i = 2 * a; i <= M; i += a)
        {
            c[i] = 0;
        }
        dp[a] = 1;
    }
    ll ans = 0;
    FOR(x, c)
    {
        ans += x;
    }
    OUT(ans);
}

Measured memory_bytes: 20332
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define maxn 30010
#define eps 1e-10
struct Nodes{
	double l,r;
}line[maxn];
struct Point{
	double x,y;
}p[maxn];
int n,m,w,h;
int S;
int sum[maxn],pos[maxn];
double area[maxn];
double cross(Point a,Point b,Point c)
{
	double dx1=b.x-a.x,dx2=c.x-a.x,dy1=b.y-a.y,dy2=c.y-a.y;
	return dx1*dy2-dy1*dx2;
}
int check(int id,int now)
{
	Point a,b,c;
	a.x=0;a.y=line[id].l;
	b.x=w;b.y=line[id].r;
	c=p[now];
	if(cross(a,c,b)>0)return 1;
	return 0;
}
double Area(int id1,int id2)
{
	return (line[id2].l-line[id1].l+line[id2].r-line[id1].r)*w/2.0;
}
int min(int x,int y)
{
	return x<y?x:y;
}
int main()
{
	int i,j,k;
	int L,R,mid;
	int ans;
	while(scanf("%d%d%d%d%d",&n,&m,&w,&h,&S),n||m||w||h||S){
		for(i=1;i<=m;i++){
			scanf("%lf%lf",&line[i].l,&line[i].r);
		}
		for(i=1;i<=n;i++){
			scanf("%lf%lf",&p[i].x,&p[i].y);
		}
		memset(sum,0,sizeof(sum));
		sum[0]=0;
		line[0].l=line[0].r=0;
		for(i=1;i<=n;i++){
			L=0;R=m;
			while(L<=R){
				mid=(L+R)/2;
				if(check(mid,i)){
					pos[i]=mid;
					R=mid-1;
				}else L=mid+1;
			}
			sum[pos[i]]++;
		}
		area[0]=0;
		for(i=1;i<=m;i++){
			sum[i]+=sum[i-1];
			area[i]=area[i-1]+Area(i-1,i);
		}
		if(S==0){
			printf("0\n");
			continue;
		}
		if(S==w*h){
		    printf("%d\n",n);
		    continue;
		}
		S=w*h-S;
		ans=n;
		for(i=1;i<=m;i++){
			//if(area[i]>S-eps){
				
				k=lower_bound(area,area+m+1,area[i]-S-eps)-area;
				//printf("%d %lf %d %d %d\n",i,area[i],k,sum[k-1],sum[i]);
				ans=min(ans,n-sum[i]+sum[k]);
			//}
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 2324
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

typedef vector<P> vp;
typedef vector<vp> matP;

int main() {
    string T, U;
    cin>>S>>T>>U;
    N = S.size();
    M = T.size();
    cout<<(S[N-1] == T[0] && T[M-1] == U[0] ? "YES" : "NO")<<endl;
}

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

int ar[300005];
int vis[300005];
int main()
{
  int n, i, j=1, ok=0,mi=300005;

  cin>>n;

  for(i=1; i<=n; i++)
  {
    cin>>ar[i];
  }

  for(i=1; i<=n; i++)
  {
    mi=min(ar[i],mi);
    if(mi==ar[i])ok++;
  }

  cout<<ok<<endl;
}

Measured memory_bytes: 1024
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	num, _ := strconv.Atoi(scanString())
	return num
}

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

var dummy = &Node{}

type Node struct {
	key        int
	next, prev *Node
}

func insert(key int) {
	node := &Node{key: key}
	first := dummy.next

	first.prev = node
	node.next = first

	node.prev = dummy
	dummy.next = node
}

func delete(key int) {
	node := search(key)
	if node == dummy {
		return
	}
	node.prev.next = node.next
	node.next.prev = node.prev
}

func deleteFirst() {
	second := dummy.next.next
	dummy.next = second
	second.prev = dummy
}

func deleteLast() {
	secondLast := dummy.prev.prev
	secondLast.next = dummy
	dummy.prev = secondLast
}

func search(key int) *Node {
	node := dummy.next
	for {
		if node.key == key {
			return node
		}
		node = node.next
		if node == dummy {
			break
		}
	}
	return dummy
}

func print() string {
	buf := bytes.Buffer{}
	current := dummy.next
	for {
		buf.WriteString(strconv.Itoa(current.key))
		current = current.next
		if current == dummy {
			break
		}
		buf.WriteString(" ")
	}
	return buf.String()
}

func init() {
	sc.Split(bufio.ScanWords)
	dummy.prev = dummy
	dummy.next = dummy
}

func main() {
	n := scanInt()

	for i := 0; i < n; i++ {
		command := scanString()
		switch command {
		case "insert":
			insert(scanInt())
		case "delete":
			delete(scanInt())
		case "deleteFirst":
			deleteFirst()
		case "deleteLast":
			deleteLast()
		}
	}

	fmt.Println(print())
}



Measured memory_bytes: 47432
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
const ll MOD=1e+9+7;
struct mint{
  ll x;
  mint(ll x=0):x(x%MOD){}
  mint& operator+=(const mint a){
    if((x+=a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator-=(const mint a){
    if((x += MOD-a.x)>=MOD) x-=MOD;
    return *this;
  }
  mint& operator*=(const mint a){
    (x*=a.x)%=MOD;
    return *this;
  }
  mint operator+(const mint a) const{
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const{
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const{
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const{
    if(!t) return 1;
    mint a = pow(t>>1);
    a*=a;
    if(t&1) a*=*this;
    return a;
  }
  
  //for prime mod
  mint inv() const{
    return pow(MOD-2);
  }
  mint& operator/=(const mint a){
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const{
    mint res(*this);
    return res/=a;
  }
};

int main()
{
  int n,m;
  cin >> n >> m;
  vector<int> a(n),b(m);
  rep(i,n){
    cin >> a[i];
  }
  rep(i,m){
    cin >> b[i];
  }

  map<int,int> raw,col;
  rep1(i,n*m){
    raw[i] = 0;
    col[i] = 0;
  }

  rep(i,n){
    raw[a[i]]++;
  }

  rep(i,m){
    col[b[i]]++;
  }

  int cntr=0,cntl=0,cnt=0;
  mint res(1);
  for(int i=n*m;i>0;--i){
    int x = raw[i];
    int y = col[i];
    //    cout << i << ":" << x << ":" << y << "\n";
    if(x>=2||y>=2){
      cout << 0 << "\n";
      return 0;
    }
    if(x==1&&y==1){
      cntr++;
      cntl++;
    }
    else if(x==1&&y==0){
      res *= (mint)cntl;
      cntr++;
    }
    else if(x==0&&y==1){
      res *= (mint)cntr;
      cntl++;
    }
    else if(x==0&&y==0){
      res *= (mint)(cntr*cntl-cnt);
    }
    cnt++;
  }

  cout << res.x << "\n";
  
  return 0;
}


Measured memory_bytes: 93952
s=input()
t=input()

s_arr=[]
t_arr=[]
for x in s:
    s_arr.append(ord(x)-ord('a'))
for x in t:
    t_arr.append(ord(x)-ord('a'))
s_arr=sorted(s_arr)
t_arr=sorted(t_arr)
t_arr.reverse()
if len(s_arr)>len(t_arr):
    t_arr+=[-1]*(len(s_arr)-len(t_arr))
elif len(s_arr)<len(t_arr):
    s_arr+=[-1]*(len(t_arr)-len(s_arr))
ans='No'
for i in range(len(s_arr)):
    if s_arr[i]<t_arr[i]:
        ans='Yes'
        break
    elif s_arr[i]>t_arr[i]:
        ans='No'
        break
    else:
        pass
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

/**
 * 解説通りに実装したソースコード
 * 
 * https://atcoder.jp/contests/abc174/submissions/15644133 と https://atcoder.jp/contests/abc174/submissions/15644479
 * にも参考<br/>
 * java.util.Scanner が遅いため、java.io.BufferedReaderを使用
 */
public class Main {

	public static void main(String[] args) {
		try (InputStreamReader isr = new InputStreamReader(System.in); BufferedReader br = new BufferedReader(isr)) {
			String[] strings = br.readLine().split(" ", 2);
			int n = Integer.parseInt(strings[0]), q = Integer.parseInt(strings[1]);
			String[] cs = br.readLine().split(" ", n);
			Query[] queries = new Query[q];
			for (int i = 0; i < q; i++) {
				String[] s = br.readLine().split(" ", 2);
				int l = Integer.parseInt(s[0]), r = Integer.parseInt(s[1]);
				queries[i] = new Query(i, l, r);
			}
			Arrays.sort(queries);
			BinaryIndexedTree bit = new BinaryIndexedTree(n + 1);
			int[] answers = new int[q], indexes = new int[n + 1];
			// Arrays.fill(indexes, 0);
			int queryIndex = 0;
			for (int i = 0; i < n; i++) {
				int c = Integer.parseInt(cs[i]);
				if (indexes[c] > 0) {
					bit.add(indexes[c], -1);
				}
				bit.add(i + 1, 1);
				indexes[c] = i + 1;
				while ((queryIndex < q) && (i + 1 == queries[queryIndex].right)) {
					answers[queries[queryIndex].index] = bit.sum(queries[queryIndex].left, queries[queryIndex].right);
					queryIndex++;
				}
				if (queryIndex >= q) {
					break;
				}
			}
			StringBuilder sb = new StringBuilder();
			for (int x : answers) {
				sb.append(x).append("\n");
			}
			System.out.print(sb);
//			for (int i = 0; i < q; i++) {
//				System.out.println(answers[i]);
//			}
			// Arrays.stream(answers).forEach(System.out::println);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}

	private static class Query implements Comparable<Query> {
		int index;
		int left;
		int right;

		Query(int index, int left, int right) {
			super();
			this.index = index;
			this.left = left;
			this.right = right;
		}

		@Override
		public int compareTo(Query o) {
			return this.right - o.right;
		}
	}

	private static class BinaryIndexedTree {
		int size;
		int[] data;

		BinaryIndexedTree(int size) {
			super();
			this.size = size;
			data = new int[size];
			// Arrays.fill(data, 0);
		}

		void add(int index, int value) {
			int mask = 1;
			while (index < size) {
				if ((index & mask) != 0) {
					data[index] += value;
					index += mask;
				}
				mask <<= 1;
			}
		}

		int sum(int index) {
			int sum = 0, mask = 1;
			while (index > 0) {
				if ((index & mask) != 0) {
					sum += data[index];
					index -= mask;
				}
				mask <<= 1;
			}
			return sum;
		}

		int sum(int from, int to) {
			return sum(to) - sum(from - 1);
		}
	}
}


Measured memory_bytes: 107396
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#define LL long long
using namespace std;
#define maxn 5007


int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    printf("%d\n",min(a,b)+min(c,d));
    return 0;
}


Measured memory_bytes: 256
// The very basic /////////////////////////////////////////////////////////////
#include <bits/stdc++.h>
using namespace std;
#define ALL_H 1

// Debug it by D(x) ///////////////////////////////////////////////////////////
#define DEBUG 0
#if DEBUG
#define D(x) x
#else
#define D(x)
#endif

// Print elements of containers using << operator /////////////////////////////
// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  for (auto &elem : v) {
    s << elem;
    if (&elem != &v.back()) s << " ";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  for (auto &elem : vv) {
    s << elem;
    if (&elem != &vv.back()) s << endl;
  }
  return s;
}
// map
template<typename T1, typename T2> ostream& operator<<(ostream& s, const map<T1, T2>& m) {
  s << "{" << endl;
  for (auto &elem: m) {
    s << " " << elem.first << " : " << elem.second << endl;
  }
  s << "}";
  return s;
}
//set
template<typename T> ostream& operator<<(ostream& s, const set<T>& m) {
  s << "{ ";
  for (auto &elem: m) {
    s << elem << " ";
  }
  s << "}";
  return s;
}

// Convenient macros //////////////////////////////////////////////////////////

// types
#define ll long long
#define ld long double
#define int ll
#define Pi pair<int, int>
#define Graph vector<vector<int>>
#define WeightGraph vector<vector<Pi>>

// other
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))

// update max or min //////////////////////////////////////////////////////////

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

// gcd
int gcd(int a,int b){return b?gcd(b,a%b):a;}

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

///////////////////////////////////////////////////////////////////////////////
//                             Start Coding Here                             //
///////////////////////////////////////////////////////////////////////////////

signed main() {
  int N; cin >> N;
  int M; cin >> M;
  vector<pair<int, string>> Input;
  int account = 0;
  int pncount = 0;
  rep(i, M) {
    int x; cin >> x;
    string S; cin >> S;
    pair<int, string> p = make_pair(x, S);
    Input.push_back(p);
  }
  D(cout << Input << endl);
  map<int, int> WAs;
  set<int> ACs;
  for(auto x: Input) {
    if (ACs.count(x.first) != 0) {
      continue;
    } else {
      if (x.second == "AC") {
        pncount += WAs[x.first];
        account++;
        ACs.insert(x.first);
      } else {
        WAs[x.first]++;
      }
    }
  }
  cout << account << " " << pncount << endl;
}


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

int main() {
  int a;
  
  cin >> a;
  long long ret = 0;
//   cout<<"TEST"<<endl;
  for(int i = 1; i<=a; i++){
    //   cout << i << endl;
      if ( i%3!=0 && i%5!=0){
          ret  += i;
      }
  }
  cout << ret << endl;
}

Measured memory_bytes: 3632
#!usr/bim/python
#! -*- coding: utf-8 -*-


a_b = raw_input()
a_b = a_b.split()
a = a_b[0]
b = a_b[1]
a = int(a)
b = int(b)

status = 0

if a % 3 == 0:
    status = 1
elif b % 3 == 0:
    status = 1
elif (a + b) % 3 == 0:
    status = 1

if status == 0:
    print "Impossible"
else:
    print "Possible"


Measured memory_bytes: 2568
import itertools
K = int(input())
ans = 0
S = list(range(1,K+1))
def gcd(a,b):
  while a != 0 or b != 0:
    if a % b == 0:
      return min(a,b)
    a, b = b, a % b
for v in itertools.combinations_with_replacement(S, 3):
  if v[0] == v[1] == v[2]:
    ans += v[0]
  elif v[0] != v[1] and v[1] != v[2] and v[0] != v[2]:
    ans += gcd(gcd(v[0],v[1]),v[2])*6
  else:
    ans += gcd(gcd(v[0],v[1]),v[2])*3

print(ans)

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

const int MAXVAL = 1e6;
using namespace std;

int main () {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector <int> a(n);
  vector <int> cnt(MAXVAL+1);
  vector <int> ans(MAXVAL+1, 1);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    cnt[a[i]]++;
  }
  for (int i = 1; i <= MAXVAL; i++) {
    if (cnt[i] > 1) 
      ans[i] = 0;
    if (!cnt[i]) continue;
    for (int j = 2 * i; j <= MAXVAL; j += i)
      ans[j] = 0;
  }
  int answer = 0;
  for (int i = 0; i < n; i++)
    answer += ans[a[i]];
  cout << answer;
  return 0;
}

Measured memory_bytes: 11908
#include <bits/stdc++.h>
//----***やべーやつら***----
using namespace std;
#define int long long

//----***型定義***----
using ll = long long;
using P = pair<int,int>;

//----***Like a Pythonista***----
#define REP(ii,jj,nn) for (ll ii=jj;ii<(nn);ii++)
#define RREP(ii,nn,jj) for (ll ii = nn; jj<ii;ii--)
#define each(i,...) for (auto&& i:__VA_ARGS__)
#define ALL(vec) (vec).begin(),(vec).end()
#define sum(...) accumulate(ALL(__VA_ARGS__),0LL)
#define dsum(...) accumulate(ALL(__VA_ARGS__),0.0)
#define vec(type,name,...) vector<type> name(__VA_ARGS__)
template<class T> inline auto max(const T& a){ return *max_element(ALL(a)); }
template<class T> inline auto min(const T& a){ return *min_element(ALL(a)); }
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

//----***定数***----
#define MOD 1000000007
#define INF 100000000000000000
#define EPS 1e-9
const vector<vector<int>> DXY={{-1,0},{1,0},{0,-1},{0,1}};

//----***パーツ***----
#define fr first
#define se second
#define pb push_back

//----***入出力***---
void print() { std::cout << "\n"; }
template <class T>void print(const T &x) {std::cout << x<<"\n";}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}
#define debug(var)  do{std::cerr << #var << " ↓ "<<"\n";view(var);}while(0);
#define dbg cerr<<"🥺🥺🥺🥺🥺🥺"<<endl;
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

//----***初期時読み込み***----
struct initial{initial(){cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);};}initial_;

signed main(){
  int N,M,C;cin>>N>>M>>C;
  vector<int> B(M);
  int ans=0;
  REP(i,0,M)cin>>B[i];
  REP(i,0,N){
    vector<int> A(M);
    int a,tmp=0;
    REP(j,0,M){
      cin>>a;
      tmp+=a*B[j];
    }
    if(tmp>-C)ans++;
  }
  print(ans);
}


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

int main() {
  ll n,m;
  cin >> n >> m;
  vector<ll>ac(n),pena(n);
  rep(i,m){
    ll p; string s;
    cin >> p >> s;
    p--;
    if(ac[p]) continue;
    if(s == "AC") ac[p]++;
    else pena[p]++;
  }
  ll AC=0,PENA=0;
  rep(i,n){
    AC += ac[i];
    if(ac[i]) PENA += pena[i];
  }
  printf("%ld %ld\n",AC, PENA);
      
    return 0;
}


Measured memory_bytes: 1792