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

const int N = 3e5 + 10;

int n , m , k , rMax , cMax , r[N] , c[N] , R , C , cnt;
vector < pair< int , int > > pot;

int main(){
	scanf("%d %d %d" , &n , &m , &k);
	for(int x , y , i = 1; i <= k; i++){
		scanf("%d %d" , &x , &y) , pot.push_back({x , y});
		rMax = max(rMax , ++r[x]) , cMax = max(cMax , ++c[y]);
	}
	for(int i = 1; i <= m; i++) C += c[i] == cMax;
	for(int i = 1; i <= n; i++) R += r[i] == rMax;
	for(int i = 0; i < k; i++)
		cnt += r[pot[i].first] == rMax && c[pot[i].second] == cMax;
	printf("%d" , rMax + cMax - (cnt == 1ll * R * C));
	return 0;
}

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

int main() {
	long long X;
	cin >> X;
	long long okane = 100;
	long long count = 0;
	while (okane<X) {
		okane += okane /100 ;
		count++;
	}
	cout << count << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
const int maxn=1<<18,mod=998244353;
inline int add(int a,int b){return a+b>=mod?a+b-mod:a+b;}
inline int dic(int a,int b){return a-b<0?a-b+mod:a-b;}
inline int mul(int a,int b){return 1ll*a*b%mod;}
inline int qpow(int a,int b,int c=1){for(;b;b>>=1,a=mul(a,a)) if(b&1) c=mul(c,a);return c;}
const int inv2=qpow(2,mod-2);
int p[maxn],n,c[maxn],len,e[maxn];
void FWT(int *f,bool typ){
	for(int i=2;i<=len;i<<=1)
		for(int j=0;j<len;j+=i)
			for(int k=j;k<j+i/2;++k){
				int u=f[k],t=f[k+i/2];
				if(!typ) f[k]=add(u,t),f[k+i/2]=dic(u,t);
				else f[k]=mul(add(u,t),inv2),f[k+i/2]=mul(dic(u,t),inv2);
			}
	return ;
}
int main(){
	int inv=0;cin>>n;len=1<<n;for(int i=0;i<1<<n;++i) scanf("%d",&p[i]),inv=add(inv,p[i]);
	inv=qpow(inv,mod-2);for(int i=0;i<1<<n;++i) p[i]=mul(p[i],inv),c[i]=mod-1;p[0]=dic(p[0],1);
	c[0]=add(len,c[0]);
	FWT(p,0),FWT(c,0);
	for(int i=1;i<len;++i) e[i]=mul(c[i],qpow(p[i],mod-2));
	FWT(e,1);
	for(int i=0;i<len;++i) printf("%d\n",dic(e[i],e[0]));
	return 0;
}

Measured memory_bytes: 6880
#include<stdio.h>

int main(){
    int num[100000];
    int N, i, flag, cnt4 = 0, cnt2 = 0, cnt = 0;
    scanf("%d", &N);

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

    for(i = 0; i < N; i++)
    {
        if(num[i] % 4 == 0)
        {
            cnt4++;
        }
        else if(num[i] % 2 == 0)
        {
            cnt2++;
        }
    }

    if((cnt4 * 2 + 1) + (cnt2 - cnt2 % 2) >= N) printf("Yes");
    else printf("No");
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
#define rushb() scanf("%d",&t);while(t--)
#define rusha() scanf("%d",&n);rep(i,1,n)scanf("%d",&a[i]);
#define debug() cout<<"LBWNB"<<'\n'
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define p() puts("");
using namespace std;
typedef long long ll;
const int mod=998244353;
const int inf=1e9+7;
const int maxn=2e5+7;
int d;
int main(){
    int a[]={0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    scanf("%d",&d);
    printf("%d\n",a[d]);
    return 0;
}










//const int M=1<<20;
//ll t1[M*2+5],t2[M*2+5],ans,ca[M],cb[M];
//inline void upd(int i){t1[i]=t1[i<<1]+t1[i<<1|1];t2[i]=max(t2[i<<1],t1[i<<1]+t2[i<<1|1]);}
//inline void add(int i,int v){for(t1[i+=M]+=v;i>>=1;upd(i));}
//int n,m,p,x,y,i,j;
//struct mons{int x,y,z;}a[M];
//int main(){
//	for(i=0;i<M;++i)ca[i]=cb[i]=1ll<<60;ans=-(1ll<<60);
//	scanf("%d%d%d",&n,&m,&p);
//	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),ca[x]=min(ca[x],(ll)y);
//	for(i=1;i<=m;++i)scanf("%d%d",&x,&y),cb[x]=min(cb[x],(ll)y);
//	for(i=0;i<M;++i)t2[i+M]=-cb[i];for(i=M-1;i;--i)upd(i);
//	for(i=1;i<=p;++i)scanf("%d%d%d",&a[i].x,&a[i].y,&a[i].z);
//	sort(a+1,a+p+1,[&](const mons&a,const mons&b){return a.x<b.x;});
//	for(i=0,j=1;i<M;++i){
//		for(;j<=p && a[j].x<i;++j)add(a[j].y,a[j].z);
//		ans=max(ans,t2[1]-ca[i]);
//	}
//	printf("%lld\n",ans);
//	return 0;
//}


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

_sum = 0
_tmp = 0
while _sum <= n:
    _tmp += 1
    _sum += _tmp
    if _sum >= n:
        break

ans = []
while n:
    if n - _tmp < 0:
        _tmp -= 1
    else:
        ans.append(_tmp)
        n -= _tmp
        _tmp -= 1

for i in ans:
    print(i)


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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(x) cout << x << endl;

int main() {
    int n; cin >> n;
    int x[n];
    int m = 0;
    rep(i, n){
        cin >> x[i];
        m = max(m, x[i]);
    }

    int ans = 0;
    REP(i, 1, m + 1){
        int sum = 0;
        rep(j, n){
            sum += pow((x[j] - i), 2.0);
        }
        if(i == 1) ans = sum;
        ans = min(ans, sum);
    }
    OP(ans);
}


Measured memory_bytes: 256
temp=input().split(" ")
N=int(temp[0])
K=int(temp[1])
sum=0
snucklist=[]
for i in range(1,K+1):
    d=int(input())
    templist=input().split(" ")
    for j in range(0,d):
        if int(templist[j]) not in snucklist:
            snucklist.append(int(templist[j]))
for t in range(1,N+1):
    if t not in snucklist:
        sum=sum+1
print(sum)

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

s = set()
last = ""
ans = "Yes"

for i in range(N):

    w = input()

    if i == 0:
        last = w
        s.add(w)

    elif (w[0] == last[-1]) and (w not in s):

        last = w
        s.add(w)

    else:
        ans = "No"
        break

print (ans)

    




Measured memory_bytes: 3060
<?php
$a1=explode(" ",trim(fgets(STDIN)));
$a2=explode(" ",trim(fgets(STDIN)));
$a3=explode(" ",trim(fgets(STDIN)));
$n=trim(fgets(STDIN));
for ($i = 0; $i < $n; $i++) {
    $b[$i]=trim(fgets(STDIN));
    for ($j = 0; $j < 3; $j++) {
        if ($a1[$j]==$b[$i]) {
            $a1[$j]=0;
        }elseif ($a2[$j]==$b[$i]) {
            $a2[$j]=0;
        }elseif ($a3[$j]==$b[$i]) {
            $a3[$j]=0;
        }
    }
    
}

$k1=array_sum($a1);
$k2=array_sum($a2);
$k3=array_sum($a3);
$k4=$a1[0]+$a2[0]+$a3[0];
$k5=$a1[1]+$a2[1]+$a3[1];
$k6=$a1[2]+$a2[2]+$a3[2];
$k7=$a1[0]+$a2[1]+$a3[2];
$k8=$a1[2]+$a2[1]+$a3[0];

if ($k1==0 or $k2==0 or $k3==0 or $k4==0 or $k5==0 or $k6==0 or $k7==0 or $k8==0) {
    echo "Yes","\n";
}else {
    echo "No","\n";
}
?>


Measured memory_bytes: 3828
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#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<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


template< unsigned mod >
struct RollingHash {
  vector< unsigned > hashed, power;

  inline unsigned mul(unsigned a, unsigned b) const {
    unsigned long long x = (unsigned long long) a * b;
    unsigned xh = (unsigned) (x >> 32), xl = (unsigned) x, d, m;
    asm("divl %4; \n\t" : "=a" (d), "=d" (m) : "d" (xh), "a" (xl), "r" (mod));
    return m;
  }

  RollingHash(const string &s, unsigned base = 10007) {
    int sz = (int) s.size();
    hashed.assign(sz + 1, 0);
    power.assign(sz + 1, 0);
    power[0] = 1;
    for(int i = 0; i < sz; i++) {
      power[i + 1] = mul(power[i], base);
      hashed[i + 1] = mul(hashed[i], base) + s[i];
      if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
    }
  }

  unsigned get(int l, int r) const {
    unsigned ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
    if(ret >= mod) ret -= mod;
    return ret;
  }

  unsigned connect(unsigned h1, int h2, int h2len) const {
    unsigned ret = mul(h1, power[h2len]) + h2;
    if(ret >= mod) ret -= mod;
    return ret;
  }

  int LCP(const RollingHash< mod > &b, int l1, int r1, int l2, int r2) {
    int len = min(r1 - l1, r2 - l2);
    int low = -1, high = len + 1;
    while(high - low > 1) {
      int mid = (low + high) / 2;
      if(get(l1, l1 + mid) == b.get(l2, l2 + mid)) low = mid;
      else high = mid;
    }
    return (low);
  }
};

using RH1 = RollingHash< 1000000007 >;
using RH2 = RollingHash< 1000000021 >;

int main(){
    int n,m;cin >> n >> m;
    string s;cin >> s;
    map<P,LL> ma;
    RH1 rh1(s);
    RH2 rh2(s);
    int l=0,r=1;
    LL ans = 0;
    for (int i = 0; i < m; i++) {
        string t;cin >> t;
        if(t=="R++") r++;
        else if(t=="R--") r--;
        else if(t=="L++") l++;
        else l--;
        ma[mp(rh1.get(l,r),rh2.get(l,r))]++;
    }
    for(auto q:ma){
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 26548
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		try {
			System.setIn(new FileInputStream("src/aoj0105/input.txt"));
			System.setOut(new PrintStream(new FileOutputStream("src/aojxxxx/result.txt")));
		} catch (FileNotFoundException e) {
		}
		new Main().run();
	}

	Scanner sc = new Scanner(System.in);

	void run() {
		
		Map<String, ArrayList<Integer>> mp = new HashMap<String, ArrayList<Integer>>();
		ArrayList<String> ss = new ArrayList<String>();
		for (;sc.hasNext();) {
			String str = sc.next();
			int index = sc.nextInt();
			if(mp.get(str) == null) {
				mp.put(str, new ArrayList<Integer>());
				ss.add(str);
			}
			mp.get(str).add(index);
		}
		Collections.sort(ss);
		for (String str : ss) {
			System.out.println(str);
			ArrayList<Integer> list = mp.get(str);
			Collections.sort(list);
			boolean first = true;
			for (int x : list) {
				if (first) first = false;
				else System.out.print(" ");
				System.out.print(x);
			}
			System.out.println();
		}
	}
}

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

int main() {
	int n, k;
	cin >> n >> k;
	int h[200000];
	long long total = 0;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
		total += (long long)h[i];
	}
	sort(h, h + n, greater<int>());
	for (int i = 0; i < k; i++) {
		total -= (long long)h[i];
	}
	cout << total << '\n';
	
	return 0;
}

Measured memory_bytes: 1532
#include<bits/stdc++.h>
#define MAXN 2010
#define INF 2000000000
using namespace std;

int dp[MAXN][2];
int a[MAXN];

int main(){
    ios::sync_with_stdio(0);
    int N;
    cin >> N;

    cin >> a[0];
    cin >> a[0];

    for(int i = 1; i <= N; i++)
        cin >> a[i];


    for(int i = N; i > 0; i--){
        for(int turn = 0; turn < 2; turn++){
            dp[i][turn] = abs(a[i-1] - a[N]);

            for(int j = i+1; j <= N; j++){
                dp[i][turn] = (turn == 0 ? min(dp[i][turn], dp[j][turn^1]) : max(dp[i][turn], dp[j][turn^1]));
            }

        }
    }

    cout << dp[1][1] << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdlib.h>
#include <vector>
using namespace std;

int main(void){
  string m;
  cin >> m;
  vector<long> T;
  T.push_back(1);
  for(int index = 0; index < m.size(); index++)
  {
    T.push_back((T[index] * 3) % 1000000007);
  }
  
  int count = 1;
  long _sum = 0;
  for(int index = 0; index < m.size(); index++)
  {
    //cout << "T[" << index << "]=" << T[index] << "\n";
    if(strncmp(&m[index], "0", 1) == 0){continue;}

    int t = m.size() - index - 1;
    _sum += (T[t] * count);
    _sum %= 1000000007;
    //cout << "index = " << index << " count = " << count << " t = " << t << "\n";
    count *= 2;
    count %= 1000000007;
  }
  
  cout << (_sum + count) % 1000000007;
}


Measured memory_bytes: 1528
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if(a == b) {
            System.out.println("a == b");
        }
        else if(a > b) {
            System.out.println("a > b");
        }
        else {
            System.out.println("a < b");
        }
    }
}



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

int main(){
 ll H,N;
 cin >> H >> N;
 vector<ll> v{istream_iterator<int>(cin), istream_iterator<int>()};
 int sum = accumulate(v.begin(),v.end(),0);
 if ( H>sum) cout <<"No"<<endl;
 else cout <<"Yes"<<endl;
 return 0;
}

Measured memory_bytes: 1400
n = int(input())
a = []
#名前はアルファベット順(昇順)，評価は降順にするために評価は-をつけて格納している
for i in range(n):
    s, p = input().split()
    a.append((s, -int(p), i + 1))
a.sort()
for b in a:
    print(b[2])


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
#define all(x) (x).begin(),(x).end()
int INF = 1000000000;

int main() {
  string Sa, Sb, Sc; cin >> Sa >> Sb >> Sc;
  queue<char> A, B, C;
  rep(i, Sa.size()) {
    A.push(Sa[i]);
  }
  rep(i, Sb.size()) {
    B.push(Sb[i]);
  }
  rep(i, Sc.size()) {
    C.push(Sc[i]);
  }
  char turn = 'a';
  while(1) {
    if (turn == 'a') {
      if (A.empty()) {
        cout << 'A' << endl;
        break;
      }
      turn = A.front();
      A.pop();
    }
    else if (turn == 'b') {
      if (B.empty()) {
        cout << 'B' << endl;
        break;
      }
      turn = B.front();
      B.pop();
    }
    else if (turn == 'c') {
      if (C.empty()) {
        cout << 'C' << endl;
        break;
      }
      turn = C.front();
      C.pop();
    }
  }
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: u32,
        a: u32,
        b: u32
    }
    println!("{}", std::cmp::min(n*a, b));
}


Measured memory_bytes: 4352
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int N, v[111111];

long long C, x[111111];


long long compute()
{
  long long G[111111], H, I, Gp = -INF, X, V = 0, r = -INF;

  for (int i = 0; i <= N; i ++) {
    X  = x[i];
    V += v[i];

    G[i] = Gp = std::max(V - X, Gp);
  }

  r = Gp;

  V = 0;
  
  Gp = -INF;

  for (int i = N; i > 0; i --) {
    X  = C - x[i];
    V += v[i];

    H = V - X;
    I = V - X - X + G[i - 1];

    Gp = std::max({H, I, Gp});
  }

  return std::max(Gp, r);
}


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

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  std::cin >> N >> C;

  x[0] = v[0] = 0;

  for (int i = 1; i <= N; i ++)
    std::cin >> x[i] >> v[i];

  long long r = -INF;

  r = std::max(compute(), r);

  std::reverse(x + 1, x + N + 1);
  std::reverse(v + 1, v + N + 1);

  for (int i = 1; i <= N; i ++)
    x[i] = C - x[i];

  r = std::max(compute(), r);

  std::cout << r << std::endl;

  return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <stdio.h>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main() {
    int n,m=0;
    string s;
    cin >> n >> s;
    for (int i = 0; i < n - 2;++i) {
        if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') m++;
    }
    cout << m << endl;


}


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

int main()
{
	using vd = std::vector<double>;
	int N, M;
	std::vector<std::vector<int>> edges;
	scanf("%d%d", &N, &M);
	edges.resize(N);
	for (int i{}; i < M; i++)
	{
		int s, t;
		scanf("%d%d", &s, &t);
		s--; t--;
		edges[s].push_back(t);
	}
	vd E(N);
	for (int i{N - 2}; i >= 0; i--)
		for (auto& e: edges[i])
			E[i] += (E[e] + 1) / edges[i].size();
	double ans{E[0]};
	for (int i{N - 2}; i >= 0; i--)
	{
		if (edges[i].size() == 1) continue;
		double max{};
		for (auto& e: edges[i])
			max = std::max(max, E[e] + 1);
		vd ignoreE(N);
		for (int j{N - 2}; j >= 0; j--)
		{
			for (auto& e: edges[j])
				ignoreE[j] += ignoreE[e] + 1;
			if (j == i)
				ignoreE[j] -= max;
			int size{(int)edges[j].size()};
			if (j == i) size--;
			ignoreE[j] /= size;
		}
		ans = std::min(ans, ignoreE[0]);
	}
	printf("%.7lf\n", ans);

	return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int S;

int memo[2048];

int kitaeri(int nokori) {
	int answer = 0;
	int i;
	if (nokori == 0) return 1;
	if (nokori < 0) return 0;
	if (memo[nokori]) return ~memo[nokori];
	for (i = 3; i <= nokori; i++) {
		answer = add(answer, kitaeri(nokori - i));
	}
	return ~(memo[nokori] = ~answer);
}

int main(void) {
	if (scanf("%d", &S) != 1) return 1;
	printf("%d\n", kitaeri(S));
	return 0;
}


Measured memory_bytes: 1756
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define N 1666666
#define inf 9999999999999
int n;
int arr[N];
signed main(){
	cin>>n;
	for(int i=1;i<=2*n;i++) cin>>arr[i];sort(arr+1,arr+1+2*n);
	int ans=inf;int l=1;int s=0;
	for(int i=1;i<=2*n;i++) if(i%2) s+=arr[i];
	cout<<s;
    return 0; 
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
#define pb push_back
#define all(a) a.begin(),a.end()
#define forn(i,n) for(int i=0;i<int(n);i++)
#define forr(i,n) for(int i=int(n-1);i>=0;i--)
#define fora(i,a,b) for(int i=int(a);i<=int(b);i++)
#define forb(i,a,b) for(int i=int(a);i>=int(b);i--)
#define mod 1000000007
using namespace std;
using ll=long long int;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<ll> vii;
typedef pair<ll ,ll> pii;
int n,m,k;
int grid[3001][3001];
ll dp[3001][3001][4];
void init()
{
	forn(i,3001)
	{
		forn(j,3001)
		{
			forn(k,4)
			{
				dp[i][j][k]=-1;
			}
		}
	}
}
ll go(int x,int y,int r)
{
	if(x==0||y==0||x==n+1||y==m+1)return 0;
	ll &z=dp[x][y][r];
	if(z!=-1)return z; 
	ll ans1=0,ans2=0;
	if(r==3)
	{
		ans1=go(x+1,y,0);
	}
	else
	{
		ans1=max(grid[x][y]+go(x,y+1,r+1),go(x,y+1,r));
		ans2=max(grid[x][y]+go(x+1,y,0),go(x+1,y,0));
	}
	return z=max(ans1,ans2);
}
void solve()
{
	init();
	cin>>n>>m>>k;
	forn(i,k)
	{
		int r,c,val;
		cin>>r>>c>>val;
		grid[r][c]=val;
	}
	cout<<go(1,1,0);
}

int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int t=1;
    //cin>>t;
    while(t--)
	solve();
    return 0;
}


Measured memory_bytes: 320840
# coding: utf-8
n = int(input())

x = [float(i) for i in input().split()]
y = [float(i) for i in input().split()]

dl = [abs(i - j) for (i,j) in zip(x,y)]

for p in range(1,4):
    d = sum([i ** p for i in dl]) ** (1/p)
    print("{:.8f}".format(d))

print("{:.8f}".format(max(dl)))

Measured memory_bytes: 7784
#define Link "https://arc085.contest.atcoder.jp/tasks/arc085_c"

#include <iostream>
#include <cstdio>
#include <vector>
#include <queue>

#define TASK "MUL"

#define pii pair<int,int>
#define i first
#define v second

using namespace std;

void OpenFile()
{
    freopen(TASK".INP","r",stdin);
    freopen(TASK".OUT","w",stdout);
}

const int oo = 1e9 + 1;
const int maxn = 1e3 + 1;
int n,S,T,a[maxn],cf[maxn],cnt,b[maxn],num[maxn];
vector <pii> e[maxn];
long long res;

void Enter()
{
    cin >> n;
    for (int i=1;i<=n;++i)
        cin >> a[i];
}

void Connect(int u, int v, int w)
{
    e[u].push_back(pii(++cnt,v));
    cf[cnt] = w;
    e[v].push_back(pii(++cnt,u));
}

void Init()
{
    S = 0;
    T = n + 1;
    cnt = 1;
    for (int i=1;i<=n;++i) {
        if (a[i] <= 0)
            Connect(S,i,-a[i]);
        else {
            Connect(i,T,a[i]);
            res += a[i];
        }
        for (int j=i+i;j<=n;j+=i)
            Connect(i,j,+oo);
    }
}

bool Can(int S, int T)
{
    queue <int> qu;
    fill(b,b+n+1+1,+oo);
    b[S] = 0;
    qu.push(S);
    while (!qu.empty()) {
        int u = qu.front();
        qu.pop();
        if (u == T)
            return 1;
        for (pii p : e[u]) {
            int i = p.i;
            int v = p.v;
            if (cf[i] > 0 && b[v] == +oo) {
                b[v] = b[u] + 1;
                qu.push(v);
            }
        }
    }
    return 0;
}

int Find(int u, int mn)
{
    if (u == T)
        return mn;
    num[u] = cnt;
    for (pii p : e[u]) {
        int i = p.i;
        int v = p.v;
        if (num[v] != cnt && cf[i] > 0 && b[v] == b[u] + 1)
            if (int x = Find(v,min(mn,cf[i]))) {
                cf[i] -= x;
                cf[i^1] += x;
                return x;
            }
    }
    return 0;
}

void Solve()
{
    while (Can(S,T))
        while (int x = (++cnt,Find(S,+oo)))
            res -= x;
    cout << res;
}

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

    //OpenFile();

    Enter();
    Init();
    Solve();
}


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

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    mut a: [usize; n]
    }
    a.sort();
    let m = 1_000_005;
    let mut dp = vec![true; m];
    let mut ans = 0;
    for i in 0..n {
        if !dp[a[i]] {continue}
        let mut k = 1;
        while k * a[i] < m {
            dp[a[i] * k] = false;
            k += 1;
        }
        if i + 1 < n && a[i] == a[i + 1] {continue}
        ans += 1;
    }
    println!("{}", ans);
}


Measured memory_bytes: 5896
/*
 * yaswanth phani kommineni
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';

void solve(){
	int n;
	cin >> n;
	vector < vector <ll> > v(4,vector <ll> (n));
	for(ll i=0;i<n;i++){
		ll x,y;
		cin >> x >> y;
		v[0][i] = x+y;
		v[1][i] = x-y;
		v[2][i] = -x+y;
		v[3][i] = -x-y;
	}
	ll ans = 0;
	for(ll i=0;i<4;i++){
		sort(v[i].begin(),v[i].end());
		ans = max(v[i].back()-v[i].front(),ans);
	}
	cout << ans << endl;
}

int main(){
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int z;
	z = 1;
	//cin >> z;
	for(int z1=1;z1<=z;z1++){
		solve();
	}
	return 0;
}


Measured memory_bytes: 11132
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict

# import fractions

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    P = il()
    P.sort()
    print(sum(P[:K]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 10220
import sys
readline = sys.stdin.buffer.readline

N = int(readline())
P = list(map(int, readline().split()))
Q = list(map(int, readline().split()))

from itertools import permutations

p = list(permutations(range(1, N+1)))

# print(p)

a = p.index(tuple(P))
b = p.index(tuple(Q))

print(abs(a-b))


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

using namespace std;

struct Dice {
    Dice(const vector<int>& v) : v(v) {};
    vector<int> v;
    void n() {
        int tmp = v[0];
        v[0] = v[1];
        v[1] = v[5];
        v[5] = v[4];
        v[4] = tmp;
    }
    void s() {
        int tmp = v[0];
        v[0] = v[4];
        v[4] = v[5];
        v[5] = v[1];
        v[1] = tmp;
    }
    void e() {
        int tmp = v[0];
        v[0] = v[3];
        v[3] = v[5];
        v[5] = v[2];
        v[2] = tmp;
    }
    void w() {
        int tmp = v[0];
        v[0] = v[2];
        v[2] = v[5];
        v[5] = v[3];
        v[3] = tmp;
    }
};

int main() {
    vector<int> v(6);
    for (int i = 0; i < v.size(); i++) {
        cin >> v[i];
    }
    Dice dice(v);
    string s;
    cin >> s;
    for (auto c : s) {
        if (c == 'N') {
            dice.n();
        } else if (c == 'S') {
            dice.s();
        } else if (c == 'E') {
            dice.e();
        } else if (c == 'W') {
            dice.w();
        }
    }
    cout << dice.v[0] << endl;
    return 0;
}



Measured memory_bytes: 3212
#include<iostream>
using namespace std;
string s;
long long int a;
int j,i;
int main(){
  for(;getline(cin,s),s!="END OF INPUT";){
    int m=int(s.size());
    for(j=a=i=0;i<m;i++){
      if(s[i]==' '){
	cout<<i-j;
	j=i+1;
      }
    }
    cout<<m-j<<endl;
  }
}

Measured memory_bytes: 1184
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
			int[] a = new int[3];
			for(int i=0 ; i<3 ; i++) {
				a[i] = stdIn.nextInt();
			}
			if(a[0]==a[1]&&a[1] == a[2]||a[0]!=a[1]&&a[1]!=a[2]&&a[2]!=a[0]) {
				System.out.println("No");
			}else {
				System.out.println("Yes");
			}
	}
}


Measured memory_bytes: 21204
n, l = gets.chomp.split(" ").map(&:to_i)
array = []

(1..n).each do |number|
  array.push((l + number - 1))
end

new_array = []
min = array.first.abs
index = 0

array.each_with_index do |number,idx|
  if min >= number.abs
    index = idx
    min = number.abs
  end
end

puts array.inject(:+) - array[index]




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

int main(){
  string n;
  cin>>n;
  int var=0;
  for(int i=0; i<n.size(); i++){
    var+=n[i]-48;
  }
  if(var%9==0) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

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

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

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

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define UB upper_bound
#define LB lower_bound
#define PQ priority_queue

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

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

template<typename T> ostream & operator<<(ostream & os, const vector<T> & v) {
	os << "[";
	FOR(it, v) {
		if(it != v.begin()) { os << ", "; }
		os << *it;
	}
	os << "]";
	return os;
}
template<typename F, typename S> ostream & operator<<(ostream & os, const pair<F, S> & p) {
	os << "<" << p.FI << ", " << p.SE << ">";
	return os;
}

// ---- ----

int n, a[100001];
vector<int> v[100001];
int  rem[100001];
int  num[100001];
int    q[100001], se, ge;
int    c[100001];
int f(int i) {
	int s = v[i].size();
	inc(j, s) { c[j] = num[ v[i][j] ]; }
	sort(c, c + s);
	inc(j, s) { setmax(num[i], (s - j) + c[j]); }
	
	rem[ a[i] ]--;
	if(rem[ a[i] ] == 0) { q[se++] = a[i]; }
	
	return num[i];
}

int main() {
	cin >> n;
	incII(i, 2, n) { cin >> a[i]; }
	
	incII(i, 2, n) { v[ a[i] ].PB(i); }
	incII(i, 1, n) { rem[i] = v[i].size(); }
	
	incII(i, 1, n) { if(rem[i] == 0) { q[se++] = i; } }
	while(ge != se) { f(q[ge++]); }
	
	cout << num[1] << endl;
	
	return 0;
}


Measured memory_bytes: 7296
import sys
readline = sys.stdin.readline

def calc(k):
    return 10-k

S = [0] + list(map(int, readline().strip()))

M = len(S)
inf = 10**9+7
dpn = [inf]*M
dpk = [inf]*M
dpn[0] = 0
dpk[0] = 1
pre = 0
for i in range(1, M):
    s = S[i]
    if s != 9:
        dpn[i] = min(dpn[i-1] + s, dpk[i-1] + calc(s))
        dpk[i] = min(dpn[i-1] + s+1, dpk[i-1] + calc(s+1))
        pre = i
    else:
        dpn[i] = min(dpn[i-1] + s, dpk[pre] + calc(s))
        dpk[i] = dpk[pre]

print(dpn[-1])

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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    string s;
    cin >> s;
    bool ans = false, flag = false;
    rep(i, s.size()){
        if(s[i] == 'C'){
            flag = true;
        }
        if(flag && s[i] == 'F'){
            ans = true;
        }
    }
    if(ans){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define rep(X, Y) for (int(X) = 0; (X) < (Y); ++(X))
#define rrep(X, Y) for (int(X) = (Y)-1; (X) >= 0; --(X))
#define itrep(X, Y) for (auto(X) = (Y).begin(); (X) != (Y).end(); (X)++)
#define all(X) (X).begin(), (X).end()
#define pb push_back
#define mp make_pair
#define fi first
#define sc second
#define print(x) cout << x << endl

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll INF = 1e16;

void solve(long long H, long long W, long long N, std::vector<long long> a,
           std::vector<long long> b) {
  map<pll, ll> cnts;
  rep(n, N) {
    for (ll da = -2; da <= 0; da++) {
      for (ll db = -2; db <= 0; db++) {
        ll ax = a[n] + da;
        ll bx = b[n] + db;

        if (ax > 0 && ax <= H - 2 && bx > 0 && bx <= W - 2) {
          cnts[mp(ax, bx)]++;
        }
      }
    }
  }

  vector<ll> counts(10);
  counts[0] = (H - 2) * (W - 2);
  itrep(iter, cnts) {
    counts[0]--;
    if (iter->sc <= 9) {
      counts[iter->sc]++;
    }
  }
  rep(i, 10) { print(counts[i]); }
}

int main() {
  long long H;
  scanf("%lld", &H);
  long long W;
  scanf("%lld", &W);
  long long N;
  scanf("%lld", &N);
  std::vector<long long> a(N);
  std::vector<long long> b(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &a[i]);
    scanf("%lld", &b[i]);
  }
  solve(H, W, N, std::move(a), std::move(b));
  return 0;
}


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

int main()
{
	string S;
	long long K;

	cin >> S >> K;

	for ( size_t i = 0; i < S.size(); i++ ) {
		if ( S[i] != '1' ) {
			cout << S[i] << endl;
			break;
		}
		if ( i == K - 1 ) {
			cout << 1 << endl;
			break;
		}
	}

	return ( 0 );
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
using _loop_int = int;
#define REP(i,n) for(_loop_int i=0; i<(_loop_int)(n); i++)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a); i<(_loop_int)(b); i++)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1; i>=(_loop_int)(a); i--)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
   int N, a;
   float ans=0;
   cin >> N;
   for(int i=0;i<N;i++){
       cin >> a;
       ans+=(1.0/a);
   }
   cout << 1/ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,K;
  cin>>A>>B>>K;
  int count=0;
  int i=min(A,B);
  while(count<K) {
    if(A%i==0 && B%i==0){
      count++;
    }
    if(count==K){
      cout<<i<<endl;
      break;
    }
    i--;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long int camel(long long int h,long long int w)
{
    long long int a,b,odr,evr;
    if((h==1&&w!=1)||(h!=1&&w==1))
    {
        a=1;
        b=0;
    }
    else
    {
    if(h%2==0)
    {
        odr=h/2;
        evr=h/2;
    }
    else
    {
        odr=(h/2)+1;
        evr=h/2;
    }
    if(w%2!=0)
    {
        a=odr*(w/2+1);
        b=evr*(w/2);
    }
    else
    {
        a=odr*(w/2);
        b=evr*(w/2);
    }
    }
    return a+b;
}
int main()
{
    long long int h,w,res;
    cin>>h>>w;
    res=camel(h,w);
    cout<<res;
    return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("03,unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include<bits/stdc++.h>
typedef long long ll;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ordered_set tree<int, null_type,less_equal<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pb           push_back
#define ff           first
#define ss           second
#define gcd(a, b)    __gcd(a, b)
#define lcm(a, b)    ((a)*((b)/gcd(a,b)))
#define all(v)       v.begin(),v.end()
#define lllim        2147483648
#define Pi           2*acos(0.0)
#define sci(n)	     scanf("%d",&n)
#define scii(n,m)    scanf("%d%d",&n,&m)
#define scl(n)       scanf("%lld",&n)
#define scll(n,m)    scanf("%lld%lld",&n,&m)
#define pii          pair<int,int>
#define pll 	     pair<ll,ll>
#define mem(a,b)     memset(a, b, sizeof(a))
#define fill_(a,b)   fill(a,a+n,b);
#define MOD          1000000007
#define fast_cin     ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define filein       freopen("input.txt","r", stdin)
#define D(x)         cerr << __LINE__ << ": " << #x << " = " << (x) << '\n'
#define case		 int t,cas=1;cin>>t;while(t--)
#define rep(i,a,n)   for(int i=a;i<n;i++)
#define rev(i,n,a)   for(int i=n;i>=a;i--)

/*------------------------------Graph Moves----------------------------*/
//const int fx[]= {+1,-1,+0,+0};
//const int fy[]= {+0,+0,+1,-1};
//const int fx[]= {+0,+0,+1,-1,-1,+1,-1,+1};  // Kings Move
//const int fy[]= {-1,+1,+0,+0,+1,+1,-1,-1}; // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/

template<class T> void ckmin(T& a, const T& b) {
    a= b < a? b:a;
}
template<class T> void ckmax(T& a, const T& b) {
    a= b > a? b:a;
}



template<class T> void read(T& a) {
    std::cin>>a;
}
template<class T> void read(T& a,const int sidx, const int eidx) {
    for(int i=sidx; i<eidx; i++)
        std::cin>>a[i];
}



using namespace std;
using namespace __gnu_pbds;

const int maxn=100005;


vector<int>pr;
bool mark[maxn];

void si()
{
    mem(mark,0);
    for(int i=4; i<maxn; i+=2) mark[i]=1;
    for(int i=3; i*i<maxn; i+=2)
    {
        if(!mark[i])
            for(int j=i*i; j<maxn; j+=2*i)
                mark[j]=1;
    }

    pr.pb(2);
    for(int i=3; i<maxn; i+=2)
        if(!mark[i])
            pr.pb(i);
}


void solve()
{
    char a;
    cin>>a;
    if(a>='A' && a<='Z')
		cout<<'A'<<endl;
	else
	cout<<'a'<<endl;
	
}


int main()
{
    fast_cin;
    // si();

    //while(scanf("%d",&n)!=EOF)
//case
    {
		//cas=cas;
        //cout<<""<<cas++<<""<<endl;
        solve();
    }

    return 0;
}


Measured memory_bytes: 3616
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization("unroll-loops")

#include "bits/stdc++.h"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define endl '\n'
#define f first
#define s second
#define IO ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cf ll testcases;cin>>testcases;while(testcases--)
#define prn(x) if(x) cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define minel(x) (*min_element(all(x)))
#define maxel(x) (*max_element(all(x)))
#define cou dbg=1;cout
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pi;
typedef vector<ll> vi;
typedef vector<ld> vd;
typedef vector<pi> vp;
ll dbg=0;
template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p);
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v);
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p);
template<typename A> istream& operator>>(istream& cin, vector<A> &v);
int dx[] = {-1, -1, -1,  0, 0,  1, 1, 1};
int dy[] = {-1,  0,  1, -1, 1, -1, 0, 1};

void solve(){
    ll n,x,t;
    cin>>n>>x>>t;
    cout<<ll(ceil(ld(n)/ld(x)))*t<<endl;
    
}

int main(){
    IO;
    // cf
    solve();
    return 0;
}


template<typename A, typename B> ostream& operator<<(ostream &cout, pair<A, B> const &p) { 
    if(dbg){
        dbg=0;
        return cout << "(" << p.f << ", " << p.s << ")"; 
    }else{
        return cout<<p.f<<' '<<p.s;
    }}
template<typename A> ostream& operator<<(ostream &cout, vector<A> const &v) {
    if(dbg){
        dbg=0;
        cout << "["; for(ll i = 0; i < v.size(); i++) {if (i) cout << ", "; cout << v[i];} return cout << "]";
    }else{
        for(ll i=0;i<v.size()-1;i++) cout<<v[i]<<' ';
        return cout<<v[v.size()-1];
    }
}
template<typename A, typename B> istream& operator>>(istream& cin, pair<A, B> &p) {
   cin >> p.first;
   return cin >> p.second;
}
template<typename A> istream& operator>>(istream& cin, vector<A> &v) {
   for(ll i=0;i<v.size()-1;i++) cin>>v[i];
   return cin >> v[v.size()-1];
}

Measured memory_bytes: 3644
import sys
readline = sys.stdin.readline


sys.setrecursionlimit(10**7)
class LowLinks:
    def __init__(self, edges, edges_num:int):
        """edges[u]: all vertexes connected with vertex 'u'
        edges_num: number of edges of graph
        the root of DFS-tree is vertex 0
        """
        self.edges = edges
        self.V = len(edges)
        self.order = [-1]*V
        self.low = [float('inf')]*V
        self.bridges = []
        # if degreee(root) > 1 and graph is tree: root is articulation
        self.articulations = []
        if len(edges[0]) > 1 and edges_num == self.V-1:
            self.articulations.append(0)
        self.k = 0

    def build(self):
        self.dfs(0, 0)

    def get_bridges(self)->tuple:
        return self.bridges

    def get_articulations(self)->tuple:
        return self.articulations

    def dfs(self, v:int, prev:int):
        self.order[v] = self.k
        self.low[v] = self.k
        self.k += 1
        is_articulation = False
        for to in self.edges[v]:
            if self.order[to] < 0: # not visited
                self.dfs(to, v)
                self.low[v] = min(self.low[v], self.low[to])
                if self.order[v] < self.low[to]:
                    self.bridges.append((v, to) if v < to else (to, v))
                is_articulation |= self.order[v] <= self.low[to]
            elif to != prev: # back edge
                self.low[v] = min(self.low[v], self.order[to])
        if v>0 and is_articulation:
            self.articulations.append(v)

if __name__ == "__main__":
    V,E = map(int, readline().split())
    edges = [[] for _ in range(V)]
    for _ in range(E):
        s,t = map(int, readline().split())
        edges[s].append(t)
        edges[t].append(s)
    lowlinks = LowLinks(edges, E)
    lowlinks.build()
    bridges = lowlinks.get_bridges()
    bridges.sort()
    if bridges:
        for s,t in bridges:
            print(s, t)



Measured memory_bytes: 19372
int main(){
  char s[3];
  int a=0,b=0,c=0;
  int flag=0;
  for(int i=0; i < 3; i++){
    scanf("%c",&s[i]);
    if(a == 1 && s[i] == 'a'){
      flag = 1;
      break;
    }
    if(b == 1 && s[i] == 'b'){
      flag = 1;
      break;
    }
    if(c == 1 && s[i] == 'c'){
      flag = 1;
      break;
    }
    if(s[i] == 'a') a = 1;
    if(s[i] == 'b') b = 1;
    if(s[i] == 'c') c = 1; 
  }
  if(flag == 0){
    printf("Yes");
  }else{
    printf("No");
  }
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iostream>
typedef long long ll;
#define rep(i,a,b) for(ll i =a ;i <= b;i++)
#define per(i,a,b) for(ll i =a ;i >= b;i--)
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;



bool solve(vvi matrix, unordered_map<int,bool> num_map)
{
	int rcount=0 , ccount=0, dcount=0;
	rep(i, 0, 2)
	{
		rcount=0 , ccount=0;
		rep(j,0,2){
			if(num_map[matrix[i][j]] == true)
				rcount++;

			if(num_map[matrix[j][i]] == true)
				ccount++;

			if(i==j && num_map[matrix[i][j]] == true)
				dcount++;
		}
		if(rcount == 3 || ccount == 3)
			return true;
	}

	if(dcount == 3)
		return true;
	dcount = 0;
	rep(i, 0, 2)	
		if(num_map[matrix[2 - i][i]])
			dcount++;

	if(dcount == 3)
		return true;
	return false;
}

int main(int argc, char const *argv[])
{
	//ifstream cin("input.txt");
	
	vvi matrix(3, vi(3));
	unordered_map<int, bool> num_map;
	rep(i,0,2){
		rep(j,0,2)
		{
			cin>>matrix[i][j];
			num_map[matrix[i][j]] = false;
		}
	}
	int n, b;
	cin>>n;
	rep(i, 0, n-1)
	{
		cin>>b;
		num_map[b] = true;
		if(solve(matrix, num_map)){
			cout<<"Yes";
			return 0;
		}

		
	}
	cout<<"No";
}

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

bool comp(pair<long long, long long> p, pair<long long, long long> q) {
  if(p.second < q.second) return true;
  else if(p.second == q.second) {
    if(p.first < q.first) return true;
    else return false;
  } else {
    return false;
  }
}

int main() {
  int N; cin >> N;
  vector<pair<long long, long long> > v(N);
  for(int i = 0; i < N; ++i) {
    cin >> v[i].first >> v[i].second;
  }
  sort(v.begin(), v.end(), comp);
  long long time = 0;
  for(int i = 0; i < v.size(); ++i) {
    time += v[i].first;
    if(time > v[i].second) {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include "cctype"
using namespace std;

int main(int argc, char const *argv[])
{
	char x;
	int sum[26]={0};

	while(cin >> x)
	{
		if(isalpha(x))
		{
			if(isupper(x))
			{
				x += 32;
			}
			sum[x-'a']++;
		}
	}

	for (int i = 0; i < 26; ++i)
	{
		printf("%c : %d\n",i + 'a',sum[i]);
	}
	return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <queue>
#include <math.h>
#include <assert.h>
#include <set>
#include <map>
#include <bitset>
#include <ctime>
#include <time.h>
#include <algorithm>
#include <cstdio>
#include <fstream>
#include <stack>
#include <ctype.h>
#include <numeric>
#include <sstream>
#include <unistd.h>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <random>
#include <chrono>
#include <iomanip>
using namespace std;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
#define debug(name) DEBUG(#name, (name))
template<typename T>
void DEBUG(string label, T value) {
    cerr << "[" << label << " = " << value << "]\n";
}

void solve(){
    int n;
    ll k;
    cin >> n >> k;
    vector<int> arr(n);
    for(auto &i : arr){
        cin >> i;
        i--;
    }

    vector<bool> vis(n);
    vector<int> path;
    int cur = 0;

    int last = -1;
    while(1){
        if(vis[cur]){
            last = arr[cur];
            break;
        }
        vis[cur] = true;
        cur = arr[cur];
        path.push_back(cur);
    }
    //for(auto i : path){
        //cout << i+1 << " ";
    //}
    //cout << endl;
    assert(last != -1);

    int start = 0;
    for(int i = path.size() - 2; i >= 0; --i){
        if(path[i] == last){
            start = i;
            break;
        }
    }

    ll sz = path.size();
    k--;
    if(k < sz){
        cout << path[k%path.size()]+1 << endl;
    }
    else{

        ll ns = sz - (ll)start;
        k -= start;
        ll idx = k % ns + (ll)start;

        cout << path[idx]+1 << endl;
    }
}
int main(int argv, char **argc){
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    solve();
}


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

int main(void)
{
  char S[4];
  
  scanf("%s", S);
  if (S[0] == S[1] && S[1] == S[2])
  {
    printf("No\n");
  }
  else
  {
    printf("Yes\n");
  }
  
  return 0;
}

Measured memory_bytes: 128