akhauriyash/Code-Regression huggingface dataset:
#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 <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,D,Q,K,R,W,H,P,L,G;
ll ans;
string S,T;
ll y[101010];
ll a[101010];
ll k[101010];
ll b[101010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};

int main() {
    cin>>N;
    vector<ll> a(N);
    rep(i,0,N){
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    ans = 0;
    ll positiv=N-1;
    rep(i,0,N){
        ans += abs(a[i]);
    }
    rep(i,0,N){
        if(a[i]>0){
            positiv=i;
            break;
        }
    }
    if(a[N-1]<0){
        ans -=abs(a[N-1]*2);
    }
    if(a[0]>0){
        ans -= a[0]*2;
        positiv = 1;
    }
    cout<<ans<<endl;
    rep(i,positiv,N-1){
        cout<<a[0]<<" "<<a[i]<<endl;
        a[0]=a[0]-a[i];
    }
    rep(i,0,positiv){
        cout<<a[N-1]<<" "<<a[i]<<endl;
        a[N-1]-=a[i];
    }
    return 0;
}


Measured memory_bytes: 2688
import sys
input = lambda: sys.stdin.readline().rstrip() 

def resolve():
    a, b, c = map(int, input().split())
    if c-a-b > 0:
        if 4*a*b < (c-a-b)**2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    resolve()


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

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int MAX { 1000010 };
const ll MOD { 1000000007 };

ll mod_pow(ll a, ll n)
{
    ll res = 1, base = a;

    while (n)
    {
        if (n & 1)
            res = (res * base) % MOD;

        base = (base * base) % MOD;
        n >>= 1;
    }

    return res;
}

ll binom(ll n, ll m)
{
    ll num = 1, den = 1;

    for (ll i = 2; i <= n; ++i)
        num = (num * i) % MOD;

    for (ll i = 2; i <= m; ++i)
        den = (den * i) % MOD;

    for (ll i = 2; i <= (n - m); ++i)
        den = (den * i) % MOD;

    auto inv = mod_pow(den, MOD - 2);
 
    return (num * inv) % MOD;
}

ll solve(int X, int Y)
{
    ll a = 0, b = 0;

    while (X > 0 and Y > 0)
    {
        if (X < Y)
        {
            --X;
            Y -= 2;
            ++a;
        } else
        {
            X -= 2;
            --Y;
            ++b;
        }
    }

    if (X or Y)
        return 0;

    return binom(a + b, a);
}

int main()
{
    ios::sync_with_stdio(false);

    int X, Y;
    cin >> X >> Y;

    auto ans = solve(X, Y);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ld long double
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define all(x) x.begin(),x.end()
#define LOL cout<<'\n';
#define MOD 1000000007
#define sz(x) ((int)x.size())
#define INF LONG_LONG_MAX
#define NINF LONG_LONG_MIN
#define deb(x) cout << "[" << #x << "=" << x << "]" << '\n'
#define deb2(x,y) cout << "[" <<#x << "=" << x << "] [" << #y << "=" << y << "]" << '\n'
#define deb3(x,y,z) cout << "[" <<#x << "=" << x << "] [" << #y << "=" << y << "] [" << #z << "=" << z << "]" << '\n'

void solve(){
	int n; cin>>n;
	string s; cin>>s;
	int cntr=0,cntw=0;
	for(int i=0 ; i<n ; i++){
		if(s[i]=='R') cntr++;
		else cntw++;
	}
	int ans=0;
		for(int i=0 ; i<cntr ; i++){
			if(s[i]=='W'){
				ans++;
			}
		}
		int ans2=0;
		int just=cntw;
		for(int i=n-1 ; just-- ; i--){
			if(s[i]=='R'){
				ans2++;
			}
		}
	cntr=min(cntr,cntw);
   //deb3(cntr,ans,ans2);
	cout<<min(cntr,min(ans,ans2));
}

signed main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
 // int _;
  //for(cin>>_ ; _ ; --_){
    //cout<<"Case "<<_<<": ";
    solve();
  //}
  return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
using namespace std;
#define N (1000000000+7)
#define M (998244353)
#define INF 1e16
typedef long long ll;
typedef pair<int,vector<ll> > P;
typedef pair<P,ll>Q;
 
ll A(ll x){
    if(x>=0)return x;
    else return -x;
}
 
int main(void){
    int n,m;
    cin>>n>>m;
    vector<ll>a(n),b(n),c(m),d(m);
    for(int i=0;i<n;i++)cin>>a[i]>>b[i];
    for(int i=0;i<m;i++)cin>>c[i]>>d[i];
    for(int i=0;i<n;i++){
        ll ans = (ll)INF;
        ll index = 0;
        for(int j=0;j<m;j++){
            ll tmp = A(c[j]-a[i])+A(d[j]-b[i]);
            if(ans>tmp){
                ans = tmp;
                index = j+1;
            }
        }
        cout<<index<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <float.h>
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_ARRAY_MAX		200000									// 最大配列数

// 内部構造体 - 範囲情報
typedef struct Rng {
	int miL, miR;												// 範囲
} Rng;

// 内部変数
static FILE *szpFpI;											// 入力
static Rng sz1Array[D_ARRAY_MAX];								// 配列
static int siACnt;												// 配列数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
	static int siTNo;
#endif

// １行出力
int
fOutLine(
	char *pcpLine				// <I> １行
)
{
	char lc1Buf[1024];

#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, pcpLine)) {
		siRes = -1;
	}
#else
	printf("%s", pcpLine);
#endif

	return 0;
}

// 比較関数 - 左昇順
int
fCmpFncLu(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Rng *lzpVal1 = (Rng *)pzpVal1;
	Rng *lzpVal2 = (Rng *)pzpVal2;

	// 左昇順
	if (lzpVal1->miL > lzpVal2->miL) {
		return 1;
	}
	else if (lzpVal1->miL < lzpVal2->miL) {
		return -1;
	}

	return 0;
}

// 比較関数 - 右降順
int
fCmpFncRd(
	const void *pzpVal1			// <I> 値１
	, const void *pzpVal2		// <I> 値２
)
{
	Rng *lzpVal1 = (Rng *)pzpVal1;
	Rng *lzpVal2 = (Rng *)pzpVal2;

	// 右降順
	if (lzpVal1->miR > lzpVal2->miR) {
		return -1;
	}
	else if (lzpVal1->miR < lzpVal2->miR) {
		return 1;
	}

	return 0;
}

// 実行メイン
int
fMain(
)
{
	int i;
	char lc1Buf[1024];

	// 配列数 - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d", &siACnt);

	// 配列 - 取得
	for (i = 0; i < siACnt; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		sscanf(lc1Buf, "%d%d", &sz1Array[i].miL, &sz1Array[i].miR);
	}

	// 左
	int li1L[2];
	qsort(sz1Array, siACnt, sizeof(Rng), fCmpFncLu);
	int liNo = (siACnt - 1) / 2;
	li1L[0] = sz1Array[liNo].miL;
	li1L[1] = sz1Array[liNo + 1].miL;

	// 右
	int li1R[2];
	qsort(sz1Array, siACnt, sizeof(Rng), fCmpFncRd);
	liNo = siACnt / 2;
	li1R[0] = sz1Array[liNo].miR;
	li1R[1] = sz1Array[liNo - 1].miR;

	// 奇数
	if (siACnt % 2) {
		return li1R[0] - li1L[0] + 1;
	}

	// 偶数
	else {
		int liCnt = 1;
		return li1R[0] + li1R[1] - li1L[0] - li1L[1] + 1;
	}
}

// １回実行
int
fOne(
)
{
	int liRet;
	char lc1Buf[1024];

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", siTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", siTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 実行メイン
	liRet = fMain();

	// 出力
	sprintf(lc1Buf, "%d\n", liRet);
	fOutLine(lc1Buf);

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", siTNo);
	}
	else {
		printf("NG %d\n", siTNo);
	}
#endif

	return 0;
}

// プログラム開始
int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		siTNo = i;
		fOne();
	}
#else
	fOne();
#endif

	return 0;
}



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

using namespace std;

#define fastIO(); ios_base::sync_with_stdio(false); cin.tie(NULL);
#define dbg(x); cout<<"\n"<<#x<<": "<<x;
#define UL 100000007
#define ret return
#define f(dt,i,a,b) for(dt i=a;i<b;i++)
#define pb push_back
#define sq(a) (a)*(a)
#define PI 3.14159

typedef vector<long long int> vlli;
typedef vector<int> vi;
typedef long long int lli;  //  e-18 to e18

int main(){
    fastIO();
    int r;
    float ans;
    cin>>r;
    cout<<(2*PI*r)<<"\n";
    ret 0; 
}       

Measured memory_bytes: 3776
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<double,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back
#define INF (1LL<<59)

#define EPS 1e-9
#define int ll

//verified AOJ GRL_1
#define MAX_V 100000
struct edge{int to;double cost;};
vector<edge> G[MAX_V];

void dijkstra(int s, vector<double> &d){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep( i,d.size() )d[i]=INF;
    d[s] = 0;
    que.push( pii(0,s) );
    
    while( que.size() ){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}

struct cir{
    int x,y,r;
};
signed main(){
    int xs,ys,xt,yt;
    cin>>xs>>ys>>xt>>yt;
    int n;
    cin>>n;
    vector<cir> v(n);
    rep(i,n){
        int a,b,c;
        cin>>a>>b>>c;
        v[i] = cir{a,b,c};
    }
    
    int s=n;
    int g=n+1;
    G[s].pb(edge{g,hypot(xs-xt,ys-yt)});
    rep(i,n){
        double d = hypot(v[i].x-xs,v[i].y-ys);
        if(d<=v[i].r+EPS){
            G[s].pb(edge{(int)i,0});
        }else{
            G[s].pb(edge{(int)i,d-v[i].r});
        }
        
        d = hypot(v[i].x-xt,v[i].y-yt);
        if(d<=v[i].r+EPS){
            G[i].pb(edge{(int)g,0});
        }else{
            G[i].pb(edge{(int)g,d-v[i].r});
        }
    }
    
    rep(i,n){
        rep(j,n){
            if(i==j)continue;
            double d = hypot(v[i].x-v[j].x,v[i].y-v[j].y);
            if(d<=v[i].r+v[j].r)G[i].pb(edge{(int)j,0});
            else                G[i].pb(edge{(int)j,d-v[i].r-v[j].r});
        }
    }
    
    vector<double> d(n+2);
    dijkstra(s,d);
    
    printf("%.20lf\n",d[g]);
}

Measured memory_bytes: 22908
#include <stdio.h>
int l, r;
int ans;
int main() {
	scanf("%d%d", &l, &r);
	if (l + 2019 <= r) {
		printf("0\n");
		return 0;
	}
	l = l % 2019;
	r = r % 2019;
	ans = 2019;
	if (l >= r)r += 2019;
	for (int i = l; i <= r; i++) {
		for (int j = i + 1; j <= r; j++) {
			if (ans > i * j % 2019)ans = i * j % 2019;
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)
template<typename T>bool maxup(T& a, T&& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool maxup(T& a, T& b) { if (a < b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T&& b) { if (a > b) { a = b; return true; }; }
template<typename T>bool minup(T& a, T& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }
signed main() {
	char c; cin >> c;
	set<char> s{ 'a','e','i','u','o' };
	cout << (s.count(c) ? "vowel" : "consonant") << endl;
	system("pause");
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,j,n,m,k,t,ans=0,a[31]={0};
	cin>>n>>m;
	for (i=0;i<n;i++){
		cin>>k;
		for (j=0;j<k;j++){
			cin>>t;
			a[t]++;
		}
	}
	for (i=0;i<=m;i++){
		if (a[i]==n){
			ans++;
		}
	}
	cout<<ans;
	return 0;
}

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

int main() {
    string s1="Sunny",s2="Cloudy",s3="Rainy";
    string s;
    cin>>s;
    if(s==s1){
        cout<<s2;
    }else if(s==s2){
        cout<<s3;
    }else{cout<<s1;
    }


}

Measured memory_bytes: 256
# from math import abs

N = int(input())
t = [0]*N
x = [0]*N
y = [0]*N

cx, cy, ct = 0, 0, 0
for i in range(N):
  t[i], x[i], y[i] = map(int, input().split())
  dx, dy, dt = abs(x[i]-cx), abs(y[i]-cy), abs(t[i]-ct)
  if dt < dx+dy:
    print("No")
    exit()
  if (dt-dx-dy) % 2 == 1:
    print("No")
    exit()

print("Yes")

Measured memory_bytes: 11636
import math
p = [2]
s = 3
max = 50000
last = 0

while p[last] <= max:
    m = int(math.sqrt(s))
    r = True
    for i in p:
        if i > m:
            break
        if s % i == 0:
            r = False
            break
    if r:
        p.append(s)
        last += 1
    s += 2

while True:
    try:
        n = int(raw_input())
    except EOFError as e:
        break
    i = 0
    while p[i] < n:
        i += 1
    print("%d %d" % (p[i-1], p[i+1] if p[i] == n else p[i]))

Measured memory_bytes: 4508
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int n = Integer.parseInt(sc.next());
	int m = Integer.parseInt(sc.next());
	int[] ax = new int[n];
	int[] ay = new int[n];
	int[] bx = new int[m];
	int[] by = new int[m];

	for(int i = 0; i<n; i++) {
	    ax[i] = Integer.parseInt(sc.next());
	    ay[i] = Integer.parseInt(sc.next());
	}

	for(int i = 0; i<m; i++) {
            bx[i] = Integer.parseInt(sc.next());
            by[i] = Integer.parseInt(sc.next());
        }

	int min = Integer.MAX_VALUE;
	int minI = 0;

	for(int i = 0; i<n; i++) {
	    min= Integer.MAX_VALUE;
	    for(int j = 0; j<m; j++) {
		int manhattan = (int)Math.abs(ax[i]-bx[j]) + (int)Math.abs(ay[i]-by[j]);
		if(manhattan < min ) {
		    min = manhattan;
		    minI = j+1;
		}
	    }
	    System.out.println(minI);
	}

    }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
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; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

map< lint, int > prime_factor(lint n) {
  map< lint, int > ret;
  for(lint i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}


int main(){
  lint n;
  lint result=0;
  cin>>n;
  map <lint,int> m;
  vector<int> l;
  vector<int> q;
  lint be;
  for(auto p:prime_factor(n)){
    while(p.second--) {
      int w=p.first;
      q.pb(w);
    }
  }
  for(int i=0;i<q.size();i++){
    int t=q[i];
    int f=count(all(l),t);
    if(f==0){
      l.pb(t);
      int num=count(all(q),t);
      for(int j=1;num>0;j++){
        num-=j;
        if(num>=0) result++;
      }
    }
  }

  cout<<result;

}

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

int main(){
  double r;
  double area,shu,p;
  p=3.14159265359;

  cin >> r;

  area=r*r*p;
  shu=2*p*r;

  cout << fixed << setprecision(6)<< area << " " << shu << endl;
}


Measured memory_bytes: 3212
import java.util.*;

class Main {
    private static Scanner sc;

    public static void main(final String[] args) {
        sc = new Scanner(System.in);
        int a = sc.nextInt();
        String N = sc.next(),ans = "...";
        if(N.length() <= a) System.out.println(N);
        else System.out.println(N.substring(0, a) + ans);
    }
}








Measured memory_bytes: 38984
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return abs(a*b)/gcd(a,b);}
#define roundup(divisor,dividend) (divisor + (dividend - 1)) / dividend
#define all(x) (x).begin(),(x).end()
ll n,ans=0;
ll a[10] = {0,0,0,0,0,0,1,1,1,2},
    b[10] = {1,1,1,2,2,3,2,2,3,3},
    c[10] = {2,3,4,3,4,4,3,4,4,4};
std::vector<ll> d(5,0);
int main(){
  cin >> n;
  for (size_t i = 0; i < n; i++) {
    string temp;
    cin >> temp;
    if(temp[0] == 'M')d[0]++;
    if(temp[0] == 'A')d[1]++;
    if(temp[0] == 'R')d[2]++;
    if(temp[0] == 'C')d[3]++;
    if(temp[0] == 'H')d[4]++;
  }
  for (size_t i = 0; i < 10; i++) {
    ans += d[a[i]]*d[b[i]]*d[c[i]];
  }
  cout << ans << endl;
}


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

int main() {
  vector<int> A(3);
  for(int i=0;i<3;i++){
    cin >>A.at(i);
  }
  sort(A.begin(),A.end());
  cout <<A.at(0)+A.at(1) <<endl;
  return 0;
}


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

long long func(string S , int i){
    long long out = 0;//結果
    if(S.size() == i + 1 ){
        for(int j=0;j < S.size();j++){
            out *= 10;
            out += S.at(j) - '0';
        }

        return out;    
    }

    //＋を入れない場合
    out += func(S , i+1);
    //＋を入れる場合
    long long add = 0;
    for(int j=0;j <= i;j++){ //i文字目までの数字を入力する
        add *= 10;
        add += S.at(0) - '0';
        S.erase(0, 1);
    }
  
	for(int j=1 ; j<S.size() ; j++) add *= 2;

    out += add + func(S , 0);

    return out;
}

int main(){
    string S;
    cin >> S;

    long long result = 0;
    result = func(S , 0);

    cout << result << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  int mx = 0, mn = 1000000;

  rep(y,B+1){
    if(B-y+A > N) continue;
    if(y > A) continue;

    mx = max(mx, y);
    mn = min(mn, y);
  }
    
  cout << mx << " " << mn << endl;
  
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (n, m) = readIntList()
    val a = readIntList().sorted()
    val b = List(m) { readIntList() }.sortedBy { it[1] }.reversed()

    var i = 0
    var ans = 0L
    b.forEach { (num, to) ->
        for (j in 0 until num) {
            if (i >= n) break
            if (i < n) {
                if (a[i] < to) {
                    ans += to
                } else {
                    ans += a[i]
                }
                i++
            }
        }
    }

    for (j in i until n) {
        ans += a[j]
    }

    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)

Measured memory_bytes: 81160
#include<stdio.h>

int search(int , int);

int n,A[20];

int main(){

int q, M[2000], i;

scanf("%d",&n);
for(i = 0; i < n; i++)
scanf("%d",&A[i]);
scanf("%d",&q);
for(i = 0;i < q; i++){
scanf("%d",&M[i]);
if( search(0,M[i]) == 1) printf("yes\n");
else printf("no\n");
}
return 0;
}

int search(int i, int m){
if(m == 0) return 1;
if(i >= n) return 0;
int res = search(i + 1, m) || search(i + 1, m - A[i]);
return res;
}

Measured memory_bytes: 1756
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<string>
using namespace std;
int main() {
	int N;
	int X;
	int T;
	cin >> N;
	cin >> X;
	cin >> T;
	int i;
	i = 0;
	while (N - X * i > 0) {
		i++;
	}
	cout << i * T << endl;
}


Measured memory_bytes: 3144
import java.util.*;

public class Main {
	int w, h, min;
	char[][] cmap;
	int[][] imap, ncost;
	ArrayList<int[]> list;
	
	int[] a = new int[]{0,0,1,-1};
	int[] b = new int[]{1,-1,0,0};
	
	void check(int[] perm){
		int[] perms = new int[list.size()];
		for(int i=0;i<list.size()-2;i++){
			perms[i+1] = perm[i]+1;
		}
		perms[list.size()-1] = list.size()-1;

		int sum = 0;
		for(int i=0;i<list.size()-1;i++){
			int cc = ncost[perms[i]][perms[i+1]];
			if(cc==0){
				calcCost(perms[i], perms[i+1]);
				cc = ncost[perms[i]][perms[i+1]];
			}
			sum += cc;
		}
		min = Math.min(min, sum);
	}
	
	void makeperm(int k, int[] perm, boolean[] flag){
		if(k==list.size()-2){
			check(perm);
		}else{
			for(int i=0;i<list.size()-2;i++){
				if(flag[i]==true) continue;
				perm[k] = i;
				flag[i] = true;
				makeperm(k+1, perm, flag);
				flag[i] = false;
			}
		}
	}
	
	
	void calcCost(int sid, int gid){
		ArrayDeque<Integer> y = new ArrayDeque<Integer>();
		ArrayDeque<Integer> x = new ArrayDeque<Integer>();
		int sy = list.get(sid)[0];
		int sx = list.get(sid)[1];
		int gy = list.get(gid)[0];
		int gx = list.get(gid)[1];
		y.offer(sy);
		x.offer(sx);
		
		int[][] cost = new int[h][w];
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				cost[i][j] = Integer.MAX_VALUE;
			}
		}
		cost[sy][sx] = 0;
		while(!y.isEmpty()){
			int ty = y.poll();
			int tx = x.poll();
			for(int i=0;i<4;i++){
				int ny = ty + a[i];
				int nx = tx + b[i];
				if(ny>=0 && ny<h && nx>=0 && nx<w && cmap[ny][nx]!='#'){
					if(cost[ny][nx] > cost[ty][tx]+imap[ty][tx]){
						cost[ny][nx] = cost[ty][tx]+imap[ty][tx];
						y.offer(ny);
						x.offer(nx);
					}
				}
			}
		}
		ncost[sid][gid] = cost[gy][gx];
	}
	
	void mark(int y, int x){
		int ty = Math.max(0, y-2);
		int ey = Math.min(h-1, y+2);
		int tx = Math.max(0, x-2);
		int ex = Math.min(w-1, x+2);
		
		for(int i=ty;i<=ey;i++){
			for(int j=tx;j<=ex;j++){
				imap[i][j] = Math.max(imap[i][j], 2);
			}
		}
		
		ty = Math.max(0, y-1);
		ey = Math.min(h-1, y+1);
		tx = Math.max(0, x-1);
		ex = Math.min(w-1, x+1);
		for(int i=ty;i<=ey;i++){
			for(int j=tx;j<=ex;j++){
				imap[i][j] = Math.max(imap[i][j], 3);
			}
		}
		
		imap[y][x] = 4;
	}
	
	void run(){
		Scanner sc = new Scanner(System.in);
		
		w = sc.nextInt();
		h = sc.nextInt();
		cmap = new char[h][w];
		imap = new int[h][w];
		list = new ArrayList<int[]>();
		int sy = -1;
		int sx = -1;
		int gy = -1;
		int gx = -1;
		for(int i=0;i<h;i++){
			String s = sc.next();
			for(int j=0;j<w;j++){
				char c = s.charAt(j);
				cmap[i][j] = c;
				if(c=='S'){
					sy = i;
					sx = j;
				}else if(c=='G'){
					gy = i;
					gx = j;
				}else if(c=='M'){
					list.add(new int[]{i, j});
				}else if(c=='#'){
					mark(i, j);
				}
			}
		}
		list.add(0, new int[]{sy,sx});
		list.add(new int[]{gy,gx});
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(imap[i][j]==0) imap[i][j] = 1;
			}
		}
		ncost = new int[list.size()][list.size()];
		min = Integer.MAX_VALUE;
		
		makeperm(0, new int[list.size()-2], new boolean[list.size()-2]);
		
		System.out.println(min);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}	
}

Measured memory_bytes: 26488
n,m = map(int, input().split())
mod = 10**9+7

lst = []
for i in range(m):
    lst.append(int(input()))
lst.sort()

#フィボナッチ数列
dp = [-1 for i in range(n+2)]
dp[0] = 1
dp[1] = 1
for i in lst:
    dp[i] = 0
for i in range(2,n+2):
    if dp[i]<0:
        dp[i] = dp[i-1] + dp[i-2]

# print(lst)
# print(lst2)
# print(dp)
print(dp[n]%mod)


Measured memory_bytes: 460056
n = gets.to_i
lss = []
n.times do |i|
  lss << gets.split.map(&:to_s)
  lss[i][2] = i + 1
end
ls = lss.sort_by{|i| i[0]}

ans = []
n.times do |i|
  next if ls[i] == nil
  temp = []
  j = i + 1
  toshi = ls[i][0]
  temp << ls[i]
  if ls[j] == nil
    b = temp.sort_by{|i| i[1].to_i}.reverse
    b.each do |y|
      ans << y[2]
    end
    break
  end
  if toshi == ls[j][0]
    until toshi != ls[j][0]
      temp << ls[j]
      ls[j] = nil
      j += 1
      break if ls[j] == nil
    end
  end
  b = temp.sort_by{|i| i[1].to_i}.reverse
  b.each do |y|
    ans << y[2]
  end
end

puts ans

Measured memory_bytes: 1788
import std.algorithm;
import std.array;
import std.container;
import std.conv;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

long calc(int n, int k) {
    auto m = new long[k];
    for (int i = 1; i <= n; i++)
        m[i % k]++;

    long ans = 0;
    for (int i = 1; i <= n; i++) { // a を固定
        int a = i % k;
        int b = (k - a) % k; // a の余りとの和が k の倍数になるための b の値
        int c = (k - a) % k;
        if ((b + c) % k == 0)
            ans += m[b] * m[c];
    }
    return ans;
}

long calc2(int n, int k) {
    long ans = 0;
    for (int i = 1; i <= n; i++) { // a を固定
        int a = i % k;
        long b = (k - a) % k;
        long c = (k - a) % k;
        if ((b + c) % k == 0) {
            ans += ((n + b) / k) * ((n + c) / k);
        }
    }
    return ans;
}

void main() {
    int n, k; scan(n, k);
    writeln(calc(n, k));
}


Measured memory_bytes: 3580
#include <iostream>
#include <algorithm>
using namespace std;
int main(){

int n;
short l[201];
int s=0;

cin>>n;

n*=2;

for(int i=0;i<n;i++)cin>>l[i];

sort(l,(l+n));

for(int i=0;i<n;i+=2)s+=l[i];

cout<<s<<endl;

return 0;
}


Measured memory_bytes: 256
def isCLKWISE(ph) : return not ((ph[-1][0] - ph[-3][0])*(- ph[-3][1] + ph[-2][1]) - (ph[-2][0] - ph[-3][0])*(- ph[-3][1] + ph[-1][1] ) < 0)
      
def ConvexHullScan(P) :
 P = sorted(P)
 phU = [P[0],P[1]]
 for p in P[2:] :
  phU.append(p)
  if isCLKWISE(phU) : continue
  while(True):
   del phU[-2]
   try:
    if isCLKWISE(phU) : break
   except IndexError : break
 phL = [P[-1],P[-2]]
 for p in P[-3::-1] :
  phL.append(p)
  if isCLKWISE(phL) : continue
  while(True) :
   del phL[-2]
   try:
    if isCLKWISE(phL) : break
   except IndexError : break
 del phL[0]
 del phL[-1]
 ph = phU + phL
 return ph
  
n = range(int(input()))
P = [[int(x) for x in input().split()] for _ in n]
P = ConvexHullScan(P)
P.reverse()
print(len(P))
idx = min([[x[1][1],x[1][0],x[0]] for x in enumerate(P)])[2]
for p in P[idx:] + P[:idx] : print(p[0],p[1])

Measured memory_bytes: 33140
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class CountedHashSet
        {
            public class Counter
            {
                public Counter()
                {
                    count = 1;
                }

                public int count { get; set; }
            }


            public Dictionary<string, Counter> keySet;

            public CountedHashSet()
            {
                keySet = new Dictionary<string, Counter>();
            }

            public void Add(string key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    c.count++;
                }
                else
                {
                    keySet.Add(key, new Counter());
                }
            }

            public int GetKeyCount(string key)
            {
                Counter c;

                if (keySet.TryGetValue(key, out c))
                {
                    return c.count;
                }

                return 0;
            }
        }


        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            CountedHashSet hs = new CountedHashSet();

            Char[] c = new char[10];
            for (int i = 0; i < N; i++)
            {
                string s = Console.ReadLine();
                for (int j = 0; j < 10; j++)
                {
                    c[j] = s[j];
                }
                Array.Sort(c);

                hs.Add(new string(c));
            }

            long ans = 0;
            foreach(KeyValuePair<string, CountedHashSet.Counter> e in hs.keySet)
            {
                long count = e.Value.count;

                ans += (count * (count - 1)) / 2;
            }

            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 31832
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int n,k,ans;
  ans=0;
  cin>>n>>k;
  vector<int> l(n);
  for(int i=0;i<n;i++){
    cin>>l[i];
  }
  sort(l.begin(),l.end());
  for(int i=n-k;i<n;i++){
    ans+=l[i];
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  if(a==0){
    cout << 1 << endl;
  }else if(b==0){
    cout << 2 << endl;
  }else if(c==0){
    cout << 3 << endl;
  }else if(d==0){
    cout << 4 << endl;
  }else{
    cout << 5 <<endl;
  }
}




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

long long N, Q, K;
vector<pair<long long, long long> >tree[100005];
long long x[100005];
long long y[100005];
long long d[100005];

int main(){
	cin >> N;
	for(long long i = 0; i < N-1; i++){
		long long a, b, c;
		cin >> a >> b >> c;
		a--;b--;
		tree[a].push_back(make_pair(b, c));
		tree[b].push_back(make_pair(a, c));
	}
	cin >> Q >> K;
	K--;
	for(long long i = 0; i < Q; i++){
		cin >> x[i] >> y[i];
		x[i]--;y[i]--;
	}


	priority_queue<pair<long long, long long>, 
			vector<pair<long long, long long> >, 
			greater<pair<long long, long long> > > que;
	set<long long> done;

	que.push(make_pair(0, K));

	while(!que.empty()){
		long long cost = que.top().first;
		long long cur = que.top().second;
		que.pop();
		if(done.count(cur) != 0)
			continue;
		done.insert(cur);
		d[cur] = cost;

		for(long long i = 0; i < tree[cur].size(); i++){
			long long npos = tree[cur][i].first;
			long long ncost = tree[cur][i].second;
			if(done.count(npos) != 0)
				continue;
			que.push(make_pair(cost + ncost, npos));
		}
	}

	for(long long i = 0; i < Q; i++){
		cout << d[x[i]] + d[y[i]] << endl;
	}

}

Measured memory_bytes: 17008
def func(X,A,B):
    count = 0
    for i in range(X,100):
        j = str(i)
        z = j[1]+j[0]
        for y in range(10):
            tmp = int(str(i)+str(y)+z)
            if A <= tmp and tmp <= B:
                count += 1
            elif tmp > B:
                return count
    return count
a,b = input().split()
x = a[:2]
A = int(a)
B = int(b)
X = int(x)
print(func(X,A,B))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define MAX 100005
using namespace std;
 
int main(){
  int n, c[MAX];
  long long a, b, ans = 0;
  scanf("%d%lld%lld%d", &n, &a, &b, &c[0]);
  for(int i = 1; i < n; i++){
    scanf("%d", &c[i]);
    ans += min(b, a*(c[i]-c[i-1]));
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 640
//use itertools::Itertools;
use std::cmp;
use std::collections::BTreeMap;
use std::collections::BTreeSet;
use std::collections::BinaryHeap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::collections::VecDeque;
use std::io::Read;
use std::usize::MAX;

macro_rules! input {(source = $s:expr, $($r:tt)*) => {let mut iter = $s.split_whitespace();let mut next = || { iter.next().unwrap() };input_inner!{next, $($r)*}};($($r:tt)*) => {let stdin = std::io::stdin();let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));let mut next = move || -> String{bytes.by_ref().map(|r|r.unwrap() as char).skip_while(|c|c.is_whitespace()).take_while(|c|!c.is_whitespace()).collect()};input_inner!{next, $($r)*}};}
macro_rules! input_inner {($next:expr) => {};($next:expr, ) => {};($next:expr, $var:ident : $t:tt $($r:tt)*) => {let $var = read_value!($next, $t);input_inner!{$next $($r)*}};}
macro_rules! read_value {($next:expr, ( $($t:tt),* )) => {( $(read_value!($next, $t)),* )};($next:expr, [ $t:tt ; $len:expr ]) => {(0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()};($next:expr, chars) => {read_value!($next, String).chars().collect::<Vec<char>>()};($next:expr, usize1) => {read_value!($next, usize) - 1};($next:expr, [ $t:tt ]) => {{let len = read_value!($next, usize);(0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()}};($next:expr, $t:ty) => {$next().parse::<$t>().expect("Parse error")};}

fn solve() {
    input! {
        s: chars
    }

    if s[s.len() - 1] == 's' {
        for i in 0..s.len() {
            print!("{}", s[i]);
        }
        println!("es");
    } else {
        for i in 0..s.len() {
            print!("{}", s[i]);
        }
        println!("s");
    }
}

fn main() {
    let thd = std::thread::Builder::new().stack_size(104_857_600);
    thd.spawn(|| solve()).unwrap().join().unwrap();

    /*
    // 入力を一括で読み込む場合
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut input = buf.split_whitespace();

    // inputに対しnext()で読み込んでいく
    let q: usize = input.next().unwrap().parse().unwrap();
    */
}

const LARGE_PRIME: u64 = 1_000_000_007;

// @〜でsnippet


Measured memory_bytes: 2236
N = gets.chomp.to_i

ans = 0

pat = Hash.new(0)
1.upto(N) do |i|
  s = i.to_s
  key = [s[0].to_i, s[-1].to_i]
  pat[key] += 1
end

1.upto(9) do |i|
  1.upto(9) do |j|
    ans += pat[[i, j]] * pat[[j, i]]
  end
end
puts ans


Measured memory_bytes: 1788
N = int(input())
A = list(map(int, input().split()))

XOR, SUM = 0, 0
ans, r = 0, 0

for l in range(N):
    while r < N and (XOR ^ A[r]) == (SUM + A[r]):
        XOR ^= A[r]
        SUM += A[r]
        r += 1  # rの更新があと！
        
    ans += r - l
    XOR ^= A[l]
    SUM -= A[l]

print(ans)


Measured memory_bytes: 24840
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
if N == 2:
	if A[0] * 2 >= A[1]:
		print(2)
	else:
		print(1)

else:
	c = 0
	s = A[0]
	for i in range(N - 1):
		if 2 * s >= A[i + 1]:
			c += 1
		else:
			c = 0
		s += A[i + 1]

	c += 1
	print(c)

Measured memory_bytes: 14276
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}
int h[105];

int main(){
    int N; cin >> N;
    for (int i = 0; i < N; i++){
        cin >> h[i];
    }
    int ans = 0;
    while (1){
        int flag = 0;
        for (int i = 0; i <= N; i++){
            if (h[i] > 0){
                h[i]--;
                flag = 1;
            }else{
                if (flag){
                    ans++;
                    break;
                }
            }
        }
        if (!flag) break;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	if(a<=c&&c<=a+b)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
}






Measured memory_bytes: 256
N, M = map(int, input().split())
P = [0] * M
S = ["a"] * M
flg = [0] * N
C = 0
D = 0
E = [0] * N

for i in range(M):
	tmp, S[i] = map(str, input().split())
	P[i] = int(tmp)

	if S[i]=="AC":
		if flg[P[i]-1]==0:
			C += 1
			flg[P[i]-1] = 1
			E[P[i]-1] = 0
	elif S[i]=="WA":
		if flg[P[i]-1]==0:
			D += 1
			E[P[i]-1] += 1

print(C, D-sum(E))


Measured memory_bytes: 14888
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

def solve():
    S = list(map(int, list(input())))
    S = S[::-1]
    n = len(S)
    mod = 2019

    A = [0] * n
    times = 1
    for i in range(n):
        A[i] = S[i] * times
        times = times * 10 % mod

    # 累積和
    R = [0] * (n + 1)
    for i in range(n):
        R[i+1] = (R[i] + A[i]) % mod
    # print(R)
    cnt = {}
    ans = 0
    for i in range(n+1):
        r = R[i] % mod
        # print(r)
        ans = ans + cnt.get(r, 0)
        # cnt.setdefault(r, 0)
        # ans = ans + cnt[r]
        cnt[r] = cnt.get(r, 0) + 1
    # print(cnt)
    print(ans)

if __name__ == '__main__':
    solve()


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


using namespace std;



int main()
{
	string s, t;

	cin >> s >> t;


	vector<vector<int>> dp(s.length() + 1, vector<int>(t.length() + 1, 0));


	for (int i = 1; i <= s.length(); i++) {
		for (int j = 1; j <= t.length(); j++) {


			if (s.substr(i - 1, 1) == t.substr(j - 1, 1)) {
				dp[i][j] = dp[i - 1][j - 1] + 1;
			}
			else {
				dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
			}

		}
	}

	string answer = "";


	int j = t.length();

	for (int i = s.length(); i > 0; i--) {
		if (dp[i - 1][j] < dp[i][j]) {
			while (dp[i][j - 1] == dp[i][j]) {
				j--;
			}
			answer += s.substr(i - 1, 1);
			j--;
		}
	}
	

	for (int i = answer.length() - 1; i >= 0; i--) {
		cout << answer.substr(i, 1);
	}
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define mt make_tuple
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sqr(x) ((ll)(x) * (x))

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

    int brojac = 0;

    for(int i = 0; i < n; i++)
    {
        string substring = s.substr(i, 3);

        if(substring == "ABC")
        {
            brojac++;
        }
    }

    cout << brojac << '\n';

    return 0;
}


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

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

    int sum = 0;
    for (int i = 0; i < M; ++i) {
        int A_i;
        cin >> A_i;
        sum += A_i;
    }

    if (N - sum < 0) {
        cout << -1 << endl;
    } else {
        cout << N - sum << endl;
    }

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
long double const pi = std::acos(-1.0L);
typedef pair<int,int> P;

int main() {
  int n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  ll cnt = 0;
  for(int i = 1; i<n; ++i){
    if(a[i]>=a[i-1]) continue;
    else {
      cnt += a[i-1]-a[i];
      a[i] += a[i-1]-a[i];
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 4020
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
struct Rect{
    int x1,y1,x2,y2;
    Rect(int a,int b,int c,int d){
        x1=a;y1=b;x2=c;y2=d;
    }
    Rect(){}
};
int ve[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
int main(){
    int w,h;
    for(;;){
        scanf("%d%d",&w,&h);
        if(w==0&&h==0)break;
        int n;
        scanf("%d",&n);
        vector<int> yoko,tate;
        vector<Rect> rects(n);
        for(int i=0;i<n;i++){
            int x1,y1,x2,y2;
            scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
            yoko.push_back(x1);
            yoko.push_back(x2);
            tate.push_back(y1);
            tate.push_back(y2);
            rects[i]=Rect(x1,y1,x2,y2);
        }
        yoko.push_back(0);
        yoko.push_back(w);
        tate.push_back(0);
        tate.push_back(h);
        sort(yoko.begin(),yoko.end());
        sort(tate.begin(),tate.end());
        yoko.erase(unique(yoko.begin(),yoko.end()),yoko.end());
        tate.erase(unique(tate.begin(),tate.end()),tate.end());
        for(int i=0;i<n;i++){
            rects[i].x1=find(yoko.begin(),yoko.end(),rects[i].x1)-yoko.begin();
            rects[i].y1=find(tate.begin(),tate.end(),rects[i].y1)-tate.begin();
            rects[i].x2=find(yoko.begin(),yoko.end(),rects[i].x2)-yoko.begin();
            rects[i].y2=find(tate.begin(),tate.end(),rects[i].y2)-tate.begin();
        }
        vector<vector<int> > table(yoko.size()-1,vector<int>(tate.size()-1,0));
        vector<vector<int> > te(yoko.size()-1,vector<int>(tate.size()-1,0));
        for(int i=0;i<n;i++){
            for(int xx=rects[i].x1;xx<rects[i].x2;xx++){
                for(int yy=rects[i].y1;yy<rects[i].y2;yy++)te[xx][yy]=1;
            }
        }
        for(int i=0;i<n;i++){
            for(int xx=rects[i].x1;xx<rects[i].x2;xx++){
                table[xx][rects[i].y1]++;
                if(rects[i].y2<table[xx].size())table[xx][rects[i].y2]--;
            }
        }
        for(int i=0;i<table.size();i++){
            for(int j=1;j<table[i].size();j++){
                table[i][j]+=table[i][j-1];
            }
        }
        int cnt=0;
        for(int i=0;i<table.size();i++){
            for(int j=0;j<table[i].size();j++){
                if(table[i][j]==0){
                    cnt++;
                    queue<pair<int,int> > que;
                    que.push(make_pair(i,j));
                    table[i][j]=1;
                    while(!que.empty()){
                        pair<int,int> t;
                        t=que.front();
                        que.pop();
                        int nox=t.first,noy=t.second;
                        for(int vi=0;vi<4;vi++){
                            int nex=nox+ve[vi][0],ney=noy+ve[vi][1];
                            if(0<=nex&&nex<table.size()&&0<=ney&&ney<table[i].size()&&table[nex][ney]==0){
                                table[nex][ney]=1;
                                que.push(make_pair(nex,ney));
                            }
                        }
                    }
                }
            }
        }
        printf("%d\n",cnt);
    }
}

Measured memory_bytes: 0
#include <iostream>
#include <algorithm>
#define MAX 100001
using namespace std;

int main() {
    int n;
    int m;
    int zahyo[MAX];
    long long int ans = 0;
    bool ff = true;
    cin >> n >> m;

    if(n > m){
        ff = false;
    }

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

    sort(zahyo,zahyo+m);

    int diff[MAX];
    for (int j = 0; j <m-1; ++j) {
        diff[j] = zahyo[j+1] - zahyo[j];
    }

    sort(diff,diff+m-1);

    for (int k = 0; k <m -n; ++k) {
        ans += diff[k];
    }

    if(ff) {
        cout << ans;
    } else{
        cout << 0;
    }
    return 0;
}

Measured memory_bytes: 1024
k = input()
len_k = len(k)
d = int(input())
MOD = 10**9 + 7

dp = [[[0]*d for i in range(len_k+1)] for i in range(2)]
dp[1][0][0] = 1

for i in range(len_k):
    for j in range(d):
        dp[1][i+1][(j+int(k[i])) % d] += dp[1][i][j]
        dp[1][i+1][(j+int(k[i])) % d] %= MOD
        for l in range(int(k[i])):
            dp[0][i+1][(j+l) % d] += dp[1][i][j]
            dp[0][i+1][(j+l) % d] %= MOD
        for l in range(10):
            dp[0][i+1][(j+l) % d] += dp[0][i][j]
            dp[0][i+1][(j+l) % d] %= MOD

print((dp[0][-1][0] + dp[1][-1][0] - 1) % MOD)

Measured memory_bytes: 60252
def rotate(A,b,m,e):
    B=A[b:e]
    for k in range(e-b):
        A[b+((k+e-m)%(e-b))]=B[k]

    return A
    

n=int(input())
A=list(map(int,input().split()))
q=int(input())

for i in range(q):
    query=list(map(int,input().split()))
    A=rotate(A,query[0],query[1],query[2])

print(' '.join(map(str,A)))



Measured memory_bytes: 5632
import java.util.*;
class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int n = stdIn.nextInt();
    int k = stdIn.nextInt();
    String s = stdIn.next();
    String s1 = s.substring(0,k-1);
    String s2 = s.substring(k-1,k).toLowerCase();
    String s3 = s.substring(k,n);
    String s4 = s1+s2+s3;
    System.out.println(s4);
  }

}

Measured memory_bytes: 21588
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt(); //red
		int b = scan.nextInt(); //green
		int c = scan.nextInt(); //blue
		int k = scan.nextInt();

		for(int i = 1; i <= k; i++) {
			if(a > b || a == b) {
				b = 2 * b;
				k = k - 1;
			}

		}



	 if(k != 0) {
			for(int j =
					0; j < k; j++) {
				if(b > c || b == c) {
					c = 2 * c;
				}
			}
		}
		if(a < b && b < c) {
			System.out.println("Yes");

		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 35572