akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)


int N, K; string S;
//-----------------------------------------------------------------
char getrev(char c, int m) {
	int cc = c - 'A';
	if (m % 2 == 1) cc = 1 - cc;
	return char('A' + cc);
}
//-----------------------------------------------------------------
int main() {
	cin >> N >> K >> S;

	deque<char> deq;
	string ans = "";
	rep(i, 0, N) deq.push_back(S[i]);
	int cnt = 0, rev = 0, done = 0;
	while (deq.size()) {
		// 右側を詰める
		while (deq.size()) {
			if (getrev(deq.back(), rev) == getrev('A', done)) {
				deq.pop_back();
				ans = getrev('A', done) + ans;
				done++;
			} else {
				break;
			}
		}
		if (deq.size() == 0) break;

		// 変換
		if (getrev(deq.front(), rev) == 'A') {
			// パターン1
			cnt++;
			char c = deq.front(); deq.pop_front();
			deq.push_front(getrev(c, 1));
		} else {
			// パターン2
			cnt++;
			deq.pop_front();
			rev++;
			ans = getrev('A', done) + ans;
			done++;
		}

		if (cnt == K) break;
	}

	if (deq.size()) {
		while (deq.size()) {
			ans = getrev(deq.back(), rev) + ans;
			deq.pop_back();
		}
		cout << ans << endl;
		return 0;
	}

	int d = K - cnt;
	if (N % 2 && d % 2) ans[0] = 'B';
	cout << ans << endl;
}

Measured memory_bytes: 1296
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		
		String a;
		int min = 1000;
		
		for(int i = 0; i < S.length() - 2; i++) {
			a = S.substring(i, i + 3);
			int X = Integer.parseInt(a);
			min = Math.min(min, Math.abs(X - 753));		
		}
		
		System.out.println(min);
		
	}
}


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

int main() {
    int h,w;
    cin >> h >> w;
    vector<string> a(h);
    for(int i = 0; i < h; i++){
        cin >> a.at(i);
    }
    for(int i = 0; i < w+2; i++){
        cout << '#';
    }
    cout << endl;

    for(int i = 0; i < h; i++){
        cout << '#' << a.at(i) << '#' << endl;
    }

    for(int i = 0; i < w+2; i++){
        cout << '#';
    }
    cout << endl;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <bits/stdc++.h>
#include <vector>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define int         long long
#define ll          long long
#define ld	    long double
#define pb          push_back
#define pp	    pop_back()
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define vii         vector<pii>
#define mi          map<ll,ll>
#define mii         map<pii,ll>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),a.rend()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define endl        '\n'
#define rep(i,a,b)  for(ll i=a;i<b;i++)
#define repj(j,a,b) for(ll j=a;j<b;j++)
#define lexistr(x,y)      lexicographical_compare(x.begin(),x.end(),y.begin(),y.end())
#define IOS	    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;

//CONSTANTS----------------------------------
#define PI 	    3.141592653589793238462643
const ll hell=1000000007;
const ll mod=1000000007;
//function-----------------------------------
ll GCD(ll a , ll b)
{
    if(b==0)
        return a;
    else
        return GCD(b,a%b);
}
ll LCM(ll a, ll b)
{
    return a*(b/GCD(a,b));
}
bool isPrime(ll n) {

    if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (ll i = 5; i * i <= n; i = i + 6)
        if (n % i == 0 || n % (i + 2) == 0)
            return false;
    return true;
}
ll fact(ll n)
{
    ll f=1;
    for(ll i=2;i<=n;i++)
	f=f*i;
    return f;
}
ll power(ll a,ll b)
{
  if(b==0)return 1;
  if(b==1)return a;
  ll t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}
//CODE------------------------------------------
ll solve()
{
    ll n,l; cin>>n>>l;
    vector<string> v(n);
    rep(i,0,n)
        cin>>v[i];
    sort(all(v));
    rep(i,0,n)
        cout<<v[i];
    return 0;
}
//MAIN------------------------------------------
signed main(){
    IOS
    #ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
    #endif
    int t=1;
    //cin>>t;
    while(t--) {
        solve();
        cout<<endl;
    }
    return 0;
}


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

const int MOD = 1000000007;
#define p(var)  std::cout<<var<<std::endl
#define pp(var) std::cout<<#var" = "<<var<<std::endl
#define PI (acos(-1))
#define rep(i, n)   for (int i = 0; i <  (n); i++)
#define repeq(i, n) for (int i = 1; i <= (n); i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
using ll = long long;
template<typename T> inline T gcd(T a, T b) { return b ? gcd(b,a%b) : a;}
template<typename T> inline T lcm(T a, T b) { return a / gcd(a,  b) * b;}

/*-----8<-----8<-----*/




int main(){
    vector<int> v(5,0);
    rep(i,5)cin >> v[i];
    int min=99999999;
    sort(v.begin(), v.end());//昇順ソート
    do {
        int t=0;
        for (int i = 0; i < v.size()-1; i++) {
            if(v[i]%10)t+=v[i] + (10-v[i]%10);
            else t+=v[i];
        }
        t+=v[4];
        if(min>t)min=t;
        
    } while (std::next_permutation(v.begin(), v.end()));//昇順順列生成、vが昇順ソート済みの必要あり



    cout << min << endl;



    
    return 0;
}



Measured memory_bytes: 256
def solve(r1, r2):
    return float(r1*r2) / (r1+r2)
assert abs(solve(2, 3) - 1.2000000000) < 1e-6
assert abs(solve(100, 99) - 49.7487437186) < 1e-6
r1, r2 = map(int, raw_input().split())
print solve(r1, r2)

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

#define fi first
#define sd second
#define lson (nd<<1)
#define rson (nd+nd+1)
#define PB push_back
#define mid (l+r>>1)
#define MP make_pair
#define SZ(x) (int)x.size()

using namespace std;

typedef long long LL;

typedef vector<int> VI;

typedef pair<int,int> PII;

inline int read(){
    int res=0, f=1;char ch=getchar();
    while(ch<'0'|ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){res=res*10+ch-'0';ch=getchar();}
    return res*f;
}

const int MAXN = 200'005;

const int MOD = 1000000007;

void addmod(int& a, int b){a+=b;if(a>=MOD)a-=MOD;}
int mulmod(int a, int b){return 1ll*a*b%MOD;}

int k, n;
int A[MAXN];

int main(){
    k=read();n=read();

    for(int i=0;i<n;++i)A[i]=read();

    int mx=0;

    for(int i=0;i<n;++i){
        if(i==n-1){
            mx=max(mx,k-A[n-1]+A[0]);
        }else{
            mx=max(mx,A[i+1]-A[i]);
        }
    }

    cout<<k-mx;

    return 0;
}


Measured memory_bytes: 1024
n, m, l = tuple(map(int, input().split(" ")))
matrixA = [list(map(int, input().split(" "))) for i in range(n)]
matrixB = [list(map(int, input().split(" "))) for i in range(m)]
matrixC = [[0 for i in range(l)] for j in range(n)]

for i in range(n):
    for j in range(l):
        for k in range(m):
            matrixC[i][j] += matrixA[i][k] * matrixB[k][j]

for row in matrixC:
    print(" ".join(map(str, row)))



Measured memory_bytes: 6888
#include <iostream>
using namespace std;
    
    bool has3(int i){
    while(i){
        if(i%10==3)return true;
        i/=10;
    }
        return false;
    }
    
    void call(int n){
        for(int i=1;i<=n;i++){
            if(i%3==0||has3(i)){
                cout<<" "<<i;
            }
        }
        cout<<endl;
    }
    
    int main(){
        int n;
        cin>>n;
        call(n);
        return 0;
    }

    


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

using namespace std;

map <int, int > ma;
int main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(fopen(".inp", "r")) freopen(".inp", "r", stdin);
    int x, n;
    cin >> x >> n;
    for(int i=1 ; i<=n ; ++i) {
        int a;cin >>a;
        ma[a]=1;
    }
    int id=x;
    while(ma[id]) --id;


    int id2=x;
    while(ma[id2]) ++id2;
    if(abs(x-id) <= abs(x-id2)) cout << id;
    else cout << id2;

    return 0;
}


Measured memory_bytes: 3644
using System;
using System.Collections.Generic;

class main
{
    static void Main(string[] args)
    {
        string S = Console.ReadLine();
        string T = Console.ReadLine();

        if(S.Equals(T.Substring(0,T.Length - 1)))
        {
            Console.Write("Yes");
        }else
        {
            Console.Write("No");
        }
    }
}



Measured memory_bytes: 25884
while True:
    H,W = map(int,input().split())
    if H == 0 and W == 0:
        break
    else:
        for l in range(H):
            if l == 0 or H - l == 1:
                print('#'*W)
            else:
                print("#%s#" % ('.'*(W-2)))
        print()


Measured memory_bytes: 5620
n, a, b, c = list(map(int, input().split()))
l = [int(input()) for _ in range(n)]


def ketame(n, i):
  return n // (4 ** i) % 4


mps = []
import itertools
for pro in itertools.product([0, 'a', 'b', 'c'], repeat=n):
  if pro.count('a') == 0 or pro.count('b') == 0 or pro.count('c') == 0:
    continue
  merge = {'a': 0, 'b': 0, 'c': 0}
  for i in range(n):
    if pro[i] != 0:
      merge[pro[i]] += l[i]
  mp = (max(pro.count('a') - 1, 0) + max(pro.count('b') - 1, 0) +
        max(pro.count('c') - 1, 0)) * 10
  mp += abs(merge['a'] - a)
  mp += abs(merge['b'] - b)
  mp += abs(merge['c'] - c)
  mps.append(mp)

print(min(mps))


Measured memory_bytes: 5028
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 1000000000
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::vector<std::vector<std::vector<int>>> dp(44, std::vector<std::vector<int>>(444, std::vector<int>(444, INF)));

  int N, Ma, Mb, a[44], b[44], c[44];

  std::cin >> N >> Ma >> Mb;

  for (int i = 0; i < N; i ++)
    std::cin >> a[i] >> b[i] >> c[i];

  dp[0][0][0] = 0;

  int cm = INF;

  for (int i = 0; i < N; i ++) {
    for (int j = 0; j < 444; j ++)
      for (int k = 0; k < 444; k ++) {
        if (j && k && Ma * k == Mb * j && dp[i][j][k] < INF)
          cm = std::min(dp[i][j][k], cm);
        
        if (dp[i][j][k] < INF) {
          dp[i + 1][j][k] = std::min(dp[i    ][j][k],
                                     dp[i + 1][j][k]);
          
          dp[i + 1][j + a[i]][k + b[i]] = std::min(dp[i    ][j       ][k       ] + c[i],
                                                   dp[i + 1][j + a[i]][k + b[i]]);
        }
      }
  }

  for (int j = 0; j < 444; j ++)
    for (int k = 0; k < 444; k ++)
      if (j && k && Ma * k == Mb * j && dp[N][j][k] < INF)
        cm = std::min(dp[N][j][k], cm);

  if (cm == INF)
    cm = -1;

  std::cout << cm << std::endl;

  return 0;
}


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

int main () {
  string S, A="", B="", C;
  int Q ;
  cin >> S >> Q ;
  int f = 1;
  int q, F;
  for(int i = 0 ; i < Q ; i++){
    cin >> q ;
    if(q == 1){
      f *= -1;
    } else if( q == 2){
      cin >> F >> C ;
      if((f==1&&F==2)||(f==-1&&F==1)){
        A += C;
      } else {
        B += C;
      }
    }
  }
  if(f==1){
    reverse(B.begin(), B.end());
    cout << B << S << A << endl ;
  } else {
    reverse(S.begin(), S.end());
    reverse(A.begin(), A.end());
    cout << A << S << B << endl ;
  }
  //cout << A << endl << B << endl << S <<f<<endl ;
}

Measured memory_bytes: 1088
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long int ll;

ll mod=1e9+7;
ll dp[100100][2];

int main(){
	string s; cin >> s;
	int n=s.size();
	dp[0][0]=1;
	for(int i=0;i<n;i++){
		for(int j=0;j<2;j++){
			if(dp[i][j]==0)continue;
			if(j==0&&s[i]=='0'){
				(dp[i+1][j]+=dp[i][j])%=mod;
			}
			else{
				(dp[i+1][1]+=dp[i][j])%=mod;
				(dp[i+1][j]+=dp[i][j])%=mod;
				(dp[i+1][j]+=dp[i][j])%=mod;
			}
		}
	}
	cout << (dp[n][0]+dp[n][1])%mod << endl;
}

Measured memory_bytes: 2048
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << "\n";
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << " ";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define dl double
#define wh while
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define tp tuple
#define ft first
#define sc second
#define ve vector
#define tos to_string
#define len length
#define rt return 0
#define br break
#define con continue
#define lcm(n, m) (n * m / gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define repill(i, m, n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define repll(i, n) repill(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m);i>(int)(n);i--)
#define rev(i, n) revi(i, 0, n)
#define revill(i, m, n) for(ll i=(ll)(m);i>(ll)(n);i--)
#define revll(i, n) revill(i, 0, n)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) (n.begin(), n.end())
#define sp(n) cout << fixed << setprecision(n)
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数 __builtin_popcount bitの個数

int main() {
  int A, B;
  ci(A, B);
  if(A <= 8 && B <= 8){
    co("Yay!");
  }
  else{
    co(":(");
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const int INF = 0x3f3f3f3f;
const LL mod = 1e9 + 7;
const int N = 100005;

bool check(string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return t == s;
}
int main() {
    double x;
    cin >> x;
    x /= 3;
    double ans = x * x * x;
    printf("%.12f\n", ans);
    return 0;
}


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

int main(){
    char b;
  	cin >> b;
  	switch(b){
      case 'A':
        cout << 'T';
        break;
     case 'T':
        cout << 'A';
        break;
     case 'G':
        cout << 'C';
        break;
	case 'C':
        cout << 'G';
        break;
      default:
        break;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
#define rep(i,strt,end) for(long long i = strt;i < end;i++)


int main(){
    long long x,y;
    cin >> x >> y;
    if(y%2 == 0){
        rep(i,0,x+1){
            int j = x - i;
            if((2*i)+(4*j) == y){
                cout << "Yes" << endl;
                return 0;
            }
        }   
    }
    cout << "No" << endl;
    //--------------
    return 0;
}

Measured memory_bytes: 3632
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

import numpy as np

N,M = map(int,readline().split())
A = np.array(read().split(),np.int64)

A.sort()

def test(n):
    if n >= N:
        return True
    # 左から 2n 個をペア、右から 2N - 2n 個をペア。
    # 右側がすべて M 以上ならTrue
    R = A[n+n:]
    return np.min(R + R[::-1]) >= M

right = N # True
left = -1
while left + 1 < right:
    x = (left + right) // 2
    if test(x):
        right = x
    else:
        left = x

n = right
L = A[:n+n]
R = A[n+n:]
x = np.concatenate([L + L[::-1], R + R[::-1]])

answer = np.max(x % M)
print(answer)


Measured memory_bytes: 25052
read X

if [ $X -ge 400 -a $X -le 599 ]
then
  echo 8
elif [ $X -ge 600 -a $X -le 799 ]
then
  echo 7
elif [ $X -ge 800 -a $X -le 999 ]
then
  echo 6
elif [ $X -ge 1000 -a $X -le 1199 ]
then
  echo 5
elif [ $X -ge 1200 -a $X -le 1399 ]
then
  echo 4
elif [ $X -ge 1400 -a $X -le 1599 ]
then
  echo 3
elif [ $X -ge 1600 -a $X -le 1799 ]
then
  echo 2
elif [ $X -ge 1800 -a $X -le 1999 ]
then
  echo 1
fi


Measured memory_bytes: 3812
#include <stdio.h>
#include <cstring>
#include <math.h>
int main ()
{
	char x[7];
	scanf("%s",&x);
	int br=strlen(x),u=1,r=0;
	if(br<=2)
	{
		printf("0");
		return 0;
	}
	int a=x[br-1]-'0',b=x[br-2]-'0';
	if((a+b*10)%5!=0)
	{
		for(int i=br-3;i>=0;i--)
		{
			int c=x[i]-'0';
			r=r+c*u;
			u=u*10;
		}
		if(((a+b*10)/5)+1>r)
		{
			printf("0");
		}
		else
		{
			printf("1");
		}
	}
	else if((a+b*10)%5==0)
	{
		for(int i=br-3;i>=0;i--)
		{
			int c=x[i]-'0';
			r=r+c*u;
			u=u*10;
		}
		if(((a+b*10)/5)>r)
		{
			printf("0");
		}
		else printf("1");
	}
	return 0;
}


Measured memory_bytes: 128
import numpy as np

N = int(input())
inputs = np.array([float(i) for i in input().split()])

dp = np.array([np.array([0.0 for _ in range(N+1)]) for _ in range(N+1)])
dp[1][0] = 1 - inputs[0]
dp[1][1] = inputs[0]
for i in range(2, N+1):
    dp[i][1:] = dp[i-1][1:] * (1.0 - inputs[i-1]) + dp[i-1][:N] * inputs[i-1]
    dp[i][0] = dp[i-1][0] * (1.0 - inputs[i-1])

print(sum(dp[-1][(N+1)//2:]))


Measured memory_bytes: 153540
S = input()

nums = []

cnt = 1
pre = S[0]

for i in range(1, len(S)):
    if pre != S[i]:
        nums.append(cnt)
        pre = S[i]
        cnt = 1
    else:
        cnt += 1

nums.append(cnt)

def cal_sum(n):
    return n * (n + 1) // 2


if S[0] == '>':
    nums = [0] + nums
if S[-1] == '<':
    nums = nums + [0]

ans = 0
for i in range(len(nums) // 2):
    max_ = max(nums[2 * i], nums[2 * i+1])
    min_ = min(nums[2 * i], nums[2 * i+1])
    ans += cal_sum(max_)
    ans += cal_sum(min_ - 1)

print(ans)


Measured memory_bytes: 8220
#include<bits/stdc++.h>
using namespace std;
typedef       long long int      ll;
#define       READ               freopen("in.txt", "r", stdin);
#define       WRITE              freopen("out.txt", "w", stdout);
#define       optimize           ios::sync_with_stdio(0);cin.tie(0);
#define       RESET(a, b)        memset(a, b, sizeof(a))
#define       gcd(a, b)          __gcd(a, b)
#define       MX                 300005
#define       MOD               1000000007
inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p & 1LL) r = modMul(r, b); b = modMul(b, b); p >>= 1LL; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }
bool cmp(ll x,ll y)
{
   return x>y;
}
int main(void)
{
   ll x,y;
   vector<ll> r,c,rmx,cmx;
   set< pair<ll,ll> > st;
   ll h,w,m,ans=0;
      cin>>h>>w>>m;
      for(ll i=0;i<m;i++)
      {
         cin>>x>>y;
         st.insert(make_pair(x,y));
         r.push_back(x);
         c.push_back(y);
      }
      sort(r.begin(),r.end());
      sort(c.begin(),c.end());
      ll cnt=1,mxr=0;
      for(ll i=1;i<m;i++)
      {
         if(r[i]==r[i-1])
            cnt++;
         else
         {
            if(cnt>mxr)
               mxr=cnt;
            cnt=1;
         }
      }
      if(cnt>mxr)
         mxr=cnt;
      cnt=1;
      ll mxc=0;
      for(ll i=1;i<m;i++)
      {
         if(c[i]==c[i-1])
            cnt++;
         else
         {
            if(cnt>mxc)
               mxc=cnt;
            cnt=1;
         }
      }
      if(cnt>mxc)
         mxc=cnt;
      cnt=1;
      //cout<<mxr+mxc<<endl;
      for(ll i=1;i<m;i++)
      {
         if(r[i]==r[i-1])
            cnt++;
         else
         {
            if(cnt==mxr)
               rmx.push_back(r[i-1]);
            cnt=1;
         }
      }
      if(cnt==mxr)
         rmx.push_back(r[m-1]);
      cnt=1;
      for(ll i=1;i<m;i++)
      {
         if(c[i]==c[i-1])
            cnt++;
         else
         {
            if(cnt==mxc)
               cmx.push_back(c[i-1]);
            cnt=1;
         }
      }
      if(cnt==mxc)
         cmx.push_back(c[m-1]);
      cnt=1;
      //cout<<rmx.size()<<" "<<cmx.size();
      ll in=0;
      for(ll i=0;i<rmx.size();i++)
      {
         for(ll j=0;j<cmx.size();j++)
         {
            if(st.find(make_pair(rmx[i],cmx[j]))==st.end())
            {
               in=1;
               break;
            }
         }
      }
      if(in)
         cout<<mxr+mxc<<endl;
      else
         cout<<mxr+mxc-1<<endl;
      //cout<<ans<<endl;
   return 0;
}


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

long long fxor(long long n){
  long long ans=0;
  if((n/2)%2==0 && n%2==0){
    ans=n;
  }
  else if((n/2)%2==0 && n%2==1){
    ans=n^(n-1);
  }
  else if((n/2)%2==1 && n%2==0){
    ans=n^1;
  }
  else{
    ans=0;
  }
  return ans;
}
    

int main(){
  long long A,B;
  cin>>A>>B;
  long long res;
  res=(fxor(A-1))^(fxor(B));
  //cout<<fxor(A-1)<<" "<<fxor(B)<<endl;
  cout<<res<<endl;
  
  return 0;
}



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

using namespace std;

int main() {
  int n;
  cin >> n;
  unordered_map<string, int> m;
  for (int i = 0; i < n; ++i) {
    string s;
    cin >> s;
    m[s]++;
  }

  cout << "AC x " << m["AC"] << endl;
  cout << "WA x " << m["WA"] << endl;
  cout << "TLE x " << m["TLE"] << endl;
  cout << "RE x " << m["RE"] << endl; 
}

Measured memory_bytes: 3584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>

using namespace std;

static int x,y;
vector<vector<int> > trap;
vector<vector<int> > table;

void solve (){
//  cout<<"entered solve",printf(" x:%d,y:%d\n",x,y);
  for(int ix=1;ix<=x;ix++){
 //   cout<<" enter first for";
    for(int iy=1;iy<=y;iy++){
      if(trap[ix][iy]==1) continue;
      if(ix==1&&iy==1) continue;
  //    printf(" ix:%d,iy:%d\n",ix,iy);

   //   printf("table[%d][%d]=table[%d][%d]+table[%d][%d] ",ix,iy,ix-1,iy,ix,iy-1);
      table[ix][iy]=table[ix-1][iy]+table[ix][iy-1];
      //table[ix*(y+1)+iy]=table[ix*(y)+iy]+table[ix*(y+1)+iy-1];
    }
  }

}
int main(void){
  while(cin>>x>>y,x&&y){
    int n;
    cin>>n;
  
    trap.clear();
    trap.resize(x+1, vector<int>(y+1,0));
    //int trap[x+1][y+1];
    //memset(trap,0,sizeof(trap));
    int tx,ty;
    for(int i=0;i<n;i++){
      cin>>tx>>ty;
      trap[tx][ty]=1;
    }

    //int table[x+1][y+1];
    //memset(table,0,sizeof(table));
    table.clear();
    table.resize(x+1,vector<int>(y+1,0));
    table[1][1]=1;

    //cout<<"before solve\n";
    solve();
    cout<<table[x][y]<<endl;

  }
  return 0;
}


/*import java.util.*;

  class Aoj0515{
  static int x,y;
  static public void main(String args[]){
  Scanner scan=new Scanner(System.in);
  while(scan.hasNext()){
  x=scan.nextInt();
  y=scan.nextInt();
  if(x==0&&y==0)
  return;
  int n;
  n=scan.nextInt();
  int trap[][]=new int [x+2][y+2];
  int tmpx,tmpy;
  for(int i=0;i<n;i++){
  tmpx=scan.nextInt();
  tmpy=scan.nextInt();
  trap[tmpx][tmpy]=1;
  }

  int table[][]=new int [x+2][y+2];
  table[1][1]=1;
  solve(trap,table);
//      print(table);
System.out.println(table[x][y]);
}
return;
}
static public void print(int table[][]){
for(int iy=1;iy<=y;iy++){
for(int ix=1;ix<=x;ix++){
System.out.printf("%d ",table[ix][iy]);
}
System.out.println();
}
}
static public void solve(int trap[][],int table[][]){

//    System.out.println("table[1][1]="+table[1][1]);

for(int ix=1;ix<=x;ix++){
int iy=1;
for(;iy<=y;iy++){
if(trap[ix][iy]==1) continue;
if(ix==1&&iy==1) continue;
if(trap[ix][iy]==1) continue;
//        System.out.printf("table[%d][%d]=table[%d][%d]+table[%d][%d] ",ix,iy,ix-1,iy,ix,iy-1);
table[ix][iy]=table[ix-1][iy]+table[ix][iy-1];
//       System.out.printf("[%d]=[%d]+[%d]\n",table[ix][iy],table[ix-1][iy],table[ix][iy-1]);
}
}
}
static public void solve(int a,int j,int trap[][]){
if(a==x && j==y){
res++;
return;
}
if(a<x) 
if(trap[a+1][j]!=1)
solve(a+1,j,trap);
if(j<y)
if(trap[a][j+1]!=1)
solve(a,j+1,trap);
}
}
 */


Measured memory_bytes: 3056
#include <stdio.h>
int main(void){
    
    int a, b, c;
    int i;
    
    scanf("%d %d %d", &a ,&b, &c);

    
    for(i = 0; i<c; i++){
        if(b-a>=0) b-=a;
        else break;
    }
    
    printf("%d", i);
}

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

int main(){
  int data[4]={};
  int sum =0;
  
  for(int i =0;i < 4;i++)
    {
      cin >> data[i];
      sum += data[i];
    }

  cout << sum/60 << endl;
  cout << sum%60 << endl;
}



Measured memory_bytes: 3100
#include <iostream>
#include <algorithm>

using namespace std;

int main(){
        int A,B,AB,X,Y;
        cin >> A >> B >> AB >> X >> Y;
        int AaB,ABaA,ABaB;

        if(X > Y) {
                swap(A,B);
                swap(X,Y);
        }
        if(X <= Y) {
                AaB = A*X + B*Y;
                ABaA = 2*AB*Y;
                ABaB = 2*AB*X + (Y-X)* B;
        }
        cout << min(min(AaB,ABaA),ABaB) << endl;

        return 0;
}

Measured memory_bytes: 256
public class Main {
    private static java.util.Scanner scanner = new java.util.Scanner(System.in);

    public static void main(String[] args) {
        long count = 0, ans = 0;
        for (char c : scanner.next().toCharArray())
            if (c == 'B') count++;
            else ans += count;
        System.out.println(ans);
    }
}

Measured memory_bytes: 26424
import bisect,collections,copy,heapq,itertools,math,numpy,string
import sys
sys.setrecursionlimit(10**7)
 
def _S(): return sys.stdin.readline().rstrip()
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
 
def main():
    A = [LI() for _ in range(3)]
    N = I()
    B = [I() for _ in range(N)]
    # print(B) 
    
    for i in range(3):
        for j in range(3):
            for k in range(N):
                if A[i][j]== B[k]:
                    A[i][j] = 0
                    break
    
    ans = 'No'
    for i in range(3):
            if (A[i][0]==0 and A[i][1]==0 and A[i][2]==0) or (A[0][i]==0 and A[1][i]==0 and A[2][i]==0):
              ans = 'Yes'
              break  
    if (A[0][2]==0 and A[1][1]==0 and A[2][0]==0) or (A[0][0]==0 and A[1][1]==0 and A[2][2]==0):
        ans = 'Yes'
    print(ans)
main()

Measured memory_bytes: 27212
#include <bits/stdc++.h>
using namespace std;
#define rep(i,c) for(int i=0;i<c;++i)
int main(){
 int a,b;
 cin >> a>>b;
 if(a>8||b>8){
     cout << ":("<<endl;
 }else{
     cout << "Yay!"<<endl;
 }
 return 0;
}

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

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int n, m;
    cin >> n >> m;
    vector< vector<bool> > a(n, vector<bool>(m, false));
    for (int i = 0; i < n; ++i)
    {
        int k;
        cin >> k;
        for (int j = 0; j < k; ++j)
        {
            int x;
            cin >> x;
            a[i][x - 1] = true;
        }
    }
    int odp = 0;
    for (int i = 0; i < m; ++i)
    {
        bool ok = true;
        for (int j = 0; j < n; ++j)
            if (!a[j][i])
                ok = false;
        if (ok)
            ++odp;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define FAST ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
 
#define MAXX 100005
 
#define PI   3.14159265358979323846264338327950

#define PB push_back 
#define F first
#define S second
 
#define ll 	 long long int

#define mod  1000000007




int main()
{
	FAST;
	ll a, b;
	cin >> a >> b;
	if(a <= 8 && b <= 8){
		cout << "Yay!";
	}
	else{
		cout << ":(";
	}
	return 0;
}

Measured memory_bytes: 3604
#include <algorithm>
#include <iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n, m;
    cin >> n >> m;
    ll a[100005];
    for(int i = 0; i < n; i++) cin >> a[i];
    sort(a, a + n);
    ll s[100005]{0};
    for(int i = 1; i <= n; i++) s[i] = s[i - 1] + a[i - 1];
    ll left = 0;
    ll right = 1e18 + 7;
    while(right - left > 1){
        ll mid = (right + left) / 2;
        ll t = 0;
        for(int i = 0; i < n; i++){
            t += lower_bound(a, a + n, mid - a[i]) - a;
        }
        if(t >= n * n - m) right = mid;
        else left = mid;
    }
    ll ans = s[n] * n * 2;
    ll t = 0;
    for(int i = 0; i < n; i++){
        ll u = lower_bound(a, a + n, right - a[i]) - a;
        ans -= s[u] + a[i] * u;
        t += u;
    }
    ans += left * (t - (n * n - m));
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include<algorithm>
#include<vector>
using namespace std;
int main(void){
    // Your code here!
int n,l;
cin>>n>>l;
vector<string> vec(n);
for(int i=0;i<n;i++){
    cin>>vec[i];
}
sort(vec.begin(),vec.end());

string ans;
for(int i=0;i<n;i++)
ans+=vec[i];

cout<<ans;
}


Measured memory_bytes: 3136
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<ctype.h>
#include<cmath>
#include<iomanip>
using namespace std;

int main(void){
	double a,c,d,e,f,dod,ret[1001],w;
	while(1){
	cin>>f;
	if(f==0){
		break;
	}
	for(int b=0;f>b;b++){
		cin>>a;
		ret[b]=a;
		c+=a;
	}
	d=c/f;
	//printf("%.8lf\n",d);
	c=0;
	for(int b=0;f>b;b++){
		e=ret[b]-d;
		dod+=e*e;
		//printf("e=%.8lf\n dod=%.8lf\n",e,dod);
		e=0;
	}
	dod=dod/f;
	printf("%.8lf\n",sqrt(dod));
	dod=0;
	}
	return 0;
}



Measured memory_bytes: 3212
#include <bits/stdc++.h>
using namespace std;
struct P
{
    //string r;
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};

vector<int> v[5555];
//bitset<4001000> b;
int a,c,i,b,k,d,n,m,e;//dy[15]={0,1,0,-1,-1,1,-1,1},dx[15]={1,0,-1,0,1,1,-1,-1};//
int l[5555];
int o[5400];
int dx[10]={0,1,0,-1},dy[10]={1,0,-1,0},dz[10]={0,0,0,0,1,-1};

long long x,y,z,mod=1000000007;
P u[1111];
double j[111];

stack<int> s;
queue<int> q;
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
map<int,int > p;
//list<int> l;
string r;
//char r[333][333];


bool as(P a,P b)
{
    if(a.x!=b.x) return a.x<b.x;
    return a.y>b.y;
}

int f()
{
    o[1]=1;
        q.push(1);
        for(;q.size();q.pop())
        for(int h=0;h<v[q.front()].size();h++)
        if(!o[v[q.front()][h]])
        {
            o[v[q.front()][h]]=o[q.front()]+1;
            q.push(v[q.front()][h]);
        }
        i=0;
        for(int t=1;t<a;t++)
            for(int w=t+1;w<=a;w++)
            i=max(i,o[t]+o[w]-2);
        return i;
}

int main()
{
    scanf("%d",&a);
    cin>>r;
    scanf("%d",&b);
    if(r[0]=='+') printf("%d",a+b);
    else printf("%d",a-b);
}


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

using namespace std;

int main() {
  int n, k;
  cin >> n >> k;
  int f = 0;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a == 1) f = i + 1;
  }
  int l = 0, r = 0;
  if (f != 1) {
    if (n <= k)
      l = 1;
    else {
      int c = (f - k) / (k - 1);
      if ((f - k) % (k - 1)) c++;
      l = max(1, 1 + c);
    }
  }
  if (f != n) {
    if ((n - f - 1) <= k)
      r = 1;
    else {
      int c = (n - f - k + 1) / (k - 1);
      if ((n - f - k + 1) % (k - 1)) c++;
      r = max(1, 1 + c);
    }
  }
  int ans = (n - 1) / (k - 1);
  if ((n - 1) % (k - 1)) ans += 1;
  cout << ans << endl;
}

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

 using namespace std;

 int main() {
	int num;
	int x,y,z;
	 int answer;
	
	 cin >> num;
	
	 for(int i = 1; i <= num; i++){
		cin >> x >> y >> z;
		 if(x<y)
			 swap(x,y);
		 if(x<z)
			 swap(x,z);
		 if(y<z)
			 swap(y,z);
		
		 if((y*y + z*z)==x*x)
			 cout <<"YES"<<endl;
		 else
			cout << "NO" << endl;
	 }
	
	 return 0;
 }

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i,n) for(i=0;i<(n);++i)
#define FOR(i,l,h) for(i=(l);i<=(h);++i)
#define FORD(i,h,l) for(i=(h);i>=(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a
using namespace std;
const int mod = 1e9 +7 ;
char ch[1007][1007];
 int H,W;


int dp[1007][1007];
int main(){
    ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
    cout.tie(NULL);
    cin>>H>>W;
    memset(dp,0,sizeof(dp));
    for(int i=0;i<H;i++){
        cin>>ch[i];
    }
   
    dp[0][0] = 1;
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(ch[i][j] == '.'){
                if(i-1>=0) dp[i][j] = (dp[i-1][j]+dp[i][j])%mod;
                if(j-1>=0) dp[i][j] = (dp[i][j-1]+dp[i][j]) % mod;
            }
         //   cout<<dp[i][j]<<" ";
        }
       // cout<<"\n";
    }
    cout<<dp[H-1][W-1];
    return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
#include <climits>
#include <tuple>
#include <queue>
//#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
 

vector<int> m,M,br; 

int MOD = 1e9 + 7;
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0); 
	ll R,C,K;
	cin >> R>>C>>K;
	vector<vector<vector<ll> > > dp(R + 1, vector<vector<ll>>(C + 1 , vector<ll>(4,0) ) );
	ll a, b, v;
	vector<vector<ll> > val(R, vector<ll>(C, 0 ));

	for (int i = 0; i < K; i++){
		cin >> a>> b>>v;
		a--;
		b--;
		val[a][b] = v;
	}
	// for (int i = 0; i < R; i++){
	// 	for (int j = 0; j < C; j++){
	// 		cout << val[i][j]<<" ";
	// 	}
	// 	cout <<endl;
	// }


	// 	for (int i = 1; i <= R; i++){
	// 	for (int j = 1; j <= C; j++){
	// 		cout << dp[i][j][0]<< " ";
	// 	}
	// 	cout << endl;
	// }
	ll mm = 0;
	for (int i = 1; i <= R; i++){
		for (int j = 1; j <= C; j++){
		

			dp[i][j][3] = max({dp[i][j - 1][3], val[i -1][j - 1] + dp[i][j -1 ][2]}); 
			dp[i][j][2] = max({dp[i][j - 1][2], val[i - 1][j - 1] + dp[i][j -1][1]}); 
			dp[i][j][0] = max({dp[i - 1][j][0],dp[i - 1][j][1],dp[i - 1][j][2],dp[i - 1][j][3] });


			dp[i][j][1] = max({dp[i][j - 1][1], val[i -1][j - 1] + dp[i][j - 1][0], dp[i][j][0] + val[i -1][j- 1]});


		


		//	dp[i][j][1] = max({dp[i][j - 1][1], val[i -1][j - 1] + dp[i][j][0]}); 
		//	dp[i][j][2] = max({dp[i][j - 1][2], val[i - 1][j - 1] + dp[i][j][1]}); 
		//	dp[i][j][3] = max({dp[i][j - 1][3], val[i -1][j - 1] + dp[i][j][2]}); 
		}
	}

	// for (int i = 1; i <= R; i++){
	// 	for (int j = 1; j <= C; j++){
	// 		cout << dp[i][j][0]<< " ";
	// 	}
	// 	cout << endl;
	// }
	// for (int i = 1; i <= R; i++){
	// 	for (int j = 1; j <= C; j++){
	// 		cout << dp[i][j][1]<< " ";
	// 	}
	// 	cout << endl;
	// }
	// for (int i = 1; i <= R; i++){
	// 	for (int j = 1; j <= C; j++){
	// 		cout << dp[i][j][2]<< " ";
	// 	}
	// 	cout << endl;
	// }

	// for (int i = 1; i <= R; i++){
	// 	for (int j = 1; j <= C; j++){
	// 		cout << dp[i][j][3]<< " ";
	// 	}
	// 	cout << endl;
	// }



	cout << max({dp[R][C][0],dp[R][C][1],dp[R][C][2],dp[R][C][3]})<< endl;
    return 0;
} 

Measured memory_bytes: 706584
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  int N, M;
  int i, j, WA = 0, AC = 0,w = 0;
  
  cin >> N >> M;
  
  vector<vector<int>> A(N);
  for (i = 0; i < M; i++) {
    int a;
    string str;
    cin >> a >> str;
    
    if(str == "WA")
      A.at(a-1).push_back(0);
    else if(str == "AC")
      A.at(a-1).push_back(1);
  }


  
  for(i = 0; i < N; i++){
    w = 0;
    for(j = 0; j < A.at(i).size(); j++){
      if(A.at(i).at(j) == 1){
        AC++;
        j = A.at(i).size();
      }
      else if(A.at(i).at(j) == 0){
        w++;
      }
      if(j == A.at(i).size())
        WA += w;
    }
  }
  
  
  cout << AC << " " << WA << endl;
 
  
}



Measured memory_bytes: 5760
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
bool sob(P x1,P x2){return x1.second> x2.second;};
int main(){
	ll n,l,u;
	cin >> n;
	vector <ll>o,e;
	bool fl=true;
	vector <pair<ll,ll>> os,es;
	for(ll i=0;i<n;i++){
    if(i%2==0) {
			cin >> l;o.push_back(l);
			if(i==0) u=l;
		}
		else {
			cin >> l; e.push_back(l);
		}
		if(l!=u) fl=false;
	}
	if(fl){
		cout << n/2<<endl;
		return 0;
	}
	sort(o.begin(),o.end());sort(e.begin(),e.end());
	l=o[0];ll cnt=1;
	for(ll i=0;i<n/2;i++){
		if(i==(n/2)-1) {
			if(cnt==0) cnt++;
			os.push_back(make_pair(l,cnt));break;
		}
     if(l==o[i+1]) cnt++;
		 if(l!=o[i+1]){
			 os.push_back(make_pair(l,cnt));cnt=1;
				 l=o[i+1];
				 if(i==(n/2)-1){
 	 			 os.push_back(make_pair(l,1));break;
 	 		 }
		 }
	}
	l=e[0];cnt=1;
	for(ll i=0;i<n/2;i++){
		if(i==(n/2)-1) {
			if(cnt==0) cnt++;
			es.push_back(make_pair(l,cnt));break;
		}
     if(l==e[i+1]) cnt++;
		 if(l!=e[i+1]){
			 es.push_back(make_pair(l,cnt));cnt=1;
				 l=e[i+1];
				 if(i==(n/2)-1){
 	 			 es.push_back(make_pair(l,1));break;
 	 		 }
		 }
	}
	sort(es.begin(),es.end(),sob);
	sort(os.begin(),os.end(),sob);
	ll ans,m;
	if(es[0].first==os[0].first){
      ans=n-es[1].second-os[0].second;
			m=n-es[0].second-os[1].second;
			cout << min(ans,m)<<endl;
	}
  else{
    ans=n-es[0].second-os[0].second;
		cout <<ans<<endl;
	}
}


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

int main() {
    int N, K; cin >> N >> K;
    ll ans = 0;
    for (int b = K+1; b <= N; b++){
        int x = (N-1)/b + 1;
        ans += x * (b-K);
        int a;
        if(K != 0){
            a = min(b*x-1-N, b-K);
            a = max(a, 0);
        } else {
            a = min(b*x-N, b-K);
            a = max(a, 0);
        }
        ans -= a;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3604
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  map<char,ll> cnt;
  for (int i = 0; i < N; i++) {
    string s;
    cin >> s;
    cnt[s[0]]++;
  }

  char march[] = {'M', 'A', 'R', 'C', 'H'};
  ll ans = 0;
  for (int i = 0; i < 5; i++) {
    for (int j = i + 1; j < 5; j++) {
      for (int k = j + 1; k < 5; k++) {
        ans += cnt[march[i]] * cnt[march[j]] * cnt[march[k]];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
dic = {}
mod = 10**9+7

if n%2==0:
    for i in a:
        if i%2==0:
            print(0)
            exit()
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

    for k, v in dic.items():
        if v != 2:
            print(0)
            exit()
    print(2**(n//2)%mod)

else:
    for i in a:
        if i%2==1:
            print(0)
            exit()
        if i in dic:
            dic[i] += 1
        else:
            dic[i] = 1

    for k, v in dic.items():
        if v != 2 and k != 0:
            print(0)
            exit()
    print(2**(n//2)%mod)

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

int main()
{
	int n, x[100], y[100];
	cin >> n;
	for (int i = 0; i < n; i++)cin >> x[i];
	for (int i = 0; i < n; i++)cin >> y[i];

	double d[4] = {0.0};
	
	for (int p = 1; p <= 3; p++) {
		for (int i = 0; i < n; i++) {
			d[p] += pow(fabs(x[i] - y[i]), p);

		}
		d[p] = pow(d[p], 1.0 / p);
	}

	for (int i = 0; i < n; i++) {
		d[0] = (d[0] < fabs(x[i] - y[i]) ? fabs(x[i] - y[i]) : d[0]);
	}

	printf("%lf\n", d[1]);
	printf("%lf\n", d[2]);
	printf("%lf\n", d[3]);
	printf("%lf\n", d[0]);

    return 0;
}

Measured memory_bytes: 3356
#include <iostream>
using namespace std;
int main(){
    int n;
    int a, b, c, d, e;

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

        int max = -1, min = 1000;
        for(int i = 0; i < n; i++){
            cin >> a >> b >> c >> d >> e;
            int sum = a + b + c + d + e;
            if(sum > max) max = sum;
            if(sum < min) min = sum;
        }
        cout << max << " " << min << endl;
    }
}



Measured memory_bytes: 3108
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <iomanip>
#include <map>
#include <bitset>
#include <cstdio>
#include <set>
#include <stack>
#include <queue>
#include <cassert>
#include <numeric>
//#include <bits/stdc++.h>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<vector<int>>
#define mii map<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())
#define ALL(a)  (a).begin(),(a).end()
#define pb push_back
//#define int ll
typedef long long ll;

const int md = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

 

ll judge(ll x,ll y){
    ll cnt = 0;
    while(x%y == 0){
        cnt++;
        x /= y;
    }
    
    return cnt;
}

int main(){
    ll n,p;
    cin >> n >> p;

    ll ans = 1;
    for(ll i = 2 ; i*i <= p ; i++){
        ll check = judge(p,i);
        if(check >= n){
            ans = i;
        }
    }
    
    cout << (n == 1 ? p : ans) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(void)
{
	char str1[11], str2[11], str3[11];
	int len1, len2, len3;

	scanf("%s %s %s", str1, str2, str3);
	len1 = strlen(str1);
	len2 = strlen(str2);
	len3 = strlen(str3);
	if (str1[len1-1]==str2[0] && str2[len2-1]==str3[0])
	{
		printf("YES\n");
	}
	else
	{
		printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <iterator>
#pragma warning(disable:4996)

typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    char str[5]={0};
    scanf("%s", str);
    
    long count=0;
    long i;
    for(i=0; i<3; i++) {
        if(str[i]=='o') count++;
    }
    printf("%ld\n", count*100+700);

    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(void){
  
  int i = 0, j = 0;
  char s[101], t[201];
  
  scanf("%s %s",s,t);
  
  while(t[i] != '\0'){
    i++;
  }
  while(s[j] != '\0'){
    t[i] = s[j];
    i++;
    j++;
  }
  
  t[i] = '\0';
  
  printf("%s\n", t);
  
  return 0;
}

Measured memory_bytes: 128
N, L = map(int, input().split())
sum = 0
flag0 = False
notallminus = False
for i in range(L, N+L):
    sum += i
    if i == 0:
        flag0 = True
    elif i > 0:
        notallminus = True
    else:
        pass

if flag0 is True and notallminus is True:
    print(sum)
elif flag0 is False and notallminus is True:
    print(sum - L)
else:
    print(sum - (N+L-1))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,s;
	cin>>n>>s;
	/*
		nのb進表記が1桁：b>n
		nのb進表記が2桁：n>=b>√n
		nのb進表記がd桁：(d-1)√n>=b>d√n
	*/
	if(n==s){
		cout<<n+1<<endl;
		return 0;
	}
	if(n<s){
		cout<<-1<<endl;
		return 0;
	}
	//小さいbから全探索
	for(ll b=2;b*b<=n;b++){
		ll f=0,t=n;
		while(t){
			f+=t%b;
			t/=b;
		}
		if(f==s){
			cout<<b<<endl;
			return 0;
		}
	}
	/*
		b>√nなら、nは2桁以下
		x*b+y==n
		x+y==sより
		b-1==(n-s)/x, b==(n-s)/x+1  x<b -> x<√n
	*/
	for(ll x=(ll)ceil(sqrt(n))-1;x>0;x--){
		ll b=(n-s)/x+1;
		ll d=n%b+n/b;
		if(d==s){
			cout<<b<<endl;
			return 0;
		}
	}
	cout<<-1<<endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import*
i=input
def f(x):
 x.sort();s,n,*h=0,len(x)
 while n:
  n-=1
  while x and x[-1][0]>n:k,l,r=x.pop();heappush(h,(r-l,l,r))
  if h:s+=heappop(h)[1]
 return s+sum(r for*_,r in x+h)
for _ in'_'*int(i()):
 n,x,*y=int(i()),[]
 for _ in'_'*n:
  k,l,r=map(int,i().split())
  if l>r:x+=(k,l,r),
  else:y+=(n-k,r,l),
 print(f(x)+f(y))

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

int main(){
    long long x, k, d;
    cin >> x >> k >> d;
    x = abs(x);
    long long cnt = min(x / d, k);
    x -= cnt * d; k -= cnt;
    x -= (k & 1 ? d : 0);
    cout << abs(x) << endl;
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl;
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 1000000007;
double pi = 3.1415926535;
void Debug(auto a);
int nibul(auto a,auto b);
int nibuu(auto a,auto b);
void input(vector<int>& a,int n);

int n;

signed main(){
    int m;
    string s;
    cin >> n >> m >> s;
    int cnt = 0;
    REP(i,n+1){
        if(s[i] == '1'){
            cnt++;
        }
        else{
            if(cnt>=m){
                print(-1);
                return 0;
            }
            cnt = 0;
        }
    }
    if(cnt>=m){
        print(-1);
        return 0;
    }
    cnt = n;
    vector<int> a;
    while(1){
        cnt -= m;
        int mov = m;
        if(cnt<=0){
            a.push_back(m+cnt);
            //cout << m+cnt << endl;
            break;
        }
        while(s[cnt] == '1'){
            cnt++;
            mov--;
        }
        a.push_back(mov);
        //cout << mov << " ";
    }
    Reverse(a);
    REP(i,a.size()){
        cout << a[i] << " ";
    }
    
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}
int nibul(auto a,auto b){
    int x = lower_bound(All(a),b) - a.begin();
    //key以上の初めてのitr
    return x;
}
int nibuu(auto a,auto b){
    int x = upper_bound(All(a),b) - a.begin();
    //key以下の最後のitr
    return x-1;
}

void input(vector<int>& a,int n){
    REP(i,n){
        cin >> a[i];
    }
}


Measured memory_bytes: 1528