akhauriyash/Code-Regression huggingface dataset:
object Main extends App {
  import scala.io.StdIn._

  val Array(a, b, q) = readLine.trim.split(' ').map(_.toInt)
  val shrine = Array.tabulate(a){_ ⇒ readLong}
  val temple = Array.tabulate(b){_ ⇒ readLong}
  for (_ ← 0 until q){
    val x = readLong
    val sl = moveToLeft(x, shrine)
    val sr: Option[Long] = moveToRight(x, shrine)
    val tr: Option[Long] = moveToRight(x, temple)
    val tl: Option[Long] = moveToLeft(x, temple)

    println(List(
      sl.flatMap(l ⇒ tr.map(r ⇒ l + r + math.min(l, r))),
      sl.flatMap(l ⇒ tl.map(r ⇒ math.max(l, r))),
      sr.flatMap(l ⇒ tr.map(r ⇒ math.max(l, r))),
      sr.flatMap(l ⇒ tl.map(r ⇒ l + r + math.min(l, r)))
    ).flatten.min)
  }
  def moveToRight(from: Long, positions: Array[Long]): Option[Long]  = {
    val pos = lowerBound(positions, from)
    if (positions.indices.contains(pos)) Some(positions(pos) - from)
    else None
  }
  def moveToLeft(from: Long, positions: Array[Long]): Option[Long] = {
    val pos = lowerBound(positions, from)
    if (positions.indices.contains(pos) && positions(pos) == from) Some(0)
    else if (positions.indices.contains(pos - 1)) Some(from - positions(pos - 1))
    else None
  }
  def lowerBound(array: Array[Long], target: Long): Int = {
    var left = 0
    var right = array.length
    while(left < right){
      val mid = (left + right) / 2
      if (array(mid) < target){
        left = mid + 1
      }else {
        right = mid
      }
    }
    right
  }
}

Measured memory_bytes: 76296
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int,int> pii;
const int MAX=22;
const int MOD=1e9+7;
int n,x;
vector<int>graf[MAX],nums[MAX];
ll dp[MAX][(1<<MAX)];
int add(int x,int y){
	return (x+y)%MOD;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=0;j<(1<<n);j++){
			if(__builtin_popcount(j)==i-1){
				nums[i].push_back(j);
			}
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>x;
			if(x==1) graf[i].push_back(j);
		}
	}
	dp[0][0]=1;
	for(int i=1;i<=n;i++){
		for(auto w:graf[i]){
			for(auto k:nums[i]){
				if(k&(1<<(w-1))) continue;
				//cout<<i<<" "<<k<<" "<<(k|(1<<(w-1)))<<"\n";
				dp[i][k|(1<<(w-1))]=add(dp[i][k|(1<<(w-1))],dp[i-1][k]);
			}
		}
	}
	cout<<dp[n][(1<<n)-1];
	return 0;
}

Measured memory_bytes: 332528
def make_div(n):
    divisors = []
    for i in range(1, int(n ** 0.5) + 1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)

    divisors.sort()
    # 偶数の場合
    if (len(divisors) + 1) % 2 == 1:
        x = (len(divisors) + 1) // 2 - 1
        ans1 = divisors[x] - 1 + divisors[x + 1] - 1
        print(ans1)
    # 奇数の場合
    else:
        y = len(divisors) // 2
        ans2 = 2 * (divisors[y] - 1)
        print(ans2)
    return divisors


m = int(input())
make_div(m)

Measured memory_bytes: 3272
using System;
using System.Collections.Generic;
using System.Linq;
using static Input;

public class Prog
{
    private const int INF = 1000000007;
    private struct Pair { public long x, y; public Pair(long x, long y) { this.x = x; this.y = y; } }
    public static void Solve()
    {
        int N = NextInt();
        int M = NextInt();
        long[] dp = new long[N + 10];
        for (int i = 0; i < M; i++)
        {
            int x = NextInt();
            dp[x] = -1;
        }
        dp[0] = 1;
        for (int i = 1; i <= N; i++)
        {
            if (dp[i] == -1) continue;
            if (i >= 2) { if (dp[i - 2] != -1) { dp[i] += dp[i - 2]; } }
            if (dp[i - 1] != -1) dp[i] += dp[i - 1];
            dp[i] %= -INF;
        }
        Console.WriteLine(dp[N]);
    }
    public static void Main()
    {
        var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
        Console.SetOut(sw);
        Solve();
        Console.Out.Flush();
    }
}
public class Input
{
    private static Queue<string> q = new Queue<string>();
    private static void Confirm() { if (q.Count == 0) foreach (var s in Console.ReadLine().Split(' ')) q.Enqueue(s); }
    public static int NextInt() { Confirm(); return int.Parse(q.Dequeue()); }
    public static long NextLong() { Confirm(); return long.Parse(q.Dequeue()); }
    public static char NextChar() { Confirm(); return char.Parse(q.Dequeue()); }
    public static string NextString() { Confirm(); return q.Dequeue(); }
    public static double NextDouble() { Confirm(); return double.Parse(q.Dequeue()); }
    public static int[] LineInt() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
    public static long[] LineLong() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
    public static string[] LineString() { return Console.ReadLine().Split(' ').ToArray(); }
    public static double[] LineDouble() { return Console.ReadLine().Split(' ').Select(double.Parse).ToArray(); }
}


Measured memory_bytes: 15952
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
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;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

int a[N];
int main()
{
	int n;
	cin >> n;
	for(ll x = 1; x <= 100; x ++)
	for(ll y = 1; y <= 100; y ++)
	for(ll z = 1; z <= 100; z ++)
		if(x*x + y*y + z*z + x*y + y*z + z*x <= n)
			a[x*x + y*y + z*z + x*y + y*z + z*x] ++;
	for(int i = 1; i <= n; i ++)
		cout << a[i] << '\n';




	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 3620
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    int m,sum=0;
    cin>>n>>m;
    int arr[n];
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    int s = sizeof(arr)/sizeof(arr[0]);
    sort(arr, arr+s);
    for(int i=0;i<m;i++)
    {
        sum=sum+arr[i];
    }
    cout<<sum;
}

Measured memory_bytes: 3596
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,m;
    while(true){
        cin>>n>>m;
        if(n+m==0)break;
        vector<ll> v(n);
        rep(i,n){
            cin>>v[i];
        }
        sort(v.rbegin(),v.rend());
        bool f=true;
        ll ans=0;
        for(int i=0;i<n-1;i++){
            for(int j=i+1;j<n;j++){
            if(v[i]+v[j]<=m&&v[i]+v[j]>ans) {
                ans = v[i] + v[j];
                f = false;
                
            }
            }
        }
        if(f==true){
            cout<<"NONE"<<endl;
        }else{
            cout<<ans<<endl;
        }

    }





    return 0;
}



Measured memory_bytes: 3084
#include <iostream>

using namespace std;

int main(void){

  long long n;

  while( cin >> n , n ){

    if( n == 1 ){
      cout << "deficient number" << endl;
      continue;
    }

    long long total = 1;
    long long a = 0;

    for( int i = 2 ; a != i && i < n/2 ; i++ ){
      if( n % i == 0 ){
	total += i;
	total += ( n / i );
	a = n / i;
	if( a == i ){
	  total -= i;
	  break;
	}
      }
      if( total > n ) break;
    }
    //cout << "a = " << a << endl;
    //cout << total << "    ";
    if( n == total ) cout << "perfect number" << endl;
    if( n < total ) cout << "abundant number" << endl;
    if( n > total ) cout << "deficient number" << endl;

  }
  return 0;
}

Measured memory_bytes: 1156
/*

*/
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <deque>
 
#define ll long long
#define cint const int
#define ld long double
#define sz(a) (int)a.size()
#define all(a) a.begin(), a.end()
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
 
using namespace std;

int n, m, a[1005];

int main () {
	cin >> n >> m;
	int c = 0;
	for (int i = 1; i <= n; ++i) {
		c += n - i;
	}
	for (int i = 1; i <= m; ++i) {
		c += m - i;
	}
	cout << c;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

//xより以下の要素へのindex
template <class T> int former(const vector<T> &v, T x) {
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素へのindex
template <class T> int latter(const vector<T> &v, T x) {
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}

int comb(int n,int k){
    int ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<double> p(n);//表の確率
    vector<double> q(n);//裏の確率
    vector<vector<double> > dp(n+1,vector<double>(n+1));//dp[i+1][j+1]←i番目のまでのコインを投げた時にj枚表
    rep(i,n){
        cin>>p[i];
        q[i]=1-p[i];
    }
    dp[1][0]=q[0];
    dp[1][1]=p[0];
    FOR(i,2,n+1){//j=0の時は全部裏
        dp[i][0]=dp[i-1][0]*q[i-1];
    }
    FOR(i,1,n){
        rep(j,i+2){
            dp[i+1][j]=dp[i][j-1]*p[i]+dp[i][j]*q[i];
        }
    }
    ld ans=0;
    FOR(i,(n+1)/2,n+1){
        ans+=dp[n][i];
    }
    cout<<setprecision(10)<<ans<<endl;
}

Measured memory_bytes: 70784
#include "bits/stdc++.h"

typedef long long ll;
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define REP(i,n) for (int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
 
using namespace std;

ll a[100010];
ll s1[100010];
ll s2[100010];

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

    ll ans1 = 0,ans2 = 0;
    //ll a[n];
    REP(i,n) cin >> a[i];
    //ll s1[n] = {0};
    //ll s2[n] = {0};
    s1[0] = a[0];
    s2[0] = a[0];

    if(s1[0] <= 0){
        ans1 += 1 - s1[0];
        s1[0] = 1;
    }
    for(int i = 1;i < n;i++){
        if(i%2){
            if(-s1[i-1] > a[i]) s1[i] = s1[i-1] + a[i];
            else{
                s1[i] = -1;
                ans1 += s1[i-1] + a[i] + 1; 
            }
        }else{
            if(-s1[i-1] < a[i]) s1[i] = s1[i-1] + a[i];
            else{
                s1[i] = 1;
                ans1 += -(s1[i-1] + a[i]) + 1; 
            }
        }
    }

    if(s2[0] >= 0){
        ans2 += 1 + s2[0];
        s2[0] = -1;
    }
    for(int i = 1;i < n;i++){
        if(i%2 == 0){
            if(-s2[i-1] > a[i]) s2[i] = s2[i-1] + a[i];
            else{
                s2[i] = -1;
                ans2 += s2[i-1] + a[i] + 1; 
            }
        }else{
            if(-s2[i-1] < a[i]) s2[i] = s2[i-1] + a[i];
            else{
                s2[i] = 1;
                ans2 += -(s2[i-1] + a[i]) + 1; 
            }
        }
    }

    ll ans = min(ans1,ans2);
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a),i##formax=(b);i<i##formax;i++)
#define FORR(i,a,b) for(int i=(a),i##formax=(b);i>=i##formax;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pcnt __builtin_popcount
#define sz(x) (int)(x).size()
#define maxs(x,y) x=max(x,y)
#define mins(x,y) x=min(x,y)
#define show(x) cout<<#x<<" = "<<x<<endl;
#define all(a) (a.begin()),(a.end())
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define perm(c) sort(all(c));for(bool c##p=1;c##p;c##p=next_permutation(all(c)))
#define bitComb(a,n,k) for(int a##x,a##y,a=(1<<k)-1;a<(1<<n);a##x=a&-a,a##y=a+a##x,a=(((a&~a##y)/a##x)>>1)|a##y)
#define uniq(v) sort(all(v));v.erase(unique(all(v)), v.end())
#define bit(n) (1LL<<(n))
#define randInt(l,r) (uniform_int_distribution<ll>(l,r)(rnd))
#define randDouble(l,r) (uniform_real_distribution<double>(l,r)(rnd))
#define dout(d) printf("%.12f\n",d)

typedef long long ll;
typedef __int128_t lll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T>using V=vector<T>;
template<class T>using VV=V<V<T>>;
template<class T,class Y>ostream& operator<<(ostream& o,const pair<T,Y>& p){return o<<"("<<p.fi<<", "<<p.se<<")";}
template<typename A,size_t N,typename T>void Fill(A (&array)[N],const T&v){fill((T*)array,(T*)(array+N),v);}
lll gcd(lll a,lll b,lll &x,lll &y){if(!b){x=1;y=0;return a;}lll d=gcd(b,a%b,y,x);y-=a/b*x;return d;}
ll modInv(ll a,ll m){lll x,y;gcd(a,m,x,y);return (x%m+m)%m;}
ll modPow(lll a,lll n,ll m){if(!a)return a;lll p=1;for(;n>0;n>>=1,a=a*a%m)if(n&1)p=p*a%m;return(ll)p;}
bool isPrime(ll n){if(n<2||n%2==0)return n==2;lll t=n-1,d=t/(t&-t);for(lll a:{2,325,9375,28178,450775,9780504,1795265022})if(a%n){for(t=d,a=modPow(a,t,n);t!=n-1&&a!=1&&a!=n-1;a=a*a%n,t=t*2%n);if(a!=n-1&&t%2==0)return 0;}return 1;}
//V<ll>fac,rfac;void setFac(int n,int mod){fac=rfac=V<ll>(++n);fac[0]=1;FOR(i,1,n)fac[i]=fac[i-1]*i%mod;rfac[n-1]=modInv(fac[n-1],mod);FORR(i,n-1,1)rfac[i-1]=rfac[i]*i%mod;}
const int IINF = 1e9+6;
const ll LINF = 1e18;
const int MOD = 1e9+7;
const double PI = acos(-1);
const double EPS = 1e-10;
static random_device rd;
static mt19937 rnd(rd());

const int N = 1e5;
string s;
main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> s;
  cout << (s[0]==s[1] || s[1]==s[2] || s[2]==s[3] ? "Bad" : "Good") << endl;
}

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

int main(){
  int a,b;
  cin >> a >> b;
  string s;
  if(a>b) s = "a > b";
  else if(a==b) s = "a == b";
  else s = "a < b";
  cout << s << endl;

  return 0;
}

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

int main(){
	int N,i,j,t,M,tt;
  	cin>>N;
  	M = N;
    tt,i,j = 0;
  	
  for(j = 0;j<M;j += 1){
    	
    	//cout<< N <<endl;
    	t = 0;
  		for(i=N;i>0;i--){
      
    		if((N%i==0)&&(N%2 == 1)){
        	  t += 1;
              //cout<< t <<endl;
        	}
    		if((t == 8)){
        	  tt += 1;
       		}
    	}
    N = N - 1;
  	}
  	
  
	printf("%d",tt);
}

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

/**
 *
 * @author lenovo
 */
public class Main {

    public static void main(String[] args) {
        int count = 0;
        Scanner scanner = new Scanner(System.in);

        while (true) {
            int a = scanner.nextInt();
            int b = scanner.nextInt();
            if (a == 0 && b == 0) {
                break;
            }
            int[] array = {a, b};
            Arrays.sort(array);
            String s = "" + array[0] +" "+ array[1];

            System.out.println(s);

        }

    }

}

Measured memory_bytes: 36432
N = int(input())
H = list(map(int, input().split()))

if N == 1:
  print('Yes')

else:
  if H[0] <= H[-1]:
    for i in range(N-1):
      if H[i+1] - H[i] >= 1:
        H[i+1] -= 1
        if i == N-2:
          print('Yes')
          break
        
        else:
          continue
      
      elif H[i+1] - H[i] == 0:
        if i == N-2:
          print('Yes')
          break
      
        else:
          continue
      
      else:
        print('No')
        break
    
  if H[0] > H[-1]:
    for i in range(N-2):
      if H[i] - H[i+1] <= 1:
        H[i] -= 1
      
        if i == N-2:
          print('Yes')
          break
        
        else:
          continue
     
      else:
        print('No')
        break

      
      


Measured memory_bytes: 14704
#include<iostream>
#include<vector>
#include<numeric>
#include<limits>
#include<queue>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
typedef int weight;
typedef vector<vector<int> > matrix;
int inf = 1000000005;
weight hungarian(const matrix &a,vector<int> &x,vector<int> &y) {
  int n = a.size(), p, q;
  vector<int> fx(n, inf), fy(n, 0);
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j)
      fx[i] = max(fx[i], a[i][j]);
  for (int i = 0; i < n; ) {
    vector<int> t(n, -1), s(n+1, i);
    for (p = q = 0; p <= q && x[i] < 0; ++p)
      for (int k = s[p], j = 0; j < n && x[i] < 0; ++j)
        if (fx[k] + fy[j] == a[k][j] && t[j] < 0) {
          s[++q] = y[j], t[j] = k;
          if (s[q] < 0)
            for (p = j; p >= 0; j = p)
              y[j] = k = t[j], p = x[k], x[k] = j;
        }
    if (x[i] < 0) {
      weight d = inf;
      for (int k = 0; k <= q; ++k)
        for (int j = 0; j < n; ++j)
          if (t[j] < 0) d = min(d, fx[s[k]] + fy[j] - a[s[k]][j]);
      for (int j = 0; j < n; ++j) fy[j] += (t[j] < 0 ? 0 : d);
      for (int k = 0; k <= q; ++k) fx[s[k]] -= d;
    } else ++i;
  }
  weight ret = 0;
  for (int i = 0; i < n; ++i) ret += a[i][x[i]];
  return ret;
}


int main(){
    int n;
    cin >> n;
    vector<vector<int> >a(n,vector<int>(n));
    vector<vector<int> >b(n,vector<int>(n));
    rep(i,n){
        rep(j,n){
            cin >> a[i][j];
        }
    }
    rep(i,n){
        rep(j,n){
            cin >> b[i][j];
        }
    }
    vector<string>s(n);
    rep(i,n){
        cin >> s[i];
    }
    vector<int> x(n, -1), y(n, -1);
    vector<vector<int> > v(n,vector<int>(n));
    for(int j=0;j<n;j++){
        for(int i=0;i<n;i++){
            int tmp = 0;
            for(int k=0;k<n;k++){
                if(i==k&&s[k][j]=='.'){
                    tmp += a[k][j];
                }else if(i!=k&&s[k][j]=='o'){
                    tmp += b[k][j];
                }
            }
            v[i][j] = -tmp;
        }
    }
    int ans = hungarian(v,x,y);
    cout << -ans << endl;
    vector<string>t(n);
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j!=x[i]){
                t[i].push_back('.');
            }else{
                t[i].push_back('o');
            }
        }
    }
    vector<pair<int,int> > ss;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(s[i][j]!=t[i][j]){
                ss.push_back(make_pair(i,j));
            }
        }
    }
    cout << ss.size() << endl;
    for(auto x:ss){
        if(s[x.first][x.second]=='o'){
            cout << x.first+1 << " " << x.second+1 << " erase" << endl;
        }else{
            cout << x.first+1 << " " << x.second+1 << " write" << endl;
        }

    }
    return 0;
}


Measured memory_bytes: 3296
#include<iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<vector>
using namespace std;

long long a, b, x;

long long f(long long n) {
	if (n >= 0) {
		return n / x + 1;
	}
	else if (n == -1) {
		return 0;
	}
}

int main() {
	cin >> a >> b >> x;
	cout << f(b) - f(a - 1) << endl;
	cin >> a;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S=input()
if S[0]==S[1] and S[2]==S[3] and S[0]!=S[2] :
  print("Yes")
elif S[0]==S[2] and S[1]==S[3] and S[0]!=S[1] :
  print("Yes")
elif S[0]==S[3] and S[1]==S[2] and S[0]!=S[1] :
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include <iostream>
#include<cstdio>
#include<cmath>
using namespace std;

int main()
{
    int n,x,t,ans,temp;
    scanf("%d\t%d\t%d",&n,&x,&t);
    ans=(ceil((n*1.0)/(x*1.0)))*t;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 3760
import java.io.PrintWriter;
import java.util.*;

import static java.lang.System.in;

public class Main {
    static int K,N;
    static final long mod = 998244353;
    static long[] pw2 = new long[4005], fac = new long[4005], inv = new long[4005];
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        K = sc.nextInt();
        N = sc.nextInt();
        init();
        PrintWriter out = new PrintWriter(System.out);
        // the main for loop
        for(int i=2;i<=2*K;i++){
            long ans;
            if(i%2==1){
                ans = get(N,K,i);
            }else{
                ans = (get(N,K-1,i-1)+get(N-1,K-1,i-1))%mod;
            }
            out.println(ans);
        }
        out.flush();
    }
    // n blanks to fill number in. totally k values can be chosen.
    // why define in this way? because when i is even it's a little tricky
    // i is the sum that we want to avoid. In the main func we will make sure that i is odd
    static long get(int n, int k, int i){
        int lim = Math.max(0,i/2-Math.max(0,i-1-k));
        long ans = 0;
        for(int q=0;q<=lim;q++){
            ans = (ans+pw2[q]*comb(lim,q)%mod*hcom(k+q-2*lim,n-q))%mod;
        }
        return ans;
    }
    static long hcom(int P, int Q){
        return comb(P+Q-1,P-1);
    }
    static long comb(int n, int m){
        if(m>n||m<0||n<0) return 0;
        return fac[n]*inv[m]%mod*inv[n-m]%mod;
    }
    static void init(){
        pw2[0] = 1;
        for(int i=1;i<4005;i++) pw2[i] = 2*pw2[i-1]%mod;
        fac[0] = 1;
        for(int i=1;i<4005;i++) fac[i] = i*fac[i-1]%mod;
        inv[0] = 1;
        inv[4004] = pow(fac[4004],mod-2);
        for(int i=4003;i>=1;i--) inv[i] = (i+1)*inv[i+1]%mod;
    }
    static long pow(long base, long p){
        long ans = 1;
        while(p>0){
            if(p%2==1) ans = ans*base%mod;
            base = base*base%mod;
            p /= 2;
        }
        return ans;
    }
}


Measured memory_bytes: 22572
//Author: Prakhar Asaiya
#include<bits/stdc++.h>
using namespace std;
#define REP(i,a,b) for(int i=a;i<b;++i)
#define REPN(i,a,b) for(int i=a;i<=b;++i)
#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define pb push_back
#define ll long long
//const int M=1e9+7;
const int INF=1000000000;

const double pi=3.14159265358979323846;

int main()
{/*
#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
#*/
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
   int r;
   cin>>r;
   cout<<fixed<<setprecision(20)<<(double)2*pi*r;
   
    return 0;
}


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

int main(){
    int N, M;
    cin >> N;
    vector<string> blue(N);
    rep(i, N){
        cin >> blue.at(i);
    }

    cin >> M;
    vector<string> red(M);
    rep(i, M){
        cin >> red.at(i);
    }

    int max = 0;
    int balance;
    
    string check;
    rep(i, N){
        check = blue.at(i);
        balance = 0;

        rep(j, N){
            if (check == blue.at(j)){
                
                balance += 1;
            }
        }

        rep(j, M){
            if (check == red.at(j)){
                balance -= 1;
            }
        }

        if (max < balance)
            max = balance;
    }

    if (max > 0){
        cout << max << endl;
    }
    else
    {
        cout << "0" << endl;
    }
    
}

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

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

  vector<pair<int, int>> lr(n);

  for (int i = 0; i < n; ++i) {
    int x, l;
    cin >> x >> l;
    lr[i] = make_pair(x - l, x + l);
  }

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

  int ans = 1;
  int border = lr[0].second;
  for (int i = 1; i < n; ++i) {
    int nl = lr[i].first;
    int nr = lr[i].second;
    if (nr < border) {
      border = nr;
      continue;
    }
    if (nl < border)
      continue;
    border = nr;
    ++ans;
  }

  cout << ans << endl;
}

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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;

const double PI = 3.14159;

using namespace std;

//vector<ll> memo(1000007, INF);

int main() {

    char a;
    cin >> a;

    for(char i = 'A'; i <= 'Z'; i++) {
        if (a == i) {
            AA('A');
            return 0;
        }
    }
    for (char i = 'a'; i <= 'z'; i++) {
        if (a == i){
            AA('a');
            return 0;
        }
    }
}

Measured memory_bytes: 3632
import bisect
import copy
import heapq
import math
import sys
from collections import *
from itertools import accumulate, combinations, permutations, product
# from math import gcd
from functools import lru_cache
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n,k=map(int,input().split())
a=list(map(int,input().split()))

dp=[[0]*(k+1) for j in range(n+1)]

for i in range(n+1):
    dp[i][0]=1

for i in range(1,n+1):
    for j in range(1,k+1):
        dp[i][j]=dp[i-1][j]+dp[i][j-1]
        if j-a[i-1]-1 >= 0:
            dp[i][j]-=dp[i-1][j-a[i-1]-1]
        dp[i][j]%=mod
# print(dp)
print(dp[n][k])

Measured memory_bytes: 119660
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		long[] H = new long[N];
		for (int i = 0; i < H.length; i++)
			H[i] = sc.nextLong();
		int ans = 0;
		int count = 0;
		for (int i = 0; i < H.length; i++) {
			if ((i + 1) < H.length && H[i] >= H[i + 1]) {
				count++;
			} else {
				if (ans < count)
					ans = count;
				count = 0;
			}
		}
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 50412
#include <stdio.h>
int main(void){
    int power_5[120] = {0};
    for(int i = 0; i < 120; i++){
        power_5[i] = i*i*i*i*i;
    }
    int x = 0;
    int flag = 0;
    scanf("%d",&x);
    for(int i = 0; i < 120; i++){
        for(int j = i; j < 120; j++){
            if(power_5[i]+power_5[j]==x){
                printf("%d %d",j,-i);
                flag = 1;
                break;
            }
            if(power_5[j] - power_5[i]==x){
                printf("%d %d",j,i);
                flag = 1;
                break;
            }
        }
        if(flag == 1){
            break;
        }
    }




    return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const ll INF=1000000000000000;
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}

int main(){
	ll N,X; cin>>N>>X;
	ll A; cin>>A;
	ll ans=abs(A-X);
	rep(i,N-1){
		ll A; cin>>A;
		ans=gcd(ans,abs(A-X));
	}
	cout<<ans;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
// #include <iostream>
// #include <set>
// #include <map>
// #include <vector>

using namespace std;

int n;
string s[15];


int main() {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    while(true) {
        cin>>n;

        int ans=0;
        int chr[26]={}; 
        bool isused[26]={};
        int coef_l[26]={},coef_r[26]={};
        bool istop[26]={};
        if(!n) break;

        for(int i=0; i<n; ++i) {
            cin>>s[i];
            if(s[i].size()>1) istop[s[i][0]-'A']=true;
            reverse(s[i].begin(),s[i].end());
            long long j=1;
            for(char c:s[i]) {
                isused[c-'A']=true;
                if(i<n-1) coef_l[c-'A']+=j;
                else coef_r[c-'A']+=j;
                j*=10;
            }
        }

        int k=0;
        for(int i=0; i<26; ++i) {
            if(isused[i]) ++k;
        }

        int p[10]={0,1,2,3,4,5,6,7,8,9};
        int lasp[10]={-1};

        do {
            bool suc=false;
            for(int i=0; i<k; ++i) {
                if(lasp[i]!=p[i]) {
                    lasp[i]=p[i];
                    suc=true;
                }
            }

            if(!suc) continue;
            long long le=0,ri=0;

            for(int i=0,j=0; i<26; ++i) {
                if(isused[i]) {
                    if(p[j]==0 && istop[i]) suc=false;
                    le+=coef_l[i]*p[j];
                    ri+=coef_r[i]*p[j];
                    ++j;
                }
            }
            
            if(suc && (le==ri)) {
                ans++;
            }

        } while(next_permutation(p,p+10));

        cout<<ans<<'\n';
    }
}


Measured memory_bytes: 3048
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string S;
	cin >> S;

	if (S[1] == 'R') S[1] = 'B';
	else S[1] = 'R';

	cout << S << "\n";

	return 0;
}

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

int main() {

	ll n, k; cin >> n >> k;
	vector<ll> num(k, 0);
	for (ll i = 1; i <= n; i++) {
		num[i % k]++;
	}
	ll ans = 0;
	for (ll a = 0; a < k; a++) {
		ll b = (k - a) % k;
		ll c = (k - a) % k;
		if ((b + c) % k != 0) continue;
		ans += num[a] * num[b] * num[c];
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	if(a % 3 == 0
	|| b % 3 == 0
	|| (a + b) % 3 == 0)
		cout << "Possible" << endl;
	else
		cout << "Impossible" << endl;	
} 

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

using namespace std;

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

int n;
double r;
int t[100];
vector<int> x,y;
int main(){
  while(1){
    cin>>r>>n;
    if(r==0&&n==0)break;
    for(int i=0;i<100;i++)t[i]=0;
    for(int i=0;i<n;i++){
      int a,b,c;
      cin>>a>>b>>c;
      a+=50,b+=50;
      for(int j=a;j<b;j++)t[j]=max(t[j],c);
    }
    x.clear(),y.clear();
    for(int i=0;i<50;i++){
      x.push_back(50-i-1);
      y.push_back(t[i]);
    }
    for(int i=50;i<100;i++){
      x.push_back(i-50);
      y.push_back(t[i]);
    }
    double ans=(1<<28);
    for(int i=0;i<(int)x.size();i++){
      if(r-0.00000001<x[i])continue;
      double d=y[i]-sqrt(r*r-x[i]*x[i]);
      ans=min(d,ans);
    }
    printf("%.8f\n",ans+r);
  }
  return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<ll> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    SORT(A);
    vector<pll> p;
    Rep(i, 1, N-1){
        if(A.front() <= 0 && 0 <= A.back()){
            if(A[i] < 0){
                p.emplace_back(A.back(), A[i]);
                A.back() -= A[i]; 
            }else{
                p.emplace_back(A.front(), A[i]);
                A.front() -= A[i];
            }
        }else if(A.front() >= 0){
            p.emplace_back(A.front(), A[i]);
            A.front() = -abs(A.front() - A[i]);
        }else{
            p.emplace_back(A.back(), A[N-2]);
            A.back() = A.back() - A[N-2];
            for(int j = N-2; j > i; j--) A[j] = A[j-1]; 
        }
    }

    ll ans = abs(A.back() - A.front());
    p.emplace_back(A.back(), A.front());

    pr(ans);
    for(auto&& pi : p) pr(pi.fi, pi.se);
}

Measured memory_bytes: 4336
import math
def C(a,b):
    if a < b:
        return 0
    else:
        return math.factorial(a) // (math.factorial(b)*math.factorial(a-b))

N = int(input())
if N == 1:
    print(0)

else:
    PF = dict()
    for i in range(2, N+1):
        n = i
        for x in PF.keys():
            while n % x == 0:
                n //= x
                PF[x] += 1
        if n != 1:
            PF[n] = 1
    
    count, number = [0]*5, [3, 5, 15, 25, 75]
    for x in PF.values():
        for i in range(5)[::-1]:
            if x + 1 >= number[i]:
                count[i] += 1
                break
    ans = 0
    ans += C(count[0], 1) * C(sum(count[1:]), 2) + 3 * C(sum(count[1:]), 3)
    ans += C(count[1], 1) * C(sum(count[2:]), 1) + 2 *C(sum(count[2:]), 2)
    ans += C(sum(count[:3]), 1) * C(sum(count[3:]), 1) + 2 * C(sum(count[3:]), 2)
    ans += count[4]
    print(ans)

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

using namespace std;
///---------------------- Ford-Fulkerson O(MaxFlow * |E|) ----------------------

struct OutEdge {
	int to, cap, rIdx;
	OutEdge ( ) { }
	OutEdge(int to, int cap, int rIdx) :
		to(to), cap(cap), rIdx(rIdx) { }
};

struct Network{
	vector<vector<OutEdge> > out;
	vector<bool> seen;

	int sink;
	int augment ( int i, const int cur ) {
		if ( i == sink ) return cur;
		if ( seen[i] ) return false;
		seen[i] = true;
		int ans;
		for ( OutEdge& e : out[i] )
			if ( e.cap > 0 && ( ans = augment(e.to,min(cur,e.cap)) ) ) {
				e.cap -= ans;
				out[e.to][e.rIdx].cap += ans;
				return ans;
			}
		return 0;
	}

	int maxflow ( int source, int _sink ) {
		sink = _sink;
		int curflow = 0, aug;
		while ( true ) {
			fill ( seen.begin(), seen.end(), false );
			aug = augment(source,INT_MAX);
			if ( aug == 0 ) break;
			curflow += aug;
		}
		return curflow;
	}

	void addEdge ( int fr, int to, int c ) {
		assert ( fr != to );
		out[fr].push_back(OutEdge(to, c, out[to].size()));
		out[to].push_back(OutEdge(fr, 0, out[fr].size() - 1));
	}

	Network(int n) {
		out.assign(n, vector<OutEdge>());
		seen.resize(n);
	}
};

int main(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  #ifdef Larra
  freopen("in","r",stdin);
  freopen("out","w",stdout);
  #endif
  int n, m;
  cin>>n>>m;
  Network netw(n);
  for(int i = 0; i < m; i++){
    int a, b, c;
    cin>>a>>b>>c;
    netw.addEdge(a, b, c);
  }
  cout<<netw.maxflow(0, n-1)<<"\n";
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    long long n,k;
    cin>>n>>k;
    int a[n+1];
    map<int,bool>cycle1,cycle2;
    for(int i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    int pos = 1,cnt=0;
    while(cycle1[pos] == 0)
    {
        cycle1[pos] = 1;
        pos = a[pos];
        cnt++;
        if(cnt == k)return cout<<pos,0;
    }
    k-=cnt;
    cnt = 0;
    while(cycle2[pos] == 0)
    {
        cycle2[pos] = 1;
        pos = a[pos];
        cnt++;
        if(cnt == k)return cout<<pos,0;
    }
    k = k % cnt;
    while(k > 0)
    {
        pos = a[pos];
        k--;
    }
    cout<<pos<<endl;

    return 0;
}


Measured memory_bytes: 16880
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{

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

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif  

    int n;
    cin>>n;
    vector<int>ans;
    for(int i=2;i*i<=n;i++)
    {
        int cnt=0;
        if(n%i==0)
        {
            while (n%i==0)
            {
                n/=i;
                cnt++;
            }      
            ans.push_back(cnt);      
        }
    }
        if(n!=1)
        {
            ans.push_back(1);
        }
    int res=0;

    for(auto i:ans)
    {
        int l=1,r=60;
        int mx=0;
        while (l<=r)
        {
            int mid=l+(r-l)/2;
            int k=(mid*(mid+1))/2;
            if(k<=i)
            {
                mx=max(mx,mid);
                l=mid+1;
            }
            else
            {
                r=mid-1;
            }            
        }
        res+=mx;
        
    }
    cout<<res;
  
} 



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

int compare(const void *a, const void *b){
	int *A = (int *)a;
	int *B = (int *)b;
	if (*A > *B) return 1;
	if (*A < *B) return -1;
	return 0;
}

int main(){
	int a[3];
	for(int i=0;i<3;i++)scanf("%d",&a[i]);
	qsort(a,3,sizeof(int),compare);
	
	int ans=0;
	ans+=a[2]-a[1];
	a[0]+=a[2]-a[1];
	a[1]=a[2];
	ans+=(a[2]-a[0])/2;
	if((a[2]-a[0])%2==1)ans+=2;
	
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl(), k = inl();
        vl v(n);
        rep(i, n) cin >> v[i];

        ll ans = 0;
        rep(i, k + 1) {
            ll tmp = 0;

            for (ll s = 0; s <= k; s++) {
                for (ll j = min(n - 1, s - 1 - i); j >= 0; --j) {
                    minPQ<ll> pq;
                    for (ll l = 0; l <= j; l++) {
                        pq.push(v[l]);
                    }
                    ll res = min(n - 1, s - 1 - i) - j - 1;
                    for (ll l = 0; l <= res; l++) {
                        pq.push(v[n - 1 - l]);
                    }

                    ll tmp2 = 0;
                    ll c = i;
                    while (!pq.empty()) {
                        if (c) pq.pop(), c--;
                        else {
                            tmp2 += pq.top();
                            pq.pop();
                        }
                    }
                    tmp = max(tmp2, tmp);
                }
            }
            ans = max(tmp, ans);
        }
        cout << ans << endl;


#ifdef MY_DEBUG
    }
#endif
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a; cin >>N;
  string S, Sa, Sb; cin >> S;
  a = N/2;
  if(N%2==1){
    cout << "No" << endl;
  }
  else{
    Sa = S.substr(0, a);
    Sb = S.substr(a);
    if(Sa == Sb){
      cout << "Yes" << endl;
    }
    else{
      cout << "No" << endl;
    }
  }
}

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

using namespace std;

int main()
{
	string s;
	cin >> s;
	string r;
	for (int i = s.size()-1; i >= 0; i--)
	{
		if (s[i] != 'B') r += s[i];
		else 
		{
			int count = 0;
			while (s[i] == 'B') { count++; i--;};
			i -= (count - 1);
		}
	}
	reverse(r.begin(), r.end());
	cout << r << endl;
	return 0;
}


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

int main()
{
    int H, W;
    cin >> H >> W;

    // ここにプログラムを追記
    // (ここで"試合結果の表"の2次元配列を宣言)
    vector<vector<char>> fig(H, vector<char>(W));
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> fig.at(i).at(j);
        }
    }
    /*    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cout << fig.at(i).at(j);
        }
        cout << endl;
    }*/
    int wflag;
    for (int i = 0; i < H; i++)
    {
        wflag = 0;
        for (int j = 0; j < W; j++)
        {
            if (fig.at(i).at(j) == '.')
            {
                wflag++;
            }
        }
        if (wflag == W)
        {
            for (int j = 0; j < W; j++)
            {
                fig.at(i).at(j) = '0';
            }
        }
    }
    int hflag;
    for (int j = 0; j < W; j++)
    {
        hflag = 0;
        for (int i = 0; i < H; i++)
        {
            if (fig.at(i).at(j) == '.' || fig.at(i).at(j) == '0')
            {
                hflag++;
            }
        }
        if (hflag == H)
        {
            for (int i = 0; i < H; i++)
            {
                fig.at(i).at(j) = '0';
            }
        }
    }
    int oflag;
    for (int i = 0; i < H; i++)
    {
        oflag = 0;
        for (int j = 0; j < W; j++)
        {
            if (fig.at(i).at(j) != '0')
            {
                cout << fig.at(i).at(j);
                oflag = 1;
            }
        }
        if (oflag != 0)
        {
            cout << endl;
        }
    }
}


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

using ll = long long;

constexpr ll inf = 1e18;

ll mul(ll a, ll b) {
    if(a > inf / b) return inf;
    return a * b;
}

ll mypow(ll x, ll n) {
    ll res = 1;
    while(n > 0) {
        if(n & 1) {
            res = mul(res, x);
        }
        x = mul(x, x);
        n >>= 1;
    }
    return res;
}

ll solve(ll n, ll m, ll a, ll b, ll p, ll q) {
    if(a == 1 && b == 1) {
        const ll t = (p + q);
        ll sum = mul(t, n);
        if(sum <= m) return m - sum;
        return min(m % t, t - m % t);
    }

    vector<ll> s1, s2, t1, t2;
    for(int i = 0; i < min(n, 40LL); ++i) {
        (i & 1 ? s1 : s2).push_back(mul(mypow(a, i), p) + mul(mypow(b, i), q));
    }
    const int sz1 = s1.size(), sz2 = s2.size();
    for(int S = 0; S < (1 << sz1); ++S) {
        ll sum = 0;
        for(int i = 0; i < sz1; ++i) {
            if(S & (1 << i)) sum = min(inf, sum + s1[i]);
        }
        t1.push_back(sum);
    }
    for(int S = 0; S < (1 << sz2); ++S) {
        ll sum = 0;
        for(int i = 0; i < sz2; ++i) {
            if(S & (1 << i)) sum = min(inf, sum + s2[i]);
        }
        t2.push_back(sum);
    }
    sort(begin(t1), end(t1));
    sort(begin(t2), end(t2));

    ll res = m;
    const int tsz2 = t2.size();
    for(auto x1 : t1) {
        const ll target = m - x1;
        const int idx = lower_bound(begin(t2), end(t2), target) - begin(t2);
        for(int i = idx - 1; i <= idx + 1; ++i) {
            if(i < 0 || tsz2 <= i) continue;
            res = min(res, abs(m - (x1 + t2[i])));
        }
    }

    return res;
}

int main() {
    ll n, m, a, b, p, q;
    cin >> n >> m >> a >> b >> p >> q;

    cout << solve(n, m, a, b, p, q) << endl;
}


Measured memory_bytes: 23324
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

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

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[100100];

int main() {
    int n; cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n) dp[i] = INF;
    dp[0] = 0;
    rep(i,n) {
        dp[i+1] = min(dp[i+1],dp[i]+abs(h[i]-h[i+1]));
        dp[i+2] = min(dp[i+2],dp[i]+abs(h[i]-h[i+2]));
    }
    cout << dp[n-1] << endl;
    return 0;
}

























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

int main( void )
{
    int a,b;
    cin >> a >> b;
    
    ll ans = max(max(a+b,a-b),a*b);
    cout << ans << endl;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
// using System.Linq;

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // int[] nx = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // long K = long.Parse(Console.ReadLine());
            // int[] ABC = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());
            // string A = Console.ReadLine();
            // string B = Console.ReadLine();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(int.Parse);
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // for(int i = 0; i<A_num.Length;i++){
            //     A_num[i] = 0;
            // }
            int fee =0;
            for(int i = 1; i <=N ;i++){
                if(i <= K){
                    fee += X;
                }else{
                    fee += Y;
                }
            }
            Console.WriteLine(fee);
        }
        //最小公倍数
        static long Lcm(long a, long b)
        {
            return a/Gcd(a,b)*b;
        }

        //最大公約数
        static long Gcd(long m, long n)
        {
            if(n==0)return m;
            return Gcd(n,m%n);
        }
    }
}

Measured memory_bytes: 13140