akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//namespace mp = boost::multiprecision;

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<int> &o) {
    int a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

void print(vector<vector<ll>> &dp) {
    for (auto &l : dp) {
        for (ll a : l) cout << a << ' ';
        cout << endl;
    }
}

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

    if (n == k) {
        cout << 0 << endl;
        ret();
    }

    vector<ll> g(n);
    rep(i, n) cin >> g[i];

    vector<vector<ll>> dp(n, vector<ll>(n, -1));

    rep(i, n) {
        rep(j, n) {
            // ｊをi番目として採用
            if (j == 0) {
                dp[i][j] = g[i];
            } else {
                rep(l, i) {
                    // lをj-1番目として使う
                    ll prev = dp[l][j - 1];
                    if (prev == -1) continue;
                    ll now = prev + max(g[i] - g[l], 0ll);
                    if (dp[i][j] == -1) dp[i][j] = now;
                    else
                        cmin(dp[i][j], now);
                }
            }
        }
    }

//    print(dp);

    int ai = n - k - 1;
    ll ans = INF;
    rep(i, n) {
        for (int ki = ai; ki < n; ki++) {
            if (dp[i][ki] == -1) continue;
            cmin(ans, dp[i][ki]);
        }
    }

    assert(ans != INF);
    assert(ans != -1);

    cout << ans << endl;

}


Measured memory_bytes: 4364
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int64_t S; cin>>S;

    int64_t x1=0,y1=0,x2=1,y2=1e9,x,y;
    // S=1e9*x-y
    x=S/y2+(S%y2>0);
    if(S%y2) y=y2-S%y2;
    else y=0;

    cout<<x1<<" "<<y1<<" "<<x2<<" "<<y2<<" "<<x<<" "<<y<<endl;
    cerr<<abs(x*y2-x2*y)<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

ll gcd(ll a, ll b) {
	if (b == 0) { return a; }
	if (a < b) { return gcd(b, a); }
	return gcd(b, a%b);
}

ll lcm(ll a, ll b) {
	return a / gcd(a, b) *b;
}

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};


///////////////////////////




int main() {

	ll N;
	cin >> N;
	cout << 180 * (N - 2);

	system("PAUSE");

}


Measured memory_bytes: 504
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <sstream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <bitset>

using namespace std;
#define LL long long
#define pb push_back
#define mk make_pair
#define fi first
#define se second
#define pill pair<int, int>
#define mst(a, b)	memset(a, b, sizeof a)
#define REP(i, x, n)	for(int i = x; i <= n; ++i)
const int MOD = 1e9 + 7;
const int qq = 1e5 + 10;
const LL INF = 1e9 + 10;
map<int, int> mp;

int main(){
	int n;	scanf("%d", &n);
	for(int i = 0; i < n; ++i) {
		int a;	scanf("%d", &a);
		mp[a]++;
	}
	int m;	scanf("%d", &m);
	bool f = true;
	for(int i = 0; i < m; ++i) {
		int a;	scanf("%d", &a);
		if(mp[a] > 0)	mp[a]--;
		else	f = false;
	}
	if(f)	puts("YES");
	else	puts("NO");
	return 0;
}

Measured memory_bytes: 9728
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s,ans;
    cin >> s;
    int n = s.size();
    for(int i=0;i<n;i++){
        if(s.at(i)=='0') ans.push_back('0');
        else if(s.at(i) == '1') ans.push_back('1');
        else if(ans.size()) ans.pop_back();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define DEBUG
#ifdef DEBUG
#define debug_printf printf
#else
#define debug_printf 1 ? 0 : printf
#endif

using namespace std;
typedef long long int ll;
typedef vector<ll> Vl;
typedef vector<int> Vi;
typedef pair<int, int> Pi;

#define BASE  (1000000000 + 7)
#define MAX_N (1000000000)
#define MAX_M (100000)

int N, M;
int X[MAX_M + 1];
ll A[3] = {1, 3, 1};
ll P[3][3] = {
  {2, 1, 0},
  {3, 1, 2},
  {1, 0, 1}
}, Q[3][3] = {
  {1, 1, 0},
  {0, 1, 2},
  {0, 0, 1}
}, R[3][3];

void mat_print3x3(ll a[3][3]) {
#ifdef DEBUG
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      debug_printf("%lld ", a[i][j]);
    }
    debug_printf("\n");
  }
#endif
}

void mat_copy3x3(ll a[3][3], ll b[3][3]) {
  for (int i = 0; i < 3; i++)
    for (int j = 0; j < 3; j++) a[i][j] = b[i][j];
}

void mat_prod3x3(ll a[3][3], ll b[3][3], ll c[3][3]) {
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      a[i][j] = 0;
      for (int k = 0; k < 3; k++) a[i][j] = (a[i][j] + b[i][k] * c[k][j]) % BASE;
    }
  }
}

void mat_pow3x3(ll a[3][3], ll b[3][3], ll n) {
  if (n == 0) {
    for (int i = 0; i < 3; i++)
      for (int j = 0; j < 3; j++) a[i][j] = (i == j)? 1: 0;
  } else {
    ll c[3][3];
    mat_pow3x3(c, b, n / 2);
    mat_prod3x3(a, c, c);
    if (n % 2 == 1) {
      mat_copy3x3(c, a);
      mat_prod3x3(a, b, c);
    }
  }
}

void solve() {
  mat_pow3x3(R, P, X[0] - 1);
  for (int i = 1; i <= M; i++) {
    ll s[3][3], t[3][3];
    mat_prod3x3(s, R, Q);
    mat_pow3x3(t, P, X[i] - X[i - 1] - 1);
    mat_prod3x3(R, s, t);
  }

  ll ans = 0;
  for (int i = 0; i < 3; i++) ans = (ans + R[0][i] * A[i]) % BASE;

  printf("%lld\n", ans);
}

int main() {
  cin >> N >> M;
  for (int i = 0; i < M; i++) cin >> X[i];
  X[M] = N;

  solve();

  return 0;
}


Measured memory_bytes: 640
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define rpe(i,r,l) for(int i=(r);i>=(l);--i)
#define rpp(i,x,e,head) for(int i=head[x];~i;i=e[i].next)
#define dyes cerr<<"yes"<<endl
#define dbg(x) cerr<<#x<<"="<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define pts puts("")
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
inline int read(){
    int f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
inline ll readll(){
    ll f=1,x=0;char ch;
    do{ch=getchar();if(ch=='-')f=-1LL;}while(ch<'0'||ch>'9');
    do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
    return f*x;
}
template <class T> inline void chmax(T &a,T b){if(a<b) a=b;}
template <class T> inline void chmin(T &a,T b){if(a>b) a=b;}
inline void swap(int &a,int &b){int c=a;a=b;b=c;}
using namespace std;
#define mst(a,val) memset(a,val,sizeof(a))
#define pii pair<int,int>
#define piii pair<int,pair<int,int> >
#define mp(i,j) make_pair(i,j)
#define fi first
#define sc second
#define inf (0x3f3f3f3f)
#define infl (0x3f3f3f3f3f3f3f3fLL)
#define forvec(i,j) for(vector<int>::iterator i=j.begin();i!=j.end();++i)
#define forvecv(i,j) for(vector<int>::iterator i=--j.end();i>=j.begin();--i)
//=====================head end======================//
const int N=1010;
int n,a[N],q[N],qn;
vector<int> ans;
int main(){
    int i,j;long long s1=0,s2=0;
    n=read();
    for(i=1;i<=n;++i) a[i]=read();
    for(i=j=1;i<=n;++i)if(a[i]>a[j])j=i;
    if(a[j]<=0){
	printf("%d\n",a[j]);
	printf("%d\n",n-1);
	for(i=n;i>j;--i)printf("%d\n",i);
	for(i=1;i<j;++i)puts("1");
	return 0;
    }
    for(i=1;i<=n;++i)if(a[i]>0)(i&1?s1:s2)+=a[i];
    printf("%lld\n",max(s1,s2));
    for(i=s1>s2?1:2;i<=n;i+=2)if(a[i]>0)q[++qn]=i;
    while(q[1]>1){ans.push_back(1);for(i=1;i<=qn;++i)--q[i];--n;}
    while(q[qn]<n)ans.push_back(n--);
    while(qn>1)	{
	while(q[2]>3){
	    ans.push_back(3);
	    for(i=2;i<=qn;++i)q[i]-=2;
	}
	ans.push_back(2);
	for(i=1;i<qn;++i)q[i]=q[i+1]-2;--qn;
    }
    printf("%d\n",ans.size());
    for(i=0;i<ans.size();++i)printf("%d\n",ans[i]);
    return 0;
}


Measured memory_bytes: 256
<?php

fscanf(STDIN, "%d %d", $n, $m);

$m_arr = array_fill(0, $m, 0);

for ($i = 0; $i < $n; ++$i) {
    $inputs = explode(' ', trim(fgets(STDIN)));

    $k = $inputs[0];

    for ($j = 1; $j <= $k; ++$j) {

        ++$m_arr[$inputs[$j] - 1];
    }
}

$count = 0;
for ($i = 0; $i < $m; ++$i) {
    if ($m_arr[$i] === $n) {
        ++$count;
    }
}

echo $count;



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

const int N = 100050;
const int mod = 1000000007;

int dp[N];
int sum[N];


int main()
{
    int n,k,v;
    scanf("%d %d",&n,&k);
    dp[0]=1;
    for(int i=1; i<=n; i++)
    {
        scanf("%d",&v);
        sum[0]=dp[0];
        for(int j=1; j<=k; j++)
        {
            sum[j]=sum[j-1]+dp[j];
            sum[j]%=mod;
        }
        for(int j=k; j>=0; j--)
        {
            int r=j,l=max(0,j-v);
            int add=sum[r];
            if(l>0) add-=sum[l-1];
            add+=mod;
            add%=mod;
            dp[j]=add;
        }
    }
    printf("%d\n",dp[k]);



}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
int main(){
    ll N;
    cin >> N;

    for(ll i=sqrt(N);i>=1;i--){
        if(N%i == 0){
            cout << (i-1)+(N/i-1) << endl;
            return 0;
        }
    }

}

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

int main(){
  ll n,m,v,p; cin >> n >> m >> v >> p;
  vector<ll> a(n);
  vector<ll> ruiseki(n);
  ll tmp;//cin >> tmp;
  //a.at(0) = tmp;
  //ruiseki.at(0) = tmp;
  for(ll i=0; i<n; i++){
    cin >> tmp;
    a.at(i) = tmp;
    //ruiseki.at(i) = ruiseki.at(i-1) + tmp; 
  }
  sort(a.begin(),a.end(),greater<ll>());
  ruiseki.at(0) = a.at(0);
  for(ll i=1; i<n; i++){
    ruiseki.at(i) = a.at(i) + ruiseki.at(i-1);
  } 
  ll vn = (n-v)*m;
  //ll cum = 0;
  ll ans = 0;
  ll ruiseki_p;
  if(1<p){ruiseki_p = ruiseki.at(p-2);}
  else{ruiseki_p = 0;}
  for(int j=1; j<=n-p; j++){
    if(a.at(p+j-1)+m<a.at(p-1)){}
    else{
      ll R = (ruiseki.at(p+j-2) - ruiseki_p) - a.at(p+j-1)*j;
      if(R<=vn)ans++;
    }
  }
  cout << p+ans << endl;
}

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

#define endl "\n"
#define ll long long int
#define vi vector<int>
#define vll vector<ll>
#define vvi vector < vi >
#define pii pair<int,int>
#define pll pair<long long, long long>
#define MOD 1000000007
#define INF 1000000000000000001;
#define all(c) c.begin(),c.end()
#define mp(x,y) make_pair(x,y) 
#define mem(a,val) memset(a,val,sizeof(a))
#define f first
#define s second
 
int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);

	ll n,k;
	cin>>n>>k;
	ll arr[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>arr[i];
	}

	sort(arr,arr+n);

	ll sum=0;
	for (int i = 0; i < n-k ; ++i)
	{
		sum+=arr[i];
	}

	cout<<sum;

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	int N, M;
	cin >> N >> M;
	vector<vector<ll>> ab(N, vector<ll>(2)); // ab[i] ... {Ai, Bi};
	rep(i, N) {
		cin >> ab[i][0] >> ab[i][1];
	}

	// 価格順にsort
	sort(ab.begin(), ab.end());

	ll ans = 0;
	ll cnt = 0;
	for(int i=0; i<N; i++) {
		//cout << "i " << i << ' ' << ab[i][0] << ' ' << ab[i][1] << endl;
		if(ab[i][1] > M-cnt ) {
			/* 必要な本数のみ買う */
			ans += (M-cnt) * ab[i][0];
			cnt += (M-cnt);
			break;
		} else {
			/* 買えるだけ買う */
			ans += ab[i][1] * ab[i][0];
			cnt += ab[i][1];
		}
	}

	cout << ans << endl;

	return 0;
}

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

int main(){
	long int a,b,k;
	long int max = 1000000000000;
	if(scanf("%ld %ld %ld",&a,&b,&k)==EOF){return 0;}
	if(a<0 || max < a){return 0;}
	if(b<0 || max < b){return 0;}
	if(k<0 || max < k){return 0;}
	
	if(k>a+b){a = 0; b = 0;}
	else if(k > a){ b = b-(k-a); a = 0;}
	else {a = a-k;}
	
	printf("%ld %ld\n",a,b);
	return 0;
}

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




typedef long long ll;
#define PI 3.14159265359
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define _GLIBCXX_DEBAC
/*map<Keyの型, Valueの型> 変数名;
queue<型> 変数名;
priority_queue<型> 変数名;
priority_queue<型, vector<型>, greater<型>> 変数名;*/
//copy(v1.begin(), v1.end(), back_inserter(v2));
using namespace std;

ll gcd(ll a, ll b) {
	ll c;
	if (a < b) {
		c = a; a = b; b = c;
	}
	while (b != 0) {
		c = a % b; a = b; b = c;
	}
	return a;
}

ll lcm(ll a, ll b) {
	ll c;
	c = a * b / gcd(a, b);
	return c;
}

int sort_greater(int m,int n) {
	vector<int> a(m);
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(),greater<int>());
	for (int i = 0; i < n; i++) {
		cout << a[i];
	}
		return 0;
}

int bubblesort(int a[], int n) {
	int sw = 0;
	bool flag = 1;
	for (int i = 0; flag; i++) {
		flag = 0;
		for (int j = n - 1; j >= i + 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				flag = 1;
				sw += 1;
			}
		}
	}
	return sw;
}

int a_z()
{
	for (int i = 0; i <= ('Z' - 'A'); i++) {
		cout << (char)('A' + i);
	}
	return 0;
}

int selecttionsort(int a[], int n) {
	int t,sw = 0, minj;
	for (int i = 0; i < n - 1; i++) {
		minj = i;
		for (int j = 0; j < n - 1; j++) {
			if (a[j] < a[minj]) {
				minj = j;
			}
		}
		t = a[i]; a[i] = a[minj]; a[minj] = t;
		if (i != minj) sw += 1;

	}
	return sw;
}

bool is_prime(int x) {
	if (x <= 1) return false;
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0) return false;
	}
	return true;
}

const ll mod = 1000000007;
struct mint {
	ll x;
	mint(ll x = 0):x(x%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		res -= a;
	}
	mint operator*(const mint a)const {
		mint res(*this);
		return res *= a;
	}
};

map<string, int> memo;

using P=pair<int, int>;




/*void dfs(int v, int p = -1) {
	for (int u : to[v]) {
		if (u == p) continue;
		ans[u] += ans[v];
		dfs(u, v);
	}
}*/


int main() {
	ll n;
	cin >> n;
	vector<ll> a(n,0),b(n,0);
	rep(i, n - 1) cin >> a[i];
	rep(i, n-1) {
		b[a[i] - 1]++;
	}
	rep(i, n)cout << b[i] << endl;
	return 0;
}










Measured memory_bytes: 6424
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)

	sum := 0.0
	for i := 0; i < n; i++ {
		a := getNextFloat64(scanner)
		sum += 1 / a
	}

	fmt.Fprintln(writer, 1.0/sum)
	writer.Flush()
}


Measured memory_bytes: 640
#-------------------------------------------------------------------------------
#関数定義
def f(a,d,T):
    try:
        return T[d+1:].index(a)+(d+1)
    except ValueError:
        return len(T)

def g(a,d,T):
    try:
        return (d-1)-T[d-1::-1].index(a)
    except ValueError:
        return 0
#-------------------------------------------------------------------------------
#インポート
from math import inf
from random import random,randint
import time
from copy import copy
#-------------------------------------------------------------------------------
#定数
TIME_LIMIT=1.80 #ループの時間制限
PROB=0.001 #突然変異の確率  
A=26 #アルファベットの数
START=time.time()
C_MIN,C_MAX=1,10
#-------------------------------------------------------------------------------
#読み込み部
D=int(input())

C=[0]+list(map(int,input().split())) #減る満足度のベース
S=[0]*(D+1) #S[d][i] :(d+1)日目にコンテストiを開催した時の満足度

for i in range(1,D+1):
    S[i]=[0]+list(map(int,input().split()))           
#-------------------------------------------------------------------------------
#貪欲部
L=[0]*(A+1)
T=[0]
for d in range(1,D+1):
    Y=-inf
    E=0
    for a in range(1,A+1):
        X=S[d][a]
        for s in range(1,A+1):
            if a!=s:
                X-=C[s]*(d-L[s])

        if X>Y:
            Y=X
            E=a
    L[E]=d
    T.append(E)
#-------------------------------------------------------------------------------
#調節部
while time.time()-START<=TIME_LIMIT:
    K=randint(C_MIN,C_MAX)
    e=randint(1,D)

    U=copy(T)
    X=0
    for d in range(e,min(e+K,D+1)):
        p=T[d]
        q=randint(1,A)
        Y=(d-g(p,d,T))*(f(p,d,T)-d)
        Z=(d-g(q,d,T))*(f(q,d,T)-d)
        X+=(S[d][q]-S[d][p])+Z*C[q]-Y*C[p]
        
    if X>0 or random()<PROB:
        T[d]=q
    else:
        T=copy(U)

for i in range(1,D+1):
    print(T[i])


Measured memory_bytes: 96372
// Shift-JIS（シフトジス）

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

int gcd(int a, int b)
{
    if (a < b)
    {
        a ^= b;
        b ^= a;
        a ^= b;
    }

    return b ? gcd(b, a % b) : a;
}

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

int main()
{
    string S, T;
    cin >> S >> T;
    bool f = false;
    for (int i = 0; i < S.size(); i++)
    {
        rotate(S.begin(), S.begin() + 1, S.end());
        if (S == T) f = true;
    }
    if (f) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
typedef unsigned long long ull;
ull a[105];
ull gcd(ull x,ull y){
	if(x%y==0) return y;
	return gcd(y,x%y);
}
main(){
	int n;scanf("%d",&n);
	for(register int i=1;i<=n;i++)
		scanf("%llu",&a[i]);
	for(register int i=2;i<=n;i++){
		a[i]=a[i]/gcd(a[i],a[i-1])*a[i-1];
	}
	printf("%llu\n",a[n]);
	return 0;
}

Measured memory_bytes: 128
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1}) = map(parseInt,x)

function main()
	n = readline() |> parseInt
	k = 10^9
	f = 0
	s = 0
	for i in 1:n
		p,q = readline() |> split |> parseMap
		s += p
		if p>q
			k = min(k,q)
			f = 1
		end
	end
	println(f==0?0:s-k)
end
main()


Measured memory_bytes: 124100
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int n;
        int[] h;

        Scanner sc = new Scanner(System.in);
        n = Integer.parseInt(sc.nextLine());
        h = Arrays.stream(sc.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        int count = 0;
        int ans = 0;
        for (int i = 0; i < n - 1; i++) {
            if (h[i] >= h[i + 1]) {
                count++;
            } else {
                if (ans < count) ans = count;
                count = 0;
            }

            if (i == n - 2) {
                if (ans < count) ans = count;
            }
        }
        System.out.println(ans);
    }
}

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

int main(){
  int a[3],max=0,tot=0;
  for(int i=0;i<3;i++){
    cin >> a[i];
    if(max<a[i])max=a[i];
  }
  for(int i=0;i<3;i++){
    tot += max-a[i];
  }
  if(tot%2==0){
    cout << tot/2 << endl;
  }
  else{
    cout << tot/2 + 2 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
ll n;cin >> n;
ll k = n;
if(n==1) {cout << 0;return 0;}
int j = 0;
int j1 = sqrt(k);
vector<int>a(j1+1,0);
for(ll i = 2;i<=sqrt(k);i++){
  if(n%i==0){
    n = n/i;
    a[i]++;
    i--;
  }
}
//for(int i = 0;i<sqrt(k);i++){
 // cout << a[i] <<' ';
//}
for(ll i = 2;i<=sqrt(k);i++){
  ll temp = 1;
  while(a[i]>=0){
    a[i] = a[i]-temp;
    temp ++;j++;
  }
j--;
}
if(n>sqrt(k))j++;
cout << j <<endl;
return 0;
}

Measured memory_bytes: 7284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(ll i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0,cnt=0;
const ll MAX=200000;
const ll MOD=1000000007;
void Main(){
    string L;cin>>L;
    ll n=L.size();
    vector<ll> pow2(MAX),pow3(MAX);
    pow2[0]=1;
    pow3[0]=1;
    For(i,1,MAX){
        pow2[i]=pow2[i-1]*2%MOD;
        pow3[i]=pow3[i-1]*3%MOD;
    }
    For(i,0,n){
        if(L[i]=='1'){
            ans+=(pow3[n-1-i]*pow2[cnt])%MOD;
            ans%=MOD;
            cnt++;
        }
    }
    ans+=pow2[cnt]%MOD;
    cout<<ans%MOD<<endl;
}
int main(){
    Main();
    return 0;
}

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

int main() {
 int n;
 while (cin >> n, n) {
  vector<int> v(n);
  for (int i = 0; i < n; i++) {
    cin >> v[i];
  }
  sort(v.begin(), v.end());
  long long cnt = 0;
  for (int i = 0; i < n - 1; i++) {
    cnt += v[i] * (n - 1 - i);
  }
  cout << cnt << endl;
 }
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define mem(x,v) memset(x,v,sizeof(x))
#define gc getchar
#define pc putchar
#define fi first
#define queue QQQ
#define se second
#define debug(x) cout << #x" = " << x << endl;
#define pp(x,y) cout << "pp: " << x << " " << y << endl;
#define rank __RAnK
inline ll read(){
	register ll x=0,f=1;register char c=gc();
	for(;!isdigit(c);c=gc())if(c=='-')f=-1;
	for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
	return x*f;
}
#define rd read
void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
void writeln(ll x){write(x);puts("");}
const int maxn = 100005;
multiset<int> s[maxn];
map<pii,int> mp;
pii q[maxn*2];
int front,rear,fa[maxn],n;
inline int find(int x){
	return fa[x] == x?x : fa[x] = find(fa[x]);
}
int main(){
	n = rd();
	Rep(i,1,n) fa[i] = i;
	front = rear = 0;
	Rep(i,1,2*n-2){
		int x,y;
		x = rd(),y = rd();
		s[x] . insert(y);
		s[y] . insert(x);
		mp[make_pair(x,y)]++;
		mp[make_pair(y,x)]++;
		if(mp[make_pair(x,y)]==2) q[rear++] = make_pair(x,y);
	}
	multiset<int>::iterator it;
	while(front < rear){
		int x = q[front].fi,y = q[front].se;front++;
		x = find(x),y = find(y);
		if(x==y) continue;
		s[x] . erase(y);
		s[y] . erase(x);
		if(s[x] . size() < s[y] . size()) swap(x,y);
		for(it = s[y].begin();it != s[y].end();it++){
			int i=*it;
			s[i].erase(y);
			s[i].insert(x);
			++mp[pii(i,x)];
			++mp[pii(x,i)];
			if(mp[pii(x,i)] == 2) q[rear++] = pii(x,i);
			s[x] . insert(i);
		}
		fa[y] = x;
		s[y].clear();
	}
	Rep(i,1,n) if(find(i) != find(1)){
		puts("NO");
		return 0;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 58496
W,H,x,y = map(float, input().split())
c_w,c_h,other = W/2,H/2,0

if c_h==y and c_w==x:
  other = 1
  print('%f %d'%(W*H/2,other))
  
elif c_h==y or c_w==x:
  if c_w==x: print('%f %d'%(min(W-x, x)*H,other))
  elif c_h==y: print('%f %d'%(min(H-y, y)*W,other))
    
else: 
  print('%f %d'%(W*H/2,other))
 
#長方形を区切る二つの点の座標を求める
'''
else:
  y_ = (c_h-y)/(c_w-x)
  #縦型台形
  if abs(y_*c_w)>=c_h:
    point_ = [[-c_h/y_+c_h,0],[c_h/y_+c_h,c_h*2]]
    S = (point_[0][0]+point_[1][0])*abs((point_[1][1]-point_[0][1]))/2
    print('%f %d'%(S,other))
  elif abs(y_*c_w)<c_h:
    point_ = [[0,-c_w*y_+c_w],[c_w*2,c_w*y_+c_w]]
    S = (point_[0][1]+point_[1][1])*abs((point_[1][0]-point_[0][0]))/2
    print('%f %d'%(S,other))
'''


Measured memory_bytes: 3064
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define SORTD(a) sort(a.rbegin(), a.rend());
#define ll long long
#define INF 1000000000000000000
#define INT_MAX 2147483647

#include <iostream>
#include <vector>
#include <cmath>
#include <numeric>
#include <algorithm>
#include <queue>
#include <set>
#include <utility>
#include <ios>
#include <iomanip>

using namespace std;

int main(){
    int N,L;
    cin >> N >> L;
    vector<string> S(N);
    REP(i, N)cin >> S[i];
    SORT(S);
    string ans="";
    REP(i, N)ans+=S[i];
    cout << ans << endl;
}

Measured memory_bytes: 504
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
ll n,m,f[110],mo=1e9+7,x[110],y[110];
char sa[110],sb[110];
int main()
{
	ll i,s,a,b,j,k;
	scanf("%lld",&n);
	scanf(" %s",sa);scanf(" %s",sb);
	for(i=n;i>=1;i--)sa[i]=sa[i-1],sb[i]=sb[i-1];sa[i]=sb[i]=0;
	for(i=1;i<=n;i++)if(sa[i]!=sa[i-1])x[i]=1;
	for(i=1;i<=n;i++)
	{
		if(sb[i]!=sb[i-1])
		{
			if(sa[i]!=sb[i])
			{
				if(x[i])
				{
					if(sa[i-1]==sb[i-1])x[i]=2;
					else x[i]=3;
				}
				else x[i]=1;
			}
			else
			{
				if(sa[i-1]==sb[i-1])x[i]=2;
				else x[i]=1;
			}
		}
		else
		{
			if(!x[i])x[i]=1;
		}
		//cout<<i<<" "<<x[i]<<endl;
	}
	if(sa[1]==sb[1])x[1]=3;
	if(sa[1]==sa[2])x[1]=6;
	f[0]=1;for(i=1;i<=n;i++)f[i]=f[i-1]*x[i],f[i]%=mo;
	printf("%lld",f[n]);
	return 0;
}

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


using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1 << 30;
const ll INFL = 1LL << 60;
const ll mod = 1000000007;


int main() {
	
	int n;
	cin >> n;
	int ans = 0;

	VS s(n);
	REP(i, n)cin >> s[i];

	REP(i, n) {

		bool check = true;

		REP(j, n) {
			REP(k, n) {
				if (s[j][k] != s[k][j])check = false;
			}
		}
		if (check)ans++;
		REP(j, n) {
			s[j] = s[j].substr(1) + s[j][0];
		}
	}
	ans *= n;
	cout << ans << endl;


}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 0;
    int n; cin >> n;
    int cnt[100010] = {};
    rep(i, n) {
        int a; cin >> a;
        if(a > 100000) {
            ans++;
            continue;
        }
        cnt[a]++;
    }
    REP(i, 1, 100000) {
        if(cnt[i] == 0) continue;
        if(cnt[i] < i) ans += cnt[i];
        if(cnt[i] > i) ans += cnt[i] - i;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4040
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A, B = MAP()

def f(n):
    if n%2 == 1:
        if ((n+1)//2)%2 == 0:
            return 0
        else:
            return 1
    else:
        return f(n-1)^n

print(f(B)^f(A-1))


Measured memory_bytes: 5204
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,a[2000],ans;
main()
{
	scanf("%d",&n);for(register int i=0;i<n;++i)scanf("%d",a+i);
	sort(a,a+n);
	for(register int i=0,j,k;i<n;++i)for(j=i+1;j<n-1;++j)
	{
		k=upper_bound(a+j+1,a+n,a[i]+a[j]-1)-a;
		ans+=k-j-1;
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
import java.util.Scanner;
import java.util.Arrays;


public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		//提示されるダイス目の入力 その１
		String dice1 = sc.nextLine();

		//入力されたダイス目の配列
		String[] dicenum1 = dice1.split(" ");
		int[] dicenumber1 = new int[6];

		for (int i = 0; i < dicenum1.length; i++) {
			dicenumber1[i] = Integer.parseInt(dicenum1[i]);
		}

		//提示されるダイス目の入力 その２
		String dice2 = sc.nextLine();

		//入力されたダイス目の配列
		String[] dicenum2 = dice2.split(" ");
		int[] dicenumber2 = new int[6];

		for (int i = 0; i < dicenum2.length; i++) {
			dicenumber2[i] = Integer.parseInt(dicenum2[i]);
		}

		//Diceクラスの呼び出し
		Dice diceClass1 = new Dice(dicenumber1);
		Dice diceClass2 = new Dice(dicenumber2);

		//Rollクラスの呼び出し
		Roll diceRoll = new Roll();

		//Diceクラスの受け渡し
		diceRoll.setDice(diceClass2);

		//Rollクラスに上面と前面を渡して結果を受け取り型に格納
				Object diceAnswer =diceRoll.roll(dicenumber1,dicenumber2);

				System.out.println(diceAnswer);

		sc.close();

	}

}


class Roll {

	Dice dice;

	public void setDice(Dice getDice) {
		this.dice = getDice;
	}

	//呼び出し元からint型のdicetopとdicefrontを受け取る
	public Object roll(int[] d1, int[] d2) {

		//1-6を配列番号0-5に割り当てて並べ替えをする
		//縦に4回、水平に4回回して一致する配列があるかどうかを判定する

		int empty = 0;
		Object YorN = "";

		//方向ごとに場合分け

		if (d1 != d2) {

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

				// if文で面の番地に指定の数字が入るまで繰り返し

				//縦回転(前後)
				if (Arrays.equals(d1,d2)) {
					break;
				}

				empty = d2[0];
				d2[0] = d2[1];
				d2[1] = d2[5];
				d2[5] = d2[4];
				d2[4] = empty;

				for (int k = 0; k < 4; k++) {
					if (Arrays.equals(d1,d2)) {
						break;
					}

					//水平回転
					empty = d2[1];
					d2[1] = d2[2];
					d2[2] = d2[4];
					d2[4] = d2[3];
					d2[3] = empty;

				}

			}
			for (int j = 0; j < 4; j++) {
				if (Arrays.equals(d1,d2)) {
					break;
				}

				//縦回転(左右)
				empty = d2[0];
				d2[0] = d2[2];
				d2[2] = d2[5];
				d2[5] = d2[3];
				d2[3] = empty;

				for (int k = 0; k < 4; k++) {
					if (Arrays.equals(d1,d2)) {
						break;
					}
					//水平回転
					empty = d2[1];
					d2[1] = d2[2];
					d2[2] = d2[4];
					d2[4] = d2[3];
					d2[3] = empty;

				}
			}
			if (Arrays.equals(d1,d2)) {
				YorN = "Yes";
			} else {
				YorN = "No";
			}

		}

		return YorN;
	}
}


class Dice {

	int[] d = new int[6];

	public Dice(int[] setd) {

		this.d[0] = setd[0];
		this.d[1] = setd[1];
		this.d[2] = setd[2];
		this.d[3] = setd[3];
		this.d[4] = setd[4];
		this.d[5] = setd[5];

	}

}



Measured memory_bytes: 26324
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>
#include<cmath>
#include<cstring>
#include<map>
#include<sstream>
#include <iomanip>

 
using namespace std;

long long N,K,score;

int main(){
  cout << fixed << setprecision(10);
  cin>>N>>K;
  double now_val;
  double probability = 0.0;
  long long tos = 0;
  
  for(int i = 1; i <= N; i++){
    score = i;
    while(score <= K-1){
      score *= 2;
      ++tos;
    }
    now_val = 1.0/N;
    probability += (now_val)*pow(0.5, tos);
    tos = 0;
  }
  
  cout <<probability<<endl;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int H, W;
void dfs_yoko(int row, int col, vector<vector<char>>& S, vector<vector<int>>& yoko, int& cnt)
{
    if (col >= W || S[row][col] == '#') {
        return;
    } else {
        cnt++;
        dfs_yoko(row, col + 1, S, yoko, cnt);
    }
    yoko[row][col] = cnt;
    return;
}

void dfs_tate(int row, int col, vector<vector<char>>& S, vector<vector<int>>& tate, int& cnt)
{
    if (row >= H || S[row][col] == '#') {
        return;
    } else {
        cnt++;
        dfs_tate(row + 1, col, S, tate, cnt);
    }
    tate[row][col] = cnt;
    return;
}

int main()
{
    cin >> H >> W;
    vector<vector<char>> S(H, vector<char>(W, '.'));
    vector<vector<int>> yoko(H, vector<int>(W, 0));
    vector<vector<int>> tate(H, vector<int>(W, 0));

    rep(row, H)
    {
        rep(col, W)
        {
            cin >> S[row][col];
        }
    }

    rep(row, H)
    {
        rep(col, W)
        {
            if (yoko[row][col] != 0)
                continue;
            int cnt = 0;
            dfs_yoko(row, col, S, yoko, cnt);
        }
    }

    rep(col, W)
    {
        rep(row, H)
        {
            if (tate[row][col] != 0)
                continue;
            int cnt = 0;
            dfs_tate(row, col, S, tate, cnt);
        }
    }

    int ans = 0;
    rep(row, H)
    {
        rep(col, W)
        {
            ans = max(ans, tate[row][col] + yoko[row][col] - 1);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 38532
K = int(input())
score = input().split()
s1 = int(score[0])
s2 = int(score[1])
if ( s1 % K ) == 0:
		print('OK')
elif ( s2 % K ) == 0:
		print('OK')
elif ( s1 // K ) < ( s2 // K ):
		print('OK')
else:
		print('NG')

Measured memory_bytes: 9184
X, K, D = map(int, input().split())

if X > 0:
    k = X // D
    if k <= K:
        X -= D * k
        K -= k
    else:
        X -= D * K
        K = 0
        print(abs(X))
        exit()

    cur_abs = abs(X)
    while K > 0:
        X -= D
        if abs(X) > cur_abs:
            X += D
            break
        cur_abs = abs(X)
        K -= 1
    K = K % 2
    if K % 2 != 0:
        print(min(abs(X + D), abs(X - D)))
    else:
        print(cur_abs)


elif X < 0:
    k = abs(X) // D
    if k <= K:
        X += D * k
        K -= k
    else:
        X += D * K
        K = 0
        print(abs(X))
        exit()

    cur_abs = abs(X)
    while K > 0:
        X += D
        if abs(X) > cur_abs:
            X -= D
            break
        cur_abs = abs(X)
        K -= 1
    K = K % 2
    if K % 2 != 0:
        print(min(abs(X + D), abs(X - D)))
    else:
        print(cur_abs)


else:   # X == 0
    if K % 2 == 0:
        print(0)
    else:
        print(min(abs(X + D), abs(X - D)))


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

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

    ll n,m;
    cin >> n >> m;

    vector<ll> fact;
    for(ll i = 1; i * i <= m; i++){
        if(m % i == 0) {
            fact.push_back(i);
            fact.push_back(m/i);
        }
    }

    sort(fact.begin(),fact.end());

    ll ans = 1;
    for(int i = 0; i < fact.size(); i++){
        if(fact[i] * n <= m) ans = fact[i];
        else break;
    }
    cout << ans << endl;
}



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

int main(int argc, char const *argv[])
{
	int n;
	string a,b,c;
	cin>>n>>a>>b>>c;
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		set<char> d;
		d.insert(a[i]);
		d.insert(b[i]);
		d.insert(c[i]);
		ans+=d.size()-1;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef  long long int ll;
typedef long double ld;
#define pb  push_back
#define vll vector<ll>
#define mll map<ll,ll>
const double PI = 2*acos(0.0);
#define gcd(a,b)   __gcd((a),(b))
#define lcm(a,b)   ((a)/(__gcd((a),(b)))*(b))
#define INF         LLONG_MAX
#define ln  INT_MAX
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
using namespace std;
int main() {
ll n,x,t;
cin>>n>>x>>t;
if(n%x!=0){n=n/x; n++;}
else{n=n/x;}
cout<<n*t;
return 0;
}


Measured memory_bytes: 3596
#include<stdio.h>
int main(){
    int n,i;
    int a[200001];
    int b[200001];
    scanf("%d",&n);
    for (i = 1; i < n; i++){
        scanf("%d", &a[i]);
    }
    for (i = 1; i < n; i++){
        b[a[i]]++;
    }
    for (i = 1; i <= n; i++){
        printf("%d\n", b[i]);
    }
    return 0;
}

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

int main() {
	int N;
	cin >> N;
	string S;
	cin >> S;
	string alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
	for (int i = 0; i < S.size(); i++) {
		int c = S.at(i) - 'A';
		cout << alphabet.at((c + N) % 26);
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
import math
import heapq
from sys import stdin, stdout, setrecursionlimit
from bisect import bisect, bisect_left, bisect_right
from collections import defaultdict, deque

# d = defaultdict(lambda: 0)
# setrecursionlimit(10**7)
# inf = float("inf")


##### stdin ####
def LM(t, r): return list(map(t, r))
def R(): return stdin.readline()
def RS(): return R().split()
def I(): return int(R())
def F(): return float(R())
def LI(): return LM(int,RS())
def LF(): return LM(float,RS())
def ONE_SL(): return list(input())
def ONE_IL(): return LM(int, ONE_IL())
def ALL_I(): return map(int, stdin)
def ALL_IL(): return LM(int,stdin)

##### tools #####
def ap(f): return f.append
def pll(li): print('\n'.join(LM(str,li)))
def pljoin(li, s): print(s.join(li))



##### main #####
def main():
	n,a,b = LI()

	print(min(n*a, b))

if __name__ == '__main__':
	main()

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2017/11/29  Problem: 080_arc_a / Link: https://arc080.contest.atcoder.jp/tasks/arc080_a  ----- */
/* ------問題------

-----問題ここまで----- */
/* -----解説等-----

境界線が見えないときは愚直に埋めてもよい

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int four = 0, two = 0;
	cin >> N;
	FOR(i, 0, N) {
		int a; cin >> a;
		if (a % 4 == 0)four++;
		else if (a % 2 == 0)two++;
	}
	int ok = 1;

	if (N > 2 * four + 1 && N > 2 * four + two)ok = 0;
	cout << (ok ? "Yes" : "No") << "\n";

	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}
int gcd(int a, int b) {
	if (b != 0)return gcd(b, a % b);
	return a;
}
ll Lgcd(ll a, ll b) {
	if (b != 0) return Lgcd(b, a % b); 
	return a;
}
int lcm(int a, int b) {
	return a / gcd(a, b) * b;
}
ll Llcm(ll a, ll b) {
	return a / Lgcd(a, b) * b;
}

/* main */
int main() {
	int a, p;
	scanf("%d%d", &a, &p);
	printf("%d", (a * 3 + p) / 2);
	return 0;
}

Measured memory_bytes: 128
#include <cstdio>

using namespace std;

char s[200001];
int dp1[200000];
int dp2[200000];

int main() {
    int n, a, b, c, d, i, j;
    
    scanf("%d %d %d %d %d", &n, &a, &b, &c, &d);
    scanf("%s", s);
    
    a--;
    b--;
    c--;
    d--;
    
    dp1[a] = 1;
    dp2[b] = 1;
    
    for (i = 0; i < n; i++) {
        for (j = 1; j <= 2 && i + j < n; j++) {
            if (dp1[i] == 1 && s[i + j] == '.') dp1[i + j] = 1;
            if (dp2[i] == 1 && s[i + j] == '.') dp2[i + j] = 1;
        }
    }
    
    if (dp1[c] == 0 || dp2[d] == 0) {
        puts("No");
    } else if (c < d) {
        puts("Yes");
    } else {
        for (i = b; i <= d; i++) {
            if (s[i - 1] == '.' && s[i] == '.' && s[i + 1] == '.') {
                puts("Yes");
                
                return 0;
            }
        }
        
        puts("No");
    }
    
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
const int INF = 1001001001;

int main() {
double a,b,h,m,ans,kaku,pi,unit;
pi = 2.0 * asin(1.0);            /* πの値 */
unit   = pi / 180.0;   
cin >> a >> b >> h >> m;
h = h*30+m/2;
m *= 6;
if (m == 0) m = 360;
kaku = min(abs(h-m),abs(m-h))*unit;
if (kaku == 180) {
    cout << a+b << endl;
}else {
ans = a * a + b * b - 2 * a*b* cos(kaku);
ans = sqrt(ans);
printf("%.20f\n",ans);
}

return 0;
}


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

#define _GLIBCXX_DEBUG
#define _LIBCPP_DEBUG 0

vector<ll> a;
vector<ll> b;
vector<ll> c;
vector<ll> d;
ll n;
ll m;
ll q;
ll ans = 0;
void dfs(vector<ll> A) {
  if (A.size() == n) {
    ll point = 0;
    for (long long i = 0; i < q; i++) {
      if ((A.at(b.at(i)) - A.at(a.at(i))) == c.at(i)) {
        point += d.at(i);
      }
    }
    ans = max(ans, point);
    return;
  }
  ll first = 1;
  if (A.size() != 0) {
    first = A.back();
  }
  for (long long i = first; i <= m; i++) {
    vector<ll> tmp(A);
    tmp.push_back(i);
    dfs(tmp);
  }
}

int main() {
  cin >> n >> m >> q;
  a.resize(q);
  b.resize(q);
  c.resize(q);
  d.resize(q);

  for (long i = 0; i < q; i++) {
    cin >> a.at(i) >> b.at(i) >> c.at(i) >> d.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  dfs({});
  cout << ans << endl;
}


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

s = sum(B)

for i in range(N-1):
  if A[i]+1 == A[i+1]:
    s += C[A[i]-1]

print(s)

Measured memory_bytes: 3060
#include <iostream>
#include <queue>

using namespace std;

struct Point {
  int x, y, dist;
};

int main() {
  int w, h;
  while(1) {
    cin >> w >> h;
    if(w == 0 && h == 0) break;
    int lr[h][w], td[h][w];
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w; j++) {
	lr[i][j] = td[i][j] = 0;
      }
    }
    for(int i = 0; i < h; i++) {
      for(int j = 0; j < w-1; j++) {
	cin >> lr[i][j];
      }
      if(i == h-1) break;
      for(int j = 0; j < w; j++) {
	cin >> td[i][j];
      }
    }


    bool visited[h][w];
    for(int i = 0; i < h; i++)
      for(int j = 0; j < w; j++)
	visited[i][j] = false;

    Point p;
    p.x = 0;
    p.y = 0;
    p.dist = 0;

    queue<Point> Q;
    Q.push(p);

    int ans = -1;

    while(!Q.empty()) {
      int d[4][2] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

      p = Q.front();
      Q.pop();
      visited[p.y][p.x] = true;
      if(p.x == w-1 && p.y == h-1) {
	ans = p.dist;
	break;
      }

      for(int i = 0; i < 4; i++) {
	if(lr[p.y][p.x] && i == 0) continue;
	if(p.x-1 >= 0 && lr[p.y][p.x-1] && i == 2) continue;
	if(td[p.y][p.x] && i == 1) continue;
	if(p.y-1 >= 0 && td[p.y-1][p.x] && i == 3) continue;

	int nx = p.x + d[i][0];
	int ny = p.y + d[i][1];
	if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;

        if(visited[ny][nx]) continue;

	Point temp;
	temp.x = nx;
        temp.y = ny;
	temp.dist = p.dist + 1;
	Q.push(temp);
	visited[ny][nx] = true;
      }
    }
    if(ans != -1) cout << ans + 1 << endl;
    else cout << 0 << endl;
  }
  return 0;
}

Measured memory_bytes: 912
#include <stdio.h>

int main(void)
{
	int num_of_mt;
	scanf("%d", &num_of_mt);

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

	int num_of_visible_hotel = 1;
	int not_visible;
	for(i = 1; i < num_of_mt; i++) {
		not_visible = 0;
		for(j = 0; j < i; j++) {
			if(mt_peak[i] < mt_peak[j]) {
				not_visible = 1;
				break;
			}
		}
		if(not_visible == 0) {
			num_of_visible_hotel++;
		}
	}

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

	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int, input().split()))
maxa = max(a)
mini = [[] for _ in range(n)]
for i, v in enumerate(a):
    r = maxa - v
    mini[i] = [v, abs(v - r)]
mini.sort(key=lambda x: x[1])
if n == 2:
    print(maxa, min(a))
else:
    print(maxa, mini[0][0])


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

if n < 10:
    print(0)
    exit()

e = [0 for _ in range(n + 1)]

for i in range(2, n + 1):
    temp = i
    for j in range(2, i + 1):
        while temp % j == 0:
            e[j] += 1
            temp //= j

a = [0 for _ in range(75)]
for i in range(n + 1):
    for j in range(min(75, e[i] + 1)):
        a[j] += 1

ans = a[74] + a[24] * (a[2] - 1) + a[14] * (a[4] - 1) + a[4] * (a[4] - 1) * (a[2] - 2) // 2
print(ans)


Measured memory_bytes: 3064
#include <stdio.h>

int main(void)
{
	int n;
	int a,b,c,d;
	int count;
	
	while (scanf("%d", &n) == 1){
		
		count = 0;
		for (a = 0; a <= 9; a++){
			for (b = 0; b <= 9; b++){
				for (c = 0; c <= 9; c++){
					for (d = 0; d <= 9; d++){
						if (a + b + c + d == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n", count);
	}
	
	
	
	return (0);
}

Measured memory_bytes: 1024