akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(void)
{
  int n,m;
  int i;
  int a[10000];
  int sum;
  scanf("%d %d", &n, &m);
  sum = 0;
  for(i=0;i<m;i++){
    scanf("%d", &a[i]);
    sum += a[i];
  }
  if(n-sum>=0){
    printf("%d\n", n-sum);
  } else {
    printf("-1\n");
  }
  return 0;
}


Measured memory_bytes: 1764
use std::io::prelude::*;
use std::str::FromStr;

fn main() {
    let stdin_ = std::io::stdin();
    let stdout_ = std::io::stdout();
    let mut stdin = stdin_.lock();
    let mut stdout = stdout_.lock();

    let mut buffer = String::new();
    stdin.read_line(&mut buffer).unwrap();
    let n = buffer
        .split_whitespace()
        .map(|s| usize::from_str(s).unwrap())
        .next()
        .unwrap();
    buffer.clear();
    stdin.read_line(&mut buffer).unwrap();
    let h = buffer
        .split_whitespace()
        .map(|s| u64::from_str(s).unwrap())
        .collect::<Vec<u64>>();

    let mut ans = 0;
    let mut highest = 0;
    for i in 0..n {
        if highest <= h[i] {
            ans += 1;
            highest = h[i];
        }
    }

    write!(stdout, "{}\n", ans).unwrap();
}


Measured memory_bytes: 4352
import java.util.Scanner;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.lang.Math;

class Main{
    public static void main(String[] args){
        InputStreamReader inputStreamReader = new InputStreamReader(System.in);
        BufferedReader reader = new BufferedReader(inputStreamReader);
        
        String str;
        int[] num;
        
        try {
            while(reader.ready()){
                str = reader.readLine();
                num = getNum(str);
                System.out.println(plusInterest(100000, num[0]));
            }
            reader.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    private static int plusInterest(int money, int week){
        if (week == 0) {return money;}
        money += money * 0.05;
        money = (money % 1000 == 0) ? money : (int) Math.round((money + 500) / 1000.0) * 1000;
        return plusInterest(money, week-1);
    }

    private static int[] getNum(String str){
        String[] data = str.split(" "); 
        int[] num = new int[data.length];

        for (int i = 0; i < data.length; i++){
            num[i] = Integer.parseInt(data[i]);
        }
        return num;
    }

}


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

using namespace std;
#define ll long long
#define ld long double
#define  P pair<ll,ll>
#define FOR(i,n,m) for(ll i=n; i<(ll)m;i++)
#define FORr(i,n,m) for(ll i=n; i>=(ll)m; i--)
#define FORm(i,m) for(auto i=m.begin();i!=m.end();i++)
#define VEC2(x,a,b) vector<vector<ll>> x = vector<vector<ll>>(a,vector<ll>(b,0))
#define sortAl(v) sort(v.begin(),v.end())
#define sortAlr(v) sort(v.begin(),v.end()); reverse(v.begin(),v.end())
#define cinv(v,n,m) FOR(i,n,m) cin>>v.at(i)
#define coutv(v,n,m) FOR(i,n,m) cout<<v.at(i) <<" "; cout<<endl
#define cout(n) cout<<fixed<<setprecision(n)

vector<string> v(100);

int s_size(string s){
  ll res = 0;
  FOR(i,0,s.size()){
    if(s[i] == '.') res++;
  }
  return res;
}


P calf(ll pos, ll dpt, string c){
  ll cur_pos = pos + 1;
  ll cur_dpt = dpt + 1;
  ll res = 0;
  if(c == "*") res++;
  if(c == "+" || c == "*"){
    while (true) {

      //cout<<"cur_pos = "<<cur_pos<<endl;
      //cout<<res<<endl;
      if(v[cur_pos] == "") break;
      if(v[cur_pos].size()-1 != cur_dpt) break;
      if(v[cur_pos][cur_dpt] == '+'){
        P p = calf(cur_pos,cur_dpt,"+");
        if(c == "+") res += p.first;
        if(c == "*") res *= p.first;
        cur_pos = p.second-1;
      }
      else if(v[cur_pos][cur_dpt] == '*'){
        P p = calf(cur_pos,cur_dpt,"*");
        if(c == "+") res += p.first;
        if(c == "*") res *= p.first;
        cur_pos = p.second-1;
      }
      else if(c == "+"){
        res += v[cur_pos][cur_dpt] - '0';
        //cout<<"aa"<<endl;
      }
      else{
        res *= v[cur_pos][cur_dpt] - '0';
        //cout<<"bb"<<endl;
      }
      cur_pos++;
    }
    return P(res, cur_pos);

  }
  return P(stoi(c), 0);

}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n = 0;
    cin>>n;
    while(n!=0){
      vector<string> ini(100);
      v = ini;

      cinv(v,0,n);
      cout<<calf(0,0,v[0]).first<<endl;
      cin>>n;
    }
}



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

int main(){
	int n;
	while(1){
		cin >> n;
		if(n==0) break;
		int a[n];
		for(int i=0;i<n;i++) cin >> a[i];
		double m = 0;
		for(int i=0;i<n;i++) m += a[i];
		m /= n;
		double b = 0;
		for(int i=0;i<n;i++) b += (a[i]-m)*(a[i]-m)/n;
		cout << setprecision(10);
		cout << sqrt(b) << endl;
	}
}

Measured memory_bytes: 1236
// C - One Quadrillion and One Dalmatians
#include <bits/stdc++.h>
using namespace std;

int main(){
	int64_t n; cin>>n;
	string ans = "";
	while(n > 0){
		int r = (n-1) % 26;
		n = (n-1) / 26;
		ans = char(r+'a') + ans;
	}
	cout<< ans <<endl;
}


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

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


Measured memory_bytes: 3620
package main

import (
	"fmt"
)

func gcd(a, b uint64) uint64 {
	if b == 0 {
		return a
	} else {
		return gcd(b, a%b)
	}
}

func lcm(a, b uint64) uint64 {
	return a / gcd(a, b) * b
}

func main() {
	var n int
	fmt.Scan(&n)

	var cur uint64 = 1
	for i := 0; i < n; i++ {
		var t uint64
		fmt.Scan(&t)
		cur = lcm(cur, t)
	}

	fmt.Println(cur)
}


Measured memory_bytes: 512
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

int main(){
  int n,k,a;
  cin>>n>>k;
  VI d(k);
  VI ans(n);
  rep(i,k){
    cin>>d[i];
    rep(j,d[i]){
      cin>>a;
      ans[a-1]++;
    }
  }
  int cnt=0;
  rep(i,n){
    if(ans[i]==0) cnt++;
  }
  cout<<cnt<<endl;
}


Measured memory_bytes: 3604
/*input
4 4
1 2
2 3
3 4
4 2
*/
#include <bits/stdc++.h>
using namespace std; 
#define int long long int
#define max(x, y) ((x) > (y) ? (x) :(y))
#define pii pair< int , int> 
#define vi vector<int>
#define fore( i ,st) for ( int i= 0 ; i < (int)(st) ; i ++)
#define REP( i , st , en ) for ( int i =st; i < (int)en; i++)
#define REPD( i , en , st ) for ( int i =en; i >= (int)st; i--)
#define SZ(a) (int)a.size()
#define all(v) v.begin() , v.end()
#define pb push_back
#define F first
#define S second
#define bitch_i_m_on_fiyaah_yeahhhh ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
// const int mod = 998244353;
const int mod = 1e9+7;
ostream& operator << ( ostream&  o, vector<int> s){for ( int i = 0;  i < (int)s.size() ; i++)o << s[i] << " ";o << "\n";return o;}
void  add( int &a, int b){a = a + b;if ( a< 0 ) a += mod; if ( a> mod ) a-= mod;}
void sub( int &a, int b){a = a - b;if ( a < 0) a += mod;}
int mul( int a , int b){return ((a %mod) * (b %mod) ) %mod;}
int exp( int a , int pow){ return (pow == 0 ? 1 : ( pow & 1  ? mul ( a ,exp( mul(a, a) , pow /2) ) : exp(mul(a ,a) , pow/2)));}
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }

const int maxn =1e5 + 5;
vector< int > graph[maxn];
int dist[maxn];

void solve(int test ) 
{	
	int n , m ;
	cin >> n >> m ;
	fore( i , m){
		int x , y;
		cin >> x >> y;
		graph[x].push_back(y);
		graph[y].push_back(x);
	}
	fill (dist , dist + maxn ,  1e9);
	dist[1] = 0;
	vector<int> q;
	q.push_back(1);
	map<int , int > ans;
	for ( int i = 0 ; i < SZ(q);  i++){
		int x = q[i];
		for ( int child : graph[x]){
			if ( dist[child] > dist[x] + 1){
				dist[child ]=  dist[x] +1;
				ans[child] = x;
				q.push_back(child); 
			}
		}

	}

	for ( int i  =2; i <= n ; i++ ){
		if ( dist[i] == 1e9){
			cout << "No";
			return;
		}
	}
	cout << "Yes\n";
	for ( int i =2; i <= n ; i++)
		cout << ans[i] << "\n";




}
signed main(){
	// bitch_i_m_on_fiyaah_yeahhhh
	int t =1; 
	// cin >> t;
	for ( int i = 0 ; i < t; i++)
	solve(i+1);
}

Measured memory_bytes: 19764
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int main()
{
	int N;
	int M;
	string S[110];
	cin >> N;
	map<string, int> mp;
	for (int i = 0; i < N; i++) {
		cin >> S[i];
		mp[S[i]]++;
	}
	cin >> M;
	for (int i = 0; i < M; i++) {
		string T;
		cin >> T;
		mp[T]--;
	}
	int ans = 0;
	for (int i = 0; i < N; i++) {
		ans = max(ans, mp[S[i]]);
	}
	cout << ans << endl;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  int s = 0;
  for (int i = 0; i < n; i++) {
    int t; cin >> t;
    s += t;
  }
  cout << s - n << '\n';
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define h1 7897897897897897
#define h2 7897466719774591
#define b1 98762051
#define b2 98765431
#define inf 1000000000
#define pi 3.1415926535897932384626
#define LMAX 9223372036854775807
#define ll long long
#define fi first
#define sec second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vl vector<ll>
#define vp vector<pii>
#define SET(a, b) memset(a, b, sizeof(a));
#define all(x) (x).begin(), (x).end()
#define FF fflush(stdout)
#define debug printf("Hello\n")
//why is my rating plummeting
int n, m, k, x, y, sum, cnt, ans;
int one, two, four;
int main () {
	scanf("%d", &n);
	for (int i=0; i<n; i++) {
		scanf("%d", &x);
		if (x%4==0) four++;
		else if (x%2==0) two++;
		else one++;
	}
	if (one==four+1&&two==0)  printf("Yes\n");
	else if (one<=four) printf("Yes\n");
	else printf("No\n");
	return 0;
}

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

int main(){
    string s;
    cin >> s;
    for(int i=0;i<3;i++) {
        if(s.at(i) == '1') {
            s.at(i) = '9';
        }else if(s.at(i) == '9'){
            s.at(i) = '1';
        }
    }
    int ans = stoi(s);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <string>
int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);

    std::string S;
    std::cin >> S;
    int32_t head = 0;
    int32_t tail = (int)S.size() - 1;
    int32_t res = 0;
    while (head < tail) {
      if (S[head] != S[tail]) {
        res++;
      }
      head++;
      tail--;
    }
    std::cout << res << std::endl;


    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python3
# -*- coding: utf-8 -*-

# import numpy as np
# from itertools import *
# from collections import *
from collections import Counter

# S = input().split()
# N = int(input().split())
# N, K = [int(x) for x in input().split()]

N = int(input())
A = [int(x) for x in input().split()]

number = range(1, N+1)
numhei = [0] * N
for n in range(N):
    numhei[n] = number[n] + A[n]

c = Counter(numhei)
count = 0
for n in number:
    count += c[n - A[n-1]]

print(count)


Measured memory_bytes: 42644
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 998244353;
const ll MAX = 4000001;
const double eps = 1E-18;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint operator^(const ll& t)const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}
	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

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

vector<mint> frac, ifrac;
void finit(ll X) {
	frac.assign(X + 1, 1);
	ifrac.assign(X + 1, 1);

	repn(i, X) {
		frac[i] = frac[i - 1] * i;
		ifrac[i] = ifrac[i - 1] / i;
	}

}

mint com(ll n, ll m) {
	if (n < 0 || m < 0 || n < m) { return 0; }
	return frac[n] * ifrac[m] * ifrac[n - m];
}

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

	finit(N);

	mint ans = 0;
	rep(i, K + 1) {
		mint k = com(N - 1, i)*((mint)(M - 1) ^ (N - i - 1))*M;
		ans += k;
	}
	cout << ans << endl;


	system("PAUSE");

}

Measured memory_bytes: 6336
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

int main() {
  size_t N;
  scanf("%zu", &N);

  std::vector<std::vector<int>> abc(N+1, std::vector<int>(3));
  for (size_t i = 1; i <= N; ++i)
    scanf("%d %d %d", &abc[i][0], &abc[i][1], &abc[i][2]);

  std::vector<std::vector<int>> dp(N+1, std::vector<int>(3));
  for (size_t i = 1; i <= N; ++i)
    for (size_t j = 0; j < 3; ++j)
      for (size_t k = 0; k < 3; ++k)
        if (j != k)
          dp[i][j] = std::max(dp[i][j], dp[i-1][k]+abc[i][j]);

  printf("%d\n", std::max({dp[N][0], dp[N][1], dp[N][2]}));
}


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

int main()
{
	int n, m;
	cin >> n >> m;
	vector<vector<int>> bv(m + 1);
	for (int i = 0; i < n; ++i) {
		int a, b;
		cin >> a >> b;
		if (m < a) {
			continue;
		}
		bv[a].push_back(b);
	}

	long long ret = 0;
	priority_queue<int> q;
	for (int i = 1; i <= m; ++i) {
		for (auto& j : bv[i]) {
			q.push(j);
		}
		if (!q.empty()) {
			ret += (long long)(q.top());
			q.pop();
		}
	}

	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 5632
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

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

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};


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

	int n,m;
	cin >> n >> m;
	
	vector<int> es[n];
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
	}

	int dp[n];
	dp[0]=0;
	for(int i=1;i<n;i++) dp[i] = INF;
	
	int e;
	for(int i=0;i<n-1;i++){
		for(int j=0;j<es[i].size();j++){
			e = es[i][j];
			if(dp[e] > dp[i]+1){
				dp[e] = dp[i]+1;
			}
		}
	}
	cout << (dp[n-1]<=2?"":"IM") << "POSSIBLE\n";

	return 0;
}

Measured memory_bytes: 9344
using System;


namespace ConsoleApplication35
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();
            string[] ss = s.Split(' ');
            int a = int.Parse(ss[0]);
            int b = int.Parse(ss[1]);
            int c = int.Parse(ss[2]);
            int d = 0;
            if (a > b)
            {
                d = a;
                a = b;
                b = c;
                c = d;
            }
            if (b > c)
            {
                d = b;
                b = c;
                c = d;
            }
            if (a > b)
            {
                d = a;
                a = b;
                b = d;
            }
            Console.WriteLine(a + " " + b + " " + c);

        }
    }
}

Measured memory_bytes: 9036
#include<bits/stdc++.h>
#define MOD 1000000007
#define MOD2 1000000006
#define TEMPMOD1 998244353
#define TEMPMOD2 998244352
#define INF 1000000000000000007
#define NEGINF -1000000000000000007
#define vll vector<ll> 
#define vvll vector<vector<ll>>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define plll pair<ll,pll>
#define vpll vector<pll>
using namespace std;
typedef long long int ll;


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

    ll n;
    cin>>n;
    ll arr1[n];
    for(ll i=0;i<n;i++)
    {
        cin>>arr1[i];
    }
    vll length;
    ll ele=arr1[0];
    ll count=1;
    for(ll i=1;i<n;i++)
    {
        if(arr1[i]<=ele)
        {
            ele=arr1[i];
            count++;
        }
        else
        {
            length.push_back(count);
            count=1;
            ele=arr1[i];
        }
    }
    length.push_back(count);
    ll ans=NEGINF;
    for(auto it:length)
    {
        ans=max(ans,it);
    }
    ans--;
    cout<<ans;
    return 0;
}

Measured memory_bytes: 2168
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main() {
	int n, m;
	cin >> n >> m;
	vector<int> x(m);
	for (int i = 0; i < m; ++i) {
		cin >> x[i];
	}
	if (n >= m) {
		cout << 0 << endl;
		return 0;
	}
	sort(x.begin(), x.end());
	vector<int> diffs(m - 1);
	for (int i = 0; i < m - 1; ++i) {
		diffs[i] = x[i + 1] - x[i];
	}
	sort(diffs.begin(), diffs.end());
	int steps = accumulate(diffs.begin(), diffs.end() - (n - 1), 0);
	cout << steps << endl;
	return 0;
}


Measured memory_bytes: 1024
using System;
using System.Linq;

namespace AGC028
{
    class A
    {
        static void Main(string[] args)
        {

            long[] input = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = input[0];
            long M = input[1];
            string S = Console.ReadLine();
            string T = Console.ReadLine();

            long gcd = CalcGCD(N, M);
            long n = N / gcd;
            long m = M / gcd;

            for (int i = 0; i < gcd; i++)
            {
                if (S[i * (int)n] != T[i * (int)m])
                {
                    Console.WriteLine("-1");
                    return;
                }

            }
            Console.WriteLine(n * m * gcd);
        }


        public static long CalcGCD(long a, long b)
        {
            if (b == 0) { return a; }
            return CalcGCD(b, a % b);
        }
    }
}


Measured memory_bytes: 13664
import java.util.Scanner;
import java.lang.*;

public class Main{
 
	public static void main(String args[]){
      
    	//入力するためのオブジェクトを生成
      	Scanner scan = new Scanner(System.in);
      	String str = scan.next();
      
      	String name = str;
          System.out.println(name.substring(0,3));    
    }
}	

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

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

void solve(void) {
  ll x; cin >> x;

  ll a = x / 500;
  ll b = (x - a * 500) / 5;

  cout << 1000 * a + b * 5 << endl;
  return;
}

int main(void) {
  solve();
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int main() {
	long long H, W;
	cin >> H >> W;
	if (H == 1 || W == 1) {
		cout << "1";
		return 0;
	}
	if ((H * W) % 2 == 0) {
		cout << (H * W) / 2;
	}
	else {
		cout << (H * W) / 2 + 1;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
   string s;
   cin>>s;
   for(int i=0;i<s.length();i++){
        for(int j=i+1;j<s.length();j++){
            if(s[i]==s[j]){
                cout<<"no";
                return 0;
            }
        }
   }
   cout<<"yes";
}


Measured memory_bytes: 256
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;
import java.util.PriorityQueue;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		char[] S = sc.next().toCharArray();
		int ans = 0;
		for(char c : S) if(c == '1') ans++;
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

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

int main(){
  string a,b,c;
  cin>>a>>b>>c;
  if(a[a.length()-1]==b[0] && b[b.length()-1]==c[0])cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
  return 0;
}



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

template <typename T>
void print_vector(vector<T>& vec) {
    cout << "print_vector -> ";
    for(int i=0; i<vec.size(); i++) {
        if(i == vec.size()-1) {
            cout << vec[i] << endl;
        }
        else {
            cout << vec[i] << " ";
        }
    }
    return;
}

vector<int> v;

void solve(int n) {
    if(n<=1) return;
    int l = sqrt(n);
    for(int i=2; i<=l; i++) {
        if(n%i==0) {
            solve(i); solve((int)(n/i)); return;
        }
    }
    v.push_back(n); return;
}

int main() {

    unsigned long long N;
    cin >> N;

    N--;
    string ans;
    while(1) {
        char name = 'a' + (N % 26);
        ans += name;
        N /= 26;
        if(N == 0) break;
        N--;
    }

    reverse(ans.begin(), ans.end());
    cout << ans << endl;

    return 0;
}

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

using namespace std;

const int MAXN=4096;
string s,t;
int dp[MAXN][MAXN];
int ls,lt;
int pre[MAXN][MAXN];

void dfs(int x,int y){
	if(!x||!y) return;
	if(pre[x][y]==1){
		dfs(x-1,y-1);
		cout<<s[x];
	}
	else if(pre[x][y]==2){
		dfs(x,y-1);
	}
	else dfs(x-1,y);
}

int main(){
	cin>>s>>t;
	ls=s.size();
	lt=t.size();
	s='$'+s;
	t='$'+t;
	for(int i=1;i<=ls;i++){
		for(int j=1;j<=lt;j++){
			if(s[i]==t[j]) dp[i][j]=dp[i-1][j-1]+1,pre[i][j]=1;
			if(dp[i][j]<dp[i][j-1]){
				dp[i][j]=dp[i][j-1];
				pre[i][j]=2;
			}
			if(dp[i][j]<dp[i-1][j]){
				dp[i][j]=dp[i-1][j];
				pre[i][j]=3;
			}
		}
	}
	if(dp[ls][lt]) dfs(ls,lt);
	else cout<<' ';
	return 0;
}
 

Measured memory_bytes: 98688
import java.util.*;

/**
 * A Main
 *
 * @date 2020.09.19
 * @author 焼き鮭 <yaki-shake@up-tri.me>
 */

public class Main {
  Scanner sc;

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

  public void execute() {
    this.sc = new Scanner(System.in);
    int d = sc.nextInt();
    int t = sc.nextInt();
    int s = sc.nextInt();

    System.out.println(d * 1.0 / s <= t ? "Yes" : "No");
  }
}


Measured memory_bytes: 27120
import java.util.*;
class Main
{
  public static void main(String args[])
    {
    int N,k=0;
    Scanner sc= new Scanner(System.in);
    N=sc.nextInt();
    int D[][]= new int[N][2];
    for(int i=0;i<N;i++)
      for(int j=0;j<2;j++)
        D[i][j]=sc.nextInt();
    for(int i=0;i<N;i++)
    {
        if(D[i][0]==D[i][1])
        {
          k++;
          if(k==3)
           break;
        }
        else
          k=0;   
      }
    if(k==3)
      System.out.println("Yes");
    else
      System.out.println("No");
  }
}

Measured memory_bytes: 36028
#include<iostream>
using namespace std;
int len, cnt, cnt1;
string s;
int main() {
    cin>>s;
    len=s.size();
    for (int i = 0; i <len; ++ i)
        if (s[i] == '0')++cnt;
        else if (s[i] == '1')++cnt1;
    cout<<2*min(cnt,cnt1)<<endl;;
    return 0;
}

Measured memory_bytes: 3776
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int number_a = Integer.parseInt(sc.next());
    int number_b = Integer.parseInt(sc.next());
    if((number_a + number_b) % 2 == 1) {
      System.out.println("IMPOSSIBLE");
    } else {
      System.out.println((number_a + number_b) / 2);
    }
  }
}


Measured memory_bytes: 23124
import java.util.*;
 
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int[] num = new int[100001];
        long sum = 0;
        for (int i = 0; i < N; i++) {
        	int n = sc.nextInt();
        	sum += n;
        	num[n]++;
        }
        int Q = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < Q; i++) {
        	int target = sc.nextInt();
        	int change = sc.nextInt();
        	int d = change-target;
        	sum += num[target]*d;
        	num[change] += num[target];
        	num[target] = 0;	
        	sb.append(sum).append("\n");
        }
        System.out.println(sb);
    }
}

Measured memory_bytes: 61380
#!/usr/bin/env python3
import math
Q = int(input())
for _ in range(Q):
    A, B, C, D = map(int, input().split())
    K = math.ceil(max(A, B) / (min(A, B) + 1))
    lo, hi = 0, A + 1
    while hi - lo > 1:
        mid = (lo + hi) // 2
        rA, rB = A - mid, B - max(0, (mid - 1) // K)
        if (rA + 1) * K < rB:
            hi = mid
        else:
            lo = mid

    f = ''
    for i in range(C - 1, D):
        na = lo
        nb = max(0, (na - 1) // K)
        if i < nb * (K + 1):
            f += ('A', 'B')[i % (K + 1) == K]
        elif i < na + nb:
            f += 'A'
        else:
            j = A + B - i - 1
            nb = B - nb
            na = max(0, (nb - 1) // K)
            if j < na * (K + 1):
                f += ('B', 'A')[j % (K + 1) == K]
            else:
                f += 'B'
    print(f)


Measured memory_bytes: 3188
//#define NDEBUG
#include <cstddef>
#include <cstdint>
#include <vector>

namespace n91 {

using i8 = std::int_fast8_t;
using i32 = std::int_fast32_t;
using i64 = std::int_fast64_t;
using u8 = std::uint_fast8_t;
using u32 = std::uint_fast32_t;
using u64 = std::uint_fast64_t;
using isize = std::ptrdiff_t;
using usize = std::size_t;

class rep {
  const usize f, l;

public:
  class itr {
    friend rep;
    usize i;
    constexpr itr(const usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { ++i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr rep(const usize first, const usize last) noexcept
      : f(first), l(last) {}
  constexpr itr begin() const noexcept { return itr(f); }
  constexpr itr end() const noexcept { return itr(l); }
};
class revrep {
  const usize f, l;

public:
  class itr {
    friend revrep;
    usize i;
    constexpr itr(usize x) noexcept : i(x) {}

  public:
    void operator++() noexcept { --i; }
    constexpr usize operator*() const noexcept { return i; }
    constexpr bool operator!=(const itr x) const noexcept { return i != x.i; }
  };
  constexpr revrep(usize first, usize last) noexcept : f(--first), l(--last) {}
  constexpr itr begin() const noexcept { return itr(l); }
  constexpr itr end() const noexcept { return itr(f); }
};
template <class T> using vec_alias = std::vector<T>;
template <class T> auto md_vec(const usize n, const T &value) {
  return std::vector<T>(n, value);
}
template <class... Args> auto md_vec(const usize n, Args... args) {
  return std::vector<decltype(md_vec(args...))>(n, md_vec(args...));
}
template <class T> constexpr T difference(const T &a, const T &b) {
  return a < b ? b - a : a - b;
}

} // namespace n91

#include <algorithm>
#include <iostream>
#include <string>
#include <utility>

namespace n91 {

void main_() {
  u64 n;
  std::cin >> n;
  u64 ans = 0;
  for (u64 x = 1; x * x <= n; ++x) {
    if ((n - x) % x == 0 && (n - x) / x > x) {
      ans += (n - x) / x;
    }
  }
  std::cout << ans << std::endl;
}

} // namespace n91

int main() {
  n91::main_();
  return 0;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;

  if (a > b) swap(a, b);

  ll dist_ab = b - a;
  if (!(dist_ab & 1)) {  // 距離偶数のときはお互いに近づけばOK
    cout << dist_ab / 2 << endl;
    return 0;
  }

  // 距離奇数のときは、端に近い方が端で1勝か1敗して偶数に調整する
  ll dist_1a = a - 1;
  ll dist_bn = n - b;
  // 端への移動 + 偶数調整 + 互いに接近
  cout << min(dist_1a, dist_bn) + 1 + (b - a - 1) / 2 << endl;
  return 0;
}


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

// print test cases

int main(){
	int x = 1, count=0;
	int datasets[10000];
	int i;
	for(i = 0; i < 10000; i++){
		cin >> datasets[i];
		if(datasets[i] == 0) break;
	}
	count = i;

	for(i = 0; i < count; i++){
		cout << "Case " << i + 1 << ": " << datasets[i] << endl;
	}

	return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef unsigned long long ull;

int main(){
    int A,B,C,X;
    cin >> A >> B>> C>>X;
    int i,j,k,count=0;
    rep(i,A+1){
        rep(j,B+1){
            rep(k,C+1){
                if(500*i+100*j+50*k == X){
                    count ++;
                }
            }
        }
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n + 1); i++)
// vector<vector<int>> A(3, vector<int>(4));
int main() {
    int N;
    cin>>N;
    vector<string>S(N);
    ll cnM=0;
    ll cnA=0;
    ll cnR=0;
    ll cnC=0;
    ll cnH=0;
    rep(i,N){
        cin>>S[i];
        if(S[i][0]=='M'){
            cnM++;
        }
        else if(S[i][0]=='A'){
            cnA++;
        }
        else if(S[i][0]=='R'){
            cnR++;
        }
        else if(S[i][0]=='C'){
            cnC++;
        }
        else if(S[i][0]=='H'){
            cnH++;
        }
    }
    ll ans=0;
    ans+=cnM*cnA*(cnR+cnC+cnH)+(cnM+cnA+cnR)*(cnC*cnH)+(cnM+cnA)*cnR*(cnC+cnH);
    cout<<ans<<endl;
}


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

int main() { /* ここに書く */
  int H,A,Ans;
  cin >> H >> A ;
  Ans = H / A ;
  if ( H % A == 0 ){
    cout << Ans << endl ;
  }
  else{
    Ans++ ;
    cout << Ans << endl ;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Graph
{
	int v;
	Set<Integer> adj[];
	int count = 0;

	Graph(int n)
	{
		v = n;

		adj = new HashSet[n];

		for(int i = 0 ; i < n ; i++)
			adj[i] = new HashSet<Integer>(); 
	}
	void addEdge(int u,int v)
	{
		adj[u].add(v);
		adj[v].add(u);
	}
	int conn()
	{
		int res = -1;
		boolean visited[] = new boolean[v];
		for(int i = 0; i < v ; i++)
		{
			if(!visited[i])
			{
				dfs(i,visited);
				if(count > res)
					res = count;
				count = 0;
			}
		}
		return res;

	}
	void dfs(int cur,boolean visited[])
	{
		visited[cur] = true;
		count++;

		for(int k : adj[cur])
		{
			if(!visited[k])
				dfs(k,visited);
		}
	}

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

		int n = kb.nextInt();

		Graph G = new Graph(n);

		int m = kb.nextInt();

		while(m-- > 0)
		{
			int a = kb.nextInt();
			int b = kb.nextInt();

			G.addEdge(a-1,b-1);
		}
		System.out.println(G.conn());

	}
}

Measured memory_bytes: 139368
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int sum=0;
    for(int i=a;i<=b;i++)
{
    if (c%i==0){
        sum=sum+1;
    }
}
cout<<sum<<endl;
    return 0;
}



Measured memory_bytes: 3088
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0)return a;
	return gcd(b, a % b);
}
int main() {
	string s, t;
	cin >> s >> t;
	s += t[t.size() - 1];
	Yes(s == t)
	return 0;
}

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

using namespace std;

int main() {

	int n, c, k;
	cin >> n >> c >> k;

	vector<int> t(n);
	for (int i = 0; i < n; i++)	{
		cin >> t[i];
	}
	sort(t.begin(), t.end());
	int timelim = 0;
	int kyakunum = 0;
	int busnum = 0;
	int i = 0;
	bool brkflg = false;
	for (int timee = 0; timee <= t[t.size() - 1] + k; timee++) {
		bool nottaflg = false;

		do {
			nottaflg = false;
			if (t[i] <= timee && kyakunum <= c) {
				if (kyakunum == 0) {
					timelim = t[i];
					busnum++;
				}
				kyakunum++;
				nottaflg = true;
				i++;
				if (i > t.size() - 1) { brkflg = true; break; }
			}

			if (kyakunum == c || timee == timelim + k) {

				kyakunum = 0;
				break;
			}
		} while (nottaflg == true);

		if (brkflg) { break; }
	}
	cout << busnum << endl;

	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vc = vector<char>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;
#define rep(i, n) for (ll i = 0; i < (n); i++)
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
#ifndef ONLINE_JUDGE
    #define debug(x) cerr << #x << ": " << x << endl;
#else
    #define debug(x)
#endif


int main() {
    ll n, m;
    cin >> n >> m;

    // 頂点 a[i], b[i]
    // 辺の長さ c[i]
    // 最短距離 dist[i][j]
    vll a(m), b(m), c(m);
    vvll dist(n, vll(n));

    // 頂点a[i]とb[i]の距離がc[i]
    for(int i = 0; i < m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        a[i]--, b[i]--;
    }

    // 最短距離の初期化
    for(int i = 0; i < n; i++) {
        for(int j = 0; j < n; j++) {
            if (i == j) dist[i][j] = 0;
            else dist[i][j] = INF;
        }
    }

    // 辺がある場合は更新
    for(int i = 0; i < m; i++) {
        chmin(dist[a[i]][b[i]], c[i]);
        chmin(dist[b[i]][a[i]], c[i]);
    }

    // ワーシャルフロイド法
    for(int k = 0; k < n; k++) { // 経由する頂点
        for(int i = 0; i < n; i++){ // スタート
            for(int j = 0; j < n; j++){ // ゴール
                chmin(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    vvll cnt(n, vll(n, 0));
    rep(i, n) rep(j, n) rep(k, m) {
        if(dist[i][a[k]] + c[k] + dist[j][b[k]] == dist[i][j]) cnt[a[k]][b[k]] = cnt[b[k]][a[k]] = 1;
        if(dist[i][b[k]] + c[k] + dist[j][a[k]] == dist[i][j]) cnt[a[k]][b[k]] = cnt[b[k]][a[k]] = 1;
    }
    ll ans = m;
    rep(i, n) for(ll j = i+1; j < n; j++) if(cnt[i][j] == 1) ans--;
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    for (int i = 2; i <= n; ++i) {
        int tmp = i;
        for (int j = 2; j * j <= i; ++j) {
            while(1) {
                if (tmp % j != 0) break;
                ++mp[j];
                tmp /= j;
            }
        }
        //cout << i << " " << tmp << endl;
        if (tmp!=1) ++mp[tmp];
    }
    //for (auto p : mp) {
    //    cout << p.first << " " << p.second << endl;
    //}
    //vector<int> dp(76, 0);
    //dp[1] = 1;
    //for (int i = 1; i <= 100; ++i) {
    //    if (mp[i]!=0) {
    //        for (int j = 75; j >= 1; --j) {
    //            for (int x = 1; x <= mp[i]; ++x) {
    //                if (j * (x+1) <= 75) {
    //                    dp[j*(x+1)] += dp[j];
    //                } 
    //            }
    //        }
    //    }
    //}
    //cout << dp[75] << endl;
    vector<vector<int>> dp(n+1, vector<int>(76, 0));
    dp[1][1] = 1;
    for (int i = 1; i < n; ++i) {
        for (int have = 0; have <= 75; ++have) {
            for (int take = 1; take <= mp[i] + 1; ++take) {
                if (have * take > 75) {
                    continue;
                }
                dp[i+1][have*take] += dp[i][have];
            }
        }
    }
    cout << dp[n][75] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 100010;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h,w,k;
    cin >> h >> w >> k;
    vector<string> grid(h);
    rep(i,h) cin >> grid[i];
    int sx,sy;
    rep(i,h){
        rep(j,w){
            if (grid[i][j] == 'S'){
                sx = i;
                sy = j;
            }
        }
    }
    vector<vector<int>> depth(h,vector<int>(w,-1));
    queue<P> q;
    int x,y;
    q.push(P(sx,sy));
    depth[sx][sy] = 0;
    while(!q.empty()){
        tie(x,y) = q.front();q.pop();
        if (depth[x][y] > k) break;
        rep(j,4){
            int xn = x+nx[j],yn = y+ny[j];
            if (xn >= 0 && xn < h && yn >= 0 && yn < w && grid[xn][yn] == '.' && depth[xn][yn] == -1){
                depth[xn][yn] = depth[x][y]+1;
                q.push(P(xn,yn));
            }
        }
    }
    int ans = 1e9;
    rep(i,h){
        rep(j,w){
            if (depth[i][j] != -1 && depth[i][j] <= k){
                int d = min({i,h-i-1,j,w-j-1});
                if (d%k == 0) d /= k;
                else d = d/k+1;
                chmin(ans,d+1);
            }
        }
    }
    PRINT(ans);
}    


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

using namespace std ;

const int MAX = 2020 + 10 ;

int mark[MAX] ;
int l , r ;

int main()
{
	ios_base::sync_with_stdio(0) ;
	cin.tie(0) ;
	cin>>l>>r ;
	for(int i = l ; i <= r ; ++i)
	{
		int x = i%2019 ;
		if(mark[x])
			break ;
		mark[x] = 1 ;
	}
	int ans = 2e9 ;
	for(int i = 0 ; i <= 2019 ; ++i)
	{
		for(int j = i+1 ; j <= 2019 ; ++j)
		{
			if(mark[i] && mark[j])
				ans = min(ans , (i * j) % 2019) ;
		}
	}
	return cout<<ans<<"\n" , 0 ;
}		

Measured memory_bytes: 256
A, B = map(int, input().split())


def f(n):
    if n % 2 == 1:
        return (n + 1) // 2 % 2
    else:
        return n // 2 % 2 ^ n


ans = f(A - 1) ^ f(B)
print(ans)

# F(A, B) = F(0, A - 1) ⊕ F(0, B)
# f(n) = F(0, n)
#  任意の偶数nについて n ⊕ (n + 1) = 1
# 0 ⊕ 1 ⊕ 2 ⊕ 3 ⊕ 4 ⊕ 5 ⊕ 6
# = (0 ⊕ 1) ⊕ (2 ⊕ 3) ⊕ (4 ⊕ 5) ⊕ 6
# = 1 ⊕ 1 ⊕ 1 ⊕ 6


Measured memory_bytes: 2940
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    int n, x, aa;
    vector<int> a;
    cin >> n >> x;
    for(int i = 0; i < n; i++){
        cin >> aa;
        a.push_back(aa);
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; i++){
        x -= a[i];
        if(x == 0){
            cout << i + 1 << endl;
            return 0;
        }
        if(x < 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << (x == 0 ? n : n - 1) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<stack>
#include<map>
#include<string>
#include<algorithm>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
#define ll __int64
//#define __int64 long long
//const ll M=1000000007;
int n;
P t[300000];
int z[300000];
int main(){
	cin>>n;
	rep(i,n){
		int x;
		cin>>x;
		t[i]=mp(x,i);
		z[i]=x;
	}

	//sort(t,t+n);
	sort(z,z+n);
	int mid=n/2;
	
	rep(i,n){
		if(t[i].first>=z[mid]){
			cout<<z[mid-1]<<endl;
		}
		
		else {cout<<z[mid]<<endl;}
	}
	return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const int MOD = 1000000007;
int main()
{
  ll a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
  ll ans[2]={0,0};

  for(ll i=0;100*a*i<=f;i++){
    for(ll j=0;100*a*i+100*b*j<=f;j++){
      ll res=f-(100*(a*i+b*j));
      for(ll k=0;k*c<=res;k++){
        for(ll l=0;k*c+l*d<=res;l++){
          ll sug=k*c+l*d;
          ll wat=100*(a*i+b*j);
          if(k*c+l*d>e*(a*i+b*j))continue;

          //cout << (wat+sug) << " " << sug << endl;
          if(ans[1]*(wat+sug)<=ans[0]*sug){
            ans[0]=(wat+sug);
            ans[1]=sug;
          }
        }
      }
    }
  }
  cout << ans[0] << " " << ans[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using i64 = int64_t;
const int INF = 1e9;
const int MOD = INF+7;
const i64 LINF = 1e18;
#define rep(i,N) for(int (i)=0;(i)<(N);++(i))
#define rrep(i,N) for(int (i)=(N-1);(i)>0;--i)
#define FOR(i,j,N) for(int (i)=(j);(i)<(N);++(i))
#define put(n) cout<<(n)<<endl;
#define all(v) v.begin(),v.end()
#define MP make_pair
#define pb(n) push_back(n)
#define int int64_t 

signed main(){
    int N,A,B,C;
    cin >> N;
    vector<int> take(3);
    rep(i,3) cin >> take[i];
    vector<int> L(N);
    rep(i,N) cin >> L[i];
    sort(all(L));

    int ans = INF;
    do{
        int cost = 0;
        int now = L[0];
        int j = 1;
        rep(i,3){
            while(j < N-(2-i) && abs(take[i]-(now+L[j])+10) < abs(take[i]-now)){
                now += L[j];
                j++;
                cost += 10;
            }
            cost += abs(take[i]-now);
            now = L[j]; j++;
        }
        ans = min(ans,cost);
    }while(next_permutation(all(L)));

    cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
goods = [int(x) for x in input().split()]

goods.sort(reverse=True)
score = 0

if len(goods) % 2 == 0:
    r = int(len(goods) / 2)
    score += goods[0]
    for i in range(1, r):
        score += goods[i] * 2
    
else:
    r = int((len(goods) - 1) / 2)
    score += goods[0]
    score += goods[r]
    for i in range(1, r):
        score += goods[i] * 2
print(score)

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

using namespace std;
using ll = long long;

int main() {
    ll a,b;
    cin >> a >> b;

    if (a >= 13) {
        cout << b << endl;
    } else if (a >= 6) {
        cout << b/2 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}


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

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

llint gcd(llint x,llint y){
    if(x<y)gcd(y,x);
    llint r;
    while((r=x%y)){
        x=y;
        y=r;
    }
    return y;
}

void solve(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin >> a[i];
    llint ans=a[0];
    for(int i=1;i<n;i++){
        ans=(ans*a[i])/gcd(ans,a[i]);
    }
    cout << ans << endl;

}

int main(){
  solve();
  return 0;
}



Measured memory_bytes: 3108