akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

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

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

struct UnionFind {
  vector<int> par;
  vector<int> sz;

  UnionFind(int n) { init(n); }

  void init(int n) {
    par.resize(n);
    sz.resize(n);
    REP(i, n) {
      par[i] = i;
      sz[i] = 1;
    }
  }

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

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sz[x] < sz[y]) {
      par[x] = y;
      sz[y] += sz[x];
    } else {
      par[y] = x;
      sz[x] += sz[y];
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }

  int size(int x) { return sz[find(x)]; }
};

int V, E;
vector<IP> edge;

int kruskal() {
  sort(ALL(edge));
  UnionFind uf(V);
  int res = 0;
  REP(i, E) {
    int u = edge[i].second.first;
    int v = edge[i].second.second;
    int cost = edge[i].first;
    if (!uf.same(u, v)) {
      uf.unite(u, v);
      res += cost;
    }
  }
  return res;
}

int main() {
  cin >> V >> E;
  REP(i, E) {
    int s, t, w;
    cin >> s >> t >> w;
    edge.push_back(make_pair(w, P(s, t)));
  }
  int ans = kruskal();
  cout << ans << endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> X(N+1);
    int ans = 100*100*100, buf;
    for(int i = 1; i <= N; ++i) cin >> X[i];
    sort(X.begin(), X.end());
    for(int P = X[1]; P <= X[N]; ++P){
        buf = 0;
        for(int i = 1; i <= N; ++i){
            buf += pow(X[i]-P, 2);
        }
        ans = min(ans, buf);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<' ';
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int n; cin>>n;
	vector<vector<int>> state(n,vector<int> (n,-1));
	rep(i,n){
		int k;cin>>k;
		rep(j,k){
			int x,y;
			cin>>x>>y;
			state[i][--x] = y;
		}
	}
	int ans = 0;
	for(int bit = (1<<n)-1; bit>0; --bit){
		vint t;
		vint al (n,-1);
		int cnt = 0;
		int p = 0;
		rep(i,n){
			if(bit & (1<<i)){
				++cnt;
				t.push_back(i);
				rep(j,n){
					if(state[i][j]==-1)continue;
					if(al[j] == -1)al[j] = state[i][j];
					else if(al[j] != state[i][j]){goto OUT;}
				}
			}
		}
		rep(i,n){
			if(i == t[p]){
				++p;
				if(al[i] == 0)goto OUT;
			}else{
				if(al[i] == 1)goto OUT;
			}
		}
		ans = max(ans,cnt);
		OUT:;
	}
	cout<<ans<<endl; return 0;
}


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

int main() {
  int x, y;
  cin >> x >> y;
  
  if(x > 9 || y > 9) {
    cout << -1 << endl;
  }
  else {
    cout << x * y << endl;
  }
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
#define int long long
int n,l,r;
main(){
  cin>>n;
  r(i,n){
    cin>>l;
    if(l%2)r++;
  }
  if(r%2==0)cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#define ALL(x) x.begin(), x.end()
#ifdef DEBUG
#define line() cerr << "[" << __LINE__ << "] ";
#define dump(i) cerr << #i ": " << i << " ";
#define dumpl(i) cerr << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int n;
    cin >> n;
    int b[n];
    int a[n];
    rep(i, n - 1) cin >> b[i];

    a[0] = b[0];
    rep(i, 1, n - 1)
    {
        a[i] = min(b[i - 1], b[i]);
    }
    a[n - 1] = b[n - 2];

    int ans = 0;
    rep(i, n) ans += a[i];
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#pragma comment(linker, "/STACK:10240000")
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 100010;

char s[MAXN];

int main()
{
    scanf("%s", &s);
    int len = strlen (s);
    int count = 0;
    for (int i = 1; i < len; i ++)
    {
        if (s[i] != s[i - 1])
        {
            count ++;
        }
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using Map = map<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
ll INF=1LL<<60;
ll MOD=998244353;

int main(){
    double n;
    cin >> n;
    double m;
    cin >> m;
    double d;
    cin >> d;

    double k=(2*(n-d))/(n*n);
    if(d==0){k/=2;}


    cout << fixed << setprecision(15);
    cout<<(m-1)*k<<endl;


    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main(N, K, S):
    cnts = []
    now = 1
    cnt = 0
    for n in S:
        if now == int(n): 
            cnt += 1
        else:
            cnts.append(cnt)
            cnt = 1
            now = 1 - now
    if cnt != 0: cnts.append(cnt)

    if len(cnts) % 2 == 0: cnts.append(0)
    
    ans = 0
    Add = 2 * K + 1

    sums = [0]
    for c in cnts:
        sums.append(sums[-1] + c)

    for i in range(0,len(cnts),2):
        left = i
        right = min(i + Add, len(cnts))
        tmp = sums[right] - sums[left]

        ans = max(tmp, ans)
    print(ans)

if __name__ == "__main__":
    n, k = list(map(int, input().split()))
    s = input()
    main(n, k, s)


Measured memory_bytes: 7932
#include <iostream>
#define N 20
using namespace std;
void func(int,int);
int jump(int,int);
int X,Y,data[N][N],memo[N][N];
int main(){
  while(1){
    cin >> X >> Y;
    if(X==0&&Y==0) break;
    for(int i=0;i<N;i++)
      for(int j=0;j<N;j++) data[i][j]=0,memo[i][j]=0;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++) cin >> data[i][j];
    for(int i=0;i<X;i++)
      if(data[0][i]!=1) func(0,i);
    int cnt=0;
    for(int i=0;i<X;i++) cnt+=memo[0][i];
    cout << cnt << endl;
  }
  return 0;
}
void func(int y,int x){
  if(y>=Y-1){
    memo[y][x]=memo[Y][x]=memo[Y-1][x]=1;
    return ;
  }
  if(0<=x-1&&data[y+1][x-1]==0){
    if(memo[y+1][x-1]==0) func(y+1,x-1);
    memo[y][x]+=memo[y+1][x-1];
  }
  if(x+1<X&&data[y+1][x+1]==0){
    if(memo[y+1][x+1]==0) func(y+1,x+1);
    memo[y][x]+=memo[y+1][x+1];
  }
  if(data[y+1][x]==0){
    if(memo[y+1][x]==0) func(y+1,x);
    memo[y][x]+=memo[y+1][x];
  }
  if(data[y+1][x]==2){
    int r=jump(y+1,x);
    if(r!=-1){
      if(memo[r][x]==0) func(r,x);
      memo[y][x]+=memo[r][x];
    }else data[y+1][x]=1;
  }
  if(memo[y][x]==0) data[y][x]=1;
}
int jump(int y,int x){
  while(1){
    y+=2;
    if(data[y][x]==1) break;
    if(data[y][x]==0||y>=Y-1) return y;
  }
  return -1;
}

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

typedef int integer;

#define FIN ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ld long double
#define pb push_back
#define bs binary_search
#define up upper_bound
#define lw lower_bound
#define fs first 
#define sd second 
#define mp make_pair    

#define fore(i,a,b) for(ll i = a; i < b; i++)
#define rfore(i, a, b) for(ll i = a - 1; i >= b; i--)
#define forev(a,b) fore(i,0,b)cout<<a[i]<<" "; 
#define mm(a,b) memset(a , b , sizeof a) 
#define ALL(a) a.begin(),a.end() 
#define SZ(n) ((ll) (n).size())

#define infi  2e9
#define int long long
#define endl '\n'
const ld pi = 3.14159265358979323846;
const ll mod = 1e9+7;
const ll INF = 1e10;
const ld EPS = 1e-8;

typedef pair<ll,ll> pll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b,a%b); } 
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }

const int MAXN = 200000;
const int K=20;

int n;
int h[MAXN];
int dp[MAXN];

int solve(int pos){
	if(pos>=n-1)return 0;
	int &r=dp[pos];
	if(r!=-1)return dp[pos];
	r = min(abs(h[pos]-h[pos+1])+solve(pos+1),abs(h[pos]-h[pos+2])+solve(pos+2));
	return r;
}

integer main(){
	cin>>n; 
	fore(i,0,n)cin>>h[i];
	h[n]=INF; h[n+1]=INF;
	mm(dp,-1);
	cout<<solve(0);
	//fore(i,0,n)cout<<dp[i]<<" ";
    return 0;
}

Measured memory_bytes: 4096
import itertools

n,m = [int(i) for i in input().split()]

chk = [[0]*n for i in range(n)]
for i in range(m):
  a,b = [int(i) for i in input().split()]
  chk[a-1][b-1] = 1
  chk[b-1][a-1] = 1

ans = 0

for i in itertools.permutations(range(n),n):
  if i[0] == 0:
    for j in range(n):
      if j == n-1:
        ans += 1
        break
      if chk[i[j]][i[j+1]] != 1:
        break
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int M = 1e9+7;
int main(){
    int H, W; cin>>H>>W; 
    vector<vector<bool> > grid(H,vector<bool> (W, false));
    vector<vector<int> > dp(H+1, vector<int>(W+1, 0));
    for(int i = 0; i < H; i++){
	string s; cin>>s;
	for(int j = 0; j < W; j++){
	    if(s.at(j) == '.'){
		grid[i][j] = true;
	    }
	}
    }
    for(int i = 1; i <= H; i++){
	for(int j = 1; j <= W; j++){
	    if(!grid[i-1][j-1]){
		continue;
	    }
	    if(i==1&&j==1) {
		dp[i][j] = 1;
		continue;
	    }
	    if(i-2>=0 &&grid[i-2][j-1]){
	       dp[i][j] = (dp[i][j] + dp[i-1][j]) % M; 
	    }
	    if(j-2>=0 && grid[i-1][j-2]){
		dp[i][j] = (dp[i][j] + dp[i][j-1]) % M;
	    }
	} 
    }
    cout<<dp[H][W];
}


Measured memory_bytes: 4352
hon = 'hon'
pon = 'pon'
bon = 'bon'

N = int(input())
hons = [2,4,5,7,9]
pons = [0,1,6,8]
bons = [3]
A = N % 10
if A in bons:
	print(bon)
elif A in pons:
	print(pon)
elif A in hons:
	print(hon)
else:
	print('?')

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

using namespace std;

typedef long long int ll;
typedef long double ld;

const ll mod = 1e9+7;
const ll mod1 = 998244353;

#define fill(a)  memset(a, 0, sizeof(a))
#define fst first
#define snd second
#define mp make_pair
#define pb push_back

void fastscan(ll &number)
{
	bool negative = false;
	register int c;
	number = 0;
	c = getchar();
	if (c=='-') 
	{
		negative = true;
		c = getchar();
	}
	for (; (c>47 && c<58); c=getchar())
		number = number *10 + c - 48;
	if (negative)
		number *= -1;
}

bool isprime(ll n)
{
    if (n <= 1)  return false;
    if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;

    for (ll i=5; i*i<=n; i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
           return false;

    return true;
}

bool checkisTree(ll degree[],ll n) 
{
    ll deg_sum = 0; 
    for (ll i = 0; i < n; i++) 
        deg_sum += degree[i]; 
    return (2*(n-1) == deg_sum);
}

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

}
int main()
{
	cin.sync_with_stdio(0);
	cin.exceptions(cin.failbit);
	cin.tie(0);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		ll n;
      	cin>>n;
      	ll arr[n], arr1[n];
      	for(ll i=0; i<n; i++)
        {
          cin>>arr[i]; 
          arr1[i] = arr[i];
        }
      	sort(arr1,arr1+n);
      	for(ll i=0; i<n; i++)
        {
          if(arr1[n-1]!=arr[i])
             cout<<arr1[n-1]<<"\n";
          else
             cout<<arr1[n-2]<<"\n";
        }
	}
	
}

Measured memory_bytes: 4864
n = gets.to_i
a = gets.split.map(&:to_i).sort

def pow(n)
  ret = 1
  n.times { ret = ret * 2 % (10**9 + 7) }

  ret
end

if n.odd? && a.shift == 0 && a.each_with_index.all? { |e, idx| e == (idx / 2) * 2 + 2 }
  puts pow(n / 2)
elsif n.even? && a.each_with_index.all? { |e, idx| e == (idx / 2) * 2 + 1 }
  puts pow(n / 2)
else
  puts 0
end

Measured memory_bytes: 9720
#include <bits/stdc++.h>
#define lli long long int

using namespace std;

int main()
{
    lli n,i,j,sum=0;
    cin>>n;
    lli a[n],dp[n][n],diag=n-1;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
        sum=sum+a[i];
    }
    for(i=0;i<n;i++)
    {
        for(j=0;j<n;j++)
        {
            if(i==j)
                dp[i][j]=a[i];
            else
                dp[i][j]=0;
        }
    }
    for(i=0;i<diag;i++)
    {
        for(j=n-diag;j<n;j++)
        {
            if(i+2<n && j>=2)
                dp[i][j]=max(min(a[i]+dp[i+1][j-1],a[i]+dp[i+2][j]),min(a[j]+dp[i+1][j-1],a[j]+dp[i][j-2]));
            else if(i+2<n)
                dp[i][j]=max(a[i]+dp[i+1][j-1],min(a[j]+dp[i+1][j-1],a[j]+dp[i][j-2]));
            else
                dp[i][j]=max(min(a[i]+dp[i+1][j-1],a[i]+dp[i+2][j]),a[j]+dp[i+1][j-1]);
            i++;
        }
        diag--;
        i=-1;
    }
    cout<<2*dp[0][n-1]-sum<<endl;
    return 0;
}


Measured memory_bytes: 70528
#include<bits/stdc++.h>
using namespace std;
string s;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long long int n,c=0,d=0;
    cin>>n;
    while(n>0)
    {
        if(n%500==0)
        {
            n-=500;
            c++;
        }
        else if(n%5==0)
        {
            n-=5;
            d++;
        }
        else if(n%100==0)
        {
            n-=100;
        }
        else if(n%50==0)
        {
            n-=50;
        }
        else if(n%10==0)
        {
            n-=10;
        }

        else
        {
            n--;
        }
    }
    cout<<c*1000+d*5<<endl;



    return 0;
}


Measured memory_bytes: 3640
S = list(input())

list_0 = list()
list_1 = list()
for i in range(len(S)):
  if i % 2 ==0:
    list_0.append(int(S[i]))
  else:
    list_1.append(int(S[i]))

count_0_0 = list_0.count(0)
count_1_0 = list_1.count(1)

count_0_1 = list_0.count(1)
count_1_1 = list_1.count(0)

sum_0 = count_0_0 + count_1_0
sum_1 = count_0_1 + count_1_1

print(min(sum_0, sum_1))

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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
typedef pair<int,int> P;
typedef vector<LL> V;
typedef vector<V> VV;
int main(){
    int N;
    cin>>N;
    VV A(N,V(N));
    cin>>A;
    VV d(N,V(N,1e15));
    REP(i,N)d[i][i]=0;
    vector<pair<LL,P>> e;
    
    REP(i,N)REP(j,i)e.pb({A[i][j],{i,j}});
    sort(ALL(e));
    cout<<
        [&](){
        LL ret=0;
        for(auto &it:e){
            int a=it.se.fi;
            int b=it.se.se;
            if(d[a][b]>A[a][b]){
                ret+=it.fi;
                d[a][b]=d[b][a]=it.fi;
                DEBUG cout<<" "<<it.fi<<endl;
                REP(i,N)REP(j,N)
                    chmin(d[i][j],d[i][a]+d[a][b]+d[b][j]);
                REP(i,N)REP(j,N)
                    chmin(d[i][j],d[i][b]+d[a][b]+d[a][j]);
                REP(i,N)REP(j,N)if(d[i][j]<A[i][j])return -1ll;
            }
        }
        REP(i,N)REP(j,N)if(d[i][j]!=A[i][j])return -1ll;
        return ret;
    }() <<endl;
    return 0;
}


Measured memory_bytes: 2808
#include <bits/stdc++.h>
using namespace std;
#define SZ(x) (int)(x.size())
#define REP(i, n) for(int i=0;i<(n);++i)
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define RREP(i, n) for(int i=(int)(n)-1;i>=0;--i)
#define RFOR(i, a, b) for(int i=(int)(b)-1;i>=(a);--i)
#define ALL(a) a.begin(),a.end()
#define DUMP(x) cerr<<#x<<" = "<<(x)<<endl
#define DEBUG(x) cerr<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<< endl;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
    if (a < b) { a = b; return true; }
    return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
    if (a > b) { a = b; return true; }
    return false;
}
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "[";
    REP(i, SZ(v)) {
        if (i) os << ", ";
        os << v[i];
    }
    return os << "]";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const map<T1, T2> &mp) {
    os << "{";
    int a = 0;
    for (auto &tp : mp) {
        if (a) os << ", "; a = 1;
        os << tp;
    }
    return os << "}";
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    os << p.first << ":" << p.second;
    return os;
}


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    for (;;) {
        int n; cin >> n;
        if (n == 0) break;

        vi cnt(26);
        char winner = '#';
        int ans;
        REP(i, n) {
            char c; cin >> c;
            if (winner != '#') continue;
            ++cnt[c - 'A'];
            vi ord(26);
            iota(ALL(ord), 0);
            sort(ALL(ord), [&](int i,int j){ return cnt[i] > cnt[j]; });

            if (cnt[ord[0]] > cnt[ord[1]] + n-1-i) {
                winner = ord[0] + 'A';
                ans = i;
            }
        }
        if (winner == '#') {
            cout << "TIE" << endl;
            continue;
        }
        cout << winner << " " << ans+1 << endl;
    }

    return 0;
}



Measured memory_bytes: 3180
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;



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

  cin>>n; int c1,c2,p,v[n]; cin>>c1>>c2>>p; 
	rep(i,n)cin>>v[i]; sort(v,v+n);
	double r=(double)p/c1;
	int cost=c1,val=p;
	gnr(i,0,n-1){
		if((double)v[i]/c2>r){
			val+=v[i]; cost+=c2;
			r=(double)val/cost; 
		}
	}
	pri1(floor(r));
}


Measured memory_bytes: 3268
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N;
int A[100010];
int x[100010];

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

  cin >> N;
  int sum = 0;
  REP(i,N) cin >> A[i], sum += A[i];
  int tmp = 0;
  for (int i = 0; i < N-1; i += 2) {
    tmp += 2 * A[i];
  }
  x[N-1] = sum - tmp;
  for (int i = N-2; i >= 0; i--) {
    x[i] = 2*A[i] - x[i+1];
  }
  REP(i,N) {
    cout << x[i] << " \n"[i+1==N];
  }

  return 0;
}

Measured memory_bytes: 2944
import sys
R = lambda:map(int,raw_input().split())

while 1:
    s = raw_input()
    if s == '.': break
    left = []
    flag = False
    for i in xrange(len(s)):
        #print s[i]
        if (s[i] == '(') or (s[i] == '['):
            left.append(s[i])
        elif s[i] == ')':
            if not left:
                flag = True
                break
            elif left[len(left)-1] == '(':
                left.pop()
            else:
                flag = True
                break
        elif s[i] == ']':
            if not left:
                flag = True
                break
            elif left[len(left)-1] == '[':
                left.pop()
            else:
                flag = True
                break
        #print left
    #print flag
    if left: flag = True
    if not flag: print 'yes'
    else: print 'no'

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

using namespace std;
using ll = long long;

using Field = vector<vector<int>>;
using Graph = vector<vector<int>>;
using VI = vector<int>;
using VC = vector<char>;
using PI = pair<int, int>;

#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(x) x.begin(), x.end()


int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int k; cin >> k;
    ll ans = 0;
    for (int a = 1; a < k + 1; a++) {
        for (int b = 1; b < k + 1; b++) {
            for (int c = 1; c < k + 1; c++) {
                ans += gcd(a, gcd(b, c));
            }
        }
    }

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

Measured memory_bytes: 3600
// Author: Vamsi Krishna Reddy Satti
// With love for Competitive Programming!
 
// #pragma comment(linker, "/stack:200000000")
// #pragma GCC optimize ("Ofast,unroll-loops,-ffloat-store,no-stack-protector")
// #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")

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

string to_string(const string& s) { return '"' + s + '"'; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cout << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
    #define debug(...) cout << "#" << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
    #define debug(...) 3
#endif
 
#define cin_exception cin.exceptions(cin.failbit);
#define cout_precision cout.setf(ios::fixed); cout.precision(15);
#define fast_io ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
using ld = long double;  using ui = uint_fast32_t;
using ll = int_fast64_t; using ul = uint_fast64_t;

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

void solve() {
    int n; string s;
    cin >> n >> s;
    int r = 0, g = 0, b = 0;
    ll re = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int k = 2 * j - i;
            if (k >= n) break;
            if (s[i] == s[j]) continue;
            if (s[i] == s[k]) continue;
            if (s[j] == s[k]) continue;
            --re;
        }
        if (s[i] == 'R') ++r;
        if (s[i] == 'G') ++g;
        if (s[i] == 'B') ++b;
    }
    re += ll(r) * g * b;
    cout << re << '\n';
}

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

int main() {
    fast_io;
#ifdef LOCAL
    cin_exception;
#endif
    int t = 1;
    // cin >> t;
    for (int i = 1; i <= t; ++i) {
        solve();
    }
}

Measured memory_bytes: 3608
import math

a, b, h, m = map(int, input().split())
h_posi = 30*h + 0.5*m
m_posi = 6*m

kakudo = abs(h_posi - m_posi)
kakudo = min(kakudo, 360-kakudo)
cos = round(math.cos(math.radians(kakudo)), 18)

print((a**2 + b**2 - 2*a*b*cos)**0.5)

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

using namespace std;

typedef long long ll;
typedef long double Double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)


long long f(long long A, long long B) {
    if (A > B) return f(B, A);
    if (A == 0) return -B;
    return 2 * A * (B/A) + f(B % A, A);
}

int main() {
    long long N, X;
    cin >> N >> X;

    cout << N + f(X, N - X) << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main(){
  string s;
  int k;
  cin>>k>>s;
  if(s.size()>k){
    s.erase(k,s.size()-k);
    s=s+"...";
  }
  cout<<s;
}


Measured memory_bytes: 3632
#include <cstdio>
using namespace std;
const long long NR=20;
char s[NR],t[NR],u[NR];
long long a,b;
bool equal(char s1[],char s2[])
{
	long long l=0;
	while(s1[l])
	{
		l++;
	}
	for(long long i=0;i<=l;i++)
	{
		if(s2[i]!=s1[i])
		{
			return false;
		}
	}
	return true;
}
int main()
{
	scanf("%s%s%lld%lld\n%s",s,t,&a,&b,u);
	if(equal(s,u))
	{
		a--;
	}
	else
	{
		b--;
	}
	printf("%lld %lld",a,b);
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
int a[101],b[10];
int main(){
  int n,c,i;

  for(i=0;i<101;i++){
    a[i]=-1;
  }
  for(i=0;i<9;i++){
	   scanf("%d",&n);
	    a[n]=i;
  }
  scanf("%d",&n);
  for(i=0;i<n;i++){
  	scanf("%d",&c);
  	b[a[c]]=1;
  }
  if((b[0]*b[1]*b[2])==1||(b[3]*b[4]*b[5])==1||(b[6]*b[7]*b[8])==1||(b[0]*b[3]*b[6])==1||(b[1]*b[4]*b[7])==1||(b[2]*b[5]*b[8])==1||(b[0]*b[4]*b[8])==1||(b[2]*b[4]*b[6])==1){
  	printf("Yes");
  }else{
  	printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define pi 3.141592653589793238
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


  

long long power(long long a, long long b,long long mod) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a %mod;
        a = a * a %mod;
        b >>= 1;
    }
    return res;
}


signed main()
{

ios_base::sync_with_stdio(false);
cin.tie(NULL);  
cout.tie(0);   

#ifndef ONLINE_JUDGE
    if(fopen("INPUT.txt","r"))
    {
    freopen ("INPUT.txt" , "r" , stdin);
    freopen ("OUTPUT.txt" , "w" , stdout);
    }
#endif      

    int n;
    cin>>n;
    string str="ACL";
    string ans="";
    for(int i=0;i<n;i++)
        ans+=str;
    cout<<ans;

}

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

int main() {
    long long a, b, n;
    cin >> a >> b >> n;

    /*
    for(long long x = 0; x <= n; x++) {
        long long res = (a * x / b) - a * (x / b);
        cout << x << ": " << res << endl;
    }
     */
    
     

    // cout << "==" << endl;

    long long x;
    if(n < b) x = n;
    else x = b - 1;

    long long ans = (a * x / b) - a * (x / b);
    /*
    long long max = 0;
    for(int i = 0; i * i < n; i++) {
        long long res = (a * i / b) - a * (i / b);
        if(max < res) max = res;
    }
     */

    // long long res = (a * x / b) - a * (x / b);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3596
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!$BDs=P;~$K%3%a%s%H%"%&%H(B!!
#ifdef DEBUG_
#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

    template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int mod = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);
const long double PI = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899;
int dx[] = {0,0,-1,1};
int dy[] = {-1,1,0,0};


signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N,K; cin >> N >> K;
    VI A(N);
    REP(i,N) cin >> A[i];
    sort(A.begin(), A.end());
    int ans = 0;
    REP(i,K){
        ans += A[i];
    }
    cout << ans << endl;

}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
/*	#include <boost/math/common_factor.hpp>  boost::math::lcm(10,20) ---> use it to find lcm. fill_n(&ans[0][0],n*m,0);*/
using namespace std;
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
typedef long long ll;
// #define int long long 
#define PI pair<int , int >
#define mpr make_pair
#define ff first
#define ss second
#define endl "\n"
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define FO(i,a,b) for(int i = (int)a;i < (int)b;++i)
#define FE(i,a,b) for(int i = (int)a;i <= (int)b;++i)
const int MOD = 1e9+7;
const int MAXN = 1e5+3;
const int inf = 2e9;
int max(int a,int b){	if(a > b)return a; else return b; }
int min(int a, int b){	if(a < b)return a; else return b; }
int dx[] = {1,-1,0,0};
int dy[] = {0,0,-1,1};
bool cmp(PI p1,PI p2){
	if(p1.ff < p2.ff)return true;	// You should not be writing p1.ss <= p2.ss !!!
	else if(p1.ff == p2.ff){ if(p1.ss < p2.ss)return true; return false; }
	return false;
}
/*		1. Take all the inputs
		4. Whenever you do multiplication and division in the same line, beware.
*/
void solve(){
	// int main  or  int32_t main ...
	int n,k;
	cin >> n >> k;
	int h[n];
	FO(i,0,n)cin >> h[i];
	
	int ans[n];
	ans[0] = 0;
	ans[1] = abs(h[1] - h[0]);
	FO(i,2,n){
		//ans[i] = min( abs(h[i]-h[i-2]) + ans[i-2],abs(h[i] - h[i-1]) + ans[i-1]);
		int temp = INT_MAX;
		for(int j = i-1;j>=0 and j>=(i-k);j--){
			temp = min(temp, abs(h[i] - h[j])+ans[j]);
		}
		if(temp != INT_MAX)ans[i] = temp;
	}
	cout << ans[n-1] << endl;
}
/*	memset() can be used to set all values as 0 or -1 for integer data types.*/

int main(){
	IO;
	#ifndef ONLINE_JUDGE
	//freopen("input.txt", "r", stdin);
	#endif // ONLINE_JUDGE
	// std::cout << std::setprecision(15); std::cout << std::fixed;
	int t; t = 1;
	// cin >> t;
	while(t--){ solve(); }
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
#include <numeric>
#include <queue>
#include <set>

#define REP(i, n) for (ll i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
#define BIG 1000000007

int main(int argc, char const *argv[])
{
  string l;
  cin >> l;
  vector<ll> dp1(l.size() + 1, 0);
  vector<ll> dp2(l.size() + 1, 0);
  dp1[1] = 1;
  dp2[1] = 2;
  if (l == "1") {
    cout << 3 << endl;
    return 0;
  }
  for (ll i = 2; i <= l.size(); i++)
  {
    if (l[i-1] == '0')
    {
      dp1[i] = (dp1[i - 1] * 3) % BIG;
      dp2[i] = (dp2[i - 1]) % BIG;
    }
    else
    {
      dp1[i] = (dp1[i - 1] * 3) % BIG + (dp2[i - 1]) % BIG;
      dp2[i] = (dp2[i - 1] * 2) % BIG;
    }
  }
  cout << (dp1[l.size()] + dp2[l.size()]) % BIG << endl;

  return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <bitset>
#include <fstream>
using namespace std;
typedef long long ll;

const int MAX_R = 20;

int dp[MAX_R][MAX_R];

int main()
{
	int A, B, N;
	while(cin>>A>>B && (A || B)){
		cin>>N;
		for(int a = 0; a < A; a++) for(int b = 0; b < B; b++) dp[a][b] = 0;
		for(int i = 0; i < N; i++){
			int x, y;
			cin>>x>>y;
			dp[x-1][y-1] = -1;
		}
		for(int a = 0; a < A; a++){
			for(int b = 0; b < B; b++){
				if(dp[a][b] == -1)	dp[a][b] = 0;
				else if(a>0&&b>0)	dp[a][b] = dp[a-1][b] + dp[a][b-1];
				else if(a>0)		dp[a][b] = dp[a-1][b];
				else if(b>0)		dp[a][b] = dp[a][b-1];
				else				dp[a][b] = 1;
			}
		}
		cout<<dp[A-1][B-1]<<endl;
	}
}

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

const int MOD = 1000000007;

//long long
using ll = long long;

//出力系
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
 
// begin() end()
#define all(x) (x).begin(),(x).end()

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

//最大公約数 
unsigned gcd(unsigned a, unsigned b) {
  if(a < b) return gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}

 int main(){
int K, X;
cin >> K >> X;

int left = X - (K - 1);
int right = X + (K - 1);

for(int i = left; i <= right; i++){
  print(i);
}

 }

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

//_____
typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> Vi;
typedef vector<Pii> Vp;
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
#define rep(i,n) for(int i=0; i<(n); ++i)
#define reps(i,f,n) for(int i=(f); i<=(n); ++i)
#define show(x) cerr << #x << ':' << x << endl
#define outl(x) cout << x << '\n';
#define INF (1 << 29)
#define FAST() cin.tie(0), ios::sync_with_stdio(false)
inline int chmax(int &a, int b){return b>a ? a=b,1 : 0;}
inline int chmin(int &a, int b){return b<a ? a=b,1 : 0;}
//_______

string S;

main(){
  FAST();
  cin >> S;
  int l = S.length()/2 - 1;

  while(l > 0){
    if(S.substr(0,l) == S.substr(l,l))break;
    --l;
  }
  outl(l*2);

}



Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        println!(concat!($(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
      n: usize,
      m: usize,
      q: usize,
      lrs: [[usize; 2]; m],
      pqs: [[usize; 2]; q],
    }
    let mut ss = vec![vec![0; n+1]; n+1];
    for i in 0..m {
        let l = lrs[i][0];
        let r = lrs[i][1];
        ss[l][r] += 1;
    }
    for l in 1..n+1 {
        for r in 1..n+1 {
            ss[l][r] = ss[l][r-1] + ss[l][r];
        }
    }
    for i in 0..q {
        let p = pqs[i][0];
        let q = pqs[i][1];

        let mut ans = 0;
        for l in p..q+1 {
            ans += ss[l][q] - ss[l][p-1];
        }
        println!("{}", ans);
    }
}


Measured memory_bytes: 19324
import java.util.HashMap;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		HashMap<Integer, Integer> map = new HashMap<>();
		boolean isFail = false;
		for (int i = 1; i <= n; i++) {
			int distance = sc.nextInt();
			if (distance == 0 && i != 1) {
				isFail = true;
			}
			if (!map.containsKey(distance)) {
				map.put(distance, 0);
			}
			map.put(distance, map.get(distance) + 1);
		}

		if (isFail) {
			System.out.println(0);
			return;
		}

		int beforeDist = -1;
		int beforeNode = 1;
		long ans = 1;
		long cons = 998244353;

		for (int dist : map.keySet().stream().sorted().collect(Collectors.toList())) {
			if (dist != beforeDist + 1) {
				System.out.println(0);
				return;
			}
			if (dist == 0) {
				if (map.get(dist) != 1) {
					System.out.println(0);
					return;
				}
				beforeDist = 0;
				continue;
			}
			int nodes = map.get(dist);
			for (int i = 1; i <= nodes; i++) {
				ans = ans * beforeNode % cons;
			}
			beforeNode = nodes;
			beforeDist++;
		}
		System.out.println(ans);
	}
}


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

typedef long long ll;

string s;
int w;

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> s >> w;
	for (int i = 0; i < s.length() ; i += w)
		cout << s[i];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int k;
	cin >> k;
	int a,b;
	cin >> a >> b;
	int flag = 0;
	for(int i = a; i <= b; i++)
	{
		if(i % k == 0)
		{
			flag = 1;
			break;
		}
	}
	if(flag)
	cout << "OK" << endl;
	else cout << "NG" <<  endl;
	return 0;
}

Measured memory_bytes: 3652
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In,' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var R = cin.ReadInt;

            if(N >= 10){
                WriteLine(R);
            }else{
                WriteLine(R+100 * (10-N));
            }
            
        }
    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream,char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if(inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for(int i = 0;i < tmp.Length;i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }

        
        public string ReadLine { get { return _stream.ReadLine(); }}
        public int ReadInt { get { return int.Parse(Read); }}
        public long ReadLong { get { return long.Parse(Read); }}
        public double ReadDouble { get { return double.Parse(Read); }}
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret;}
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret;}
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret;}
    }

}

Measured memory_bytes: 13268
//
// Created by moono on 2018/10/27.
//

#include <iostream>
#include <string>
#include <cmath>
using namespace std;


int main() {
    string a, b;
    cin >> a >> b;

    string str = a + b;
    int s = stoi(str);
    int s2 = sqrt(s);
    if(s == s2*s2){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }




  return 0;
}

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

int main()
{
  string s;
  cin >> s;
  int count1 = 0, count2 = 0;
  for (int i = 0; i < 4; i++)
  {
    for (int j = i + 1; j < 4; j++)
    {
      if(s[i] == s[j]) count1++;
    }
  }
  for (int i = 0; i < 4; i++)
  {
    for (int j = i + 1; j < 4; j++)
    {
      if(s[i] == s[j]) count2++;
    }
  }
  if(count1 == 2 && count2 == 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

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

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n;
    m = n;
    int sum = 0;
    while (n > 0) {
      sum += n % 10;
      n /= 10;
    }
    if (m % sum == 0) {
      cout << "Yes" << '\n';
    } else {
      cout << "No" << '\n';
    }

    return 0;
}


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





int fun(int arr[], int n)
{
    sort(arr,arr+n);
    int count = 0;


    for (int i = 0; i < n - 2; ++i)
    {

        int k = i + 2;
        int j;
        for (j = i + 1; j < n; ++j)
        {


            while (k < n && arr[i] + arr[j] > arr[k])
            ++k;


            if(k > j)
            count += k - j - 1;
        }
    }

    return count;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n;
    cin>>n;
    int i,l[n];
    for(i=0;i<n;i++)
    cin>>l[i];
    cout<<fun(l,n)<<endl;
    return 0;
}


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

using ll = long long;
using P = pair<ll, ll>;

const ll MOD = 1e9+7;
// const ll MOD = 998244353;
const ll INF = 1ll<<60;

#define FOR(i,a,b) for (ll i=(a);i<(ll)(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

ll A, B, C, D;
map<ll, ll> ma;

ll solve_sub(ll n)
{
	if (n == 0) return 0;
	if (ma.count(n)) return ma[n];
	ll res;
	if (n <= 3e9) res = n*D;
	else res = 1e18;

	for (ll i = -1; i <= 1; ++i)
	{
		ll x = n + i;
		if (x < 0 || x & 1) continue;
		ll y = x/2;
		if (y < n)
			res = min(res, abs(i)*D + A + solve_sub(y));
	}

	for (ll i = -2; i <= 2; ++i)
	{
		ll x = n + i;
		if (x < 0 || x % 3 != 0) continue;
		ll y = x/3;
		if (y < n)
			res = min(res, abs(i)*D + B + solve_sub(y));
	}

	for (ll i = -4; i <= 4; ++i)
	{
		ll x = n + i;
		if (x < 0 || x % 5 != 0) continue;
		ll y = x/5;
		if (y < n)
			res = min(res, abs(i)*D + C + solve_sub(y));
	}

	return ma[n] = res;
}

ll solve()
{
	ll N;
	cin >> N >> A >> B >> C >> D;
	ma.clear();
	return solve_sub(N);
}

int main(int argc, char **argv)
{
	ll T; cin >> T;
	REP(i, T)
	{
		std::cout << solve() << std::endl;
	}
}


Measured memory_bytes: 4376
c = input()
dictionary = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

for i in range(len(dictionary)) :
    if dictionary[i] == c :
        print(dictionary[i+1])
        break


Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int ans[1000];
int main() {
 int n,i,a,b,c;
 cin >> n;
 for (i=0;i<n;i++) {
	 cin >> a >> b >> c;
	 if (a*a==b*b+c*c || b*b==a*a+c*c || c*c==a*a+b*b) ans[i]=1;
 }
 for (i=0;i<n;i++) if (ans[i]==0) cout << "NO" << endl; else cout << "YES" << endl;
 return 0;
}

Measured memory_bytes: 1156
using namespace std;
#include <cstdio>
#include <cstring>
#include <algorithm>
#define N 55
#define mo 1000000007
#define ll long long
int n;
ll C[N][N],f[N][N];
int main(){
	scanf("%d",&n);
	for (int i=0;i<=n;++i){
		C[i][0]=1;
		for (int j=1;j<=i;++j)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	}
	f[1][0]=f[1][1]=n;
	for (int i=1;i<n;++i)
		for (int j=0;j<=i;++j)
			for (int k=(j==0?2:j);i+k<=n;k+=2){
				int t=(k+j)/2;
				for (int x=0;x<=k;++x)
					(f[i+k][abs(x-t)]+=f[i][j]*C[n-i][k]%mo*C[k][x])%=mo;
			}
	printf("%lld\n",f[n][0]);
	return 0;
}

Measured memory_bytes: 3240
from collections import defaultdict,deque
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl(): return list(map(int, input().split()))
def inpl_s(): return list(input().split())

N,K = inpl()
aa  = inpl()

SUM_aa = [0]
ABS_aa = [0]
tmp1 = tmp2 = 0
for a in aa:
	tmp1 += a
	tmp2 += max(a,0)
	SUM_aa.append(tmp1)
	ABS_aa.append(tmp2)

SUM = ABS_aa[N]
ans = 0
for i in range(N-K+1):
	left = ABS_aa[i]
	right = SUM - ABS_aa[i+K]
	mid = SUM_aa[i+K]-SUM_aa[i]
	ans = max(ans,left+right+max(0,mid))

print(ans)


Measured memory_bytes: 18268