akhauriyash/Code-Regression huggingface dataset:
#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
#include<boost/multiprecision/cpp_int.hpp>
namespace multiprecisioninteger = boost::multiprecision;
using cint=multiprecisioninteger::cpp_int;
using namespace std;
using ll=unsigned long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;++i)
#define bFor(i,b,a) for(i=b,--i;i>=(ll)a;--i)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define brep1(i,N) bFor(i,N,1)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
#define matoutput(v) do{for(auto outimat:v)output(outimat);}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}
cint A,B,C,D;
map<cint,cint> mp;
cint solve(cint N){
  if(N==0)return 0;
  if(mp[N])return mp[N];
  cint K,x,res=inf;
  K=N>>1;
  if(~N&1){
    x=solve(K);
    res=min(res,x+D*K);
    res=min(res,x+A);
  }else{
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+A+D);
    ++K;
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+A+D);
  }
  K=N/3;
  if(3*K==N){
    x=solve(K);
    res=min(res,x+min(2*D*K,B));
  }else{
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+B+(N-K*3)*D);
    ++K;
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+B+(K*3-N)*D);
  }
  K=N/5;
  if(5*K==N){
    x=solve(K);
    res=min(res,x+min(4*D*K,C));
  }else{
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+C+(N-K*5)*D);
    ++K;
    x=solve(K);
    res=min(res,x+D*(N-K));
    res=min(res,x+C+(K*5-N)*D);
  }
  return mp[N]=res;
}
int main(){
  // startupcpp();
  int T;cin>>T;while(T--){
  cint N;
  cin>>N>>A>>B>>C>>D;
  mp[1]=D;
  print(solve(N));
  mp.clear();
}}

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

using namespace std;

int main() {

    int N, bb; cin >> N;
    int INDEX[N], t; for(int i=0; i<N; i++) INDEX[i] = i;
    string S[N], a, b, tmp;
    for(int i=0; i<N; i++) {
        cin >> a >> bb;
        bb = 100 - bb;
        b = to_string(bb);
        while(b.length() < 3) b = "0" + b;
        S[i] = a + b;
    }

    for(int i=1; i<N; i++) {
        for(int j=1; j<N; j++) {
            if (S[j-1].compare(S[j])>0) {
                tmp = S[j-1];   t = INDEX[j-1];
                S[j-1] = S[j];  INDEX[j-1] = INDEX[j];
                S[j] = tmp;     INDEX[j] = t;
            }
        }
    }

    for(int i=0; i<N; i++) cout << INDEX[i]+1 << "\n";
    
    return 0;
}

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

struct edge{
  int to, weight;
};

using Graph = vector<vector<edge>>;
using Res = pair<int, int>; //(weight, to)

Res dfs(const Graph& g, int p, int s){
  Res r = {0, s};
  for(int i=0; i<g[s].size(); i++){
    if(g[s][i].to == p) continue;
    Res t = dfs(g, s, g[s][i].to);
    t.first += g[s][i].weight;

    if(t.first > r.first) r = t;
  }

  return r;
}

int dTree(const Graph& g){
  Res p = dfs(g, -1, 0);
  Res dt = dfs(g, -1, p.second); //(直径、頂点)
  return dt.first;
}

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

  Graph g(n);

  for(int i=0; i<n-1; i++){
    int s, t, w;
    cin >> s >> t >> w;
    g[s].push_back({t, w});
    g[t].push_back({s, w});
  }

  cout << dTree(g) << endl;

  return 0;
}



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

using namespace std;
typedef long long ll;
const ll mx = 10000007;
const ll mod = 1e9 + 7;
const double pi = acos(-1);
#define    ss   second
#define    ff   first
#define    pb   push_back
#define gcd(a, b) __gcd((a), (b))
#define lcm(a, b) ((a) / __gcd((a), (b)) * (b))
#define FIO ios_base::sync_with_stdio(false);  cin.tie(NULL);


int main() {
    FIO;
    string s, t;
    cin >> s >> t;
    vector<ll>sv(26);
    vector<ll>tv(26);


    for (ll i = 0; i < s.size(); i++) {
        sv[s[i] - 'a']++;
        tv[t[i] - 'a']++ ;
    }

    sort(sv.begin(), sv.end());
    sort(tv.begin(), tv.end());

    for (ll i = 0; i < sv.size(); i++) {
        if(sv[i] != tv[i]) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 3804
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

typedef long long ll;

string a[12];
int pairs[12];
int h, w;

bool check_columns();
bool make_even();
bool make_pair_of_lines(int);

bool check_columns(){
    string b[12];
    for(int i=0;i<h;i++){
        if(b[pairs[i]] == ""){
            b[pairs[i]] = a[i];
        }else{
            b[h-1-pairs[i]] = a[i];
        }
    }

    bool center = (w % 2 == 0);
    bool used[w];
    fill(used, used+w, false);

    for(int j=0;j<w;j++){
        if(used[j]) continue;
        used[j] = true;
        bool same = false;

        for(int jj=0;jj<w;jj++){
            if(used[jj]) continue;

            same = true;
            for(int i=0;i<h;i++){
                if(b[i][j] != b[h-1-i][jj]){
                    same = false;
                    break;
                }
            }
            if(same){
                used[jj] = true;
                break;
            }
        }

        if(!same){
            if(center) return false;
            else center = true;
        }
    }

    return true;
}

bool make_even(){
    h++;
    for(int i=0;i<h-1;i++){
        a[h-1] = a[i];
        pairs[h-1] = -1;
        if(make_pair_of_lines(0)) return true;
    }
    return false;
}

bool make_pair_of_lines(int paired_line){
    if(h % 2) return make_even();

    if(paired_line == h) return check_columns();

    int pair_line_first = -1;
    for(int i=0;i<h;i++){
        if(pairs[i] == -1){
            if(pair_line_first == -1){
                pair_line_first = i;
                pairs[pair_line_first] = paired_line/2;
                break;
            }
        }
    }

    for(int ii=0;ii<h;ii++){
        if(pairs[ii] == -1){
            pairs[ii] = paired_line/2;
            if(make_pair_of_lines(paired_line+2)) return true;
            pairs[ii] = -1;
        }
    }

    pairs[pair_line_first] = -1;

    return false;
}

int main(){
    cin >> h >> w;
    for(int i=0;i<h;i++) cin >> a[i];

    fill(pairs, pairs+h, -1);
    cout << (make_pair_of_lines(0)?"YES":"NO") << endl;
    return 0;
}

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

int main()
{
    int n;
    int i = 0, ans;
    
    cin >> n;
    
    do {
        i++;
        ans += i;
    } while(ans < n);
    
    cout << i << endl;
    
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	var h = scn.nextInt()
	var w = scn.nextInt()
	var maze = Array(h){
		scn.next().toCharArray().map{ c -> c=='.' }.toBooleanArray()
	}
	if (w>h){
		maze = Array(w){ i -> BooleanArray(h) {j -> maze[j][i]} }
		val tmp = w; w = h; h = tmp
	}
	var ans = 0
	for (i in 0 until h){
		for (j in 0 until w){
			if (!maze[i][j]) continue
			ans = Math.max(ans, max_dist(maze, Pair(i, j)))
		}
	}
	print(ans)
}

fun max_dist(maze: Array<BooleanArray>, from: Pair<Int, Int>): Int{
	val map = Array(maze.size){i -> IntArray(maze[0].size){ j -> if (maze[i][j]) -1 else -2 } }
	map[from.first][from.second] = 0
	var list = listOf(from)
	val side = arrayOf(Pair(-1, 0), Pair(0, -1), Pair(0, 1), Pair(1, 0))
	while (list.size!=0){
		val nextList = mutableListOf<Pair<Int, Int>>()
		for ((r, c) in list){
			for ((dy, dx) in side){
				val (nr, nc) = Pair(r+dy, c+dx)
				if (nr in maze.indices && nc in maze[0].indices){
					if (map[nr][nc]==-1){
						map[nr][nc] = map[r][c]+1
						nextList.add(Pair(nr, nc))
					}
				}
			}
		}
		list = nextList
	}
	return map.map{it.max()!!}.max()!!
}

Measured memory_bytes: 44284
a,c;S(p,q,m,n,d){c+=!p;for(;m*d<=a*!!n;d++)q>p*d||S(p*d-q,q*d,m*d,n-1,d);}main(p,q,n){for(;scanf("%d%d%d%d",&p,&q,&a,&n)*n;c=!printf("%d\n",c))S(p,q,1,n,1);}

Measured memory_bytes: 408
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;

int main(){
    int N;
    string S;
    cin >> N;
    cin >> S;
    int i,j;
    int count[26]={0};
    unsigned long long ans=1;
    for(i=0;i<26;i++){
        for(j=0;j<N;j++){
            if((int)S[j]=='a'+i)count[i]++;
        }
        ans=(ans*(count[i]+1))%1000000007;
    }
    if(ans==0)cout<<1000000006<<endl;
    else
    cout << ans-1 << endl;
    return 0;
}

Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, a, b) for(ll i = ll(a); i <= ll(b); i++)
int main()
{
	ll n,x=0,max_x=0;
	cin>>n;
	string s;
	cin>>s;
	REP(i,0,s.size()-1)
	{
		if(s[i]=='I')
			x++;
		else if(s[i]=='D')
			x--;
		max_x=max(x,max_x);
	}	
	cout<<max_x;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	int[] a, tmp;

	void shuffle(int p, int c) {
		for (int i = 0; i < p - 1; i++) {
			tmp[i] = a[i];
		}
		for (int i = 0; i < c; i++) {
			a[i] = a[p - 1 + i];
		}
		for (int i = 0; i < p - 1; i++) {
			a[c + i] = tmp[i];
		}
	}

	void run() {
		Scanner sc = new Scanner(System.in);

		while (true) {
			int n = sc.nextInt();
			int r = sc.nextInt();
			if ((n | r) == 0) {
				break;
			}
			a = new int[n];
			tmp = new int[n];
			for (int i = 0; i < n; i++) {
				a[i] = n - i;
			}
			for (int i = 0; i < r; i++) {
				int p = sc.nextInt();
				int c = sc.nextInt();
				shuffle(p, c);
			}
			System.out.println(a[0]);
		}
	}

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

Measured memory_bytes: 28436
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <cstring>
#include <cassert>
#include <ext/rope>

using namespace __gnu_cxx;

#define rep(i,e) for(int i=0;i<(e);i++)
#define rep1(i,e) for(int i=1;i<=(e);i++)
#define repx(i,x,e) for(int i=(x);i<=(e);i++)
#define pii pair<int,int>
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define mset(var,val) memset(var,val,sizeof(var))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false);cin.tie(0)

using namespace std;

#ifdef local
    #define dbg(args...) do { cout  << #args << " -> "; err(args); } while (0)
#else
    #define dbg(...)
#endif

void err() {  }
//template<template<typename...> class T, typename t, typename... Args>
//void err(T<t> a, Args... args) { for (auto x: a) cout << x << ' '; err(args...); }
template<typename T, typename... Args>
void err(T a, Args... args) { cout << a << ' '; err(args...); }


typedef long long ll;
template <class T>
void test(T a) {
    cout<<a<<endl;
}
template <class T,class T2>
void test(T a,T2 b) {
    cout<<a<<" "<<b<<endl;
}
template <class T,class T2,class T3>
void test(T a,T2 b,T3 c) {
    cout<<a<<" "<<b<<" "<<c<<endl;
}
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;
const int mod = 1e9+7;

const int N = 1e5+10;

char s[N];

ll dp[2][4];

void work() {
    cin >> s;
    int n = strlen(s);
    int cur = 0, pre = 1;
    dp[cur][0] = 1;
    for(int i = 0; i < n; ++i){
        swap(cur, pre);
        mset(dp[cur],0);
        if(s[i] != '?'){
            dp[cur][s[i]-'A'+1] = dp[pre][s[i]-'A'];
        }
        else{
            rep1(j,3){
                dp[cur][j] = dp[pre][j-1];
            }
        }
        rep(j,4){
            dp[cur][j] = (dp[pre][j] + dp[cur][j]) % mod;
        }
        if(s[i] == '?'){
            rep(j,4){
                dp[cur][j] = (dp[pre][j] + dp[cur][j]) % mod;
                dp[cur][j] = (dp[pre][j] + dp[cur][j]) % mod;
            }
        }
//        rep(j,4){
//            cout << dp[cur][j] << " ";
//        }
//        cout << endl;
    }
    cout << dp[cur][3] << endl;
}


int main() {
#ifdef local
    freopen("in.txt","r",stdin);
//        freopen("out1.txt","w",stdout);
#endif // local
    IOS;
//    init();
//    int t;
//    cin >> t;
//    scd(t);
//    for(; t--;)
        work();
    return 0;
}


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

void InputSet(std::vector<int> & a) {
	int n;
	cin >> n;
	a.resize(n,0);
	for(int i=0;i<n;++i) {
		cin >> a.at(i);
	}
}
void Printf(std::vector<int> & a) {
	for(int i=0;i<(int)a.size();++i) {
		if (i>0){ 
			cout << " ";
		}
		cout  << a.at(i);
	}
	cout << std::endl;
}

void SelectionSort(std::vector<int> & A,int & swaptimes)
{
	for(int i=0;i<(int)A.size();++i){
		int mini=i;
		for(int j=i;j<(int)A.size();++j){
			if (A[j] < A[mini]) {
				mini = j;
			}
		}
		if (mini != i) {
			int tmp = A[mini];
			A[mini] = A[i];
			A[i]=tmp;
			swaptimes++;
		}
	}
}
int main(){
	std::vector<int> A;
	::InputSet(A);
	int swaptimes=0;
	SelectionSort(A,swaptimes);
	::Printf(A);
	cout << swaptimes << std::endl;
}

Measured memory_bytes: 1200
#include <iostream>
#include <vector>
using namespace std;
int n;
vector<int> v;
int R0, W0, C, R;
int main() {
    while(cin >> R0 >> W0 >> C >> R, R0&&R0&&C&&R){
        int cnt=0;
        while(true){
            if(R0/W0>=C) break;
            cnt++;
            R0 += R;
        }
        cout << cnt << endl;
    }
    return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a;
  int b;
  cin >> a >> b;
  double x;
  x=(a+b)/2.0;
  double y;
  y=(a+b)/2;
  if (x==y) {
  cout << y << endl;
  }
  else {
    cout << y+1<< endl;
  }
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  int n, t, c, time, best = -1, first = 0;
  cin >> n >> t;
  while(n--){
    cin >> c >> time;
    if(first == 0 && time<=t){
      first = 1;
      best = c;
    }
    else if(first == 1)
      if(c < best && time<=t)
        best = c;
  }
  if(first)
    cout << best << endl;
  else
    cout << "TLE" << endl;
  return 0;
}


Measured memory_bytes: 256
//I am so vegetable
//#define err
#pragma GCC optimize(2)
#include <bits/stdc++.h>
#define FIO ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define pb push_back
#define in insert
#define er erase
#define ct count
#define ep empty
#define _for(i,a,b) for(int i = (a);i<(b);++i)
#define _rfor(i,a,b) for(int i = (a);i>(b);--i)
#define _sfor(p,st) for(auto &p:st)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int INF = 0x3f3f3f3f;
const double eps = 1e-6;
const double pi = acos(-1.0);
int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); }
ll qpow(ll x, ll y) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans *= x; x *= x; }return ans; }
ll qpow(ll x, ll y, ll MOD) { ll ans = 1; for (; y > 0; y >>= 1) { if (y & 1)ans = ans*x%MOD; x = x*x%MOD; }return ans; }
void exgcd(ll a,ll b,ll &x,ll &y){
    if(!b){x=1;y=0;return;}
    exgcd(b,a%b,x,y);
    ll X=x;
    x=y; y=X-a/b*y;
}
ll inv(ll x, ll MOD) { return qpow(x, MOD - 2) % MOD; }
ll m_m(ll a,ll MOD){ return (a%MOD+MOD)%MOD; }


signed main() {
	//ofstream cout("E:\\acm dream\\out.txt",ios::out);
	FIO;
    #ifdef err
	double be = clock();
    #endif
    int n;cin>>n;
    int ans = 0;
    _for(i,0,n){
        int x;cin>>x;
        if((i+1)%2&&x%2)++ans;
    }
    cout<<ans;
    #ifdef err
	double en = clock();
    cout<<"time: "<<fixed<<setprecision(8)<<en-be;
    #endif
	return 0;
}

Measured memory_bytes: 3648
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline int ri() {int x; scanf("%d", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/



const int maxn = 1e9;
int n, p[100010], a[100010], b[100010];
int main() {
  #ifdef _TEST_
  freopen("input.txt", "r", stdin);
  //freopen("out.txt", "w", stdout);
  #endif
  cin >> n;
  rep(i, n) cin >> p[i];
  for (int i = 0; i < n; i ++) b[i] = 20001 * i;
  for (int i = 0; i < n; i ++) a[p[i] - 1] = b[p[i] - 1] + i + 1;
  rep(i, n) cout << a[i] << ' '; cout << endl;
  rep(i, n) cout << maxn - b[i] << ' '; cout << endl;

  return 0;
}


Measured memory_bytes: 896
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	string s;
    cin>>s;
    int cnt=0;
    REP(i,4){
        if(s[i]=='2'){
            cnt++;
        }
    }

    cout<<cnt<<endl;
	
	
	return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Ti = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main()
{
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int l[100];
  l[0] = 2;
  l[1] = 1;
  reps(i, 2, 100) {
    l[i] = l[i-1]+l[i-2];
  }

  int n;
  cin >> n;
  cout << l[n] << endl;

  return 0;
}


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

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

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

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

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

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

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



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




int main() {

	ll A, B, C;
	cin >> A >> B >> C;

	string ans = "No";

	if (A == B && A != C) { ans = "Yes"; }
	if (A == C && A != B) { ans = "Yes"; }
	if (C == B && A != C) { ans = "Yes"; }

	cout << ans;
	system("PAUSE");

}


Measured memory_bytes: 504
n,k,*a=map(int,open(0).read().split())
a,f=sorted(a[:n]),sorted(a[n:],reverse=1)
ok=10**12
ng=-1
while ok-ng>1:
    mid=(ok+ng)//2
    l=k
    for b,g in zip(a,f):
        t=b-mid//g
        if t>0:l-=t
    if l<0:ng=mid
    else:ok=mid
print(ok)

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

static int toMinutes(int h, int m)
{
    return h * 60 + m;
}


void a(std::istream& in)
{
    int H1, M1, H2, M2, K;
    in >> H1 >> M1 >> H2 >> M2 >> K;

    int goodMorning = toMinutes(H1, M1);
    int goodNight = toMinutes(H2, M2);

    int studyStartRange = goodNight - K - goodMorning;
    studyStartRange = studyStartRange < 0 ? 0 : studyStartRange;

    std::cout << studyStartRange;
}

int main(int, char* [])
{
    a(std::cin);
    return 0;
}


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

void leave(string message) {
    cout << message << endl;
    exit(0);
}

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

    if(s == "hi")  leave("Yes");
    if(s == "hihi")  leave("Yes");
    if(s == "hihihi")  leave("Yes");
    if(s == "hihihihi")  leave("Yes");
    if(s == "hihihihihi")  leave("Yes");
    if(s == "hihihihihihi")  leave("Yes");
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{		
		int bb(char a[],int n);
    	char a[50];
    	while(scanf("%s",a)!=EOF)
    	{
    		
    		int len=strlen(a);
    		if(bb(a,len))
    			printf("no\n");
    		else 
    			printf("yes\n");
    	}
    	return 0;
    }
int bb(char a[],int n)
{
    	int i,c;
    	for(i=0;i<n;i++)
    	{
    		for(c=i+1;c<n;c++)
    		{
    			if(a[i]==a[c])
    				return 1;
    		}
    	}
    	return 0;
}

Measured memory_bytes: 128
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
/*
//#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
*/

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
/*
//#if __cplusplus >= 201103L
#include <array>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
*/
using namespace std;
#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define uni(x) x.erase(unique(all(x)),x.end())
template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;

#define INF INT_MAX/3
#define MAX_N 1000
#define M_INF 1000000000
int n,m,v,i,k;
void solve(){
   cin.tie(0);
  ios::sync_with_stdio(false);
  cin>>n>>k;ll p;
  ll ans =0;
  repl(i,1,n+1){
    if(i*2%k==0){
      p = i/k;
      ans += ((n+i)/k-p) * ((n+i)/k-p);
    }
     // cout<<i<<" "<<ans<<" "<<((n+i)/k-p)<<endl;
  }

  cout<<ans<<endl;
}

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


Measured memory_bytes: 256
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, acos, atan, asin, log, log10, gcd
from itertools import permutations, combinations, product, accumulate, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
#from fractions import gcd
def debug(*args):
    if debugmode:
        print(*args)
def input(): return sys.stdin.readline().strip()
def STR(): return input()
def INT(): return int(input())
def FLOAT(): return float(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 9)
inf = sys.maxsize
mod = 10 ** 9 + 7
dx = [0, 1, 0, -1, 1, -1, -1, 1]
dy = [1, 0, -1, 0, 1, -1, 1, -1]
debugmode = True

s = STR()
t = STR()
if t[:-1] == s:
    print('Yes')
else:
    print('No')

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

using namespace std;

char a[1000000];

int main(){
	int n;
	int mx=-100000;
	cin>>n;
	cin>>a;
	int x=0;
	mx=max(x,mx);
	for(int i=0;i<n;i++)
	{
		if(a[i]=='I')
		{
			x++;
		}
		else x--;
		mx=max(mx,x);
	}
	cout<<mx;
	return 0;
}

Measured memory_bytes: 384
"""
dp[i][j][k]
i桁で非零要素をj個含み, 
「k==0」→ Nのi桁目までと一致
「k==1」→ Nのi桁目までよりも小さい
"""

N = int(input())
K = int(input())
digit = len(str(N))
N_str = str(N)

dp = [[[0]*2 for _ in range(4)] for _ in range(digit+1)]

dp[0][0][0] = 1
#配るDP
for i in range(digit): 
    for j in range(4): 
        for k in range(2):
            for d in range(10):
                ni = i+1; nj = j; nk = k
                nd = int(N_str[i])
                if d != 0: 
                    nj += 1
                if nj > K:
                    continue
                if k == 0:
                    if d > nd:
                        continue
                    if d < nd:
                        nk = 1
    
                dp[ni][nj][nk] += dp[i][j][k]

ans = dp[digit][K][1]+dp[digit][K][0]
#print(dp)
print(ans)

Measured memory_bytes: 3064
#include <iostream>
using namespace std;
long long k,t,s;
int main() {
    cin>>k;
    t=k/50;
    s=k-t*50;
    cout<<50<<endl;
    for(int i=1 ; i<=50; i++){
        if(i<=s){
            cout<<100+t-s<<" ";
        }
        else
            cout<<49+t-s<<" ";
    }
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

func main() {
	var s string
	fmt.Scan(&s)
	r := 1000
	for i := 0; i < len(s)-2; i++ {
		a, _ := strconv.Atoi(s[i : i+3])
		sa := Abs(753 - a)
		if a == 753 {
			fmt.Println("0")
			return
		} else if r > sa {
			r = sa
		}
	}
	fmt.Println(r)
}

func Abs(a int) int {
	if a < 0 {
		return -a
	} else {
		return a
	}
}


Measured memory_bytes: 512
import sys
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))

def main():
    n = IS()
    if n[0]=='7' or n[1]=='7' or n[2]=='7': print('Yes')
    else: print('No')

if __name__ == '__main__':
    main()


Measured memory_bytes: 8980
#include <bits/stdc++.h>
#define ll long long
#define fi first
#define se second
#define sz(a)  int((a).size())
#define pb  push_back
#define eb  emplace_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define repC3(vari,varj,vark,n)  for(int vari=0;vari<(n)-2;++vari)for(int varj=vari+1;varj<(n)-1;++varj)for(int vark=varj+1;vark<(n);++vark)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))
using namespace std;
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); }


int main() {
    int A,B,C,D,N,K;
    int ans=0;
    
    cin>>N>>K;
    int d[N];
    rep(i,N){
        cin>>A;
        if(A>=K){
            ans++;
        }
    }
    Out(ans);
    return 0;
}

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

int main(){
	int n;
	cin>>n;
	vector <int> a(n);
	rep(i,n){
		cin>>a.at(i);
	}
	rep(i,n){
		if(a.at(i)%2==0){
			if(a.at(i)%3==0||a.at(i)%5==0){
				continue;
			}else{
				cout<<"DENIED"<<endl;
				return 0;
			}
		}
	}
	cout<<"APPROVED"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
#define endl '\n'
#define vec vector<ll>
#define mat vector<vector<ll> >
#define fi first
#define se second
typedef long long ll;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
signed main(){
    string s;cin>>s;
    ll n=s.size();
    map<ll,ll>ma;
    ma[0]=0;
    ll now=0;
    ll ans=n;
    rep(i,n){
        now^=(1LL<<(s[i]-'a'));
        ll tmp=inf;
        rep(j,26){
            if(ma.find((1LL<<j)^now)!=ma.end()){
                tmp=min(tmp,ma[(1LL<<j)^now]+1);
            }
        }
        if(ma.find(now)!=ma.end()){
            tmp=min(tmp,ma[now]);
        }
        if(tmp!=inf){
            ma[now]=tmp;
            if(i==n-1){
                ans=min(ans,tmp);
            }
        }
        //cout<<tmp<<endl;
    }
    if(ans==0)ans++;
    cout<<ans<<endl;
}

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

int main() {
  int N, tmp;
  cin >> N;
  int A[N];
  for(int i=0; i<N; i++) A[i]=0;
  
  for(int i=0; i<N-1; i++) {
    cin >> tmp;
    A[tmp-1]++;
  } 
  
  for(int i=0; i<N; i++) {
    printf("%d\n", A[i]);
  } 
  return 0;
}

Measured memory_bytes: 4472
#include <bits/stdc++.h>
using namespace std;
int k;
int a[9][9];
int r[9];
int c[9];
int zhu[19];
int ci[19];
bool ok=0;
void dfs(int i){
	if(i==8){ok=1;return;}
	for(int j=0;j<8;j++){
		if(a[i][j])dfs(i+1);
		if(!a[i][j]&&!c[j]&&!r[i]&&!zhu[i-j+8]&&!ci[i+j]){
			a[i][j]=1;
			c[j]++;r[i]++;zhu[i-j+8]++;ci[i+j]++;
			dfs(i+1);
			if(ok)return;
			a[i][j]=0;
			c[j]--;r[i]--;zhu[i-j+8]--;ci[i+j]--;
		}
	}
}
void solve(){
	dfs(0);
}
int main(){
//	freopen("a.txt","r",stdin);
	cin>>k;
	for(int i=0;i<k;i++){
		int x,y;
		cin>>x>>y;
		a[x][y]=1;
		r[x]++;c[y]++;
		zhu[x-y+8]++;
		ci[x+y]++;
	}
	solve();
	for(int i=0;i<8;i++){
		for(int j=0;j<8;j++){
			if(a[i][j])cout<<'Q';
			else cout<<'.';
		}cout<<"\n";
	}
	return 0;
}


Measured memory_bytes: 3108
import sys
sys.setrecursionlimit(10 ** 5 + 10)
def input(): return sys.stdin.readline().strip()

def resolve():
    def main():
        S=str(input())

        # bit全探索
        # https://qiita.com/gogotealove/items/11f9e83218926211083a#%E4%BE%8B%E9%A1%8C-1
        n = len(S)-1
        if n==0:
            return int(S)
        else:
            # 昇順での探索だよ
            ans=0
            for i in range(2 ** n):
                temp = n+1
                for j in range(n):  # このループが一番のポイント
                    if ((i >> j) & 1):
                        ans+=int(S[-j-1:temp])
                        temp=-j-1
                    if j==n-1:
                        ans+=int(S[:temp])# 順
            return ans# に右にシフトさせ最下位bitのチェックを行う
    print(main())


resolve()

Measured memory_bytes: 3064
N,K=map(int,input().split())
S=list(input())
ans=0
lr=0
rl=0
for i in range(N-1):
    if S[i]=="L":
        if S[i+1]=="R":
            lr=lr+1
        else:
            ans=ans+1
    else:
        if S[i+1]=="L":
            rl=rl+1
        else:
            ans=ans+1
change=max(rl,lr)
ans=ans+2*min(change,K)
print(min(ans,N-1))

Measured memory_bytes: 4084
n, d = list(map(int, input().split()))
v = [list(map(int, input().split())) for i in range(n)]
ans = 0
for i in range(n):
  for j in range(i+1, n):
    dist = 0
    for k in range(d):
      dist += (v[i][k]-v[j][k])**2
    dist = dist**(1/2)
    if dist.is_integer():
      ans += 1
print(ans)


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

int main(){
  int M1, D1, M2, D2;
  cin >> M1 >> D1;
  cin >> M2 >> D2;
  
  if ( M1 == M2 ){
    cout << 0 << endl;
  }
  else{
    cout << 1 << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[1001];
int main()
{
	int m;
	scanf("%s",a);
	m=strlen(a);
	if (a[m-1]=='s') 
	 printf("%s%s",a,"es");
	else printf("%s%s",a,"s");
	return 0;
}

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

#define REP(i,n) for(int i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define INF INT_MAX/3
#define LINF LLONG_MAX/3
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(v) (v).begin(),(v).end()
#define debug(x) cout<<#x<<":"<<x<<endl
#define debug2(x,y) cout<<#x<<","<<#y":"<<x<<","<<y<<endl
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;

void solve(int N,int M){
    vector<int> h(N),w(M);
    rep(i,N) cin>>h[i];
    rep(i,M) cin>>w[i];

    map<int,int> hh,ww;
    for(int i=0;i<N;i++){
        int sum = 0;
        for(int j=i+1;j<=N;j++){
            sum += h[j-1];
            hh[sum]++;
        }
    }

    for(int i=0;i<M;i++){
        int sum = 0;
        for(int j=i+1;j<=M;j++){
            sum += w[j-1];
            ww[sum]++;
        }
    }

    ll ans=0;
    for(auto x:hh){
        ans += (ll)x.second * ww[x.first];
    }
    cout << ans << endl;
}

int main(){
    int N,M;
    while(cin>>N>>M){
        if(N==0 and M==0) break;
        solve(N,M);
    }
}

Measured memory_bytes: 34364
import java.util.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int dice[] = {6,2,1,5,3,4};
        int num,i;
        int sum,tmp;
        String roll;

        while(sc.hasNext()){
        num = Integer.parseInt(sc.nextLine());
        if(num == 0) break;
        
        dice[0] = 6;
        dice[1] = 2;
        dice[2] = 1;
        dice[3] = 5;
        dice[4] = 3;
        dice[5] = 4;
        sum = dice[2];
        
        for(i = 0; i < num; i++){
            roll = sc.nextLine();
            if(roll.equals("North")){
                tmp = dice[2];
                dice[2] = dice[1];
                dice[1] = dice[0];
                dice[0] = dice[3];
                dice[3] = tmp;
            }else if(roll.equals("East")){
                tmp = dice[2];
                dice[2] = dice[5];
                dice[5] = dice[0];
                dice[0] = dice[4];
                dice[4] = tmp;
            }else if(roll.equals("West")){
                tmp = dice[2];
                dice[2] = dice[4];
                dice[4] = dice[0];
                dice[0] = dice[5];
                dice[5] = tmp;
            }else if(roll.equals("South")){
                tmp = dice[2];
                dice[2] = dice[3];
                dice[3] = dice[0];
                dice[0] = dice[1];
                dice[1] = tmp;
            }else if(roll.equals("Right")){
                tmp = dice[3];
                dice[3] = dice[5];
                dice[5] = dice[1];
                dice[1] = dice[4];
                dice[4] = tmp;
            }else if(roll.equals("Left")){
                tmp = dice[3];
                dice[3] = dice[4];
                dice[4] = dice[1];
                dice[1] = dice[5];
                dice[5] = tmp;
            }
            sum += dice[2];
        }
        
        System.out.println(sum);
        }        
    }
}

Measured memory_bytes: 41748
n = int(raw_input())
A = map(int, raw_input().split())
c = 0
absA = [abs(0-A[0])]
jumpA = []
for i in range(n-1):
    absA.append(abs(A[i+1]-A[i]))
    jumpA.append(abs(c-A[i+1]))
    c = A[i]
absA.append(abs(A[-1]-0))
jumpA.append(abs(A[-2]-0))
total = sum(absA)
for i in range(n):
    print total - absA[i] - absA[i+1] + jumpA[i]

Measured memory_bytes: 17656
// #pragma GCC optimize ("O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/assoc_container.hpp>

using namespace std;
// using namespace __gnu_pbds;
// using namespace __gnu_cxx;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

// #define oset tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 

#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound

#define sz(x) (int)x.size()
#define beg(x) x.begin()
#define en(x) x.end()
#define all(x) beg(x), en(x)
#define zero(a) memset(a,0,sizeof(a))

// #define int ll

const ll INF = 1e18;
const ld PI = 4*atan((ld)1);
const int MOD = 1000000007; // 998244353


int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int a,b,t;cin >> a >> b >> t;
	cout << b*(t/a) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class GL {
	public long GCD,LCM;

	public GL(long a,long b){
		long g = gcd(a,b);
		this.GCD = g;
		this.LCM = a * b / g;
	}
	private long gcd(long a,long b){
		while( a != b ){
			if( a < b ){
				b -= a;
			} else if( a > b ){
				a -= b;
			}
		}
		return a;
	}
}

public class Main {
	public static void main(String[] args) {

		ArrayList<GL> ar = new ArrayList<GL>();

		//input
		Scanner sc = new Scanner(System.in).useDelimiter(System.getProperty("line.separator"));
		String[] s;
         while(sc.hasNext()){
             s = sc.next().split("\\s");
             ar.add(new GL(Long.parseLong(s[0]),Long.parseLong(s[1])));
         }
		
         //output
         for(GL g:ar){System.out.println(g.GCD + " " + g.LCM);}
	}
}

Measured memory_bytes: 17180
#include <bits/stdc++.h>
using namespace std;
#define ll                      long long int
#define fi                      first
#define se                      second
#define pb                      push_back
#define pbb                     pop_back
#define mp                      make_pair
#define pii     	            pair<int,int>
#define all(x)                  x.begin(), x.end()
#define mem(array, value)       memset(array, value, sizeof(array))
#define fastRead 	            ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#ifdef Lollipop
    #define line                    cout << "\n===================\n"
    #define trace(...)              __f( #__VA_ARGS__ , __VA_ARGS__ )
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " = " << arg1 << "\n";
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " = " << arg1 << " , ";
    __f(comma + 1, args...);
    }
#else
    #define line
    #define trace(...)
#endif


int main ()
{
    #ifdef Lollipop
        //freopen ("input.txt", "r", stdin);
        //freopen ("output.txt", "w", stdout);
    #endif
    //fastRead;
    ll x;
    cin >> x;
    ll res = 0;
    ll cnt = x / 500;
    res = cnt * 1000;
    x %= 500;
    res += (x / 5) * 5;
    cout << res << endl;
    return 0;
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
int buf[500];
using namespace std;
int main()
{
         string s;
         cin >> s;
         for(int i=0;i<s.size();i++)
         {
                   buf[s[i]]++;
         }
         int ans;
         ans=min(min(buf['K'],buf['U']),min(buf['P'],buf['C']));
         cout << ans << endl;
         return 0;
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define foe(it,c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define long long long 
#define db double 
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)

const int INF = 1e9+7;
const int MOD = 1e9+7;
const int dx[4] = {0,0,-1,1};
const int dy[4] = {-1,1,0,0};

const int N = 2e6+2;

long fact[N], ifact[N];

long POW(long x, long n){
  if (n == 0) return 1;
  long y = POW(x, n / 2);
  y = y * y % MOD;
  if (n % 2) return x * y % MOD;
  else return y;
}

int main()
{
  fastio;
  int u, v, x, y;
  cin >> u >> v >> x >> y;
  fact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = fact[i - 1] * i % MOD;
  ifact[N - 1] = POW(fact[N - 1], MOD - 2); ifact[0] = 1;
  for (int i = N - 2; i > 0; i--) ifact[i] = ifact[i + 1] * (i + 1) % MOD;
  auto C = [&](int k, int n){
    long res = fact[n] * (ifact[k] * ifact[n - k] % MOD) % MOD;  
    return res;
  };
  auto F = [&](int u, int v){
    long res = 0;
    for (int i = 1; i <= u + 1; i++){
      res += C(i, v + i);
      res %= MOD;
    }
    return res;
  };
  long res = F(x, y) - F(u - 1, y) - F(x, v - 1) + F(u - 1, v - 1);
  res %= MOD; (res += MOD) %= MOD; 
  cout << res;
  return 0;
}

Measured memory_bytes: 31488
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"

using namespace std;
using namespace __gnu_pbds;


#define ll long long int
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(),a.end()

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    double s;
    cin>>s;
    double a = s/3;
    double b = s/3;
    double c = s - (a + b);
    printf("%.6lf\n", a*b*c);
}

Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
using namespace std;
#define REP(i,n) for(int i = 0; i < n; i++)

int main(void)
{
    string S;
    cin >> S;
    bool first = false;
    bool second = false;
    bool third = true;

    if(S.front() == 'A'){
        first = true;
    }

    int idx = 0;
    int c = 0;
    for(int i  = 2; i <= S.length() - 2; i++){
        if(S[i] == 'C'){
            c++;
            idx = i;
        }
    }
    if(c == 1) second = true;

    for(int i = 1; i < S.length(); i++){
        if(i == idx) continue;

        if(isupper(S[i])){
            third = false;
        }
        // if(S[i] < 'a' && S[i] > 'z'){
            // third = false;
        // }
    }

    if(first && second && third)
        cout << "AC" << endl;
    else    
        cout << "WA" << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby
    #from itertools import product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    n,k = map(int, input().split())
    a = input().rstrip().split()

    for i in range(n, 10**8):
        s = str(i)
        for j in a:
            if j in s:
                break
        else:
            print(i)
            exit()

if __name__ == '__main__':
    main()

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

int __p = 0;
int __ST[100];

void s_push(int v){
	__ST[__p++] = v;
}
int s_pop(){
	return __ST[--__p];
}
int main(){
	
	string str;
	
	while(cin >> str){
		if('1'<=str[0] && str[0]<='9'){
			s_push(stoi(str));
		} else {
			int a;
			switch(str[0]){
			case '+':
				s_push(s_pop() + s_pop());
				break;
			case '-':
				a = s_pop();
				s_push(s_pop() - a);
				break;
			case '*':
				s_push(s_pop() * s_pop());
				break;
			}
		}
	}
	cout << s_pop() << endl;
	
	return 0;
}


Measured memory_bytes: 3180
#include<bits/stdc++.h>
#define reg register
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
string s;
ll ans=inf;
int main()
{
    getline(cin,s);
    for(reg int i=0;i<=s.length()-1;i++) 
    if(s[i]!=s[i-1])
    ans=min(ans,max((ll)i,(ll)s.length()-i));
	printf("%lld",min(ans,(ll)s.length()));
    return 0;
}

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

#define fst(t) std::get<0>(t)
#define snd(t) std::get<1>(t)
#define thd(t) std::get<2>(t)
#define unless(p) if(!(p))
#define until(p) while(!(p))

using ll = std::int64_t;
using T = std::tuple<int,int,int>;

const int dx[] = {-1, +1, 0, 0, -1, -1, +1, +1, 0}, dy[] = {0, 0, -1, +1, -1, +1, -1, +1, 0};
constexpr int INF = 2001001001;

int H, W, A, B;
std::string m[1100];
int sy, sx, gy, gx;
bool has[1100][1100];
int dist[1100][1100];
std::priority_queue<T, std::vector<T>, std::greater<T>> pq;

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

    std::cin >> H >> W >> A >> B;

    for(int i=0;i<H;++i){
        std::cin >> m[i];

        for(int j=0;j<W;++j){
            if(m[i][j] == 's'){
                sy = i;
                sx = j;
            }else if(m[i][j] == 'g'){
                gy = i;
                gx = j;
            }
        }
    }

    for(int i=0;i<H;++i){
        for(int j=0;j<W;++j){
            if(m[i][j] == '*'){
                for(int k=0;k<9;++k){
                    int y = i + dy[k], x = j + dx[k];

                    if(0 <= y && y < H && 0 <= x && x < W){
                        has[y][x] = true;
                    }
                }
            }
        }
    }

    std::fill(&dist[0][0], &dist[0][0] + 1100 * 1100, INF);
    dist[sy][sx] = 0;
    pq.emplace(0, sy, sx);

    until(pq.empty()){
        int d, y, x;
        std::tie(d, y, x) = pq.top();
        pq.pop();

        if(d > dist[y][x]){
            continue;
        }

        for(int i=0;i<4;++i){
            int ny = y + dy[i], nx = x + dx[i];

            if(0 <= ny && ny < H && 0 <= nx && nx < W && m[ny][nx] != '#'){
                if(d + A < dist[ny][nx]){
                    dist[ny][nx] = d + A;
                    pq.emplace(dist[ny][nx], ny, nx);
                }
            }
        }

        unless(has[y][x]){
            for(int i=0;i<8;++i){
                int ny = y + dy[i], nx = x + dx[i];

                if(0 <= ny && ny < H && 0 <= nx && nx < W && m[ny][nx] == '#'){
                    int ma = std::abs(ny - y) + std::abs(nx - x);

                    if(d + ma * A + B < dist[ny][nx]){
                        dist[ny][nx] = d + ma * A + B;
                        pq.emplace(dist[ny][nx], ny, nx);
                    }
                }
            }
        }
    }

    if(dist[gy][gx] < INF){
        std::cout << dist[gy][gx] << std::endl;
    }else{
        std::cout << "INF" << std::endl;
    }
}



Measured memory_bytes: 9792