akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
#define rep(i,n) for(int i=0;i<n;i++)
#define all(a)  (a).begin(),(a).end()
#define P pair<int, int>
#define ll long long
const int MOD = 1000000007;
//bitset<64>(x).count()
//fixed << setprecision(15) << 

int main(){
  int n;
  cin >> n;
  ll ans = 0;
  for(int i=1;i< 1000001;i++){
    for(int j=1;j< 1000001;j++){
      if(n-i*j>0){
        ans++;
      } else{
        break;
      }
    }
  }
  cout << ans << endl;
}


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

const int N = 1e2 + 7;
int n , m , w[N] , v[N];
long long f[N][100005];

int main()
{
    cin >> n >> m;
    memset(f , 0 , sizeof(f));
    for(int i = 1 ; i <= n; ++i)
    {
        cin >> w[i] >> v[i];
        f[i][0] = 0;
        f[0][i] = 0;
    }
    for(int i = 1; i <= n; ++i)
    {
        for(int j = 1; j <= m; ++j)
        {
            if(w[i] > j)f[i][j] = f[i-1][j];
            else f[i][j] = max(f[i-1][j] , f[i-1][j-w[i]] + v[i]);
        }
    }
    cout << f[n][m];
    return 0;
}


Measured memory_bytes: 87200
#include<stdio.h>
int main(void){
  int r, g, b, sum;
  scanf("%d %d %d",&r, &g, &b);
  sum = 100*r + 10*g + b;
  if(sum % 4 == 0) puts("YES");
  else puts("NO");
  return 0;
}
 

Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		Boolean isNull = str==null;
		while (!isNull) {
			String[] datas = str.split(" ", 8);
			double x1 = Double.parseDouble(datas[0]);
			double y1 = Double.parseDouble(datas[1]);
			double x2 = Double.parseDouble(datas[2]);
			double y2 = Double.parseDouble(datas[3]);
			double x3 = Double.parseDouble(datas[4]);
			double y3 = Double.parseDouble(datas[5]);
			double xp = Double.parseDouble(datas[6]);
			double yp = Double.parseDouble(datas[7]);
			double x = xp - x1;
			double y = yp - y1;
			double p = x2 - x1;
			double q = y2 - y1;
			double r = x3 - x1;
			double u = y3 - y1;
			double[] coefficient = Simultaneous(p, r, x, q, u, y);
			double s = coefficient[0];
			double t = coefficient[1];
			if (s < 0 || t < 0) {
				System.out.println("NO");
			} else if (s + t > 0 && s + t < 1) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
			str = br.readLine();
			isNull = str==null;
		}
	}

	private static double[] Simultaneous(double a, double b, double c,
			double d, double e, double f) {
		double x = (double) (e * c - b * f) / (a * e - b * d);
		double y = (double) (a * f - c * d) / (a * e - b * d);
		double[] answer = { x, y };
		return answer;
	}
}

Measured memory_bytes: 24980
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long 
#define PB push_back
#define PII pair <long long , long long>
#define FAST ios::sync_with_stdio(false);cin.tie(0);

const int maxn = 2e5;
ll a[maxn] , b[maxn];
set <ll> s;

int main() {
    int n , cnt = 0;
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[i] = a[i];
    }
    sort(a , a + n);
    for (int i = 0; i < n; ++i) {
        if(i % 2 == 0) {
            s.insert(a[i]);
        }
    } 
    for (int i = 0; i < n; ++i) {
        if(i % 2 != 0 && s.find(b[i]) != s.end()) {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 4096
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define pii pair<int,int>
#define low lower_bound
#define upp upper_bound
#define mod 1000000007 //10^9+7
#define inf 10000000000000000 //10^16
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define vsort(vec) sort(all(vec))
#define vrever(vec) reverse(all(vec));
#define vunsort(vec) vsort(vec); vrever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
#define P pair<int,int>
using namespace std;

signed main() {
	int n,k,a,b;
	cin>>n>>k>>a>>b;
	if(n<=k) cout<<n*a<<endl;
	else cout<<k*a+(n-k)*b<<endl;
}


Measured memory_bytes: 384
# エラトステネスの篩
def make_prime_table(n):
    sieve = list(range(n + 1))
    sieve[0] = -1
    sieve[1] = -1
    for i in range(2, int(n ** 0.5) + 1):
        if sieve[i] != i:
            continue
        for j in range(i * i, n + 1, i):
            if sieve[j] == j:
                sieve[j] = i
    return sieve


def prime_factorize(n):
    result = []
    while n != 1:
        p = prime_table[n]
        c = 0
        while n % p == 0:
            n //= p
            c += 1
        result.append((p, c))
    return result


N = int(input())

prime_table = make_prime_table(100)

d = {}
for i in range(2, N + 1):
    for p, c in prime_factorize(i):
        d.setdefault(p, 0)
        d[p] += c

# 75 = 5 * 5 * 3
#    = 15 * 5
#    = 25 * 3
#    = 75
n74 = 0
n24 = 0
n14 = 0
n4 = 0
n2 = 0
for k in d:
    if d[k] >= 74:
        n74 += 1
    if d[k] >= 24:
        n24 += 1
    if d[k] >= 14:
        n14 += 1
    if d[k] >= 4:
        n4 += 1
    if d[k] >= 2:
        n2 += 1

result = 0
# x ^ 4 * y ^ 4 * z ^ 2 の約数の個数は75個
result += n4 * (n4 - 1) // 2 * (n2 - 2)
# x ^ 14 * y ^ 4 の約数の個数は75個
result += n14 * (n4 - 1)
# x ^ 24 * y ^ 2 の約数の個数は75個
result += n24 * (n2 - 1)
# x ^ 74 の約数の個数は75個
result += n74
print(result)


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

int main(){
  int n;
  cin>>n;
  vector<int> A(n);
  vector<int> B(n);
  vector<int> C(n-1);
  rep(i,n) cin>>A[i];
  rep(i,n) cin>>B[i];
  rep(i,n-1) cin>>C[i];
  int ans=0;
  rep(i,n) ans+=B[i];
  rep(i,n-1){
    if(A[i+1]-A[i]==1){
      ans+=C[A[i]-1];
    }
  }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repv(i,a,b) for(ll i=b-1;i>=a;i--)
#define MAXN 100005
#define endl "\n"

ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;}

int n,h[MAXN],dp[MAXN];

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    rep(i,1,n+1) cin>>h[i];
    rep(i,1,n+1) dp[i]=INT_MAX;
    dp[1]=0;
    for(int i=1;i<=n;i++)
    {
        dp[i+1]=min(dp[i+1],abs(h[i+1]-h[i])+dp[i]);
        dp[i+2]=min(dp[i+2],abs(h[i+2]-h[i])+dp[i]);
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 1024
let () = Scanf.scanf "%d\n%s" @@ fun n s ->
  let dp = Array.make_matrix (n + 1) (n + 1) 0 in
  for i = 0 to n - 1 do
    for j = 0 to n - 1 do
      dp.(i + 1).(j + 1) <-
        if s.[i] = s.[j]
        then 1 + dp.(i).(j)
        else 0
    done
  done;
  Printf.printf "%d\n" @@
  Array.fold_left (Array.fold_left max) min_int @@
  Array.init (n + 1) @@ fun i ->
    Array.init (n + 1) @@ fun j ->
      min dp.(i).(j) @@ abs @@ i - j


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

#define INF 1e18
#define REP(i, n) for (int i=0; i<n; i++)
#define print(x) cout << x << endl
#define debug(x) cout << #x << " = "<< x << endl

const double PI=3.141592653589793238462643383279502884197169399375105820974944;

typedef long long ll;

using namespace std;

void dfs(vector<vector<int>> &to, int i, int cnt, bool &ans, int n) {
    if (to[i].size() == 0) {
        if (i == n-1 && cnt == 2) {
            ans = true;
        }
        return;
    }
    REP(j, to[i].size()) {
        int tmp = cnt + 1;
        dfs(to, to[i][j], tmp, ans, n);
    }
    return;
}

void solve() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> to(N);
    REP(i, M) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
    }
   
    bool ans = false;
    dfs(to, 0, 0, ans, N);

    if (ans) {
        print("POSSIBLE");
    } else {
        print("IMPOSSIBLE");
    }
}

signed main() {
    solve();
}


Measured memory_bytes: 8576
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func main() {
	solve(NewScanner())
}

func getStrength(x []int, point int) int {
	strength := 0
	for i := 0; i < len(x); i++ {
		strength += pow((x[i] - point), 2)
	}
	return strength
}

func solve(s *Scanner) {
	wtr := bufio.NewWriter(os.Stdout)
	N := s.nextInt()
	X := s.nextIntSlice(N)

	min := MinIntSlice(X)
	max := MaxIntSlice(X)

	strength := math.MaxInt64

	for i := min; i <= max; i++ {
		st := getStrength(X, i)
		if strength > st {
			strength = st
		}
	}

	fmt.Fprintln(wtr, strength)
	wtr.Flush()
}

func pow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func MinIntSlice(v []int) int {
	sort.Ints(v)
	return v[0]
}
func MaxIntSlice(v []int) int {
	sort.Ints(v)
	return v[len(v)-1]
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}


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

#define ll long long int

int main() 
{ 
    float d, t, s;
    cin>>d>>t>>s;
    float ans = d/t;
    if(s < ans) cout<<"No\n";
    else cout<<"Yes\n";
    return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin>>H>>W;
  
  vector<string> photo(H+2);
  photo.at(0)=string(W+2,'#');
  for(int i=1;i<=H;i++){
    string tmp;
    cin>>tmp;
    photo.at(i)="#"+tmp+"#";
  }
  photo.at(H+1)=string(W+2,'#');
  
  for(int i=0;i<H+2;i++){
    cout<<photo.at(i)<<endl; 
  }
}

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

using namespace std;

void solve()
{
	int n, q;
	cin >> n >> q;
	vector<int> fish(n);
	int maxa = 0;
	int maxv = 0;
	for(int i = 0; i < q; ++i)
	{
		int a, v;
		cin >> a >> v;
		--a;
		fish[a] += v;
		if(maxa == a)
		{
			maxv += v;
			if(v < 0)
			{
				vector<int>::iterator it = max_element(fish.begin(), fish.end());
				maxa = it - fish.begin();
				maxv = fish[maxa];
			}
		}
		if(fish[a] >= maxv)
		{
			if(fish[a] == maxv)
			{
                if(a < maxa)
				{
					maxa = a;
				}
            }
			else
			{
				maxv = fish[a];
                maxa = a;
            }
        }
        cout << maxa + 1 << ' ' << maxv << endl;
	}
}

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

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

int main() {
  string S, T;
  cin >> S >> T;

  int count = 0;
  for (int i = 0; i < S.length(); i++) {
    if (S[i] != T[i]) count ++;
  }

  cout << count << endl;
  return 0;
}


Measured memory_bytes: 3896
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#define pb push_back
using namespace std;
vector<int>a,b,p;
int N;
bool iscmp(){
  int i,t=0;
  for(i=1;i<=N;i++){
    if(t>=a[p[i]]+b[p[i]]) return false;
    t=a[p[i]]+b[p[i]];
  }
  return true;
}
 
int main(void){
  int i,j,k,t,tmp;
  int c,c2;
  a.clear(); b.clear(); p.clear();
  cin>>N;
  a.pb(-1); b.pb(-1); p.pb(-1);
  for(i=1;i<=N;i++){
    cin>>tmp;
    p.pb(tmp);
    a.pb(i*N);
    b.pb((N-i+1)*N);
  }
  
  while(!iscmp()){
    t=p[1];
    for(i=2;i<=N;i++){
      
      if((c=a[t]+b[t]) >=  (c2=a[p[i]]+b[p[i]])){
        a[p[i]]+=(c-c2+1);
      }
      t=p[i]; 
    }
  }
 
  for(i=1;i<=N;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;
 
  for(i=1;i<=N;i++){
    cout<<b[i]<<" ";
  }
  cout<<endl;
 
  return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>

using namespace std;
#define INF (1<<29)
int n, m, x;
int c[20];
int dp[21600][256];
bool solve(){
	cin >> n >> m;
	if(n == 0 && m == 0)return false;
	for(int i = 0;i < m;i++){
		cin >> c[i];
	}
	for(int i = 0;i < 21600;i++){
		for(int j = 0;j < 256;j++){
			dp[i][j] = INF;
		}
	}
	dp[0][128] = 0;
	for(int i = 0;i < n;i++){
		cin >> x;
		for(int j = 0;j < 256;j++){
			for(int k = 0;k < m;k++){
				int nxt = max(0, min(255, j + c[k]));
				dp[i+1][nxt] = min(dp[i+1][nxt], dp[i][j] + (x - nxt)*(x - nxt));
			}
		}
	}
	int res = INF;
	for(int i = 0;i < 256;i++)res = min(res, dp[n][i]);
	cout << res << endl;
	return true;
}

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

Measured memory_bytes: 24580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
int main() {
    string S;
    cin >> S;
    long long ans;
    for(int bit = 0; bit < (1<<(S.size()-1)); bit++) {
        long long res = 0;
        long long cur = 0;
        cur += S[0] - '0';
        for(int i = 0; i < (S.size() -1); i++) {
            if(bit &(1<<i)) {
                res += cur;
                cur = S[i+1] - '0';
            } else {
                cur *= 10;
                cur += S[i+1] - '0';
            }
        }
        res += cur;
        ans += res;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;

int main() {
	int t; scanf("%d", &t);
	for(int i = 0; i < t; i++) {
		double x1,y1,x2,y2,x3,y3,x4,y4;
		scanf("%lf%lf%lf%lf%lf%lf%lf%lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4);
		double x5 = x2-x1;
		double y5 = y2-y1;
		double x6 = x4-x3;
		double y6 = y4-y3;
		double det = x5*y6-y5*x6;
		if(fabs(det)<0.00000001) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int power(int a, int b, int p) {
	int c = 1;
	while (b > 0) {
		if (b & 1)
			c = 1LL * c * a % p;
		a = 1LL * a * a % p;
		b >>= 1;
	}
	return c;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n, p;
	cin >> n >> p;
	vector<vector<int>> dp(n + 1, vector<int>(n + 1)), c(n + 1, vector<int>(n + 1));
	dp[0][0] = 1;
	for (int i = 1; i <= n; ++i) {
		for (int j = 0; j < i; ++j) {
			dp[i][j] = (dp[i][j] + 1LL * dp[i - 1][j] * (j + 1)) % p;
			dp[i][j + 1] = (dp[i][j + 1] + dp[i - 1][j]) % p;
		}
	}
	for (int i = 0; i <= n; ++i) {
		c[i][0] = 1;
		for (int j = 1; j <= i; ++j)
			c[i][j] = (c[i - 1][j] + c[i - 1][j - 1]) % p;
	}
	int ans = 0;
	for (int i = 0; i <= n; ++i) {
		int res = 0;
		int sets = power(2, n - i, p);
		for (int j = 0, x = 1; j <= i; ++j) {
			res = (res + 1LL * dp[i][j] * x) % p;
			x = 1LL * x * sets % p;
		}
		res = 1LL * res * power(2, power(2, n - i, p - 1), p) % p * c[n][i] % p;
		ans = (ans + (i % 2 == 0 ? res : p - res)) % p;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    string S;  cin >> S;
    cout << S.substr(0,4) + " " + S.substr(4, 8) << endl;
    
    return 0;
}





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

namespace MyProgram{
    class AtCoder{
        static void Main(){
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);
            int N = input[0];
            int K = input[1];
            int[] D = Array.ConvertAll(Console.ReadLine().Split(' '),int.Parse);

            for(var i=N;i<=10*N;i++){
                string S = i.ToString();
                for(var j=0;j<K;j++){
                    string dk = D[j].ToString();
                    if(S.Replace(dk,"").Length != S.Length)break;
                    if(K-1==j){
                        Console.WriteLine(S);
                        return;
                    }
                }
            }

        }
    } 
}

Measured memory_bytes: 13264
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;


int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long X,A,B;
	cin>>X;
	for(A=-150;A<=150;A++){
		for(B=-150;B<=150;B++){
			if(pow(A,5)-pow(B,5)==X){
				cout<<A<<" "<<B<<endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 4116
#include <iostream>
using namespace std;
int main(void){
    long long n, k;
    cin >> n >> k;
    long long t = n % k;
    long long t2 = k-t;
    t2 = (t2<0)?-t2:t2;
    if(t2<t){
        cout << t2 << endl;
    }else{
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
#define ll long long int

using namespace std;

int main(){
  int N;
  cin>>N;
  string s;
  cin>>s;
  int red=0;
  int blue = 0;
  for(int i=0;i<N;i++){
    if(s[i] == 'R') red++;
    else blue++;
  }

  if(red > blue) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rp(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

void solve(){
    ll n;
    cin >> n;
    ll num=n;
    ll sum=0;
    while(num>0){
        sum+=num%10;
        num/=10;
    }
    Yes(n%sum==0);
    return;
}
int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    std::cout<<std::fixed<<std::setprecision(30);
    solve();
    return 0;
}

Measured memory_bytes: 3584
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;

constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-9;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;

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

	string s;
	cin >> s;
	for (auto &i : s) {
		if (i == '?')i = 'D';
	}
	cout << s << endl;
}

Measured memory_bytes: 3740
package main

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

const INFINITY = math.MaxInt64/2 - 1

func exec(stdin *Stdin, stdout *Stdout) {
	n := stdin.ReadInt()
	x := stdin.ReadInt() - 1
	y := stdin.ReadInt() - 1

	c := NewCounter()
	for i := 0; i < n; i++ {
		for j := i + 1; j < n; j++ {
			d1 := j - i
			d2 := Abs(x-i) + Abs(y-j) + 1
			c.Increment(Min(d1, d2))
		}
	}

	for k := 1; k < n; k++ {
		stdout.Println(c.Get(k))
	}
}

type Counter map[interface{}]int

func NewCounter() *Counter {
	return &Counter{}
}

func (c *Counter) put(key interface{}, v int) {
	d := map[interface{}]int(*c)
	d[key] = v
}

func (c *Counter) Increment(key interface{}) {
	c.put(key, c.Get(key)+1)
}

func (c *Counter) Decrement(key interface{}) {
	v := c.Get(key)
	if v > 0 {
		c.put(key, v-1)
	}
}

func (c *Counter) Get(key interface{}) int {
	d := map[interface{}]int(*c)
	if v, ok := d[key]; ok {
		return v
	} else {
		return 0
	}
}

func (c *Counter) Keys() []interface{} {
	d := map[interface{}]int(*c)
	keys := []interface{}{}
	for key := range d {
		if c.Get(key) > 0 {
			keys = append(keys, key)
		}
	}
	return keys
}

func (c *Counter) String() string {
	strs := []string{}
	for _, key := range c.Keys() {
		strs = append(strs, fmt.Sprintf("%v => %d", key, c.Get(key)))
	}
	return "[" + strings.Join(strs, ", ") + "]"
}

func main() {
	stdout := NewStdout()
	defer stdout.Flush()
	exec(NewStdin(bufio.ScanWords), stdout)
}

type Stdin struct {
	stdin *bufio.Scanner
}

func NewStdin(split bufio.SplitFunc) *Stdin {
	s := Stdin{bufio.NewScanner(os.Stdin)}
	s.stdin.Split(split)
	s.stdin.Buffer(make([]byte, bufio.MaxScanTokenSize), INFINITY)
	return &s
}

func (s *Stdin) Read() string {
	s.stdin.Scan()
	return s.stdin.Text()
}

func (s *Stdin) ReadInt() int {
	n, _ := strconv.Atoi(s.Read())
	return n
}

func (s *Stdin) ReadFloat64() float64 {
	n, _ := strconv.ParseFloat(s.Read(), 64)
	return n
}

type Stdout struct {
	stdout *bufio.Writer
}

func NewStdout() *Stdout {
	return &Stdout{bufio.NewWriter(os.Stdout)}
}

func (s *Stdout) Flush() {
	s.stdout.Flush()
}

func (s *Stdout) Println(a ...interface{}) {
	fmt.Fprintln(s.stdout, a...)
}

func Min(a int, b ...int) int {
	for _, v := range b {
		if v < a {
			a = v
		}
	}
	return a
}

func Max(a int, b ...int) int {
	for _, v := range b {
		if a < v {
			a = v
		}
	}
	return a
}

func Abs(x int) int {
	if x > 0 {
		return x
	} else {
		return x * -1
	}
}

func Pow(x, y int) int {
	z := 1
	for y > 0 {
		if y%2 == 0 {
			x *= x
			y /= 2
		} else {
			z *= x
			y -= 1
		}
	}
	return z
}


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

int s[65][65];

void func1(int c, int m){
  for(int i=0; i<c; i++){
      for(int j=0; j<m; j++){
          s[2*c-1-i][j] += s[i][j];
      }
  }

}

void func2(int c, int n){
    for(int i=0; i<c; i++){
      for(int j=0; j<n; j++){
          s[j][2*c-1-i] += s[j][i];
      }
    }
}

void func3(int c, int n, int m){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            s[i][j] = s[i+c][j];
        }
    }

    for(int i=0; i<c; i++){
        for(int j=0; j<m; j++){
            s[n+i][j] = 0;
        }
    }
}

void func4(int c, int n, int m){
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            s[i][j] = s[i][j+c];
        }
    }
    for(int i=0; i<n; i++){
        for(int j=0; j<c; j++){
            s[i][m+j] = 0;
        }
    }
}


int main(){
    for(int i=0; i<65; i++){
        for(int j=0; j<65; j++){
            s[i][j] = 0;
        }
    }
    while(1){
        int n,m,t,p;
        cin>>n>>m>>t>>p;
        if(n == 0 && m == 0 && t == 0 && p == 0){
            break;
        }

        for(int i=0; i<n; i++){
            for(int j=0; j<m; j++){
                s[i][j] = 1;
            }
        }

        int d;
        int c;
        for(int i=0; i<t; i++){
            cin>>d>>c;
            switch(d){
                case 1:{
                    if(n < 2*c)  n += 2*c-n;
                    func1(c, m);
                    n -= c;
                    func3(c, n, m);
                    break;
                }
                case 2:{
                    if(m < 2*c)  m += 2*c-m;
                    func2(c, n);
                    m -= c;
                    func4(c, n, m);
                    break;
                }
            }
        }

        int x[p];
        int y[p];
        int cnt = 0;
        for(int i=0; i<p; i++){
            cin>>x[i]>>y[i];
        }

        for(int i=0; i<p; i++){
            cout << s[x[i]][y[i]] <<endl;
        }

        for(int i=0; i<65; i++){
            for(int j=0; j<65; j++){
                s[i][j] = 0;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3116
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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(a>b){a=b;return 1;}return 0;}


//解説AC
//https://atcoder.jp/contests/agc031/submissions/4609072
//https://atcoder.jp/contests/agc031/submissions/4608972

int add(int &x, int y) {  
  x += y;
  if (x >= MOD) {
    x -= MOD;
  }
}

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

  ll n;
  cin >> n;
  vector<ll> c(n);
  REP(i, n) {
    cin >> c[i];
    c[i]--;
  }

  //連続部分の結合
  c.erase(unique(c.begin(), c.end()), c.end());
  n = c.size();

  //check
  //REP(i, n) cerr << c[i] << " ";
  //cout << endl;

  vector<ll> dp(n+1, 0);
  //vector<ll> num(2*100000+10, 0);
  vector<ll> num(*max_element(c.begin(), c.end())+1);
  dp[0] = 1;
  REP(i,n){
    dp[i+1] = dp[i] + num[c[i]];
    dp[i+1] %= MOD;    
    num[c[i]] += dp[i];
    num[c[i]] %= MOD;
  }
  cout << dp[n] << endl;
  
  return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<cmath>

int main(){
    int a, b, c, d;
    std::cin >> a >> b >> c >> d;
    if(std::abs(a - c) <= d
        || (std::abs(a - b) <= d && std::abs(b - c) <= d)){
            std::cout << "Yes" << std::endl;
    }else{
        std::cout << "No" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main() {
	int N; scanf("%d", &N);
	int ans = 0;
	for (int i = 0; i < N; i++) {
		int l, r; scanf("%d%d", &l, &r);
		ans += r - l + 1;
	}
	printf("%d\n", ans);
}

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


def main():
    N = int(input())
    res = N % 10

    if res in [2,4,5,7,9]:
        print('hon')
    elif res in [0, 1, 6, 8]:
        print('pon')
    elif res == 3:
        print('bon')


if __name__ == '__main__':
    main()

Measured memory_bytes: 61684
n, x = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
tmp = count = 0

a.each_cons(2) do |i, j|
  if x < i + j - tmp
    count += i + j - tmp - x
    tmp = [i + j - tmp - x, j].min
  else
    tmp = 0
  end
end

puts count

Measured memory_bytes: 11140
//https://atcoder.jp/contests/dp/tasks/dp_e
//E - Knapsack 2

#include <bits/stdc++.h>
using namespace std;

using ll=long long;

void max_self(ll& a, ll b){
	a=max(a,b);
}

void min_self(ll& a, ll b){
	a=min(a,b);
}

const ll inf=1e18L+7;

int main() {
	
	int n,W;
	cin>>n>>W;
	vector<int> weight(n), value(n);
	for(int i=0; i<n; ++i){
		cin>>weight[i]>>value[i];
	}
	int sum_value=0;
	for(int x:value){
		sum_value+=x;
	}
	vector<ll> dp(sum_value+1, inf);
	// dp[i] - minimum total weight of items with total value exactly i
	dp[0]=0;

	for(int item=0; item<n; ++item){
		for(int value_alredy=sum_value-value[item]; value_alredy>=0; --value_alredy){
			min_self(dp[value_alredy+value[item]], dp[value_alredy]+weight[item]);
		}
	}
	ll answer=0;
	for(int i=0; i<=sum_value; ++i){
		if(dp[i]<=W){
			max_self(answer, (ll)i);
		}
	}
	
	cout<<answer<<"\n";
	
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#define inf (2147483647)
#define MAX_N 500010

using namespace std;

class RMQ{
    
public:
    int N;
    int dat[2 * MAX_N - 1];

    RMQ(int n){
        int k = 1;
        while (k < n) k *= 2;
        N = k;
        for(int i = 0; i < 2 * N - 1; i++){
            dat[i] = inf;
      }
    }
    
    void update(int i,int x){
        i += N - 1;
        dat[i] = x;
        while(i > 0){
            i = (i - 1) / 2;
            dat[i] = min(dat[2 * i + 1], dat[2 * i + 2]);
        }
    }
    
    int find(int a, int b, int k, int l, int r){
        if(r <= a || b <= l)return inf;
        if(a <= l && r <= b)return dat[k];
        
        int mid = (l + r) / 2;
        return min(find(a, b, 2 * k + 1, l, mid), find(a, b, 2 * k + 2, mid, r));
    }
    
    int _find(int a, int b){
        return find(a, b, 0, 0, N);
    }
    
};

int main(int argc, const char * argv[]) {
    int n, q, c, x, y;
    cin >> n >> q;
    RMQ rmq(n);
    
    for (int i = 0; i < q; i ++){
        cin >> c >> x >> y;
        if (c == 0){
            rmq.update(x, y);
        }
        else {
            cout << rmq._find(x, y + 1) << endl;
        }
    }
        
    return 0;
}


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

using namespace std;

#define INF (1 << 30)
#define EPS 1e-10
#define MOD 1000000007

using ll = long long;

int a[200000];

int main() {
    int k, n;
    cin >> k >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    int maxd = 0;
    for (int i = 0; i < n - 1; ++i) {
        maxd = max(maxd, abs(a[i] - a[(i + 1) % n]));
    }
    maxd = max(maxd, (a[0] - a[n - 1] + k) % k);
    cout << k - maxd << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <map>

using namespace std;


int main() {

    int n;
    cin >> n;
    map<int, int> as;
    vector<int> xs;
    vector<int> pattern = {-1, 0, 1};
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        as[a] += 1;
        for (int k = 0; k < 3; k++) {
            xs.push_back(a + pattern[k]);
        }
    }

    int result = 0;

    for (int i = 0; i < n * 3; i++) {

        int x = xs[i];

        int tmp = 0;

        for (int k = 0; k < 3; k++) {
            tmp += as[x - pattern[k]];
        }

        result = max(result, tmp);
    }

    cout << result << "\n";


    return 0;

}

Measured memory_bytes: 6896
#include <bits/stdc++.h>
using namespace std;
const int N = 300005;
const int mod = 1000000007;
const int go[8][2] = {{1, 2}, {3, 4}, {5, 6}, {1, 1}, {1, 2}, {7, 2}, {6, 6}, {5, 5}};
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
int n, f[N][8];
char S[N];
int main() {
	scanf("%s", S + 1);
	n = strlen(S + 1);
	f[0][0] = 1;
	for (int i = 1; i <= n; i++) {
		for (int j = 0; j < 8; j++) {
			if (S[i] != '1') Add(f[i][go[j][0]], f[i - 1][j]);
			if (S[i] != '0') Add(f[i][go[j][1]], f[i - 1][j]);
		}
	}
	printf("%d\n", (f[n][2] + f[n][6]) % mod);
	return 0;
}

Measured memory_bytes: 9856
h, w = map(int, input().split())
S = [str(input()) for i in range(h)]

for i in range(h):
    for j in range(w):
        if S[i][j] == '#':
            flag = False
            for di,dj in (-1, 0), (1, 0), (0, 1), (0, -1):
                ni, nj = i+di, j+dj
                if 0 <= ni < h and 0 <= nj < w:
                    if S[ni][nj] == '#':
                        flag = True
            if not flag:
                print('No')
                exit()
else:
    print('Yes')


Measured memory_bytes: 39664
#include<bitset>
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define rep1n(i, n) for(int i=1;i<=(int)(n);i++)
#define all(t) t.begin(), t.end()
#define rall(t) t.rbegin(), t.rend()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout<<(cond? "Yes":"No")<<endl;
#define YES(cond) cout<<(cond? "YES":"NO")<<endl;
int main() {
	ll n;
	cin >> n;
	ll a, b;
	int mi = INT_MAX;
	rep1n(i, sqrt(n)) {
		if (n%i == 0) {
			a = i;
			b = n / a;
			auto sa = to_string(a);
			auto sb = to_string(b);
			mi = min(mi, (int)max(sa.length(), sb.length()));

		}
	}
	cout << mi;
	return 0;
}

Measured memory_bytes: 256
import sys

def main():
    num = int(input())
    ans = num // 11
    ans *= 2
    nokori = num % 11
    if nokori == 0:
        print(ans)
    elif nokori <= 6:
        print(ans + 1)
    else:
        print(ans + 2)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38292
#include <bits/stdc++.h>
using namespace std;
#define benfero freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define mm ' '
#define nl '\n'
#define MOD 1000007
typedef unsigned long long int ull;
typedef long long int ll;
int main()
{
    //benfero
    int n, k;
    cin>>n>>k;
    int ar[n];
    int dp[n]={0};
    int i, e;
    for(i=0;i<n;i++){
        cin>>ar[i];
    }
    dp[0]=0;
    int mn=1e9;
    for(i=1;i<n;i++){
        mn=1e9;
        for(e=k;e>0;e--){
            if((i-e)>=0){
                mn=min(mn,abs(ar[i]-ar[i-e])+dp[i-e]);
            }
        }
        dp[i]=mn;
    }
    cout<<dp[n-1]<<endl;


    
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>	
#include<cmath>
using namespace std;
int main() {
	long long n, h, w, a, b, sum = 0; cin >> n >> h >> w;
	for (int i = 1; i <= n; i++) {
		cin >> a >> b;
		if (a >= h && b >= w) {
			sum++;
		}
	}
	cout << sum << endl;
	cin >> n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define PRINT(v) for (auto x : (V)) cout <<x <<" " <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
template<class T> struct edge { int from, to; T cost;};
template<class T> inline bool chmin(T& a, T b){if (a>b){a = b; return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if (a<b){a = b; return true;}return false;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }


int main() {
  int n,m; cin >>n >>m;
  vector<ll> A(n); rep(i, n) cin >>A[i];
  sort(all(A));
  vector<pair<ll,int>> bc(m);
  rep(i, m) cin >>bc[i].second >>bc[i].first;
  sort(all(bc)); reverse(all(bc));
  int ai = 0;
  for (int i=0; i<m; i++){
    bool ng = false;
    rep(j, bc[i].second){
      if (ai >= n || bc[i].first <= A[ai]){
        ng = true; break;
      }
      A[ai++] = bc[i].first;
    }
  }
  ll res = 0;
  rep(i, n) res += A[i];
  cout <<res <<endl;
}


Measured memory_bytes: 2560
INF = float('inf')
V, E = map(int, input().split())
dist = [[INF] * V for _ in range(V)] #dist[i][j]:=iからjまで行く最小距離
for i in range(E):
  s, t, d = map(int, input().split())
  dist[s][t] = d
for j in range(V):
  dist[j][j] = 0
for k in range(V):
  for l in range(V):
    for m in range(V):
      dist[l][m] = min(dist[l][m], dist[l][k]+dist[k][m])
flag = 0
for i in range(V):
  if(dist[i][i] < 0):
    flag = 1
    print('NEGATIVE CYCLE')
    break
if(flag == 0):
  for i in range(V):
    for j in range(V):
      if(dist[i][j] == INF):
        dist[i][j] = 'INF'
    print(*dist[i])


Measured memory_bytes: 6280
//yukicoder@cpp14
//author:luckYrat(twitter:@luckYrat_)
//<ここに一言>

//せんげん！
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <bitset>

#include <cctype>
#include <utility>
#include <climits>


//なまえくーかん！
using namespace std;
using ll = long long;
using P = pair<ll,ll>;

//てーすう！
const int mod = 1000000007;
const int inf = (1<<30)-1;
const ll linf = (1LL<<62LL)-1;
const double EPS = (1e-10);

//でふぁいん！
#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)

//みじかく！
#define pb push_back
#define fir first
#define scn second
#define ednl endl

//いぇすのー！
#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")

//きんぼーnほーこー！！
P ar4[4] = {{0,1},{0,-1},{1,0},{-1,0}};
P ar8[8] = {{-1,-1},{-1,0},{-1,1},{0,-1},{0,1},{1,-1},{1,0},{1,1}};
/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる

計算量は変わらないが楽できるシリーズ
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる
*/
template <typename T>
T gcd(T a,T b){
  if(a%b==0)return b;
  else return gcd(b,a%b);
}
template <typename T>
T lcm(T a,T b){
  return a/gcd(a,b)*b;
}
int dp[200][200];
struct z{
	int a,b,c;
};
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main(){
	int a,b,x;cin>>a>>b>>x;//1000 500
	if(b*2 < a){
		cout << ((x-1)/500+1)*b << endl;
	}else{
		int z = 0;
		if(x%1000 > 500)z = 2;
		else if(x%1000 != 0)z = 1;
		cout << min(((x-1)/1000+1)*a,(x/1000)*a+z*b) << endl;
	}

}


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

int main(){
  int N;
  string S;
  cin >> N >> S;
  string a = S.substr(0, N/2);
  string b = S.substr(N/2, N);
  if(a==b)cout << "Yes" << endl;
  if(a!=b)cout << "No" << endl;
  return 0;
}

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

const ll MOD = 1e9 + 7;

int main() {
  int n;
  string s;
  cin >> n >> s;

  map<char, int> m;
  for (char c = 'a'; c <= 'z'; c++) m[c] = 0;

  for (int i = 0; i < n; i++) m[s[i]]++;

  ll ans = 1;
  for (auto e : m) {
    int num = e.second + 1;
    ans = ans * num % MOD;
  }

  ans -= 1;
  cout << ans << endl;
}


Measured memory_bytes: 3768
#include<bits/stdc++.h>
using namespace std;
int main(){
        int n;
        cin>>n;
        int* h=new int[n];
        long long int p=0,ans=0;
        for(int i=0;i<n;i++){
            cin>>h[i];
            if(i!=0&&p>h[i]){
                ans+=(p-h[i]);
            }
            else{
                p=h[i];
            }
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 4376
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
#include <string>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    if(a<b){
        printf("0\n");
    }else{
        printf("10\n");
    }
    return 0;
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#define MOD 1000000007
#define INF (1LL<<30)
#define LLINF (1LL<<60)
#define PI 3.14159265359
#define EPS 1e-12
//#define int ll

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

string s[105];
signed main(void)
{
	int h, w;
	cin >> h >> w;
	REP(i, h) cin >> s[i];

	REP(i, 2*h) {
		REP(j, w) {
			cout << s[i/2][j];
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
bool ok[11];
bool ok2[11][11];
set<int> st;
int main(){
    int n;
    string s;
    cin >> n >> s;
    rep(i,n){
        rep(j,10)rep(k,10){
            if(ok2[j][k]){
                st.insert(j * 100 + k * 10 + (int)(s[i]-'0'));
            }
        }
        rep(j,10)if(ok[j]){
            ok2[j][s[i]-'0'] = true;
        }
        ok[s[i]-'0'] = true;
    }
    cout << st.size() << endl;
}


Measured memory_bytes: 384
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

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

        String line1 = scanner.nextLine();
        String ball_color_s = line1.split(" ")[0];
        String ball_color_t = line1.split(" ")[1];

        String line2 = scanner.nextLine();
        String ball_num_s = line2.split(" ")[0];
        String ball_num_t = line2.split(" ")[1];

        String ball_collor_u = scanner.nextLine();

        Map<String, Integer> ball_map = new HashMap<>();
        ball_map.put(ball_color_s, Integer.valueOf(ball_num_s));
        ball_map.put(ball_color_t, Integer.valueOf(ball_num_t));
        ball_map.put(ball_collor_u, ball_map.get(ball_collor_u) - 1);

        System.out.println(ball_map.get(ball_color_s) + " " + ball_map.get(ball_color_t));
    }

}

Measured memory_bytes: 20948
N, Y = map(int, input().split())

for m in range(2001):
    nokori = Y - 10000*m
    for g in range(2001):
        nokori -= 5000*g
        if nokori < 0: break
        sen_mai = float(nokori)/1000
        if nokori==sen_mai*1000 and m+g+sen_mai==N:
            print('{} {} {}'.format(m,g,int(sen_mai)))
            exit()
        else:
            nokori = Y - 10000*m
            continue

print('-1 -1 -1')


Measured memory_bytes: 41452
n = int(input())
al = list(map(int, input().split()))

foud = 0
twod = 0

for i in range(n):
    if al[i] % 4 ==0:
        foud += 1
    elif al[i] % 2 ==0:
        twod += 1
        
if (foud*2+1)+max(0,(twod-1)) >=n:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 15020
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char const* argv[]) {
	int N;
	int d[110];
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &d[i]);
	}
	sort(d, d + N, greater<int>());

	int ans = 0;
	int tmp = 110;
	for (int i = 0; i < N; i++) {
		if (d[i] < tmp) {
			ans++;
		}
		tmp = d[i];
	}
	printf("%d", ans);

	return 0;
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;

vector<int> fac(300001); //n!(mod M)
vector<int> ifac(300001); //k!^{M-2} (mod M)

long long fpow(long long a,long long n){
  long long ret=1;
  if(n==1) return a;
  if(n%2==0) {
      ret = fpow(a*a%mod, n/2) %mod ;
  }else {
      ret = (a%mod)*fpow(a*a%mod, n/2) %mod;
  }
  return ret %mod;
}
int comb(int a, int b){ //aCbをmod計算
    if(a == 0 && b == 0)return 1;
    if(a < b || a < 0)return 0;
    int tmp = ifac[a-b]* ifac[b] % mod;
    return tmp * fac[a] % mod;
}
const int D = 60;
int to[D][MX];

signed main(){
    int n,m;
    cin >> n >>m;
    priority_queue<int> q;
    rep(i,n) {
        int a;
        cin >> a;
        q.push(a);
    }
    rep(i,m) { 
        int ma = q.top();
        q.pop();
        q.push(ma/2);
    }
    int ans = 0;
    while(q.size()>0) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 6136
import java.io.*;
import java.util.*;

class Main {

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		double[] x = new double[N];
		double[] y = new double[N];
		for (int i = 0; i < N; i++) {
			x[i] = sc.nextDouble();
			y[i] = sc.nextDouble();
		}

		int[] a = new int[N];
		for (int i = 0; i < N; i++) {
			a[i] = i;
		}

		double d = 0.0;
		while (true) {
			for (int i = 0; i < N - 1; i++) {
				d += Math.sqrt(Math.pow(x[a[i + 1]] - x[a[i]], 2) + Math.pow(y[a[i + 1]] - y[a[i]], 2));
			}
			if (!nextPermutation(a)) break;
		}

		System.out.println(d / (double) fact(N));
	}

	private static int fact(int n) {
		if (n == 1) return 1;
		return n * fact(n - 1);
	}

	private static boolean nextPermutation(int[] a) {
		int n = a.length, k = n - 2, l = n - 1;
		while (k >= 0) {
			if (a[k] < a[k + 1]) break;
			k--;
		}
		if (k < 0) return false;
		while (a[l] <= a[k]) l--;
		swap(a, k, l);
		k++;
		n--;
		while (k < n) swap(a, k++, n--);
		return true;
	}

	private static void swap(int[] a, int i, int j) {
		int t = a[i];
		a[i] = a[j];
		a[j] = t;
	}
}


Measured memory_bytes: 23764