akhauriyash/Code-Regression huggingface dataset:
def walk(h, w, maze, que, step):
    search_area = ((h, w - 1), (h, w + 1), (h - 1, w), (h + 1, w))
    for i in range(4):
        search_cell = search_area[i]
        condition1 = search_cell[0] in range(H)
        condition2 = search_cell[1] in range(W)
        if condition1 and condition2:
            if maze[search_cell[0]][search_cell[1]] == '.':
                que.append(search_cell)
                maze[search_cell[0]][search_cell[1]] = step


def warp(h, w, maze, que, step):
    for i in range(-2, 3):
        for j in range(-2, 3):
            search_cell = (h + i, w + j)
            condition1 = search_cell[0] in range(H)
            condition2 = search_cell[1] in range(W)
            if condition1 and condition2:
                if maze[search_cell[0]][search_cell[1]] == '.':
                    que.append(search_cell)
                    maze[search_cell[0]][search_cell[1]] = step


H, W = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
maze = [list(input()) for _ in range(H)]
                    
ques = [[(Ch - 1, Cw - 1)]]  # list of list of tuples
step = 0

i = 0
while True:
    try:
        walk(h=ques[step][i][0], w=ques[step][i][1], maze=maze, que=ques[step], step=step)
        i += 1
    except:
        step += 1
        ques.append([])
        break

while True:
    for cell in ques[step - 1]:
        warp(h=cell[0], w=cell[1], maze=maze, que=ques[step], step=step)
    if ques[step] == []:
        break
    else:
        i = 0
        while True:
            try:
                walk(h=ques[step][i][0], w=ques[step][i][1], maze=maze, que=ques[step], step=step)
                i += 1
            except:
                step += 1
                ques.append([])
                break

if type(maze[Dh - 1][Dw - 1]) == int:
  print(maze[Dh - 1][Dw - 1])
else:
  print(-1)


Measured memory_bytes: 176484
n=int(input())
l=list(map(int,input().split()))
mod=10**9+7
c=[-1]*(n+1)
for i,j in enumerate(l,1):
    if(c[j]==-1):
        c[j]=i
    else:
        i1,i2=c[j],i
        break
fra=[1]*(n+2)
inv=[1]*(n+2)
c=1
t=1
for i in range(1,n+2):
    c*=i
    c%=mod
    t*=pow(i,mod-2,mod)
    t%=mod
    fra[i]=c
    inv[i]=t
def comb(n,r):
    return fra[n]*inv[n-r]*inv[r]%mod
for i in range(1,n+2):
    t=n-i2+i1
    if t+1<i:
        print(comb(n+1,i))
    else:
        print((comb(n+1,i)-comb(t,i-1))%mod)

Measured memory_bytes: 16008
#include<iostream>
using namespace std;
int main(){
    int n,y;
    cin>>n>>y;
    int a,b,c,x=0;
    for(int i=0;i<=n;i++){
        for(int j=0;j<=n;j++){
            if(y-10000*i-5000*j>=0&&(y-10000*i-5000*j)/1000==n-i-j){
                x=1,a=i,b=j,c=n-i-j;
                break;
            }
        }
        if(x==1) break;
    }
    if(x==0) a=-1,b=-1,c=-1;
    cout<<a<<" "<<b<<" "<<c;
}

Measured memory_bytes: 256
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque

def lcm(a, b):
    """最小公倍数"""
    from math import gcd
    return (a * b) // gcd(a, b)


# from decorator import stop_watch
#
#
# @stop_watch
def solve(A, B, C, D):
    A -= 1
    non_div_A = A - (A // C) - (A // D) + (A // lcm(C, D))
    non_div_B = B - (B // C) - (B // D) + (B // lcm(C, D))
    print(non_div_B - non_div_A)


if __name__ == '__main__':
    # S = input()
    # N = int(input())
    A, B, C, D = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(A, B, C, D)


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

bool solve() {
    ll N, M;
    cin >> N >> M;
    vector<string> A(N), B(M);
    for ( int i = 0; i < N; i++ ) {
        cin >> A[i];
    }
    for ( int i = 0; i < M; i++ ) {
        cin >> B[i];
    }

    for ( int i1 = 0; i1 + M - 1 < N; i1++ ) {
        for ( int i2 = 0; i2 + M - 1 < N; i2++ ) {
            bool ng = false;
            for ( int j1 = 0; j1 < M; j1++ ) {
                if ( A[i1+j1].substr(i2, M) != B[j1] ) {
                    ng = true;
                    break;
                }
            }
            if ( !ng ) return true;
        }
    }
    return false;
}

int main() {
    string ans = solve() ? "Yes" : "No";
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main()
{
	ll A,B;
	ll coin=0;
	cin>>A>>B;
	if(A>B){
		coin+=A;
		A--;
	}else{
		coin+=B;
		B--;
	}
	if(A>B){
		coin+=A;
		A--;
	}else{
		coin+=B;
		B--;
	}
	cout<<coin<<endl;
}

Measured memory_bytes: 256
main = do
    n <- read <$> getLine :: IO Int
    print $ length (filter ((<=n) . read) (num753Numbers 9 ""))

num753Numbers :: Int -> String -> [String]
num753Numbers maxDigit xs
    | length xs > maxDigit = []
    | otherwise = let list7 = num753Numbers maxDigit ('7':xs)
                      list5 = num753Numbers maxDigit ('5':xs)
                      list3 = num753Numbers maxDigit ('3':xs)
                      includes753 = '7' `elem` xs && '5' `elem` xs && '3' `elem` xs
                      includesOnly753 = and (map (`elem` "753") xs)
                      list = if includes753 && includesOnly753 then [xs] else []
                  in concat [list7, list5, list3, list]


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
typedef long long ll;

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

  vector <int> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  
  vector <bool> checked(N + 1);
  vector <int> cnt(N + 1);
  int M = 0;

  for (int i = N - 1; i >= 0; i--){
    checked[A[i] - 1] = true;
    if (checked[A[i]] == false){
      cnt[A[i] - 1] = 1;
    }else{
      cnt[A[i] - 1] = cnt[A[i]] + 1;
    }

    if (M < cnt[A[i] - 1]){
      M = cnt[A[i] - 1];
    }
  }

  cout << N - M << endl;
  

  return 0;
}


Measured memory_bytes: 1792
n = int(input())

a = list(map(int,input().split()))
b = [0]*n
for i in range(n):
    if i % 2 == 0:
        b[i//2] = a[n-i-1]
    if i % 2 == 1:
        b[n-((i+1)//2)] = a[n-(i+1)]


ans = list(map(str,b))
print(" ".join(ans))


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

bool solve(string s) {
	unordered_map<char, int> map;
	for (int i = 0; i < s.length(); i++)
		map[s[i]]++;
	for (auto x: map)
		if (x.second % 2 == 1) return 0;
	return 1;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	string s;
	cin >> s;
	if (solve(s)) cout << "Yes";
	else cout << "No";
}

Measured memory_bytes: 256
#include       <set>
#include       <map>
#include     <queue>
#include     <cmath>
#include    <cstdio>
#include    <cctype>
#include    <vector>
#include   <cstring>
#include <algorithm>
using namespace std;

typedef long long ll;
const ll mod = 1e9+7;
const double eps = 1e-7;
const int maxn = 1e5+5;

ll fast_pow(ll a,ll b,ll mod){
    ll ans = 1;
    while(b){
        if(b&1)
            ans = ans*a%mod;
        a = a*a%mod;
        b>>=1;
    }
    return ans;
}

int f(ll x){
    int k = 0;
    while(x){
        k ++;
        x /= 10;
    }
    return k;
}
int main(){
    ll n;
    scanf("%lld",&n);
    int ans = f(n);
    for(int i=1;i<maxn;i++)
        if(n%i==0)
            ans = min(ans,max(f(i),f(n/i)));
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cstring>

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

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector< vector<int> > Buil(2, vector<int>(n + 2));
		for(int i = 0; i < 2; ++i)
		{
			for(int j = 0; j < n; ++j)
			{
				cin >> Buil[i][j];
			}
		}
		queue<PP> Que;
		Que.push(PP(P(0, 0), 0));
		Que.push(PP(P(1, 0), 0));
		bool used[2][101];
		memset(used, 0, sizeof(used));
		while(!Que.empty())
		{
			PP pp = Que.front();
			Que.pop();
			if(Buil[pp.first.first][pp.first.second] == 1)
			{
				while(pp.first.first < n && Buil[pp.first.first][pp.first.second] == 1)
				{
					++pp.first.second;
				}
				--pp.first.second;
			}
			else if(Buil[pp.first.first][pp.first.second] == 2)
			{
				while(Buil[pp.first.first][pp.first.second] == 2)
				{
					--pp.first.second;
				}
			}

			if(used[pp.first.first][pp.first.second])
			{
				continue;
			}
			used[pp.first.first][pp.first.second] = true;
			if(pp.first.second >= n - 1)
			{
				cout << pp.second << endl;
				goto END;
			}
			
			for(int i = 0; i < 3; ++i)
			{
				Que.push(PP(P(!pp.first.first, pp.first.second + i), pp.second + 1));
			}
		}
		cout << "NA" << endl;
END:
		;
	}
}

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

Measured memory_bytes: 0
#include <iostream>
#include <iomanip>
#include <vector>

void calc(std::vector<double> first, std::vector<double> second) {
    double div;

    div = second[0] / first[0];
    second[1] -= first[1] * div;
    second[2] -= first[2] * div;
    second[2] /= second[1];

    first[2] -= first[1] * second[2];
    first[2] /= first[0];

    std::cout << std::fixed << std::setprecision(3) << first[2] << " " << second[2] << std::endl;
    return;
}

int main(void) {
    std::vector<double> first(3, 0);
    std::vector<double> second(3, 0);
    while(std::cin >> first[0]) {
        for (int i = 1; i < 3; i++) {
            std::cin >> first[i];
        }
        for (int i = 0; i < 3; i++) {
            std::cin >> second[i];
        } 
        calc(first, second);
    }
    return 0;
}

Measured memory_bytes: 3224
# coding: utf-8

n, m = [int(x) for x in input().rstrip().split(" ")]

l_max = 1
r_min = n

for i in range(m):
    l, r = [int(x) for x in input().rstrip().split(" ")]
    if l > l_max:
        l_max = l
    if r_min > r:
        r_min = r

if r_min < l_max:
    print(0)
else:
    print(r_min - l_max + 1)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define ALL(obj) (obj).begin(), (obj).end()

#define endl "\n"
#define pb push_back
#define elif else if
#define cout_db cout << fixed

#define MOD 1000000007LL
#define PI 3.1415926

typedef long long ll;

template <typename T>
inline T GCD(T a,T b){T c;while(b!=0){c=a%b;a=b;b=c;}return a;}
template <typename T>
inline T LCM(T a,T b){T c=GCD(a,b);a/=c;return a*b;}
template <typename T>
inline T nCr(T a,T b){T i,r=1;for(i=1;i<=b;i++){r*=(a+1-i);r/=i;}return r;}
template <typename T>
inline T nHr(T a,T b){return nCr(a+b-1,b);}
template <typename T>
inline T POW(T a,T b){int i,r=1;for(i=1;i<=b;i++){r*=a;}return r;}

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

	int n;
	ll t[100], ans = 1;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t[i];
		ans = LCM(ans, t[i]);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>
#include <locale>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;
typedef pair<long long int, pll> lpll;


const long long int mod = 998244353;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 
const long long int pl=1000000;

long long int N,M;
int main(){
    cout << fixed << setprecision(18);
    cin>>N>>M;
    cout<<(1900*M+100*(N-M))*(1<<M)<<endl;
}




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

#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
mt19937 rnd(time(0));
#define ioss ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("avia.in", "r", stdin); freopen("avia.out", "w", stdout);
#define _GLIBCXX_DEBUG
//#define s second
//#define f first
#define pb push_back
#define add insert
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define pii pair<int,int>
#define res resize
#define NO cout<<"NO"<<'\n'; return;
#define YES cout<<"YES"<<'\n'; return;
#define PI acos(-1)
#define gggg cout << "NO";return;
const ll INF = 1e9;//9223372036854775807L; //LONG_MAX;
constexpr ll mod = 1e9 + 7;


void solve() {
    int n;
    cin >> n;
    vector<int> arr(62);
    for (ll i = 0, x; i < n; i++) {
        cin >> x;
        for (int j = 0; j < 62; j++)if (x & (1LL << j))arr[j]++;
    }
    ll ans = 0;
    for (int i = 0; i < 62; i++) {
        ll upd = (1LL << i) % mod;
        upd = (upd * arr[i]) % mod;
        upd = (upd * (n - arr[i])) % mod;
        ans = (ans + upd) % mod;
    }
    cout << ans;
}

signed main() {
    ioss
    //file
    //id.resize(3e5);
    int t = 1;                                                                                                                                                                        //ll
    //cin >> t;
    while (t--) {
        solve();
    }
    return 0;
}




Measured memory_bytes: 256
A,V=map(int,input().split())
B,W=map(int,input().split())
#R=10**9
#L=(-1)*(10**9)
T=int(input())

ans="NO"
if A<B:
    if A+T*V>=B+T*W:
        ans="YES"
else:
    if A-T*V <= B-T*W:
        ans="YES"
print(ans)

Measured memory_bytes: 9184
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> Int -> Int -> Int
solve !a !b !c = minimum [a + b, b + c, c + a]

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  (p, q, r) <-
    (\vec -> (vec VU.! 0, vec VU.! 1, vec VU.! 2))
    .   VU.unfoldrN 3 readInt
    <$> B.getLine
  print $ solve p q r


Measured memory_bytes: 380
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <map>
#include <iterator>
#include <queue>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
// #define ll long long
typedef long long ll;
typedef pair<int, int> P;

bool compare(pair<int,int> i1, pair<int,int> i2) 
{ 
    return (i1.second < i2.second); 
} 

void bfs(){

}

int main(int argc, const char * argv[]) {

  string s, t;
  cin >> s >> t;
  int ans = 0;
  rep(i, s.size()){
    if (s[i] == t[i]) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb(a) push_back(a)
#define pf(a) push_front(a)
#define MP make_pair
#define SV(n,v) {int tmp;for(int i=0;i<n;++i){scanf("%d", &tmp);v.push_back(tmp);}}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  int n;
  scanf("%d", &n);

  printf("%d\n", n / 3);
  return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int N,M,C;
    cin >> N >> M >> C;
    int B[M+1];
    int A[N+1][M+1];
    int i,j;
    for(i=1;i<=M;i++){
        cin >> B[i];
    }
    for(i=1;i<=N;i++){
        for(j=1;j<=M;j++){
            cin >> A[i][j];
        }
    }
    int ans=0,sum=C;
    for(i=1;i<=N;i++){
        for(j=1;j<=M;j++){
            sum+=A[i][j]*B[j];
        }
        if(sum>0) ans++;
        sum=C;
    }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define int long long
 
const int N=1005;
const int MOD=1e9+7;
 
 
// lower_bound - which does not compare less than val
// upper_bound - which compares greater than val
 
 
int32_t main()
{
 
  

  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  /* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
*/
int  h , w , k = 2;
  cin>>h>>w;
  int x=h*w;

  if(h==1|| w==1)
  {
    cout<<"1";
    return 0;
  }
  if(x%2==0)
  {
    cout<<x/2;
  }
  else
  {
    cout<<(x/2)+1;
  }
 
  
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n, m, ans = 0;
    cin >> n >> m;
    vector<P> a(n);
    priority_queue<ll> que;
    rep(i, n)cin >> a[i].first >> a[i].second;
    sort(all(a));
    int j = 0;
    rep(i, m){
        while(j < n && a[j].first <= i+1){
            que.push(a[j].second);
            j++;
        }
        if(!que.empty()){
            ans += que.top();
            que.pop();
        }
    }
    cout << ans << endl;
}
    

Measured memory_bytes: 2168
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char te[] = "ABC";
int main()
{
	char *s;
	int i,count,n,flag,j;
	
	count = 0;
	scanf("%d",&n);
	
	getchar();
	
	s = malloc(sizeof(char) * n);
	
	gets(s);
	
	for(i = 0;*(s + i);)
	{
		if(*(s + i) == te[0])
		{
			flag = 1;
			for(j = 1;te[j];j++)
			{
				if(te[j] != *(s + i + j))
				{
					flag = 0;
					break;
				}
			}
			if(flag == 1)
				count++;
				
			i++;
		}
		else i++;
	}
	
	printf("%d\n",count);
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long N, M;
    cin >> N >> M;
    ll A, B;
    vector<vector<ll>> Node(N+1);
    for(size_t i=0;i<M; i++)
    {
        cin >> A >> B;
        Node[A].push_back(B);
        Node[B].push_back(A);
    }

    queue<ll> q;
    q.push(1);
    vector<ll> ans(N+1);
    ans[1]=1;

    while(!q.empty())
    {
        //Node 1からスタート
        ll index = q.front();q.pop();
        cerr << index << endl;
        for(size_t i=0;i<Node[index].size(); i++)
        {
            //探索してなければ足す
            if(!ans[Node[index][i]])
            {
                ans[Node[index][i]] = index;
                q.push(Node[index][i]);
            }
        }
    }

    cout << "Yes" << endl;
    for(size_t i=2;i<=N; i++)
    {
        cout << ans[i] << endl;
    }

#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 12864
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <stack>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

using namespace std;
typedef long long int ll;

int main()
{
	int n;
	cin>>n;
	int num = 0;
	for(int i = 1; i< 100; i++){
		if( num >= n) break;
		num = i * 1000;
	}
	cout<<num - n<<endl;
	return 0;
}


Measured memory_bytes: 3192
import sys
input = sys.stdin.readline

def find_where( List , word ):
    flag = 1
    for i , list_i in enumerate(List):
        if list_i > word:
            flag = 0
            break
    return i + flag

def main():
    n , l = map( int, input().split() )
    I = []
    for i in range(n):
        s = str(input())
        s = s[:-1]
        I.append( s )
    Ss = []
    Ss.append( I[0] )

    for i in range(1,n):
        s = I[i]
        where_i = find_where( Ss , s )


        Ss.insert( where_i , s )

    ans = ''.join(Ss)
    print(ans)

main()

Measured memory_bytes: 9160
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define repeat(i,a,b) for(int i=(a),i##__end=(b);i<i##__end;i++)
#define repeat_back(i,a,b) for(int i=(b)-1,i##__end=(a);i>=i##__end;i--)
#define mst(a,x) memset((a),(x),sizeof(a))
struct node{
	int to,dis;
	bool operator<(node x)const{
		return x.dis<dis;
	}
};
vector<node> a[1010];
priority_queue<node> q;
int dis[1010],vis[1010],u[2010],v[2010],last[1010];
int n,m,s,x,p,i;
vector<int> ans;

void dijkstra(const int s){
	repeat(i,0,n){
		vis[i]=0;
		dis[i]=10000;
	}
	dis[s]=0; last[s]=-1;
	q=priority_queue<node>();
	q.push((node){s,0});
	while(!q.empty()){
		x=q.top().to; q.pop();
		if(vis[x])continue; vis[x]=1;
		repeat(i,0,a[x].size()){
			p=a[x][i].to;
			if(dis[p]>dis[x]+a[x][i].dis){
				dis[p]=dis[x]+a[x][i].dis;
				if(!vis[p])q.push((node){p,dis[p]});
				last[p]=x;//
			}
		}
	}
}

int main(){
	//ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cin>>n>>m;
	repeat(i,0,m){
		cin>>u[i]>>v[i];u[i]--,v[i]--;
		a[u[i]].push_back((node){v[i],1});
	}
	repeat(i,0,m){
		dijkstra(v[i]);
		if(dis[u[i]]!=10000)
		if(ans.empty() || ans.size()>dis[u[i]]+1){
			ans.clear();
			for(int k=u[i];k!=-1;k=last[k])
				ans.push_back(k+1);
			//cout<<ans.size()<<"--"<<dis[u[i]]+1<<endl;
		}
		//cout<<"dis: ";
		//repeat(i,0,n)cout<<dis[i]<<' ';cout<<'\n';
	}
	if(ans.empty())cout<<-1<<endl;
	else{
		cout<<ans.size()<<endl;
		repeat_back(i,0,ans.size())
			cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

template<ll Mod>
struct ModInt{
    long long x;
    ModInt():x(0){}
    ModInt(long long y):x(y>=0?y%Mod:(Mod-(-y)%Mod)%Mod){}
    ModInt &operator+=(const ModInt &p){
        if((x+=p.x)>=Mod) x-=Mod;
        return *this;
    }
    ModInt &operator-=(const ModInt &p){
        if((x+=Mod-p.x)>=Mod)x-=Mod;
        return *this;
    }
    ModInt &operator*=(const ModInt &p){
        x=(int)(1ll*x*p.x%Mod);
        return *this;
    }
    ModInt &operator/=(const ModInt &p){
        (*this)*=p.inverse();
        return *this;
    }
    ModInt operator-()const{return ModInt(x);}
    ModInt operator+(const ModInt &p)const{return ModInt(*this)+=p;}
    ModInt operator-(const ModInt &p)const{return ModInt(*this)-=p;}
    ModInt operator*(const ModInt &p)const{return ModInt(*this)*=p;}
    ModInt operator/(const ModInt &p)const{return ModInt(*this)/=p;}
    ModInt operator==(const ModInt &p)const{return x==p.x;}
    ModInt operator!=(const ModInt &p)const{return x!=p.x;}
    ModInt inverse()const{
        int a=x,b=Mod,u=1,v=0,t;
        while(b>0){
            t=a/b;
            swap(a-=t*b,b);swap(u-=t*v,v);
        }
        return ModInt(u);
    }
    ModInt pow(long long n)const{
        ModInt ret(1),mul(x);
        while(n>0){
            if(n&1) ret*=mul;
            mul*=mul;n>>=1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os,const ModInt &p){return os<<p.x;}
    friend istream &operator>>(istream &is,ModInt &a){long long t;is>>t;a=ModInt<Mod>(t);return (is);}
    static int get_mod(){return Mod;}
};
using mint=ModInt<mod>;

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    ll l,r;cin>>l>>r;
    mint dp[100][3][3][3]={};

    dp[60][0][0][0]=1;
    // dp[d][i][j][k]
    // d : 桁
    // i : Rより小さい確定, (2: 破棄)
    // j : Lより大きい確定，(2: 破棄)
    // k : (1,1)の登場済み


    auto rc=[&](int bit,int idx,int put){
        // bit立ってるなら置こうとしてるのが0ならok
        if(bit) return int(idx or !put);
        else return put?2-idx:idx;
        // bitが立ってない，かつidx=0で1置こうとしてるなら2
    };

    auto lc=[&](int bit,int idx,int put){
        if(!bit) return int(idx or put);
        else return put?idx:2-idx;
    };

    for(int d=59;d>=0;d--)rep(i,2)rep(j,2)rep(k,2){
        mint s=dp[d+1][i][j][k];
        ll br=(r>>d)&1,bl=(l>>d)&1;
        dp[d][rc(br,i,0)][lc(bl,j,0)][k]+=s;
        if(k) dp[d][rc(br,i,1)][lc(bl,j,0)][k]+=s;
        dp[d][rc(br,i,1)][lc(bl,j,1)][1]+=s;
    }

    mint ans=0;
    rep(i,2)rep(j,2)ans+=dp[0][i][j][1];
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include<iostream>
using namespace std;
int main()
{
    int x,hr,mnt,sec,temp;
    float rem;
    cin>>x;
    hr=x/3600;
    rem=x%3600;
    mnt=rem/60;
    temp=rem;
    sec=temp%60;
    cout<<hr<<":"<<mnt<<":"<<sec<<endl;
    return 0;
}


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

#pragma warning(disable:4996)
using namespace std;
using ld = long double;
ld eps=1e-9;
#define Seg_Max_N (1<<18) 

int ans=0;
int need;
int dfs(long long int num, int k,vector<int>&oks) {
	vector<int>v{ 3,5,7 };
	if(num<=need&&oks[0]&&oks[1]&&oks[2])ans++;
	if(num>=1e9)return 0;
	for (int i = 0; i < 3; ++i) {
		oks[i]++;
		dfs(num*10+v[i],k,oks);
		oks[i]--;
	}
	return 0;
}


vector<int>primes;
void hurui(const int amax) {
	static bool flag = false;
	if (flag)return;
	vector<int>sos;
	sos = vector<int>(amax + 1, true);
	sos[0] = false; sos[1] = false;
	for (int i = 2; i <= amax; ++i) {
		if (sos[i]) {
			for (int j = 2 * i; j <= amax; j += i)sos[j] = false;
		}
	}
	for (int i = 0; i <= amax; ++i) {
		if (sos[i]) {
			primes.push_back(i);
		}
	}
	flag = true;
}
map<long long int, int>soinnsuu(long long int a) {
	hurui(1000);
	map<long long int, int>ans;
	for (auto i : primes) {
		if (i> a)break;
		while (a%i == 0) {
			ans[i]++;
			a /= i;
		}
	}
	if (a != 1)ans[a]++;
	return ans;
}
int main() {

	/*string st;cin>>st;
	int ans=100000;
	for (int i = 0; i <= st.size() - 3; ++i) {
		string a=st.substr(i,3);
		int k=stoi(a);
		ans=min(ans,abs(753-k));

		
	}
	cout<<ans<<endl;
*/
	cin>>need;
	vector<int>oks(3);
	dfs(0,1,oks);
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
using namespace std;
 
int ed(string a,string b){
  int n=a.size();
  int m=b.size();
  vector< vector< int > > dp;
  dp.resize(n+1);
 
  for(int i=n;i>=0;i--){
    dp[i].resize(m+1);
     
    for(int j=m;j>=0;j--){
      if(i==n){
        dp[i][j]=m-j;
      }else if(j==m){
        dp[i][j]=n-i;
      }else{
        dp[i][j]=1e9;
        if(a[i]==b[j])dp[i][j]=dp[i+1][j+1];
        else dp[i][j]=min(dp[i+1][j+1],min(dp[i][j+1],dp[i+1][j]))+1;
      }
    }
  }
  return dp[0][0];
}
 
 
int main(){
  string a,b;
  cin>>a>>b;
  cout<<ed(a,b)<<endl;
  return 0;
}


Measured memory_bytes: 6928
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int N,K,X,Y;
    cin >> N;
  	cin >> K;
  	cin >> X;
  	cin >> Y;
    
    int sum=0;
    for(int i=1;i<=N;i++){
        if(i<=K)
            sum+=X;
         else
            sum+=Y;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <array>
#include <numeric>
using namespace std;
using ll = long long;
using P = complex<double>;

double area(const array<double, 3> &sides) {
  double s = accumulate(sides.begin(), sides.end(), 0.0) / 2;
  double t = s;
  for (double x: sides) {
    t *= s - x;
  }
  return sqrt(t);
}

double inscribedCircleRadius(const array<double, 3> &sides) {
  double S = area(sides);
  double R = 2 * S / accumulate(sides.begin(), sides.end(), 0.0);
  return R;
}

int main() {
  array<P, 3> ps; 
  for (int i = 0; i < 3; i++) {
    int x, y;
    cin >> x >> y;
    ps[i] = P(x, y);
  }
  array<double, 3> sides;
  for (int i = 0; i < 3; i++) {
    sides[i] = abs(ps[i] - ps[(i+1)%3]);
  }
  double R = inscribedCircleRadius(sides);
  double m = *max_element(sides.begin(), sides.end());
  double res = m / (2 + m / R);
  printf("%.15f\n", res);
  return 0;
}


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

const int direction[4][2] = {{0,1},{0,-1},{-1,0},{1,0}};

int h,w,k;
char map[888][888];
int result[888][888];
std::priority_queue<std::pair<int,int>,std::vector<std::pair<int,int> >,std::greater<std::pair<int,int> > > queue;

inline int id(int a,int b)
{
    return a * (w + 1) + b;
}

int main(void)
{
    int i,j;
    int x,y;
    std::pair<int,int> z;
    int answer = 0x7f7f7f7f;
    int nx,ny;

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

    scanf("%d %d %d",&h,&w,&k);
    for(i = 1;i <= h;++i)
        scanf("%s",&map[i][1]);

    for(i = 1;i <= h;++i)
        for(j = 1;j <= w;++j)
            if(map[i][j] == 'S')
                goto next;

next:;
    z.first = 0;
    z.second = id(i,j);
    queue.push(z);
    while(!queue.empty())
    {
        z = queue.top();
        queue.pop();
        if(z.first > k)
            break;
        x = z.second / (w + 1);
        y = z.second % (w + 1);
        if(result[x][y] != z.first)
            continue;
        if(x == 1 || y == 1 || x == h || y == w)
            return puts("1"),0;
        answer = std::min(answer,(std::min(std::min(x,y) - 1,std::min(h - x,w - y)) + k - 1) / k);
        for(j = 0;j < 4;++j)
        {
            nx = x + direction[j][0];
            ny = y + direction[j][1];
            if(map[nx][ny] == '#')
                continue;
            if(result[nx][ny] && result[nx][ny] <= result[x][y] + 1)
                continue;
            z.first = result[nx][ny] = result[x][y] + 1;
            z.second = id(nx,ny);
            queue.push(z);
        }
    }
    printf("%d\n",answer + 1);

    return 0;
}

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

// #define DEBUG

const int NUM = 2 * 10e5 + 1;
// 存储
long long list[NUM];
// 标志访问
bool visit[NUM];
// 回路栈
vector<long long> vec;

int main()
{
#ifdef DEBUG
    freopen("debug/test.txt", "r", stdin);
    freopen("debug/result.txt", "w", stdout);
#endif // DEBUG
    // test case
    long long n, k;
    scanf("%lld %lld", &n, &k);
    // 初始化
    memset(list, 0, sizeof(list));
    memset(visit, 0, sizeof(visit));
    // 输入
    for (long long i = 0; i < n; i++) {
        scanf("%lld", &list[i]);
    }
    // 初始化
    long long buffer = 1;
    // 计算
    for (int i = 0; i < n; i++) {
        // 标志访问
        visit[buffer] = 1;
        // 节点入栈
        vec.push_back(buffer);
        // 获取下一个节点
        buffer = list[buffer - 1];
        // 若形成环路
        if (visit[buffer] == 1) {
            break;
        }
    }
    // 在栈中找出环路开始位置
    auto it = find(vec.begin(), vec.end(), buffer);
    // 环路长度
    long long cycleLength = vec.end() - it;
    // 环路开始前的栈深度
    long long stackLength = it - vec.begin();
    // debug
    // for (size_t i = 0; i < vec.size(); i++) {
    //     printf("%lld ", vec[i]);
    // }
    // printf("\n");
    // printf("cycleLength:%lld, stackLength:%lld, k:%lld\n", cycleLength, stackLength, k);
    // 最终位置
    long long posMark;
    if (k > stackLength) {
        // 若存在环路
        posMark = (k - stackLength) % cycleLength;
    } else {
        // 若不存在环路
        posMark = (k - stackLength);
    }

    //
    // printf("posMark:%lld, %lld\n", posMark, stackLength + posMark);
    // 输出
    printf("%lld\n", vec[stackLength + posMark]);
}


Measured memory_bytes: 22804
def angle(h, m)
  2*Math::PI * ((h/12 + m/60/12) - m/60)
end

def yogen(b, c, t)
  Math.sqrt(b**2 + c**2 - (2 * b * c * Math.cos(t)))
end

inputs = gets.chomp.split(/\s/)
puts yogen(inputs[0].to_r, inputs[1].to_r, angle(inputs[2].to_r, inputs[3].to_r))

Measured memory_bytes: 14740
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long INF = numeric_limits<long long>::max();
int main()
{
    int bingo[3][3];
    for (int i = 0; i < 3; i++){
        for (int j = 0; j < 3; j++){
            cin >> bingo[i][j];
        }
    }
    int N;
    int input;
    cin >> N;
    for (int no = 0; no < N; no++){
        cin >> input;
        for (int i = 0; i < 3; i++){
            for (int j = 0; j < 3; j++){
                if (bingo[i][j] == input){
                    bingo[i][j] = 0;
                }
            }
        }
    }
    //Vertical
    bool bingo_flag = false;
    for (int i = 0; i < 3; i++){
        int total = 0;
        for (int j = 0; j < 3; j++){
            total += bingo[i][j];
        }
        if (total == 0){
            bingo_flag = true;
            break;
        }
    }
    for (int j = 0; j < 3; j++){
        int total = 0;
        for (int i = 0; i < 3; i++){
            total += bingo[i][j];
        }
        if (total == 0){
            bingo_flag = true;
            break;
        }
    }
    int total1 = bingo[0][0] + bingo[1][1] + bingo[2][2];
    int total2 = bingo[0][2] + bingo[1][1] + bingo[2][0];
    if (total1==0 || total2 == 0){
        bingo_flag = true;
    }
    if (bingo_flag) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int N;
	vector<pair<int,int>> A;
	
	cin>>N;
	
	A.resize(N);
	
	for(int i = 0; i < N; i++){
		cin>>A[i].first;
		A[i].second = i+1;
	}
	
	sort(A.begin(), A.end());
	
	for(int i = 0; i < N; i++){
		if(i) cout<<" ";
		cout<<A[i].second;
	}
	cout<<endl;
	
	return 0;
}

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

int main()
{
    int n;
    cin>>n;
    
    int count[n+1];
    int arr[n+1];
    
    int i;
    
    for(i=0;i<=n;i++)
    count[i]=0;
    
    for(i=1;i<=n;i++)
    cin>>arr[i];
    
    int ans=1;
    
    for(i=1;i<=n;i++)
    {
        int temp=arr[i];
        //cout<<temp<<" "<<temp-1<<" "<<count;
        count[temp]=count[temp-1]+1;
        //cout<<count[temp]<<"\n";
        ans=max(ans,count[temp]);
        //cout<<ans<<"\n";
    }
    
    cout<<n-ans<<"\n";
}


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

int is_prime_f(int n) {
    int i;
    if(n < 2)
        return -1;
    else if(n == 2)
        return 1;

    if(n % 2 == 0)
        return -1;

    for(i = 3; i <= n / i; i += 2)
        if(n % i == 0)
            return -1;
    return 1;
}

unordered_map<int, int> map;

bool is_prime_map(int n) {
    int is_prime = map[n];
    if (is_prime == 0) {
        is_prime = is_prime_f(n);
        map[n] = is_prime;
    }
    return is_prime == 1;
}

int prime_num_count(int max) {
    int count = 0;
    for (int i = 1; i <= max; ++i) {
        if (is_prime_map(i)) {
            count++;
        }
    }
    return count;
}

int main() {
    string str;
    while(getline(cin, str)) {
        cout << prime_num_count(stoi(str.c_str())) << endl;
    }
    return 0;
}

Measured memory_bytes: 42172
#include <bits/stdc++.h>
using namespace std;
const unsigned int MOD = 1000000007;
#define ll long long
#define PI 3.1416
string day[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
int main() {
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    char x,y;
    while(cin>>x>>y){
        if(x<y)cout<<"<"<<endl;
        else if(x>y)cout<<">"<<endl;
        else cout<<"="<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
from decimal import *

INT = lambda: int(input())
INTM = lambda: map(int,input().split())
STRM = lambda: map(str,input().split())
STR = lambda: str(input())
LIST = lambda: list(map(int,input().split()))
LISTS = lambda: list(map(str,input().split()))
def do():
    n=INT()
    count=0
    if n%2==1:
        print(0)
    else:
        for i in range(1,30,1):
            b=n//(2*(5**i))
            count+=b
        print(count)
if __name__ == '__main__':
    do()

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

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

	int N = A.size();
	vector<vector<long long>> v( N, vector<long long>( 26 ) );
	for( int i = 0; i < N; i++ ) {
		int j = A[N - 1 - i] - 'a';
		v[N - 1 - i][j]++;
	}
	for( int i = 0; i < N - 1; i++ ) {
		for( int j = 0; j < 26; j++ ) {
			v[N - 2 - i][j] += v[N - 1 - i][j];
		}
	}
	long long ans = 1;
	for( int i = 0; i < N; i++ ) {
		long long n = 0;
		int k = A[i] - 'a';
		for( int j = 0; j < 26; j++ ) {
			if( j == k ) continue;
			n += v[i][j];
		}
		ans += n;
	}

	cout << ans << endl;
}


Measured memory_bytes: 51980
n = int(input())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
ans = 0
for i in range(n):
    ans += abs(x[i] - y[i])
print(ans)
ans = 0
for i in range(n):
    ans += (x[i] - y[i])**2
print(ans**(1/2))
ans = 0
for i in range(n):
    ans += (abs(x[i] - y[i]))**3
print(ans**(1/3))
ans = 0
for i in range(n):
    ans = max(ans, abs(x[i] - y[i]))
print(ans)


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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  bool beauty = false;
  if(b-a==c-b) beauty = true;
  if(beauty){
    printf("YES");
  }else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 256
// #include <bits/stdc++.h>
// // #include <ext/pb_ds/assoc_container.hpp>
// // #include <ext/pb_ds/tree_policy.hpp>
// // #pragma GCC optimize("unroll-loops,no-stack-protector")
// // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// // using namespace __gnu_pbds;
// using namespace std;
 
// // template <typename T>
// // using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
// typedef long long ll;
// typedef long double ld;
// typedef pair<long long ,long long> ii; 	
// //typedef complex<long double> com;

// const ll mod = 1e9+7;

// int main(){
// 	ios_base::sync_with_stdio(false);
// 	cin.tie(NULL);
// 	ll n,k;
// 	cin >> n >> k;
// 	vector <string> arr(n);
// 	for (int z=0;z<n;z++){
// 		cin >> arr[z];
// 	}
// 	sort(arr.begin(),arr.end());
// 	for (int z=0;z<n;z++){
// 		for (int x=z+1;x<n;x++){
// 			for (int y=x+1;y<n;y++){
// 				for (int a=0;a<k;a++){
// 					if (arr[z][a] == arr[z][] )
// 				}
// 			}
// 		}
// 	}	
// }

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

int n;

bool areEqual(vector <int> a, vector <int> arr){
    for(int i = 0; i < n; i++){
        if(a[i] != arr[i]){
            return false;
        }
    }
    return true;
}

int main(){
    cin >> n;
    vector <int> a(n);
    vector <int> arr(n);
    for(int i = 0; i < n; i++){
        cin >> arr[i];
        a[i] = arr[i];
    }
  	sort(a.begin(),a.end());
    int t1= 0,t2 = 0;
    while(!areEqual(a,arr)){
        next_permutation(a.begin(),a.end());
        t1++;
    }  
  	for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    sort(a.begin(),a.end());
    while(!areEqual(a,arr)){
        next_permutation(a.begin(),a.end());
        t2++;
    }
    int ans = t2 - t1;
    cout << abs(ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
char a1,b1,c1,d1;
int ans,a,b,c,d;
cin>>a1>>b1>>c1>>d1;
a=a1-'0';b=b1-'0';c=c1-'0';d=d1-'0';
for(char i='+';i<='-';i++)
    for(char j='+';j<='-';j++)
        for(char k='+';k<='-';k++)
        {
            ans=a;
            if(i=='+') ans+=b;
            else if(i=='-') ans-=b;
            if(j=='+') ans+=c;
            else if(j=='-') ans-=c;
            if(k=='+') ans+=d;
            else if(k=='-') ans-=d;
            if(ans==7)//找到了
            {
                cout<<a<<i<<b<<j<<c<<k<<d<<"="<<ans<<"\n";
                return 0;
            }
        }
}

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

int main() {
int n;
cin >> n;
vector<int> a(n);
double resultinv = 0.0;
for(int i=0; i<n; i++) {
    cin >> a[i];
    resultinv += 1.0 / (double)a[i];
}
cout << 1.0 / resultinv << endl;

return 0;

}

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


int main(){
    int n;
    cin >> n;
    int temp = n;
    n/=1.08;
    
    int ans1 = n*1.08;
    int ans2 = (n+1)*1.08;
    if(ans1 == temp)
        cout << n;
    else if(ans2 == temp)
        cout << n+1;
    else    
        cout << ":(";
    
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(_vs) for(auto _x : _vs){cout << _x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(_p) cout << _p.first << " " << _p.second << endl
#define printVP(_vp) for(auto _p : _vp) printP(_p);

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vector<int>> Graph;
const int inf = 1e9;
const int mod = 1e9 + 7;

// [1, x]???????????????3??§???5??§???????????????????????´??°????????°
int f(int x) {
    int n3 = x / 3;
    int n5 = x / 5;
    int n15 = x / 15;
    return x - n3 - n5 + n15;
}

// ??°x?????§???????????¨????????????????????????
int calc(int x) {
    int ret = 0;
    ret += 4 * (x / 3 + x / 5);

    int a = 0;
    int b = 9;
    rep(i, 100) {
        bool finish = false;
        if (x <= b) {
            b = x;
            finish = true;
        }
        // [a, b]???????????????3??§???5??§???????????????????????´??°????????°
        int m = f(b) - f(a);
        ret += (i + 1) * m;
        if (finish) {
            return ret;
        }
        a = b + 1;
        b = 10 * a - 1;
    }
}

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

    int n;
    cin >> n;

    int l = 0, r = 1e18;
    while (r - l > 1) {
        int m = (l + r) / 2;
        (calc(m) < n ? l : r) = m;
    }

    string s;
    rep2(x, l + 1, l + 100) {
        if (x % 3 == 0) s += "Fizz";
        if (x % 5 == 0) s += "Buzz";
        if (x % 3 != 0 && x % 5 != 0) s += to_string(x);
    }
    cout << s.substr(n - calc(l) - 1, 20) << endl;
}

Measured memory_bytes: 3304
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define INF ((1LL<<62)-(1LL<<31))
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))
#define bit(n,m)(((n)>>(m))&1)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}
ll pom(ll a,ll n,int m){ll x=1;for(a%=m;n;n/=2)n&1?x=x*a%m:0,a=a*a%m;return x;}
//#define MOD 998244353
#define MOD 1000000007
#define invp(a,p)pom(a,p-2,p)

int divisor[1000000+10];
int p[1000000+1],pcnt;
void maked(int n){divisor[0]=-1;divisor[1]=1;rep(i,2,n+1){if(!divisor[i])p[pcnt++]=divisor[i]=i;for(int j=0;j<pcnt&&p[j]<=divisor[i]&&i*p[j]<=n;j++)divisor[i*p[j]]=p[j];}}
int divv(ll n,ll*a){//約数（div使用）
	ll cnt=1;a[0]=1;
	while(n!=1){ll num=1,i=divisor[n],temp=i;while(n%i==0){n/=i;num++;}rep(k,1,num){rep(j,0,cnt)a[k*cnt+j]=a[j]*temp;temp*=i;}cnt*=num;}
	//sortup(a,cnt);
	return cnt;
}

int n;
int a[200010];
int aa[1000010];
ll yakusuu[1000];
int main(){
	maked(1000000+5);
	scanf("%d",&n);
	rep(i,0,n)scanf("%d",a+i);
	rep(i,0,n)aa[a[i]]++;

	int ans=0;
	rep(i,0,n){
		int cnt=divv(a[i],yakusuu);
		int flag=aa[a[i]]==1;
		rep(j,0,cnt)if(yakusuu[j]!=a[i])flag&=aa[yakusuu[j]]==0;
		if(flag)ans++;
	}
	printf("%d",ans);
}

Measured memory_bytes: 10540
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
	int c1=0,c2=0,c3=0,c0=0;
	int n;
	string s;
	
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>s;
		if(s=="AC")
		c0++;
		else if(s=="WA")
		c1++;
		else if(s=="TLE")
		c2++;
		else
		c3++;
		
	}
	
cout<<"AC x "<<c0<<endl
    <<"WA x "<<c1<<endl
    <<"TLE x "<<c2<<endl
    <<"RE x "<<c3<<endl; 
	return 0;
}

Measured memory_bytes: 3564