akhauriyash/Code-Regression huggingface dataset:
n = int(input())
s = input()
r = 0
g = 0
b = 0
for x in s:
    if x == 'R':
        r += 1
    elif x == 'G':
        g += 1
    elif x == 'B':
        b += 1

ng_cnt = 0
for i in range(n):
    for j in range(i+1, n):
        if s[i] == s[j]:
            continue
        else:
            k = 2 * j - i
            if k < n and s[i] != s[k] and s[j] != s[k]:
                ng_cnt += 1

print(r * g * b - ng_cnt)

Measured memory_bytes: 68112
import math
def main():
  n = int(input())
  s = input()
  ans=0
  for i in range(0,n):
    sum=0
    x=s[:i+1]
    y=s[i+1:]
    while len(x)>0:
      if x[0] in y :
        sum+=1
      x=x.replace(x[0],'')
    if sum>ans:
      ans=sum
  print(ans)
main()

Measured memory_bytes: 9192
import java.util.Scanner;

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

        int[] squares = new int[N];

        for (int i = 0; i < squares.length; i++) {
            squares[i] = in.nextInt();
        }

        int min = 0, count = 0;
        boolean flag = false;
        for (int i = squares.length-1; i > 0; i--) {
            if (squares[i] <= squares[i-1]) {
                count++;
            }
            else {
                flag = true;
                min = Math.max(count, min);
                count = 0;
            }
        }

        if (flag) System.out.println(min);
        else System.out.println(count);
    }
}

Measured memory_bytes: 51592
{-# LANGUAGE BangPatterns #-}
 
module Main
  ( main
  )
where
 
import           Control.Applicative
import           Control.Monad
import           Control.Monad.ST
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import           Data.List
import           Data.Maybe
import           Data.Ord
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as MV
import qualified Data.Vector.Unboxed           as UV

parse = fst . fromJust
parseInt = parse . BS.readInt
parseInteger = parse . BS.readInteger
readInt = parseInt <$> BS.getLine
readInteger = parseInteger <$> BS.getLine
readIntList = map parseInt . BS.words <$> BS.getLine
readIntegerList = map parseInteger . BS.words <$> BS.getLine

main = do
  [k, s] <- readIntList
  let candidate = solve k s
  print $ length candidate

solve k s = do
  a <- [0..k]
  b <- [0..(min (s - a) k)]
  let c = s - a - b
  if c >= 0 && c <= k 
    then return (a, b, c) 
    else []


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

int main()
{
  int n;
  cin>>n;
  vector<int>a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a[i];
  }

  int count=0;
  int Num=1;
  for(int i=0;i<n;i++)
  {
    if(a[i]==Num)
    {
      Num++;
    }
    else
    {
      count++;
    }
    
    if(i==n-1 && count>0 && Num==1)
    {
      count=-1;
    }
  }
  cout<<count<<endl;

  return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

  long n;
  long i;
  long ans[1000000];
  long sum = 0;
  
  scanf("%ld",&n);
  
  for(i = 0; i <= n; i++){
  	if(i % 15 == 0 || i % 5 == 0 || i % 3 == 0){
      ans[i] = 0;
      //printf("%d\n", ans[i]);
    }else{
      ans[i] = i;
      //printf("%d\n", ans[i]);
    }
  }
    
    for(i = 0; i <= n; i++){
      sum += ans[i];
    }
   
    printf("%ld", sum);
  
  return 0;
}

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,x,n) for(int i=x;i<n;i++)
#define mod 1000000007 //10^9+7
#define INF 1000000000000 //10^12
#define F first
#define S second
//#define P pair<int,int>
#define all(vec) vec.begin(),vec.end()
//library begin
int gcd(int a,int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a*b/gcd(a,b);
}
int log(int a){
    int b=a;
    int cnt=0;
    while(b%2==0){
        b/=2;
        cnt++;
    }
    return cnt;
}
int mypow(int a,int b){
    if(b==0)return 1;
    if(b==1)return a;
    int t=mypow(a,b/2);
    if(b%2==0)return (t*t)%mod;
    return (t*t*a)%mod;
}

//library end
vector<int>eight,ten;
signed main(){
    int a,b;
    cin>>a>>b;
    for(int i=1;i<2000;i++){
        int va=i*0.08,vb=i*0.1;
        if(va==a&&vb==b){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
data=[int(input()) for i in range(n)]
x=1
was=set()
now=1
while x==1:
    if now==2:
        print(len(was))
        break
    if now in was:
        print('-1')
        break
    was|={now,}
    now=data[now-1]
    

Measured memory_bytes: 13212
#![allow(unused_parens)]
#![allow(unused_imports)]
#![allow(non_upper_case_globals)]
#![allow(non_snake_case)]
#![allow(unused_mut)]
#![allow(unused_variables)]
#![allow(dead_code)]

use itertools::Itertools;
use proconio::input;
use proconio::marker::{Chars, Usize1};

#[allow(unused_macros)]
#[cfg(debug_assertions)]
macro_rules! mydbg {
    //($arg:expr) => (dbg!($arg))
    //($arg:expr) => (println!("{:?}",$arg));
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
      }
}
#[cfg(not(debug_assertions))]
macro_rules! mydbg {
    ($($arg:expr),*) => {};
}

macro_rules! echo {
    ($($a:expr),*) => {
          $(println!("{}",$a))*
      }
}

use std::cmp::*;
use std::collections::*;
use std::ops::{Add, Div, Mul, Sub};

#[allow(dead_code)]
static INF_I64: i64 = 92233720368547758;
#[allow(dead_code)]
static INF_I32: i32 = 21474836;
#[allow(dead_code)]
static INF_USIZE: usize = 18446744073709551;
#[allow(dead_code)]
static M_O_D: usize = 1000000007;
#[allow(dead_code)]
static PAI: f64 = 3.1415926535897932;

trait IteratorExt: Iterator {
    fn toVec(self) -> Vec<Self::Item>;
}

impl<T: Iterator> IteratorExt for T {
    fn toVec(self) -> Vec<Self::Item> {
        self.collect()
    }
}

trait CharExt {
    fn toNum(&self) -> usize;
    fn toAlphabetIndex(&self) -> usize;
    fn toNumIndex(&self) -> usize;
}
impl CharExt for char {
    fn toNum(&self) -> usize {
        return *self as usize;
    }
    fn toAlphabetIndex(&self) -> usize {
        return self.toNum() - 'a' as usize;
    }
    fn toNumIndex(&self) -> usize {
        return self.toNum() - '0' as usize;
    }
}

trait VectorExt {
    fn joinToString(&self, s: &str) -> String;
}
impl<T: ToString> VectorExt for Vec<T> {
    fn joinToString(&self, s: &str) -> String {
        return self
            .iter()
            .map(|x| x.to_string())
            .collect::<Vec<_>>()
            .join(s);
    }
}

trait StringExt {
    fn get_reverse(&self) -> String;
}
impl StringExt for String {
    fn get_reverse(&self) -> String {
        self.chars().rev().collect::<String>()
    }
}

trait UsizeExt {
    fn pow(&self, n: usize) -> usize;
}
impl UsizeExt for usize {
    fn pow(&self, n: usize) -> usize {
        return ((*self as u64).pow(n as u32)) as usize;
    }
}

fn main() {
    input! {
       N: usize,
       K:usize,
       mut a:[usize;N],
    }
    a.sort();
    let mut ans: usize = a.iter().take(K).fold(0, |a, x| a + x);

    echo!(ans);
}


Measured memory_bytes: 2120
///見ました

#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long l,r;
  cin >> l >> r;
  r = min(r,l+4038);
  
  int ans=2018;
  
  for(long long i=l; i<r; i++){
    for(long long j=l+1; j<=r; j++){
     int x = i*j%2019;
      ans = min(ans,x);
    }
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n)
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define var(n) int n; scn(n)
#define F first
#define S second 
#define pb(n) push_back(n)
#define pii pair<int,int> 
#define all(x) (x).begin(),(x).end()
const int N=2e5+5;
const ll M=1e9+7;
const ll inf=1e18+5;


int main()
{
	var(n);
	ll ans = 0;
	for(int i=0;i<n;i++)
	{
		var(x);
		ans+=x-1;
	}
	lpri(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define IOS                                                                    \
  ios_base::sync_with_stdio(false);                                            \
  cin.tie(0);                                                                  \
  cout.tie(0)
#define ll long long int
#define ld long double
#define el '\n'
#define PI (ld)3.141592653589793238462643383279502884197169399375105820974944
#define inf (ll)1000000000
#define mod (ll)1000000007
#define mod1 (ll)998244353
#define fo(i, n) for (long long i = 0; i < int(n); i++)
#define pll pair<ll, ll>
#define ml map<ll,ll>
#define vli vector<pair<ll,int>>
#define vpl vector<pll>
#define vvl vector<vector<ll> >
#define vvpl vector< vector<pll> >
#define ff first
#define ss second
#define pqueue priority_queue< ll >
#define pdqueue priority_queue< ll,vl ,greater< ll > >
#define mem(a,b) memset(a,b,sizeof(a));
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define sz(a) (ll)a.size()
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fd(i,a,b) for(ll i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define vl vector<ll>
//#define x ff
//#define y ss
#define pt(a) for(auto it:a)cout<<it<<" ";cout<<endl;
unsigned seed = std::chrono::system_clock::now().time_since_epoch().count();
using namespace std;

double gcd(double a, double b) { return a < 0.01 ? b : gcd(fmod(b, a), a); }

vector<ll> parent, rak;

void make_set(int f){
    fo(i,f+1)parent.pb(i);
    rak.assign(f+1,1);
}

ll find_set(ll v) {
    if (v == parent[v])
        return v;
    return parent[v] = find_set(parent[v]);
}

ll union_sets(ll a, ll b) {
    a = find_set(a);
    b = find_set(b);
    if (a != b) {
        if (rak[a] < rak[b])
            swap(a, b);
        parent[b] = a;
        rak[a]+=rak[b];
        return (rak[a]-rak[b])*(rak[b]);
    }
    return 0;
}

long long bpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
  }
  return res;
}
ll extend_gcd(ll a,ll b,ll &x,ll &y){
    if(b==0){
        x=1;
        y=0;
        return a;
    }
    ll x1,y1;
    ll ans =extend_gcd(b,a%b,x1,y1);
    x=y1;
    y=x1-(a/b)*y1;

    return ans;
}
ll inverse(ll a,ll m){
    ll x,y;
    extend_gcd(m,a,x,y);
    y%=m;
    y+=m;
    y%=m;
    return y;
}

/*const int N = 1000001;
int lp[N+1];
vector<int> pr;
void s(){
for (int i=2; i<=N; ++i) {
        if (lp[i] == 0) {
            lp[i] = i;
            pr.push_back (i);
        }
        for (int j=0; j<(int)pr.size() && pr[j]<=lp[i] && i*pr[j]<=N; ++j)
            lp[i * pr[j]] = pr[j];
    }
}*/


ll kv;
ll t,n,x,y,h,k,z,p,q,w;
string s;
//vvl v;
//vl vis,d;

int main() {
    IOS;
    cin>>n;
    ll a[n];
    fo(i,n)cin>>a[i];x=1;
    do{
        x=0;h=0;
        fo(i,n){
            if(a[i]>0&&h==0)a[i]--,kv++,x=1,h=1;
            else if(a[i]>0)a[i]--,x=1;
            else if(a[i]==0)h=0;
        }
    }while(x!=0);
    cout<<kv;
    return 0;
}


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

long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}

int main () {

    int N;
    ll H;
    cin >> N >> H;
    ll a[N],b[N],cmp=0,count=0;
    for(ll i = 0; i < N; i++) {
        cin >> a[i] >> b[i];
    }
    sort(a,a+N);
    sort(b,b+N);
    reverse(b,b+N);
    for(ll i = 0; i < N; i++) {
        if(b[i] < a[N-1]) {
            break;
        }
        cmp += b[i];
        count++;
        if(cmp >= H) {
            cout << count << endl;
            return 0;
        }
    }
    count+=(H-cmp)/a[N-1];
    if((H-cmp)%a[N-1]!=0) {
        count++;
    }
    cout << count << endl;
    return 0;
}


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

int n;
vector<int> adj[100005];
long long dp[100005][2];
const long long MOD = 1e9+7;

void dfs(int x,int par){
	if(adj[x].size() == 1){
		dp[x][0] = 1;
		dp[x][1] = 1;
		return;
	}
	dp[x][0] = dp[x][1] = 1;
	for(int y:adj[x]){
		if(y == par)continue;
		dfs(y,x);
		dp[x][0] *= (dp[y][0] + dp[y][1])%MOD;
		dp[x][0] %= MOD;
		dp[x][1] *= dp[y][0];
		dp[x][1] %= MOD;
	}
}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	cin>>n;
	for(int i=1;i<n;i++){
		int x,y;
		cin>>x>>y;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}
	
	if(n == 1){
		cout<<2;
		return 0;
	}
	if(n == 2){
		cout<<3;
		return 0;
	}
	int ans = 0;
	for(int i=1;i<=n;i++){
		if(adj[i].size()!=1){
			dfs(i,i);
			ans = dp[i][0] + dp[i][1];
			ans%=MOD;
			cout<<ans;
			return 0;
		}
	}
	
	// beware of n == 1 and n == 2
	return 0;
}


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

int main(){
    string s1, s2;
    cin >> s1 >> s2;
    
    int n = s1.size(), m = s2.size();
    
    vector<vector<int>> dp(n + 1, vector<int>(m + 1));
    
    for(int i = 0; i <= m; ++i)dp[0][i] = i;
    
    for(int i = 1; i <= n; ++i){
        dp[i][0] = i;
        for(int j = 1; j <= m; ++j){
            dp[i][j] = min({dp[i - 1][j] + 1, dp[i][j - 1] + 1, dp[i - 1][j - 1] + (s1[i - 1] != s2[j - 1])});
        }
    }
    
    cout << dp[n][m] << endl;
    return 0;
}


Measured memory_bytes: 6756
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
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; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */



template<class Type>
Type solve(Type res = Type()){
    ll N; cin >> N;
    vector<ll> A(N); for(auto& in:A) cin >> in;
    map<ll,ll> mp;
    for(auto& a:A) mp[a]++;
    sort(A.begin(),A.end());
    A.erase(unique(A.begin(),A.end()),A.end());
    
    int l = 0;
    int sz = (int)A.size();
    while(true){
        if(l == sz) break;
        if(mp[A[l]] != 1){
            if(mp[A[l]]%2 == 1){
                mp[A[l]] = 1;
            }else{
                mp[A[l]] = 1;
                int r = l+1;
                bool ok = false;
                while(true){
                    if(r == sz){
                        mp[A[r-1]]--;
                        ok = true;
                        break;
                    }
                    if(mp[A[r]] >= 2){
                        mp[A[r]]--;
                        break;
                    }
                    r++;
                }
                if(ok) break;
            }
        }
        l++;
    }
    for(auto p:mp) res += p.second;
    cout << res << endl;
    return res;
}


int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<string>() << endl;
    return 0;
}


Measured memory_bytes: 7296
a, b, c = map(int, input().split())
if a == 5:
    if (b == 5) & (c == 7):
        print("YES")
    elif (b == 7) & (c == 5):
        print("YES")
    else:
        print("NO")
elif a == 7:
    if (b == 5) & (c == 5):
        print("YES")
    else:
        print("NO")
else:
    print("NO")

Measured memory_bytes: 3064
use v5.26; # strict say state biwise
use warnings;
use List::Util qw(reduce any all none notall first max maxstr min minstr product sum sum0 pairs unpairs pairkeys pairvalues pairfirst pairgrep pairmap shuffle uniq uniqnum uniqstr);

sub pow {
  my $d = shift;
  if ($d == 0) {
    1;
  } elsif ($d == 1) {
    10;
  } elsif ($d % 2 == 1) {
    (10 * pow($d - 1)) % 2019;
  } else {
    (pow($d / 2) ** 2) % 2019;
  }
}
my @s;
{
  chomp (my $in = <STDIN>);
  @s = split '', $in;
}
my $ans = 0;
my (@dp, @dpmod);
$dp[0] = 1;
for my $i (1..scalar(@s)) {
  my $t = $s[-$i];
  $dpmod[$i] = ($t * pow($i) + $dpmod[$i - 1]) % 2019;
  $ans += $dp[$dpmod[$i]];
  $dp[$dpmod[$i]]++;
}
say $ans;

Measured memory_bytes: 27644
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {
	
	long long int n;
	long long int count = 0;
	long long int totala = 0, totalb = 0;
	long long int res = 0;


	cin >> n;
	vector<long long int> a(n), b(n), sa(n);
	vector<P> pa(n);
	FOR(i, 0, n-1) {
		cin >> a[i];
		pa[i].first = a[i];
		totala += a[i];
	}
	FOR(i, 0, n - 1) {
		cin >> b[i];
		pa[i].second = b[i];
		totalb += b[i];
	}
	FOR(i, 0, n - 1) {
		sa[i] = a[i] - b[i];
	}

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

	if (totala < totalb) {
		count = -1;
	}
	else {
		FOR(i, 0, n - 1) {
			if (sa[i] < 0) {
				res += sa[i];
				count++;
				//cout << res << endl;
			}
			else {
				break;
			}
			
		}

		RFOR(i, n - 1, 0) {
			if (res >= 0) {
				break;
			}
			res += sa[i];
			count++;
			//cout << res << endl;
			if (res >= 0) {
				break;
			}
		}
	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 4096
#include<bits/stdc++.h>
#define fi first
#define er erase
#define in insert
#define se second
#define pp pop_back
#define pb push_back
#define mp make_pair
#define ll long long
#define vec vector<int>
#define pii pair<int,int>
#define smin(a,b) (a=min(a,b))
#define smax(a,b) (a=max(a,b))
#define fl(a,x) memset(a,x,sizeof a)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define cs ios_base::sync_with_stdio(0),cin.tie(0)
using namespace std;
const int mx=2e5+10;
int main(){
    cs;
    int cnt=0;
    int k,s;cin>>k>>s;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++){
            if(s-i-j>=0 && s-i-j<=k) cnt++;
    }
    cout<<cnt;
}


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

using namespace std;

typedef long long int ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int INF = 1000000000;
const ll LINF = (ll) 4000000000000000000;
const ll MOD = (ll) 1000000007;
const double PI = acos(1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define NP(v) next_permutation(v.begin(),v.end())
#define smaller_queue  priority_queue <ll, vector<ll>, greater<ll> >
//------------------------------------------------------

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

    vector<int> v;

    rep(i, n) {
        int a;
        cin >> a;
        v.push_back(a);
    }

    rep(i, n - 1) {
        if (v[i] == v[i + 1]) {
            v[i + 1] = limit + i;
            cnt++;
        }
    }

    cout << cnt << endl;


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>//////////////////////////////////////////
#define deb(...)/////////////////////////////////////////////////
#define DBP(...)/////////////////////////////////////////////////
#ifdef LOC///////////////////////////////////////////////////////
#include"debuglib.h"/////////////////////////////////////////////
#endif///////////////////////////////////////////////////////////
#define x first//////////////////////////////////////////////////
#define y second/////////////////////////////////////////////////
#define pb push_back/////////////////////////////////////////////
#define sz(x)int((x).size())/////////////////////////////////////
#define each(a,x)for(auto&a:(x))/////////////////////////////////
#define all(x)(x).begin(),(x).end()//////////////////////////////
#define rep(i,b,e)for(int i=(b);i<(e);i++)///////////////////////
using namespace std;using ll=long long;using Pii=pair<int,int>;//
using Vi=vector<int>;void run();int main(){cin.sync_with_stdio///
(0);cin.tie(0);cout<<fixed<<setprecision(18);run();return 0;}////
//-------------------------------------------------------------//

constexpr ll MOD = 998244353;

struct Zp {
	ll x;
	Zp(ll a = 0) {
		if (a < 0) a = a%MOD + MOD;
		else if (a >= MOD*2) a %= MOD;
		else if (a >= MOD) a -= MOD;
		x = a;
	}
	Zp operator+(Zp r) const{ return x+r.x; }
	Zp operator-(Zp r) const{ return x-r.x+MOD; }
	Zp operator*(Zp r) const{ return x*r.x; }
	Zp operator/(Zp r) const{return x*r.inv().x;}
	Zp operator-()     const{ return MOD-x; }
	Zp inv() const { return pow(MOD-2); }
	Zp pow(ll e) const {
		Zp t = 1, m = *this;
		while (e) {
			if (e & 1) t = t*m;
			e >>= 1; m = m*m;
		}
		return t;
	}
	#define OP(c) Zp& operator c##=(Zp r){ return *this=*this c r; }
	OP(+)OP(-)OP(*)OP(/)
	void print() { cerr << x; }
};

constexpr int MAX_V = 90001;
Zp dp[301][MAX_V]; // (sum, prefix) -> options
Zp dp2[301][MAX_V];

void run() {
	int n; cin >> n;
	Vi elems(n);
	each(e, elems) cin >> e;

	int sum = 0;
	each(e, elems) sum += e;
	dp[0][0] = 1;
	dp2[0][0] = 1;

	rep(i, 0, n) {
		rep(j, 0, sum+1) {
			dp[i+1][j] = dp[i][j];
			dp2[i+1][j] = dp2[i][j];
			if (j-elems[i] >= 0) {
				dp[i+1][j] += dp[i][j-elems[i]]*2; // red or green
				dp2[i+1][j] += dp2[i][j-elems[i]];
			}
		}
	}

	Zp ans = Zp(3).pow(n);

	rep(rg, 0, sum+1) {
		int b = sum-rg;
		if (rg <= b) {
			ans -= dp[n][rg]*3;
		}
		if (rg == b) {
			ans += dp2[n][rg]*3;
		}
	}

	cout << ans.x << endl;
}


Measured memory_bytes: 423680
/*
* ID: juryc
* PROG: Round One
* LANG: C++
*/
#include<bits/stdc++.h>
using namespace std;
int main(){
int n; cin>>n;
string s,t; cin>>s>>t;
string g="";
for(int i=0;i<n;i++){
g=g+s[i]; g=g+t[i]; 
}
cout<<g<<"\n"; 
return 0;
}

Measured memory_bytes: 3640
/**
 * @author torith
 * @date 2018-12-22
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

map<ll, ll> prime;

void prime_find(ll n){
    for (ll i = 2; i <= sqrt(n) + 2; i++) {
        while(n % i == 0){
            n /= i;
            prime[i]++;
        }
    }
    if(n > 1) prime[n]++;
    return;
}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N, P; cin >> N >> P;

    if(N == 1) {
        cout << P << "\n";
        return 0;
    }

    prime_find(P);

    ll ans = 1;
    for(auto& i: prime) {
        if(i.second >= N) {
            ans *= pow(i.first, (i.second / N));
        };
    }
    cout << ans << "\n";

    return 0;
}



Measured memory_bytes: 256
open System

[<EntryPoint>]
let main _ =
    let n = stdin.ReadLine() |> int
    let ans =
        match n with
        | m when m >= 64 -> 64
        | m when m >= 32 -> 32
        | m when m >= 16 -> 16
        | m when m >= 8 -> 8
        | m when m >= 4 -> 4
        | m when m >= 2 -> 2
        | m when m >= 1 -> 1
        | _ -> 0
    stdout.WriteLine ans
    0


Measured memory_bytes: 13268
import java.util.*;
import java.io.*;

class Main {

    public static void main(String[] args) {

	final Scanner stdin = new Scanner(System.in);
	final StringBuilder sb = new StringBuilder();
	
	while ( stdin.hasNextLine() ) {
	    sb.append( stdin.nextLine() );
	}

	final String input = sb.toString().replaceAll( "[^0-9]", " " );
	final Scanner ir = new Scanner( input );

	int sum = 0;
	while ( ir.hasNextInt() ) {
	    sum += ir.nextInt();
	}
	System.out.println( sum );
    }    
}

Measured memory_bytes: 19428
//Himanshu Shukla
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
//#define file_input
//#define multitest
//#define measure_time
#define ll long long
#define v32 vector<int>
#define v64 vector<ll>
#define s32 set<int>
#define s64 set<ll>
#define graph vector<v32>
#define p32 pair<int, int>
#define p64 pair<ll, ll>
#define sz(v) (ll)(v).size()
#define fi first
#define se second
#define ln '\n'
#define debug(x) cerr << (#x) << ": " << (x) << ln
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
inline ll add(ll a, ll b, ll m) { return (((a % m + b % m) % m + m) % m); }
inline ll mul(ll a, ll b, ll m) { return (((a % m * b % m) % m + m) % m); }
const double EPS = 1e-6;
const ll MOD = 1e9 + 7;
template <typename T, typename U>
ostream &operator<<(ostream &out, const pair<T, U> &p)
{
    out << '[' << p.fi << ", " << p.se << ']';
    return out;
}
template <template <typename, typename...> class ContainerType, typename ValueType, typename... Args>
void print_container(const ContainerType<ValueType, Args...> &c)
{
    cout << "{ ";
    for (const auto &v : c)
        cout << v << ' ';
    cout << '}' << ln;
}

const int N = 2e5 + 5;
ll dp[N][2];

void solve()
{
    int n;
    cin >> n;
    v64 arr(n + 1, 0);
    for (int i = 1; i < n + 1; i++)
        cin >> arr[i];
    memset(dp, 0, sizeof(dp));
    dp[2][1] = arr[2];
    dp[2][0] = arr[1];
    for (int i = 3; i < n + 1; i++)
    {
        if (i & 1)
        {
            ll temp = max({dp[i - 3][1], dp[i - 3][0], dp[i - 2][1], dp[i - 2][0]});
            dp[i][1] = arr[i] + temp;
            dp[i][0] = dp[i-1][1] ;
        }
        else
        {
            dp[i][1] = arr[i] + max({dp[i - 2][1], dp[i - 2][0], dp[i - 1][0]});
            dp[i][0] = arr[i - 1] + dp[i - 2][0];
        }
    }
    cout << max(dp[n][1], dp[n][0]) << ln;
    return;
}

int main()
{
    FASTIO;
#ifdef file_input
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    clock_t start, stop;
    int t = 1;
#ifdef multitest
    cin >> t;
#endif
#ifdef measure_time
    start = clock();
#endif
    for (int tc = 1; tc < t + 1; tc++)
        solve();
#ifdef measure_time
    stop = clock();
    cerr << "Time :" << fixed << setprecision(5) << double(stop - start) / double(CLOCKS_PER_SEC) << "s" << ln;
#endif
    return 0;
}


Measured memory_bytes: 7988
#include <bits/stdc++.h>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define descSort(a) sort(a.begin(),a.end(),std::greater<int>())
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
ll gcd(ll x,ll y){
    if(x%y==0)return y;
    return gcd(y,x%y);
}


vector<vector<bool>> connect(8,vector<bool>(8,false));
int dfs(int now,int n,vector<bool> visited){
    bool all_visited = true;
    rep(i,0,n){
        if(visited[i]==false) all_visited=false;
    }
    if(all_visited)return 1;
    int ans=0;
    rep(i,0,n){
        if(connect[now][i]==false || visited[i])continue;
        visited[i]=true;
        ans+=dfs(i,n,visited);
        visited[i]=false;
    }
    return ans;
}
int main(void){
    int n,m;
    cin>>n>>m;
    vector<int> a(m),b(m);
    rep(i,0,m){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
        connect[a[i]][b[i]]=connect[b[i]][a[i]]=true;
    }
    vector<bool> visited(n,false);
    visited[0]=true;
    cout<<dfs(0,n,visited)<<endl;
    return 0;
}

Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
cnt = 0
for i in range(c+1):
    for j in range(b+1):
        for k in range(a+1):
            if i*50 + j*100 + k*500 ==x:
                cnt +=1
print(cnt)

Measured memory_bytes: 3060
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline

    n = int(input())

    m = 1046527

    H = [None]*m

    table = str.maketrans({
    'A':'1',
    'C':'2',
    'G':'3',
    'T':'4',
    })

    # 文字から数値に変換
    # https://qiita.com/tag1216/items/df6c93bdb823dd48af6c参照
    def getChar(string):
        return int(string.translate(table))

    # pythonでは12桁でもメモリを考えず動くのでgetKeyを実装していません。

    def h1(key):
        return key % m

    def h2(key):
        return 1 + (key % (m-1))

    def find(string):
        i = 0
        key = getChar(string)
        while True:
            h = (h1(key) + i*h2(key))%m
            if H[h] == string:
                return 1
            elif H[h] is None:
                return 0
            else:
                i += 1

    def insert(string):
        i = 0
        key = getChar(string)
        while True:
            h = (h1(key) + i*h2(key))%m
            if H[h] is None:
                H[h] = string
                break
            else:
                i += 1

    for _ in range(n):
        com, string = input().split()
        if com[0] == 'i':
            insert(string)
        else:
            if find(string):
                print('yes')
            else:
                print('no')



Measured memory_bytes: 48580
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#include <cmath>
#include <string>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define Cout(s) cout<<s<<endl

bool sosuu(const int x)
{
	if (x == 2)return true;
	if (x < 2 || x % 2 == 0)return false;
	for (int i = 3; i * i <= x; i += 2)
		if (x % i == 0)return false;
	return true;
}

typedef long long ll;
using namespace std;
string Yes(bool b) { if (b) { return "Yes"; } else { return "No"; } }
string YES(bool b) { if (b) { return "YES"; } else { return "NO"; } }
//================================================

int a = 0, b = 0, c, d, n, k = 0,ans=0;
string s, t;


int main()
{
	cin >> n; bool x = false;
	while (x == false)
	{
		if (sosuu(n))
		{
			x = true; cout << n << endl; return 0;
		}
		else
			n++;
	}
	return 0;
}

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

bool isEven(string s){
	int n=(int) s.length();
	return s.substr(0,n/2) == s.substr(n/2,n/2);
}

int main(){
	string s;
	cin >> s;
	int n = (int) s.length();
	for(int i = 2; i<n; i+=2){
		if (isEven(s.substr(0,n-i))) {
			cout << n-i;
			return 0;
		}
	}
	
			
     
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll INF = 1ll << 60;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
  string S; cin >> S;
  if (S == "ABC") cout << "ARC" << endl;
  else cout << "ABC" << endl;

  return 0;
}


Measured memory_bytes: 3560
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define m_p make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
int k,x;
int main(){
	cin>>k>>x;
	if(k*500>=x)
	cout<<"Yes";
	else
	cout<<"No"; 
	re 0;
}


Measured memory_bytes: 256
n = int(input())
i = 1
m = 0
alp = list(map(str,"abcdefghijklmnopqrstuvwxyz"))
ls = []
while True:
    if m + 26**i < n:
        m += 26**i
        i += 1
    else:
        break
ans = n-m
for ii in range(i):
    l = i-ii
    q = ans//(26**(l-1))
    if  ans/(26**(l-1)) % 1 != 0:
        q += 1
    ans -= q*(26**(l-1))
    ls.append(alp[q-1])
print("".join(ls))

Measured memory_bytes: 9248
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class Program
{
    static void Main()
    {
        string A = Console.ReadLine().Trim();
        string B = Console.ReadLine().Trim();

        var kouho = new List<string>();
        kouho.Add("1");
        kouho.Add("2");
        kouho.Add("3");

        kouho.Remove(A);
        kouho.Remove(B);

        Console.WriteLine(kouho[0]);
    }
}

Measured memory_bytes: 11100
#include <bits/stdc++.h>
using namespace std;
int main() {
  string a;
  cin >> a;
  int st = a.length();
  if (a[st-1] == 's'){
    cout << a << "es" << endl;
  }
  else { cout << a << "s" << endl; }
  
  return 0;
  
}
  

Measured memory_bytes: 3620
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <map>
#include <functional>


int main(int argc, char *argv[]){
    long int N,M;
    std::cin >> N >> M;
    std::vector<long int> A(N);
    for(auto &a : A){
        std::cin >> a;
    }
    std::sort(A.begin(),A.end());


    std::vector<std::pair<long int,long int> >BC(M);
    for(auto &bc : BC){
        std::cin >> bc.first >> bc.second;
    }

    std::sort(BC.begin(),BC.end(),
        [](const auto &a, const auto &b){
            return (a.second > b.second) || (a.second == b.second && a.first > b.first);
        });

    auto leftIter = A.begin();
    auto rightIter = A.begin();
    for(const auto &bc : BC){
        const auto &B = bc.first;
        const auto &C = bc.second;
        rightIter += B;
        rightIter = std::min(rightIter,A.end());
        rightIter = std::lower_bound(leftIter,rightIter,C);
        for(auto iter=leftIter; iter!=rightIter; ++iter){
            *iter = C;
        }
        leftIter = rightIter;
    }

    std::cout << std::accumulate(A.begin(),A.end(),0l) << std::endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <cmath>
#include <iostream>
#include <functional>
#include <string>
#include <sstream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <iomanip>
#include <math.h>
#include <list>
#include <numeric>
using namespace std;

int main(){    
  int N;
  cin >> N;
  int j=0,B;
  int A[N];
  
  for(int i=0;i<N;i++){
    cin >> B;
    if(B%2==0){
      if(B%3!=0 && B%5!=0){
	cout << "DENIED" << endl;
	return 0;
      }
    }
  }
  cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//CLOCKS_PER_SEC
#define se second
#define fi first
#define ll long long
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define Pii pair<int,int>
#define Pli pair<ll,int>
#define ull unsigned long long
#define pb push_back
#define fio ios::sync_with_stdio(false);cin.tie(0)
const double Pi=3.14159265;
const int N=1e4+5;
const ull base=163;
const int INF=0x3f3f3f3f;
using namespace std;
int main(){
    string s;cin>>s;
    ll x;cin>>x;
    int now=0;
    for(int i=0;s[i];++i){
        if(s[i]!='1'){
            now=i;
            break;
        }
    }
    if(now==0&&s[0]=='1')now=s.size();
    if(x<=now)cout<<1;
    else cout<<s[now];
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;


int main(){
  string s;
  //scanf("%s",s);
  cin >> s;
  int ans=0;
  vector<string> t={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  rep(i,t.size()){
   if(s == t[i])ans = 7-i;
  }
  
  printf("%d",ans);
}



Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>


/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */


#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
const ll inf = 1000000000000000;
ll in = 1000000000000000000;
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
int main()
{
	FastIO;
	ll t, a, i, j, k, m,n, q,b,c;
	cin >> n >> k;
	vector<ll>v;
	f(i, n)
	{
		cin >> a;
		v.push_back(a);
	}
	sort(all(v));
	ll sum = 0;
	f(i, k)
	{
		sum += v[i];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3628
N,M=map(int,input().split())
AB=[list(map(int,input().split())) for i in range(N)]
r=0
from heapq import heappop,heappush
q=[]
l=[[] for i in range(10**5)]
for a,b in AB:
    l[a-1].append(b)
for i in range(M):
    for e in l[i]:
        heappush(q,-e)
    if len(q)>0:
        r+=-heappop(q)
print(r)

Measured memory_bytes: 39592
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

using namespace std;

int main() {
	char a;
	int o=0;
	rep (i, 3) {
		cin >> a;
		if (a == '1') {
			o++;
		}
	}
	cout << o << endl;
}

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

int main(void){
  long long n;
  std::cin >> n;

  std::string ans = "";

  while(n){
    n--;
    ans  += (char)('a' + (n % 26));
    n /= 26;
  }

  std::reverse(ans.begin(), ans.end());

  std::cout << ans << std::endl;

  return 0;

}

Measured memory_bytes: 3612
#pragma GCC optimize("Ofast") 
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define sz(a) a.size()
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define owo ios_base::sync_with_stdio(0);cin.tie(0);
#define MOD (ll)(1e9+7)
#define INF (ll)(1e18)
#define debug(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define time__(d) for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false);\
debug("%s time : %.4fs\n", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> PII;
typedef pair<int,int> pii;
typedef vector<vector<int>> vii;
typedef vector<vector<ll>> VII;
ll gcd(ll a,ll b){if(!b)return a;else return gcd(b,a%b);}
vector<ll> fact;
vector<ll> ifact;
ll add(ll a,ll b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
ll mult(ll a,ll b)
{
	return (a*1LL*b)%MOD;
}
ll binpow(ll a, ll b)
{
	ll r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
ll choose(ll a, ll b)
{
	if(a<b) return 0;
	if(b==0) return 1;
	if(a==b) return 1;
	ll r = mult(ifact[b],ifact[a-b]);
	r = mult(r,fact[a]);
	return r;
}
ll inv(int a){return binpow(a,MOD-2);}
void init(ll n)
{
	fact.clear(); ifact.clear();
	fact.resize(n+1);
	ifact.resize(n+1);
	ifact[0]=1;
	fact[0]=1;
	for(int i=1;i<=n;i++){fact[i]=mult(fact[i-1],i);}
	ifact[n] = inv(fact[n]);
	for(int i=n-1;i>=1;i--)
	{
		ifact[i] = mult(ifact[i + 1], i + 1);
	}
}
ll rchoose(ll n,ll r){
	ll res = 1;
	for(int i=0;i<r;i++)res = mult(res,n-i);
	return res;
}
int main()
{
	ll n;
	cin>>n;
	init(n);
	if(n == 1)cout<<0<<'\n';
	else{
		ll total = binpow(10,n);
		total-=binpow(8,n);
		total+=MOD;
		total%=MOD;
		for(int i=1;i<=n;i++){
			ll res = choose(n,i);
			res = mult(res,binpow(8,n-i));
			res = mult(res,2);
			//cout<<res<<'\n';
			total-=res;
			total+=MOD;
			total%=MOD;
		}
		total+=MOD;
		total%=MOD;
		cout<<total;
	}
	
}


Measured memory_bytes: 18632
import sys
N = int(input())
W = []
for _ in range(N):
    W.append(input())
for i in range(N):
    if W.count(W[i]) >= 2:
        print('No')
        sys.exit()
    elif i < N - 1:
        if not W[i][len(W[i]) - 1] == W[i + 1][0]:
            print('No')
            sys.exit()
print('Yes')



Measured memory_bytes: 3060
#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 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);
}

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

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



int main(){
  string s,t; cin >> s >> t; ll n = s.size(); bool ans = false;
  
  for(ll i=0; i < n; i++){
    bool flag = true;
    
    for(ll j=0; j < n; j++){
      if(s[j] != t[(i+j) % n]){
        flag = false;
        break;
      }
    }
    
    if(flag) ans = true;
  }
  
  if(ans) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }



bool contain(string str, string sub) {
    for (int i = 0; i < (int)str.size() - (int)sub.size() + 1; ++i) {
        if (str.substr(i, (int)sub.size()) == sub) return true;
    }
    return false;
}

struct data {
    string title, author, date;
    
    data(string t_, string a_, string d_) { title = t_; author = a_; date = d_; }
    
    bool equal(string t, string a, string from, string to) {
        if (t != "*") {
            if (!contain(title, t)) return false;
        }
        if (a != "*") {
            if (!contain(author, a)) return false;
        }
        if (from != "*") {
            if (from > date) return false;
        }
        if (to != "*") {
            if (to < date) return false;
        }
        return true;
    }
};

int n, q;

int main() {
    while (cin >> n) {
        vector<data> se;
        for (int i = 0; i < n; ++i) {
            string a, b, c;
            cin >> a >> b >> c;
            se.PB(data(a, b, c));
        }
        cin >> q;
        for (int i = 0; i < q; ++i) {
            string t, a, from, to;
            cin >> t >> a >> from >> to;
            
            for (int i = 0; i < se.size(); ++i) {
                data d = se[i];
                if ( d.equal(t, a, from, to)) {
                    cout << d.title << endl;
                }
            }
            if (i != q-1) cout << endl;
        }            
    }
    return 0;
}


Measured memory_bytes: 1244
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr
def gcd(x,y):
    if x==y:
        return x
    elif x>y:
        r=-1
        while r!=0:
            r=x%y
            x=y
            y=r
        return x
    else:
        r=-1
        while r!=0:
            r=y%x
            y=x
            x=r
        return y

a,b=map(int,input().split())
x=gcd(a,b)
l=factorization(x)
ans=1
ans+=len(l)
if x==1:
    print(1)
else:
    print(ans)


Measured memory_bytes: 38640
//Menagerie
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
using namespace std;
const int inf=2147483647,dx[]={-1,0,1,0},dy[]={0,-1,0,1};// 上 左 下 右
const int N=100005,M=1000005,mod=1000000007;
const long long llinf=9223372036854775807ll;
// 1 相同 0 不同 
// 1 羊 0 狼 
// 1 相同 0 不同 
int n;
bool talk[N],ani[N];
void make(void)
{
	for(int i=2;i<n;i++)
	{
		bool op=1^(ani[i]^talk[i]);
		if(op==true)
			ani[i+1]=ani[i-1];
		else
			ani[i+1]=ani[i-1]^1;
	}
}
bool check(void)
{
	int op1=1^(ani[1]^talk[1]),op2=1^(ani[n]^talk[n]);
	if(op1!=(1^(ani[n]^ani[2])))
		return false;
	if(op2!=(1^(ani[1]^ani[n-1])))
		return false;
	return true;
}
void print(void)
{
	for(int i=1;i<=n;i++)
		cout<<((ani[i]==1)?'S':'W');
}
int main(){
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		char ch;
		cin>>ch;
		if(ch=='o')
			talk[i]=true;
		else
			talk[i]=false;
	}
	for(int i=0;i<=1;i++)
		for(int j=0;j<=1;j++)
		{
			ani[1]=i,ani[2]=j;
			make();
			if(check())
			{
				print();
				return 0;
			}
		}
	cout<<-1;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <iomanip>
#include <algorithm>
#include <iostream>
#define ll long long int
#define cases int t; cin >> t; while (t--)
#define pb push_back
using namespace std;

int main()
{
    int n; cin >> n;
    int a[n+1], pref[n+1];
    for (int i = 1; i <= n; i++) cin >> a[i];
    pref[0] = 0;
    for (int i = 1; i <= n; i++) pref[i] = pref[i-1] + a[i];
    int s1, s2, dif, ans = INT_MAX;
    for (int i = 1; i < n; i++)
    {
        s1 = pref[i];
        s2 = pref[n] - pref[i];
        dif = abs(s2 - s1);
        ans = min(ans, dif);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256