akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define ld long double
#define pb push_back
#define mod 1000000007
#define mk make_pair
#define sz size
#define inf 1e9+5
 
 
int main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    
    ll n;
    cin>>n;
    string str;
    cin>>str;
    vector<char> s;
    s.pb(str[0]);
    for(ll i=1;i<n;i++){
        if(str[i]!=str[i-1]){
            s.pb(str[i]);
        }
    }
    // for(ll i=0;i<s.size();i++)cout<<s[i]<<" ";
    cout<<s.size();


    

    return 0;  
}

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

signed main() {
	int n;
	cin >> n;
	int x=0, y = 0;
	vector<int> v(n);
	rep(i, n) cin >> v[i];
	rep(i, n) {
		int c; cin >> c;
		if (c < v[i]){
			x += v[i];
			y += c;
		}
	}
	cout << x - y << endl;
}


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

typedef long long ll;

int main() {
    int n, k;
    scanf("%d%d", &n, &k);
    ll a = n / k;
    ll b = n / (k / 2) - a;
    if (k & 1) {
       printf("%lld", a * a * a);
       return 0;
    } else {
        printf("%lld",  a * a * a + b * b * b);
        return 0;
    }
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
#define PI acos(-1)

// code starts
typedef pair<int,int> P;

void solve()
{
  int n;
  cin >> n;
  vector<int> k(n);
  vector<int> l(n);
  vector<int> r(n);
  int i,j;
  rep(i,n) cin >> k[i] >> l[i] >> r[i];
  rep(i,n) k[i]--;
  vector<vector<int>> vs(n);
  ll ans = 0;
  rep(i,n)
  {
    vs[k[i]].emplace_back(l[i]-r[i]);
  }
  priority_queue<int,vector<int>,greater<int>> pq;
  rep(i,n)
  {
    rep(j,vs[i].size())
    {
      if(vs[i][j] >= 0)
      {
        pq.push(vs[i][j]);
      }
    }
    while(pq.size() > i+1)
    {
      pq.pop();
    }
  }
  while(!pq.empty())
  {
    ans += pq.top();
    pq.pop();
  }
  for(i=n-1;i>=0;i--)
  {
    rep(j,vs[i].size())
    {
      if(vs[i][j] < 0)
      {
        pq.push(-vs[i][j]);
      }
    }
    while(pq.size() > n-i-1)
    {
      pq.pop();
    }
  }
  while(!pq.empty())
  {
    ans += pq.top();
    pq.pop();
  }
  rep(i,n)
  {
    ans += min(l[i],r[i]);
  }
  cout << ans << "\n";
}

int main()
{
  int t;
  cin >> t;
  int i;
  rep(i,t) solve();
}


Measured memory_bytes: 14448
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		Main m = new Main();
		m.run();
	}
	
	private void run(){
		Scanner scan = new Scanner(System.in);
		int number = scan.nextInt();
		while (number != 0) {
			int[] string = new int[number];
			for (int i = 0; i < number; i++) {
				string[i] = 0;
			}
			string[0] = number;
			System.out.println(string[0]);
			int digit = decrease(string, number);
			while (digit != number) {
				for (int i = 0; i <= digit; i++) {
					System.out.print(string[i]);
					if (i != digit) {
						System.out.print(" ");
					}else {
						System.out.println();
					}
				}
				digit = decrease(string, number);
			}
			
			number = scan.nextInt();
		}
	}
	
	private int decrease(int[] string, int number){
		for (int i = number - 1; i >= 0; i--) {
			if (string[i] > 1) {
				string[i]--;
				if (string[i] == 1) {
					int digit = 0;
					for (int j = 0; j < number; j++) {
						if (string[j] == 0) {
							string[j] = 1;
							digit = j;
							break;
						}
					}
					return digit;
				}else {
					int sum;
					int end = i;
					do {
						sum = 0;
						for (int j = 0; j < end+1; j++) {
							sum += string[j];
						}
						if (sum < number) {
							if (number - sum > string[end]) {
								string[end + 1] = string[end];
							}else {
								string[end + 1] = number - sum;
							}
						}
						end++;
					}while (sum != number);
					for (int p = end; p < number; p++) {
						string[p] = 0;
					}
					return end-1;
				}
			}
		}
		return number;
	}

}

Measured memory_bytes: 36316
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,a,b;
  cin >> n >> a >> b;
  bool check = false;
  for(int i=a;i<=b;i++){
    if(i%n == 0) check = true;
  }
  check ? cout << "OK" << endl : cout << "NG" << endl;
}

Measured memory_bytes: 3592
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <functional>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <cmath>
#include <cstdio>

using namespace std;

typedef long long ll;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)

int main(int argc, char **argv)
{
    ll X;
    cin >> X;

    for(ll i = -1000; i <= 1000; ++i) {
        for(ll j = -1000; j <= 1000; ++j) {
            ll a5 = i * i * i * i * i;
            ll b5 = j * j * j * j * j;
            if (a5 - b5 == X) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
int main (){
  int n,i;
  string s;
  cin>>n>>s;
  int c=0,flag=0;
  for(i=0;i<n-2;i++){
    if(s[i]=='A'){
//cout<<'a';
      if(s[i+1]=='B'&&s[i+2]=='C')
        c++;
    }
  }
  cout<<c;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
typedef pair<int, int> P;
static const int MAX_N = 500000;
static const int INF = 1e9;

int main(){
  int n;
  P A[MAX_N];
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> A[i].first >> A[i].second;
  }
  sort(A, A + n);
  int L = INF;
  for(int i = 1; i < n; i++){
    for(int j = i - 1; j >= 0; j--){
      if((A[i].first - A[j].first) > L) break;
      int d2 = (A[i].first - A[j].first) * (A[i].first - A[j].first) + (A[i].second - A[j].second) * (A[i].second - A[j].second);
      if(d2 < L) L = d2;
    }
  }
  cout << L << endl;
  return 0;
}



Measured memory_bytes: 7000
#include<stdio.h>
char S[999],v[999];main(T,C,i){for(;fgets(S,999,stdin),S[2];puts(T?"no":"yes")){for(T=C=i=0;i<strlen(S);i++)switch(S[i]){case'(':v[C++]=1;break;case'[':v[C++]=2;break;case')':if(!C||v[--C]!=1)goto F;break;case']':if(!C||v[--C]!=2)goto F;break;}if(!C)continue;F:T=1;}exit(0);}

Measured memory_bytes: 0
N = int(input())

import heapq 





def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i,i, cnt])

    if temp!=1:
        arr.append([temp,temp, 1])

    if arr==[]:
        arr.append([n,n,1])

    return arr

# for N in range(1,100000):
# N = 288
# print(N)

heap = factorization(N) 
# print(heap)
# print(heap)
heapq.heapify(heap)
ans = 0

while(heap):
    # print(heap)
    if N == 1:
        break
    sub,prime,cnt = heapq.heappop(heap)
    if N < sub:
        break
    if N % sub == 0:
        N = N // sub
        ans += 1
        if cnt > 0:
            cnt -= 1
            sub *= prime
            heapq.heappush(heap, [sub,prime,cnt])

print(ans)




Measured memory_bytes: 9448
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main {

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

		final int n = sc.nextInt();
		final int x = sc.nextInt();

		int remindx = x;

		List<Integer> mlist = new ArrayList<Integer>();
		for (int i = 0; i < n; i++) {
			mlist.add(sc.nextInt());
		}

		int count = 0;
		for (final int donuts : mlist) {
			remindx = remindx - donuts;
			count++;
		}

		if (remindx == 0) {
			System.out.println(count);
			return;
		}

		Collections.sort(mlist);
		count = count + (remindx / mlist.get(0));

		System.out.println(count);

	}

}


Measured memory_bytes: 22100
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.141592653589793238

int main() {
	int64_t N;
	cin >> N;
	int digit = to_string(N).size();
	if (digit == 1) {
		cout << N << endl;
		return 0;
	}
	string n = to_string((N + 1) / (int64_t)pow(10, digit - 1) * (int64_t)pow(10, digit - 1) - 1);
	int ans = 0;
	rep(i, n.size()) {
		ans += n[i] - '0';
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int N;
  cin >> N;
  vector<int> A(N), B(N), C(N);
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> B[i];
  REP(i, N - 1) cin >> C[i];
  int ans = 0;
  REP(i, N) {
    ans += B[A[i] - 1];
    if(i >= 1 && A[i] - A[i - 1] == 1) ans += C[A[i - 1] - 1];
  }
  cout << ans << endl;
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <assert.h>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;
typedef long long ll;
typedef long double ld;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define sz(x) ((int)(x).size())
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ld> vld;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<ld>> vvd;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;


int main() {
    cout << setprecision(30);
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);

    ll n;
    cin >> n;
    vl a(n + 1);
    vl b(n + 1);
    for (int i = 0; i < n + 1; ++i) {
        cin >> a[i];
    }
    for (int i = 0; i < n; ++i) {
        cin >> b[i];
    }
    ll ans = 0;
    for (int i = 0; i < n; ++i) {
        ll c = min(a[i], b[i]);
        ans += c;
        a[i] -= c;
        b[i] -= c;

        c = min(a[i + 1], b[i]);
        ans += c;
        a[i + 1] -= c;
        b[i] -= c;
    }

    cout << ans << endl;

    return 0;
}


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

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

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

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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

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

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

// ---- ----

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	
	cout << (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d) ? "Yes" : "No") << endl;
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string>
using namespace std;
int n,a,b,c,k,k1;
int main()
{
	cin>>a>>b>>k;
	for(int i=100;i>=1;i--)
	{
		if(a%i==0&&b%i==0)
		{
			k1++;
			if(k1==k)
			{
				cout<<i;
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
int gcd(int a,int b){return b?gcd(b,a%b):a;}

int main(){
    int w,h;
    cin>>h>>w;
    int sy=0,sx=0;
    int gy=h-1,gx=w-1;
    string maze[h];
    rep(i,h){
        cin>>maze[i];
    }
    int dis[h][w];
    for(int i=0;i<h;i++)for(int j=0;j<w;j++) dis[i][j]=INF;

    //bfs
    dis[sy][sx]=0;
    queue<pair<int,int>> q;
    q.push(make_pair(sx,sy));
    while(!q.empty()){
        pair<int,int> now=q.front();//x y
        if(now.first==gx&&now.second==gy) break;
        q.pop();
        for(int i=0;i<4;i++){
            int nx=now.first+dx[i],ny=now.second+dy[i];
            if(0<=nx&&nx<w&&0<=ny&&ny<h&&maze[ny][nx]!='#'&&dis[ny][nx]==INF){
                q.push(make_pair(nx,ny));
                dis[ny][nx]=dis[now.second][now.first]+1;
            }
        }
    }
    int blacks=0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(maze[i][j]=='#') blacks++;
        }
    }
    if(dis[gy][gx]==INF) cout<<-1<<endl;
    else cout<<(h*w-dis[gy][gx]-blacks-1)<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

typedef long long ll;

int abs_val(int a, int b){return (a - b) > 0 ? (a - b) : (b - a);}

int main(){
    int n, a;

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

    printf("%d\n", n * n - a);

    return 0;
}


Measured memory_bytes: 1672
#include <stdio.h>
#include <iostream>
#include <vector>
#include <assert.h>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <memory.h>
#include <time.h>
#include <string.h>
#include <stdlib.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 200001;
int n, k, v[N], BIT[N + 1];
ll s[N];
vector<ll> mp;
void add(int idx, int val) {
	while (idx <= mp.size()) {
		BIT[idx] += val;
		idx += idx&-idx;
	}
}
int get(int idx) {
	int ret = 0;
	while (idx) {
		ret += BIT[idx];
		idx -= idx&-idx;
	}
	return ret;
}
int main()
{
	scanf("%d%d", &n, &k);
	for (int i = 1; i <= n; ++i)
		scanf("%d", v + i);
	++n;
	ll ss = 0;
	for (int i = 0; i < n; ++i) {
		if (v[i] < k)
			ss -= k - v[i];
		else
			ss += v[i] - k;
		s[i] = ss;
		mp.push_back(ss);
	}
	sort(mp.begin(), mp.end());
	mp.resize(unique(mp.begin(), mp.end()) - mp.begin());
	ll res = 0;
	for (int i = n - 1; i >= 0; --i) {
		res += n - i - 1 - get(lower_bound(mp.begin(), mp.end(), s[i]) - mp.begin());
		add(lower_bound(mp.begin(), mp.end(), s[i]) - mp.begin() + 1, 1);
	}
	printf("%lld\n", res);
	return 0;
}

Measured memory_bytes: 5488
n=int(input())
if n%2==0:
    a=n//2+1
else:
    a=n//2+2
def wa(k):
    kai=0
    while k>0:
        kai+=round(k%10)
        k=round((k-round(k%10))/10)
    return kai
ans=10000000000
for i in range(1,a+1):
    b=i
    c=n-i
    if ans>(wa(b)+wa(c)):
        ans=wa(b)+wa(c)
print(ans)

Measured memory_bytes: 3064
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

func abs(x int) int {
	if x > 0 {
		return x
	}
	return -x
}

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

// Sort
type Val struct {
	id, num int
}
type ByNum []Val

func (a ByNum) Len() int           { return len(a) }
func (a ByNum) Less(i, j int) bool { return a[i].num < a[j].num }
func (a ByNum) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	N := sc.nextInt()
	ans := 1
	max := 0
	for i := 1; i <= N; i++ {
		count := 0
		num := i
		for num != 0 {
			num /= 2
			count++
		}
		if max < count {
			max = count
			ans = i
		}
	}

	fmt.Fprintln(wtr, ans)
	wtr.Flush()
}


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

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

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

#define    ll    long long int

int main( )
{
    int n, m;
    cin >> n >> m;
    cout << ( max(0, (n * (n - 1)) / 2) + max(0, (m * (m - 1)) / 2) ) << '\n';
    return 0;
}


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >
# define PQ priority_queue

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvs vector < vs >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);

# define fr(a,b) for(int i = a; i < b; i++)
# define rep(i,a,b) for(int i = a; i < b; i++)

string vow = "aeiou";
int month[] = {-1, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.1415926535897932384626 ;
const ll mod = 1e9 + 7 ;

void solve(){

    float n,x,t;
    cin>>n>>x>>t;
    int ans = ceil(n/x)*t;

    cout << ans;line
    return;

}

int main(){
    fast
    int t=1;
    //cin >> t;
    while(t--){
             solve();
    }

    R 0;
}


Measured memory_bytes: 3708
#include<iostream>
int main(){for(float a,b,c,d,e,f,x,y;;){std::cin>>a>>b>>c>>d>>e>>f;if(std::cin.eof())break;d&&b*d-a*e?(x=f/d-e*(c*d-a*f)/(b*d-a*e)/d,y=b?c/b-a*x/b:f/e-d*x/e):(y=(c*d-a*f)/(b*d-a*e),x=a?c/a-b*y/a:f/d-e*y/d);printf("%.3f %.3f\n",x,y);}}

Measured memory_bytes: 0
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int a, b;
    cin >> a >> b;
    if (a*b % 2 == 0) {
        cout << "Even" << endl;
    } else cout << "Odd" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
vector<long long> fct(0),invfct(0);

long long modpow(long long a,long long n, long long mod){
    long long res = 1;
    while(n>0){
        if ( n & 1 ) res = (res * a) % mod;
        a = (a * a) % mod;
        n >>= 1;
    }
    return res;
}

void fct_input(long long maximum,long long mod){
    fct.resize(maximum+1,-1);
    fct.at(0) = 1;
    fct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        fct.at(i) = x;
    }
 }

void invfct_input(long long maximum,long long mod){
    invfct.resize(maximum+1,-1);
    invfct.at(0) = 1;
    invfct.at(1) = 1;
    long long x = 1;
    for(long long i=2;i<=maximum;i++){
        x = x * i % mod;
        invfct.at(i) = modpow(x,mod - 2,mod);
    }
}

ll nck(ll nn,ll kk){
    return ((invfct.at(kk) * invfct.at(nn-kk) % mod) * fct.at(nn) ) % mod;
}


int main(){
    long long n,k;
    cin >> n >> k;
    fct_input(n,mod);
    invfct_input(n,mod);

    ll ans = 0;
    for(ll i=0;i<=min(n-1,k);i++){
        ans= (ans + (((nck(n,i)*fct.at(n-1)%mod)*invfct.at(i)%mod)*invfct.at(n-i-1)%mod))%mod;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int S = sc.nextInt();
		int W = sc.nextInt();
		if (S < 1 || S   > 100) {
			throw new IllegalArgumentException("不適切な値です");
		}
		else if(W < 1 || W > 100){
			throw new IllegalArgumentException("不適切な値です。");
		}
		if (S <= W){
			System.out.println("unsafe");
		}
		else{
			System.out.println("safe");
		}
	}
}


Measured memory_bytes: 35752
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <stdio.h>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
#include <math.h>
//ceil(a/b)   (a + (b - 1))/ b
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf=1000000007;
const ll mod=1000000007;
const double PI=3.14159265358979323846;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};


int main(){
    int N;
    cin >> N;
    cout << N / 3 << endl;
    
    return 0;
}



Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
#define int long long
using P = pair<int,int>;
const int INF = 1e18;
const int MOD = 1e9+7;
#define put(n) cout<<(n)<<endl
#define rep(i,N) for(int(i)=0;(i)<(N);++(i))
#define all(v) (v).begin() , (v).end()
#define rall(v) (v).rbegin() , (v).rend()
#define pb(n) push_back(n)

signed main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];
    if(N%2) A.push_back(0);

    sort(all(A));

    bool ok = true;
    int ans = 1;

    for(int i=0;i<N;i+=2){
        if(A[i] != A[i+1]) ok = false;
        (ans *= 2) %= MOD;
    }

    if(!ok) ans = 0;
    if(N%2) ans /= 2;

    put(ans);
}


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


ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}


ll divide(ll a, ll b, ll m) {
    a %= m;
    return a * modinv(b, m) % m;
}


ll comb(ll n, ll r, ll m) {
    if (n < 0 or r < 0 or n < r) return 0;
    ll ans = 1;
    for (ll i = n; i > n - r; --i) {
        n %= m;
        ans *= i;
        ans %= m;
    }
    for (ll j = 1; j <= r; ++j) {
        ans = divide(ans, j, m);
    }
    return ans;
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll mod = 1000000007;
    ll n, b;
    cin >> n >> b;
    ll r = n - b;
    for (ll i = 1; i <= b; ++i) {
        if (n == b and i == 1) {
            cout << 1 << endl;
            continue;
        }
        ll cur = 0;
        cur += comb(b - 1, i - 1, mod) % mod * comb(r - 1, i - 2, mod) % mod;
        cur %= mod;
        cur += 2 * comb(b - 1, i - 1, mod) % mod * comb(r - 1, i - 1, mod) % mod;
        cur %= mod;
        cur += comb(b - 1, i - 1, mod) % mod * comb(r - 1, i, mod) % mod;
        cout << cur % mod << "\n";
    }
}


Measured memory_bytes: 3676
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
#include<cmath>

using namespace std;


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

	unsigned long long ans = 0;
	long long ab = b - a;
	++ab;
	if (a % 2 == 0 && b % 2 == 1) {
		ans = (ab / 2) % 2;
	}
	else if (a % 2 == 1 && b % 2 == 0) {
		ab = max(ab - 2, 0ll);
		ans = (ab / 2) % 2;
		ans = ans ^ a ^ b;
	}
	else if (a % 2 == 0 && b % 2 == 0) {
		ab = max(ab - 1, 0ll);
		ans = (ab / 2) % 2;
		ans ^= b;
	}
	else {
		ab = max(ab - 1, 0ll);
		ans = (ab / 2) % 2;
		ans ^= a;
	}

	cout << ans << endl;
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m,tem;
  cin>>n>>m;
  int a[n]={};
  for(int i=0;i<2*m;++i){
    cin>>tem;
    a[tem-1]++;
  }
  for(int i=0;i<n;++i){
    cout<<a[i]<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{

    int i,j,n,h,w,a[1000],b[1000];

    scanf("%d %d %d",&n,&h,&w);

    for(i=0;i<n;i++){
        scanf("%d %d",&a[i],&b[i]);
    }
    j=0;
    for(i=0;i<n;i++){
        if(a[i]>=h&&b[i]>=w){
            j++;
       }
    }

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

    return 0;
}

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

int main(){
  string s;
  
  cin>>s;
  
  int n=s.length();
  
  int i;
  string b="";
  
  for(i=0;i<n;i++){
    if(s[i]=='A'){
      b += "T";
    }
    else if(s[i]=='T'){
      b += "A";
    }
    else if(s[i]=='G'){
      b += "C";
    }
    else if(s[i]=='C'){
      b += "G";
    }
  }
    
    cout << b<< endl;
    return 0;
  }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long int N, M, K, cnt = 0;
  vector<long long int> P_v;
  cin >> N >> K;
  // cin >> N >> M;
  // vector<long long int> p_v(10), k_v(10), x_v(10, 0);
  // vector<vector<long long int>> s_v(10, vector<long long int>(10));
  for (int i = 1; i <= N; i++) {
    long long int point = i;
    if (point >= K) {
      P_v.push_back(0);
    }
    else {
      cnt = 0;
      while (point < K) {
        point *= 2;
        cnt ++;
      }
      P_v.push_back(cnt);
    }
  }
  double P = 0;
  for (int i = 0; i < N; i++) {
    double k = 1;
    for (int t = 0; t < P_v[i]; t++) {
      k /= double(2);
    }
    P += k;
    //P += pow(0.5f, P_v[i]);
    //cout << P_v[i] << endl;
  }
  //cout << P/(float)N << endl;
  printf("%.12f\n", P/(double)N);
  // for (int i = 0; i < M; i++) {
  //   cin >> k;
  //   k_v.at(i) = k;
  //   for (int j = 0; j < k; j++) {
  //     //cout << "sdssd" << endl;
  //     cin >> s_v.at(i).at(j);
  //   }
  // }
  // for (int i = 0; i < M; i++) {
  //   cin >> p_v.at(i); 
  // }
  // x_v[N-1] = -1;
  // for (int i = 0; i < pow(2, N); i++) {
  //   int flag = 0;
  //   x_v[N-1] += 1;
  //   for (int j = N-1; j >= 0; j--) {
  //     //cout << "s" << endl;
  //     if (x_v[j] >= 2) {
  //       x_v[j] = 0;
  //       x_v[j-1] += 1;
  //     }
  //   }
    
  //   for (int j = 0; j < N; j++) {
  //     //printf("%lld ", x_v[j]);
  //   }
  //   //puts("");

  //   for (int j = 0; j < M; j++) {
  //     int sum = 0;
  //     for (int k = 0; k < k_v[j]; k++) {
  //       sum += x_v[s_v[j][k]-1];
  //     }
  //     if (sum % 2 == p_v[j]) {
  //       ;
  //     }
  //     else {
  //       flag = -1;
  //       break;
  //     }
  //   }
  //   if (flag == 0) cnt++;

  // }
  // cout << cnt << endl;
  // f_n = f_{n-1} + f_{n-2}
  // f_0 = 1
  // f_1 = 1
  // f_2 = 2
  // f_3 = 3
  // long long int j = 0;
  // for (int i = 0; i <= N; i++) {
  //   if (a_v[j] == i) {
  //     j++;
  //   }
  //   else {
  //     if (i >= 2) {
  //       f[i] = f[i-1] + f[i-2];
  //     }
  //     else if (i == 1) {
  //       f[i] = f[i-1] + 0;
  //     }
  //     else if (i == 0) {
  //       f[i] = 1;
  //     }

  //   }
  // }
  // for (int i = 0; i <= N; i++) {
  //   //cout << "f" << f[i] << endl;
  // }
  // //cout << "j:" << j << endl;

  // cout << f[N]%1000000007 << endl;
  return 0;
}


Measured memory_bytes: 1400
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18

N, W = map(int, raw_input().split())
DP = [0] + [INF] * 100000
for _ in range(N):
    w, v = map(int, raw_input().split())
    for i in range(v, 100001)[::-1]:
        DP[i] = min(DP[i], DP[i - v] + w)

for i in range(100001)[::-1]:
    if DP[i] <= W:
        print i
        break

Measured memory_bytes: 134252
//666yuchen
#include<bits/stdc++.h>
using namespace std;
string st,st1,st2;
int main()
{
  getline(cin,st);
  getline(cin,st1);
  sort(st.begin(),st.end());
  sort(st1.begin(),st1.end());
  for(int i=st1.size()-1;i>=0;i--)st2=st2+st1[i];
  if(st<st2)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(Console.ReadLine());
            string S = Console.ReadLine();

            if(S.Length <= K){
                Console.WriteLine(S);
            }else{
                Console.WriteLine(S.Substring(0, K) + "...");
            }
            
        }
    }
}


Measured memory_bytes: 27460
from collections import defaultdict

n=int(input())
a=list(map(int,input().split()))
#n=2*pow(10,5)
#a=range(1,pow(10,5)+1)
# dp[i][j]:i番目の数字の中からj個数字を取った時の最大。(i//2)-1<=j<=(i+1)//2
# 求めるのはdp[n][n//2]
dp=defaultdict(lambda:-pow(10,18))
dp[(1,1)]=a[0]
for i in range(2,n+1): #i番目の数字はa[i-1]
      for j in range(i//2-1,(i+1)//2+1):
            if j==1:
                  dp[(i,j)]=max(dp[(i-1,1)],a[i-1])
            elif j==0:
                  dp[(i,j)]=0
            else:
                  dp[(i,j)]=max(dp[(i-2,j-1)]+a[i-1],dp[(i-1,j)])
print(dp[(n,n//2)])

Measured memory_bytes: 131508
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <string>
#include <bitset>
#include <fstream>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
typedef vector<pii> vii;

#define INF 1000000007ll
#define PB push_back
#define MP make_pair
#define X first
#define Y second
#define cil(a,b) ( ((a)%(b) == 0)?((a)/(b)):((a)/(b)+1) )
#define err(x) cerr << #x << " = " << x << endl;
#define SIZE 100010

map<int, int> cnt;
int main() {
   int n;
   scanf("%d", &n);
   for (int i = 0 ; i < n ; ++i) {
      int j;
      scanf("%d", &j);
      ++cnt[j];
   }
   map<int, int>::iterator it = cnt.end();
   --it;
   ll a = 0, b = 0;
   while (a == 0 || b == 0) {
      if (it->Y >= 4) {
         if (a == 0) a = b = it->X;
         else b = it->X;
      }
      else if (it->Y >= 2) {
         if (a == 0) a = it->X;
         else b = it->X;
      }
      if (it == cnt.begin()) break;
      --it;
   }
   printf("%lld\n", 1ll * a * b);
   return 0;
}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define MAXN 100009
#define INF 1000000007
#define mp(x,y) make_pair(x,y)
#define all(v) v.begin(),v.end()
#define pb(x) push_back(x)
#define wr cout<<"----------------"<<endl;
#define ppb() pop_back()
#define tr(ii,c) for(__typeof((c).begin()) ii=(c).begin();ii!=(c).end();ii++)
#define ff first
#define ss second
#define my_little_dodge 46
#define debug(x)  cerr<< #x <<" = "<< x<<endl;

using namespace std;

typedef long long ll;
typedef pair<int,int> PII;

template<class T>bool umin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T>bool umax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
int n;
int ans;
bool od(int x){
	int s=0;
	for(int i=1;i<=x;i++)
		if(x%i==0)
			s++;
	return s==8;
}
int main()
{
    //~ freopen("file.in", "r", stdin);
    scanf("%d",&n);
	for(int i=1;i<=n;i+=2)
		if(od(i))
		ans++;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    int x[n];
    rep(i,n) cin >> x[i];

    int result = 1000000000;

    rep(i,100){
        int cost = 0;
        rep(j,n) cost += (x[j]-i) * (x[j]-i);
        result = min(result, cost);
    }

    cout << result << endl;
}

Measured memory_bytes: 256
x,y = map(int, input().split())
d = {1:300000, 2:200000, 3:100000}
if x == y == 1:
  print(1000000)
  exit()
a = 0
b = 0
if 1 <= x <= 3:
  a = d[x]
if 1 <= y <= 3:
  b = d[y]

print(a+b)

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)

const double eps=(int)1e-9;
const int mod=1e9+7;
const int N=1e5+9;

int32_t main() {
    IOS;
int l,r;
cin>>l>>r;
r=min(r,l+2019);
int ans=2019;
FOR(i,l,r)FOR(j,i+1,r)ans=min(ans,i*j%2019);
cout<<ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
vector<string>vs;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vs.resize(n);
  for(int i=0;i<n;i++){
    cin>>vs[i];
    sort(ALL(vs[i]));
  }
  sort(ALL(vs));
  ll ans=0;
  ll cnt=1;
  for(int i=0;i<n-1;i++){
    cnt=1;
    while(i<n-1&&vs[i]==vs[i+1]){
      i++;
      cnt++;
    }

    ans+=(cnt-1)*(cnt)/2;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 5760
while 1:
    w = int(input())
    if w < 0: break
    s = 1150
    if w > 10:
        if w <= 20: s+= (w-10)*125
        else: s += 1250
    if w > 20:
        if w <= 30: s += (w-20)*140
        else: s += 1400
    if w > 30: s += (w-30)*160;
    print(4280-s)


Measured memory_bytes: 5588
import java.util.*;
public class Main {
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      long[] div = new long[n];
      
      
      for(int i=1;i<n+1;i++){
        for(int j=1;j*i<n+1;j++){
          div[i-1] += i*j;
        }
      }
      
      long ans = 0;
      for(int i=1;i<n+1;i++){
        ans += div[i-1];
      }
      System.out.println(ans);
	}
}

Measured memory_bytes: 106472
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<math.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
	#define repp(i, n) for (int i = (int)(n-1); i >= 0; i--)
	#define long long ll
	using namespace std;
int main() {
	int h, w;
	cin >> h >> w;
	char field[2000][2000];
	rep(i, h) {
		rep(j, w) {
			cin >> field[i][j];
		}
	}

	int L[2000][2000], R[2000][2000], D[2000][2000], U[2000][2000];

	rep(i, h) {
		rep(j, w) {
			if (field[i][j] == '#') {
				L[i][j] = 0;
				U[i][j] = 0;
			}
			else {
				if (j == 0) {
					L[i][j] = 1;
				}
				else if (j > 0) {
					L[i][j] = L[i][j - 1] + 1;
				}
				if (i == 0) {
					U[i][j] = 1;
				}
				else if (i > 0) {
					U[i][j] = U[i - 1][j] + 1;
				}
			}
		}
	}
	repp(i, h) {
		repp(j, w) {
			if (field[i][j] == '#') {
				R[i][j] = 0;
				D[i][j] = 0;
			}
			else {
				if (j == w - 1) {
					R[i][j] = 1;
				}
				else if (j < w - 1) {
					R[i][j] = R[i][j + 1] + 1;
				}
				if (i == h - 1) {
					D[i][j] = 1;
				}
				else if (i < h - 1) {
					D[i][j] = D[i + 1][j] + 1;
				}
			}
		}
	}
	int ans = -1;
	rep(i, h) {
		rep(j, w) {
			ans = max(ans, L[i][j] + R[i][j] + D[i][j] + U[i][j] - 3);
		}
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

int main() {

    int n; cin >> n;

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

    vector<int> q(n);
    for (int i = 0; i < n; ++i) {
        cin >> q[i];
    }

    vector<int> t;
    for (int i = 0; i < n; ++i) {
        t.push_back(i+1);
    }

    int pn = 0;
    int qn = 0;

    int num = 1;

    do {
        if (t == p) {
            pn = num;
        }

        if (t == q) {
            qn = num;
        }

        ++num;
    } while (next_permutation(t.begin(), t.end()));

    cout << abs(pn - qn) << endl;
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int D, T, S;
    cin >> D >> T >> S;
    if(D <= T*S) puts("Yes");
    else puts("No");
    return 0;
}

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

int main(void) {
    double d, t, s;
    cin >> d >> t >> s;
    if (s * t >= d) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a(H);
  for (int i = 0; i < H; i++) {
    cin >> a.at(i);
  }
  
  vector<bool> row(H, false);
  vector<bool> col(W, false); 
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      if (a.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  
  for (int i = 0; i < H; i++) {
    if (row.at(i)) {
      for (int j = 0; j < W; j++) {
        if (col.at(j)) {
          cout << a.at(i).at(j);
        }
      }
      cout << endl;
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  string s;
  int a[26] = {};
  cin >> s;
  REP(i,s.size()){
    a[s[i]%26]++;
  }
  
  REP(i,26){
    if(a[i]%2 != 0){
      cout << "No" << endl;
      return 0;
    }
    
  }
  
  cout << "Yes" << endl;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
using ll = long long;
using ull = unsigned long long;
constexpr int MOD = 1000000007;

int mod(int x){
	return x % MOD;
}

int main(void)
{
    IOS
    int n,k; cin >> n >> k;
    int ml = (n-1)*(n-2) / 2;
    if (ml < k) {
        cout << -1 << endl;
        return 0;
    } else {
        int l = ml-k;
        cout << n-1 + l << endl;
        FOR(i,1,n) cout << 1 <<" "<< i+1 << endl;

        int i = 2;
        int j = 3;
        while(l > 0) {
            cout << i <<" "<< j << endl;
            j++;
            if (j > n) {
                i++;
                j = i+1;
            } 
            l--;
        }
    }


    return 0;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	nums := make([]int, n)

	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}

	count := 0
	flag := true

	for flag {
		for i := 0; i < n; i++ {
			if nums[i] % 2 == 0 {
				nums[i] /= 2
			} else {
				flag = false
			}
		}
		if flag {
			count++
		}
	}

	fmt.Println(count)
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(lint (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
const lint MOD =1000000007;
const lint MAX = 1000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
typedef map<lint,lint> M;
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    } 

    vector<lint> sieve(lint n) {
    vector<lint> res(n);
    iota(res.begin(), res.end(), 0);
  for (lint i = 2; i*i < n; ++i) {
    if (res[i] < i) continue;
    for (int j = i*i; j < n; j += i)
      if (res[j] == j) res[j] = i;
  }
  return res;
}
    vector<lint> factor(int n, const std::vector<lint>& min_factor) {
  // min_factor は sieve() で得られたものとする
  vector<lint> res;
  if(n==1)res.push_back(-1);
  while (n > 1) {
    res.push_back(min_factor[n]);
    n /= min_factor[n];
    // 割った後の値についても素因数を知っているので順次求まる
  }
  return res;
}
  int main(){
      lint n;
      cin>>n;
      lint a[n];
      rep(i,n)cin>>a[i];
      lint gc=a[0];
      rep(i,n-1)gc=gcd(gc,a[i+1]);
      vector<lint> p;
     p=sieve(1000005);
     vector<lint> x;
     x=factor(n,p);
     M m;
     rep(i,n){
         x=factor(a[i],p);
         rep(i,x.size()-1){
             if(x[i]==x[i+1])x[i]=0;
         }
         rep(i,x.size())m[x[i]]++;
     }
     bool f=true;
     for(auto g:m){
         if(g.first==0||g.first==-1)continue;
         if(g.second>1){
             f=false;
             break;
         }
     }
     if(f)cout<<"pairwise coprime"<<endl;
     else if(gc==1)cout<<"setwise coprime"<<endl;
     else cout<<"not coprime"<<endl;
  }
      

Measured memory_bytes: 23564
#include <iostream>
#include <cassert>
#include <set>

template <class T> inline void chmax(T &a, const T &b) {
  if (a < b)
    a = b;
}

int main()
{
  std::string S;
  std::cin >> S;
  assert(1 <= S.size() and S.size() <= 10);

  std::set<char> ACGT({'A', 'C', 'G', 'T'});
  bool onFlag = false;
  int result = 0;
  int count = 0;
  for (auto c : S) {
    if (onFlag) {
      if (ACGT.find(c) != ACGT.end()) {
        ++count;
      } else {
        chmax(result, count);
        count = 0;
        onFlag = false;
      }
    } else {
      assert(not onFlag);
      if (ACGT.find(c) != ACGT.end()) {
        onFlag = true;
        count = 1;
      }
    }
  }
  if (onFlag)
    chmax(result, count);
  std::cout << result << std::endl;

  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,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
typedef long long ll;
int main(){
    int N,cpy;
    cin >> N;
    cpy = N;
    int sum = 0;
    while(cpy > 0){
        sum += cpy%10;
        cpy /= 10;
    }
    if(N%sum == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int solve(int , int );
int n,A[20];	  

int main(){
  int i,q;
  int m[200];

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

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&m[i]);
  }

  for(i = 0; i < q; i++){
    if(solve(0,m[i]) == 0) printf("no\n");
    else printf("yes\n");
  }

  return 0;
}

int solve(int i, int m){
  int v,k;

  if(m == 0) return 1;
  if(i >= n) return 0;

  v = solve(i+1,m);
  k = solve(i+1,m-A[i]);
  
  if(v == 0 && k == 0) return 0;
  else return 1;
}
    



Measured memory_bytes: 2108
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define pi 3.14159265358979323846
#define INF 100000000000000000

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

int main(){
    ll N,W;cin>>N>>W;
    vector<ll> w(N),v(N);

    for(ll i=0;i<N;i++){
        cin>>w[i]>>v[i];
    }

    vector<vector<ll>> dp(110,vector<ll>(100010,0));//i-1個目において商品の合計値がsum以下での、最大の価値

    for(ll i=0;i<=N-1;i++){//i個の商品の選択肢が与えられている時
        for(ll sum=0;sum<=W;sum++){//商品の重さがsum以下の時　　の最大の価値を出したい

            if(sum-w[i]>=0) chmax(dp[i+1][sum],dp[i][sum-w[i]]+v[i]);//i番目を選ぶときの価値のmaxを更新(2次元表を考えると分かる)
            chmax(dp[i+1][sum],dp[i][sum]);//i番目を選ばないときの価値のmaxを更新
        }
    }

    cout<<dp[N][W]<<endl;
	return 0;
}

Measured memory_bytes: 87424