akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
    //FILE *inp = freopen("in.txt", "r", stdin);
    int n;
    cin>>n;
    long long minUpto, maxProfit , firstRate, secondRate, rate;
    cin>>firstRate>>secondRate;
    maxProfit = secondRate-firstRate;
    minUpto = min(firstRate, secondRate);
    for(int i = 2; i < n; ++i){
        cin>>rate;
        maxProfit = max(maxProfit, rate-minUpto);
        minUpto = min(rate, minUpto);
    }
    cout << maxProfit << endl;
    //fclose(inp);
    return 0;
}

Measured memory_bytes: 3104
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <stack>
#include <queue>
#include <vector>

static const int IINF = 1 << 30;
static const long long LINF = 1LL << 60;
static const long long MOD = 1.0e+9 + 7;

template <typename T> std::vector<T> vectors(std::size_t n, T val) {
  return std::vector<T>(n, val);
}

template <typename T, typename... Args>
auto vectors(std::size_t n, Args... args) {
  return std::vector<decltype(vectors<T>(args...))>(n, vectors<T>(args...));
}

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

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

template <class T> inline void chadd(T &a, const T &b) {
  a += b, a %= MOD;
  // TODO minus case
}

template <class T>
std::ostream &operator<<(std::ostream &s, const std::vector<T> &v) {
  if (v.empty())
    return s;
  s << *v.begin();
  for (auto iter = v.begin() + 1; iter != v.end(); ++iter)
    if (std::is_fundamental<T>::value)
      s << " " << *iter;
    else
      s << std::endl << *iter;
  return s;
}

int main() {
  int N, M;
  std::cin >> N >> M;
  std::vector<int> p(M);
  std::vector<std::string> S(M);
  for (int j = 0; j < M; ++j) {
    int p_;
    std::string S_;
    std::cin >> p_ >> S_;
    p[j] = p_ - 1;
    S[j] = S_;
  }
  // std::cout << p << std::endl;
  // std::cout << S << std::endl;

  std::vector<std::vector<std::string>> res(N);

  for (int j = 0; j < M; ++j) {
    res[p[j]].push_back(S[j]);
  }

  int num_ac = 0;
  int pen = 0;
  for (int i = 0; i < N; ++i) {
    // AC or Not
    bool ac = false;
    for (auto v : res[i]) {
      if (v == "AC")
        ac = true;
    }
    if (not ac)
      continue;
    ++num_ac;

    for (auto v : res[i]) {
      if (v == "AC")
        break;
      ++pen;
    }
  }
  std::cout << num_ac << " " << pen << std::endl;

  return 0;
}


Measured memory_bytes: 11520
#include <iostream>
#include <map>
#include <queue>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;
#pragma warning (disable: 4996)

int N, U, V, A[1 << 18], B[1 << 18], dist[1 << 18], dist2[1 << 18];
vector<int> X[1 << 18];
bool used[1 << 18];

void dfs(int pos, int dep) {
	used[pos] = true;
	dist[pos] = dep;

	int maxv = dist[pos];
	for (int i : X[pos]) {
		if (used[i] == true) continue;
		dfs(i, dep + 1);
	}
}

void dfs2(int pos, int dep) {
	used[pos] = true;
	dist2[pos] = dep;

	int maxv = dist2[pos];
	for (int i : X[pos]) {
		if (used[i] == true) continue;
		dfs2(i, dep + 1);
	}
}

int main() {
	cin >> N >> U >> V;
	for (int i = 1; i <= N - 1; i++) {
		cin >> A[i] >> B[i];
		X[A[i]].push_back(B[i]);
		X[B[i]].push_back(A[i]);
	}
	dfs(V, 0);
	for (int i = 1; i <= N; i++) used[i] = false;
	dfs2(U, 0);

	int D = 0;
	for (int i = 1; i <= N; i++) {
		if (dist2[i] < dist[i]) D = max(D, dist[i]);
	}

	int p1 = 0, p2 = dist[U];
	if (p2 == D) p2--; else p2++;
	if (p1 == p2) {
		cout << "0" << endl;
		return 0;
	}

	for (int t = 1; t <= 10000000; t++) {
		// 青木君
		if (p1 == D) p1--; else p1++;
		if (p1 == p2) { cout << t << endl; return 0; }

		// 高橋君
		if (p2 == D) p2--; else p2++;
		if (p1 == p2) { cout << t << endl; return 0; }
	}
	cout << "-1" << endl;
	return 0;
}

Measured memory_bytes: 16000
n = int(input())
d = {'M': 0, 'A': 0, 'R': 0, 'C': 0, 'H': 0, }
t = "MARCH"
for i in range(n):
    s = input()
    if s[0] in d:
        d[s[0]] += 1

ans = 0
for bits in range(1<<5):
    bits_list = [i for i in range(5) if (bits >> i) & 1 == 1]
    if len(bits_list) == 3:
        ans += d[t[bits_list[0]]] * d[t[bits_list[1]]] * d[t[bits_list[2]]]

print(ans)


Measured memory_bytes: 3188
#include<iostream>
#include<queue>
#include<vector>
#include<functional>
#include<algorithm>

using namespace std;

typedef long long ll;

ll N, a[100000 * 3 + 10];
ll bleft[100000 + 1 + 10], bright[100000 + 1 + 10];

int main() {
	cin >> N;
	for (int i = 0; i < 3 * N; i++)cin >> a[i];

	priority_queue <ll, vector <ll>, greater<ll>> pq1;
	for (int i = 0; i < N; i++)pq1.push(a[i]), bleft[0] += a[i];
	for (int i = N; i < 2 * N; i++) {
		bleft[i + 1 - N] = max(bleft[i - N], bleft[i - N] - pq1.top() + a[i]);
		if (pq1.top() < a[i])pq1.pop(), pq1.push(a[i]);
	}

	priority_queue<ll> pq2;
	for (int i = 2 * N; i < 3 * N; i++)pq2.push(a[i]), bright[N] += a[i];
	for (int i = 2 * N - 1; i >= N; i--) {
		bright[i - N] = min(bright[i + 1 - N], bright[i + 1 - N] - pq2.top() + a[i]);
		if (pq2.top() > a[i])pq2.pop(), pq2.push(a[i]);
	}
	ll ans = -114514919810893;
	for (int i = 0; i <= N; i++) {
		ans = max(ans, bleft[i] - bright[i]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 5876
n = int(input())
p = list(map(int, input().split()))
cnt = 0
for i in range(2, n):
    p_n = p[i-2:i+1]
    p_n_sort = sorted(p_n)
    if p_n_sort[1] == p_n[1]:
        cnt += 1
print(cnt)

Measured memory_bytes: 3060
N = int(input())
A, B = map(int, input().split())
P = list(map(int, input().split()))

count = [0, 0, 0]
for p in P:
	if p <= A:
		count[0] += 1
	elif p <= B:
		count[1] += 1
	else:
		count[2] += 1
print(min(count))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	int a,b;
	vector<int> p(n),q(n),memo(n);
	rep(i,n){
	    memo[i]=i+1;
	    cin>>p[i];
	}
	rep(i,n)cin>>q[i];
	int cnt=1;
	do{
	    bool b_a=true,b_b=true;
	    rep(i,n){
	        if(p[i]!=memo[i])b_a=false;
	        if(q[i]!=memo[i])b_b=false;
	    }
	    if(b_a)a=cnt;
	    if(b_b)b=cnt;
	    cnt++;
	}while(next_permutation(memo.begin(),memo.end()));
	cout<<abs(a-b)<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int s = sc.nextInt();
    int w = sc.nextInt();
    if(s>w){
      System.out.println("safe");
    }
      else{
        System.out.println("unsafe");
      }
  }
}

Measured memory_bytes: 35772
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

void dfs(vector<vector<llong> >&Map, vector<vector<bool> > &seen, llong x, llong y){
    llong w,h;
    w = Map[0].size();
    h = Map.size();
    if(x<0 || x>=w || y<0 || y>=h){
        return;
    }
    if(Map[y][x]==0){
        return;
    }
    if(seen[y][x]){
        return;
    }
    seen[y][x] = true;
    for(int dy=-1; dy<2; dy++){
        for(int dx=-1; dx<2; dx++){
            dfs(Map, seen, x+dx, y+dy);
        }
    }
    return;
}

int main(){
    llong w,h;
    while(1){
        llong ans=0;

        cin >> w >> h;
        if(w==0 && h==0){
            break;
        }
        vector<vector<llong> > Map(h);
        vector<vector<bool> > seen(h);
        for(int i=0; i<h; i++){
            Map[i].assign(w, 0);
            seen[i].assign(w, false);
            for(int j=0; j<w; j++){
                cin >> Map[i][j];
            }
        }
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(seen[i][j] || (Map[i][j]==0)){
                    continue;
                } 
                dfs(Map, seen, j, i);
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 3308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cstring>
#include <cmath>
#include <queue>
#include <map>
#include <set>
using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define FOR(i,s,n) for(int i=s; i<n; i++)
#define ALL(x) x.begin(), x.end()
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;

int dist[101][101][21];
int cost[101][101];

const int INF = 1e7;

int main() {
	int _n, _m, _c, _s, _g;
	while(cin >> _n >> _m >> _c >> _s >> _g, _n) {
		rep(i,101) rep(j,101) rep(k,21) dist[i][j][k] = INF;
		rep(i,101) rep(j,101) cost[i][j] = INF;
		rep(i, _m) {
			int x, y, d, c;
			cin >> x >> y >> d >> c;
			dist[x][y][c] = min(dist[x][y][c], d);
			dist[y][x][c] = min(dist[y][x][c], d);
		}
		vector<int> p(_c);
		vector< vector<int> > q(_c), r(_c);
		rep(i,_c) cin >> p[i];
		rep(i,_c) {
			q[i].resize(p[i]+1);
			q[i][0] = 0;
			for(int j=1; j<p[i]; j++) {
				cin >> q[i][j];
			}
			q[i][p[i]] = INF;
			r[i].resize(p[i]+1);
			rep(j, p[i]) {
				cin >> r[i][j];
			}
		}
		rep(c,_c) rep(k,_n) rep(i,_n) rep(j,_n)
			dist[i+1][j+1][c+1] = min( dist[i+1][j+1][c+1], dist[i+1][k+1][c+1] + dist[k+1][j+1][c+1] );
		rep(c,_c) rep(i,_n) rep(j,_n) {
			int co = 0;
			int d = 0, pos = 0;
			while(d+q[c][pos+1] < dist[i+1][j+1][c+1]) {
				co += r[c][pos] * (q[c][pos+1]-q[c][pos]);
				pos++;
			}
			co += r[c][pos] * (dist[i+1][j+1][c+1]-q[c][pos]);
			cost[i+1][j+1] = min(cost[i+1][j+1], co);
		}
		rep(k,_n) rep(i,_n) rep(j,_n)
			cost[i+1][j+1] = min( cost[i+1][j+1], cost[i+1][k+1] + cost[k+1][j+1] );

		if( cost[_s][_g] >= INF ) {
			cout << -1 << endl;
		} else {
			cout << cost[_s][_g] << endl;
		}

	}
	return 0;
}

Measured memory_bytes: 2084
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>

int main(void) {
	int N, M;
	int A[10000];
	int i, sum=0;

	scanf("%d", &N);
	scanf("%d", &M);

	for (i = 0; i < M; i++) {
		scanf("%d", &A[i]);
		sum += A[i];
	}

	if (N - sum >= 0) {
		printf("%d", N - sum);
	}
	else  {
		printf("%d", -1);
	}
	return 0;
}

Measured memory_bytes: 1748
#include <cstdio>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#include<fstream>

#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)

using namespace std;


int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
       
    int i,j,k,p=1,q=1;
    long n,m,tmp;
    string s[200000];
    string str;
    ll sum=0;
    int strr[200005];
    vector<int> a(0);//初期の配列のサイズを0にセット
    cin>>n;
    rep(i,n)    {
        cin >> k;
        a.push_back(k);
    }
    sort(a.begin(),a.end());
    rep(b,n)rep(c,b){
        int ab=a[c]+a[b];
        int r=lower_bound(a.begin(),a.end(),ab)-a.begin();
        int l=b+1;
        sum+=max(0,r-l);
    }
    //outputfile<<str;
   // outputfile.close();
    cout<<sum;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator <<(std::ostream& os, std::pair<T, S> p)
{
  return os << "(" << p.first << " " << p.second << ")";
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  //os << v[0]; for (ll i = 1; i < (ll)v.size(); i++){ os << " " << v[i]; }
  return os;
}

template<class T, class S> std::ostream& operator <<(std::ostream& os, std::map< T, S > m)
{
  ll i = 0; for (auto p : m){ os << " [" << i << "]" << p.first << "->" << p.second; i++;}
  return os;
}

template<class T> std::ostream& operator <<(std::ostream& os, std::vector< std::vector<T> > vv)
{
  for (auto& vec : vv){ os << vec; }
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H&& head){ std::cout << head << std::endl; }
template<typename H, typename... T> void print(H&& head, T&&... tail){
  std::cout << head << " ", print(std::forward<T>(tail)...);
}

// GCD, LCM
ll gcd(ll a, ll b) {
  while (b != 0) { a %= b; std::swap(a, b); }
  return a;
}
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

// FAIL
void fail(){ print(-1); std::exit(0); }
//void fail(){ print("No"); std::exit(0); }

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

  ll N;
  std::cin >> N;
  std::vector< ll > va(N, 0LL);
  for (ll i = 0; i < N; i++) {
    std::cin >> va[i];
  }

  std::vector< ll > vmin(N, 0LL);
  vmin[0] = va[0];
  for (ll i = 1; i < N; i++) {
    vmin[i] = std::min(vmin[i-1], va[i]);
  }

  ll cnt = 1LL;
  for (ll i = 1; i < N; i++) {
    if (vmin[i-1] >= va[i]) {
      cnt++;
    }
  }

  print(cnt);
  return 0;
}


Measured memory_bytes: 3456
#include<iostream>    
#include<cstdio>  
#include<stdio.h>  
#include<cstring>    
#include<cstdio>    
#include<climits>    
#include<cmath>   
#include<vector>  
#include <bitset>  
#include<algorithm>    
#include <queue>  
#include<map> 
#define inf 9999999; 
using namespace std;

int a[100005];
int n,i,sum;
bool flag[100005];
bool check(int x)
{
	if(flag[x]!=true)
	{
		sum++;
		flag[x]=true;
		if(x==2)
			return true;
		else
			check(a[x]);
	}
	else
	{
		return true;
	}
	return true;

}
int main()
{
	cin>>n;
	memset(flag,false,sizeof(flag));
	for(i=1;i<=n;i++)
	{
		cin>>a[i];
	}
	sum=0;
	check(1);
	if(flag[2]==true)
		cout<<sum-1<<endl;
	else
		cout<<-1<<endl;
}

Measured memory_bytes: 2304
#include <iostream>
#include <vector>
#include <numeric>

std::vector<int> accept_costs(const std::size_t n_costs)
{
  std::vector<int> result(n_costs);
  for (std::size_t i=0; i<n_costs; ++i) {
    std::cin >> result[i];
  }
  return result;
}

int main()
{
  int n_days;
  int n_hws;
  
  std::cin >> n_days >> n_hws;
  const std::vector<int> costs = accept_costs(n_hws);
  
  const int remains = n_days - std::accumulate(costs.begin(), costs.end(), 0);
  const int result = (remains < 0) ? -1 : remains;
  std::cout << result << std::endl;
}


Measured memory_bytes: 3232
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <valarray>
#include <vector>
using namespace std;

using ll = long long;
using ld = long double;
const int INF = 1e9;
const double EPS = 1e9;
const ll MOD = 1e9 + 7;

int main()
{
  long long N;
  scanf("%lld", &N);
  ll ans = 0;
  ll t = 1;
  for (ll i = 1; i <= 30; ++i)
  {
    t *= 5;
    if (t > 1e18)
      break;
    ans += N / t / 2;
  }
  if (N % 2 == 0)
    cout << ans << endl;
  else
    cout << 0 << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int h,w;
    while(cin>>h>>w,h!=0||w!=0){
        for(int i=0;i<h;i++){
            for(int j=0;j<w;j++){
                if((j%2+i%2)%2)cout<<".";
                else cout<<"#";
            }
            cout<<endl;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 3136
#include<iostream>
#include<string.h>
using namespace std;
int main(){
	char s[205], p[105];
	char a[10000];
	cin >> s;
	cin >> p;
	strcat(a, s);
	strcat(a, s);
	if (strstr(a, p) != NULL){
		cout << "Yes" << endl;
	}
	else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3096
package main

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

var si = bufio.NewScanner(os.Stdin)

func readInt() int {
        si.Scan()
        r, _ := strconv.Atoi(si.Text())
        return r
}

func powmod(a, N, m int) int {
        n := uint(N)
        r := 1
        for n != 0 {
                if n&1 != 0 {
                        r = r * a % m
                }
                n >>= 1
                a = a * a % m
        }
        return r
}
func factorialmod(n, m int) int {
        r := 1
        for i := 2; i <= n; i++ {
                r = r * i % m
        }
        return r
}
func main() {
        MOD := 1000000007
        si.Split(bufio.ScanWords)
        X, Y := readInt(), readInt()

        ret := 0
        for i := 0; i <= X/2; i++ {
                n := X - i*2
                if Y != n*2+i {
                        continue
                }
                c := n + i
                f := factorialmod(c, MOD)
                inv := make([]int, c+1)
                inv[c] = powmod(f, MOD-2, MOD)
                for j := c; j > 0; j-- {
                        inv[j-1] = inv[j] * j % MOD
                }
                ret = f * inv[i] % MOD * inv[n] % MOD
                break
        }
        fmt.Println(ret)

}

Measured memory_bytes: 6528
<?php
 
define('EPS', 1e-8);
while (true) {
    $a = fscanf(STDIN, '%f %f %f %f %f %f %f %f');
    if (feof(STDIN)) {
        break;
    }
    $line = array();
    $line[] = $a[1] - $a[3] === 0.0 ? INF : ($a[0] - $a[2]) / ($a[1] - $a[3]);
    $line[] = $a[5] - $a[7] === 0.0 ? INF : ($a[4] - $a[6]) / ($a[5] - $a[7]);
    if (max($line) === INF && min($line) === 0 || abs($line[0] * $line[1] + 1.0) < EPS) {
        echo 'YES';
    } else {
        echo 'NO';
    }
    echo PHP_EOL;
}

Measured memory_bytes: 6636
#include <bits/stdc++.h>
 
using namespace std;
#define int long long
const int MAX = 2001;
const int MOD = 1000000007;
 
 


 
signed main(){
    int a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b));

    return 0;
}

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

int N;
ll A[100010];

ll gcd(ll n,ll m){
	if(n%m==0) return m;
	else return gcd(m,n%m);
}

int main(){
	cin >> N;
	ll t = 1;
	for(int i=0;i<N;i++){
		cin >> A[i];
//		t *= A[i]/gcd(t,A[i]);
	}
	//cout << t << endl;*/
	ll ans = 0;
	for(int i=0;i<N;i++) ans += A[i]-1;
	cout << ans << endl;
}

Measured memory_bytes: 256
//             بسم الثالوث الاقدس
#include<iostream>	
#include<algorithm>
#include<cstdio>
#include<sstream>
#include<cmath>
#include<climits>
#include<string>
#include<iomanip>
#include<vector>
#include<stack>
#include<map>
#include<queue>
#include<set>
#include<fstream>
using namespace std;
//********************************************************************************************
//******************************************************************************************** 
/*
jesus help me.......
*/
typedef long long lld;
typedef char c;



/*
jesus help me.......
jesus help me.......
jesus help me.......
*/



int binarySearch(int arr[], int l, int r, int x)
{
	while (l <= r)
	{
		int m = l + (r - l) / 2;

		if (arr[m] == x)
			return m;

		if (arr[m] < x)
			l = m + 1;

		else
			r = m - 1;
	}

	return -1;

}





bool sortbysec(const pair<string, int> &a, const pair<string, int> &b)
{
	
	return (a.second > b.second);
}







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


	//freopen("keys.in", "r", stdin);

	int a, b;
	cin >> a >> b;
	int c = 0, n = b;
	while (b)
	{
		b /= 10;
		c++;

	}
	while (a)
	{
		n += ((a % 10)*pow(10, c));
		c++;
		a /= 10;
	}
	int x = sqrt(n);
	if (x*x == n)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

	///system("pause");


	return 0;
}
/*
jesus help me.......
jesus help me.......
jesus help me.......
*/

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 200000;
const int INF = 1<<30;

int n, a[N], ans = 0; 
double mid, _ans = INF;

int main()
{
	scanf( "%d", &n );
	for( int i = 1; i <= n; i ++ )
		scanf( "%d", &a[i] );
	
	sort( a+1, a+1+n );
	double mid = double( a[n] ) / 2;
	for( int i = 1; i <= n; i ++ )
		if( fabs( mid - a[i] ) < _ans ) 
			ans = i, _ans = fabs( mid - a[i] );
	if( ans == n ) ans = n-1;
	
//	for( int i = 1; i <= n; i ++ )
//		printf( "%f\n", fabs( mid - a[i]) );
	
	printf( "%d %d\n", a[n], a[ans] );
		
	return 0;
}

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

using namespace std;

using ll = long long int;
using ld = long double;

using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vb>;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : x; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

using edge = struct{
	int to;
	ll cost;
};
vector<edge> tree[100030];
ll depth[100030];

void dfs(int v, int p, ll d) {
	depth[v] = d;
	for (auto &e : tree[v]) {
		if (e.to == p) {
			continue;
		}

		dfs(e.to, v, d + e.cost);
	}
}

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

	int n;
	cin >> n;

	for (int i = 0; i < n - 1; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		tree[a].push_back({ b, c });
		tree[b].push_back({ a, c });
	}

	int q, k;
	cin >> q >> k;
	k--;

	dfs(k, -1, 0);
	for (int i = 0; i < q; i++) {
		int x, y;
		cin >> x >> y;
		x--; y--;

		cout << depth[x] + depth[y] << endl;
	}
	return 0;
}

Measured memory_bytes: 14336
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define fi first
#define se second
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>
using namespace std;

ll n,a[200010],b;

int main()
{

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

    cin >> n;
    for(ll i=1; i<n; i++) cin >> b , a[b]++;
    for(ll i=1; i<=n; i++) cout << a[i] << "\n";

    return 0;
}


Measured memory_bytes: 5264
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array
 
const int N = 1e6 + 5;
int cnt[N];
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int n;
    cin >> n;
    vector<int> a(n);
    memset(cnt, 0, sizeof(cnt));
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        cnt[a[i]]++;
    }
    if (cnt[1] == 1) {
        cout << 1 << '\n';
        return 0;
    }
    if (cnt[1] > 1) {
        cout << 0 << '\n';
        return 0;
    }
    int ans = 0;
    for (int i = 0; i < n; i++) {
        bool ok = true;
        if (cnt[a[i]] > 1) ok = false;
        else {
            for (int j = 2; j * j <= a[i]; j++) {
                if (a[i] % j == 0 && (cnt[j] != 0 || cnt[a[i] / j] != 0)) {
                    ok = false;
                    break;
                }
            }
        }
        ans += ok;
    }
    cout << ans << '\n';
}

Measured memory_bytes: 7936
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e6 + 10;
int fact[MAXN];
bool used[MAXN];

int gcd(int a, int b) {
  if (a > b) swap(a, b);
  if (a == 0) return b;
  return gcd(b%a, a);
}




int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  for (int i = 2; i < MAXN; i++) {
    if (fact[i] != 0) continue;
    for (int j = i+i; j < MAXN; j += i) {
      fact[j] = i;
    }
  }
  int n; cin >> n;
  int ret = 0;
  bool pairwise = true;
  for (int i = 0; i < n; i++) {
    int val; cin >> val;
    ret = gcd(ret, val);
    if (!pairwise) continue;
    set<int> ps;
    while (val > 1 && fact[val]) {
      ps.insert(fact[val]);
      val /= fact[val];
    }
    if (val > 1) ps.insert(val);
    for (int p : ps) {
      if (used[p]) pairwise = false;
      else used[p] = true;
    }
  }
  if (ret != 1) cout << "not coprime\n";
  else if (pairwise) cout << "pairwise coprime\n";
  else cout << "setwise coprime\n";







/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 8016
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstring>
#include<string>
using namespace std;
int f[105][5][2],k;
char str[105];
int Calc(int now,int sumz,int flag){
	if(!now){
		if(sumz==k)return 1;
		return 0;
	}
	if(sumz>k)return 0;
	if(~f[now][sumz][flag])return f[now][sumz][flag];
	f[now][sumz][flag]=0;
	int &s=f[now][sumz][flag];
	int h=(flag?str[now]-'0':9);
	for(int i=0;i<=h;i++){
		s+=Calc(now-1,sumz+(i?1:0),flag&&i==h);
	}
	return s;
}
int main(){
	memset(f,-1,sizeof(f));
	scanf("%s%d",str+1,&k);
	int l=strlen(str+1);
	reverse(str+1,str+l+1);
	printf("%d\n",Calc(l,0,1));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); i++)
#define rep(i, n) rep2(i, 0, n)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}


int main() {
  ll n, x; cin >> n >> x;
  if (x == 1 || x == 2*n-1) {
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  if (n == 2) {
    cout << 3 << endl;
    cout << 2 << endl;
    cout << 1 << endl;
    return 0;
  }

  if (x == 2) {
    rep(i, n-3) cout << (i+5) << endl;
    cout << 3 << endl;
    cout << 2 << endl;
    cout << 1 << endl;
    cout << 4 << endl;
    rep(i, n-2) cout << (n+2+i) << endl;
    return 0;
  }

  V ans;
  rep2(i, 1, 2*n) if (i < x-2 || i > x+1) ans.push_back(i);
  rep(i, n-3) cout << ans[i] << endl;
  cout << (x-2) << endl;
  cout << (x) << endl;
  cout << (x+1) << endl;
  cout << (x-1) << endl;
  rep(i, n-2) cout << ans[n-3+i] << endl;
  return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/14  Problem: 064_arc_a / Link: https://abc048.contest.atcoder.jp/tasks/arc064_a?lang=en  ----- */
/* ------問題------

N 個の箱が横一列に並んでいます。 最初、左から i 番目の箱には ai 個のキャンディが入っています。
すぬけ君は次の操作を好きな回数だけ行うことができます。
キャンディが 1 個以上入っている箱をひとつ選び、その箱のキャンディを 1 個食べる。
すぬけ君の目標は次の通りです。
どの隣り合う 2 つの箱を見ても、それらの箱に入っているキャンディの個数の総和が x 以下である。
目標を達成するために必要な操作回数の最小値を求めてください。

-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	int X;

	cin >> N>>X;
	VL a(N);
	FOR(i, 0, N) {
		cin >> a[i];
	}
	FOR(i, 0, N - 1) {
		LL sum = a[i] + a[i + 1];
		if (sum >= X) {
			LL ne = sum - X;
			ans += ne;
			if (ne > a[i + 1]) {
				a[i+1] = 0;
			}
			else a[i + 1] -= ne;
		}
	}
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 1024
n  = int(input())
d,x = map(int, input().split())
l = list()
for i in range(n):
    l.append(int(input()))
total = 0
for i in range(n):
    j = 0
    while True:
        if l[i] *j + 1 <= d:
            total += 1
            j += 1
        else:
            break
print(x+total)

Measured memory_bytes: 3060
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#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 D()
#define INF 1000000000000
#define MOD 10000007
#define MAXR 100000
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define INITA(a,i,j,v) for(ll k=i;k<=j;k++){a[k]=v;}

int main() {
    int n, t, a;
    int h[100001]; INITA(h, 0, 100000, 0);
    cin >> n >> t >> a;

    double min_diff = 100000;
    int min_h = -1;
    FOR(i, 1, n) {
        cin >> h[i];
        double diff = abs(a - (t - h[i] * 0.006));
        if (diff < min_diff) {
            min_diff = diff;
            min_h = i;
        }
    }
    cout << min_h << endl;
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#define _USE_MATH_DEFINES
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
typedef pair<ll,ll> P;
typedef map<ll,ll> MP;
typedef priority_queue<ll> PQ;
#define pb push_back
#define st first
#define nd second
#define SZ(x) ((int)(x).size())
#define FOR(i,s,n) for(int i=(int)(s); i< (int)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define all(x) (x).begin(),(x).end()
#define each(x,c) for(auto x: (c))
#define LB(x,a) lower_bound(all(x), a)
#define UB(x,a) upper_bound(all(x), a)
const ll mod=1e9+7;
const ll INF=1e18;
const double EPS=1.0e-10;
const double PI=M_PI;

int main(){
    int N,K; scanf("%d %d",&N,&K);
    int M=(int)sqrt(N);
    vec MA,n;
    FOR(i,1,M+1){
        MA.pb(i); n.pb(1);
    }
    int m=M;
    if(M*M==N) m--;
    rep(i,m){
        MA.pb(N/(m-i)); n.pb(MA[M+i]-MA[M+i-1]);
    }
    int j=SZ(MA);
    vec dp(j),S(j,1);
    rep(k,K){
        rep(i,j){
            dp[i]=(n[i]*S[j-i-1])%mod;
        }
        S[0]=dp[0];
        FOR(i,1,j) S[i]=(S[i-1]+dp[i])%mod;
    }
    printf("%lld\n",S[j-1]);
    return 0;
}

Measured memory_bytes: 2420
import math
while 1:
    D,E=map(int,input().split())
    if not D and not E:break
    f=lambda l:abs(math.sqrt(l[0]**2+l[1]**2)-E)
    m=min(map(f,[[i,D-i] for i in range(math.ceil((D+1)/2))]))
    print(m)


Measured memory_bytes: 5676
using System;
using System.Collections.Generic;


public class A
{
	public static void Main()
	{
		long a = Int64.Parse(Console.ReadLine());
		long b = Int64.Parse(Console.ReadLine());
		long c = Int64.Parse(Console.ReadLine());
		long d = Int64.Parse(Console.ReadLine());
		long e = Int64.Parse(Console.ReadLine());
		long k = Int64.Parse(Console.ReadLine());
			
		Console.WriteLine(((e-a) > k) ? ":(" : "Yay!");
	}	
}

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

int main(void)
{
    char a, b, c;
    cin >> a >> b >> c;
    if((a=='7') || (b=='7') || (c=='7'))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 3528
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int main(){
	int n,c0=0,c1=0,c2=0,c3=0;
	string s;
	cin>>n;
	while(n--){
		cin>>s;
		if(s=="AC"){
			c0++;
		}
		else if(s=="WA"){
			c1++;
		}
		else if(s=="TLE"){
			c2++;
		}
		else{
			c3++;
		}
	}
	cout<<"AC x "<<c0<<endl;
	cout<<"WA x "<<c1<<endl;
	cout<<"TLE x "<<c2<<endl;
	cout<<"RE x "<<c3<<endl;
	return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

struct RangeSumQuery {
	// SegmentTree (1-indexed)
	int n;
	vector<int>d;
	RangeSumQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, 0);
	}
	void add(int i, int x) {
		d[n + i] += x;
		for (int j = (n + i) / 2; j > 0; j >>= 1) {
			d[j] += x;
		}
	}
	int sum(int a, int b) {
		return sum(a, b, 1, 0, n);
	}
	int sum(int a, int b, int k, int l, int r) {
		// [a,b) [l,r)
		if (r <= a || b <= l)return 0;
		else if (a <= l&&r <= b)return d[k];
		else {
			int vl, vr;
			vl = sum(a, b, k * 2, l, (l + r) / 2);
			vr = sum(a, b, k * 2 + 1, (l + r) / 2, r);
			return (vl + vr);
		}
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeSumQuery rsq(n);
	rep(i, 0, q) {
		int com, x, y; cin >> com >> x >> y;
		if (com)cout << rsq.sum(x - 1, y) << endl;
		else rsq.add(x - 1, y);
	}
	dump(rsq.d);
	return 0;
}

Measured memory_bytes: 3876
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  for (int i = 0; i < n; ++i) {
    cin >> p[i];
  }
  int mn = n + 1;
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    if (mn >= p[i]) {
      ans++;
      mn = min(mn, p[i]);
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>


int main()
{
	int A;
	int B;

	std::cin >> A >> B;

	const int sum = A + B;
	const int sub = A - B;
	const int mul = A * B;

	if (sum > sub)
	{
		if (sum > mul)
		{
			std::cout << sum << std::endl;
		}
		else
		{
			std::cout << mul << std::endl;
		}
	}
	else
	{
		if (sub > mul)
		{
			std::cout << sub << std::endl;
		}
		else
		{
			std::cout << mul << std::endl;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

 void solve() {
     int k;
     cin>>k;
     int sm=0;
     rep(i,1,k+1) {
		   rep(j,1,k+1) {
			     rep(z,1,k+1) {
					   sm+=__gcd(i,__gcd(j,z));
					 }
			   }
		 }          
		 cout<<sm<<endl;
 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


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

int main() {
  int n;
  cin>>n;
  if(n<600)cout<<8<<endl;
  else if(n<800)cout<<7<<endl;
  else if(n<1000)cout<<6<<endl;
  else if(n<1200)cout<<5<<endl;
  else if(n<1400)cout<<4<<endl;
  else if(n<1600)cout<<3<<endl;
  else if(n<1800)cout<<2<<endl;
  else cout<<1<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;

#define ll long long
#define INF (1 << 30)
#define INFLL (1LL << 60)

int main() {
	int n,l;
	string str[101];
	cin >> n >> l;
	for(int i = 0;i < n;i++){
		cin >> str[i];
	}
	sort(str, str + n);
	string ans = "";
	for(int i = 0;i < n;i++){
		ans += str[i];
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int N = scanner.nextInt();
        int[] W = new int[N];

        for (int i = 0 ; i < N ; i++) {
            W[i] = scanner.nextInt();
        }

        int total = 0;
        for (int i = 0 ; i < N ; i++) {
            total += W[i];
        }

        int S1 = 0;
        int minDiff = Integer.MAX_VALUE;
        for (int i = 0 ; i < N - 1 ; i++) {
            S1 += W[i];
            int S2 = total - S1;
            minDiff = Math.min(minDiff, Math.abs(S1 - S2));
        }

        System.out.println(minDiff);
    }
}


Measured memory_bytes: 36008
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }

int main(){
  int r,c; cin>>r>>c;
  int s[r+1][c+1];
  CINA2(s,r,c);
  REP(i,r){
    int x = 0; REP(j,c){ x += s[i][j];}
    s[i][c] = x;
  }
  REP(i,c+1){
    int x = 0; REP(j,r){ x += s[j][i]; }
    s[r][i] = x;
  }
  REP(i,r+1){
    REP(j,c){ printf("%d ",s[i][j]);}
    printf("%d",s[i][c]);
    printf("\n");
  }
}


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

int sod(int x){
    int v=0;
    while(x){
        v+=x%10;
        x/=10;
    }
    return v;
}

int main(){
    int n,a,b,ans=0,v;
    cin>>n>>a>>b;
    for(int i=1;i<=n;i++){
        v=sod(i);
        if(v>=a&&v<=b)ans+=i;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
n = gets.to_i
x_vec = gets.split.map(&:to_f)
y_vec = gets.split.map(&:to_f)

d1 = 0
n.times do |i|
  d1 += (x_vec[i] - y_vec[i]).abs
end

d2 = 0
n.times do |i|
  d2 += (x_vec[i] - y_vec[i].abs) ** 2
end
d2 = Math.sqrt(d2)

d3 = 0
n.times do |i|
  d3 += (x_vec[i] - y_vec[i]).abs ** 3
end
d3 = d3 ** (1.0 / 3.0)

d4 = 0
n.times do |i|
  if d4 < (x_vec[i] -y_vec[i]).abs then d4 = (x_vec[i] - y_vec[i]).abs end
end

puts sprintf("%.6f", d1)
puts sprintf("%.6f", d2)
puts sprintf("%.6f", d3)
puts sprintf("%.6f", d4)

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

int main(){
    int t, i, ac=0, wa=0, tle=0, re=0;
    cin>>t;
    string n;
    for(i=0; i<t+1; i++){
        getline(cin,n);
        if(n == "AC"){
            ac++;
        }
        else if(n == "WA"){
            wa++;
        }
        else if(n == "TLE"){
            tle++;
        }
        else if(n == "RE"){
            re++;
        }
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <climits>
using namespace std;

int main(){
    double r ; cin >> r;
    double pi = 3.14159265358979;
    
    printf("%.6f %.6f" , pi * r * r , 2 * pi * r );
    return 0;
    
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 5LL << 60;
const ll mod = 1e9 + 7;

int main() {
	int N;
	cin >> N;
	int T, A;
	cin >> T >> A;
	T *= 1000;
	A *= 1000;
	int H[N];
	for(int i = 0; i < N; i++) cin >> H[i];

	int ans = 0;
	int best = inf;
	for(int i = 0; i < N; i++) {
		if(abs(A - T + 6 * H[i]) <= best) {
			best = abs(A - T + 6 * H[i]);
			ans = i;
		}
	}
	cout << ans + 1;
	return 0;
}


Measured memory_bytes: 3608
n = int(input())
number_list = []
for i in range(1, n + 1):
    if i % 15 == 0:
        None
    elif i % 3 == 0:
        None
    elif i % 5 == 0:
        None
    else:
        number_list.append(i)

print(sum(number_list))

Measured memory_bytes: 29984
#include <bits/stdc++.h>
using namespace std;
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define rep(i, n) for(int i =0 ; i < n; ++i)
#define repr(i, n) for(int i=n-1;i>=0;i--)
#define Rep(i,a,b) for(int i=a;i<=b;i++)
#define Repr(i,a,b) for(int i=a;i>=b;i--)
#define pii pair < int, int >
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
typedef vector<int> vi;
typedef long long ll;
const int inf = int(1e9);
const int mod = inf + 7;

void solve(){
	int n;
	cin>>n;
	int a[n];
	set<int>s;
	rep(i,n){
		cin>>a[i];
		s.insert(a[i]);
	}
	if(sz(s)==n)cout<<"YES";
	else cout<<"NO";

}

int main(){
	Red;
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}

Measured memory_bytes: 10368
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

int main() {
    string S; cin >> S;
    vector<string> V = {
        "dreamer",
        "eraser",
        "dream",
        "erase"};
    
    stack<pair<ll,ll>> ST;
    ll pos = 0;
    ll cur = 0;
    while(1) {
        string T = V[cur];
        if (S.find(T, pos) == pos) {
            if (cur < V.size() - 1) ST.push({pos,cur+1});
            pos += T.size();
            if (pos == S.size()) {
                cout << "YES" << endl;
                return 0;
            }
            cur = 0;
            continue;
        }
        if (++cur < V.size()) continue;
        if (!ST.empty()) {
            pair<int,int> P = ST.top(); ST.pop();
            pos = P.first;
            cur = P.second;
            continue;
        }
        cout << "NO" << endl;
        return 0;
    }
}


Measured memory_bytes: 512
from string import ascii_lowercase
def main():
    n=int(input())
    Ans=['a']
    A=ascii_lowercase
    for i in range(n-1):
        Tmp=[]
        for a in Ans:
            s=set(list(a))
            for l in A:
                Tmp.append(a+l)
                if l not in s:
                    break
        Ans=Tmp[:]
    for ans in Ans:
        print(ans)
    
if __name__=='__main__':
    main()

Measured memory_bytes: 57564
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
c=0
t=a[0]
for x in range(n):
    c+=min(t+a[x+1],b[x])
    t=a[x+1] if t>=b[x] else max(0,t+a[x+1]-b[x])
print(c)

Measured memory_bytes: 18476
inf = 10**15
mod = 10**9+7
h,n = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(n)]
dp = [[inf for j in range(h+1)] for i in range(n+1)]
for i in range(n):
    dp[i][0] = 0
    a,b = ab[i]
    for j in range(h):
        if j+1-a>=0:
            dp[i+1][j+1] = min(dp[i+1][j+1-a]+b, dp[i][j+1], dp[i][j+1-a]+b)
        else:
            dp[i+1][j+1] = min(dp[i][j+1], b)
print(dp[n][h])

Measured memory_bytes: 125276