akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

const ll mod = 1e9+7;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
  vector<mint> fact, ifact;
  combination(ll n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (ll i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (ll i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(ll n, ll k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
  mint p(ll n, ll k) {
    return fact[n]*ifact[n-k];
  }
} c(1000005);

int main(){
    ll n,k;
    cin >> n >> k;
    ll c=0;
    for(ll i=1;i*i<=n;i++){
        c=i;
    }
    map<ll,ll> m;
    ll sum=0;
    ll i=1;
    while(1){
        ll d=n/i-n/(i+1);
        sum+=d;
        if(sum>n-c) break;
        if(d>0){
            m[i]+=d;
        }
        i++;
    }
    for(ll i=1;i*i<=n;i++){
        m[n/i]++;
    }
    
    ll sz=m.size();
    vector<mint> num(sz);
    ll cnt=0;
    for(auto [x,y]:m){
        //cout << x << " " << y << endl;
        num[sz-1-cnt]=y;
        cnt++;
    }
    vector<mint> dp(sz,1),nxt(sz);
    rep(i,k-1){
        rep(j,sz){
            if(j==0){
                nxt[j]=dp[sz-1-j];
            }
            else{
                nxt[j]=nxt[j-1]+num[j]*dp[sz-1-j];
            }
        }
        dp=nxt;
        nxt=vector<mint>(sz);
    }
    mint ans=0;
    rep(i,sz){
        ans+=dp[i]*num[sz-1-i];
        //cout << dp[i] << " " << num[sz-i-1] << endl;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 24768
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

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

int main(void) {
	int num, i;
	ll a, b, n, ans;
	//double a, b, n;
	cin >> a >> b >> n;
	ans = (a * n / b) - a * (n / b);
	n = n - (n % b) - 1;
	ans = max(ans, (a * n / b) - a * (n / b));
	cout << ans << "\n";
	return 0;
}

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

using namespace std;

using int64 = long long;
const int mod = 1e9 + 7;
// const int mod = 998244353;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template< typename T >
istream &operator>>(istream &is, vector< T > &v) {
  for(T &in : v) is >> in;
  return is;
}

template< typename T1, typename T2 >
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }

template< typename T1, typename T2 >
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

template< typename T = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int A, B, K;
  cin >> K >> A >> B;
  int V = (A + K - 1) / K * K;
  if(V <= B) cout << "OK\n";
  else cout << "NG\n";
}

Measured memory_bytes: 3640
#include <algorithm>
#include <cstring>
#include <iostream>
#include <queue>
#include <vector>

using namespace std;

int main() {
  long long sum = 0;
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    if (i % 3 == 0 || i % 5 == 0) {
      continue;
    }
    sum += i;
  }
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3156
#include<iostream>
using namespace std;
int main()
{
    string s;
    int k;
  cin>>k;
    cin>>s;
    if(s.length()<=k) cout<<s;
    else
    {
        for(int i=0;i<k;i++) cout<<s[i];
        cout<<"...";
    }
}


Measured memory_bytes: 3628
import sys

def main():
  input = sys.stdin.readline
  N, M = map(int, input().split())
  A = list(map(int, input().split()))
  d = {1: 2, 2: 5, 3: 5, 4: 4, 5: 5, 6: 6, 7: 3, 8: 7, 9: 6}
  
  dp = [0 for _ in range(N+1)]
  for i in range(1, N+1):
    dpi = - float('inf')
    for a in A:
      if d[a] <= i:
        dpi = max(dpi, dp[i - d[a]] + 1)
    dp[i] = dpi

  ans = [0 for _ in range(dp[N])]
  for i in range(len(ans)):
    num = 0
    for a in A:
      if (d[a] <= N) and (dp[N - d[a]] == dp[N] - 1):
        num = max(num, a)
    ans[i] = str(num)
    N -= d[num]

  print(''.join(ans))


if __name__ == '__main__':
  main()

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

const int ALP_NUM = 26;
const int INF = 1001001001;

int main() {
    int d;
    cin >> d;
    vector<int> C(ALP_NUM);
    rep(i, ALP_NUM) cin >> C[i];
    vector<vector<int>> S(d, vector<int>(ALP_NUM));
    rep(i, d) rep(j, ALP_NUM) cin >> S[i][j];
    vector<int> T;
    vector<set<int>> schedules(ALP_NUM);
    rep(i, ALP_NUM) schedules[i].insert(-1);
    

    auto get_score = [&](vector<int> A, int n) {
        int res = 0;
        vector<int> D(ALP_NUM, -1);
        rep(i, n) {
            int t = A[i];
            res += S[i][t];
            D[t] = i;
            rep(j, ALP_NUM) {
                res -= (i-D[j]) * C[j];
            }
        }
        return res;
    };

    auto change = [&](int nd, int nt) {
        int pt = T[nd];
        int res = S[nd][nt] - S[nd][pt];

        auto it_l = schedules[pt].lower_bound(nd);
        auto it_r = schedules[pt].upper_bound(nd);
        --it_l;
        int pt_ld = *it_l;
        int pt_rd;
        if (it_r != schedules[pt].end()) pt_rd = *it_r;
        else pt_rd = d;
        res -= C[pt] * (nd-pt_ld) * (pt_rd-nd);

        it_l = schedules[nt].lower_bound(nd);
        it_r = schedules[nt].upper_bound(nd);
        --it_l;
        int nt_ld = *it_l;
        int nt_rd;
        if (it_r != schedules[nt].end()) nt_rd = *it_r;
        else nt_rd = d;
        res += C[nt] * (nd-nt_ld) * (nt_rd-nd);

        return res;
    };

    rep(i, d) {
        int max_score = -INF;
        int tmp = 0;
        T.push_back(0);
        rep(j, ALP_NUM) {
            T[i] = j;
            int score = get_score(T, i+1);
            if (score > max_score) {
                max_score = score;
                tmp = j;
            }
        }
        T[i] = tmp;
    }
    

    rep(i, d) {
        cout << T[i]+1 << endl;
    }

    //cout << get_score(T, d) << endl;

    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int ma = 0, mi = 1e9;
    for(int i=0; i<n; i++){
        int x; cin >> x;
        ma = max(ma, x);
        mi = min(mi, x);
    }
    cout << abs(ma - mi) << endl;
    return 0;
}

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

int countdiv(int n) {
  int count=0;
  
  for(int i=n; i>0; i/=2) {
    if(i%2 == 0) count++;
  }
  
  return count;
}

int main(){
  int N,count,maxcount=0,maxnumber;
  
  cin >> N;
  
  for(int i=1; i<=N; i++) {
    count = countdiv(i);
    if(maxcount <= count) {
      maxcount = count;
      maxnumber = i;
    }
  }
  
  cout << maxnumber << endl;
  
  return 0;
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> TUP;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
	if(s[5]=='1'){
		cout<<"TBD";
	}else{
		ll c=s[6]-'0';
		if(c<=4) cout<<"Heisei";
		else cout<<"TBD";
	}
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
using std::cin; using std::cout;
using std::endl;
using std::bitset; using std::map;
using std::queue; using std::priority_queue;
using std::set; using std::string;
using std::stringstream; using std::vector;
using std::pair; using std::make_pair;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;
typedef pair<ULL, ULL> puu;
#ifdef DEBUG
using std::cerr;
#define pass cerr << "[" << __FUNCTION__ << "] : line = " << __LINE__ << endl;
#define display(x) cerr << #x << " = " << x << endl;
#define displaya(a, st, n)                      \
	{                                           \
		cerr << #a << " = {";                   \
		for (int qwq = (st); qwq <= (n); ++qwq) \
			if (qwq == (st))                    \
				cerr << a[qwq];                 \
			else                                \
				cerr << ", " << a[qwq];         \
		cerr << "}" << endl;                    \
	}
#define displayv(a) displaya(a, 0, (int)(a.size() - 1))
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#include <ctime>
class MyTimer {
	clock_t st;
public:
	MyTimer() { cerr << std::fixed << std::setprecision(0); reset(); }
	~MyTimer() { report(); }
	void reset() { st = clock_t(); }
	void report() {  cerr << "Time consumed: " << (clock() - st) * \
		1e3 / CLOCKS_PER_SEC << "ms" << endl; }
} myTimer;
#else
#define cerr if(false) std::cout
#define pass ;
#define display(x) ;
#define displaya(a, st, n) ;
#define displayv(a) ;
#define eprintf(...) if(0) fprintf(stderr, __VA_ARGS__)
class MyTimer {
public: void reset() {} void report() {}
} myTimer;
#endif

template<typename A, typename B>
std::ostream& operator << (std::ostream &cout, const pair<A, B> &x) {
	return cout << "(" << x.first << ", " << x.second << ")";
}
template<typename T1, typename T2>
inline bool chmin(T1 &a, const T2 &b) { return a > b ? a = b, true : false; }
template<typename T1, typename T2>
inline bool chmax(T1 &a, const T2 &b) { return a < b ? a = b, true : false; }


const LL P = 1000000007;
int n;
LL c[26];

int main() {
	string s;
	cin >> n >> s;
	memset(c, 0, sizeof(c));
	for(char p : s) c[(int)(p - 'a')]++;
	LL ans = 1;
	for(int i = 0; i < 26; ++i) ans = ans * (c[i] + 1) % P;
	ans = (ans - 1 + P) % P;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 512
A, B, C = gets.split.map(&:to_i)
K = gets.to_i

["a", "b", "c"].repeated_combination(K).to_a.each do |combi|
  a, b, c = A, B, C
  combi.each do |s|
    if s == "a"
      a *= 2
    elsif s == "b"
      b *= 2
    elsif s == "c"
      c *= 2
    end
  end
  if a < b && b < c
    print "Yes\n"
    exit
  end
end
print "No\n"

Measured memory_bytes: 14404
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
using namespace std;
//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/
int recur_depth = 0;
#ifdef DEBUG
#define dbg(x) {++recur_depth; auto x_=x; --recur_depth; cerr<<string(recur_depth, '\t')<<"\e[91m"<<__func__<<":"<<__LINE__<<"\t"<<#x<<" = "<<x_<<"\e[39m"<<endl;}
#else
#define dbg(x)
#endif
template<typename Ostream, typename Cont>
typename enable_if<is_same<Ostream,ostream>::value, Ostream&>::type operator<<(Ostream& os,  const Cont& v){
	os<<"[";
	for(auto& x:v){os<<x<<", ";}
	return os<<"]";
}
template<typename Ostream, typename ...Ts>
Ostream& operator<<(Ostream& os,  const pair<Ts...>& p){
	return os<<"{"<<p.first<<", "<<p.second<<"}";
}
// debugging ends here

typedef long long int ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	string s;
	cin >> s;
	int n = s.length();
	for(int i =0;i<n;i++)
		cout << 'x';
	cout << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = a; i < n; i++)
#define repr(i, a, n) for (int i = n - 1; i >= a; i--)
using namespace std;
using ll = long long;
using P = pair<int, int>;
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() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  string s;
  cin >> s;
  int ans = 1e9;
  rep(i, 0, s.size() - 2) {
    int val = stoi(s.substr(i, 3));
    chmin(ans, abs(753 - val));
  }
  cout << ans << endl;
}


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

def solve():
    n = int(input())
    al = [int(i) for i in input().split()]
    ss, xs = 0, 0
    
    ans = 0
    last_index = 0
    length = 0
    for i in range(n):
        ss += al[i]
        xs ^= al[i]
        length += 1
        while ss != xs:
            ss -= al[last_index]
            xs ^= al[last_index]
            last_index += 1
            length -= 1
        ans += length
    print(ans)

if __name__=="__main__":
    solve()


Measured memory_bytes: 23560
/*!enjoy karo yaar!*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int             long long int
#define     fast()          ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)          (x).begin(),(x).end()
#define     rz(x)           resize(x)
#define     mem(a,b)        memset(a,b,sizeof(a))
#define     sz(x)           ((int)(x.size()))
#define     eb              emplace_back
#define     pb              push_back
#define     pf              push_front
#define     pob             pop_back
#define     pof             pop_front
#define     ins             insert
#define     vi              vector<int>
#define     pii             pair<int,int>
#define     mii             map<int,int>
#define     F               first
#define     S               second
#define     makep           make_pair
#define     maket           make_tuple
#define     remax(a,b)      a=max(a,b)
#define     remin(a,b)      a=min(a,b)
#define     bitcount(x)     __builtin_popcountll(x)
#define     iceil(n,x)      (((n)+(x)-1)/(x))
#define     gcd(a,b)        (__gcd((a),(b)))
#define     lcm(a,b)        (((a)*(b))/gcd((a),(b)))
#define     dbug(x)         cout<<#x<<": "<<(x)<<"\n"
#define     flush           fflush(stdout)
#define     show(x)         for(auto zz:x)cout<<zz<<" ";cout<<"\n";
#define     show2(x)        for(auto zz:x)cout<<zz.F<<" "<<zz.S<<"\n";

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;

const ld pi=acos(-1);
const ll inf=1e18,M=1e9+7;
const int N=1;

void solve()
{
    int n;
    cin>>n;

    vi v(n);
    for(int i=0;i<n;++i)
        cin>>v[i];

    vi a(n);
    for(int i=0;i<n;++i)
        a[i]=(i+1)-v[i];

    mii mp;

    int ans=0;
    for(int i=0;i<n;++i)
    {
        ans+=mp[a[i]];

        ++mp[(i+1)+v[i]];
    }

    cout<<ans;
}

int32_t main()
{
    fast();

    int t=1;
    //cin>>t;
    for(int z=1;z<=t;++z)
    {
        solve();
        //cout<<"\n";
    }

    return 0;
}



Measured memory_bytes: 29008
import Control.Monad

main :: IO ()
main = do
  s <- getLine
  print $ sum $ map read . filter (not . null) $ concat $ splits s

splits :: [a] -> [[[a]]]
splits xs = map (`split` xs) $ filterM (const [True, False]) [1..length xs - 1]

split :: [Int] -> [a] -> [[a]]
split [] xs = [xs]
split _ [] = []
split (i:is) xs = let
    (ls, rs) = splitAt i xs
  in ls : split (map (subtract i) is) rs


Measured memory_bytes: 1020
#include<bits/stdc++.h>
#define pb(x) push_back(x)
#define make(a,b) make_pair(a,b)
#define  mi map<int,int>
#define ll long long 
#define pii  pair<int,int>
#define vii vector<pii>
#define vi vector<int>
#define INF 1000000000
#define mod 1000000007
using namespace std;
int main()
 {
 	ios_base::sync_with_stdio(false);
 	cin.tie(NULL);
 	cout.tie(NULL);
   /*#ifndef ONLINE_JUDGE
   	freopen("input.txt","r",stdin);
   	freopen("output.txt","w",stdout);
	#endif*/
	ll a ,b,c,d;
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
	cout<<"Yes\n";
	else
	cout<<"No\n";
}

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

using namespace std;

#define inf 1<<30
#define pqueue priority_queue
#define mp make_pair
#define pb push_back
#define fn fill_n
typedef long long llong;
typedef unsigned long long ullong;
typedef pair<int, int> P;
struct UnionFind{
	vector<int> par, rank;

	UnionFind(){};
	UnionFind(int n){
		par.resize(n), rank.resize(n);
		for(int i = 0; i < n; i++)
			par[i] = i, rank[i] = 0;
	};
	int find(int n){
		if(par[n] == n) return n;
		return par[n] = find(par[n]);
	};
	bool isSame(int a, int b){
		return find(a) == find(b);
	};
	void marge(int a, int b){
		a = find(a);
		b = find(b);
		if(a == b) return;
		if(rank[a] > rank[b]) swap(a,b);
		if(rank[a] == rank[b]) rank[a]++;
		par[b] = a;
		return;
	};
};

int N, M;
int id[100001] = {};
UnionFind uf;

int main(){
	cin >> N >> M;
	uf = UnionFind(N+1);
	int in;
	for(int i = 1; i <= N; i++){
		cin >> in;
		id[in] = i;
	}
	int a, b;
	for(int i = 0; i < M; i++){
		cin >> a >> b;
		uf.marge(a,b);
	}
	int cnt = 0;
	for(int i = 1; i <= N; i++)
		if(uf.isSame(i, id[i]))
			cnt++;

	cout << cnt << endl;

	return 0;
}

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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

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

    for(int i = n; i > 0; i--){
        if(floor(sqrt(i)) == sqrt(i)){
            cout << i << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		int count = 0;
		for(int i=0; i<3; i++){
			if(s.charAt(i) == 'o'){
				count++;
			}
		}
		System.out.println(700 + count * 100);
	}
}


Measured memory_bytes: 35508
#include<iostream>
#include<bits/stdc++.h>
#define mod 1000000007
#define ps(x,noOfDecimal) fixed<<setprecision(noOfDecimal)<<x
using namespace std;

signed main()
{
    if (fopen("input.txt", "r")) {
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    }
    std::ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    // cin>>t;
    while (t--) {
        string str;
        cin>>str;
        int n=str.size();
        if(str[n-1]=='s'){
            str+="es";
        }
        else{
            str+='s';
        }
        cout<<str;
    }   
    return 0;
}

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

class Program
{
  static void Main()
  {
    var input = Console.ReadLine()
       .Split(' ')
       .Select(s => int.Parse(s));
    int n = input.First();
    int m = input.Last();
    
    int l = 0;
    if (n >= 2)
      l += n * (n-1) / 2;
    if (m >= 2)
      l += m * (m-1) / 2;
    Console.WriteLine(l);
  }
}


Measured memory_bytes: 11348
#include <stdio.h>

int aiu(int a){
  int ret;
  if(a%2==1){
    ret=(a-1)/2;
  }else{
    ret=a/2;
  }
  return ret;
}

int main(){
  int n,sum;
  int count=0;
  scanf("%d",&n);
  int a[n+1],b[n+1];
  for(int i=1;i<=n;i++){
    scanf("%d",&a[i]);
    if(i>aiu(n)){
      b[i]=a[i];
      if(b[i]==1){
        count=count+1;
      }
    }
  }
  
  for(int i=aiu(n);i>=1;i--){
    sum=0;
    for(int j=2*i;j<=n;j=j+i){
      sum=sum+b[j];
    }
    if(sum%2==a[i]){
      b[i]=0;
    }else{
      b[i]=1;
      count=count+1;
    }
  }
  
  printf("%d\n",count);
  for(int i=1;i<=n;i++){
    if(b[i]==1){
      printf("%d ",i);
    }
  }
  
  return 0;
}

Measured memory_bytes: 2432
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int[] D = new int[N];
		for (int i = 0; i < N; ++i) {
			D[i] = sc.nextInt();
		}
		Arrays.sort(D);
		int max = C / A;
		int sum = 0;
		for (int i = N - 1; i >= 0; --i) {
			sum += D[i];
			max = Math.max(max, (C + sum) / (A + B * (N - i)));
		}
		System.out.println(max);
	}
}

Measured memory_bytes: 18140
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, x, y;
    cin >> n >> m >> x >> y;
    int max_x = x;
    int min_y = y;
    REP(i, n) {
        int temp;
        cin >> temp;
        max_x = max(max_x, temp);
    }
    REP(i, n) {
        int temp;
        cin >> temp;
        min_y = min(min_y, temp);
    }
    cout << (max_x < min_y ? "No War" : "War") << endl;
    
    return 0;
}


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

int main() {
    int ans = 0;

    rep(i, 5) {
        int x;
        cin >> x;
        if (x == 0) ans = i + 1;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3620
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;
using System.IO;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static int Sum(long N)
        {
            int sum = 0;
            while (N > 0)
            {
                sum += (int)(N % 10);
                N /= 10;
            }
            return sum;
        }
        private static int Solve(long N)
        {
            int max = Sum(N);
            for (long n = 1; n < N; n *= 10)
            {
                max = Math.Max(Sum(N - N % n - 1), max);
            }
            return max;
        }
        static void Main(string[] args)
        {
            long N = ReadLong();
            Console.WriteLine(Solve(N));
        }
    }
}


Measured memory_bytes: 11092
#How many ways M=a1*a2*...*aN ex)N=2,M=6 a={1,6},{2,3},{3,2},{6,1}
import math
n,m=map(int,input().split())
factor=[]
c=0
mod=10**9+7

#Prime Factorization [number,times]
while m%2 == 0:
    m//=2
    c+=1
    '''
    if c>=20:
        c=0
        break
        '''
if c != 0:
    factor.append([2,c])
#Alternate
for i in range(3,m+1,2):
    c=0
    while m%i == 0:
        m//=i
        c+=1
    if c != 0:
        #print(i,c)
        factor.append([i,c])
    if m == 1:
        break
    if i*i>=m:  # m is prime
        factor.append([m,1])
        break
        
#print(factor)

def C(n,k):
    ans=1
    for s in range(1,k+1):
        ans*=n
        ans//=s
        n-=1
    return ans

def funcount(length,rest,memo):
    a=0
    if length==1:
        #print(length,rest)
        memo[length][rest]=1
        return 1,memo
    elif rest <= 1:
        #print(length,rest)
        memo[length][rest]=0
        return 0,memo
    if memo[length][rest] != -1:
        return memo[length][rest],memo
    else:
        for i in range(1,rest):
            #print(i,end=" ")
            a+=funcount(length-1,rest-i,memo)[0]
            memo=funcount(length-1,rest-i,memo)[1]
            #print(memo)
        memo[length][rest]=a
        return a,memo
    

way=1
for f in factor:
    sum=0
    for k in range(1,f[1]+1):
        memo=[[-1 for r in range(f[1]+1)] for l in range(k+1)] 
        #print(memo)
        sum+=funcount(k,f[1],memo)[0]*C(n,k)
    way=(way*sum)%mod
    
print(way%mod)

Measured memory_bytes: 3188
package main

import (
	"fmt"
)

func calc(hp int) int{
	if hp <= 1 {
		return 1
	}
	return 2 * calc(hp/2) + 1
}

func main() {
	var (
		h int
	)
	fmt.Scan(&h)
	fmt.Println(calc(h))
}

Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define ll long long

long long modpow(long long,long long);
ll combi(ll,ll);

int main(){
    ll x,y,keyx,keyy,key,ans;scanf("%lld%lld",&x,&y);
    if((-x+2*y)%3!=0 || (2*x-y)%3!=0 || (-x+2*y)<0 || (2*x-y)<0){
        printf("0\n");
        return 0;
    }
    keyx=(-x+2*y)/3;keyy=(2*x-y)/3;
    if(keyx<=keyy){key=keyx;}
    else if(keyy<=keyx){key=keyy;}

    ans=combi(keyx+keyy,key);
    printf("%lld\n",ans);
    return 0;
}

long long combi(long long n,long long r){//繰り返し二乗法を用いてcombination計算
    long long ans,i,under=1,up=1,mod=1000000007;
    for(i=1;i<=r;i++){
        under=under*i;
        under=under%mod;
    }
    under=modpow(under,mod-2);//フェルマーの小定理
    
    for(i=1;i<=r;i++){
        up=up*(n-i+1);
        up=up%mod;
    }
    ans=up*(under%mod);
    return ans%mod;
}

long long modpow(long long a,long long n){//繰り返し二乗法
    long long mod=1000000007;
    if(n==1) return a%mod;
    if(n%2==1) return (a*modpow(a,n-1))%mod;
    long long t=modpow(a,n/2);
    return (t*t)%mod;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main(void){
	double r;
	double syu,men;
	scanf("%lf",&r);
	syu=r*2*M_PI;
	men=r*r*M_PI;
	printf("%.6lf %.6lf",men,syu);
	return 0;
}


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

typedef long long ll;
const ll INF = 1e18;
const int BIG = 1e9 + 555;

ll n, d;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin >> n >> d;
	int ans = n + 1;

	for(int bitmask = 0; bitmask < (1 << n); bitmask++){
		vector<bool> mrk(n);
		int cur = 0;
		for(int i = 0; i < n; i++){
			int l = max(0LL, i - d);
			int r = min(n - 1, i + d);
			if((bitmask & (1 << i)) == 0){
				continue;
			}
			cur++;
			for(int j = l; j <= r; j++){
				mrk[j] = true;
			}
		}

		bool flag = true;
		for(int i = 0; i < n; i++){
			if(!mrk[i]){
				flag = false;
				break;
			}
		}

		if(flag){
			ans = min(ans, cur);
		}
	}
	
	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <cstring>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <stack>
#include <set>
#include <queue>
#include <algorithm>
#include <deque>
#include <map>
#include <cmath>
using namespace std;

#define INF 1e18
#define int long long

signed main() {
    int n; cin >> n;
    vector<int> v(2 * n);
    for(int i = 0; i < 2 * n; i++) cin >> v[i];

    sort(v.rbegin(), v.rend());

    int ans = 0;
    for(int i = 2 * n - 1; i >= 0; i-=2) {
        ans += min(v[i], v[i - 1]);
    }

    cout << ans << endl;
    return 0;
}


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

int main() {
	// your code goes here
	int tc=1;
	//cin>>tc;
	while(tc--)
	{
		string n;
		cin>>n;
		int cnt=0;
		for(int i=0;i<n.size();i++)
		{
			cnt+=n[i]-48;
			cnt%=9;
		}
		if(cnt%9==0)
			cout<<"Yes";
		else
			cout<<"No";
		
	}
	return 0;
}

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

long kekka = 0,h,w,black,white;
long used[500][500];
char a[500][500];
void dfs(long x,long y,char cur){
  if(used[x][y] == 1){
    return;
  }
  used[x][y] = 1;
  if(a[x][y] == '.'){
    white++;
  }
  else{
    black++;
  }
  //cout << x << " " << y << " " << k << " " << kekka << endl;
  if(x+1 < h && cur != a[x+1][y]){
    dfs(x+1,y,a[x+1][y]);
  }
  if(x-1 >= 0 && cur != a[x-1][y]){
    dfs(x-1,y,a[x-1][y]);
  }
  if(y+1 < w && cur != a[x][y+1]){
    dfs(x,y+1,a[x][y+1]);
  }
  if(y-1 >= 0 && cur != a[x][y-1]){
    dfs(x,y-1,a[x][y-1]);
  }
  return;
}
    
int main(){
  cin >> h >> w;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      cin >> a[i][j];
    }
  }
  
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      used[i][j] = 0;
    }
  }
  
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      if(used[i][j] != 1){
        white = 0;
        black = 0;
        dfs(i,j,a[i][j]);
        kekka += black*white;
      }
    }
  }
  cout << kekka << endl;
}

Measured memory_bytes: 7040
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double a,b,mean,decimal;
  int integer,ans;
  cin >> a >> b;
  
  mean = (a+b)/2;
  
  integer = mean;
  decimal = mean - integer;
  
  //cout << "mean : " << mean << endl;
  //cout << "integer : "<<integer << endl;
  //cout <<"decimal : " <<decimal << endl;
  
  double hosei;
  hosei = decimal * 2;
  
  ans = integer + hosei;
  cout << ans << endl;

}

Measured memory_bytes: 256
import std.stdio;
import std.algorithm;
import std.string;
import std.range;
import std.array;
import std.conv;
import std.complex;
import std.math;


void main() {
	int n = to!int(readln().strip());
	int[][] a = new int[][](n,n);
	for(int i; i < n; ++i){
		auto s = readln().strip().split();
		for(int j; j < n; ++j) {
			a[i][j] = to!int(s[j]);
		}
	}
	int dp[][] = new int[][](n+1,n+1);
	dp[0][0] = a[0][0];
	for(int i = 1; i <= n; ++i){
		for(int j = 1; j <= n; ++j) {
			dp[i][j] = dp[i-1][j] + dp[i][j-1] + a[i-1][j-1] - dp[i-1][j-1];
		}
	}
	int ans = int.min;
	for(int i; i < n; ++i) {
		for(int j; j < n; ++j) {
			for(int k = i+1; k <= n; ++k) {
				for(int l = j+1; l <= n; ++l) {
					ans = max(ans, dp[k][l] - dp[k][j] - dp[i][l] + dp[i][j]);
				}
			}
		}
	}
	writeln(ans);
}

Measured memory_bytes: 1500
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    public static bool f = false, t = true;
    static void Main(string[] args)
    {
        string a = Console.ReadLine();
        string s = ""+a[2]+"";
        s += a[1];
        s += a[0];

        Console.WriteLine(a==s?"Yes":"No");
    }

    public static long gcd(long a, long b)
    {
        while (true)
        {
            if (a == 0) { return b; }
            if (b == 0) { return a; }
            if (a > b) { a -= b; }
            else { b -= a; }
        }
    }
    public static long lcm(long a, long b)
    {
        return a * b / gcd(a, b);
    }
    public static bool IsPrime(long n)
    {
        if (n < 2) return false;
        if (n == 2) return true;

        for (long i = 2; i < Math.Sqrt(n); i++)
        {
            if (n % i == 0) return false;
        }
        return true;
    }

}
public static class Read
{
    public static void outl(string n = "") { Console.WriteLine(n); return; }
    public static long Long()
    {
        return long.Parse(Console.ReadLine());
    }
    public static long[] longs()
    {
        return Console.ReadLine().Split().Select(long.Parse).ToArray();
    }
    public static int Int()
    {
        return int.Parse(Console.ReadLine());
    }
    public static int[] ints()
    {
        return Console.ReadLine().Split().Select(int.Parse).ToArray();
    }
    public static string Str() { return Console.ReadLine(); }
    public static string[] Strs() { return Console.ReadLine().Split(); }
}

Measured memory_bytes: 11092
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string s,t,u="UNRESTORABLE";
    cin>>s>>t;
    int a=s.length(),b=t.length();
    for(int i=a-b;i>=0;i--){
        bool f=true;
        for(int j=0;j<b;j++){
            if(s[i+j]!='?'&&s[i+j]!=t[j]){
                f=false;
            }
        }
        if(f){
            u=s.substr(0,i)+t+s.substr(i+b);
            for(int j=0;j<a;j++){
                if(u[j]=='?'){
                    u[j]='a';
                }
            }
            i=0;
        }
    }
    cout<<u<<endl;
}


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

int main(){
    int a[3];
    int count=0;
    int m=-1;
    int ans=0;
    cin>>a[0]>>a[1]>>a[2];
    for(int i=0;i<3;i++){
        if(a[i]%2){count++;}//奇数カウント
    }
    if(count==1){
        ans++;
        for(int i=0;i<3;i++){
            if(a[i]%2==0){
                a[i]+=1;
            }
        }
    }else if(count==2){
        ans++;
        for(int i=0;i<3;i++){
            if(a[i]%2==1){
                a[i]+=1;
            }
        }
    }
    //最大値
    for(int i=0;i<3;i++){
        if(m<a[i]){m=a[i];}
    }
    for(int i=0;i<3;i++){
        ans+=(m-a[i])/2;
    }

    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)

from collections import deque,defaultdict,Counter
def main():
    H,W,K = map(int,input().split())
    sy,sx,gy,gx = map(int,input().split())
    sy -= 1; sx -= 1; gy -= 1;gx -= 1
    pond = [list(input()) for _ in range(H)]
    
    q = deque([(sy,sx)])
    dist = [[-1]*W for _ in range(H)]
    dist[sy][sx] = 0
    while q:
        ny,nx = q.popleft()
        for dy,dx in zip(Dy,Dx):
            y,x = ny,nx
            for _ in range(K):
                y += dy
                x += dx
                if y < 0 or y >= H:
                    break
                if x < 0 or x >= W:
                    break
                if pond[y][x] == '@':
                    break
                if dist[y][x] >= 0 and dist[y][x] <= dist[ny][nx]:
                    break
                if dist[y][x] < 0:
                    dist[y][x] = dist[ny][nx] + 1
                    q.append((y,x))
                if (y,x) == (gy,gx):
                    break
    print(dist[gy][gx] if dist[gy][gx] >= 0 else -1) 
if __name__ == '__main__':
    main()

Measured memory_bytes: 140524
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin >> n >> k;
	int a[n];
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	int res[n];
	res[0]=0;
	res[1]=abs(a[1]-a[0]);
	for(int i=2;i<n;i++){
		res[i]=INT_MAX;
		for(int j=1;j<=k && i>=j;j++){
			res[i] = min(res[i],res[i-j]+abs(a[i]-a[i-j]));
		}
	}
	/*for(int i=0;i<n;i++){
		cout << res[i] << " ";
	}*/
	cout << res[n-1];
	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i,k,n) for(int i = k; i < n; i++)
#define mmax(start, end) *max_element(start, end)
#define mmin(start, end) *min_element(start, end)
#define argmax max_element
#define argmin min_element
#define ALL(x) (x).begin(), (x).end()

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

int dx[4] = {1, -1, 0, 0};
int dy[4] = {0, 0, 1, -1};
int dx8[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

template<class T = ll> T in() {
    T _in;
    cin >> _in;
    return _in;
}

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

    int N;
    cin >> N;
    int a[100001];
    bool closed[100001] = {false};
    a[0] = N;
    REP(i, 1, N+1) {
        cin >> a[i];
    }

    int cur = 1;
    int ans = 0;
    while(true) {
        if(closed[cur])
            break;

        closed[cur] = true;
        if(cur == 2)
            break;

        cur = a[cur];
        ans++;
    }

    if(closed[2])
        cout << ans << endl;
    else
        cout << -1 << endl;

    return 0;
}


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

typedef pair<int, int> Point;

const int maxn = 2000 + 7;

Point a[maxn];
int anc[maxn];

int find(int x) {
	if (x == anc[x]) return x;
	return anc[x] = find(anc[x]);
}


multiset<int> L[maxn];
void merge(int u, int v) {
	u = find(u), v = find(v);
	if (u == v) return ;
	anc[u] = v;
	for (auto x : L[u]) L[v].insert(x);
	// L[v].insert(L[v].end(), L[u].begin(), L[u].end());
}

multiset<int> T;
bool opened[maxn];

int main() {
	int n, k, q;
	scanf("%d%d%d", &n, &k, &q);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &a[i].first);
		a[i].second = i;
	}
	sort(a + 1, a + n + 1);

	for (int i = 1; i <= n; i++) anc[i] = i, L[ a[i].second ].insert(a[i].first);
	for (int i = 1; i <= n; i++) opened[i] = false;

	int ans = a[n].first - a[1].first;
	for (int i = n; i >= 1; i--) {
		if (a[i].second != 1 && opened[a[i].second - 1]) merge(a[i].second - 1, a[i].second);
		if (a[i].second != n && opened[a[i].second + 1]) merge(a[i].second + 1, a[i].second);
		opened[ a[i].second ] = true;

		T.clear();
		for (int j = 1; j <= n; j++) 
			if (anc[j] == j && opened[j]) {
				auto p = L[j].begin();
				for (unsigned int _ = 0; _ + k <= L[j].size(); _++, p++) {
					T.insert(*p);
				}
			}
	
		// for (auto x : T) cout << x << ' ';
		// 	cout << endl;
		if (T.size() >= (unsigned int)q) {
			auto p = T.begin();
			// for (int j : T) cout << j << endl;
			for (int j = 1; j < q; j++) p++;
			ans = min(ans, *p - a[i].first); 
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 94208
#include<stdio.h>
int main(){
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);
    int flg=0;
    if(a<b){
        if(b<c){
            flg++;
        }
    }
    if(flg==0){
        printf("No");
    }else{
        printf("Yes");
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
int main(){
    int x,n;
    cin>>x>>n;
    vector<int> p(n);
    for(int i=0;i<n;i++)cin>>p[i];
    int ans=0,i=x,j=x;
    while(1){
        bool flagJ=true,flagI=true;
        for(auto P:p){
            if(j==P)flagJ=false;
            if(i==P)flagI=false;
        }
        if(flagJ){
            ans=j;
            break;
        }
        else if(flagI){
            ans=i;
            break;
        }
        i++,j--;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3584
// MOHIT KUMAR
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pin;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

#define ff(i, a, b) for ( ll i=a; i<(b); i++)
#define ffd(i, a, b) for ( ll i=a; i<= b; i++)
#define fr(i, a, b) for ( ll i = (b)-1; i >= a; i--)
#define ffr(i, a, b) for ( ll i = b ; i >= a; i--)
#define vl vector < ll >
#define vp vector < pl >
#define endl "\n"
#define sz(x) (ll)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const ld pi = acos(-1) ;
const ll maxn = 105 ;
const int mod = 1e9 + 7 ;
const ll INF = 1e18 ;
const int MX = 2000000001 ; // check the limits, dummy

int main() {
  ios_base::sync_with_stdio(0) , cin.tie(0);
  ll t, q, n, a, b, c, d, k, l, m, r,  x = 0, y = 0, z = 0 , sum = 0, ans = 0, temp = 0, res = 0 ;
  cin >> n  ;
  ll dp[n + 1] = {0} ;
  dp[0] = 1 ;
  ffd(i, 3, n) {
    ffr(j, 0, i - 3) {
      dp[i] += (dp[j] % mod) ;
      dp[i] %= mod ;
    }
  }
  cout << dp[n] ;
}

Measured memory_bytes: 3640
use std::cmp;

#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;$n:expr) => {
        (0..$n).map(|_| scan!()).collect::<Vec<_>>()
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (a, b, c) = scan!(i64, i64, i64);
    println!("{}", cmp::min(a + b, cmp::min(b + c, a + c)));
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
typedef long long LL;

int N;
vector<int>G[111];
int d[101][101];

int deep[1001];
bool used[201];

void dfs(int r,int num,int x,int y,int z){
	int g=G[r].size();
	//cout<<"g"<<g<<"root"<<r<<"num"<<num<<endl;
	if(num!=0)g--;
	if((num==0)&&(z==0))g--;
	//cout<<r<<" roo" <<g<<endl;
	deep[num]=max(deep[num],g);
	used[r]=true;
	REP(i,G[r].size()){
		if((r==x)&&(G[r][i]==y))continue;
		if((r==y)&&(G[r][i]==x))continue;
		if(used[G[r][i]]==false){
			dfs(G[r][i],num+1,x,y,z);
		}
	}
}

LL calc(int r,int num,int x,int y,int z){
	REP(i,200){
		deep[i]=0;
		used[i]=false;
	}
	if(x!=-1){
		dfs(x,num,x,y,z);
	}
	if(y!=-1){
		dfs(y,num,x,y,z);
	}
	LL cc=1;
	REP(i,200){
		if(deep[i]!=0){
			//cout<<"deep"<<i<<" "<<deep[i]<<endl;
			cc*=deep[i];
		}
	}
	if((x!=-1)&&(y!=-1)){
		return 2*cc;
	}else{
		return cc;
	}
}

int main(){
	cin>>N;
	REP(i,N){
		REP(j,N){
			d[i][j]=100000;
		}
	}
	REP(i,N)d[i][i]=0;
	
	REP(i,N-1){
		int a,b;
		cin>>a>>b;
		G[a-1].push_back(b-1);
		G[b-1].push_back(a-1);
		d[a-1][b-1]=1;
		d[b-1][a-1]=1;
	}
	
	REP(k,N){
		REP(i,N){
			REP(j,N){
				d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
			}
		}
	}
	
	int dis=0;
	REP(i,N){
		REP(j,N){
			if(d[i][j]>=1000)continue;
			dis=max(dis,d[i][j]);
		}
	}
	int color=dis/2+1;
	vector<int>t;
	REP(i,N){
		int a=0;
		REP(j,N){
			a=max(a,d[i][j]);
		}
		//cout<<i<<" mi "<<a<<endl;
		if(((dis+1)/2)==a){
			t.push_back(i);
		}
	}
	
	/*REP(i,t.size()){
		G[N].push_back(t[i]);
		G[t[i]].push_back(N);
	}
	N++;*/
	
	

	
	LL aa=0;
	if(t.size()==2){
		aa=calc(N-1,0,t[0],t[1],0);
	}else{
		aa=calc(N-1,0,t[0],-1,1);
		REP(i,G[t[0]].size()){
			int nx=G[t[0]][i];
			aa=min(aa,calc(N-1,0,t[0],nx,0));
		}
		
	}
	
	cout<<color<<" "<<aa<<endl;
	//cout<<dis<<" dis"<<endl;
	return(0);
}

Measured memory_bytes: 256
n, y = map(int, input().split())
ans = -1, -1, -1
for i in range(n + 1):
    for j in range(n - i + 1):
        k = n - i - j
        if y == (i * 10000) + (j * 5000) + (k * 1000):
            ans = i, j, k
            print(*ans)
            exit(0)
print(*ans)

Measured memory_bytes: 40684
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define PRINT(x) cout<<(x)<<endl
#define INF 1000000000000 // 10^12
#define MOD 1000000007 // 10^9+7
#define PB push_back
#define MP make_pair

const int MAX_N = 100000;

int N;
int A[MAX_N];

int last_num[MAX_N + 1];
int num_color = 0;

int my_binary_search(int key) {
    int ng = -1;
    int ok = num_color;
    while (abs(ng - ok) > 1) {
        int mid = (ng + ok) / 2;
        if (last_num[mid] < key) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    cin >> N;
    REP(i, N) cin >> A[i];

    last_num[0] = MOD;

    REP(i, N) {
        if (A[i] <= last_num[num_color]) last_num[++num_color] = A[i];
        else {
            int j = my_binary_search(A[i]);
            last_num[j] = A[i];
        }
    }

    PRINT(num_color);
    return 0;
}

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

int main() {
  int a,b,c,d,e;
  cin >> a >> b >> c;
  d=max(a,b)-min(a,b);
  e=max(a,c)-min(a,c);
  if(d<e){
    cout << "A" << endl;
  }
  else{ 
    cout << "B" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,h1,h2,h3,x,y,z,x1,y1,z1;
	cin>>n;
	cin>>h1>>h2>>h3;
	x1=h1,y1=h2,z1=h3;
	for(int i=0;i<n-1;i++){
		cin>>x>>y>>z;
		h1=x+max(y1,z1);
		h2=y+max(x1,z1);
		h3=z+max(x1,y1);
		x1=h1,y1=h2,z1=h3;
	}
	cout<<max(h1,max(h2,h3))<<endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <string>
#include <deque>
#include <tuple>
#include <map> 
#include <set>
#include <stack>
#include <functional>
#define ll long long
using namespace std;

int main() {
	int N, X, T;

	cin >> N >> X >> T;

	int times = ceil((double)N / X);

	cout << T * times << endl;
}

Measured memory_bytes: 3572
def main():
    data = list(input())
    # dp = [[0 for i in range(4)] for i in range(len(data) + 1)]
    # dp[len(data)][3] += 1

    dp = [0, 0, 0, 1]
    mod = 10 ** 9 + 7

    dic = {0:'A', 1:'B', 2:'C'}
    for i in range(len(data))[::-1]:
        element = data[i]
        for j in range(4):
            if j == 3:
                if element == '?':
                    dp[j] *= 3
            else:
                if dic[j] == element:
                    dp[j] += dp[j + 1]

                elif element == '?':
                    dp[j] = dp[j] * 3 + dp[j + 1]

            dp[j] %= mod



    print(dp[0] % mod)





if __name__ == '__main__':
    main()


Measured memory_bytes: 49648