akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>

using namespace std;

int main() {
    string s;   cin >> s;
    bool p = (s[0] == 'R');
    bool q = (s[1] == 'R');
    bool r = (s[2] == 'R');

    if (p && q && r)
        cout << 3 << endl;
    else if ((p && q) || (q && r))
        cout << 2 << endl;
    else if (p || q || r)
        cout << 1 << endl;
    else
        cout << 0 << endl;

    return 0;
}

Measured memory_bytes: 3608
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define FOR(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll INF = 1LL<<60;
const ll mod = 1e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = ll> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%mod; }a = a * a%mod; b >>= 1LL; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1LL; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%mod; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], mod - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % mod)*inv[n - r] % mod; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1LL); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

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

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int n;
	cin >> n;
	int a[n];
	int cnt = 0;
	int minmin = INF;
	int sum = 0;
	REP (i,n) {
		cin >> a[i];
		sum += abs(a[i]);
		if (a[i] < 0) {
			cnt++;
		}
		minmin = min(minmin,abs(a[i]));
	}
	if (cnt %2 == 1) {sum -= 2 * abs(minmin);}
	cout << sum << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
	string S;
	cin >> S;
	char a, b;
	a = S[0];;
	if (S[1] != a) {
		b = S[1];
	}
	else {
		b = S[2];
	}
	int A = 0;
	int B = 0;
	for (int i = 0; i < S.length(); i++) {
		if (S[i] == a) {
			A++;
		}
		else if (S[i] == b) {
			B++;
		}
	}
	if (A == 2 && B == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
# 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()))

MOD = 998244353

def cmb(k):
    if k < 0 or k > N-1: return 0
    return factN * fact_inv[k] % MOD * fact_inv[N-1-k] % MOD

def cumprod(arr, MOD):
    L = len(arr); Lsq = int(L**.5+1)
    arr = np.resize(arr, Lsq**2).reshape(Lsq, Lsq)
    for n in range(1, Lsq):
        arr[:, n] *= arr[:, n-1]; arr[:, n] %= MOD
    for n in range(1, Lsq):
        arr[n] *= arr[n-1, -1]; arr[n] %= MOD
    return arr.ravel()[:L]

def make_fact(U, MOD):
    x = np.arange(U, dtype=np.int64); x[0] = 1
    fact = cumprod(x, MOD)
    x = np.arange(U, 0, -1, dtype=np.int64); x[0] = pow(int(fact[-1]), MOD-2, MOD)
    fact_inv = cumprod(x, MOD)[::-1]
    return fact, fact_inv

U = 10 ** 6  # 階乗テーブルの上限
fact, fact_inv = make_fact(U, MOD)

# 左からDP
N, M, K = lr()
factN = fact[N-1]
answer = 0
for i in range(K+1):
    answer += cmb(i) * pow((M-1), N-1-i, MOD) % MOD
    answer %= MOD

print(answer * M % MOD)

Measured memory_bytes: 66080
#define _USE_MATH_DEFINES

#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
/////////

typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;

////定数
const int INF = (int)1e9 + 10;
const LL MOD = (LL)1e9 + 7;
const LL LINF = (LL)4e18 + 20;
const LD PI = acos(-1.0);
const double EPS = 1e-9; 
/////////
using namespace::std;
template<typename T>
void chmax(T& a, T b) {
	a = max(a, b);
}

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

template<typename T>
void IN(vector<T> &A,int N=-1) {
	if (N == -1) {
		N = A.size();
	}
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
}

template<typename T>
void SO(vector<T> &A,bool F=false) {
	sort(A.begin(), A.end());
	if (F) {
		reverse(A.begin(), A.end());
	}
}
//////////////
LL f(vector<LL> A) {
	LL ans = abs(A[0]) + abs(A[1]) + abs(A[2]);
	return ans;
}

LL fn(vector<LL> A,int K) {
	LL ans = 0;
	for (int  k= 0; k < 3; ++k) {
		if (K & (1 << k)) {
			ans -= A[k];
		}
		else {
			ans += A[k];
		}
	}
	
	return ans;
}
vector<LL> V(vector<LL>& A, vector<LL>& B) {
	vector<LL> ans(3);
	for (int i = 0; i < 3; ++i) {
		ans[i] = A[i] + B[i];
	}
	return ans;
}
void solve() {
	int N, M;
	cin >> N >> M;
	vector<vector<LL>> X(N,vector<LL>(3));
	for (int i = 0; i < N; ++i) {
		cin >> X[i][0] >> X[i][1] >> X[i][2];
	}
	///N個中M個食べる。
	//合計の絶対値
	vector<LL> AAA = { LINF,LINF,LINF };
	vector<vector<vector<vector<LL>>>> dp(N+1,
		vector<vector<vector<LL>>>(M+1, vector<vector<LL>>(8,
			vector<LL>(AAA))));
	for (int k = 0; k < (1 << 3); ++k) {
		dp[0][0][k] = { 0,0,0 };
	}
	
	for (int i = 0; i <N; ++i) {
		for (int m = 0; m < M; ++m) {
			for (int k = 0; k < (1 << 3); ++k) {
				if (dp[i][m][k] == AAA) continue;
				//使わない
				if (dp[i + 1][m][k] == AAA) {
					dp[i + 1][m][k] = dp[i][m][k];
				}
				else if (fn(dp[i + 1][m][k],k) < fn(dp[i][m][k],k) ){
					dp[i+1][m][k] = dp[i][m][k];
				}

				//使う
				vector<LL> temp;
				temp = V(dp[i][m][k], X[i]);
				if (dp[i + 1][m + 1][k] == AAA) {
					dp[i + 1][m + 1][k] = temp;
				}
				else if (fn(dp[i+1][m+1][k], k) < fn(temp, k)) {
					dp[i + 1][m + 1][k] = temp;
				}
				
			}
		}
	}
	//f
	LL ans = 0;
	for (int i = 0; i <= N; ++i) {
		for (int k = 0; k < (1 << 3); ++k) {
			if (dp[i][M][k] != AAA) {
				chmax(ans, f(dp[i][M][k]));
			}
		}
	}
	cout << ans << endl;
}

signed main(void) {
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}


Measured memory_bytes: 478336
"""
n = int(sys.stdin.readline())
a, b = map(int, sys.stdin.readline().split())
c = list(map(int, sys.stdin.readline().split()))
s = [list(map(int,list(sys.stdin.readline()))) for i in range(h)]  # 二次元配列入力　二次元マップみたいな入力のとき

a = 100
b = 0.987654321
print('{0:06d}-{1:6f}'.format(a,b))  # 0埋め, 小数点出力桁指定時のときの出力
000100-0.987654

# 文字列をリストに格納
char_list = list("abcd") # ["a","b","c","d"]
"""

import math
import sys
import itertools
import queue
from fractions import gcd

def lcm(a, b):
    return a * b // gcd(a, b)


mod = 1000000007

if __name__ == "__main__":
    H, W = map(int, sys.stdin.readline().split())
    h, w = map(int, sys.stdin.readline().split())
    print(H * W - (h * W + w * H - h * w))

Measured memory_bytes: 5200
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

// inf
constexpr ll infl = 10000000000000000LL;
constexpr int inf = 1000000000;

int main() {
    int n;
    cin >> n;
    int cnt = 0;

    for (int i = 1; i <= n; ++i) {
        int d = 0;
        int t = i;
        while (t) {
            ++d;
            t /= 10;
        }
        if (d & 1)
            ++cnt;
    }

    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int check(int a, int b, int c){
    if(a==1&&b==1&&c==1) return 1;
    else return 0;
}

int main(){
    int A[3][3] = {};
    int bingo[3][3] = {};
    int n;
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++) cin >> A[i][j];
    }
    cin >> n;
    int b[n]={};
    for(int i=0; i<n; i++) cin >> b[i];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            for(int k=0; k<n; k++){
                if(A[i][j]==b[k]) bingo[i][j] = 1;
            }
        }
    }
    if(check(bingo[0][0],bingo[0][1],bingo[0][2])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[1][0],bingo[1][1],bingo[1][2])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[2][0],bingo[2][1],bingo[2][2])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[0][0],bingo[1][0],bingo[2][0])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[0][1],bingo[1][1],bingo[2][1])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[0][2],bingo[1][2],bingo[2][2])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[0][0],bingo[1][1],bingo[2][2])){
        cout << "Yes" << endl;
        return 0;
    }
    if(check(bingo[0][2],bingo[1][1],bingo[2][0])){
        cout << "Yes" << endl;
        return 0;
    }
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int w, h, x, y, r;
	
	scanf("%d %d %d %d %d", &w, &h, &x, &y, &r);
	
	
	if ((x >= r) && (y >= r) && (w-x >= r) && (h-y >= r)){
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}
	
	return (0);
	
}

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

int main(){
    int a,b;
    int flag=0;
    int n;
    int ans=0;

    cin >>a>>b;

    if(b<10){
        a *= 10;
    }else if(b<100){
        a *= 100;
    }else{
        a *= 1000;
    }

    if(sqrt(a+b) == (int)sqrt(a+b))flag=1;
    
    //cout << ans <<endl;
    //cout <<fixed<<setprecision(16)<< ans <<endl;

    if(flag==1)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

long long gcd(long long x, long long y) {
    if (x < y) swap(x, y);
    while (x % y != 0) {
        long long divisor = x % y;
        x = y;
        y = divisor;
    }
    return y;
}

int main() {
    int N, X;
    cin >> N >> X;
    int x[N];
    int d[N];
    for (int i = 0; i < N; i++) {
        scanf("%d", &x[i]);
        d[i] = abs(X - x[i]);
    }
    if (N == 1) {
        cout << d[0] << endl;
        return 0;
    }
    int ans = gcd(d[0], d[1]);
    for (int i = 2; i < N; i++) {
        ans = gcd(ans, d[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
# 数値になる項を入れるリストを初期化
num_list = []

# 入力の数だけ繰り返す
for i in range(1, int(input())+1):
	# 3でも5でも割り切れない数だけリストに格納
    if i % 3 != 0 and i % 5 != 0:
    	num_list.append(i)
# リスト内の数字を合計する
print(sum(num_list))

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define rrep(i, n) for (ll i = (n)-1; i >= 0; i--)

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;

    vector<ll> A(N+1), B(N+1);
    rep (i, N+1) {
        cin >> A[i];
    }
    rep (i, N) {
        cin >> B[i];
    }
    B[N] = 0;

    ll ans = 0;
    rep (i, N) {
        if (A[i] > B[i]) {
            ans += B[i];
        } else {
            ans += A[i];
            ll tmp = B[i]-A[i];
            if (tmp > A[i+1]) {
                ans += A[i+1];
                A[i+1] = 0;
            } else {
                ans += tmp;
                A[i+1] -= tmp;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define endl "\n"
#define ll long long int
#define pii pair<int,int>
#define pll pair<long long, long long>
#define mod 1000000007
#define inf 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y)
#define mem(a,val) memset(a,val,sizeof(a))
#define eb emplace_back
#define f first
#define s second
#define MAXN 1000007
#define fr(i, s, e, st) for(ll (i) = (s); (i) < (e); (i) += (st))
#define fre(i, s, e, st) for(ll (i) = (s); (i) <= (e); (i) += (st))
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cout<<fixed;cout<<setprecision(10);
 
using namespace std;

int main()
{
    fastio;
    int T = 1;
    //cin>>T;
    while(T--){
        ll n;
        cin>>n;
        ll a[n];
        fr(i, 0, n, 1) cin>>a[i];
        ll c=a[0],d=1;
        fr(i, 1, n, 1) if(c>a[i])d++,c=a[i];
        cout<<d<<endl;
    }                
    return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
const ld EPS = 1e-12L;
const ld PI = 3.1415926535897932385L;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ull x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>inline bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>inline bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vs s(n);
    vll c(5, 0);
    rep(i, n){
        cin >> s[i];
        if(s[i][0] == 'M') c[0]++;
        if(s[i][0] == 'A') c[1]++;
        if(s[i][0] == 'R') c[2]++;
        if(s[i][0] == 'C') c[3]++;
        if(s[i][0] == 'H') c[4]++;
    }
    ll ans = 0;
    rep(i, 5)repr(j, i+1, 5)repr(k, j+1, 5){
        ans += c[i] * c[j] * c[k];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5760
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#include<set>
#include<complex>
#include<map>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    string temp;
    map<string,vi>mp;
    
    while(cin>>temp){
        int n; cin>>n;
        mp[temp].push_back(n);
        sort(all(mp[temp]));
    }
    for(auto itr=mp.begin();itr!=mp.end();itr++){
        cout<<itr->first<<endl;
        rep(i,mp[itr->first].size()){if(i)cout<<" ";cout<<mp[itr->first][i];}
        cout<<endl;
    }
}

Measured memory_bytes: 3000
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
	vector<int> arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  	int k;
  	cin >> k;
  	cout << arr[k-1] << endl;
    return 0;
}



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

import numpy as np
def main():
    N = int(readline())
    tasks = np.array(read().split(), np.int64).reshape((-1, 2))
    tasks = tasks[np.argsort(tasks[..., 1]), ...]
    tasks[..., 0] = np.add.accumulate(tasks[..., 0], axis=0)
    if (tasks[..., 1]-tasks[..., 0]>=0).all():
        print('Yes')
    else:
        print('No')
if __name__ == '__main__':
    main()


Measured memory_bytes: 35576
/******************************************************************************

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <bits/stdc++.h>

using namespace std;
int n,m;
int main()
{
    
    cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	map<string,int> m;
	string s;
	char c;
	int n;
	scanf("%d",&n);
	n--;
	cin>>s;
	m[s] ++;
	int len = s.size();
	c = s[len-1];
	bool flag = true;
	while(n--)
	{
		cin>>s;
		if(m[s])
		{
            flag = false;
		}
		m[s] ++;
        len = s.size();
        if(s[0] != c)
		{
			flag = false;
		}
		c = s[len-1];
	}
	if(flag)
	{
        cout<<"Yes";
	}else cout<<"No";
	return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main {
    public static void main (String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        double x1 = sc.nextDouble();
        double y1 = sc.nextDouble(); 
        double x2 = sc.nextDouble(); 
        double y2 = sc.nextDouble();
        System.out.printf("%.9f\n", Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)));
    }
}



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


class UnionFind {
private:
    vector<int> parent;
    vector<int> rank;

public:
    UnionFind(int n) {
        parent.resize(n);
        rank.resize(n);
        for (int i = 0; i < n; i++) {
            parent[i] = i;
            rank[i] = 0;
        }
    }

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

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

        if (rank[x] < rank[y]) {
            parent[x] = y;
        } else {
            parent[y] = x;
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    vector<unordered_set<int>> G(N);
    UnionFind F(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        F.unite(a, b);
        G[a].insert(b);
        G[b].insert(a);
    }

    for (int i = 0; i < K; i++) {
        int c, d;
        cin >> c >> d;
        c--; d--;
        if (F.same(c, d)) {
            G[c].insert(d);
            G[d].insert(c);
        }
    }

    unordered_map<int, int> hash;
    for (int i = 0; i < N; i++) {
        hash[F.find(i)]++;
    }

    for (int i = 0; i < N; i++) {
        int res = hash[F.find(i)] - (int)G[i].size();
        cout << res - 1 << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 27556
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n*3);
  for(auto &a:A)cin>>a;
  sort(ALL(A),greater<ll>());
  ll ans = 0;
  ll now = 1;
  for(int i=0;i<n;i++){
    ans += A[now];
    now += 2;
  }
  cout<<ans<<endl;
  return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, k, ans=-1, sum, a[5005];
    cin >> n >> k;
    for(int i=0; i<n; ++i)
        cin >> a[i];
    sort(a,a+n,greater<int>());
    for(int i=0; i<n; ++i) {
        sum = 0;
        for(int j=i; j<n; ++j) {
            if(sum+a[j]<k) {
                sum += a[j];
                continue;
            }
            ans = max(ans, j);
        }
    }
    P(n-ans-1);
    return 0;
}



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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int n;
    cin >> n;
    vector<int> v(n);
    for(auto& i : v) cin >> i;

    int ans = 0;

    REP(i, n-2){
        vector<int> u(3);
        u[0] = v[i];
        u[1] = v[i+1];
        u[2] = v[i+2];
        sort(all(u));
        if(u[1] == v[i+1]){
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(int x){
  char f[10];
  int m=0, s=0;
  if(x<0){
    m=1;
    x=-x;
  }
  while(x){
    f[s++]=x%10;
    x/=10;
  }
  if(!s){
    f[s++]=0;
  }
  if(m){
    putchar_unlocked('-');
  }
  while(s--){
    putchar_unlocked(f[s]+'0');
  }
}
int main(){
  int K, N;
  rd(N);
  rd(K);
  wt_L(N + 1 - K);
  wt_L('\n');
  return 0;
}
// cLay varsion 20190721-1

// --- original code ---
// {
//   int N, K;
//   rd(N, K);
//   wt(N + 1 - K);
// }


Measured memory_bytes: 256
import java.util.Map.Entry;
import java.util.*;
import java.math.*;
import org.w3c.dom.css.Counter;
  
public class Main{
    public static void main(final String[] args){
       
        final Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int K = sc.nextInt();
        Long ans = 0l;
        
        HashSet hoge =new HashSet<Integer>(); 
        ArrayList Zero =new ArrayList<Integer>(); 
        for(int i =0;i<N;i++){
                //hoge.add(sc.nextInt());
                Zero.add(sc.nextLong());
        }
        Collections.sort(Zero);
        int count =0;
        for(int i=N-1;0<K&& i>-1;i--){
            Zero.set(i, 0l);
            K--;
        }
        for(int i =0;i<N;i++){
            ans =ans+(Long)Zero.get(i);
        }
        
        

/*         String abc = "abcdefghijklmnopqrstuvwxyz";
        Long alf = 26l;
        Long N = sc.nextLong();
        String ans = "";

        for(;N>0;){
            Long Num = N-1;
            int tStr = (int)(Num%alf);
            ans = abc.substring(tStr,tStr+1)+ans;
            N =  Num/alf;
        } */
        System.out.println(ans);
    }
}
    


    

Measured memory_bytes: 66472
#include<bits/stdc++.h>
using namespace std;
using UL = unsigned int;
using ULL = unsigned long long;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {
public:

	void Solve() {
		UL N; scanf("%d", &N);
		UL F = (1 << N) - 1;
		UL M = F;
		UL K; scanf("%d", &K);
		rep(i, K) {
			UL m; scanf("%d", &m);
			M &= ~(1 << m);
		}
		UL p = M;
		rep(k, 1 << (N - K)) {
			printf("%d:", (F ^ p));
			rep(j, N) {
				if (((F ^ p) >> j) & 1) printf(" %d", j);
			}
			printf("\n");
			p = M & (p - 1);
		}
	}
};

int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}



Measured memory_bytes: 3192
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<cctype>
#define ld long double
#define ll long long int
#define ull unsigned long long int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long INF=1LL<<60;


int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	int k,s,x,y,z;
	ll ans=0;
	cin>>k>>s;
	for(x=0;x<=k;x++){
		for(y=0;y<=k;y++){
			z=s-x-y;
			if(z<0)break;
			else if(z>k)continue;
			else if(x!=z&&y!=z){
				ans+=1;
//				cout<<"1:"<<x<<" "<<y<<" "<<z<<" "<<ans<<endl;
			}
			else if(x==y&&y==z){
				ans+=1;
//				cout<<"2:"<<x<<" "<<y<<" "<<z<<" "<<ans<<endl;
			}
			else if(x==y||y==z||z==x){
				ans+=1;
//				cout<<"3:"<<x<<" "<<y<<" "<<z<<" "<<ans<<endl;
			}
		}
	}
	cout<<ans<<endl;
	
	return 0;
}

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

vector<int>adj[sz];

// c = 1 - white parent
// c = 0 - black parent

pair<ll, ll> dfs(int s, int p)
{
	if (adj[s].size() == 1 && adj[s][0] == p)
		return {1, 1};
	pair<ll, ll>ans = {1, 1};
	for (auto it : adj[s])
	{
		if (it == p)
			continue;
		pair<ll, ll>cur = dfs(it, s);
		ans.first = (ans.first * (cur.first + cur.second) % MOD) % MOD;
		ans.second = (ans.second * cur.first % MOD) % MOD;
	}
	return ans;
}

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

	int n; cin >> n;
	if (n == 1)
	{
		cout << 2;
		return 0;
	}
	for (int i = 0; i < n - 1; i++)
	{
		int a, b; cin >> a >> b;
		adj[a].push_back(b);
		adj[b].push_back(a);
	}
	pair<ll, ll> ans = dfs(1, -1);
	cout << (ans.first + ans.second) % MOD;
	return 0;
}

Measured memory_bytes: 15920
#include<iostream>
#include<cstdio>
using namespace std;
int coin(int change){
    int count;
    count = 0;
    while(change >= 500){
        change -= 500;
        count++;
    }
    while(change >= 100){
        change -= 100;
        count++;
    }
    while(change >= 50){
        change -= 50;
        count++;
    }
    while(change >= 10){
        change -= 10;
        count++;
    }
    while(change >= 5){
        change -= 5;
        count++;
    }
    while(change >= 1){
        change -= 1;
        count++;
    }
    return count;
}
int main(){
    int money;
    while(1){
        scanf("%d",&money);
        if(money == 0) break;
        else printf("%d\n",coin(1000-money));
        
    }
    return 0;
}


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

using namespace std;

int main()
{
    int n;
    cin>>n;
    int arr[n];
    for(int i=0;i<n;i++)
        cin>>arr[i];
    int ans=0;
    int xp=111111;
    for(int i=0;i<n-1;i++)
    {
        if(arr[i]==arr[i+1])
        {
            arr[i+1]=xp;
            xp++;
            ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const int prime_max = 100500;
bool prime[prime_max + 1];

void initial_prime()
{
    for (int i = 0; i < prime_max; i++)
        prime[i] = true;

    prime[0] = prime[1] = false;
    for (int i = 2; i * i < prime_max; i++) {
        if (prime[i])
            for (int j = 2 * i; j < prime_max; j += i)
                prime[j] = false;
    }
}


int main()
{
    int p;
    ll n;

    initial_prime();
    
    while (cin >> n >> p, n != -1 || p != -1) {
        ll pr[50];
        priority_queue<ll, vector<ll>, greater<ll> > pq;
        
        int idx = n;

        for (int i = 0; i < 30; i++) {
            while (!prime[++idx])
                ;
            pr[i] = idx;
        }

        for (int i = 0; i < 30; i++) 
            for (int j = i; j < 30; j++) 
                pq.push(pr[i] + pr[j]);

        for (int i = 0; i < p - 1; i++)
            pq.pop();
        cout << pq.top() << endl;
    }

    return 0;
}

Measured memory_bytes: 1320
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%lld", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int main(){
        ll n;
        while(~getI(n)){
                ll ans=0;
                for(ll deno=10;deno<=n;deno*=5) ans+=n/deno;
                printf("%lld\n",n%2==0?ans:0);
        }
}

Measured memory_bytes: 256
import java.io.*;

class Main{
	public static void main(String[] args) {

		InputStreamReader sr = new InputStreamReader(System.in);
        BufferedReader br = new BufferedReader(sr);
        try{
	        String[] str = br.readLine().split(" ");
			int a = Integer.parseInt(str[0]);
			int b = Integer.parseInt(str[1]);
	
			if (a < b) {
				System.out.println("a < b");				}
			else if(a > b){
				System.out.println("a > b");
			}
			else if (a == b) {
				System.out.println("a == b");
			}
		}	
		catch(IOException e) {
            e.printStackTrace();
        }
	}
}

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

int main() {long long x,t,mx=-10e6-8,mn=10e6+8,sum=0;
	// your code goes here
	cin>>t;
	while(t--){cin>>x;
		mx=max(mx,x);
		mn=min(mn,x);
		sum+=x;
	} 
	cout<<mn<<" "<<mx<<" "<<sum<<endl;
	return 0;
}

Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n;
	cin>>n;
	long long a[n];
	rep(i,n)cin>>a[i];
	sort(a,a+n);
	cout<<a[n-1]-a[0]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1000100011;
// clang-format on

int n, m;
int ans = 0;

bool isAll(vector<bool> visited) {
  for (auto v : visited)
    if (!v) return false;
  return true;
}

void dfs(int cur, vector<vector<int>> G, vector<bool> visited, int visnum) {
  visited[cur] = true;
  for (auto child : G[cur]) {
    if (visited[child]) continue;
    visnum++;
    dfs(child, G, visited, visnum);
  }
  if (isAll(visited)) ans++;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> n >> m;
  vector<vector<int>> G(n);
  int a, b;
  // 0-indexed
  REP(i, m) {
    cin >> a >> b;
    G[a - 1].push_back(b - 1);
    G[b - 1].push_back(a - 1);
  }

  vector<bool> visited(n);
  dfs(0, G, visited, 1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
use proconio::input;
use std::collections::HashSet;

fn main() {
    input! {
        n: usize,
        aa: [usize; n],
    }

    let mut set = HashSet::new();

    for a in aa {
        set.insert(a);
    }

    let ans = if set.len() % 2 == 0 {
        set.len() - 1
    } else {
        set.len()
    };

    println!("{}", ans);
}


Measured memory_bytes: 5076
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#define ll long long
#define ld long double
using namespace std;
int read(){int x;scanf("%d",&x);return x;}
int main(){
	int a=read(),b=read();
	cout<<(double)a/b<<endl;
	return 0;
}

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

#define int long long
#define rep(i, l, r) for (int i = (int)(l); i < (int)(r); i++)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)x.size())
template <class T> bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T> bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T> using V = vector<T>;
using P = pair<int, int>;

/*
 *  *  */

signed main() {
  int n;
  cin >> n;

  set<int> div;
  rep(i, 1, n/i+1){
    if(n%i == 0){
      div.insert(i);
      div.insert(n/i);
    }
  }

  n--;
  rep(i, 1, n/i+1){
    if(n%i == 0){
      div.insert(i);
      div.insert(n/i);
    }
  }

  int ans = 0;
  for(auto i : div){
    if(i == 1) continue;

    int t = n + 1;
    while(t%i == 0) t /= i;
    if(t%i == 1) ans++;
  }

  cout << ans << endl;

  return 0;
}





Measured memory_bytes: 512
N = int(input())
a = list(map(int, input().split()))
c2=c4=0

for i in range(N):
  if a[i]%4==0:
    c4+=1
  if a[i]%2==0:
    c2+=1

nodd=N-c2
c2=c2-c4
if c2>0:
  nodd+=1
if c4>=nodd-1:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 14252
#include<stdio.h>
#include<string.h>

int LCSLength(char *X, char *Y){
  int i,j,m,n,c[1001][1001];
  m = strlen(X);
  n = strlen(Y);
  
  for(i=0; i<m; i++){
    c[i][0] = 0;
  }
  for(j=0; j<n; j++){
    c[0][j] = 0;
  }

  for(i=1;i<m+1;i++){
    for(j=1;j<n+1;j++){
      if (X[i-1]==Y[j-1]) c[i][j]=c[i-1][j-1]+1;
      else if (c[i-1][j]>=c[i][j-1]) c[i][j]=c[i-1][j];
      else c[i][j]=c[i][j-1];
    }
  }
  return c[i-1][j-1];
}

int main(){
  int i, q;
  char X[1001], Y[1001];
  
  scanf("%d", &q);
  for(i=0; i<q; i++){
    scanf("%s", X);
    scanf("%s", Y);
    printf("%d\n", LCSLength(X, Y));

  }
  return 0;
}

Measured memory_bytes: 4520
#include <bits/stdc++.h>
#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long

using namespace std;

const int MOD = 1000000007;

ll getLast(ll n) {
  for (;;) {
    if (n < 10) {
      break;
    }
    n /= 10;
  }
  return n;
}
int main() {
  ll n;
  scanf("%lld", &n);

  map<ll, ll> m;

  for (ll i = 1; i <= n; i++) {
    ll first = i % 10;
    ll last = getLast(i);

    ll id = last * 10 + first;
    m[id] += 1;
    // cout << i << "," << id << endl;
  }

  ll r = 0;

  for (ll n1 = 10; n1 <= 99; n1++) {
    ll n2 = n1 / 10 + n1 % 10 * 10;

    // cout << n1 << "," << n2 << endl;

    r += m[n1] * m[n2];
  }

  cout << r << endl;
}


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

int main() {
	int n,q;cin>>n>>q;
	queue<int> que[1010];
	
	while(q--){
		int query,t;cin>>query>>t;
		if(query==0){
			int x;cin>>x;
			que[t].push(x);
		}else if(query==1){
			if(que[t].empty()) continue;
			cout<<que[t].front()<<endl;
		}else{
			if(que[t].empty()) continue;
			que[t].pop();
		}
	}
  return 0;
}



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

int main() {
    int n;
    double sum = 0, co = 0;
    cin >> n;
    vector<vector<double>> a(n, vector<double>(2));
    vector<int> b(n);
    rep(i, n) cin >> a[i][0] >> a[i][1];
    rep(i, n) b[i] = i;
    do {
        rep(i, n - 1) {
            sum += sqrt((a[b[i]][0] - a[b[i + 1]][0]) * (a[b[i]][0] - a[b[i + 1]][0]) + (a[b[i]][1] - a[b[i + 1]][1]) * (a[b[i]][1] - a[b[i + 1]][1]));
        }
        co++;
    } while (next_permutation(b.begin(), b.end()));
    printf("%.8f", sum / co);
}

Measured memory_bytes: 3812
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())
#define maxIndex(v) max_element(v.begin(), v.end()) - v.begin()
#define maxElement(v) *max_element(v.begin(), v.end())
#define minIndex(v) min_element(v.begin(), v.end()) - v.begin()
#define minElement(v) *min_element(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;

int main()
{
  ll N, M = 0; cin >> N;
  vector<ll> A(N + 1), box(N + 1, 0);
  A[0] = 0;
  rep(i, 1, N + 1) cin >> A[i];
  for (ll i = N; i > 1; i--) {
    box[i] = A[i];
  	for (ll j = 2; i * j <= N; j++) {
    	box[i] ^= box[i * j];
    }
    if (box[i]) M++;
  }
  box[1] = (M % 2) ^ A[1];
  if (box[1]) M++;
  cout << M << endl;
  rep(i, 1, N + 1) {
  	if (box[i]) cout << i << " ";
  }
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
#define f(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define Max(a,b,c) max(a,max(b,c))
#define Min(a,b,c) min(a,min(b,c))
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define pc(x)  __builtin_popcount (x)
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define ld long double
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod 1000000007
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
#define flush fflush(stdout) 
#define gcd __gcd
#define primeDEN 727999983
#define nx_pe next_permutation(s.begin(),s.end())
#define cl cout<<"\n"
#define sp(x) setprecision(x)

void solve()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    vl v;
    rep(i,n){
        if(s[i]=='R'){
            v.pb(i);
        }
    }
    if(v.size()==0){
        cout<<0<<"\n";
        return;
    }
    ll ans=0;
    ans+=v[0];
    f(i,1,v.size()){
        ll x=v[i]-v[i-1];
        ans+=x-1;
    }
    ll y=v.size();
    ll z=y;
    rep(i,y){
        if(s[i]=='R')
        {
            // cout<<i<<"\n";
            z--;
        }
    }
    // cout<<z<<"\n";
    
    ans=min(ans,z);
    cout<<ans<<'\n';
}


    
int main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin) ;
    freopen("ouput.txt", "w", stdout) ;
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    std::ios::sync_with_stdio(false);
    ll te=1;
    // cin>>te;
    while(te--){
        solve();
    }
    
}


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

int main() {
    int a,b;
    cin >> a >> b;
    if (a-2*b<0)
        cout << 0;
    else
        cout << a-2*b;
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

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

    int ans = (a + b + 1) / 2;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<size_t I,class H,class...T>struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template<class H,class...T>struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class...T>istream&operator>>(istream&i,tuple<T...>&t){t=TupleReaderWriter<sizeof...(T),T...>::r(i);return i;}
template<class...T>ostream&operator<<(ostream&o,tuple<T...>&t){string delim=" ";TupleReaderWriter<sizeof...(T)-1,T...>::w(o,t,delim);return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int x;fixprec(int d):x(d){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.x);}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    // 全てのAをBにすると考えて、3を法として同値類で扱う
    string S, T;
    cin >> S >> T;
    vector<int> X(S.size()), Y(T.size());
    for(int i = 0; i < S.size(); i++) {
        X[i] = ( (i ? X[i - 1] : 0) + (S[i] == 'A' ? 2 : 1));
    }
    for(int i = 0; i < T.size(); i++) {
        Y[i] = ( (i ? Y[i - 1] : 0) + (T[i] == 'A' ? 2 : 1));
    }
    int Q;
    cin >> Q;
    for(int i = 0; i < Q; i++) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        a--, b--, c--, d--;
        int x_val = X[b] - (a ? X[a - 1] : 0);
        int y_val = Y[d] - (c ? Y[c - 1] : 0);
        R_YESNO((x_val - y_val) % 3 == 0);
    }
    return 0;
}



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

int main() {
  int n, k, q;
  cin >> n >> k >> q;
  
  vector<int> ans_count(n);
  
  // 10^5
  vector<int> q_list(q);
  for(int i = 0; i < q; i++) {
    cin >> q_list.at(i);
    q_list.at(i)--;
  }
  
  for(int i = 0; i < q; i++) {
    int x = q_list.at(i);
    ans_count.at(x)++;
  }
  
  for(int i = 0; i < n; i++) {
    if(k-q+ans_count.at(i) <= 0) {
      cout << "No" << endl;
    } else {
      cout << "Yes" << endl;
    }
  }
  
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n], b[n], c[n];
  for (int i=0; i<n; i++) cin>>a[i]>>b[i]>>c[i];

  long long dp[3][n];
  dp[0][0] = a[0];
  dp[1][0] = b[0];
  dp[2][0] = c[0];

  for (int i=1; i<n; i++) {
    dp[0][i] = max(dp[1][i-1] + a[i], dp[2][i-1] + a[i]);
    dp[1][i] = max(dp[2][i-1] + b[i], dp[0][i-1] + b[i]);
    dp[2][i] = max(dp[0][i-1] + c[i], dp[1][i-1] + c[i]);
  }
  cout<<max(max(dp[0][n-1], dp[1][n-1]), dp[2][n-1])<<endl;
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,k,h) for(int i = k; i < h; ++i)
#define rep3(l,k,h) for(int l = k; l <= h; ++l)
#define INF LLong_MAX // long long INF
#define inf INT_MAX // int inf

typedef pair<int,int> int_pair;
typedef pair<string,string> string_pair;



int main() {
    int d,n,count = 0, cou = 0;
    cin >> d >> n;
    for(int i = 1; i < 1e7; i++) {
        int res = i;
        while(res >= 100 && res % 100 == 0) {
            res /= 100;
            count++;
        }
        if(count == d) {
            cou++;
        }
        if(cou == n) {
            cout << i << endl;
            return 0;
        }
        count = 0;
    }
    return 0;
}

Measured memory_bytes: 256