akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[200005];
    ll n,ans=0;
    scanf("%s",s);
    // ll [n];
    n=strlen(s);
    ll ss=0;
    rep(i,0,n){
        if(s[i]=='S'){
            ss++;
        }else{
            if(ss==0){
                ans++;
            }else{
                ss--;
            }
        }
    }
    ans+=ss;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <vector>
#include <string.h>
#include <set>

using namespace std;

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> void printvec(const vector<T>& v) {
  for (auto x : v) { cout << x << " "; }
  cout << endl;
}
template<class T> void printtree(const vector< vector<T> >& tree) {
  for (long long i = 0; i < tree.size(); ++i) {
    cout << i + 1 << ": "; printvec(tree[i]);
  }
}
template<class T, class U> void printmap(const map<T, U>& mp) {
  for (auto x : mp) { cout << x.first << "=>" << x.second << endl; }
}

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; }

#define rep(i, n) for(ll i = 0; i < n; ++i)
#define all(s) s.begin(), s.end()
#define sz(x) (ll)(x).size()
#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> triple;
typedef double D;
typedef vector<ll> vl;
typedef vector<P> vp;

const ll INF = 1e9;
const ll MOD = 1000000007;  // 1e9 + 7

// RollingHash with mod(2**64)
struct RollingHash {
  // Mod is 2**64 (max of ull + 1)
  static const ull base1 = 1000000007;
  vector<ull> _hash, _power;

  RollingHash(const string& S) { init(S); }
  void init(const string& S) {
    int n = S.size();
    _hash.resize(n+1);
    _power.assign(n+1, 1);
    rep(i, n) {
      _hash[i+1] = _hash[i] * base1 + S[i];
      _power[i+1] = _power[i] * base1;
    }
  }

  // get hash of S[l,r)
  inline ull get(int l, int r) const {
    ull res1 = _hash[r] - _hash[l] * _power[r-l];
    return res1;
  }

  // get lcp of S[a:] and T[b:]
  inline int getLCP(int a, int b) const {
    int len = min((int)_hash.size()-a, (int)_hash.size()-b);
    int low = 0, high = len;
    while (high - low > 1) {
      int mid = (low + high) >> 1;
      if (get(a, a+mid) != get(b, b+mid)) high = mid;
      else low = mid;
    }
    return low;
  }
};

// int main(int argc, char** argv) {
//   string S("abcabc");
//
//   RollingHash rh(S);
//
//   cout << (rh.get(0, 3) == rh.get(3, 6)) << endl; // abc == abc: true
//   cout << (rh.get(0, 3) == rh.get(3, 5)) << endl; // abc == ab: false
//
//   cout << rh.getLCP(0, 3) << endl; // abc, abc: 3
//   cout << rh.getLCP(1, 4) << endl; // bc, bc: 2
//   cout << rh.getLCP(0, 4) << endl; // abc, bc: 0
// }

int main(int argc, char** argv) {
  cin.tie(NULL);
  cout.tie(NULL);
  ios_base::sync_with_stdio(false);
  //cout << setprecision(10) << fixed;

  ll n;
  cin >> n;
  string S;
  cin >> S;
  RollingHash rh(S);

  ll ans = 0;
  rep(l,n) {
    for (ll r = l+1; r < n; ++r) {
      ll lcp = rh.getLCP(l,r);
      lcp = min(lcp, r-l); // NOTE: overlap is not allowed
      chmax(ans, lcp);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

int main() {
	int d;
	cin >> d;
	if (d == 25) {
		cout << "Christmas";
	} else if (d == 24) {
		cout << "Christmas Eve";
	} else if (d == 23) {
		cout << "Christmas Eve Eve";
	} else {
		cout << "Christmas Eve Eve Eve";
	}
}


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

using namespace std;
typedef unsigned int uint;
typedef long long int ll;
typedef unsigned long long int ull;

#define debugv(v) printf("L%d %s => ",__LINE__,#v);for(auto e:v){cout<<e<<" ";}cout<<endl;
#define debugm(m) printf("L%d %s is..\n",__LINE__,#m);for(auto v:m){for(auto e:v){cout<<e<<" ";}cout<<endl;}
#define debuga(m,w) printf("L%d %s is => ",__LINE__,#m);for(int x=0;x<(w);x++){cout<<(m)[x]<<" ";}cout<<endl;
#define debugaa(m,w,h) printf("L%d %s is..\n",__LINE__,#m);for(int y=0;y<(h);y++){for(int x=0;x<(w);x++){cout<<(m)[x][y]<<" ";}cout<<endl;}
#define ALL(v) (v).begin(),(v).end()
#define BIGINT 0x7FFFFFFF
#define E107 1000000007

#define TIME chrono::system_clock::now
#define MILLISEC(t) (chrono::duration_cast<chrono::milliseconds>(t).count())

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

int m,n;

int memo[100000];

int main(){
    int i,j,k,l;
    
    int counter = 0;
    
    cin>>n;
    
    for (i=1;i<=n;i++){
        scanf("%d",&k);
        if (memo[k]==i){
            counter++;
        }
        memo[i]=k;
    }
    cout << counter<<endl;
    
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  map<string,int> M;
  set<string> S;
  string s;
  for (int i = 0; i < N; i++){
    cin >> s;
    if (S.count(s)){
      M[s]++;
    } else {
      S.insert(s);
      M[s] = 1;
    }
  }
  int m = 0;
  for (auto i : S){
    m = max(m,M[i]);
  }
  vector<string> V;
  for (auto i : S){
    if (M[i] == m){
      V.push_back(i);
    }
  }
  sort(V.begin(),V.end());
  for (int i = 0; i < V.size(); i++){
    cout << V[i] << endl;
  }
}

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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
typedef long long ll;
//typedef long long int;
const ll M = 1000000007;
ll A, B, C, D, G, H, N, L, K, P, Q, R, W, X, Y, Z;
string S, T;

signed main(){
	std::cin >> K ;
	std::cin >> A>>B;
	int flag=0;
	for (ll i=A;i<=B;i++){
	    if (i%K==0) flag++;
	}
	if (flag>0) std::cout << "OK" << std::endl;
	else std::cout << "NG" << std::endl;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <algorithm>
int main() {
  std::string topping;
  std::cin >> topping;
  int total_price = 700;
  int n_topping = std::count(topping.begin(), topping.end(), 'o');
  total_price += 100 * n_topping;
  std::cout << total_price;
}


Measured memory_bytes: 256
import queue

def intMap(): return map(int,input().split())

numRoom,numPath = intMap() # numRoom = n, numPath = m
#room = [[]] * numRoom # <- これが間違いでした。
#                           これだと全てのroom[ほにゃらら]が同じオブジェクトを指す（らしい）
room = [[] for i in range(numRoom)]

for _ in range(numPath):
    a,b = intMap()
    a -= 1
    b -= 1
    room[a].append(b)
    room[b].append(a)

prevRoom = [-1] * numRoom
distance = [-1] * numRoom
q = queue.Queue()

distance[0] = 0
q.put(0)
while not q.empty():
    checkRoom = q.get()
    for connectedTo in room[checkRoom]:
        if distance[connectedTo] != -1:
            continue
        distance[connectedTo] = distance[checkRoom] + 1
        prevRoom[connectedTo] = checkRoom
        q.put(connectedTo)

print('Yes')
for i in range(1,numRoom):
    print(prevRoom[i]+1)


Measured memory_bytes: 35044
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include <set>
#define ll long long
using namespace std;
ll  a[500000];
ll sum=0;
int main()
{
    ll n;
    cin>>n;
    for(ll i=0;i<n;i++)
    {
        ll k;
        cin>>k;
        sum+=k;
        a[k]++;
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++)
    {
        ll b,c;
        cin>>b>>c;
        ll x=a[b];
        sum=sum-x*b+x*c;
        a[b]=0;
        a[c]=a[c]+x;
        cout<<sum<<endl;
    }
    return 0;
}


Measured memory_bytes: 4340
from collections import deque
from collections import Counter
from itertools import product, permutations,combinations
from operator import itemgetter
from heapq import heappop, heappush
from bisect import bisect_left, bisect_right, bisect
#pypyではscipy, numpyは使えない
#from scipy.sparse.csgraph import shortest_path, floyd_warshall, dijkstra, bellman_ford, johnson, minimum_spanning_tree
#from scipy.sparse import csr_matrix, coo_matrix, lil_matrix
#import numpy as np
from fractions import gcd
from math import ceil,floor, sqrt, cos, sin, pi, factorial
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10**8)
INF = float('inf')

def main():
  a, b, c = map(int, readline().split())
  print(min(b//a, c))
  
  
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 5076
a, b, c, d = map(int, input().split())

if c > a and c-a <= d:
    print("Yes")

elif a > c and a - c <= d:
    print("Yes")

elif c > b > a and c - b <= d and b - a <= d:
    print("Yes")

elif a > b > c and a - b <= d and b - c <= d:
    print("Yes")

elif a == c:
    print("Yes")

else:
    print("No")

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define pr(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define all(v) (v).begin(), (v).end()
#define int long long
#define sz(v) (int)(v).size()
#define mod 1000000007 // ((a- b)% mod+ mod)% mod

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

map<int, int> mp[300001];

void solve() {
        int n, m, k; cin >> n>> m>> k;
        vector<int> r(n+ 1), c(m+ 1);

        for (int i= 0; i< k; i++) {
                int x, y; cin >> x>> y;
                x--, y--;
                mp[x][y]= 1;
                r[x]++;
                c[y]++;
        }

        int mxr= *max_element(all(r));
        int mxc= *max_element(all(c));

        vector<int> anr, anc;

        for (int i= 0; i< n; i++) if (r[i]== mxr) anr.push_back(i);

        for (int i= 0; i< m; i++) if (c[i]== mxc) anc.push_back(i);

        n= anr.size(), m= anc.size();
        int ans= 0;
        bool ok= 0;

        for (int i= 0; i< anr.size(); i++) {
                for (int j = 0; j< anc.size(); j++) {
                        ans= max(ans, mxr+ mxc- mp[anr[i]][anc[j]]);
                        if (ans== mxr+ mxc) {
                                cout << ans<< "\n";
                                ok= 1;
                                break;
                        }
                }
                if (ok) break;
        }
        if (!ok) cout << ans;

}

int32_t main(){
ios::sync_with_stdio(0), cin.tie(NULL), cout.tie(NULL);
        int T= 1;
        //cin >> T;
        while ( T-- ) {
                solve();
        }
return 0;
}


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

int main() {
	// your code goes here
	int n,i,max=0,count=0;
	cin>>n;
	long int a[n];
	cin>>a[0];
	for(i=1;i<n;i++)
	{
		cin>>a[i];
		if(a[i]<=a[i-1])
		count++;
		else
		count=0;
		if(max<count)
		max=count;
	}
	cout<<max;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int low[200000];
int high[200000];
int a[200000];

int part(int a[],int b[],int l,int r){
  int i,j,x,t;

  i = l - 1;
  j = r;

  x = b[r];

  while(1){
    while(b[++i] < x);
    while(i < --j && x < b[j]);

    if(i >= j) break;

    t = a[i]; a[i] = a[j]; a[j] = t;
    t = b[i]; b[i] = b[j]; b[j] = t;
  }

  t = a[i]; a[i] = a[r]; a[r] = t;
  t = b[i]; b[i] = b[r]; b[r] = t;
  return i;
}

void quicksort(int a[],int b[],int n){
  int l,r,v;
  int sp;

  low[0] = 0;
  high[0] = n - 1;
  sp = 1;

  while(sp > 0){
    sp--;
    l = low[sp];
    r = high[sp];

    if(l >= r);

    else {
      v = part(a,b,l,r);

      if(v - l < r - v){
        low[sp] = v + 1;
        high[sp++] = r;
        low[sp] = l;
        high[sp++] = v - 1;
      }

      else{
        low[sp] = l;
        high[sp++] = v - 1;
        low[sp] = v + 1;
        high[sp++] = r;
      }
    }
  }
}

int main(){
  int n,m;
  int i;
  int a[100006];
  int b[100006];
  int cnt = 0;
  int t;

  scanf("%d %d", &n, &m);

  for(i = 0;i < m;i++) scanf("%d %d", &a[i], &b[i]);

  quicksort(a,b,m);

  t = 0;
  for(i = 0;i < m;i++){
    if(t <= a[i]){
      t = b[i];
      cnt++;
    }
  }

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

  return 0;
}


Measured memory_bytes: 896
package main

import (
	"fmt"
)

const MAX_N = 20

var (
	A [MAX_N]int
	ASelect [MAX_N]bool
	N int
	Values map[int]bool = make(map[int]bool)
)

func scannInt(num *int) {
	for {
		read, _ := fmt.Scanf("%d", num)
		if read>0 {
			break;
		}
	}
}

func sum(end int) int {
	result := 0
	for i:=0; i<=end && i<N; i++{
		if (ASelect[i]) {
			result += A[i]
		}
	} 
	return result
}

func solve(i int) {
	if i==N {
		Values[sum(i-1)] = true
		return
	}
	solve(i+1)
	ASelect[i] = true
	solve(i+1)
	ASelect[i] = false
}

func main() {
	scannInt(&N)
	for i:=0; i<N; i++ {
		scannInt(&A[i])
	}
	solve(0)
	var q int
	var num int
	scannInt(&q)
	for i:=0;i<q;i++ {
		scannInt(&num)
		_, ok := Values[num]
		if ok {
			fmt.Println("yes")
		} else {
			fmt.Println("no")
		}
	}
	return
}


Measured memory_bytes: 1172
#include<stdio.h>
#include<stack>
#include<queue>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdlib.h>
using namespace std;
int main()
{
	int n,a[105];
	scanf("%d",&n);
	int sum=0;
	for(int i=0;i<n;i++)
	{
	scanf("%d",&a[i]);
	sum=sum+a[i];
    }
	int m;
	scanf("%d",&m);
	for(int i=0;i<m;i++)
	{
		int n,k;
		int u;
		u=sum;
		scanf("%d %d",&n,&k);
		u=sum-a[n-1]+k;
		printf("%d\n",u);
	}
	return 0;
}

Measured memory_bytes: 128
N = int(input())
A = []
for i in range(N):
    X = input()
    if "." in X:
        XL = X.split(".")
        XN = len(XL[1])
        X = int(XL[0])*10**XN+int(XL[1])
        Y = X*10**(9-XN)
    else:
        Y = int(X)*10**9
    A.append(Y)
T = [[0]*2 for i in range(N)]
max2 = 0
max5 = 0
for i in range(N):

    X = A[i]
    cnt = 0
    while X%5==0:
        cnt+=1
        X = X//5
    T[i][0]=cnt
    max5 = max(max5,cnt)

    X = A[i]
    cnt = 0
    while X%2==0:
        cnt+=1
        X = X//2
    T[i][1]=cnt
    max2 = max(max2,cnt)

S = [[0]*(max2+1) for i in range(max5+1)]

for i in range(N):
    S[T[i][0]][T[i][1]]+=1

out = 0
for j1 in range(max2+1):
    for i1 in range(max5+1):
        for j2 in range(max2+1):
            for i2 in range(max5+1):
                X = S[i1][j1]
                Y = S[i2][j2]
                if i1+i2>=18 and j1+j2>=18:
                    if i1==i2 and j1==j2:
                        out += X*(X-1)
                    else:
                        out += X*Y
print(out//2)

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

Measured memory_bytes: 576
import itertools
import math
import sys
import heapq
from collections import Counter
from collections import deque
from fractions import gcd
from functools import reduce
INF = 1 << 60
sys.setrecursionlimit(10 ** 6)

#ここから書き始める
def my_gcd(gap):
    n = len(gap)
    if n == 1:
        return gap[0]
    ret = gap[0]
    for i in range(1, n):
        ret = gcd(ret, gap[i])
    return ret

n, start = map(int, input().split())
a = list(map(int, input().split()))
gap = []
a.append(start)
a.sort()
for i in range(1, n + 1):
    gap.append(abs(a[i] - a[i - 1]))
# print(gap)
print(my_gcd(gap))

Measured memory_bytes: 16284
#include <iostream>

int main() {
	int x;
	std::cin >> x;

	int s = 0;
	int y = x % 100;
	for (int i = 5; i >= 1; --i) {
		s += y / i;
		y %= i;
	}

	std::cout << (s * 100 <= x) << std::endl;
}

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



int sc1(){int x; scanf("%d",&x); return x;}

long long sc2(){long long x;scanf("%lld",&x);return x;}

#define  gcd(a,b)         __gcd(a,b)
#define  lcm(a,b)         (a*b)/gcd(a,b)
#define  Int              sc1()
#define  LL               sc2()
#define  For(n)           for(int i=0;i<n;i++)
#define  Forj(n)          for(int j=0;j<n;j++)
#define  Fork(n)          for(int k=0;k<n;k++)
#define  For1(n)          for(int i=1;i<=n;i++)
#define  ll               long long
#define  vi               std::vector<int>
#define  vll              std::vector<ll>
#define  qui              qu
#define  pb               push_back
#define  mpsi             std::map<string, int>







int main()
{
	//freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n=Int;
    string s;
    cin>>s;

    if(n<3200) puts("red");
    else cout<<s<<endl;
    
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include<cmath>
#include<string>
#define pb push_back
#define x first
#define y second
#define fast ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define all(x) x.begin(),x.end()
#define int long long
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
//void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
// look for  all edge cases
//search for a pattern



signed main() {    
	ios::sync_with_stdio(0);
	cout.tie(0);
	cin.tie(0);
	
	string s;
	cin >>s;
	
	int n = s.size();
	
	if(s[n-1] == 's'){
		cout<<s<<"es";
	}
	else{
		cout<<s<<"s";
	}	
	
	 
	return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

int main(){
  int P, Q, R;
  std::cin >> P >> Q >> R;
  int sum = P + Q + R;
  if(P > Q){
    if(P > R){
      std::cout << sum-P <<std::endl;
    }
    else{
      std::cout << sum-R <<std::endl;
    }
  }
  else if(Q > R){
      std::cout << sum-Q <<std::endl;
  }
  else{
      std::cout << sum-R <<std::endl;
  }
  return 0;
}

Measured memory_bytes: 888
import collections
[n,m] = [int(i) for i in input().split()]
dic = collections.defaultdict(int)
for i in range(m):
  [a,b] = [int(j)-1 for j in input().split()]
  if a == 0:
    dic[b] += 1
  elif b == n-1:
    dic[a] += 1
if max(dic.values()) >= 2:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")


Measured memory_bytes: 107376
#include <bits/stdc++.h>
  
using namespace std;
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
#define REP(i,n) for(ll i=0;i<n;++i)
#define REPR(i,n) for(ll i=1;i<n;++i)
#define FOR(i,a,b) for(ll i=a;i<b;++i)
  
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()
  
#define MOD (ll)(1e9+7)
#define ADD(a,b) a=((a)+(b))%MOD
#define FIX(a) ((a)%MOD+MOD)%MOD

#define INF 1000000000

typedef long double Real;
#define EPS 1e-11
#define EQ(x) (-EPS<x && x<EPS)
typedef complex<Real> P;
Real dot(P a,P b){return real(conj(a)*b);}
Real cross(P a,P b){return imag(conj(a)*b);}

int main(){
  char s[11];
  while(~scanf("%s",s)){
    int a[10];
    REP(i,10)a[i]=s[i]-'0';
    REP(i,9)REP(j,9-i)a[j] = (a[j]+a[j+1])%10;
    cout<<a[0]<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 2147483647;
const ll LINF = 9223372036854775807;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

int main() {
	ll n; cin >> n;
	vector<P> a(n); 
	REP(i,n){
		cin >> a[i].first;
		a[i].second=i;
	}
	sort(ALL(a),greater<P>());
	ll dp[2020][2020]; dp[0][0]=0; dp[0][1]=0;
	REP(i,n-1){
		ll p=a[i].first, x=a[i].second;
		ll aki=n-i;
		REP(j,i+2){
			if(j==0)
				dp[i+1][j]=dp[i][j]+abs(x-(j+aki-1))*p;
			else if(j==i+1)
				dp[i+1][j]=dp[i][j-1]+abs(x-(j-1))*p;
			else
				dp[i+1][j]=max(dp[i][j]+abs(x-(j+aki-1))*p,dp[i][j-1]+abs(x-(j-1))*p);
		}
	}
	ll ans=0;
	REP(i,n) ans=max(ans,dp[n-1][i]+a[n-1].first*abs(i-a[n-1].second));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 26320
import Data.List

prefixes = map reverse ["dream", "dreamer", "erase", "eraser"]
matcher s = filter (\x -> isPrefixOf x s) prefixes

matching "" = "YES"
matching str =
  let x = matcher str
  in if length x  > 0 then matching $ drop (length . head $ x) str else "NO"

main = getLine >>= putStrLn . matching . reverse

Measured memory_bytes: 7548
#include<iostream>
#include<vector>
#include<set>
#include<algorithm>
using namespace std;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> a(N), b(N);
    for(int i = 0; i < N; i++) cin >> a[i].first >> a[i].second;
    for(int i = 0; i < N; i++) cin >> b[i].first >> b[i].second;

    sort(b.begin(), b.end());

    vector<int> v;
    for(int i = 0; i < N; i++) {
        int y = -1e9;
        int n = -1;
        for(int j = 0; j < N; j++) {
            bool update = true;
            for(auto e: v) if(e == j) update = false;
            if(!update) continue;
            if(b[i].first > a[j].first && b[i].second > a[j].second){
                if(y < a[j].second) {
                    y = a[j].second;
                    n = j;
                }
            }
        }
        if(n != -1) v.push_back(n);
    }


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

    return 0;
}

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

using namespace std; 



int main () {
  int n; cin >> n; 
  string temp = to_string(n); 
 

  

  
int check = temp.back();
  

    if (check == '2' || check == '4' ||check == '5' ||check == '7' ||check == '9') {
      cout << "hon" << endl;
    }
    else if (check == '0' || check == '1'|| check == '6'|| check == '8') {
      cout << "pon" << endl; 
    }
    else {
      cout << "bon"; 
    }
  

}

Measured memory_bytes: 3700
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#define all(c) c.begin(), c.end()
#define pb push_back
#define ll long long
const int MAXN = 1e5 + 5;
const int mod = 1e9 + 7;

using namespace std;

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n;
  cin >> n;
  while (n) {
    if (n%10 == 7) {
      cout << "Yes";
      return 0;
    }
    n /= 10;
  }
  cout << "No";
  return 0;
}

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

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

Measured memory_bytes: 4048
#include <algorithm>　　　 //STL 通用算法
#include <bitset>　　　　　//STL 位集容器
#include <cctype>         //字符处理
#include <cerrno> 　　　　 //定义错误码
#include <cfloat>　　　　 //浮点数处理
#include <ciso646>         //对应各种运算符的宏
#include <climits> 　　　　//定义各种数据类型最值的常量
#include <clocale> 　　　　//定义本地化函数
#include <cmath> 　　　　　//定义数学函数
#include <complex>　　　　 //复数类
#include <csignal>         //信号机制支持
#include <csetjmp>         //异常处理支持
#include <cstdarg>         //不定参数列表支持
#include <cstddef>         //常用常量
#include <cstdio> 　　　　 //定义输入／输出函数
#include <cstdlib> 　　　　//定义杂项函数及内存分配函数
#include <cstring> 　　　　//字符串处理
#include <ctime> 　　　　　//定义关于时间的函数
#include <cwchar> 　　　　 //宽字符处理及输入／输出
#include <cwctype> 　　　　//宽字符分类
#include <deque>　　　　　 //STL 双端队列容器
#include <exception>　　　 //异常处理类
#include <fstream> 　　　 //文件输入／输出
#include <functional>　　　//STL 定义运算函数（代替运算符）
#include <limits> 　　　　 //定义各种数据类型最值常量
#include <list>　　　　　　//STL 线性列表容器
#include <locale>         //本地化特定信息
#include <map>　　　　　　 //STL 映射容器
#include <memory>         //STL通过分配器进行的内存分配
#include<new>            //动态内存分配
#include <numeric>         //STL常用的数字操作
#include <iomanip> 　　　 //参数化输入／输出
#include <ios>　　　　　　 //基本输入／输出支持
#include <iosfwd>　　　　　//输入／输出系统使用的前置声明
#include <iostream> 　　　//数据流输入／输出
#include <istream>　　　　 //基本输入流
#include <iterator>        //STL迭代器
#include <ostream>　　　　 //基本输出流
#include <queue>　　　　　 //STL 队列容器
#include <set>　　　　　　 //STL 集合容器
#include <sstream>　　　　 //基于字符串的流
#include <stack>　　　　　 //STL 堆栈容器
#include <stdexcept>　　　 //标准异常类
#include <streambuf>　　　 //底层输入／输出支持
#include <string>　　　　　//字符串类
#include <typeinfo>        //运行期间类型信息
#include <utility>　　　　 //STL 通用模板类
#include <valarray>        //对包含值的数组的操作
#include <vector>　　　　　//STL 动态数组容器
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;

const int MAXN=1e5+10;
const int MOD=998244353;

inline int read(){
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c))x=(x<<3)+(x<<1)+c-'0',c=getchar();
	return x*f;
}
inline ll readll(){
	ll x=0;int f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-') f=-1;c=getchar();}
	while(isdigit(c)) x=(x<<3ll)+(x<<1ll)+1ll*(c-'0'),c=getchar();
	return x*f;
}
int gcd(int x,int y){
	return y?gcd(y,x%y):x;
}
ll gcd(ll x,ll y){
	return y?gcd(y,x%y):x;
}

int n;

int main(){
	n=read();
	printf("%d\n",((n-1)/1000+1)*1000-n);
	return 0;
}

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

int main()
{
    int a, b;
    cin >> a >> b;

    int count = 0;
    rep(i, 1, a + 1)
    {
        bool isEnd = false;
        rep(j, 1, 32)
        {
            if (i == j)
            {
                ++count;
            }
            if (i == a && j == b)
            {
                isEnd = true;
                break;
            }
        }
        if (isEnd)
            break;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 3584
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = np.array(lr(), dtype=np.int32)
A -= np.arange(1, N+1)
answer = np.abs(A - int(np.median(A))).sum()
print(answer)


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

int main(){
	int N;
	vector<int> H;
	int tmp;

	cin >> N;
	for(int i = 0; i < N; i++){
		cin >> tmp;
		H.push_back(tmp);
	}

	if(0 < H[0]){
		H[0]--;
	}

	for(int i = 1; i < N; i++){
		if(H[i-1] < H[i]){
			H[i]--;
		}
	}
	bool result = true;
	for(int i = 0; i < N-1; i++){
		if(H[i] > H[i+1]){
			result = false;
			break;
		}
	}
	if(result){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}


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

int main (){
  int a, b;
  cin >> a >> b;
  
  if (a % 2 != 0 && b % 2 != 0){
    cout << "Odd" << endl;
  }
  else {
    cout << "Even" << endl;
  }
}

Measured memory_bytes: 256
program abc129d
  implicit none
  character(2000),dimension(:),allocatable :: s
  integer :: h, w, i, j
  integer,dimension(:,:,:),allocatable :: grid

  read *, h, w
  allocate(s(h),grid(w,h,3))
  read *, s

  do i = 1,h
     do j = 1,w
        grid(j,i,:) = merge(0,1,s(i)(j:j)=='#')
     end do
  end do

  do j = 2,w
     grid(j,:,2) = merge(grid(j,:,2)+grid(j-1,:,2),grid(j,:,2),grid(j,:,1)/=0)
  end do

  do j = w-1,1,-1
     grid(j,:,2) = merge(grid(j+1,:,2),grid(j,:,2),grid(j,:,1)/=0.and.grid(j+1,:,1)/=0)
  end do

  do i = 2,h
     grid(:,i,3) = merge(grid(:,i,3)+grid(:,i-1,3),grid(:,i,3),grid(:,i,1)/=0)
  end do

  do i = h-1,1,-1
     grid(:,i,3) = merge(grid(:,i+1,3),grid(:,i,3),grid(:,i,1)/=0.and.grid(:,i+1,1)/=0)
  end do

  print *, maxval(grid(:,:,2)+grid(:,:,3))-1
end program abc129d


Measured memory_bytes: 51584
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
/* テンプレートここまで */

ll exchange(ll N, vector<vector<ll>>& g){
  //交換すべき金属を表すindexのリスト
  vector<int> gain;
  REP(i, 3){
    if(g[i][1] - g[i][0] > 0 && g[i][0] <= N) gain.push_back(i);
  }

  if(gain.size() == 0) return N;

  int k, l;
  if(gain.size() == 1){
    k = gain[0];
    return N + (g[k][1] - g[k][0])*(N/g[k][0]);
  }

  ll ret = N;
  if(gain.size() == 2){
    k = gain[0];
    l = gain[1];
    for(int i=0; g[k][0] * i <= N; i++){
      ll tmp = N + (g[k][1]-g[k][0]) * i + (g[l][1]-g[l][0])*((N-g[k][0] * i)/g[l][0]);
      if(ret < tmp) ret = tmp;
    }
    return ret;
  }
  
  //0,1,2
  for(int i = 0; g[0][0] * i <= N; i++){
    for(int j = 0; g[1][0] * j <= N - g[0][0]*i; j++){
      ll tmp = N + (g[0][1]-g[0][0]) * i + (g[1][1]-g[1][0]) * j + (g[2][1]-g[2][0]) * ((N - g[0][0]*i - g[1][0] * j)/g[2][0]);
      if(ret < tmp) ret = tmp;
    }
  }
  return ret;
}

int main() {
  ll N; cin >> N;
  vector<vector<ll>> g(3, vector<ll>(2));
  REP(i, 2) REP(j, 3){
    cin >> g[j][i];
  }
  N = exchange(N, g);
  REP(i, 3){
    swap(g[i][0], g[i][1]);
  }
  N = exchange(N, g);
  cout << N << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fine cout<<"fine"<<endl;
#define ll long long int
#define pb push_back
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
const ll inf=(ll)2e18;
const int mod=1e9+7;
bool overflow(ll a,ll b){
    if (a <= (inf+b-1)/b) return false;
    return true;
}
int main(){
FASTIO;
ll x,i;
cin>>x;
ll n=100;
for(i=1;n<x;i++){
    n=n+(n/100);
}
cout<<i-1<<endl;
}


Measured memory_bytes: 3648
#include<stdio.h>
int main(void)
{
	int N;
	int count=0;
	scanf("%d", &N);
	int ary[N+1];
	for(int i=1;i<=N;i++){
		scanf("%d", &ary[i]);
		if(ary[i]==i){
			count=count+0;
			}
		else{count++;}
		
			
	}
	if(count==0 || count==2 ||count==1)printf("YES");
	else printf("NO");
	return 0;
	
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
#define all(v) v.begin(), v.end()
#define rep(i, from, to) for (ll i = from; i < ll(to); ++i)

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

    ll x,y;
    cin>>x>>y;
    if(x%y==0)
        cout<<-1<<endl;
    else
        cout<<x<<endl;

    return 0;
}


Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  sc.scan(N);

  string[] S = new string[N];
  int[] P = new int[N];
  int[] num = new int[N];
  foreach (i; 0 .. N) {
    sc.scan(S[i], P[i]);
    num[i] = i + 1;
  }

  sort(zip(S, P, num));

  for (int i = 0; i < N; ++i) {
    int[] tmp = new int[N];
    tmp ~= P[i];
    int j = i;
    int k = 0;
    while (S[i] == S[j]) {
      tmp[k] = P[j];
      j++;
      k++;

      if (j >= N)
        break;
    }
    reverse(zip(tmp, num[i .. i + k]));

    i += k - 1;
  }

  foreach (i; 0 .. N)
    writeln(num[i]);
}


Measured memory_bytes: 380
#include<stdio.h>
#include<string>//需加上Using
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string a,b,c;
	int n,m;
	while(cin>>a)
	{
		cin>>b;
		scanf("%d%d",&n,&m);
		cin>>c;
		if(c==a)
			n--;
		else
			m--;
		printf("%d %d\n",n,m);
	}
} 

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

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

  bool flag = false;

  for(int i = 0;i < M-1;i++){
    int L2,R2;
    cin >> L2 >> R2;
    if(R2 < L || R < L2){
      flag = true;
    }
    else{
      if(R <= R2 && L >= L2){
        continue;
      }
      else if(R2 <= R && L2 >= L){
        R = R2;
        L = L2;
      }
      else if(R2 <= R && R2 >= L){
        R = R2;
      }
      else if(R <= R2&& R >= L2){
        L = L2;
      }
    }
  }

  if(flag)cout << 0 << endl;
  else cout << (R - L + 1) << endl;

}


Measured memory_bytes: 256
//#pragma warning(disable:4996)
//#include <Windows.h>
#include <iostream>
#include <vector>
#include <limits.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <random>
#include <functional>
#include <stack>
#include <iomanip>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>
#include <complex>
#include <cstdio>
#include <list>
#include <bitset>
//#include <stdio.h>

//< in.txt > out.txt
using namespace std;
//std::ios::sync_with_stdio(false);
//std::cin.tie(0);
const long long MOD = 1e9 + 7;
const long long INF = 1e18;
typedef long long LL;
typedef long double LD;
//typedef boost::multiprecision::cpp_int bigint;
typedef pair<LL, LL> PLL;
typedef pair<int, int> PI;
typedef pair<LD, LL> pdl;
typedef pair<LD, LD> pdd;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef unsigned long long ULL;

template<class T>
inline void chmin(T& a, T b) {
	a = min(a, b);
}

template<class T>
inline void chmax(T& a, T b) {
	a = max(a, b);
}

void input();
void solve();

void daminput();

int main() {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	input();
	//daminput();
	solve();
	return 0;
}

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

int A, B, C;

void input() {
	cin >> A >> B >> C;
}

void daminput() {
}

void solve() {
	if (A <= C && C <= B)cout << "Yes\n";
	else cout << "No\n";
}

Measured memory_bytes: 3032
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
#define PI 3.14159265358979323846264338327950L;
const int INF2 = 1001001001;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};

const int MAX_N = 110000;

int memo[MAX_N];

int rec(int n) {
	if (n == 0)return 0;
	if (memo[n] != -1)return memo[n];

	int res = n;

	for (int pow6 = 1; pow6 <= n; pow6 *= 6)res = min(res, rec(n - pow6) + 1);

	for (int pow9 = 1; pow9 <= n; pow9 *= 9)res = min(res, rec(n - pow9) + 1);

	return memo[n] = res;
}

int calc(int x) {
	int ret = 0;
	while (x % 2 == 0) {
		x /= 2;
		ret++;
	}

	return ret;
}

int a[12][12];
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;

	cin >> n;

	vector<ll> b(n);

	rep(i, 0, n) {
		ll a;
		cin >> a;
		b[i] = a - i;
	}

	sort(b.begin(), b.end());
	ll mid = b[n/2];

	ll ans = 0;

	rep(i, 0, n) {

		ans += abs(b[i] - mid);
	}

	
	//cout << fixed << setprecision(12);
	cout << ans << endl;
	
	
	

	
		
	



}
	

Measured memory_bytes: 1792
import sys
input = sys.stdin.readline
from itertools import combinations


def read():
    N = int(input().strip())
    S = []
    for i in range(N):
        s = input().strip()
        S.append(s)
    return N, S


def solve(N, S):
    Z = [0 for i in range(26)]
    for s in S:
        a = s[0]
        Z[ord(a)-ord("A")] += 1
    ans = 0
    D = [Z[ord(a)-ord("A")] for a in "MARCH"]
    for i, j, k in combinations(D, r=3):
        ans += i * j * k
    return ans


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 15896
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    long M = scanner.nextInt();
    Set<Integer> list = new HashSet<>();
    for (int i = 0; i < N; i++) list.add(scanner.nextInt() / 2);
    List<Integer> a = new ArrayList<>(list);

    long lcm = 1;
    for (int num : a) lcm = lcm(lcm, num);

    for (int num : a) {
      if ((lcm / num) % 2 == 0) {
        System.out.println(0);
        return;
      }
    }

    if (M < lcm) {
      System.out.println(0);
      return;
    }
    System.out.println((M - lcm) / (lcm * 2) + 1);
  }

  private static long lcm(long i, long j) {
    long gcd = gcd(i, j);
    return i / gcd * j;
  }
  
  private static long gcd(long i, long j) {
    if (i > j) return gcd(j, i);
    while (i > 0) {
      long r = j % i;
      j = i;
      i = r;
    }
    return j;
  }
}


Measured memory_bytes: 48736
# coding: utf-8
# Your code here!

n,k=map(int,input().split())
s=input()
pre=s[0]
cnt=1
st=[]
if s[0]=='0':
    st.append(0)
for i in range(1,n):
    cur=s[i]
    if cur==pre:
        cnt+=1
    else:
        st.append(cnt)
        cnt=1
    pre=cur
if cnt!=0:
    st.append(cnt)
if s[-1]=='0':
    st.append(0)
#print(n,k,s,st)

ac=[]
pre=0
for i in st:
    pre+=i
    ac.append(pre)

ans=0
if 2*k+1>=len(st):
    ans=n
else:
    ans=ac[2*k]
    for i in range(2,len(st)-2*k,2):
        #print(i,i+2*k)
        ans=max(ans,ac[i+2*k]-ac[i-1])
print(ans)

Measured memory_bytes: 47284
#include <stdio.h>
 
int main(){
   int w, h, x, y, r;
 
   scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);

   if (x+r>w || x-r<0 || y+r>h || y-r<0){
      puts("No");
   }else{
      puts("Yes");
   }
 
   return 0;
}

Measured memory_bytes: 584
import math
import string


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


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


n = int(input())
w = list(map(int, input().split()))
cnt = 0
for i in range(n):
    a = True
    for j in range(i):
        if w[j] > w[i]:
            a = False
            break
    if a:
        cnt += 1
print(cnt)


Measured memory_bytes: 3832
/*************************************************************************
  >         File: C.cc
  >       Author: lyyllyyl
  >         Mail: riho.yoshioka@yandex.com
  > Created Time: Sat 01 Oct 2016 08:21:20 PM CST
*************************************************************************/
#include <bits/stdc++.h>
int a[111], has[111];

int main() {
  std::ios::sync_with_stdio(0);
  bool bad = false;
  int n;
  std::cin >> n;
  for (int i = 1; i <= n; ++i) std::cin >> a[i], has[a[i]] = 1;
  int minValue = *std::min_element(a + 1, a + n + 1);
  int maxValue = *std::max_element(a + 1, a + n + 1);
  if (maxValue & 1) {
    bad = std::count(a + 1, a + n + 1, minValue) != 2;
  } else {
    bad = std::count(a + 1, a + n + 1, minValue) != 1;
  }
  for (int i = minValue; i <= maxValue; ++i) if (!has[i]) bad = true;
  for (int i = 1; i <= n; ++i) if (a[i] > n - 1) bad = true;
  for (int i = 1; i <= n; ++i) if (a[i] < 1) bad = true;
  bad ? puts("Impossible") : puts("Possible");
  return 0;
}


Measured memory_bytes: 384
import math

n, m = input().split()
N = int(n)
K = int(m)

NN = (N / 2) * (N + 1)

NN = NN / N

result = 0.0
for i in range(N):
    X = K / (i + 1)
    X = math.log(X, 2)
    if X == int(X):
        pass
    else:
        X = math.floor(X) + 1
    if X < 0:
        result += (1 / N)
    else:
        result += (1 / N) * ((1/2) ** X)
print(result)


Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    cin >> a >> b;
    string ans = "No" ;
    for (int i = 0; i <= a ; i++){
        int j = a - i;
        if ( 2* i + 4 * j == b) ans = "Yes";
    }
    cout << ans << endl;
    return 0;
}


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


signed main() {
    ll n, a ,b;
    cin >> n >> a >> b;
    ll dif = b - a;
    if(dif % 2 == 0) cout << dif / 2 << endl;
    else{
        ll tmp = min(a-1, n-b);
        cout << tmp + 1 + (b-a-1)/2;
    }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
//#define MOD 998244353
#define MOD 1000000007

int main(){
    int n;
    cin>>n;
    cout<<(n+1)/2<<endl;
    
}

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

using namespace std;

const int P=1e9+7;

int n,K;
int a[100010];
int f[102][100002];
int sum[102][100002];

int main(){
	scanf("%d%d",&n,&K);
	for(int i=1;i<=n;i++){
		scanf("%d",a+i);
	}
	for(int i=0;i<=K;i++)
		f[0][i]=sum[0][i]=1;
	for(int i=1;i<=n;i++){
		for(int j=0;j<=K;j++){
			f[i][j]=((sum[i-1][j]-((j-a[i]-1)>=0?sum[i-1][j-a[i]-1]:0))%P+P)%P;
			sum[i][j]=((j==0?0:sum[i][j-1])+f[i][j])%P;
		}
	}
	printf("%d\n",f[n][K]);

	return 0;
}

Measured memory_bytes: 80128
#include <stdio.h>

int main(void)
{
	int candy;
	int amari;
	
	while (scanf("%d" ,&candy) != EOF){
		
		amari = candy % 39;
		
		if (amari == 0){
			printf("3C39\n");
		}
		
		else if ((amari >= 1) && (amari <= 9)){
			printf("3C0%d\n" , amari);
		}
		
		else {
			printf("3C%d\n" , amari);
		}
	}
	
	return (0);
}

Measured memory_bytes: 608
#![allow(
  non_snake_case,
  unused_variables,
  unused_assignments,
  unused_mut,
  unused_imports,
  unused_macros,
  dead_code
)]
//use proconio::fastout;
use proconio::{input, marker::*};
use std::cmp::*;
use std::collections::*;
//use std::collections::VecDeque;

macro_rules! debug {
  ($($a:expr),* $(,)*) => {
      #[cfg(debug_assertions)]
      eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
  };
}

fn main() {
  input! {
     N:usize,Q:usize,
     c:[Usize1;N],
     lr:[(Usize1,Usize1);Q]
  }
  let inf = std::usize::MAX;
  let c: Vec<usize> = c;
  let lr: Vec<(usize, usize)> = lr;
  let mut ans = vec![0; Q];
  let mut last = vec![inf; N];
  let mut next = vec![vec![]; N];
  for i in 0..N {
    let v = last[c[i]];
    if v != inf {
      next[v as usize].push(i);
    }
    last[c[i]] = i;
  }
  let mut qs = vec![Vec::with_capacity(N); N];
  for qi in 0..Q {
    debug!(lr);
    //(qi, &(l, r)) in lr.iter().enumerate() {
    let (l, r) = lr[qi];
    qs[l].push((r, qi));
  }
  //println!("p{:?}", next);
  let mut bit = vec![0; N + 1];
  for x in (0..N).rev() {
    for &y in next[x].iter() {
      bit.add(y, 1usize);
    }
    //println!("prev={:?}", next);
    for &(r, qi) in qs[x].iter() {
      //println!("sum={}", bit.sum(r));
      ans[qi] = (r - x + 1) - bit.sum(r);
    }
  }

  for a in ans {
    println!("{}", a);
  }
}

use std::ops::{AddAssign, Sub};
trait BIT<T: Copy + Clone + Sub + AddAssign> {
  fn add(&mut self, idx: usize, w: T);
  fn sum(&self, idx: usize) -> T;
  fn range(&self, l: usize, r: usize) -> T;
}
impl<T: Copy + Clone + Sub<Output = T> + AddAssign> BIT<T> for [T] {
  fn add(&mut self, idx: usize, w: T) {
    let mut j = (idx + 1) as i64;
    while j < self.len() as i64 {
      self[j as usize] += w;
      j += j & -j;
    }
  }
  /// [0, r]
  fn sum(&self, idx: usize) -> T {
    let mut i = (idx + 1) as i64;
    let mut sum = self[0];
    while i != 0 {
      sum += self[i as usize];
      i -= i & -i;
    }
    sum
  }
  /// [l, r)
  fn range(&self, l: usize, r: usize) -> T {
    match (l, r) {
      (0, _) => self.sum(r - 1),
      _ => self.sum(r - 1) - self.sum(l - 1),
    }
  }
}


Measured memory_bytes: 87132
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int a,long long int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}

int main(){
    long long int n,x,q=0;
    cin>>n>>x;
    vector<long long int>a(200000);
    vector<long long int>b(200000);
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    a[n]=x;
    sort(a.begin(),a.end(),greater<>());
    for(int i=0;i<n;i++){
        b[i]=a[i]-a[i+1];
    }
    sort(a.begin(),a.end(),greater<>());
    q=b[n-1];
    for(int i=0;i<n-1;i++){
        q=gcd(b[n-2-i],q);
    }
    cout<<q<<endl;
    return 0;
}

Measured memory_bytes: 3456
import java.io.*;
public class Main {
  public static void main (String[] args) throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String s = br.readLine();
    String[] line = s.split(" ");
    int a = Integer.parseInt(line[0]);
    int b = Integer.parseInt(line[1]);
    int c = Integer.parseInt(line[2]);
    int d = Integer.parseInt(line[3]);
    int s1 = a * b;
    int s2 = c * d;
    if (s1 == s2) {
      System.out.println(s1);
    } else if (s1 > s2) {
      System.out.println(s1);
    } else {
      System.out.println(s2);
    }
  }
}


Measured memory_bytes: 8148