akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

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

using namespace std;

int main() {
  int h, w;
  std::cin >> h >> w;
  std::vector<string> s(h);
  rep(i, h) std::cin >> s[i];

  bool ok = true;
  rep(i, h) {
    rep(j, w) {
      if (s[i][j] == '#') {
        int dx1 = i - 1;
        int dx2 = i + 1;
        int dy1 = j - 1;
        int dy2 = j + 1;

        if ((dx1 >= 0 && dx2 < h && s[dx1][j] != '#' && s[dx2][j] != '#') &&
            (dy1 >= 0 && dy2 < w && s[i][dy1] != '#' && s[i][dy2] != '#')) {
          ok = false;
        }
      }
    }
  }

  std::cout << (ok ? "Yes" : "No") << std::endl;
  return 0;
}


Measured memory_bytes: 3604
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;

int main()
{
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <math.h>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstdlib>

using namespace std;

int main() {
    
    int N,M;
    cin >> N >> M;
    string out = "No";
    if(N == M) out = "Yes";
    cout << out << endl;
    return 0;
}


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

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

    if (k > a) {
        cout << "0 " << max(a + b - k, 0ll) << endl;
    } else {
        cout << a - k << " " << b << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    double solve(int a, int b, int x) {
        double PI = acos(-1) / 2;
        long long V = a * a * b;
        if (x * 2 <= V) {
            double c = (double) x * 2.0 / (a * b);
            double A = acos((double)b / hypot(c, b));
            double res = 90.0 - A / PI * 90.0;
            return res;
        }
        double h = (2.0 * x - a * a * b) / (a * a);
        double A = asin((double) a / hypot(a, b - h));
        double res = 90.0 - A / PI * 90.0;
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cout << fixed << setprecision(12);

    int a, b, x;
    cin >> a >> b >> x;
    Solution sol;
    cout << sol.solve(a, b, x) << "\n";

    return 0;
}

Measured memory_bytes: 256
// copy from AKMer
// https://www.cnblogs.com/AKMer/p/10077087.html

#include <set>
#include <cstdio>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=2e5+5,inf=2e9;

multiset<int>R,B;
ll Rmx=-inf,Rmn=inf,Bmx=-inf,Bmn=inf,ans;

int read() {
    int x=0,f=1;char ch=getchar();
    for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
    for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
    return x*f;
}

struct bags {
    int v1,v2;

    bags() {}

    bags(int _v1,int _v2) {
        v1=_v1,v2=_v2;
    }

    bool operator<(const bags &a)const {
        return v1<a.v1;
    }
}p[maxn];

ll calc() {
    return 1ll*(*R.rbegin()-*R.begin())*(*B.rbegin()-*B.begin());
}

int main() {
    int n=read();
    for(int i=1;i<=n;i++) {
        int x=read(),y=read();
        if(x>y)swap(x,y);
        p[i]=bags(x,y);
        R.insert(x),B.insert(y);
    }
    sort(p+1,p+n+1);
    ans=calc();
    for(int i=1;i<=n;i++) {
        int x=p[i].v1,y=p[i].v2;
        R.erase(R.find(x)),B.insert(x);
        B.erase(B.find(y)),R.insert(y);
        ans=min(ans,calc());
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 22528
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>

const int maxn = 1e5 + 20;
const int maxs = (1 << 16) + 7;

int n;
int val[maxn], cnt[16], ans;
int dp[maxs];

template<class TAT>void checkmin(TAT &x,const TAT &y)
{
	if(y < x) x = y;
}
int dfs(int x)
{
	if(dp[x] != -1) return dp[x];
	
	dp[x] = maxs;
	
	for(int i = 0; i < 16; i++)
		for(int j = 0; j < 16; j++)
			if(i != j && ((x >> i) & 1) && ((x >> j) & 1))
			{
				int tmp = x ^ (1 << i) ^ (1 << j);
				int modify = i ^ j;
				
				checkmin(dp[x], dfs(tmp ^ (1 << modify)) + 1 + ((tmp >> modify) & 1));
			}
	
	return dp[x];
}
int main()
{
	scanf("%d", &n);
	for(int i = 1, x, y, a; i < n; i++)
	{
		scanf("%d%d%d", &x, &y, &a);
		++x, ++y;
		val[x] ^= a, val[y] ^= a;
	}
	
	for(int i = 1; i <= n; i++)
	{
		if(val[i])
		{
			ans += cnt[val[i]];
			cnt[val[i]] ^= 1;
		}
	}
	
	int now = 0;
	
	for(int i = 0; i < 16; i++) now |= (1 << i) * cnt[i];
	
	memset(dp, -1, sizeof(dp));
	dp[0] = 0;
	ans += dfs(now);
	
	printf("%d\n", ans);
	return 0;
}

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

int main(){
	int N;
	int A[21];
	int B[21];
	int C[21];

	cin >> N;


	for(int i = 1; i <= N; i++){
		cin >> A[i];
	}
	
	
	for(int i = 1; i <= N; i++){
		cin >> B[i];
	}
	
	
	for(int i = 1; i < N; i++){
		cin >> C[i];
	}

	int sum = 0;

	sum += B[ A[1] ];
	for(int i = 2; i <= N; i++){
		int food_id = A[i];
		sum += B[ food_id ];
		if( A[i-1] + 1 == A[i] ) sum += C[ food_id - 1 ];
	}

	cout << sum << endl;
	
}


Measured memory_bytes: 256
w,h,n = map(int,input().split())
ab = [-1]*2
cd = [10000]*2
for _ in range(n):
    x, y, a = (int(x) for x in input().split())
    if a == 1:
        ab[0] = max(ab[0],x)
    elif a == 3:
        ab[1] = max(ab[1],y)
    elif a == 2:
        cd[0] = min(cd[0],x)
    elif a == 4:
        cd[1] = min(cd[1],y)

if ab[0] != -1 and cd[0] != 10000:
    if cd[0] <= ab[0]:
        yoko = 0
    else:
        yoko = cd[0]-ab[0]
elif ab[0] != -1:
    yoko = w-ab[0]
elif cd[0] != 10000:
    yoko = cd[0]
else:
    yoko = w

if ab[1] != -1 and cd[1] != 10000:
    if cd[1] <= ab[1]:
        tate = 0
    else:
        tate = cd[1]-ab[1]
elif ab[1] != -1:
    tate = h-ab[1]
elif cd[1] != 10000:
    tate = cd[1]
else:
    tate = h

print(yoko*tate)

Measured memory_bytes: 38256
class ReversePopHeap
  attr_accessor :nodes, :size
  def initialize(n)
    @nodes = Array.new(n)
    @size = 0
  end

  def push(x)
    current_index = @size
    @size += 1
    while current_index > 0 do
      parent_index = (current_index - 1)>>1
      parent_value = @nodes[parent_index]
      break if parent_value >= x
      @nodes[current_index] = parent_value
      current_index = parent_index
    end
    @nodes[current_index] = x
  end

  def pop
    top = @nodes[0]
    current_node_index = 0
    current_node_value = @nodes[0] = @nodes[@size - 1]
    @nodes[@size - 1] = nil
    @size -= 1

    while
      child_node_index_r = (current_node_index + 1) << 1
      child_node_index_l = child_node_index_r - 1
      return top unless child_node_index_l < @size
      child_node_value_l = @nodes[child_node_index_l]
      child_node_value_r = @nodes[child_node_index_r]
      if child_node_value_r&.>child_node_value_l
        max_child_value = child_node_value_r
        max_child_index = child_node_index_r
      else
        max_child_value = child_node_value_l
        max_child_index = child_node_index_l
      end
      return top unless max_child_value > current_node_value
      change(current_node_index, max_child_index)
      current_node_index = max_child_index
    end
  end

  private

  def change(index_i, index_j)
    @nodes[index_i], @nodes[index_j] = @nodes[index_j], @nodes[index_i]
  end
end

n, m = gets.split.map(&:to_i)

values = []
n.times do
  a, b = gets.split.map(&:to_i)
  values << (a << 17) + b
end
values.sort!

mask = (1 << 17) - 1

rhp = ReversePopHeap.new(n)
ans = 0
ite = 0
1.step(m) do |limit_day|
  while true
    break unless values[ite] && (values[ite] >> 17) == limit_day
    rhp.push(values[ite] & mask)
    ite += 1
  end
  ans += rhp.pop.to_i if rhp.size > 0
end

puts ans

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

using namespace std;

int main()

{
    int a;
    cin>>a;
    if(a==1||a==10||a==100||a==1000||a==10000||a==100000)
    cout<<"10"<<endl;
    else
    {
        int sum=0,num;
        while(a!=0)
        {
            num=a%10;
            sum+=num;
            a/=10;
        }
        cout<<sum;
    }
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
long long int x[100005], y[100005];
int asc1(const void* a, const void* b)
{
	if (x[*(long long int*)a] > x[*(long long int*)b])return 1;
	if (x[*(long long int*)a] < x[*(long long int*)b])return -1;
	return 0;
}
int asc2(const void* a, const void* b)
{
	if (y[*(long long int*)a] > y[*(long long int*)b])return 1;
	if (y[*(long long int*)a] < y[*(long long int*)b])return -1;
	return 0;
}
long long int llabs(long long int n)
{
	if (n < 0)
		n *= -1;
	return n;
}
long long int dist(long long int a, long long int b)
{
	if (llabs(x[a] - x[b]) < llabs(y[a] - y[b]))
		return llabs(x[a] - x[b]);
	else
		return llabs(y[a] - y[b]);
}
long long int h[200005], l;
void swap_h(long long int a, long long  int b)
{
	long long int f = h[a];
	h[a] = h[b];
	h[b] = f;
	return;
}
int comp_h(long long int a, long long int b)
{
	long long int a1, a2, b1, b2;
	a = h[a];
	b = h[b];
	a1 = a / 100000;
	a2 = a % 100000;
	b1 = b / 100000;
	b2 = b % 100000;
	if (dist(a1, a2) > dist(b1, b2))return 1;
	return 0;
}
void f1(long long int n)
{
	h[l] = n;
	long long int now = l;
	l++;
	while (now > 0)
	{
		if (comp_h((now - 1) / 2, now) > 0)
			swap_h((now - 1) / 2, now);
		now = (now - 1) / 2;
	}
	return;
}
long long int f2()
{
	l--;
	swap_h(0, l);
	long long int now = 0;
	for (;;)
	{
		if (2 * now + 2 < l)
		{
			if (comp_h(2 * now + 1, 2 * now + 2) > 0)
			{
				if (comp_h(now, 2 * now + 2) > 0)
					swap_h(now, 2 * now + 2);
				now = 2 * now + 2;
			}
			else
			{
				if (comp_h(now, 2 * now + 1) > 0)
					swap_h(now, 2 * now + 1);
				now = 2 * now + 1;
			}
		}
		else if (2 * now + 1 < l)
		{
			if (comp_h(now, 2 * now + 1) > 0)
				swap_h(now, 2 * now + 1);
			now = 2 * now + 1;
		}
		else
			break;
	}
	return h[l];
}
long long int p[100005];
long long int root(long long int n)
{
	if (p[n] != n)
		p[n] = root(p[n]);
	return p[n];
}
void uni(long long int a, long long int b)
{
	a = root(a);
	b = root(b);
	if (a != b)
		p[a] = b;
	return;
}
int main()
{
	long long int n;
	scanf("%lld", &n);
	long long int i, j;
	for (i = 0; i < n; i++)
		scanf("%lld %lld", &x[i], &y[i]);
	long long int a[100005], b[100005];
	for (i = 0; i < n; i++)
		a[i] = b[i] = i;
	qsort(a, n, sizeof(long long int), asc1);
	qsort(b, n, sizeof(long long int), asc2);
	l = 0;
	for (i = 0; i < n - 1; i++)
		f1(100000 * a[i] + a[i + 1]);
	for (i = 0; i < n - 1; i++)
		f1(100000 * b[i] + b[i + 1]);
	for (i = 0; i < n; i++)
		p[i] = i;
	long long int ans = 0;
	while (l > 0)
	{
		i = f2();
		j = i / 100000;
		i %= 100000;
		if (root(i) != root(j))
		{
			ans += dist(i, j);
			uni(i, j);
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 7916
#include <iostream>

int GetFizzBuzzVal(int n)
{
    if (n % 3 == 0)
    {
        return 0;
    }
    else if (n % 5 == 0)
    {
        return 0;
    }
    
    return n;
}

int main()
{
    int n = 0;
    std::cin >> n;
    long long sum = 0;

    for (auto count = 1; count <= n; ++count)
    {
        sum += GetFizzBuzzVal(count);
    }

    std::cout << sum;

    return 0;
}

Measured memory_bytes: 3620
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
  int  n=kbd.nextInt();
  int  w=kbd.nextInt();
  if(n>w){
    System.out.println("safe");
  }else{
    System.out.println("unsafe");
  }
}
}



Measured memory_bytes: 35828
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<20;


LL c[26];

LL dfs(int k,LL sum){
    if(k==26) return sum;
    LL ret = (dfs(k+1,(sum*c[k])%mod) + dfs(k+1,sum))%mod;
    return ret;
}

int main(){
    int n;cin >> n;
    string s;cin >>s;
    for (int i = 0; i < s.length(); i++) {
        c[s[i]-'a']++;
    }
    cout << (dfs(0,1)-1+mod)%mod << endl;
    return 0;
}


Measured memory_bytes: 512
#include <stdio.h>
int main()
{
  long a,b,c;
  scanf("%ld %ld %ld",&a,&b,&c);
  if (!((a >= 1 && a <= 1000000000) && (b >= 1 && b <= 1000000000) && (c >= 1 && c <= 1000000000)))
  {
    printf("No");
    return(0);
  }
  if (c-a-b < 0)
  {
 	 if (4*(a*b) < (c-a-b)*(c-a-b)*(-1))
  	{
   	 printf("Yes");
  	}
 	 else
 	 {
  	  printf("No");
 	 }
  }
  else
  {
 	 if (4*(a*b) < (c-a-b)*(c-a-b))
  	 {
   	 printf("Yes");
  	 }
 	 else
 	 {
  	  printf("No");
 	 }
  }
}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <limits>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <numeric>
#include <unordered_set>
#include <unordered_map>
#include <chrono>
#include <random>
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define PI 3.14159265358979323846
#define min(a,b) ((a<b)?(a):(b))
#define max(a,b) ((a<b)?(b):(a))
#define abs(a) ((a>0)?a:-(a))
#define pii pair<int,int>

const double eps = (double)1e-6;
const int maxn = 1e5+5;
const ll mod = 1e9+7;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());


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

    int h,n; cin >> h >> n;
    for (int i = 0; i < n; i++) {
        int a; cin >> a;
        h -= a;
        if (h <= 0) {cout << "Yes" << endl; return 0;}
    }
    cout << "No" << endl;

}



Measured memory_bytes: 256
using System;

public class ITP1_11_A{
    public static void Main(){
        var values = Console.ReadLine().Split(' ');
        
        Dice dice = new Dice
        {
            Top = values[0],
            South = values[1],
            East = values[2],
            West = values[3],
            North = values[4],
            Bottom = values[5]
        };
        
        foreach (char cmd in Console.ReadLine())
        {
            switch (cmd)
            {
                case 'E':
                    dice.RollToEast();
                    break;
                case 'N':
                    dice.RollToNorth();
                    break;
                case 'S':
                    dice.RollToSouth();
                    break;
                default:
                    dice.RollToWest();
                    break;
            }
        }
        
        Console.WriteLine(dice.Top);
    }
    
    class Dice
    {
        public string Top { get; set; }
        public string Bottom { get; set; }
        public string North { get; set; }
        public string South { get; set; }
        public string East { get; set; }
        public string West { get; set; }
        
        public void　RollToNorth()
        {
            string tmp = this.North;
            this.North = this.Top;
            this.Top = this.South;
            this.South = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToSouth()
        {
            string tmp = this.South;
            this.South = this.Top;
            this.Top = this.North;
            this.North = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToEast()
        {
            string tmp = this.East;
            this.East = this.Top;
            this.Top = this.West;
            this.West = this.Bottom;
            this.Bottom = tmp;
        }
        
        public void　RollToWest()
        {
            string tmp = this.West;
            this.West = this.Top;
            this.Top = this.East;
            this.East = this.Bottom;
            this.Bottom = tmp;
        }
    }
}



Measured memory_bytes: 15884
N = int(input())
R = [0]*(N)
C = [0]*(N)
for i in range(N):
    R[i], C[i] = map(int, input().split())

dp = [[1<<60]*(N+1) for i in range(N+1)]
for i in range(N+1):
    dp[i][i] = 0

for le in range(1, N):
    for i in range(N-le):
        j = i + le

        for k in range(i, j):
            tmp = dp[i][k] + dp[k+1][j] + R[i]*C[k]*C[j]
            dp[i][j] = min(dp[i][j], tmp)
print(dp[0][N-1])


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<ll, ll>;
string char_to_string(char val) {
  return string(1, val);
}
int char_to_int(char val) {
  return val - '0';
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
struct edge {
  ll to, cost;
};

int main() {
  int N; cin >> N;
  vector<ll> A(N); REP(i, N) cin >> A[i];
  map<int, int> m;
  REP(i, N) {
    if(m[A[i]]) m.erase(A[i]);
    else m[A[i]]++;
  }
  cout << m.size() << endl;
}

Measured memory_bytes: 8636
#include <cstdio>
long long a,b,s;

bool check(long long x){
    
    if(x*x < s) return true;
    return false;
}

void swap(long long &a, long long &b){

    a = a^b;
    b = a^b;
    a = a^b;
}
int main(int argc, const char * argv[]) {
   
    int q;
    
    scanf("%d",&q);
    
    for(int i=0;i<q;i++){
        
        scanf("%lld %lld",&a,&b);
        
        s = a*b;
        long long ans = 0;
        if(a<b){ //a가 작은경우
            ans += 2*(a-1);
        }else if(a==b){
            printf("%lld\n",2*(b-1));
            continue;
        }else{
            ans += 2*(b-1);
            swap(a,b);
        }
        
        if(a+1 != b){
            
            long long l = a+1;
            long long r = b-1;
            long long val = 0;
            while(l<=r){
                
                long long mid = (l+r)/2;
                
                if(check(mid)){
                    l = mid+1;
                    val = mid;
                }else{
                    r = mid-1;
                }
            }
            
            if(val!=0){
                if(val *(val+1) < s) ans += 2*(val-a);
                else ans += 2*(val-a) - 1 ;
            }
            ans++;
            
        }
        printf("%lld\n",ans);
    }
    
    return 0;
}


Measured memory_bytes: 128
n,x = map(int,input().split())
a = list(map(int,input().split()))
a = a[-1:] + a

ans = 10**9 * n
for i in range(n):
    ans = min(ans,sum(a[1:])+i*x)
    for j in range(n,0,-1):
        a[j] = min(a[j],a[j-1])
    a[0] = a[-1]
print(ans)

Measured memory_bytes: 74252
#include<bits/stdc++.h>
using namespace std;
#define lps(i,j,n) for(int i=j;i<n;i++)
#define lp(i,n) lps(i,0,n)
#define DEKAI 1000000007
#define INF (1<<28)
#define int long long

signed main(){
  while(1){
    int t,d,l;
    cin>>t>>d>>l;
    if(t==0&&d==0&&l==0) break;
    int stat=INF,ans=0;
    lps(i,1,t+1){
      if(stat<d) ans++;
      int a;
      cin>>a;
      if(a>=l) stat=0;
      else stat++;
      // cout<<stat<<endl;
    }
    cout<<ans<<endl;
  }
  return 0;
  
}



Measured memory_bytes: 3052
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const ll MOD = 1000000007;
ll fac[MAX], finv[MAX], inv[MAX];


int main(){
 ll n,m,k,ans=0;cin>>n>>m>>k;
 vll a(n+1,0),b(m+1,0);
 rep(i,0,n){
   ll x;
   cin>>x;
   a[i+1]=a[i]+x;
 }
 rep(i,0,m){
   ll x;
   cin>>x;
   b[i+1]=b[i]+x;
 }
 rep(i,0,n+1){
   if(k<a[i]){continue;}
   auto ite=upper_bound(b.begin(),b.end(),k-a[i]);
   ll it=ite-b.begin();
   if(ite==b.end()){
     if(*ite==k-a[i]){
       it++;
     }
   }
   
   ans=max(ans,i+it-1);
   
 }
 cout<<ans<<endl;
}






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

using namespace std;
typedef long long ll;

int main() {
    int n;
    ll x;
    cin >> n >> x;
    ll as[n];
    ll mins[n];
    ll res = 0;
    for(int i=0; i<n; i++) {
        cin >> as[i];
        mins[i] = as[i];
        res += as[i];
    }
    for(int t=1; t<n; t++) {
        ll tmp = min(mins[0], mins[n-1]);
        ll alltime = tmp;
        for(int i=n-1; i>0; i--) {
            mins[i] = min(mins[i], mins[i-1]);
            alltime += mins[i];
        }
        mins[0] = tmp;
        res = min(res, alltime+t*x);
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define GRAVITY (1.0)
#define EPSILON (0.000001)

int main(void) {
	int d; /* 目標距離 */
	int n; /* 障害物の個数 */
	int b; /* バウンド回数の上限 */
	int p[10]; /* 障害物の座標 */
	int h[10]; /* 障害物の高さ */
	double vmin;
	int i, j;

	/* 入力 */
	scanf("%d%d%d", &d, &n, &b);
	for (i = 0; i < n; i++) scanf("%d%d", p + i, h + i);

	/* 速さの最小値を探す */
	for (i = 1; i <= b + 1; i++) {
		double vx, vy, top, bottom, t, tb, vi;
		/* 二分探索 */
		top = 10000.0; /* 最大値を仮定 */
		bottom = 0.0;
		while (top - bottom >= EPSILON) {
			vy = bottom + (top - bottom) / 2.0;
			tb = vy * 2.0 / GRAVITY; /* バウンド周期 (v = v0 - g * t で v = -v0 より) */
			vx = 1.0 * d / i / tb;
			/* 各障害物について衝突するか調べる */
			for (j = 0; j < n; j++) {
				t = p[j] / vx; /* 障害物のx座標に到達する時刻 */
				while (t >= tb) t -= tb;
				if (- 0.5 * GRAVITY * t * t + vy * t <= h[j]) break; /* 衝突 */
			}
			if (j < n) bottom = vy; /* 衝突した */
			else if (vy > vx) top = vy; /* 衝突しなかった */
			else bottom = vy;
			/* debug */
			/* printf("%.5f (%2d: %.5f %.5f) (%.5f - %.5f)\n", sqrt(vx * vx + vy * vy), i, vx, vy, bottom, top); */
		}
		/* 最小値をとる */
		vi = sqrt(vx * vx + vy * vy);
		if (i == 1 || vi < vmin) vmin = vi;
	}

	/* 出力 */
	printf("%.6f\n", vmin);

	return 0;
}

Measured memory_bytes: 636
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
inline ll read(){ll s=0,w=1;char ch=getchar();
while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=getchar();}
while(ch>='0'&&ch<='9') s=s*10+ch-'0',ch=getchar();
return s*w;}
string str,s1,s2;
int main(){
	cin>>str;
	s1="",s2="";
	int cnt=0;
	ll q=read();
	while(q--){
		ll t=read();
		if(t==1) cnt++;
		else {
			int f;
			char a;
			cin>>f>>a;
			if(f==1) {
				if(cnt%2!=0) s2.insert(s2.end(),a);
				else s1.insert(s1.begin(),a);
			}
			else {
				if(cnt%2!=0) s1.insert(s1.begin(),a);
				else s2.insert(s2.end(),a);
			}
		}
	}
	if(cnt%2!=0){
		reverse(str.begin(),str.end());
		reverse(s1.begin(),s1.end());
		reverse(s2.begin(),s2.end());
		cout<<s2<<str<<s1;
	}
	else cout<<s1<<str<<s2;
}

Measured memory_bytes: 1088
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
//using namespace __gnu_pbds;

typedef long long int ll;
 
//typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 

 
const ll N = 200005;
const ll mod = 998244353;
const long long int inf = 10e17;
#define pp pair<ll,ll>

typedef long double ld;
typedef vector<pp> vpl;
#define MP make_pair
#define endl "\n"
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<n;i++)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define repb(i,n) for(ll i=1;i<n-1;i++) 
#define trace(i,a) for(auto i=a.begin();i!=a.end();i++) 
#define mtrace(i,a) for(auto i=a.begin();i!=a.end();i++)  cout<<i->first<<" "<<i->second<<endl;   
 
const ld pi = 3.14159265359;

mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}

 
void fastIO(void);
void decimal(int);
ll modmulti(ll, ll);
ll modadd(ll, ll);
ll modpower(ll, ll);
ll gcd(ll, ll );
ll modinv(ll);


int main()
{
	ll x,y,res;
	cin>>x;
	y = x/500;
	res = y*1000;
	x = x%500;
	y = x/5;
	res+=y*5;
	cout<<res<<endl;
}

	


 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
void fastIO(void)
{  ios_base::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
}
 
void decimal(int n){
   cout<<fixed;
   cout<<setprecision(n);
}
ll modmulti(ll a, ll b){
   return ((a%mod)*1ll*(b%mod))%mod;
}
ll modadd(ll a, ll b){
   ll asdfgh =  ((a%mod)+(b%mod)+mod+mod)%mod;
   asdfgh = (asdfgh+mod)%mod;
   return asdfgh;
}
ll modpower(ll a, ll n){
   if(n==0) return 1;
   if(n==1) return a%mod;
   ll b = modpower(a,n/2);
   b = modmulti(b,b);
   if(n%2==0) return b;
   return modmulti(a,b);
}
ll gcd(ll a, ll b){
   if(b==0)
      return a;
   return gcd(b,a%b);
}
ll modinv(ll a){
   return modpower(a,mod-2);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,a,b,minn=99999999;
inline int read()
{  
	int N=0;
	bool C=1;
	char tf=getchar();
	while(tf<'0'||tf>'9'){if(tf=='-')C=0;tf=getchar();}
	while(tf>='0'&&tf<='9')N=(N<<1)+(N<<3)+(tf^48),tf=getchar();
	return C?N:-N;
}
int work(int a,int b)
{
	int r=0;
	while(a)
	{
		r+=a%10;
		a/=10;
	}
	while(b)
	{
		r+=b%10;
		b/=10;
	}
	return r;
}
int main()
{
	n=read(); 
	for(int i=1;i<=n/2+1;i++)
		minn=min(minn,work(i,n-i));
	printf("%d",minn);
	return 0;
}

Measured memory_bytes: 256
import os

def main():
	n,k = map(int, input().split())
	num = []
	for i in range(k):
		d = int(input())
		a = list(map(int, input().split()))
		for j in a:
			num.append(j)
	print(n - len(set(num)))

if __name__ == "__main__":
        main()


Measured memory_bytes: 9196
#include<iostream>
#include<cstring>
#include<math.h>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>

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

using namespace std;


int main(){

    int n,k;
    cin >> n >> k;

    cout << n-k+1 << endl;
}


Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	int n;lint out=0;
	cin>>n;
	REP(i,1,n+1){
		if(i%3>0 && i%5>0) out+=i;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3636
import numpy as np

def main():
    N, M = map(int, input().split())

    AB= np.array([list(map(int, list(input().split()))) for _ in range(N)])
    #print(AB)
    #AB = np.array([[4,9],[2,4]])
    AB_sort_by_A = np.sort(AB.view('i8,i8'), order=['f0'], axis=0).view(np.int)

    #print(AB_sort_by_A)
    buyNum = 0
    money = 0
    for i in range(N):
        if buyNum >= M:
            break
        else:
            drinkVal, drinkNum = AB_sort_by_A[i]
            if M - buyNum > drinkNum:
                buyNum += drinkNum
                money += drinkVal * drinkNum
            else:
                money += drinkVal * (M-buyNum)
                break
    print(money)
    
    
if __name__ == "__main__":
    main()


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

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

  
  return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

// 一行の文字列を読み込む
func nextLine() string {
	sc.Scan()
	return sc.Text()
}

// 数値（INT）を読み込む
func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	K, X := nextInt(), nextInt()
	// fmt.Println(K, X)
	start := X - (K - 1)
	end := X + (K - 1)
	for i := start; i <= end; i++ {
		fmt.Printf("%d ", i)
	}
}


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

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

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


const ll MRINF = 5000000000000000;
int main() {

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N)cin >> A[i];
    sort(A.begin(), A.end());
    vector<ll> num(A[N-1]+1);
    REP(i, N){
        ll start = A[i];
        for(ll i = 1; i*start <= A[N-1]; i++){
            num[i*start]++;
        }
    }
    // REP(i, num.size()){
    //     cout << num[i] << " ";
    // }
    ll ans = 0;
    REP(i, N){
        if(num[A[i]]<=1)ans++;
    }
    cout << ans << endl;
}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 12632
using System;
    class Program
    {
        static void Main(string[] args)
        {
            string[] a1 = Console.ReadLine().Split(' ');
            int[] s1 = new int[2];
            for(int i=0;i<2;i++)
            {
                s1[i] = int.Parse(a1[i]);
            }

            int hole = 1;
            int count = 0;
            while(hole<s1[1])
            {
                hole += s1[0];
                hole -= 1;
                count+=1;
            }
           
            Console.WriteLine(count);
            Console.ReadLine();
           
        }
    }

Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int mod=998244353;
inline int add(int a,int b)
{
    if((a+=b)>=mod)a-=mod;
    return a;
}
inline int dec(int a,int b)
{
    if((a-=b)<0)a+=mod;
    return a;
}
inline int mult(int a,int b)
{
    ll t=(ll)a*b;
    if(t>=mod)t%=mod;
    return t;
}
inline int power(int a,int b)
{
    int out=1;
    while(b)
    {
        if(b&1)out=mult(out,a);
        a=mult(a,a);
        b>>=1;
    }
    return out;
}
int a,b,c,d,f[3010][3010],tag[3010][3010];
int main()
{
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(a==c)
    {
        printf("%d\n",power(a,d-b));
        return 0;
    }
    if(b==d)
    {
        printf("%d\n",power(b,c-a));
        return 0;
    }
    f[c][d]=1;
    for(int i=c;i>=1;i--)
    {
        for(int j=d;j>=1;j--)
        {
            tag[i][j]=add(tag[i][j],mult(tag[i][j+1],i+1));
            f[i][j]=add(f[i][j],mult(j,tag[i][j]));
            f[i-1][j]=add(f[i-1][j],mult(f[i][j],j));
            tag[i-1][j-1]=add(tag[i-1][j-1],f[i][j]);
            // int fl=1;
            // for(int k=1;k<=j;k++)
            // {
            //     f[i-1][j-k]=add(f[i-1][j-k],mult(f[i][j],mult(j-k,fl)));
            //     fl=mult(fl,i);
            // }
        }
    }
    int res=0,fl=1;
    for(int j=b;j<=d;j++)
    {
        res=add(res,mult(f[a][j],fl));
        fl=mult(fl,a);
    }
    printf("%d\n",res);
    // printf("%d\n",f[a][b]);
    return 0;
}

Measured memory_bytes: 74308
function Main(input) {
  input = input.split("\n");
  n = input[0].split(" ");
  d = input[1].split(" ");
  v = input[2].split(" ");
  p = input[3].split(" ");
  var r=-1;
  var ans=0;
  for(var i=0; i<n; i++){
    ans=ans+Number(v[d[i]-1]);
    if (r==d[i]-1){
      ans=ans+Number(p[r-1]);
    }
    r=d[i];
  }
  console.log(ans);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 9420
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

struct Team{
	int score;
	int time;
	int team;
	//各問題の間違えた回数
	vector<int> wrong;
	Team(){
		score = time = team = 0;
		wrong.assign(11,0);
	}

	bool operator==(const Team& rhs) const{
		return score == rhs.score && time == rhs.time;
	}
};


	//　順位の降順でソート
	bool operator<(const Team& lhs, const Team& rhs){
		return lhs.score > rhs.score || (lhs.score == rhs.score && 
			(lhs.time < rhs.time ||
			(lhs.time == rhs.time && lhs.team > rhs.team)));
	}

int main(){
	int M, T, P, R;
	while(cin>>M>>T>>P>>R,M){
		vector<Team> ts(T);
		for(int i=0;i<T;++i) ts[i].team = i+1;
		for(int i=0;i<R;++i){
			int m, t, p, j;
			cin >> m >> t >> p >> j;
			Team& tm = ts[t-1];
			if(j == 0){
				tm.score++;
				tm.time += m + tm.wrong[p] * 20;
			}
			else
				tm.wrong[p]++;
		}
		for(int i=0;i<T;++i)
			for(int j=0;j<T;++j)
				if(ts[i] < ts[j])
					swap(ts[i],ts[j]);

		for(int i=0;i+1<T;++i){
			cout << ts[i].team << (ts[i]==ts[i+1]?"=":",");			
		}
		cout << ts[T-1].team << endl;
	}

	return 0;
}

Measured memory_bytes: 1204
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;
ll const INF = 1LL << 60;

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  for (int i = 0; i <= k; i++) {
    ll A = pow(2, i) * a;
    for (int j = 0; j <= k; j++) {
      if (i + j > k) continue;
      ll B = pow(2, j) * b;
      ll l = k - i - j;
      if (l < 0) continue;
      ll C = pow(2, l) * c;
      if (A < B && B < C) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 4020
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int itemCount = sc.nextInt();
        int pickupCount = sc.nextInt();
        List<Integer> itemList = new ArrayList<>();
        for(int i = 1; i <= itemCount ; i++){
            itemList.add(sc.nextInt());
        }

	    String result = execute(itemCount,pickupCount,itemList);
        System.out.println(result);
    }

    public static String execute(
            int itemCount,
            int pickupCount,
            List<Integer> itemList){

        int canPickupCount = 0;

        int allVote = itemList.stream()
                .mapToInt(Integer::intValue)
                .sum();
        int border = BigDecimal.valueOf(allVote)
                .divide(BigDecimal.valueOf(4 * pickupCount),0, RoundingMode.UP)
                .intValue();
        for(Integer item : itemList){
            if(item >= border) canPickupCount++;
            if(pickupCount == canPickupCount) return "Yes";
        }
        return "No";
    }
}


Measured memory_bytes: 28624
#![allow(unused_imports)]

use std::cmp;
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::fmt;
use std::io::{self, BufWriter, Read, Write};
use std::ops::{Add, Div, Mul, Sub};
use std::str::{self, FromStr};


fn solve(n: u32, a: u32, b: u32) -> u32 {
    cmp::min(n * a, b)
}


fn main() {
    let stdin = io::stdin();
    let mut sc = Scanner::new(stdin.lock().bytes());
    println!("{}", solve(sc.next(), sc.next(), sc.next()));
}


struct Scanner<R: Read> {
    buf: Vec<u8>,
    bytes: io::Bytes<R>,
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
    fn new(bytes: io::Bytes<R>) -> Self {
        Scanner {
            buf: Vec::with_capacity(1024),
            bytes: bytes,
        }
    }

    fn next<T: FromStr>(&mut self) -> T
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        let buf = &mut self.buf;
        buf.clear();
        self.bytes
            .by_ref()
            .map(Result::unwrap)
            .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
            .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
            .foreach(|c| buf.push(c));
        str::from_utf8(&buf).unwrap().parse().unwrap()
    }

    fn vec<T: FromStr>(&mut self, n: usize) -> Vec<T>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| self.next()).collect()
    }

    fn pairs<T1: FromStr, T2: FromStr>(&mut self, n: usize) -> Vec<(T1, T2)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
    {
        (0..n).map(|_| (self.next(), self.next())).collect()
    }

    fn trios<T1: FromStr, T2: FromStr, T3: FromStr>(&mut self, n: usize) -> Vec<(T1, T2, T3)>
    where
        <T1 as FromStr>::Err: fmt::Debug,
        <T2 as FromStr>::Err: fmt::Debug,
        <T3 as FromStr>::Err: fmt::Debug,
    {
        (0..n)
            .map(|_| (self.next(), self.next(), self.next()))
            .collect()
    }

    fn mat<T: FromStr>(&mut self, m: usize, n: usize) -> Vec<Vec<T>>
    where
        <T as FromStr>::Err: fmt::Debug,
    {
        (0..m).map(|_| self.vec(n)).collect()
    }

    fn strings_as_mat<T, F: FnMut(u8) -> T>(&mut self, h: usize, mut f: F) -> Vec<Vec<T>> {
        (0..h)
            .map(|_| {
                self.bytes
                    .by_ref()
                    .map(Result::unwrap)
                    .skip_while(|&c| c == ' ' as u8 || c == '\n' as u8)
                    .take_while(|&c| !(c == ' ' as u8 || c == '\n' as u8))
                    .map(&mut f)
                    .collect()
            })
            .collect()
    }
}


trait Foreach {
    type Item;
    fn foreach<F: FnMut(Self::Item)>(self, f: F);
}

impl<T, I: Iterator<Item = T>> Foreach for I {
    type Item = T;

    fn foreach<F: FnMut(T)>(self, mut f: F) {
        self.fold((), move |(), x| f(x));
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()

using namespace std;

typedef unsigned int uint;
typedef long long ll;

int main(){
  int n;
  const int dx[4] = { 1,-1, 0, 0};
  const int dy[4] = { 0, 0, 1,-1};

  while(scanf("%d ",&n),n){
    char s,t,b;
    double d[3][3] = {{0.0}};
    scanf(" %c %c %c ",&s,&t,&b);
    s -= 'A'; t -= 'A'; b -= 'A';
    d[s/3][s%3] = 1.0;

    REP(i,n){
      double dn[3][3] = {{0.0}};
      REP(y,3) REP(x,3){
	REP(i,4){
	  int xx = x + dx[i];
	  int yy = y + dy[i];
	  if(xx >= 0 && xx <3 && yy >= 0 && yy <3 && (xx != b%3 || yy != b/3))
	     dn[yy][xx] += d[y][x]/4;
	     else
	       dn[y][x] += d[y][x]/4;
	}
      }
      memcpy(d,dn,sizeof(d));
      //REP(y,3){REP(x,3)printf("%.2f ",d[y][x]);puts("");}puts("");
    }
    printf("%.8f\n",d[t/3][t%3]);
  }
  return 0;
}

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


int main()
{
   int n,x,t;
   cin>>n>>x>>t;
   int y=n%x;
   if(y==0)
        cout<<(n/x)*t;
   else
        cout<<((n/x)+1)*t;


}


Measured memory_bytes: 3608
inf = 1 << 60
N,M = map(int, input().split())
A = list(map(int, input().split()))
#A.insert(0)
use = [0,2,5,5,4,5,6,3,7,6]

# dp[i] = i本でできる最大の数
dp = [-inf for i in range(N+1)]
dp[0] = 0
for i in range(N+1):
    for a in A:
        if i < use[a]:
            continue
        dp[i] = max(dp[i], dp[i-use[a]] * 10 + a)
print(dp[N])


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 25;
char mp[maxn][maxn];
int sx, sy, gx, gy;
int cnt;
int h, w;
bool vis[maxn][maxn];
struct node
{
    int x;
    int y;
    int step;
};
int dx[] = {-1, 0, 1, 0};
int dy[] = {0, 1, 0, -1};
void bfs()
{
    cnt = 0;
    queue<node> q;
    q.push({sx, sy, 0});
    while (!q.empty())
    {
        node cur = q.front();
        q.pop();
        int x = cur.x;
        int y = cur.y;
        if (x == gx && y == gy)
        {
            cnt = cur.step;
        }
        int step = cur.step;
        for (int i = 0; i < 4; i++)
        {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if (nx >= 1 && nx <= h && ny >= 1 && ny <= w && !vis[nx][ny] && mp[nx][ny] == '.')
            {
                vis[nx][ny] = 1;
                q.push({nx, ny, step + 1});
            }
        }
    }
}
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    vector<pii> v;
    cin >> h >> w;
    for (int i = 1; i <= h; i++)
    {
        cin >> mp[i] + 1;
    }
    for (int i = 1; i <= h; i++)
    {
        for (int j = 1; j <= w; j++)
        {
            if (mp[i][j] == '.')
            {
                v.push_back({i, j});
            }
        }
    }
    int len = v.size();
    //DBG(len);
    int ans = 0;
    for (int i = 0; i < len; i++)
    {
        for (int j = i + 1; j < len; j++)
        {
            sx = v[i].first, sy = v[i].second;
            gx = v[j].first, gy = v[j].second;
            memset(vis, 0, sizeof(vis));
            bfs();
            ans = max(ans, cnt);
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    H, W = LI()
    c = [LI() for _ in range(H)]

    # dp[i][j]: (i-1, j-1)から左上に作れる最大正方形の1辺の長さ
    dp = [[0] * (W + 1) for _ in range(H + 1)]

    max_len = 0
    for i in range(H):
        for j in range(W):
            if c[i][j] == 1:
                dp[i+1][j+1] = 0
            else:
                dp[i+1][j+1] = min(dp[i][j+1], dp[i][j], dp[i+1][j]) + 1
            max_len = max(dp[i+1][j+1], max_len)

    print(max_len ** 2)

    # for i in dp:
    #     print(i)

if __name__ == '__main__':
    resolve()



Measured memory_bytes: 56848
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#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 MOD 1000000007


int main(){
ios::sync_with_stdio(0);
cin.tie(0);
    ll n;cin>>n;
    ll tmp,ans=0;
    rep(i,1,n+1){
        tmp=n/i;
        ans+=(tmp*(tmp+1)/2)*i;
    }
    cout<<ans;

 
return 0;
}

Measured memory_bytes: 3632
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#define rep(i,l,r) for(int i=(l);i<=(r);++i)
#define per(i,r,l) for(int i=(r);i>=(l);--i)
using namespace std;
const int N=3e5+10,P=1e9+7;
const int tr[][2]={{1,2},{3,4},{5,6},{1,1},{1,2},{7,2},{6,6},{5,5}};
char s[N];int dp[N][8];
inline void upd(int &x,int y){((x+=y)>=P)&&(x-=P);}
int main(){
	scanf("%s",s);int n=strlen(s);
	dp[0][0]=1;
	rep(i,0,n-1){
		rep(j,0,7){
			if(s[i]^49) upd(dp[i+1][tr[j][0]],dp[i][j]);
			if(s[i]^48) upd(dp[i+1][tr[j][1]],dp[i][j]);
		}
	}
	printf("%d\n",dp[n][2]+dp[n][6]>=P?dp[n][2]+dp[n][6]-P:dp[n][2]+dp[n][6]);
	return 0;
}

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

int main() {
  bool flag = true;

  string str;
  //cout << "--------------" << endl;
  int i = 0;

  while(getline(cin, str)) {
    bool already_cout = false;
    // cout << str << "===============" << endl;
    //cout << i << endl;
    if (str == ".") {
      // cout << "brak" << endl;
      break;
    }
    stack<char> S;
    bool total_ok = true;
    for (int i = 0; i < str.size(); i ++) {
      if (str[i] == '(' || str[i] == '[' || str[i] == ')' || str[i] == ']') {
        // cout << i << "," << str[i] <<endl;
      }

      // 左括弧
      if (str[i] == '(' || str[i] == '[') {
        S.push(str[i]);
      }
      // 右括弧
      else if (str[i] == ')') {
        bool is_ok = true;
        if (S.empty()) {
          is_ok = false;
          total_ok = false;
        } else {
          if (S.top() == '(') {

            S.pop();
          } else {
            is_ok = false;
            total_ok = false;
            already_cout = true;
            // cout << "kokode no, " << S.top() << "," << i << endl;
            cout << "no" << endl;
            break;
          }
        }
      }
      else if (str[i] == ']') {
        bool is_ok = false;

        if (S.empty()) {
          if (i >= 99) {
            // cout << "koko kitayo 1" << endl;
          }
          is_ok = false;
          total_ok = false;
        } else {
          if (S.top() == '[') {
            if (i >= 99) {
              // cout << "koko kitayo 2" << "," << i << endl;
            }
            S.pop();
          } else {
            if (i >= 99) {
              // cout << "koko kitayo 3" <<  "," << i << endl;
            }
            is_ok = false;
            total_ok = false;
            already_cout = true;
            // cout << "kokode no 2" << endl;
            cout << "no" << endl;
            break;
          }
        }
      }
    }
    if (!S.empty()) {
      // cout << "dame" << endl;
      total_ok = false;
    }
    if (total_ok) {
      cout << "yes" << endl;
    } else if (!already_cout) {
      cout << "no" << endl;
    }
  }
}



Measured memory_bytes: 3224
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int main(){
    int a,b,c,d;    cin>>a>>b>>c>>d;
    if(a+b<c+d) cout<<"Right"<<endl;
    else if(a+b>c+d)    cout<<"Left"<<endl;
    else    cout<<"Balanced"<<endl;
    
}

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

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    vector<ll> h(n + 1, 0);
    for(int i = 1; i <= n; i++) cin >> h[i];
    vector<vector<ll>> dp(n + 1, vector<ll>(n + 1, 1LL << 60));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++) {
        for(int j = 1; j <= n - k; j++) {
            for(int k = 0; k < i; k++) {
                dp[i][j] = min(dp[i][j], dp[k][j - 1] + max(0LL, h[i] - h[k]));
            }
        }
    }
    ll ans = 1LL << 60;
    for(int i = n - k; i <= n; i++) {
        ans = min(ans, dp[i][n - k]);
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 4384
from collections import Counter
N,M = map(int,input().split())
A = list(map(int,input().split()))

cums = [0]
for a in A:
    cums.append((cums[-1] + a) % M)

ctr = Counter(cums)

ans = 0
for v in ctr.values():
    ans += v*(v-1)//2
print(ans)


Measured memory_bytes: 16552
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

MOD = 10 ** 9 + 7
INF = float("inf")


def main():
    H1, M1, H2, M2, K = map(int, input().split())
    if M2 >= M1:
        time = (H2 - H1) * 60 + M2 - M1
    else:
        time = (H2 - H1 - 1) * 60 + M2 + 60 - M1
    answer = max(time - K, 0)

    print(answer)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9116