akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
const int N = 1e5;  // limit for array size
ll n;  // array size

int main(){
   ll a,b,c,k;cin>>a>>b>>c>>k;
   
   ll ans=0;
   
   ans+=min(k,a);
   k-=min(k,a);
   
   k-=b;
   
   if(k>0){
      	ans-=min(k,c);
   }
   
   cout<<ans<<endl;
   
	return 0;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
 
using ll = long long;
using namespace std;


void solveCase() {
   int n, a, b;
   cin >> n >> a >> b;
   if(a > b) {
      cout << 0 << endl;
      return;
   }
   if(n == 1) {
      cout << 1 * (a == b) << endl;
      return;
   }

   ll ans = (n - 2) * 1LL * (b - a) + 1;
   cout << ans << endl;
}

int main() {
   cin.tie(0);
   cin.sync_with_stdio(0);
   
   int testcase = 1;
   // cin >> testcase;
 
   for(int i = 0; i < testcase; i++) {
      solveCase();
   }
 
   return 0;
}

Measured memory_bytes: 3588
import java.util.*;
public class Main{
        public static void main(String[] args){
                Scanner sc = new Scanner(System.in);
                long n = sc.nextLong();
                long k = sc.nextLong();
                sc.close();
                if(n == 1 && k == 1){
                        System.out.println(1);
                }else{
                        System.out.println((long)(k * Math.pow(k - 1 , n - 1)));
                }
        }
}

Measured memory_bytes: 35692
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        String[] s = new String[n];
        for (int i = 0; i < n; i++)
        {
            s[i] = Console.ReadLine();
        }

        Array.Sort(s);

        List<String> ansS = new List<String>();
        var max = 0;
        var disS = s.Distinct();
        var count = 0;

        foreach (var item in disS)
        {
            var tmp = 0;
            for (int i = count; i < s.Length; i++)
            {
                if (s[i].Equals(item))
                {
                    tmp++;
                }
                else
                {
                    count = i;
                    break;
                }
            }

            if (tmp > max)
            {
                max = tmp;
                ansS = new List<String>();
                ansS.Add(item);
            }
            else if (tmp == max)
            {
                ansS.Add(item);
            }

        }

        foreach (var item in ansS)
        {
            Console.WriteLine(item);
        }
    }
}

Measured memory_bytes: 49416
N = int(input())
*a, = map(int, input().split())
a.sort()
ok = True
t = 1
if N % 2 == 1:
    if a.pop(0) != 0:
        ok = False
    t = 2

if ok:
    for i in range(0, len(a), 2):
        if t != a[i] or t != a[i+1]:
            ok = False
            break
        t += 2

if ok:
    print((2**((N-N % 2)//2)) % (10**9+7))
else:
    print(0)


Measured memory_bytes: 55148
N, W = map(int, input().split())
K = [[0, 0] for _ in range(N)]
V = 0
for i in range(N):
    w, v = map(int, input().split())
    K[i] = [w, v]
    V += v
dp = [[float('inf')]*(V+1) for _ in range(N+1)]
dp[0][0] = 0
for i in range(N):
    w, v = K[i]
    for sum_v in range(V+1):
        if sum_v-v>=0:
            dp[i+1][sum_v] = min(dp[i][sum_v], dp[i][sum_v-v]+w)
        else:
            dp[i+1][sum_v] = dp[i][sum_v]
ans = 0
for i, d in enumerate(dp[-1]):
    if d<=W: ans = i
print(ans)

Measured memory_bytes: 307960
#include<cstdio>
#include<cstring>
#include<cctype>
#include<algorithm>
#include<vector>
#define pb push_back
#define mp make_pair
#define xx first
#define yy second
#define rep(i,a,b) for(int i=(a),i##_end_=(b);i<=i##_end_;i++)
#define dwn(i,a,b) for(int i=(a),i##_end_=(b);i>=i##_end_;i--)
using namespace std;
inline int read() {
    int x=0,f=1;char c=getchar();
    for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
    for(;isdigit(c);c=getchar()) x=x*10+c-'0';
    return x*f;
}
typedef long long ll;
typedef pair<int,int> pii;
int A[200010],n;
int main() {
	n=read();
	rep(i,1,n) A[i]=read();
	sort(A+1,A+n+1);
	int ok=1;
	rep(i,2,n) if(A[i]==A[i-1]) ok=0;
	puts(ok?"YES":"NO");
	return 0;
}


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

int main() {
    ll a, b, c; cin >> a >> b >> c;
    if (a == b && b != c ||
        b == c && c != a ||
        a == c && c != b
    ) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=sorted(list(map(int,input().split())))
if n>=m:
    print(0)
else:
    x_interval=[]
    for i in range(0,m-1):
        x_interval.append(-(x[i]-x[i+1]))
    x_interval=sorted(x_interval,reverse=True)
    print(x[m-1]-x[0]-sum(x_interval[:(n-1)]))

Measured memory_bytes: 13968
#include <cstdio>
#include <vector>
using namespace std;
#define MAX 100000

vector<int> G[MAX];
int color[MAX];
int c = 0;

void dfs(int v) {
    color[v] = c;
    for (int i = 0; i < G[v].size(); i++) {
        if (color[G[v][i]] == 0) dfs(G[v][i]);
    }
}

int main(void) {
    int n, m, s, t, q, i;
    scanf("%d %d", &n, &m);

    for (i = 0; i < m; i++) {
        scanf("%d %d", &s, &t);
        G[s].push_back(t);
        G[t].push_back(s);
    }

    for (i = 0; i < n; i++) color[i] = 0;

    for (i = 0; i < n; i++) {
        if (color[i] == 0) {
            c++;
            dfs(i);
        }
    }

    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        scanf("%d %d", &s, &t);
        if (color[s] > 0 && color[s] == color[t]) printf("yes\n");
        else printf("no\n");
    }

    return 0;
}

Measured memory_bytes: 10012
import numpy as np
#from numba import njit

def getVar():
    return map(int, input().split())
def getArray():
    return list(map(int, input().split()))
def getNumpy():
    return np.array(list(map(int, input().split())), dtype='int64')

def main():
    N = getVar()
    A = getArray()

    m = 1
    upper = 1000000000000000000

    if 0 in A:
        print(0)
        return
        
    for a in A:
        m *= a
        if m > upper:
            print(-1)
            return

    print(m)

main()

Measured memory_bytes: 39836
#include <stdio.h>
#include <inttypes.h>

int64_t zettaiti(int64_t asumikana) {
	return asumikana < 0 ? -asumikana : asumikana;
}

int main(void) {
	int N;
	int64_t T, A;
	int64_t H[1024];
	int i;
	int bestIndex;
	int64_t bestDiff;
	if (scanf("%d", &N) != 1) return 1;
	if (scanf("%" SCNd64 "%" SCNd64, &T, &A) != 2) return 1;
	T *= 1000;
	A *= 1000;
	for (i = 0; i < N; i++) {
		if (scanf("%" SCNd64, &H[i]) != 1) return 1;
	}
	bestIndex = 0;
	bestDiff = zettaiti(A - (T - H[0] * 6));
	for (i = 1; i < N; i++) {
		int64_t score = zettaiti(A - (T - H[i] * 6));
		if (score < bestDiff) {
			bestIndex = i;
			bestDiff = score;
		}
	}
	printf("%d\n", bestIndex + 1);
	return 0;
}


Measured memory_bytes: 128
import bisect
import collections
import itertools


def getint(): return int(input())
def getints(): return list(map(int, input().split()))
def getint2d(rows): return [getints() for _ in range(rows)]
def getgrid(rows): return [input() for _ in range(rows)]
def array1d(n, value): return [value for _ in range(n)]
def array2d(n, m, value): return [array1d(m, value) for _ in range(n)]

n=getint()

res = 0
for i in range(1,n+1):
    res += len(str(i)) % 2

print(res)


Measured memory_bytes: 40172
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define x first
#define LL long long
#define ULL unsigned long long 
#define y second
#define sqr(x) ((x)*(x))
#define pii pair<int,int>
#define pll pair<LL,LL>
#define pdd pair<double,double>
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
#define MEMS(x) memset(x,-1,sizeof(x))
using namespace std;
int C(int a,int b){
    int cnt=0;
    int tmp=a;
    while(tmp){
        cnt+=tmp/2;
        tmp/=2;
    }
    //printf("%d ",cnt);
    tmp=b;
    while(tmp){
        cnt-=tmp/2;
        tmp/=2;
    }
    //printf("%d ",cnt);
    tmp=a-b;
    while(tmp){
        cnt-=tmp/2;
        tmp/=2;
    }
    //printf("%d")
    return cnt;
}
int main(){ 
    int n;
    scanf("%d",&n);
    srand(time(NULL));
    for(int t = 0;t<1;t++){
        int a[1000005];
        int havetwo=0;
        for(int i = 0;i<n;i++){
            char c=rand()%3+'1';
            //printf("%c",c);
            scanf(" %c",&c);
            a[i]=c-'1';
            if(a[i]==1)havetwo=1;
        }
        //printf("\n");
    
        int tot=0;
        for(int i = 0;i<n;i++){
            if(C(n-1,i)==0){
              //  printf("%d %d\n",i,C(n-1,i));
                if(havetwo){
                    if(a[i]==1)tot++;
                }
                else{
                    if(a[i]==2)tot++;
                }
            }
        }
        int ans;
        if(tot%2==0)ans=0;
        else{
            if(havetwo)ans=1;
            else ans=2;
        }
        /*for(int i = 0;i<n-1;i++){
           // for(int j=0;j<n;j++)
           // printf("%d",a[j]);
            for(int j=0;j<n-i;j++){
                a[j]=abs(a[j]-a[j+1]);
            }
           // printf("\n");
        }*/
        printf("%d\n",ans);
      //  printf("%d %d\n",ans,a[0]);
      //  assert(a[0]==ans);
    }
}
/*

5
AACCMMAA
A
AA
MM
ACA
ACMAA


5
0 9 7 1 100
-1 0 -1 -1 91
-1 5 0 -1 96
-1 8 9 0 99
-1 -1 -1 -1 0
3 4
3 5
5 6
5 7
3 or 4
3 or 5
5 or 6
5 or 7

dp[x]=max(dp[x-w_i*j]+j*t_i-delta t_i*j*(j-1)/2)
dp[x]=max(dp[j]+x*t_i-j*t_i-delta t_i*(x-j)*(x-j-1)/2)
dp[x]=max(dp[j]-j*t_i-delta t_i *(j^2/2+j/2) - 
        delta t_i * xj + x*t_i + delta t_i * (x^2/2-x/2))
dp[x]=max(dp[j] + g(j) - delta t_i *xj + w(i) )
g(j)= dp[j]-j*t_i-delta t_i *(j^2/2+j/2)
w(i)=  x*t_i + delta t_i * (x^2/2-x/2)
x^2/2 -xj -x/2  +j^2/2 +j/2
*/

/*
 

*/

Measured memory_bytes: 4096
#include<stdio.h>

int main(){
  int N, M, i, j , k , l, flag;
  char A[50][51], B[50][51];
  
  scanf("%d %d", &N, &M);
  for (i = 0; i < N; i++){
    scanf("%s", A[i]);
  }
  for (i = 0; i < M; i++){
    scanf("%s", B[i]);
  }
  
  for (i = 0; i <= N - M; i++){
    for (j = 0; j <= N - M; j++){
      flag = 1;
      for (k = i; k < i + M; k++){
        for (l = j; l < j + M; l++){
          if(A[k][l] != B[k - i][l - j]){
            printf("\n");
            flag = 0;
            break;
          }
        }
        if(flag == 0){
          break;
        }
      }
      if(k == i + M && l == j + M){
        break;
      }
    }
    if(k == i + M && l == j + M){
      break;
    }
  }
  
  if(k == i + M && l == j + M){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}
  

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define rep(i, l, r) for(int i = (l), i##end = (r);i <= i##end;++i)
using std::cin; using std::cout;
const int maxn = 200200;
typedef long long ll;
const int mod = 998244353;
inline ll pow(ll a,int b,int ans = 1) {
	for(;b;b >>= 1,a = a * a % mod) if(b & 1)
		ans = ans * a % mod;
	return ans;
}
inline ll inverse(int x){ return pow(x, mod - 2); }
int a[maxn], b[maxn], c[maxn], d[maxn];
std::unordered_map<ll, int> map;
int n;
inline ll pr(int a,int b,int c,int d) { return (ll) (a << 16 | b) << 32 | (c << 16 | d); }
inline ll minpr(int a,int b,int c,int d) {
	return std::min(std::min(pr(a, b, c, d), pr(b, c, d, a)), std::min(pr(c, d, a, b), pr(d, a, b, c)));
}
inline void swap(int & a,int & b,int & c,int & d) { int t = a; a = b, b = c, c = d, d = t; }
inline void add(int a,int b,int c,int d,int v) { map[minpr(a, b, c, d)] += v; }
inline ll C(int x,int v) {
	if(v == 1) return x;
	if(v == 2) return x * (x - 1);
	if(v == 3) return x * (x - 1) * (x - 2);
	return (ll) x * (x - 1) * (x - 2) * (x - 3);
}
int main() {
	std::ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	map.rehash(1e6 + 7);
	cin >> n;
	rep(i, 1, n) {
		cin >> a[i] >> b[i] >> c[i] >> d[i];
		add(a[i], b[i], c[i], d[i], 1);
	}
	ll ans = 0;
	rep(i, 1, n) rep(j, 1, i - 1) {
		add(a[i], b[i], c[i], d[i], -1);
		add(a[j], b[j], c[j], d[j], -1);
		for(int t = 0;t < 4;++t) {
			std::map<ll, int> mp;
			++ mp[minpr(b[j], a[j], b[i], a[i])];
			++ mp[minpr(a[j], d[j], c[i], b[i])];
			++ mp[minpr(d[j], c[j], d[i], c[i])];
			++ mp[minpr(c[j], b[j], a[i], d[i])];
			ll mul = 1;
			for(auto i : mp) {
				if(i.first >> 16 == i.first << 16 >> 16) mul <<= i.second;
				if(i.first >> 32 == i.first << 32 >> 32) mul <<= i.second;
				mul *= C(map[i.first], i.second);
			}
			ans += mul;
			swap(a[i], b[i], c[i], d[i]);
		}
		add(a[i], b[i], c[i], d[i], 1);
		add(a[j], b[j], c[j], d[j], 1);
	}
	cout << ans / 3 << '\n';
}


Measured memory_bytes: 58368
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;
typedef long double llf;
typedef pair<int, int> pi;
const int MAXN = 500005;
const int mod = 1e9 + 7;
#define sz(v) ((int)v.size())

int n, a[MAXN];

int main(){
	scanf("%d",&n);
	for(int i=0; i<n; i++) scanf("%d",&a[i]);
	sort(a, a + n);
	pi dap(-2e9, -1);
	for(int i=0; i<n-1; i++){
		int cst = min(a[n-1] - a[i], a[i]);
		dap = max(dap, pi(cst, i));
	}
	cout << a[n-1] << " " << a[dap.second] << endl;
}


Measured memory_bytes: 640
import { readFileSync } from "fs";

const read = () =>
  readFileSync(0, "utf8")
    .split("\n")
    .map((line) => line.split(" "));

const main = (input: string[][]) => {
  const [A, B, C, D] = input[0].map(Number);

  if (C > B || A > D) {
    return 0;
  }

  return Math.min(B, D) - Math.max(A, C);
};

console.log(main(read()));


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

/// Constant:
#define         eps         10e-9
#define         pi          2*acos(0)
#define         P1          1e9+7
#define         P2          1e9+9

#define         lli         long long int
#define         PB          push_back
#define         pb          pop_back
#define         mk          make_pair
#define         I           insert
/// Loop:
#define         f1(a,b)     for (int i=a; i<=b; i++)
#define         f2(a,b)     for (int j=a; j<=b; j++)
#define         f-1(a,b)     for (int i=b; i>=a; i--)
#define         f-2(a,b)     for (int j=b; j>=a; j--)
///Print:
#define         pY          cout<<"YES"<<endl;
#define         pN          cout<<"NO"<<endl;
#define         py          cout<<"Yes"<<endl;
#define         pn          cout<<"No"<<endl;

using namespace std;
///ISNNJB

/// Functions:
//lli bigmod(lli b, lli p, lli m){if(p==0)return 1;if(p%2!=0) return b%m*fun(b,p-1,m)%m;if(p%2==0){ lli res=fun(b,p/2,m);return (res%m*res%m)%m;}}
//lli mod_inverse(lli a, lli mod) { return bigmod(a,mod-2,mod); }
//lli LCM(lli a, lli b){ return a*b/ __gcd(a,b);}

///Global Variable:
int ara[400005],brr[400004];

/**int fx[]={+1,-1,+0,+0};
int fy[]={+0,+0,+1,-1};
int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};*/

int main() {

    /**freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/

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

    lli a,b,c,d,k,t,n,m,x,y,q,ctn=0,l1,l2,total=0;
    //string s,p,q;
    string s;
    string p[7]={ "AC", "WA", "TLE", "RE"};

    cin>>n;
    f1(1,n) {
        //int ac=0,tle=0,wa=0,re=0;
        s.clear();
        cin>>s;
        if(s[0]=='A')
            ara[0]++;
        else if(s[0]=='W')
            ara[1]++;
        else if(s[0]=='T')
            ara[2]++;
        else if(s[0]=='R')
            ara[3]++;
    }

    f1(0,3) {
    cout<<p[i]<<" x "<<ara[i]<<endl;
    }
    return 0;
}


Measured memory_bytes: 3660
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

long long gcd(long long a, long long b){
  return b == 0LL ? a : gcd(b, a % b);
}

int main(){
	ll n;
	cin>>n;
	ll a;
	cin>>a;
	rep(i,0,n-1){
		ll b;
		cin>>b;
		a = gcd(a,b);
	}
	cout << a << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    int a, b, k; cin >> a >> b >> k;
    if (b-a+1<2*k){
        repp(i,b+1,a) cout << i << endl;
        return 0;
    }
    rep(i,k) cout << a + i << endl;
    rep(i,k) cout << b-k+i+1 << endl;
}

Measured memory_bytes: 3612
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Mmax = 1e5;
int N, M;
int L[Mmax], R[Mmax];

int main(){
    cin >> N >> M;
    for(int i=0; i<M; i++){
        cin >> L[i] >> R[i];
    }

    int lmax=L[0], rmin=R[0];
    for(int i=0; i<M; i++){
        lmax = max(lmax, L[i]);
        rmin = min(rmin, R[i]);
    }
    cout << max(0, rmin-lmax+1) << endl;
    return 0;
}


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

int main(){
  long long n; cin >> n;
  long long a[n]={};
  
  for(long long i=0; i<n; i++){cin >> a[i];}
  sort(a,a+n);
  
  long long b[n] = {};
  b[0] = a[0];
  for(int i=1; i<n; i++) b[i] = b[i-1] + a[i];
  
  long long ans;
  
  if(n%2 == 0){
    ans = 2 * b[n-1] - 4 * b[n/2-1] - a[n/2] + a[n/2-1];
  }else{
    ans = 2 * b[n-1] - 4 * b[n/2] + a[n/2] + a[n/2-1];
    ans = max(ans, 2 * b[n-1] - 4 * b[n/2-1] - a[n/2] - a[n/2+1]);
  }
  
  cout << ans << endl; 
}

Measured memory_bytes: 1792
#include <cstdio>
#include <set>
#include <boost/math/quaternion.hpp>

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

using namespace std;
using namespace boost::math;

inline int getInt(){ int s; scanf("%d", &s); return s; }

int main(){
  while(const int n = getInt()){
    REP(i,n){
      quaternion<int> q[2];

      REP(j,2){
        const int x = getInt();
        const int y = getInt();
        const int z = getInt();
        const int w = getInt();
        q[j] = quaternion<int>(x, y, z, w);
      }

      const quaternion<int> r = q[0] * q[1];

      printf("%d %d %d %d\n",
             r.R_component_1(),
             r.R_component_2(),
             r.R_component_3(),
             r.R_component_4());
    }
  }

  return 0;
}

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

#define ll long long
#define ar array
#define vi vector<int>
#define INF 1000000000

int gcd(int a, int b){
	if(a % b == 0) return b;
	return gcd(b, a % b);
}
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int k; cin >> k;
	ll ans = 0;
	for(int a=1; a <= k; a++){
		for(int b=1; b <=k; b++){
			for(int c=1; c <=k; c++){
				ans += gcd(gcd(a,b), c);
			}
		}
	}
	cout << ans << endl;

	return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#pragma endregion

#pragma region Dijkstra

static const int MAX = 100007; // 頂点数の最大
static const int INF = 1e9+7;	// 経路長∞
static const int WHITE = 0; // 状態 : 未訪問
static const int GRAY = 1; // 状態 : 訪問済(未確定)
static const int BLACK = 2; // 状態 : 確定済

int n, m; // n:頂点数, m:辺数
vector<P> adj[MAX]; // 隣接行列(行先,コスト)
int back[MAX]; // 最短経路におけるひとつ前の頂点

void dijkstra(int start){
	priority_queue<P, vector<P>, greater<P>> pq;
	int color[MAX]; // 頂点の訪問状態
	int d[MAX]; // 最短経路長

	// 初期化
	rep(i,n){
		d[i] = INF;
		color[i] = WHITE;
		back[i] = -1;
	}

	// スタート地点を優先度付きキューに登録
	d[start] = 0;
	pq.push(make_pair(d[start],start)); // (部屋0からの距離, 部屋番号)
	color[start] = GRAY;

	while(!pq.empty()){
		P f = pq.top(); pq.pop();
		int u = f.second;
		color[u] = BLACK;

		// pqの最小値が最短でなければ無視
		if(d[u] < f.first) continue;

		rep(j,adj[u].size()){
			int v = adj[u][j].first;
			int cost = adj[u][j].second;
			
			// 行先確定済みなら行かない
			if(color[v] == BLACK){
				continue;
			}
			// たどった時の経路長がそれまでの最小であれば更新
			if(d[v] > d[u] + cost){
				d[v] = d[u] + cost;
				back[v] = u;
				pq.push(make_pair(d[v], v));
				color[v] = GRAY;
			}
		}
	}
}

#pragma endregion

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	cin >> n >> m;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		a--;b--;
		adj[a].eb(make_pair(b,1));
		adj[b].eb(make_pair(a,1));
	}

	dijkstra(0);

	FOR(i,1,n){
		if(back[i] == -1){
			cout << "No" << endl;
			return;
		}
	}

	cout << "Yes" << endl;
	FOR(i,1,n){
		cout << back[i] + 1 << endl;
	}
}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

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

ans = 0
for i in range(1, N+1):
    a = list(map(int, str(i)))
    x = a[0]
    y = a[-1]
    if x == y:
        ans += 1
    if y != 0:
        for j in (5, 4, 3, 2, 1):
            z = (y+1)*(10**j)
            if z <= N:
                ans += 10**(j-1)
            elif y*(10**j) + x <= N and N < z:
                s = N-y*(10**j)
                ans += int(s/10)
                if N%10 >= x:
                    ans += 1

print(ans)

Measured memory_bytes: 9212
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <list>
#include <stack>

using namespace std;

int main()
{
	long long n, h;
	cin >> n >> h;
	vector<long long> b(n);
	long long a = 0;
	for (long long i = 0; i < n; i++)
	{
		long long an;
		cin >> an >> b[i];
		if (an > a)
			a = an;
	}
	sort(b.begin(), b.end(), greater<long long>());

	long long a_num = h / a;
	a_num += h % a == 0 ? 0 : 1;
	long long b_num = 0;

	for (long long i = 0; i < n; i++)
	{
		if (h <= 0)
			break;
		if (a >= b[i])
			break;
		b_num++;
		h -= b[i];
		if (h <= 0)
		{
			a_num = 0;
			break;
		}
		a_num = h / a;
		if (h % a != 0)
			a_num++;
	}

	printf("%lld", a_num + b_num);

	return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define ll long long
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
using namespace std;
const int INF = 1001001001;
const int MOD = 1e9+7;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }

class UnionFind{
public:
  vector<ll> parent;  //parent[i]はiの親
  vector<ll> siz;  //素集合のサイズを表す配列(1で初期化)
  UnionFind(ll n) : parent(n), siz(n,1){ rep(i,n) parent[i] = i; } //コンストラクタ  //全ての要素の根が自身であるとして初期化
  ll root(ll x){ //データxの属する木の根を取得(経路圧縮も行う)
    if(parent[x] == x) return x;
    return parent[x] = root(parent[x]);  //代入式の値は代入した変数の値なので、経路圧縮できる
  }
  void unite(ll x,ll y){ //xとyの木を併合
    ll rx = root(x);  //xの根
    ll ry = root(y);  //yの根
    if(rx == ry) return;  //同じ木にある時
    if(siz[rx] < siz[ry]) swap(rx,ry);
    siz[rx] += siz[ry];  //小さい集合を大きい集合へと併合(ry→rxへ併合)
    parent[ry] = rx;  //xとyが同じ木にない時はyの根ryをxの根rxにつける
  }
  bool same(ll x,ll y){ return root(x) == root(y); } //xとyが属する木が同じかを判定
  ll size(ll x){ return siz[root(x)]; } //xの素集合のサイズを取得
};

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n,m,k; cin >> n >> m >> k;
  vector<vi> frnd(n),block(n);
  UnionFind f(n);
  rep(i,m){
    int a,b; cin >> a >> b;
    --a; --b;
    frnd[a].push_back(b);
    frnd[b].push_back(a);
    f.unite(a,b);
  }
  rep(i,k){
    int c,d; cin >> c >> d;
    --c; --d;
    block[c].push_back(d);
    block[d].push_back(c);
  }
  rep(i,n){
    int ans = f.size(i);
    ans -= frnd[i].size();
    for(auto b : block[i]) ans -= f.same(i,b);
    cout << ans-1 << " ";
  }
  return 0;
}


Measured memory_bytes: 15844
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

x,y = mi()
#a,b
# x = a + 2b
# y  = 2a + b

if (-x + 2*y) % 3 == 0 and (2*x - y) % 3 ==0:
    a = (-x+2*y) //3
    b = (2*x-y)//3
    if a < 0 or b < 0:
        print(0)
        exit()
else:
    print(0)
    exit()

#a+b C a
#a^-1 (mod P)
def modinv(a, mod=10**9+7):
    return pow(a, mod-2, mod)

#  これは計算量rでncr mod p を求められる。
def combination(n, r, mod=10**9+7):
    r = min(r, n-r)
    res = 1
    for i in range(r):
        res = res * (n - i) * modinv(i+1, mod) % mod
    return res

ans = combination(a+b,a)
print(ans)



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

#define F first
#define S second 
#define mp make_pair
#define pb push_back
#define pf push_front
#define speed_up ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define debug cerr << "OK\n";
#define ub upper_bound
#define lb lower_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<pii> vpii;
typedef set <int> si;
typedef set <ll> sll;
typedef multiset <int> msi;
typedef multiset <ll> msll;
typedef map <int, int> mi;
typedef map <ll, int> mll;
 
const int N = 1e5 + 2;
const int M = 1e5 + 2;
const int mod = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e16;
 
void data() {
    #ifdef PC
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
}

void scerr(vi nums) {
	for (auto it : nums)
		cerr << it << " | ";
	cerr << "\n";
}

ll n, dp[N], a[N];

int main() {
	data();
	scanf("%lld", &n);
	dp[0] = dp[1] = 0LL;
	for (int i = 1; i <= n; ++i) {
		scanf("%lld", &a[i]);
		if (i > 1)
			if (i > 2)
				dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
			else
				dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
	}
	printf("%lld", dp[n]);
	return 0;
}
 
/*
	Timus: 288481RF
	CodeForces: __fractal
*/

Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <vector>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <algorithm>
#include <stdio.h>
#include <functional>
using namespace std;

int main()
{
	int h, w;
	while (cin >> h >> w)
	{
		if (h == 0 && w == 0)
		{
			break;
		}
		for (int j = 0; j < h; j++)
		{
			for (int i = 0; i < w; i++)
			{
				cout << '#';
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <cstdio>
using namespace std;
const int N = 1e5+7;
int p[N], a[N], b[N], aa[N], bb[N];

int main(){
    int n;
    scanf("%d", &n);
    int nk = n+1;
    for(int i = 2; i <= nk ; i++)   scanf("%d", p+i) , aa[i] = bb[i] = a[i] = b[i] = i;
    p[0] = p[1] = p[nk+1] = p[nk+2] = 0x7fffffff;
    a[0] = a[1] = aa[0] = aa[1] = 0;
    b[nk+1] = bb[nk+1] = b[nk+2] = bb[nk+2] = nk+2;
    for(int i = 2 ; i <= nk ; i++){
        int& ai = a[i];
        ai--;
        while( p[ai] < p[i] ){
            if( a[ai] == ai ){
                ai--;
            }else{
                ai = a[ai];
            }
        }
        int& aai = aa[i];
        aai = ai - 1;
        while( p[aai] < p[i] ){
            if( aa[aai] == aai ){
                aai--;
            }else{
                aai = a[aai];
            }
        }
    }
    for(int i = nk ; i > 1  ; i--){
        int& bi = b[i];
        bi++;
        while( p[bi] < p[i] ){
            if( b[bi] == bi ){
                bi++;
            }else{
                bi = b[bi];
            }
        }
        int& bbi = bb[i];
        bbi = bi + 1;
        while( p[bbi] < p[i] ){
            if( bb[bbi] == bbi ){
                bbi++;
            }else{
                bbi = b[bbi];
            }
        }
    }
    long long sum = 0;
    for(int i = 2 ; i <= nk ; i++){
        //printf("%d %d %d %d %d\n", i , aa[i], a[i], b[i], bb[i]);
        if( a[i] > 1 ){
            sum += 1LL * p[i] * (a[i] - aa[i]) * (b[i] - i);
        }
        if( b[i] <= nk ){
            sum += 1LL * p[i] * (bb[i] - b[i]) * (i - a[i]);
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 2176
import java.util.Scanner;
public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length = 2*r*pi;
        System.out.printf("%f %f",area,length);
    }
}


Measured memory_bytes: 28312
#include<bits/stdc++.h>
 
using namespace std;
 
#define INF 1000000007
#define LINF 1000000000000000007
 
typedef long long i64;
typedef pair<i64,i64> P;


char b;

int main(){
	cin >> b;
	if(b == 'A') cout << 'T' << endl;
	if(b == 'T') cout << 'A' << endl;
	if(b == 'G') cout << 'C' << endl;
	if(b == 'C') cout << 'G' << endl;
	
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
#define CEIL(A,B) ((A)+(B)-1)/(B)
using namespace std;
typedef int_fast64_t ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){ll c=max(a,b);ll d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

ll N, A, ans, tmp;
map<ll, ll> E, O;
vector<Pll> cnt_e, cnt_o;

int main() {
    fastio();
    cin >> N;
    REP(i, N) {
        cin >> A;
        if(i & 1) {
            if(O.find(A) == O.end()) O[A] = 1;
            else O[A]++;
        } else {
            if(E.find(A) == E.end()) E[A] = 1;
            else E[A]++;
        }
    }
    for(auto e : E) cnt_e.push_back(e);
    for(auto e : O) cnt_o.push_back(e);
    sort(ALL(cnt_e), [](const Pll& x, const Pll& y){return x.second > y.second;});
    sort(ALL(cnt_o), [](const Pll& x, const Pll& y){return x.second > y.second;});
    ans = -1;
    REP(i, cnt_e.size()) {
        REP(j, cnt_o.size()) {
            if(cnt_e[i].first == cnt_o[j].first) {
                tmp = max(cnt_e[i].second, cnt_o[j].second);
                if(ans < tmp) ans = tmp;
            } else {
                tmp = cnt_e[i].second + cnt_o[j].second;
                if(ans < tmp) ans = tmp;
                else break;
            }
        }
    }
    cout << N - ans << endl;
	return 0;
}

Measured memory_bytes: 8824
#include <algorithm>
#include <stdio.h>
#define MOD 1000000007
#define ll long long
#define maxf 200000

int f[maxf+1], invf[maxf+1];

inline int lgput (int a, int n) {
    int rez = 1;
    while (n) {
        if (n % 2 == 1)
            rez = (1LL * rez * a) % MOD;
        a = (1LL * a * a) % MOD, n /= 2;
    }
    return rez;
}

inline int combinari (int a, int b) {
    if(b < a) return 0;
    else return 1LL * f[b] % MOD * invf[a] % MOD * invf[b-a] % MOD;
}
int main() {
    int n, m, a, b, nr = 0;
    scanf("%d%d%d%d", &n, &m, &a, &b);

    f[0] = 1;
    invf[0] = 1;
    for (int i = 1; i <= maxf; i++) f[i] = 1LL * i * f[i-1] % MOD;
    invf[maxf] = 1LL * lgput (f[maxf], MOD - 2);
    for (int i = maxf - 1; i >= 1; i--) invf[i] = 1LL * invf[i+1] * (i+1) % MOD;
    for (int i = 1; i <= n - a; i++) {
        nr = (nr + 1LL * combinari(i - 1, b + i - 2) * combinari(m - b - 1, m + n - b - i - 1) % MOD)% MOD;
    }

    printf("%d", nr);

    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
#include <fstream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <algorithm>

#define MOD_BIG 1000000007
#define MOD_BIG2 998244353
using std::string;
using std::cin;
using std::cout;
using std::cerr;
using std::endl;
using ll = long long;
using std::vector;

template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) {
    vec.resize(len);
    for (auto &v : vec) ndarray(v, args...);
}

//////////////////////////////////////

//////////////////////////////////////

int main() {
    
    ll H, W, K;
    cin >> H >> W >> K;
    vector<vector<int>> ans= vector<vector<int>>(H, vector<int>(W, 0));
    int p = 1;
    int first = 0;
    int lasth = 0;
    for (int i = 0; i < H; i++) {
        bool flag = false;
        for (int j = 0; j < W; j++) {
            char c;
            cin >> c;
            if (c == '#') {
                if (first == 0) {
                    first = 1;
                }
                if (flag == true) {
                    p += 1;
                }
                flag = true;
            }
            ans[i][j] = p;
        }
        if (first == 1) {
            for (int i2 = 0; i2 < i; i2++) {
                for (int j = 0; j < W; j++) {
                    ans[i2][j] = ans[i][j];
                }
            }
            first = 2;
        }
        if (flag == false && first == 2) {
            for (int i2 = lasth+1; i2 <= i; i2++) {
                for (int j = 0; j < W; j++) {
                    ans[i2][j] = ans[lasth][j];
                }
            }
        }
        if (flag) {
            lasth = i;
            p += 1;
        }
    }
    
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            cout << ans[i][j] << " ";
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>

int main(void){
   int N,i;
   int y=0;
   int data[1000];
   scanf("%d",&N);
   for(i=0;i<N;i++){
      scanf("%d",&data[i]);
   }
   for(i=0;i<N;i++){
      if(data[i]%2==0){
         if((data[i]%3!=0)&&(data[i]%5)!=0){
            y=1;
         }
      }
   }
         if(y==0){
            printf("APPROVED\n");
         }else{
            printf("DENIED\n");
         }
         return 0;
}


Measured memory_bytes: 1636
import java.util.*;

public class Main {
	public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
		Map<Integer, Integer> map = new HashMap<Integer, Integer>();

		for (int i = 0; i < n; i++) {
			int a = sc.nextInt();
			if (map.get(a) == null) {
				map.put(a, 1);
			} else {
				map.put(a, map.get(a) + 1);
			}
		}

		int cnt = 0;
		for (int k : map.keySet()) {
			int v = map.get(k);
			if (k < v) {
				cnt += (v - k);
			} else if (k > v) {
				cnt += v;
			}
		}

		System.out.println(cnt);
	}
}


Measured memory_bytes: 62804
#![allow(unused_imports)]
#![allow(non_snake_case, unused)]

use std::cmp::*;
use std::collections::*;
use std::ops::*;

// https://atcoder.jp/contests/hokudai-hitachi2019-1/submissions/10518254

macro_rules! eprint {
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = write!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! eprintln {
    () => { eprintln!(""); };
    ($($t:tt)*) => {{
        use ::std::io::Write;
        let _ = writeln!(::std::io::stderr(), $($t)*);
    }};
}
macro_rules! dbg {
    ($v:expr) => {{
        let val = $v;
        eprintln!("[{}:{}] {} = {:?}", file!(), line!(), stringify!($v), val);
        val
    }}
}

macro_rules! mat {
    ($($e:expr),*) => { Vec::from(vec![$($e),*]) };
    ($($e:expr,)*) => { Vec::from(vec![$($e),*]) };
    ($e:expr; $d:expr) => { Vec::from(vec![$e; $d]) };
    ($e:expr; $d:expr $(; $ds:expr)+) => { Vec::from(vec![mat![$e $(; $ds)*]; $d]) };
}

macro_rules! ok {
    ($a:ident$([$i:expr])*.$f:ident()$(@$t:ident)*) => {
        $a$([$i])*.$f($($t),*)
    };
    ($a:ident$([$i:expr])*.$f:ident($e:expr$(,$es:expr)*)$(@$t:ident)*) => { {
        let t = $e;
        ok!($a$([$i])*.$f($($es),*)$(@$t)*@t)
    } };
}

pub fn readln() -> String {
    let mut line = String::new();
    ::std::io::stdin().read_line(&mut line).unwrap_or_else(|e| panic!("{}", e));
    line
}

macro_rules! read {
    ($($t:tt),*; $n:expr) => {{
        let stdin = ::std::io::stdin();
        let ret = ::std::io::BufRead::lines(stdin.lock()).take($n).map(|line| {
            let line = line.unwrap();
            let mut it = line.split_whitespace();
            _read!(it; $($t),*)
        }).collect::<Vec<_>>();
        ret
    }};
    ($($t:tt),*) => {{
        let line = readln();
        let mut it = line.split_whitespace();
        _read!(it; $($t),*)
    }};
}

macro_rules! _read {
    ($it:ident; [char]) => {
        _read!($it; String).chars().collect::<Vec<_>>()
    };
    ($it:ident; [u8]) => {
        Vec::from(_read!($it; String).into_bytes())
    };
    ($it:ident; usize1) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1
    };
    ($it:ident; [usize1]) => {
        $it.map(|s| s.parse::<usize>().unwrap_or_else(|e| panic!("{}", e)) - 1).collect::<Vec<_>>()
    };
    ($it:ident; [$t:ty]) => {
        $it.map(|s| s.parse::<$t>().unwrap_or_else(|e| panic!("{}", e))).collect::<Vec<_>>()
    };
    ($it:ident; $t:ty) => {
        $it.next().unwrap_or_else(|| panic!("input mismatch")).parse::<$t>().unwrap_or_else(|e| panic!("{}", e))
    };
    ($it:ident; $($t:tt),+) => {
        ($(_read!($it; $t)),*)
    };
}


pub fn main() {
    let _ = ::std::thread::Builder::new().name("run".to_string()).stack_size(32 * 1024 * 1024).spawn(run).unwrap().join();
}

const MOD: usize = 1_000_000_007;
const INF: i64 = std::i64::MAX/2;

fn solve() {
    let (n,x,t) = read!(i64,i64,i64);
    println!("{}",(n+x-1)/x*t);
}

fn run() {
    solve();
}


Measured memory_bytes: 2244
#include<bits/stdc++.h>
using namespace std;
int main()
{long long int a,b;
 cin>>a>>b;
 if(((4*a)-b>=0)&&(((4*a)-b)%2==0))
 {if(((4*a)-b)/2<=a)
   cout<<"Yes";
  else
    cout<<"No";
 }
 else
   cout<<"No";
}

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

char n;
long long a, b, c;
char ans;

void in();
void solve();
void out();

int main(){
    in();
    solve();
    out();
}

void in(){
    ios::sync_with_stdio(false);
    cout.tie(0);
    cin.tie(0);
    cin >> n;
}

void solve(){
    ans = n + 1;
}

void out(){
    cout << ans;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int a, b;
    int S=0, R=0;
    
    scanf("%d %d", &a, &b);
    
    S = a * b;
    R = (a + b) * 2;
    
    printf("%d %d\n", S, R);
    
    return 0;
    
    
}


Measured memory_bytes: 2048
/**********************************************
 *Author*        :XzzF
 *Created Time*  : 2018/4/8 21:57:57
 *Ended  Time*  : 2018/4/8 22:01:52
*********************************************/

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;

int n;

int main()
{
	while(scanf("%d", &n) != EOF)
	{
		LL MIN = INF;
		LL sum = 0;
		bool f = 1;
		for(int i = 1; i <= n; i++) {
			LL a, b;
			scanf("%lld %lld", &a, &b);
			sum += a;
			if(a != b) f = 0;
			if(a > b) MIN = min(MIN, b);
		}
		if(f == 1) printf("0\n");
		else printf("%lld\n", sum - MIN);
	}
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#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;

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e6;

int main()
{
    int n;
    cin>>n;
    int l[n];
    int sum=0;
    rep(i,n)
    {
        cin>>l[i];
        sum+=l[i];
    }
    sort(l,l+n);
    if(sum-l[n-1]>l[n-1])
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
    
}

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

int main() { 
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n + 69);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }
    vector<int> dp(n + 69, INT_MAX);
    dp[1] = 0;
    for (int i = 1; i <= n; i++) {
        dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
        dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
    }
    cout << dp[n] << '\n';
}

Measured memory_bytes: 1024
n, m = gets.chomp.split(" ").map(&:to_i)
a = gets.chomp.split(" ", n).map(&:to_i)

sum = a.inject(&:+)
a.sort!{|a, b| b <=> a}
if a[m-1] >= sum * (1.to_f / (4 * m))
  print "Yes\n"
else
  print "No\n"
end

Measured memory_bytes: 1788
import java.util.*;
//import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		long n = parseLong(sc.next());
		sc.close();
		long ans = n*(n-1)/2;
		out.println(ans);
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <unordered_map>
typedef std::string str;
const std::unordered_map<str, int> W = {
  {"SUN", 7}, {"MON", 6}, {"TUE", 5}, {"WED", 4},
  {"THU", 3}, {"FRI", 2}, {"SAT", 1}
};
str S;

void fastio() {
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
}

int main() {
  fastio();
  std::cin >> S;
  std::cout << W.at(S) << '\n';
  return 0;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back

int n,m,i,a[100010],pre[100010],l,w,vw,val,r,vl,vr,x,cnt,ans,p;

signed main()
{
    ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	for (i=1;i<n+1;i++) cin>>a[i];
	sort(a+1,a+n+1);
	pre[1]=a[1];
	for (i=2;i<n+1;i++) pre[i]=pre[i-1]+a[i];
	vl=2;vr=2e5;val=2;cnt=n*n;
	while (vl<=vr)
	{
		vw=(vl+vr)/2;
		x=0;
		for (i=1;i<n+1;i++)
		{
			if (2*a[i]>=vw) x++;
			l=1;r=i-1;p=i;
			while (l<=r)
			{
				w=(l+r)/2;
				if (a[w]+a[i]>=vw)
				{
					r=w-1;p=w;
				}
				else l=w+1;
			}
			x=x+2*(i-p);
		}
		if (x>=m)
		{
			val=vw;vl=vw+1;
		}
		else vr=vw-1;
	}
//	cout<<val<<" ";
	x=0;
	for (i=1;i<n+1;i++)
	{
		if (2*a[i]>=val) x++,ans=ans+2*a[i];
		l=1;r=i-1;p=i;
		while (l<=r)
		{
			w=(l+r)/2;
			if (a[w]+a[i]>=val)
			{
				r=w-1;p=w;
			}
			else l=w+1;
		}
		x=x+2*(i-p);ans=ans+2*(a[i]*(i-p)+pre[i-1]-pre[p-1]);
	}
	ans=ans-val*(x-m);
	cout<<ans;
}


Measured memory_bytes: 5184
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define dd double
#define endl "\n"
#define pb push_back
#define all(v) v.begin(),v.end()
#define mp make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pll pair<ll,ll>
#define fo(i,n) for(int i=0;i<n;i++)
#define fo1(i,n) for(int i=1;i<=n;i++)
ll mod=1000000007;
ll n,k,t,m,q,flag=0;
ll power(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
// #include <ext/pb_ds/assoc_container.hpp> 
// #include <ext/pb_ds/tree_policy.hpp> 
// using namespace __gnu_pbds; 
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
// ordered_set s ; s.order_of_key(a) -- no. of elements strictly less than a
// s.find_by_order(i) -- itertor to ith element (0 indexed)
ll min(ll a,ll b){if(a>b)return b;else return a;}
ll max(ll a,ll b){if(a>b)return a;else return b;}
ll gcd(ll a , ll b){ if(b > a) return gcd(b , a) ; if(b == 0) return a ; return gcd(b , a%b) ;}
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    #ifdef NOOBxCODER
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #else 
    #define NOOBxCODER 0
    #endif
    //cin>>t;
    t=1;
    while(t--){
        ll a,b,c,d;
        cin>>a>>b>>c>>d;
        if((c+b-1)/b <= (a+d-1)/d)cout<<"Yes";
        else cout<<"No";





        
    }
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
    return 0;
}


Measured memory_bytes: 3796
#include<iostream>
    #include<stdio.h>
    //#include <bits/stdc++.h>
    #include<vector>
    #include<float.h>
    #include<iomanip>
    #include<algorithm>
    #include<string>
    #include<cstring>
    #include<math.h>
    #include<cmath>
    #include<sstream>
    #include<set>
    #include<map>
    #include<queue>
    #include <cassert>
    #include <cmath>

    #define INF 1e9
    #define rep(i,n)for(int i=0;(i)<(int)(n);i++)
    #define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
    #define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
    #define vec(type,n) vector<type>(n)
    #define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))

    using namespace std;
    using ll = long long;
    using Graph = vector<vector<int>>;
    using P = pair<int,int>;

    int main(){
      int n;cin>>n;
      VEC(ll,a,n);
      auto b = vec(ll,n);
      b[0] = a[1]-a[0];
      REP(i,1,n-2){
        b[i] = a[i+1]-b[i-1];
      }
      ll r = b[n-2];
      auto c = vec(ll,n);
      c[0] = r;
      c[1] = 2*a[0]-r;
      REP(i,2,n-1){
          c[i] = 2*b[i-2]+(r*pow(-1,i));
      }
      rep(i,n)cout<<c[i]<<" ";
    }
    


Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define inf 1000000000
#define maxs(x,y) (x = max(x , y))
#define mins(x,y) (x = min(x , y))
using namespace std;
typedef long long int ll;

int main(){

    int N,ans;
    cin >> N;
    

    if(N%111 == 0){
        ans = N;
    }else if(N/111 >= N/100){
        ans = N/100;
        ans++;
        ans *= 111;
    }else if(N/111 <= N/100){
        ans = N/100;
        ans *= 111;
    }
    

    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <map>
 
using namespace std;
int N;
vector<int> A;

int main()
{
  int i;
  long sum=0;
  int th;
  int cn=0;

  cin >> N;

  for (i=1; i<=N; i++) {
    if (i%3 != 0 && i%5 != 0) sum+= i;
  }

  printf("%ld\n", sum);

  return 0;
}


Measured memory_bytes: 3764