akhauriyash/Code-Regression huggingface dataset:
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N, M = MAP()
S = input()
T = input()
L = N*M//gcd(N, M)
g = gcd(N, M)
for i in range(g):
	if S[N//g*i] != T[M//g*i]:
		print(-1)
		break
else:
	print(L)


Measured memory_bytes: 5464
#include <iostream>

using namespace std;

int main() {

	int n, k[10001];
	int i, j, l;
	int cnt = 0;

	while (true) {
	
		cin >> n;

		if (n == 0) return 0;

		for (i = 0; i < n; i++) {

			cin >> k[i];

			if (k[i] == 0) cnt++;

		}

		if (n == 1) {

			i = -9999;
			if (k[0] <= 1) {
				cout << "NA" << endl;
			}
		}



		else {

			for (i = 0; i < n; i++) {

				if (k[i] >= 2) { break; }

			}

		}

		if (i >= (n - 1)) { cout << "NA" << endl;}
		else cout << n - cnt + 1 << endl;

		cnt = 0;

	}
	return 0;
}


Measured memory_bytes: 3148
def sol(n):
    d = {}
    N = 100000
    for i in xrange(-N, N+1):
        d[i**5]=i
    for i in d:
        j = n+i
        if j in d:
            print d[j], d[i]
            return

def main():
    n = input()
    sol(n)
if __name__ == '__main__':
    main()

Measured memory_bytes: 135980
#include <bits/stdc++.h>
#include <math.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

int main(){
    string s; cin >> s;
    int K; cin >> K;
    int n = s.size();
    set<string> ans;

    rep(i,n){
        string t;
        rep(j,K){
            if (i+j < n){
                t += s[i+j];
                ans.insert(t);
            }
        }
    }

    //sort(ans.begin(), ans.end());
    
    for(auto a : ans){
        if (--K == 0) {
            cout << a << endl;
            break;
        }
    }

   // cout << ans[K-1] << endl;
    

}


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

int main()
{
  int A,B,K;
  int res=0;
  cin >> A >>B>>K;

  if(A+2*K-1>B) {
    for(int i=A;i<=B;i++){
      cout << i << endl;;
    }
  }
  else {
    rep(i,K){
      cout << A+i<<endl;
    }
    rep(i,K){
      cout << B-(K-i)+1 <<endl;;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
bool judge(int m, int n)
{
	return m>n;
}
int main()
{
	int num[3];
	int m,n;
	cin>>num[0]>>num[1]>>num[2];
	sort(num,num+3,judge);
	m=num[0]-num[1];
	n=num[1]-num[2];
	if(n%2==0)
	{
		cout<<m+n/2;
	}
	else
	{
		cout<<m+(n+1)/2+1;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    Graph G(n);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        --a, --b;
        G[a].push_back(b);
    }
    int sv, tv;
    cin >> sv >> tv;
    --sv, --tv;
    vector<vector<int>> dist(n, vector<int>(3, INF));
    queue<pair<int, int>> que;
    que.push(make_pair(sv, 0));
    dist[sv][0] = 0;
    while(!que.empty()) {
        int v = que.front().first;
        int l = que.front().second;
        que.pop();
        for (auto nv : G[v]) {
            int nl = (l + 1) % 3;
            if (dist[nv][nl] != INF) continue;
            dist[nv][nl] = dist[v][l] + 1;
            que.push(make_pair(nv, nl));
        }
    }
    int ans = dist[tv][0];
    if (ans == INF) ans = -1;
    else ans /= 3;
    cout << ans << endl;
    return 0;
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

typedef struct data
{
	data* child[26];
	int f[26] = {};
	int fin = 0;
}trie;

trie* head;

void insert(string x)
{
    int freq[26] = {};
    for(char c:x)freq[c-'a']++;
	trie* cur = head;
	for(int i=0;i<x.length();i++)
	{
		int b = x[i] - 'a';
		if(!cur->child[b])cur->child[b] = new trie();
		cur = cur->child[b];
		for(int j=0;j<26;j++)cur->f[j] += (freq[j]>0);
		freq[b]--;
	}
	cur->fin++;
}

void dfs(trie* c)
{
    for(int i=0;i<26;i++)if(c->child[i])
    {
        dfs(c->child[i]);
        for(int j=0;j<26;j++)
            c->fin += c->child[i]->fin;
    }
}

int check(string x)
{
    int m = x.length();
    trie* cur = head;
	for(int i=0;i<m-1;i++)
    {
        cur = cur->child[x[i]-'a'];
    }
	int lastc = x[m-1]-'a';
	int ans = (cur->child[lastc]->f[lastc]) - 1;
	for(int i=0;i<26;i++)if(i != lastc && cur->child[i])
        ans += cur->child[i]->f[lastc];
	return ans;
}

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        head = new trie();
        int n;
        cin>>n;
        string s[n];
        for(int i=0;i<n;i++)cin>>s[i],reverse(all(s[i])),insert(s[i]);
        dfs(head);
        int ans = 0;
        for(int i=0;i<n;i++)ans += check(s[i]);
        cout<<ans<<endl;
    }
    return 0;
}
/*
5
abc
abbc
aabc
abac
dabc
*/


Measured memory_bytes: 452312
#include <stdio.h>
 
int main(void){
    int a,b;
    int sum=0,sum2=0;
    int cnt=0;
    while(scanf("%d,%d",&a,&b)!=EOF){
        sum+=a*b;
        sum2+=b;
        cnt++;
    }
    printf("%d\n%d\n",sum,(sum2+(cnt/2))/cnt);
    return 0;
}

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

int main() {
  int a, b, c, d, l ,r;
  cin >> a >>  b >> c >> d;
  l = a+b;
  r = c+d;
  if (l>r) {
    cout << "Left" << endl;
  }
  else if (l == r) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
  
}


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

using namespace std;
//using namespace __gnu_pbds;

#define LL       long long
#define DS       pair<int, int>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

DS a[N];
vector<int> yo[N];

int main() {
    //ios::sync_with_stdio(false);
    //cin.tie(0);
    int n, m;
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        scanf("%d %d", &a[i].first, &a[i].second);
        yo[a[i].first].push_back(a[i].second);
    }
    for (int i = 1; i <= n; i++) {
        sort(yo[i].begin(), yo[i].end());
    }
    for (int i = 0; i < m; i++) {
        int f = a[i].first, s;
        int L = 0, R = yo[a[i].first].size() - 1;
        while (L <= R) {
            int mid = L + R >> 1;
            if (yo[a[i].first][mid] == a[i].second) {
                s = mid + 1;
                break;
            } else if (yo[a[i].first][mid] > a[i].second) {
                R = mid - 1;
            } else {
                L = mid + 1;
            }
        }
        string x = to_string(f);
        string y = to_string(s);
        while (x.size() < 6) x = "0" + x;
        while (y.size() < 6) y = "0" + y;
        cout << x << y << '\n';
    }
    return 0;
}


Measured memory_bytes: 12800
#include <iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
long long  s[5]= {0};
int main()
{

    long long  n;
    long long  m;
    int i,j,k;
    long long  t=0;
    scanf("%lld",&n);
    for(i=0; i<5; i++)
    {
        scanf("%lld",&s[i]);
    }
    t=s[0];
   for(i=0;i<5;i++)
   {
       if(t>s[i])
       {
           t=s[i];
           j=i;
       }
   }
    if(n%t==0)
        m=n/t;
    else
        m=n/t+1;
    printf("%lld",5+m-1);
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
    public static void main (String args[]) {
	Scanner scan = new Scanner(System.in);
	scan.useDelimiter(",|\n");
	int n = scan.nextInt();
	int m = scan.nextInt();
	int[] seq = new int[n];

	for (int i=0; i<n; i++) {
	    seq[i] = i+1;
	}

        for (int i=0; i<m; i++) {
	    int a = scan.nextInt() - 1;
	    int b = scan.nextInt() - 1;
	    
	    int tmp = seq[a];
	    seq[a] = seq[b];
	    seq[b] = tmp;
	}

	for (int data: seq) {
	    System.out.println(data);
	}
    }
}

Measured memory_bytes: 26212
#include<iostream>
#include<numeric>
#include<vector>
using namespace std;
using ll = long long;

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(ll i=0;i<n;i++) cin>>a[i];
    ll sum=accumulate(a.begin(),a.end(),0LL);

    ll ans=sum,t=0;
    for(int i=0;i<n;i++){
        t+=a[i];
        ans=min(ans,abs(t-(sum-t)));
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
import copy
n = int(input())
a = list(map(str, input().split()))
a_buble = copy.copy(a)
for i in range(n):
  for j in range(n-1,i,-1):
    if int(a_buble[j][1]) < int(a_buble[j-1][1]):
      temp = a_buble[j]
      a_buble[j] =a_buble[j-1]
      a_buble[j-1] = temp
      
print(" ".join(map(str,a_buble)))
print("Stable")

for i in range(0,n):
  minj = i
  for j in range(i,n):
    if int(a[j][1]) < int(a[minj][1]):
      minj = j
  temp = a[i]
  a[i] = a[minj]
  a[minj] = temp
print(" ".join(map(str,a)))
ans = "Stable"
for k in range(n):
  if a[k] != a_buble[k]:
    ans = "Not stable"
print(ans)



Measured memory_bytes: 6344
def makePascal(n):  # l[m][k] で mCk を取り出せるリストを返す
  res = [[1]]

  for m in range(1, n+1):
    l = []
    for k in range(m + 1):
      if k == 0 or k == m:
        l.append(1)
      else:
        tmp = res[m-1][k-1] + res[m-1][k]
        l.append(tmp)
    res.append(l)

  return res


comb = makePascal(50)
N, A, B = map(int, input().split())
v = list(map(int, input().split()))

v.sort(reverse = True)

ans1 = sum(v[:A]) / A
print(ans1)

if len(set(v[:A])) == 1:
  maxs = v.count(v[0])
  B = min(B, maxs)
  ans = 0
  for i in (range(A, B+1)):
    ans += comb[maxs][i]
  print(ans)
else:
  mini = min(v[:A])
  minis = v[:A].count(mini)
  ans = comb[v.count(mini)][minis]
  print(ans)


Measured memory_bytes: 3064
#float型を許すな
#numpyはpythonで
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n,k=MI()
lis=[LI() for i in range(n)]
lis.sort()
sm=[]
for i in range(n):
    sm.append(lis[i][1])
sm=list(accumulate(sm))
for i in range(n):
    if sm[i]>=k:
        print(lis[i][0])
        break
    
    
    

    


Measured memory_bytes: 34092
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int N;
  cin >> N;
  vector<int> patterns(N + 1, 0);
  for (int x = 1; x <= 100; x++)
  {
    for (int y = 1; y <= 100; y++)
    {
      for (int z = 1; z <= 100; z++)
      {
        long res = x * x + y * y + z * z + x * y + y * z + z * x;
        if (res <= N)
        {
          patterns[res]++;
        }
      }
    }
  }
  for (int i = 1; i <= N; i++)
  {
    cout << patterns[i] << endl;
  }
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pt;

bool cmp(pt p, pt q) {
  if (p.first == q.first) return p.second > q.second;
  return p.first > q.first;
}

bool cmp2(pt p, pt q) {
  if (p.second == q.second) return p.first < q.first;
  return p.second < q.second;
}

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  int n; cin>>n;
  
  vector<pt> red(n), blue(n);
  for (int i=0; i<n; i++) {
    cin>>red[i].first>>red[i].second;
  }
  for (int i=0; i<n; i++) {
    cin>>blue[i].first>>blue[i].second;
  }
  sort(red.begin(),red.end(),cmp);
  sort(blue.begin(), blue.end(),cmp2);
  
  vector<bool> used(n);
  int res = 0;
  
  for (int j=0; j<n; j++) {
    pt p = blue[j];
    for (int i=0; i<n; i++) {
      pt r = red[i];
      if (r.first < p.first && r.second < p.second && !used[i]) {
	res++;
	used[i]=true;
	break;
      }
    }
  }


  cout<<res<<endl;

  return 0;
}


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

const int N = 105;
const int W = 100005;

int n, ww, w[N], v[N];
long long dp[N][W];

int main() {
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n >> ww;
	for (int i = 1; i <= n; i++) {
		cin >> w[i] >> v[i];
	}
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j <= ww; j++) {
			dp[i][j] = dp[i - 1][j];
			int u = j - w[i];
			if (u < 0) continue;
			dp[i][j] = max(dp[i][j], dp[i - 1][u] + v[i]);
		}
	}
	cout << dp[n][ww];
	return 0;
}


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

#define int long long
#define INT int
#define MOD 1000000007

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
template <typename T>
void print(T x)
{
    std::cout << x << '\n';
}
typedef long long ll;
const long long INF = 1LL << 60;

signed main()
{

    int n,d;
    cin >> n>>d;
    vector<int>x(n),y(n);
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    d = d*d;

    int ans=0;
    rep(i,n){
        int temp = x[i]*x[i]+y[i]*y[i];
        if(d>=temp){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 6424
#include<bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <complex>
#include <cstdio>
#include <cmath>
#include <utility>
#include <vector>
using namespace std;
using W = double;
using P = complex<W>;
using L = pair<P,P>;
using C = pair<P,W>;
using Poly = vector<P>;
#define X real()
#define Y imag()
const W EPS = (1e-10), pi = acos(-1);
double dot(P a, P b){ return a.X * b.X + a.Y * b.Y;}
W cross(P a, P b){ return a.X * b.Y - a.Y * b.X;}
W ps_dist(P a, L s){
  P sf = s.first, ss = s.second;
  if(dot(ss-sf,a-sf) >= 0 && dot(sf-ss,a-ss) >= 0)
    return abs(cross(sf-ss,a-ss))/abs(sf-ss);
  return min(abs(a-sf), abs(a-ss));
} 

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin >> n >> m;
    P ori;
    double x,y;
    cin >> x >> y;
    ori = P(x,y);
    vector<P> p;
    for(int i=0; i<n; i++){
        cin >> x >> y;
        p.emplace_back(x,y);
        // cout << p[i] << endl;
    }
    vector<pair<double,int>> dist(n);
    pair<W,int> mn = make_pair(100000000,100000000);
    for(int i=0; i<n; i++){
        dist[i].first = abs(ori-p[i]);
        dist[i].second = i;
        // cout << ori << endl;
        // cout << p[i] << endl;
        // cout << dist[i].first << endl;
        mn = min(mn,dist[i]);
    }
    vector<bool> used(n,false);
    double ans = 0;
    used[mn.second] = true;
    ans += mn.first;
    for(int i=0; i<n; i++){
        if(used[i]) continue;
        dist[i].first = min(dist[i].first,abs(p[i]-p[mn.second]));
        // 線分
        L sen = make_pair(ori,p[mn.second]);
        dist[i].first = min(dist[i].first,ps_dist(p[i],sen));
    }
    for(int i=0; i<m-1; i++){
        mn = make_pair(1000000000,10000000);
        for(int j=0; j<n; j++){
            if(used[j]) continue;
            mn = min(mn,dist[j]);            
        }
        int id = mn.second;
        pair<double,int> kyo = make_pair(abs(ori-p[id]),-1);        
        for(int j=0; j<n; j++){
            if(used[j]){
                kyo = min(kyo,pair<double,int>(abs(p[j]-p[id]),j));
            }
        }
        used[id] = true;
        ans += kyo.first;
        for(int j=0; j<n; j++){
            if(used[j]) continue;
            dist[j].first = min(dist[j].first,abs(p[j]-p[id]));
            L sen;
            if(kyo.second == -1){
                sen = make_pair(ori,p[id]);
            }else{
                sen = make_pair(p[kyo.second],p[id]); 
            }
            dist[j].first = min(dist[j].first,ps_dist(p[j],sen));
        }
    }
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}


Measured memory_bytes: 3480
n=int(input())
if(len(str(n))==6):
    ans= 9 + 900 + 90000
elif(len(str(n))==5):
    ans= 9 + 900 + n - 9999
elif(len(str(n))==4):
    ans= 9 + 900
elif(len(str(n))==3):
    ans= 9 + n - 99
elif(len(str(n))==2):
    ans=9
elif(len(str(n))==1):
    ans=n
    
print(ans)


Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <array>
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <bitset>
#include <utility>
#include <assert.h>
#include <regex>
#include <numeric>
#include <functional>
using namespace std;

typedef unsigned long long ull;
typedef signed long long ll;
#define INF (1LL << 48)

struct PT { ll x; ll y; };
string to_s(ull x) { return to_string(x); }
string to_s(ll x) { return to_string(x); }
ll to_ll(const string& x) { return stoll(x); }
ull to_ull(const string& x) { return stoull(x); }




int main(int argc, char* argv[])
{
	for (;;) {
		int N, M;

		cin >> N >> M;
		if (cin.fail()) break;

		ll res = M * 1900 + (N - M) * 100;
		cout << res * (1LL << M) << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */


const int inf = 1e9;
vector<int> b[15];


signed main(){
   IOS;
   int n,m,x; cin >> n >> m >> x;  
   vector<int> c(n);
   rep(i,0,n){
      cin >> c[i];
      rep(j,0,m){
         int x;
         cin >> x;
         b[i].pb(x);
      }
   }
   int ans = inf;
   rep(at,0,1<<n){
      int res = 0;
      vector<int> s(m);
      rep(i,0,n){
         if(1<<i & at){
            res+=c[i];
            rep(j,0,m){
               s[j]+=b[i][j];
            }
         }
      }
      int ok = 1;
      rep(i,0,m){
         if(s[i] < x){
            ok = 0;
            break;
         }
      }
      if(ok) ans=min(ans,res);
   }
   if(ans == inf) cout << "-1\n";
   else cout << ans << '\n';
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
#define  inf 2e18
#define  mod 1000000007
#define  bg begin()
#define  en end()
#define  ll long long int
#define  pb push_back
#define  mp make_pair
#define  vi vector<int>
#define  vll vector<long long int>
#define  vpll vector<pair<long long int,long long int> >
#define  vpii vector<pair<int,int> >
#define  vstr vector<string>
#define  mpii map<int ,int>
#define  mpll map<long long int,long long int >
#define  max3(a,b,c) max(a,max(b,c))
#define  min3(a,b,c) min(a,min(b,c))
#define  w(t) ll t; cin>>t; while(t--)
#define  vin(v,n) for(int i=0;i<n;i++){ll x;cin>>x; v.pb(x);}
#define  for0(i,n) for(int i=0;i<n;i++)
#define  for1(i,n) for(int i=1;i<=n;i++)
#define  forv(it,v) for(auto it=v.begin();it!=v.end();it++)
#define  mem(a,val) memset(a,val,sizeof(a))
#define  Sort(vec) sort(vec.begin(),vec.end())
#define  RSort(vec) sort(vec.rbegin(),vec.rend())
#define  eb emplace_back
#define  bs binary_search
#define  lb(v,a) lower_bound(v.begin(),v.end(),a)
#define  ub(v,a) upper_bound(v.begin(),v.end(),a)
#define  deb1(x) cerr<<#x<<": "<<x<<" "<<endl
#define  deb2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define  deb3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define  deb4(a, b, c, d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define  FIFO ios::sync_with_stdio(false); cin.tie(0);cout.tie(0)
#define  yes "YES"
#define  no "NO"
#define  PI 3.141592653589793238462643383279502884L
ll Ceil(ll a, ll b) {return a / b + (a % b != 0);}
ll fastModExp(ll a, ll b) { ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
ll Logn(ll n, ll r)
{
    return (n > r - 1) ? 1 + Logn(n / r, r) : 0;
}
// 2- Dimensional vector:- vector<vector<int> > v(n, vector<int> (26, 0));

mpll mpx, mpx2;
int main()
{
    FIFO;
    ll x, y;
    cin >> x >> y;
    ll t = (y - 2 * x);
    if (t & 1 || t < 0)
        cout << "No" << endl;
    else {
        ll r = t / 2;
        ll c = x - r;
        if (c < 0)
            cout << "No" << endl;
        else cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>
#define MAX 25
struct Node{
  int parent;
  int right;
  int left;
  int degree;
};
int n;
struct Node u[MAX];
int s(int);
int d(int);
int h(int);

int s(int x){
  if(u[x].right!=-1) return u[x].right;
  else if(u[u[x].parent].left!=x) return u[u[x].parent].left;
  else return -1;
}
 
int d(int x){
  int d=0,p;
  p=u[x].parent;
 
  while(p!=-1){
    p=u[p].parent;
    d++;
  }
 
  return d;
}
int h(int x) {
  int i,a=0,y;
  
  for(i=0;i<n;i++) {
    if(u[i].parent==x) {
      y=h(i)+1;
      if(y>a) a=y;
    }
  }
  return a;
}

int main(){
  int i,id,r,l;
 
  scanf("%d",&n);
 
  for(i=0;i<n;i++){
    u[i].parent=-1;
    u[i].right=-1;
    u[i].left=-1;
    u[i].degree=0;
  }
 
  for(i=0;i<n;i++){
    scanf("%d%d%d",&id,&l,&r);
    u[id].left=l;
    u[u[id].left].right=r;
    if(u[id].left!=-1){
      u[u[id].left].parent=id;
      u[id].degree++;
    }
    if(u[u[id].left].right!=-1){
      u[u[u[id].left].right].parent=id;
      u[id].degree++;
    }
  }
 
  for(i=0;i<n;i++){
    if(u[i].parent==-1)
      printf("node %d: parent = -1, sibling = -1, degree = %d, depth = 0, height = %d, root\n",i,u[i].degree,h(i));
 
    else if(u[i].degree==0)
      printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, leaf\n",i,u[i].parent,s(i),u[i].degree,d(i),h(i));
 
    else printf("node %d: parent = %d, sibling = %d, degree = %d, depth = %d, height = %d, internal node\n",i,u[i].parent,s(i),u[i].degree,d(i),h(i));
  }
 
  return 0;
}
 

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

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i=0;i<s.length();i++){
        for(int j=0;j<n;j++){
            s[i]+=1;
            if(s[i] == 91){
                s[i] = 65;
            }
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define fo(i,s,e) for (int i=(s); i < (e); i++)
#define all(obj) (obj).begin(), (obj).end()
/*卍卍卍 #define int long long 卍卍卍*/
signed main () {
  int n,m;cin >> n >> m;
  int L=0;int R=INT_MAX;
  rep(i,m){
    int l,r;cin>>l>>r;
    L=max(L,l);R=min(R,r);
  }
  cout << max(0,R-L+1) << endl;
}

Measured memory_bytes: 3624
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

int main() {
	int sum = 0;
	for (int i = 0; i < 5; i++) {
		int t;
		cin >> t;
		sum += t;
	}
	cout << 15 - sum << endl;
	return 0;
}


Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
#include <cstring>
#include <climits>
#include <cstdlib>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cmath>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>

#define fi first
#define se second
#define U unsigned
#define P std::pair
#define LL long long
#define pb push_back
#define MP std::make_pair
#define all(x) x.begin(),x.end()
#define CLR(i,a) memset(i,a,sizeof(i))
#define FOR(i,a,b) for(int i = a;i <= b;++i)
#define ROF(i,a,b) for(int i = a;i >= b;--i)
#define DEBUG(x) std::cerr << #x << '=' << x << std::endl

const int MAXN = 1e5 + 5;

struct Edge{
	int to,w,nxt;
}e[MAXN<<1];
int du[MAXN],cnt,head[MAXN];

inline void add(int u,int v,int w){
	e[++cnt] = (Edge){v,w,head[u]};head[u] = cnt;
	e[++cnt] = (Edge){u,w,head[v]};head[v] = cnt;
	du[u]++;du[v]++;
}

int n,m;
bool vis[MAXN],used[MAXN<<1];
bool flag = false;
std::vector<int> tt;

inline void dfs(int v){
	vis[v] = 1;
	// DEBUG(v);
	if(flag) return;
	for(int i = head[v];i;i = e[i].nxt){
		if(used[e[i].w]) continue;
		used[e[i].w] = 1;
		if(e[i].to == tt[0]){
			flag = true;
			break;
		}
		if(!vis[e[i].to]) dfs(e[i].to);
	}
	if(flag) return;
}

inline bool pd(){
	FOR(i,1,n) if(du[i] == 4) tt.pb(i);
	vis[tt[1]] = true;
	dfs(tt[0]);
	return flag;
}

int main(){
	scanf("%d%d",&n,&m);
	FOR(i,1,m){
		int u,v;scanf("%d%d",&u,&v);
		add(u,v,i);
	}
	int mx = 0,cntt = 0;
	FOR(i,1,n){
		if(du[i]&1){
			puts("No");
			return 0;
		}
		mx = std::max(mx,du[i]);
		if(du[i] == 4) cntt++;
	}
	if(mx >= 6){
		puts("Yes");
		return 0;
	}
	if(mx == 4 && cntt >= 3){
		puts("Yes");
		return 0;
	}
	if(mx == 4 && cntt == 2){
		puts(pd() ? "Yes" : "No");
		return 0;
	}
	puts("No");
	return 0;
}

Measured memory_bytes: 3840
n = int(input())

if n % 2 == 0:
    pairs = [(i, n+1-i) for i in range(1, n//2+1)]
    x = len(pairs)
    if n == 4:
        print(4 * (x - 1))
        for i in range(2):
            for j in range(2):
                print(pairs[0][i], pairs[1][j])
    else:
        print(4 * x)
        for k in range(n//2):
            for i in range(2):
                for j in range(2):
                    print(pairs[k%x][i], pairs[(k+1)%x][j])

else:
    pairs = [(i, n-i) for i in range(1, n//2+1)]
    x = len(pairs)
    if n == 3:
        print(2)
        print(1, 3)
        print(2, 3)
    else:
        print(4 * x)
        for k in range(n//2-1):
            for i in range(2):
                for j in range(2):
                    print(pairs[k % x][i], pairs[(k+ 1) % x][j])
        print(n, pairs[0][0])
        print(n, pairs[0][1])
        print(n, pairs[-1][0])
        print(n, pairs[-1][1])

Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.S;
		Console.WriteLine("{0}",s=="AAA"||s=="BBB"?"No":"Yes");
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 13140
#include <iostream>
#include <complex>
#include <vector>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <map>
#include <cstring>

using namespace std;

int a[100010];
int b[100010];

pair<int,int> l[100010],r[100010];


int main(){
    int N;
    cin >> N;
    for(int i = 0 ; i < N ; i++){
        cin >> a[i];
        if(i){
            if( a[i] < a[i-1]){
                cout << 0 << endl;
                return 0;
            }
        }
    }

    for(int i = 0 ; i < N ; i++){
        cin >> b[i];
        //cout << b[i] << " " << N << i << endl;
        if( i and b[i-1] < b[i]){
                cout << 0 << endl;
                return 0;
            
        }
    }
    //cout << N << endl;
    for(int i = 0 ; i < N ; i++){
        if( !i or a[i] != a[i-1]){
            l[i] = {a[i],a[i]};
        }else{
            l[i] = {1,l[i-1].second};
        }
    }
    for(int i = N-1 ; i >= 0 ; i--){
        if( i == N-1 or b[i] != b[i+1]){
            r[i] = {b[i],b[i]};
        }else{
            r[i] = {1,r[i+1].second};
        }
    }
    long long ans = 1;
    for(int i = 0 ; i < N ; i++){
        //cout << r[i].first << " " << r[i].second << endl;
        long long A = max(l[i].first,r[i].first);
        long long B = min(r[i].second,l[i].second);
        if( A > B ) ans = 0;
        //cout << A << " " << B << endl;
        ans *= B - A + 1;
        ans %= 1000000007;
    }
    cout << ans << endl;


}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() 
{
    int n;
    cin>>n;
    vector<ll> a(n);
    for (int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    ll ans=0;
    ll mod=1e9+7;
    for(int i=0;i<=60;i++)
    {
        int tmp=0;
        for (int j=0;j<n;j++)
        {
            if((a[j]>>i)&1) tmp++;
        }
        ans=(ans+(1ll<<i)%mod*tmp%mod*(n-tmp))%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int a, b, c, k;
  cin >> a >> b >> c >> k;
  long long int ans;
  if(k<=a) ans = k;
  else if(k<=a+b) ans = a;
  else ans = 2*a+b-k;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
typedef long long l;

int n,k;
l T[100000];

int check(l P){
	int i=0;
	int j;
	for(j=0;j<k;j++){
		l s=0;
		while(s+T[i]<=P){
			s+=T[i];
			i++;
			if(i==n){return n;}
		}
	}
	return i;
}

int solve(){
	l left=0;
	l right=100000*10000;
	l mid;
	int v;
	
	while(right - left > 1){
		mid=(left+right)/2;
		v=check(mid);
		if(v>=n){right=mid;}
		else{left=mid;}
	}
	return right;
}

int main(void){
	int i;
	l ans;
	scanf("%d",&n);
	scanf("%d",&k);
	
	for(i=0; i<n; i++){
		scanf("%d",&T[i]);
	}
	
	ans=solve();
	printf("%d\n",ans);
	
	return 0;
}


Measured memory_bytes: 2528
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <set>
#include <stack>
#include <map>
#include <unordered_map>
#include <cmath>
#include <utility> // pair make_pair
#include <algorithm>
#include <functional>
#include <iomanip>
#include <climits> // LLONG_MAX, LLONG_MIN, INT_MIN, INT_MAX
#include <assert.h>

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define ll long long
//#define int ll
#define INF INT_MAX/10
#define MOD 1000000007

using namespace std;
using Pi = pair<int, int>;
using Graph = vector<vector<int> >;
using WeightGraph = vector<vector<Pi> >;

int Input[100100];

int main() {
  int A, B; cin >> A >> B;
  if (A != B) {
    if (A < B) swap(A, B);
    cout << 2 * A - 1 << endl;
  } else {
    cout << 2 * A << endl;
  }
}


Measured memory_bytes: 256
while True:
    try:
        A=list(map(int,input().split()))
        B=list(map(int,input().split()))
    except:
        break

    h=0
    for i in range(4):
        if A[i]==B[i]:
            h+=1
    b=0
    for i in A:
        if i in B:
            b+=1
    b-=h
    print(h,b)


Measured memory_bytes: 5592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
#define IN(a, x, b) (a<=x && x<b)
template<class T>inline bool CHMAX(T&a,T b){if(a<b){a = b;return true;}return false;}
template<class T>inline bool CHMIN(T&a,T b){if(a>b){a = b;return true;}return false;}
constexpr long long INF = 1e18;


signed main(){
	int N;
	cin>>N;
	vector<int>a(N);
	vector<vector<pair<int,int>>>v(N);
	REP(i,N){
		cin>>a[i];
		REP(j,a[i]){
			int x,y;
			cin>>x>>y;
			x--;
			v[i].push_back({x,y});
		}
	}
	int ans = 0;
	REP(i,1ll<<N){
		int flg = 1;
		REP(j,N){
			if((i&(1ll<<j))==0)continue;
			for(auto e:v[j]){
				if((i&(1ll<<e.first))){
					if(e.second==0)flg=0;
				}else{
					if(e.second)flg=0;
				}
			}
		}
		int cnt = 0;
		REP(j,N)if((i&(1ll<<j)))cnt++;
		if(flg)CHMAX(ans,cnt);
	}
	cout<<ans<<endl;
}

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

int main()
{
  int a,b;
  cin>>a>>b;
  if(a<=9&&b<=9)cout<<a*b<<endl;
  else cout<<-1<<endl;
  return 0;
}


Measured memory_bytes: 256
def partition(A, p, r):
   x = A[r][1]
   i = p-1
   for j in range(p,r):
      if A[j][1] <= x:
         i = i+1
         A[i], A[j] = A[j], A[i]
   A[i+1], A[r] = A[r], A[i+1]
   return i+1

def quickSort(A, p, r):
   if p < r:
      q = partition(A, p, r)
      quickSort(A, p, q-1)
      quickSort(A, q+1, r)

def check(A, s, e):
   for i in range(s,e-1):
      if A[i][1] == A[i+1][1]:
         if A[i][2] > A[i+1][2]:
            return "Not stable"
   return "Stable"

r = int(input())
a = []
for i in range(r):
   c = input().split()
   a.append((c[0],int(c[1]),i))
quickSort(a, 0, r-1)
print(check(a,0,r))
for s,r,d in a:
   print("{} {}".format(s,r))

Measured memory_bytes: 22292
#include <iostream>
#include <math.h>

using namespace std;

typedef long long ll;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define FOR(i, n, m) for (ll i = (n); i < (m); ++i)

const int MOD = 1e9+7;
const int MAX = 1e5+10;

ll fac[MAX];  /// fac[n] = n!
ll finv[MAX]; /// (fac[n] * finv[n]) % MOD = 1
ll inv[MAX];  /// (n * inv[n]) % MOD = 1

void init() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  FOR (i, 2, MAX) {
    fac[i] = fac[i-1]*i % MOD;
    inv[i] = MOD - inv[MOD%i]*(MOD/i) % MOD;
    finv[i] = finv[i-1]*inv[i] % MOD;
  }
}

ll nCk (int n, int k) {
  if (n < k || k < 0 || n < 0) return 0;
  return fac[n]*finv[k]%MOD*finv[n-k]%MOD;
}

int A[MAX];
int N;

int main() {

  init();

  cin >> N;
  ll p = 0;
  REP (i, N+1) {
    cin >> A[i];
    p += A[i]-i;
  }

  int p1 = -1, p2 = -1;
  REP (i, N+1) {
    if (A[i] == p) {
      if (p1 == -1) p1 = i;
      else p2 = i;
    }
  }

  REP (k, N+1) {
    cout << (MOD + nCk(N+1, k+1) - nCk(N-p2+p1, k))%MOD << endl;
  }
}

Measured memory_bytes: 3968
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define MOD 1000000007
#define INF 1e9
#define All(x) (x).begin(), (x).end()
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {
  int N;
  cin>>N;
  vector<ll> A(N);
  REP(i,N)cin>>A[i];
  ll GCD=A[0];
  for(int i=1;i<N;i++){
    GCD=gcd(GCD,A[i]);
  }

  ll ans=0;
  while(1){
    if(GCD%2==0){
      GCD/=2;
      ans++;
    }else{
      break;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String... args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();

		if (Math.abs(c-a) <= d || (Math.abs(b-a) <= d && Math.abs(c-b) <= d)) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
char a[100][100];
int main()
{
	int m,n;
	cin>>m>>n;
	memset(a,48,sizeof(a));
	for(int i=1;i<=m;++i)
	  for(int j=1;j<=n;++j)
	  {
	  	char t;
	  	cin>>t;
	  	if(t=='#')a[i][j]='#';
	  }
	for(int i=1;i<=m;++i)
	  for(int j=1;j<=n;++j)
	  {
	  	if(a[i][j]==48)
	  	{
	  		for(int k=i-1;k<=i+1;++k)
	  		  for(int l=j-1;l<=j+1;++l)
	  		  if(a[k][l]=='#')a[i][j]++;
		}
	  }
	for(int i=1;i<=m;++i)
	{
	 	for(int j=1;j<=n;++j)
	    cout<<a[i][j];
	    cout<<endl;
	} 
}

Measured memory_bytes: 256
N=int(input())

M=0
A=0
R=0
C=0
H=0
for i in range(N):
    name=input()
    if name[0]=="M":
        M+=1
    elif name[0]=="A":
        A+=1
    elif name[0]=="R":
        R+=1
    elif name[0]=="C":
        C+=1
    elif name[0]=="H":
        H+=1

count=0
list1=[M,A,R,C,H]
#print(list1)
for j in range(3):
    
    for k in range(j+1,4):
        
            for l in range(k+1,5):
                #print(list1[j]*list1[k]*list1[l])
                count=count+list1[j]*list1[k]*list1[l]
print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
    vector<int> num(3);
    cin >> num.at(0) >> num.at(1) >> num.at(2);
	int c5 = 0;
    int c7 = 0;
	for(int i=0; i<3; i++){
    	if(num.at(i) == 5){
        	c5++;
        }else if(num.at(i) == 7){
        	c7++;
        }
    }
	if(c5 == 2 && c7 == 1){
    	cout << "YES" << endl;
    }else{
    	cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
n = gets.chomp.to_i
c = []
j = 0
arr = gets.chomp.split(' ').map(&:to_i)
m = arr.shift
arr.each do |i|
  if m >= i
    m = i
    j += 1
  else
    c << j
    m = i
    j = 0
  end
end
c << j
print(c.max)



Measured memory_bytes: 9860
#include <stdio.h>

int main(void)
{
	int n;
	scanf("%d",&n);
	char s[n];
	scanf("%s",s);
	int x=0,i=0,max=0;
	for(i;i<=n-1;i++)
		{
		if(s[i]=='I')
			{x++;
			if(x>max){max=x;}
			}
		else
			{x--;}
		}
	printf("%d\n",max);
	return 0;
}


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

int main()
{
	string s,p;
	cin >> s;
	cin >> p;
	while (s.size() <= 100)
	{
		s += s;
	}
	if (s.find(p) != string::npos)
	{
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
}


Measured memory_bytes: 3220
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>
#include <numeric>
#include <cstring>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;
const int INF = numeric_limits<int>::max();
const ll INFL = numeric_limits<ll>::max();


// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

//greatest common divisor
long long gcd(ll a, ll b) 
{
    if (a % b == 0) {
        return b;
    } else {
        return gcd(b, a % b);
    }
}

//least common multiple
long long lcm(ll a, ll b)
{
    return a / gcd(a, b) * b ;
}

ll factorial(ll n) {
    ll res = 1;
    for (ll i = 1; i <= n; i++) {
        res *= i;
    }
    return res;
}

int main()
{
    int n, m; cin >> n >> m;
    set<int> s, g;
    rep(i,m) {
        int a, b; cin >> a >> b;
        a--;b--;
        if (a == 0)
            s.insert(b);
        if (b == n-1)
            g.insert(a);
    }
    for (auto ss : s) {
        auto it = g.find(ss);
        if (it != g.end()) {
            cout << "POSSIBLE" << endl;
            return 0;
        }
    }
    cout << "IMPOSSIBLE" << endl;
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    vector<int> dp(n);
    dp[0] = 0; dp[1] = abs(a[0] - a[1]);
    for(int i = 2; i < n; i++) {
        dp[i] = min(dp[i-1] + abs(a[i-1] - a[i]), dp[i-2] + abs(a[i-2] - a[i]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using  namespace std;
#define ll    long long int
#define pai     pair<int,int>
#define vi      vector<int>
#define vd      vector<double>
#define mpi     map<int,int>
#define mps     map<string,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define MAX      10000010
bool prime[MAX];
void seive(){
memset(prime,true,sizeof(prime));
prime[0]=prime[1]=false;
for(int p=2;p*p<=MAX;p++){
       if(prime[p]){
    for(int i=p*p;i<=MAX;i+=p){
       prime[i]=false;
    }
}

}
}
int main(){
seive();
ll n;
int c=0;
while(cin>>n){
 for(int i=2;i<=n;i++){
   if(prime[i]){
    c++;
   }
 }
 cout<<c<<endl;
 c=0;
}

}






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

int main(){
    long long n;
    cin >> n;
    long long x;
    for(long long i = 1; i <= sqrt(n); i++){
        if(n % i == 0) x = i;
    }
    //cout << x << endl;
    cout << x + n/x -2 << endl;
    return 0;
}

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

int n, h[100004];

int main() {
	cin>>n;
	for(int i = 0;i<n;i++)	cin>>h[i];
	for(int i = n-2;i>=0;i--){
		if(h[i] <= h[i+1])	continue;
		h[i]--;
		if(h[i] > h[i+1]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 640
n=int(input())
s=str(input())
l=list(s)
t=len(s)

for i in range(t):
    if ord(l[i])+n<65+26:
        l[i]=chr(ord(l[i])+n)
    else:
        l[i]=chr(ord(l[i])+n-26)
ans="".join(l)
print(ans)

Measured memory_bytes: 3064
N,Q=map(int,input().split())
S=input()
lst=[0]*(N-1)
x=0
for i in range(len(S)-1):
  if S[i:i+2]=='AC':
    x+=1
  lst[i]=x
lst=[0]+lst
lst2=[]
for i in range(Q):
  l,r=map(int,input().split())
  lst2.append(lst[r-1]-lst[l-1])
for i in lst2:
  print(i)

Measured memory_bytes: 10804
import copy
N = int(input())
A = list(input().split())
C = []
C = copy.deepcopy(A)

for i in range(N):
    for j in range(N-1,i,-1):
        if int(C[j][1:]) < int(C[j-1][1:]):
                temp = C[j]
                C[j] = C[j-1]
                C[j-1] = temp

for i in range(N-1):
    minj = i
    for j in range(i+1,N):
        if int(A[j][1:]) < int(A[minj][1:]):
            minj = j
    temp = A[i]
    A[i] = A[minj]
    A[minj] = temp


print(*C)
print("Stable")
print(*A)
if A == C:
    print("Stable")
else:
    print("Not stable")


Measured memory_bytes: 6344
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>
#include<set>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
typedef pair<ll,ll> pll;
int dx[4] = {1,0,0,-1};
int dy[4] = {0,1,-1,0};
#define MOD 1000000007
#define ARRAY_MAX 100005

const int INF = 1e9+7;


int main(){

    int a,b;
    cin >> a >> b;
    cout << (a+b)/2 << endl;    



    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <utility>
using namespace std;
typedef pair<int,int> pii;
#define mp make_pair
#define fst first
#define scn second

complex<int> rot;
void rotate(pii *p){
	complex<int> P(p->fst,p->scn);
	P*=rot;
	*p=mp(P.real(),P.imag());
}

pii getpair(){
	pii ret;
	cin>>ret.fst>>ret.scn;
	return ret;
}

int main(){
	int m;	cin>>m;
	while(m--){
		pii s=getpair(),t=getpair();
		rot=complex<int>(s.scn-t.scn,s.fst-t.fst);
		rotate(&s);	rotate(&t);
		if(s.scn>t.scn)	swap(s,t);
		int n;	cin>>n;
		vector<pair<double,int>> ls;
		for(int i=0;i<n;i++){
			pii p=getpair(),q=getpair();
			int o,l;	cin>>o>>l;
			if(o==0)	l^=1;
			rotate(&p);	rotate(&q);
			if(p.fst==q.fst)	continue;
			double r=(double)(s.fst-q.fst)/(p.fst-q.fst);
			if(r<0||1<r)	continue;
			double y=(p.scn-q.scn)*r+q.scn;
			if(s.scn<=y&&y<=t.scn){
				ls.push_back(mp(y,l));
			}
		}
		sort(ls.begin(),ls.end());
		int ret=0;
		for(int i=1;i<ls.size();i++){
			if(ls[i].scn!=ls[i-1].scn)	ret++;
		}
		cout<<ret<<endl;
	}
	return 0;
}

Measured memory_bytes: 3064