akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll=long long int;
using ld=long double;
using VI=vector<ll>;
using VD=vector<ld>;
using VVI=vector<VI>;
using VC=vector<char>;
using VVC=vector<VC>;
using VS=vector<string>;
using PLL =pair<ll,ll>;
using PLD=pair<ld,ld>;
using VPLL=vector<PLL>;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SZ(x) ((ll)(x).size())
#define MAX(x) *max_element((x).begin(),(x).end())
#define MIN(x) *min_element((x).begin(),(x).end())
#define SORTR(x) sort((x).rbegin(),(x).rend())
#define SORT(x) sort((x).begin(),(x).end())
#define SUM(x) accumulate((x).begin(),(x).end(), 0)
#define FILL(x,a) fill(x.begin(),x.end(),a)
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
#define print(x) cout<<x<<"\n"

const ll INF = 1e18;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}
ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll GCD(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = gcd(a, v[i]);} return a;}
ll LCM(VI v){ll a = v[0]; for (ll i = 1; i<SZ(v); i++) {a = lcm(a, v[i]);} return a;}

void Main()
{
	ll n,m;
	ll res=0;
	string sres;
	cin>>n>>m;
	VVI link(n);
	VI h(n);
	rep(i,n) cin>> h[i];
	rep(i, m){
		ll a,b;
		cin >> a>>b;
		a--;b--;
		link[a].emplace_back(b);
		link[b].emplace_back(a);
	}
	//自分の位置
	rep(i,n){
		bool highest=true;
		//相手の位置
		for(auto &j:link[i]){
			if(h[j]>=h[i]) highest=false;
		}
		if(highest) res++;
	}

	cout << res << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 9808
#include<cstdio>
#include<algorithm>
#include<cstring>
#define STB(i, s, t) for(i = s; i <= t; ++i)

using namespace std;

typedef long long LL;
const int LEN = 110;
int n;
LL ans, num[LEN], K; int cnt;
char s[LEN];

int main() {
	int i;
	scanf("%s", s+1); n = strlen(s+1);
	scanf("%lld", &K);
	STB(i, 1, n)
	if(i == 1 || s[i] != s[i-1]) num[++cnt] = 1;
	else ++num[cnt];
	
	if(cnt == 1) {ans = num[1] * K / 2;}
	else {
		ans = num[1] / 2 + num[cnt] / 2;
		if(s[1] == s[n]) ans += (num[1] + num[cnt]) / 2 * (K - 1);
		else ans += num[1] / 2 * (K - 1) + num[cnt] / 2 * (K - 1); 
		STB(i, 2, cnt-1) ans += num[i] / 2 * K;
	}
	printf("%lld\n", ans);
	return 0;
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define fastIO ios::sync_with_stdio(NULL); cin.tie(NULL);

using namespace std;
const int N = 1E6+7;
const long long INF = 1E18;

long long NODE[N];
long long a[N], h[N];
int n;

long long get_max(int id,int s,int e,int l,int r)
{
    if (s > e || l > e || r < s) return -INF;
    
    if (l <= s && e <= r) return NODE[id];
    
    int mid = (s+e)>>1;
    long long tmp1 = get_max(id*2,s,mid,l,r);
    long long tmp2 = get_max(id*2+1,mid+1,e,l,r);
return max(tmp1,tmp2);
}

void update(int id,int s,int e,int pos,long long val)
{
    if (s > e || pos < s || pos > e) return;
    
    if (s == e)
    {
        if (s == pos)
        {
            NODE[id] = val;
            return;
        }
        return;
    }
    
    int mid = (s+e)>>1;
    update(id*2,s,mid,pos,val);
    update(id*2+1,mid+1,e,pos,val);
    NODE[id] = max(NODE[id*2],NODE[id*2+1]);
}

int main()
{
    fastIO
    cin>>n;
    
    for (int i = 1;i <= n;++i) cin>>a[i];
    
    for (int i = 1;i <= n;++i) cin>>h[i];
    
    long long res = 0;
    for (int i = 1;i <= n;++i)
    {
        long long k = get_max(1,1,n,1,a[i]) + h[i];
        update(1,1,n,a[i],k);
        res = max(res,k);
    }
    
    cout<<res;
}

Measured memory_bytes: 10920
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    const char *p = "pon", *h = "hon", *b = "bon";
    const char* word[] = {p, p, h, b, h, h, p, h, p, h};
    cout << word[N % 10] << endl;
}

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

int main(){
	cin.tie(0);
	cout.tie(0);
 	ios_base::sync_with_stdio(0);
	int a,b;
	cin >> a >> b;
	int cnt = max(a,b);
	int k = min(a,b);
	for(int i = 0;i < cnt; ++i){
		cout << k;
	}
	cout << '\n';
}


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

using namespace std;

void Main() {
    char c;
    cin >> c;
    if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
        cout << "vowel" << endl;
    }
    else {
        cout << "consonant" << endl;
    }
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

typedef long long ll;
using namespace std;

int main(){
	ll n,y;
	cin>>n>>y;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			int k=n-i-j;
			if(k>=0){
				if(i*10000+j*5000+k*1000==y){
					cout << i<<" "<<j<<" "<<k<<endl;
					return 0;
			    }
			}
		}
	}
	cout << "-1 -1 -1"<<endl;
  return 0; 
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
const int N=2e5+10;

int n,b[N][2];
char str[N];

int main()
{
	cin>>n>>str+1;
	for(int i=1; i<=n; i++)
	{
		if(str[i]=='R') b[i][1]=b[i-1][1]+1,b[i][0]=b[i-1][0];
		else b[i][1]=b[i-1][1],b[i][0]=b[i-1][0]+1; 
	}
	
	int r=b[n][1],w=b[n][0];
	int ans=min(b[r][0],min(w,r));
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5404
import sys
def input():
    return sys.stdin.readline()[:-1]

N,K,S = map(int,input().split(' '))
u = 10**9

if S==u:
    ans = ['1']*N
    for i in range(K):
        ans[i] = str(u)
    print(' '.join(ans))
    exit()
str_s = str(S)
ans = ['1000000000']*N
for i in range(K):
    ans[i] = str_s
print(' '.join(ans))

Measured memory_bytes: 13300
///////////////////////////////////////////////////////////
#include <algorithm>
#include <array>
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
///////////////////////////////////////////////////////////
#define ll long long
#define ull unsigned lon long
///////////////////////////////////////////////////////////
int absolute(int n);
double absolute(double n);
void input(vector<int>& vec);
void input(vector<ll>& vec);
void print(vector<int> vec);
void print(vector<ll> vec);
void print(vector<double> vec);
int sum(vector<int> vec);
double sum(vector<double> vec);
void upsort(vector<int>& vec);
void downsort(vector<int>& vec);
int maxvec(vector<int> vec);
int minvec(vector<int> vec);
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int main()
{
    size_t n;
    cin >> n;
    vector<ll> h(n);
    input(h);
    h.push_back(10e9 + 1);
    int count=0,m=0;
    for (size_t i = 0; i < n; ++i) {
        if(h.at(i)>=h.at(i+1)){
            ++count;
        }else{
            m=max(m,count);
            count=0;
        }
    }
    cout << m << endl;
    return 0;
}
///////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////
int absolute(int n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

double absolute(double n)
{
    if (n < 0) {
        return (-n);
    }
    return n;
}

void input(vector<int>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void input(vector<ll>& vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cin >> vec.at(i);
    }
}

void print(vector<int> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<ll> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

void print(vector<double> vec)
{
    for (size_t i = 0; i < vec.size(); ++i) {
        cout << vec.at(i) << " ";
    }
    cout << endl;
}

int sum(vector<int> vec)
{
    int s = accumulate(vec.begin(), vec.end(), 0);
    return s;
}

double sum(vector<double> vec)
{
    double s = accumulate(vec.begin(), vec.end(), 0.0);
    return s;
}

void upsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end());
}

void downsort(vector<int>& vec)
{
    sort(vec.begin(), vec.end(), greater<int>());
}

int maxvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = max(m, vec.at(i));
    }
    return m;
}

int minvec(vector<int> vec)
{
    int m = vec.at(0);
    for (size_t i = 0; i < vec.size(); ++i) {
        m = min(m, vec.at(i));
    }
    return m;
}
///////////////////////////////////////////////////////////

Measured memory_bytes: 1792
"use strict"
let x=require('fs').readFileSync('/dev/stdin','utf8');
let arr=x.split(' ');
let len=arr.length;
for(let i=0;i<len;i++){
	arr[i]=parseInt(arr[i]);
}

let p=0;
for(let i=p;i<len-1;i++){
	for(let j=p+1;j<len;j++){
		if(arr[i]>arr[j]){
			let t=arr[i];
			arr[i]=arr[j];
			arr[j]=t;
		}
	}
	p+=1;
}
let ans=arr[0];
for(let i=1;i<len;i++){
	ans += ' ' + arr[i];
}
console.log(ans);



Measured memory_bytes: 15152
n=int(input())
lists=[]
for i in range(n):
    a=input()
    lists.append(a)
import collections 
D=dict(collections.Counter(lists))
K=0
for some in D.values():
    K=max(K,some)
P=[]
for some in D.keys():
    if D[some]==K:
        P.append(some)
P=sorted(P)
for some in P:
    print(some)

Measured memory_bytes: 41612
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define fast std::ios::sync_with_stdio(false);cin.tie(0); cout.tie(0);
 
 //string ans="";
/*ll solve(ll n )
 {
     if(n<12)
        return n;
     if(mp[n]==0)
            mp[n]=max(solve(n/2)+solve(n/3)+solve(n/4),n);
     return mp[n];
        
 }
*/
 
int main()
{
   
    fast;
    ll t=1,x=1;
    //cin>>t;
    while(t--)
    {
        ll i,n,k;
        cin>>n;
        ll a[n];
        for(i=0;i<n;i++)
            cin>>a[i];
        ll x=1000;
        ll r=0;
        for(i=1;i<n;i++)
        {
            if(a[i-1]<a[i])
            {
                ll r1=x/a[i-1];
                ll x1=x%a[i-1];
                x1+=r1*a[i];
                x=x1;
            }
        }
        cout<<x;
    }
}

Measured memory_bytes: 3652
#include <stdio.h>
#include <stdlib.h>

int main()
{
   int a,b;
   scanf("%d%d",&a,&b);
   int i;
   if(a>b)
   {
       for(i=1;i<=a;i++)
       {
           printf("%d",b);
       }
   }
   else
   {
       for(i=1;i<=b;i++)
       {
           printf("%d",a);
       }
   }
    return 0;
}


Measured memory_bytes: 128
import itertools

def solve(T,X):
    """
    >>> solve(8,3)
    2.6666666667
    """
    print(T/X)


def main():
    T,X = map(int,input().split())
    solve(T,X)


def _test():
    import doctest
    doctest.testmod()


if __name__ == "__main__":
    import sys
    argv = sys.argv
    if len(sys.argv) == 1:
        # no option
        main()
    elif sys.argv[1] == "-t":
        _test()
    else:
        input = open(sys.argv[1]).buffer.readline

Measured memory_bytes: 9148
n = int(input())
G = [[0]]+[list(map(int, input().split()))[2:] for _ in range(n)]
# print(G)
from collections import deque
d = deque([1])
dist  = [10**10 for _ in range(n+1)]
dist[1] = 0
while len(d) != 0:
    now = d.popleft()
    # print(now)
    for nexte in G[now]:
        if dist[now] +1 < dist[nexte]:
            dist[nexte] = dist[now] + 1
            d.append(nexte)
for i,d in enumerate(dist[1:]):
    if d != 10**10:
        print(i+1,d)
    else:
        print(i+1,-1)

        



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

int main() {
  int x;
  cin >> x;

  if ((x%1000)%111==0) {
    cout << "Yes" << endl;
  }
  else if ((x/10)%111==0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define sz size()
#define all(x) (x).begin(), (x).end()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)

#define ll long long

int main() {

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

    // freopen("input.in","r",stdin);

    ll x,k,d;
    cin>>x>>k>>d;
    
    x = abs(x);

    ll kolku = x/d;

    if (k<kolku) {
        cout<<abs(x-k*d)<<"\n";
    } else {
        ll raz = kolku - k;
        ll min1 = 1e15+7;

        if (raz % 2 == 0) {
            if (abs(x-kolku * d) <min1)
                min1 = abs(x-kolku*d);
        } else {
            if (abs(x-kolku * d - d) <min1) {
                min1 = abs(x-kolku * d - d);
            }
            if (abs(x-kolku * d + d) <min1) {
                min1 = abs(x-kolku * d + d);
            }
        }
        cout<<min1<<"\n";
    }

    // cout<<kolku<<"\n";
    // cout<<kolku * d<<"\n";    

    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <bitset>
#include <queue>
#include <stack>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <limits>

using namespace std;
using ll=long long;
using vint=vector<int>;
using pint=pair<int,int>;

const double EPS = 1e-9;
const int inf = numeric_limits<int>::max();

#define rep(i,n) for(int i=0;i<int(n);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define SHOW(a) cout << #a << " = " << a << endl
#define ARR(a,i,n) for(int i=0;i<int(n);++i) cout << #a << "[" << i << "]" << " = " << a[i] << endl

void solve(){
	ll N, M;
	cin >> N >> M;
	if(N == 1 && M == 1){
		cout << 1;
	}else if(N == 2 || M == 2){
		cout << 0;
	}else if(N == 1){
		cout << M-2;
	}else if(M == 1){
		cout << N-2;
	}else{
		cout << (N-2) * (M-2);
	}
	cout << endl;
}

int main(){
	solve();
	return 0;
}

Measured memory_bytes: 256
n=int(input())
A=list(map(int,input().split()))
A.sort()
M=10**6+1
cnt=[0]*M
for i in A:
    if cnt[i]!=0:
        cnt[i]=2
        continue
    for j in range(i,M,i):
        cnt[j]+=1
ans=0
for i in A:
    if cnt[i]==1:
        ans+=1
print(ans)

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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const long double PI = (acos(-1));
const long double EPS = 0.0000000001;
const int INF = 0x3f3f3f3f;
const int maxn = 110000;

void run_case()
{
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1), c(n + 1), vis(55);
    int ans = 0;
    for (int i = 1; i <= n; i++)
        cin >> a[i];
    for (int i = 1; i <= n; i++)
    {
        cin >> b[i];
        ans += b[i];
    }
    for (int i = 1; i <= n - 1; i++)
        cin >> c[i];
    for (int i = 2; i <= n; i++)
    {
        if (a[i] - a[i - 1] == 1)
        {
            ans += c[a[i - 1]];
        }
    }
    cout << ans << "\n";
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    run_case();
    cout.flush();
    return 0;
}

Measured memory_bytes: 3660
#include<iostream>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<numeric>
#include<vector>
#include<cstdio>
#include<climits>
#include<cfloat>
#include<cstring>
#define foreach(t,p,tit) for(t::iterator tit=p.begin();tit!=p.end();++tit)
#define rforeach(t,p) for(t::reverse_iterator it=p.rbegin();it!=p.rend();++it)
#define all(p) p.begin(),p.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
using namespace std;
ll f10(int n)
{
    return (n==1)? 10: 10*f10(n-1);
}


int main()
{
    long long a,b,n;
    while(cin>>a>>b>>n)
    {
        ll ans = 0;
        vector<ll> f;
        vector<ll> g;
        f.push_back( a/b);
        g.push_back(a/b);
        for(int i=1;i<=n;i++)
        {
            g.push_back(a*f10(i) /b);
            f.push_back(g[i]-g[i-1]*10);
            ans += f[i];
        }
        

        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include <iostream>

int main(int argc, char const *argv[]) {
  int a, b, c;

  std::cin >> a >> b >> c;

  if (a==5 && b==5 && c==7){
    printf("YES\n");
  }else if (a==5 && b==7 && c==5){
    printf("YES\n");
  }else if(a==7 && b==5 && c==5){
    printf("YES\n");
  }else {
    printf("NO\n");
  }
  return 0;
}


Measured memory_bytes: 256
n,m = map(int,input().split())
if n == 1 and m == 1:
    print(1)
elif n == 1:
    print(m-2)
elif m == 1:
    print(n-2)
elif n == 2 or m == 2:
    print(0)
else:
    print(n*m-(n*2 + m*2 - 4))

Measured memory_bytes: 38384
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>
#include<iomanip>
#include<limits>
#include<bitset>

using namespace std;
typedef long long int ll; typedef pair<int, int> P; typedef unsigned long long int ull;
const ll mod = 1e9 + 7;
const int inf = 1e9 + 7;
const ll linf = 1LL << 60;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define REP(i,m,n) for(int i=(m);i<(int)n;i++)
#define all(a) (a).begin(),(a).end()
#define allg(a) (a).begin(),(a).end(),greater<>()
#define SUM(a) accumulate((a).begin(),(a).end(),0)
#define d10 std::setprecision(10)
#define d20 std::setprecision(20)
#define vec vector<int>
#define vecd vector<double>
using str = string;
const double PI = 3.14159265359;
ll gcd(ll a, ll b) { ll t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
int gcd(int a, int b) { int t; while (b != 0) { t = a % b; a = b; b = t; }return a; }
ll recfact(ll start, ll n) {
	ll i;
	if (n <= 16) {
		ll r = start;
		for (i = start + 1; i < start + n; i++) r = r * i % mod;
		return r % mod;
	}
	i = n / 2;
	return recfact(start, i) % mod * recfact(start + i, n - i) % mod;
}
ll lcm(ll a, ll b) {
	return a * b / gcd(a, b);
}
ll fct(ll n) { return recfact(1, n); }
ll ncm(ll n, ll m) {
	if (n < m)return 0;
	ll x = (fct(n) % mod / (fct(m) * fct(n - m)) % mod) % mod;
	return x;
}
std::string sreverse(string str, int firstItr, int secondItr) {
	if (firstItr < 0 || secondItr>int(str.size() - 1))return str;
	while (firstItr < secondItr) {
		swap(str[firstItr], str[secondItr]);
		firstItr++; secondItr--;
	}
	return str;
}
std::string RunLengthEncoding(std::string str) {
	int itr = 0; std::string res;
	while (itr < int(str.size())) {
		char tmp = str[itr++];
		int length = 1;
		while (itr <int(str.size()) && str[itr] == tmp) { ++itr; ++length; }
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}
std::string split(std::string str, size_t first_itr, bool isFront) {
	if (first_itr < 0 || first_itr > str.size()) {
		return str;
	}
	else {
		if (isFront) {
			std::string tmp;
			for (size_t i = 0; i < first_itr; i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
		else {
			std::string tmp;
			for (size_t i = first_itr; i < str.size(); i++) {
				tmp.push_back(str.at(i));
			}
			return tmp;
		}
	}
}


bool dfs(int depth, str s) {
	/*if (depth == n) {
		ans.push_back(s);
		return false;
	}
	for (int i = 0; i < n; i++) {
		if (dfs(depth + 1, s + dic.at(i))) {
			return true;
		}
	}*/
	return false;
}



int main() {
	int n; cin >> n;
	vec v(n); rep(i, n)v[i] = i + 1;
	vec tmp(n); rep(i, n)cin >> tmp[i];
	vec tmp2(n); rep(i, n)cin >> tmp2[i];
	int res1 = 0, res2 = 0, itr = 0;
	do {
		itr++;
		bool f1 = 1, f2 = 1;
		for (int i = 0; i < n; i++) {
			if (v[i] != tmp[i]) {
				f1 = 0;
			}
			if (v[i] != tmp2[i]) {
				f2 = 0;
			}
		}
		if (f1)res1 = itr;
		if (f2)res2 = itr;
	} while (next_permutation(all(v)));

	cout << abs(res1 - res2) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    int l = n%10;
    if (l==2 || l==4 || l==5 || l==7 || l==9)
        cout << "hon" ;
    else if (l==0 || l==1 || l==6 || l==8)
        cout << "pon";
    else 
        cout << "bon";
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;

int main(){
    int A,B;cin>>A>>B;
    if(A>=13) cout<<B<<endl;
    else if(A<=5) cout<<0<<endl;
    else cout<<B/2<<endl;
}

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

int main() {
    int64_t n;
    cin >> n;
    vector<int> vec(n);
    rep(i,n) cin >> vec[i];
    int64_t money=1000;
    int64_t min=300;
    rep(i,n){
        int64_t x=vec[i];
        if(min<x){
            if(vec[i+1]<x||i+1==n){
                money+=(x-min)*(money/min);
                min=300;
            }
        }
        else min=x;
    }
    cout << money << endl;
}


Measured memory_bytes: 3624
import java.lang.reflect.Array;
import java.math.BigDecimal;
import java.util.*;
import java.util.stream.Stream;

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

        ArrayList<Integer> list = new ArrayList<>();

        for(int i=0; i<num; i++){
            list.add(Integer.numberOfTrailingZeros(sc.nextInt()));
        }

        System.out.println(Collections.min(list));

//        System.out.println(Integer.numberOfTrailingZeros(num));
    }
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9+10;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  
  string s; cin>>s;
  ll n=s.size();
  
  if(n%2==0){
    rep(i,n-1){
      if(s[i]==s[i+1]){
        cout<<i+1<<' '<<i+2<<endl;
        return 0;
      }
    }
    if(n>2){
      rep(i,n-2){
        if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
          cout<<i+1<<' '<<i+3<<endl;
          return 0;
        }
      }
    }
    cout<<-1<<' '<<-1<<endl;
    
    return 0;
  }else{
    rep(i,n-2){
      if(s[i]==s[i+1] || s[i]==s[i+2] || s[i+1]==s[i+2]){
        cout<<i+1<<' '<<i+3<<endl;
        return 0;
      }
    }
    cout<<-1<<' '<<-1<<endl;
    
    return 0;
  }
  
}

Measured memory_bytes: 3764
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	bool ok_odd = true, ok_even = true;
	for(int i =0;i<s.size();i++)
	{
		if(i%2==0)
		{
			if(s[i]=='L')
			{
				ok_even=false;
				break;
			}
			else
				continue;
		}
		else
		{
			if(s[i]=='R')
			{
				ok_odd=false;
				break;
			}
			else
				continue;
		}
	}
	if(ok_odd == false || ok_even == false)
		cout<<"No"<<endl;
	else
		cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
n = int(input())
s = input()
s = [s[i:i+1] for i in range(n)]
lcost = [0 for _ in range(n)]
rcost = [0 for _ in range(n)]
if s[0] == 'W':
  lcost[0] = 1
if s[-1] == 'E':
  rcost[-1] = 1
for i in range(1, n):
  if s[i] == 'W':
    lcost[i] = lcost[i - 1] + 1
  else:
    lcost[i] = lcost[i - 1]
for i in range(2, n + 1):
  if s[-i] == 'E':
    rcost[-i] = rcost[-i + 1] + 1
  else:
    rcost[-i] = rcost[-i + 1]
mincost = min(lcost[-1], rcost[0])
#print(lcost)
#print(rcost)
for i in range(1, n - 1):
  hoge = lcost[i - 1] + rcost[i + 1]
  if hoge < mincost:
    mincost = hoge
print(mincost)

Measured memory_bytes: 21892
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nabcd = readln.split.to!(int[]);
    auto N = nabcd[0];
    auto A = nabcd[1]-1;
    auto B = nabcd[2]-1;
    auto C = nabcd[3]-1;
    auto D = nabcd[4]-1;
    auto S = readln.chomp.to!(char[]);
    auto len = S.length;

    if (D < C) {
        swap(A, B);
        swap(C, D);
    }

    bool moved;
    while (A != C || B != D) {
        if (B < D) {
            if (B+1 < len && S[B+1] != '#' && B+1 != A) {
                ++B;
                moved = true;
            } else if (B+2 < len && S[B+2] != '#' && B+2 != A) {
                B += 2;
                moved = true;
            }
        }
        if (A < C && !moved) {
            if (A+1 < len && S[A+1] != '#' && A+1 != B) {
                ++A;
                moved = true;
            } else if (A+2 < len && S[A+2] != '#' && A+1 != B && A+2 != B) {
                A += 2;
                moved = true;
            }
        }
        if (!moved) {
            writeln("No");
            return;
        }
        moved = false;
    }
    writeln("Yes");
}

Measured memory_bytes: 2812
S = input()
list_A = []
list_Z = []
for i in range(len(S)):
  if S[i] == 'A':
    list_A.append(i)
  if S[i] == 'Z':
    list_Z.append(i)
a = list_A[0]
z = list_Z[-1]
print(z - a + 1)


Measured memory_bytes: 11172
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
#include <cassert>
using namespace std;

typedef long long ll;

// Combinatorics
constexpr int MAX_N = 200003;
constexpr ll mod = 1e9 + 7;
ll fact[MAX_N], inv[MAX_N];

ll powm(ll x, ll p) {
	if (p == 0) return 1;
	ll res = powm(x, p / 2);
	res *= res;
	res %= mod;
	if (p % 2LL == 1) {
		res *= x;
		res %= mod;
	}
	return res;
}

void init_fact() {
	fact[0] = inv[0] = 1;
	for (ll i = 1; i < MAX_N; i++) {
		fact[i] = fact[i - 1] * i;
		fact[i] %= mod;
		inv[i] = powm(fact[i], mod - 2);
	}
}


int main() {
	ll n, m; cin >> n >> m;
	init_fact();
	map<ll, int> cnt;
	for (ll i = 2; i*i <= m; i++) {
		while (m%i == 0) {
			m /= i;
			cnt[i]++;
		}
	}
	if (m != 1) cnt[m]++;
	ll ans = 1;
	for (auto p : cnt) {
		ll c = p.second;
		ans *= (fact[c + n - 1] * inv[c] % mod) * inv[n - 1] % mod;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;

int main()
{
	int a, b, c;
	cin >> a >> b >> c;
	set <int> s;
	s.insert(a);
	s.insert(b);
	s.insert(c);

	cout << s.size() << endl;

	return 0;
}	

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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b<=a+c){
    if(a+b<=b+c){
      cout<<a+b<<endl;
    }else{
      cout<<b+c<<endl;
    }
  }else{ 
    if(a+c<=b+c){
      cout<<a+c<<endl;
    }else{
      cout<<b+c<<endl;
    }
  }
}


Measured memory_bytes: 256
n = int(input())
a_ = [int(i) for i in input().split()]
a = [[a_[i], i+1] for i in range(n)]
a.sort(reverse=True)

dp = [[0 for i in range(n+1)] for j in range(n+1)]
ans = 0
for x_plus_y in range(n):
    for x in range(x_plus_y + 1): #x：左に詰めた個数
        y = x_plus_y - x #y：# 右に詰めた個数
        dp[x][y+1] = max(dp[x][y+1], a[x_plus_y][0] * abs((n - y) - a[x_plus_y][1]) + dp[x][y]) #右
        dp[x+1][y] = max(dp[x+1][y], a[x_plus_y][0] * abs((a[x_plus_y][1] - (1+x))) + dp[x][y]) #左

        if x_plus_y == n-1:
            ans = max(ans, dp[x][y+1], dp[x+1][y])

print(ans)

Measured memory_bytes: 107836
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
//typedef pair<ll, ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define revrep(i, n) for(ll i = (n)-1; i >= 0; i--)
#define pb push_back
#define f first
#define s second
/*
ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll max3(ll a, ll b, ll c){return max(a, max(b, c));};
ll min3(ll a, ll b, ll c){return min(a, min(b, c));};
ll max4(ll a, ll b, ll c, ll d){return max(max(a, b), min(c, d));};
ll min4(ll a, ll b, ll c, ll d){return min(min(a, b), min(c, d));};
ll max5(ll a, ll b, ll c, ll d, ll e){return max(max(a, b), max3(c, d, e));};
ll min5(ll a, ll b, ll c, ll d, ll e){return min(min(a, b), min3(c, d, e));};
*/
const ll INFL = 1LL << 60;//10^18 = 2^60
const int INF = 1 << 30;//10^9
//ll MOD = 1000000007;
ll MOD = 998244353;

vector<ll> dy = {0, 0, 1, -1, 1, 1, -1, -1, 0};
vector<ll> dx = {1, -1, 0, 0, 1, -1, 1, -1, 0};

//デバッグ
void BinarySay(ll x, ll y = 60){rep(i, y) cout << (x>>(y-1-i) & 1); cout << endl;}

ll pow_long(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}
ll pow_mod(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}

ll inverse(ll x){return pow_mod(x, MOD - 2);};

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

ll lcm(ll x, ll y){return x / gcd(x, y) * y;};


ll kai_mod(ll x){
  if(x == 0) return 1;
  return x * kai_mod(x-1) % MOD;
}

//コンビネーション
const int MAXcomb = 200010;
ll fac[MAXcomb], finv[MAXcomb], inv[MAXcomb];
//facはn!,finvは1/n!
//invは逆元
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAXcomb; i++){
        fac[i] = fac[i-1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
        finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
ll comb(int n, int k){
    if(n < k) return 0;
    if(n < 0 || k < 0) return 0;
    return fac[n] * finv[k] % MOD * finv[n-k] % MOD;
}

ll N;
vector<pair<ll, ll>> xy;
set<pair<ll, ll>> Left, Right;
ll getAns(){  
  return (Left.rbegin()->f - Left.begin()->f) * (Right.rbegin()->f - Right.begin()->f);
}

void solve(){
  sort(xy.begin(), xy.end());
  rep(i, N){
    Left.insert({xy[i].f, i});
    Right.insert({xy[i].s, i});
  }
  ll ans = getAns();
  rep(i, N){
    Left.erase({xy[i].f, i});
    Right.erase({xy[i].s, i});
    Left.insert({xy[i].s, i});
    Right.insert({xy[i].f, i});
    ans = min(ans, getAns());
  }
  cout << ans << endl;
}

int main(){
  cin >> N;
  xy.resize(N);
  rep(i, N){
    ll x, y;
    cin >> x >> y;
    xy[i] = {min(x, y), max(x, y)};
  }
  solve();
}


Measured memory_bytes: 28416
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int x,y;
        while(true){
            x=sc.nextInt();
            y=sc.nextInt();
            if(x==0&&y==0)break;
            if(x>y)System.out.println(y+" "+x);
            else System.out.println(x+" "+y);
        }
        sc.close();
    }
}


Measured memory_bytes: 35872
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define zero_pad(num) setfill('0') << std::right << setw(num)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, int>;

int main() {
    int n, m, s;
    cin >> n >> m >> s;
    vector<int> u(m), v(m), a(m), b(m);
    rep(i, m){
        cin >> u[i] >> v[i] >> a[i] >> b[i];
        u[i]--; v[i]--;
    }
    vector<int> c(n), d(n);
    rep(i, n)cin >> c[i] >> d[i];
    int mx = 0;
    rep(i, m)mx = max(mx, a[i]);
    mx = (n-1)*mx;
    s = min(s, mx);

    vector<vector<pair<int, ll>>> to(n*(mx+1));
    rep(i, n){
        rep(j, mx){
            if(j+c[i]<=mx){
                to[i*(mx+1)+j].push_back(make_pair(i*(mx+1)+j+c[i], d[i]));
            }else{
                to[i*(mx+1)+j].push_back(make_pair(i*(mx+1)+mx, d[i]));
            }
            
        }
    }
    rep(i, m){
        rep(j, mx+1){
            if(j-a[i]<0)continue;
            to[u[i]*(mx+1)+j].push_back(make_pair(v[i]*(mx+1)+j-a[i], b[i]));
            to[v[i]*(mx+1)+j].push_back(make_pair(u[i]*(mx+1)+j-a[i], b[i]));
        }
    }

    ll INF = 1001001001001001001;
    vector<ll> dist(n*(mx+1), INF);
    dist[0*(mx+1)+s] = 0;
    priority_queue<P, vector<P>, greater<P>> que;
    que.push(make_pair(0, 0*(mx+1)+s));
    while(!que.empty()){
        P p = que.top();
        que.pop();
        ll distance = p.first;
        int v = p.second;
        if(dist[v] < distance)continue;
        for(P t : to[v]){
            if(dist[t.first] > dist[v] + t.second){
                dist[t.first] = dist[v] + t.second;
                que.push(make_pair(dist[t.first], t.first));
            }
        }
    }
    
    for(int i = 1; i < n; i++){
        ll ans = INF;
        rep(j, mx+1){
            ans = min(ans, dist[i*(mx+1)+j]);
        }
        cout << ans << endl;
    }
    
}

Measured memory_bytes: 23988
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
typedef long long ll;
vector<ll> ans;
void kkk(ll a){
    if(a>10000000000) return;
    else if(a%10==1){
        ans.push_back(a*10+0);
        kkk(a*10+0);
        ans.push_back(a*10+1);
        kkk(a*10+1);
        ans.push_back(a*10+2);
        kkk(a*10+2);
    }
    else if(a%10==2){
        ans.push_back(a*10+3);
        kkk(a*10+3);
        ans.push_back(a*10+1);
        kkk(a*10+1);
        ans.push_back(a*10+2);
        kkk(a*10+2);
    }
    else if(a%10==3){
        ans.push_back(a*10+3);
        kkk(a*10+3);
        ans.push_back(a*10+4);
        kkk(a*10+4);
        ans.push_back(a*10+2);
        kkk(a*10+2);
    }
    else if(a%10==4){
        ans.push_back(a*10+3);
        kkk(a*10+3);
        ans.push_back(a*10+4);
        kkk(a*10+4);
        ans.push_back(a*10+5);
        kkk(a*10+5);
    }
    else if(a%10==5){
        ans.push_back(a*10+6);
        kkk(a*10+6);
        ans.push_back(a*10+4);
        kkk(a*10+4);
        ans.push_back(a*10+5);
        kkk(a*10+5);
    }
    else if(a%10==6){
        ans.push_back(a*10+6);
        kkk(a*10+6);
        ans.push_back(a*10+7);
        kkk(a*10+7);
        ans.push_back(a*10+5);
        kkk(a*10+5);
    }
    else if(a%10==7){
        ans.push_back(a*10+6);
        kkk(a*10+6);
        ans.push_back(a*10+7);
        kkk(a*10+7);
        ans.push_back(a*10+8);
        kkk(a*10+8);
    }
    else if(a%10==8){
        ans.push_back(a*10+9);
        kkk(a*10+9);
        ans.push_back(a*10+7);
        kkk(a*10+7);
        ans.push_back(a*10+8);
        kkk(a*10+8);
    }
    else if(a%10==9){
        ans.push_back(a*10+9);
        kkk(a*10+9);
        ans.push_back(a*10+8);
        kkk(a*10+8);
    }
    else if(a%10==0){
        ans.push_back(a*10+0);
        kkk(a*10+0);
        ans.push_back(a*10+1);
        kkk(a*10+1);
    }
}


int main() {
  int k;
  cin>>k;
  for(int i=1;i<10;i++) kkk(i);
  for(int i=1;i<10;i++) ans.push_back(i);

  sort(ans.begin(),ans.end());
  cout<<ans[k-1]<<endl;
  
}

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

#define rep(i,n) for(ll i = 0; i < (n); i++)
#define repd(i,n) for(ll i = (n); i >= 0; i--)
#define FOR(i,t,n) for(ll i = (t); i < (n); i++)
#define FORD(i,t,n) for(ll i = (n); i >= t; i--)
#define ALL(x) x.begin(),x.end()
#define asort(x) sort(ALL(x))

int main() {
    ll N, a, prev_a, sum = 0, dai;
    cin >> N;
    rep(i,N) {
        cin >> a;
        if(i == 0) {
            prev_a = a;
            continue;
        } else {
            if(prev_a > a) {
                dai = prev_a - a;
                prev_a = a + dai;
            } else {
                dai = 0;
                prev_a = a;
            }
        }   
        sum += dai;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3616
/**
*    author:  velengel
*    created: 12.06.2020 17:07:19
*    to run & test the code, type below command.
*    cptest abc000_a
**/

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

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int a,b;
  cin >> a >> b;
  cout << a * b << endl;
  return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>
int n,k,i,j,p,num[5040],c[4],card[10],ans;
void set(int x){
    int i,j;
    if (x==k) {
        for (i=0; i<k; i++) {
            num[p]=num[p]*10;
            if (card[c[i]]>=10) {
                num[p]=num[p]*10;
            }
            num[p]+=card[c[i]];
        }
        p++;
        return;
    }
    for (i=0; i<n; i++) {
        int flag=1;
        for (j=0; j<x; j++) {
            if (c[j]==i) {
                flag=0;
                break;
            }
        }
        if (flag) {
            c[x]=i;
            set(x+1);
        }
    }
    return;
}
int main(){
    while (1) {
        scanf("%d%d",&n,&k);
        if (n==0&&k==0) {
            return 0;
        }
        for (i=0; i<n; i++) {
            scanf("%d",&card[i]);
        }
        for (i=0; i<5040; i++) {
            num[i]=0;
        }
        p=0;
        set(0);
        ans=0;
        k=p;
        while (k>0) {
            for (i=0; i<p; i++) {
                if (num[i]!=-1) {
                    ans++;
                    k--;
                    for (j=i+1; j<p; j++) {
                        if (num[i]==num[j]) {
                            k--;
                            num[j]=-1;
                        }
                    }
                }
            }
        }
        printf("%d\n",ans);
    }
}

Measured memory_bytes: 2604
#include <cstdio>
using namespace std;
int main() {
  int a[4] = {}, b;
  for (int i = 0; i < 2; i++) {
    scanf("%d", &b);
    a[b] = 1;
  }
  for (int i = 1; i <= 3; i++) {
    if (a[i] == 0) {
      printf("%d\n", i);
      return 0;
    }
  }
}

Measured memory_bytes: 128
n = int(input())
A = list(map(int, input().split()))

from collections import Counter
C = Counter(A)

X = [0]*(10**6+1)
A = list(set(A))
A.sort()
ans = 0
for a in A:
    if X[a] == 0 and C[a] == 1:
        ans += 1
    X[a] += 1
    j = 2*a
    while j <= 10**6:
        X[j] += 1
        j += a
print(ans)


Measured memory_bytes: 164652
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#define inf 10000000
using namespace std;

int main(){
    string S;
    cin >> S;

    int i,a,ans=inf;

    for(i=0 ; i<S.length()-2 ; i++){
        a = stoi(S.substr(i,3));
        ans = min(ans , abs(753-a));
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=2e5+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,m,ans,a[N];

int main() {
	qr(n);qr(m);
	for(int i=1,x;i<=m;i++) {
		int t;qr(t); while(t--) qr(x),a[x]=1;
	}
	for(int i=1;i<=n;i++) ans+=!a[i];
	pr2(ans); 
	return 0;
}



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


int E;
while(1){
scanf("%d",&E);if(E==0)break;
int min=E;int m=E,max=0;
int i=1;int y=0,z=0;
for(int j=0;j*j<=(E);j++){
	
for(int k=0;k*k*k<=(E-j*j);k++)
{i=E-j*j-k*k*k;//printf("%d %d %d\n",i,j,k*k*k);
	if(i+j*j+k*k*k>E)break;
	if(i>=0&&i+j*j+k*k*k==E&&i+j+k<min){min=i+j+k;max=j*j+k*k*k;y=j;z=k;}
}}
i=E-y*y-z*z*z;
m=i+y+z;
printf("%d\n",min);
}
return 0;
}

Measured memory_bytes: 1028
from heapq import heappush, heappop
from collections import deque,defaultdict,Counter
import itertools
from itertools import permutations,combinations
import sys
import bisect
import string
import math
import time
import random
def I():
    return int(input())
def MI():
    return map(int,input().split())
def LI():
    return [int(i) for i in input().split()]
def LI_():
    return [int(i)-1 for i in input().split()]
def show(*inp,end='\n'):
    if show_flg:
        print(*inp,end=end)
YN=['Yes','No']
mo=10**9+7
ts=time.time()
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
show_flg=False
#show_flg=True

class Bit:
    def __init__(self,n):
        self.size=n
        self.m=len(bin(self.size))-2
        self.arr=[0]*(2**self.m+1)
        
    def __str__(self):
        return str(self.arr)
        
    def add(self,i,x):
        k=0
        while i<=self.size:
            k+=1
            self.arr[i]+=x
            i+=i&(-i)
        return
    
    def sum(self,i):
        rt=0
        while i>0:
            rt+=self.arr[i]
            i-=i&(-i)
        return rt
    
    def l_bound(self,w):
        if w<=0:
            return 0
        x=0
        k=2**self.m
        while k>0:
            if x+k<self.size and self.arr[x+k]<w:
                w-=self.arr[x+k]
                x+=k
            k//=2
        return x+1

        
class Bit0(Bit):
    def add(self,j,x):
        super().add(j+1,x)
    def l_bound(self,w):
        return max(super().l_bound(w)-1,0)

n=I()
a=LI()
p=[i+1 for i,j in sorted(enumerate(a),key=lambda x:x[1])]
bt=Bit0(n+2)
bt.add(0,1)
bt.add(n+1,1)
ans=0
for i in range(n-1,-1,-1):
    c=bt.sum(p[i])
    w,x,y,z=[bt.l_bound(c-1+i) for i in range(4)]
    c=p[i]
    bt.add(p[i],1)
    d=(i+1)*((x-w)*(y-c)+(c-x)*(z-y))
    ans+=d
print(ans)

Measured memory_bytes: 65184
"""AtCoder"""

N = int(input())
xu = [list(input().split()) for _ in range(N)]

ans = 0

for i in range(N):
  if xu[i][1] == "JPY":
    ans += int(xu[i][0])
  else:
    ans += float(xu[i][0]) * 380000.0

print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define rrep(i,n) for (int i=(n-1);i >= 0;i--)
#define all(v) v.begin(),v.end()
#define sz(v) (int)((v).size())
#define MAX(v) *max_element(all(v))
#define MIN(v) *min_element(all(v))
using namespace std; using ll = long long; using P = pair<int,int>;
using vl = vector<ll>; using vvl = vector<vl>;
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << H << " ";
    debug_out(T...);
}
#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
    for (std::size_t i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
    return os;
}
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){cin >> first;IN(rest...);return;}
template<class T>bool chmax(T &a, const T &b) {if(a<b){a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) {if(b<a){a=b; return 1;} return 0;}
const ll INF = 1LL << 60;
const ll mod = 1000000007;
const int dx[8] = {1,0,-1,0,1,1,-1,-1}; const int dy[8] = {0,1,0,-1,1,1,-1,-1};

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n; cin >> n;
    vl p(n);
    ll cnt1 = 0,cnt2 = 0;
    rep(i,n){
        cin >> p[i];
    }
    rep(i,n){
        if(p[i] == i+1){
            if(i == n-1){
                debug(i,'a');
                cnt1++;
                break;
            }
            if(p[i+1] == i+2){
                debug(i,'b');
                cnt2++;
                i++;
            }else{
                debug(i,'c');
                cnt1++;
            }
        }
    }
    cout << cnt1 + cnt2 << endl;
}

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

int main(){
  int n;
  cin >> n;
  n = n%10;
  if(n == 3){cout << "bon" << endl;}
  else if(n == 0 ||n ==  1 || n == 6 || n == 8){
    cout << "pon" << endl;}
  else cout << "hon" << endl;}



Measured memory_bytes: 3644
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass
{
    static void Main()
    {
        int K = int.Parse(ReadLine());
        long ans = 0;
        for (int i = 0; i < K; i++)
        {
            for (int j = 0; j < K; j++)
            {
                for (int k = 0; k < K; k++)
                {
                    ans += gcd(gcd(i + 1, j + 1), k + 1);
                }
            }
        }
        WriteLine(ans);
    }
    static long gcd(long a,long b)
    {
        return a == 0 ? b : gcd(b % a, a);
    }
}


Measured memory_bytes: 27536
N, K = map(int, input().split())
V = list(map(int, input().split()))
lst = []
take = min(N, K)
ans = 0

for i in range(take+1):
    for j in range(take - i +1):
        lst = V[:i] + V[N - j:]
        lst.sort()
        cnt = 0
        for t in lst:
            if t < 0:
                cnt += 1
        d = min(cnt, K - ( i + j))
        del lst[:d]
        ans = max(ans, sum(lst))

print(ans)

Measured memory_bytes: 3064
#include <cmath>
#include <iostream>
#include <numeric>
#include <vector>
using namespace std;
int main()
{
    int n;
    cin >> n;
    vector<int>h(n);
    for(auto &x : h){
        cin >> x;
    }
    auto c = 0;
    for(int i = 0; i < n; ++i){
        auto flg = 1;
        for(int j = 0; j < i; ++j){
            if(h[j] > h[i]){
                flg = 0;
            }
        }
        if(flg){
            c++;
        }
    }
    cout << c;
    return 0;
}

Measured memory_bytes: 256