akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        System.out.println(Math.max(0, C-(A-B)));
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;
int main(){
  char A[3];
  int i,j,count=0;
  for(i=0;i<3;i++)
    cin>>A[i];
  for(i=0;i<3;i++)
  {
    if(A[i]=='R'&&count==0)
    {
      count++;
      for(j=i+1;j<3;j++)
      {
        if(A[j]=='R')
          count++;
        else
          break;
      }
    }
  }
  cout<<count;
}

Measured memory_bytes: 3632
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

#define Re return
#define In inline
#define inc(l, i, r) for(i=l; i<r; ++i)


const int mxn=1<<17;

int n, a[mxn], b[mxn], f[mxn];
#define Pair pair<int, int>
#define fst first
#define snd second
#define mP make_pair
#define lB lower_bound
Pair a1[mxn], b1[mxn];
char bo[mxn], vis[mxn];

int get(int x){Re f[x]? f[x]=get(f[x]): x;}

In void link(int a, int b)
{
//    printf("%d %d\n", a, b);
    if(get(a+1)!=get(b+1))
        f[get(a+1)]=get(b+1);
}

int main()
{
    int i, j, k, l;
    scanf("%d", &n);
    inc(0, i, n)
        scanf("%d", a+i), a[n]^=a[i];
    inc(0, i, n)
        scanf("%d", b+i), b[n]^=b[i];
    k=n-1;
    inc(j=0, i, n+1)
        if(i<n && a[i]==b[i]) bo[i]=1, --k;
        else
            a1[j  ]=mP(a[i], i),
            b1[j++]=mP(b[i], i);
    
    sort(a1, a1+j), sort(b1, b1+j);
    inc(0, i, j)
        if(a1[i].fst!=b1[i].fst)
            goto NO;

    inc(0, i, n+1)
        if(!bo[i])
            link(i, lB(b1, b1+j, mP(a[i], 0))->snd);
    inc(0, i, j-1)
        if(b1[i].fst==b1[i+1].fst)
            link(b1[i].snd, b1[i+1].snd);

    inc(0, i, n+1)
        if(!bo[i] && !f[i+1])
            ++k;
    
    printf("%d\n", k);
    Re 0;
NO: Re puts("-1"), 0;
}


Measured memory_bytes: 2944
n=input()
arr=map(int,raw_input().split())
na=[0,abs(arr[0]-arr[1])]
for i in range(2,n):
    na.append(min(na[-2]+abs(arr[i-2]-arr[i]),na[-1]+abs(arr[i-1]-arr[i])))
print na[-1]
        


Measured memory_bytes: 12700
/////////////////////////////////////////////

//
//	FileName	:	First.cpp
//	Creator		:	Fm
//	Date		:	2019-11-15 01:18
//	Comment		:	OJ(P1227)
//
///////////////////////////////////////////

//#include "pch.h"
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
#include <set>
#include <list>
#include <queue>
#include <map>

using namespace std;
#define	MAXNUM		10010
#define	EPS         0.0001
#define MODNUM		2e31


typedef unsigned char       BYTE;
typedef int                 BOOL;
typedef unsigned long       DWORD;

int main(int argc, char* argv[])
{
	int				nN;
	int				nA;
	deque<int>		q;
	scanf("%d", &nN);

	for (int i = 1; i <= nN; i++)
	{
		scanf("%d", &nA);
		if (i & 1)
			q.push_back(nA);
		else
			q.push_front(nA);
	}
	if (nN & 1)
		reverse(q.begin(), q.end());
	for (auto iter = q.begin(); iter != q.end(); iter++)
		cout << *iter << " ";
	printf("\n");
Exit0:

	return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;

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

    vector<string> S(N);
    vector<int> res(4);
    REP(i, N){
        cin >> S[i];
        if (S[i] == "AC") res[0]++;
        else if(S[i] == "WA") res[1]++;
        else if(S[i] == "TLE") res[2]++;
        else if(S[i] == "RE") res[3]++; 
    }

    cout << "AC x " << res[0] << endl;
    cout << "WA x " << res[1] << endl;
    cout << "TLE x " << res[2] << endl;
    cout << "RE x " << res[3] << endl;
}


Measured memory_bytes: 6424
n, m = map(int,input().split())
A = [input() for _ in range(n)]
B = [input() for _ in range(m)]

ans = 'No'
for i in range(n - m + 1):
    for j in range(n - m + 1):
        C = []
        for k in range(m):
            c = A[i + k][j : j + m]
            C.append(c)
        if B == C:
            ans = 'Yes'
            break
print(ans)

Measured memory_bytes: 3060
import sys
from sys import exit
from collections import deque
from bisect import bisect_left, bisect_right, insort_left, insort_right #func(リスト,値)
from heapq import heapify, heappop, heappush
from itertools import product, permutations, combinations, combinations_with_replacement
from functools import reduce
from math import *

sys.setrecursionlimit(10**6)
INF = 10**20
eps = 1.0e-20
MOD = 10**9+7

def lcm(x,y):
    return x*y//gcd(x,y)
def lgcd(l):
    return reduce(gcd,l)
def llcm(l):
    return reduce(lcm,l)
def mint():
    return map(int,input().split())
def lint():
    return list(map(int,input().split()))
def ilint():
    return int(input()), list(map(int,input().split()))
def judge(x, l=['Yes', 'No']):
    print(l[0] if x else l[1])
def lprint(l, sep='\n'):
    for x in l:
        print(x, end=sep)
def ston(c, c0='a'):
    return ord(c)-ord(c0)
def ntos(x, c0='a'):
    return chr(x+ord(c0))
class counter(dict):
    def __init__(self, *args):
        super().__init__(args)
    def add(self,x):
        self.setdefault(x,0)
        self[x] += 1

n = int(input())
L = [INF]*26
for _ in range(n):
    S = input()
    tmp = [0]*26
    for i in range(len(S)):
        tmp[ston(S[i])] += 1
    for i in range(26):
        L[i] = min(L[i],tmp[i])
ans = []
for i in range(26):
    for j in range(L[i]):
        ans.append(ntos(i))
print(''.join(ans))

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

using namespace std;

typedef long long LL;

const int N = 100010;

char str[N];

int main()
{
    scanf("%s", str + 1);

    int len = strlen(str + 1);
    printf("%c%d%c\n", str[1], len - 2, str[len]);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const ll inf=1e18;
int main(){
	ll n,x;
	cin>>n>>x;
	vi in(n);
	rep(i,n)cin>>in[i];
	ll out=inf;
	vi tmp=in;
	rep(q,n){
		ll sum=x*q;
		rep(i,n)tmp[i]=min(tmp[i],in[(i-q+n)%n]);
		rep(i,n)sum+=tmp[i];
//		rep(i,n)cout<<" "<<tmp[i];cout<<endl;
		out=min(out,sum);
	}
	cout<<out<<endl;
}








Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

int main()
{
	while (true) {
		int size;
		std::cin >> size;
		if (size == 0) break;
		
		int** table = new int*[size+1];
		for (int i=0; i<size+1; i++) {
			table[i] = new int[size+1];
		}
		
		for (int i=0; i<size; i++) {
			for (int j=0; j<size; j++) {
				std::cin >> table[i][j];
			}
		}
		
		for (int i=0; i<size; i++) {
			int row_sum = 0;
			for (int j=0; j<size; j++) row_sum += table[i][j];
			table[i][size] = row_sum;
		}
		for (int j=0; j<=size; j++) {
			int column_sum = 0;
			for (int i=0; i<size; i++) column_sum += table[i][j];
			table[size][j] = column_sum;
		}
		
		for (int i=0; i<=size; i++) {
			for (int j=0; j<=size; j++) {
				std::cout.setf(std::ios::right, std::ios::adjustfield);
				std::cout << std::setw(5) << table[i][j];
			}
			std::cout << std::endl;
		}
		
		for (int i=0; i<size+1; i++) delete[] table[i];
		delete[] table;
	}
	
	return 0;
}
		
			


Measured memory_bytes: 3020
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

char buf[20];

int main() {
  scanf("%s", buf);
  for(int i = 0; i < 4; i++) printf("%c", buf[i]);
  printf(" ");
  for(int i = 4; i < 12; i++) printf("%c", buf[i]);
  printf("\n");
}


Measured memory_bytes: 256
'''
Created on 2017/03/09

@author: 03key
'''

def gcd(x,y):
    if x<y:
        tmp = x
        x = y
        y = tmp
    ans = y
    if x%y != 0:
        ans = gcd(y,x%y)
    return ans

class Mobile:
    def __init__(self,leftratio=0,rightratio=0,left=-1,right=-1):
        self.weight = 0
        self.leftratio = leftratio
        self.rightratio = rightratio
        self.left = left
        self.leftweight = 0
        self.right = right
        self.rightweight = 0

    def calc(self):
        if self.weight != 0 : return self.weight

        if self.left == -1:
            self.leftweight = 1
        else:
            self.leftweight = Mobile.calc(self.left)
        if self.right == -1:
            self.rightweight = 1
        else:
            self.rightweight = Mobile.calc(self.right)

        lmoment = self.leftratio*self.leftweight
        rmoment = self.rightratio*self.rightweight
        lcs = lmoment * rmoment // gcd(lmoment,rmoment)
        self.weight = (lcs//self.leftratio) + (lcs//self.rightratio)

        return self.weight

    def stdout(self):
        print(self.left, self.right)

while True:
    n = int(input())
    if n==0: break
    barlist = [Mobile() for i in range(n)]
    for i in range(n):
        p,q,r,b = map(int, input().split())
        barlist[i].leftratio = p
        barlist[i].rightratio = q
        if r != 0 : barlist[i].left = barlist[r-1]
        if b != 0 : barlist[i].right = barlist[b-1]

    maxi = 0
    for i in range(n):
        maxi = max(barlist[i].calc(),maxi)

    print(maxi)

Measured memory_bytes: 7696
#include <stdio.h>
int main()
{
    int a,b,c;
    printf("");
    scanf("%d %d %d", &a, &b, &c);
    if(a==b&&b==c)
    {
        printf("Yes");
         }
else if(c>a&&b>c)
    {
    printf("Yes");
}
else
    {
    printf("No");
}
    return 0;
}


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

typedef long long ll;
using namespace std;

void solve(){
    ll a; cin >> a;
    string s; cin >> s;

    ll b = 0;
    int p = 1;
    for (int i = (int)s.size() - 1; i >= 0; i--) {
        if (s[i] == '.') continue;
        b += (p) * (s[i] - '0');
        p *= 10;
    }
    cout << (a * b ) / 100 << endl;
}

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

    solve();

    return 0;
}


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

int main() {
  int k, n;
  cin >> k >> n;
  
  vector<int> arr(n);
  for(int i=0; i<n; i++)
    cin >> arr[i];
  
  int mx = 0;
  for(int i=1; i<n; i++)
    mx = max(mx, arr[i] - arr[i-1]);
  
  mx = max(mx, (k-arr[n-1]) + arr[0]);
  
  cout << (k - mx) << endl;
  
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<math.h>
#define N1 10000
#define N2 1e8

int Isprime(int);

int F[(int)N2],f=0;

int main(void){
  int num,pr_num=0,A[N1],max=0;
  int i;

  F[0] = 2;
  
  scanf(" %d",&num);
  for(i = 0; i < num; i++){
    scanf(" %d",&A[i]);
  }
  
  for(i = 0; i < num; i++){
    if(Isprime(A[i]) == 1){
      pr_num++;
    } 
  }


  printf("%d\n",pr_num);
 
  return 0;
}

int Isprime(int n){
  int i;

  if(n == 2)return 1;
  if(n%2 == 0)return 0;

  i = 3;
  while(i <= sqrt(n)){
    if(n%i == 0)return 0;
    i += 2;
  }

  return 1;
}

/*
int Isprime(int n, int judge){
  int i,j,flag=0;
  
  if(judge == 0){
    for(i = 2; i < n; i++){
      for(j = 0; j < f; j++){
	if(i%F[j] == 0) break;
      }
      if(j == f){
	F[f] = i;
	f++;
      }
      if(n%i == 0){
	flag = 1;
      }
    }
    if(flag == 1) return 0;
    else return 1;
  }
  else if(judge == 1){
    if(n == 2)return 1;
    if(n%2 == 0)return 0;
    for(i = 0; i < f; i+=2){
      if(n == F[i]) return 1;
    }
    return 0;
  }
}
*/



Measured memory_bytes: 2104
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <cstring>
#include <string>
#include <vector>
#include <map>
#include <set>
#define MIN 1<<31-1
#define HMAX 1000000000000000000
#define MOD 1000000007
#define REP(i,n) for(ll i = 0; i < (n); i++)
#define RSET(s) for(set<ll>::iterator it=s.begin();it!=s.end();it++)
typedef long long int ll;
using namespace std;
map<ll,ll> Q;
ll S[200020];
int main()
{
	ll n;
	cin>>n;
	Q[0]=1;
	cin>>S[0];Q[S[0]]=Q[S[0]]+1;
	for(ll i=1;i<n;i++)
	{
		ll a;cin>>a;
		S[i]=S[i-1]+a;
		Q[S[i]]=Q[S[i]]+1;
	}
	ll sum=0;
	for(ll i=0;i<n;i++)
	{
		ll d=Q[S[i]];
		sum+=(d*(d-1)/2);
		Q[S[i]]=0;
	}
	cout<<sum;
//  freopen("1.txt","r",stdin);
//  freopen("2.txt","w",stdout);
	return 0;
}

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

using namespace std;

int n, s;

int dfs(int now, int sum, int i)
{
	if (sum > s) return 0;

	if (now == n) {
		if (sum == s) return 1;
		return 0;
	}

	int res = 0;

	for (int j = 0; j < 10; ++j) if (i < j) res += dfs(now + 1, sum + j, j);

	return res;
}

int main()
{
	while (cin >> n >> s, n || s) cout << dfs(0, 0, -1) << endl;
}

Measured memory_bytes: 1160
using System;

class AOJ
{
	private static void Output(int[] input)
	{
		string tmp = "";
		foreach(var i in input)
		{
			tmp += i.ToString() + " ";
		}
		tmp = tmp.Trim();
		Console.WriteLine(tmp);
	}

	private static void insertionSort(int[] input, int length)
	{
		for(int i = 1; i < length; i++)
		{
			Output(input);
			int tmp = input[i];
			int j = i - 1;
			while(j >= 0 && input[j] > tmp)
			{
				input[j + 1] = input[j];
				j--;
			}
			input[j + 1] = tmp;
		}
		Output(input);
	}

	public static void Main()
	{
		int length = int.Parse(Console.ReadLine().Trim());
		var input = Console.ReadLine().Trim().Split(' ');
		var num = new int[length];
		for (int i = 0; i < length; i++) { num[i] = int.Parse(input[i]); }

		insertionSort(num, length);
	}
}

Measured memory_bytes: 6208
#include <stdio.h>

int main(int argc, const char * argv[]) {
    // insert code here...
    int x, y, z, tmp;
    scanf("%d %d %d", &x, &y, &z);
    if(x>y){
        tmp=x;
        x=y;
        y=tmp;
    }
    if (x>z) {
        tmp=x;
        x=z;
        z=tmp;
    }
    if (y>z) {
        tmp=y;
        y=z;
        z=tmp;
    }
    printf("%d %d %d\n", x, y, z);
    return 0;
}



Measured memory_bytes: 2068
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mod 1000000007

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string s, t;
    cin >> s >> t;
    int ans = INT_MAX, n = s.length(), m = t.length();
    for(int i=0; i<n-m+1; i++){
        int cost = 0;
        for(int j=0, k=i; j<m; j++, k++){
            cost += (s[k] != t[j]) ? 1 : 0;
        }
        ans = min(ans, cost);
    }
    cout << ans << '\n';
}


Measured memory_bytes: 3628
#include <bits/stdc++.h> 
using namespace std; 
#define ll long long int
#define pb push_back             
#define se second                
#define fi first  
#define be begin()
#define en end()
#define all(v) v.be, v.en
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
template<typename... T> void po(T... args) { ((cout << args << " "), ...); cout<<""; }

 
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
     int test=1;
     //cin>>test;
     for(int tt=1; tt<=test; tt++){
       ll t,d,s;
       cin>>d>>t>>s;
       if(s*t>=d)pp("Yes");
       else pp("No");
     //cout<<"Case #"<<tt<<": ";  
     }
 
    return 0;
}

Measured memory_bytes: 3644
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();
		int[] p = new int[n];
		for (int i = 0; i < n; i++) {
			p[i] = sc.nextInt() - 1;
		}
		int[] parent = new int[n];
		for (int i = 0; i < n; i++) {
			parent[i] = i;
		}
		for (int i = 0; i < m; i++) {
			int x = sc.nextInt() - 1;
			int y = sc.nextInt() - 1;
			union(parent, x, y);
		}
		sc.close();

		int ans = 0;
		for (int i = 0; i < n; i++) {
			if (find(parent, i) == find(parent, p[i])) {
				ans++;
			}
		}
		System.out.println(ans);
	}

	static void union(int[] parent, int x, int y) {
		int px = find(parent, x);
		int py = find(parent, y);
		if (px != py) {
			parent[px] = py;
		}
	}

	static int find(int[] parent, int x) {
		if (parent[x] == x) {
			return x;
		}
		parent[x] = find(parent, parent[x]);
		return parent[x];
	}
}


Measured memory_bytes: 92692
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
const int INF (1<<30);
const ll mod = 1e9+7;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};



struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; i--) ifact[i-1] = ifact[i] * i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n] * ifact[k] * ifact[n-k];
  }
};


int main() {
  int N, K; cin >> N >> K;
  vector<ll> A(N);
  rep(i, N) cin >> A[i];
  sort(all(A));
  
  combination comb(N+5);

  mint ans = 0;
  for (int i = 0; i <= N-K; i++) {
    ans -= comb(N-i-1, K-1) * A[i];
    //ans -= (A[i] * comb(N-i-1, K-1)) % mod;
    //ans %= mod;
    ans += comb(N-i-1, K-1) * A[N-1-i];
    //ans += (A[N-1-i] * comb(N-i-1, K-1)) % mod;
    //ans %= mod;
  }

  cout << ans.x << endl;

  return 0;
}


Measured memory_bytes: 3200
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  int ret = 0;
  for (int i = 1; i < n - 1; ++i) {
    if (a[i] > a[i - 1] && a[i] < a[i + 1]) ++ret;
    if (a[i] < a[i - 1] && a[i] > a[i + 1]) ++ret;
  }
  cout << ret << endl;
  return 0;
}


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

int main() {

	int N, A, B;
	int sum = 0;
	int res = 0;

	cin >> N >> A >> B;
	
	for (int num = 1; num <= N; num++) {
		int NUM = num;
		for (int i = 0; i <= 5; i++) {
			sum = sum + NUM % 10;
			NUM = NUM / 10;
		}
		if (sum >= A && sum <= B) {
			res = res + num;
		}
		sum = 0;
	}

	cout << res << endl;
	return 0;

}

Measured memory_bytes: 256
unittest
{
	assert( [ "1 + 2" ].parse.expand.solve == 3 );
	assert( [ "5 - 7" ].parse.expand.solve == -2 );
}



import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto aopb = input.front.split;
	return tuple( aopb[ 0 ].to!( long ), aopb[ 1 ], aopb[ 2 ].to!( long ) );
}

auto solve( long a, string op, long b )
{
	if( op == "+" ) return a + b;
	else            return a - b;
}


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

vector<int>v[100009];
int col[100009],start;
int n,x;
bool used[100009];

int dfs(int now,int pre){ //cout<<"  "<<now<<endl;
  
  if(used[now]){
    start = now;
    return pre;
  }
  
  used[now]=1;
  r(i,v[now].size()){
    
    int nex = v[now][i];
    if(nex==pre)continue;
    
    int tmp=dfs(nex,now);
    if(tmp!=-1)return tmp;
    
  }
  return -1;
}

int dfs2(int now,int pre){ //cout<<"  "<<now<<" "<<pre<<endl;
  
  if(now==x)return col[now]=1;
  
  r(i,v[now].size()){
    
    int nex = v[now][i];
    if(nex==pre)continue;
    
    col[now] = dfs2(nex,now);
    if(col[now])return 1;
  }

  return 0;
  
}

int main(){
  cin>>n;
  r(i,n){
    int a,b;
    cin>>a>>b;
    a--;b--;
    v[b].push_back(a);
    v[a].push_back(b);
  }
  
   x = dfs(n/2,-1);
   // cout<<start<<"  "<<x<<endl;
   dfs2(start,x);
   

   //r(i,n)cout<<col[i]<<endl;
   int q;
   cin>>q;
   while(q--){
     int a,b;
     cin>>a>>b;
     a--;b--;
     if(col[a]&&col[b])cout<<2<<endl;
     else cout<<1<<endl;
   }
}



Measured memory_bytes: 15320
#include <iostream>
#include <sstream>
#include <vector>
#include <cassert>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <tuple>
#include <regex>
#include <map>

using namespace std;
using ull = unsigned long long;


int main() {
	ull a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;

	vector<ull> v{a, b, c, d, e};

	sort(begin(v), end(v), [](auto x, auto y) {
		ull xmod10 = (x % 10 == 0) ? 10 : x % 10;
		ull ymod10 = (y % 10 == 0) ? 10 : y % 10;
		return xmod10 > ymod10; });

	ull sum = 0;
	for (size_t i = 0; i < v.size(); i++) {
		sum += v[i];
		if ((sum % 10 != 0) && (i < v.size() - 1)) {
			sum += 10 - (sum % 10);
		}
	}

	cout << sum << endl;

	return 0;
}



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

int main() {
    int N, x, ans;
    
    cin >> N >> x;

    int a[N];
    for (int i = 0; i < N; i++){
        cin >> a[i];
    }
    
    sort(a, a + N);

    int res = 0;
    for (int i = 0; i < N; i++){
        
        x += -a[res];
        res += 1;
        if (x <= 0) {
            break;
        }
    }
    
    if (x != 0){
        res -= 1;
    }

    cout << res << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <iostream>
#include <string>
#include <string.h>
static const int Max = 100000;
int main()
{
    int N, Q;
    std::string S;
    scanf("%d %d", &N, &Q);
    std::cin >> S;
    int l[Max], r[Max];
    for (int i = 0; i < Q; ++i)
    {
        scanf("%d %d", &l[i], &r[i]);
    }
    // 累積和の考えを用いて解く
    int t[Max]; 
    // t[i] : 1からi番目までに出現するaの数.ただし,aは右隣がCとなっているAを表す
    // t[i]を用いると各クエリの答えは t[r[i] - 1] - t[l[i] - 1]
    t[0] = 0;          
    for (int i = 0; i < N; ++i)
    {
        std::string sub = S.substr(i, 2);
        if (sub.compare("AC") == 0)
        {
            t[i + 1] = t[i] + 1;
        }
        else
        {
            t[i + 1] = t[i];
        }
        
        //printf("%d\n", t[i+1]);
    }
    for (int i = 0; i < Q; ++i)
    {
        printf("%d\n", t[r[i]-1] - t[l[i]-1]);
    }
    return 0;
}

Measured memory_bytes: 2176
import java.io.IOException;
import java.util.Arrays;
import java.util.InputMismatchException;

public class Main {
	int n, m;
	int[] c, x;
	int[][] dp;

	int dp(int k, int pre) {
		if (n <= k) return 0;
		if (0 <= dp[k][pre]) return dp[k][pre];

		int res = 1 << 30;

		for (int i = 0; i < m; i++) {
			int y = pre + c[i];
			if (255 < y) {
				y = 255;
			}
			if (y < 0) {
				y = 0;
			}
			int diff = Math.abs(x[k] - y);
			res = Math.min(res, dp(k + 1, y) + diff*diff);
		}

		return dp[k][pre] = res;
	}

	void run() {
		MyScanner sc = new MyScanner();

		while (true) {
			n = sc.nextInt();
			m = sc.nextInt();
			if ((n | m) == 0) {
				break;
			}
			c = sc.nextIntArray(m);
			x = sc.nextIntArray(n);
			dp = new int[n][300];
			for (int i = 0; i < n; i++) {
				Arrays.fill(dp[i], -1);
			}

			/*
			for (int i = 0; i < n; i++) {
				for (int j = 0; j < 256; j++) {
					for (int k = 0; k < m; k++) {
						dp[i][j] = 0;
					}
				}
			}
			 */

			for (int i = 255; 0 <= i; i--) {
				for (int j = n - 1; 0 <= j; j--) {
					dp(j, i);
				}
			}

			System.out.println(dp(0, 128));
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	public void mapDebug(int[][] a) {
		System.out.println("--------map display---------");
		for (int i = 0; i < a.length; i++) {
			for (int j = 0; j < a[i].length; j++) {
				System.out.printf("%3d ", a[i][j]);
			}
			System.out.println();
		}
		System.out.println("----------------------------" + '\n');
	}

	class MyScanner {
		int read() {
			try {
				return System.in.read();
			} catch (IOException e) {
				throw new InputMismatchException();
			}
		}

		boolean isSpaceChar(int c) {
			return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
		}

		boolean isEndline(int c) {
			return c == '\n' || c == '\r' || c == -1;
		}

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

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

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

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

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

		double[] nextDoubleArray(int n) {
			double[] array = new double[n];
			for (int i = 0; i < n; i++)
				array[i] = nextDouble();
			return array;
		}

		String next() {
			int c = read();
			while (isSpaceChar(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isSpaceChar(c));
			return res.toString();
		}

		String[] nextStringArray(int n) {
			String[] array = new String[n];
			for (int i = 0; i < n; i++)
				array[i] = next();

			return array;
		}

		String nextLine() {
			int c = read();
			while (isEndline(c))
				c = read();
			StringBuilder res = new StringBuilder();
			do {
				res.appendCodePoint(c);
				c = read();
			} while (!isEndline(c));
			return res.toString();
		}
	}
}

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

int main() {
  int N, M;
  cin >> N >> M;

  string lst[100000] = {};
  int lst_wa[100000] = {};
  int P;
  string S;
  int n_ac = 0;
  int n_wa = 0;
  for (int i = 0; i < M; i++) {
    cin >> P >> S;
    if (lst[P-1] == "AC") {
      continue;
    }

    if (S == "AC") {
      n_ac++;
      n_wa += lst_wa[P-1];
      lst[P-1] = S;
    } else if (S == "WA") {
      lst_wa[P-1]++;
    }
  }

  cout << n_ac << " " << n_wa << endl;
}

Measured memory_bytes: 6144
N = int(input())
b = list(map(int, input().split()))
res = []
for i in range(N):
    for j in range(N-i):
        if b[N-i-j-1] == N-i-j:
            res.append(N-i-j)
            b = b[:N-i-j-1] + b[N-i-j:]
            break
    else:
        print(-1)
        exit()
print(*res[::-1], sep = '\n')

Measured memory_bytes: 38512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i,n) cin >> d[i];
    sort(d.begin(), d.end());
    int m = n / 2;
    cout << d[m] -  d[m - 1] << endl;
    return 0;
}


Measured memory_bytes: 3768
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int a = sc.nextInt();
		// スペース区切りの整数の入力
		int b = sc.nextInt();
      	if(a * b % 2 == 0){
			// 偶数
			System.out.println("Even");
        } else {
        	// 奇数
			System.out.println("Odd");
        }
	}
}

Measured memory_bytes: 21204
import java.util.Scanner;

class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
       int n = sc.nextInt();
       int x[][] = new int[2][n];
       for(int i = 0; i < 2; i++){
           for(int j = 0; j < n; j++){
               x[i][j] = sc.nextInt();
           }
       }
       int ans = 0;
       for(int i = 0; i < n; i++){
           int count = 0;
           for(int j = 0; j < n; j++){
               if(i == j){
                   count += x[0][j];
               }
               if(i <= j){
                   count += x[1][j];
               }else {
                   count += x[0][j];
               }
           }
           ans = Math.max(ans,count);
           //System.out.println(count);
       }
        System.out.println(ans);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d,s,ss;
    cin>>a>>b>>c>>d;
    s=ceil(a/(d*1.0));
    ss=ceil(c/(b*1.0));
    //cout<<s<<ss;
    if(s<ss)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
 
int main() {

	int N;
    cin >> N;
    N %= 10;
  
  	cout << (N == 3 ? "bon" : N == 0 || N == 1 || N == 6 || N == 8 ? "pon" : "hon") << endl;

}

Measured memory_bytes: 3636
def slove():
    import sys
    input = sys.stdin.readline
    n, k = list(map(int, input().rstrip('\n').split()))
    ls = [0] * k
    pos = 0
    for i in range(n):
        ls[pos] += 1
        if pos + 1 < k:
            pos += 1
    print(0 if len(ls) == 1 else ls[-1] - ls[0])


if __name__ == '__main__':
    slove()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int n,a[(int)2e5+10],b[(int)2e5+10];
vector<int> v[(int)2e5+10];

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

    int i,j;
    cin>>n;
    for(i=1;i<=n;i++)
        cin>>a[i];
    for(i=1;i<=n;i++)
        for(j=1;j*i<=n;j++)
            v[i].push_back(i*j);
    stack<int> s;
    for(i=n;i>0;i--)
    {
        int sum=0;
        for(j=1;j<(int)v[i].size();j++)
            sum+=b[v[i][j]];
        if(a[i]!=(sum%2))
            b[i]=1;
        else
            b[i]=0;
        if(b[i])
            s.push(i);
    }
    printf("%d\n",s.size());
    while(!s.empty())
    {
        printf("%d ",s.top());
        s.pop();
    }
    puts("");
    return 0;
}


/*

5
2 1 4 3 0

5
2 1 4 5 3


*/


Measured memory_bytes: 24180
from math import factorial as f
from sys import exit

def main():
    bign = 10**9+7
    n,k = map(int,input().split())

    edge = [[] for i in range(n+1)]
    for i in range(n-1):
        a,b = map(int,input().split())
        edge[a].append(b)
        edge[b].append(a)

    if len(edge[1]) > k-1:
        print(0)
        exit()
    ans = (f(k)//f(k-1-len(edge[1])))%bign

    for i in range(2,n+1):
        if len(edge[i]) > k-1:
            print(0)
            exit()
        if len(edge[i])==1:
            continue
        t = k-2
        for j in range(len(edge[i])-1):
            ans = ans * t % bign
            t-=1
        
    print(ans)


main()


Measured memory_bytes: 71968
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,b,n) for(int i=b;i<n;i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};

int N,k;
const int MOD =10000;
const int MAX_N =110;
int plan[MAX_N+1];
int memo[MAX_N][4][4];
int solve(int n,int a,int b){//n日目n-1日目がa,n-2日目がbの時計算
	if(n==N+1)return 1;
	if(memo[n][a][b]!=-1)return memo[n][a][b];
	if(plan[n]!=0){
		if(a==b&&a==plan[n])return 0;
		else return solve(n+1,plan[n],a)%MOD;
	}
	int t = 0;
	for(int i =1;i <=3;i++){
		if(a==b&&a==i)continue;
		t +=solve(n+1,i,a)%MOD;
	}
	return memo[n][a][b]=t%MOD;
}


int main(){
	cin>>N>>k;
	rep(i,k){
		int d,k;
		cin>>d>>k;
		plan[d]=k;
	}
	for(int i =0;i <=N;i++){
		for(int j =0;j <4;j++){
			for(int k =0;k <4;k++){
				memo[i][j][k] =-1;
			}
		}
	}
	cout <<solve(1,0,0)<<endl;
	return 0;
}

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


int main(){
  long long n,k;cin>>n>>k;
  long long ans = n % k;
  long long tmp = abs(ans - k);
  //cout << ans << endl;
  //cout << tmp << endl;
  ans = min(ans, tmp);
  cout << ans << endl;
}

Measured memory_bytes: 256
a = input()

a = int(a)

city_list = []

total_dist = 0

from itertools import permutations
import math

for i in range (a):
    x, y = input().split()
    x = int(x)
    y = int(y)
    city_list.append([x, y])

perms = (permutations(city_list))

divisor = 0

for cities in list(perms):
    divisor += 1
    for j in range(1, len(cities),):
        total_dist = total_dist + math.sqrt((cities[j][0] - cities[j-1][0])**2 + (cities[j][1] - cities[j-1][1])**2)


print(total_dist/divisor)

Measured memory_bytes: 7972
#include<stdio.h>
int min(int x,int y)
{
    if(x<y)
        return x;
    return y;
}
int main()
{
    int p,q,r;
    scanf("%d%d%d",&p,&q,&r);
    printf("%d\n",min(p+q,min(p+r,q+r)));
    return 0;
}


Measured memory_bytes: 128
/*  
    Through the fish-eyed lens of tear stained eyes
    I can barely define the shape of this moment in time
    And far from flying high in clear blue skies
    I'm spiralling down to the hole in the ground where I hide
    _________________________
    _________________________
    1032 Hours of Solitude
    Quarantine_Day : 43
*/

#include<bits/stdc++.h>

using namespace std;

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

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<ll>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 1000

bool div(int n){
    int cnt = 0;
    for(int i = 1; i * i <= n; i++){
        if(i * i == n) cnt ++;
        else if(n % i == 0) cnt += 2;
    }
    return cnt == 8;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n, ans(0); cin>>n;
    FOR(i, 1, n){
        if((i&1) && div(i)) ans++;
    }
    cout<<ans<<"\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int n;
  cin>>n;
  vi a(n);
  rep(i,n)cin>>a[i],a[i]--;
  int x=0;
  rep(i,n){
    x=a[x];
    if(x==1){
      cout<<i+1<<endl;
      return 0;
    }
  }
  cout<<-1<<endl;
}


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

using namespace std;

const int MAX_N = 1e5 + 5;
const int MAX_L = 20;
const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;



void solve() {
    int a, b; cin >> a >> b;
    if (a >= 13) cout << b;
    else if (a >= 6) cout << b / 2;
    else cout << 0;
}

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int tc; tc = 1;
    for (int t = 1; t <= tc; t++) {
        //cout << "Case #" << t  << ": ";
        solve();
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <vector>

struct Magic
{
  long power;
  long mp;
};

using Magics = std::vector<Magic>;

long solve(long h, long n, Magics& magics)
{
  std::vector<long> mps(h + 1, LONG_MAX);
  mps[0] = 0;
  for (long i = 0; i < h; ++i) {
    if (mps[i] == LONG_MAX) continue;
    for (const auto& m : magics) {
      const auto p = std::min(h, i + m.power);
      mps[p] = std::min(mps[p], mps[i] + m.mp);
    }
  }
  return mps[h];
}

int main()
{
  long h, n;
  std::cin >> h >> n;
  Magics magics(n);
  for (auto& m : magics) {
    std::cin >> m.power >> m.mp;
  }

  std::cout << solve(h, n, magics) << std::endl;
}


Measured memory_bytes: 384
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort((x).rbegin(),(x).rend())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl
const ll LINF = (1LL << 62) - 1;
const int INF = (1 << 30) - 1;
template<class T>bool chmax(T &a, const T &b){if (a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if (b<a){a=b;return 1;}return 0;}
// clang-format on

void solve(long long A, long long B) {
  ANS(A * B);
}

// clang-format off
int main() {
  long long A;
  scanf("%lld",&A);
  long long B;
  scanf("%lld",&B);
  solve(A, B);
  return 0;
}


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

#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
#define setIO(i, o) freopen(i, "r", stdin), freopen(o, "w", stdout)
#define trav(e, x) for (auto &(e) : (x))
#define pb(x) push_back(x)
#define eb(x...) emplace_back(x)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int) (x).size()
#define lc(i) 2*i
#define rc(i) 2*i+1
#define int long long
using namespace std;
using vi = vector<int>;
using ii = pair<int, int>;

const int MAXN = 1e5, INF = 1e9 + 5, MOD = 1e9 + 7;

signed main() {
    FAST_IO;
//    setIO("input.txt", "output.txt");

    int n, x, t;
    cin >> n >> x >> t;
    int ans = t;
    if (n > x) ans = (n / x + (n % x != 0)) * t;
    cout << ans;
}


Measured memory_bytes: 3600
import java.util.Scanner;
import java.util.Arrays;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner s = new Scanner(System.in);
        int N = s.nextInt();
        int[] n = new int[3];
        HashSet<String> set = new HashSet<String>(); 
        
        for(int i=0;i<N;i++){
            n[0] = s.nextInt();
            n[1] = s.nextInt();
            n[2] = s.nextInt();
            
            Arrays.sort(n);
            String s1 = String.valueOf(n[0]);
            String s2 = String.valueOf(n[1]);
            String s3 = String.valueOf(n[2]);
            
            String str = s1 + s2 + s3;
            set.add(str);
        }
        System.out.println(N - set.size());
    }
}

Measured memory_bytes: 35328
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long ll;
const int N=1000005;
queue<int> q;
int n,m,x[N],y[N],lt1[N],rt1[N],lt2[N],rt2[N],a[400],b[400],Flow,pre[N],lst[N],A[N],i,j,k,l,head[N],adj[N],nxt[N],flow[N],cap[N],cnt;
bool v[N];
ll val[N],cost[N],Cost,dis[N],ans;
char s[400][10];
void addedge(int u,int v,int w,ll c)
{
	adj[++l]=v;
	nxt[l]=head[u];
	head[u]=l;
	flow[l]=0;
	cap[l]=w;
	cost[l]=c;
	adj[++l]=u;
	nxt[l]=head[v];
	head[v]=l;
	flow[l]=0;
	cap[l]=0;
	cost[l]=-c;
}
bool spfa()
{
	int i,j;
	for(i=1;i<=cnt;++i)
		dis[i]=-(1ll<<60),v[i]=false;
	dis[cnt-1]=0;
	q.push(cnt-1);
	v[cnt-1]=true;
	A[cnt-1]=1<<30;
	while(!q.empty())
	{
		i=q.front();
		q.pop();
		v[i]=false;
		for(j=head[i];j;j=nxt[j])
			if(flow[j]<cap[j]&&dis[i]+cost[j]>dis[adj[j]])
			{
				dis[adj[j]]=dis[i]+cost[j];
				A[adj[j]]=min(A[i],cap[j]-flow[j]);
				pre[adj[j]]=i;
				lst[adj[j]]=j;
				if(!v[adj[j]])
				{
					v[adj[j]]=true;
					q.push(adj[j]);
				}
			}
	}
	if(dis[cnt]==-(1ll<<60))
		return false;
	Flow+=A[cnt];
	Cost+=A[cnt]*dis[cnt];
	i=cnt;
	while(i!=cnt-1)
	{
		flow[lst[i]]+=A[cnt];
		flow[lst[i]&1?lst[i]+1:lst[i]-1]-=A[cnt];
		i=pre[i];
	}
	return true;
}
int main()
{
	scanf("%d",&n);
	for(i=1;i<=n;++i)
		scanf("%d%d%lld",x+i,y+i,val+i);
	scanf("%d",&m);
	for(i=1;i<=m;++i)
		scanf("%s%d%d",s[i],a+i,b+i);
	for(i=1;i<=n;++i)
	{
		for(j=1;j<=i;++j)
			lt1[j]=lt2[j]=1,rt1[j]=rt2[j]=100;
		for(j=1;j<=m;++j)
		if(b[j]<i)
		{
			if(s[j][0]=='L')
				lt1[b[j]+1]=max(lt1[b[j]+1],a[j]+1);
			else if(s[j][0]=='R')
				rt1[i-b[j]]=min(rt1[i-b[j]],a[j]-1);
			else if(s[j][0]=='D')
				lt2[b[j]+1]=max(lt2[b[j]+1],a[j]+1);
			else
				rt2[i-b[j]]=min(rt2[i-b[j]],a[j]-1);
		}
		for(j=2;j<=i;++j)
		{
			lt1[j]=max(lt1[j-1],lt1[j]);
			lt2[j]=max(lt2[j-1],lt2[j]);
		}
		for(j=i-1;j>=1;--j)
		{
			rt1[j]=min(rt1[j+1],rt1[j]);
			rt2[j]=min(rt2[j+1],rt2[j]);
		}
		for(j=1;j<=2+2*n+2*i;++j)
			head[j]=0;
		l=0;
		for(j=1;j<=i;++j)
		{
			addedge(2*n+2*i+1,j,1,0);
			addedge(i+j,2*n+2*i+2,1,0);
			for(k=1;k<=n;++k)
			{
				if(x[k]>=lt1[j]&&x[k]<=rt1[j])
					addedge(j,2*i+k,1,0);
				if(y[k]>=lt2[j]&&y[k]<=rt2[j])
					addedge(2*i+n+k,i+j,1,0);
			}
		}
		for(j=1;j<=n;++j)
			addedge(2*i+j,2*i+n+j,1,val[j]);
		cnt=2+2*n+2*i;
		Cost=Flow=0;
		while(spfa());
		if(Flow<i)
			break;
		ans=max(ans,Cost);
	}
	printf("%lld",ans);
	return 0;
}


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

using namespace std;

int main() {
    const int red = 0, blue = 1;

    int n;
    cin >> n;

    vector<int> y(2 * n, 2 * n), clr(2 * n);
    for (int i = 0; i < n; i++) {
        int a, b;
        cin >> a >> b;
        y[a] = b;
        clr[a] = red;
    }

    for (int i = 0; i < n; i++) {
        int c, d;
        cin >> c >> d;
        y[c] = d;
        clr[c] = blue;
    }

    int res = 0;
    for (int i = 0; i < 2 * n; i++) {
        if (clr[i] == blue) {
            int x = -1, h = -1;
            for (int j = 0; j < i; j++) {
                if (clr[j] == red && h < y[j] && y[j] < y[i]) {
                    x = j;
                    h = y[j];
                }
            }

            if (x != -1) {
                y[x] = 2 * n;
                res++;
            }
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 256
program Project1;
             
{$APPTYPE CONSOLE}
         
uses
  SysUtils,math;
var
  g,l,r,a,h,w,i,j,count,x,y,sw,m,n,b,c,soeji,sum,max,k,t,z:Integer;
  //l:array of Integer;
  s,s123,s1,s2,s3:string;
  tf:Boolean;
  //nyu:TStringList;
  xc,yc,space:char;
begin
  try
    { TODO -oUser -cConsole Main : ここにコードを記述してください }
    Readln(s);

    if ((s[1]=s[2])and(s[2]=s[3])) or ((s[2]=s[3])and(s[3]=s[4])) then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define INF 1e9+7
#define LLINF 1e18
using namespace std;
const int MOD = 1e9 +7;

ll cnt=0;
ll sumofdigits(ll n){
    ll sum =0;
    while(n>0){
        sum += n%10;
        n /=10;
        cnt++;
    }
    return sum;
}

int main(){
    ll n;
    cin>>n;
    ll n1=n;
    ll ans=sumofdigits(n1);
    ans=max(ans,(ll)(n/pow(10,cnt-1))-1+9*(cnt-1));
    cout<<ans<<endl;
    return 0;
}

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

int main() {

    string o;
    string e;

    cin >> o >> e;

    for (int i = 0; i < o.size(); i++) {
        cout << o[i];
        if (i < e.size())
            cout << e[i];        
    }

    cout << endl;   


}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<sstream>

std::string toString(int a){
	std::stringstream z;
	std::string s;

	z << a;
	z >> s;

	return s;
}

void calc(std::string &str){

	std::string newstr;
	char bef=str[0];
	int cnt = 1;

	for (int i = 1; i <= str.size(); i++){
		if (i == str.size() || str[i] != bef){
			newstr += toString(cnt) + bef;
			cnt = 1;
		}
		else cnt++;

		bef = str[i];
	}
	str = newstr;
}

int main(){

	int n;

	while (std::cin >> n,n){

		std::string str;
		std::cin >> str;

		for (int i = 0; i < n; i++)calc(str);

		std::cout << str << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
vector<int> graph[100005];
int dp[100005];
int dfs(int x){
	if(dp[x]!=-1)
		return dp[x];
	int ans=0;
	for(int i=0;i<graph[x].size();i++){
		int z=graph[x][i];
		ans=max(ans, 1 + dfs(z));
	}
	return dp[x] = ans;
}
int main(){
	int n, m;
	cin>>n>>m;
	int x, y;
	for(int i=0;i<m;i++){
		cin>>x>>y;
		graph[x].push_back(y);
	}
	int a=0;
	memset(dp, -1, sizeof(dp));
	for(int i=1;i<=n;i++){
		a=max(a, dfs(i));
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 8192
def f(points, l = 0, r = points.size-1)
	if r - l + 1 < 40
		return (l..r).to_a.combination(2).map{|i, j|
			x1, y1 = points[i]
			x2, y2 = points[j]
			(x1 - x2)**2 + (y1 - y2)**2
			}.min
	end
			
	c = (l + r) / 2
	d_l = f(points, l, c)
	d_r = f(points, c + 1, r)
	d = [d_l, d_r].min

	x_c = points[c][0]
	l += 1 until x_c - Math.sqrt(d) < points[l][0]
	return d if l > c
	r -= 1 until points[r][0] < x_c + Math.sqrt(d)
	return d if r <= c

	blocks = {}
	points[c+1..r].each{|x, y|
		(blocks[(y/d).to_i] ||= []) << [x, y]
	}

	ans = d
	points[l..c].each{|x1, y1|
		i = (y1/d).to_i
		[i-1, i, i+1].each{|j|
			next unless blocks[j] 
			blocks[j].each{|x2, y2|
				d2 = (x1 - x2)**2 + (y1 - y2)**2
				ans = d2 if d2 < ans
			}
		}
	}
	ans
end

n = gets.to_i
points = (1..n).map{ gets.split.map(&:to_i) }.sort
p f(points)

Measured memory_bytes: 98620