akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stdio.h>
using namespace std;
static const int MAX = 100;

struct Card {
    char suit;
    char value;
};

void printLine (Card A[], int N) {
    for (int i = 0; i < N; i++) {
        if (i > 0) {
            printf(" ");
        }
        printf("%c%c", A[i].suit, A[i].value);
    }
    printf("\n");
}

void bubbleSort(Card C[], int N) {
    int cnt = 0;
    for (int i = N - 1; i > 0; i--) {
        Card left = C[i-1];
        Card right = C[i];
        if (left.value > right.value) {
            C[i-1] = right;
            C[i] = left;
            cnt++;
        }
    }
    if (cnt > 0) {
        bubbleSort(C, N);
    }
}

void selectionSort(Card C[], int N, int step) {
    int min = -1;
    int minIdx = -1;
    for (int i = step; i < N; i++) {
        if (i == step) {
            min = C[i].value;
            minIdx = i;
            continue;
        }
        if (C[i].value < min) {
            min = C[i].value;
            minIdx = i;
        }
    }
    
    if (min == -1) {
        return;
    }
    
    if (minIdx != step) {
        Card v = C[step];
        C[step] = C[minIdx];
        C[minIdx] = v;
    }
    
    step++;
    selectionSort(C, N, step);
}

bool isStable(Card C[], int N, Card left, Card right) {
    Card P[N];
    int cnt = 0;
    for (int i = 0; i < N; i++) {
        if (C[i].value == left.value) {
            P[cnt] = C[i];
            cnt++;
        }
    }
    for (int i = 0; i < cnt; i++) {
        if (P[i].value == left.value && P[i].suit == left.suit) {
            return P[i+1].value == right.value && P[i+1].suit == right.suit;
        }
    }
    return false;
}

// 同じ数字を持つカードが複数ある場合、それらが入力に
// 出現する順序で出力されることを「安定な出力」と評価
void checkStable(Card Original[], Card Sorted[], int N) {
    bool stable = true;
    for (int i = 1; i < N; i++) {
        Card left = Sorted[i-1];
        Card right = Sorted[i];
        if (left.value == right.value) {
            stable = isStable(Original, N, left, right) && stable;
        }
    }
    if (stable) {
        printf("%s", "Stable\n");
    } else {
        printf("%s", "Not stable\n");
    }
}

int main() {
    int N;
    scanf("%d", &N);
    
    // Set input array to A
    Card A[MAX];
    for (int i = 0; i < N; i++) {
        cin >> A[i].suit >> A[i].value;
    }
    
    // Copy A to C1 and C2
    Card C1[MAX];
    Card C2[MAX];
    for (int i = 0; i < N; i++) {
        C1[i] = A[i];
        C2[i] = A[i];
    }
    
    // Bubble sort
    bubbleSort(C1, N);
    printLine(C1, N);
    
    // Stable ?
    checkStable(A, C1, N);
    
    // Selection sort
    selectionSort(C2, N, 0);
    printLine(C2, N);
    
    // Stable ?
    checkStable(A, C2, N);
   
    return 0;
}



Measured memory_bytes: 3224
#include <iostream>
#include <string>
#include <vector>
#include <cmath>

using namespace std;

int main(void) {

    double N;
    string s;
    long long r, g, b;
    int i, j, k;
    long long sum;


    cin >> N;

    N = M_PI * N * 2.0;

    cout << N << endl;

    return 0;    
}

Measured memory_bytes: 3820
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse4")
using namespace std;

# define mp make_pair
# define pb push_back
# define PI acos(-1)
# define ff first 
# define ss second 
# define endl '\n'
# define vt vector
# define all(c) (c).begin(), (c).end()
# define rep(i,a,b) for(ll i = a ; i < b ; ++i)

typedef long long ll ; 
typedef long double ld ; 
typedef pair<int,int> pii ; 
typedef pair<ll,ll> pll ;

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

const int MOD = 998244353  ;
const ll inf = 1e18 ;  
const ll mod = 1e9+7 ;  
template<typename T> T gcd(T a,T b) { if(a==0) return b; return gcd(b%a,a); }
template<typename T> T lcm(T a, T b) { return (a*b)/gcd(a,b) ; }
template<typename T> T power(T a,T b, ll m){T ans=1; while(b>0){ if(b%2==1) ans=(ans*a)%m; b/=2; a=(a*a)%m; } return ans%m; }
ll nCr(ll n,ll r){ll t=1;if(r>n)return 0;if(r>n-r)r=n-r;for(ll i=0;i<r;i++){t*=(n-i);t/=(i+1);}return t;}

void read(vt<int> &a) {
    rep(i,0,a.size()) 
        cin >> a[i] ; 
}
void read(vt<ld> &a) {
    rep(i,0,a.size()) 
    cin >> a[i] ; 
}

bool prime(ll t) {
    for(ll i  =2 ; i*i <= t ; ++i) {
        if(t%i==0) 
            return 0 ; 
    }
    return 1 ; 
}
bool cmp(pii &a , pii &b) {
    if(a.ss == b.ss) 
        return a.ff > b.ff ; 
    return a.ss < b.ss ; 
}

// ==========Start Here==============
const int N = 2e5+1 ;
vt<int> adj[N] ;
vt<bool> vis(N) ; 
int cnt  ; 

void dfs(int u) {
    vis[u] = 1 ;
    cnt++;  
    for(int x : adj[u]) {
        if(!vis[x])
            dfs(x) ;
    }
}

int main() 
{ 
    int n , m ; 
    cin >> n >> m ; 
    int u,v ; 
    rep(i,0,m) {
        cin >> u >> v ; 
        adj[u].pb(v) ; 
        adj[v].pb(u) ; 
    } 

    int ans = 0 ; 
    rep(i,1,n+1){
        if(!vis[i]) {
            cnt = 0 ; 
            dfs(i) ; 
            umax(ans,cnt) ; 
        }
    }
    cout << ans ; 




    return 0; 
} 

Measured memory_bytes: 20776
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>

using namespace std;

void func(int up, int down){
	int array_up[up],array_down[down],merge[up+down+1];

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

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

	merge[0] = 0;
	int p_up = 0,p_down = 0;
	for(int i = 1; i <= up+down; i++){
		if((p_down >= down)|| (p_up < up && array_up[p_up] <= array_down[p_down])){
			merge[i] = array_up[p_up];
			p_up++;
		}else{
			merge[i] = array_down[p_down];
			p_down++;
		}
	}

	int ans = 0;
	for(int i = 1; i <= up+down;i++){
		ans = max(ans,merge[i] - merge[i-1]);
	}

	printf("%d\n",ans);

}

int main(){

	int up,down;

	while(true){
		scanf("%d %d",&up,&down);
		if(up == 0 && down == 0)break;

		func(up,down);
	}

    return 0;
}

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

vector<vector<pair<int, int>>> to(100000);
vector<int> ans(100000);

void dfs(int v = 0, int p = -1, int c = 0)
{
  ans.at(v) = c;
  for (auto n : to.at(v)) {
    if (n.first == p) continue;
    dfs(n.first, v, (n.second + c) % 2);
  }
}

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

  for (int i = 0; i < n - 1; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--; v--; w %= 2;
    to.at(u).emplace_back(v, w);
    to.at(v).emplace_back(u, w);
  }

  dfs();

  for (int i = 0; i < n; i++) {
    cout << ans.at(i) << endl;
  }
}


Measured memory_bytes: 8448
n = int(input())
b = list(map(int,input().split()))

dp = [10**8]*n

for i in range(n-1):
    if dp[i] > b[i] :
        dp[i] = b[i]
    if dp[i+1] > b[i] :
        dp[i+1] = b[i]

print(sum(dp))


Measured memory_bytes: 9112
n,a=int(input()),list(map(int,input().split()))
a.sort()
b,j=[a[0]],0
for i in a[1:]:b.append(b[-1]+i)
while a[-1-j]<=b[-2-j]*2:
  j+=1
  if j==n-1:break
print(j+1)

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

int main() {
  long long H;
  
  cin >> H;
  
  long long T;
  int N=0;
  
  while (H>0){
    H /= 2;
    T += pow(2,N);
    N++;
  }

  cout << T << endl;

}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using int32=int_fast32_t;using uint32=uint_fast32_t;using int64=int_fast64_t;using uint64=uint_fast64_t;using pi=pair<int32,int32>;using pll=pair<int64,int64>;using vi=vector<int32>;using vvi=vector<vector<int32>>;using vll=vector<int64>;using ll=int64;using ull=uint64;
#define all(x) x.begin(),x.end()
inline ll read(){ll x=0,f=1;char c=getchar();while(c<'0'||c>'9'){if(c=='-')f=-1;c=getchar();}while(c>='0'&&c<='9')x=x*10+c-'0',c=getchar();return x*f;}
inline string read_s(){string s="";char c=getchar();while(c<'!'||c>'~'){c=getchar();}while(c>='!'&&c<='~'){s+=c;c=getchar();}return s;}
void Main(){
    ll N=read(), max_min=0;
    for(int i=0;i<5;i++){
        ll a=read();
        ll com = N/a;
        if(N%a!=0) com++;
        max_min = max(max_min, com+4);
    }
    printf("%lld\n", max_min);
}
int main(){cin.tie(nullptr);ios::sync_with_stdio(false);Main();return 0;}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define REP(i, a) FOR(i, 0, a - 1)
using PII = pair<int, int>;
#define ST first
#define ND second

vector<vector<int>> graph;

PII dfs(int v, int d = 0, int p = -1) {
	PII ans = {1, v};
	for(int u : graph[v]) {
		if(u != p) {
			PII ret = dfs(u, d + 1, v);
			ret.ST += 1;
			ans = max(ans, ret);
		}
	}
	return ans;
}

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

	int n;
	cin >> n;

	graph.resize(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		graph[a - 1].emplace_back(b - 1);
		graph[b - 1].emplace_back(a - 1);
	}

	PII x = dfs(0);
	PII y = dfs(x.ND);

	vector<int> dp(y.ST + 1);
	dp[1] = 1;

	FOR(i, 3, y.ST) dp[i] = (!dp[i - 1] || !dp[i - 2]);
	if(dp[y.ST]) cout << "First\n";
	else cout << "Second\n";
}


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

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

    int ans;

    ans = 10*b;
    bool fin = false;
    while (!fin) {
        if ((ans*8)/100 == a) {
            fin = true;
            break;
        } else {
            ans++;
            if (ans/10 != b) {
                ans = -1;
                fin = true;
                break;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>

int main() {
  int N, D, X;
  std::cin >> N >> D >> X;

  int answer = X;

  for (int i = 0; i < N; i++) {
    int a;
    std::cin >> a;

    answer += (D - 1) / a + 1;
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 256
X,Y,Z,K = map(int,input().split())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
C = list(map(int,input().split()))

# A,B,Cのリストを降順にソート
A.sort(reverse =True)
B.sort(reverse =True)
C.sort(reverse =True)

# A,B,Cを上からp,q,r番目を選択した場合にp*q*rがKより大きい組み合わせがKより上位に来ることはない
# A,B,Cを上から参照していき。p*q*rがK以下の場合はリストにa+b+cを追加，K以上の場合はbreak
D = []
for p in range(1,X+1):
    for q in range(1,Y+1):
        for r in range(1,Z+1):
            if p*q*r<=K:
                D.append(A[p-1]+B[q-1]+C[r-1])
            else:
                break
D.sort(reverse=True)

for i in range(K):
    print(D[i])

Measured memory_bytes: 48224
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define test int t;cin>>t;while(t--)

signed main(){
    fast
string s="No";
 int n;
 cin>>n;int c=0;
 f0(i,0,n)
 {
     int a,b;
     cin>>a>>b;
     if(a==b)c++;
     else c=0;
     if(c==3)s="Yes";
 }cout<<s;
}

Measured memory_bytes: 3644
a = int(input())
b = int(input())
c = int(input())
x = int(input())

count = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if(500*i+100*j+50*k == x):
                count += 1
print(count)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define FOR(i,l,r) for(i=l;i<r;i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define P pair<ll,ll>
#define F first
#define S second
signed main(){
  double N,K,i,ans;cin>>N>>K;
  REP(i,N){
    ll A=i+1,S=1;
    while(A<K){A*=2;S*=2;}
    ans+=1.000000000000/(double)S;
  }
  printf("%.12lf\n",ans/N);
  return 0;
}

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

vector<int> G[100000], color(100000);
int c;
void dfs(int v) {
    color[v] = c;
    for (int i = 0; i < G[v].size(); ++i) {
        int e = G[v][i];
        if (!color[e]) dfs(e);
    }
}
int main() {
    int n, m;
    cin >> n >> m;
    while (m--) {
        int s, t;
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }
    for (int i = 0; i < n; ++i) {
        if (!color[i]) {
            c++;
            dfs(i);
        }
    }
    int q;
    cin >> q;
    while (q--) {
        int s, t;
        cin >> s >> t;
        if (color[s] == color[t]) cout << "yes" << endl;
        else cout << "no" << endl;
    }
    return 0;
}


Measured memory_bytes: 11772
import java.util.*;
import java.util.stream.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		String N = sc.next();
		if (N.contains("9")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 23764
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <map>
#include <cmath>

using namespace std;
using ll = long long;

int gcd(int a, int b) { return (b == 0) ? a : gcd(b, a % b); }

#define CIN(T, x) T x; cin >> x;
#define CINS(T, x, N) vector<T> x(N); for(int i = 0; i < (N); i++) { cin >> x[i]; }
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << " "; } cout << "\n";
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << "\n";


int main() {

    CIN(int, H);
    CIN(int, W);
    CIN(int, N);

    CIN(int, sr);
    CIN(int, sc);

    CIN(string, S);
    CIN(string, T);

    string ans = "YES";
    int count;

    count = sc;
    for (int i = 0; i < N; i++) {
        if ( ans == "NO" ) break;
        if ( S[i] == 'L' ) count--;
        if ( count < 1 ) ans = "NO";
        if ( T[i] == 'R' && count < W ) count++;
    }

    count = sc;
    for (int i = 0; i < N; i++) {
        if ( ans == "NO" ) break;
        if ( S[i] == 'R' ) count++;
        if ( count > W ) ans = "NO";
        if ( T[i] == 'L' && 1 < count ) count--;
    }

    count = sr;
    for (int i = 0; i < N; i++) {
        if ( ans == "NO" ) break;
        if ( S[i] == 'U' ) count--;
        if ( count < 1 ) ans = "NO";
        if ( T[i] == 'D' && count < H ) count++;
    }

    count = sr;
    for (int i = 0; i < N; i++) {
        if ( ans == "NO" ) break;
        if ( S[i] == 'D' ) count++;
        if ( count > H ) ans = "NO";
        if ( T[i] == 'U' && 1 < count ) count--;
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 776
import math

K = int(input())
ans = 0

for a in range(1, K + 1):
    for b in range(1, K + 1):
        g = math.gcd(a, b)
        if g == 1:
            ans += K
            continue      
        for c in range(1, K + 1):
            ans += math.gcd(c, g)

print(ans)

Measured memory_bytes: 9196
import numpy as np

n, m = map(int, input().split())
a = np.array(sorted(list(map(int, input().split()))), dtype=np.int64)
bc = sorted([list(map(int, input().split())) for _ in range(m)], key=lambda x: -x[1])

p = 0
for b, c  in bc:
    a[p:p+b] = np.maximum(a[p:p+b], c)
    p += b
print(np.sum(a))

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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

int main()
{
    cout << fixed << setprecision(15);
    ll N, M;
    cin >> N >> M;

    Graph G(N);

    REP(i,M){
        int a,b;
        cin >> a;
        cin >> b;
        a--; b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    vector<int> dist(N, -1);
    vector<ll> ans(N);
    queue<int> que;

    dist[0] = 0;
    que.push(0);

    while(!que.empty()){
        int p;
        p = que.front();
        que.pop();

        for(int next :G[p]){
            // もし次のノードが訪問済みなら処理を飛ばす
            if(dist[next] != -1) continue;

            dist[next] = dist[p] + 1;
            ans[next] = p;
            que.push(next);
        }
    }
    cout << "Yes" << endl;
    for(ll i=1; i<N; i++){
        cout << ans[i]+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 10932
import java.util.*;

public class Main {

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int k = sc.nextInt();
		char[] arr = s.toCharArray();
		Arrays.sort(arr);
		int idx = 0;
		char prev = '0';
		TreeSet<String> set = new TreeSet<>();
		for (int i = 0; i < s.length() || (set.size() < k && prev == arr[i]); i++) {
			if (arr[i] != prev) {
				idx = 0;
				prev = arr[i];
			}
			int start = s.indexOf(prev, idx);
			idx = start + 1;
			for (int j = i + 1; j <= s.length() && j - i <= 5; j++) {
				set.add(s.substring(i, j));
			}
		}
		ArrayList<String> list = new ArrayList<String>(set);
		System.out.println(list.get(k - 1));
	}
}


Measured memory_bytes: 24900
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;   
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define ld long double
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll x,y,a,b,c;
	cin>>x>>y>>a>>b>>c;
	multiset<ll> mlt;
	std::vector<ll> pa,pb;
	for(ll i=1;i<=a;i++)
	{
		ll z;
		cin>>z;
		pa.pb(z);
	}
	for(ll i=1;i<=b;i++)
	{
		ll z;
		cin>>z;
		pb.pb(z);
	}
	sort(all(pa));reverse(all(pa));
	sort(all(pb));reverse(all(pb));
	for(ll i=0;i<x;i++)
		mlt.insert(pa[i]);
	for(ll i=0;i<y;i++)
		mlt.insert(pb[i]);
	for(ll i=0;i<c;i++)
	{
		ll z;
		cin>>z;
		mlt.insert(z);
		mlt.erase(mlt.begin());
	}
	ll ans=0;
	for(auto u:mlt)
		ans+=u;
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;
using ll = long long;

long nCr(int n, int r) {
    long ans = 1;
    for (int i = n; i > n - r; --i) {
        ans = ans*i;
    }
    for (int i = 1 ; i < r + 1; ++i) {
        ans = ans / i;
    }
    return ans;
}

int main() {
    int n, m;
    cin >> n >> m;
    cout << nCr(n, 2) + nCr(m, 2) << endl;
    return 0;
}

Measured memory_bytes: 256
import fractions
N,K=map(int,input().split())
L=list(map(int,input().split()))
tmp=0
if N==1:
	if L[0]==K:
		print("POSSIBLE")
		exit()
	else:
		print("IMPOSSIBLE")
		exit()
for i in range(1,N):
	if i==1:
		tmp=fractions.gcd(L[0],L[1])
	else:
		tmp=fractions.gcd(tmp,L[i])
if max(L)>=K and K%tmp==0:
	print("POSSIBLE")
else:
	print("IMPOSSIBLE")

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

	/* 177

	int D, T, S;
	cin >> D >> T >> S;
	int hour = D / S;
	if (D % S != 0)hour++;
	if (hour <= T) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
	
	*/

	/* 175
	string S;
	cin >> S;
	if (S == "RRR") {
		cout << 3 << endl;
	}
	else if (S == "SSS") {
		cout << 0 << endl;
	}
	else if (S == "SRR" || S == "RRS") {
		cout << 2 << endl;
	}
	else {
		cout << 1 << endl;
	}
	*/	

	/* 178
	int x;
	cin >> x  ;
	if (x == 1) {
		cout << 0 << endl;
	}
	if (x == 0) {
		cout << 1 << endl;
	}
	*/ 

	/* 174
	int X;
	cin >> X;
	if(X>=30){
		cout << "Yes"<<endl;
	}
	else{
		cout << "No"<<endl;
	}
	*/
	/*
	int N, X, T;
	cin >> N >> X >> T;
	if (N % X == 0) {
		cout << N / X * T << endl;
	}
	else {
		cout << N / X *T +T<<endl;
		return 0;
	}
	*/
	
	int n,x,t;
 int ans=0;
 cin>>n>>x>>t;
 
 if(n%x==0){
 cout<<n/x*t<<endl;
 }
 
if(n%x!=0){
  cout<<n/x*t+t<<endl;
}
 
 return 0;
 
}




Measured memory_bytes: 3532
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#define MOD 1000000007
using namespace std;

int main()
{
	int n;
	int a[102];
	cin >> n;
	int i,j,ans,b;
	for (i = 0; i < n; i++){
		cin >> a[i];
	}
	ans = 100000000;
	for (i = 0; i < 201; i++){
		b = 0;
		for (j = 0; j < n; j++){
			b = b + (a[j] - i + 100)*(a[j] - i + 100);
		}
		if (ans >= b){
			ans = b;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(_) for _ in input().split()]
b = [0] * n
res = []
m = 0
for i in range(n//2,n):
    if a[i] == 1:
        res.append(i+1)
        b[i] = 1
        m += 1
for i in range(n//2):
    k = n//2-i
    cnt = 0
    for j in range(2*k-1,n,k):
        if b[j] == 1:
            cnt = (cnt+1)%2
    if cnt != a[k-1]:
        res.append(k)
        b[k-1] = 1
        m += 1 
if m == 0:
    print(0)
else:
    print(m)
    for i in range(m):
        if i != 0:
            print(' ',end='')
        print(res[i],end='',)
    print()

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

struct st {
	char a;
	int b, c;
};
int main() {
	int n;
	while (cin >> n, n) {
		vector<st>v;
		rep(i, n) {
			char t; int a = 0, b = 0;
			cin >> t;
			rep(j, n - 1) {
				int r; cin >> r;
				if (!r)a++;
				if (r == 1)b++;
			}
			v.push_back({ t,a,b });
		}
		stable_sort(v.begin(), v.end(), [](st a, st b) {return a.c < b.c; });
		stable_sort(v.begin(), v.end(), [](st a, st b) {return a.b > b.b; });
		for (st i : v) {
			cout << i.a << endl;
		}
	}
}



Measured memory_bytes: 3152
import java.util.Scanner;

public class Main{
		
	public static void main(String args[]){
		  
	    Scanner sc = new Scanner(System.in);
	    
	    int a = sc.nextInt();
	    String s = sc.next();
	    int b = sc.nextInt();
	    
	    if(s.equals("+")) {
	    	System.out.println(a+b);
	    }else {
	    	System.out.println(a-b);
	    }
	}
}

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

int main(){
  int n;
  int count=0;
  string s;
  cin >> n >> s;
  for(int i=1;i<n;i++){
    if(s[i-1]==s[i]){
     continue;
    }else{
      count++;
    }
  }
    cout << count+1 << endl;
}

Measured memory_bytes: 512
let rec read u =
    let (num, sum) = Scanf.scanf "%d %d\n" (fun x y -> (x,y)) in
    if num = 0 && sum = 0 then ()
    else
        let n = if num > (sum-3) then sum - 3 else num in
        let m = min (n-1) (sum-n-1) in
        let rec loop ct k l = match k with
            k when k < 3 -> Printf.printf "%d\n" ct
          | k -> ( match l with
                     l when l < 2 -> let m' = min (sum-k) (k-2) in loop ct (k-1) m'
                   | l -> let s = sum-k-l in
                        if s >=1 && s < l then loop (ct+1) k (l-1)
                        else loop ct k (l-1)
                 )
        in loop 0 n m;read u;;
let () = read ();;

Measured memory_bytes: 2424
def main():
  element_num = int(input())
  elements = [int(s) for s in input().split()]
  swap_count = 0

  for i in range(1, element_num):
    for j in reversed(range(i, element_num)):
      if elements[j-1] > elements[j]:
        elements[j-1], elements[j] = elements[j], elements[j-1]
        swap_count += 1

  print(' '.join(list(map(str, elements))))
  print(swap_count)
  return 0

if __name__ == '__main__':
  main()

Measured memory_bytes: 7676
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 400001;


int main()
{
//  freopen("in.txt", "r", stdin);
//  freopen("out.txt", "w", stdout);
  int n;
  cin >> n;
  int arr[n];

  vector<pair<int, int>> v;
  for(int i = 0;i < n;i++){
    cin >> arr[i];

  }
  int mxi, mni;
  mxi = max_element(arr, arr + n) - arr;
  mni = min_element(arr, arr + n) - arr;

  if(arr[mxi] > -arr[mni]){
    for(int i = 0;i < n;i++){
      if(arr[i] < 0){
        v.push_back({mxi, i});
        arr[i] += arr[mxi];
      }
    }
  }else{
    for(int i = 0;i < n;i++){
      if(arr[i] > 0){
        v.push_back({mni, i});
        arr[i] += arr[mni];
      }
    }
  }
  ll x = accumulate(arr, arr + n, 0);
  if(x < 0){
    for(int i = n - 2;i >= 0;i--){
      v.push_back({i + 1, i});
      arr[i] += arr[i + 1];
    }
  }else{
    for(int i = 1;i < n;i++){
      v.push_back({i - 1, i});
      arr[i] += arr[i - 1];
    }
  }
  cout << v.size() << endl;
  for(auto el : v){
    cout << el.first + 1 << ' ' << el.second + 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){

	int N, K;	cin >> N >> K;
	string s, t = "f";	cin >> s;
	t += s + 'f';

	int hp = 0;
	for(int i = 1 ; i <= N ; i++){

	 	if(t[i] == 'L'){
		 	if(t[i] == t[i - 1]) hp += 1;
		}else{
		 	if(t[i] == t[i + 1])	hp += 1;
		}
	
	}

	cout << min(hp + K * 2 , N - 1) << endl;

 return 0;
}


Measured memory_bytes: 512
#include<iostream>
using namespace std;
int main(){
  int h,w;
  cin >> h >> w;
  while(h!=0){
    int i,j;
    for(i=0;i<h;i++){
      for(j=0;j<w;j++){
	if((i%2==0&&j%2==0)||(i%2==1&&j%2==1))
	  cout << "#";
	else cout << ".";
      }
      cout << endl;
    }
    cout << endl;
    cin >> h >> w;
  }
  return 0;
}



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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.f,", ",x.s,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

ll N, L, T;
vll solve(vll pos, vb dir) {
	ll s = 0;
	while (s < N && !dir[s]) ++s;

	if (s == N) {
		// all facing the same way case
		vll ans (N);
		F0R(i, N) {
			ans[i] = ((pos[i] - T) % L + L) % L;
		}
		return ans;
	}

	ll opp = 0;
	F0R(i, N) if (!dir[i]) ++opp;
	ll bumps = opp * ((2 * T) / L);

	F0R(i, N) if (!dir[i]) {
		ll dist = 0;
		if (pos[i] < pos[s]) 
			dist = L - pos[s] + pos[i];
		else
			dist = pos[i] - pos[s];
		if (dist < ((2 * T) % L)) bumps++;
	}
	
	vll ans (N);
	vll spots (N);
	F0R(i, N) {
		ll npos;
		if (dir[i])
			npos = (pos[i] + T) % L;
		else
			npos = (((pos[i] - T) % L) + L) % L;
		spots[i] = npos;
	}
	sort(spots.begin(), spots.end());
	int i = 0; 
	while (spots[i] != (pos[s] + T) % L) ++i;
	F0R(j, N) ans[(s + bumps + j) % N] = spots[(i + j) % N];
	return ans;
}

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N >> L >> T;
	vll pos (N);
	vb dir (N); // is clockwise
	F0R(i, N) {
		ll x, d; cin >> x >> d;
		pos[i] = x;
		dir[i] = (d == 1);
	}
	
	vll ans = solve(pos, dir);
	
	for (ll x : ans) print(x);
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)
#define rem(i, m, n) for (int i = m; i >= n; --i)
typedef long long ll;
#define mod 1000000007
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }

int main() {
  int N; cin >> N;
  if(N == 1) {
    cout << "Hello World" << endl;
    return 0;
  }
  int a,b;
  cin >> a >> b;
  cout << a + b << endl;
  return 0;
}


Measured memory_bytes: 256
def modify_flags(flags, temp):
  num_idx = temp[0]*3+temp[1]
  corr = {0:(1,6,7), 1:(2,6), 2:(3,6,8), 3:(1,5), 4:(2,5,7,8), 5:(3,5), 6:(1,4,8), 7:(2,4), 8:(3,4,7)}
  for item in corr[num_idx]:
    flags[item-1] += 1

nums = {}
for i in range(3):
  x = [int(_) for _ in input().split(" ")]
  for j in range(3):
    nums[x[j]] = (i, j)

flags = [0]*8
N = int(input())
for i in range(N):
  temp = int(input())
  if (temp not in nums.keys()):
    continue
  modify_flags(flags, nums[temp])

rst = "No"
for item in flags:
  if (item == 3):
    rst = "Yes"
    break
print(rst)


Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  int n;
  cin>>n;
  vi b(n);
  int bn;
  int ans[n];

  REP(i, n) {
    cin>>bn;
    b[i]=bn;
  }

  if(n==1){
    cout<<1<<endl;
    return 0;
  }
 bool erased;
  REP(i, n){
    erased = false;
    for(int j = n-i-1; j>-1; --j){
      if(b[j] == j+1){
        ans[n-i-1] = j+1;
        b.erase(b.begin() + j);
        erased=true;
        break;
      }
    }

    if(!erased){
      cout<<-1<<endl;
      return 0;
    }
  }
  REP(i, n)cout<<ans[i]<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char s1[100],s2[100];
int main(){
	scanf("%s %s",s1,s2);
	bool sw  =1;
	for(int i = 0; i < strlen(s1); i++)
		sw &= s1[i]==s2[i];
	if(sw)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 3740
def xorsum(x):
    if x % 4 == 0:
        return(x)
    if x % 4 == 1:
        return(1)
    if x % 4 == 2:
        return(x+1)
    if x % 4 == 3:
        return(0)
    
A, B = map(int,input().split())

if A == 0:
    print(xorsum(B))
else:
    print(xorsum(B)^xorsum(A-1))

Measured memory_bytes: 3060
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
#define endl "\n"
#define fcout cout<<fixed<<setprecision(15)
typedef pair<int, int> P;
//struct edge { int to, cost; };

int dx[8] = { 1,0,0,-1,1,1,-1,-1 };
int dy[8] = { 0,-1,1,0,-1,1,-1,1 };

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

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int modinv2(int a, int mod) {
    return mod_pow(a, mod - 2, mod);
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k, int mod) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= mod;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= mod;
    }
    return x * modinv(y, mod) % mod;
}

signed main() {
    //srand((unsigned)time(NULL));

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

    int a, b;
    int v, w;
    int t;
    cin >> a >> v >> b >> w >> t;
    int cnt;
    if (v <= w) {
        cout << "NO" << endl;
        return 0;
    }
    if (abs(a - b) % abs(v - w) == 0) {
        cnt = abs(a - b) / abs(v - w);
    }
    else cnt = abs(a - b) / abs(v - w) + 1;
    if (cnt <= t) cout << "YES" << endl;
    else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 3676
# Insertion Sort
N = int(input())
A = list(map(int, input().split()))

for i in range(N):
    key = A[i]
    j = i - 1
    while j >= 0 and A[j] > key:
        A[j + 1] = A[j]
        j -= 1
    A[j + 1] = key
    print(" ".join(map(str, A)))


Measured memory_bytes: 5600
#include "bits/stdc++.h"
using namespace std;
typedef long double ld;
int main() {
    ld w,h,x,y;
    cin>>w>>h>>x>>y;
    if(w==2*x&&h==2*y){
        cout<<fixed<<setprecision(10)<<(w*h)/2<<" "<<1;
    }
    else cout<<fixed<<setprecision(10)<<(w*h)/2<<" "<<0;
}

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

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

const string T = "AB";

int N, K;
deque<int> deq;
string s;

int main() {
	cin >> N >> K >> s;
	rep(i, N) deq.pb(s[i] != 'A');

	int f = 0;

	rep(tt, N * 2) {
		if (K == 0) {
			break;
		}
		if (deq[0] == f) {
			deq[0] = f^1;
		} else {
			f ^= 1;
			deq.pop_front();
			deq.push_back(f);
		}
		--K;
	}

	K %= 2;

	if (K) {
		if (deq[0] == f) {
			deq[0] = f^1;
		} else {
			f ^= 1;
			deq.pop_front();
			deq.push_back(f);
		}
	}
	rep(i, N) {
		printf("%c", T[deq[i]^f]);
	}
	puts("");

	return 0;
}

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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;




long yakusu(long a){
    int ans = 1;

    for(int i=2;i<=sqrt(a);i++) {
        int cnt = 0;
        while (a % i == 0) {
            cnt++;
            a /= i;
        }
        ans *= (cnt + 1);
        if(a == 1) break;
    } 
    if (a != 1) ans *= 2;

    return ans;
}


int main(){
    long N;
    cin >> N;
    long ans = 0;

    N--;
    while(N){
        ans += yakusu(N);
        N--;
    }

    cout << ans << endl;

}

/*
    while(N){
        for(long i=1;i*i<N;i++){
            if(i==1) {
                ans++;
                continue;
            }

            if(N%i==0){
                ans = ans+2; // AとBひっくり返せる
            }
        }
        N--;
    }
*/

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

int main() {
    int H, W;
    cin >> H >> W;
    
    char S[H+2][W+2];
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cin >> S[i][j];
            if (S[i][j] == '.') {
                S[i][j] = '0';
            }
        }
    }
    
    // 計算
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            if (S[i][j] == '#') {
                if (S[i-1][j-1] != '#') S[i-1][j-1]++;
                if (S[i-1][j] != '#')   S[i-1][j]++;
                if (S[i-1][j+1] != '#') S[i-1][j+1]++;
                if (S[i][j-1] != '#')   S[i][j-1]++;
                if (S[i][j+1] != '#')   S[i][j+1]++;
                if (S[i+1][j-1] != '#') S[i+1][j-1]++;
                if (S[i+1][j] != '#')   S[i+1][j]++;
                if (S[i+1][j+1] != '#') S[i+1][j+1]++;
            }
        }
    }
    
    // 出力
    for (int i = 1; i <= H; i++) {
        for (int j = 1; j <= W; j++) {
            cout << S[i][j];
        }
        cout << endl;
    }
    cout << endl;
}


Measured memory_bytes: 256
N = int(input())
x=[]
y=[]
for i in range(N):
    xi, yi = map(int,input().split())
    x.append(xi)
    y.append(yi)
    
import itertools
total =0
for a,b in itertools.permutations(range(N), 2):
    len_x = (x[a]-x[b])**2
    len_y = (y[a]-y[b])**2
    length = (len_x+len_y)**0.5
    total+=length / N
print(total)    

Measured memory_bytes: 3064
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int[] a = new int[3];
		for(int i = 0;i<a.length;i++) {
			a[i] = sc.nextInt();
		}
		Arrays.parallelSort(a);
		for(int i = 0;i<a.length;i++) {
			if(i != a.length-1)
				System.out.print(a[i]+" ");
			else System.out.println(a[i]);
		}
	}
}



Measured memory_bytes: 26244
#include<stdio.h>
#include<math.h>
 
 
#define MAX 999999
 
 
int Primes[ MAX + 1 ] ;
 
 
int IsPrime( int n )
{
    if( n < 2 )
    {
        return 0 ;
    }
 
    else if( n == 2 )
    {
        return 1 ;
    }
 
    else if( n % 2 == 0 )
    {
        return 0 ;
    }
 
    else
    {
        int i = 3 ;
        for( ; i <= sqrt( n ) ; i += 2 )
        {
            if( n % i == 0 )
            {
                return 0 ;
            }
        }
    }
 
    return 1 ;
}
 
int main( void )
{
    int i ;
    for( i = 1 ; i <= MAX ; ++i )
    {
        Primes[ i ] += IsPrime( i ) + Primes[ i - 1 ] ;
    }
 
    int N ;
    while( scanf( "%d" ,&N ) != EOF )
    {
        printf( "%d\n" ,Primes[ N ] ) ;
    }
 
    return 0 ;
}


Measured memory_bytes: 5640
package main

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

func solution(n int, p, q []int) int {
	i := dictionaryOrder(p)
	j := dictionaryOrder(q)
	return abs(i, j)
}

func abs(x, y int) int {
	z := x - y
	if z < 0 {
		return z * -1
	}
	return z
}

func dictionaryOrder(nums []int) int {
	var ans int
	l := len(nums)
	for i := 0; i < l; i++ {
		n := nums[i]
		arr := make([]int, len(nums)-i)
		copy(arr, nums[i:])
		a := ascNumber(arr, n) - 1
		if a == 0 {
			ans += 0
		} else {
			ans += a * factorical(l-i-1)
		}
	}
	ans++
	return ans
}

func ascNumber(nums []int, n int) int {
	sort.Ints(nums)
	var i int = 1
	for _, v := range nums {
		if v == n {
			break
		}
		i++
	}
	return i
}

func factorical(n int) int {
	if n == 0 || n == 1 {
		return 1
	}
	return n * factorical(n-1)
}

func main() {
	reader := bufio.NewReaderSize(os.Stdin, 10240*10240)

	n, err := strconv.Atoi(readLine(reader))
	checkError(err)
	p := make([]int, n)
	ss := strings.Split(readLine(reader), " ")
	for i := range ss {
		p[i], err = strconv.Atoi(ss[i])
		checkError(err)
	}
	q := make([]int, n)
	ss = strings.Split(readLine(reader), " ")
	for i := range ss {
		q[i], err = strconv.Atoi(ss[i])
		checkError(err)
	}
	fmt.Println(solution(n, p, q))
}

func readLine(reader *bufio.Reader) string {
	str, _, err := reader.ReadLine()
	if err == io.EOF {
		return ""
	}

	return strings.TrimRight(string(str), "\r\n")
}

func checkError(err error) {
	if err != nil {
		panic(err)
	}
}


Measured memory_bytes: 3968
//https://atcoder.jp/contests/abc159/tasks/abc159_e
#include <bits/stdc++.h>
#if LOCAL
#include "dump.hpp"
#else
#define dump(...)
#endif
using namespace std;
using ll=long long;
const ll LINF = 0x1fffffffffffffff;
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
template<class T>bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1; } return 0;}
template<class T>bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1; } return 0;}
int main() {
#if LOCAL&01
  std::ifstream in("./test/sample-3.in");
  //std::ifstream in("./input.txt");
  std::cin.rdbuf(in.rdbuf());
#else
  cin.tie(0);
  ios::sync_with_stdio(false);
#endif
  ll H,W,K; cin>>H>>W>>K;
  vector<string> shw(H);
  for(auto&& sw:shw){
    cin>>sw;
  }

  vector<vector<ll>> sums(H+1, vector<ll>(W+1));
  FOR(y,1,H+1){
    FOR(x,1,W+1){
      sums[y][x]=sums[y][x-1];
      auto c=shw.at(y-1).at(x-1);
      if(c=='1'){
        sums[y][x]+=1;
      }
    }
  }
  FOR(x,1,W+1){
    FOR(y,1,H+1){
      sums[y][x]+=sums[y-1][x];
    }
  }
  auto getnum = [&](ll x0, ll y0, ll x1, ll y1){
    return sums[y1][x1] - sums[y0-1][x1] - sums[y1][x0-1] + sums[y0-1][x0-1];
  };

  ll bitmax=2<<(H-1-1);
  vector<vector<ll>> ytbl(bitmax);
  FOR(m,0,bitmax){
    ytbl.at(m).push_back(0);
    FOR(j,0,H){
      if(m&(1<<j)){
        ytbl.at(m).push_back(j+1);
      }
    }
    ytbl.at(m).push_back(H);
  }

  ll ans=INT32_MAX;
  FOR(m,0,bitmax){
    const auto& tbl=ytbl[m];
    ll lines =tbl.size()-2;

    ll prev=1;
    FOR(j,1,W+1){
      FOR(k,0,tbl.size()-1){
        auto sty=tbl[k]+1;
        auto edy=tbl[k+1];
        //こえたら線をひく
        ll num = getnum(prev,sty,j,edy);
        if (num>K){
          if(prev==j){
            lines=INT32_MAX;
          }else{
            dump(prev,sty,j,edy,num);
            prev=j;
            ++lines;
          }
          break;
        }
      }
    }
    dump(m, lines);
    chmin(ans,lines);
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}

signed main() {
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	int ans = 1;
	for (int i = 0; i < n;) {
		if (i == 0 && s[i] == t[i]) {
			ans *= 3;
			ans %= inf;
			i++;
		}
		elif(i == 0 && s[i] == s[i + 1] && t[i] == t[i + 1]) {
			ans *= 6;
			ans %= inf;
			i += 2;
		}
		elif(i != 0 && s[i] == t[i]) {
			if (s[i - 1] == t[i - 1]) {
				ans *= 2;
				ans %= inf;
				i++;
			}
			else {
				ans *= 1;
				ans %= inf;
				i++;
			}
		}
		elif(i != 0 && s[i] == s[i + 1] && t[i] == t[i + 1]) {
			if (s[i - 1] == t[i - 1]) {
				ans *= 2;
				ans %= inf;
				i+= 2;
			}
			else {
				ans *= 3;
				ans %= inf;
				i += 2;
			}
		}
	}
	cout << ans % inf << endl;
}


Measured memory_bytes: 256
//R<3S
#include <bits/stdc++.h>
#define FAST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define DECIMAL(n)  std::cout << std::fixed;std::cout << std::setprecision(n);
#define hell 1000000007
#define PI 3.14159265358979323844
#define mp make_pair
#define pb push_back
#define fi first 
#define se second
#define ALL(v) v.begin(), v.end()
#define SORT(v) sort(ALL(v))  
#define REVERSE(v) reverse(ALL(v))
#define endl "\n"
#define maxc(v) max_element(all(v))
#define minc(v) min_element(all(v))
#define GCD(m,n) __gcd(m,n)
#define LCM(m,n) m*(n/GCD(m,n))
#define inputarr(a,n) for(int i=0;i<n;++i) cin>>a[i]
#define initarr(a,n,x) for (int i=0;i<n;++i) a[i]=x
#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define trav(a, x) for(auto& a : x)
#define sz(a) (int)a.size()
#define sl(a) (int)a.length()
#define invect(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.pb(tmp);commands}
#define inset(data,n,commands) for(int i = 0;i<n;i++){int tmp;cin>>tmp;data.insert(tmp);commands}
#define ll long long
#define ld long double 
#define pii std::pair<int, int> 
#define pll std::pair<ll, ll>  
#define vi vector<int>  
#define vvi vector<vi > 
#define vii vector<pii >
#define mii map<int,int>
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl


using namespace std;

void solve()
  {

    int a,b;
    cin>>a>>b;
    int a1=(a*100)/8;
    int a2=(b*100)/10;
    int start=min(a1,a2);
    int flag=0;
    while(start!=99999)
    {
      int a1lo=(start*10)/100;
      int a2lo=(start*8)/100;
      //cout<<a1lo<<a2lo;
      if(a1lo==b&&a2lo==a){cout<<start;flag=1;break;}
      start++;
    }
    if(!flag)cout<<-1;
  }



int main()
{
   FAST
   // #ifndef ONLINE_JUDGE
   //   freopen("input.txt","r",stdin);
   //   freopen("output.txt","w",stdout);
   // #endif
   int t;
   t=1;
   //cin>>t;
   while(t--)
  {
      solve();
  }


   return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i = (l); i < (r); ++i)
using ll = long long;
template<class T,class U>using umap = unordered_map<T,U>;
template<class T>using uset = unordered_set<T>;
template<class T>using max_heap = priority_queue<T>;
template<class T>using min_heap = priority_queue<T, vector<T>, greater<T>>;
template<class T>inline bool Chmax(T&a, const T&b){
  if(b > a){    a = b;    return true;  }
  return false;
}
template<class T>inline bool Chmin(T&a, const T&b){
  if(a > b){    a = b;    return true;  }
  return false;
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  double x; cin >> x;
  if(int(x)%2 == 0)cout << "0.500000000" << endl;
  else cout << fixed << setprecision(10) << double(int(x)/2+1)/x << endl;
  return 0;
}


Measured memory_bytes: 256
fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut iter = s.split_whitespace();
    let a: i32 = iter.next().unwrap().parse().unwrap();
    let b: i32 = iter.next().unwrap().parse().unwrap();
    if a <= 9 && b <= 9 {
        println!("{}", a * b)
    } else {
        println!("-1")
    }
}

Measured memory_bytes: 4352
use std::io;

fn get_line() -> String {
  let mut line = String::new();
  io::stdin()
    .read_line(&mut line)
    .unwrap();
  line
}

fn line_to_vec_i64(line: &str) -> Vec<i64> {
  line
    .trim()
    .split_whitespace()
    .map(|val| { val.parse::<i64>().unwrap() })
    .collect()
}

fn main() {
  loop {
    let v = line_to_vec_i64(&get_line());
    let (h, w) = (v[0], v[1]);
    if h == 0 && w == 0 {
      break;
    }
    else {
      for _ in 0..h {
        println!("{}", "#".repeat(w as usize));
      }
      println!();
    }
  }
}



Measured memory_bytes: 5024