akhauriyash/Code-Regression huggingface dataset:
//   _/                _/                 _/_/_/   _/
//_/_/_/_/   _/_/   _/_/_/_/   _/_/    _/       _/_/
// _/     _/    _/   _/     _/    _/  _/_/_/     _/
//_/     _/    _/   _/     _/    _/  _/    _/   _/
// _/_/   _/_/       _/_/   _/_/      _/_/     _/
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<queue>
#include<vector>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const double pi=3.14159265358979323846;
const int inf=1e9;
const ll INF=5e18;
typedef pair<int,int> P;
int main() {
  cin.tie(0),cout.tie(0);
  ios::sync_with_stdio(false);
  int h,w;
  cin >> h >> w;
  char c[55][55]={};
  for(int i=1; i<=h; i++) {
    for(int j=1; j<=w; j++) {
      cin >> c[i][j];
    }
  }
  for(int i=1; i<=h; i++) {
    for(int j=1; j<=w; j++) {
      if(c[i][j]=='#'&&c[i-1][j]=='.'&&c[i][j-1]=='.'&&c[i+1][j]=='.'&&c[i][j+1]=='.') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

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

int main(){
  ll N;
  cin >> N;
  vector<ll> P(N);
  vector<ll> Q(N);
  for(ll i=0;i<N;i++){
    ll p;
    cin >> p;
    P[i]=p;
  }
  for(ll i=0;i<N;i++){
    ll q;
    cin >> q;
    Q[i]=q;
  }
  vector<ll> Num(N);
  iota(Num.begin(),Num.end(),1);
  ll tot=1;
  for(ll i=1;i<=N;i++){
    tot*=i;
  }
  ll a=0;
  ll b=0;
  for(ll i=0;i<tot;i++){
    if(P==Num){
      a=i;
    }
    if(Q==Num){
      b=i;
    }
    next_permutation(Num.begin(),Num.end());
  }
  cout << abs(a-b) << endl;
}



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

#define dump(x)  cout << #x << " = " << (x) << endl;

typedef long long ll;
typedef pair<int, int> ii;
const int mod = 1e9+7;
const ll INF = 1e18;
const int inf = 1e9;

void solve()
{
  ll n; cin>>n;
  ll dp[n+1][4][4][4];
  memset(dp,0,sizeof(dp));
  dp[0][3][3][3]=1;

  for (int i=0; i<n; i++) {
    for(int j=0; j<4; j++)for(int k=0; k<4; k++)for(int l=0; l<4; l++)for(int m=0; m<4; m++) {
      if(k==0&&l==1&&m==2) continue;
      if(k==0&&l==2&&m==1) continue;
      if(k==1&&l==0&&m==2) continue;
      if(j==0&&l==1&&m==2) continue;
      if(j==0&&k==1&&m==2) continue;
      dp[i+1][k][l][m] += dp[i][j][k][l];
      dp[i+1][k][l][m] %= mod;
    }
  }

  ll ans=0;
  for(int j=0; j<4; j++)for(int k=0; k<4; k++)for(int l=0; l<4; l++) {
    ans += dp[n][j][k][l];
    ans %= mod;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define tcn cin.tie(0);
#define tct cout.tie(0);
#define pb push_back
#define ll long long
#define fr first
#define se second
#define TIME ios_base::sync_with_stdio(0);
using namespace std;

const long long N = 2e3 + 7;
const ll mod = 1e6 + 7;
ll n , m , a , b , c ,d ;
long double p = 3.141592653589793;
string s;
char ch;
vector<int>v ,v1;
int main()
{
    TIME tcn tct
    cin >> n;
    cout << n * (2 * p);
}


Measured memory_bytes: 3804
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


# aとbの最大公約数
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


# aとbの最小公倍数
def lcm(a, b):
    g = gcd(a, b)
    return a / g * b


def main():
    A, B, K = map(int, input().split())
    v = []
    for i in range(1, 1000):
        if A % i == 0 and B % i == 0:
            v.append(i)
    v = v[::-1]
    print(v[K - 1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 3956
#include <iostream>
#include <algorithm>
#include <vector>
#include <functional>
#include <string>
#include <map>
using namespace std;

int main(void){
	unsigned long long n;
	cin>>n;
	string s;
	map<string,unsigned long long> m;
	unsigned long long ans=0;
	for(int i=0;i<n;i++){
		cin>>s;
		sort(s.begin(),s.end());
		m[s]++;
		ans+=m[s]-1;
	}
	cout<<ans<<endl;

	return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#define MAXN 300010
int n, a[MAXN], b[MAXN], c[MAXN];
int main() {
	std::ios::sync_with_stdio(0);
	std::cin.tie(0);
	std::cout.tie(0);
	std::cin >> n;
	for (int i = 1; i <= n; i++) std::cin >> a[i], c[a[i]] = i;
	for (int i = 1; i <= n; i++) b[i] = a[i] == i ? 1 : 2;
	for (int l = 1, r = 1; r <= n;) {
		for (int i = l; i <= r; i++) r = std::max(r, c[i]);
		for (int i = l, x = 0, y = 0; i <= r; i += 2) {
			if (i + 1 <= r && a[i + 1] != i + 1) {
				std::cout << "No" << std::endl;
				return 0;
			}
			if (a[i] > i) {
				if (a[i] > x) {
					x = a[i];
				} else {
					std::cout << "No" << std::endl;
					return 0;
				}
			} else {
				if (a[i] > y) {
					y = a[i];
				} else {
					std::cout << "No" << std::endl;
					return 0;
				}
			}
		}
		l = ++r;
	}
	std::cout << "Yes" << std::endl;
	return 0;
}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }

using namespace std;

int main(int argc, char** argv) 
{
#ifdef HOME
	if(IsDebuggerPresent())
	{
		freopen("../in.txt", "rb", stdin);
		freopen("../out.txt", "wb", stdout);
	}
#endif
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.precision(10);
	cout << fixed;
	int N;
	cin >> N;
	vector<vector<int>> edges(N);
	forn(i, N - 1)
	{
		int u, v;
		cin >> u >> v;
		--u, --v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}

	vector<bool> used(N);
	constexpr uint64_t mod = 1e9 + 7;
	function<pair<uint64_t, uint64_t>(int)> dfs = [&edges, &used, &dfs, &mod](int v) -> pair<uint64_t, uint64_t> {
		used[v] = true;
		pair<uint32_t, uint32_t> res(1, 1);
		bool leaf = true;
		auto& actE = edges[v];
		for (auto u : actE)
		{
			if (!used[u])
			{
				leaf = false;
				auto ur = dfs(u);
				res.first = (res.first * (ur.first + ur.second)) % mod;
				res.second = (res.second * ur.first) % mod;
			}
		}
		//w,b
		return res;
	};

	auto r0 = dfs(0);

	cout << (r0.first + r0.second) % mod << endl;

	return 0;
}


Measured memory_bytes: 11264
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
#define rep(i, N) for(i = 0; i < N; i++)
#define ll long long

int main() {
  int H1, M1, H2, M2, K;
  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int ans = (H2 * 60 + M2) - K - 1 * (H1 * 60 + M1);
  cout << ans;

  return 0;
}

Measured memory_bytes: 3632
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	cin >> n;
	int ans = 0;

	for (int i = 1; i < min(n + 1, 10);i++) ans++;
	for (int i = 100; i < min(n + 1, 1000); i++) ans++;
	for (int i = 10000; i < min(n + 1, 100000); i++) ans++;


	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc106/tasks/abc106_d

MAX_N = 505
n, m, q = map(int, input().split())
P = [[0] * MAX_N for _ in range(MAX_N)]

# 二次元累積和
for _ in range(m):
    li, ri = map(int, input().split())
    P[li][ri] += 1
for i in range(1, MAX_N):
    for j in range(1, MAX_N):
        P[i][j] += P[i][j - 1]
for i in range(1, MAX_N):
    for j in range(1, MAX_N):
        P[i][j] += P[i - 1][j]

# queryに答える
for _ in range(q):
    l, r = map(int, input().split())
    ans = P[r][r] + P[l - 1][l - 1] - P[l - 1][r] - P[r][l - 1]
    print(ans)

Measured memory_bytes: 78524
n, k = map(int, input().split())
p = list(map(int, input().split()))

if n == k:
    print(1)
    exit()

def slide_min(n, k, p):
    res = [0] * n
    deq = [0] * n
    s = 0
    t = 0
    for i in range(n):
        while s < t:
            if p[deq[t-1]] >= p[i]:
                t -= 1
            else:
                break
        deq[t] = i
        t += 1
        if i-k+1 >= 0:
            res[i-k+1] = p[deq[s]]
            if deq[s] == i-k+1:
                s += 1
    return res

def slide_max(n, k, p):
    res = [0] * n
    deq = [0] * n
    s = 0
    t = 0
    for i in range(n):
        while s < t:
            if p[deq[t-1]] < p[i]:
                t -= 1
            else:
                break
        deq[t] = i
        t += 1
        if i-k+1 >= 0:
            res[i-k+1] = p[deq[s]]
            if deq[s] == i-k+1:
                s += 1
    return res

s_min = slide_min(n, k, p)
s_max = slide_max(n, k, p)

ans = 1
for i in range(n-k):
    if p[i] > s_min[i] or p[i+k] != s_max[i+1]:
        ans += 1

mode = 0
count = 0
e = 0
for i in range(n-1):
    if p[i] < p[i+1]:
        if mode == 0:
            count = 2
            mode = 1
        else:
            count += 1
    else:
        mode = 0
        if count >= k:
            e += 1
            count = 0

if mode == 1 and count >= k:
    e += 1

if e > 1:
    ans -= e-1

print(ans)


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

int main() {
	int s;
  	cin>>s;
  
  map<int,bool>mp;//mpに、sの値とイエローカードを残す
  
  	int cnt=0;//こっちを1にしてもいいんだな
  
  while(0==0){//whileってこんな使い方あるんだな
    if(mp[s]==true){//イエローもらっててもう一回同じ値になったら終わり
    	break;
    }
    mp[s]=true;//sの値を格納してイエロー
    if(s%2==0){//sを直接動かす
    	s/=2;
    }
    else{
    	s=(3*s)+1;
    }
    cnt++;//回数を数える
   }
  cout << cnt+1 << endl;
}

Measured memory_bytes: 3532
# include<bits/stdc++.h>
using namespace std;
int main(){
	int n, flag = 0;
  cin >> n;
  for (int i = 1; i < 10; i++){

  	if(n % i == 0 && n/i < 10){
		flag = 1;
      	break;
    }
  }
  if(flag)
    cout << "Yes" << '\n';
  else 
    cout << "No" << '\n';
  
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef _WIN32
#include "debug.hpp"
#endif
using namespace std;

#define rep(i, N)  for(int i = 0; i < (N); i++)
#define reps(i, N) for(int i = 1; i <= (N); i++)
#define repr(i, N) for(int i = (N) - 1; i >= 0; i--)
#define pub push_back

template<typename T> 
void chmax(T &a, T b){ a = max(a, b); };
template<typename T> 
void chmin(T &a, T b){ a = min(a, b); };

typedef long long ll;
typedef pair<int, int> P;
const int INF = 100000000;
const ll LINF = 10000000000000000;
const int MOD = 1000000007;
const int dx[9] = { 0, 1,  0, -1, 1,  1, -1, -1, 0};
const int dy[9] = { 1, 0, -1,  0, 1, -1, -1,  1, 0};
//--------------------------------------//
int N;
int x[100], y[100], h[100];

void solve(){
	rep(X, 101){
		rep(Y, 101){
			int H;
			rep(i, N){
				if(h[i] != 0){
					H = abs(X - x[i]) + abs(Y - y[i]) + h[i];
					break;
				}
			}
			bool b = true;
			rep(i, N){
				int D = abs(X - x[i]) + abs(Y - y[i]);
				if(max(H - D, 0) != h[i]){
					b = false;
					break;
				}
			}
			if(b){
				cout << X << " " << Y << " " << H << endl;
				return;
			}
		}
	}
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> N;
	rep(i, N) {
		cin >> x[i] >> y[i] >> h[i];
	}
		solve();
	return 0;
}


Measured memory_bytes: 256
object Main extends App {
  val in = new java.util.Scanner(System.in)
  val N = in.next.map(_ - '0').toList

  implicit class ComparableIntList(val l: List[Int]) extends AnyVal {
    def <=(o: List[Int]): Boolean = {
      if (l.size < o.size) true
      else if (l.size > o.size) false
      else l.zip(o).find(t => t._1 != t._2).fold(true)(t => t._1 <= t._2)
    }
  }

  def valid(l: List[Int]): Boolean = List(3, 5, 7).forall(n => l.contains(n))

  def dfs(l: List[Int], fixed: Boolean): Int = {
    Array(3, 5, 7).map{i =>
      val next = i :: l
      if (next <= N) {
        if (fixed || valid(next)) 1 + dfs(next, fixed)
        else dfs(next, false)
      } else 0
    }.sum
  }

  println(dfs(Nil, false))
}

Measured memory_bytes: 45468
#include<bits/stdc++.h>
using namespace std;
string a;
long long ans=0;
int main()
{
	cin>>a;
	for(int i=0;i<a.size();i++)
	{
		if(a[i]=='W'&&a[i+1]=='B')
		ans++;
		if(a[i]=='B'&&a[i+1]=='W')
		ans++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int con=8;
int N;
long long kouyaku(long long a,long long b){
  long long w;
  if(a<b){
    w=b;
    b=a;
    a=w;
  }
  while(1){
    w=a%b;
    a=b;
    b=w;
    if(w==0){  
      return a;
    }
  }
}
int main(void)
{
  long long CountTime;
  long long Time;
  long long w;
  cin>>N;
  cin >> CountTime;
  for(int i=0;i<N-1;i++){
    cin >> Time;
    if(CountTime%Time==0||Time%CountTime==0){
      if(CountTime<Time)CountTime=Time;
    }else{
       CountTime=CountTime*(Time/kouyaku(CountTime,Time));
    }
  }
  cout <<CountTime<< endl;
  return 0;
}

Measured memory_bytes: 256
(stdin => {
  // Define Function
  const smallOrLargeOrEqual = (a, b) => {
    const lessThen = (a, b) => a < b
    const greaterThen = (a, b) => a > b
     
    if (lessThen(a, b)) return 'a < b'
    if (greaterThen(a, b)) return 'a > b'
 
    return 'a == b'
  }
  // Declare Variable
  const inputs = stdin.toString().trim().split('\n')
  const [a, b] = Array.from(inputs[0].split(' '), Number)
 
  console.log(smallOrLargeOrEqual(a, b))
})(require('fs').readFileSync('/dev/stdin', 'utf8'))



Measured memory_bytes: 15128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int s,s1,s2,s3;
  
  cin >> s;
  s1 = s / 100;
  s2 = (s - s1 * 100) / 10;
  s3 = s - s1 * 100 - s2 * 10;
  cout << s1 + s2 + s3 << endl;  
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

class Data
{
public:
    int w, s;
    long long v;
    bool operator< (const Data& d) const{
        return d.s - w < s - d.w;
    }
};

const long long INF = LLONG_MAX / 2;

int main()
{
    int n;
    cin >> n;
    vector<Data> d(n);
    for(int i=0; i<n; ++i)
        cin >> d[i].w >> d[i].s >> d[i].v;
    sort(d.begin(), d.end());

    vector<long long> dp(10001, -INF);
    for(int i=0; i<n; ++i){
        for(int a=1; a<=10000; ++a){
            int b = min(d[i].s, a - d[i].w);
            if(b >= 0)
                dp[b] = max(dp[b], dp[a] + d[i].v);
        }
        dp[d[i].s] = max(dp[d[i].s], d[i].v);
    }

    long long ans = *max_element(dp.begin(), dp.end());
    cout << ans << endl;

    return 0;
}


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

def primelist(N):
    prime = [2]
    for i in range(3, N+1):
        flag = 1
        for j in prime:
            if i % j == 0:
                flag = 0
                break
        if flag == 1:
            prime.append(i)
    return prime

import bisect
a = primelist(110000)

print(a[bisect.bisect_left(a, n)])


Measured memory_bytes: 41104
#include<bits/stdc++.h>
#define Fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Freed freopen ("0in.txt","r",stdin);
#define Fout freopen ("0out.txt","w",stdout);
#define ll long long int
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define Mod 1000000007
#define limit 1000008
using namespace std;

void solve(int t)
{
    ll i,j,n,m,a,ans=0,temp=-1;
    cin >> n;
    for(i=0; i<n; i++)
    {
        cin>> a;
        if(i!=0)
            ans += max((ll)0,temp-a);
        temp = max(temp,a);
    }
    cout <<ans<<endl;
}
int  main()
{
//    Fast
//    Freed
//    Fout
    int t,tt=1;
  //  cin >> tt;
    for(t=1; t<=tt; t++)
        solve(t);
  return 0;
}




Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> c(n);
    vector<vector<int>> v(n, vector<int>(m));
    for (int i = 0; i < n; i++)
    {
        cin >> c[i];
        for (int j = 0; j < m; j++)
            cin >> v[i][j];
    }
    int all = 1 << n, mn = INT_MAX;
    for (int mask = 0; mask < all; mask++)
    {
        vector<int> nw(m);
        int sum = 0;
        for (int i = 0; i < n; i++)
        {
            if ((mask >> i) & 1)
            {
                sum += c[i];
                for (int j = 0; j < m; j++)
                {
                    nw[j] += v[i][j];
                }
            }
        }
        bool ans = true;
        for (int i = 0; i < m; i++)
        {
            if (nw[i] < k)
            {
                ans = false;
                break;
            }
        }
        if (ans)
        {
            mn = min(mn, sum);
        }
    }
    if (mn == INT_MAX)
    {
        cout << -1 << endl;
    }
    else
    {
        cout << mn << endl;
    }
}

Measured memory_bytes: 3648
h, w, k = map(int, input().split())
c = [list(input()) for i in range(h)]
ans = 0
for hh in range(2**h):
    for ww in range(2**w):
        cnt = 0
        for i in range(h):
            for j in range(w):
                if (hh >> i) & 1 and (ww >> j) & 1:
                    if c[i][j] == '#':
                        cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9132
#0:中央 1:南 2:東 3:西 4:北 5:裏側
class Dice():

    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]


    def setNumber(self,n0,n1,n2,n3,n4,n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5


    def roll(self,loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3],self.work[1],self.work[0],self.work[5],self.work[4],self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1],self.work[5],self.work[2],self.work[3],self.work[0],self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4],self.work[0],self.work[2],self.work[3],self.work[5],self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2],self.work[1],self.work[5],self.work[0],self.work[4],self.work[3])


    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int,input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d"%(dice.get_Top()))


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

int N;

int kaijo(int n){
  int r=1;
  for(int i=1;i<=n;i++){
    r*=i;
  }
  return r;
}

bool same(vector<long> x,vector<long> y){
  bool flg=true;
  for(int i=0;i<N;i++){
    if(x[i]!=y[i]) flg=false;
  }
  return flg;
}
int main() {


cin>>N;
vector<long> p(N);
vector<long> q(N);

for(int i=0;i<N;i++) cin>>p[i];
for(int i=0;i<N;i++) cin>>q[i];

vector<long> a(N);
for(int i=0;i<N;i++) a[i]=i+1;
long P,Q;
for(int i=0;i<kaijo(N);i++){
  if(same(a,p)) P=i;
  if(same(a,q)) Q=i;
  next_permutation(a.begin(),a.end());
}
cout<<abs(P-Q)<<endl;
}


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

struct BipartiteGraph {
	struct Edge {
		const int from;
		const int to;
		Edge(const int from, const int to) :
			from(from),
			to(to)
			{}
	};
	const int V;
	vector<vector<Edge>> G;
	vector<int> color;
	BipartiteGraph(const int V) :
		V(V),
		G(vector<vector<Edge>>(V, vector<Edge>())),
		color(vector<int>(V, -1))
		{}
	void addEdge(const int from, const int to) {
		G[from].emplace_back(from, to);
		G[to].emplace_back(to, from);
	}
	bool dfs(const int from, const int col) {
		color[from] = col;
		bool ret = true;
		for(Edge e : G[from]) {
			if(color[e.to] == -1) {
				ret &= dfs(e.to, col ^ 1);
			}
			if(color[e.to] == col) {
				return false;
			}
		}
		return ret;
	}
	int bipart() {
		if(not dfs(0, 0)) throw "NOT Bipartite Graph";
		int ret = 0;
		for(int i : color) ret += i;
		return ret;
	}
};


int main() {
	int64_t n, m; cin >> n >> m;
	BipartiteGraph bg(n);
	for(int i = 0; i < m; ++i) {
		int a, b; cin >> a >> b;
		--a, --b;
		bg.addEdge(a, b);
	}
	try {
		int64_t b = bg.bipart();
		int64_t w = n - b;
		cout << b * w - m << '\n';
	}
	catch(...) {
		cout << n * (n - 1) / 2 - m << '\n';
	}
	return 0;
}

Measured memory_bytes: 7040
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#include <list>

using namespace std;

typedef long long ll;

#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep1(i,n) for(int i=1; i<=(int)(n); i++)
#define all(c) c.begin(),c.end()
#define psb push_back
#define ppb pop_back

const int INF = 1001001001;

int main() {
    ll A;
    string B;

    cin >> A >> B;

    ll ans = A * ((B[0]-'0')*100 + (B[2]-'0')*10 + (B[3]-'0')) / 100;

    cout << ans << endl;
}


Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys

def solve(N: int, u: "List[int]", v: "List[int]", w: "List[int]"):

    G=[dict() for i in range(N)]
    for i in range(N-1):
        ui,vi,wi=u[i],v[i],w[i]
        G[ui-1][vi-1]=wi
        G[vi-1][ui-1]=wi

    dist = [-1]*N
    p = [0]
    dist[0] = 0

    while (len(p)>0):
        k = p.pop()
        for n in G[k]:
            if dist[n]==-1:
                dist[n] = dist[k] + G[k][n]
                p.append(n)
    
    for x in dist:
        print(x%2)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    u = [int()] * (N - 1)  # type: "List[int]"
    v = [int()] * (N - 1)  # type: "List[int]"
    w = [int()] * (N - 1)  # type: "List[int]"
    for i in range(N - 1):
        u[i] = int(next(tokens))
        v[i] = int(next(tokens))
        w[i] = int(next(tokens))
    solve(N, u, v, w)

if __name__ == '__main__':
    main()


Measured memory_bytes: 57748
#include <bits/stdc++.h>
using namespace std;
#define fix(f,n) std::fixed<<std::setprecision(n)<<f
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long int ll;
typedef unsigned long long int ull;
#define vi vector<int>
#define pii pair<int,int>
#define vii vector<pii>
#define max(a,b) ((a>b)?a:b)
#define min(a,b) ((a>b)?b:a)
#define max3(a,b,c) ((a>b)?(a>c)?a:c:(b>c)?b:c)
#define min3(a,b,c) ((a<b)?(a<c)?a:c:(b<c)?b:c)
#define REP(i,a,n) for(ll i=a;i<n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define MAX 1000000001

int main(){
	fast;
	int test=1;
	//cin >> test;
	while(test--){
	    bool x;
	    cin >> x;
	    cout << !x << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include <stdio.h>

int main(void){
  int i, count;
  char s[25], t[25];

  scanf("%s", s);

  count = 0;
  for (i = 0; s[i] != 0; i++) {
    count++;
  }

  for (i = 0; i < count; i++) {
    t[i] = s[count-i-1];
  }

  for (i = 0; i < count; i++) {
    printf("%c", t[i]);
  }
  printf("\n");

  return 0;
}



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

typedef struct {
    int num[6], temp;
}dice_struct;
dice_struct dice1, dice2;

void setting1(int d[]) {
    for (int i = 0; i < 6; i++) {
        dice1.num[i] = d[i];
    }
}

void setting2(int d[]) {
    for (int i = 0; i < 6; i++) {
        dice2.num[i] = d[i];
    }
}

void throw_dice(char order) {
    switch (order) {
        case 'R':
            dice1.temp = dice1.num[1];
            dice1.num[1] = dice1.num[3];
            dice1.num[3] = dice1.num[4];
            dice1.num[4] = dice1.num[2];
            dice1.num[2] = dice1.temp;
            break;
        case 'E':
            dice1.temp = dice1.num[0];
            dice1.num[0] = dice1.num[3];
            dice1.num[3] = dice1.num[5];
            dice1.num[5] = dice1.num[2];
            dice1.num[2] = dice1.temp;
            break;
        case 'S':
            dice1.temp = dice1.num[0];
            dice1.num[0] = dice1.num[4];
            dice1.num[4] = dice1.num[5];
            dice1.num[5] = dice1.num[1];
            dice1.num[1] = dice1.temp;
            break;
        case 'W':
            dice1.temp = dice1.num[0];
            dice1.num[0] = dice1.num[2];
            dice1.num[2] = dice1.num[5];
            dice1.num[5] = dice1.num[3];
            dice1.num[3] = dice1.temp;
            break;
        case 'N':
            dice1.temp = dice1.num[0];
            dice1.num[0] = dice1.num[1];
            dice1.num[1] = dice1.num[5];
            dice1.num[5] = dice1.num[4];
            dice1.num[4] = dice1.temp;
            break;            
    }
        
}

int isSame() {
    for (int i = 0; i < 6; i++) {
        if (dice1.num[i] != dice2.num[i]) {
            return 0;
        }
    }
    return 1;
}


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

    int n1[6], n2[6];
    for (int i = 0; i < 6; i++) {
        scanf("%d", &n1[i]);
    }
    setting1(n1);

    for (int i = 0; i < 6; i++) {
        scanf("%d", &n2[i]);
    }
    setting2(n2);

    int judge = -1;
    for (int i = 0; i < 4; i++) {
        throw_dice('E');
        for (int j = 0; j < 4; j++) {
            throw_dice('S');
            for (int k = 0; k < 4; k++) {
                throw_dice('W');
                for (int l = 0; l < 4; l++) {
                    throw_dice('N');
                    for (int m = 0; m < 4; m++) {
                        throw_dice('E');
                        for (int n = 0; n < 4; n++) {
                            if (judge != 1)  {
                                judge = isSame(dice1, dice2);
                                if (judge) {
                                    break;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    if (judge) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 2100
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
ll NcR(int n, int r) 
{ 
    ll p = 1, k = 1; 
    if (n - r < r) 
        r = n - r; 
  
    if (r != 0) { 
        while (r) { 
            p *= n; 
            k *= r; 
            ll m=__gcd(p, k); 
            p /= m; 
            k /= m; 
            n--; 
            r--; 
        } 
    } 
    else
        p = 1; 
    return p;
}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x)
{
    return (ll)(log(x)/log(base));
}
ll h,n;
pii p[1001];
ll dp[200001],mm=200001;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS;
    while(TESTS--)
    {
    	ll i,j,m,k,ans,a,b,g,mc,mh;
    	cin>>h>>n;
    	mc=mod; mh=0; vec v;
    	rep(i,0,n)
    	{
    		cin>>a>>b;
    		p[i].F=a; p[i].S=b;
//    		if(b<mc)
//    		{
//    			mc=b; mh=a;
//			}
		}
    	repi(i,0,mm)
    	dp[i]=mod;
    	dp[0]=0;
//    	repi(i,1,mh)
//    	dp[i]=mc;
    	repi(i,1,mm)
    	{
    		rep(j,0,n)
    		{
    			a=p[j].F; b=p[j].S;
    			if(i>=a)
    			dp[i]=min(dp[i],dp[i-a]+b);
			}
		}
		ans=mod;
		rep(i,h,mm)
		ans=min(ans,dp[i]);
		cout<<ans;
    } 
	return 0;
}

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

typedef long long ll;


int main()
{
    int n,k;
    cin >> n >> k;

    double ans = 0;
    for (int i = 1; i <= n; i++)
    {
        double ans_i = 1.0/n;
        int now = i;
        while(now < k){
            now *= 2;
            ans_i /= 2.0;
        }
        ans += ans_i;
    }
    printf("%.12f\n", ans);
}



Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <vector>
using namespace std;
using large = long long;

int main() {
    int n;
    cin >> n;
    auto a = vector<int>(n);
    auto counter = map<int, int>();
    for (auto &a_i : a) {
        cin >> a_i;
        counter[a_i]++;
    }

    auto combination_decrements = map<int, large>();
    auto sum_comb = 0LL;
    for (auto kv : counter) {
        int val = kv.first;
        int cnt = kv.second;
        if (cnt < 2) {
            combination_decrements[val] = 0;
            continue;
        }

        large comb = large(cnt) * (cnt - 1) / 2;
        large comb2 = large(cnt - 1) * (cnt - 2) / 2;

        combination_decrements[val] = (comb - comb2);
        sum_comb += comb;
    }

    for (auto a_i : a) {
        auto c = sum_comb - combination_decrements[a_i];
        cout << c << "\n";
    }
    return 0;
}


Measured memory_bytes: 16256
#include <stdio.h>

int gyou = 0;
int retsu = 0;
int masu = 0;

int main(void)
{
    int cnt = 0;
    int paint = 0;
    int big;

    scanf("%d", &gyou);
    scanf("%d", &retsu);
    scanf("%d", &masu);

    if (gyou >= retsu) {
        big = gyou;
    } else {
        big = retsu;
    }

    while (paint < masu) {
        paint += big;
        cnt++;
    }
    
    printf("%d", cnt);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll=long long int;
int main()
{
   ll ans=0;
  for(int i=1;i<=5;i++)
  {
      int x;
      cin>>x;
      if(x==0)
      {
        ans=i;
        break;
      }
  }
  cout<<ans<<endl;
  return 0;
}


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

vector<ll> divisors(101, 0);

void calcDivisors(int n){
    for(ll i = 2; i <= n; ++i){
        while(n%i == 0){
            divisors[i]++;
            n /= i;
        }
    }
}

int main() {
    ll n;
    cin >> n;
    for(ll i = 2; i <= n; ++i) calcDivisors(i);

    ll count = 0;

    // 4, 4, 2
    vector<tuple<ll, ll, ll>> v;
    for(ll i = 2; i <= n; ++i){
        if(divisors[i] < 4) continue;

        for(ll j = 2; j <= n; ++j){
            if(i == j) continue;
            if(divisors[j] < 4) continue;
            
            for(ll k = 2; k <= n; ++k){
                if(i == k || j == k) continue;
                if(divisors[k] < 2) continue;

                if(find(v.begin(), v.end(), make_tuple(i,j,k)) == v.end() &&
                   find(v.begin(), v.end(), make_tuple(j,i,k)) == v.end()){
                       count++;
                       v.push_back(make_tuple(i,j,k));
                       v.push_back(make_tuple(i,j,k));
                }else{
                    continue;
                }
            }
        }
    }

    // 14, 4
    for(ll i = 2; i <= n; ++i){
        if(divisors[i] < 14) continue;
        for(ll j = 2; j <= n; ++j){
            if(i == j) continue;
            if(divisors[j] < 4) continue;
            count++;
        }
    }

    // 24, 2
    for(ll i = 2; i <= n; ++i){
        if(divisors[i] < 24) continue;
        for(ll j = 2; j <= n; ++j){
            if(i == j) continue;
            if(divisors[j] < 2) continue;
            count++;
        }
    }

    // 74
    for(ll i = 2; i <= n; ++i){
        if(divisors[i] >= 74){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    int n;
    cin >> n;
    ll sum = 0;
    vector<ll> a(100001, 0);
    rep(i, n){
        ll num;
        cin >> num;
        sum += num;
        a[num]++;
    }
    int q;
    cin >> q;
    rep(i, q){
        ll b, c;
        cin >> b >> c;
        a[c] += a[b];
        sum -= a[b] * b;
        sum += a[b] * c;
        a[b] = 0;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 4008
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr int MOD = 1000000007;
constexpr int INF = 1e18;

using namespace std;


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

  cout << N*(N-1)/2 << endl;

  return 0;
}

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

int main(void)
{
    string s,t;
    cin >> s>>t;
    
    std::string::size_type  Pos( t.find( s ) );
    
    if((int)Pos == 0 )
        t.replace(Pos,s.length(), "");

    cout<<((t.length() == 1)?"Yes":"No") << endl;
    return 0;
}


Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int i;
	char c;
	for (i = 0; i < 19; i++) {
		cin >> c;
		if (i == 5 || i == 13) {
			cout << " ";
		}
		else {
			cout << c;
		}
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <limits.h>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;
using P = pair<int,int>;
using ll = long long;
int main(){
    int a,b,c,d,e;
    cin>>a>>b>>c>>d>>e;
    cout<<15-a-b-c-d-e<<endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main () {
  string N;
  cin >> N;
  int SN = 0;
  for (int i = 0; i < N.size(); i++) {
    SN += N.at(i) - '0';
  }
  if (stoi(N) % SN == 0)cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,c,d[30][30],C[500][500],col[3][30],cnt,min=2147483647;
	cin>>n>>c;
	for(int i=0;i<c;i++)
		for(int j=0;j<c;j++)
			cin>>d[i][j];
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			cin>>C[i][j];
	for(int i=0;i<3;i++)
		for(int j=0;j<30;j++)
			col[i][j]=0;
	for(int i=0;i<n;i++)
		for(int j=0;j<n;j++)
			col[(i+j)%3][C[i][j]-1]++;
	for(int i=0;i<c;i++){
		for(int j=0;j<c;j++){
			if(i==j)j++;
			if(j>=c)break;
			for(int k=0;k<c;k++){
				if(i==k)k++;
				if(j==k)k++;
				if(i==k)k++;
				if(k>=c)break;
				for(int l=0;l<c;l++){
					cnt+=col[0][l]*d[l][i]+col[1][l]*d[l][j]+col[2][l]*d[l][k];
				}
				if(cnt<min)min=cnt;
				cnt=0;
			}
		}
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
// -----------------<fast IO>------------------
#define IOS             ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FLSH             fflush(stdout)
#define fileIO(name) \
    freopen(name".in", "r", stdin); \
    freopen(name".out", "w", stdout);
#define PRECISION(x)     cout << fixed << setprecision(x);
// -----------------<TypeDef Start>------------------
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
// -----------------<Constants>------------------
const int MAXN = 1000005;
const int SQRTN = 1003;
const int LOGN = 22;
const double PI=acos(-1);

const int INF=1e9;
ll mn1=-9223372036854775808;
int MOD = 1000000007;
const int FMOD = 998244353;
const double eps = 1e-9;
/*ll gcd(ll a,ll b)
{
    if(a==0)
    return(b);
    return(gcd(b%a,a));
}*/
// --------------------------------------------------</TEMPLATE>--------------------------------------------------

ll power(ll a,ll b,ll p)
{
    ll res=1;
    a%=p;
    while(b>0)
    {
        if(b&1)
        res=res*a%p;
        a=a*a%p;
        b>>=1;
    }
    return(res);
}
void solve()
{
    ll s;
    cin>>s;
    if(s<=2)
        cout<<0<<endl;
    else
    {
        ll dp[s+1];
        dp[0]=1;
        for(int i=1;i<=s;i++)
            dp[i]=0;
        for(int i=3;i<=s;i++)
        {
            for(int j=3;i-j>=0;j++)
            {
                dp[i]=(dp[i]%MOD+dp[i-j]%MOD)%MOD;
            }
        }
        cout<<dp[s]<<endl;
    }
}
int main()
{
    IOS
    ll t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    return(0);

}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    vi a(5);
    rep(i, 5) cin >> a[i];
    int ans = 10000;
    do {
        int now = 0;
        rep(i, 5) {
            if (i == 4) {
                now += a[i];
            } else {
                now += (a[i]+9)/10 * 10;
            }
        }
        chmin(ans, now);
    } while (next_permutation(a.begin(), a.end()));
    cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
t, a = map(int, input().split())
h = list(map(int, input().split()))
tmp = 0
ans = 0
for i in range(n):
    if i == 0:
        tmp = abs(t - h[i] * 0.006 - a)
        ans = i
    elif abs(t - h[i] * 0.006 - a) <= tmp:
        tmp = abs(t - h[i] * 0.006 - a)
        ans = i
print(ans+1)


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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<int> h(N),ans(N,1e9+7);
	repp(i,0,N) cin >> h[i];
	ans[0] = 0;
	repp(i,1,N){
		if(i > 1) ans[i] = min(ans[i],ans[i-2]+abs(h[i]-h[i-2]));
		ans[i] = min(ans[i],ans[i-1]+abs(h[i]-h[i-1]));
	}
	cout << ans[N-1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1e9;

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> vec(m);

    for (int i = 0; i < m; ++i) {
        int k;
        cin >> k;
        vec[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> vec[i][j];
            --vec[i][j];
        }
    }

    vector<int> p(m);
    for (int i = 0; i < m; ++i) cin >> p[i];

    int ans = 0;
    for (int i = 0; i < (1 << n); ++i) {
      bool ok = true;
      for (int j = 0; j < m; ++j) {
        int c = 0;
        for (int id : vec[j]) {
          if ((i >> id) & 1) {
            ++c;
          }
        }
        c %= 2;
        if (c != p[j]) {
          ok = false;
        }
      }
      if (ok) {
        ++ans;
      }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    (1..n).map {
        val s = readLine()!!.split(" ")
        if(s[1]=="JPY") s[0].toDouble() else 380000.0*s[0].toDouble()
    }.sum().let { println(it) }

}

Measured memory_bytes: 37992
#include <bits/stdc++.h>
using namespace std;
int main(){
    cin.tie(0);
    //ios::sync_with_stdio(false);
    int N;
    cin >> N;
    int K;
    cin >> K;
    int a[N] = {0};
    for(int i = 0;i < N;i++){
        cin >> a[i];
    }
    int count = 0;
    for(int i = 0;i < N;i++){
        if(K - a[i] < a[i] ){
            count += (K - a[i]) * 2;
        }else{
            count += a[i] * 2;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int t, n, i;
    cin >> n;
    for(i=1;i<=9;i++) {
        if(!(n%i) && (n/i)<=9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

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

    int ans = 0;
    while(N>0) {
        ans += N%10;
        N /= 10;
    }
    if(ans == 1) ans = 10;
    cout << ans << endl;
}

Measured memory_bytes: 256
from sys import stdin
from sys import setrecursionlimit
import bisect
setrecursionlimit(10 ** 7)

s = input()
point = 0

for i in range(len(s)):
    for j in range(i,len(s)):
        now = s[:i]+s[j:]
        if now == "keyence":
            print("YES")
            exit()
print("NO")

Measured memory_bytes: 3060
import numpy as np
import sys


def get_data(stream):
    buf = b''
    b = stream.buffer.read(1)
    while b != b'\n':
        buf += b
        b = stream.buffer.read(1)
    H, W = map(int, buf.split())
    c = stream.buffer.read(H * (W + 1))
    arr = np.array(c.split())
    arr = np.frombuffer(arr, dtype='S1').reshape((H, W))
    return H, W, arr


def main():
    H, W, arr = get_data(sys.stdin)
    a = arr == b'.'
    L = np.empty((H, W), dtype='i8')
    R = np.empty((H, W), dtype='i8')
    T = np.empty((H, W), dtype='i8')
    B = np.empty((H, W), dtype='i8')
    T[0] = a[0]
    for i in range(1, H):
        T[i] = (T[i - 1] + 1) * a[i]
    B[-1] = a[-1]
    for i in range(H - 2, -1, -1):
        B[i] = (B[i + 1] + 1) * a[i]
    L[:, 0] = a[:, 0]
    for i in range(1, W):
        L[:, i] = (L[:, i - 1] + 1) * a[:, i]
    R[:, -1] = a[:, -1]
    for i in range(W - 2, -1, -1):
        R[:, i] = (R[:, i + 1] + 1) * a[:, i]

    print((T + B + L + R - 3).max())


if __name__ == "__main__":
    main()

Measured memory_bytes: 207800
package main

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

type Pair struct {
	a, b int
}

func main() {
	N := ReadInt()
	m := make(map[Pair]Pair)
	zeros := 0
	for i := 0; i < N; i++ {
		x, y := ReadInt(), ReadInt()
		if x == 0 && y == 0 {
			zeros++
			continue
		}
		gcd := GCD(x, y)
		x /= gcd
		y /= gcd
		if y < 0 {
			x, y = -x, -y
		}
		if y == 0 && x < 0 {
			x, y = -x, -y
		}
		rot90 := x <= 0
		if rot90 {
			x, y = y, -x
		}
		p := m[Pair{x, y}]
		if rot90 {
			p.a++
		} else {
			p.b++
		}
		m[Pair{x, y}] = p
	}

	ans := 1
	for _, p := range m {
		s := p.a
		t := p.b
		now := 1
		now = now + ModPow(2, s) + Mod - 1
		now %= Mod
		now = now + ModPow(2, t) + Mod - 1
		now %= Mod
		ans *= now
		ans %= Mod
	}
	ans = ans + zeros + Mod - 1
	ans %= Mod
	fmt.Println(ans)
}

func GCD(a, b int) int {
	if b == 0 {
		return a
	}
	return GCD(b, a%b)
}

const Mod = int(1e9) + 7

func ModPow(a, b int) (x int) {
	for x = 1; b > 0; b >>= 1 {
		if b&1 == 1 {
			x = x * a % Mod
		}
		a = a * a % Mod
	}
	return
}
func ModCombination(n, k int) int { return fac[n] * (finv[k] * finv[n-k] % Mod) % Mod }

var fac, finv, inv []int

func init() {
	const MAX = 5 * 1e5
	fac, finv, inv = make([]int, MAX+1), make([]int, MAX+1), make([]int, MAX+1)
	fac[0], fac[1], finv[0], finv[1], inv[1] = 1, 1, 1, 1, 1
	for i := 2; i <= MAX; i++ {
		fac[i] = fac[i-1] * i % Mod
		inv[i] = Mod - inv[Mod%i]*(Mod/i)%Mod
		finv[i] = finv[i-1] * inv[i] % Mod
	}
}

var reader = bufio.NewReader(os.Stdin)

func Scan(a ...interface{}) {
	if _, err := fmt.Fscan(reader, a...); err != nil {
		panic(err)
	}
}
func ReadInt() (i int)       { Scan(&i); return }
func ReadString() (s string) { Scan(&s); return }
func ReadInts(n int) []int {
	v := make([]int, n)
	for i := 0; i < n; i++ {
		Scan(&v[i])
	}
	return v
}


Measured memory_bytes: 39344
N, K = map(int, input().split())

dice_max = N
goal = K



dice = list(range(1, dice_max+1))

import math

ans = 0
    
for d in dice:
    win = 1
    if d < goal:
        lose_num = math.ceil(math.log2(goal / d))
        #print(lose_num)
        win = 1 / (2** lose_num)

        
    ans += win

ans /= len(dice)
print('{:.15g}'.format(ans))

# 0.999973749998

Measured memory_bytes: 6900
line_str = input().split()

A = int(line_str[0])
B = int(line_str[1])
K = int(line_str[2])

if A >= K:
    print(A-K, B)
elif A < K <= A+B:
    print(0, B-(K-A))
else:
    print(0, 0)

Measured memory_bytes: 3064