akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

const ll MOD = 1e9 + 7;
const ll INF = 1e14;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)

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

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    ll N, K;
    cin >> N >> K;
    vl A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));

    ll m=0, z=0, p=0; //負、ゼロ、正の各要素数
    rep(i,N){
        if(A[i]<0) m++;
        else if (A[i] == 0) z++;
        else p++;
    }
    
    if(K<=m*p){ //負の値
        vl M, P;
        rep(i,m){
            M.eb(A[i]);
        }
        repe(i,m+z,N){
            P.eb(A[i]);
        }

        reverse(all(P));
        ll ng = -1e18-1, ok=-1, mid;
        while(ok-ng>1){
            mid = (ok + ng) / 2;
            ll pi = p - 1, cnt = 0;
            rep(i,m){
                while (pi >= 0 && P[pi] * M[i] > mid) pi--;
                if (pi == -1) break;
                cnt += pi + 1;
            }
            (cnt < K ? ng : ok) = mid;
        }
        cout << ok << endl;

    }
    else if(K<=m * p + (m+p)*z + z*(z-1)/2){ //ゼロ
        cout << 0 << endl;
    }
    else{ //正の値
        K -= m * p + (m+p)*z + z*(z-1)/2;
        // cout <<m<<" "<<z<<" "<<p<<" K "<< K << endl;
        vl M(m), P(p);
        rep(i, m) M[i] = A[m-i-1];
        repe(i, m + z, N) P[i-m-z] = A[i];

        ll ng = 0, ok = 1e18;
        while(ok-ng>1){
            ll mid = (ok + ng) / 2;
            ll mi = m - 1, cnt = 0;
            rep(i,m){
                while (mi >i && M[i] * M[mi] > mid) mi--;
                if (mi <= i) break;
                cnt += mi-i;
            }
            ll pi = p - 1;
            rep(i,p){
                while (pi > i && P[i] * P[pi] > mid) pi--;
                if (pi <= i) break;
                cnt += pi-i;
            }
            
            (cnt >= K ? ok : ng) = mid;
        }

        // //////
        // vl B;
        // rep(i, p-1) {
        //     repe(j, i + 1, p) B.eb(P[i] * P[j]);
        // }
        // rep(i,m-1){
        //     repe(j, i + 1, m) B.eb(M[i] * M[j]);
        // }
        // sort(all(B));
        // cout << (ll)B.size() << endl;
        // rep(i, (ll)B.size()) {
        //     if (B[i] == 206120723597717280) cout << i << endl;
        //     cout << B[i] << endl;
        // }
        cout << ok << endl;
    }
}

Measured memory_bytes: 4084
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n):return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx as nx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()

d=deque([3,5,7])
ans=0
while True:
    a=d.popleft()
    if a>n:
        break
    else:
        s=str(a)
        if s.count("3")>0 and s.count("5")>0 and s.count("7")>0:
            ans+=1
        d.append(10*a+3)
        d.append(10*a+5)
        d.append(10*a+7)
print(ans)

Measured memory_bytes: 6236
N, L = map(int, input().split())
a = list(map(int, input().split()))
end = 0
for i in range(N - 1):
    if a[i] + a[i + 1] >= L:
        end = i + 1
        break
else:
    print('Impossible')
    exit()

ans = list(range(1, end)) + list(range(end, N))[::-1]
print('Possible')
print(*ans, sep='\n')

Measured memory_bytes: 14924
//PseudoName

#include <bits/stdc++.h>

#define FOR(i,n) for(i=0;i<n;i++)
#define FOR1(i,n) for(i=1;i<=n;i++)
#define FOR2(I, A, B) for (int I = (A); I <= (B); ++I)
#define pb push_back
#define uniquelysorted(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define print(v) for(auto it:v)cout<<it<<" ";cout<<endl
#define vi vector<int>

typedef long long ll;

using namespace std;

int main() {
    int n,i,j,k;
    ll days=0;
    cin>>n;
    int a[n][n-1];
    int top[n]={0};
    bool flag=true;
    int nw=0,nxt=1;
    vi vec;
    vi tv[2];
    
    
    FOR(i,n)
        FOR(j,n-1)
        {
            cin>>k;
            a[i][j]=k-1;
        }
        
  
    FOR(i,n){
        if(i==a[a[i][0]][0]){
            
            tv[nw].pb(i);
        }
    }

    while(!tv[nw].empty())
    {
        days++;
        tv[nxt].clear();
        FOR(i,tv[nw].size())
        {
            int k=tv[nw][i];
            top[k]++;
            if(top[k]<n-1)
            {
                int in=a[k][top[k]];
                if(top[in]<n-1 && a[in][top[in]]==k)
                {
                    tv[nxt].pb(k);
                    tv[nxt].pb(in);
                }
            }
            
           
            
        }
         swap(nw,nxt);
         uniquelysorted(tv[nw]);
    
    }
    FOR(i,n)if(top[i]!=n-1)flag=false;
    if(flag)cout<<days<<endl;
    else
    cout<<"-1\n";

}

Measured memory_bytes: 4224
const lines=readlines()
input()=shift!(lines)
int(x)=parse(Int,x)
function intLine()
    s=input()|>split
    int(s[1]),int(s[2])
end
function bfs(n,e,s,t)
    f=ones(Int,(n,3))*-3
    f[s,1]=0
    q=Array{Pair{Int,Int}}([s=>1])
    while !isempty(q)
        v,m=shift!(q)
        u=m>2?1:m+1
        for w=e[v]
            if f[w,u]<0
                f[w,u]=f[v,m]+1
                push!(q,w=>u)
            end
        end
    end
    f[t,1]÷3
end
function main()
    n,m=intLine()
    e=Array{Int,1}[[]for i=1:n]
    for i=1:m
        u,v=intLine()
        push!(e[u],v)
    end
    s,t=intLine()
    show(bfs(n,e,s,t))
end
main()

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

using namespace std;
using ll=long long;
using ull=unsigned long long;
using pii=pair<int,int>;

#define INF 1e18
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()
#define rep(i,N) for(int i=0;i<N;i++)

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

  int N;
  cin>>N;
  vector<ll>a(N);
  for(int i=0;i<N;i++)cin>>a[i];
  ll ans=0;
  while(true){
    ll s=0;
    for(int i=0;i<N;i++)s+=a[i]/N;
    ans+=s;
    for(int i=0;i<N;i++)a[i]=a[i]-(a[i]/N)*N+s-a[i]/N;
    bool ok=true;
    for(int i=0;i<N;i++)if(a[i]>=N)ok=false;
    if(ok)break;
  }
  cout<<ans<<endl;
  return 0;
}


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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second
#define lwb lower_bound
#define upb upper_bound
#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in", "r", stdin);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n; cin >> n;
  vector<int> a(n);
  for (auto &i : a) cin >> i, --i;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    ans += (a[a[i]] == i);
  }
  cout << ans / 2 << '\n';
}


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

clock_t present = clock();
void complexiti(){
	present = clock() - present;
	cerr << "TIME : " << float(present)/CLOCKS_PER_SEC << '\n';
}

void solver(){
	//~ type your code here
	int n , d;
	cin >> n >> d;
	int val = d + d + 1;
	cout << n / val + (n % val == 0 ? 0 : 1) << endl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int queries = 1;
	//~ cin >> queries;
	for(int i = 0 ; i < queries ; ++i){
		solver();
	}
	complexiti();
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
const ll inf=1e9+7;

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

  if(a>b) swap(a,b); //a<b

  string ans;
  if(a<0 && b>0){
    ans="Zero";
  }
  else{
    int cnt=0;
    if(a>0) cnt=0;
    else cnt=b-a-1;

    if(cnt%2==0) ans="Positive";
    else ans="Negative";
  }
  cout<<ans<<endl;

}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}

ll LCM(ll a, ll b){
    return a * b / __gcd(a, b);
}

signed main(){
    ll n, m;
    cin >> n >> m;
    vector<ll> v(n);
    REP(i, n){
        cin >> v[i];
        v[i] /= 2;
    }
    sort(all(v));

    ll lcm = v[0];
    ll po = lcm;
    int two = 0;
    while(po % 2 == 0){
        two++;
        po /= 2;
    }
    FOR(i, 1, n){
        ll po = v[i];
        int cnt = 0;
        while(po % 2 == 0){
            cnt++;
            po /= 2;
        }
        if(cnt != two){
            cout << 0 << endl;
            return 0;
        }
        lcm = LCM(lcm, v[i]);
        if(lcm > m){
            cout << 0 << endl;
            return 0;
        }
    }
    cout << (m / lcm + 1) / 2 << endl;

    return 0;
}


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

using namespace std;

int main()
{
  int a,b,h,m;
  cin>>a>>b>>h>>m;
  long double ans;
  long double pi = M_PI;
  long double use = pi/360;
  long double use2 = pi/30;
  int whole = m/5;
  int rem = m%5;
  long double hourdis = h*60*use + m*use;
  long double mind = whole*60 + rem;
  long double mindis = m * use2;
  long double angle;
  angle = hourdis - mindis;
  if(angle<0)
  {
      angle = angle * -1;
  }
  long double finangle = pi - angle;
  long double cosval = cos(finangle);

  long double final = a*a + b*b + 2*a*b*cosval;
  final = sqrt(final);
   std::cout << std::fixed << std::setprecision(10) << final;
  return 0;
}

Measured memory_bytes: 4164
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Globalization;
using System.Diagnostics;
using static System.Console;
//using System.Numerics;
//using static System.Math;

class Program
{
    static void Main()
    {
        //SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
        new Program().solve();
        Out.Flush();
    }
    Scanner cin = new Scanner();
    readonly int[] dd = { 0, 1, 0, -1, 0 }; //→↓←↑
    readonly int mod = 1000000007;


    void solve()
    {
        int H = cin.nextint;
        int W = cin.nextint;
        input(10);
        warshall_floyd(10);

        long ans = 0;
        for (int i = 0; i < H; i++)
        {
            for (int j = 0; j < W; j++)
            {
                int k = cin.nextint;
                if (k != -1)
                {
                    ans += D[k, 1];
                }
            }
        }
        WriteLine(ans);
    }


    long[,] D;
    const long inf = long.MaxValue / 3;
    void input(int n)
    {
        D = new long[n, n];
        for (int i = 0; i < n; i++)
        { 
            for (int j = 0; j < n; j++)
            {
                D[i, j] = cin.nextint;
            }
        }

    }
    void warshall_floyd(int n)
    {
        for (int k = 0; k < n; k++)
        {
            for (int i = 0; i < n; i++)
            {
                for (int j = 0; j < n; j++)
                {
                    D[i, j] = Math.Min(D[i, j], D[i, k] + D[k, j]);
                }
            }
        }
    }
}

class Scanner
{
    string[] s; int i;
    char[] cs = new char[] { ' ' };
    public Scanner() { s = new string[0]; i = 0; }
    public string[] scan { get { return ReadLine().Split(); } }
    public int[] scanint { get { return Array.ConvertAll(scan, int.Parse); } }
    public long[] scanlong { get { return Array.ConvertAll(scan, long.Parse); } }
    public double[] scandouble { get { return Array.ConvertAll(scan, double.Parse); } }
    public string next
    {
        get
        {
            if (i < s.Length) return s[i++];
            string st = ReadLine();
            while (st == "") st = ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return next;
        }
    }
    public int nextint { get { return int.Parse(next); } }
    public long nextlong { get { return long.Parse(next); } }
    public double nextdouble { get { return double.Parse(next); } }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using  namespace std;
#define ll      long long int
#define pai     pair<int,int>
#define vi      vector<long long int>
#define vb      vector<bool>
#define vm      vector<vector<int> >
#define vd      vector<double>
#define vs      vector<string>
#define vp      vector< pair <string,int> >
#define mpi     map<int,int>
#define mps     map<char,int>
#define sti     stack<int>
#define stc     stack<char>
#define sei     set<int>
#define ses     set<string>
#define multii  multiset<int>
#define forn(i,n)    for (int i = 0; i < n; i++)
#define fork(i,k,n)  for (int i = k; i <= n; i++)
#define forkr(i,k,n) for (int i = k; i >= n; i--)
const int MAX=1e5+1;

 int main()
{
 ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
ll n;
cin>>n;
vi v(n);
forn(i,n){
cin>>v[i];
}
ll m=v[0];
ll c=0;
for(int i=1;i<n;i++){
if(m>v[i]){
   c+=m-v[i];
}
else{
  m=v[i];
}
}
cout<<c<<endl;
}






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

int main(){
	int n;
	cin>>n;
	vector<long long int>l(n);
	rep(i,n)cin>>l[i];
	sort(l.begin(),l.end());
	int sum=0;
	for(int i=0;i<n;i++){
		for(int j=i+1;j<n;j++){
			for(int k=j+1;k<n;k++){
				if(l[i]+l[j]>l[k] and l[i]!=l[j]and l[k]!=l[j])sum++;
			}
		}
	}
	cout<<sum<<endl;


	return 0;
}

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

int main() {
  vector<queue<char>> vec_q(3);
  rep(i,0,3) {
    string S; cin >>S;
    rep(j,0,S.size()) {
      vec_q[i].push(S[j]);
    }
  }

  int cur=0;
  while(true) {
    if (vec_q[cur].empty()) break;
    char card=vec_q[cur].front();
    vec_q[cur].pop();
    if (card=='a') cur=0;
    else if (card=='b') cur=1;
    else cur=2;
  }

  if (cur==0) cout <<'A' <<endl;
  else if (cur==1) cout <<'B' <<endl;
  else cout <<'C' <<endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            long S = sc.nextLong();

            long x1 = 0;
            long y1 = 0;
            long x2 = 1000000000;
            long y2 = 1;

            long x3;
            long y3;

            if (S % x2 == 0) {
                y3 = S / x2;
                x3 = 0;
            } else {
                y3 = S / x2 + 1;
                x3 = y3 * x2 - S;
            }

            System.out.println(x1 + " " + y1 + " " + x2 + " " + y2 + " " + x3 + " " + y3);
        }
    }

}


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

using namespace std;

int n,m;

int qpow(int base,int tms,int mod = m)
{
	int tmp = 1;
	while(tms)
	{
		if(tms & 1) tmp = tmp * 1ll * base % mod;
		base = base * 1ll * base % mod;
		tms >>= 1;
	}
	return tmp;
}

int C[3050][3050];
int S[3050][3050];

int main()
{
	scanf("%d%d",&n,&m);
	C[0][0] = S[0][0] = 1;
	for(int i = 1;i <= 3001; ++ i)
	{
		C[i][0] = 1;
		for(int j = 1;j <= i; ++ j)
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % m,
			S[i][j] = (S[i - 1][j - 1] + S[i - 1][j] * 1ll * j % m) % m;
	}
	long long ans = 0;
	for(int i = 0;i <= n; ++ i)
	{
		int fg = (i & 1) ? m - 1 : 1;
		long long xs = C[n][i] * 1ll * qpow(2,qpow(2,n - i,m - 1)) % m;
		long long su = 0;
		for(int j = 0;j <= i; ++ j)
			su = (su + S[i + 1][j + 1] * 1ll * qpow(2,(n - i) * j) % m) % m;
		ans = ans + fg * 1ll * xs % m * su % m;
		ans %= m;
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 71040
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

struct CHT{
    using i64=int_fast64_t;
    const i64 INF=INT_FAST64_MAX;
    int n;
    vector<i64> v;
    map<i64,int> nm;
    vector<array<i64,2>> dat;
    vector<bool> vis;
    explicit CHT(vector<i64> v_,i64 inf){
        sort(v_.begin(),v_.end());
        v.clear();nm.clear();
        fr(i,v_.size()){
            if(i<v_.size()-1&&v_[i]==v_[i+1]) continue;
            nm[v_[i]]=v.size();
            v.emplace_back(v_[i]);
        }
        n=1;
        while(n<v.size()) n<<=1;
        v.resize(n+1,inf);
        dat.clear();vis.clear();
        dat.resize(2*n-1,{0,INF});
        vis.resize(2*n-1);
    }
    void add(i64 a,i64 b,int k,int l,int r){
        //cout<<"!"<<k<<" "<<l<<" "<<r<<" ";
        if(l+1==r){
            vis[k]=true;
            dat[k][0]=a,dat[k][1]=b;
            return;
        }
        int m=(l+r)/2;
        i64 A=dat[k][0],B=dat[k][1],vl=a*v[l]+b,vm=a*v[m]+b,vr=a*v[r]+b,VL=A*v[l]+B,VM=A*v[m]+B,VR=A*v[r]+B;
        if(!vis[k]) VL=VM=VR=INF,vis[k]=true;
        //cout<<vl<<" "<<VL<<" "<<vm<<" "<<VM<<" "<<vr<<" "<<VR<<endl;
        if(vl<=VL&&vm<=VM&&vr<=VR) dat[k][0]=a,dat[k][1]=b;
        if(vl<=VL&&vm> VM&&vr> VR) add(a,b,2*k+1,l,m);
        if(vl> VL&&vm> VM&&vr<=VR) add(a,b,2*k+2,m,r);
        if(vl> VL&&vm<=VM&&vr<=VR){
            dat[k][0]=a;dat[k][1]=b;
            add(A,B,2*k+1,l,m);
        }
        if(vl<=VL&&vm<=VM&&vr> VR){
            dat[k][0]=a;dat[k][1]=b;
            add(A,B,2*k+2,m,r);
        }
    }
    void add(i64 a,i64 b){add(a,b,0,0,n);}
    i64 mn(i64 x){
        int k=nm[x];
        i64 ans=INF;
        k+=n-1;
        while(true){
            if(vis[k]) ans=min(ans,dat[k][0]*x+dat[k][1]);
            if(k==0) return ans;
            k=(k-1)/2;
        }
    }
};

class ZFrog3 {
public:
    void solve(istream& in, ostream& out) {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        using i64=int_fast64_t;
        int n;
        i64 c;
        in>>n>>c;
        vector<i64> h(n);
        fr(i,n) in>>h[i];
        CHT lct(h,1e6+1);
        vector<i64> dp(n);
        fr(i,n){
            if(i) dp[i]=lct.mn(h[i])+h[i]*h[i]+c;
            lct.add(-2*h[i],h[i]*h[i]+dp[i]);
            /*fr(j,2*lct.n-1) cout<<lct.dat[j][0]<<","<<lct.dat[j][1]<<" ";
            cout<<endl;*/
        }
        //fr(i,n) cout<<dp[i]<<endl;
        out<<dp[n-1]<<endl;
    }
};

int main() {
    ZFrog3 solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

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

int main(void) {
    const int INF = 1 << 30;
    int n, t, a, h, min_a = INF, min_pos = 0;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    cin >> t >> a;
    REP(i, n) {
        cin >> h;
        if (min_a > abs(t * 1000 - h * 6 - a * 1000)) {
            min_pos = i + 1;
            min_a = abs(t * 1000 - h * 6 - a * 1000);
        }
    }

    cout << min_pos << "\n";
    return 0;
}

Measured memory_bytes: 256
from collections import deque
INF = int(1e10)

def main():
    from builtins import int, map
    H, W = map(int, input().split())
    Ch, Cw = map(lambda x: int(x) - 1, input().split())
    Dh, Dw = map(lambda x: int(x) - 1, input().split())
    S = [input() for _ in range(H)]

    # dist = defaultdict(lambda: float("inf"))
    dist = [[float("inf")] * W for _ in range(H)]
    queue = deque([(Ch, Cw, 0)])

    while queue:
        (h, w, d) = queue.popleft()

        if dist[h][w] == float("inf") or dist[h][w] > d:
            dist[h][w] = d
            
            # 5x5-grid
            for ddh in range(-2, 3):
                for ddw in range(-2, 3):
                    nh, nw = h + ddh, w + ddw
                    if 0 <= nh < H and 0 <= nw < W and S[nh][nw] == '.':
                        # cost-0 move
                        if abs(ddh) + abs(ddw) <= 1:
                            queue.appendleft((nh, nw, d))
                        # cost-1 move
                        else:
                            queue.append((nh, nw, d + 1))

    if dist[Dh][Dw] == float("inf"):
        print(-1)
    else:
        print(dist[Dh][Dw])

if __name__ == '__main__':
    main()


Measured memory_bytes: 237612
#include <bits/stdc++.h>
 
#define pb push_back
#define ll long long
#define F first
#define S second
#define ld long double
#define fa fflush(stdout); 
#define mp make_pair
using namespace std;
void data() {
    #ifdef NURS
        freopen("main.in", "r", stdin);
        freopen("main.out", "w", stdout);
    #endif
} 
const int N = 1e6 + 100;
const ll mod = 998244353;
const ll mod2 = 1e9 + 7;
 
ll mul(ll a, ll b) {
	return (a * b) % mod2;
}
ll ans = 1;
ll ans2 = 1;
int main () 
{
    data();     
    int n, m;
    cin >> n >> m;
    int all = n + m;
    int n2 = n;
    int m2 = m;
    for (int i = 1; i <= all; i++)
    {
    	if (i % 2)
    	{
    		ans = mul(ans, n);
    		n--;
    	}
    	else {
    		ans = mul(ans, m);
    		m--;
    	}
    	ans = max(ans, 0LL);
    	if (i % 2)
    	{
    		ans2 = mul(ans2, m2);
    		m2--;
    	}
    	else {
    		ans2 = mul(ans2, n2);
    		n2--;
    	}
    	ans2 = max(ans2, 0LL);
    	ans %= mod2;
    	ans2 %= mod2;
    }
  //  cout << ans << " " << ans2 << '\n';
    cout << (ans + ans2) % mod2;
}
//Timus:295965SY              

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

public class Main {

  public static void main(String[] args) throws IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String in;
    while ((in = reader.readLine()) != null) {
      int d = Integer.parseInt(in);
      int x = 600;
      int count = x / d;
      int result = 0;
      for (int i = 0; i < count; i++) {
        result += d * Math.pow(d * i, 2);
      }
      System.out.println(result);
    }
  }

}

Measured memory_bytes: 24172
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>

#include<iostream>

using namespace std;

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

  if (a==5 && b==7 && c==5) {
    printf("YES \n");
  }
  else if (a==5 && b==5 && c==7) {
    printf("YES \n");
  }
  else if (a==7 && b==5 && c==5) {
    printf("YES \n");
  }

  else printf("NO \n");

  return 0;
}


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

int main(){
	int a,b,c,d,e,f;
	cin >> a >> b >> c >> d >> e >> f;
	int h = max(max(max(max(a,b),c),d),e);
	int i = min(min(min(min(a,b),c),d),e);
	if(h-i>f){
		cout << ":(";
	}
	else{
		cout << "Yay!";
	}
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

int main() {
	int N; std::cin >> N;
	int count{ 0 };
	for (auto i{ 1 }; i <= N; ++i) {
		if (i < 10) ++count;
		if (1000 > i && 99 < i) ++count;
		if (100000 > i && 9999 < i) ++count;
		if (10000000 > i && 999999 < i) ++count;
	}
	std::cout << count << std::endl;

	return 0;
}


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

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

    vector<int> v(n);
    vector<int> c(n);

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

    int sum = 0;
    for ( int i = 0; i < n; i++ ) {
        if ( v[i] - c[i] > 0 ) {
            sum += ( v[i] - c[i] );
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

#define N 51
char map[N][N];
bool flag=true;

bool judge(int x,int y)
{
	if(map[x-1][y]=='#'||map[x+1][y]=='#'||map[x][y-1]=='#'||map[x][y+1]=='#')
		return true;
		return false;
}
int main()
{
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			map[i][j]=' ';
	int h,w;
	cin>>h>>w;
	for(int i=1;i<h+1;i++)
	{
	
		for(int j=1;j<w+1;j++)
			cin>>map[i][j];
			getchar();	
}

for(int i=1;i<h+1;i++)
	for(int j=1;j<w+1;j++)
		if(map[i][j]=='#')
			if(!judge(i,j))
			flag=false;
			
if(flag==false)
cout<<"No"<<endl;
else
cout<<"Yes";

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#define ll long long

using namespace std;

int main()
{
  int N; cin>>N;
  ll ans=0;
  for(int i=1; i<=N; i++){
    for(int j=i; j<=N; j+=i){
      ans+=j;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pll pair<long long,long long>
#define mod 1000000007
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);

ll power(ll a,ll b){
	ll ans=1;
	while(b>0){
		if(b%2!=0){
			ans=(ans*a)%mod;
		}
		a=(a*a)%mod;
		b>>=1;
	}
	return ans;
}

bool check(ll n, ll k){
	while(n>=k){
		if(n%k==0)
		n/=k;
		else{
			if((n-1)%k==0)
			return true;
			return false;
		}
	}
	if(n==1)
	return true;
	return false;
}

int main() {
	IOS;
	int t=1;
	//cin>>t;
	while(t--){
		ll n;
		cin>>n;
		vector<ll> v;
		for(ll i=1;i*i<=n;i++){
			if(n%i!=0)
			continue;
			if(i!=1)
			v.push_back(i);
			if(i*i!=n)
			v.push_back(n/i);
		}
		set<ll> s;
		for(ll i=1;i*i<=n-1;i++){
			if((n-1)%i!=0)
			continue;
			s.insert(i);
			s.insert((n-1)/i);
		}
		for(int i=0;i<v.size();i++){
			if(check(n,v[i]))
			s.insert(v[i]);
		}
		s.erase(1);
		cout<<s.size();
	}
	return 0;
}

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

void solv() {
    int N;
    cin >> N;
    vector<int> p(N);
    int max = 0;
    rep(i, N) {
        cin >> p.at(i);
        if(p.at(i) >= p.at(max)){
            max = i;
        }
    }
    int sum = 0;
    rep(i, N) {
        if(max != i){
            sum += p.at(i);
        }
        else{
            sum += p.at(i) / 2;
        }
    }
    cout << sum << endl;
}

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

Measured memory_bytes: 256
from collections import Counter


n = int(input())
an = list(map(int, input().split(' ')))

nn = list(range(1, n + 1))

nam = [None] * n
for i in range(n):
    nam[i] = nn[i] - an[i]
    
nap = [None] * n
for i in range(n):
    nap[i] = nn[i] + an[i]
    
c = Counter()
for p in nap:
    c[p] += 1

ans = 0
for m in nam:
    ans += c[m]

print(ans)



Measured memory_bytes: 124784
import java.io.*;
import java.util.*;
/**
 * Main
 */
public class Main {
        static Stack<Integer> subset = new Stack<>();
        static String input = "";
        static int stop = 0;
        static int mod  = 1000000007;
        static PrintWriter pw = new PrintWriter(new OutputStreamWriter(System.out));
        static HashMap<Integer,Integer> map = new HashMap<>();
        static ArrayList<String> list = new ArrayList<>();
    public static void main(String[] args) {
       MyScanner ms  = new MyScanner();
       int N = ms.nextInt();
        double min = Integer.MAX_VALUE;
        int [] xes = new int[N];
        for(int i=0;i<N;i++)
        xes[i] = ms.nextInt();
        for(int p=0;p<100;p++){
            double sum=0;
            for(int i=0;i<N;i++){
                sum+= Math.pow((xes[i]-p), 2);
            }
            min = Math.min(sum, min);
        }
        pw.println((long)min);
        pw.flush();

      
        

    }


       /**
1.What is the unknown: the maxium number of nodes he can buy
2.What are the data: the size of the array and  element int he array
3.What is the condition: the longest increasing usbsequece
4.What is the restriction: the 100,000 *100 = 100,000,000 = thus made N^2 for 3 second
*/

    public static class MyScanner {
        BufferedReader br;
        StringTokenizer st;
   
        public MyScanner() {
           br = new BufferedReader(new InputStreamReader(System.in));
        }
   
        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
   
        int nextInt() {
            return Integer.parseInt(next());
        }
   
        long nextLong() {
            return Long.parseLong(next());
        }
   
        double nextDouble() {
            return Double.parseDouble(next());
        }
   
        String nextLine(){
            String str = "";
        try {
           str = br.readLine();
        } catch (IOException e) {
           e.printStackTrace();
        }
        return str;
        }
  
     }
    
}

Measured memory_bytes: 22740
#include<iostream>
#include<string>
#include<algorithm>
#define N 50

using namespace std;

int n, m;
int data[N][N];

int char_to_int(const char& c){
  int x = c - 48;
  return x;
}

void solve(){
  for(int j=1; j<m; ++j){
    data[0][j] += data[0][j-1];
  }
  for(int i=1; i<n; ++i){
    data[i][0] += data[i-1][0];
    for(int j=1; j<m; ++j){
      data[i][j] += min(data[i-1][j], data[i][j-1]);
    }
  }
}

int main(){
  string s;
  cin >> n >> m;
  for(int i=0; i<n; ++i){
    cin >> s;
    for(int j=0; j<m; ++j){
      data[i][j] = char_to_int(s[j]);
    }
  }
  solve();
  cout << data[n-1][m-1] << endl;
  return 0;
}

Measured memory_bytes: 1212
#ifndef DEBUG
  #pragma GCC optimize ("Ofast")
#endif
#include <bits/stdc++.h>

//Syntax Sugars
using namespace std;
using f64 = double;
using i8=char;using i16=short;using i32=int;using i64=long long;
using u8=unsigned char;using u16=unsigned short;using u32=unsigned;using u64=unsigned long long;
const f64 pi=acos(-1);
const f64 eps=1e-12;
const i32 prime=i32(2e9 + 11);
i32 mod=i32(1e9 + 7);
template<typename T> T inf() { return numeric_limits<T>::max() / 2; }
#define forh(var, begin, end) for(int var=begin; (int)begin<=var && var<(int)end; ++var)//for: half-opened range
#define forhi(var, begin, end) for(int var=end-1; (int)begin<=var && var<(int)end; --var)//inversion
#define forho(var, begin, end) int var=begin; for(; (int)begin<=var && var<(int)end; ++var)//out declaration
#define forhoi(var, begin, end) int var=end-1; for(; (int)begin<=var && var<(int)end; --var)
#define forc(var, begin, end) for(int var=begin; (int)begin<=var && var<=(int)end; ++var)//for: closed range
#define forci(var, begin, end) for(int var=end; (int)begin<=var && var<=(int)end; --var)//inversion
#define forco(var, begin, end) int var=begin; for(; (int)begin<=var && var<=(int)end; ++var)//out declaration
#define forcoi(var, begin, end) int var=end; for(; (int)begin<=var && var<=(int)end; --var)
#define trav(var, begin, cond) for(i64 var=begin; cond; ++var)//travel
#define travo(var, begin, cond) i64 var=begin; for(; cond; ++var)//out declaration

//Extensions
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;

//Settings
#define endl '\n'//do not use when solving interactive problem!!!

int main() {
	ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
	cout << fixed << setprecision(11);
	srand((uint)time(0));

  int n;
  cin>>n;
  i64 arr[300][300];
  forh(i,0,n){
    forh(j,0,n){
      cin>>arr[i][j];
    }
  }
  i64 ans=0;
  forh(i,0,n){
    forh(j,i+1,n){
      bool need=true;
      forh(k,0,n){
        if(k==i||k==j)
          continue;
        if(arr[i][j]>arr[i][k]+arr[k][j]){
          cout<<-1<<endl;
          return 0;
        }
        else if(arr[i][j]<arr[i][k]+arr[k][j]){

        }
        else{
          need&=false;
        }
      }
      if(need)
        ans+=arr[i][j];
    }
  }
  cout<<ans<<endl;

	return 0;
}


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

using namespace std;

typedef long long int ll;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
 
    ll a[5];

    for(ll i=0; i<5; i++)
    {
        cin >> a[i];
    }

    ll k;
    cin >> k;

    for(ll i=0; i<5; i++)
    {
        for(ll j=0; j<5; j++)
        {
            if(abs(a[i]-a[j]) > k)
            {
                cout << ":(" << endl;
                return 0;
            }
        }
    }

    cout << "Yay!" << endl;

    return 0;
}

Measured memory_bytes: 256
N = int(input())

def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a

l = prime_factorize(N)

ans = 0
for prime in set(l):
    n_prime = l.count(prime)
    i = 1
    while (i + 2) * (i + 1) / 2 <= n_prime:
        i += 1
    ans += i

print(ans)

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)

int main(){
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int last_index = -1;
    for(int i = 0; i < n-1; i++){
        if(a[i]+a[i+1] >= l){
            last_index = i+1;
            break;
        }
    }
    if(last_index == -1){
        cout << "Impossible" << endl;
        return 0;
    }else{
        cout << "Possible" << endl;
        for(int i = 1; i < last_index; i++){
            cout << i << endl;
        }
        for(int i = n-1; i >= last_index; i--){
            cout << i << endl;
        }
    }
    return 0;

}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e15;
using namespace std;
typedef long long ll;
int main() {
  ll n, m;
  cin >> n >> m;
  bool conn[m][n];
  vector<ll> p(m);
  REP(i, m) REP(j, n) conn[i][j] = false;
  REP(i, m) {
    ll k;
    cin >> k;
    REP(j, k) {
      ll s;
      cin >> s;
      s--;
      conn[i][s] = true;
    }
  }
  REP(i, m) {
    ll P;
    cin >> P;
    p[i] = P;
  }

  ll ans = 0;
  ll cnt[m];
  REP(bit, (1 << n)) {
    REP(i, m) {
      cnt[i] = 0;
      REP(j, n) {
        if (bit & (1 << j)) {
          if (conn[i][j]) {
            cnt[i]++;
          }
        }
      }
    }

    bool ok = true;
    REP(i, m) {
      if (cnt[i] % 2 != p[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
/**
 * @author torith
 * @date 2018-10-28
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int sum = 0;
    vector<int> s;
    for (int i = 0; i < N; ++i) {
        int t; cin >> t;
        s.push_back(t);
        sum += t;
    }

    if(sum % 10 != 0){
        cout << sum << "\n";
        return 0;
    }

    sort(s.begin(),s.end());

    for (auto & a: s){
        if (a % 10 != 0) {
            cout << sum - a << "\n";
            return 0;
        }
    }
    cout << 0 << "\n";
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

// まずは全探索，次にDP
// 偶奇，逆から，ソート，出現回数，出現位置，DP
// 余事象，包除
// データ構造
// 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
int main() {
cin.tie(0);
ios::sync_with_stdio(false);

int N;
string S;
cin >> N >> S;

// ) が余分にあれば ( を先頭に追加．
int cntr = 0;
stack<char> st;
for (char c: S) {
    if (c == '(') st.push(c);
    if (c == ')') 
        if (st.empty()) ++cntr;
        else st.pop();
}
rep(i, 0, cntr) cout << '('; 
cout << S;
rep(i, 0, st.size()) cout << ')';
cout << "\n";
}

// 境界，出力文字列 チェック



Measured memory_bytes: 256
N = int(input())
A = []
for i in range(N):
  A.append(list(map(int,input().split())))

A.sort(key=lambda x:x[1])
n = 0
ans = "Yes"

for a in A:
  n += a[0]
  if n > a[1]:
    ans = "No"
print(ans)

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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    long int n;
    cin>>n;
    
    int arr[n];
    
    for(int i=0;i<n;i++)
    {
        cin>>arr[i];
    }
    
    sort(arr,arr+n);
    
    int cnt=0;
    for(int i=0;i<n-2;i++)
    {
        for(int j=i+1;j<n-1;j++)
        {
            for(int k=j+1;k<n;k++)
            {
                if(arr[i]+arr[j]>arr[k])
                cnt++;
            }
        }
    }
    
    cout<<cnt<<endl;
   return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <set>
#include <map>
#include <deque>
#define WMAX 10000
#define HMAX 1000007

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef long long ll;

ll A,B,C,a,b,c,N,W,H,ans = 0;
static const ll dx[8] = {0,1,1,1,0,-1,-1,-1},
					dy[8] = {1,1,0,-1,-1,-1,0,1};

void solve(){
	while(!(A%2) && !(B%2) && !(C%2)){
		ans++;
		ll i = (B+C)/2,j = (C+A)/2,k = (A+B)/2;
		if(A == i && B == j && C == k){
			ans = -1;
			break;
		}
		A = i,B = j,C = k;
	}
}

int main(){
	cin >> A >> B >> C;
	solve();
	cout << ans << "\n";
	return 0;
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) s >> x;
  return s;
}

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

    int H, W; cin >> H >> W;
    vector<string> v;;

    string s;
    rep(i, H) {
        cin >> s;
        if (s.find('#')!=string::npos)
            v.push_back(s);
    }

    vector<bool> col(W, false);
    rep(j, W) {
        rep(i, v.size()) {
            if (v[i][j] == '#') {
                col[j] = true;
                break;
            }
        }
    }

    rep(i, v.size()) {
        rep(j, W)
            if (col[j])
                cout << v[i][j];
        cout << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i = 0; i < n; i++)cin >> a[i];
  sort(a, a+n);
  a[n-1]/=2;
  int sum = 0;
  for(int i = 0; i < n; i++)sum+=a[i];
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ld long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define all(v) v.begin(),v.end()
#define ff first
#define ss second
#define rep(i, a, b) for(int i = a; i < (b); ++i)
//#define per(i, a, b) for(int i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define td(v) v.begin(),v.end()
#define sz(v) (int)v.size()
//#define M   1000000007 // 1e9 + 7
#define int long long
using namespace std;
typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> pii;
inline ll mod(ll n, ll m ){ ll ret = n%m; if(ret < 0) ret += m; return ret; }
ll gcd(ll a, ll b){return (b == 0LL ? a : gcd(b, a%b));}
ll exp(ll a,ll b,ll m){
    if(b==0LL) return 1LL;
    if(b==1LL) return mod(a,m);
    ll k = mod(exp(a,b/2,m),m);
    if(b&1LL){
        return mod(a*mod(k*k,m),m);
    }
    else return mod(k*k,m);
}


const int N = 3010;
int dp[N][N],a[N];
int S;
int n;
const int M = 998244353;
int solve(int id,int s){
  if(s>S)return 0;
  if(id==n+1){
    if(s==S)return 1;
    return 0;
  }
  int &x = dp[id][s];
  if(x!=-1)return x;

  x=0;
  x=(2LL*solve(id+1,s))%M;
  x = (x + solve(id+1,s+ a[id]))%M;
//  cout << id<<" "<<s <<" "<<x<<endl;
  return mod(x,M);
}

int32_t main(){
 fastio;
 cin>>n>>S;
 for(int i=1;i<=n;i++){
  cin >> a[i];
 }
 ms(dp,-1);
 cout << solve(1,0) << endl;
  // Math -> gcd it all
  // Did u check N=1? Did you switch N,M?
}

Measured memory_bytes: 74636
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    string s;
    cin>>s;
    stack<char> mae;
    for(int i=0;i<s.length();i++){
        if(s[i]=='S'){
            mae.push(s[i]);
        }else if(!mae.empty()&&s[i]=='T'&&mae.top()=='S'){
            mae.pop();
        }else{
            mae.push(s[i]);
        }
    }
    out(mae.size());
}


Measured memory_bytes: 3812
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int main(){
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    int n;
    n = 0;
    int L = s.length();
    for (int i = 0; i < L; i++) {
        if(s[i] == 'F'){
            n++;
        }
        else{
            break;
        }
    }
    vector<int> even, odd;
    int tmp = 0;
    bool check = false; //falseのときoddに入れる
    for (int i = n+1; i < L; i++) {
        if(s[i] == 'T'){
            if(check){
                if(tmp != 0){
                    even.push_back(tmp);
                }
            }
            else{
                if(tmp != 0){
                    odd.push_back(tmp);
                }
            }
            tmp = 0;
            check = !check;
        }
        else{
            tmp++;
        }
    }
    if(check){
        if(tmp != 0){
            even.push_back(tmp);
        }
    }
    else{
        if(tmp != 0){
            odd.push_back(tmp);
        }
    }

    int E, O;
    int LE, LO;
    LE = even.size();
    LO = odd.size();
    E = 0; O = 0;
    for (int i = 0; i < LE; i++) {
        E += even[i];
        //printf("%d ", even[i]);
    }
    //printf("\n");
    for (int i = 0; i < LO; i++) {
        O += odd[i];
        //printf("%d ", odd[i]);
    }
    //printf("\n");

    if(((E - x + n) % 2 == 1) || (E - x + n < 0)){
        No();
        return 0;
    }
    if(((O - y) % 2 == 1) || (O - y < 0)){
        No();
        return 0;
    }

    vector<bool> dp(E+1, false);
    dp[0] = true;
    for (int i = 0; i < LE; i++) {
        for (int j = E; j >= 0; j--) {
            if(j - even[i] >= 0 && dp[j - even[i]] == true){
                dp[j] = true; 
            }
        }
    }
    if(dp[(E - x + n) / 2] == false){
        No();
        return 0;
    }

    dp.resize(O + 1);
    fill(ALL(dp), false);
    dp[0] = true;
    for (int i = 0; i < LO; i++) {
        for (int j = O; j >= 0; j--) {
            if(j - odd[i] >= 0 && dp[j - odd[i]] == true){
                dp[j] = true; 
            }
        }
    }
    if(dp[(O-y) / 2] == false){
        No();
        return 0;
    }

    Yes();
    return 0;


}

Measured memory_bytes: 3668