akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;


int main() {
  int a,b,c,d;

  cin >> a >> b >> c >> d;

  bool alice[100], bob[100];

  for(int i = 0;i<100;i++){
    alice[i] = false;
    bob[i] = false;
  }

  for(int i = a;i<b;i++){
    alice[i] = true;
  }
  for(int i = c;i<d;i++){
    bob[i] = true;
  }

  int time = 0;

  for(int i=0;i<100;i++){
    if(alice[i]&&bob[i]) time++;
  }

  cout << time;

}


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

using namespace std;

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d ;
  if ((a+b) < (c+d)) {
    cout<< "Right" << endl;
  } else if ((a+b) > (c+d)) {
    cout<< "Left" << endl;
  } else {
    cout<< "Balanced" << endl;
  } 
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
#define int long long
#define veb vector<bool>
#define vveb vector<veb>
#define vel vector<long long>
#define vvel vector<vel>
#define vvvel vector<vvel>
void mmin(int &a, int b) { a = min(a, b); }
void mmax(int &a, int b) { a = max(a, b); }
void sor(vel &v) { sort(v.begin(), v.end()); }
int zero(void) { return 0; }
signed main() {
	int n;
	cin >> n;
	vel l(n);
	for (int i = 0; i < n; i++) cin >> l[i];
	sor(l);
	int ans = l[n - 1];
	for (int i = 0; i + 1 < n; i++) {
		ans -= l[i];
	}
	if (ans < 0) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

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

typedef long long int ll;
#define endl '\n'
#define ld long double
#define all(a) a.begin(),a.end()
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define sz(v) (int)v.size() 
#define UB upper_bound
#define LB lower_bound
#define OST tree<pii, null_type,less<pii>, rb_tree_tag,tree_order_statistics_node_update>

const int INF = 1e15 + 0;
const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve() {
   int x; cin >> x;
   int cur = 100, cnt = 0;
   while(cur < x) {
    cnt++; cur += (cur/100);
   }
   cout << cnt << '\n';
}

signed main() {
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

    #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif
    int t = 1; // cin >> t;
    for(int i = 1; i <= t; i++) {
        solve();
    }
}    


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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef tuple<ll, ll, ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef vector<iii> viii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define REP(i,n) for (ll i = 0; i < n; ++i)
#define REPR(i,n) for (ll i = n-1; i >= 0; --i)
#define FOR(i,m,n) for (ll i = m; i < n; ++i)
#define FORR(i,m,n) for (ll i = n-1; i >= m; --i)
#define FORE(x,xs) for (const auto& x : xs)
#define FORI(i,v) for (auto i = v.begin(); i != v.end(); i++)
#define ALL(v) v.begin(), v.end()
#define CHMIN(x,y) x = min(x, y)
#define CHMAX(x,y) x = max(x, y)
#define YES(b) cout << ((b) ? "YES" : "NO") << endl
#define Yes(b) cout << ((b) ? "Yes" : "No") << endl

const int MAX = 1e5+10;

int N, Q, A[MAX], B[MAX], C[MAX];

void solve() {
    ll ans = 0;
    vi cnt(MAX);
    REP (i, N) {
        ans += A[i];
        cnt[A[i]]++;
    }

    REP (q, Q) {
        int b = B[q], c = C[q];
        ans += (c-b) * cnt[b];
        cnt[c] += cnt[b];
        cnt[b] = 0;
        cout << ans << endl;
    }
}

int main() {
    cout << fixed << setprecision(15);
    cin >> N;
    REP (i, N) cin >> A[i];
    cin >> Q;
    REP (i, Q) cin >> B[i] >> C[i];
    solve();
}

Measured memory_bytes: 4984
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

int gcd(int a, int b) {
	if (a < b) {
		int tmp = a;
		a = b;
		b = tmp;
	}
	int r = a % b;
	while (r != 0) {
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}


int main() {
	int a, b, c, d, e, k;
	cin >> a >> b >> c >> d >> e >> k;
	if (e - a > k)cout << ":(" << endl;
	else cout << "Yay!" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include "algorithm"
typedef long long ll;
using namespace std;
ll A[200050];
bool cmp(ll a,ll b){
	return a>b;
}
int main() {
    int N;
    cin >> N;
    int A[N];
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    sort(A,A+N,cmp);

    ll res = A[0];
    int number = 2;
    for (int i = 1; number<N ; i++ ) {
        if(number+2<=N) {
            res = res + 2 * A[i];
            number+=2;
        }else{
            res = res + A[i];
            number++;
        }
    }
    cout << res;
    return 0;
    
}


Measured memory_bytes: 4360
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        long ans = 0;
        long start = 0;
        for (int i = 1; i < k; i++) {
            start += i;
        }
        long end = 0;
        for (int i = n; i > n - k; i--) {
            end += i;
        }
        for (int i = k; i <= n + 1; i++) {
            if (i > k) {
                start += i - 1;
                end += n + 1 - i;
            }
            ans += end - start + 1;
            ans %= 1000000007;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 35784
list_W = []
list_K = []

for i in range(10) :
    list_W.append(int(input()))
for i in range(10) :
    list_K.append(int(input()))

list_W.sort(reverse = True)
list_K.sort(reverse = True)

sum_W = sum(list_W[0:3])
sum_K = sum(list_K[0:3])

print(sum_W, sum_K)



Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define int long long int
#define endl "\n"
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define mem(a,b) memset(a,b,sizeof(a))
#define loop(i,n) for(int i=0;i<(n);i++)
#define fors(a,b,i) for(int i=(a);i<=(b);i++)
#define ford(a,b,i) for(int i=(a);i>=(b);i--)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fastm_fast ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL)
using namespace std;
const int  mod = 1e9 + 7;
#define pb push_back
#define mp make_pair
#define S second
#define F first
const int MAX = 1e5;
void sujho()
{
   
   
   int n,k;
   cin >> n >> k;
   
   vector<int> v(n);
   
   loop(i,n) cin >> v[i];
   
   vector<int> dp(n+1,INT_MAX);
   

   
   dp[0] = 0;
   
   for(int i = 1; i < n; i++)
   {
      for(int j = 1; j <= k; j++)
         {
            if(i - j < 0 ) break;
            
            dp[i] = min(dp[i] , dp[i-j] + abs(v[i] - v[i-j]));
         }
         
   }
   cout<<dp[n-1]<<endl;
   
   
   
}
int32_t main()
 {
 fastm_fast;
//  int tt;
//  cin >> tt;
//  while(tt--)
  {
    sujho();
 }
 return 0;
 }

Measured memory_bytes: 4656
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>

using namespace std;

typedef complex<double> P;

int main(){

	pair<double,double> ret[1001];
	
	double cx,cy;
	cx=1,cy=0;
	ret[1].first=cy,ret[1].second=cx;
	for(int i = 2; i < 1001; i++){
		complex<double> cv=complex<double>(cx,cy);
		// äËÌÊu©ç»ÝÌÊuÖÌPÊ@üxNg
		P nve = P(-cy,cx)/abs(P(-cy,cx));
		double ny=nve.imag()+cy;
		double nx=nve.real()+cx;
		cx=nx;
		cy=ny;
		ret[i].first=cy,ret[i].second=cx;
	}
	int n;
	while(cin>>n&&n!=-1){
		cout<<ret[n].second<<endl;
		cout<<ret[n].first<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <stdio.h>

int main(){
  int x, y, cnt=0, sum=0;
  double average=0;
  while(scanf("%d,%d", &x, &y) != EOF){
    sum += x*y;
    if(y != 0){
    cnt++;
    }
    average += (double)y;
  }
  printf("%d\n%d\n",sum,  (int)((average/cnt)+0.5));
  return 0;

}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin >> n >> m && n && m){
    ll t = 0,h = 0;
    vary(ll,T,n,0);
    vary(ll,H,m,0);
    rep(i,n){
      cin >> T[i];
      t += T[i];
    }
    rep(i,m){
      cin >> H[i];
      h += H[i];
    }
    rep(i,n){
      rep(j,m){
        if(t - T[i] + H[j] == h - H[j] + T[i]){
          cout << T[i] << " " << H[j] << endl;
          i = n;
          break;
        }
      }
      if(i == n-1){
        cout << -1 << endl;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3032
#include <algorithm>
#include <iostream>

using namespace std;
#define pi 3.14159265

int main()
{
	long long ans = 0, i = 0, j = 0, k = 0, l = 0;
	long long a, b, c;
	cin >> a >> b >> c;

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)
		ans = 0;
	else
		ans=min(a*b,min(b*c,c*a));

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define repr(i,n) for(int i = n-1; i >= 0; i--)
using namespace std;
typedef long long ll;
int n;
vector<int> b;
ll ans;
const int inf = 100000000;
int main(int argc, char** argv){
	cin >> n;
	b.resize(n);
	rep(i,n-1){
		cin >> b[i];
	}
	b[n-1] = inf;
	ans = b[0];
	rep(i,n-1){
		ans += min(b[i],b[i+1]);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC043A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, s;

            s = 0;
            n = int.Parse(Console.ReadLine());

            for (int i = 1; i <= n; i++)
                s = s + i;

            Console.WriteLine(s);

            Console.ReadKey();

               
        }
    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using static System.Math;
 
public class Hello{
    public static void Main(){
//        long readhp = long.Parse(ReadLine());
//        string[] reader = ReadLine().Split(' ');
//        int monsterhp = int.Parse(reader[0]);
//        int magicnum = int.Parse(reader[1]);
        string[] reader = ReadLine().Split(' ');
        string[] reader1 = ReadLine().Split(' ');
        int a = int.Parse(reader1[0]);
        int b = int.Parse(reader1[1]);
        string c = ReadLine();
        //WriteLine(d);
        if(c == reader[0]){
            a-=1;
            WriteLine($"{a} {b}");
        }else if(c == reader[1]){
            b-=1;
            WriteLine($"{a} {b}");
        }else{
            WriteLine($"{a} {b}");
        }
//        string[] readerhp = ReadLine().Split(' ');
//        long total = 0;
//        int leng = readerhp.Length;
/*        int[,] map = new int[magicnum+10,monsterhp+10];
        for(int i=0;i<=monsterhp;i++){
            map[0,i] = 1000000000;
        }
        for(int i=1;i<=magicnum;i++){
            string[] reader2 = ReadLine().Split(' ');
            int magicdam = int.Parse(reader2[0]);
            int magicuse = int.Parse(reader2[1]);
            
            for(int j=1;j<=monsterhp;j++){
                if(j <= magicdam){
                    map[i,j] = Min(map[i-1,j],magicuse);
                }else{
                    map[i,j] = Min(map[i-1,j],map[i,j-magicdam]+magicuse);
                }
            }
        }
        /*for(int i=0;i<=magicnum;i++){
            for(int j=0;j<=monsterhp;j++){
                Write(map[i,j]);
                Write(" ");
            }
            WriteLine();
        }*/
        //WriteLine(map[magicnum,monsterhp]);*/
    }
}


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

#if defined(DEBUG)

#include <unistd.h>
#include <sys/fcntl.h>
#define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
#define DCALL(func, ...) func(__VA_ARGS__)

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#else  // defined(DEBUG)

#define DLOG(...)
#define DCALL(func, ...)

#endif // defined(DEBUG)

int main(int argc, char *argv[]) {
#if defined(DEBUG)
  // GDB on Cygwin ignores redirection at run command.
  if (argc == 2) dup2(open(argv[1], 0), 0);
#else
  // For performance.  We should not use C-style stdio functions
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
#endif
  cout << setprecision(20);

  int A, B, C; cin >> A >> B >> C;
  int x = C - (A - B);
  cout << max(0, x) << endl;

  return 0;
}



Measured memory_bytes: 256
#include<algorithm>
#include<complex>
#include<ctype.h>
#include<iomanip>
#include<iostream>
#include<map>
#include<math.h>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<stdio.h>
#include<string>
#include<string>
#include<vector>

using namespace std;
typedef long long ll;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

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

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll N;
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    vector<ll> B(N);
    FOR(i, 0, N){
        cin >> B.at(i);
    }

    ll a_sum = 0;
    FOR(i, 0, N){
        a_sum += A[i];
    }

    ll b_sum = 0;
    FOR(i, 0, N){
        b_sum += B[i];
    }

    // どうやりくりしても無理
    if(a_sum < b_sum){
        p(-1);
        return 0;
    }

    // 以降は並び替えれば受かる

    // 差分 A - B
    vector<ll> C(N);
    FOR(i, 0, N){
        C[i] = A[i] - B[i];
    }

    // 足りてない数
    ll shortage_num = 0;
    ll shortage_sum = 0;
    FOR(i, 0, N){
        if(C[i] < 0){
            shortage_num++;
            shortage_sum -= C[i];
        }
    }

    // すでに足りている
    if(shortage_num==0){
        p(0);
        return 0;
    }

    // 足りている箇所から借りてくる
    sort(ALL(C), greater<ll>());
    ll rent_num = 0;
    FOR(i, 0, N){
        if(C[i]>0){
            rent_num++;
            shortage_sum -= C[i];
        }

        if(shortage_sum<=0){
            break;
        }
    }

    p(shortage_num + rent_num);
    
    return 0;
}

Measured memory_bytes: 2560
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template<class T> inline T sqr(T x) {return x*x;}

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

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

#define CLR(a) memset((a), 0 ,sizeof(a))

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

int main(void){
  int S;
  cin >> S;

  int h, m, s;
  h = S/3600;
  S = S%3600;
  m = S/60;
  S = S%60;
  s = S;

  cout << h << ":" << m << ":" << s << endl;

  return 0;
}

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

using namespace std;

int main(){
  string s1,s2;
  cin >> s1 >> s2;
  if((s1[0]==s2[2])&&(s1[1]==s2[1])&&(s1[2]==s2[0]))cout<<"YES";
  else cout<<"NO";
    
}


Measured memory_bytes: 256
#include <iostream>
#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>
#include <iomanip>
using namespace std;

int main() {
	cout << fixed << setprecision(15);
	double x1, y1, x2, y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double d =pow((x1-x2),2) + pow((y1-y2),2);
	double dis = sqrt(d);
	cout << dis << endl;
	return 0;
}



Measured memory_bytes: 3284
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
using namespace std;
int n,k;
int main(){
	scanf("%d",&n);k=n/1000;
	if(n==k*1000)putchar('0');
	else printf("%d",(k+1)*1000-n);
	return 0;
}

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

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

    ll t[N + 1], x[N + 1], y[N + 1];
    t[0] = 0;
    x[0] = 0;
    y[0] = 0;
    for(ll i = 1; i < N + 1; i++) {
        cin >> t[i] >> x[i] >> y[i];
    }

    for(ll i = 1; i < N + 1; i++) {
        ll dist = abs(x[i] - x[i - 1]) + abs(y[i] - y[i - 1]);
        ll td = t[i] - t[i - 1];
        if(!(td - dist >= 0 && (td - dist) % 2 == 0)) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    
    return 0;
}

Measured memory_bytes: 5928
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
typedef long long ll;
typedef long double ld;


int main() {
    ll N;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        ll ans = 0;
        for(int x = 1; x * x <= i; x++){
            for(int y = 1; x * x + y * y + x * y <= i; y++){
                ld z = (-(x + y) + sqrt(-3 * x * x - 2 * x * y - 3 * y * y + 4 * i)) / 2;
                if( z >= 1 &&  ceill(z) == floor(z) ) ans++;
            }
        }
        cout << ans << endl;
    }
}

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

#ifdef LOCAL
#include "dump.hpp"
#else
#define dump(...)
#define dumpv(...)
#endif

#define rep(i, n) for (int i = 0; i < (n); i++)
#define mins(x, y) (x = min(x, y))
#define maxs(x, y) (x = max(x, y))
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using P = pair<int, int>;
const int MOD = 1e9 + 7;
const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

void solve() {
  int n;
  cin >> n;
  vi a(n + 1);
  rep(i, n + 1) cin >> a[i];
  dump(a);
  vl mn(n + 1), mx(n + 1);
  mn[n] = a[n];
  mx[n] = a[n];
  rep(i, n) {
    int j = n - i - 1;
    mn[j] = (mn[j + 1] + 1) / 2 + a[j];
    mx[j] = mx[j + 1] + a[j];
  }
  dump(mn, mx);
  if (1 < mn[0]) {
    cout << -1 << endl;
    return;
  }
  ll cnt = 1;
  ll b = 1;
  rep(i, n) {
    int j = i + 1;
    b *= 2;
    mins(b, mx[j]);
    cnt += b;
    b -= a[j];
  }
  cout << cnt << endl;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(15);
  // freopen("temp.1", "r", stdin);
  solve();
  return 0;
}

Measured memory_bytes: 5312
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")


void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
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 upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s1[55],s2[55];
    ll n,ans=1;
    scanf("%lld%s%s",&n,s1,s2);
    rep(i,0,n){
        if(s1[i]==s2[i]){
            if(i==0){
                ans*=3;
            }else{
                if(s1[i-1]==s2[i-1]){
                    ans=ans*2%MOD1;
                }
            }
        }else{
            if(i==0){
                ans*=6;
            }else{
                if(s1[i-1]==s2[i-1]){
                    ans=ans*2%MOD1;
                }else{
                    ans=ans*3%MOD1;
                }
            }
            i++;
        }
    }
    printf("%lld\n",ans);
    return 0;
}


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

typedef long long ll;
ll mod=1000000007;
	string a,b;

ll dp[60][3][3];
ll calc(int i, int c1, int c2) {
	if(dp[i][c1][c2]!=-1) return dp[i][c1][c2];
	if(a[i]!=b[i] && c1==c2) return 0;

	if(a[i]==b[i] && c1!=c2) return 0;


	if(i==0) {
		 return 1;
	 }
			
	ll ans=0;
	for(int ii=0;ii<3;++ii) {
		for(int jj=0;jj<3;++jj) {
			//if(c1==ii || c2==jj) continue ;
			if(ii==jj && a[i-1]!=b[i-1]) continue ;


			if(ii!=jj && a[i-1]==b[i-1]) continue ;
									
			if(a[i]==a[i-1] && c1!=ii) continue ;
			
			if(c1==ii && a[i]!=a[i-1]) continue ;
			
			if(b[i]==b[i-1] && c2!=jj) continue ;
			if(c2==jj && b[i]!=b[i-1]) continue ;
			
			ans+=calc(i-1, ii, jj);
			ans%=mod;
		}
	}
	
	return dp[i][c1][c2]=ans;
}

int main() {
	memset(dp, -1, sizeof dp);	
	
	int n;
	cin>>n;
	cin>>a>>b;
	
	ll ans=0;
	for(int i=0;i<3;++i) for(int j=0;j<3;++j) {
		ans=(ans+calc(n-1,i,j))%mod;
	}
	
	
	cout<<ans<<"\n";
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(){
    string card,str;
    int m,h;
    while(cin>>card&&card!="-"){
        cin>>m;
        for(int i=0;i<m;i++){
            cin>>h;
            str=card.substr(0,h);
            card.erase(0,h);
            card=card+str;
        }cout<<card<<endl;
    }
    return 0;
}


Measured memory_bytes: 3168
S = input()

B_nums = []
for s in S:
    if len(B_nums) == 0:
        B_nums.append(1 if s == "B" else 0)
    else:
        B_nums.append((B_nums[-1] + 1) if s == "B" else B_nums[-1])

res = 0
for index, s in enumerate(S):
    if s == "W":
        res += B_nums[index]

print(res)



Measured memory_bytes: 11400
from sys import stdin
def input():
    return stdin.readline().strip()

import heapq

def main():
    h, w, k = map(int, input().split())
    x1, y1, x2, y2 = map(int, input().split())

    # surround the square with '@'
    c = [['@'] * (w+2)]
    for _ in range(h):
        i = input()
        l = ['@']
        for j in i:
            l.append(j)
        l.append('@')
        c.append(l)
    c.append(['@'] * (w+2))

    # Dijkstra
    # seen[x][y] = the minimum cost of (x, y)
    # if seen[x][y] == -1, (x, y) is unresearched
    seen = [[-1] * (w+2) for _ in range(h+2)]

    # todo[i] == (cost, x, y, direction)
    todo = [(0, x1, y1, 0)]
    heapq.heapify(todo)

    # direction
    dx = [-1, 0, 1, 0]
    dy = [0, 1, 0, -1]

    while len(todo) > 0:
        cost, xi, yi, direction = heapq.heappop(todo)

        # only straight
        if seen[xi][yi] != -1:
            if (seen[xi][yi]+k-1)//k * k > cost:
                xj, yj = xi + dx[direction], yi + dy[direction]
                if c[xj][yj] == '.':
                    heapq.heappush(todo, (cost+1, xj, yj, direction))
            continue
        seen[xi][yi] = cost

        # goal
        if xi == x2 and yi == y2:
            print((cost+k-1)//k)
            exit()
        
        # 4 directions
        for j in range(4):
            xj, yj = xi + dx[j], yi + dy[j]
            if c[xj][yj] == '.':
                if j == direction:
                    if seen[xj][yj] == -1 or (seen[xj][yj]+k-1)//k * k > cost:
                        heapq.heappush(todo, (cost+1, xj, yj, j))
                elif seen[xj][yj] == -1:
                    heapq.heappush(todo, ((cost+k-1)//k * k + 1, xj, yj, j))

    print(-1)

main()

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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

typedef struct {
    bool L, R;
} p_t;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<pair<Int, Int>> v(n);
    for (Int i = 0; i < n; i++) {
        cin >> v[i].fi >> v[i].se;
    }
    sort(all(v));
    Int cnt = 0;
    for (Int i = 0; i < n; i++) {
        cnt += v[i].se;
        if (k <= cnt) {
            dump(v[i].fi);
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using P = pair<long long,long long>;

int main(){
  int n,k; cin>>n>>k;
  vector<P> dr(n);
  for(int i=0;i<n;i++){
    long long a,b; cin>>a>>b;
    dr[i]=P(a,b);
  }
  sort(dr.begin(),dr.end());
  int count=0;
  unsigned long long ans=0;
  for(int i=0;i<n;i++){
    if(k>count+dr[i].second){
      ans+=dr[i].first*dr[i].second;
      count+=dr[i].second;
    }else{
      cout<<ans+dr[i].first*(k-count)<<endl;
      return 0;
    }
  }
}

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

int main() {
	int n, c0=0, c1=0, c2=0, c3=0;
	cin >> n;
    string si;
	for (int i = 0; i < n; i++) {
        cin >> si;
		if(si=="AC") c0++;
        if(si=="WA") c1++;
        if(si=="TLE") c2++;
        if(si=="RE") c3++;
	}
	cout << "AC x " << c0 << endl;
    cout << "WA x " << c1 << endl;
    cout << "TLE x " << c2 << endl;
    cout << "RE x " << c3 << endl;
}


Measured memory_bytes: 3576
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define ARR(array) for(int i=0;i<array.size();i++)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 1000000007
#define SIZE 10005
#define PI 	3.14159265358979323846

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; } //最大公倍数

ll input(){
  ll a;
  cin >> a;
  return a;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,x;
    cin >> k >> x;
    FOR(i,max(-(ll)1000000,x-k+1),min((ll)1000000,x+k))cout << i << " ";
    cout << endl;
}

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

using namespace std;

int main(){
    int n;
    cin >> n;
    int p[n];
    int temp;
    int c=0;
    int count=0;
    for(int i=0; i<n; ++i){
        cin >> p[i];
        p[i] -= i + 1;
        c += p[i];
        if(p[i]!=0) ++count;
    }
    if(c==0&&count<3) cout << "YES" << endl;
    else cout << "NO" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// #define ll long long
// bool isEven(ll n) {return (n%2!=0)?false:true;}

using namespace std;

//atcoder - dp
//d

int N, W;
long long weight[105], value[105];
long long memo[105][100005];

long long dp(int i, int w)
{

    if(w<0)
        return INT_MIN;
    else if(w==0&&i>=0)
        return 0;
    else if(i<0)
        return 0;

    if(memo[i][w]!=-1)
        return memo[i][w];


    memo[i][w] = max(value[i] + dp(i-1, w-weight[i]) , dp(i-1, w));

    return memo[i][w];
}

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

    for (int i = 0; i < N; ++i)
    {
        cin>>weight[i]>>value[i];
    }

    memset(memo, -1, sizeof(memo));

    // for (int i = 0; i < N; ++i)
    // {
    //     FOR0(j, 10)
    //         cout<<memo[i][j]<<" ";
    //     cout<<endl;
    // }

    cout<<dp(N-1, W)<<endl;;
}

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

#define int long long

#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)

using namespace std;
using P = pair<int, int>;
using ll = long long;
using ld = double;

using bint = boost::multiprecision::cpp_int;

constexpr int MOD = 1e9 + 7;

template<typename T, typename U>
istream& operator>>(istream& in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}

// https://twitter.com/vane11ope ←フォローしましょう
// (ノ)>◡<(ヾ)ﾓﾁﾓﾁ
signed main(signed argc, char* argv[]) {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int x;
    cin>>x;
    if(30<=x)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 3612
import sys, re
from math import ceil, floor, sqrt, pi, factorial, gcd
from copy import deepcopy
from collections import Counter, deque
from heapq import heapify, heappop, heappush
from itertools import accumulate, product, combinations, combinations_with_replacement
from bisect import bisect, bisect_left, bisect_right
from functools import reduce
from decimal import Decimal, getcontext
# input = sys.stdin.readline 
def i_input(): return int(input())
def i_map(): return map(int, input().split())
def i_list(): return list(i_map())
def i_row(N): return [i_input() for _ in range(N)]
def i_row_list(N): return [i_list() for _ in range(N)]
def s_input(): return input()
def s_map(): return input().split()
def s_list(): return list(s_map())
def s_row(N): return [s_input for _ in range(N)]
def s_row_str(N): return [s_list() for _ in range(N)]
def s_row_list(N): return [list(s_input()) for _ in range(N)]
def lcm(a, b): return a * b // gcd(a, b)
sys.setrecursionlimit(10 ** 6)
INF = float('inf')
MOD = 10 ** 9 + 7
num_list = []
str_list = []

def main():
    n = i_input()

    print(800*n-n//15*200)

if __name__ == '__main__':
    main()


Measured memory_bytes: 77192
import java.io.DataInputStream;
import java.io.IOException;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.SortedMap;
import java.util.TreeMap;

public class Main {

	// invoked from main
	private void solve() throws Exception {
		int A = in.i();
		int P = in.i();
		out.println((3*A + P)/2);
	}


	public static void main(String[] args) throws Exception {
		instance.solve();
	}

	static PrintStream out = System.out;
	static FastReader in = new FastReader();
	static Main instance = new Main();
}

class FastReader {
	final private int BUF_SIZE = 1 << 16;
	private DataInputStream din = new DataInputStream(System.in);
	private byte[] buffer = new byte[BUF_SIZE];
	private int bufferPointer, bytesRead;

	String s() throws IOException {
		return s(64);
	}

	String s(int capacity) throws IOException {
		byte[] buf = new byte[capacity];
		int cnt = 0, c;
		while ((c = c()) != -1) {
			if (c == '\n') break;
			buf[cnt++] = (byte) c;
		}
		return new String(buf, 0, cnt);
	}

	int i() throws IOException {
		int ret = 0;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	long l() throws IOException {
		long ret = 0;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		return neg ? -ret : ret;
	}

	double d() throws IOException {
		double ret = 0, div = 1;
		byte c = c();
		while (c <= ' ') c = c();
		boolean neg = (c == '-');
		if (neg) c = c();
		do {
			ret = ret * 10 + c - '0';
		} while ((c = c()) >= '0' && c <= '9');
		if (c == '.')
			while ((c = c()) >= '0' && c <= '9')
				ret += (c - '0') / (div *= 10);
		return neg ? -ret : ret;
	}

	private void fillBuffer() throws IOException {
		bytesRead = din.read(buffer, bufferPointer = 0, BUF_SIZE);
		if (bytesRead == -1) buffer[0] = -1;
	}

	byte c() throws IOException {
		if (bufferPointer == bytesRead) fillBuffer();
		return buffer[bufferPointer++];
	}
}



Measured memory_bytes: 21204
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

vector<pair<int, int>> solve(int N, int M){
    vector<pair<int, int>> v(M);
    for(int i=0; i<M; i++){
        v[i] = make_pair(i+1, N-i);
    }
    if(N%2==0){
        for(int i=N/4; i<M; i++)
            v[i].second--;
    }

    //set<int> st;
    //set<int> st2;
    //for(int i=0; i<M; i++){
    //    int a = v[i].first;
    //    int b = v[i].second;
    //    st2.insert(a);
    //    st2.insert(b);
    //    int hoge = min(b-a, a+N-b);
    //    st.insert(hoge);
    //}
    //assert(st.size()==M);
    //assert(st2.size()==2*M);

    return v;
}

int main(){
    //for(int m=1; m<=100; m++){
    //    for(int n=2*m+1; n<=1000; n++){
    //        //cerr << n << " " << m << endl;
    //        solve(n, m);
    //    }
    //}



    int N, M;
    cin >> N >> M;
    auto v = solve(N, M);
    for(auto z : v){
        cout << z.first << " " << z.second << endl;
    }



    return 0;
}

Measured memory_bytes: 3952
n = int(input())
A = list(map(int, input().split()))

# 4の倍数と2の倍数を(重複しないように)カウントする
mul4, mul2 = 0, 0
for a in A:
    if a%4 == 0:
        mul4 += 1
    elif a%2 == 0:
        mul2 += 1
others = n - mul4 - mul2

if others <= mul4:  # 1, 4, 1, 4, 2, 2...
    print('Yes')
elif mul2 == 0 and others <= mul4 + 1:  # 1, 4, 1, 4, 1...
    print('Yes')
else:
    print('No')

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

const int N = 121;
int a[N], ans[N];

int main() {
	ios :: sync_with_stdio(0);
	int n, m; cin >> n >> m;
	for(int i = 1; i <= m; i ++)
		cin >> a[i];
	for(int i = 1; i <= m; i ++) {
		for(int j = 1; j <= n; j ++) {
			int x; cin >> x;
			if(x == a[i])
				ans[j] ++;
			else
				ans[a[i]] ++;
		}
	}
	for(int i = 1; i <= n; i ++)
		cout << ans[i] << '\n';
}

Measured memory_bytes: 3124
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <stdlib.h>
#include <math.h>


int merge(long int a1[], long int a2[], long int a1_size, long int a2_size, long int a[]);
int mergeSort(long int a[], long int number);

int main(void)
{
	long int n;
	long int count;
	long int i, j, k;
	long int work;
	long int flg;
	long int l[2000];
	
	scanf("%ld", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%ld", &l[i]);
	}
	
	mergeSort(l, n);
	/*
	for(i = 0; i < n; i++) {
		printf("%ld\n", l[i]);
	}
	*/
	
	count = 0;
	
	for(i = 0; i < n - 2; i++) {
		flg = 0;
		for(j = i + 1; j < n - 1; j++) {
			if(i == j) {
				continue;
			}
			for(k = j + 1; k < n; k++) {
				if( (i == k) || (j == k) ) {
					continue;
				}
				if(l[i] < l[j] + l[k]) {
					count++;
				} else {
					if(k == j + 1) {
						flg = 1;
					}
					break;
				}
			}
			if(flg) {
				break;
			}
		}
	}
	
	printf("%ld\n", count);
	
	return 0;
}

int merge(long int a1[], long int a2[], long int a1_size, long int a2_size, long int a[])
{
	long int i = 0, j = 0;
	
	while( (i < a1_size ) || (j < a2_size) ){
		if( (j >= a2_size ) || ( (i < a1_size) && (a1[i] > a2[j]) ) ) {
			a[i + j] = a1[i];
			i++;
		} else {
			a[i + j] = a2[j];
			j++;
		}
	}
	
	return 0;
}


int mergeSort(long int a[], long int number)
{
	long int m = number / 2, n = number - m;
	long int a1[m];
	long int a2[n];
	int i, j;
	
	if(number > 1) {
		for(i = 0; i < m; i++) {
			a1[i] = a[i];
		}
		for(i = 0; i < n; i++) {
			a2[i] = a[m + i];
		}
		mergeSort(a1, m);
		mergeSort(a2, n);
		merge(a1, a2, m, n, a);
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int main()
{
  int n;
  ll a[100001], b[100000];
  cin >> n;
  REP(i, n + 1)
  {
    cin >> a[i];
  }
  REP(i, n)
  {
    cin >> b[i];
  }

  ll ans = 0;

  REP(i, n)
  {
    if (a[i] + a[i + 1] <= b[i])
    {
      ans += a[i] + a[i + 1];
      a[i + 1] = 0;
      a[i] = 0;
    }
    else if (a[i] <= b[i])
    {
      ans += b[i];
      a[i + 1] = a[i + 1] - (b[i] - a[i]);
      a[i] = 0;
    }
    else
    {
      ans += b[i];
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<iostream>
#include<map>
using namespace std;
map<long long,int> mp;
int h[300010],l[300010];
long long hmx[300010],lmx[300010],cnt1,cnt2,mx1,mx2;
long long n,m,k,ans;
int main()
{
    int i,j;
    long long t1,t2;
    cin>>n>>m>>k;
    for(i=1;i<=k;i++)
    {
        cin>>t1>>t2;
        mp[t1*n+t2]=1;
        h[t1]++;
        l[t2]++;
    }
    for(i=1;i<=300000;i++)
     if(h[i]>mx1)
      mx1=h[i];
    for(i=1;i<=300000;i++)
     if(h[i]==mx1)
      hmx[++cnt1]=i;
    for(i=1;i<=300000;i++)
     if(l[i]>mx2)
      mx2=l[i];
    for(i=1;i<=300000;i++)
     if(l[i]==mx2)
      lmx[++cnt2]=i;
    if(cnt1*cnt2>k) cout<<mx1+mx2;
    else
    {
        ans=-1;
        for(i=1;i<=cnt1;i++)
         for(j=1;j<=cnt2;j++)
         {
             t1=hmx[i];
             t2=lmx[j];
             if(mp[t1*n+t2]==0) ans=0;
         }
        cout<<ans+mx1+mx2;
    }
    system("pause");
}
    


Measured memory_bytes: 29444
#include <iostream>
   
int main() {
  int sec;
  std::cin >> sec;

  int hour = sec / 3600;
  int tmp = sec % 3600;
  int min = tmp / 60;
  sec = tmp % 60;

  std::cout << hour << ":" << min << ":" << sec << std::endl;
  return 0;
} 


Measured memory_bytes: 3100
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
 
using namespace std;
 
int main(){
	ios_base::sync_with_stdio(false);
	int n;
	string s;
	cin >> n >> s;
	vector<int> a(n + 1);
	for(int i = 0; i < n; ++i){
              a[i + 1] = a[i];
               if(s[i] == 'E') a[i + 1]++;
	}
	int answer = n;
	for(int i = 0; i < n; ++i){
		const int left = a[i] - a[0];
		const int right = a[n] - a[i + 1];
		answer = min(answer, (i - left) + right);
	}
	cout << answer << endl;
	return 0;
}

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

int main() {
	int R, G, B, N; cin >> R >> G >> B >> N;

	long long int ans = 0;
	for (int r = 0; R * r <= N; r++) {
		for (int g = 0; R * r + G * g <= N;g++) {
			if ((N - R * r - G * g) % B == 0) {

				ans++;
			}
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int a[10000], min, max, n, i;
    long long sum = 0;
    scanf("%d", &n);
    for(i = 0; i < n; i++){
        scanf("%d", &a[i]);
        sum += a[i];
    }
    max = min = a[0];
    for(i = 1; i < n; i++){
        if(a[i] > max)max = a[i];
        if(a[i] < min)min = a[i];
    }
    printf("%d %d %lld\n", min, max, sum);

    return 0;
}


Measured memory_bytes: 2104
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

template<class T>
bool UpdateMax(T &a, const T &b){
  if(a<b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template<class T>
bool UpdateMin(T &a, const T &b){
  if(a>b){
    a=b;
    return true;
  }else{
    return false;
  }
}

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int d;
  cin>>d;
  vector<int> c(27);
  vector<vector<int>> s(d+1, vector<int>(27));
  vector<set<int>> date(27);

  for(int i=1;i<=26;i++){
    cin>>c[i];
  }

  for(int i=1;i<=d;i++){
    for(int j=1;j<=26;j++){
      cin>>s[i][j];
    }
  }

  for(int i=1;i<=26;i++){
    date[i].insert(0);
    date[i].insert(d+1);
  }

  vector<int> t(d+1);
  for(int i=1;i<=d;i++){
    cin>>t[i];
    date[t[i]].insert(i);
  }

  lint result=0;
  vector<int> last(27, 0);
  for(int di=1;di<=d;di++){
    result+=s[di][t[di]];
    last[t[di]]=di;
    for(int i=1;i<=26;i++){
      result-=c[i]*(di-last[i]);
    }
  }

  int m;
  cin>>m;
  for(int i=0;i<m;i++){
    int day, q;
    cin>>day>>q;

    auto itr_x=date[t[day]].find(day);
    auto itr_x_sml=itr_x;
    --itr_x_sml;
    auto itr_x_big=itr_x;
    ++itr_x_big;
    auto itr_y_big=date[q].upper_bound(day);
    auto itr_y_sml=itr_y_big;
    --itr_y_sml;
    int a=day-*(itr_y_sml);
    int b=day-*itr_x_sml;
    int e=*itr_x_big-day;
    int f=*itr_y_big-day;


    result=result
          -s[day][t[day]]
          +s[day][q]
          +(c[t[day]]*(b*(b-1)+e*(e-1))/2+c[q]*(a+f)*(a+f-1)/2)
          -(c[t[day]]*(b+e)*(b+e-1)/2 + c[q]*(a*(a-1)+f*(f-1))/2);

    cout<<result<<endl;

    date[t[day]].erase(day);
    date[q].insert(day);
    t[day]=q;

  }



  return 0;
}




Measured memory_bytes: 3596
implicit none
integer :: h,w
character(100) :: str
integer :: i,j

read *,h,w

do j = 1, w+1
   write(*,'(a)',advance='no') '#'
enddo
write(*,'(a)') '#'

do i = 1, h
   read *,str
   write(*,'(a,a,a)') '#',str(1:w),'#'
enddo

do j = 1, w+1
   write(*,'(a)',advance='no') '#'
enddo
write(*,'(a)') '#'

end

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <float.h>

#define _max(_x, _y) ((_x)>(_y)?(_x):(_y))
#define _min(_x, _y) ((_x)>(_y)?(_y):(_x))

int main(void)
{
  int A,B,C;

  scanf("%d %d %d", &A,&B,&C);
  printf("%d\n", _min(B/A,C)); 

  return 0;
}

Measured memory_bytes: 128
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

var (
	readString func() string
	readBytes  func() []byte
)

func init() {
	readString, readBytes = newReadString(os.Stdin)
}

func newReadString(ior io.Reader) (func() string, func() []byte) {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	f1 := func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
	f2 := func() []byte {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Bytes()
	}
	return f1, f2
}

func readInt() int {
	return int(readInt64())
}

func readInt64() int64 {
	i, err := strconv.ParseInt(readString(), 10, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readFloat64() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func minInt64(a, b int64) int64 {
	if a < b {
		return a
	}
	return b
}

func maxInt64(a, b int64) int64 {
	if a > b {
		return a
	}
	return b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func absInt64(a int64) int64 {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a []int) int {
	var ret int
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumInt64(a []int64) int64 {
	var ret int64
	for i := range a {
		ret += a[i]
	}
	return ret
}

func sumFloat64(a []float64) float64 {
	var ret float64
	for i := range a {
		ret += a[i]
	}
	return ret
}

// sort ------------------------------------------------------------

type int64Array []int64

func (s int64Array) Len() int           { return len(s) }
func (s int64Array) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s int64Array) Less(i, j int) bool { return s[i] < s[j] }

type xxx struct {
	a int64
	b int64
}

type sortArray []xxx

func (s sortArray) Len() int           { return len(s) }
func (s sortArray) Swap(i, j int)      { s[i], s[j] = s[j], s[i] }
func (s sortArray) Less(i, j int) bool { return s[i].b < s[j].b }

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

func main() {
	n := readInt()
	x := make(sortArray, n)
	for i := 0; i < n; i++ {
		x[i] = xxx{
			a: readInt64(),
			b: readInt64(),
		}
	}
	sort.Sort(x)

	var t int64
	for i := range x {
		t += x[i].a
		if t > x[i].b {
			fmt.Println("No")
			return
		}
	}

	fmt.Println("Yes")
}


Measured memory_bytes: 6272