akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>

int main(void)
{
    int j, o, i;
    char c, now;
    int ans;
    
    c = now = 'K';
    j = o = i = 0;
    ans = 0;
    
    while (1){
        c = getchar();
        if (now == 'I' && c != 'I'){
            if (j >= o && o <= i){
                ans = ans > o ? ans : o;
            }
            j = o = i = 0;
        }
        
        if (c == '\n'){
            break;
        }
        
        if ((j == 0 || now == 'J') && c == 'J'){
            j++;
            now = 'J';
        }
        else if (now == 'J' && c == 'I'){
            j = o = i = 0;
            now = 'I';
        }
        
        if ((j != 0 || now == 'O') && c == 'O'){
            o++;
            now = 'O';
        }
        else if (now == 'O' && c == 'J'){
            o = i = 0;
            j = 1;
            now = 'J';
        }
        
        if ((o != 0 || now == 'I') && c == 'I'){
            i++;
            now = 'I';
        }
    }
    printf("%d\n", ans);
    
    return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll n; cin >> n;
  vector<ll> a(n);
  REP(i,n) cin >> a[i];
  multiset<ll> tail;
  REP(i,n) tail.insert(-1);
  REP(i,n){
    auto ub = tail.lower_bound(a[i]);
    tail.erase(--ub);
    tail.insert(a[i]);
  }
  ll ans = n;
  auto it = tail.begin();
  while(it!=tail.end()){
    if(*it==-1) ans--;
    it++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 5760
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb = new StringBuilder();
        while(true){
            String str[] = br.readLine().split(" ");
            int H = Integer.parseInt(str[0]);
            int W = Integer.parseInt(str[1]);
            if(H==0 && W==0) break;
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i==0 || i==H-1){
                        sb.append("#");
                    }else{
                        if(0<j && j<W-1){
                            sb.append(".");
                        }else{
                            sb.append("#");
                        }
                    }
                }
                sb.append("\n");
            }
            sb.append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 25284
def large_expo(x,n,mod):
    if n == 2:
        return (x*x)%mod
    elif n %2 == 1:
        return (large_expo(x,n-1,mod)*x)%mod
    else:
        temp = large_expo(x,n//2,mod)%mod
        return (temp*temp)%mod

n,a,b = map(int,input().split())

ans = 0
m = 10**9+7

all_num = large_expo(2,n,m)-1

minus1 = 1
minus2 = 1

inv_m = [0]+[1]
for i in range(2,max(a,b)+1):
  inv_m += [inv_m[m % i] * (m - int(m / i)) % m]


for i in range(a):
    minus1 *= (n-i)
    minus1 = minus1 * inv_m[i + 1]
    minus1 %= m

for i in range(b):
    minus2 *= (n-i)
    minus2 = minus2 * inv_m[i + 1]
    minus2 %= m

# print(all_num,minus1,minus2)
# print(minus1+minus2)
# print((all_num-minus1-minus2))
# print((all_num-minus1-minus2)+2*m)
print((all_num-minus1-minus2)%m)

Measured memory_bytes: 11024
/* 
      Life before Death
      Strength before Weakness
      Journey before Destination
*/
                           
#include <bits/stdc++.h>
using namespace std;
                 
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for (ll i=n;i>a;i--)
#define te ll t; std::cin >> t; while(t--)
#define SZ 500010
//# define M_PIl  3.141592653589793238462643383279502884L 
/*------Just DO IT--------------------------------------*/

ll solve(){
   ll n,k,mi=1e9;
  cin>>n>>k;
  --k;
  ll a[n];
  rep(i,0,n) cin>>a[i];
  sort(a,a+n);
  rep(i,k,n) mi = min(mi, abs(a[i] - a[i-k]));
  cout<<mi<<endl;
  }

int main() {
  fastio;
   solve();
}

Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	X := getStdinInt()
	if X >= 30 {
		fmt.Printf("Yes\n")
		return
	}
	fmt.Printf("No\n")
}

var sc = bufio.NewReaderSize(os.Stdin, 1024*1024*10)

func getStdin() string {
	return readLine()
}
func getStdinInt() int {
	str := getStdin()
	rtn, _ := strconv.Atoi(str)
	return rtn
}
func getStdinInt2() (int, int) {
	list := getStdinIntArr()
	return list[0], list[1]
}
func getStdinInt3() (int, int, int) {
	list := getStdinIntArr()
	return list[0], list[1], list[2]
}
func getStdinInt64() int64 {
	str := getStdin()
	rtn, _ := strconv.ParseInt(str, 10, 64)
	return rtn
}
func getStdinInt64_2() (int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1]
}
func getStdinInt64_3() (int64, int64, int64) {
	list := getStdinIntArr64()
	return list[0], list[1], list[2]
}
func getStdinIntArr() []int {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.Atoi(val)
	}
	return rtn
}
func getStdinIntArr64() []int64 {
	str := getStdin()
	list := strings.Split(str, " ")
	rtn := make([]int64, len(list))
	for idx, val := range list {
		rtn[idx], _ = strconv.ParseInt(val, 10, 64)
	}
	return rtn
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func min64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}
func max64(a, b int64) int64 {
	if a < b {
		return b
	}
	return a
}
func abs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
func abs64(n int64) int64 {
	if n < 0 {
		return -n
	}
	return n
}
func readLine() string {
	buf := make([]byte, 0, 0)
	for {
		l, p, _ := sc.ReadLine()
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}


Measured memory_bytes: 2180
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
using namespace __gnu_pbds;
typedef tree<pair<ll,pair<ll,ll> >, null_type, less<pair<ll,pair<ll,ll> > >, rb_tree_tag, tree_order_statistics_node_update>ordered_set;
#define me BOSS
#define bug() cout<<"AIkahne aise"<<endl
#define PI acos(-1)
/* Precode Start Here *\
     Sieve
void sieve()
{
    for(ll i=3; i<=2000; i+=2)
    {
        for(ll j=i*i; j<=4000000; j+=i)
            A[j]=1;
    }
    v.push_back(2);
    for(ll i=3; i<=4000000; i+=2)
        if(A[i]==0)
            v.push_back(i);
}

     Power Function Modulo P

ll modPow(ll a, ll x, ll p) {
    //calculates a^x mod p in logarithmic time.
    long res = 1;
    while(x > 0) {
        if( x % 2 != 0) {
            res = (res * a) % p;
        }
        a = (a * a) % p;
        x /= 2;
    }
    return res;
}


   factorial

ll fact(ll n)
{
    ll ans=1;
    for(ll i=1;i<=n;i++)
    {
        ans=(ans*i)%mod;
    }
    return ans;
}
     Calculating nCr using Fermats law Theorem

ll modInverse(ll a, ll p) {
    //calculates the modular multiplicative of a mod m.
    //(assuming p is prime).
    return modPow(a, p-2, p);
}


ll modBinomial(ll n, ll k, ll p) {
// calculates C(n,k) mod p (assuming p is prime).

    ll numerator = 1; // n * (n-1) * ... * (n-k+1)
    for (ll i=0; i<k; i++) {
        numerator = (numerator * (n-i) ) % p;
    }

    ll denominator = 1; // k!
    for (ll i=1; i<=k; i++) {
        denominator = (denominator * i) % p;
    }

    // numerator / denominator mod p.
    return ( numerator* modInverse(denominator,p) ) % p;
}
     num of divisor and euler totient

ll phi[1000001],mark[1000001],divi[1000001];;
void divisorPhi(ll n)
{
    for(int i=1;i<=n;i++)
        phi[i]=i;
    for(int i=2;i<=n;i++)
    {
        if(!mark[i])
        {
            for(int j=i;j<=n;j+=i)
            {
                mark[j]=1;
                phi[j]*=(1-1/(double)i);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    {
        for(ll j=i;j<=n;j+=i)
            divi[j]++;
    }
}
/* Precode Ends */
#define mod 1000000007
ll A[5000001],B[5000001];
vector<ll>v;
map<ll,ll>myMap;
set<ll>mySet;
vector<pair<ll,ll> >vp;
priority_queue<ll> pq;
priority_queue<ll, vector<ll>, std::greater<ll> > first;
ll po(ll a,ll n)
{
  ll ans=1;
  for(int i=1;i<=n;i++)
       ans*=a;
    return ans;
}

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

 ll a,b,c,d;
 cin>>a>>b>>c>>d;
 while(1)
 {
     c-=b;
     if(c<=0)
     {
         cout<<"Yes"<<endl;
         break;
     }
     a-=d;
     if(a<=0)
     {
         cout<<"No"<<endl;
         break;
     }
 }
return 0;
}



Measured memory_bytes: 3652
#include <iostream>

using namespace std;

int main() {
  	long n, a, b;
  	cin >> n >> a >> b;
  	long e = n % (a + b), ans;
  	ans = (n - e) / (a + b);
  	ans *= a;
  	if (e < a) {
      	ans += e;
    } else {
      	ans += a;
    }
  	cout << ans << endl;
  
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;
#define ll long long
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x,a,b;
    cin >> x >> a >> b;
    cout << (x-a)%b << endl;

    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()

ans = 0
for i in range(1000):
    num = str(i).zfill(3)
    if S.find(num[0]) == -1:
        continue  # 1文字目が合っているかどうか
    S1 = S[S.find(num[0])+1:]
    if S1.find(num[1]) == -1:
        continue  # 2文字目が合っているかどうか
    S2 = S1[S1.find(num[1])+1:]
    if S2.find(num[2]) == -1:
        continue  # 3文字目が合っているかどうか
    ans += 1
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ll long long

int main()
{
	//freopen("test.txt","r",stdin);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n;
	cin>>n;
	ll arr[n+1];
	for(ll i=1;i<=n;i++)
		cin>>arr[i];
	ll res[n+1];
	for(ll i=1;i<=n;i++)
		res[arr[i]]=i;
	for(ll i=1;i<=(n);i++)
		cout<<res[i]<<" ";

}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s, t;
    cin >> s >> t;

    int ans = 0;
    REP(i, 3)
    {
        if(s[i] == t[i])ans++;
    }



    cout << ans << endl;
    
}

Measured memory_bytes: 256
#include <stdio.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
#include <functional>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef vector<vector<int>> v2int;
typedef vector<ll> vll;
typedef vector<vector<ll>> v2ll;
typedef list<int> liint;
typedef pair<int, int> pint;
const int INF = int(2e9);
const ll LINF = ll(2e9) * ll(2e9);
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for(int i = x; i < n; i++)
template<class T, class C> void chmax(T& a, C b) { a > b ? : a = b; }
template<class T, class C> void chmin(T& a, C b) { a < b ? : a = b; }



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string S;
    cin >> S;
    vll X(S.size() + 1);
    vll tens(S.size() + 1);
    tens[0] = 1;
    reverse(S.begin(), S.end());
    rep(i, S.size()) {
        tens[i + 1] = (tens[i] * 10) % 2019;
    }
    vint nums(2019, 0);
    rep(i, S.size()) {
        X[i + 1] = (X[i]  + (S[i] - 0x30) * tens[i]) % 2019;
        
    }

    ll ans = 0;
    ll now = 0;
    REP(i, 0, S.size() + 1) {
        nums[X[i]]++;
    }

    rep(i, 2019) {
        ans += ll(nums[i]) * (ll(nums[i]) - 1) / 2;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6700
//#include <bits/stdc++.h>
#include<iostream>
#include <iosfwd>
#include<limits.h>
#include <sstream>
#include <iomanip>
#include <iterator>
#include <algorithm>
#include <limits>
#include<stdio.h>
#include <queue>
#include <stack>
#include <math.h>
#include<string.h>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include<vector>
#include <chrono>
#include <random>
using namespace std;
using namespace std::chrono;
#define fr(i,j,n)   for(lli i=j;i<(n);++i)
#define bk(i,j,n)   for(lli i=j;i>=n;--i)
#define pb push_back
#define m_p make_pair
#define Fs first
#define Sc second
#define endl "\n"
#define MOD 2147483647
#define present(c,x)    ((c).find(x) != (c).end())
#define run ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define ordered_set tree<lli, null_type,less<lli>, rb_tree_tag,tree_order_statistics_node_update>
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define mem(p,v) memset(p,(lli)v,sizeof p);
#define ub upper_bound
#define lb lower_bound
typedef long long int lli;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<lli> vl;
typedef pair<lli,lli> pl;
inline lli max(lli a,lli b){ return a>b?a:b;}
inline lli min(lli a,lli b){ return a<b?a:b;}
void show(vector<lli> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(vector<int> v)
{
    fr(i,0,v.size())
    cout<<v[i]<<" ";
    cout<<endl;
}
void show(int a[], int arraysize)
{
    for (int i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(lli a[], lli arraysize)
{
    for (lli i = 0; i < arraysize; ++i)
        cout << a[i] << " ";
    cout<<endl;
}
void show(unordered_set<int> s)
{
    for (auto it = s.begin(); it != s.end(); it++)
    {
        cout << *it << " ";
    }
    cout<<endl;
}
void show(unordered_map<int,int> mp)
{
    for (auto it = mp.begin(); it != mp.end(); it++)
    {
        cout << it->first << " "<<it->second<<endl;
    }
    cout<<endl;
}
int main()
{
    lli t,n,m;
    t=1;
    while(t)
    {
        cin>>n;
        m=n;
        string ans="";
        while(m)
        {
            if(m%26==0)
            {
                ans='z'+ans;
                m--;
            }
            else
            {
                ans=char('a'+(m%26-1))+ans;
            }
            m=m/26;
        }
        cout<<ans<<endl;
        t--;
    }
    return 0;
}





Measured memory_bytes: 3536
#include<bits/stdc++.h>
using namespace std;
int a,b,c;
inline int read()
{
	int n_read=0,o_read=1;
	char c_read=getchar();
	while(c_read<'0'||c_read>'9')
	{
		if(c_read=='-')
			o_read=-1;
		c_read=getchar();
	}
	while(c_read>='0'&&c_read<='9')
	{
		n_read=n_read*10+c_read-'0';
		c_read=getchar();
	}
	return n_read*o_read;
}
int main()
{
 	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	a=read(),b=read(),c=read();
    cout<<a<<" "<<b<<" "<<3*c-a-b<<" "<<endl;
    cout<<4*c-2*a-b<<" "<<c<<" "<<2*a+b-2*c<<" "<<endl;
    cout<<a+b-c<<" "<<2*c-b<<" "<<2*c-a<<" "<<endl;
    return 0 ;
	putchar('\n');
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		int a = io.nextInt();
		int b = io.nextInt();
		int c = io.nextInt();
		
		System.out.println(((b-a) == (c-b))?"YES":"NO");
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <stdio.h>
using namespace std;

int main()
{
    string T, H;
    int n,t=0,h=0;
    cin>> n;
    for (int i =0; i<n; i++){
        cin >> T>>H;
        if(T<H){
            h += 3;
        }else if(T>H){
            t+=3;
        }else{
            ++t;
            ++h;
        }

    }
    cout << t <<" "<<h<<"\n";

    return 0;
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
typedef double db;
const ll mod=1000000007;
ll powmod(ll a,ll b) {ll res=1;a%=mod;assert(b>=0);for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n,m;
	cin>>n>>m;
	vector<int>v(n);
	ll sum = 0;
	int val;
	for(int i = 0;i <n ;i++){
		cin>>v[i];
		sum+=v[i];
	}
	int l,r;
	vector<pii>v2(m);
	for(int i =0 ;i < m ;i++){
		cin>>l>>r;
		v2[i] = make_pair(r,l);
	}
	sort(v.begin(),v.end());
	sort(v2.begin(), v2.end(), greater<pii>());
	int i1=0;
	int i2 = 0;
	while(i2<m && i1 <n){
		while(i1<n && v2[i2].first>v[i1]&&v2[i2].second>0){
			sum+=v2[i2].first-v[i1];
			i1++;
			v2[i2].second--;
		}
		i2++;
	}
	cout<<sum;
	return 0;
}

Measured memory_bytes: 4476
#include <bits/stdc++.h>
#include <iomanip>
 
using namespace std;
 
typedef long long LL;
typedef long double LD;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef pair<LD, LD> PLDLD;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VB;
 
#define FOR(i,a,b) for(int i=(a);i<(int)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
#define endl "\n"
 
const LD EPS=1e-10;
const long long INFLL=(LL)(1e9)*(LL)(1e9);
const int INF=1e9;
 
template<class T>
void chmin(T& a, const T b)
{
	if(a>b)
		a=b;
}
template<class T>
void chmax(T& a, const T b)
{
	if(a<b)
		a=b;
}
 
const LL pow(const LL p, const LL q)
{
	LL t=1;
	for(int i=0;i<q;i++)
		t*=p;
	return t;
}

template <typename T>
struct has_iter
{
	private:
		template <typename U>
		static constexpr true_type check(typename U::iterator*);
		template <typename U>
		static constexpr false_type check(...);

	public:
		static constexpr bool value = decltype(check<T>(nullptr))::value;
};


template<typename T, typename U = typename T::iterator>
void print(const T& container)
{
		auto&& first=begin(container), last=end(container);
		auto&& back=prev(last);
		for(auto e=first; e!=last; e=next(e))
			cout<<*e<<" \n"[e==back];
}


extern void* enabler;
template<typename Head, typename enable_if<!has_iter<Head>::value>::type*& = enabler>
void print(const Head& head)
{
	cout<<head<<endl;
}

template<> void print<string>(const string& container)
{
	cout<<container<<endl;
}

template<typename Head, typename... Tail>
void print(const Head& head, const Tail&... tail)
{
	cout<<head<<" ";
	print(tail...);
}

void io_speedup()
{
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec)
{
	for(T& x: vec) is >> x;
	return is;
}


template<typename T, typename U>
ostream& operator << (ostream& os, const pair<T, U>& p)
{
	os<<'('<<p.first<<", "<<p.second<<')';
	return os;
}

template<typename T>
vector<T> read(int n)
{
	vector<T> t(n);
	cin>>t;
	return t;
}

template<typename T>
T read()
{
	T t;
	cin>>t;
	return t;
}

template<typename Head, typename... Tail>
struct vector_demensions
{
	using type=vector<typename vector_demensions<Tail...>::type>;
};

template<typename Head>
struct vector_demensions<Head> { using type=Head; };

template<typename T>
vector<T> make_vectors(int size, T val)
{
	return vector<T>(size, val);
}

template<typename T=int, typename... Args>
auto make_vectors(int size, Args... tail)
	-> typename vector_demensions<Args..., T>::type
{
	auto val=make_vectors<T>(forward<Args>(tail)...);
	return vector<decltype(val)>(size, val);
}

int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	VI r(n+1);
	REP(i,n)
		r[i+1]=r[i]+(s[i]=='E'?1:0);
	
	int ans=INF;
	REP(i,n)
	{
		int sum=0;
		sum+=i-r[i];
		sum+=(r[n]-r[i+1]);
		//print(i-r[i], (r[n]-r[i+1]));
		chmin(ans,sum);
	}
	print(ans);

}


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

int main () {
  string s;
  cin >> s;
  int ans = 0;
  for (int i = 0; i < s.size()/2; i++){
    if (s.at(i) != s.at(s.size()-i-1)) ans ++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	Loop(readInt(), 1e6, func(i int) {
		flag := false
		for p := 2; p < i; p++ {
			if (i % p) == 0 {
				flag = true
				break
			}
		}
		if !flag {
			fmt.Println(i)
			os.Exit(0)
		}
	})
}

/////////////////////////////////////////
var scanner = bufio.NewScanner(os.Stdin)

func init() {
	scanner.Split(bufio.ScanWords)
	//scanner.Split(bufio.ScanLines)
}

func readString() string {
	scanner.Scan()
	return scanner.Text()
}

func readInt() int {
	scanner.Scan()
	t, _ := strconv.Atoi(scanner.Text())
	return t
}

func Loop(start, end int, f func(i int)) {
	for i := start; i < end; i++ {
		f(i)
	}
}

Measured memory_bytes: 640
#include<stdio.h>
int main()
{

    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }
    else if(a>b){
        printf("a > b\n");
    }
    else if(a==b){
        printf("a == b\n");
    }


    return 0;
}

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

class Prime
{
	ll i, iLimit;
public:
	bool isPrime(ll a);
};

bool Prime::isPrime(ll a)
{
	if (a == 1) return false;
	iLimit = (int)sqrt(a);
	for (i = 2; i <= iLimit; i++) if (a % i == 0) break;
	return (i == iLimit + 1 ? true : false);
}

int main() {
	ll a, b;
	cin >> a >> b;
	vector<ll> resa;
	vector<ll> resb;
	for (ll i = 1; i * i <= a; ++i) {
		if (a % i == 0) {
			resa.emplace_back(i);
			if (i * i != a) resa.emplace_back(a / i);
		}
	}
	for (ll i = 1; i * i <= b; ++i) {
		if (b % i == 0) {
			resb.emplace_back(i);
			if (i * i != b) resb.emplace_back(b / i);
		}
	}
	vector<ll> res;
	for (auto& c : resa) {
		for (auto& p : resb) {
			if (p == c) res.emplace_back(c);
		}
	}
	Prime p;
	int ans = 0;
	for (auto& c : res) {
		bool elf = p.isPrime(c);
		if (elf) ans++;
	}
	cout << ans + 1 << endl;
	return 0;
}


Measured memory_bytes: 512
S = input()
S2 = S[:(len(S) - 1) // 2]
S3 = S[(len(S) + 3) // 2 -1:]
is_ng = False
for i in range(len(S)):
    if S[i] != S[-i - 1]:
        is_ng = True
for i in range(len(S2)):
    if S2[i] != S2[-i - 1]:
        is_ng = True
for i in range(len(S3)):
    if S3[i] != S3[-i - 1]:
        is_ng = True
print('YNeos'[is_ng::2])

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
	class Program
	{
		static void Main(string[] args)
		{
			string word=Console.ReadLine();
			char[] chars = word.ToCharArray();

			bool flag = false;
			if ((chars[0]==chars[1]&&chars[2]==chars[3])&&chars[0]!=chars[2])
			{
				flag = true;
			}
			if ((chars[0] == chars[2] && chars[1] == chars[3]) && chars[0] != chars[1])
			{
				flag = true;
			}

			if ((chars[0] == chars[3] && chars[1] == chars[2]) && chars[0] != chars[1])
			{
				flag = true;
			}
			switch (flag)
			{
				case true:Console.WriteLine("Yes");
					break;
				case false:Console.WriteLine("No");
					break;
			}
		
	}
}


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

int main(){
    int data[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;
    cout << data[k-1] <<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){

    int a,b,n;
    scanf("%d", &n);
    scanf("%d", &a);
    scanf("%d", &b);
    if(n*a > b){
        printf("%d\n", b);
    }else{
        printf("%d\n", n*a);
    }
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>

using namespace std;

int main(){
    int H, W;
    char image[100][100];
    //入力
    cin >> H >> W;
    for(int y = 0; y < H; ++y){
        for(int x = 0; x < W; ++x){
            cin >> image[y][x];
        }
    }
    //出力
    for(int y = 0; y < H*2; ++y){
        for(int x = 0; x < W; ++x){
            cout << image[y / 2][x];
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){

  int a,b,k,i;
  scanf("%d %d %d",&a,&b,&k);
  
  for(i=100;i>=1;--i){
  	if(a%i==0 && b%i==0){
    	k--;
      if(k==0){
    	printf("%d",i);
    }
    }
  }
  
  return 0;
}
  


Measured memory_bytes: 1712
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rep2(i,n) for(int i=1; i<=(n); ++i)
#define all(x) (x).begin(),(x).end()
#define Sort(x) sort((x).begin(),(x).end())
#define Sort2(x) sort((x).begin(),(x).end(), greater<int>())
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;

bool isPrime(int n, int i = 2){
    // Base cases
    if (n <= 2)
        return (n == 2) ? true : false;
    if (n % i == 0)
        return false;
    if (i * i > n)
        return true;

    // Check for next divisor
    return isPrime(n, i + 1);
}

int main()
{
    ll x; cin >> x;
    while(!isPrime(x++)){}
    cout << x-1 << endl;
}

/*
Ctrl+@ でコンソールを開け、以下で実行。
g++ c.cpp
./a.out

サンプルのダウンロードは oj d URL
テストは oj t
コード変えたらコンパイルする
不正解ならWAが出る
*/

Measured memory_bytes: 256
#include <stdio.h>
int main(){
 int k,s,p=0;
  scanf("%d %d",&k,&s);
  for(int x=k;x>=0;x--){
    for(int y=k;y>=0;y--){
      if(s-x-y<=k&&s-x-y>=0) p++;
    }
  }
  printf("%d\n",p);
  return 0;
}

Measured memory_bytes: 128
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <set>
#define SIZE (1<<18)+5

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

int A[SIZE];
int ans[SIZE];
int deg[SIZE];
int low[SIZE],up[SIZE];
bool use[SIZE];
vector <int> vec2[SIZE];
int n,t;

void modify1()
{
	for(int i=0;i<n;i++)
	{
		low[i]=0;
		if(ans[i]!=-1) low[i]=ans[i];
	}
	for(int i=t-1;i>=0;i--)
	{
		for(int j=1;j<1<<(t-i);j+=2)
		{
			int v=j<<i;
			for(int k=0;k<t;k++)
			{
				if(v>>k&1)//lose
				{
					low[v]=max(low[v],low[v^(1<<k)]);
				}
			}
		}
	}
}
void modify2()
{
	for(int i=0;i<n;i++)
	{
		up[i]=n-1;
		if(ans[i]!=-1) up[i]=ans[i];
	}
	int all=n-1;
	for(int i=t-1;i>=0;i--)
	{
		for(int j=1;j<1<<(t-i);j+=2)
		{
			int v=all^(j<<i);
			for(int k=0;k<t;k++)
			{
				if(!(v>>k&1))//win
				{
					up[v]=min(up[v],up[v^(1<<k)]);
				}
			}
		}
	}
}
int main()
{
	scanf("%d",&t);
	n=1;
	for(int i=0;i<t;i++) n<<=1;
	for(int i=0;i<n;i++)
	{
		scanf("%d",&A[i]);
		A[i]--;
	}
	if(A[0]>0)
	{
		puts("NO");
		return 0;
	}
	A[0]=0;
	for(int i=1;i<n;i++)
	{
		if(A[i]==0)
		{
			puts("NO");
			return 0;
		}
	}
	memset(ans,-1,sizeof(ans));
	memset(use,false,sizeof(use));
	for(int i=0;i<n;i++)
	{
		if(A[i]!=-1)
		{
			use[A[i]]=true;
			int to=0;
			for(int j=0;j<t;j++)
			{
				to<<=1;
				if(i>>j&1) to++;
			}
			ans[to]=A[i];
		}
	}
	modify1();
	modify2();
	for(int i=0;i<n;i++)
	{
		deg[i]=0;
		for(int j=0;j<t;j++)
		{
			if(!(i>>j&1))
			{
				int to=i^(1<<j);
				if(ans[to]==-1) deg[i]++;
			}
		}
		if(low[i]>up[i])
		{
			puts("NO");
			return 0;
		}
		if(ans[i]==-1) vec2[low[i]].push_back(i);
	}
	//for(int i=0;i<n;i++) printf("%d : %d %d\n",ans[i],low[i],up[i]);
	set <int> st;
	set <int>::iterator it;
	for(int i=n-1;i>=0;i--)
	{
		if(!use[i])
		{
			st.insert(i);
		}
	}
	for(int i=n-1;i>=0;i--)
	{
		if(!use[i]) continue;
		priority_queue <P> que;
		for(int j=0;j<vec2[i].size();j++)
		{
			int v=vec2[i][j];
			if(deg[v]==0)
			{
				que.push(P(up[v],v));
			}
		}
		int all=vec2[i].size();
		while(all>0)
		{
			if(que.empty())
			{
				puts("NO");
				return 0;
			}
			P p=que.top();que.pop();
			int v=p.second;
			it=st.upper_bound(up[v]);
			if(it==st.begin())
			{
				puts("NO");
				return 0;
			}it--;
			int gt=*it;
			if(gt<i)
			{
				puts("NO");
				return 0;
			}
			ans[v]=gt;
			st.erase(it);
			all--;
			for(int j=0;j<t;j++)
			{
				if(v>>j&1)
				{
					int to=v^(1<<j);
					deg[to]--;
					if(deg[to]==0)
					{
						if(low[to]==i)
						{
							que.push(P(up[to],to));
						}
					}
				}
			}
		}
	}
	puts("YES");
	for(int i=0;i<n;i++)
	{
		if(i!=0) printf(" ");
		printf("%d",ans[i]+1);
	}puts("");
	return 0;
}


Measured memory_bytes: 26752
from fractions import gcd
A, B, C, D = map(int, input().split())
#l = [i for i in range(A, B+1)]
div_a_c = (A-1) // C
div_b_c = B // C
div_c = div_b_c - div_a_c

div_a_d = (A-1) // D
div_b_d = B // D
div_d = div_b_d - div_a_d

lcm = C * D // gcd(C, D)
div_a_l = (A-1) // lcm
div_b_l = B // lcm
div_l = div_b_l - div_a_l
#print(div_c, div_d, div_l)
divs = div_c + div_d - div_l
print(B-A+1-divs)

Measured memory_bytes: 5076
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
double pi = 3.141592653589793;
ll mod = 1000000007;
ll INF = 1000000001;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;



int main(){
    int a, b, ans=0,tmp=1;
    cin >> a >> b;
    if(b==1)ans = 0;
    else{
        while(1){
            tmp += a-1;
            ans++;
            if(tmp>=b)
                break;
        }
    }
    // ans = ceil((b - a) / (a - 1) + 1);
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define max0(a,b,c) max(max(a,b),c)
#define min0(a,b,c) min(min(a,b),c)
#define ft first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define all(v) (v).begin(),(v).end()
#define mod 1000000007
using namespace std;
using Graph = vector<vector<int>>;
typedef long long lint;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ldouble;
typedef vector<int> vec;
typedef vector<ll> lvec;
typedef vector<ull> ulvec;
typedef vector<pair<int,int>> pvec;
typedef vector<pair<ll,ll>> plvec;
typedef vector<tuple<ll,ll,ll>> tvec;
typedef vector<string> svec;

int main(){
    int n,l,sum=0;
    cin>>n>>l;
    vec a(n);
    bool flag;
    rep(i,n) a[i]=l+i;
    if(a[0]>=0){
        for(int i=1;i<n;i++) sum+=a[i];
    }else if(a[n-1]<=0){
        rep(i,n-1) sum+=a[i];
    }else{
        int k;
        rep(i,n-1){
            if(a[i]<=0&&a[i+1]>=0){
                if(abs(a[i])>=a[i+1]){
                    k=i+1;
                    break;
                }else{
                    k=i;
                    break;
                }
            }
        }
        rep(i,n){
            if(i!=k) sum+=a[i];
        }
    }
    cout<<sum;
}

Measured memory_bytes: 256
import sys
mod = 7 + 10 ** 9

def solve():
    input = sys.stdin.readline
    N, K = map(int, input().split())
    ans = 0
    for k in range(K, N + 2):
        minS = (k - 1) * k // 2
        maxS = (N - k + 1 + N) * k // 2
        ans += (maxS - minS + 1)
        ans %= mod

    print(ans) 

    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 9196
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
using namespace std;

const double pi = acos(-1.0);
char s[100010];

int main() {
    int a, b, h, m;
    scanf("%d%d%d%d", &a, &b, &h, &m);
    double theta1 = (h * 60 + m) / 720.0 * 2 * pi;
    double theta2 = (m) / 60.0 * 2 * pi;
    double theta = fabs(theta1 - theta2);
    printf("%.20f\n", sqrt(a * a + b * b  - 2.0 * a * b * cos(theta)));

    return 0;
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
struct edge { int cost, to; edge(int c, int t) : cost(c), to(t) {} };
using Graph = vector<vector<edge>>;

int main()
{
	int K;
	cin >> K;
	Graph G(K);
	for (int i = 0; i < K; i++) {
		G[i].emplace_back(0, i * 10 % K);
		G[i].emplace_back(1, (i + 1) % K);
	}
	vector<int> d(K, -1);
	deque<P> dq;
	dq.emplace_back(1, 1);
	while (!dq.empty()) {
		auto p = dq.front(); dq.pop_front();
		if (d[p.first] != -1 && d[p.first] < p.second) continue;
		d[p.first] = p.second;
		for (auto e : G[p.first]) if (d[e.to] == -1) {
			if (e.cost) {
				dq.emplace_back(e.to, d[p.first] + e.cost);
			}
			else {
				dq.emplace_front(e.to, d[p.first]);
			}
		}
	}
	cout << d[0] << endl;
	return 0;
}


Measured memory_bytes: 6744
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define MP make_pair
#define PB push_back
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(int i=0;i<(n);i++)
#define REP1(i,n) for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n) for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	int q,n,ans=0,cnt=0;
	VI N;

	cin >> q;
	
	for(int i=0;i<q;i++){
		cin >> n;
		N.PB(n);
	}

	for(int j=0;j<q;j++){
		while(1){
			if(N[j]<10){
				break;
			}
			double k=1.0;
			while(1){
				int b=(int)pow(10.0,k);
				if((N[j]/b)==0){
					break;
				}
				ans=max(ans,((N[j]/b) * (N[j]%b)));
				k++;
			}
			cnt++;
			N[j]=ans;
			ans=0;
		}
		cout << cnt << endl;
		cnt=0;
	}
	return 0;
}

Measured memory_bytes: 1260
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,sum=0;;cin>>a>>b;
  for(int i=a;i<=b;i++){
    string s=to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])sum++;
  }
  cout<<sum;
}

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

int main()
{
	/*input*/
	int n, m, c;
	cin >> n >> m >> c;
	int *b = new int[m];
	int **a = new int *[n];
	for (int i = 0; i < n; i++)
	{
		a[i] = new int[m];
	}
	for (int i = 0; i < m; i++)
	{
		cin >> b[i];
	}
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < m; j++)
		{
			cin >> a[i][j];
		}
	}
	/*calculation*/
	int o = 0;
	for (int i = 0; i < n; i++)
	{
		int wa = 0;
		for (int j = 0; j < m; j++)
		{
			wa += a[i][j] * b[j];
		}
		wa += c;
		if (wa > 0)
		{
			o++;
		}
	}
	/*output*/
	cout << o << endl;
	delete[] b;
	for (int i = 0; i < n; i++)
	{
		delete[] a[i];
	}
	delete[] a;
}


Measured memory_bytes: 256
program answer
  implicit none

  integer :: N, i

  read(*,*) N

  do i = 0, 10
     if(N==1000*i) then
        write(*,*) 0
        stop
     end if
     if(N>1000*i.and.N<1000*(i+1)) then
        write(*,*) 1000*(i+1)-N
        stop
     end if
  end do

  stop
 end program answer

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

#define TYPE(c)   remove_reference_t<decltype(c)>
#define REP(i, n) for(TYPE(n) i = 0; i < n; i++)
#define FOR(v, c) for(TYPE(c.begin()) v = c.begin(); v != c.end(); v++)
#define ALL(c)    c.begin(), c.end()
#define SORT(c)   sort(ALL(c))
#define RSORT(c)  sort(ALL(c), greater<TYPE(c)::value_type>())
#define UNIQUE(c) c.erase(unique(ALL(c)), c.end())

using namespace std;
using ll = long long;

constexpr int MOD  = (int)1e9 + 7;
constexpr int INF  = (int)1e9 + 1;
constexpr ll  LINF = (ll)1e18 + 1;
template<typename T> constexpr bool chmax(T& a, const T& b)
{ if(a < b) { a = b; return true; } else { return false; } }
template<typename T> constexpr bool chmin(T& a, const T& b)
{ if(b < a) { a = b; return true; } else { return false; } }
template<typename S, typename T> ostream& operator<<(ostream &os, const pair<S, T>& p)
{ return os << "(" << p.first << "," << p.second << ")"; }
ostream& operator<<(ostream &os, const string& s)
{ FOR(v, s) os << *v; return os; }
template<typename T> auto operator<<(ostream& os, const T& t)
    -> typename conditional<true, ostream&, decltype(*t.begin())>::type
{ os << "["; FOR(v, t) { if(v != t.begin()) os << ","; os << *v; } os << "]"; return os; }

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

    ll N;
    std::cin >> N;
    std::vector<ll> A(N), B(N);
    REP(i, N) {
        std::cin >> A[i] >> B[i];
    }

    ll ans = 0;
    for(int i = N - 1; i >= 0; i--) {
        if((ans + A[i]) % B[i] == 0) continue;
        ans += B[i] - ((ans + A[i]) % B[i]);
    }
    std::cout << ans << std::endl;

    return 0;
}


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

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

	if(a > 0 && b > 0)
		cout<<"Positive"<<endl;
	else if(a <= 0 && b > 0)
		cout<<"Zero"<<endl;
	else if(a <= 0 && b == 0)
		cout<<"Zero"<<endl;
	else if(a < 0 && b < 0)
	{
		if((b-a)%2 == 0)
			cout<<"Negative"<<endl;
		else
			cout<<"Positive"<<endl;
	}

	return 0;
}

Measured memory_bytes: 256
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

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

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"3
2 5"# => "9",

r#"2
3"# => "6",

r#"6
0 153 10 10 23"# => "52",
}

// 23, 0, 10, 10, 10

fn solve(src: &str) -> String {
    input! {
        source = src,
        n: usize,
        b: [usize; n - 1],
    }

    let mut ans = b[0] + b[n - 2]; // B0 = max(A0, A1)
    // print!("{}, ", ans);

    for i in 0..n - 2 {
        let a = std::cmp::min(b[i + 1], b[i]);
        ans += a;
        // print!("{}, ", a);
    }
    ans.to_string()
}

Measured memory_bytes: 4352
#include <math.h>
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <string>

#define YES "YES"
#define NO "NO"
#define space ' '

using namespace std;

void func();

int main(void)
{
	
	func();

	return 0;
}

void func()
{

	int a,b, g, l;
	while (cin >> a >> b, !cin.eof())
	{
		int d[2] = { max(a, b), min(a, b) };
		while (d[1] != 0)
		{
			d[0] %= d[1];
			swap(d[0], d[1]);
		}
		g = d[0];

		l = max(a, b) / g*min(a, b);
		cout << g << space << l << endl;
	}
}

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

int main () {
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < s.size()-1; i++){
        if (s.at(i) == s.at(i + 1)){
            count++;
        }
    }
    if (count > 0) {
        cout << "Bad" << endl;
    }
    else
    {
        cout << "Good"<< endl;
    }
    
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int n;
vvi v;
vi visited;
int dfs(int u)
{
    visited[u] = 1;
    int res = 0;
    bool flag = true;
    rep(i, n)
    {
        if (visited[i] == 0)
        {
            flag = false;
        }
    }
    if (flag)
    {
        res++;
    }
    rep(i, v[u].size())
    {
        if (!visited[v[u][i]])
        {
            res += dfs(v[u][i]);
            visited[v[u][i]] = 0;
        }
    }
    return res;
}
int main()
{
    int m;
    cin >> n >> m;
    v.resize(n);
    rep(i, m)
    {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    visited.resize(n);
    cout << dfs(0) << endl;
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, W, K;
  cin >> H >> W >> K;
  vector<string> S(H);
  for (int i = 0; i < H; i++) {
    cin >> S[i];
  }
  int res = 0;
  for (int bh = 0; bh < (1 << H); bh++) {
    for (int bw = 0; bw < (1 << W); bw++) {
      int k = 0;
      for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
          if (((bh >> i) & 1) || ((bw >> j) & 1)) continue;
          if (S[i][j] == '#') k++;
        }
      }
      if (k == K) res++;
    }
  }
  cout << res << '\n';
  return 0;
}


Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<unordered_map>
using namespace std;
int main(){
    long long N,X,M;
    cin >> N >> X >> M;
    long long ps[2*M+1];
    ps[0]=0;
    long long patt=X;
    long long prev=X;
    ps[1]=X;
    long long basic;
    long long patlength;
    unordered_map<int,int>ok;
    ok[X]=1;
    long long uwu;
    for(int i=2;i<=2*M;i++){
        prev=(prev*prev)%M;
        if(ok[prev]){
            basic=ok[prev];
            patlength=i-ok[prev];
            uwu=i-1;
            break;
        }
        ok[prev]=i;
        ps[i]=ps[i-1]+prev;
        patt+=prev;
    }
    long long ans=ps[basic-1];
    N-=(basic-1);
    ans+=(N/patlength)*(ps[uwu]-ps[basic-1]);
    ans+=ps[basic-1+N%patlength]-ps[basic-1];
    cout<<ans;
}

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

typedef long long ll;
typedef pair<int,int> p_int;
typedef pair<ll,ll> p_ll;
typedef tuple<ll,ll,ll> t3_ll;
int dx[] = {-1,0,1,0},dy[] = {0,1,0,-1};
int prime[] = {2,3,5,7,11,13,17,19,23,29,31,37,41,43,47,53,59,61,67,71,73,79,83,89,97};
const ll inf = 1000000007;

int main() {
	int n,W;
	cin >> n >> W;
	ll w[n],v[n];
	ll dp[n][W+1];
	for (int i = 0;i < n;i++) {
		cin >> w[i] >> v[i];
		for (int j = 0;j < W+1;j++) {
			dp[i][j] = -1;
		}
	}
	dp[0][0] = 0; dp[0][w[0]] = v[0];
	for (int i = 0;i < n-1;i++) {
		for (int j = 0;j < W+1;j++) {
			dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
			if (j+w[i+1] <= W) {
				dp[i+1][j+w[i+1]] = max(dp[i+1][j+w[i+1]],dp[i][j]+v[i+1]);
			}
		}
	}
	ll ans = 0;
	for (int i = 0;i < W+1;i++) {
		ans = max(ans,dp[n-1][i]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 78336
#include<bits/stdc++.h>
using namespace std;
int a[3][101]={0};
int f[3][101]={0};
int main()
{
	int i,j,n;
	int s=0;
	scanf("%d",&n);
	for(i=1;i<=2;i++)
	{
		for(j=1;j<=n;j++)
		{
			scanf("%d",&a[i][j]);
		}
	}
	for(i=1;i<=2;i++)
	{
		for(j=1;j<=n;j++)
		{
			if(f[i-1][j]>f[i][j-1])
			{
				f[i][j]=f[i-1][j]+a[i][j];
			}
			else
			{
				f[i][j]=f[i][j-1]+a[i][j];
			}
		}
	}
		printf("%d",f[2][n]);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<sstream>
#include<string>
#include<vector>
#include <cmath>
#include <limits>
#include <queue>
#include<algorithm>
#include<cstring>
#include <cstdlib>
#include <cstdio>
#include <set>
 
using namespace std;
 
#define rep(i,n) for (int (i)=0;(i)<(n);i++)


int main(){
    string s,t;
    cin >> s >> t;
    int flag, ind;
    rep(i,s.length()-t.length()+1){
        flag = 0;
        rep(j,t.length()){
            char ss = s[(s.length()-t.length()-i)+j];
            if (ss == '?') continue;
            else if (ss == t[j]) continue;
            else {flag = 1; break;}
        }
        if (flag == 0) {
            ind = s.length()-t.length()-i;
            break;
        }
    }
    if (flag == 1) {
        cout << "UNRESTORABLE";
    }
    else{
        rep(i,s.length()){
            if (i-ind >= 0 && i-ind < t.length()){
                cout << t[i-ind];
            }
            else if (s[i] == '?') cout << 'a';
            else cout << s[i];
        }
    }
    cout << endl;


    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()

{
    int n,AC=0,WA=0,TLE=0,RE=0;
    string s;
    cin>>n;
    while(n--)
    {
        cin>>s;
        if(s=="AC") AC++;
        else if(s=="WA") WA++;
        else if(s=="TLE") TLE++;
        else RE++;
    }

    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
    return 0;
}


Measured memory_bytes: 3220
#include<stdio.h>
int main(){
  int n;
  scanf("%d",&n);
  char s[2];
  for(int i = 0;i < n;i++){
    scanf("%s",&s);
    if(s[0] == 'Y'){
      printf("Four\n");
      return 0;
    }
  }
  printf("Three\n");
  return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
 
int same(char *T, char *P, int i, int plength){
  int j;
 
  for(j = 0; j < plength; j++){
    if(T[i+j] != P[j]){
      return 0;
    }
  }
  return -1;
}
 
int main(){
  char T[1000], P[1000];
  int i, tlength, plength;
 
  scanf("%s", T);
  scanf("%s", P);
 
  tlength = strlen(T);
  plength = strlen(P);
 
  for(i = 0; i < tlength; i++){
    if(same(T, P, i, plength)){
      printf("%d\n", i);
    }     
  }
  return 0;
}

Measured memory_bytes: 540
use std::cmp::min;
use std::io::stdin;

fn main() {
    const W: usize = 101;
    const H: usize = 101;
    let mut s = String::new();
    stdin().read_line(&mut s).ok();
    let mut t = s.split_whitespace().map(|e| e.parse().unwrap());
    let h: usize = t.next().unwrap();
    let w: usize = t.next().unwrap();
    let mut v = vec![vec![0; W]; H];
    for i in 1..h + 1 {
        let mut s = String::new();
        stdin().read_line(&mut s).ok();
        let mut t = s.chars();
        for j in 1..w + 1 {
            let n = t.next().unwrap();
            v[i][j] = if n == '#' { 1 } else { 0 };
        }
    }

    println!("{}", solve(&mut v, h, w));
}
fn solve(v: &mut Vec<Vec<usize>>, height: usize, width: usize) -> i32 {
    let mut dp = vec![vec![0; 101]; 101];

    for i in 2..dp.len() {
        dp[i][0] = 10000;
    }

    for i in 2..dp[0].len() {
        dp[0][i] = 10000;
    }

    for i in 1..height + 1 {
        for j in 1..width + 1 {
            let t1 = dp[i - 1][j]
                + if v[i][j] == 1 && v[i - 1][j] == 0 {
                    1
                } else {
                    0
                };

            let t2 = dp[i][j - 1]
                + if v[i][j] == 1 && v[i][j - 1] == 0 {
                    1
                } else {
                    0
                };
            dp[i][j] = min(t1, t2);
        }
    }

    dp[height][width]
}


Measured memory_bytes: 4352