akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int h[100001];
int dp[100001];
int main(void){
	int n;
	cin>>n;
	int i,j;
	for(i=1;i<=n;i++){
		cin>>h[i];
	}
	for(i=0;i<=n;i++){
		dp[i]=INT_MAX;
	}
	dp[1]=0;
	for(i=1;i<=n;i++){
		for(j=1;j<=2;j++){
			if(i+j<=n)	dp[i+j]=min(dp[i]+abs(h[i]-h[i+j]),dp[i+j]);
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}

	

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include <numeric>
#include<map>
#include<unordered_map>
#include <queue>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
    int n;
    cin >> n;
    string s[n];
    rep(i, n)cin >> s[i];
    int cnt = 0;
    rep(a, n){
        bool flag = true;
        rep(i, n)rep(j, n){
            if(s[i][(j+a)%n]!=s[j][(i+a)%n]){
                flag = false;
            }
        }
        if(flag)cnt++;
    }
    cout << cnt*n << endl;
}

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

using ll = long long;
#define pq priority_queue
#define debug(x) cerr << #x << ": " << x << endl;
#define line() cerr << "---------------" << endl;

int main() {
   int n, m;
   while (cin >> n >> m) {
      if (n == 0 && m == 0) break;
      vector<int> v(n);
      int sum = 0;
      for (int &x : v) {
         cin >> x;
         sum += x;
      }
      sort(v.begin(), v.end(), greater<int>());
      for (int i = m-1; i < v.size(); i+=m) {
         sum -= v[i];
      }
      cout << sum << endl;
   }

   return 0;
}


Measured memory_bytes: 3152
import java.util.*;
import java.io.*;
//Bellman Ford
public class Main {
	static int N, M, P;
	static List<ArrayList<Integer>> to, rto;
	static List<int[]> edges;
	static boolean reachableFrom1[];
	static boolean reachableToN[];
	static int INF = Integer.MAX_VALUE/2;
	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int N = fs.nextInt(), M = fs.nextInt(), P = fs.nextInt();
		to = new ArrayList<>();
		rto = new ArrayList<>();
		edges = new ArrayList<>();
		for(int i=0;i<N;i++) {
			to.add(new ArrayList<Integer>());
			rto.add(new ArrayList<Integer>());
		}
		for(int i=0;i<M;i++) {
			int a = fs.nextInt()-1, b = fs.nextInt()-1, c = fs.nextInt();
			to.get(a).add(b);
			rto.get(b).add(a);
			c -= P; //コストを辺から引くことで時間を意識しなくてよくなる
			c = -c; //最短経路問題にする
			int t[] = {a, b, c};
			edges.add(t);
		}
		
		//startからたどり着けないノードと、goalにたどり着けないノードを事前に消去する
		reachableFrom1 = new boolean[N];
		reachableToN = new boolean[N];
		dfs(0);
		rdfs(N-1);
		boolean ok[] = new boolean[N];
		for(int i=0;i<N;i++) {
			if(reachableFrom1[i]&&reachableToN[i])ok[i]=true;
		}
		
		//Bellman Ford
		int d[] = new int[N];
		Arrays.fill(d, INF);
		d[0]=0;
		boolean upd = true;
		int loopcnt = 0;
		while(upd) {
			upd = false;
			for(int i=0;i<M;i++) {
				int a = edges.get(i)[0];
				int b = edges.get(i)[1];
				int c = edges.get(i)[2];
				if(!ok[a] || !ok[b])continue;
				int newD = d[a]+c;
				if(newD < d[b]) {
					d[b] = newD;
					upd = true;
				}				
			}
			loopcnt ++;
			if(loopcnt > N+3) {//Nでいいはずだけど余裕を持って
				System.out.println(-1);
				return;
			}
		}
		int ans = Math.max(0, -d[N-1]);
		System.out.println(ans);
		
	}
	static void dfs(int v) {
		if(reachableFrom1[v])return;
		reachableFrom1[v]=true;
		for(int t:to.get(v)) {
			dfs(t);
		}
	}
	static void rdfs(int v) {
		if(reachableToN[v])return;
		reachableToN[v]=true;
		for(int t:rto.get(v)) {
			rdfs(t);
		}
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 28272
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

//FUNCTION

void solve(void)
{
  int N; cin>>N;
  vector<int> A (N,0);
  vector<int> B (N,0);
  for (int i = 0; i < N; i++)
  {
    cin>>A[i];
  }
  for (int i = 0; i < N; i++)
  {
    cin>>B[i];
  }
  int CNT = 0;
  int SUM = 0;
  vector<int> diff (N,0);
  for (int i = 0; i < N; i++)
  {
    if(B[i] > A[i]) {
      CNT ++;
      SUM += B[i] - A[i];
  }
  diff[i] = A[i] - B[i];
  }
  sort(ALL(diff));reverse(ALL(diff));
  int ANS = 0;
  while(SUM > 0)
  {
    if(diff[ANS] < 0 || ANS == N)
    {
      cout<<-1<<endl;
      return;
    }
    SUM -= diff[ANS];
    ANS++;
  }
  cout<<ANS + CNT <<endl;
  
  
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 2560
#![allow(unused_imports)]
use std::cmp::*;
use std::collections::*;
use itertools::Itertools;
use num_traits::clamp;
use ordered_float::OrderedFloat;
use proconio::{input, marker::*, fastout};
use superslice::*;

fn main() {
    input! {
        h: usize, w: usize, k: usize,
        s: [Chars; h],
    }

    let mut cum = vec![vec![0; w+1]; h];
    for (y, s) in (0..).zip(&s) {
        for (x, c) in (0..).zip(s) {
            cum[y][x+1] = cum[y][x] + if *c == '1' { 1 } else { 0 };
        }
    }

    let mut ans = 1<<60;
    'outer: for pattern in 0..1<<(h-1) {
        let mut hcut = Vec::new();
        let mut line = Vec::new();
        for i in 0..h {
            line.push(i);
            if pattern>>i & 1 == 1 {
                hcut.push(line);
                line = Vec::new();
            }
        }
        hcut.push(line);

        let mut cum2 = vec![vec![0; w+1]; hcut.len()];
        for (i, line) in (0..).zip(&hcut) {
            for &j in line {
                for x in 1..=w {
                    cum2[i][x] += cum[j][x];
                }
            } 
        }

        let mut prev = 0;
        let mut res = hcut.len() - 1;
        'vert: for x in 1..=w {
            for line in 0..cum2.len() {
                if cum2[line][x] - cum2[line][prev] > k {
                    if prev + 1 == x {
                        continue 'outer;
                    } else {
                        res += 1;
                        prev = x - 1;
                        continue 'vert;
                    }
                }
            }
        }

        ans = min(ans, res);
    }
    println!("{}", ans);
}


Measured memory_bytes: 2352
#include<stdio.h>
#include<algorithm>
#include<vector>
using namespace std;
int g[210][210];
double mat[210][210];
inline double ABS(double a){return max(a,-a);}
double EPS=1e-9;
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<b;i++){
		int p,q;
		scanf("%d%d",&p,&q);
		p--;q--;
		g[p][q]=g[q][p]=1;
	}
	int TM=30;
	while(TM--){
		for(int i=0;i<a;i++){
			for(int j=i;j<a;j++){
				if(!g[i][j]){
					mat[i][j]=mat[j][i]=0;
				}else{
					mat[i][j]=(double)(rand()%1000000000)/1000000000;
					if(i==0&&rand()%2==0)mat[j][i]=mat[i][j];
					else mat[j][i]=-mat[i][j];
				}
			}
		}
		bool zero=false;
		for(int i=0;i<a;i++){
			int at=i;
			for(int j=i+1;j<a;j++){
				if(ABS(mat[at][i])<ABS(mat[j][i])){
					at=j;
				}
			}
			if(ABS(mat[at][i])<EPS){
				zero=true;break;
			}
			for(int j=0;j<a;j++){
				swap(mat[at][j],mat[i][j]);
			}
			for(int j=0;j<a;j++){
				if(i==j)continue;
				double ks=mat[j][i]/mat[i][i];
				for(int k=0;k<a;k++)mat[j][k]-=ks*mat[i][k];
			}
		}
		if(!zero){
			printf("Yes\n");return 0;
		}
	}
	printf("No\n");
}

Measured memory_bytes: 1500
def judge(bit):
    for i in range(N):
        if not(bit & (1 << i)):
            continue
        for xy in v[i]:
            x = xy[0] 
            y = xy[1]
            if y == 1 and not(bit & (1 << x)):
                return False
            if y == 0 and (bit & (1 << x)):
                return False
    return True

N = int(input())
v = []
for i in range(N):
    A = int(input())
    array = []
    for i in range(A):
        a,b = map(int, input().split())
        a-=1 
        array.append((a,b))
    v.append(array)

res = 0
for bit in range(1 << N):
    if judge(bit):
        count = bin(bit).count("1")
        res = max(res, count)
    
print(res)

Measured memory_bytes: 44892
#include <bits/stdc++.h>
#define Cout(x)        cout << #x << " " << x << endl
#define ld long double
#define ll long long
#define vll vector<ll>
#define pll pair<ll ,ll >
#define vpll vector< pll >
#define pb push_back
#define MOD 1000000007
#define all(v) v.begin(),v.end()
#define fr(i,n) for(ll (i) = 0 ; (i) < (n) ; ++(i))
#define fr1(i,n) for(ll (i) = 1 ; (i) <= (n) ; ++(i))
#define frr(i,n) for(ll (i) = (n)-1 ; (i)>=0 ; --(i))
#define frab(i,a,b,c) for(ll (i) = a ; (i) < (b) ; (i)+=(c))
#define print(v) for( auto it: v) cout<<it<<" ";
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
ll A[300005];
int main()
{
	ios;
 
	ll a, b, c, d, n, m, k,   q;


	double t;
	cin >> t;
	if (t == 0) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}

}


Measured memory_bytes: 3824
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

int power(int x,int y){
	int res=1;
	x=x;
	while(y){
		if(y&1)res=(res*x);
		y=y>>1;
		x=(x*x);
	}
	return res;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N,K; cin >> N >> K;
    int a[N]; rep(i,N) cin >> a[i];
    vi A;
    rep(i,N){
        rep(j,N-i){
            int pos=i+1;
            int sum=0;
            rng(k,j,j+pos){
                sum+=a[k];
            }
            A.eb(sum);
        }
    }
    int ans=0;
    per(j,40){
        int cnt=0;
        int pos=ans+power(2,j);
        rep(i,SZ(A)){
            if((pos&A[i])==pos) cnt++;
        }
        if(cnt>=K) ans=pos;
    }
    cout << ans << endl;
}

Measured memory_bytes: 6512
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <functional>
#include <numeric>
#include <math.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main(void) {
	string s;
	cin >> s;
	for (int i = 0; i < s.length(); i++) {

	}
	if (s == "RRR") {
		cout << 3 << endl;
	} else if (s == "RRS" or s == "SRR") {
		cout << 2 << endl;
	} else if (s == "SSS") {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;


int dp[3005][3005];



int32_t main()
{
	string a, b, ans;


	cin >> a >> b;



	int N = a.length();

	int M = b.length();




	for (int i = 0; i <= N; ++i)
		dp[i][0] = 0;


	for (int i = 0; i <= M; ++i)
		dp[0][i] = 0;


	dp[0][0] = 0;



	for (int i = 1; i <= N; ++i)
	{

		for (int j = 1; j <= M; ++j)
		{

			if (a[i - 1] == b[j - 1])
				dp[i][j] = 1 + dp[i - 1][j - 1];
			else dp[i][j] = max(dp[i - 1][j] , dp[i][j - 1]);

		}

	}


	// for (int i = 0; i <= N; ++i)
	// {

	// 	for (int j = 0; j <= M; ++j)
	// 		cout << dp[i][j] << " ";

	// 	cout << endl;

	// }


	int i = N, j = M;


	while (i > 0 && j > 0)
	{

		if (a[i - 1] == b[j - 1])
		{

			ans.push_back(a[i - 1]);

			i--;
			j--;

		}
		else
		{

			if (dp[i - 1][j] > dp[i][j - 1])
				i--;
			else
				j--;

		}

	}


	reverse(ans.begin(), ans.end());



	//int ans = dp[N][M];

	cout << ans << endl;


}

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

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int n,x;
	while(true){
		cin >> n >> x;
		if(n==0 && x==0){
			break;
		}
		int cnt=0;
		for (int i = 1; i <= n; ++i) {
			for (int j = i+1; j <= n; ++j) {
				int k;
				k = x - i - j;
				if(i<k && j <k && k <= n){
					cnt++;
				}
			}
		}
		println(cnt);
	}



	return 0;
}



Measured memory_bytes: 3020
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		StringBuilder soto=new StringBuilder("");
		StringBuilder naka=new StringBuilder("");
		int H=sc.nextInt(),W=sc.nextInt(),x;
	while(H!=0||W!=0){
		x=2;
			soto.append("##");
		naka.append("#");
		for(int n=1;n<=W-2;n++){
			naka.append(".");
			soto.append("#");
			x++;}
		naka.append("#");
		System.out.println(soto);
		for(int n=1;n<=H-2;n++){
			System.out.println(naka);}
		System.out.println(soto);
		System.out.println();
		soto.delete(0,x);naka.delete(0,x);
		H=sc.nextInt();W=sc.nextInt();
			}
	}}

Measured memory_bytes: 21128
#include <iostream>
#include<cmath>
#include<algorithm>
#include <cassert>
#include <stdio.h>
using namespace std;
int main()
{
	char image[4];
	int count=0;
	for (int i = 0; i < 4; i++) {
		cin >> image[i];
		if (image[i] == '+') {
			count=count+1;
		}
		else { count=count-1; }
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<climits>
#include<cmath>
#include<iomanip>

using namespace std;

int main(void){
    int N, K;
    cin >> N >> K;
    if(N >= 2 * K - 1) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
//*--  ILSH  --*//
#include <bits/stdc++.h>
using namespace std; 
typedef long long int ll;
#define pb push_back 
#define pop pop_back
#define mp make_pair
#define vii vector < int >
#define vll vector < ll > 
#define pii pair < int , int >
#define pll pair < ll , ll >
#define vpi vector < pii >
#define vpl vector < pll >
#define fi first
#define sz size 
#define se second 
#define len length
const int N=2e5+5;
const ll inf=1e18+1e17;
void solve(){
	string s;
	cin>>s;
	int arr[26];
	memset( arr,0,sizeof ( arr));
	for ( int i=0;i<s.len();i++)
		arr[s[i]-'A']++;
	vii v;
	for ( int i=0;i<26;i++)
		if ( arr[i]>0)
			v.pb( arr[i]);
	if ( v.sz()==2&&v[0]==2&&v[1]==2)
		cout<<"Yes\n";
	else
		cout<<"No\n";

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


Measured memory_bytes: 256
#include <stdio.h>  
#include <algorithm>  
#include <assert.h>
#include <bitset>
#include <cmath>  
#include <complex>  
#include <deque>  
#include <functional>  
#include <iostream>  
#include <limits.h>  
#include <map>  
#include <math.h>  
#include <queue>  
#include <set>  
#include <stdlib.h>  
#include <string.h>  
#include <string>  
#include <time.h>  
#include <unordered_map>  
#include <unordered_set>  
#include <vector>  
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(int i=0;i<n;i++)
#define rep3(i,a,b) for(int i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define tii tuple<int,int,int>
#define pq priority_queue<int>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define edge(v,a,b) v[a].pb(b);v[b].pb(a);
#define MAX_V 400010
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define endl "\n"
#define ALL(c) (c).begin(),(c).end()
using namespace std;
int in() {int x;scanf("%d",&x);return x;}
ll lin() {ll x;scanf("%lld",&x);return x;}
template<typename A, size_t NNN, typename T>
void Fill(A (&array)[NNN], const T &val){
    fill( (T*)array, (T*)(array+NNN), val );
}
#define INF 1e9+7
#define LLINF 1e18+7
ll MOD=1e9+7;
#define N 610000
ll n,m,k;
ll dp[N][3];
int a[N];
int main(){
    n=in();
    rep2(i,1,n){
        int a[3];
        rep(j,3){
            a[j]=in();
        }
        rep(j,3){
            rep(k,3){
                if(j==k)continue;
                else{
                    dp[i][j]=max(dp[i-1][k]+a[j],dp[i][j]);
                }
            }
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
    return 0;
}

Measured memory_bytes: 4480
n=int(input())
a=list(map(int,input().split()))
ave=sum(a)//n
cost=0
for i in range(n):
    cost+=(a[i]-ave)**2
for i in range( min(a),max(a)+1 ):
    cost2=0
    for j in range(n):
        cost2+=(a[j]-i)**2
        if cost2 > cost:
            break
    if cost2 < cost:
        cost=cost2
print(cost)


Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        var NXT = ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        var (N, X, T) = (NXT[0], NXT[1], NXT[2]);

        var ans = T * (N / X + ((N % X > 0) ? 1 : 0));

        WriteLine(ans);
    }
}


Measured memory_bytes: 28144
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < n; i++)
#define ENDL "\n"
#define print(i) std::cout << (i) << "\n"

#define int long long // at least int64 > 9*10^18
#define all(v) v.begin(), v.end()

signed main() {
	int n,m;
	std::cin >> n >> m;
	std::vector<int> v(n,0);
	rep(i,m) {
		int a,b;
		std::cin >> a >> b;
		a--;b--;
		v[a]++;v[b]++;
	}
	bool alleven = true;
	rep(i,n) if(v[i]&1) alleven=false;
	if(alleven) {
		print("YES");
		return 0;
	}
	print("NO");
	return 0;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#include<algorithm>//next_permutation
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
#define dec(n) cout << fixed << setprecision(n);
#define large "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define small "abcdefghijklmnopqrstuvwxyz"
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

const ll MOD = 1000000007;
const ll MAX = 2000001;

ll mod(ll a){
  return a % MOD;
}

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

ll fac[MAX], finv[MAX], inv[MAX];

void nCrprep() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

ll nCr(ll n, ll r){
    if (n < r) return 0;
    if (n < 0 || r < 0) return 0;
    return fac[n] * (finv[r] * finv[n - r] % MOD) % MOD;
}

ll nCrcheep(ll n,ll r){
  if(r == 0) return 1;
  else if(r == 1) return n;
  else return nCrcheep(n-1,r-1)*n/r;
}

vector<pair<ll,ll>> prime_factorize(ll n){
  vector<pair<ll,ll>> res;
  
  for(ll i=2; i*i <= n; i++){
    if(n % i != 0) continue;
    
    ll ex = 0;
    while(n % i == 0){
      ex++;
      n /= i;
    }
    
    res.push_back({i,ex});
  }
  
  if(n != 1) res.push_back({n,1});
  
  return res;
  
}




int main(){
  ll n; cin >> n; vl color(n); vector<bool> iscame(n);
  
  vector<vector<pair<ll,ll>>> table(n);
  rep(i,n){
    ll u,v,w; cin >> u >> v >> w;
    
    table[u-1].push_back(make_pair(v-1,w));
    table[v-1].push_back(make_pair(u-1,w));
  }
  
  queue<ll> q;
  
  q.push(0);
  
  while(!q.empty()){
    ll x = q.front();
    q.pop();
    iscame[x] = true;
    
    for(auto p : table[x]){
      ll a = p.first; ll b = p.second;
      
      if(!iscame[a]){
        if(b % 2 == 0){
          color[a] = color[x];
        }
        else{
          if(color[x] == 1) color[a] = 0;
          else color[a] = 1;
        }
      
        q.push(a);
      }
    }
    
  }
  
  for(ll x : color) cout << x << endl;
  
  
}

Measured memory_bytes: 14452
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DPL_3_A
// Pattern - Largest Square
// status: [solve][review]

#define SUBMIT

#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int MAX_SIDE = 1400;
int c[MAX_SIDE + 1][MAX_SIDE + 1];
// dp[y][x] タイル(y, x)から左上に向かってできる最大の正方形の辺の長さ（タイルの数）
int dp[MAX_SIDE + 1][MAX_SIDE + 1];

int H, W;

int compute_largest_square() {
    int max_side = 0;
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j) {
            if (c[i][j] == 1) dp[i][j] = 0;
            else {
                dp[i][j] = 1;
                max_side = 1;
            }
        }
    }

    for (int i = 1; i < H; ++i) {
        for (int j = 1; j < W; ++j) {
            if (c[i][j] == 1) dp[i][j] = 0;
            else {
                dp[i][j] = min<int>({dp[i - 1][j - 1], dp[i - 1][j], dp[i][j - 1]}) + 1;
                max_side = max(max_side, dp[i][j]);
            }
        }
    }

    return max_side * max_side;
}

int main() {
#ifdef SUBMIT
    auto& stream = cin;
#else
    string program_input_str = R"(4 5
0 0 1 0 0
1 0 0 0 0
0 0 0 1 0
0 0 0 1 0
)";
    stringstream stream(program_input_str);
#endif
    stream >> H >> W;
    for (int y = 0; y < H; ++y) {
        for (int x = 0; x < W; ++x) {
            stream >> c[y][x];
        }
    }

    cout << compute_largest_square() << endl;
    return 0;
}



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


int main(){
  string s;
  int a, z;
  
  cin >> s;
  
  for(int i = 0;;i++){
    if(s.at(i) == 'A'){
      a = i;
      break;
    }
  }
  for(int i = s.size() - 1;;i--){
    if(s.at(i) == 'Z'){
      z = i;
      break;
    }
  }
  
  cout << z - a + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr ll inf = 1ll<<62;
class UF{
    vector<int> par;
    public:
    UF(int n):par(n){iota(par.begin(),par.end(),0);}
    int operator[](int x){ return (par[x] == x)?x:par[x] = UF::operator[](par[x]);}
    void operator()(int x,int y){
        x = operator[](x);y = operator[](y);
        if(x == y)return;
        if(x > y)swap(x,y);
        par[y] = x;
    }
};
int main(){
    int n,m;
    cin>>n>>m;
    UF uf(n+1);
    for(int i=0;i<m;++i){
        int x,y,z;
        cin>>x>>y>>z;
        x--;
        y--;
        uf(x,y);
    }
    map<int ,int> mp;
    int count = 0;
    for(int i=0;i<n;++i){
        if(!mp.count(uf[i])){
            count++;
            mp[uf[i]]++;
        }
    }
    cout << count << endl;
    return 0;
}



Measured memory_bytes: 5376
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

using namespace std;

int main() {
        int n, t, a;
        vector<int> va;
        cin >> n >> t;
        for (int i = 0; i < n; i++) {
                cin >> a;
                va.push_back(a);
        }
        int b, minb = 1e9;
        vector<int> vb;
        vb.push_back(va[0]);
        for (int i = 1; i < n; i++) {
                minb = min(minb, va[i-1]);
                vb.push_back(minb);
        }
        vector<int> vc;
        for (int i = 0; i < n; i++) {
                vc.push_back(va[i] - vb[i]);
        }
        sort(vc.begin(), vc.end());
        reverse(vc.begin(), vc.end());

        int ans = 0;
        for (int i = 0; i < n; i++) {
                if (vc[i] == vc[0]) {
                        ans++;
                }
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 1784
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
int read(){int a;scanf("%lld",&a);return a;}

const int inf = 1e9 + 10;

int N;
int m[105];

void p_factor(int n)
{
	for (int i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			//printf("%lld\n", i);
			m[i]++;
			n /= i;
		}
	}

	if (n != 1) m[n]++;
}

signed main()
{
	cin >> N;
	for (int i = 1; i <= N; ++i) p_factor(i);

	int ans = 0;

	// { 74 }
	rep1(i, N) if (m[i] >= 74) ans++;
	// {2, 24}
	rep1(i, N) {
		rep1(j, N) {
			if (i == j) continue;
			if (m[i] >= 2 and m[j] >= 24) ans++;
		}
	}
	// {4, 14}
	rep1(i, N) {
		rep1(j, N) {
			if (i == j) continue;
			if (m[i] >= 4 and m[j] >= 14) ans++;
		}
	}
	// {2, 4, 4}
	rep1(i, N) {
		rep1(j, N) {
			if (i == j) continue;
			rep1(k, j - 1) {
				if (k == i) continue;
				if (m[i] >= 2 and m[j] >= 4 and m[k] >= 4) {
					ans++;
				}
			}
		}
	}

	cout << ans << endl;
}


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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int v = 1e9;
    ll s;
    cin >> s;
    ll x1, x2, x3, y1, y2, y3;
    x1 = y1 = 0;
    x2 = v, y2 = 1;
    x3 = (v - s % v) % v;
    y3 = (x3 + s) / v;
    cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << x3 << " " << y3 << endl;
    
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <string>

using namespace std;

typedef pair<string, int> s_i;

int main()
{
    for (int i = 0; i < 3; i++) {

        int a, b, c;
        cin >> a >> b >> c;
        long at = 0, bt = 0;
        at = a * 3600 + b * 60 + c;
        cin >> a >> b >> c;
        bt = a * 3600 + b * 60 + c;
        bt -= at;
        a = bt / 3600;
        bt -= a * 3600;
        b = bt / 60;
        bt -= b * 60;
        cout << a << " " << b << " " << bt << endl;
    }
    return 0;
}
        

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

int main() {
	int a, b, n;
	while (cin >> a >> b >> n) {
		if (a >= b) a %= b;
		int sum = 0;
		for (int i = 0; i < n; i++) {
			a *= 10;
			sum += a/b;
			a %= b;
		}
		cout << sum << endl;
	}
	return 0;
}

Measured memory_bytes: 0
n,m,x = map(int,input().split())
a = [[]for i in range(n)]
ans = -1
for i in range(n):
    a[i] = list(map(int,input().split()))
for i in range(2**n):
    b = str(bin(i))
    c = [0]*(m+1)
    cscore = 0
    for j in range(0,len(b)-2):
        if b[-j-1] == "1":
            for k in range(m+1):
                c[k]+=a[j][k]
    cscore = c[0]
    for j in range(m):
        if c[j+1] < x:
            cscore = -1
    if cscore!=-1:
        if ans == -1:
            ans = cscore
        else:
            ans = min(ans,cscore)

print(ans)

Measured memory_bytes: 68540
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
////////////////////////////

struct eq{
    ll t,a;
    const bool operator<(const eq opponent)const{
        return t<opponent.t;
    }
};

int main(){
    ll n;cin>>n;
    eq e[n];
    rep(i,0,n-1){
        cin>>e[i].t>>e[i].a;
    }
    ll q;cin>>q;
    ll l[q],r[q];
    rep(i,0,q-1){
        cin>>l[i]>>r[i];
    }
    double p[n+1];
    p[0]=0;
    rep(i,0,n-1){
        p[i+1]=p[i]+log(1-(double)(0.1*e[i].a));
        
    }
    ll li,ri;
    eq E;
    double m=1000000000;
    rep(i,0,q-1){
        E.t=l[i];
        li=lower_bound(e,e+n,E)-e;
        E.t=r[i];
        ri=lower_bound(e,e+n,E)-e;
        //cout<<li<<' '<<ri<<endl;
        cout<<setprecision(20)<<m*exp(p[ri]-p[li])<<endl;
    }
    
    return 0;
}



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

int main() {
	string S, T;
	int ans = 0;
	cin >> S;
	cin >> T;

	for (unsigned int i = 0; i < S.size(); i++) {
		if (S.at(i) != T.at(i)) ans++;
	}

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

Measured memory_bytes: 3832
#define _CRT_SECURE_NO_WARNINGS
#pragma comment(linker, "/stack:16777216")
#include <string>
#include <vector>
#include <map>
#include <list>
#include <iterator>
#include <set>
#include <queue>
#include <iostream>
#include <sstream>
#include <stack>
#include <deque>
#include <cmath>  
#include <memory.h>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <algorithm>
#include <utility>
#include <time.h>
#include <bitset>
using namespace std;

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(A,value) memset(A,value,sizeof(A))

#define ALL(V) V.begin(), V.end()
#define SZ(V) (int)V.size()
#define PB push_back
#define MP make_pair
const double PI=acos(-1.0);

typedef long long Int;
typedef long long LL;
typedef unsigned long long UINT;
typedef vector <int> VI;
typedef pair <int, int> PII;
typedef pair <double, double> PDD;

const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 500000;
const int MAX1 = 2007;
const int MAX2 = 24000000;
const int LEN = 21;
const int BASE = 1000000000;

const int CNT = 100;

int n;
int A[MAX];


int main()
{
  cin >> n;
  FOR (i,1,n+1)
  {
    scanf("%d", &A[i]);
  }

  Int res = 0;
  FOR (i,1,n+2) res += abs(A[i]-A[i-1]);

  FOR (i,1,n+1)
  {
    Int tot = res;
    tot -= abs(A[i]-A[i-1]);
    tot -= abs(A[i+1]-A[i]);
    tot += abs(A[i-1]-A[i+1]);
    printf("%lld\n", tot);
  }
  
  
  
  return 0;
}


Measured memory_bytes: 1664
//#include "pch.h"
#include <iostream>
#include <vector>
#include <string>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <math.h>
#define OO INT_MAX
#define mp(x,y) make_pair(x,y)
#define x first
#define y second
#define ll unsigned long long int
#define pp pair<int,int>
#define heap priority_queue<pp, vector<pp>, greater<pp>>
using namespace std;

int main()
{
	//freopen("test.txt", "r", stdin);
	
	int n, H;
	cin >> H >> n;
	ll S = 0;
	int in;
	for (int i = 0; i < n; i++) {
		cin >>in;
		S += in;
	}
	if (S >= H) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
	return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<list>
using namespace std;
static const int MAX = 100000;

vector<int>G[MAX];
list<int>out;
bool V[MAX];
int N;

void dfs(int u) {
	V[u] = true;
	for (int i = 0; i < G[u].size(); i++) {
		int v = G[u][i];
		if (!V[v])dfs(v);
	}
	out.push_front(u);
}

int main() {
	int s, t, M;

	cin >> N >> M;

	for (int i = 0; i < N; i++)V[i] = false;

	for (int i = 0; i < M; i++) {
		cin >> s >> t;
		G[s].push_back(t);
	}

	for (int i = 0; i < N; i++) {
		if (!V[i])dfs(i);
	}

	for (list<int>::iterator it = out.begin(); it != out.end(); it++)
		cout << *it << endl;

	return 0;
}


Measured memory_bytes: 6220
package main

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

var (
	nstr   func() string
	stdout *bufio.Writer
)

func init() {
	nstr = newReadString(os.Stdin)
	stdout = bufio.NewWriter(os.Stdout)
}

func main() {
	defer stdout.Flush()
	n := nint()
	k := nint()
	aList := getIntSlice(n)

	sumList := make([]int, 0)
	for i:=0;i<n ;i++  {
		for j:=i+1;j<n+1 ;j++  {
			sum := 0
			for tmp:=i;tmp<j ;tmp++  {
				sum += aList[tmp]
			}
			sumList = append(sumList, sum)
		}
	}
	var (
		ans int
		count int
	)
	for i:=40; i>=0; i--{
		checkNum := 1 << uint(i)
		tmp := make([]int, 0)
		for j:=0;j<len(sumList) ;j++  {
			logical := checkNum & sumList[j]
			if logical !=0{
				count ++
				tmp = append(tmp, sumList[j])
			}
		}
		if count >= k{
			ans += checkNum
			sumList =  tmp
		}
		count = 0

	}
	fmt.Println(ans)
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}

func nint64() int64 {
	i, err := strconv.ParseInt(nstr(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func nint() int {
	return int(nint64())
}

func getIntSlice(n int) []int {
	b := make([]int, n)
	for i := 0; i < n; i++ {
		b[i] = nint()
	}
	return b
}

func getStringSlice(n int) []string {
	b := make([]string, n)
	for i := 0; i < n; i++ {
		b[i] = nstr()
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func contains(s []int, e int) bool {
	for _, a := range s {
		if a == e {
			return true
		}
	}
	return false
}

func bin(i int, prefix bool) string {
	i64 := int64(i)

	if prefix {
		return "0b" + strconv.FormatInt(i64, 2)
	} else {
		return strconv.FormatInt(i64, 2)
	}
}

func strReverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}

	return string(runes)
}



Measured memory_bytes: 15104
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<string>
#include<bitset>
#include <sstream>
#include<queue>
#include<set>
#define rep(i,n) for(ll i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef pair<int,ll>P;

int main()
{
    int n,d;
    cin>>n>>d;
    cout<<(n-1)/(2*d+1)+1;
}

Measured memory_bytes: 256
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	n, k := io.ScanInt(), io.ScanInt()
	towns := io.ScanInts(n)

	foundTownMap := map[int]int{}
	curTown := 1
	curCount := 0
	for i := 0; i <= k; i++ {
		if i == k {
			fmt.Println(curTown)
			return
		}
		if foundTownMap[curTown] > 0 {
			curCount = i
			break
		}
		foundTownMap[curTown] = i
		curTown = towns[curTown-1]
	}
	loopNum := curCount-foundTownMap[curTown]
	if loopNum == 0 {
		fmt.Println(curTown)
		return
	}
	remain := (k-curCount)%loopNum
	for i := 0; i < remain; i++ {
		curTown = towns[curTown-1]
	}
	fmt.Println(curTown)
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 17184
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
using namespace std;
const int N=305;
const int INF=1e9;

int n,m;
int a[N][N];

int ans;

bool played[N];
int part[N];

int check()
{
    int i,j;
    int res=0;

    memset(part,0,sizeof(part));
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(played[a[i][j]])
            {
                part[a[i][j]]++;

                break;
            }
        }
    }

    for(i=1;i<=m;i++)
        res=max(res,part[i]);

    return res;

}

int find_most()
{
    int i,j;
    int res=0;

    memset(part,0,sizeof(part));

    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            if(played[a[i][j]])
            {
                part[a[i][j]]++;

                break;
            }
        }
    }


    for(i=1;i<=m;i++)
    {
        if(part[i]>part[res])
            res=i;
    }

    return res;

}

int main()
{
   int i,j;
   int rem;

   cin>>n>>m;
   for(i=1;i<=n;i++)
   {
       for(j=1;j<=m;j++)
       {
           scanf("%d",&a[i][j]);
       }
   }

   for(i=1;i<=m;i++)
    played[i]=true;

   ans=check();


   for(i=1;i<m;i++)
   {
       rem=find_most();

       played[rem]=false;


       ans=min(ans,check());

   }

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

   return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  ll n;
  cin >> n;
  ll sum = 0, last;
  for (ll i = 1; i <= n; ++i) {
    sum += i;
    if (sum >= n) {
      last = i;
      break;
    }
  }
  ll dif = sum - n;
  debug(dif);
  for (ll i = 1; i <= last; ++i) {
    if (i != dif) cout << i << "\n";
  }
  return 0;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

// ABC157 C - Guess The Number
int main(){
  int n, m; // 1 <= N <= 3, 0 <= M <= 5
  cin >> n >> m;

  vector<int> digits(n, 0);
  unordered_map<int, int> inputs; // s, c

  bool canCreate = true;
  rep(i,m) {
    int s, c;
    cin >> s >> c;
    const auto itr = inputs.find(s);
    if (n != 1 && s == 1 && c == 0) {
      canCreate = false; // 左から1桁が0はNG
    }
    if (itr != inputs.end() && itr->second != c) {
      canCreate = false; // 同じ桁に異なる数値
    }
    inputs[s] = c;
    digits[s-1] = c;
  }
  if (!canCreate) {
    cout << -1 << endl;
    return 0;
  }
  if (n >= 2 && digits[0] == 0) {
    digits[0] = 1;
  }
  rep(i,n) {
    cout << digits[i];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 3568
import bisect
w, h = map(int, input().split())
p = [int(input()) for _ in range(w)]
q = [int(input()) for _ in range(h)]

q.sort()
q_cum = [0 for _ in range(h+1)]
for i in range(h):
    q_cum[i+1] = q_cum[i] + q[i]

ans = sum(q)
for i in range(w):
    x = bisect.bisect_left(q, p[i])
    ans += q_cum[x] + p[i] * (h + 1 - x)

print(ans)

Measured memory_bytes: 16064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <set>
#include <queue>

using namespace std;

typedef long long ll;

int N, V[100005];
ll C, X[100005];
ll A[100005], B[100005];
int main() {
  scanf("%d %lld", &N, &C);
  for (int i = 1; i <= N; i++) {
    scanf("%lld %d", &X[i], &V[i]);
  }
  X[N + 1] = C;
  ll sum = 0;
  for (int i = 1; i <= N; i++) {
    sum += -(X[i] - X[i - 1]) + V[i];
    A[i] = max(A[i - 1], sum);
  }
  sum = 0;
  for (int i = N; i >= 1; i--) {
    sum += -abs(X[i + 1] - X[i]) + V[i];
    B[i] = max(B[i + 1], sum);
  }
  ll res = max(A[N], B[1]);
  for (int i = 1; i <= N; i++) {
    ll best = A[i] - X[i] + B[i + 1];
    res = max(res, best);
  }
  for (int i = N; i >= 1; i--) {
    ll best = B[i] - (C - X[i]) + A[i - 1];
    res = max(res, best);
  }
  printf("%lld\n", max(0LL, res));
  return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <vector>

using namespace std;

vector<int> generate(int N, int d){
    int arr[2][8] = {
        {0, 1, 3, 2, 2, 3, 1, 0},
        {0, 1, 3, 2, 2, 0, 1, 3}
    };
    vector<int> res(2);
    res[0] = 0;
    res[1] = 1;
    --d;
    for(int i=1;i+1<N;i+=2){
        vector<int> next;
        for(int j=0;j<res.size();j+=2){
            int use = (d > 0 && j+2 == res.size() ? 1 : 0);
            for(int k=0;k<8;k++) next.push_back(4*res[j+k/4] + arr[use][k]);
            if(use) d -= 2;
        }
        res = next;
    }
    if(N%2 == 0){
        vector<int> next;
        for(int j=0;j<res.size();j+=2){
            next.push_back(2*res[j]);
            next.push_back(2*res[j]+1);
            next.push_back(2*res[j+1]+1);
            next.push_back(2*res[j+1]);
        }
        res = next;
    }
    return res;
}

vector<int> solve(int N, int A, int B){
    vector<int> same;
    vector<int> dif;
    for(int i=0;i<N;i++){
        if((A&(1<<i)) == (B&(1<<i))) same.push_back(i);
        else dif.push_back(i);
    }
    if(dif.size()%2 == 0) return vector<int>();
    auto base = generate(N, dif.size());
    vector<int> res;
    for(auto& t : dif) same.push_back(t);
    for(auto& t : base){
        int v = 0;
        for(int i=0;i<same.size();i++){
            if((A>>same[i])%2 != (t>>i)%2) v |= 1 << same[i];
        }
        res.push_back(v);
    }
    return res;
}

int main(){
    int N, A, B; cin >> N >> A >> B;
    auto res = solve(N, A, B);
    if(res.empty()){
        cout << "NO" << endl;
    } else {
        cout << "YES" << endl;
        cout << res[0];
        for(int i=1;i<res.size();i++) cout << " " << res[i];
        cout << endl;
    }
}

Measured memory_bytes: 2112