akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n;
string str;
string ans;
vector<int>pos,a,b;
int A,B;
bool ok[6005];
string dp[3005];
void rec(){
	string ans = "";
	for(int i=0;i<=pos.size();i++){
	    if(i == pos.size() && !pos.empty()) break;
		vector<int>in;
		for(int j=i;j<pos.size();j++){
			in.pb(a[pos[j]]);
			in.pb(b[pos[j]]);
			assert(a[pos[j]]>b[pos[j]]);
		}
		SORT(in);
		string cur = "";
		for(int ii=0;ii<in.size();ii++){
			cur.pb(str[in[ii]]);
		}
		int nxt = 0;
		if(in.size()) nxt = in[in.size()-1]+1;
		while(nxt<2*n){
			int p = POSL(a,nxt);
			if(p == a.size()) break;
			assert(a[p]<b[p]);
			cur.pb('a'); cur.pb('b');
			nxt = b[p]+1;
		}
		if(ans<cur) ans = cur;
	}
	cout<<ans<<endl;
}
int main(){
	cin>>n;
	cin>>str;
	for(int i=0;i<2*n;i++){
		if(str[i] == 'a') a.pb(i);
		else b.pb(i);
	}
	assert(a.size()==b.size());
	for(int i=0;i<n;i++){
		if(a[i]>b[i]){
			pos.pb(i);
		}
		ok[i] = 1;
	}
	string ans = "";
	if(pos.empty()){
		rec(); return 0;
	}
	vector<int>vec;
	for(int i=0;i<pos.size();i++){
		vector<int>in;
		int pre = INF;
		int en = pos.size();
		en--;
		for(int j=i;j<pos.size();j++){
			if(pre < b[pos[j]]){
				en = j-1;
				break;
			}
			in.pb(a[pos[j]]);
			in.pb(b[pos[j]]);
			pre = a[pos[j]];
		}
		SORT(in);
		string cur = "";
		for(int ii=0;ii<in.size();ii++){
			cur.pb(str[in[ii]]);
		}
		if(dp[en] < cur)	{
			dp[en] = cur;
			vec.pb(en);
		}
	}
	ERASE(vec);
	string pre = "";
	for(int i=0;i<vec.size();i++){
		string S = dp[vec[i]];
		for(int j=0;j<i;j++) dp[vec[i]] = max(dp[vec[i]],dp[vec[j]]+S);
		int nxt = a[pos[vec[i]]]+1;//cout<<nxt<<endl;
		string cur = dp[vec[i]];
		while(nxt<2*n){
			int p = POSL(a,nxt);
			if(p == a.size()) break;
			if(a[p]>b[p]) break;
			assert(a[p]<b[p]);
			cur.pb('a'); cur.pb('b');
			nxt = b[p]+1;
		}
		if(ans<cur) ans = cur;
	
	}
	cout<<ans<<endl;
}


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

int main() {
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    vector<int> a(n, 0);
    for(int i = 1; i < n; i++){
        if(s.at(i) == 'C' && s.at(i - 1) == 'A') a[i]++;
    }
    for(int i = 1; i < n; i++){
        a[i] += a[i - 1];
    }
    vector<int> ans;
    for(int i = 0; i < q; i++){
        int l, r;
        cin >> l >> r;
        ans.push_back(a[r - 1] - a[l - 1]);
    }
    for(int i = 0; i < q; i++){
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 1912
N, A, B, C = map(int, input().split())
s = ["" for i in range(N)]
for i in range(N):
    s[i] = input()
   
valid = True
ans = []
all_sum = A + B + C
if all_sum >= 3:
    for op in s:
        if op == "AB":
            if A > B:
                A -= 1
                B += 1
                ans.append("B")
            else:
                A += 1
                B -= 1
                ans.append("A")
        elif op == "BC":
            if B > C:
                B -= 1
                C += 1
                ans.append("C")
            else:
                B += 1
                C -= 1
                ans.append("B")
        else:
            if A > C:
                A -= 1
                C += 1
                ans.append("C")
            else:
                A += 1
                C -= 1
                ans.append("A")
        if A < 0 or B < 0 or C < 0:
            valid = False
            break
        
    if valid:
        print("Yes")
        for c in ans:
            print(c)
    else:
        print("No")
else:
    for i in range(N):
        op = s[i]
        if op == "AB":
            if A > B:
                A -= 1
                B += 1
                ans.append("B")
            elif A < B:
                A += 1
                B -= 1
                ans.append("A")
            else:
                if i != N - 1 and "A" in s[i + 1]:
                    A += 1
                    B -= 1
                    ans.append("A")
                else:
                    A -= 1
                    B += 1
                    ans.append("B")
        elif op == "AC":
            if A > C:
                A -= 1
                C += 1
                ans.append("C")
            elif A < C:
                A += 1
                C -= 1
                ans.append("A")
            else:
                if i != N - 1 and "A" in s[i + 1]:
                    A += 1
                    C -= 1
                    ans.append("A")
                else:
                    A -= 1
                    C += 1
                    ans.append("C")
        else:
            if B > C:
                B -= 1
                C += 1
                ans.append("C")
            elif B < C:
                B += 1
                C -= 1
                ans.append("B")
            else:
                if i != N - 1 and "B" in s[i + 1]:
                    B += 1
                    C -= 1
                    ans.append("B")
                else:
                    B -= 1
                    C += 1
                    ans.append("C")
        if A < 0 or B < 0 or C < 0:
            valid = False
            break
    if valid:
        print("Yes")
        for c in ans:
            print(c)
    else:
        print("No")

Measured memory_bytes: 16940
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import Data.Ord

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    n <- getInt
    (os,es) <- f <$> getIntList
    print $ solve os es

f [] = ([],[])
f (a:b:xs) = let (as,bs) = f xs in (a:as, b:bs)

solve os es | snd o /= snd e = sumo + sume
            | null os' && null es' = fst o
            | otherwise = min (sum (map fst (o : (tail os'))) + sume) (sum (map fst (e : (tail es'))) + sumo)
    where (o:os') = fm os
          (e:es') = fm es
          sumo = sum $ map fst os'
          sume = sum $ map fst es'

fm xs = sortOn Down . map (\g -> (length g, head g)) . group $ sort xs

Measured memory_bytes: 25980
function main(input) {
  	const results = input.split('\n').slice(1)
	let doubletNum = 0

    const result = results.some(res => {
        const [a, b] = res.split(' ')
    	doubletNum = a === b ? doubletNum+1 : 0
      	return doubletNum >= 3
    })
	console.log(result ? 'Yes' : 'No')
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29524
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace _20191021
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string t = Console.ReadLine();
            int Count = 0;

            if (s[0] == t[0])
                Count++;

            if (s[1] == t[1])
                Count++;

            if (s[2] == t[2])
                Count++;

            Console.WriteLine(Count);
        }
    }
}


Measured memory_bytes: 13140
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ATheNumberOfEvenPairs solver = new ATheNumberOfEvenPairs();
        solver.solve(1, in, out);
        out.close();
    }

    static class ATheNumberOfEvenPairs {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt(), m = s.nextInt();
            w.println(n * (n - 1) / 2 + m * (m - 1) / 2);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 21332
#include<iostream>
#include <bits/stdc++.h>
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
    fastio;
    long long n,m,a,i,correct=0,wrong=0;
    string b;
    cin>>n>>m;
    long cnt[n];
    map<long long,bool> mp;
    for(i=0;i<n;i++)
    {
        cnt[i]=0;
        mp[i]=false;
    }
    for(i=0;i<m;i++)
    {
        cin>>a>>b;
        if(b=="AC" && mp[a]==false)
        {
            correct++;
            mp[a]=true;
            wrong=wrong+cnt[a-1];
        }
        else if(b=="WA" && mp[a]==false)
        {
            cnt[a-1]++;
        }
    }
    cout<<correct<<" "<<wrong;
    return 0;
}


Measured memory_bytes: 7296
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

struct Sieve {
    int n;
    vector<int> f, primes;
    Sieve(int n=1):n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(int64_t i=2; i<=n; ++i) {
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(int64_t j = i*i; j <= n; j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    //素数判定
    bool isPrime(int x) {return f[x] == x;}
    //素数判定(1つ用)(宣言はsqrt(x)のサイズで)
    bool isPrime1(int64_t x) {
        bool m = true;
        for(int z:primes) {
            if(!(x%z)) {
                m = false;
                break;
            }
        }
        return m;
    }
    //素数列挙
    vector<int > factorList(int x) {
        assert(x <= n);
        vector<int> res;
        while(x != 1) {
            res.emplace_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    //素因数分解　pair(素数, 素因数の数)
    vector<pair<int, int> > factor(int x) {
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int, int> > res(1, pair<int, int>(fl[0], 0));
        for(int p : fl) {
            if(res.back().first == p) {
                ++res.back().second;
            } else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)
    vector<int64_t> factorList1(int64_t x) {
        vector<int64_t> vec;
        for(int z:primes) {
            while(!(x%z)) {
                vec.emplace_back(z);
                x /= z;
            }
        }
        if(x != 1) vec.emplace_back(x);
        return vec;
    }
    //素数列挙(1つ用)(宣言はsqrt(x)のサイズで)　pair(素数, 素因数の数)
    vector<pair<int64_t, int> > factor1(int64_t x) {
        vector<int64_t> vec = factorList1(x);
        vector<pair<int64_t, int> > vecc;
        for(vector<int64_t>::iterator itr = vec.begin(); itr != vec.end(); ++itr) {
            if(itr != vec.begin() && *itr == *(itr-1)) {
                (vecc.end()-1)->second++;
            } else {
                vecc.emplace_back(pair<int64_t, int>(*itr, 1));
            }
        }
        return vecc;
    }
};

int64_t gcd(int64_t a, int64_t b) {return b?gcd(b, a%b):a;}
int64_t lcm(int64_t a, int64_t b) {return a/gcd(a,b)*b;}
int64_t extgcd(int64_t a, int64_t b, int64_t &x, int64_t &y) { // ax+by=gcd(a, b)の解を与える
    int64_t d = a;
    if(b) {
        d = extgcd(b, a%b, y, x);
        y -= (a/b)*x;
    } else {
        x = 1; y = 0;
    }
    return d;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b;
    cin >> a >> b;

    a = gcd(a, b);

    Sieve pa(sqrt(a));

    auto x = pa.factor1(a);

    cout << 1+x.size() << endl;
}

Measured memory_bytes: 4860
# 2019/04/28
# AtCoder Beginner Contest 122 - C

# Input
n, q = map(int,input().split())
s = input()

acgt = ["A", "C", "G", "T"]
acgtl = list()
acgtl.append(0)

# Search AC and make Accumed sum
for i in range(n-1):
    if s[i] == "A" and s[i+1] == "C":
        acgtl.append(acgtl[i]+1)
    else:
        acgtl.append(acgtl[i])
        
# Calc AC count
for x in range(q):
    l, r = map(int,input().split())
    ans = acgtl[r-1] - acgtl[l-1]
    print(ans)


Measured memory_bytes: 6104
import sys

s_list = list(input())

a = 1

for _ in range(len(s_list) - 1):
    if s_list[a - 1] == s_list[a]:
        print(a, (a + 1))
        sys.exit()
    else:
        a += 1
        
a = 1
        
for _ in range(len(s_list) - 2):
    if s_list[a - 1] == s_list[a + 1]:
        print(a, (a + 2))
        sys.exit()
    else:
        a += 1
        
print('-1 -1')

Measured memory_bytes: 3956
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() /4;
const ll linf = numeric_limits<ll>::max() /4;
const ull ulinf = numeric_limits<ull>::max()/4;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.end(), v.begin());
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

int n,m,a,b,c,d[100005] = {};
string s,t;

int main(){

    cin >> n >> a;

    n %= 500;

    if( a >= n)Yes;
    else No;
	
	return  0;
}

Measured memory_bytes: 256
import math
import string
import itertools
import fractions
import heapq
import collections
import re
import array
import bisect
import sys
import random
import time
inf = 10**9


def main():
    ans = 2018
    l, r = list(map(int, input().split()))
    for i in range(l, min(l+2019, r)):
        for j in range(i+1, min(l+2019, r)+1):
            ans = min(ans, i*j % 2019)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 5668
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<ctype.h>
#include<stdlib.h>
#define STR 11
int main(){
    int n,cnt=1;
    scanf("%d",&n);
    char S[n+1][STR];

    for(int i=0;i<n;i++){
        scanf("%s\n",S[i]);
    }
    qsort(S,n,sizeof(S[0]),strcmp);

    for(int i=1;i<n;i++){
        if(strcmp(S[i-1],S[i]) != 0){
            cnt += 1;
        }
    }
    printf("%d\n",cnt);
    return 0;
}


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

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template<typename Head> void dump(Head&& head) { cerr << head; dump(); }
template<typename Head, typename... Tail> void dump(Head&& head, Tail&&... tail) { cerr << head << ", "; dump(forward<Tail>(tail)...); }
#define debug(...) do {cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; dump(__VA_ARGS__); } while (false)
#else
#define dump(...)
#define debug(...)
#endif

template<typename T>
struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template<typename T>
using Edges = vector<edge<T>>;
template<typename T>
using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template<typename T>
using Matrix = vector<vector<T>>;

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

const ll inf = 1LL<<60;
const ll MUL = 1000000000;

int main()
{
  ll n; cin >> n;
  vector<ll> b(n);
  for (int i=0; i<n; i++){
    long double a; cin>>a;
    b[i] = a * MUL + 0.1;
  }

  vector<vector<ll>> g(21, vector<ll>(21));
  vector<ll> x(n);
  vector<ll> y(n);
  rep(i, n) {
    ll two = 0, five = 0;
    ll tmp = b[i];
    while (tmp % 2 == 0) { two = min(18LL, two+1); tmp/=2; }
    tmp = b[i];
    while (tmp % 5 == 0) { five = min(18LL, five+1); tmp/=5; }
    x[i] = two;
    y[i] = five;
    g[two+1][five+1]++;
  }

  rep(i, 19) g[i+1][0] += g[i][0];
  rep(i, 19) g[0][i+1] += g[0][i];
  rep(i, 19) rep(j, 19) g[i+1][j+1] += g[i+1][j] + g[i][j+1] - g[i][j];

  ll ans = 0;
  rep(i, n) {
    ll two = 18 - x[i];
    ll five = 18 - y[i];
    ll t = g[19][19] - g[two][19] - g[19][five] + g[two][five];
    if (x[i]*2 >= 18 && y[i]*2 >= 18) t--;
    ans += t;
  }
  ans /= 2;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 8012
#include <iostream>
#include <vector>
#include <cstring>
#include <string>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <cassert>
using namespace std;
typedef long long ll;
ll dp[11][50][170];

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

	int n, k, s;
	while(cin >> n >> k >> s, n + k + s) {
		memset(dp, 0, sizeof dp);

		dp[0][0][0] = 1;
		for(int i = 0; i < k; i++) {
			for(int j = 0; j <= n; j++) {
				for(int l = 0; l < s; l++) {
					if(dp[i][j][l] == 0) continue;
					for(int m = j + 1; m <= n; m++) {
						if(j + m <= s) {
							dp[i + 1][m][l + m] += dp[i][j][l];
						}
					}
				}
			}
		}

		ll sum = 0;
		for(int i = 0; i <= n; i++) {
			sum += dp[k][i][s];
		}
		cout << sum << endl;
	}
}

Measured memory_bytes: 3832
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] S = sc.next().toCharArray();
		int x = 0;
		int res = 0;
		for (int i=0; i<N; i++) {
			if (S[i] == 'I') x++;
			else x--;
			res = Math.max(res, x);
		}
		System.out.println(res);
	}
}


Measured memory_bytes: 21716
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
typedef long long ll;

int main(){
    int n,m; cin >> n >> m;
    cout << (n-1)*(m-1) << endl; return 0;
}


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

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == '+')
			ans++;
		else if (s[i] == '-')
			ans--;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=200010;
int n,a[4],ans[N];
char s[N][4];
int main()
{
	cin>>n>>a[0]>>a[1]>>a[2];
	int flag=0;
	for(int i=1;i<=n;i++)
		scanf("%s",s[i]+1);
	for(int i=1;i<=n;i++)
	{
		int x=s[i][1]-'A',y=s[i][2]-'A';
		if(a[x]<a[y])
			a[x]++,a[y]--,ans[i]=x;
		else if(a[y]<a[x])
			a[x]--,a[y]++,ans[i]=y;
		else
		{
			if(a[x]==1&&!a[3-x-y])
			{
				if(i==n||(s[i+1][1]!=3-x-y+'A'&&s[i+1][2]!=3-x-y+'A'))
					a[x]--,a[y]++,ans[i]=y;
				else
				{
					int x1=s[i+1][1]-'A',x2=s[i+1][2]-'A';
					if(x1==x||x2==x)
						ans[i]=x,a[x]++,a[y]--;
					else
						ans[i]=y,a[x]--,a[y]++;
				}
			}
			else
				a[x]--,a[y]++,ans[i]=y;
		}
		if(a[x]<0||a[y]<0)
		{
			flag=1;
			break;
		}
	}
	if(flag)
		cout<<"No";
	else
	{
		cout<<"Yes"<<endl;
		for(int i=1;i<=n;i++)
			cout<<(char)(ans[i]+'A')<<endl;
	}
	return 0;
}


Measured memory_bytes: 4416
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

int X[109];

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

	int N; cin >> N;
	for (int i = 0; i < N; i++) cin >> X[i];
	int ans = INF;
	for (int i = 0; i <= 100; i++) {
		int cost = 0;
		for (int j = 0; j < N; j++) {
			cost += (i - X[j]) * (i - X[j]);
		}
		ans = min(ans, cost);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define  rep(i,a,b)for(long long i=a;i<b;++i)
#define  rrep(i,a,b)for(int i=a;i>=b;--i)
#define  yesno(flag)if(flag)cout<<"Yes"<<endl; else cout<<"No"<<endl;
using namespace std;
const ll INF=1000000000000LL;
const ll r197=1000000007;
typedef pair<ll,ll>P;
typedef pair<P,P>Pa;
bool Inframe(int a,int b,int c,int d,int h,int w){
	if(a+b>=0&&a+b<h&&c+d>=0&&c+d<w)return true;
	return false;
}
ll calc(ll s,ll m){
	if(m==1)return s;
	ll x=calc(s,m/2);
	if(x>1000000)return 0;
	if(m%2==0){
		return x*x;
	}
	return x*x*s;
}

ll n,p;
int main() {
	cin>>n>>p;
	ll ans=1;
	ll i=2;
	if(n==1)ans=p;
	else{
		while(1){
			ll v=calc(i,n);
			if(v==0)break;
			if(v>p)break;
			while(1){
				if(p%v>0)break;
				p/=v;
				ans*=i;
			}
			i++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


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

int main() {
    long long x;  cin >> x;
    long long ans = 1LL << 60;
    for (long long i = 1; i * i <= x; ++i) {
        if (x % i) continue;
        ans = min(ans, i + x / i - 2);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
n = gets
until n.nil?
 x = n.split
 a = x[0].to_i
 b = x[1].to_i
 c = x[2].to_i
 
 card = [1,2,3,4,5,6,7,8,9,10]
 mysum = a + b
 leftcard = card.reject{|k| k == a || k == b || k == c}
 wantcard = leftcard.count{|k| mysum + k <= 20}
 if wantcard >= 4
 puts "YES"
 else
 puts "NO"
 end
 
 n = gets
end


Measured memory_bytes: 6836
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val A, B, K = sc.nextInt()

    println((for {
      i <- 1 to Math.min(A, B)
      if A % i == 0 && B % i == 0
    } yield i).toArray.sorted(Ordering.Int.reverse).apply(K - 1))
  }

}



Measured memory_bytes: 25632
// Author : MohamedSameh
#include <bits/stdc++.h>
typedef long long ll ;
#define pb push_back
#define f first
#define s second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SZ(a) (int)a.size()
#define IN(n) scanf("%d" , &n )
#define debug(x) cout<<#x<<" = { "<<x<<" }\n"
void fo (){fflush(stdout);}
using namespace std;
int n ;
int ans ;
int main ()
{
scanf ("%d" , &n );
for (int i=0,j;i<n;i++)
{
  scanf ("%d" , &j );
  ans += j-1;
}
printf ("%d\n" ,ans );
cerr << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
  return 0;
}


Measured memory_bytes: 256
/// Rustで競技プログラミングの入力をスッキリ記述するマクロ
///
/// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[inline]
fn gcd(mut m: u64, mut n: u64) -> u64 {
    if m < n {
        std::mem::swap(&mut m, &mut n);
    }

    loop {
        let k = m % n;
        if k == 0 {
            return n;
        }

        m = n;
        n = k;
    }
}

#[inline]
fn lcm(m: u64, n: u64) -> u64 {
    m / gcd(m, n) * n
}

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

    use std::collections::HashSet;
    let mut paper = HashSet::new();

    for a in &aa {
        if !paper.remove(a) {
            paper.insert(a);
        }
    }

    let answer = paper.iter().count();
    println!("{}", answer);
}


Measured memory_bytes: 8444
#include <vector>
#include <iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; ++i) cin >> p[i];
	int cnt = 0;
	for (int i = 2; i < n; ++i) {
		if (p[i - 2] < p[i - 1] && p[i - 1] < p[i]) ++cnt;
		if (p[i - 2] > p[i - 1] && p[i - 1] > p[i]) ++cnt;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,a,b,c,d,cnt=0,cnt2=0,pen1=0,pen2=0,cost=0;
	cin>>n>>a>>b>>c>>d;
	while(n>=pen1){
		pen1=pen1+a;
		cnt++;}
	while(n>pen2){
		pen2=pen2+c;
		cnt2++;}
	if(cnt2*d>cnt*b)
		cost=cnt*b;
	if(cnt*b>cnt2*d)
		cost=cnt2*d;
	if(cnt2*d==cnt*b)
		cost=cnt*b;
	cout<<cost<<endl;
	
	return 0;
}


Measured memory_bytes: 3096
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define all(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long




//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  int A,B,M;
  cin >> A >> B >> M;
  vector<int> a,b;
  a.resize(A);
  b.resize(B);
  int a_lowest = llINF;
  int b_lowest = llINF;
  for(int i = 0; i < A; i++){
  	cin >> a[i];
  	if(a[i] < a_lowest){
  		a_lowest = a[i];
  	}
  }
  for(int i = 0; i < B; i++){
  	cin >> b[i];
  	if(b[i] < b_lowest){
  		b_lowest = b[i];
  	}
  }

  vector<int> cand;
  cand.emplace_back(a_lowest + b_lowest);
  for(int i = 0; i < M; i++){
  	int x,y,c;
  	cin >> x >> y >> c;
  	x--;
  	y--;
  	cand.emplace_back(a[x] + b[y] - c);
  }

  sort(all(cand));
  cout << cand[0] << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 2936
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<unordered_map>

using namespace std;

int main()
{
	int N;
  	cin >> N;
  	unordered_map<string, int>count;
  	int m = 1;
  	while(N--)
    {
    	string s;
      	cin >> s;
      	auto it = count.find(s);
      	if(it == count.end())
        	count[s] = 1;
      	else
        {
        	it->second += 1;
          	m = max(m, it->second);
        }
    }
  	vector<string>result;
  	for(auto it = count.begin(); it != count.end(); it++)
    {
    	if(it->second == m) 
          result.push_back(it->first);
    }
  	sort(result.begin(), result.end());
  	for(auto r: result)
      	cout << r << endl;
  	return 0;
}


Measured memory_bytes: 26692
#include <iostream>

using namespace std;

int main() {
    int n;
    cin >> n;
    int a[n];
    long long s = 0, s2 = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s += a[i];
        if (i % 2 == 1) {
            s2 += a[i];
        }
    }

    int x = s - s2 * 2;
    cout << x;
    for (int i = 1; i < n; i++) {
        x = a[i-1] * 2 - x;
        cout << " " << x;
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
 
using namespace std;
 
using P = pair<int, int>;
using PI = pair<P, int>;
using Graph = map<P, vector<PI> >;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, m;
	cin >> n >> m;
	Graph g;
	for (int i = 0; i < m; i++) {
		int p, q, c;
		cin >> p >> q >> c;
		P x0(p, 0), x1(p, c), y0(q, 0), y1(q, c);
		g[x1].emplace_back(y1, 0);
		g[y1].emplace_back(x1, 0);
		g[x1].emplace_back(x0, 0);
		g[x0].emplace_back(x1, 1);
		g[y1].emplace_back(y0, 0);
		g[y0].emplace_back(y1, 1);
	}
 
	deque<PI> q;
	q.emplace_front(P(1, 0), 0);
	map<P, int> minc;
	while (!q.empty()) {
		PI pi = q.front();
		q.pop_front();
		if (minc.find(pi.first) != minc.end() && minc[pi.first] <= pi.second) continue;
		minc[pi.first] = pi.second;
		if (pi.first == P(n, 0)) break;
		for (PI& npi : g[pi.first]) {
			int cost = pi.second + npi.second;
			if (minc.find(npi.first) != minc.end() && minc[npi.first] <= cost) continue;
			if (npi.second) q.emplace_back(npi.first, cost);
			else q.emplace_front(npi.first, cost);
		}
	}
	P dst(n, 0);
	if (minc.find(dst) == minc.end()) cout << -1 << endl;
	else cout << minc[dst] << endl;
	return 0;
}

Measured memory_bytes: 75392
from itertools import permutations

n = int(input())
x = [0] * n
y = [0] * n

for i in range(n):
    x[i], y[i] = [int(j) for j in input().split()]

root = list(permutations(range(0,n)))
dist = 0

for r in root:
    for i in range(1,n):
        dist += ((x[r[i]]-x[r[i-1]])**2 + (y[r[i]]-y[r[i-1]])**2)**0.5

print(dist/len(root))

Measured memory_bytes: 8308
#include<bits/stdc++.h>
typedef long long ll;
#define F(i,L,R) for (ll i = L; i < R; i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define re(x) scanf("%lld",&x)
using namespace std;


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll n;
  cin>>n;
  ll a[n];
  F(i,0,n) cin>>a[i];

  ll cnt = 0;
  F(i,0,n) if((i+1)%2==1 && a[i]%2==1) cnt++;

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


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define rep(i,n) for((int) (i)=0;(i)<(int)(n);(i)++)
#define mp make_pair
#define pb push_back
using namespace std;

int main(){
	int a,b;
	cin>>a>>b;
	cout<<max(a+b,max(a-b,a*b));
	return 0;
}


Measured memory_bytes: 256
import sys,collections,math;sys.setrecursionlimit(10**7)
def Is(): return [int(x) for x in sys.stdin.readline().split()]
def Ss(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

n = I()
ans = 0
for i in range(n):
    v,c = Ss()
    m = 1
    if c == "BTC":
        m = 380000
    ans += float(v)*m
print(ans)

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 1e6+7;
string s[MAXN];

set< int >row[MAXN];
set< int >col[MAXN];
vector< int >dist[MAXN];

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

    int h, w, k;
    cin >> h >> w >> k;

    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    for (int i = 0; i < h; i++) {
        cin >> s[i];
        dist[i].resize(w);
        for (int j = 0; j < w; j++) {
            row[i].insert(j);
            col[j].insert(i);
            dist[i][j] = -1;
        }
    }

    queue< int >q;
    q.push(x1-1);
    q.push(y1-1);
    dist[x1-1][y1-1] = 0;

//    cout << x1-1 << " " << y1-1 << " at " << 0 << endl;

    while (!q.empty()) {
        int x = q.front(); q.pop();
        int y = q.front(); q.pop();

        {
            auto it = row[x].lower_bound(y+1);
            while (it != row[x].end() && *it <= y+k && (s[x][*it]=='.')) {
                dist[x][*it] = dist[x][y]+1;
//                cout << x << " " << *it << " at " << dist[x][*it] << endl;
                q.push(x);
                q.push(*it);
                col[*it].erase(x);
                it = row[x].erase(it);
            }
        }
        {
            auto jt = col[y].lower_bound(x+1);
            while (jt != col[y].end() && *jt <= x+k && (s[*jt][y]=='.')) {
                dist[*jt][y] = dist[x][y]+1;
//                cout << *jt << " " << y << " at " << dist[*jt][y] << endl;
                q.push(*jt);
                q.push(y);
                row[*jt].erase(y);
                jt = col[y].erase(jt);
            }
        }
        {
            auto it = row[x].lower_bound(y);
            while (it != row[x].begin() && *prev(it) >= y-k && (s[x][*prev(it)]=='.')) {
                it = prev(it);
                dist[x][*it] = dist[x][y]+1;
//                cout << x << " " << *it << " at " << dist[x][*it] << endl;
                q.push(x);
                q.push(*it);
                col[*it].erase(x);
                it = row[x].erase(it);
            }
        }
        {
            auto jt = col[y].lower_bound(x);
            while (jt != col[y].begin() && *prev(jt) >= x-k && (s[*prev(jt)][y]=='.')) {
                jt = prev(jt);
                dist[*jt][y] = dist[x][y]+1;
//                cout << *jt << " " << y << " at " << dist[*jt][y] << endl;
                q.push(*jt);
                q.push(y);
                row[*jt].erase(y);
                jt = col[y].erase(jt);
            }
        }
    }

    cout << dist[x2-1][y2-1] << endl;

    return 0;
}


Measured memory_bytes: 250924
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b , a % b);
}

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}



int main(){
  ll n,a,b,c,d; cin >> n >> a >> b >> c >> d;
  string s; cin >> s;
  
  a--; b--; c--; d--;
  
  for(ll i=a; i < d; i++){
    if(s[i] == '#' and s[i+1] == '#'){
      cout << "No" << endl;
      return 0;
    }
  }
  
  if(c < d){
    cout << "Yes" << endl;
    return 0;
  }
  
  for(ll i=b; i <= d; i++){
    if(s[i-1] == '.' and s[i] == '.' and s[i+1] == '.'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  
  cout << "No" << endl;
  
  
}

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

int main(){

  int an[5];
  for(int i = 0;i < 5;i++)cin >> an[i];
  int k; cin >> k;

  bool flag = true;

  for(int i = 0;i < 4;i++){
    for(int j = i+1;j < 5;j++){
      if(k < an[j] - an[i])flag = false;
    }
  }
  if(flag)cout << "Yay!" << endl;
  else cout << ":(" << endl;

}


Measured memory_bytes: 256
N = int(input())
A = [list(map(int, input().split())) for _ in range(2)]


def bfs(q):
    ans = 0
    while len(q):
        x, y, c = q.pop(0)
        for xx, yy in [(x + 1, y), (x, y + 1)]:
            if (xx, yy) == (N - 1, 1):
                ans = max(ans, c + A[yy][xx])
            if 0 <= xx < N and 0 <= yy < 2:
                q.append((xx, yy, c + A[yy][xx]))
    return ans


def main():
    print(bfs([(0, 0, A[0][0])]))


main()


Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] d = new int[n];
        int ans = 0;
        for(int i = 0;i < n;i++){
            d[i] = sc.nextInt();
        }
        for(int i = 0;i < n-1;i++){
            for(int j = i+1;j < n;j++){
                ans += d[i]*d[j];
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 23892
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	if(N>=30)	cout<<"Yes"<<endl;
	else		cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int, int> pii;
int main() {
    int n;cin >> n;
    string s; cin >> s;
    char temp = s[0];
    vector<char> str;
    str.push_back(s[0]);
    for(int i = 1; i < n; i++){
        if(temp == s[i]) continue;
        temp = s[i];
        str.push_back(s[i]);
    }
    cout << str.size() << endl;
    return 0;
}


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

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

    vector<int> s_height(n,0);

    for(int i = 0; i < n; ++i)
    {
        int tmp;
        cin >> tmp;
        s_height.at(i) = tmp;
    }
    
    vector<int> s_cost(n,2000000000);
    s_cost.at(0) = 0;

    for(int i = 0; i < n-2; ++i)
    {
        s_cost.at(i+1) = min(s_cost.at(i+1), s_cost.at(i)+abs(s_height.at(i+1)-s_height.at(i)));
        s_cost.at(i+2) = min(s_cost.at(i+2), s_cost.at(i)+abs(s_height.at(i+2)-s_height.at(i)));
    }

    s_cost.at(n-1) = min(s_cost.at(n-1), s_cost.at(n-2)+abs(s_height.at(n-1)-s_height.at(n-2)));


    cout << s_cost.at(n-1) << endl;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	char a;
	while (cin >> a)
	{
		if (a == 'A') cout << 'X';
		else if (a == 'B') cout << 'Y';
		else if (a == 'C') cout << 'Z';
		else
		{
			char c = a - 3;
			cout << c;
		}
	}
	cout<<endl;
	return 0;
}




Measured memory_bytes: 3104
s = input()
l = len(s)
anslist = [0 for i in range(l)]
sum_count = 0
mode = False
for i in range(l):
    if mode == True and s[i] == 'R':
        if not sum_count % 2:
            anslist[conc_num1] += int(sum_count/2)
            anslist[conc_num2] += int(sum_count/2)
        else:
            if not o_e_num % 2:
                anslist[conc_num1] += int(sum_count//2+1)
                anslist[conc_num2] += int(sum_count//2)
            else:
                anslist[conc_num1] += int(sum_count//2)
                anslist[conc_num2] += int(sum_count//2+1)
        mode = False
        sum_count = 0
    sum_count += 1
    if mode == False and s[i] == 'L':
        conc_num1 = i-1
        conc_num2 = i
        o_e_num = sum_count
        mode = True
if not sum_count % 2:
    anslist[conc_num1] += int(sum_count/2)
    anslist[conc_num2] += int(sum_count/2)
else:
    if not o_e_num % 2:
        anslist[conc_num1] += int(sum_count//2+1)
        anslist[conc_num2] += int(sum_count//2)
    else:
        anslist[conc_num1] += int(sum_count//2)
        anslist[conc_num2] += int(sum_count//2+1)
for i in range(len(anslist)):
    print(anslist[i], end = ' ')

Measured memory_bytes: 4992
#include<iostream>
#include<queue>
#include<map>
using namespace std;
const int N=2e6+6;
int n,m,cnt,nod;
map<int,int>head[N/10];
bool vis[N],vss[N];
struct Edge{
	int to,nxt,id,c;
}e[N];
namespace graph{
	struct edge{
		int to,nxt;
	}e[N];
	int head[N],cnt,dep[N];
	queue<int>q;
	inline void addedge(int u,int v){
		e[++cnt]=(edge){v,head[u]},head[u]=cnt;
		e[++cnt]=(edge){u,head[v]},head[v]=cnt;
	}
	int work(){
		dep[1]=1;
		for(q.push(1);!q.empty();){
			int u=q.front();q.pop();
			for(int i=head[u];i;i=e[i].nxt)
			if(!dep[e[i].to]){
				dep[e[i].to]=dep[u]+1;
				q.push(e[i].to);
			}
		}
		return dep[n]?dep[n]/2:-1;
	}
	void clear(int u){
		for(int i=head[u];i;i=e[i].nxt)vss[e[i].to]=0;
	}
}
void dfs(int now,int c){
	vss[now]=1;
	graph::addedge(nod,now);
	for(int i=head[now][c];i;i=e[i].nxt)if(!vis[e[i].id]){
		vis[e[i].id]=1;
		if(!vss[e[i].to])dfs(e[i].to,c);
	}
}
int main(){
	ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	cin>>n>>m;nod=n;
	for(int i=1;i<=m;++i){
		int u,v,c;
		cin>>u>>v>>c;
		e[++cnt]=(Edge){v,head[u][c],i,c},head[u][c]=cnt;
		e[++cnt]=(Edge){u,head[v][c],i,c},head[v][c]=cnt;
	}
	for(int i=1;i<=cnt;i+=2)if(!vis[e[i].id]){
		++nod;
		dfs(e[i].to,e[i].c);
		graph::clear(nod);
	}
	cout<<graph::work()<<'\n';
	return 0;
}

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

string a;
bool ada=false;
int sol;

int main(){
  cin>>a;
  for(int i=a.length()-2;i>=0;i--){
    if(i%2==1){
      if(a.substr(0,(i+1)/2) == a.substr((i+1)/2,(i+1)/2)){
        sol=i+1;
        ada=true;
        break;
      }
    }
  }
  if(ada){
    cout<<sol;
  }
  else{
    cout<<-1;
  }
}
    

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
#define pb push_back
#define show(x) cout << (#x) << " : " << x << endl;
#define ll long long
#define ld long double

#define mp make_pair
#define ff first
#define ss second
#define pii pair<ll, ll>
#define sq(x) ((x) * (x))
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
const ll MOD = 1000 * 1000 * 1000 + 7;
using namespace std;



ll N;

ll k;

ll p[100005];


ll dp[100005];
ll ans[100005];

ll rec(ll idx,ll D)
{
  
if (idx+1>D-1)
return 0;  



if (dp[idx]!=INT_MAX)
return dp[idx];



for(int j=1;j<=k;j++)
{

if (idx+j<=D-1)
ans[idx]=min(ans[idx],abs(p[idx]-p[idx+j])+rec(idx+j,D));

}

dp[idx]=ans[idx];
return dp[idx];
}


int main()
{


fastio();

cin>>N;

cin>>k;

for (int i=0;i<N;i++)
cin>>p[i];  

fill(dp,dp+N,INT_MAX);
fill(ans, ans+N,INT_MAX);

ll g=rec(0, N);

cout<<g;
    
return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a;
    cin >> a;

    string ans = "Yes";

    for(int i =0; i<a.length(); i++){
        if(i%2 == 0){
            if(a.at(i) != 'R' && a.at(i) != 'U' && a.at(i) != 'D'){
                ans = "No";
                break;
            }
        }
        if(i%2 == 1){
            if(a.at(i) != 'L' && a.at(i) != 'U' && a.at(i) != 'D'){
                ans = "No";
                break;
            }
        }
    }

    cout << ans << endl;
}



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

using namespace std;
int X,N;
int A[2000010]{};

int main()
{
  cin>>N>>X;
  int ans=X;
  for(int i=1;i<N;i++){
    ans*=X-1;
  }

  cout<<ans;
  return 0;
}





Measured memory_bytes: 3652
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s;
    int zero = 0, one = 0;
    
    cin >> s;
    
    for(int i = 0; i < s.length() ; i++){
        if(s[i] == '0'){
            zero++;
        }else if(s[i] == '1'){
            one++;
        }
    }
    cout << (zero < one ? zero : one) * 2 << endl; 
    
}


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

int main(void){
	int n;
	char s[120];
	map<char,int> m1,m2; 
	while(cin>>n>>s){
		int cnt,mx = 0;
		for(int i=0;i<n;i++){
			m1.clear();
			m2.clear();
			cnt = 0;
			for(int j=0;j<=i;j++){
				m1[s[j]] = 1;
			}
			for(int j=i+1;j<n;j++){
				m2[s[j]] = 1;
			}
			for(int i=0;i<=25;i++){
				if(m1['a'+i]&&m2['a'+i])
					cnt++;
			}
			mx = max(mx,cnt);
		}
		printf("%d\n",mx);
	}
	return 0;
} 

Measured memory_bytes: 256