akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
void sort(long long* data,int l,int r);
int pivot(long long* data,int i,int j);
int partition(long long* data,int i,int j,long long x);

int main(void){
	int N,M,i,j;
	scanf("%d %d",&N,&M);
	long long data[N][3],sum[N];
	for(i=0;i<N;i++){
		scanf("%lld %lld %lld",&data[i][0],&data[i][1],&data[i][2]);
	}
	long long ans=0;
	for(j=1;j<=8;j++){
		for(i=0;i<N;i++){
			sum[i]=0;
			if(j<=4)	sum[i]+=data[i][0];
			else		sum[i]-=data[i][0];
			if(j==1 ||j==2 ||j==5 ||j==6 )	sum[i]+=data[i][1];
			else		sum[i]-=data[i][1];
			if(j==1 ||j==3 ||j==5 ||j==7 )	sum[i]+=data[i][2];
			else		sum[i]-=data[i][2];
		}
		sort(sum,0,N-1);
		
		long long tmp=0;
		for(i=0;i<M;i++){
			tmp += sum[N-i-1];
		}
		if(tmp>ans) ans=tmp;
	}
	
	printf("%lld",ans);

	return 0;
}

int pivot(long long* data,int i,int j){
	int k = i+1;
	while(k <= j && data[i]==data[k]) k++;
	if(k>j)	return -1;
	if(data[i] >= data[k]) return i;
	return k;
}

int partition(long long* data,int i,int j,long long x){
	int l = i, r = j;
	while(l <= r){
		while( l <= j && data[l] < x) l++;
		while( r >= i && data[r] >= x) r--;
		if(l > r) break;
		long long t = data[l];
		data[l] = data[r];
		data[r] = t;
		l++;r--;
	}
	return l;
}

void sort(long long* data,int i,int j){
	if(i == j) return;
	int p = pivot(data,i,j);
	if(p != -1){
		int k = partition(data,i,j,data[p]);
		sort(data,i,k-1);
		sort(data,k,j);
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool solve() {
  int N; cin >> N;
  vector<pair<int, int>> A, B;
  for (int i = 0; i < N; i++) {
    string s; cin >> s;
    bool flag = true;
    if (count(s.begin(), s.end(), '(') < count(s.begin(), s.end(), ')')) {
      reverse(s.begin(), s.end());
      for (auto& c : s) c = '(' + ')' - c;
      flag = false;
    }
    int sum = 0, mi = 0;
    for (auto c : s) {
      if (c == '(') sum++;
      else sum--;
      mi = min(mi, sum);
    }
    (flag ? A : B).emplace_back(mi, sum);
  }
  sort(A.rbegin(), A.rend());
  sort(B.rbegin(), B.rend());
  auto f = [](const vector<pair<int, int>>& v) -> int {
    int res = 0;
    for (auto [mi, sum] : v) {
      if (mi + res < 0) return -1;
      res += sum;
    }
    return res;
  };
  int a = f(A);
  int b = f(B);
  if (a < 0 || b < 0 || a != b) return false;
  return true;
}

int main() {
  if (solve()) cout << "Yes" << endl;
  else cout << "No" << endl;
}


Measured memory_bytes: 11332
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <tuple>
#include <utility>
#include <vector>
#define rep(i, j) for (long long i = 0; i < j; i++)
#define int long long
#define gcn(N) \
    int N;     \
    cin >> N;
#define debug(var)                  \
    do {                            \
        std::cout << #var << " : "; \
        view(var);                  \
    } while (0)
template <typename T>
void view(T e)
{
    std::cout << e << std::endl;
}
template <typename T>
void view(const std::vector<T>& v)
{
    for (const auto& e : v) {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>>& vv)
{
    for (const auto& v : vv) {
        view(v);
    }
}

using namespace std;
/*


*/

signed main()
{
    gcn(N);
    vector<int> L(N, 0);
    rep(i, N)
    {
        cin >> L[i];
    }
    std::sort(L.begin(), L.end());
    // debug(L);
    int cnt = 0;
    rep(i, N - 2)
    {
        //L[i]~L[N]で三角形を作るような組み合わせを探す
        for (int k = i + 1; k < N - 1; k++) {
            //ここ二分探索
            int sum = L[i] + L[k];
            int left = k;
            int right = N - 1;
            int m = right;
            while (right - left > 1) {
                m = (left + right) / 2;
                if (sum < L[m]) {  //行き過ぎ
                    right = m;
                } else {
                    left = m;
                }
            }
            while ((m + 1 < N) && (sum > L[m + 1])) {
                m += 1;
            }  //m は sum > L[m]を満たす最大の整数
            while (sum <= L[m]) {
                m -= 1;
            }  //m は sum > L[m]を満たす最大の整数
            if (!(m == k)) {
                // cout << "i: " << i << " k:" << k << " m-k:" << m - k << ": " << L[i] << " " << L[k] << " " << L[m] << endl;
                cnt += m - k;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
def main():
    c=[list(map(int,input().split())) for i in range(3)]
    a=[0,0,0]
    b=[0,0,0]
    for i in range(0,101):
        a[0]=i
        a[1]=-1
        a[2]=-1
        b[0]=c[0][0]-a[0]
        b[1]=c[0][1]-a[0]
        b[2]=c[0][2]-a[0]
        for j in range(1,3):
            if c[j][0]-b[0]!=c[j][1]-b[1] or c[j][1]-b[1]!=c[j][2]-b[2]:
                break
            a[j]=c[j][0]-b[0]

            if j == 2 and check(a,b):
                print('Yes')
                return
    print('No')

def check(a,b):
    for i in range(0,3):
        if a[i] >= 0 and b[i] >= 0 :
            continue
        else:
            return False
    return True

if __name__=='__main__':
    main()


Measured memory_bytes: 3064
#include <cstdio>
#include <set>
using namespace std;
int main() {
	int a, b, c;
  	set<int> s;
  	scanf("%d %d %d", &a, &b, &c);
  	s.insert(a);
  	s.insert(b);
  	s.insert(c);
  	printf("%d\n", (int) s.size());
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF (int)1e10
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

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

    vector<int> a(n), b(n);

    for (int &x : a)
        cin >> x;
    for (int &y : b)
        cin >> y;

    vector<int> arr(n);
    for (int i = 0; i < n; i++)
        arr[i] = i + 1;

    int x = 0, y = 0;
    int c = 1;
    do
    {
        if (arr == a)
        {
            x = c;
        }
        if (arr == b)
        {
            y = c;
        }
        c++;

    } while (next_permutation(arr.begin(), arr.end()));

    cout << abs(x - y) << endl;
}

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<LL, LL> PLL;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL gcd(LL x, LL y){
  if(y == 0) return x;
  return gcd(y, x%y);
}
LL lcm(LL x, LL y){
  return x/gcd(x,y)*y;
}

LL powm(LL x, LL y){
  if(y == 0) return 1;
  return powm(x*x%MOD, y/2) * (y%2==1?x:1)%MOD;
}

LL inv(LL x){
  return powm(x, MOD-2);
}


int NN;
class SegT{
private:
public:
  LL sum[2 * (1 << 18) - 1];
  LL lc[2 * (1 << 18) - 1];

  SegT(int n_){
	NN = 1;
	while(NN < n_) NN <<= 1;
	for(int i=0;i<2*NN-1;++i) sum[i] = 0;
	for(int i=0;i<2*NN-1;++i) lc[i] = 1;
  }

  // dat[idx] = a, 0-indexed
  void update(int idx, LL a, LL lm){
	idx += NN - 1;
	lc[idx] = lm;
	sum[idx] = a * inv(lm) % MOD;
	while(idx > 0){
	  idx = (idx - 1) / 2;
	  sum[idx] = (sum[idx*2+1] + sum[idx*2+2]) % MOD;
	  lc[idx] = lcm(lc[idx*2+1], lc[idx*2+2]);
	}
  }

  // calc min of [a,b)
  // k := index of node
  // [l,r) := range of node k
  // use query(a,b,0,0,n)
  PLL query(int a, int b, int k=0, int l=0, int r=NN){
	// no intersect
	if(r <= a || b <= l) return MP(0,1);

	// completely contain
	if(a <= l && r <= b) return MP(sum[k], lc[k]);
	else{
	  PLL vl = query(a, b, k*2+1, l, (l+r)/2);
	  PLL vr = query(a, b, k*2+2, (l+r)/2, r);
	  return MP((vl.FF+vr.FF)%MOD, lcm(vl.SS,vr.SS));
	}
  }
};

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int N, Q; cin >> N >> Q;
  VI pm(N+1);
  REP(i,N) cin >> pm[i+1];

  VI cl(N+1);
  vector<LL> sum(N+1), len(N+1);
  FOR(i,1,N+1){
	int ix = i;
	while(cl[ix] == 0){
	  cl[ix] = i;
	  (sum[i] += ix) %= MOD;
	  len[i]++;
	  ix = pm[ix];
	}
  }

  SegT seg(N+1);
  FOR(i,1,N+1)
	seg.update(i, sum[cl[i]], len[cl[i]]);
  
  while(Q--){
	int l, r; cin >> l >> r;
	LL res = 0;
	auto p = seg.query(l,r+1);
	res = p.FF * (p.SS % MOD) % MOD;
	cout << res << endl;
  }
  
  return 0;
}

Measured memory_bytes: 9460
#include<bits/stdc++.h>
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define full(a) a.begin(),a.end()
#define rfull(a) a.rbegin(),a.rend()

using namespace std;
const double pi=acos(-1.0);
const double pii=2*pi;
const double eps=1e-6;
const long long MOD=1e9+7;

long long no_of(long long a, long long b){
	long long ans=0,p_b=b;
	while(p_b<=a){
		ans+=(a/p_b);
		if(a/p_b >= b){
			p_b*=b;
		}
		else{
			p_b=a+1;
		}
	}
	return ans;
}

void solve(){
	long long n;
	cin>>n;
	if(n%2==1){
		cout<<0<<"\n";
		return;
	}

	long long ans = min(no_of(n/2,5ll),n/2+1+no_of(n/2,2ll));
	cout<<ans<<"\n";
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(NULL);
	std::cout.tie(NULL);
	solve();
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <utility>
#include <typeinfo>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

long long int L = 1000000007;

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

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

  long long int a[1000]={};
  int count = 0;
  long long int ans = 1;

  for(long long int i=2;i<n+1;i++)
  {
    if(isPrime(i))
    {
      for(int j=i;j<n+1;j = j+i)
      {
        int k = j;
        while(k >= i)
        {
          if(k%i == 0)
          {
            k /= i;
            a[count]++;
          }
          else
          {
            break;
          }
        }
      }
    }
    if(a[count]>0)
    {
      ans = ( ans * (a[count] +1) ) % L ;
      count ++;
    }
  }
  cout << ans <<endl;

  return 0;
}




Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	unsigned long a;
	scanf("%lu",&a);
	unsigned long i=0;
  unsigned long mon=100;
  while(1){
    i++;
    mon=mon*1.01;
    if(mon>=a){
      break;
    }
  }
  printf("%lu",i);
	return 0;
}

Measured memory_bytes: 2156
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
int main(){
  double x,y;
  double dx,dy;
  double len;
  int n;
  while( cin >> n ){
    if(n == -1)break;
  n--;
  x = 1;
  y = 0;
  while(n--){
    dx = -y;
    dy = x;
    len = sqrt(pow(x,2) + pow(y,2));
    x+=dx/len;
    y+=dy/len;
  }
  printf("%.2f\n%.2f\n",x,y);
  }
  return 0;
}

Measured memory_bytes: 1196
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double Pi = 3.14159265358979323846;
double dis(double a, double b, double deg) {
    //printf("a = %f b = %f deg = %f\n",a,b,deg);
    return sqrt(a*a + b*b - 2*a*b*cos(Pi*deg/180.0));
}

int main() {
    double h, w, a, b;
    cin >> a >> b >> h >> w;
    double degh,degw;
    degh = h*30.0+w/2.0;
    degw = w*6.0;
    printf("%.16f\n",dis(a,b,fabs(degh-degw)));
}

Measured memory_bytes: 4268
<?php
$str = trim(fgets(STDIN));
$len = strlen($str);
$max = pow(2,$len-1);
$total = 0;
if($len==1){echo $str; exit;}
for($i = 0; $i < $max; $i++){
  $bits = sprintf("%0".($len-1)."b", $i)."1";
  $subtotal = 0;
  for($j = 0; $j < $len; $j++){
    $subtotal*=10;
    $subtotal+=$str[$j];
    if($bits[$j]){
      $total += $subtotal;
      $subtotal = 0;
    }
  }
}
echo $total,"\n";

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

int main(){
	int x,y;
	scanf("%d%d",&x,&y);
	
	int ret = 0;
	if(x <= 3)ret += (4-x)*100000;
	if(y <= 3)ret += (4-y)*100000;
	if(ret == 600000)ret += 400000;
	cout << ret << endl;
}

Measured memory_bytes: 256
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer

// 21:10~
object Main {

  case class Edge(u: Int, v: Int, w: Long)

  case class NextInfo(v: Int, w: Long)

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    // 0-index化
    val edges = IndexedSeq.fill(n - 1)(
      Edge(sc.nextInt() - 1, sc.nextInt() - 1, sc.nextLong()))
    (n, edges)
  }


  def solve(n: Int, edges: IndexedSeq[Edge]): IndexedSeq[Int] = {
    val nextList = IndexedSeq.fill(n)(ArrayBuffer.empty[NextInfo])
    for (edge <- edges) {
      nextList(edge.u).append(NextInfo(edge.v, edge.w))
      nextList(edge.v).append(NextInfo(edge.u, edge.w))
    }
    val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()

    open.add(0)
    val colorList = Array.fill(n)(-1)
    val visited = Array.fill(n)(false)

    // 頂点0を白(0)で塗る
    colorList(0) = 0
    visited(0) = true

    // @inline
    def calcColor(parentColor: Int, dist: Long): Int = {
      val parity = (dist % 2).toInt
      (parentColor + parity) % 2
    }

    while (!open.isEmpty) {
      val current = open.remove()
      for (next <- nextList(current)) {
        if (!visited(next.v)) {
          // 色をつける
          colorList(next.v) = calcColor(colorList(current), next.w)
          visited(next.v) = true
          open.add(next.v)
        }
      }
    }
    colorList.toIndexedSeq
  }

  def output(result: IndexedSeq[Int]) = {
    val out = new java.io.PrintWriter(System.out)
    result.foreach(out.println)
    out.flush()
  }

  def main(args: Array[String]): Unit = {
    val (n, edges) = read()
    val result = solve(n, edges)
    output(result)
    // result.foreach(println)
  }
}

Measured memory_bytes: 121860
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<iomanip>
#include<functional>
using namespace std;

int MOD = 1e9 + 7;

typedef long long ll;
typedef pair<int, int> P;

int main() {
	string s;
	int w;
	cin >> s >> w;
	for (int i = 0; i < s.size(); i += w) cout << s[i];
	cout << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<functional>
#include<algorithm>
#include<iostream>
#define MAX 1000
#define TS 13
#define rep(i,a) for(i=1;i<=a;i++)
using namespace std;
typedef pair<char,int> p;
int main(void)
{
	int n,i,j;
	p card[53];
	int s[TS+1],h[TS+1],c[TS+1],d[TS+1];
	rep(i,TS) {
		s[i]=MAX;
		h[i]=MAX;
		c[i]=MAX;
		d[i]=MAX;
	}
	cin>>n;
	rep(i,n) cin>>card[i].first>>card[i].second;
	rep(i,n) {
		if(card[i].first=='S') s[card[i].second]=card[i].second;
		else if(card[i].first=='H') h[card[i].second]=card[i].second;
		else if(card[i].first=='C') c[card[i].second]=card[i].second;
		else d[card[i].second]=card[i].second;
	}
	rep(i,TS) if(s[i]==MAX) cout<<"S "<<i<<endl;
	rep(i,TS) if(h[i]==MAX) cout<<"H "<<i<<endl;
    rep(i,TS) if(c[i]==MAX) cout<<"C "<<i<<endl;
	rep(i,TS) if(d[i]==MAX) cout<<"D "<<i<<endl;
	return 0;
}

Measured memory_bytes: 3076
import sys
s=int(input())
a=[0]*1000
for i in range(1000):
    if i==0:
        a[0]=s
    else:
        if a[i-1]%2==0:
            a[i]=a[i-1]/2
        else:
            a[i]=3*a[i-1]+1

for i in range(1000):
    for j in range(i+1,1000):
        if a[i]==a[j]:
            print(j+1)
            sys.exit(0)


        
        


Measured memory_bytes: 3064
//Never stop trying
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

typedef string str;
typedef long long ll;
#define int ll
typedef double db;
typedef long double ld;

typedef pair<int,int> pi;
#define fi first
#define se second

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pi> vpi;

#define pb push_back
#define eb emplace_back
#define pf push_front

#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define endl "\n"

const int MOD = 1e9+7; //998244353
const ll INF = 1e18;
const int nx[4]={0,0,1,-1}, ny[4]={1,-1,0,0}; //right left down up

void IO(){
#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin); 
    freopen("output.txt", "w", stdout); 
#endif 
}

const int MX=2e5+10;
int N;
int h[MX],a[MX];
vi st(4*MX,0);

int mx(int l, int r, int pos, int tl, int tr){
	if(r<l) return 0;
	if(l==tl && r==tr) return st[pos];
	int tm=(tl+tr)/2;
	return max(mx(l,min(r,tm),pos*2,tl,tm),mx(max(l,tm+1),r,pos*2+1,tm+1,tr));
}

void update(int i, int v, int pos, int l, int r){
	if(l>r) return;
	if(l==r){
		st[pos]=v;
		return;
	}
	int m=(l+r)/2;
	if(i<=m) update(i,v,pos*2,l,m);
	else update(i,v,pos*2+1,m+1,r);
	st[pos]=max(st[pos*2],st[pos*2+1]);
}

int32_t main(){
   boost;
   IO();

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

   int dp[N+1];
	for(int i=0; i<=N; i++) dp[i]=0;
	for(int i=0;i<N;i++){
		int x=mx(1,h[i]-1,1,1,N);
		dp[h[i]]=max(dp[h[i]],x+a[i]);
		update(h[i],dp[h[i]],1,1,N);
	}

	int ans=0;
	for(int i=1; i<=N; i++) ans=max(ans,dp[i]);
	cout << ans << endl;
	


   return 0;
}



Measured memory_bytes: 14284
#include<bits/stdc++.h>
#define ll  long long
#define pp pair<int,int>
#define ppn pair<pp,int>
#define F first
#define S second
#define N 200005
#define mod 1000000007
#define pi 3.14159265358979323846

using namespace std;

int fun(int x, int y, int z){
    return x*x+y*y+z*z+x*y+y*z+z*x;
}
int main()
{


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

    int n;
    cin>>n;
    map<int,int>m;
    for(int i=1; i<=100; i++){
     for(int j=1; j<=100; j++){
        for(int k=1; k<=100; k++){
               int x = i*i+j*j+k*k+i*j+j*k+k*i;

                m[x]++;
                //cout<<fun(i,j,k)<<endl;
        }
     }
    }

   for(int i=1; i<=n; i++)cout<<m[i]<<endl;
}


Measured memory_bytes: 5464
#include<iostream>
#include<deque>
#include<string>
#define loop(i,a,b) for(int i=a; i<int(b); i++)
#define rep(i,n) loop(i,0,n)

using namespace std;

int main(){
    deque<char> d;
    string s;
    int n; cin >> n;
    rep(i,n){
        cin >> s;
        int p = 0, max = 0, min = 0;
        d.clear();
        d.push_back(s[0]);
        rep(k, s.size())if (k){
            if (s[k] == '-') p++;
            else p--;
            k += 2;
            if (p>max){
                d.push_back(s[k]);
                max = p;
            }
            else if (p<min){
                d.push_front(s[k]);
                min = p;
            }
        }

        rep(i, d.size()){
            cout << d[i];
        }
        cout << endl;
    }
}

Measured memory_bytes: 1200
import java.util.Scanner;
 
public class Main {
    public static void main(String [] args){
        Scanner scan = new Scanner(System.in);
        int i = 1;
         
        while(true){
            int x = scan.nextInt();
             
            if(x == 0) break;
             
            System.out.println("Case " + i++ + ": " + x);
        }
    }
}
 

Measured memory_bytes: 44436
#include<iostream>
using namespace std;
int main(){
    int n,a;
    char suto;
    bool cards[4][13];
    for(int i=0;i<=3;i++){
        for(int k=0;k<=12;k++){
            cards[i][k]=false;
        }
    }
    cin  >>n;
    for(int i=0;i<=n;i++){
        cin >>suto >>a;
        if (suto=='S'){
            cards[0][a-1]=true;
        }
        else if(suto=='H'){
            cards[1][a-1]=true;
        }
        else if(suto=='C'){
            cards[2][a-1]=true;
        }
        else if(suto=='D'){
            cards[3][a-1]=true;
        }
    
    }
    for(int i=0;i<=3;i++){
        for(int k=0;k<=12;k++){
            if (cards[i][k]==false){
                if (i==0){
                    cout<<"S"<<" "<<k+1<<endl;
                }
                else if(i==1){
                    cout<<"H"<<" "<<k+1<<endl;
                }
                else if(i==2){
                   cout<<"C"<<" "<<k+1<<endl;
                }
                else if(i==3){
                    cout<<"D"<<" "<<k+1<<endl;
                }
            }
        }
    }
 
    
    return 0;
}




Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
 
// cout<<fixed<<setprecision(10);
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main() {
    int n; cin >> n;
    bool isOk = false;
    rep(i, n) {
        int t; cin >> t;
        if(t % 2 != 0) continue;
        if(t % 3 == 0 || t % 5 == 0) {
            continue;
        } else {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}



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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
    //ll a = x*(x-1);
    //ll b = 2;
    //return a/b;
}



int main(){
    ll n,m;
    cin >> n >> m;
    if((n>=2&&m>=2)||(n==1&&m==1)){
        cout << (n-2)*(m-2) << endl;
    }else{
        cout << max(n,m)-2 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define int long long
vector<char>v;
void setup() {
	v.push_back('a');
	v.push_back('b');
	v.push_back('c');
	v.push_back('d');
	v.push_back('e');
	v.push_back('f');
	v.push_back('g');
	v.push_back('h'); 
	v.push_back('i');
	v.push_back('j');
	v.push_back('k');
	v.push_back('l'); 
	v.push_back('m');
	v.push_back('n');
	v.push_back('o');
	v.push_back('p'); 
	v.push_back('q');
	v.push_back('r');
	v.push_back('s');
	v.push_back('t'); 
	v.push_back('u');
	v.push_back('v');
	v.push_back('w');
	v.push_back('x');
	v.push_back('y');
	v.push_back('z');
}
bool low(char c) {
	for (int i = 0; i < v.size(); i++)
		if (c == v[i])return 1;
	return 0;
}
string s;
bool solve() {
	if (s[0] != 'A') {
		return 0;
	}
	int C = 0;
	for (int i = 1; i < s.size(); i++) {
		if (low(s[i]));
		else if (s[i] == 'C') {
			if (C > 0) {
				return 0;
			}
			else C = i;
		}
		else {
			return 0;
		}
	}
	if (C > 1 && C != s.size() - 1)return 1;
	else {
		return 0;
	}
}
signed main() {
	setup();
	cin >> s;
	cout << (solve() ? "AC\n" : "WA\n");
	cin >> s;
}

Measured memory_bytes: 256
#include<stdio.h>


int main()
{
	int S, h, m, s;
	
	scanf("%d", &S);
	h = S / 3600;
	m = (S - h * 3600) / 60;
	s = S - (h * 3600) - (m * 60);
	printf("%d:%d:%d\n", h, m, s);
	
	return 0;
	
} 


Measured memory_bytes: 2756
#include<iostream>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define eps 1e-6
#define INF (1<<20)
#define PI acos(-1.0)
#define MAX 100005
#ifdef LOCAL
//#include<windows.h>
#endif // LOCAL
using namespace std;
int f(int a,int b)
{
    int t=a+b;
    int r=0;
    while(t)
    {
        t/=10;
        r++;
    }
    return r;
}
int main(int argc,char argv[])
{
    #ifdef LOCAL
    freopen("in.txt","r",stdin);
    //freopen("out.bat","w",stdout);
    #endif // LOCAL
    int a,b;
    while(scanf("%d%d",&a,&b)!=EOF)
    {
        printf("%d\n",f(a,b));
    }
    return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
using ll = long long;

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

    int D; cin >> D;
    vector<int> C(26); vector<vector<int>> S(D, vector<int>(26));
    REP(i, 0, 26) cin >> C[i];
    REP(i, 0, D) REP(j, 0, 26) cin >> S[i][j];


    vector<int> T(D);
    REP(i, 0, D) {
        int max_idx = 0;
        REP(j, 0, 26) {
            if (S[i][max_idx] < S[i][j]) max_idx = j;
        }
        T[i] = max_idx + 1;
    }

    vector<vector<int>> last(26, vector<int>(D, 0));
    vector<ll> ret(26, 0);
    REP(i, 0, D) {
        ret[T[i] - 1] += S[i][T[i] - 1];
        last[T[i] - 1][i] = i + 1;
        REP(j, 0, 26) {
            if (i > 0 && !last[j][i]) last[j][i] = last[j][i - 1];
            ret[j] -= C[j] * (i + 1 - last[j][i]);
        }
    }

	auto start = std::chrono::system_clock::now();
    const ll limit = 1950*1000;

    ll best = accumulate(ALL(ret), 0LL);
    mt19937_64 mt(random_device{}());
    uniform_int_distribution<int> day(0, D - 1);
    uniform_int_distribution<int> con(0, 25);
    while (1) {
        std::chrono::system_clock::time_point now = std::chrono::system_clock::now();
        double elapsed = std::chrono::duration_cast<std::chrono::microseconds>(now-start).count();
        if(elapsed > limit) break;

        int d = day(mt);
        int next = con(mt);
        int prev = T[d] - 1;
        T[d] = next + 1;
        last[prev].assign(D, 0);
        last[next].assign(D, 0);
        ret[prev] = 0;
        ret[next] = 0;
        REP(i, 0, D) {
            if (T[i] == prev + 1 || T[i] == next + 1) {
                ret[T[i] - 1] += S[i][T[i] - 1];
                last[T[i] - 1][i] = i + 1;
            }
            if (i > 0) {
                if (!last[prev][i]) last[prev][i] = last[prev][i - 1];
                if (!last[next][i]) last[next][i] = last[next][i - 1];
            }
            ret[prev] -= C[prev] * (i + 1 - last[prev][i]);
            ret[next] -= C[next] * (i + 1 - last[next][i]);
        }
        if (best >= accumulate(ALL(ret), 0LL)) {
            T[d] = prev + 1;
        } else {
            best = accumulate(ALL(ret), 0LL);
        }
        // cout << best << endl;
    }
    
    for (auto t : T) cout << t << endl;
    return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


struct Precision{
  Precision(){
    cout<<fixed<<setprecision(12);
  }
}precision_beet;

//INSERT ABOVE HERE
signed main(){
  int n;
  cin>>n;
  vector<int> h(n);
  for(int i=0;i<n;i++) cin>>h[i];

  const int MAX = 400;
  vector<double> dp(MAX,1e15);
  dp[1]=0;
  for(int i=0;i<n;i++){    
    vector<double> nx(MAX,1e15);
    for(int j=1;j<MAX;j++){
      for(int k=1;k<MAX;k++){
        double di=0;
        if(h[i]<=j&&h[i]<=k) di=(j-h[i])+(k-h[i]);
        else if(j<=h[i]&&k<=h[i]) di=(h[i]-j)+(h[i]-k);
        else{
          int a=h[i]-min(j,k),b=max(j,k)-h[i];
          assert(a>0&&b>0);
          di=double(a*a+b*b)/(a+b);
        }          
        chmin(nx[k],dp[j]+di/2.0);        
      }
    }    
    swap(dp,nx);
  }
  cout<<*min_element(dp.begin(),dp.end())<<endl;
  return 0;
}



Measured memory_bytes: 3284
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.InteropServices;
using System.Text;

namespace AC
{
    class Program
    {
        static void Main(string[] args)
        {
            var x = ReadArrayInt();
            var ans = 0;
            for (int i = 0; i < 5; i++)
            {
                if (x[i] == 0)
                {
                    ans = i + 1;
                    break;
                }
            }

            Console.WriteLine(ans);
            Console.ReadLine();
        }

        static string Read() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Read()); }
        static long ReadLong() { return long.Parse(Read()); }
        static string[] ReadArrayString() { return Read().Split(' '); }
        static int[] ReadArrayInt() { return Read().Split(' ').Select(s => int.Parse(s)).ToArray(); }
        static long[] ReadArrayLong() { return Read().Split(' ').Select(s => long.Parse(s)).ToArray(); }
    }
}

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

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

const long long MOD = 1000000007;

int main(){
  double r;
  cin >> r;
  cout << fixed << setprecision(6);
  cout << 2*r*3.141592 << endl;
}


Measured memory_bytes: 3772
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;


namespace Test1 {

    


    class ClassMain {


        public static void Main(String[] args) {
            string line;
            while ((line = Console.ReadLine()) != null) {
                int[] ints = line.Split(' ').Select(int.Parse).ToArray();
                int sum1 = ints[0] + ints[1] + ints[2] + ints[3];
                ints = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                int sum2 = ints[0] + ints[1] + ints[2] + ints[3];
                Console.WriteLine(Math.Max(sum1, sum2));
                break;
            }
        }

        
    }



    
}

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

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

int main(){
    int N;
    cin >> N;
    vector<long long> A(N);
    for(int i=0;i<N;i++) cin >> A[i];
  
    for(int i=0;i<N-1;i++){
        A[i+1]=gcd(A[i],A[i+1]);
    }
    cout<<A[N-1]<<endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define P pair<ll,ll>
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
#define FORR(I,A,B) for(ll I = (B-1); I >= (A); --I)
const ll INF=1e18+7;
const ll MOD=1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	ll N,W;
	cin>>N>>W;
	vector<ll> v(N),w(N);
	FOR(i,0,N)cin>>v[i]>>w[i];
	ll dp[N+1][100*N+1];
	FOR(i,0,N+1)FOR(j,0,100*N+1)dp[i][j]=INF;
	FOR(i,0,N+1)dp[i][0]=0;
	FOR(i,1,N+1){
		FOR(j,0,100*N+1){
			dp[i][j] = min(dp[i][j],dp[i-1][j]);
			if(j+v[i-1]<=(100*N+1))dp[i][j+v[i-1]] = min(dp[i-1][j+v[i-1]],dp[i-1][j]+w[i-1]);
		}
	}
	FORR(i,0,100*N+1){
		if(dp[N][i]<=W){
			cout << i << endl;
			return 0;
		}
	}
}


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

int main(){
    double pai=3.141592653589;
    int dice[6],tmp;
    char c[100];
    for(int i=0;i<6;i++){
        scanf("%d",&dice[i]);
    }
    scanf("%s",&c);
    for(int i=0;c[i];i++){
        if(c[i]=='S'){
            tmp=dice[4];
            dice[4]=dice[5];
            dice[5]=dice[1];
            dice[1]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='N'){
            tmp=dice[1];
            dice[1]=dice[5];
            dice[5]=dice[4];
            dice[4]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='W'){
            tmp=dice[2];
            dice[2]=dice[5];
            dice[5]=dice[3];
            dice[3]=dice[0];
            dice[0]=tmp;
        }else if(c[i]=='E'){
            tmp=dice[3];
            dice[3]=dice[5];
            dice[5]=dice[2];
            dice[2]=dice[0];
            dice[0]=tmp;
        }
    }
    printf("%d\n",dice[0]);
    return 0;
}

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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = numeric_limits<int>::max();
constexpr ll L_INF = numeric_limits<ll>::max();

//==================================

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

    int N;
    cin >> N;
    Vl A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    ll ans = 0;
    for (int i = 0; i < N; i++) {
        ll Ai = A[i];
        ll cnt = 0;
        while ((Ai & 1) == 0) {
            ++cnt;
            Ai /= 2;
        }
        ans += cnt;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
//#define sd(t) scanf("%d",&t)
//#define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N   200005
#define MAX 300005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
//#define endl "\n"
#define inf 1e+15

signed main(){
  fast;
 
  int a;
  cin >> a;
  cout << 3ll*a*a << endl;
}
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define Y cout << "Yes\n"
#define N cout << "No\n"
#define REP(i, a, b) for (int i = a; i <= b; i++)
#define R(i, n) for (int i = 0; i < n; i++)
#define RE(i, a, b) for (int i = a; i >= b; i--)


long long mo = 1000000007 ;
int p(long long a , long long b , ll mod)
{
     int ans = 1 ;
    while(b)
    {
        if(b%2)
        {
            ans = ( (ans%mod)*(a%mod) ) %mod ;
        }
        a = ((a%mod)*(a%mod))%mod ;
        b /= 2 ;
    }
    return ans ;
}

int main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     string s ;
     cin >> s ;
     int cnt = 0 , max = 0 ;
     if(s[0] == 'R')
     {
          cnt++ ;
     }
     for(int i = 1 ; i < 3 ; i++ )
     {
          if(s[i] == s[i-1] && s[i] == 'R')
          {
               cnt++ ;
          }
          else if(s[i] == 'S')
          {
               if(max < cnt)
               {
                    max = cnt ;
                    cnt = 0 ;
               }
          }
          else if(s[i] == 'R')
          {
               cnt++ ;
          }
     }
     if(max < cnt)
     {
          max = cnt ;
          cnt = 0 ;
     }
     cout <<max << endl ;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N=2e9+7;

int main()
{   
    ios_base::sync_with_stdio(0);
    cin.tie(0); 
   long double a,b,ans;
    cin>>a>>b;
    ans=a*b;
    //ans=ans*100;
   // int y = (int)(ans + 0.5);
  //  cout<<ans<<'\n';
    ll x=ans;
    cout<<x<<endl; 
    
       
    
    return 0;
}
    

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

using namespace std;

#define ALL(x) (x).begin(), (x).end()
#define AND(x,y,z) set_intersection((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define CONCAT(x,y) (x).insert((x).end(),(y).begin(),(y).end())
#define DUMP(xs) for (auto x:xs) cout<<x<<' ';cout<<endl
#define FOR(i,a,b) for (int i=(int)(a);i<(int)(b);++i)
#define OR(x,y,z) set_union((x).begin(),(x).end(),(y).begin(),(y).end(),inserter((z),(z).end()))
#define OUT(x) cout<<x<<endl
#define REP(i,n) FOR(i,0,n)

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<int> VECINT;
typedef vector<ll> VECLL;

int main() {
  int N;cin>>N;
  // さらに、次のxとyの和は前のxとyの和からtの差分だけ変更可能
  int prev_t=0,prev_x=0,prev_y=0;
  REP(i,N) {
    int t,x,y;cin>>t>>x>>y;
    // 次のtが奇数なら、xとyの和も奇数
    if ((t-(x+y))%2!=0) {
      OUT("No");
      return 0;
    }
    // 前の座標からの移動はtの差分県内か
    if (abs(x-prev_x)+abs(y-prev_y)>t-prev_t) {
      OUT("No");
      return 0;
    }

    // 最後に入れ替え
    prev_t=t,prev_x=x,prev_y=y;
  }
  OUT("Yes");

  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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


    int N;
    cin >> N;

    vector<bool> prime(55556);
    vector<int> primes;

    rep(i, 0, 55555) {
        prime[i] = true;
    }
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i <= 55555; i++) {
        if (prime[i]) {
            for (int j = i * 2; j <= 55555; j += i) {
                prime[j] = false;
            }
        }
    }
    rep(i, 0, prime.size()) {
//        if (prime[i]) primes.push_back(i);
        if(prime[i] && N > 0){
            if( i % 5 == 1){
                primes.push_back(i);
                N--;
            }
        }
    }

    rep(i,0,primes.size()){
        cout << primes[i] << " ";
    }
    cout << endl;


    return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

typedef int _loop_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)

#define VIN(v) for(auto&elem_: (v) )cin>>elem_
#define VOUT(v, sep) for(_loop_int idx=0; idx<(_loop_int)v.size(); idx++) {cout<<v[idx]; if(idx<v.size()-1) cout<<sep;} cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(debugidx,v.size())cout<<" "<<v[debugidx];cout<<endl
#define DEBUG_ARR(v,n) cout<<#v<<":";REP(debugidx,n)cout<<" "<<v[debugidx];cout<<endl

const ll MOD = 1000000007ll;
const int IINF = numeric_limits<int>::max()/2-1;
const ll LINF = numeric_limits<ll>::max()/2-1;

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


int n,k;
int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    cin>>n>>k;
    
    int ans=0;
    REP(i,n){
        int x;
        cin>>x;

        ans += min(x*2, abs(k-x)*2);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
a = input()
b = int(len(a))
c = []

for i in range(b):
    c.append(int(0))

d = str()

if a[b-1] == "L":
    d = "R"
else:
    d = "L"

a = a+d

temp = int(1)

for i in range(b):
    if a[i] == a[i+1]:
        c[i] += 0
        temp += 1
    elif a[i] != a[i+1] and a[i] == "R":
        c[i+1] += temp // 2
        c[i] += (temp - temp // 2)
        temp = 1
    else:
        c[i-temp] += temp // 2
        c[i-temp+1] += (temp - temp // 2)
        temp = 1
f = [str(s) for s in c]
e = " ".join(f)
print(e)

Measured memory_bytes: 17260
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define dofloat cout<<fixed<<setprecision(8)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define bitcount __builtin_popcount
#define all(vec) vec.begin(),vec.end()
#define rall(vec) vec.rbegin(),vec.rend()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<long long> vl;
typedef pair<long long,long long> pll;
typedef vector<pair<long long,long long> > vll;
typedef vector<pair<int,int> > vii;
typedef vector<int> vi;
typedef pair<int,int> ii;
const long long MOD=1000000007;
const long long MAX=100005;
const long double PI=3.14159265359;
const long double G=9.807;
const long long INF=1e18;
const long double EPS=1e-6;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
bool isprime(ll a){
  if(a==2)return 1;
  if(!(a&1))return 0;
  for(ll i=3;i*i<=a;i+=2)
    if(a%i==0)return 0;
  return 1;
}
ll mpow(ll base,ll exponent,ll modulus){
  if(modulus==1)return 0;
  long long result = 1;
  base=base%modulus;
  while(exponent){
    if(exponent%2 == 1)
    result=(result*base)%modulus;
    exponent=exponent>>1;
    base=(base*base)%modulus;
  }
  return result;
}
ll minv(ll a,ll mod){
  ll _gcd=gcd(a,mod);
  assert(_gcd==1);
  return mpow(a,mod-2,mod);
}


/*
ll ncr(ll N,ll K){
  if(N<K)return 0;
  if(K==0)return 1;
  if(N==0)return 0;

  ll den=1;
  for(ll i=1;i<=K;i++)den*=i;
  ll num=1;
  while(K--){
    num*=N;
    if(num%den==0){
      num/=den;
      den=1;
    }
    N--;
  }

  return num;
}
*/
ll n,x,t;
int main(){FAST;
cin>>n>>x>>t;
cout<<(n+x-1)/x*t;
return 0;
}

/*
 WA? check edge cases, N=1,M=1 etc. Read code fully once and check all variables.
 Read the question again and see what you might have missed.
 Consider changing your solution or find more cases.
 */


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll ,ll> P;
struct Edge{ll from, to, cost;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

vector<P> v[100100];
vector<ll> cost;
/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, M;
  cin >> N >> M;
  cost = llvec(N, 1e16);
  //fill(ALL(cost), 1e16);
  rep(i,N-2){
    v[i+1].push_back({i, 0});
  }
  rep(i, M){
    ll l, r, c;
    cin >> l >> r >> c;
    l--;r--;
    v[l].push_back({r,c});
  }

  cost[0]=0;
  priority_queue<P, vector<P>, greater<P>> que;
  que.push({0, 0});
  while(!que.empty()){
    P p =que.top();
    ll from = p.second;
    que.pop();
    if(p.first>cost[from])continue;
    for(auto iedge:v[from]){
      ll to = iedge.first;
      ll c = iedge.second;
      if(cost[to]>cost[from]+c){
        cost[to]=cost[from]+c;
        que.push({cost[to], to});
      }
    }
  }
  
  cout << (cost[N-1]==1e16?-1:cost[N-1]);
  
  return 0;
}


Measured memory_bytes: 10104
import java.util.Scanner;

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

    int a = sin.nextInt();
    int b = sin.nextInt();
    int c = sin.nextInt();
    int count = 0;

    for( int i = a; i <= b; i++) {
      if( (c % i) == 0) count++;
    }

    System.out.println(count);

    sin.close();
  }
}


Measured memory_bytes: 26352
# -*- coding: utf-8 -*-

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

# solve
ans = 0
prev = 0
for i in range(N):
    now = A[i] - 1
    ans += B[now]
    if i != 0 and prev == now - 1:
        ans += C[prev]
    prev = now

# output
print(ans)


Measured memory_bytes: 3060
import sys
def t(A,p,r):
 x=A[r][1];i=p-1
 for j in range(p,r):
  if A[j][1]<=x:i+=1;A[i],A[j]=A[j],A[i]
 A[i+1],A[r]=A[r],A[i+1]
 return i+1
def k(A,p,r):
 if p<r:q=t(A,p,r);k(A,p,q-1);k(A,q+1,r)
def m(L,R):
 T=[]
 for l in L[::-1]:
  while R and R[-1][1]>=l[1]:T+=[R.pop()]
  T+=[l]
 return R+T[::-1]
def d(A):l=len(A);s=l//2;return m(d(A[:s]),d(A[s:]))if l>1 else A
n=int(input())
f=lambda x,y:(x,int(y))
A=[f(*e.split())for e in sys.stdin]
B=A[:]
k(A,0,n-1)
print(['Not s','S'][A==d(B)]+'table')
for e in A:print(*e)


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

int rec(int a, int b, int c){
	if(!a&&!b) return 0;
	int ans = 0;
	if(c&1) ans = rec(a>>1, b>>1, c>>1);
	else if(b&1) ans = rec(c>>1, b>>1, a>>1) + rec((a|b|c)>>1, 0, 0) + 1;
	else if(a&1) ans = rec(a>>1, b>>1, c>>1) + 2*rec((a|b|c)>>1, 0, 0) + 2;
	return ans;
}

int main(){
	int n, m;
	while(cin >> n >> m, n+m){
		int tray[3] = {0};
		rep(ti, 3){
			int ts; cin >> ts;
			rep(i, ts) {
				int num; cin >> num;
				tray[ti] |= 1 << num-1;
			}
		}
		int ans = min(rec(tray[0], tray[1], tray[2]), rec(tray[2], tray[1], tray[0]));
		cout << (ans <= m ? ans : -1) << endl;
	}

	return 0;
}


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

#define ll long long
#define ar array

bool ok(string s) {
	int n = s.size();
	for (int i = 0; i < n / 2; i++) {
		if (s[i] != s[n - i - 1]) {
			return 0;
		}
	}
	return 1;
}

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

	string s;
	cin >> s;
	int n = s.size();
	bool ok1, ok2, ok3;
	ok1 = ok(s);
	ok2 = ok(s.substr(0, (n - 1) / 2));
	ok3 = ok(s.substr((n + 3) / 2 - 1));

	if (ok1 && ok2 && ok3) {
		cout << "Yes\n";
	} else {
		cout << "No\n";
	}
	// cout << s.substr(0, (n - 1) / 2) << "\n";
	// cout << s.substr((n + 3) / 2 - 1) << "\n";
}

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

void solve(long long N, std::vector<std::string> s, std::vector<long long> t, std::string X) {
    long long ans = 0;
    bool sleeping = false;
    for (long long i = 0; i < N; i++) {
        if (sleeping) {
            ans += t[i];
        }
        if (s[i] == X) {
            sleeping = true;
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main() {
    long long N;
    scanf("%lld", &N);
    std::vector<std::string> s(N);
    std::vector<long long> t(N);
    for (int i = 0; i < N; i++) {
        std::cin >> s[i];
        scanf("%lld", &t[i]);
    }
    std::string X;
    std::cin >> X;
    solve(N, std::move(s), std::move(t), X);
    return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())
# memo[N+1]はあとで除外する。
memo = [0]*(N+1)

for _ in range(M):
    L, R = map(int, input().split())
    memo[L-1] += 1
    memo[R] -= 1

memo_sum = memo[0]
for i in range(1, N):
    memo_sum += memo[i]
    memo[i] = memo_sum

ans = 0
for a in memo:
    if a == M:
        ans += 1

print(ans)


Measured memory_bytes: 6900