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

using namespace std;

const int N = 2e5 + 3;
const int M = 1e6 + 5;
const long long INF = 1e9 + 7;
const int SM = 1e3 + 5;
const double EPS = 3e-16;

int main(){
    long long n, s;
    cin >> n >> s;
    
    vector<long long> w(n + 1), v(n + 1);
    vector<vector<long long>> dp(n + 1, vector<long long>(s + 1));
    
    for(long long i = 1; i <= n; i++){
        cin >> w[i] >> v[i];
    }
    
    for(long long i = 1; i <= n; i++){
        for(long long j = 0; j <= s; j++){
            if(j - w[i] >= 0) dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - w[i]] + v[i]);
            else dp[i][j] = dp[i - 1][j];
        }
    }
    
    cout << dp[n][s];
    return 0;
}

Measured memory_bytes: 80256
#include <bits/stdc++.h>
using namespace std;
#define lson rt<<1
#define rson rt<<1|1
#define scd(x) scanf("%d",&x)
#define scdd(x,y) scanf("%d%d",&x,&y)
const int maxn=3e5+10;
typedef long long ll;
typedef pair<int,int> pii;
const int INF=0x3f3f3f3f;
multiset<int>s;
vector<int>vec;
int main() {
#ifdef LOCAL
    freopen("in.txt","r",stdin);
#endif // LOCAL
    int n;
    //cout<<(1<<18)<<endl;
    scd(n);
    int la=1<<n;
    int mx=0;
    for(int i=1; i<=la; i++) {
        int x;
        scd(x);
        s.insert(x);
        mx=max(x,mx);
    }
    bool flag=false;
    vec.clear();
    vec.push_back(mx);
    multiset<int>::iterator it=s.lower_bound(mx);
    s.erase(it);
    while(!flag) {
        if(vec.size()==la) {
            flag=true;
            break;
        }
        int siz=vec.size();
        for(int i=0; i<siz; i++) {
            multiset<int>::iterator it = s.lower_bound(vec[i]);
            if(it==s.begin()){
                flag=true;break;
            }
            it--;
            vec.push_back(*it);
            s.erase(it);
        }
    }
    if(vec.size()==la)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 13692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#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 FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_que<int> pque;//これは大きい順
//typedef priority_que<int, vector<int>, greater<int>> pque;//これは小さい順


int main(){
	int n;
	cin >> n;
	std::vector<int> a(n+1);
	rep(i,n){
		cin >> a[i];
	}
	map<int,int> mp;
	rep(i,n){
		mp[a[i]]++;
	}
	rep(i,n){
		if(mp[a[i]] > 1){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;

  return 0;
}


Measured memory_bytes: 10368
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>

using namespace std;
int main() {
	int n;
	cin >> n;
	if (n / 100 == 7 || (n / 10) % 10 == 7 || (n) % 10 == 7) {
		cout << "Yes" << endl;
		return 0;
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  while(1){
    cin>>n;
    if(n==0){
      break;
    }
    int a,b;
    int aa=0,bb=0;
    for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a>b){
	aa+=a+b;
      }else if(b>a){
	bb+=a+b;
      }else{
	aa+=a;
	bb+=b;
      }
    }
    cout<<aa<<' '<<bb<<endl;
  }
  return(0);
}
      



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

typedef unsigned long long int ull;
typedef long double ldb;
typedef long long int ll;

#define MOD1        1000000007
#define MOD2        998244353
#define PI          3.1415926535897932384626433832795
#define FILL(a, value) memset(a, value, sizeof(a))
#define BOOST       ios_base::sync_with_stdio(false); cin.tie(NULL)
#define what_is(x)  cerr << #x << " is " << x << endl;
#define ASSERT(left,operator,right) { if(!((left) operator (right))){ std::cerr << "ASSERT FAILED: " << #left << #operator << #right << " @ " << __FILE__ << " (" << __LINE__ << "). " << #left << "=" << (left) << "; " << #right << "=" << (right) << std::endl; } }

#define rep01(k,n)      for (ll i=k; i<n; i++)
#define rep02(k,n)      for (ll j=k; j<n; j++)
#define rep03(k,n)      for (ll k=k; k<n; k++)
#define rep11(k,n)      for (ll i=k; i<=n; i++)
#define rep12(k,n)      for (ll j=k; j<=n; j++)
#define rep13(k,n)      for (ll k=k; k<=n; k++)
#define repIT(c,it)     for(typeof(c.begin()) it = c.begin(); it != c.end(); ++it)
#define all(c)      c.begin(), c.end()

using namespace std;

const double pi = acos(-1.0);
const double epsilon = 1e-9;        // Add epsilon when casting double to int to avoid rounding pitfall issues, eg, 0.94*8178 in int
const int maxn = 1e6+10;

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

    ll i = x;
    while(1)
    {
        ll fact = 0;
        for(ll f = 2; f < i; f++)
        {   
            if(i % f == 0)
                fact++;
        }

        if(fact == 0 && i >= x)
        {
            cout << i;
            return;
        }
        i++;
    }

}

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

    cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 3760
fun main(args: Array<String>) {
    val N = readLine()!!.toInt()
    val a = readLine()!!.split(" ").map { it.toInt() }


    val hashMap = hashMapOf<Int, Int>()
    var answer = 0
    a.forEach {
        if (!hashMap.contains(it)) {
            hashMap[it] = 1
        } else {
            hashMap[it] = hashMap[it]!! + 1
        }
        if (hashMap[it]!! > it) {
            answer++
            hashMap[it] = hashMap[it]!! - 1
        }
    }

    hashMap.keys.forEach {
        if (hashMap[it] != it) {
            answer += hashMap[it]!!
        }
    }

    println(answer)
}


Measured memory_bytes: 58920
#include "bits/stdc++.h"
using namespace std;
const int N = 1e5 + 5;
const int LN = 60;
int n;
int x[N];
int m;
long long k;
int a;
int p[LN][N];
int res[N];
long long ans;
int tmp[N];
int main(){
    scanf("%d" , &n);
    for(int i = 1 ; i <= n ; ++i){
        scanf("%d" , x + i);
        p[0][i] = i;
    }
    scanf("%d %lld" , &m , &k);
    for(int i = 1 ; i <= m ; ++i){
        scanf("%d" , &a);
        swap(p[0][a] , p[0][a + 1]);
    }
    for(int i = 1 ; i < LN ; ++i){
        for(int j = 1 ; j <= n ; ++j){
            p[i][j] = p[i - 1][p[i - 1][j]];
        }
    }
    for(int i = 1 ; i <= n ; ++i){
        int res = i;
        for(int j = 0 ; j < LN ; ++j){
            if(k & (1LL << j)){
                res = p[j][res];
            }
        }
        ::res[i] = res;
    }
    for(int i = 1 ; i <= n ; ++i){
        tmp[i] = x[res[i]] - x[res[i] - 1];
    }
    for(int i = 1 ; i <= n ; ++i){
        ans += tmp[i];
        printf("%lld\n" , ans);
    }
}

Measured memory_bytes: 25856
import fractions
from functools import reduce
def lcm_base(x, y):
    return (x * y) // fractions.gcd(x, y)

def lcm(*numbers):
    return reduce(lcm_base, numbers, 1)

def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)
N=int(input())
T=[]
for i in range(N):
    Ti=int(input())
    T.append(Ti)
print(lcm_list(T))

Measured memory_bytes: 5076
// Marcin Knapik
#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

// #include <ext/pb_ds/assoc_container.hpp> // order_of_key
// #include <ext/pb_ds/tree_policy.hpp> // find by order
// using namespace __gnu_pbds; 
// #define ordered_set tree< int , null_type,less< int >, rb_tree_tag,tree_order_statistics_node_update>  

// const ll MAX_LL = 0xFFFFFFFFFFFFFFFF;
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define losuj(a, b) uniform_int_distribution<ll>(a, b)(rng)

typedef long double             ld;
typedef long long               ll;
typedef pair<int, int>          ii;
typedef vector<int>             vi;
typedef vector<ll>              vll;
typedef vector<vll>             vvll;
typedef vector<ii>              vii;
typedef vector<vi>              vvi;
typedef vector<vii>             vvii;
#define pll pair<long long, long long>
#define ull unsigned long long

#define sz(a)                   (int)(a).size()
#define pb                      push_back
#define all(c)                  (c).begin(), (c).end()
#define rall(c)                 (c).rbegin(), (c).rend()
#define FOR(i, a)               for (int i = 0; i < (a); i++)
#define f                       first
#define s                       second

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

template<class T> inline T fast(T a,T b,T mod) {ll res = 1; while(b){if(b&1) res = (res*a)%mod;a = (a*a)%mod;b >>= 1;}return res;}
template<class T> istream &operator>>(istream &os, vector<T> &container){for (auto &u : container)os >> u;return os;}
template<class T> ostream &operator<<(ostream &os, const vector<T> &container){for (auto &u : container)os << u << " ";return os;}
template<class T> inline T gcd(T a, T b) { while (b)swap(a %= b, b); return a; }

const ll INF = 1e9 + 7;
const ll mod = 998244353;
const ll BIG_INF = 1e18 + 7;
const ll N = 2e5+7;
const ll T = 1<<17;
const ld inf = 1e18;
ll m, n, k, q;

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

    ll a, b, c, d, e;
    cin >> a >> b >> c >> d >> e;

    ll dl = (c - a) * 60 + (d - b);
    cout << dl - e << endl;
}




Measured memory_bytes: 3656
n = int(input())
low, high = map(int, input().split())
points = list(map(int, input().split()))
c = len(list(filter(lambda p: p > high, points)))
b = len(list(filter(lambda p: low < p <= high, points)))
a = len(list(filter(lambda p: p <= low, points)))
print(min(a,b,c))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int h, w;
int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
int main(){
  cin >> h >> w;
  string M[h];
  for(int i=0; i<h; ++i) cin >> M[i];
  for(int y=0; y<h; ++y){
    for(int x=0; x<w; ++x){
      bool judge = [&]{
        for(int i=0; i<4; ++i){
          int nx = x+dx[i], ny = y+dy[i];
          if(nx < 0 || nx >= w || ny < 0 || ny >= h) continue;
          if(M[ny][nx] == '#') return false;
        }
        return true;
      }();
      if(M[y][x] == '#' && judge){ cout << "No" << endl; return 0; }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 3604
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

int n , K;

int main(){
    scanf("%d%d",&K,&n);
    if(K % 2 == 0) {
        rep(i,0,n) printf("%d%c",i?K:K/2," \n"[i+1==n]);
    } else {
        vi v(n , (K + 1) / 2);
        int times = n / 2;
        rep(i,0,times) {
            if(v.back() == 1) v.pop_back();
            else {
                v[sz(v)-1]--;
                rep(j,sz(v),n) v.pb(K);
            }
        }
        rep(i,0,sz(v)) printf("%d%c",v[i]," \n"[i+1==n]);
    }
    return 0;
}


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

typedef long long ll;
const int N = 2000006;

map<pair<int,int>,ll > mp;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	int n;
	cin>>n;
	
	ll ans = 0;
	for(int i=1;i<=n;i++){
		int f = i%10;
		int t = i;
		int l = f;
		while(t){
			l = t%10;
			t /= 10;
		}
		mp[{f,l}]++;
	}
	for(auto p:mp){
		int f = p.first.first,l = p.first.second;
		ans += mp[{f,l}]*mp[{l,f}];
	}
	
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
const int N=100007;
char pre[N],fch[N];
int cnt,n;
char change(char ch){
	if(ch=='b')return 'd';
	if(ch=='d')return 'b';
	if(ch=='p')return 'q';
	if(ch=='q')return 'p';
}
int main(){
	pre[1]=getchar();
	cnt=1;
	char ch;
	while(cin>>ch){
		pre[++cnt]=ch;		
	}
	n=cnt++;
	//for(int i=1;i<=cnt;i++)cout<<pre[i];
	for(int i=n;i>=1;i--){
		fch[i]=change(pre[--cnt]);
	}
	cnt=n;
	for(int i=1;i<=n;i++){
		if(fch[i]!=pre[cnt]){
			puts("No");
			return 0;
		}
		cnt--;
	}
	puts("Yes");
	return 0;
}

Measured memory_bytes: 384
use std::cmp;
const INF: i64 = 1e18 as i64;

fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n = sc.read();
    let a: Vec<i64> = sc.vec(n);
    let mut graph = vec![vec![]; n];
    for _ in 1..n {
        let u = sc.read::<usize>() - 1;
        let v = sc.read::<usize>() - 1;
        graph[u].push(v);
        graph[v].push(u);
    }

    let mut dp1 = vec![vec![]; n];
    let mut dp2 = vec![vec![]; n];
    dp(0, 0, &mut dp1, &mut dp2, &a, &graph);

    for i in 0..n {
        if dp1[0][i] < INF || dp2[0][i] < 0 {
            println!("{}", i);
            return;
        }
    }
}

fn dp(
    v: usize,
    p: usize,
    dp1: &mut Vec<Vec<i64>>,
    dp2: &mut Vec<Vec<i64>>,
    a: &Vec<i64>,
    graph: &Vec<Vec<usize>>,
) {
    dp1[v].push(if a[v] > 0 { a[v] } else { INF });
    dp2[v].push(a[v]);
    for &next in graph[v].iter() {
        if next == p {
            continue;
        }
        dp(next, v, dp1, dp2, a, graph);
        dp1[v] = connect(&dp1[v], &dp1[next], &dp2[next], true);
        dp2[v] = connect(&dp2[v], &dp1[next], &dp2[next], false);
    }
}

fn connect(dp: &Vec<i64>, child1: &Vec<i64>, child2: &Vec<i64>, is_power: bool) -> Vec<i64> {
    let mut next = vec![INF; dp.len() + child1.len() + 1];
    for parent_cut in 0..dp.len() {
        for child_cut in 0..child1.len() {
            let total_cut = parent_cut + child_cut;

            if child1[child_cut] < INF {
                next[total_cut] = cmp::min(next[total_cut], dp[parent_cut] + child1[child_cut]);
            }
            if child2[child_cut] < INF && !is_power {
                next[total_cut] = cmp::min(next[total_cut], dp[parent_cut] + child2[child_cut]);
            }
            if child1[child_cut] < INF || child2[child_cut] < 0 {
                next[total_cut + 1] = cmp::min(next[total_cut + 1], dp[parent_cut]);
            }
        }
    }
    next
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 408572
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int a[200005];
int main()
{

    ll n,a,b;
    char s[5];
    scanf("%lld%lld%lld",&n,&a,&b);
    bool f=0;
    if(n%(a+b))f=1;
    if(!f)printf("%lld\n",n/(a+b)*a);
    else
    {
        ll ans=n/(a+b)*a;
        n-=n/(a+b)*(a+b);
        printf("%lld\n",ans+min(n,a));
    }
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue<int>
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2 vector<vec>
#define vecll2 vector<vecll>
#define vec3 vector<vec2d>
#define vecll3 vector<vecll2d>
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(vector<T> v){for(T e:v)cout<<e<<" ";cout<<endl;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
void print(vector<vec> v){for(auto e:v){for(auto ee:e)cout<<ee<<" ";cout<<endl;}}
void print(map<int,int> mp){for(auto e:mp)cout<<e.first<<" "<<e.second<<endl;cout<<endl;}

const int N=1e5+10;
const ll INF=1e9+7;
ll a[N<<4];
int sum[11];
main(){
    
    int h,w,n;scanf("%d%d%d",&h,&w,&n);
    int x,y;
    int cnt=0;
    ll m=(ll)(h-2)*(w-2);
    rep(iii,n){
        scanf("%d%d",&x,&y);
        rep(i,3)if( x-i>=1 && x-i<=h-2 ){
            const ll b=INF*(x-i);
            rep(j,3)if(y-j>=1 && y-j<=w-2){
            a[cnt++]=b+(y-j);
            }
        }
    }
    sort(a,a+cnt);
    ll t=1;
    rep(i,cnt){
        if(a[i]==a[i+1])t++;
        else sum[t]++,t=1,m--;
    }
    printf("%lld %d %d %d %d %d %d %d %d %d",m,sum[1],sum[2],sum[3],sum[4],sum[5],sum[6],sum[7],sum[8],sum[9]);
}



Measured memory_bytes: 8448
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll              long long
#define pb              push_back
#define ppb             pop_back
#define endl            '\n'
#define mii             map<ll,ll>
#define pii             pair<ll,ll>
#define vi              vector<ll>
#define vs              vector<string>
#define all(a)          (a).begin(),(a).end()
#define F               first
#define S               second
#define sz(x)           (ll)x.size()
#define hell            1000000007
#define inf             (ll)1e18 + 5
#define PI              3.14159265358979323844
#define rep(i,a,b)      for (ll i=a;i<b;i++)
#define repr(i,a,b)     for (ll i=a-1;i>=b;i--)
#define lbnd            lower_bound
#define ubnd            upper_bound
#define mp              make_pair
#define ios             ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ordered_set     tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
#define trace(...)      __f(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

using namespace std;
using namespace __gnu_pbds;

/*----------------------Graph Moves----------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

//primes for hashing 937,991,1013,1409,1741

void solve() {
    ll n;
    cin>>n;
    ll temp=n/500;
    ll ans=temp*1000;
    n-=(temp*500);
    temp=n/5;
    ans+=temp*5;
    cout<<ans<<endl;
}

signed main() {
    ios
    ll test=1;
    //cin>>test;
    while (test--) solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int main() {
  string S; cin >> S;
  for(int bit = 0; bit < (1<<3); bit++) {
    int tmp = S[0] - '0';
    for(int i = 0; i < 3; i++) {
      if(bit & (1<<i)) tmp += S[i+1] - '0';
      else tmp -= S[i+1] - '0';
    }
    if(tmp == 7) {
      cout << S[0];
      for(int i = 0; i < 3; i++) {
        if(bit & (1<<i)) cout << '+';
        else cout << '-';
        cout << S[i+1] - '0';
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c,d;
int k1,k2;
string s1,s2,s3;

int main(){
  cin >> s1 >> s2 >> s3;
  cout << s1[0] << s2[1] << s3[2] << endl;
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int K, N;
  long long sum = 0;
  cin >> N >> K;
  vector<long long> H(N);
  for(int i = 0; i < N; i++){
    cin >> H[i];
  }
  sort(H.begin(), H.end());
  int fl = N - K;
  for(int i = 0; i<fl; i++){
    sum += H[i];
  }
  if(K>=N){
    cout << 0 << endl;
  }
  else{
    cout << sum << endl;
  }

}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	int maxn, maxs;
	cin >> maxn >> maxs;
	for (int i = 0; i < n - 1; i++){
		int a, b; cin >> a >> b;
		if (maxs < b){
			maxn = a;
			maxs = b;
		}
		else if (maxs == b){
			maxn = min(maxn, a);
		}
	}
	cout << maxn <<' '<< maxs << endl;
}

Measured memory_bytes: 3112
import math

# def comb_count(n, r):
#     return math.factorial(n) // math.factorial(r) // math.factorial(n - r)

S = input()[::-1]
ans = 0

mods = [0] * 2019 #余りが0~2018
mods[0] = 1
current = 0
tmp = 1

for i in range(len(S)):
    current = (int(S[i]) * tmp + current) % 2019
    mod = current % 2019
    ans += mods[mod]
    mods[mod] += 1
    tmp = tmp * 10 % 2019

# for mod in mods:
#     if mod > 1:
#         ans += comb_count(mod, 2)
print(ans)



Measured memory_bytes: 9364
#include <iostream>
using namespace std;
int main(void){
    int A,B,C,X;int ans=0;
    cin >> A >> B >> C >> X;
    for(int i=0;i<=A;i++){
        for(int j=0;j<=B;j++){
            for(int k=0;k<=C;k++){
                if(500*i+100*j+50*k==X)ans++;
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
N, Q=map(int,input().split())
S=input()
t=[0]*(N+1)
for i in range(N):
  t[i+1]=t[i]+(1 if S[i : i+2]== 'AC' else 0)
for i in range(Q):
  l, r=map(int,input().split())
  print(t[r-1]-t[l-1])

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

using namespace std;

long long n,k,s;

int main()
{
    cin >> n >> k;
    if (k==0)
    {
        cout << n*n;
        return 0;
    }
    for (int i = k+1; i <= n; i++)
    {
        int x=(n+1)/i;
        s+=x*(i-k);
        if ((x+1)*k+x*(i-k)<=n) s+=1+n-(x+1)*k-x*(i-k);
    }
    cout << s;
}

Measured memory_bytes: 384
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする
 
vector<int> G[100005];
std::vector<P> tree[100010];
 
int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
 
#define p(x) cout<<x<<endl;
#define e cout<<endl;
#define pe(x) cout<<x<<" ";
#define re(i,a,b) for(i=a;i<=b;i++)
 
ll i,j,k,l,ii,jj;
ll n,m;
ll x,y;
ll a,b,c;
ll h,w;

ll ans=0;
ll sum=0;
ll memo,num;
bool dame=false;
char s[55][55];
 
int main(){
	cin>>h>>w;
	for(i=0;i<h;i++){
		cin>>s[i];
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			//s[i][j]
			if(s[i][j]=='#'){
				bool flag=false;
				for(k=0;k<4;k++){
					if(0<=i+dx[k] && i+dx[k]<h && 0<=j+dy[k] && j+dy[k]<w && s[i+dx[k]][j+dy[k]]=='#')flag=true;
				}
				if(!flag){
					dame=true;
					break;
				}
			}
		}
	}
	if(dame){
		p("No");
	}else p("Yes");
	return 0;
				
}

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

#define INF 1e9
using namespace std;

int main() {

    int N; cin >> N;

    vector<int> d(N);
    for (int i = 0; i < N; ++i) {
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << d[N/2] - d[N/2-1] << endl;
}

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

int main(){
  string s;
  string t;
  cin >> s >> t;
  int cnt;
  rep(i,3){
    if (s[i]==t[i]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
 
int main(){
  int a,b,c,
      n,
      r;
  double ab,bc,ca,
         min;
  for(;;){
    scanf("%d %d %d\n",&a,&b,&c);
    
    if(a == 0 && b == 0 && c == 0)
      break;
 
    ab = a*a+b*b;
    bc = b*b+c*c;
    ca = c*c+a*a;
    
    min = ab;
    if(bc < min)min = bc;
    if(ca < min)min = ca;
    
/*    printf("min : %lf\n",min); */
    
    scanf("%d\n",&n);
    while(n-- != 0){
      scanf("%d\n",&r);
      r = (r*r) * 4;
      puts(min < r? "OK" : "NA");
    }
  }
  return 0;
}

Measured memory_bytes: 588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

ll dep(ll a,ll b){
	if(b==0){
		return a;
	}
	return dep(b,a%b);
}
int main() {
	ll a,b;
	cin>>a>>b;
	ll n=dep(max(a,b),min(a,b));
	cout << a*b/n;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr ll MOD = 1e9 + 7;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    cin >> s;
    for (int i = 0; i < s.length(); i++) {
        s[i] = 'A' + (s[i] - 'A' + n) % 26;
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int n,*h,*dp;

int calcCost(int from,int to)
{
	if (h[from]>h[to]) return h[from] - h[to];
	return h[to] - h[from];
}

int myMin(int a,int b)
{
	return (a-b>0)?b:a;
}

int main(void)
{
	int i,j;
	scanf("%d",&n);
	h = (int *)malloc(sizeof(int) * n);
	for (i=0;i<n;i++) scanf("%d",&h[i]);

	dp = (int *)malloc(sizeof(int) * n);
	for (i=0;i<n;i++) dp[i] = 0;
	dp[1] = calcCost(0,1);
	
	for (i=2;i<n;i++) {
		dp[i] = myMin(dp[i-2] + calcCost(i-2,i), dp[i-1] + calcCost(i-1,i));
	}
	
	printf("%d\n",dp[n-1]);

	free(h);
	free(dp);
	return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;

const int M=1e9+7;

int main()
{
    string n;
    cin>>n;
    vector<int> number;
    for(int i=0;i<n.size();++i)
        number.push_back(n[i]-'0');
    ll sum=0;
    for(auto x:number)
        sum+=x;

    if(sum%9==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


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

sint const sint_min = numeric_limits<sint>::min();
sint const sint_max = numeric_limits<sint>::max();

template<class T> T read() {
	T t;
	cin >> t;
	return t;
}

template<class T> vector<T> read_vector(sint const n) {
	vector<T> vs;
	for (sint i = 0; i < n; ++i) {
		vs.push_back(read<T>());
	}
	return vs;
}

inline void write() {
}

template<class T> void write(T const& t) {
	cout << t;
}

template<class T> void write(vector<T> const& ts) {
	if (ts.size() > 0) {
		cout << ts[0];
	}
	for (size_t i = 1; i < ts.size(); ++i) {
		cout << ' ' << ts[i];
	}
}

template<class T, class... Args> void write(T const& t, Args const&... args) {
	cout << t << ' ';
	write(args...);
}

template<class... Args> void writeln(Args const&... args) {
	write(args...);
	cout << '\n';
}

inline sint gcd(sint y, sint x) {
	while (x != 0) {
		sint const t = y % x;
		y = x;
		x = t;
	}
	return y;
}

inline sint div_floor(sint const y, sint const x) {
	assert(x > 0);
	sint const r = y / x;
	return r * x <= y ? r : r - 1;
}

inline sint mod(sint const a, sint const p) {
	return a - p * div_floor(a, p);
}

inline sint pow_mod(sint const a, sint const n, sint const p) {
	if (n == 0) {
		return 1;
	}
	sint const h = pow_mod(a, n / 2, p);
	sint const f = (h * h) % p;
	if (n % 2 == 1) {
		return (a * f) % p;
	}
	else {
		return f;
	}
}

inline sint rcp_mod(sint const a, sint const p) {
	assert(a % p != 0);
	return pow_mod(a, p - 2, p);
}

inline sint factorial_mod(sint const n, sint const p) {
	sint r = 1;
	for (sint i = 2; i <= n; ++i) {
		r = (r * i) % p;
	}
	return r;
}

inline sint combination_mod(sint const n, sint const k, sint const p) {
	return (factorial_mod(n, p) * rcp_mod((factorial_mod(k, p) * factorial_mod(n - k, p)) % p, p)) % p;
}

struct FactorialMod {
	FactorialMod(sint const n, sint const p):
		_p(p)
	{
		_table.push_back(1);
		sint r = 1;
		for (sint i = 1; i < n; ++i) {
			r = (i * r) % p;
			_table.push_back(r);
		}
	}

	sint factorial(sint const n) {
		assert(0 <= n && n < sint(_table.size()));
		return _table[n];
	}

	sint combination(sint const n, sint const k) {
		return (factorial(n) * rcp_mod((factorial(k) * factorial(n - k)) % _p, _p)) % _p;
	}

private:
	vector<sint> _table;
	sint _p;
};

int main() {
	ios_base::sync_with_stdio(false);
	cin .exceptions(ios_base::badbit | ios_base::failbit);
	cout.exceptions(ios_base::badbit | ios_base::failbit);
	cin .tie(nullptr);
	cout.tie(nullptr);
	cout.precision(16);
	void run();
	run();
	return 0;
}

void run() {
	sint const MOD = 1000000007;
	auto const N = read<sint>();
	auto const K = read<sint>();
	auto As = read_vector<sint>(N);

	FactorialMod fact_mod(N, MOD);

	sort(As.begin(), As.end());
	sint sum_min = 0;
	for (sint i = 1; i <= N - K + 1; ++i) {
		sum_min = (sum_min + (mod(As[i - 1], MOD) * fact_mod.combination(N - i, K - 1)) % MOD) % MOD;
	}

	reverse(As.begin(), As.end());
	sint sum_max = 0;
	for (sint i = 1; i <= N - K + 1; ++i) {
		sum_max = (sum_max + (mod(As[i - 1], MOD) * fact_mod.combination(N - i, K - 1)) % MOD) % MOD;
	}

	writeln((sum_max + mod(-sum_min, MOD)) % MOD);
}

Measured memory_bytes: 2548
using System;

namespace CA {
	class Prg {
		static void Main() {
			string[] s = Console.ReadLine().Split(' ');
			try {
				checked {
					byte x = (byte)int.Parse(s[2]);
					byte y = (byte)int.Parse(s[3]);
					byte r = (byte)int.Parse(s[4]);
					byte W = (byte)(int.Parse(s[0]) - x);
					byte H = (byte)(int.Parse(s[1]) - y);
					W -= r;
					H -= r;
					x -= r;
					y -= r;
					Console.WriteLine("Yes");
				}
			}catch {
				Console.WriteLine("No");
			}
		}
	}
}

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

#define forw(i,a,n) for (int i=a;i<n;i++)
#define ford(i,a,n) for (int i=n-1;i>=a;i--)
#define fi first
#define se second
#define SZ(x) ((int)(x).size())

typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

const ll mod=1000000007;
const int maxn = 1e5 + 3;
void mf(){
	freopen("input.in","r",stdin);
	//freopen("output.ou","w",stdout);
}
//START SOL
ll a[maxn], f[maxn];
int n, k;
void minself(ll& a, ll b){
	a = min(a,b);
}
void solve(){
	cin>>n>>k;
	for(int i = 1; i <= n; i++) cin>>a[i];
	for(int i = 2; i <= n; i++){
		f[i] = 1e9 + 5;
		for(int j = 1; j <= k; j++){
			if(i - j < 1) break;
			minself(f[i], f[i-j] + abs(a[i] - a[i-j]));
		}
	}
	cout<<f[n]<<endl;

}

int main(){
	ios_base::sync_with_stdio(false);
	#ifdef tuanh
		mf();
	#endif
	solve();
	return 0;
}

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

int num[505][505];

int main(){
	int a, b, w, h;
	long long sum;
	scanf("%d %d %d %d",&b,&a,&h,&w);
	memset(num, 0, sizeof(num));
	for (int i = 1; i <= b / h; i++){
		for (int j = 1; j <= a / w; j++){
			num[i * h][j * w] = -(w * h - 1) * 3000 - 1;
		}
	}
	sum = 0;
	for (int i = 1; i <= b; i++){
		for (int j = 1; j <= a; j++){
			if (!num[i][j]) num[i][j] = 3000;
			sum += num[i][j];
		}
	}
	if (sum <= 0) printf("No\n");
	else{
		printf("Yes\n");
		for (int i = 1; i <= b; i++){
			for (int j = 1; j <= a; j++){
				printf("%d", num[i][j]);
				if (j < a) printf(" ");
			}
			printf("\n");
		}
	}
	return 0;
} 

Measured memory_bytes: 2560
read N
read A
read B
read C
S=0
for i in `seq 0 $(($N-1))`; do
	a=${A:$i:1}
	b=${B:$i:1}
	c=${C:$i:1}
    if [ $a != $b ] && [ $b != $c ] && [ $a != $c ] ; then
    	S=$(($S+2))
    elif [ $a = $b ] && [ $b = $c ]; then
    	S=$S
    else
    	S=$(($S+1))
    fi
done

echo $S


Measured memory_bytes: 1428
/*input
100000 1
1 100000 100
*/

#include <bits/stdc++.h>

using namespace std;

const int SIZE = 1e5 + 10;

vector<int> adj[SIZE];
vector<int> vis(SIZE);

void bfs(int s) {
	queue<int> q;
	q.push(s);
	vis[s] = true;

	while(!q.empty()) {
		s = q.front();
		q.pop();
		for(auto i : adj[s]) {
			if(!vis[i]) {
				vis[i] = true;
				q.push(i);
			}
		}
	}
}

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

	int n, m;
	cin >> n >> m;

	int x, y, z;
	for(int i = 1; i <= m; i++) {
		cin >> x >> y >> z;
		adj[x].push_back(y);
		adj[y].push_back(x);
	}

	int ans = 0;
	for(int i = 1; i <= n; i++) {
		if(!vis[i]) {
			bfs(i);
			ans++;
		}
	}

	cout << ans;

	return 0;
}

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  
  for (int i = 0;i < n-2;i++){
    if (s.at(i) == 'A' && s.at(i+1) == 'B' && s.at(i+2) == 'C'){
      ans++;
    }
  }
  cout << ans << endl;
}

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

int main(){
  int p,q,n;
  char c;
  long l=0,r=0;
  cin>>q;
  while(q--){
    cin>>p>>c>>n;
    if(c=='(') l+=n;
    else r+=n;
    if(l==r) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }
  return 0;
}

Measured memory_bytes: 1156
n = int(input())
B = list(map(int,input().split()))
A=[0]*n
A[0]=B[0]
for i in range(n-1):
    if A[i]>B[i]:
        A[i]=B[i]
    A[i+1]=B[i]

t=0
for a in A:
    t+=a
print(t)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>
#include <iomanip>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rep(i,N) for(ll i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1


ll sq(ll num) { return num*num; }
ll mod_pow(ll x, ll n) {
	if (n == 0)return 1;
	if (n == 1)return x%MOD;
	ll res = sq(mod_pow(x, n / 2));
	res %= MOD;
	if (n % 2 == 1) {
		res *= x;
		res %= MOD;
	}
	return res;
}
ll mod_add(ll a, ll b) { return (a + b) % MOD; }
ll mod_sub(ll a, ll b) { return (a - b + MOD) % MOD; }
ll mod_mul(ll a, ll b) { return a*b % MOD; }

ll h, w;
string s[210];
ll d[210][210];
ll dd[210][210];
ll sx, sy;
ll dx[] = { 0,1,0,-1 };
ll dy[] = { 1,0,-1,0 };

void solve() {
	rep(i, 210)rep(j, 210)d[i][j] = INF;
	d[sy][sx] = 0;

	typedef pair<P, ll> ppi;
	queue<ppi> que;
	que.push(ppi({ sy,sx }, 0));
	while (que.size()) {
		ppi p = que.front();
		que.pop();
		int y = p.first.first;
		int x = p.first.second;
		//cout << "!" << y << " " << x << endl;
		rep(i, 4) {
			int ny = y + dy[i];
			int nx = x + dx[i];
			//cout << ny << " " << nx << endl;
			if (ny >= h || ny < 0 || nx >= w || nx < 0)continue;
			if (s[ny][nx] == '#')continue;
			if (d[ny][nx] > p.second + 1) {
				d[ny][nx] = p.second + 1;
				if (s[ny][nx] == '.')que.push(ppi(P(ny, nx), d[ny][nx]));
			}
		}
	}
}

int main() {
	cin >> h >> w;
	rep(i, h) {
		cin >> s[i];
		rep(j, w) {
			if (s[i][j] == '%') {
				sx = j, sy = i;
			}
		}
	}
	solve();
	ll dd = INF;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '@')dd = d[i][j];
		}
	}
	bool f = 1;
	rep(i, h) {
		rep(j, w) {
			if (s[i][j] == '$') {
				if (dd >= d[i][j])f = 0;
			}
		}
	}
	if (f)cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 3568
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int a, b, x; cin >> a >> b >> x;
    double x0 = (double)x / a;
    double ans;
    if(2 * x <= a * a * b){
        double c = (double)(2 * x0) / b;
        ans = atan((double)b / c);
    }else{
        double c = (double)(2 * ((double)(a * b) - x0)) / a;
        ans = atan(c / (double)a);
    }

    Out(ans * 180 / M_PI);

    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int N; cin >> N;
	int a[100001];
	for (int i = 0; i <= 100000; i++)
		a[i] = 0;
	for (int i = 0; i < N; i++) {
		int x; cin >> x;
		a[x]++;
	}
	int res = 0;
	for (int i = 0; i+2 <= 100000; i++) {
		int sum = a[i] + a[i + 1] + a[i + 2];
		res = max(res, sum);
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 640
let readIntArray _ =
    stdin.ReadLine().Split(" ") |> Array.map int

let rec solve count arr =
    let x =
        arr
        |> Array.filter (fun x -> (x % 2) <> 0)
        |> Array.length

    if x = 0
    then solve (count + 1) (arr |> Array.map (fun x -> x / 2))
    else count

stdin.ReadLine()

() |> readIntArray |> solve 0 |> printfn "%d"


Measured memory_bytes: 30956
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
typedef tuple<ll, ll, ll> T;


int main() {
	ll N;
	cin >> N;
	vector<T> v(N);
	for (int i = 0;i < N-1;i++) {
		ll c, s, m;
		cin >> c >> s >> m;
		v[i] = T(c, s, m);
	}
	for (int i = 0;i < N;i++) {
		ll ans = 0;
		ll now = i;
		ll time = 0;
		while (now < N-1) {
			ll c, s, m;
			tie(c, s, m) = v[now];
			now++;
			if (time <= s)
				time = s + c;
			else
				time = time + (m - (time % m))%m + c;
		}
		cout << time << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<cmath>
#include<iostream>
#include<cstdio>

using namespace std;
int main(){
    
    long long x;

    scanf("%lld",&x);

    int i,l;
    long long m;
    long long n;

    for(i = -119; i <= 120; i++){
         m = pow(i,5);
    for(l = -120; l <= i; l++){
         n = pow(l,5);
    if (m - n == x){
        printf("%d %d\n",i,l);       
        break;       
    }
    }
    if (m - n == x) break;

    }

    return 0;

}

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
    int A, B, C, D; cin >> A >> B >> C >> D;
    vector<int> cnt(101, 0);
    for(int i = A; i <= B; i++) cnt[i]++;
    for(int i = C; i <= D; i++) cnt[i]++;
    int ans = 0;
    for(int i = 0; i < 101; i++) if(cnt[i] == 2) ans++;
    ans = max(ans - 1, 0);
    cout << ans << endl;
    return 0;
}

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

#ifndef __TOPCYBERFLOWER
#define debug(...) 0
#else
#define debug(...) cout << " [-] ", _dbg(#__VA_ARGS__, __VA_ARGS__)
template<class TH> void _dbg(const char *sdbg, TH h){ cout << sdbg << '=' << h << endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
    while(*sdbg != ',') cout << *sdbg++;
    cout << '=' << (h) << ','; 
    _dbg(sdbg+1, a...);
}
#endif

#define TYPEMAX(type)   numeric_limits<type>::max()
#define TYPEMIN(type)   numeric_limits<type>::min()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;

int main(void){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n; cin>>n;
    vector<int> arr(n+5,0);
    for(int i=1;i<n;i++){
        int x; cin>>x;
        arr[x]++;
    }
    for(int i=1;i<=n;i++) cout<<arr[i]<<'\n';
    return 0;
}

Measured memory_bytes: 3984
import sys
sys.setrecursionlimit(10**7)

N,Q = map(int,input().split())
par = [i for i in range(N)]
rank = [0]*(N+1)
def find(x):
    if par[x] == x:
        return x
    else:
        par[x] = find(par[x]) #経路圧縮
        return par[x]
def same(x,y):
    return find(x) == find(y)
def unite(x,y):
    x = find(x)
    y = find(y)
    if x == y:
        return 0
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x]==rank[y]:rank[x]+=1

for _ in range(Q):
  a,b=map(int,input().split())
  a,b=a-1,b-1
  unite(a,b)
from collections import Counter
a=[-1]*N
for i in range(N):
  a[i]=find(i)
ca=Counter(a)
ans=0
for c in ca.values():
  ans=max(ans,c)
print(ans)


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

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

    vector<int> x(n);
    vector<int> y(n);
    vector<int> z(n);

    for(int i = 0; i < n; i++) {
        cin >> x.at(i);
    }
    for(int i = 0; i < n; i++) {
        cin >> y.at(i);
    }

    for(int i = 0; i < n; i++) {
        z.at(i) = max(x.at(i), y.at(i)) - min(x.at(i), y.at(i));
    }

    double p1=0;
    double p22=0;
    double p33=0;
    int pinfinf=0;

    for(int i = 0; i < n; i++) {
        p1 += z.at(i);
        p22 += z.at(i)*z.at(i);
        p33 += z.at(i)*z.at(i)*z.at(i);
        pinfinf = max(z.at(i), pinfinf);
    }

    printf("%.8f %.8f %.8f %.8f\n", p1, sqrt(p22), pow(p33, 0.3333333333), (double)pinfinf);
}


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

using namespace std;

typedef long long ll;

vector<int> a;
ll dp[18][18][2][2][2];

ll solve(int l, int r, int isl, int isr, int fi){
	if(l>r)
	{
		if(isl==isr){
			return 1;
		}
		else{
			return 0;
		}
	}
	
	ll &p=dp[l][r][isl][isr][fi];
	if(p!=-1){
		return p;
	}
	
	p=0;
	for(int i=fi;i<=9;i++){
		for(int j=0;j<=9;j++){
			for(int pl=0;pl<=1;pl++){
				for(int pr=0;pr<=1;pr++){
					int ri = i-isr+10*pr;
					int rj = j;
					
					int lj = j+10*isl-pl;
					int li = i;
					
					if(ri-rj == a[r] && lj-li == a[l]){
						//cout << i << " " << j << endl;
						p+=solve(l+1,r-1,pl,pr,0);
					}
				}
			}
		}
	}
	
	return p;
} 

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int d; cin >> d;
	while(d){
		a.push_back(d%10);
		d/=10;
	}
	
	int n=a.size();
	while(a.size()<2*n){
		a.push_back(0);
	}
	reverse(a.begin(),a.end());
	
	memset(dp,-1,sizeof(dp));
	ll ans=0;
	for(int i=n;i<=2*n;i++){
		ans+=solve(2*n-i,2*n-1,0,0,1);
		//cerr << ans << endl;
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
// 2015/06/01 Tazoe

#include <iostream>
#include <cstring>
using namespace std;

int main()
{
	while(true){
		char S[11000];
		cin >> S;

		if(cin.eof())
			break;

		int cnt = 0;		// "JOI"を数える
		char* p = S;		// ポインタを配列の先頭へ
		while(true){
			p = strstr(p, "JOI");

			if(p==0)
				break;

			cnt++;
			p++;		// 見つかった場所から1つずらす
		}
		cout << cnt << '\n';

		cnt = 0;		// "IOI"を数える
		p = S;
		while(true){
			p = strstr(p, "IOI");

			if(p==0)
				break;

			cnt++;
			p++;
		}
		cout << cnt << '\n';
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
#define all(V) V.begin(),V.end()
using ll = long long;

int main() {
	ll H, W;
	cin >> H >> W;
	if (H == 1) {
		cout << 1 << endl;
	}
	else if (W == 1) {
		cout << 1 << endl;
	}
	else if (H % 2 == 1 && W % 2 == 1) {
		cout << (H * W + 1) / 2 << endl;
	}
	else {
		cout << H * W / 2 << endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    int temp=0;
    for(int i = 0;; i++){
        cin>>a>>b;
        if(a==0&&b==0)break;
        else if(a>b){
            temp = a;
            a = b;
            b = temp;
            
        }
    cout<<a<<" "<<b<<endl;
    
    }
}



Measured memory_bytes: 3088
import copy
n,m = map(int,input().split())
a = set(list(map(int,input().split())))
a = list(a)
a_div2 = [0]*len(a)
a2 = copy.deepcopy(a)
# for i in range(len(a)):
#     if a[i] % 2 == 1:
#         print(0)
#         exit()
for i in range(len(a)):
    while a2[i] % 2 == 0:
        a2[i] //= 2
        a_div2[i] += 1
if len(set(a_div2)) != 1:
    print(0)
    exit()


def gcd(a,b):
    while b != 0:
        a, b = b, a % b
    return a


def lcm(a,b):
    return a // gcd(a,b) * b


if len(a) == 1:
    if m < a[0]//2:
        print(0)
    else:
        print((m-a[0]//2)//a[0] + 1)
else:
    cnt = 1
    for i in range(len(a)):
        a[i] //= 2
        cnt = lcm(cnt,a[i])
    if m < cnt:
        print(0)
    else:
        print((m-cnt)//(cnt*2)+1)




Measured memory_bytes: 14804