akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
int main()
{
	string s;
	cin >> s;
	long long total = 0, len = (long long)s.length();	
	for(long long i = 0, j = 0; i < len; ++i)
	{
		if(s[i] == 'W')
		{
			total += j;
		}
		else
		{
			++j;
		}
	}
	cout << total << "\n";
}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<algorithm>
#include<numeric>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>

#define rep(i,n) for(int i=0;i<n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define rp(i,c) rep(i,(c).size())
#define fr(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf=1<<28;
const double INF=1e12,EPS=1e-9;

int n,m,s;
int dp[50][3001];

int main()
{
	while(scanf("%d%d%d",&n,&m,&s),n){
		rep(i,n*n+1)rep(j,s+1)dp[i][j]=0;
		dp[0][0]=1;
		m=min(m,s);
		
		rep(i,m){
			for(int j=n*n;j>0;j--)for(int k=s;k>n*n-j;k--){
				dp[j][k]=dp[j-1][k-(n*n-j+1)]+dp[j][k-(n*n-j+1)];
				if(dp[j][k]>100000)dp[j][k]-=100000;
			}
		}
		printf("%d\n",dp[n*n][s]);
	}
	return 0;
}

Measured memory_bytes: 1460
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize
    }
    let mut es = vec![vec![0; n]; n];
    dfs(0, n, 1, &mut es);
    for i in 0..n - 1 {
        print!("{}", es[i][i + 1]);
        for j in i + 2..n {
            print!(" {}", es[i][j]);
        }
        println!("");
    }
}

fn dfs(s: usize, n: usize, l: usize, es: &mut Vec<Vec<usize>>) {
    if n <= 1 {
        return;
    }
    let m = s + n / 2;
    for i in s..m {
        for j in m..s + n {
            es[i][j] = l;
        }
    }
    dfs(s, n / 2, l + 1, es);
    dfs(s + n / 2, (n + 1) / 2, l + 1, es);
}


Measured memory_bytes: 6652
#ifndef ONLINE_JUDGE
    #include "debug.cpp"
#endif

#include <bits/stdc++.h>

using namespace std;

#define int long long
#define ar array



void solve(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << max({a*c,a*d,b*c,b*d}) << "\n";
	/*if(b > 0 && d > 0) cout << (b*d) << "\n";
	else{
		if(b <= 0){
			cout << max((c*b),(c*a)) << "\n";
		}else{
			cout << max((a*d),(a*c)) << "\n";
		}
	}*/
}

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

    int TC = 1;
//    cin>>TC;
    while(TC--)
        solve();

    return 0;
}



Measured memory_bytes: 3652
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace AtCoder
{
	public class ABC
	{
		static public void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
			Solve(args);
			Console.Out.Flush();
		}

		private const int mod = 1000000007;  // 10^9+7

		static public void Solve(string[] args)
		{
			//string s = Console.ReadLine();
			int n = int.Parse(Console.ReadLine());
			//long x = long.Parse(Console.ReadLine());
			//int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] vs = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();

			int[] ans = new int[n];
			for (int i = 0; i < n - 1; i++) {
				ans[a[i] - 1]++;
			}
			for (int i = 0; i < n; i++) {
				Console.WriteLine(ans[i]);
			}
		}

	}
}


Measured memory_bytes: 43664
#include<iostream>
#include<string>

using namespace std;
int main(){
  int n,k,q,a,i,j;
  cin >> n >> k >> q;
  int *t = new int[n];
  for(i=0;i<n;i++) t[i] = k-q;
  for(i=0;i<q;i++){
    cin >> a;
    t[a-1]++;
  }
  for(i=0;i<n;i++){
    if(t[i]<=0){
      cout << "No" << endl;
    }else{
      cout << "Yes" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1024
def solve(string):
    a, b = map(int, string.split())
    if b == 0:
        return "0"
    bin_a = "{:040b}".format(a)
    bin_b = "{:040b}".format(b)
    aa = [-1 if _a == "0" else int(bin_a[i + 1:] or "0", 2) for i, _a in enumerate(bin_a)]
    bb = [-1 if _b == "0" else int(bin_b[i + 1:] or "0", 2) for i, _b in enumerate(bin_b)]
    index = 0
    while True:
        if bb[index] != -1:
            break
        index += 1
    ans = []
    while index < 40:
        if aa[index] == bb[index] == -1:
            ans.append("0")
        elif aa[index] == -1:
            ans.append(str((bb[index] + 1) % 2))
        elif bb[index] == -1:
            ans.append(str(aa[index] % 2))
        else:
            ans.append(str((bb[index] + 1 - aa[index]) % 2))
        index += 1
    ans[-1] = str((b - a) // 2 % 2) if a % 2 == b % 2 == 0 else str(((b - a) // 2 + 1) % 2)
    return str(int("".join(ans), 2))


if __name__ == '__main__':
    print(solve(input()))


Measured memory_bytes: 3188
# Me
def check(s):
    words = [
            'dream',
            'dreamer',
            'erase',
            'eraser',
            ]

    while len(s) != 0:
        flag = False
        for w in words:
            if s[-len(w):] == w:
                s = s[:-len(w)]
                flag = True
                break
        if not flag:
            return 'NO'
    return 'YES'


print(check(input()))


Measured memory_bytes: 134248
#include <stdio.h>


int main()
{
	int x, y, bk, amari;

	scanf("%d %d", &x, &y);

	if(x < y){
		bk = x;
		x = y;
		y = bk;
	}

	// 処理
	while( (amari = x % y) != 0){
		x = y;
		y = amari;
	}
	printf("%d\n", y);

	return 0;
}



Measured memory_bytes: 2108
import java.util.Scanner;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Map;
import java.util.HashMap;

public class Main
{
    int n, k;
    
    public static void main(String args[])
    {
	new Main().solve();
    }
    
    void solve()
    {
	in();

	out(k * (int)Math.pow(k - 1, n - 1));
    }

    void in()
    {
	Scanner sc = new Scanner(System.in);
	n = sc.nextInt();
	k = sc.nextInt();
    }

    void out()
    {
	
    }
    
    void out(int n)
    {
	System.out.println(n);
    }

    void out(char c)
    {
	System.out.print(c);
    }
    
    void out(String s)
    {
	System.out.println(s);
    }
}


Measured memory_bytes: 20948
def factorial(n, mod=10**9+7):
    a = 1
    for i in range(1,n+1):
        a = a * i % mod
    return a


def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


def comb(n, k, mod=10**9+7):
    if n < k or k < 0:
        result = 0
    else:
        a = factorial(n, mod=mod)
        b = factorial(k, mod=mod)
        c = factorial(n-k, mod=mod)
        result = (a * power(b, mod-2, mod=mod) * power(c, mod-2, mod=mod)) % mod
    return result

n, k = map(int, input().split())
MOD = 10**9 + 7

if k >= n:
  print(comb(2*n-1, n))
  quit()

def power(n, r, mod=10**9+7):
    if r == 0: return 1
    if r%2 == 0:
        return power(n*n % mod, r//2, mod) % mod
    if r%2 == 1:
        return n * power(n, r-1, mod) % mod


fl = [-1]*(k+1)
fl[0] = 1
def f(i):
  global fl
  if fl[i] > 0: return fl[i]
  else:
    if i <= n//2:
      res = f(i-1)*(n-i+1)*(n-i)
      t = power(i, MOD-2)
      res *= t
      res %= MOD
      res *= t
      res %= MOD
      fl[i] = res
      return res
    else:
      res = f(n-i) * (n-i)
      res *= power(i, MOD-2)
      res %= MOD
      fl[i] = res
      return res


if k <= n//2:
  fl = [-1]*(k+1)
  fl[0] = 1
  def f(i):
    global fl
    if fl[i] > 0: return fl[i]
    else:
      res = f(i-1)*(n-i+1)*(n-i)
      t = power(i, MOD-2)
      res *= t
      res %= MOD
      res *= t
      res %= MOD
      fl[i] = res
      return res

  ans = 0
  for i in range(k+1):
    ans += f(i)
    ans %= MOD
else:
  fl = [-1]*(n+1)
  fl[0] = comb(n, k) * comb(n-1, k) % MOD
  def f(i):
    global fl
    if fl[i-k] > 0: return fl[i-k]
    else:
      res = f(i-1)*(n-i+1)*(n-i)
      t = power(i, MOD-2)
      res *= t
      res %= MOD
      res *= t
      res %= MOD
      fl[i-k] = res
      return res
  
  ans = 0
  for i in range(k+1, n+1):
    ans += f(i)
    ans %= MOD
  ans = comb(2*n-1, n) - ans
  ans %= MOD


print(ans % MOD)

Measured memory_bytes: 6352
import java.util.Scanner;

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

        int w = sc.nextInt();
        int n = sc.nextInt();

        int[] num = new int[w];
        for (int i=0; i<w; ++i) {
            num[i] = i+1;
        }

        for (int i=0; i<n; ++i) {
            String[] s = sc.next().split(",", 0);
            int a = Integer.parseInt(s[0]) - 1;
            int b = Integer.parseInt(s[1]) - 1;

            num[a] = num[a] ^ num[b];
            num[b] = num[a] ^ num[b];
            num[a] = num[a] ^ num[b];
        }
        for (int i=0; i<w; ++i) {
            System.out.println(num[i]);
        }
        sc.close();
    }
}



Measured memory_bytes: 26020
import java.util.Scanner;
import java.util.Arrays;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int givenNumber = scanner.nextInt();
        int usage = scanner.nextInt();
        int[] array = new int[givenNumber];
        for(int i=0; i<givenNumber; i++) {
            array[i] = scanner.nextInt();
        }

        int output = 0;
        int loopCount = 0;
        Arrays.sort(array);
        while(loopCount < usage) {
            output += array[array.length-1-loopCount];
            loopCount++;
        }
        System.out.println(output);
    }
}


Measured memory_bytes: 23380
def num2bi(x, k):
  #10進数xを2進数k桁(string)で出力
  out=format(x, '0'+str(k)+'b')
  return out

def f(a, b, c):
  n=len(format(max([a, b, c]), '0b'))
  a=format(a, '0'+str(n)+'b')
  b=format(b, '0'+str(n)+'b')
  c=format(c, '0'+str(n)+'b')
  out=True
  for i in range(n):
    if (a[i]==b[i] and c[i]=='1') or (a[i]!=b[i] and c[i]=='0'):
      out=False
  return out

N=int(input())
a=list(map(int, input().split()))
a.sort()
if sum(a)==0:
  print('Yes')
  exit()
  
if N%3==0 and a[0]==a[N//3-1] and a[N//3]==a[2*N//3-1] and a[2*N//3]==a[-1]:
  if f(a[0], a[N//3], a[2*N//3])==True:
    print('Yes')
    exit()
    
print('No')


Measured memory_bytes: 14708
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int k,q; cin >> k >> q;
    vector<int> d(k);
    for(int i=0;i<k;i++){
        cin >> d[i];
    }
    while(q--){
        ll n,x,m; cin >> n >> x >> m;
        x%=m;
        ll all=0,sum=x;
        for(int i=0;i<k;i++){
            if(d[i]%m){
                ll cnt=(n-1)/k+((n-1)%k>i);
                all+=cnt;
                sum+=(d[i]%m)*cnt;
            }
        }
        cout << all-sum/m << endl;
    }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
using namespace std;
int main(void){
    int N,M,C;
    int count = 0;
    cin >> N >> M >> C;
    vector<int> Bi = vector<int>(M);
    vector<int> Ai = vector<int>(M);
    for (int i=0;i<M;i++){
        cin >> Bi[i];
    }
    for (int i=0;i<N;i++){
        for (int j=0;j<M;j++){
            cin >> Ai[j];
        }
        int d = 0;
        for (int j=0;j<M;j++){
            d += Ai[j]*Bi[j];
        }
        d += C;
        if (d>0){
            count++;
        }
    }
    cout << count << endl;   
}

Measured memory_bytes: 256
N = int(input())
hs = list(map(int, input().split()))

costs1 = 0
costs2 = abs(hs[1] - hs[0])
for i in range(2, N):
  costs1, costs2 = costs2, min(costs1 + abs(hs[i] - hs[i - 2]), costs2 + abs(hs[i] - hs[i - 1])),
  
print(costs2)


Measured memory_bytes: 52592
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(auto i=0; i<(n); i++)

int p[10];
int c[10];
int getCnt(int cnt, int cur, int rem, bool b) {
  int res = INF;
  if (rem <= 0) {
    return cnt;
  }
  if (cur < 0) {
    return INF;
  }
  res = min(res, getCnt(cnt, cur-1, rem, b));
  res = min(res, getCnt(cnt+p[cur], cur-1, rem - ((cur+1) * p[cur]) - (c[cur]/100), b));
  if (b) {
    rep(i, p[cur]) {
      res = min(res, getCnt(cnt+i, cur-1, rem - ((cur+1) * i), false));
    }
  }
  return res;
}

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

  int d, g;
  cin >> d >> g;
  g /= 100;

  rep(i, d) {
    cin >> p[i] >> c[i];
  }

  cout << getCnt(0, d-1, g, true) << endl;
}


Measured memory_bytes: 256
//When I wrote this, only God and I understood what I was doing
//Now, God only knows :-)
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define ch char
#define vc vector

bool is(string str) 
{ 
    // Start from leftmost and rightmost corners of str 
    int l = 0; 
    int h = str.size() - 1; 
  
    // Keep comparing characters while they are same 
    while (h > l) 
    { 
        if (str[l++] != str[h--]) 
        { 
            
            return false; 
        } 
    } 
   return true;
} 
  
int main() {
ios_base::sync_with_stdio(false);
    cin.tie(NULL);
   string s;
   cin>>s;
   ll N=s.size();
   string k=s.substr(0,(N-1)/2);
   string j=s.substr((N+3)/2-1,(N-(N+3)/2)+1);
   if(is(s)&&is(k)&&is(j))
   cout<<"Yes";
   else
   cout<<"No";

}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
	int N, i = 1;
	double d = 0, u;

	scanf("%d", &N);

	while (i <= N) {
		if (i % 2 == 1) {
			d++;
		}
		i++;
	}
	u = d / N;
	printf("%lf", u);
}

Measured memory_bytes: 128
program abc162dr
      implicit none
      integer::n
      character(len=4000)::s
      integer::i,j,k
      integer(8)::ans
      integer(8)::x(3)=0

         read *,n
         read *,s

         do i=1,n
            if (s(i:i)=='R') x(1)=x(1)+1
            if (s(i:i)=='G') x(2)=x(2)+1
            if (s(i:i)=='B') x(3)=x(3)+1
         end do

         ans=x(1)*x(2)*x(3)

         do i=1,n-2
            do j=i+1,(n-i)/2+i
               k=(j-i)+j
               if ((s(i:i)/=s(j:j)) .and. (s(i:i)/=s(k:k)) &
                                   .and. (s(j:j)/=s(k:k))) then
                  ans=ans-1
               end if
            end do
         end do

         print *,ans

   end program abc162dr

Measured memory_bytes: 2836
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,k;cin >> n >> k;
  vector<int> a(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  vector<bool> b(n);
  int cnt=1;
  bool e=false;
  for(int i=1;i<n;i++){
    if(a[i]>a[i-1]){
      cnt++;
      if(cnt>=k){
        b[i]=true;
        e=true;
      }
    }
    else{
      cnt=1;
    }
  }
  set<int> st;
  int ans=0;
  bool f=false;
  for(int i=0;i<n;i++){
    if(i&&i<k){
      if(a[i-1]>a[i]){
        f=true;
      }
    }
    if(i>=k){
      auto itr=st.begin();
      auto itr2=st.end();
      itr2--;
      int u=*itr,v=*itr2;
      if(!(u==a[i-k]&&v<a[i])&&!b[i]){
        ans++;
      }
      st.erase(a[i-k]);
    }
    st.insert(a[i]);
  }
  if(e){
    ans++;
  }
  if(f){
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 10368
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

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

void calcZ(char in[], int z[]){
	int l=-1,r=-1;
	for(int i=1;in[i];i++){
		int j=i;
		if(i<=r){
			if(z[i-l]<r-i+1){
				z[i]=z[i-l];
				continue;
			}
			j=r+1;
		}
		while(in[j]==in[j-i]){
			j++;
		}
		z[i]=j-i;
		if(z[i]){
			r=j-1;
			l=i;
		}
	}
}
const int L=5e5+1;
char in[L];
int z[2][L];
bool f[2][L];

int main() {
	scanf("%s",in);
	int s=strlen(in);
	calcZ(in,z[0]);
	reverse(in,in+s);
	calcZ(in,z[1]);
#if 0
	for(int i=0;i<s;i++){
		cerr << z[0][i] << " ";
	}
	cerr << endl;
#endif
	if(s==1){
		puts("1");
		puts("1");
		return 0;
	}
	if(z[0][1]==s-1){
		printf("%d\n%d\n",s,1);
		return 0;
	}
	for(int k=0;k<2;k++){
		for(int i=1;i<=s/2;i++){
			if(f[k][i])continue;
			for(int j=2*i;j<=i+z[k][i];j+=i){
				f[k][j]=true;
			}
		}
	}
	if(!f[0][s]){
		puts("1");
		puts("1");
		return 0;
	}
	puts("2");
	int ret=0;
	for(int i=1;i<s;i++){
		if(!f[0][i]&&!f[1][s-i]){
			//cerr << i << endl;
			ret++;
		}
	}
	printf("%d\n",ret);

	return 0;
}



Measured memory_bytes: 5632
/*Read the problem carefully before starting to work on it*/
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
//using namespace __gnu_pbds;

typedef long long ll;

#define pb push_back
#define eb emplace_back
#define mp(x,y) make_pair(x,y)
#define mod 1000000007

double PI = 3.1415926535897932384626;

//template<typename T> T power(T x,T y,ll m=mod){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}

//typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ost;

//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
//#define rnd(x, y) uniform_int_distribution<ll>(x, y)(rng)

//struct custom_hash {
//    static uint64_t splitmix64(uint64_t x) {
//        // http://xorshift.di.unimi.it/splitmix64.c
//        x += 0x9e3779b97f4a7c15;
//        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
//        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
//        return x ^ (x >> 31);
//    }
//    size_t operator()(uint64_t x) const {
//        static const uint64_t FIXED_RANDOM =
//            chrono::steady_clock::now().time_since_epoch().count();
//        return splitmix64(x + FIXED_RANDOM);
//    }
//};

#define fi first
#define se second

ll n;

bool check(vector<ll>&A, vector<ll>&B)
{
	for (ll i = 0; i < n; i++)
	{
		if (A[i] == B[i])
			return true;
	}
	return false;
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	vector<ll>A(n), B(n);
	map<ll, ll>mm;
	for (ll i = 0; i < n; i++)
	{
		cin >> A[i];
		mm[A[i]]++;
	}
	for (ll i = 0; i < n; i++)
	{
		cin >> B[i];
		mm[B[i]]++;
	}
	ll fl = 0;
	for (auto &x : mm)
	{
		if (x.se > n)
		{
			fl = 1;
			break;
		}
	}
	if (fl)
		cout << "No\n";
	else
	{
		cout << "Yes\n";
		// while (check(A, B))
		// {
		// 	random_shuffle(B.begin(), B.end());
		// }
		sort(B.rbegin(), B.rend());
		vector<ll>ans;
		for (ll i = 0; i < n; i++)
		{
			if (A[i] != B[i])
			{
				ans.eb(B[i]);
				continue;
			}
			ll ree = n - 1;
			while (ree > i && A[i] == B[ree])
				ree--;
			if (B[i] != B[ree])
			{
				swap(B[i], B[ree]);
				ans.eb(B[i]);
			}
			else
			{
				for (ll lul = 0; lul < i; lul++)
				{
					if ((A[lul] != B[i]) && (A[i] != ans[lul]))
					{
						ans.eb(B[i]);
						swap(ans[lul], ans[i]);
						break;
					}
				}
			}
		}
		for (auto &noo : ans)
		{
			cout << noo << " ";
		}
		cout << endl;
	}
	return 0;
}


//252908XL

/*
comments:-

*/


Measured memory_bytes: 20916
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
ll dp[55][55][65];
int a[55][55],n;
ll v;
ll ans[55][65];
int main(){
	cin>>n>>v;
	rep(i,n) rep(j,n){
		cin>>a[i][j];
		if(a[i][j] == 1) dp[i][j][0] = 1;
	}
	for(int x=0;x<60;x++){
		rep(i,n)rep(j,n)rep(k,n){
			dp[i][j][x+1] += dp[i][k][x]*dp[k][j][x]%mod;
			if(dp[i][j][x+1]>=mod 	)dp[i][j][x+1]%=mod ;
		}
	}
	rep(i,n)ans[i][0]=1;
	int cur = 0;
	rep(x,61){
		if(((v>>x)&1LL)){
			for(int i=0;i<n;i++) for(int j=0;j<n;j++){
				ans[j][cur+1] += ans[i][cur]*dp[i][j][x]%mod;
				ans[j][cur+1] %= mod;
			}
			cur++;
		}
	}
	ll ret = 0;
	rep(i,n){
		ret += ans[i][cur];
		ret %= mod;
	}
	cout<<(ret%mod+mod)%mod<<endl;
}


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

using namespace std;

int main()
{
    int S;
    cin>>S;
    int h=S/3600;
    int m=(S%3600)/60;
    int s=(S%3600)%60;
    cout<<h<<":"<<m<<":"<<s<<endl;
    return 0;
}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 2e5 + 5;
const ll LINF = 1e18 + 5;
int n, a[N], b[N];
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	for(int i=0; i<n; i++) cin >> a[i];
 	bool tag = 0;
 	b[0] = a[0];
 	for(int i=1; i<n; i++)
 	{
 		if(!tag) b[0] -= a[i];
 		else b[0] += a[i];
 		tag = !tag;
 	}
 	for(int i=0; i<n-1; i++)
 	{
 		b[i+1] = 2*a[i] - b[i];
 	}
 	for(int i=0; i<n; i++) cout << b[i] << " \n"[i==n-1];
	return 0;
}


Measured memory_bytes: 2176
<?php

$dict = array('I' => 1, 'V' => 5, 'X' => 10, 'L' => 50, 'C' => 100, 'D' => 500, 'M' => 1000);

while (true) {
    fscanf(STDIN, '%s', $s);
    if (feof(STDIN)) {
        break;
    }

    echo toInt(str_split($s)) . PHP_EOL;
}

function toInt($s) {
    global $dict;
    if (count($s) <= 1) {
        return count($s) ? $dict[$s[0]] : 0;
    }
    $maxIdx = 0;
    for ($i = 0; $i < count($s); $i++) {
        if ($dict[$s[$i]] > $dict[$s[$maxIdx]]) {
            $maxIdx = $i;
        }
    }
    return - toInt(array_slice($s, 0, $maxIdx)) + $dict[$s[$maxIdx]] + toInt(array_slice($s, $maxIdx + 1, count($s) - $maxIdx - 1));
}

Measured memory_bytes: 6740
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s1 second
const ll INF=(1LL<<60)-1;
int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
li pow(li a,li b,li mo)
{
    if(a==0)
    return 1;
    li u=pow(a,b/2,mo);
    u=(u%mod*u%mod)%mo;
    if(b%2==1)
    u=(u%mod*a%mod)%mod;
    return u;
}
ll power(ll a,ll b)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const char &i, char &j)
{
    
    return i > j;
    
}

void solve()
{
   string a,b;
   cin>>a>>b;
   li ans=0;
   li o=a.length();
   rep(i,o)
   {
       if(a[i]!=b[i])
       ans++;
   }
   cout<<ans;
    
    
    
}
int main()
{
    FAST_IO;
    li t;
    t=1;
    while(t--)
    solve(),cout<<endl;
    
}


Measured memory_bytes: 3840
#include <iostream>

using namespace std;

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

  long int sum = 0;
  long int score = 0;

  sum = (x / 11) * 2;
  if(x % 11 != 0) sum++;
  if(x % 11 > 6) sum++;


  cout << sum << endl;

  return 0;
}


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

int main() {

	int n, k; cin >> n >> k;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		int x; cin >> x;
		ans += 2 * min(x, k - x);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);i++)
#define erep(i,a,b) for(int i=a;i<=(int)(b);i++)
#define per(i,a,b) for(int i=(b)-1;i>(a);i--)
#define eper(i,a,b) for(int i=((int)(a));i>=b;i--)
#define pb push_back
#define mp make_pair
using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;
const ll MOD=1000000007;
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int n;
int main() {
 ios::sync_with_stdio ( false );
 cin.tie ( 0 );
    cin >> n;
    ll t = 1LL, a = 1LL, v = 0LL;
    rep (i, 0, n) {
        ll l, m;
        cin >> l >> m;
        v = max((ll)(t+l-1)/l, (ll)(a+m-1)/m);
        t = v * l;
        a = v * m;
    }
    printf("%lld\n", t + a);
    return 0;
}


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

int main () {
    string s, t;
    cin >> s >> t;

    int ans = t.size();
    bool x = true;
    for (int i = 0; i <= s.size()-t.size(); i++) {
        int count = 0;
        for (int j = 0; j < t.size(); j++) {
            if (s[i+j] != t[j]) {
                count ++;
            }
        }
        ans = min(ans,count);
    }
    cout << ans << endl;
}

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

int main()
{
    char A[3],B[3];
    cin >> A;
    cin >> B;
    int count=0;
    for(int i=0;i<3;i++)
    {
        if(A[i]==B[i])
        count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

	Scanner sca = new Scanner(System.in);
	int a = sca.nextInt();
	int b = sca.nextInt();
	int c = sca.nextInt();

	if(a == b && b != c) {
		System.out.println("Yes");
	}
	else if(a == c && b != c) {
		System.out.println("Yes");
	}
	else if(b == c && a != c) {
		System.out.println("Yes");
	}
	else {
		System.out.println("No");
	}

	// ArrayList<String> list = new ArrayList<String>();
	// list.add("");

	// 後始末
	sca.close();
	}
}

Measured memory_bytes: 21716
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1LL << 60;
ll n;
int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cin >> n;
  if(n & 1) {
    cout << 0;
    return 0;
  }
  n /= 2;
  ll ans = 0;
  while(n) {
    ans += n / 5;
    n /= 5;
  }
  cout << ans << endl;

  return 0;
}



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

int main() {
    int n;
    string s;
    cin >> n >>  s;

    for (int i = 0; i < s.length(); i++) {
        if (s.at(i) + n - 'Z' <= 0) {
            s.at(i) += n;
        } else {
            s.at(i) += n - 26;
        }
    }

    cout << s << endl;

    return 0;
}

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

int main() {
  int N;
  string S;
  cin >> N >> S;
  int rbra = 0; //)
  int lbra = 0;// (
  for(int i=0;i<N;i++){
    //0:(, 1:)
    if(S.at(i) - '('){ //)
      if(lbra){ //(が残っている
        lbra--; //(を減らす
      }else{ //(がない
        rbra++; //)を増やす
      }
    }else{ // (
      lbra++; // (を増やす
    }
  }
  string tmp = "";
  for(int i=0;i<rbra;i++){ //残りの)の数だけ(をくっつける
    tmp += "(";
  }
  S = tmp + S;
  
  lbra = 0;
  for(int i=0;i<S.size();i++){
    lbra += (S.at(i)-'(')*(-2) + 1;
  }
  tmp = "";
  for(int i=0;i<lbra;i++){ // (の数)をくっつける
    tmp += ")";
  }
  S = S + tmp;
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
s=input()
cnt=0
idx=0
while(1):
  if idx >=len(s):
    break
  if s[idx:idx+2] in ('01','10'):
    cnt+=1
    s=s[:idx]+s[idx+2:]
    idx = max(0,idx-1)
  else:
    idx+=1
print(cnt*2)

Measured memory_bytes: 3428
N = int(input())
S_non10 = []
S_10 = []
for i in range(N):
    Si = int(input())
    if Si % 10 == 0:
        S_10.append(Si)
    else:
        S_non10.append(Si)

if S_non10 == []:
    print(0)

else:
    sumS = sum(S_non10)
    if sumS % 10 == 0:
        sumS -= min(S_non10)

    if S_10 == []:
        sumS10 = 0
    else:
        sumS10 = sum(S_10)
    print(sumS + sumS10)


Measured memory_bytes: 2940
def solve():
  import sys
  import math
  import heapq

  sys.setrecursionlimit(10**7)
  readline=sys.stdin.readline

  n,m = map(int,input().split())
  a = [-int(i) for i in input().split()]
  heapq.heapify(a)
  
  t = heapq.heappop(a)
  for i in range(m-1):
    t = heapq.heappushpop(a,t/2)
  heapq.heappush(a,t/2)
  
  print(sum(int(-i) for i in a))

if __name__ == '__main__':
  solve()

Measured memory_bytes: 14380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N, M;
	cin >> N >> M;
	vector<int> IE[100001];
	int num = 1;
	int topo[100001], jisuu[100001] = {};
	rep(i, N + M - 1) {
		int a, b;
		cin >> a >> b;
		IE[b].pb(a);
		jisuu[a]++;
	}

	vector<int> V;
	rep1(i, N) {
		if(!jisuu[i]) V.pb(i);
	}
	while (V.size()) {
		int k = V.back();
		V.pop_back();
		topo[k] = num++;
		for (int u : IE[k]) {
			jisuu[u]--;
			if (!jisuu[u]) V.pb(u);
		}
	}

	rep1(i, N) {
		int kotae = 0;
		int saishou = 1e9;
		if (topo[i] == N) kotae = 0;
		else {
			for (int u : IE[i]) {
				if (saishou > topo[u]) {
					saishou = topo[u];
					kotae = u;
				}
			}
		}
		co(kotae);
	}

	Would you please return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define SP << " " 
#define LLi long long int

using namespace std;

int imax=2147483647;
long long int llimax=9223372036854775807;

//int型vectorを出力
void PV(vector<int> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

//LLi型vectorを出力
void PVL(vector<LLi> pvv) {
	rep(i, pvv.size()) cout << pvv[i] SP;
	cout << endl;
}

int main(){

	int x, y;
	cin>> x >> y;

	rep(i, x+1){
		if(i*2+(x-i)*4==y){
			cout<< "Yes" <<endl;
			return 0;
		}
	}
	
	cout<< "No" <<endl;
 
	return 0;
}

Measured memory_bytes: 3640
#include <stdio.h>

void selectionSort(int A[100],int N);

int main(){
  int A[100],N,i;

  scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&A[i]);
  }
  selectionSort(A,N);
  return 0;
}

void selectionSort(int A[100],int N){
  int minj,i,j,count=0,tmp;
  for(i=0;i<N;i++){
    minj = i;

    for(j=i+1;j<N;j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }
       if(minj != i){
	 tmp = A[i];
	 A[i] = A[minj];
	 A[minj] = tmp;
	  count++;
	}
    
  }

  for(i=0;i<N;i++){
    if(i==N-1){
      printf("%d\n",A[i]);
    }
    else{
      printf("%d ",A[i]);
    }
  }
  printf("%d\n",count);
}



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

// #include <boost/multiprecision/cpp_dec_float.hpp>
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision;
// using Bint = mp::cpp_int;
// using Real = mp::number<mp::cpp_dec_float<1024>>;

int main(){
    int N;
    cin >> N;
    vector<int> A(N+1), B(N+1), C(N+1);
    rep(i, N) cin >> A.at(i);
    rep(i, N) cin >> B.at(i);
    rep(i, N) cin >> C.at(i);
    sort(all(A));
    sort(all(B));
    sort(all(C));
    A.push_back(INF);
    B.push_back(INF);
    C.push_back(INF);

    ll ans = 0;
    for(int i = 1; i <= N; i++){
        ll an = 0, cn = 0;
        int b = B.at(i);

        int l = 0, r = N + 1;
        while( r - l > 1){
            int m = (l + r)/2;
            if(A.at(m) < b) l = m;
            else r = m;
        }
        an = l;

        l = 0, r = N + 1;
        while( r - l > 1){
            int m = (l + r)/2;
            if(C.at(m) > b) r = m;
            else l = m;
        }
        cn = N - r + 1;

        ans += an * cn;
    }

    cout << ans << endl;
}

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

using namespace std;
using Graph = vector<vector<int>>;
using Grid= vector<vector<char>>;
using vin= vector<int>;
using ll=long long;
using vll= vector<ll>;
using vbl=vector<bool>;
using vch=vector<char>;
using pinin=pair<int ,int>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rell(i,n) for (ll i=0; i< (ll)(n); i++)
#define sort(x) sort(x.begin(), x.end());
#define rese(x) reverse(x.begin(), x.end());

string yes="Yes",no="No";

int main() {
    int n;
    cin>>n;
    set<string> s;
    map<string ,int> u;
    rep(i,n){
        string t;
        cin>>t;
        if(s.count(t)){
            u[t]++;
        }
        else{
            u[t]=1;
            s.insert(t);
        }
    }
    int ahu=0;
    for(auto p: u){
        ahu=max(ahu,p.second);
    }
    set<string> ans;
    for(auto p:u){
        if(ahu==p.second){
            ans.insert(p.first);
        }
    }
    for(auto p:ans ){
        cout<<p<<endl;
    }
  
}


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

bool a[10];
bool b[10][10];
bool ans[10][10][10];

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    for(int i = 0; i < n - 2; i++){
        if(a[s[i] - '0']) continue;
        a[s[i] - '0'] = true;
        for(int j = i + 1; j < n - 1; j++){
            if(b[s[i] - '0'][s[j] - '0']) continue;
            b[s[i] - '0'][s[j] - '0'] = true;
            for(int k = j + 1; k < n; k++) ans[s[i] - '0'][s[j] - '0'][s[k] - '0'] = true;
        }
    }
    int r = 0;
    for(int i = 0; i < 10; i++) for(int j = 0; j < 10; j++) for(int k = 0; k < 10; k++)
        if(ans[i][j][k]){
            r++;
        }
    cout << r << endl;
}

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

int main()
{
    int numa , numb, numc, numd;
    cin >> numa >> numb;
    if(numa >=13){
        cout << numb;
    }else if(numa>=6){
        cout << numb/2;
    }else{
        cout << "0";
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
readline = sys.stdin.readline
N = int(readline())
t = []
x = []
y = []
for i in range(N):
    _t, _x, _y = list(map(int, readline().split()))
    t.append(_t)
    x.append(_x)
    y.append(_y)

p = [0, 0]
pt = 0
px = 0
py = 0
f = True
for i in range(N):
    a = t[i] - pt
    b = abs(px - x[i]) + abs(py - y[i])
    # 距離が足りないかt~t+1間の座標の差のと偶奇が一致しない場合はたどり着けない
    if a < b or (a % 2 != b % 2):
        f = False
        break
    px = x[i]
    py = y[i]
    pt = t[i]

if f == True:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 11840
r = input().split(" ")
n = int(r[0])
d = int(r[1])
t = 0
import math
for i in range(n):
  inp = input().split(" ")
  x = int(inp[0])
  y = int(inp[1])
  distance = math.sqrt( ((0-x)**2)+((0-y)**2) )
  if distance <= d:
    t += 1
    
print(t)

Measured memory_bytes: 9128
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 2e5 + 10;

int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
	return 0;
}


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

//.define
// #define FILE_IN_OUT
#define RET(_x)    return cout << (_x) << '\n', 0;
#define all(_obj)  (_obj).begin(), (_obj).end()
#define loop(_n)   for (int i = 0; i < (_n); ++i)
#define sz(_obj)   static_cast<int>((_obj).size())
#ifdef SHJ_LOCAL
#define debug(_x)  std::cerr << (#_x) << " = " << (_x) << '\n' << std::flush;
#else
#define debug(_x)  {}
#endif
#define endl "\n"
template<typename P, typename Q>
P CeilDiv(P _dividend, Q _divider) {
    return static_cast<P>((_dividend - 1LL + _divider) / _divider);
}
template<typename Tp>
inline void outarr(Tp _begin, Tp _end, const char* _delim = " ") {
    for (Tp current = _begin; current != _end; ++current) {
        std::cout << *current << _delim;
    }
    std::cout << '\n';
}

//.constant
using ll  = long long;
using pii = std::pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr int MOD = static_cast<const int>(1e9 + 7);

//.data
constexpr int MAXN = 100000;

vector<int> gr[MAXN];
bool used[MAXN];

void Dfs(int from) {
    used[from] = true;
    for (int to : gr[from]) {
        if (!used[to]) {
            Dfs(to);
        }
    }
}

//.code
int main() {
#ifdef FILE_IN_OUT
    std::ifstream cin ("input.txt",  std::ios::in);
    std::ofstream cout("output.txt", std::ios::out);
#else
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
#endif

    int n, m;
    cin >> n >> m;
    loop(m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        gr[a].push_back(b);
        gr[b].push_back(a);
    }
    int ans = -1;
    for (int i = 0; i < n; ++i) {
        if (!used[i]) {
            Dfs(i);
            ++ans;
        }
    }
    cout << ans << endl;

#ifdef FILE_IN_OUT
    cin.close();
    cout.close();
#endif
    return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

LL n, a[100000];
LL ans[100000];
bool flag[100001];
typedef pair<LL, LL> PLL;
PLL v[100001];

int main() {
	cin >> n;
	inc(i, n) { cin >> a[i]; }
	
	LL ma = 0;
	inc(i, n) { flag[i] = setmax(ma, a[i]); }
	
	inc(i, n) { v[i] = MP(a[i], -i); }
	sort(v, v + n, greater<PLL>());
	inc(i, n) { v[i].SE *= -1; }
	
	flag[n] = true;
	v[n] = MP(0, n);
	
	LL p = 0, sum = 0;
	inc(i, n + 1) {
		if(flag[ v[i].SE ]) {
			ans[ v[p].SE ] = sum - v[i].FI * (i - p) + p * (v[p].FI - v[i].FI);
			p = i;
			sum = 0;
		}
		sum += v[i].FI;
	}
	
	inc(i, n) {
		cout << ans[i] << "\n";
	}
	
	return 0;
}


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

int main() {
    string s; cin >> s;
    if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
        cout << "Yes";
    }else cout << "No";

    return 0;
}

Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main() {
	string s, t;
	cin >> s >> t;
	vector<char>a, b;
	bool ok = true, equal = true;
	for (int i = 0; i < s.length(); i++) {
		a.emplace_back(s[i]);
	}
	for (int i = 0; i < t.length(); i++) {
		b.emplace_back(t[i]);
	}
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	reverse(b.begin(), b.end());
	for (int i = 0; i < min(a.size(), b.size()); i++) {
		if (equal && a[i] > b[i])ok = false;
		if (a[i] != b[i])equal = false;
	}
	if (equal && a.size() < b.size()) {
		cout << "Yes" << endl;
	} else if (equal && a.size() == b.size()) {
		cout << "No" << endl;
	} else if (equal && a.size() > b.size()) {
		cout << "No" << endl;
	} else {
		if (ok)cout << "Yes" << endl;
		else cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/*
void solve1() {
    vector<vector<pll>> dp(2, vector<pll>(N+1));
    dp[1][0] = pll(1000, 0);
    dp[0][0] = pll(1000, 0);
    for (int i = 0; i < N; i++) {
        ll t = dp[1][i].first / a[i];
        ll dm = dp[1][i].first - t * a[i];
        dp[0][i+1] = pll(dm, t);
        dp[1][i+1] = dp[1][i];
        for (int j = 0; j <= i; j++) {
            ll m = dp[0][j].second * a[j] + dp[0][j].first;
            dp[1][i+1] = max(dp[1][i+1], pll(m, 0));
        }
    }
    cout << dp[1][N].first << '\n';
}
*/
/* main */
int main(){
    int N;
    cin >> N;
    vector<ll> a(N);
    for (int i = 0; i < N; i++) cin >> a[i];
    ll M = 1000;
    for (int i = 0; i < N - 1; i++) {
        if (a[i] < a[i+1]) {
            ll k = M / a[i];
            M %= a[i];
            M += k * a[i+1];
        }
    }
    cout << M << '\n';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  cout << ((n + x - 1) / x) * t << endl;
  return 0;
}

Measured memory_bytes: 3644
// use proconio::marker::Chars;
use proconio::{fastout, input};
// use std::cmp::{max, min};

#[fastout]
fn main() {
    input! {
        n: usize
    };

    let n: usize = n;
    let mut v = vec![0; n.to_string().len()];

    let count = dfs(n, &mut v, 0);

    println!("{}", count);
}

fn dfs(base: usize, v: &mut Vec<usize>, i: usize) -> usize {
    let mut count = 0;

    if base.to_string().len() == i {
        let mut sum = 0;
        for (i, vi) in v.iter().rev().enumerate() {
            sum += vi * 10i32.pow(i as u32) as usize;
        }

        if sum <= base && v.contains(&5) && v.contains(&3) && v.contains(&7) {
            count += 1;
        }
    } else {
        let x = vec![0, 3, 5, 7];

        for &xi in x.iter() {
            if xi == 0 && (v.contains(&5) || v.contains(&3) || v.contains(&7)) {
                continue;
            }

            v[i] = xi;
            count += dfs(base, v, i + 1)
        }
    }
    count
}


Measured memory_bytes: 2148
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {
	int n;
	cin >> n;
	int x[n], y[n];
	for (int i = 0; i < n; i++) {
		cin >> x[i] >> y[i];
	}
	double ans = 0;
	for (int i = 0; i < n+1; i++) {
		for (int j = i+1; j < n; j++) {
			ans += sqrt(pow(x[i]-x[j],2) + pow(y[i]-y[j],2));
		}
	}
	ans *= 2;
	ans /= n;
	cout << setprecision(6) << scientific << ans << endl;
	return  0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define f first
#define s second
#define MOD 1000000007
#define PMOD 998244353
#define pb(x) push_back(x)
using namespace std;

typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> plii;
typedef pair<int, pii> piii;
const int INF = 1e9+10;
const ll LINF = 1LL*INF*INF;
const int MAXN = 2e5+10;
const int MAXM = 5e3+10;

priority_queue<int> pq;
vector<vector<int> > graph;
queue<int> que;

int A[MAXN];
char S[MAXN];

int main()
{
    ll n,m,k,a,b,x,y,q;
    int sum = 0;
    int cnt = 0;
    int mx = 0;
    int mn = INF;
    int cur = 0, idx = -1;
    int tc;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>n;

    a = 100;

    idx = -1;

    for(int i=0;;i++){

       a = a+(a/100);
       if(a>=n){
         idx = i;
         break;
       }
    }

    cout<<(idx+1)<<"\n";

    return 0;
}


Measured memory_bytes: 3660