akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long MD=1e9+7;
long long n,fact[2005],ans;
long long qpow(long long b,long long exp) {
    long long ret=1;
    while (exp!=0) {
        if (exp%2==1) {ret*=b; ret%=MD;}
        b*=b; b%=MD;
        exp/=2;
    }
    return ret;
}
long long xcy(int x,int y) {
    if (y>x) return 0;
    if (y==0 or y==x) return 1;
    long long nom=fact[x];
    long long de1=qpow(fact[x-y],MD-2),de2=qpow(fact[y],MD-2);
    return (((nom*de1)%MD)*de2)%MD;
}
int main() {
    cin>>n;
    fact[0]=1;
    for (int i=1; i<=n; i++) {fact[i]=fact[i-1]*i; fact[i]%=MD;}
    for (int i=1; i<=n; i++) {
        long long x=n-(2*i)-1;
        if (x<0) continue;
        long long add=xcy(x,i-1);
        ans+=add; ans%=MD;
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 3608
# if true

# include <iostream>
# include <string>


int main()
{

	std::string s;
	std::cin >> s;



	if (s == "keyence") 
	{
		std::cout << "YES";
		return 0;
	}

	for (int i{}; i < s.size(); ++i)
	{
		for (int j{i}; j < s.size(); ++j)
		{

			if (s.substr(0, i) + s.substr(j + 1, s.size() - j) == "keyence")
			{
				std::cout << "YES";
				return 0;
			}
		}
	}

	std::cout << "NO";

	return 0;
}


# endif

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

#define N 20

int main(int argc, char const *argv[])
{
    int n;
    int h[N];

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> h[i];
    }

    int top = 0;
    int ans = 0;

    for (int i = 0; i < n; i++)
    {
        if (top <= h[i])
        {
            top = h[i];
            ans++;
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <climits>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include <string>
#include <stack>
#include <algorithm>
#include <map>
#include <numeric>
#include <set>
using namespace std;

#define ll long long
#define ld long double
// v:vector  type:型  order:greater or less
#define _sort(v,type,order) do { sort(v.begin(),v.end(),order<type>()); } while(0)
// vector 要素の総和算出
// v:vector  default_value:初期値
#define _sum(v,default_value) accumulate(v.begin(),v.end(),default_value )
// vector 最大値( return ite )
#define _max_element(v) max_element(v.begin(),v.end())
// vector 最大値が格納されている要素値
#define _max_element_number(v) distance(v.begin(),max_element(v.begin(),v.end()))

//set<uint32_t> member;	// 重複するデータを保持する事はできない member.insert(2) member.insert(2) ⇒ member.count(2)は1
//                                                              member.emplace(2)とかも同じ
//multiset<uint32_t> v;	// 重複するデータも保持する事はできる   member.insert(2) member.insert(2) ⇒ member.count(2)は2

// 丸め
#define _round(v) round(v)
// 2乗 / 3乗
#define _square(v) pow(v,2)
#define _cube(v)   pow(v,3)
// 大小判定
#define _max(x,y) max(x,y)
#define _min(x,y) min(x,y)
// string ⇒ int
#define _stringtoi(s) stoi(s)
// double 平方根
#define _sqrt(x) sqrt(x)
// double 引数 x 以上で最小の整数値 ex) 3.30303 ⇒ 4
#define _ceil(x) ceil(x)
// 指定された要素以上の値が現れる最初の位置のイテレータを取得する
#define _lower_bound(v,min) lower_bound(v.begin(), v.end(), min)
// 指定された要素より大きい値が現れる最初の位置のイテレータを取得する
#define _upper_bound(v,min) upper_bound(v.begin(), v.end(), min)

// 順列 n個の数が与えられる
// 0,1,2,...,n-1
// 全ての並べ方を1行ごとに出力する
// ex 0 1 2 / 0 2 1 / 1 0 2 / 1 2 0 / 2 0 1 / 2 1 0
#define _next_permutation(v) do {   \
	for (auto num : v) {            \
		printf("%d ", num);         \
	}                               \
	printf("\n");                   \
} while (next_permutation(v.begin(), v.end()))

// 絶対値
static int32_t _abs(const int32_t x) { return  (x > 0 ? x : -x); }
// 最大公約数
static int gcd(int a, int b)
{
	if (a < b) {
		a ^= b;
		b ^= a;
		a ^= b;
	}
	return b ? gcd(b, a % b) : a;
}
// 最小公倍数
static int lcm(int a, int b) { return a * b / gcd(a, b); }
// 多次元 std::vector 生成
template<class T>
vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
// ex) auto dp = make_vec<uint64_t>(SIZE + 1, 2, 2);


/*
半径 R の円の周長を出力してください
*/
// ABC 163 A
// https://atcoder.jp/contests/abc163/tasks/abc163_a
int main()
{
	uint32_t r;
	cin >> r;

	printf("%f\n", r*2*3.14159265359f);
	return 0;
}


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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> H(N);
	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	
	int moveCount = 0;
	int answer = 0;
	for (int i = 0; i < N - 1; i++)
	{
		// 右隣のマスの高さが今居るマスの高さ以下
		if (H[i] >= H[i + 1])
		{
			moveCount++;
		}
		else {
			// マス移動の更新
			answer = max(moveCount, answer);
			// マス移動の回数のリセット
			moveCount = 0;
		}
	}
	
	// 最終チェック
	answer = max(moveCount, answer);
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 640
from itertools import product
s=list(input())
cnt=0
pl=list(product(['','+'],repeat=len(s)-1))
for j in pl:
	for _ in range(len(s)):
		l=[s[0]]
		for i in range(len(s)-1):
			l.append(j[i])
			l.append(s[i+1])
	a="".join(l)
	cnt+=eval(a)
print(cnt)

Measured memory_bytes: 3060
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	static int V;
	static int E;
	static ArrayList<Integer>[] g;

	@SuppressWarnings("unchecked")
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		V = sc.nextInt();
		E = sc.nextInt();
		g = new ArrayList[V];
		for (int i = 0; i < V; ++i)
			g[i] = new ArrayList<>();

		for (int i = 0; i < E; ++i) {
			int s = sc.nextInt();
			int t = sc.nextInt();
			g[s].add(t);
		}

		ord = new int[V];
		vis = new boolean[V];
		pending = new boolean[V];

		sort();

		for (int i = 0; i < V; ++i) {
			System.out.println(ord[i]);
		}
	}

	static int[] ord;
	static boolean[] vis;
	static boolean[] pending;
	static int now = 0;

	static void sort() {
		for (int i = 0; i < V; ++i) {
			if (!vis[i])
				dfs(i, -1);
		}
	}

	static void dfs(int cur, int pre) {
		for (int to : g[cur]) {
			if (to != pre && !vis[to]) {
				if (pending[to])
					throw new AssertionError();
				dfs(to, cur);
			}
		}
		ord[V - now - 1] = cur;
		vis[cur] = true;
		++now;
	}
}

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

int main()
{
    int n,i,j=0;
    double d;
    cin>>n>>d;
    double x,y;
    for(i=0;i<n;i++)
    {
       cin>>x>>y;
       if(sqrt(x*x+y*y)<=d)
            j++;
    }
    cout<<j<<endl;
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
using namespace std;
int main() {
    vector<int> a(60);
    for(int i=0;;i++){ 
       
        cin>>a[i];
        if(a[i]==0) break;
    } 
    int n;
    for(int i=0;i<a.size();i++){
        if(a[i]==0) break;
        if(i%10==0) n=a[i];
        else n-=a[i];
        if(i%10==9){
            cout<<n<<endl;
        }
    }
}


Measured memory_bytes: 3008
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#include<deque>
#include <regex>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define per(i,n) for(ll i=n-1;i>=0; --i)
#define all(x) (x).begin(),(x).end()
#define _GLIBCXX_DEBUG
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
const ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,cnt=0;
	string s;
	cin >> n >> s;
	rep(i, n-2) {
		if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')cnt++;
	}
	cout << cnt << endl;
} 




Measured memory_bytes: 256
// 🐋💭
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func getStreth(aryX:[Int],ave:Int) -> Int {
    return aryX.map { Int(pow(Double($0 - ave), 2.0)) }
    .reduce(0) { $0 + $1 }
}

func main() {
    let _ = Int(readLine()!)!
    let aryX = readInts()
    //_____________________________ここまで入力
    
    var ans = Int.max
    var count = 0
    
    while ans > getStreth(aryX: aryX, ave: count) {
        ans = getStreth(aryX: aryX, ave: count)
        count += 1
    }
        
    print(ans)
}

main()





Measured memory_bytes: 13540
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint


INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))

H, W = [int(x) for x in input().split()]
A = []
BQ = deque()
for _ in range(H):
    L = list(input())
    A.append(L)

bCnt = 0
for x in range(W):
    for y in range(H):
        if A[y][x] == '#':
            BQ.append((x, y))
            bCnt += 1


def check(a):
    a2 = sum(a, [])
    cnt = a2.count('.')
    return cnt == 0


def ok(x, y, W, H):
    if x >= 0 and x < W and y >= 0 and y < H:
        return True
    return False


# X,Y座標
DX = [1, -1, 0, 0]
DY = [0, 0, 1, -1]

cnt = 0

while bCnt != H * W:
    newBQ = deque()
    for (x, y) in BQ:
        for (dx, dy) in zip(DX, DY):
            X = x + dx
            Y = y + dy
            if ok(X, Y, W, H) and A[Y][X] == '.':
                A[Y][X] = '#'
                newBQ.append((X, Y))
                bCnt += 1

    cnt += 1

    # print("len:{}".format(len(newBQ)))
    # for a in A:
    #     print(a)
    # print("---")

    BQ = newBQ

print(cnt)


Measured memory_bytes: 116956
#include<bits/stdc++.h>
#include<math.h>
#define ll long long int
#define ve vector<int>
#define vl vector<long long int>
#define all(a) a.begin(),a.end()
using namespace std;

int warikan(ll x){
  ll count=0;
  while(true){
    if(x%2!=0) break;
    x=x/2;
    count++;
  }
  return count;
}

int main(){
  ll n,a,A=0;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    A+=warikan(a);
  }
  cout<<A<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rf(x) (x)=0;while(*p<48)p++;while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);
//#define rf(x) (x)=0;while(*p<48)im=*p=='-';while(47<*p)(x)=((x)<<3)+((x)<<1)+(*p++&15);if(im)(x)=-(x);
#define pb push_back
#define eb emplace_back
#define sz(V) ((int)(V).size())
#define allv(V) ((V).begin()),((V).end())
#define befv(V) ((V)[(sz(V)-2)])
#define sorv(V) sort(allv(V))
#define revv(V) reverse(allv(V))
#define univ(V) (V).erase(unique(allv(V)),(V).end())
#define clv(V) (V).clear()
#define upmin(a,b) (a)=min((a),(b))
#define upmax(a,b) (a)=max((a),(b))
#define rb(x) ((x)&(-(x)))
#define cb(x) (x)=(!(x))
#define INF (0x3f3f3f3f)
#define INFLL (0x3f3f3f3f3f3f3f3fll)
#define INFST (0x7f7f7f7f)
#define INFLLST (0x7f7f7f7f7f7f7f7fll)
using namespace std;
typedef long long ll;
typedef __int128_t lll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
typedef complex<ld> base;
const ld EPS = (ld)1e-7;
const ld PI = acos(0) * 2;
bool isZero(const ld& x) { return abs(x) <= EPS; }
int sign(const ld& x) { return isZero(x) ? 0 : (0 < x ? 1 : -1); }
ll gcd(ll a, ll b) { for(;b;a%=b,swap(a,b)){} return abs(a); }
pll operator + (const pll& a, const pll& b) { return pll(a.first+b.first, a.second+b.second); }
pll operator - (const pll& a, const pll& b) { return pll(a.first-b.first, a.second-b.second); }
pll operator * (const pll& a, const ll& b) { return pll(a.first*b, a.second*b); }
ll operator * (const pll& a, const pll& b) { return a.first*b.second - b.first*a.second; }
ll ccw(const pll& a, const pll& b, const pll& c) { return a*b + b*c + c*a; }
int rd(int s, int e) { return rand()%(e-s+1) + s; }
void fg(vector<int> G[], int a, int b) { G[a].pb(b); G[b].pb(a); }
void fg(vector<pii> G[], int a, int b, int c) { G[a].pb({b, c}); G[b].pb({a, c}); }

const int MAXN = 100005;

int A[MAXN];

int N, Ans;

int main() {
	ios::sync_with_stdio(false);

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

	{
		vector<int> V;
		for(int i = 1; i <= N; i++) V.pb(A[i]);
		sorv(V);
		for(int i = 1; i <= N; i++)
			A[i] = (int)(lower_bound(allv(V), A[i]) - V.begin()) + 1;
	}

	for(int i = 2; i <= N; i += 2)
		Ans += (A[i] & 1);
	
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 1276
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

R = []
G = []
B = []

for i in range(N):
    if S[i] == "R":
        R.append(i)
    elif S[i] == "G":
        G.append(i)
    else:
        B.append(i)

# print(R, G, B)

ans = len(R) * len(G) * len(B)

count = 0

for i in range(N):
    for j in range(N):
        if i < j:
            k = j + (j - i)
            if k < N:
                if S[i] != S[j] and S[i] != S[k] and S[j] != S[k]:
                    count += 1
print(ans - count)

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin >> N;
    vector<ll> A(N);
    REP(i,N) cin >> A[i];
    ll sum = 0;
    REP(i,N) sum+=A[i];
    ll ng = -2;
    ll ok = sum + 2;
    vector<ll> ans(N);
    while (abs(ng-ok) > 1) {
        bool big = false;
        bool sml = false;
        ll mid = (ok+ng) / 2;
        vector<ll> R(N,0);
        R[0] = mid;
        for (int i=1;i<N;i++) {
            R[i] = (A[i-1] - R[i-1]/2) * 2;
            
        }
        ll temp = (A[N-1] - R[N-1]/2) * 2;
        if (temp < mid) {
            ok = mid;
        } 
        else if (temp == mid) {
            REP(i,N) cout << R[i] << " \n"[i==N-1];
            return 0;
        }
        else {
            ng = mid;
            
        }
    }
    //cout << ok << " " << ng << endl;
    return 0;
}

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

int main() {
  int A,B,C;
  cin >> A >> B >> C;
  if (A == 5 && B == 5 && C == 7) cout << "YES" << endl;
  else if (A == 5 && B == 7 && C == 5) cout << "YES" << endl;
  else if (A == 7 && B == 5 && C == 5) cout << "YES" << endl;
  else cout << "NO" << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long inf=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)
#define ZERO(a) memset(a,0,sizeof(a))





//3111111111111111111111111111111
	int dp[100031][13];
	int mo = 1e9+7;

	void solve(){

		

		ins(morty);
		dp[0][0] = 1;
		FOR(i,0,morty.size()){
			FOR(o,0,10){
				if(morty[i]!= '?' and morty[i]!=('0'+o))continue;
				FOR(p,0,13){
					dp[i+1][(p*10+o)%13]+=dp[i][p];
					dp[i+1][(p*10+o)%13]%=mo;
				}
			}
		}
		out(dp[morty.size()][5]);
		








	}	























int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	solve();
	


	return 0;
}


Measured memory_bytes: 10604
#include <bits/stdc++.h>
const double PI = acos(-1);
using namespace std;
int main() {
    int room[4][3][10] = {};
    int n;
    cin >> n;
    int count = n; 
    int a, b, c, d;
    for (int  i = 0; i < count; i++)
    {
        cin >> a >> b >> c >> d;
        room[a-1][b-1][c-1] += d;
        /* code */
    }
     for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
                        cout <<" ";
            cout << room[0][i][j]; 
        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
                        cout <<" ";
            cout << room[1][i][j];

        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
                        cout <<" ";
            cout << room[2][i][j];
        
        }
        cout << endl;
    }
    cout << "####################" << endl;
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 10; j++){
                        cout <<" ";
            cout << room[3][i][j];
        }
        cout << endl;
    }

    
    
}
    


Measured memory_bytes: 3088
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#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(int 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 vector<string> vs;
typedef pair<int,int> pii;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a*b/gcd(a,b);
}


int main(void) {
    int i,j;
    int h,w,n;
    cin >> h >> w >> n;
    vector<pii> p(n);
    rep(i,n)cin >> p[i].first >> p[i].second;
    sort(all(p));
    int x = 0, y = 0;
    int ans = h;
    rep(i,n){
        p[i].first--;
        p[i].second--;
        if(p[i].first-x < p[i].second-y)continue;
        if(p[i].first-x == p[i].second-y){
            x = p[i].first, y = p[i].second-1;
            //cout << "?" << x << " " << y << endl;
        }else{
            ans = min(ans, p[i].first);
            //cout << "!" << p[i].first << " " << p[i].second << " " << ans << endl;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 1792
#include<stdio.h>
#include<math.h>
int main(){
	int n;
	double x1,x2,x3,y1,y2,y3;
	double X,Y,r;
	double a,b,c;
	scanf("%d",&n);
	while(1){
		scanf("%lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3);
			X=(double)1/2*(double)((x1*x1+y1*y1)*(y2-y3)+(x2*x2+y2*y2)*(y3-y1)+(x3*x3+y3*y3)*(y1-y2))/(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2));
			Y=(double)1/2*(double)((x1*x1+y1*y1)*(x2-x3)+(x2*x2+y2*y2)*(x3-x1)+(x3*x3+y3*y3)*(x1-x2))/(y1*(x2-x3)+y2*(x3-x1)+y3*(x1-x2));
			a=(x2-x3)*(x2-x3)+(y2-y3)*(y2-y3);
			b=(x3-x1)*(x3-x1)+(y3-y1)*(y3-y1);
			c=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
			r=sqrt((double)(1/((b+c-a)/(b*c)+(c+a-b)/(c*a)+(a+b-c)/(a*b))));
		printf("%.3f %.3f %.3f\n",X,Y,r);
		n--;
		if(n==0){
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    vi l(n);
    rep(i, n) cin >> l[i];
    int mx = *max_element(l.begin(), l.end());
    bool ans = (accumulate(l.begin(), l.end(), 0) - 2*mx > 0);
    cout << (ans?"Yes":"No") << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include <limits.h>
   
#define N 101
  
#define White 0
#define Gray  1
#define Black 2
   
   
int n=0;
int G[N][N];
int d[N];
int color[N];
int que[N];
int head=0;
int tail=0;
   
void Enqueue(int);
int Dequeue();
void BFS(int);
  
int main()
{
  int i,j,s,v,r;
  int p=1;
  
  scanf("%d",&n);
  
  for(i=1;i<=n;i++)
    {
    for(j=1; j<=n;j++)
      {
    G[i][j] = 0;
      }
    }
   
  for(i=1;i<=n;i++){
    scanf("%d%d", &v,&r);
    for(j=1;j<=r;j++){
      scanf("%d",&s);
      G[i][s] = 1;
    }
  }
  
  BFS(p);
  for(i=1;i<=n;i++){
    printf("%d %d\n",i, d[i]);
  }
  return 0;
}
 
void Enqueue(int s)
{
  que[tail]=s;
  tail+=1;
}
  
int Dequeue()
{
  int sugiyama;
  sugiyama = que[head];
  head+=1;
  return sugiyama;
} 
  
void BFS(int s)
{
  int sugi,yama;
  for(sugi=1;sugi<=n;sugi++){
    color[sugi] = White;
    d[sugi] = -1;
  }
  color[s] = Gray;
  d[s] = 0;
  Enqueue(s);
  while(head != tail){
    sugi = Dequeue();
    for(yama=1;yama<=n;yama++){
      if(color[yama] == White && G[sugi][yama] == 1){
        color[yama] = Gray;
        d[yama] = d[sugi] + 1;
        Enqueue(yama);
      }
    }
    color[sugi] = Black;
  }
}

Measured memory_bytes: 636
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define rg register
#define ll long long
int n;
double x;
char y[10];
int main()
{
    cin>>n;
    double ans=0;
    for(rg int i=1;i<=n;i++)
    {
        cin>>x>>y;
        if(y[0]=='J') ans+=x;
        else ans+=380000*x;
    }
    printf("%.5f",ans);
    return 0;
}



Measured memory_bytes: 256
#include 	<ext/pb_ds/assoc_container.hpp> 
#include 	<ext/pb_ds/tree_policy.hpp> 
#include 	<iostream>
#include 	<queue>
#include 	<tuple>
#include 	<vector>
#include	<bits/stdc++.h>
#include	<algorithm>
#include 	<cmath>
#include 	<map>
#include 	<string>
#include 	<iomanip> 
#include 	<ctype.h>
#define 	ll  long long int
#define		read(a) long long int a; cin>>a;
#define 	readstr(s) string s; cin>>s;
#define 	readc(c) char c; cin>>c;
#define 	readarr(a,l) long long int a[l]={0}; for(ll i=0;i<l;i++) cin>>a[i];
#define 	loop(i,a,b) for(ll i=a;i<b;i++)
#define 	rloop(i,a,b) for(ll i=a;i>b;i--)
#define 	loopchar() for(char c='a';c<='z';c++)
#define 	printarr(a, n) fori (i, 1, n) cout << a[i] << " "; cout << endl;
#define		printv(v) for (int i: v) cout << i << " "; cout << endl;
#define 	loopitr(vec) for(auto itr=vec.begin();itr!=vec.end();itr++)
#define 	ff first
#define 	ss second
#define 	readmtrx(i,j,a,b) ll arr[a][b]={0};for(ll i=0;i<a;i++)for(ll j=0;j<b;j++) cin>>arr[i][j];
#define 	all(a) a.begin(), a.end()
#define 	yes cout <<"YES"<<endl;
#define 	no cout <<"NO"<<endl;
#define 	sc(x) cout << (#x) << " is " << (x) << endl;
#define 	fast ios_base::sync_with_stdio(false);cin.tie(0);
#define 	pb(p) push_back(p)
#define 	mp make_pair
#define 	fsort(vec) sort(vec.begin(),vec.end())
#define 	rsort(vec) sort(vec.begin(),vec.end(),compare)
#define 	Endl endl
#define 	ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define 	roundoff std::cout << std::setprecision(15)
#define 	inf 9223372036854775807
#define 	infn -9223372036854775807
#define 	pi 3.14159265358979323846
const 		int mod = 1e9+7; 
#define 	intsize ll size = trunc(log10(num)) + 1
#define 	REVERSE(vec) reverse(vec.begin(),vec.end())
using 		namespace __gnu_pbds; 
using 		namespace std;

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

//code start from here 

int main() {
	fast;
	read(a)
	read(b)
	ll arr[a+1]={0};
	loop(j,1,a+1) cin>>arr[j];
	vector<pair<ll,ll>>vec;
	while(b--){
		read(c)
		read(d)
		vec.pb(mp(c,d));
		vec.pb(mp(d,c));
	}
	fsort(vec);
	map<ll,ll>mp1;
	map<ll,ll>mp2;
	loop(j,0,vec.size()) mp2[vec[j].ff]++;
	loop(j,0,vec.size()){
		if(arr[vec[j].ff]>arr[vec[j].ss]){
			mp1[vec[j].ff]++;
		}
	}
	ll sum=0;
	loop(j,1,a+1){
		if(mp2[j]==mp1[j] && mp2[j]!=0) sum++;
		if(mp2[j]==0) sum++;
	}
	cout<<sum<<endl;
	return 0;
}

//ends here 

Measured memory_bytes: 19500
from sys import exit, stderr, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = [int(c) for c in input()]
L = len(N)

if all(N[i] == 9 for i in range(1, L)):
  print(sum(N))
else:
  print((N[0]-1) + 9 * (L-1))


Measured memory_bytes: 3700
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  string s;
  cin >> s;
  if (s[0] == s[2]){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
import java.io.*;

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {

		int N=nextInt();
		long ans=1;
		for(int i=2;i<(int)Math.sqrt(N)+1;i++){
			long tmp = i;
			while(tmp<=N){
				tmp*=i;
			}
			ans=Math.max(ans, tmp/i);
		}

		System.out.println(ans);

	}
	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 22484
from collections import deque
k = int(input())
d = deque()
mat = []
for i in range(k):
    mat.append([])
#mark = [False]*k
dis = [10**18]*k
dis[1] = 0
for i in range(k):
    mat[i].append(((i+1)%k,True))

    if (10*i)%k != i:
        mat[i].append(((10*i)%k,False))

#bfs 1->0
d.append(1)
res = 0
while d:
    left = d.popleft()
    for neighbour,edge in mat[left]:
        distance = edge + dis[left]
        if dis[neighbour] > distance: 
            dis[neighbour] = distance 
            
            if edge == 0:
                d.appendleft(neighbour)
            else:
                d.append(neighbour)
print(dis[0]+1) 



Measured memory_bytes: 35344
package main

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

var (
	BufferSize = 10*10*10*10*10 + 10
)

func scanStr(sc *bufio.Scanner) string {
	if !sc.Scan() {
		panic(nil)
	}

	return sc.Text()
}

func scanInt(sc *bufio.Scanner) int {
	if !sc.Scan() {
		panic(nil)
	}

	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func check() {
	sc := bufio.NewScanner(os.Stdin)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, BufferSize)
	sc.Split(bufio.ScanWords)

	a := scanInt(sc)
	b := scanInt(sc)
	c := scanInt(sc)

	if c > a && c < b {
		fmt.Printf("Yes\n")
		return
	}

	if c < a && c > b {
		fmt.Printf("Yes\n")
		return
	}

	fmt.Printf("No\n")

}

func main() {
	check()
}


Measured memory_bytes: 640
L, R = map(int, input().split())

if R - L >= 2019:
    print(0)
    exit(0)

A = []
for i in range(L, R + 1):
    A.append(i % 2019)

ans = 10e9
for i in range(0, len(A)):
    for j in range(i + 1, len(A)):
        ans = min(ans, (A[i] * A[j]) % 2019)

print(ans)


Measured memory_bytes: 40812
#include<bits/stdc++.h>
#define LL long long
#define il inline

using namespace std;
const int N=1e5+10;
il int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9') {if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') {x=(x<<3)+(x<<1)+(ch^48);ch=getchar();}
    return x*w;
}
int to[N<<1],nt[N<<1],hd[N],dg[N],ddg[N],tot;
void add(int x,int y)
{
    ++tot,to[tot]=y,nt[tot]=hd[x],hd[x]=tot,++dg[x];
    ++tot,to[tot]=x,nt[tot]=hd[y],hd[y]=tot,++dg[y];
}
int n,m,ans,s[N],de[N],sx,sy;
bool v[N];
int st[N],tt,sq[N],ts,kk[N];
void findd()
{
    queue<int> q;
	for(int i=1;i<=n;++i) if(dg[i]==1) q.push(i);
	while(!q.empty())
	{
		int x=q.front();
		q.pop();
		for(int i=hd[x];i;i=nt[i])
		{
			int y=to[i];
			--dg[y];
			if(dg[y]==1) q.push(y);
		}
	}
	for(int i=1;i<=n;++i)
		if(dg[i]>1)
		{
			int la=0,x=i;
			while(1)
			{
				sq[++ts]=x;
				for(int i=hd[x];i;i=nt[i])
				{
					int y=to[i];
					if(dg[y]<=1||y==la) continue;
					la=x,x=y;break;
				}
				if(x==i) break;
			}
			return;
		}
}
void dfs(int x,int ffa,int ss)
{
	if(x==sx) kk[x]=1;
	else if(x==sy) kk[x]=-1;
	s[x]+=de[x]=ss;
	for(int i=hd[x];i;i=nt[i])
	{
		int y=to[i];
		if(y==ffa) continue;
		if(min(x,y)==min(sx,sy)&&max(x,y)==max(sx,sy)) continue;
		dfs(y,x,-ss);
		s[x]+=s[y],kk[x]+=kk[y];
	}
	ans+=abs(s[x]);
}

int main()
{
/////
    n=rd(),m=rd();
    for(int i=1;i<=m;++i) add(rd(),rd());
    if(m==n-1)
    {
		dfs(1,0,1);
		printf("%d\n",s[1]?-1:ans);
    }
    else
    {
		findd();
		sx=sq[1],sy=sq[2];
		dfs(1,0,1);
		if(ts&1)
		{
			if(abs(s[1])&1) puts("-1");
			else
			{
				int sht=-(s[1]/2);
				for(int i=1;i<=n;++i) s[i]=0;
				s[sq[1]]=s[sq[2]]=sht;
				ans=0,dfs(1,0,1);
				printf("%d\n",ans+abs(sht));
			}
		}
		else
		{
			if(s[1]) puts("-1");
			else
			{
				ans=0;
				st[tt=1]=0;
				for(int i=1;i<=n;++i)
				{
					if(!kk[i]) ans+=abs(s[i]);
					else st[++tt]=(~kk[i])?-s[i]:s[i];
				}
				sort(st+1,st+tt+1);
				for(int i=1;i<=tt;++i) ans+=abs(st[i]-st[(tt+1)/2]);
				printf("%d\n",ans);
			}
		}
    }
    return 0;
}

Measured memory_bytes: 11136
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

void solve_dp(int n, const string &s) {
    vector<vector<int>> dp(n+10, vector<int>(n+10, 0));
    for (int i = n-1; i >= 0; --i) {
        for (int j = i; j >= 0; --j) {
            if (s[i] == s[j]) {
                dp[i][j] = min(dp[i+1][j+1]+1, abs(j-i));
            }
        }
    }
    int ret = 0;
    rep(i,n) rep(j,n) chmax(ret,dp[i][j]);
    cout << ret << '\n';
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    string s; cin>>s;
    solve_dp(n,s);

    return 0;
}

Measured memory_bytes: 98432
#include <iostream>

using namespace std;

typedef long long ll;

int main(){
  ll l, r;
  std::cin >> l >> r;

  if( 4038 < r-l ){
    /**
     * r - l の幅が2019以上あるということは、その中に2019の倍数があるということ
     * つまり、i または j を 0にでき、それは答えがゼロになるということが断定できる
     */
    std::cout << 0 << '\n';
    return 0;
  }

  ll ans = 2018;
  for(ll i=l; i<r; i++){
    for(ll j=l+1; j<=r; j++){
      ans = min( ans, (i*j)%2019 );
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://atcoder.jp/contests/arc097/tasks/arc097_c>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    vector<pair<char,int>> ca(2*N);
    map<pair<char,int>,int> mp;
    for(int i = 0; i < 2*N;i++){
        cin >> ca[i].first >> ca[i].second;
        ca[i].second--;
    }
    res = LINF;
    
    vector<vector<ll>> B(N+1,vector<ll>(N+1,0));
    vector<vector<ll>> W(N+1,vector<ll>(N+1,0));
    
    vector<ll> bcnt(N,0),wcnt(N,0);
    for(int i = 0; i < 2*N;i++){
        char c; int a; tie(c,a) = ca[i];
        
        vector<ll> bsum(N+1,0),wsum(N+1,0);
        for(int j = N; j > 0; j--){
            bsum[j-1] = bsum[j] + bcnt[j-1];
            wsum[j-1] = wsum[j] + wcnt[j-1];
        }
        for(int j = N+1; j > 0; j--){
            if(c == 'B') B[a][j-1] = wsum[j-1] + bsum[a+1];
            if(c == 'W') W[a][j-1] = wsum[a+1] + bsum[j-1];
        }
        if(c=='B') bcnt[a]++;
        else wcnt[a]++;
    }

    vector<vector<ll>> dp(N+1,vector<ll>(N+1,LINF));
    dp[0][0] = 0;
    for(int i = 0; i <= N;i++){
        for(int j = 0; j <= N;j++){
            if(i!=N) dp[i+1][j] = min(dp[i+1][j],dp[i][j]+B[i][j]);
            if(j!=N) dp[i][j+1] = min(dp[i][j+1],dp[i][j]+W[j][i]);
        }
    }
    res = dp[N][N];
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    // solve(0);
    cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 94336
n,a,b,c=map(int,input().split())
arr=[input() for _ in range(n)]
ans=[]
for i in range(n):
  if arr[i]=='AB':
    if a==1 and b==1:
      if i==n-1 or arr[i+1]=='AB' or arr[i+1]=='AC':
        a+=1
        b-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        b+=1
        ans.append('B')
    elif a==0 and b==0:
      print('No')
      break
    else:
      if a>=b:
        a-=1
        b+=1
        ans.append('B')
      else:
        a+=1
        b-=1
        ans.append('A')
  elif arr[i]=='AC':
    if a==1 and c==1:
      if i==n-1 or arr[i+1]=='AC' or arr[i+1]=='AB':
        a+=1
        c-=1
        ans.append('A')
      elif arr[i+1]=='BC':
        a-=1
        c+=1
        ans.append('C')
    elif a==0 and c==0:
      print('No')
      break
    else:
      if a>=c:
        a-=1
        c+=1
        ans.append('C')
      else:
        a+=1
        c-=1
        ans.append('A')
  elif arr[i]=='BC':
    if b==1 and c==1:
      if i==n-1 or arr[i+1]=='BC' or arr[i+1]=='AB':
        b+=1
        c-=1
        ans.append('B')
      elif arr[i+1]=='AC':
        b-=1
        c+=1
        ans.append('C')
    elif b==0 and c==0:
      print('No')
      break
    else:
      if b>=c:
        b-=1
        c+=1
        ans.append('C')
      else:
        b+=1
        c-=1
        ans.append('B')
else:
  print('Yes')
  for i in range(n):
    print(ans[i])

Measured memory_bytes: 17116
n, l, m = map(int, input().split())
matrixA = [[0] * (l) for i in range(n)]
matrixB = [[0] * (m) for i in range(l)]
matrix = [[0] * (m) for i in range(n)]

for i in range(0, n):
    listnum = input().split()
    for j in range (0, l):
        matrixA[i][j] = listnum[j]

for i in range(0, l):
    listnum = input().split()
    for j in range (0, m):
        matrixB[i][j] = listnum[j]

for i in range(0,n):
    for j in range(0,m):
        s = 0
        for k in range(0,l):
            s = s + int(matrixA[i][k])*int(matrixB[k][j])
            matrix[i][j] = str(s)

for i in range(0, n):
    print(" ".join(matrix[i]))



Measured memory_bytes: 7392
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"
using namespace std;

#define int long long

#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,x,...) x
#define REP1(i, s, cond, cal) for (signed i = signed(s); i cond; i cal)
#define REP2(i, s, n) REP1(i, s, < signed(n), ++)
#define REP3(i, n) REP2(i, 0, n)
#define rep(...) CHOOSE((__VA_ARGS__,REP1,REP2,REP3))(__VA_ARGS__)
#define rrep(i, s) rep(i, s, >= 0, --)

#define all(c) begin(c), end(c)

template<typename T, typename U>bool maxup(T& a, U&& b) { if (a < b) { a = b; return true; }; }
template<typename T, typename U>bool minup(T& a, U&& b) { if (a > b) { a = b; return true; }; }

#define X first
#define Y second

using VV = vector<vector<int>>;
using V = vector<int>;
using P = pair<int, int>;
using IP = pair<int, P>;

template<typename T>
inline void input(vector<T>& v) { for (auto& x : v) cin >> x; }

signed main() {
	int n, k, x, y; cin >> n >> k >> x >> y;
	cout << min(k, n) * x + max(0ll, n - k) * y << endl;
	system("pause");
}

Measured memory_bytes: 504
n, m = map(int, input().split())
a = [list(map(int, input().split())) for i in range(m)]

for i in range(m):
	a[i].append(i)
b = sorted(a)

count = 1

for i in range(m):
	temp = b[i][2]
	b[i].pop(2)
	b[i].insert(0, temp)
	b[i].append(count)
	count += 1
	if i == m - 1:
		continue
	if b[i][1] != b[i + 1][0]:
		count = 1
b.sort()
for i in range(m):
	print(str(b[i][1]).zfill(6) + str(b[i][-1]).zfill(6))


Measured memory_bytes: 36164
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}

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

int main (){
	int n; cin >> n;
	vector<ll> v(n);
	cinv(n,v);
	sort(all(v));
	int count = 0;
	v.push_back(0);
	int before = 0;
	for(int i = 1; i < n+1; i++){
		if (v[i]!=v[i-1]){
			if (v[i-1] > i-before){
				count += i-before;
			}else if (v[i-1] < i-before){
				count += i-before - v[i-1];
			}
			before = i;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 1792
//Pck2018 Yosen 8 Taxi
//20181023
//F_Naru
#include<iostream>
#include<set>
#include<algorithm>
using namespace std;

int main(){
  multiset<int>max;//料金の最大値を保存
  int N,M,c;
  cin >> N;
  for(int i=1; i<=N; i++){
    cin >> M;
    for(int j=1; j<=M; j++){
      cin >> c;
      max.insert(c);
      if(max.size() > i) max.erase(max.begin());//小さい要素の削除
    }
  }
  unsigned long long ans=0;
  for(auto it=max.begin(); it!=max.end(); it++)ans += *it;//要素の合計
  cout << ans << endl;
}



Measured memory_bytes: 17164
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <string>

using namespace std;

#define LL long long

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

int h, w, n;
int main() {
	cin >> h >> w >> n;
	int ah = (n + h - 1) / h;
	int aw = (n + w - 1) / w;
	cout << min(ah, aw) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <ctime>
#include <cassert>
#include <unordered_map>
#include <fstream>
#include <random>
#include <cstring>
#include <bitset>
#include <functional>
#include <tuple>
#include <complex>

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef unsigned int uint;

mt19937 rnd(random_device{}());

const int MAXN = 220000;

vector<int> g[MAXN];
int x[MAXN][2];
int dead[MAXN];

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

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

    int n, m;
    cin >> n >> m;
    string str;
    cin >> str;
    vector<int> type(n);
    for (int i = 0; i < n; ++i) {
        type[i] = str[i] == 'A';
    }

    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    set<pair<int, int>> s[2];
    for (int i = 0; i < n; ++i) {
        for (int u : g[i]) {
            ++x[i][type[u]];
        }
        s[0].insert({x[i][0], i});
        s[1].insert({x[i][1], i});
    }

    for (int i = 0; i < n; ++i) {
        int v, cnt;
        tie(cnt, v) = *s[0].begin();
        if (cnt == 0) {
            dead[v] = 1;
            s[0].erase({x[v][0], v});
            s[1].erase({x[v][1], v});

            for (int u : g[v]) {
                if (dead[u]) {
                    continue;
                }
                s[type[v]].erase({x[u][type[v]], u});
                --x[u][type[v]];
                s[type[v]].insert({x[u][type[v]], u});
            }
            continue;
        }
        tie(cnt, v) = *s[1].begin();
        if (cnt == 0) {
            dead[v] = 1;
            s[0].erase({x[v][0], v});
            s[1].erase({x[v][1], v});

            for (int u : g[v]) {
                if (dead[u]) {
                    continue;
                }
                s[type[v]].erase({x[u][type[v]], u});
                --x[u][type[v]];
                s[type[v]].insert({x[u][type[v]], u});
            }
            continue;
        }
        break;
    }

    cout << (sz(s[0]) > 0 ? "Yes\n" : "No\n");
}

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

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    int count =0;
    for (int i=a;i<=b;i++){
        if(c%i==0){
            count ++;
        }
    }
    cout << count << endl;
}


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


using namespace std;

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

    vector<int> cost(N);
    vector<vector<int>> books(N);
    for (int i = 0; i < N; i++) {
        cin >> cost[i];
        for (int j = 0; j < M; j++) {
            int a;
            cin >> a;
            books[i].push_back(a);
        }
    }

    bool viable = false;
    int ans = INT_MAX;
    for (int i = 0; i < (1 << N); i++) {
        int spend = 0;
        vector<int> alg(M, 0);
        for (int j = 0; j < N; j++) {
            if (!(i & (1 << j)))
                continue;

            // chosen book j
            for (int k = 0; k < M; k++) {
                alg[k] += books[j][k];
            }
            spend += cost[j];
        }
        bool sat = true;
        for (int j = 0; j < M; j++) {
            if (alg[j] < X) {
                sat = false;
                break;
            }
        }
        if (sat) {
            ans = min(ans, spend);
        }
        viable |= sat;
    }
    if (viable) {
        cout << ans << endl;
    } else {
        cout << -1 << endl;
    }
}


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

constexpr int64_t inf = 1e18;
const vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};

void dijkstra(vector<vector<vector<int64_t>>> &d, const vector<string> &c, int x, int y, int k) {
  const int h = d.size(), w = d.at(0).size();
  auto in_grid = [=](int i, int j) {
    return 0 <= i and i < h and 0 <= j and j < w and c.at(i).at(j) == '.';
  };
  priority_queue<tuple<int64_t, int, int, int>> q;
  for (int i = 0; i < 4; i++) {
    q.emplace(0, x, y, i);
  }
  while (!q.empty()) {
    auto t = q.top();
    q.pop();
    int64_t d0 = -get<0>(t);
    int x0 = get<1>(t), y0 = get<2>(t), dir = get<3>(t);
    if (d0 >= d.at(x0).at(y0).at(dir)) continue;
    d.at(x0).at(y0).at(dir) = d0;
    for (int i = 0; i < 4; i++) {
      int64_t d_next = (d0 + k - 1) / k * k;
      if (d.at(x0).at(y0).at(i) <= d_next) continue;
      q.emplace(-d_next, x0, y0, i);
    }
    int x_next = x0 + dx.at(dir), y_next = y0 + dy.at(dir);
    if (not in_grid(x_next, y_next)) continue;
    if (d.at(x_next).at(y_next).at(dir) <= d0 + 1) continue;
    q.emplace(-(d0 + 1), x_next, y_next, dir);
  }
}

int main() {
  int h, w, k, x1, y1, x2, y2;
  cin >> h >> w >> k >> x1 >> y1 >> x2 >> y2;
  x1--;
  y1--;
  x2--;
  y2--;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c.at(i);
  }
  vector d(h, vector(w, vector(4, inf)));
  dijkstra(d, c, x1, y1, k);
  int64_t ans = *min_element(d.at(x2).at(y2).begin(), d.at(x2).at(y2).end());
  if (ans == inf) {
    cout << -1 << endl;
  } else {
    cout << (ans + k - 1) / k << endl;
  }
}


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

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

	int fn = 0, i = N;
	
	while (i > 0) {
		fn += i % 10;
		i /= 10;
	}

	cout << ((N % fn) == 0 ? "Yes" : "No") << endl;
	return 0;
}

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

using namespace std;

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

    int a,b,c,d;
    cin>>a>>b>>c;
    d = a*b;
    if(c>d)
    {
        cout<<d<<endl;
    }
    else if(d>c)
    {
        cout<<c<<endl;
    }
    else if(d==c)
    {
        cout<<c<<endl;
    }
    return 0;
}


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

int main() {
	int n; cin >> n;
	long long int l1=2, l2=1, ans=1;

	for (int i = 2; i <= n; i++) {
		ans = l1 + l2;
		l1 = l2;
		l2 = ans;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256