akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define repA(a,i,n) for(int i=a;i<n;i++)
#define trav(a,x)for(auto &a: x)
#define fll(a) memset(a,0,sizeof(a));
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fst first
#define sec second
#define itr(it,x) for(auto it=x.begin();it!=x.end();it++)
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
typedef vector<int>vi;
typedef map<int,int>ma;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
void fopen()
{
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	freopen("error.txt","w",stderr);	
}
int main(){
	fastio;
	//fopen();
	string s;
	cin>>s;
	ll c1=0,c2=0,k=0;
	vector<ll>v;
	int f=0,f2=0;
	ll y=0;
	rep(i,s.size())
	{
		if(s[i]=='<' && f==0)
			{c1+=1;f2=1;}
		else if(s[i]=='>' && f2==1){
			c2+=1;
			f=1;
		}
		else if(s[i]=='<' && f==1)
		{
			v.pb(max(c1,c2));
			y+=((min(c1,c2)-1)*min(c1,c2))/2;
			f=0;
			c1=1;
			c2=0;
		}
		else if(s[i]=='>')
		{
			//cout<<i;
			k++;
		}
	}
	if(c1!=0 && c2!=0)
		{v.pb(max(c1,c2));}
	else if(c1!=0)
	{
		v.pb(c1);
	}
	//cout<<c1<<" ";
	v.pb(k);
	ll p=0;
	trav(a,v)
	{
		//cout<<a<<" ";
		p+=(a*(a+1))/2;
	}
	cout<<p+y;
}


Measured memory_bytes: 2332
#define MYDEBUG
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <algorithm>
#include <queue>
#include <set>
#include <cstdio>
#include <unordered_map>

#ifdef MYDEBUG
#define debug(x) cout<<#x<<": "<<x<<endl
#else
#define debug(x)
#endif
#define ll long long
#define ull unsigned long long
#define eps 1e-14
#define all(x) x.begin(), x.end()
using namespace std;

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
	out << "[";
	size_t last = v.size() - 1;
	for (size_t i = 0; i < v.size(); ++i) {
		out << v[i];
		if (i != last)
			out << ",";
	}
	out << "]";
	return out;
}

void solve() {
	int x;
	cin >> x;
	if (x < 1200)
		cout << "ABC" << endl;
	else
		cout << "ARC" << endl;
}
int main() {
	solve();
	return 0;
}


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

#define pb push_back
#define fi first
#define se second
#define eb emplace_back

using namespace std;

typedef pair<int, int> ii;
typedef long long ll;
const int N = 2007, inf = 0x3f3f3f3f, M = 1e9 + 7;


int memo[N];

int solve(int s) {
	if(s == 0) return 1;
	if(s < 3) return 0;

	int & st = memo[s];

	if(st == -1) {
		st = 0;
		for(int i = 3; i <= s; ++i) st = (st + solve(s - i))%M;
	}
	return st;
}

int main() {
	ios::sync_with_stdio(0); cin.tie(0);
	memset(memo, -1, sizeof memo);
	int s; cin >> s;
	cout << solve(s) << endl;
}

Measured memory_bytes: 3656
n=int(input())
a=list(map(int,input().split()))
lst1=[0]*(n+1)
lst2=[0]*(n+1)
for i in a:
  lst1[i]+=1
for i in range(n+1):
  if lst1[i]>0:
    lst2[i]=lst1[i]-1
lst3=list(map(lambda x:x*(x-1)//2,lst1))
lst4=list(map(lambda x:x*(x-1)//2,lst2))
ans=sum(lst3)
for i in a:
  print(ans-(lst3[i]-lst4[i]))

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

const ll MAX_V = 60;
vector<pair<ll, ll> > G[MAX_V];
// a -> bにいくときに通る辺のbits
ll E[MAX_V][MAX_V];
// 制約iで通る辺のbits
ll EM[30];

void dfs(ll v, ll parent, ll root, ll mask) {
  E[root][v] = mask;
  for(auto kv : G[v]) {
    if(kv.first == parent)continue;
    dfs(kv.first, v, root, mask | kv.second);
  }
}

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);

  ll n;cin>>n;
  for(ll i=0;i<n-1;i++){
    ll a,b;cin>>a>>b;a--,b--;
    G[a].push_back({b,1ll<<i});G[b].push_back({a,1ll<<i});
  }
  for(ll i=0;i<n;i++) dfs(i, -1, i, 0);
  ll m;cin>>m;
  for(ll i=0;i<m;i++){
    ll u,v;cin>>u>>v;u--,v--;
    EM[i] = E[u][v];
  }
  // 包除原理
  ll ans=0;
  for(ll i=0;i<(1ll<<m);i++){
    ll whites = 0;
    for(ll j=0;j<m;j++){
      if(i & (1ll << j)) whites |= EM[j];
    }
    ll cnt = pow(2, n - 1 - __builtin_popcountll(whites));
    if (__builtin_popcountll(i) % 2 == 0) {
      ans += cnt;
    } else {
      ans -= cnt;
    }
    // cout<<cnt<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


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

int main(){
	int N;
	cin >> N;
	
	bool flag=false;
	
	for(int i=1; i<=9; i++){
		
		if(N%i==0 && N/i<=9){
			
			flag=1;		
		}
		
	}
	if (flag){
		
		cout << "Yes" << endl;
		
	}
	else{
		
		cout << "No" << endl;
	}
}
	

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define pii              pair <int,int>
#define debug(x) cerr << '>' << #x << ':' << x << endl;
typedef long long ll;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const int MOD=1e9+7;
const int N=2*1e5+30;
const int inf = 1e17+995;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int32_t main() {
    boostIO();
int n;
cin>>n;
vi arr(n,inf);
int ans=0;
    for (int i = 0; i < n-1; ++i) {
        cin>>arr[i];
    }
    for (int i = 0; i < n-1 ; ++i) {
int tmp=arr[(i>0?i-1:0)];
ans+=min(tmp,arr[i]);
    }
    ans+=arr[n-2];
    cout<<ans<<endl;
}

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

using ll = long long;
using ld = long double;
using vi = vector<int>;
using vll = vector<ll>;
using P = pair<int, int>;

const int INF = 1e9;
const ll INFLL = 1e18;
const int MOD = 1e9 + 7;
const int NIL = -1;
const ld PI = acosl(-1);

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//cout << fixed << setprecision(6);
	int n; cin >> n;
	
	for(int i = 0; i <= 100/4; i++){
		for(int j = 0; j < 100/7; j++){
			int dol = 4*i + 7*j;
			if(dol == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var y, m, d int
	fmt.Scanf("%d/%d/%d\n", &y, &m, &d)

	if y < 2019 {
		fmt.Println("Heisei")
		return
	}
	if 2019 < y {
		fmt.Println("TBD")
		return
	}
	if m <= 4 {
		fmt.Println("Heisei")
		return
	}
	fmt.Println("TBD")
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define int long long
#define double long double
using namespace std;
const int MOD = 1000000007;
const int INF = 1e12;
using Graph = vector<vector<int>>;

signed main(){
  string S, T;
  cin >> S >> T;
  vector<vector<int>> dp(3100, vector<int>(3100, 0));

  int s = (int)S.size();
  int t = (int)T.size();

  //LCSの長さを求める
  //dp[i][j]＝Sのi-1文字目までとTのi-1文字目までのLCSの長さ
  for( int i = 1; i <= s; i++ ){
    for( int j = 1; j <= t; j++ ){
      dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
      if( S[i-1] == T[j-1] ){
        dp[i][j] = max(dp[i][j], dp[i-1][j-1]+1);
      }
    }
  }

  //文字列を後ろから復元する
  string ans = "";
  while( s > 0 && t > 0 ){
    if( dp[s][t] == dp[s-1][t] ) s--;
    else if( dp[s][t] == dp[s][t-1] ) t--;
    else{
      s--; t--;
      ans+= S[s];
    }
  }
  reverse(ans.begin(), ans.end());
  cout << ans << endl;

}

Measured memory_bytes: 78500
#include <bits/stdc++.h>
using namespace std;
#define w(x) int x;cin>>x;while(x--)
#define ll long long
#define pb push_back
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL)
#define vi vector<int>
#define ff first
#define ss second
#define fr(a,b) for(int i=a;i<=b;i++)
#define inf 1e18
#define mod 1000000007
vector<int>v[200005];
bool vis[200005];
void dfs(int src,int &c)
{
    c++;
    vis[src]=true;
    for(auto nvr:v[src])
    {
        if(vis[nvr]==false)
        dfs(nvr,c);
    }
}
int main()
{
    ll n,m;
    cin>>n>>m;
    while(m--)
    {
        int x,y;
        cin>>x>>y;
        v[x].push_back(y);
        v[y].push_back(x);
    }
    int ans=INT_MIN;
    int c=0;
    memset(vis,false,sizeof(vis));
    for(int i=1;i<=n;i++)
    {
        if(vis[i]==false)
        {
            c=0;
            dfs(i,c);
            ans=max(ans,c);
        }
    }
    cout<<ans<<"\n";
    return 0;
    
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;

// vals for the tree
ll vals[MAXN];

// 0-indexed Fenwick tree (for sum)
// Use: fill n, call init(MyArray)
// Call get_val(l, r) and upd_val(pos, add)
struct fenwick_tree{
	// Number of elements
	int n;
	
	// Items of the tree
	ll ft[MAXN];
	
	// Initialization
	void init(ll *vals){
		REP(i, 0, n){
			upd_val(i, vals[i]);
		}
	}
	
	// Get query [l ... r]
	ll get_val(int l, int r){
		return get_val(r) - get_val(l - 1);
	}
	
	// Get query [0 ... r]
	ll get_val(int r){
		ll res = 0;
		for(; r >= 0; r = (r & (r + 1)) - 1){
			res += ft[r];
		}
		return res;
	}
	
	// Update query
	void upd_val(int pos, ll add){
		for(; pos < n; pos = (pos | (pos + 1))){
			ft[pos] += add;
		}
	}
} ft;

int v[MAXN];
int pos[MAXN];
pair<ll, int> pp[MAXN];


void solve(){
	int n;
	ll k;
	scanf("%d%lld", &n, &k);
	REPN(i, 1, n) {
		scanf("%d", &v[i]);
		v[i] -= k;
		pp[i] = mp(pp[i - 1]._1 + v[i], i);
	}
	sort(pp + 1, pp + n + 1);
	REPN(i, 1, n) {
		pos[pp[i]._2] = i;
	}
	
	ft.n = n + 1;
	
	ll ans = 0ll, offset = 0;
	REPN(i, 1, n) {
		int ind = lower_bound(pp + 1, pp + n + 1, mp(offset, -1)) - pp;
		int cnt = n + 1 - ind;
		int sub = ft.get_val(n) - ft.get_val(ind - 1);
		ans += cnt - sub;
		ft.upd_val(pos[i], 1);
		offset += v[i];
	}
	printf("%lld\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define all(a) (a).begin(),(a).end()

template<typename T1, typename T2> inline void chkmin(T1 & x, const T2 & y) {if (y < x) x = y;}
template<typename T1, typename T2> inline void chkmax(T1 & x, const T2 & y) {if (x < y) x = y;}

int n;
vector<int> a;
deque<int> b;

void read() {
    cin >> n;
    a.resize(n);
    for (auto &i : a) {
        cin >> i;
    }
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        b.push_back(x);
    }
}

mt19937 rnd(time(0));
vector<int> order;

bool check() {
    for (auto i : order) {
        if (a[i] == b[i]) {
            return false;
        }
    }
    return true;
}

void nxt() {
    b.push_front(b.back());
    b.pop_back();
}

bool check(int la, int ra, int lb, int rb) {
    return max(la, lb) <= min(ra, rb);
}

vector<int> pref;

void ban(int l, int r) {
    //cout << "l = " << l << " r = " << r << endl;
    pref[l]++;
    pref[r + 1]--;
}

void run() {
    order.resize(n);
    iota(all(order), 0);
    shuffle(all(order), rnd);
    /*
    do {
        if (check()) {
            cout << "Yes\n";
            for (auto i : b) {
                cout << i << " ";
            }
            cout << "\n";
            exit(0);
        }
    } while (next_permutation(all(b)));*/
    
    pref.assign(5 * n + 10, 0);

    vector<int> l(n + 1, n), r(n + 1, -1);
    for (int i = 0; i < n; i++) {
        chkmin(l[a[i]], i);
        chkmax(r[a[i]], i);
    }
    for (int L = 0; L < n; L++) {
        if (l[b[L]] == n) continue;
        int R = L;
        while (R < n && b[R] == b[L]) R++;
        R--;
        if (check(l[b[L]], r[b[L]], L, R)) {
            ban(0, r[b[L]] - L);
        } else {
            if (R < l[b[L]]) {
                ban(l[b[L]] - R, r[b[L]] - L);
            } else {
                l[b[L]] += n;
                r[b[L]] += n;
                ban(l[b[L]] - R, r[b[L]] - L);
            }
        }
        L = R;
    }

    for (int i = 1; i < 5 * n; i++) {
        pref[i] += pref[i - 1];
    }
    for (int i = 0; i < 5 * n + 10; i++) {
        pref[i % n] += pref[i];
    }
    /*cout << "pref = " << endl;
    for (int i = 0; i < n; i++) {
        cout << pref[i] << " ";
    }
    cout << endl;*/
    for (int i = 0; i < n; i++) {
        /*cout << "i = " << i << endl;
        cout << "b = " << endl;
        for (auto x : b) {
            cout << x << " ";
        }
        cout << endl;*/
        if (pref[i] == 0 && check()) {
            cout << "Yes\n";
            for (auto i : b) {
                cout << i << " ";
            }
            cout << "\n";
            exit(0);
        }
        nxt();
    }
}

void write() {
    cout << "No\n";
}

signed main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0), cout.precision(20), cout.setf(ios::fixed);
    read();
    run();
    write();
    return 0;
}


Measured memory_bytes: 11112
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


ll memo[100005];

int main(){
  ll N, X, M;
  cin >> N >> X >> M;

  if(N == 1){
    cout << X << endl;
    return 0;
  }

  rep(i,100005) memo[i] = -1;

  vector<ll> v;
  v.push_back(X);
  ll now = X;
  memo[now] = 0;
  ll ret = X;
  int idx = 2;
  bool flg = false;
  for(; idx<=N; idx++){
    now = (now*now)%M;
    if(memo[now] == -1){
      ret += now;
      memo[now] = idx-1;
      v.push_back(now);
    }else{
      flg = true;
      break;
    }
  }

  if(!flg){
    cout << ret << endl;
    return 0;
  }

  ll bgn = memo[now];
  ll end = v.size();
  ll m = end - bgn;

  vector<ll> w;
  ll s = 0;
  REP(i,bgn,end){
    s += v[i];
    w.push_back(v[i]);
  }

  ll cnta = (N+1-idx)/m;
  ll cntb = (N+1-idx)%m;
  ret += cnta * s;
  rep(i,cntb){
    ret += w[i];
  }
  
  cout << ret << endl;
  
  
  return 0;
}



Measured memory_bytes: 5028
#include <iostream>
#include <vector>
#define max(x, y) ((x) > (y) ? (x) : (y))
using namespace std;
const int N = 1e5 + 5;
vector<int> adjList[N];
int vis[N];
int dp[N];
void dfs(int src) {
	vis[src] = 1;
	for (int i : adjList[src]) {
		if (!vis[i]) dfs(i);
		dp[src] = max(dp[src], 1 + dp[i]);
	}
}
int main() {
	for (int i = 0; i < N; i++) {
		vis[i] = 0;
		dp[i] = 0;
	}
	int n,m;
	cin >> n >> m;
	for (int i = 1; i <= m; i++) {
		int a, b;
		cin >> a >> b;
		adjList[a].push_back(b);
	}
	for (int i = 1; i <= n; i++) {
		if (!vis[i]) {
			dfs(i);
		}
	}
	int path = 0;
	for (int i = 1; i <= n; i++) {
		path = max(path, dp[i]);
	}
	cout << path;
	return 0;
}


Measured memory_bytes: 8576
def resolve():
    N, M = map(int, input().split())
    H = list(map(int, input().split()))

    A = [[] for _ in range(N)]
    for i in range(M):
        pp, ss = map(int, input().split())
        ss -= 1
        pp -= 1
        A[pp].append(H[ss])
        A[ss].append(H[pp])

    ans = 0
    for j in range(N):
        now = H[j]
        if not A[j] or now > max(A[j]):
            ans += 1

    print(ans)


resolve()

Measured memory_bytes: 22988
//32
#include<iostream>
#include<vector>
#include<utility>

using namespace std;

typedef pair<int,int> pii;

#define S(X) ((X)*(X))

int main(){
  for(int a,b,r;cin>>a>>b>>r,a|b|r;){
    int x[100000],y[100000];
    for(int i=0;i<a;i++){
      cin>>x[i]>>y[i];
    }
    vector<pii> v[250][250];
    for(int i=0;i<b;i++){
      int xb,yb;
      cin>>xb>>yb;
      v[yb/40][xb/40].push_back(pii(yb,xb));
    }
    int s=0;
    for(int i=0;i<a;i++){
      int yy=y[i]/40,xx=x[i]/40;
      for(int j=-1;j<=1;j++){
	for(int k=-1;k<=1;k++){
	  int yt=yy+j,xt=xx+k;
	  if(0<=yt&&yt<250&&0<=xt&&xt<250){
	    for(int l=0;l<v[yt][xt].size();l++){
	      s+=S(y[i]-v[yt][xt][l].first)+S(x[i]-v[yt][xt][l].second)<=S(4*r);
	    }
	  }
	}
      }
    }
    cout<<s<<endl;
  }
  return 0;
}

Measured memory_bytes: 4464
N = int(input())
n = len(str(N))
NS = str(N)
ans0 = 0
for i in NS:
    ans0 += int(i)
ans1 = int(NS[0])-1 + 9 * (n-1)
ans2 = 9 * (n-1)

print(max(ans0, ans1, ans2))


Measured memory_bytes: 9120
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
#define ep emplace_back
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(v) v.begin(), v.end()
#define revall(v) v.rbegin(), v.rend()
constexpr int mod=1000000007;
constexpr int mod1=998244353;
vector<int> dx={0,1,0,-1},dy={-1,0,1,0};
bool inside(int y,int x,int h,int w){ if(y<h && y>=0 && x<w && x>=0) return true; return false; }
template<class T> inline bool chmin(T& a, T b){ if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b){ if(a < b){ a = b; return true; } return false; }





int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s,t;cin >> s >> t;
	string ans = "";
	int n = s.size(), m = t.size();
	rep(i,n - m + 1){
		bool flg = true;
		rep(j,m){
			if(s.at(i + j) != '?' && s.at(i + j) != t.at(j)) flg = false;
		}
		if(flg){
			string u = s;
			rep(j,m) u.at(i + j) = t.at(j);
			rep(j,n) if(u.at(j) == '?') u.at(j) = 'a';
			if(ans == "") ans = u;
			else ans = min(ans, u);
		}
	}
	if(ans == "") cout << "UNRESTORABLE" << endl;
	else cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
 int n ;
 cin >> n;
 int arr[n+2];
 for(int i=1;i<=n;i++)
    cin >> arr[i];
 int mini = 100000000;
 for(int i=-100;i<=100;i++){
   int cost = 0 ;
   for(int j=1;j<=n;j++){
      int y = i;
      cost+= ((arr[j]-y)*(arr[j]-y));
   }
   mini=min(cost ,mini);
 }
 cout << mini <<endl;
 return 0;
}


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

int main() {
  vector<vector<int>> c(3, vector<int>(3));
  
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> c.at(i).at(j);
    }
  }
  
  vector<vector<int>> d(3, vector<int>(2));
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 2; j++) {
      d.at(i).at(j) = c.at(i).at(j+1) - c.at(i).at(j);
    }
  }
  
  /*
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 2; j++) {
      cout <<d.at(i).at(j);
    }
    cout << endl;
  }
  */
  
  bool flag0 = d.at(0).at(0)==d.at(1).at(0) && d.at(1).at(0)==d.at(2).at(0);
  bool flag1 = d.at(0).at(1)==d.at(1).at(1) && d.at(1).at(1)==d.at(2).at(1);
  
  //cout << flag0 << ' ' << flag1 << endl;
  
  if(flag0 && flag1) 
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
import numpy as np
def main():
    N = int(input())
    A = map(int, input().split())
    l = []
    for i, v in enumerate(A):
        l.append(v-i-1)
    x = int(np.median(l))
    y = x + 1
    tx = 0
    ty = 0
    for i in l:
        tx += abs(i-x)
        ty += abs(i-y)
    print(min(ty, tx))
main()


Measured memory_bytes: 34200
#include<bits/stdc++.h>
 
using namespace std;
typedef long long int ll;
bool comp(ll a, ll b)
{
   return a>b;
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
    cin>>n;
    set<ll> s;
    for(ll i=0; i<n;i++)
    {
        ll x;
        cin>>x;
        s.insert(x);
    }
   // cout<<s.size();
    if(s.size()!=n)
        cout<<"NO";
    else
        cout<<"YES";
    return 0;
}

Measured memory_bytes: 9600
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];
    
    vector<int> ans(N, 0);
    REP(i, N) ++ans[A[i] - 1];
    rep(i, N) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 4756
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define repr4(i,s,n) for(ll i = (n);i>=(s);i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
using Graphw = vector<vector<pair<ll,ll>>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/
const int mod = 1000000007;


int main() {
int N,M;
cin>>N>>M;
ll K,A[N+1],B[M+1],now=0;
cin>>K;
rep3(i,N){
    cin>>A[i];
}
rep3(j,M){
    cin>>B[j];
}
A[0]=0;
B[0]=0;
rep3(i,N){
    A[i]+=A[i-1];
}
rep3(i,M){
    B[i]+=B[i-1];
}
int pa=0,pb=0,max_count=0;
while((pa<N)&&(A[pa+1]<=K)){
    
    pa++;
    
}
max_count=pa;
int pac=pa;
repr(pa,pac+1){
    now=A[pa];
    
    while((pb<M)&&(A[pa]+B[pb+1]<=K)){
        pb++;
    }
    max_count=max(max_count,(int)pa+pb);
}
cout<<max_count<<endl;
return 0;
}

Measured memory_bytes: 6672
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  vector<int> cards(N);
  for (int n = 0; n < N; n++) {
    cin >> cards.at(n);
  }
  
  sort(cards.begin(), cards.end());
  reverse(cards.begin(), cards.end());
  
  int alice = 0;
  int bob = 0;
  for (int n = 0; n < N; n++) {
    if (n % 2 == 0) {
      alice += cards.at(n);
    } else {
      bob += cards.at(n); 
    }
  }
  
  cout << alice - bob << endl;
}


Measured memory_bytes: 3592
#pragma GCC optimize("O3")
//#pragma GCC target("avx")
#include <bits/stdc++.h>
using namespace std;
#define re return
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all(x)),x.resize(unique(all(x))-x.begin())
#define fi first
#define se second
#define ss second.second
#define sf second.first
#define ff first.first
#define fs first.second
#define sqrt(x) sqrt(abs(x))
#define mp make_pair
#define PI 3.14159265358979323846
#define E 2.71828182845904523536
#define er erase
#define in insert
#define fo(i,n) for((i)=0;(i)<(n);(i)++)
#define ro(i,n) for((i)=n-1;(i)>=0;(i)--)
#define fr(i,j,n) for((i)=(j);(i)<(n);(i)++)
#define rf(i,j,n) for((i)=((n)-1);(i)>=(j);(i)--)
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int uint;
    const int N=(int)1e6+100;
    const int M=(int)2e6+100;
    const int inf=(int)1e9+100;
#define filename ""
    int ans[N];
int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //freopen(filename".in","r",stdin);
    //freopen(filename".out","w",stdout);
    //freopen("ans.txt","w",stdout);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    srand(time(0));
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n,a,i;
    cin>>n;
    fo(i,n-1)
    {
        cin>>a;
        a--;
        ans[a]++;
    }
    fo(i,n)
    {
        cout<<ans[i]<<'\n';
    }
}


Measured memory_bytes: 4428
#include <iostream>
#include <stdlib.h>
#include <vector>
#include <string>
using namespace std;

void
print_vec (vector<int> exp)
{
	for (auto x:exp)
	{
		if (x == -5)
			cout << "+";
		else if (x == -6)
			cout << "*";
		else if (x)
			cout << x;
		else
			cout << "error";
	}
	cout <<endl;
}

vector<int>
str_to_vec (string exp)
{
	vector<int> v;
	for (int i = 0; i < exp.size(); i++)
	{
		int c = exp[i] - '0';
		if (0 <= c || c <= 9) // number
			v.push_back(c);
		else 
			v.push_back(c);
	}
	return v;
}

int
mis_cal (vector<int> exp)
{
	int num = exp[0];
	bool add, mul;
	add = mul = false;
	for (int i = 1; i < exp.size(); i++)
	{
		if (exp[i] == -5) // plus
			add = true;
		else if (exp[i] == -6) // mul
			mul = true;
		else 
		{
			if (add)
			{
				num += exp[i];
				add = false;
			}
			else if (mul)
			{
				num *= exp[i];
				mul = false;
			}
			else
			{
				cout << "error" <<endl;
				exit(1);
			}
		}
	}
	return num;
}

int
cal (vector<int> exp)
{
	int num = exp[0];
	vector<int> v;
	bool add, mul;
	add = mul = false;
	for (int i = 1; i < exp.size(); i++)
	{
		if (mul)
		{
			num *= exp[i];
			mul = false;
		}
		else if (add)
		{
			v.push_back(num);
			v.push_back(-5);
			num = exp[i];
			add = false;
		}
		else if (exp[i] == -6)
			mul = true;
		else if (exp[i] == -5)
			add = true;
		else if (0 <= exp[i] && exp[i] <= 9)
		{
			num = exp[i];
		}
		else 
		{
			cout << "error"<<endl;
			exit(1);
		}
	}
	v.push_back(num);
#ifdef D
	cout << "cal";
	print_vec(v);
#endif

	return mis_cal(v);
}

	int
main (void)
{
	int bob_ans;
	string str_exp;
	cin >> str_exp >> bob_ans;

	vector<int> vec_exp = str_to_vec(str_exp);
#ifdef D
	print_vec(vec_exp);
	cout << "mis_cal " << mis_cal(vec_exp) << endl;
	cout << "cal     " << cal(vec_exp) << endl;
#endif
	int m, c;
	m = mis_cal(vec_exp); c = cal(vec_exp);
	if (bob_ans == m && bob_ans == c)
		cout << "U" <<endl;
	else if (bob_ans == c)
		cout << "M" <<endl;
	else if (bob_ans == m)
		cout << "L" <<endl;
	else
		cout << "I" <<endl;

	return 0;
}



Measured memory_bytes: 3148
#include <iostream>
#include <sstream>
#include <fstream>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <cmath>
using namespace std;

struct rect {
    int w;
    int h;
    long t;
    bool operator>(rect r) const {
        return this->t == r.t ? this->h > r.h : this->t > r.t;
    };
    bool operator<(rect r) const {
        return this->t == r.t ? this->h < r.h : this->t < r.t;
    };
    bool operator==(rect r) const {
        return this->h == r.h && this->w == r.w;
    };
};

int main() {
    vector<rect> v;
    for(int i = 1; i < 151; i++){
        for(int k = i + 1; k < 151; k++){
            rect r;
            r.w = k;
            r.h = i;
            r.t = k*k + i*i;
            v.push_back(r);
        }
    }
    sort(v.begin(), v.end());
    
    while(1){
        rect r;
        cin >> r.h >> r.w;
        if(r.w == 0 && r.h == 0) break;
        r.t = r.w*r.w + r.h*r.h;
        vector<rect>::iterator it = find(v.begin(), v.end(), r);
        r = *(++it);
        cout << r.h << " " << r.w << endl;
    }
    return 0;
}

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

int main() {
	int h,w,d;
	cin>>h>>w>>d;
	int a[h][w];
	long long x[h*w+1],y[h*w+1];
	long long m[h*w+1];
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			cin>>a[i][j];
			x[a[i][j]]=i;
			y[a[i][j]]=j;
		}
	}
	for(int i=h*w;i>0;i--){
		if(i>h*w-d){
			m[i]=0;
		}else{
			m[i]=m[i+d]+abs(x[i]-x[i+d])+abs(y[i]-y[i+d]);
		}
	}
	int q;
	cin>>q;
	int l[q];
	int r[q];
	for(int i=0;i<q;i++){
		cin>>l[i]>>r[i];
		cout<<m[l[i]]-m[r[i]]<<endl;;
	}
	return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

// MACROS

#define ll long long
#define ull unsigned long long
#define ld long double

#define vi vector<int>
#define vll vector<ll>
#define vld vector<ld>
#define u_s unordered_set

#define pii pair<int,int>
#define pll pair<ll,ll>

#define FOR(i, n) for (ll i = 0; i < n; i++)
#define FORN(i, a, b) for (ll i = a; i < b; i++)
#define FORE(i, l) for (auto i : l)

#define pb push_back
#define pob pop_back
#define emp emplace
#define fi first
#define se second

#define all(n) n.begin(), n.end()
#define in(n) cin >> (n);
#define debug(n) cout << #n << ": " << n << '\n';

// FUNCTIONS

template< typename T >
inline T gcd(T a, T b) { if (b) return gcd(b, a % b); return a; }

template< typename T >
inline T ext_gcd(T a, T b, T & x, T & y) { if (a == 0) { x = 0; y = 1; return b; } T x1, y1; T g = ext_gcd(b % a, a, x1, y1); x = y1 - (b / a) * x1; y = x1; return g; }

bool check(ll x, ll f)
{
    while (x % f == 0) x /= f;
    return x % f == 1;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);	
    //cout << setprecision(15);
    ll n;
    cin >> n;
    set<ll> s;
    for (ll i = 2; i * i <= n; i++)
    {
        if (check(n, i)) s.emp(i);
        if ((n - 1) % i == 0)
        {
            s.emp(i);
            s.emp((n - 1) / i);
        }
    }
    s.emp(n); if (n > 2) s.emp(n - 1);
    cout << s.size() << '\n';
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

int main(){
	ll N;
	cin >> N;
	ll x = -3;
	REP(i, 101010){
		if(i*(i-1)==2*N) x = i;
	}
	if(x==-3){
		cout << "No" << endl;
		return 0;
	}else{
		vector<ll> res[x];
		ll tmp = 0;
		REP(i, x)REP(j, x){
			if(i>=j) continue;
			res[i].push_back(tmp);
			res[j].push_back(tmp);
			tmp++;
		}
		cout << "Yes" << endl;
		cout << x << endl;
		REP(i, x){
			cout << res[i].size() << " ";
			REP(j, res[i].size()){
				cout << res[i][j]+1 << " ";
			}
			cout << endl;
		}
	}
    return 0;
}

Measured memory_bytes: 3200
N, K = map(int, input().split())
mod = 10 ** 9 + 7
cnt = [0] * (K + 1)
answer = 0
for i in range(K, 0, -1):
    tmp = pow(K // i, N, mod) - sum(cnt[::i])
    cnt[i] = tmp
    answer = (answer + tmp * i) % mod

print(answer)


Measured memory_bytes: 12048
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
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;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<double> VD;
typedef vector<VD> VVD;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    ll a = 1, b = 0;
    int n;
    cin >> n;
    while (n--){
        ll q, x;
        cin >> q >> x;
        if (q == 1){
            a *= x;
            b *= x;
        }else if (q == 2){
            b += x;
        }else{
            b -= x;
        }
    }
    cout << -b << " " << a << endl;
    return 0;
}



Measured memory_bytes: 3120
input = $stdin.read.split("\n")

while !input.empty?
	input.shift()
	as = input.shift.split(" ").map(&:to_i)
	an = as.count
	en = as.count {|a| a%2==0}
	on = as.count {|a| a%2==1}

	puts (3**an - 2**en)
end



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

using namespace std;

#define fi first
#define se second
#define eb emplace_back
#define mt make_tuple
#define all(x) (x).begin(), (x).end() 
#define MOD 1000000007

typedef long long ll;
typedef pair <int, int> ii;
typedef pair <ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef long double ld;

const ll INF=LLONG_MAX;
const int mxn=101;
int a[mxn];

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
	int n; cin >> n;
	for(int i=0; i<n; i++)cin >> a[i];
	sort(a,a+n);
	cout << a[n-1]-a[0] << endl;
}
	
// READ & UNDERSTAND
// ll, int overflow, array bounds, memset(0)
// special cases (n=1?), n+1 (1-index)
// do smth instead of nothing & stay organized
// WRITE STUFF DOWN


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>

//Some constants don't work
#ifndef INT_MAX
#define INT_MAX 2147483647
#endif
#ifndef INT_MIN
#define INT_MIN -2147483648
#endif
//short hand tricks
typedef long long ll;

using namespace std;

int main(int argc, char * argv[]) {
    ios_base::sync_with_stdio(false);
    string s;
    cin >> s;
    int maxR = 0;
    int r = 0;
    for(int i=0; i<s.size(); i++) {
        if(s[i]=='R') {
            r++;
            maxR = max(r, maxR);
        } else {
            r = 0;
        }
    }
    cout << maxR << "\n";
    return 0;
}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> A;
    A.emplace_back(0);
    rep(i, N) {
        int a;
        cin >> a;
        A.emplace_back(a);
    }
    A.emplace_back(0);

    vector<int> vec(N+1);
    rep(i, N+1) vec[i] = abs(A[i+1] - A[i]);

    vector<int> dpl(N+2), dpr(N+2);
    rep(i, N+1) dpl[i+1] = dpl[i] + vec[i];
    repr(i, N+1) dpr[i] = dpr[i+1] + vec[i];

    for (int i = 1; i <= N; ++i) {
        int ans = dpl[i-1] + dpr[i+1] + abs(A[i-1] - A[i+1]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 2936
while True :
    S = input()
    
    if(S == ".") :
        break
    
    else :
        B = list()
        b = -1
        for i in range(len(S)) :
            if(S[i] == "(" or S[i] == "[") :
                B.append(S[i])
                b += 1
                
            elif(S[i] == ")") :
                if(b > -1) :
                    if(B[b] == "(") :
                        del B[b]
                        b -= 1
                    else :
                        b = 0
                        break
                else :
                    b = 0
                    break
                
            elif(S[i] == "]") :
                if(b > -1) :
                    if(B[b] == "[") :
                        del B[b]
                        b -= 1
                    else :
                        b = 0
                        break
                else :
                    b = 0
                    break
                
            else :
                pass
            
        if(b == -1) :
            print("yes")
        else :
            print("no")


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

const int D = 60;
const int Max_N = 200'006;
int to[D][Max_N];

int main(){
	int n; ll k;
	cin >> n >> k;
	rep(i,n) cin >> to[0][i];
	rep(i,n) to[0][i]--;
	rep(i,D-1)rep(j,n){
		to[i+1][j] = to[i][to[i][j]];
	}
	int v = 0;
	for(int i=D-1; i >= 0; i--){
		ll l = 1ll<<i;
		if(l <= k){
			v = to[i][v];
			k -= l;
		}
	}
	cout << v+1 << endl;
	return 0;
}


Measured memory_bytes: 50500
package main

import (
	"fmt"
)

func main() {
	var year int
	var month int
	var date int
	// 2019/01/01
	_, _ = fmt.Scanf("%d/%d/%d", &year, &month, &date)
	if year <= 2019 && month <= 4 {
		fmt.Println("Heisei")
	} else {
		fmt.Println("TBD")
	}


}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <utility>
#include <set>
#include <map>
#include <tuple> 
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
using namespace  std;
using ll = long long;
using P = pair<ll, ll>;
#define REP(i, n) for(long long (i)=0, i_bound = (long long)(n); (i)<i_bound; ++i)
#define FOR(i, a, b) for(long long (i)=(a); (i)<(b); ++i)
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
const long long MOD = static_cast<long long>(1e9) + 7LL;
const long long INF = 1234567891234567890LL;
int main(){
    cin.tie(0);
    cout.sync_with_stdio(false);
    ll X; cin >> X;
    ll res = X / 500 * 1000;
    X %= 500;
    res += X/5 * 5;
    cout << res << endl;
    return 0;

}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<cctype>
#include<cmath>
#include<algorithm>
#define ll long long
using namespace std;
int read(){
    char c;int s=0,t=1;
    while(!isdigit(c=getchar()))if(c=='-')t=-1;
    do{s=s*10+c-'0';}while(isdigit(c=getchar()));
    return s*t;
}
/*------------------------------------------------------------*/
const int inf=0x3f3f3f3f,maxn=3010;
const double eps=1e-6;

int n,A,B,C,D,E,F,m,v;
bool f[50][maxn];
double ans;
int main(){
	A=read();B=read();C=read();D=read();E=read();F=read();
	memset(f,0,sizeof(f));
	f[0][0]=1;
	ans=0;m=0;v=0;
	for(int i=0;i<=F/100;i++){
		for(int j=0;j<=F;j++){
			if(i-A>=0)f[i][j]|=f[i-A][j];
			if(i-B>=0)f[i][j]|=f[i-B][j];
			if(j-C>=0)f[i][j]|=f[i][j-C];
			if(j-D>=0)f[i][j]|=f[i][j-D];
			//f[i][j]=f[i-A][j]|f[i-B][j]|f[i][j-C]|f[i][j-D];
			//if(f[i][j])printf("f[%d][%d]=%d\n",i,j,f[i][j]);
			if(f[i][j]&&i*E>=j&&i*100+j<=F&&1.0*j/(100*i+j)+eps>ans){//printf("c\n");
				ans=1.0*j/(100*i+j);
				m=i*100+j;v=j;
			}
		}
	}
    printf("%d %d\n",m,v);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define PI 3.141592653589793



int main(){
  int N; string S; cin >> N >> S; ll ans=0; ll igai=0;
  int cntr=0, cntg=0, cntb=0;
  rep(i, N){
    if(S[i]=='R') cntr++;
    else if(S[i]=='G') cntg++;
    else if(S[i]=='B') cntb++;
  }
  ans+=(ll)cntr*cntg*cntb;
  for(int i=1; i<=N; i++){
    rep(j, N){
      if(j+2*i<=N-1 && S[j]!=S[j+i] && S[j+i]!=S[j+2*i] && S[j]!=S[j+2*i]){
        igai++;
      }
    }
  }
  cout << ans-igai << endl;
}

Measured memory_bytes: 3636
def f(n, k):
    hs = list(map(int, input().split()))
    dp = [0] * n
    for i, h in enumerate(hs[1:]):
        i += 1
        L = max(0, i - k)
        dp[i] = min(dk + abs(h - hk) for dk, hk in zip(dp[L:i], hs[L:i]))
    print(dp[-1])


n, k = map(int, input().split())
f(n, k)


Measured memory_bytes: 13980
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/

#include <cstdio>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
#include <iomanip>
#include <set>
#include <stack>
#include <bitset>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma gcc target ("avx2")
//#pragma gcc optimization ("o3")
//#pragma gcc optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printim(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a) //少数出力
#define printLdb(a) printf("%.50Lf\n", a) //少数出力
#define printdbd(a) printf("%.16lf\n", a) //少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str()) //string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2LL) //等差数列の和、初項,末項,項数
#define pb push_back
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0L)*2.0L*PI)
#define rad_to_deg(rad) (((rad)/2.0L/PI)*360.0L)
#define Please return
#define AC 0
#define manhattan_dist(a, b, c, d) (abs(a - c) + abs(b - d)) /*(a, b) から (c, d) のマンハッタン距離 */
#define inf numeric_limits<double>::infinity();
#define linf numeric_limits<long double>::infinity()


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
constexpr long double eps = 1e-9;
const long double PI = acosl(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);
	while (c != '\n' && c != -1 && c != ' ') {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n, x, c;
	scanf("%d%d", &n, &x);
	c = x;
	vector<int> a(n);
	rep(i, n)scanf("%d", &a[i]);
	int ans = 0;
	sort(all(a));
	rep(i, n) {
		if (c >= a[i]) {
			++ans;
			c -= a[i];
		}
	}
	printf("%d\n", min(ans, n - !(accumulate(all(a), 0) == x)));

	Please AC;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll D, N;
  cin >> D >> N;

  ll ans = N + N/100;
  while(D>0){
    ans *= 100;
    D--;
  }

  cout << ans << "\n";

  return 0;
}

Measured memory_bytes: 768
//g++ -std=c++14 test.cpp -o test.out
//問題URL
//https://atcoder.jp/contests/dp/tasks/dp_t
//参考
//https://kyopro-friends.hatenablog.com/entry/2019/01/12/231035

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (LL)(1e18)+1;
const int INF_INT = 2147483647-1e6;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

struct mint {
  LL x; 
  mint(LL x=0):x((x%mod+mod)%mod){}
  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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

//xを素因数分解する
//例えば60 = 5*3*2*2 であれば[(5,1),(3,1),(2,2)]を返す
vector<pair<LL,LL>> factorial(LL x){
	vector<pair<LL,LL>> ret;
	for(LL i=2;i*i<=x;i++){
		if(x%i==0){
			LL counter = 0;
			while(1){
				if(x%i!=0) break;
				x /= i;
				counter++;
			}
			ret.push_back(make_pair(i,counter));
		}
	}
	if(x!=1) ret.push_back(make_pair(x,1));
	return ret;
}

LL N;
LL A[10000];

LL ans = 0;

void solve(){
	map<LL,LL> factorial_of_lcm_of_A;//Aの最小公倍数の約数を格納する
	//普通に最小公倍数を求めようとするとオーバーフローで失敗する
	//よって最小公倍数の約数を求めることにする
	for(int i=0;i<N;i++){
		vector<pair<LL,LL>> facts = factorial(A[i]);
		for(int j=0;j<facts.size();j++){
			LL num = facts[j].first;
			factorial_of_lcm_of_A[num] = max(factorial_of_lcm_of_A[num],facts[j].second);
		}
	}

	mint lcm_A = 1;
	for(auto iter=factorial_of_lcm_of_A.begin();iter!=factorial_of_lcm_of_A.end();iter++){
		lcm_A *= mint(iter->first).pow(iter->second);
	}

	mint B_sum = 0;
	for(int i=0;i<N;i++){
		B_sum += lcm_A/mint(A[i]);
	}
	ans = B_sum.x;
}
 
int main(){
    cin >> N;
    for(int i=0;i<N;i++) cin >> A[i];
 
    solve();

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

Measured memory_bytes: 896
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<map>
#include<queue>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
char a;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a;
	if('A'<=a&&a<='Z')
	{
		cout<<'A'<<endl;
	}
	else
	{
		cout<<'a'<<endl;
	}
	return 0;
}


Measured memory_bytes: 3648