akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int n,a[305];
ll dp[900005];
ll dp2[900005];
ll modpow(ll x,ll n){
	ll res=1;
	while(n>0){
		if(n&1) res=res*x%mod;
		x=x*x%mod;
		n>>=1;
	}
	return res;
}
int main(){
	cin>>n;
	int s = 0;
	repn(i,n) {cin>>a[i];s+=a[i];}
	dp[0] = 1;
	dp2[0] = 1;
	ll hf = (mod+1)/2;
	repn(i,n){
		for(int j=300*300+2;j>=0;j--){
			dp[j+a[i]] += dp[j]*hf%mod;
			if(dp[j+a[i]] >= mod) dp[j+a[i]]-=mod;
			dp2[j+a[i]] += dp2[j];
			if(dp2[j+a[i]] >= mod) dp2[j+a[i]]-=mod;
		}
	}
	ll t = 1;
	rep(i,n) t = t*2LL%mod;
	ll ans = 1;
	rep(i,n) ans = ans*3LL%mod;
	for(int i=(s+1)/2;i<=s;i++){
		ans -= dp[i]*t%mod*3LL%mod;
	}
	if(s%2==0){
	    ans += dp2[s/2]*3LL%mod;
	}
	cout<<(ans%mod+mod)%mod<<endl;
}

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

using namespace std;

int64_t solve(const std::vector<int>& as) {
  int const n = as.size();
  int64_t x = as.front();
  int64_t y = as.back();
  if (n == 2) {
    return abs(x - y);
  }
  for (int i = 1; i < n - 1; i++) {
    y += as[i];
  }
  int64_t ret = abs(x - y);
  for (int i = 1; i < n - 1; i++) {
    int const a = as[i];
    x += a;
    y -= a;
    ret = std::min(abs(x - y), ret);
  }
  return ret;
}

int main() {
  int n;
  std::cin >> n;
  std::vector<int> as(n);
  for (auto& a : as) {
    std::cin >> a;
  }
  std::cout << solve(as) << std::endl;
  return 0;
}


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

#define PI 3.1415926535

int main(void){
	double x=0.0,y=0.0,d,a,ang=0.0;
	int xint,yint;
	scanf("%lf,%lf",&d,&a);
	while(d!=0.0 || a!=0.0){
		x += d*sin(ang);
		y += d*cos(ang);
		a *= (PI/180);
		ang += a;
		scanf("%lf,%lf",&d,&a);
	}
	xint = x;
	yint = y;
	cout << xint << endl << yint << endl;
	return 0;
}

Measured memory_bytes: 3348
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back

const int M = 1000000007;

int32_t main(){
	#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
	#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s;
    cin>>s;
    int n =  s.length();
    if(s[n-1]=='s'){
    	cout<<s<<"es";
    }
    else{
    	cout<<s<<"s";
    }
    return 0;
}

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

int main() {
  int x, y, z; cin >> x >> y >> z;
  if (x < y + z*2) cout << 0 << endl;
  else {
    x -= y + z*2;
    cout << 1 + x / (y+z) << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    vvl a(3,vl(3,0));
  	cin>>a;
  	ll n;
  	cin>>n;
  	vvl v(3,vl(3,0));
  
  	rep(i,n){
      ll t;
      cin>>t;
      rep(j,3)rep(k,3)if(a[j][k]==t)v[j][k]=1;
    }

  	bool ans=false;
  	rep(i,3)if(v[i][0]+v[i][1]+v[i][2]==3)ans=true;
  	rep(i,3)if(v[0][i]+v[1][i]+v[2][i]==3)ans=true;
    if(v[0][0]+v[1][1]+v[2][2]==3)ans=true;
    if(v[0][2]+v[1][1]+v[2][0]==3)ans=true;
	Yn(ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
#include<complex>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tuple<int,int> tii;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pb push_back
#define mt make_tuple
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-8;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV int(1e9+7)
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}
inline ll lcm(ll d1, ll d2){return d1 / __gcd(d1, d2) * d2;}

 /* Coding Space*/
vector<bool> used(200002,0);
int main(){
  int n,x; cin >> n >> x;
  if(x == 1 || x == 2*n-1) {cout << "No" << endl; return 0;}
  if(n == 2 && x == 2){cout<<"Yes\n1\n2\n3\n";return 0;}
  cout << "Yes" << endl;
  vi cent = {x-1,x,x+1,x-2};
  if(x == 2)
    cent = {x+1,x,x-1,x+2};
  rep(i,4) used[cent[i]] = 1;
  int index = 1;
  rep(i,2*n-4){
    //SHOW(used[index],index);
    if(i == n-2){
      rep(j,4) cout << cent[j] << endl;
      continue;
    }
    
    if(used[index] == 1){
      index++,i--; continue;
    }
    if(used[index] == 0){
      cout << index << endl;
      used[index] = 1;
      index++;
      continue;
    }
  }
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<array>
#include<vector>
#include<functional>
#include<unordered_map>
#include<map>
#include<numeric>
#include<limits>
#include<utility>
#include<queue>
#include<random>
using namespace std;

int main(){
   int a,b;
    
    cin >> a;
    cin >> b;
    
    if(a == 1 || b == 1){
    
    if(a == b){cout << "Draw"<<endl;}
        else if(a != 1){cout << "Bob"<<endl;}
        else{cout << "Alice"<<endl;}
        
    }
    else{
    if(a==b){
    cout<<"Draw"<<endl;}
    else if(a>b){
    cout<<"Alice"<<endl;
    }
    else{cout<<"Bob"<<endl;}
    
    }

    return 0;

}

Measured memory_bytes: 256
main=readLn>>=print.(\n->(if n<6 then n else ((mod n 3)+(f (quot n 3)))))
 where f n = if (even n) then (g (quot n 2) 0) else (g ((quot n 2)-1) 1)
       g a b = if a<3 then (h a b) else (min (h a b) (g (a-3) (b+2)))
       h a b = (i a)+(j b)
       i a = sum[mod(quot a (6^x))6|x<-[0..5]]
       j b = sum[mod(quot b (9^x))9|x<-[0..4]]

Measured memory_bytes: 1148
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

template <typename Monoid>
struct SegmentTree
{

  int sz;
  vector<Monoid> seg;

  const Monoid M1;

  Monoid f(Monoid a, Monoid b)
  {
    return min(a, b);
  }

  SegmentTree(int n, const Monoid &M1) : M1(M1)
  {
    sz = 1;
    while (sz < n)
      sz <<= 1;
    seg.assign(2 * sz, M1);
  }

  void set(int k, const Monoid &x)
  {
    seg[k + sz] = x;
  }

  void build()
  {
    for (int k = sz - 1; k > 0; k--)
    {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  void update(int k, const Monoid &x)
  {
    k += sz;
    seg[k] = x;
    while (k >>= 1)
    {
      seg[k] = f(seg[2 * k + 0], seg[2 * k + 1]);
    }
  }

  Monoid query(int a, int b)
  {
    Monoid L = M1, R = M1;
    for (a += sz, b += sz; a < b; a >>= 1, b >>= 1)
    {
      if (a & 1)
        L = f(L, seg[a++]);
      if (b & 1)
        R = f(seg[--b], R);
    }
    return f(L, R);
  }

  Monoid operator[](const int &k) const
  {
    return seg[k + sz];
  }
};

int main()
{
  i64 n;
  cin >> n;
  vector<i64> edge[n], c(n), cnt(n);
  for (i64 i = 0; i < n - 1; i++)
  {
    i64 a, b;
    cin >> a >> b;
    a--;
    b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
    cnt[a]++;
    cnt[b]++;
  }
  for (i64 i = 0; i < n; i++)
    cin >> c[i];
  SegmentTree<pair<i64, i64>> seg(n, {1e9, 0});
  for (int i = 0; i < n; i++)
    seg.update(i, {cnt[i], i});
  i64 sum = 0;
  vector<i64> ans(n);
  sort(c.begin(), c.end());
  for (i64 i = 0; i < n; i++)
  {
    pair<i64, i64> p = seg.query(0, n);
    sum += p.first * c[i];
    ans[p.second] = c[i];
    seg.update(p.second, {1e9, p.second});
    cnt[p.second] = 1e9;
    for (i64 t : edge[p.second])
    {
      cnt[t]--;
      seg.update(t, {cnt[t], t});
    }
  }
  cout << sum << endl;
  for (i64 i = 0; i < n; i++)
    cout << ans[i] << (i + 1 == n ? "\n" : " ");
  return 0;
}


Measured memory_bytes: 1664
def insert_sort(A, N):
    print(*A, sep=' ')
    for i in range(1, N):
        tmp = A[i]
        j = i-1
        while j>=0 and A[j]>tmp:
            A[j+1] = A[j]
            j -= 1
            A[j+1] = tmp
        print(*A, sep=' ')

N = int(input())
A = list(map(int, input().split()))

insert_sort(A, N)


Measured memory_bytes: 5980
#!/usr/bin python3
# -*- coding: utf-8 -*-

from collections import deque
def main():
    N = int(input())
    Node = [set() for _ in range(N)]
    Edge = {}
    for i in range(N-1):
        a , b = map(int, input().split())
        a-=1
        b-=1
        if b<a:
            a, b = b, a
        Edge[(a, b)]=i
        Node[a].add(b)
        Node[b].add(a)

    K = 0
    for i, x in enumerate(Node):
        if len(x)>K:
            K = len(x)
            top = i


    q = deque()
    seen = [False]*(N-1)
    used = [set() for _ in range(N)]
    q.append(top)
    while len(q)>0:
        cur = q.popleft()
        col = 1
        for i in Node[cur]:
            if cur>i:
                ed = (i, cur)
            else:
                ed = (cur, i)
            if seen[Edge[ed]]==False:
                while col in used[cur] or col in used[i]:
                    col+=1
                seen[Edge[ed]] = col
                used[cur].add(col)
                used[i].add(col)
                q.append(i)

    print(K)
    print('\n'.join(map(str, seen)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 91412
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[200000], b[200000];
vector<int>c;
signed main() {
	cin >> n;
	int sum = 0, ans = 0;
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < n; i++) {
		cin >> b[i];
		if (a[i] > b[i]) {
			c.push_back(a[i] - b[i]);
		}
		else if (a[i] < b[i]) {
			sum += b[i] - a[i];
			ans++;
		}
	}
	sort(all(c));
	reverse(all(c));
	for (int i = 0; sum > 0 && i < c.size(); i++) {
		sum -= c[i];
		ans++;
		if (sum <= 0) break;
	}
	if (sum > 0) {
		cout << -1 << endl;
	}
	else {
		cout << ans << endl;
	}
}

Measured memory_bytes: 2296
#include <iostream>
#define int long long
#define MOD 1000000007
using namespace std;
int N, M;
int mod_times(int a, int b){
    return (a*b)%MOD;
}
int pow(int n, int p){
    if(p==1){
        return n;
    }else if(p%2 == 0){
        int n2 = pow(n, p/2);
        return mod_times(n2, n2);
    }else{
        return mod_times(pow(n, p-1), n);
    }
}
signed main(){
    while(cin >> N >> M){
        cout << pow(N, M) << endl;
    }
}


Measured memory_bytes: 3120
#include <iostream>
#include <vector>


using namespace std;


int main(){
  long long N, Q, ans=0;
  cin >> N;
  vector<long long> A(N), P(1e5+100);
  for (int i=0; i<N; ++i){
    cin >> A.at(i);
    ans += A.at(i);
    ++P.at(A.at(i));
  }
  cin >> Q;
  for(int i=0; i<Q; ++i) {
    long long b, c;
    cin >> b >> c;
    ans -= b * P.at(b);
    ans += c * P.at(b);
    P.at(c) += P.at(b);
    P.at(b) = 0;
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 4744
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin>>s;
  int len=s.size();
  int a=0,b=0;
  for(int i=0;i<len;i++){
   // cout<<s[i]<<endl;
    if(s[i]!=s[len-i-1]){
      a=1;
    }
  }if(a==0){
    if(len%4==1){
      for(int i=0;i<(len-1)/4;i++){
        if(s[i]!=s[len/2-i-1]){
          b=1;
        }
      }
    }else for(int i=0;i<(len+1)/4;i++){
      if(s[i]!=s[len/2-i-1]){
          b=1;
        }
    }
  }if(a==0&&b==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
// cout<<a<<b<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int i,j;
	for (i = 0; i < 9; i++)
	{
		for (j = 0; j < 9; j++)
		{
			cout << (i + 1) << "x" << (j + 1) <<"="<<((i + 1) * (j + 1))<<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1112
require "set"
n,k = gets.chomp.split(" ").map(&:to_i)
p_arr = gets.chomp.split(" ").map(&:to_i)
c_arr = gets.chomp.split(" ").map(&:to_i)

# 添字調整
p_arr.unshift(0)
c_arr.unshift(0)

cycle_arr = []

set = Set.new
# 閉路がいくつかあるのでそれを求める
(1..n).each do |i|
  start_index = i
  # 重複してたどるのを避ける
  next if set.include?(start_index)
  index = start_index
  in_cycle_arr = []
  sum = 0
  while true do
    # 問題文では移動先のスコアを計上するとあるが, 対象のグラフは閉路なので移動元のスコアで計上しても大丈夫
    score = c_arr[index]
    in_cycle_arr << score
    sum += score
    # 通った印づけ
    set << index
    # 次のindex
    index = p_arr[index]
    # ループ判定
    break if index == start_index
  end
  cycle_arr << [in_cycle_arr, sum]
end

# 負の無限大(c_iの最小値で良い)
max = (10 ** 9) * (-1)

# 各閉路の各indexで試す
cycle_arr.each do |(cycle, sum)|
  cycle.each_with_index do |c, i|
    c_length = cycle.length
    # sumが正ならなるべく繰り返した方がお得, 負なら繰り返さないほうがお得(0はどっちでもOK)
    if sum > 0
      loop_num = k / c_length
      r = k % c_length 
      if r == 0
        loop_num -= 1
        r += c_length
      end
      in_sum = sum * loop_num
      #max = in_sum if in_sum > max
      t = r
    else
      in_sum = 0
      t = c_length
    end
    t.times do |j|
      in_sum += cycle[(i + j) % c_length]
      max = in_sum if in_sum > max
    end
  end
end

puts max


Measured memory_bytes: 15448
#include <cstring>
#include <queue>
#include <algorithm>
#include <stdlib.h>
#include <iostream>
using namespace std;
int main()
{
    int n;
    char x[10010];
    cin>>n>>x;
    int l=strlen(x);
    for(int i=0;i<l;i++)
    {
        if(x[i]+n>'Z')
            x[i]-=26;
        x[i]+=n;
        cout<<x[i];
    }
return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int min(int a,int b)
{ return fabs(a-b);
}
int main()
{ int w,a,b;
  while((scanf("%d %d %d",&w,&a,&b))==3)
     {  int sum,t;
        if((b>=a&&b<=a+w)||b+w>=a&&b+w<=a+w)
        printf("0\n");
        else 
        {
        sum=min(a,b+w);
        sum=sum<min(a+w,b)? sum:min(a+w,b);
        printf("%d\n",sum);  
       }
	 }
	 return 0;
}


Measured memory_bytes: 128
open System

let [|N; M|] = stdin.ReadLine().Split(' ') |> Array.map int
let KA = [| for i in 1..N -> (stdin.ReadLine().Split(' ') |> Array.map int).[1..] |> Set.ofArray|]

let f a = Array.reduce (fun l h -> Set.intersect l h) a |> Set.count

f KA |> printf "%d"


Measured memory_bytes: 13020
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
const int mod=10007;

int main() {
  int N;
  cin>>N;
  vector<int>L(N);
  for(int i=0;i<N;i++){
    cin>>L[i];
  }
  sort(L.begin(),L.end());
 
  int cnt=0;
  for(int i=0;i<N-1;i++){
    for(int j=i+1;j<N;j++){
      int x=L[i]+L[j];
      int r=lower_bound(L.begin(),L.end(),x)-L.begin();
      cnt+=r-1-j;
    }
  }
  cout<<cnt<<endl;
  return 0;  
}

Measured memory_bytes: 3612
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <functional>
#include <map>
#include <queue>
#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
using namespace std;
using ll = long long;
ll MOD = 1e9+7;


int main(int argc, const char * argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    cin >> s;
    if(s.size() == 3){
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;

namespace mp = boost::multiprecision;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

const int MAX_N = 405;
int N;
vector<int> A;

int sumA[MAX_N];
int dp[MAX_N][MAX_N];

int solve(int l, int r) 
{
  if(dp[l][r] != -1) {
    return dp[l][r];
  }

  if(r-l==1) {
    return dp[l][r] = 0;
  }

  int ret = INF_LL_MAX;

  for(int mid = l+1; mid < r; mid++) {
    int tmp = solve(l,mid) + solve(mid,r);
    ret = min(ret, tmp + sumA[mid]-sumA[l]+sumA[r]-sumA[mid]);
  }

  return dp[l][r] = ret;
}

signed main()
{
  cin >> N;
  REP(n,N) {
    int a; cin >> a; A.push_back(a);
    sumA[n+1] = sumA[n] + a;
  }

  memset(dp, -1, sizeof(dp));
  cout << solve(0, N) << endl;

  return 0;
}

Measured memory_bytes: 1536
n=int(input())
a=[]
b=[0,0,0,0]
for i in range(n):
    a.append(input())

for i in range(n):
    if a[i]=='AC':
        b[0]+=1
    elif a[i]=='WA':
        b[1]+=1
    elif a[i]=='TLE':
        b[2]+=1
    else:
        b[3]+=1
print('AC x '+str(b[0]))
print('WA x '+str(b[1]))
print('TLE x '+str(b[2]))
print('RE x '+str(b[3]))
    

Measured memory_bytes: 16324
from copy import copy, deepcopy
from collections import Counter
from math import sqrt, floor, factorial
from itertools import permutations, combinations, combinations_with_replacement
from operator import mul
from functools import reduce
import bisect

MOD = 10**9 + 7
INF = float('inf')

N, K = list(map(int, input().split()))

A = list(map(int, input().split()))

A = [A[i]-1 for i in range(len(A))]

mem = [0]*N
mem2 = [0]*N

idx = 0
count1 = 0
while True:
    mem[idx] += 1
    if mem[idx] == 2:
        break
    count1 += 1
    idx = A[idx]


idx2 = idx
count2 = 0

count2 += 1
idx2 = A[idx2]

while True:
    if idx2 == idx:
        break
    count2 += 1
    idx2 = A[idx2]

tmp = count1 - count2

if tmp >= K:
    ans = 0
    for _ in range(K):
        ans = A[ans]
else:
    e = (K - tmp) % count2 + tmp
    ans = 0
    for _ in range(e):
        ans = A[ans]

print(ans+1)


Measured memory_bytes: 32252
#include <stdio.h>

int main (void) {
  
  int N, K;
  
  scanf("%d %d", &N, &K);
  
  int l[N];
  
  int i, j, d;
  
  for (i=0; i<N; i++){
    scanf("%d" , &l[i]);
  }
  
  for (i=0; i<N; i++){
   for (j=i+1; j<N; j++){
     if (l[i]<l[j]) {
       d = l[i];
       l[i] = l[j];
       l[j] = d;
     }
   }
  }
  
  int sum = 0;
  
  for (i=0; i<K; i++){
   sum = sum + l[i];
  }
  
  printf("%d", sum);
  
  return 0;
}

Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const int MAX = 510000;

int main() {
  vector<int> N(4);
  for (int i=0; i<4; i++) cin >> N[i];
  sort(N.begin(), N.end());
  bool can = false;
  do {
    if (N[0]==1&&N[1]==9&&N[2]==7&&N[3]==4) {
      can = true;
      break;
    }
  } while (next_permutation(N.begin(), N.end()));
  if (can) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
const char nl = '\n';
using namespace std;
typedef long long ll;
typedef long double ld;
typedef complex<ld> pt;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const int N = 105, W = 1e5+10;
inline char get() {
	static char buf[10000], *S = buf, *T = buf;
	if (S == T) {
		T = (S = buf) + fread(buf, 1, 10000, stdin);
		if (S == T) return EOF;
	}
	return *S++;
}
inline void read(int &x) {
	static char c; x = 0; int sgn = 0;
	for (c = get(); c < '0' || c > '9'; c = get()) if (c == '-') sgn = 1;
	for (; c >= '0' && c <= '9'; c = get()) x = x * 10 + c - '0';
	if (sgn) x = -x;
}

int n, totw;
ll dp[W];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  read(n); read(totw);
  for (int i = 0; i < n; i++) {
    int w, v; read(w); read(v);
    for (int j = totw; j >= w; j--) {
      dp[j] = max(dp[j], dp[j-w] + v);
    }
  }
  cout << *max_element(dp, dp + W) << nl;
  return 0;
}


Measured memory_bytes: 1024
N = int(input())
P = [int(i) - 1 for i in input().split()]

count = 0
for i in range(N - 1):
    if P[i] == i:
        P[i], P[i + 1] = P[i + 1], P[i]
        count += 1
if P[N - 1] == N - 1:
    count += 1

print(count)

Measured memory_bytes: 13880
A,B=map(int,input().split())
count=0
for i in range(A,B+1):
  #print(i)
  str_i=str(i)
  for j in range(len(str_i)):
    #print(str_i[j],str_i[-j-1])
    if(str_i[j]!=str_i[-j-1]):
      break
    if(j>(len(str_i)//2+1)):
      #print(i)
      count+=1
print(count)

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

int main(){
  ll n; cin >> n;
  vector<ll> c(n+10,0);
  vector<ll> s(n+10,0);
  vector<ll> f(n+10,0);
  for(ll i = 0; i < n-1; i++){
    cin >> c[i] >> s[i] >> f[i];
  }

  for(int i = 0; i < n-1; i++){
    ll time = c[i] + s[i];
    for(int j = i+1; j < n-1; j++){
      if(time < s[j]){time = c[j] + s[j];}
      else if((time - s[j]) % f[j] == 0){time += c[j];}
      else{
        time += f[j] - ((time - s[j]) % f[j]);
        time += c[j];
      }
    }
    cout << time << endl;
  }
  cout << 0 << endl;
}

Measured memory_bytes: 256
//Jai Bhole Ki
#include <bits/stdc++.h>
using namespace std;
#define fast static int fastline = []() { std::ios::sync_with_stdio(false); cin.tie(NULL); return 0; }();
#define ll long long
#define LL unsigned ll
#define pb push_back
#define pi pair<ll,ll>
#define debug(x) cout<<x<<"\n";
#define debug cout<<"debugged\n";
#define minval -2e9
#define maxval 2e9
long double PI =3.14159265358979323846;
 
const ll M=1e9+7;
const ll inf=1e18;
const ll ms=2e5+5;
fast;
ll ans;
ll n,k,b;
void solve()
{
    string s;cin>>s;
    for(int i=0;i<s.size();i++)
    {
        if((i+1)%2)
        {
            if(s[i]=='L')
                {cout<<"No"<<endl;return;}
        }
        else
        {
            if(s[i]=='R')
                {cout<<"No"<<endl;return;}
        }
    }
    {cout<<"Yes"<<endl;}
    
}

int main()
{
 // freopen("input.txt","r",stdin);
//  freopen("output.txt","w",stdout);
   // int t;cin>>t;while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.algorithm;
import std.range;
import std.string;
import std.typecons;
import std.math;
 
void main()
{
    auto a = readln().strip.to!int + 1;
    writefln("%d", cast(int)(1. / sqrt(5.) * (pow((1. + sqrt(5.)) / 2, a) - pow((1. - sqrt(5.)) / 2., a))));
}


Measured memory_bytes: 2488
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int m = sc.nextInt();

		int[] a = new int[n];
		int[] b = new int[n];
		int[] c = new int[m];
		int[] d = new int[m];

		for (int i = 0; i < n; i++) {
			a[i] = sc.nextInt();
			b[i] = sc.nextInt();
		}

		for (int i = 0; i < m; i++) {
			c[i] = sc.nextInt();
			d[i] = sc.nextInt();
		}


		for (int i = 0; i < n; i++) {
			int minDist = Integer.MAX_VALUE;
			int num = 0;
			for (int j = 0; j < m; j++) {

				int tmpDist = Math.abs(a[i] - c[j]) + Math.abs(b[i] - d[j]);
				if (minDist > tmpDist || tmpDist == 0) {
					minDist = tmpDist;
					num = j;
				}
			}
			System.out.println(num + 1);
			}

	}
}

Measured memory_bytes: 20564
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
    public static void main(String[] args) throws IOException {
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    	String s = br.readLine();
    	br.close();
	int rgd = 999;
	int sft = 753;
    	for (int i=0;i<s.length()-2;i++) {
	    int sub = Integer.parseInt(s.substring(i,i+3));
	    if (Math.abs(sft-sub) < rgd) {
		rgd = (int)Math.abs(sft-sub);
	    }
	}
	System.out.println(rgd);
    }	
}

Measured memory_bytes: 21332
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(ll N) : par(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
    }

    int root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(ll x, ll y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};


bool pairCompareF(const P& firstElof, const P& secondElof)
{
    return firstElof.first < secondElof.first;
}

bool pairCompareS(const P& firstElof, const P& secondElof)
{
    return firstElof.second < secondElof.second;
}

int main()
{
    ll N, K, L;
    cin >> N >> K >> L;
    UnionFind union1(N);
    UnionFind union2(N);
    rep(i, K) {
        ll p, q;
        cin >> p >> q;
        union1.unite(p-1, q-1);
    }
    rep(i, L) {
        ll p, q;
        cin >> p >> q;
        union2.unite(p-1, q-1);
    }
    map<P, ll> mp;
    rep(i, N) {
        mp[make_pair(union1.root(i), union2.root(i))]++;
    }
    rep(i, N) {
        cout << mp[make_pair(union1.root(i), union2.root(i))] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 15104
def solve(n, m, s):
    cnt = 0
    for i in range(1, n+1):
        if (s[i-1] == "0") and (s[i] == "1"):
            cnt = 1
        elif (s[i-1] == "1") and (s[i] == "1"):
            cnt += 1
        if cnt >= m:
            return -1
    s = s[::-1]
    i = 0
    path = []
    while i < n:
        for j in range(min(m, n-i), 0, -1):
            ni = i+j
            if s[ni] == "0":
                i = ni
                path.append(j)
                break
    return " ".join(map(str, path[::-1]))

n, m = map(int, input().split())
s = input()
print(solve(n, m, s))

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

using namespace std;
#define int long long
#define N 666666
#define inf  999999999999
int ans;
signed main(){
	int n,m;
	cin>>n>>m;
	ans=inf;
	if(n%3==0||m%3==0){
		cout<<"0";return 0;
	}
	ans=min(n,m);
	for(int i=1;i<n;i++){
		int s1=i*m,s2,s3;
		if(m%2){
			s2=(m/2)*(n-i);
			s3=(m/2+1)*(n-i);
		}else{
			s2=(m/2)*(n-i);
			s3=(m/2)*(n-i);
		}
		ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
	}
	
	for(int i=1;i<m;i++){
		int s1=i*n,s2,s3;
		if(n%2){
			s2=(n/2)*(m-i);
			s3=(n/2+1)*(m-i);
		}else{
			s2=(n/2)*(m-i);
			s3=(n/2)*(m-i);
		}
		ans=min(ans,max(s1,max(s2,s3))-min(s1,min(s2,s3)));
	}
	cout<<ans;
	return 0;
}

/*
4
2 1 -1 -2
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long int
#define ar array
#define mp make_pair
using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin>>s;
	set<char>st;
	for(auto it:s)
		st.insert(it);
	for(char i = 'a'; i<='z'; i++)
	{
		int j = st.count(i);
		if(j==0)
		{
			cout<<i<<endl;
			return 0;
		}
	}
	cout<<"None"<<endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    char c;
    int ans=0;
    
    for(int i=0;i<4;i++){
        cin>>c;
        if(c=='+'){
            ans+=1;
        }
        else if(c=='-'){
            ans-=1;
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
const int N=2e5+5;

i64 ans[N];
int x[N];
int s[N];
int c[N];
vector<int>e[N];

void dfs(int v,int p){
	int i,l=x[c[v]];s[v]=1;
	for(i=0;i<e[v].size();i++)
		if(e[v][i]!=p)
			x[c[v]]=0,dfs(e[v][i],v),s[v]+=s[e[v][i]],
			ans[c[v]]-=1ll*(s[e[v][i]]-x[c[v]])*(s[e[v][i]]-x[c[v]]+1)/2;
	x[c[v]]=l+s[v];
}

int main()
{
	int n,i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&c[i]);
		ans[c[i]]=1ll*n*(n+1)/2;
	}
	for(i=1;i<n;i++)
		scanf("%d%d",&u,&v),
		e[u].push_back(v),
		e[v].push_back(u);
	dfs(1,0);
	for(i=1;i<=n;i++)
		if(ans[i])ans[i]-=1ll*(n-x[i])*(n-x[i]+1)/2;
	for(i=1;i<=n;i++)
		printf("%lld\n",ans[i]);
	return 0;
}

Measured memory_bytes: 34184
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
const ll inf=1e+18;
int main(void){
    int n,m;cin>>n>>m;
    vector<vector<pair<ll,ll>>> t(n);
    
    if(m==0){
        cout<<"Yes"<<endl;
        return 0;
    }
    vector<ll> v(n,-inf);
    rep(i,m){
        ll l,r,d;cin>>l>>r>>d;l--;r--;
        t[l].push_back({r,d});
        t[r].push_back({l,-d});
    }
    rep(i,n){
        if(v[i]!=-inf)continue;
        if(t[i].size()==0)continue;
        v[i]=0;
        queue<ll> que;
        que.push(i);
        while(que.size()){
            ll l=que.front();que.pop();
            rep(j,t[l].size()){
                ll r=t[l][j].first,d=t[l][j].second;
                if(v[r]==-inf){
                    v[r]=v[l]+d;
                    que.push(r);
                }else{
                    if(v[r]!=v[l]+d){
                        cout<<"No"<<endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 14080
import sys
f = sys.stdin


while True:
    seven, bar, grape, cherry, star, all_game = map(int, f.readline().split())
    if seven == bar == grape == cherry == star == all_game == 0:
        break
        
    init_coin = 100
    free_game = star        
    bonus_game = seven * 5 + bar * 3
    nomal_game = all_game - free_game - bonus_game

    last_coin = init_coin - bonus_game * 2 - nomal_game * 3 + (bonus_game + seven + bar) * 15 + grape * 7 + cherry * 2
    print(last_coin)

    

Measured memory_bytes: 6720
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define pi 3.14159265359
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
	string s;
	cin >> s;
	int cnt = 0;
	int old = 0;
	int maxcnt = 0;
	for(int i = 0; i < 3; i++){
		if(s[i] == 'R'){
			cnt++;
		}else{
			cnt = 0;
		}
		maxcnt = max(maxcnt, cnt);
	}
	cout << maxcnt << endl;
	// cout << ans << endl;
}

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

using namespace std;

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

const double pi = 3.14159265358979323846;

// #define fio() cin.tie(0); ios::sync_with_stdio(false);
// 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 (a>b) { a = b; return 1; } return 0; }
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define TG0 get< 0 >
#define TG1 get< 1 >
#define TG2 get< 2 >
#define F first
#define S second
#define VL vector< ll >

// to_string(123)
// atoi("123"); atoi(s.c_str());
// "abc".size()
// s.find('+') == string::npos
// 1e18

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

  ll N, K;
  cin >> N >> K;

  if (N == 1) {
    cout << 0 << endl;
  } else if (N % K == 0) {
    cout << 0 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
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;}
std::vector<int> sieve(int n)
{
    std::vector<int> res(n);
    std::iota(res.begin(), res.end(), 0);
    for (int i = 2; i * i < n; ++i)
    {
        if (res[i] < i)
            continue;
        for (int j = i * i; j < n; j += i)
            if (res[j] == j)
                res[j] = i;
    }
    return res;
}
std::vector<int> factor(int n, const std::vector<int> &min_factor)
{
    // min_factor は sieve() で得られたものとする
    std::vector<int> res;
    while (n > 1)
    {
        res.push_back(min_factor[n]);
        n /= min_factor[n];
        // 割った後の値についても素因数を知っているので順次求まる
    }
    return res;
}
int main()
{
    ll n;
    cin >> n;
    vector<int> v=sieve(n+1);
    ll ans=0;
    REP(i,n){
        vector<int> v2=factor(i+1,v);
        ll tmp=1;
        map<int,int> m;
        REP(j,v2.size()){
            m[v2[j]]++;
        }
        for(auto& j:m){
            tmp*=(j.second+1);
        }
        ans+=(i+1)*tmp;
    }
    cout << ans << endl;
}


Measured memory_bytes: 42272
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <cassert>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <list>


using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype
template <class T> int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define CLEAR(arr, val) memset(arr, val, sizeof(arr))

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

template <class T> void max_swap(T& a, const T& b) { a = max(a, b); }
template <class T> void min_swap(T& a, const T& b) { a = min(a, b); }

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

const double EPS = 1e-8;
const double PI = acos(-1.0);
const int dx[] = { 0, 1, 0, -1 };
const int dy[] = { 1, 0, -1, 0 };


int main()
{
	int n, a, b, c, d[128], s[128];
	cin >> n >> a >> b >> c;
	for (int i = 1; i <= n; ++i)
		cin >> d[i];
	d[0] = 0;
	sort(d + 1, d + n + 1, greater<int>());
	partial_sum(d, d + n + 1, s);

	int res = 0;
	for (int k = 0; k <= n; ++k)
		max_swap(res, (c + s[k]) / (a + k * b));
	cout << res << endl;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

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

    unordered_map<string, int> M;
    REP(i, 0, N) {
        string s; cin >> s;
        M[s]++;
    }

    int maxs = 0;
    for (auto m : M) {
        if (maxs < m.second) maxs = m.second;
    }

    vector<string> S;
    for (auto m : M) {
        if (maxs == m.second) S.push_back(m.first);
    }

    sort(ALL(S));
    REP(i, 0, S.size()) {
        cout << S[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 26692
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>

using namespace std;
using ll=long long int;

template <typename T>
T powi(T a, ll n) {
    T ret = 1;
    while (n > 0) {
        if (n & 1) ret *= a; 
        a *= a;
        n >>= 1;
    }
    return ret;
}

template <ll mod>
class ModInt {
private:
    ll num;
public:
    ModInt() {};
    ModInt(ll n) { num = n % mod; }
    ModInt inv() const { return powi(*this, mod-2); }
    explicit operator ll() const { return num; }

    ModInt& operator+=(const ModInt& a) {
        num += a.num; 
        if (num >= mod) num -= mod; 
        return *this;
    }
    ModInt& operator-=(const ModInt& a) {
        if (num < a.num) num += mod;
        num -= a.num;
        return *this;
    }
    ModInt& operator*=(const ModInt& a) {
        num = num * a.num % mod;
        return *this;
    }
    ModInt& operator/=(const ModInt& a) { return *this *= a.inv(); }
    friend ModInt operator+(const ModInt& a, const ModInt& b) { return ModInt(a) += b; }
    friend ModInt operator-(const ModInt& a, const ModInt& b) { return ModInt(a) -= b; }
    friend ModInt operator*(const ModInt& a, const ModInt& b) { return ModInt(a) *= b; }
    friend ModInt operator/(const ModInt& a, const ModInt& b) { return ModInt(a) /= b; }

    friend ostream& operator<<(ostream& os, const ModInt& a) { return os << a.num; }
    friend istream& operator>>(istream& is, ModInt& a) {
        ll tmp;
        is >> tmp;
        a.num = tmp % mod;
        return is;
    }
};
using mint = ModInt<1000000007>;
//using mint = ModInt<998244353>;

int main() {
    string l;
    cin >> l;
    int n = l.length();

    int pcnt = 0;
    mint ans = 0;
    for (int i = 0; i < n; ++i) {
        if (l[i] == '0') continue;
        ans += powi((mint)2, pcnt) * powi((mint)3, n-i-1);
        ++pcnt;
    }
    ans += powi((mint)2, pcnt);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
int main()
{
    int a, b, c;
    cin >> a>>b>>c;

    int ans = a+b+c;
    ans = min(ans, a+b);
    ans = min(ans, c+b);
    ans = min(ans, a+c);

    cout << ans<< endl;

   return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int N, A, B;
  scanf("%d", &N);
  if(N == 1){
    printf("Hello World\n");
  }
  if(N == 2){
    scanf("%d %d", &A, &B);
    printf("%d\n", A+B);
  }
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  string s,t,u;
  cin >> s >> t >> a >> b >> u;
  if(s==u){
    cout << a-1 << endl;
    cout << b << endl;
  } 
  else if(t==u){
    cout << a << endl;
    cout << b-1 << endl;
  }
  return 0; 
} 

Measured memory_bytes: 256
def main():
    import sys
    import numpy as np
    sys.setrecursionlimit(10**6)
    s = input().strip()
    N = len(s)
    p = sum([1 if si == 'p' else 0 for si in s])
    print(N//2-p)

if __name__ == '__main__':
    main()

Measured memory_bytes: 28036
// In the name of God

#include <iostream>
#include <algorithm>
#include <fstream>
#include <vector>
#include <deque>
#include <assert.h>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <stdio.h>
#include <string.h>
#include <utility>
#include <math.h>
#include <bitset>
#include <iomanip>

using namespace std;

const int N = (int) 0, mod = (int) 1e9 + 7;
int cnt[1234567];
void nein(int x) {
    if (x) {
        cout << 0 << endl;
        exit(0);
    }
}
int32_t main() {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int n;
    cin >> n;
    for (int j = 0; j < n; ++j) {
        int x;
        cin >> x;
        cnt[x]++;
    }
    int z = 1;
    if (n & 1) {
        for (int j = 0; j < n / 2; ++j)
            z *= 2, z %= mod;
        nein(cnt[0] != 1);
        for (int j = 2; j < n; j += 2)
            nein(cnt[j] != 2);
    } else {
        for (int j = 0; j < n / 2; ++j)
            z *= 2, z %= mod;
        for (int j = 1; j < n; j += 2)
            nein(cnt[j] != 2);
    }
    cout << z << endl;
}




Measured memory_bytes: 764
def get_unvisted_child(v, timestamp):
  while len(G[v]) > 0:
    c = G[v].pop(0)
    if not c in timestamp: return c
  return -1

def get_unvisited_node(G, timestamp):
  for v in sorted(G):
    if not v in timestamp: return v
  return -1

def dept_first_search(G):
  t = 1
  timestamp = {}
  stack = []

  v = get_unvisited_node(G, timestamp)
  while v > 0:
    stack.append(v)
    timestamp[v] = [t]
    t += 1

    while len(stack) > 0:
      v = stack[-1]
      c = get_unvisted_child(v, timestamp)
      if c > 0:
        #c = G[v].pop(0)
        stack.append(c)
        timestamp[c] = [t]
      else:
        timestamp[v].append(t)
        stack.pop()
      t += 1

    v = get_unvisited_node(G, timestamp)

  for v in sorted(timestamp):
    print(v, *timestamp[v])

G = {}
for i in range(int(input())):
  x = list(map(int, input().split()))
  G[x[0]] = x[2:]

dept_first_search(G)

Measured memory_bytes: 7732
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


int main() {
	string S;
	cin >> S;
	//reverse(S.begin(), S.end());
	vector<vector<ll>> dp(S.size() + 1, vector<ll>(13, 0));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < 13; j++) {
			dp[i][j] %= MOD;
			if (S[i] == '?') {
				for (int k = 0; k < 10; k++) {
					dp[i + 1][(j * 10 + k) % 13] += dp[i][j];
				}
			}
			else {
				dp[i + 1][(j * 10 + S[i] - '0') % 13] += dp[i][j];
			}
		}
	}
	cout << dp[S.size()][5] % MOD << endl;
}

Measured memory_bytes: 13696
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <cstring>

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000
const int MAX_N = 2 * 1e5;

struct union_find_tree {
	int par[MAX_N]; // 親
	int depth[MAX_N]; // 木の深さ

	// n要素で初期化
	void init(int n) {
		rep(i, 0, n) {
			par[i] = i;
			depth[i] = 0;
		}
	}

	// 木の根を求める
	int find(int x) {
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(depth[x] < depth[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	union_find_tree uft1, uft2;
	int N, K, L;
	cin >> N >> K >> L;
	int p[K], q[K], r[L], s[L];
	uft1.init(N);
	uft2.init(N);

	rep(i, 0, K) {
		cin >> p[i] >> q[i];
		p[i]--; q[i]--;
		uft1.unite(p[i], q[i]);
	}

	rep(i, 0, L) {
		cin >> r[i] >> s[i];
		r[i]--; s[i]--;
		uft2.unite(r[i], s[i]);
	}

	map<P, int> result;
	rep(i, 0, N) {
		result[make_pair(uft1.find(i), uft2.find(i))]++;
	}

	rep(i, 0, N - 1) cout << result[make_pair(uft1.find(i), uft2.find(i))] << " " ;
	cout << result[make_pair(uft1.find(N - 1), uft2.find(N - 1))] << endl;



	
}


Measured memory_bytes: 16640