akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define lol long long
#define fixed(x) fixed<<setprecision(x)
#define EPS (1e-10)
#define equals(a,b) (fabs((a) - (b)) < EPS)

class Point{
  public:
  double x,y;

  Point(double x=0, double y=0):x(x),y(y){}

  Point operator + (Point p) {return Point(x+p.x, y+p.y);}
  Point operator - (Point p) {return Point(x-p.x,y-p.y);}
  Point operator * (double a) {return Point(a*x,a*y);}
  Point operator / (double a) {return Point(x/a,y/a);}

  double abs(){return sqrt(norm());}
  double norm(){return x*x+y*y;}

  bool operator < (const Point &p) const{
    return x != p.x ? x < p.x : y < p.y;
  }

  bool operator == (const Point &p) const{
    return (fabs(x-p.x) < EPS && fabs(y-p.y) < EPS);
  }
};
// ベクトルを表す
typedef Point Vector;
// 線分を表す
struct Segment{
  Point p1,p2;
};
// 直線を表す
typedef Segment Line;
// 円を表す
class Circle{
  public:
  Point c;
  double r;
  Circle(Point c=Point(), double r=0.0): c(c),r(r){}
};
// 多角形を表す
typedef vector<Point> Polygon;



// ベクトルaとbの内積
double dot(Vector a, Vector b);
// ベクトルaとbの外積
double cross(Vector a, Vector b);
// ベクトルaとbのなす角
double VecAngle(Vector a, Vector b);
// ベクトルaとbの直交判定
bool isOrthogonal(Vector a, Vector b);
// ベクトルaとbの平行判定
bool isParallel(Vector a, Vector b);
// 線分sに対する点pの射影
Point projection(Segment s, Point p);
// 線分sを軸とした点pの線対称の点
Point reflect(Segment s, Point p);


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int x[3],y[3];
  cin >>x[0]>>y[0]>>x[1]>>y[1];
  Segment s={Point(x[0],y[0]),Point(x[1],y[1])};
  int q;
  cin >>q;
  for(int i=0;i<q;i++){
    int x,y;
    cin >>x>>y;
    Point ans=reflect(s,Point(x,y));
    cout <<fixed(9)<<ans.x<<' '<<fixed(9)<<ans.y<<'\n';
  }

  return (0);
}

// ベクトルaとbの内積
double dot(Vector a, Vector b){
  return (a.x*b.x + a.y*b.y);
}
// ベクトルaとbの外積
double cross(Vector a, Vector b){
  return (a.x*b.y - a.y*b.x);
}
// ベクトルaとbのなす角
double VecAngle(Vector a, Vector b){
  return acos((dot(a,b)/(a.abs()*b.abs())));
}
// ベクトルaとbの直交判定
bool isOrthogonal(Vector a, Vector b){
  return equals(dot(a,b),0.0);
}
// ベクトルaとbの平行判定
bool isParallel(Vector a, Vector b){
  return equals(cross(a,b),0.0);
}
// 線分sに対する点pの射影
Point projection(Segment s, Point p){
  Vector base = s.p2 - s.p1;
  double r = dot(p - s.p1, base)/(base.norm());
  return (s.p1 + base*r);
}
// 線分sを軸とした点pの線対称の点
Point reflect(Segment s, Point p){
  return (p + (projection(s,p) - p) *2.0);
}


Measured memory_bytes: 3304
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>
#include <bits/stdc++.h>

#define countof(a) (sizeof(a)/sizeof(*a))

#define vi vector<int>
#define vvi vector<vector<int> >
#define pi pair<int,int>
#define fi first
#define se second

#define FOR(var, to)          for (register s64 var = 0; var < (s64)to; var++)
#define FROMTO(var, from, to) for (register s64 var = from; var <= (s64)to; var++)

#define INIT(var) FOR(i,countof(var)) var[i] = 0
#define INPUT(var) FOR(i,countof(var)) var[i] = ri()

#define SORT(v) qsort(v,countof(v),sizeof(*v),int_less)
#define SORTT(v) qsort(v,countof(v),sizeof(*v),int_greater)

#define MOD 1000000007
#define INF (1 << 30)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

using namespace std;

static inline int ri() {
  int a;
  scanf("%d", &a);
  return a;
}

static inline s64 rs64() {
  s64 a;
  scanf("%" SCNd64, &a);
  return a;
}

static inline void wi(int a) {
  printf("%d", a);
}

static inline void wu64(u64 a) {
  printf("%" PRIu64, a);
}

static inline void ws64(s64 a) {
  printf("%" PRId64, a);
}

int int_less(const void *a, const void *b) {
  return (*((const int*)a) - *((const int*)b));
}
int int_greater(const void *a, const void *b) {
  return (*((const int*)b) - *((const int*)a));
}

int main() {
    char s[1000];
    scanf("%s",s);
    bool ret = true;
    if (s[0] != 'A') ret = false;
    int c = 0;
    for (int i = 2; i <= (int)strlen(s)-2; i++) {
        if (s[i] == 'C') c++;
    }
    if (c != 1) ret = false;
    int t = 0;
    for (char* p = s; *p; p++) {
        if (*p < 'a' || *p > 'z')t++;
    }
    if (t != 2) ret = false;
    
    printf(ret?"AC":"WA");
  
  return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var (x1, y1, x2, y2) = readLine()!!.split(" ").map(String::toDouble)
    val distance = Math.sqrt(Math.pow(x2 - x1, 2.0) + Math.pow(y2 - y1, 2.0))
    println("$distance")
}



Measured memory_bytes: 32000
#include <bits/stdc++.h>
using namespace std;
const int  N=1e5+1;
int n,k,A[N];
int gcd(int a,int b){
    if(a%b==0)
        return b;
    return gcd(b,a%b);
}
int main()
{
    scanf("%d %d",&n,&k);
    scanf("%d",&A[1]);
    int x=A[1],maks=A[1];
    for(int i=2;i<=n;i++){
        scanf("%d",&A[i]);
        maks=max(maks,A[i]);
        x=gcd(x,A[i]);
    }
    if(k>maks){
        printf("IMPOSSIBLE");
        return 0;
    }
    if(k%x!=0){
        printf("IMPOSSIBLE");
        return 0;
    }
    printf("POSSIBLE");
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
using namespace std;
constexpr int64_t INF = 1000000000;

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

  int32_t N, K, S;
  cin >> N >> K >> S;
  vector<int> res(N, INF);
  if (S != INF) {
    for (int i = 0; i <K; i++) {
      res[i] = S;
    }
  } else {
    for (int i = 0; i <N - K; i++) {
      res[i] = S - 1;
    }
  }
  for (auto val : res) {
    cout << val << " ";
  }
  cout << endl;
  return 0;
}


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

int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    vector<int> size(n);
    long long max=LLONG_MAX;
    rep(i,n){
        cin>>a[i];
        if(i==0) size[i]=a[i];
        else size[i]=size[i-1]+a[i];
    }
    vector< vector<ll> > dp(n,vector<ll>(n,max));
    rep(i,n){
        dp[i][i]=0;
    }
    //差をiでとる
    For(i,1,n){
        //jを回す
        For(j,0,n-i){
            ll tmp=LONG_MAX;
            ll sum=0;
            For(k,j,j+i){
                tmp=min(tmp,dp[j][k]+dp[k+1][j+i]);
                sum+=a[k];
            }
            sum+=a[j+i];
            dp[j][j+i]=tmp+sum;
        }
    }
    cout<<dp[0][n-1]<<endl;
    return 0;
}

Measured memory_bytes: 1536
N = int(input())
A = [ int(a) for a in input().split() ] # [45, 21, 30, 45]
A_sort = sorted(A) # [21, 30, 45, 45]
A_sort.sort(reverse=True) # [45, 45, 30, 21]
sum_alice = 0
sum_bob = 0
for i in range(0,N):
  if i%2 == 0:
    sum_alice += A_sort[i]
  else:
    sum_bob += A_sort[i]
print(sum_alice - sum_bob)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#define INF 1000000001

using namespace std;

int nos;

void merge(vector<int>& A, int left, int mid, int right) {
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> L(n1+1);
	vector<int> R(n2+1);
	for (int i = 0; i < n1; ++i) {
		L[i] = A[left+i];
	}
	L[n1] = INF;
	for (int i = 0; i < n2; ++i) {
		R[i] = A[mid+i];
	}
	R[n2] = INF;

	int lind = 0;
	int rind = 0;
	for (int i = left; i < right; ++i) {
		if (L[lind] < R[rind]) {
			A[i] = L[lind];
			++lind;
		}
		else {
			A[i] = R[rind];
			++rind;
		}
		++nos;
	}
	return;
}

void merge_sort(vector<int>& S, int left, int right) {
	if (left+1 < right) {
		int mid = (left+right)/2;
		merge_sort(S,left,mid);
		merge_sort(S,mid,right);
		merge(S,left,mid,right);
	}
	return;
}

int main(void) {
	int n;
	cin >> n;
	vector<int> S(n);
	for (int i = 0; i < n; ++i) {
		cin >> S[i];
	}
	nos = 0;
	merge_sort(S,0,n);
	for (int i = 0; i < n; ++i) {
		cout << S[i];
		if (i < n-1) {
			cout << " ";
		}
	}
	cout << endl;
	cout << nos << endl;
	return 0;
}



Measured memory_bytes: 6904
#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::*;
use std::collections::*;
use std::ops::*;
use procon::*;

pub fn main() -> () {
    let N = read_line().parse::<usize>().unwrap();
    let names = read_vec(N);

    let counts = {
        let mut map = "MARCH"
            .chars()
            .map(|c| (c, 0))
            .collect::<HashMap<char, i64>>();

        for name in names {
            let c = name.chars().next().unwrap();
            if let Some(value) = map.get_mut(&c) {
                *value += 1;
            }
        }

        map.values().cloned().collect::<Vec<i64>>()
    };

    let combi = vec![
        (0, 1, 2),
        (0, 1, 3),
        (0, 1, 4),
        (0, 2, 3),
        (0, 2, 4),
        (0, 3, 4),
        (1, 2, 3),
        (1, 2, 4),
        (1, 3, 4),
        (2, 3, 4),
    ];
    let mut sum = 0;
    for (i, j, k) in combi {
        sum += counts[i] * counts[j] * counts[k];
    }

    println!("{}", sum);
    return;
}

pub mod procon {
    use std;
    use std::collections::*;
    use std::io;
    use std::mem;
    use std::str::FromStr;

    pub fn read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.trim_right().to_owned()
    }

    pub fn read_words<T>() -> Vec<T>
    where
        T: std::str::FromStr,
        T::Err: std::fmt::Debug,
    {
        let mut buf = String::new();
        io::stdin().read_line(&mut buf).unwrap();
        buf.split_whitespace()
            .map(|word| T::from_str(word).unwrap())
            .collect()
    }

    pub fn read_vec(len: usize) -> Vec<String> {
        let mut vec = Vec::new();
        while vec.len() < len {
            let line = read_line();
            for word in line.split_whitespace() {
                vec.push(word.to_owned());
            }
        }
        assert!(vec.len() == len);
        vec
    }

    pub fn make_vec<T, F>(len: usize, f: F) -> Vec<T>
    where
        F: Fn(usize) -> T,
    {
        return (0..len).into_iter().map(f).collect();
    }
}


Measured memory_bytes: 9720
line1=input("")
li1=line1.split()
numOfSnuke=eval(li1[0])
numOfSnack=eval(li1[1])
list=[];
num=0
count=1
for i in range(numOfSnuke):
  list.append(0)

while(count<=numOfSnack):
  snack = eval(input(""))
  line=input("")
  li=line.split()
  for item in li:
    list[eval(item)-1]+=1
  count+=1
for i in list:
  if i==0:
    num+=1
print(num)

Measured memory_bytes: 9104
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main()
{
    auto money = 0;
    auto ignore_count = 0;

    // 金額とNGな数字の数を取得
    cin >> money >> ignore_count;

    // 実際にNGな数を取得
    vector<int> num;
    for (auto i = 0 ; i < ignore_count ; i++) {
        auto n = 0;
        cin >> n;
        num.push_back(n);
    }

    // 文字が含まれているか？
    auto includeNum = [](const auto& m, const auto& num) {
        for (auto n: num) {
            if (string::npos != to_string(m).find(to_string(n))) return true;
        }
        return false;
    };

    // NGである数字を使用せずに、金額を支払う
    while(true) {
        if (false == includeNum(money, num)) {
            cout << money;
            break;
        }
        money++;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}

#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)



int main() {
	ll N, M, X;
	std::cin >> N >> M >> X;
	
	vll C(N);
	vector<vll> A(N, vll(M));
	rep(i, 0, N) {
		std::cin >> C[i];
		rep(j, 0, M) {
			std::cin >> A[i][j];
		}
	}


	ll ans = 9999999;
	rep(i, 0, (1LL << N)) {
		vll s(M, 0);
		ll t = 0;

		rep(j, 0, N) {
			if (i & (1LL << j)) {
				rep(k, 0, M) {
					s[k] += A[j][k];
				}
				t += C[j];
			}
		}

		bool flg = true;
		rep(j, 0, M) {
			if (s[j] < X) {
				flg = false;
			}
		}

		if (flg) {
			ans = min(ans, t);
		}
	}

	if (ans == 9999999) {
		ans = -1;
	}
	std::cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3636
#!/usr/bin/env python3
import sys
# 複数の整数の最大公約数を求める
import fractions
from functools import reduce
def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

def solve(N: int, A: "List[int]"):
    print(gcd_list(A))
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 17492
#include <iostream>
#include <vector>
using namespace std;
int n,m;
int c,d,an=0;
bool a[200001]={false};//1,a
bool b[200001]={false};//a,n

int main(){
	cin>>n>>m;
	for(int i=0;i<m;i++){
		cin>>c;
		if(c==1){
			cin>>d;
			a[d]=true;
		}else{
			cin>>d;
			if(d==n){
				b[c]=true;
			}
		}
	}
	for(int i=0;i<n;i++){
		if(a[i]==true&&b[i]==true){
			an=1;
			break;
		}
	}
	if(an==1){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
m, d = list(map(str, input().split()))
ans = 0

if int(d) < 22 or int(m) < 4:
    print(ans)
    exit()

for i in range(4, int(m)+1):
    for j in range(22, int(d)+1):
        if i == int(str(j)[0]) * int(str(j)[1]) and int(str(j)[0]) > 1 and int(str(j)[1]) > 1:
            ans += 1

print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=1e5+5;
vector<ll> V;
int pre[maxn];
int main() {
    int n;cin>>n;
    if(n%10==7||n/10%10==7||n/100%10==7) puts("Yes");
    else puts("No");
    return 0;
}

Measured memory_bytes: 3624
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
INF = 10**9
mod = 10**9+7

def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

N,P = I()
A = l()
odd = 0
even = 0
for i in range(N):
    if A[i]%2 == 0:
        even += 1
    else:
        odd += 1
ans = 0
if P == 0:
    for i in range(0,odd+1,2):
        ans += cmb(odd,i)
    print(ans*(2**even))
else:
    for i in range(1,odd+1,2):
        ans += cmb(odd,i)
    print(ans*(2**even))

Measured memory_bytes: 77408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)

#define DEBUG

#ifdef DEBUG
#define var_dump(...) fprintf(stdout, __VA_ARGS__)
#define dump(a) cout << a << "\n";
#else
#define var_dump(...) 42
#define dump(a) 42
#endif

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://beta.atcoder.jp/contests/abc090/tasks/abc090_b

int main() {
    int A, B;
    cin >> A >> B;

    int cnt = 0;
    FOR(i, A, B+1) {
        string rev = to_string(i);
        std::reverse(rev.begin(), rev.end());

        if (rev == to_string(i)) {
            cnt++;
        }
    }

    cout << cnt << "\n";

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector <long long> v;
	for(long long i=2;(i*i)<=n;i++){
		long long temp=0;
		while(n%i==0){
			temp++;
			n/=i;
		}if(temp>0){
			v.push_back(temp);
		}
	}if(n>1){
		v.push_back(1);
	}long long ans=0;
	for(long long i=0;i<v.size();i++){
		long long temp=1;
		while((temp*(temp+1)/2)<=v[i]){
			temp++;
		}ans+=(temp-1);
	}cout<<ans<<endl;
	return 0;
}

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

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

    string s[n], t[n];
    for (int i = 0; i < n; i++) cin >> s[i], t[i] = s[i];

    // buble sort
    for (int i = 0; i < n; i++) {
        for (int j = n - 1; j > 0; j--) {
            if (t[j][1] < t[j - 1][1]) swap(t[j], t[j - 1]);
        }
    }

    // select sort
    for (int i = 0; i < n; i++) {
        int minj = i;
        for (int j = i; j < n; j++) {
            if (s[j][1] < s[minj][1]) minj = j;
        }
        swap(s[i], s[minj]);
    }

    for (int i = 0; i < n; i++) cout << t[i] << (i == n - 1 ? "" : " ");
    cout << endl << "Stable" << endl;

    bool f = true;
    for (int i = 0; i < n; i++) {
        cout << s[i] << (i == n - 1 ? "" : " ");
        if (s[i] != t[i]) f = false;
    }
    cout << endl << (f ? "Stable" : "Not stable") << endl;

    return 0;
}



Measured memory_bytes: 3144
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;

bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd_(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}

int main(){
  
  int h,w,a,b;
  cin>>h>>w>>a>>b;
  char s[h][w];
  REP(i,h){
    REP(j,w){
      if(i<b){
        if(j<a){
          s[i][j] = '0';
        }else{
          s[i][j] = '1';
        }
      }else{
        if(j<a){
          s[i][j] = '1';
        }else{
          s[i][j] = '0';
        }
      }
    }
  }
  REP(i,h){
    REP(j,w){
      cout<<s[i][j];
    }
    cout<<endl;
  }
  return 0;
}

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

vector<int> primes;
bool table[100001] = {false};

int main(){
	primes = vector<int>();	
	for(int i = 2; i < 100000; i++){
		if(!table[i]){
			primes.push_back(i);
			for(int j = i*2;j < 100000; j+=i){
				table[j] = true;
			}
		}
	}

	int n,n2;
	cin >> n;
	n2 = n;
	vector<int> fct = vector<int>();
	int it = 0;
	while(n != 1 && it != primes.size()){
		if(n % primes[it] == 0){
			fct.push_back(primes[it]);
			while(n % primes[it] == 0){
				n /= primes[it];
			}
		}
		it++;
	}
	if(n == n2){
		cout << n-1 << endl;
	}
	else{
		double ans = n2;
		for(int i = 0; i < fct.size(); i++){
			ans *= (1.0 - 1.0/fct[i]);
		}
		if(n != 1){
			ans *= (1.0 - 1.0/n);
		}
		cout << (int)ans << endl;
	}

	return 0;
}



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

int main() {
    int H,W;
    cin >>H>>W;
    vector<string> a;
    for(int i=0; i<H; i++){
        string s;
        cin>>s;
        a.push_back(s);
    }

    for(int i=0; i<a.size(); i++){
       if(a[i].find("#") == string::npos){
           a.erase(a.begin()+i);
           i--;
       }
    }

    for(int i=0; i<a[0].size(); i++){
        bool ok = true;
        for(int j=0; j<a.size(); j++){
            if(a[j][i] == '#'){
                ok = false;
                break;
            }
        }
        if(ok){
            for(int j=0; j<a.size(); j++){
                a[j].erase(a[j].begin()+i);
            }
            i--;
        }
    }

    for(int i=0; i<a.size(); i++){
        cout << a[i] << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for (int i = int(a); i < int(b); ++i)
typedef long long ll;
long long mod = 1e9 + 7;
const int iINF = 0x3f3f3f3f;
const long long INF = 1LL << 60;
using namespace std;

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;
}

map<int64_t, int> prime_factor(int64_t n)
{
  map<int64_t, int> ret;
  for (int64_t i = 2; i * i <= n; i++)
  {
    while (n % i == 0)
    {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

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

  map<ll, ll> mp;

  ll tmp = -1;
  for (auto p : prime_factor(n))
  {
    while (p.second--)
    {
      mp[p.first]++;
    }
  }

  ll ans = 0;
  for (auto mi : mp)
  {
    ll v = mi.second;
    int tmp = 1;
    for (;;)
    {
      if (v - tmp < 0)
        break;

      ans++;
      v -= tmp;
      tmp++;
    }
  }
  cout << ans << endl;
  return 0;

  // return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main() {
	int a;
	bool y=true;
	cin >> a;
	for (int i = 0;i < a;i++) {
		int x;
		cin >> x;
		if (x % 2 == 0) {
			if (x %3 != 0 && x % 5 != 0) {
				cout << "DENIED";
				y = false;
				break;
			}
		}
	}
	if (y == true) {
		cout << "APPROVED";
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		
		System.out.println((H-h)*(W-w));
	}
	
}


Measured memory_bytes: 22868
#include <stdio.h>

int main(int argc, const char * argv[]) {
    char string[10002];
    int number;
    scanf("%d", &number);
    while (getchar() != '\n') {
        continue;
    }
    gets(string);
    for (int i = 0; i < 10002 && string[i] != '\0'; i++) {
        if (string[i] + number > 90) {
            printf("%c", string[i] + number - 26);
        }
        else {
            printf("%c", string[i] + number);
        }
    }
    return 0;
}


Measured memory_bytes: 128
#include<stdio.h>

int main(int argc, char *argv[]){
  long long int a, b, x;
  scanf("%lld %lld %lld", &a, &b, &x);
  //printf("%lld %lld %lld\n", a, b, x);

  long long cnt_a = a / x;
  long long cnt_b = b / x;
  long long cnt = cnt_b - cnt_a;
  if((a%x) == 0) cnt++;

  printf("%lld\n", cnt);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int one[] ={0,0,0,0,0,0,1,1,1,2}; 
int two[] ={1,1,1,2,2,3,2,2,3,3};
int thr[] ={2,3,4,3,4,4,3,4,4,4};
int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  map<char,int> m;
  rep(i,n){
      if(s[i][0] == 'M'|| s[i][0] == 'A'|| s[i][0] == 'R'||s[i][0] == 'C'||s[i][0] == 'H'){
        m[s[i][0]]++;
      }
  }
  ll res = 0;
  vector<ll> d(5,0);
  int index = 0;
  for(auto ma:m){
    d[index] = (ll)ma.second;
    index++;
  }
  rep(i,10) res+=(d[one[i]]*d[two[i]]*d[thr[i]]);
  cout << res <<endl;
}

Measured memory_bytes: 6144
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main()
{
  ll h,w,n,t,s,res;
  cin >> h >> w;
  n=h*w;
  if(h%3==0||w%3==0){
    res=0;
  }else{
    t=(h/3)*w;
    s=max(((h-h/3)/2)*w,(w/2)*(h-h/3));
    res=max({t,s,n-t-s})-min({t,s,n-t-s});
    t=(h/3+1)*w;
    s=max(((h-h/3-1)/2)*w,(w/2)*(h-h/3-1));
    res=min(res,max({t,s,n-t-s})-min({t,s,n-t-s}));
    t=(w/3)*h;
    s=max(((w-w/3)/2)*h,(h/2)*(w-w/3));
    res=min(res,max({t,s,n-t-s})-min({t,s,n-t-s}));
    t=(w/3+1)*h;
    s=max(((w-w/3-1)/2)*h,(h/2)*(w-w/3-1));
    res=min(res,max({t,s,n-t-s})-min({t,s,n-t-s}));
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 3628
def calculate(A, B, C):
    for i in range(1000):
        if A % 2 == 1 or B % 2 == 1 or C % 2 == 1:
            return i
        else:
            _A = (B + C) // 2
            _B = (A + C) // 2
            _C = (A + B) // 2
            A, B, C = _A, _B, _C
    return -1

A, B, C = map(int, input().split())
print(calculate(A, B, C))

Measured memory_bytes: 38384
#include<stdio.h>

int main()
{
    int k,n,max_dis=-1;

    scanf("%d%d",&k,&n);

    int arr[n];

    scanf("%d",&arr[0]);
    for(int i=1;i<n;i++)
    {
        scanf("%d",&arr[i]);
        if(arr[i]-arr[i-1]>max_dis)
            max_dis=arr[i]-arr[i-1];
    }

    if((k-arr[n-1])+arr[0]>max_dis)
        max_dis=(k-arr[n-1])+arr[0];

    printf("%d",k-max_dis);

    return 0;
}


Measured memory_bytes: 896
// ABC177C.cpp :

#include <iostream>
#include <vector>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<(n);++i)

const int mod = 1'000'000'007;
int main()
{
    int n;
    cin >> n;
    vector<ll>a(n);
    ll sum = 0;
    ll ans = 0;
    rep(i,n){
        cin >> a.at(i);
        ans = (ans + (a.at(i) * sum)) % mod;
        sum = (sum+a.at(i)) % mod;
    }
    cout << ans << endl;
}


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

const int MAX_N = 100 * 1000, MAX_M = 100 * 1000;
vector<int> adjLis[MAX_N + 1], adjInd[MAX_N + 1], EdgeDir[MAX_N + 1];
bitset<MAX_N + 1> markVer, isOddDeg;
stack<int> path;

void dfs(int preVer, int v) {
    markVer[v] = true;
    int u;
    if (isOddDeg[v]) {
        path.push(v);
        if (path.size() > 1) {
            isOddDeg[v] = false;
            int w;
            while (path.size() > 1) {
                u = path.top();
                path.pop();
                w = path.top();
                for (int i = 0; i < adjLis[u].size(); i++) {
                    if (adjLis[u][i] == w) {
                        EdgeDir[u][i] = !EdgeDir[u][i];
                        EdgeDir[w][adjInd[u][i]] = !EdgeDir[w][adjInd[u][i]];
                        break;
                    }
                }
            }
            isOddDeg[w] = false;
            path.pop();
        }
    } else if (!path.empty())
        path.push(v);
    for (int i = 0; i < adjLis[v].size(); i++) {
        u = adjLis[v][i];
        if (!markVer[u])
            dfs(v, u);
    }
    if (!path.empty())
        if (!isOddDeg[v]) {
            path.pop();
            if (path.top() != preVer) {
                path.push(v);
                path.push(preVer);
            }
        } else
            path.push(preVer);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N, M;
    cin >> N >> M;
    int A[M + 1], B[M + 1];
    for (int i = 1; i <= M; i++) {
        cin >> A[i] >> B[i];
        adjLis[A[i]].push_back(B[i]);
        adjLis[B[i]].push_back(A[i]);
        adjInd[A[i]].push_back(adjLis[B[i]].size() - 1);
        adjInd[B[i]].push_back(adjLis[A[i]].size() - 1);
        EdgeDir[A[i]].push_back(true);
        EdgeDir[B[i]].push_back(false);
        isOddDeg[A[i]] = !isOddDeg[A[i]];
    }
    if (M % 2 == 1)
        cout << "-1\n";
    else {
        dfs(-1, 1);
        int u;
        for (int v = 1; v <= N; v++)
            for (int i = 0; i < adjLis[v].size(); i++) {
                u = adjLis[v][i];
                if (EdgeDir[v][i])
                    cout << v << ' ' << u << '\n';
            }
    }
    return 0;
}


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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x, y) CPP_CAT_I(x, y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x, y) x##y

#define ASSERT(expr...) assert((expr))

using i8 = int8_t;
using u8 = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;
// }}}

constexpr i64 INF = 1'010'000'000'000'000'017LL;

constexpr i64 MOD = 1'000'000'007LL;

constexpr f64 EPS = 1e-12;

constexpr f64 PI = 3.14159265358979323846;

#define M5 100007
#define M9 1000000000

// util {{{
#define FOR(i, start, end) for (i64 i = (start), CPP_CAT(i, xxxx_end) = (end); i < CPP_CAT(i, xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f, c, ...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ##__VA_ARGS__); })(c))
#define ll long long int
#define VI vector<int>
template <typename C>
i64 SIZE(const C &c)
{
    return static_cast<i64>(c.size());
}

template <typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

template <typename T, typename U, typename Comp = less<>>
bool chmax(T &xmax, const U &x, Comp comp = {})
{
    if (comp(xmax, x))
    {
        xmax = x;
        return true;
    }
    return false;
}

template <typename T, typename U, typename Comp = less<>>
bool chmin(T &xmin, const U &x, Comp comp = {})
{
    if (comp(x, xmin))
    {
        xmin = x;
        return true;
    }
    return false;
}
// }}}

// init {{{
struct ProconInit
{
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit()
    {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if (AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;
// }}}

//--------------------------------------------------------------------

bool isOK(int mid, double key)
{
}

int binary_search(double key)
{
    int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
    int right = 2000000000;
    /* どんな二分探索でもここの書き方を変えずにできる！ */
    while (right - left > 1)
    {
        int mid = left + (right - left) / 2;

        if (isOK(mid, key))
            right = mid;
        else
            left = mid;
    }

    /* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
    return right;
}

bool isKaibun(string st)
{
    bool ans = true;
    int n = st.length();
    REP(i, n / 2)
    {
        if (st[i] != st[n - i - 1])
        {
            return false;
        }
    }
    return true;
}

int toInt(char a)
{
    return a - '0';
}

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

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

void solve()
{
    int N;
    cin >> N;
    vector<int> a(N);
    REP(i, N)
    cin >> a[i];

    int x = a[0];
    REP(i, N - 1)
    {
        x = x ^ a[i + 1];
    }

    REP(i, N)
    {
        int y = x ^ a[i];
        cout << y << " ";
    }
}

signed main()
{

    solve();

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;
template<class T> void dprint(T s){
  if(DEBUG){ cout << s << "\n"; }
}

int main(int argc, char *argv[]){
  if(argc>1 && argv[1][0]=='D'){ DEBUG = 1;}
  ll N,D; cin>>N>>D;
  int ans = 0;
  REP(i,N){
    ll x,y; cin>>x>>y;
    if(x*x+y*y<=D*D){++ans;}
  }
  cout << ans << "\n";
}

Measured memory_bytes: 3632
#coding: utf-8

while True:
    s = raw_input()
    if s  == '.':
        break
    l = []
    a = 0
    for i in range(len(s)):
        if s[i] == '(' or s[i] == '[':
            l.append(s[i])
        elif s[i] == ')':
            if l and l[-1] == '(':
                l = l[:-1]
            else:
                a = 1
                break
        elif s[i] == ']':
            if l and l[-1] == '[':
                l = l[:-1]
            else:
                a = 1
                break
        else:
            pass
    if l or a == 1:
        print 'no'
        continue
    print 'yes'

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

int main() {
	// your code goes here
int m,n;
  cin>>m>>n;
  if(m!=1&&n!=1)
    cout<<"1";
  if(m!=2&&n!=2)
    cout<<"2";
  if(m!=3&&n!=3)
    cout<<"3";
  return 0;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define vout(x) rep(i,x.size()) cout << x[i] << " "
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    ll a, b, x; cin >> a >> b >> x;
    ll ans;
    if (a != 0) ans = b/x - (a-1)/x;
    else ans = b/x + 1;
    cout << ans << endl;
}

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

#define ll long long

int main(void){

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

    int m;
    cin>>m;
    for(int i=0;i<m;i++){
        int p,x;
        cin>>p>>x;
        cout<<sum - t[p-1] + x << endl;
    }

    return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            int cellsCount = (int) Math.pow(Double.parseDouble(br.readLine()), 2);
            int blackCellsCount = cellsCount - Integer.parseInt(br.readLine());

            System.out.println(blackCellsCount);

        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

Measured memory_bytes: 22484
n = int(input())
ls_a = list(map(int, input().split()))

Alice = 0
Bob = 0

ls_b = sorted(ls_a, reverse=True)

for i in range(n):
    if i % 2 == 0:
        Alice += ls_b[i]
    elif i % 2 == 1:
        Bob += ls_b[i]

print(Alice - Bob)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <array>
#include <algorithm>
#include <cstring>
#include <queue>
#include<iomanip>
#include <numeric>

using namespace std;

//#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))

typedef long long ll;

//static const ll MOD = 1000000007;

int main() {
    ll N;
    ll answer = 0;

    // input
    cin >> N;

    // process
    for(ll i=1;i<N;i++){
        answer+=i;
    }

    cout << answer << endl;

    return 0;
}

Measured memory_bytes: 256
A, B, C = map(int, input().split())
ans = 0
max_ABC = max(A, B, C)

if max_ABC != A:
    ans += (max_ABC - A) // 2
    A += 2 * ((max_ABC-A) // 2)

if max_ABC != B:
    ans += (max_ABC - B) // 2
    B +=  2 * ((max_ABC-B) // 2)

if max_ABC != C:
    ans += (max_ABC - C) // 2
    C += 2 * ((max_ABC-C) // 2)

if 3 * max_ABC - (A+B+C) == 2:
    ans += 1
elif 3 * max_ABC - (A+B+C) == 1:
    ans += 2
print(ans)

Measured memory_bytes: 3064
/**********************************************
*               COMMENT BOX                   *
**********************************************/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout<<"YES\n"
#define no cout<<"NO\n"
#define ll long long
#define llu unsigned long long
#define pb push_back
#define mp make_pair
#define tc int t; cin>>t; while(t--)
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n-1 ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define fast ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const long long int inf64 = 1e18;
const int mod = inf + 7;
const int N = 1000010;

int main()
{
    fast;
    int n;
    cin >> n;
    ll ans = 1, z = 0;
    ll a[n];
    f(i,0,n)
    {
        cin >> a[i];
        if(a[i] == 0)
            z++;
    }
    if(z > 0)
    {
        cout << 0;
        return 0;
    }
    f(i,0,n)
    {
        if(a[i] <= 1000000000000000000/ans)
            ans *= a[i];

        else
        {
            cout << -1;
            return 0;
        }
    }
    cout << ans;
}


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


void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[], int n) {
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
}
int no = 1, n1;
int recu(int n, int k, int val) {


	if (n == n1) {
		return min(val * 2, val + k);
	}
	return min( recu(n + 1, k, 2 * val), recu(n + 1, k, val + k)              );


}
int digit(int n) {

	int temp = 0;
	while (n) {
		// temp += n % 10;
		n = n / 10;
		temp++;
	}



	return temp;
}

bool check(int a[], int n) {
	for (int i = 0; i < n; ++i)
	{
		/* code */
		if (a[i] % 2)
			return false;
	}
	return true;
}
bool ispalin(int n) {


	string  str = to_string(n);
	// cout<<str<<endl;


	for (int i = 0; i < str.size() / 2; ++i)
	{
		/* code */
		// watch2(str[i],str[str.size()-i-1]);
		if (str[i] != str[str.size() - i - 1]) {
			return false;
		}
	}


	return true;


}

int main() {
	int i,  n, m, k;
	// int sum = 0;
	c_p_c();
	ll no;
	cin>>no;

	ll ans = no/500;
	ll rem = no%500;

	ll sum =0;
	sum+=(1000*ans);
	ll remmm = rem/5;
	sum+=(remmm*5);
	cout<<sum<<endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
const int INF = 2100100100;

int main() {
    string ramen;
    cin >> ramen;
    int price = 700;
    for (int i=0;i<3;i++){
        if(ramen.at(i) == 'o')
            price+=100;
        else if(ramen.at(i) == 'x');
        else cout << "input error" << endl;
    }
    cout << price << endl;
    return 0;

}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

const int N = 1e6;
const int LOG = 21;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LLMOD = 998244353;
const ll LLINF = 1e18;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    map<int, vi> tasks;
    forn(i, n) {
        int a, b;
        cin >> a >> b;
        tasks[a].pb(b);
    }
    multiset<int> q;
    ll ans = 0;
    forn(i, m) {
        if (tasks.count(i + 1)) for (int x : tasks[i + 1]) q.insert(-x);
        if (!q.empty()) ans -= *q.begin(), q.erase(q.begin());
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 11008
m, d = map(int,input().split())
ans = 0

for i in range(1,m+1):
    for j in range(1, d + 1):
        if i == int(j/10)*int(j%10) and int(j%10) >= 2 and int(j/10) >= 2:
            ans += 1

print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
  ll n;
  cin >> n;
  ll k;
  cin>>k;
  
  ll arr[n];
  ll dp[n];
  
  for(ll i=0; i<n; i++)
  {
    cin >> arr[i];
  }
  dp[0] = 0;

  for(ll i=1; i<n; i++)
  {
    dp[i] = INT_MAX;
    for(int j=1; j<=k && i-j>=0; j++)
      dp[i] = min(dp[i], dp[i-j] +abs(arr[i] - arr[i-j]) );
  }
  cout<< dp[n-1];
}

Measured memory_bytes: 5112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <functional>
#include <sstream>
#include <complex>
#include <climits>
using namespace std;

#define REP(i,a,n) for(int i=(a);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define EPS 1e-8

int main(){
	int n,p;
	int owan[64],temoto[64];
	while(scanf("%d%d",&n,&p),n|p){
		rep(i,64)owan[i]=temoto[i]=0;
		owan[0] = p;
		int cur = 0;
		for(int i=0; i<=1000000; i++){
			if( owan[cur]>0 ){
				owan[(cur+1)%n] = owan[cur]-1;
				temoto[cur]++;
				if( owan[cur]-1==0 ){
					if( temoto[cur]==p ){
						printf("%d\n",cur);
						break;
					}
				}
			}else{
				owan[(cur+1)%n] = temoto[cur];
				temoto[cur] = 0;
			}
			//printf("next:owan[%d]:%d , temoto[%d]:%d\n",(cur+1)%n,owan[(cur+1)%n],cur,temoto[cur]);
			cur = (cur+1)%n;
		}
	}
	return 0;
}

Measured memory_bytes: 872
#include <stdio.h>
int main()
{
	int n;
	scanf("%d",&n);
	int a[n],i;
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		}
	int high=0,low=1000000001,j;
		for(j=0;j<n;j++){
			if(high<a[j]){
				high=a[j];
				}
			if(low>a[j]){
				low=a[j];
				}
			}
	printf("%d",high-low);
	
	return 0;
}
	


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define mid ((x + y) / 2)
#define left (ind * 2)
#define right (ind * 2 + 1)
#define mp make_pair
#define timer ((double)clock() / CLOCKS_PER_SEC)
#define endl "\n"
#define spc " "
#define d1(x) cerr<<#x<<":"<<x<<endl
#define d2(x, y) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<endl
#define d3(x, y, z) cerr<<#x<<":"<<x<<" "<<#y<<":"<<y<<" "<<#z<<":"<<z<<endl
#define fast_io() ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

typedef long long int lli;
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<double, double> dd;

const int N = (int)(1e6 + 5);
const int LOG = (int)(20);

int n, nx[N], ans, k, f, nd[N], fl, one;
vector<int> v[N];

int dfs(int x) {
	int re = 0;
	for(auto i : v[x]) {
		int val = dfs(i);
		if(val == k)
			ans++;
		else
			re = max(re, val);
	}
	return re + 1;
}

int main() {
	fast_io();
	// freopen("inp.in", "r", stdin);

	cin >> n >> k;
	if(k > n)
		k = n + 10;
	for(int i = 1; i <= n; i++)
		cin >> nx[i];
	if(nx[1] != 1) {
		fl = 1;
		nx[1] = 1;
	}
	for(int i = 1; i <= n; i++)
		if(i != nx[i])
			v[nx[i]].pb(i); 
	for(auto i : v[1]) 
		dfs(i);
	cout << ans + fl;
}

Measured memory_bytes: 33152