akhauriyash/Code-Regression huggingface dataset:
//BIRDS SET FREE
#include<bits/stdc++.h> 
using namespace std;                          //31 July 1999
#pragma GCC optimize("O3")
typedef long long ll;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define vec(i, a)  for( auto i=a.begin();i != a.end(); ++i)
#define all(x) x.begin(), x.end()
#define sz(x) (ll)(x).size()
#define fill(a)  memset(a, 0, sizeof (a))
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define endl '\n'
#define sp '\t'
#define fast  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define in  freopen("input.txt","r",stdin);
#define out freopen("output.txt","w",stdout);
#define rocket in out 
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...); }
typedef long double ld;
typedef std::pair<ll, ll> pii;
typedef std::vector<ll> vi;
const ll MOD = 10e9 + 7;
const ll N=10e6;
ll n_bits(ll n ) { ll x= __builtin_popcount(n) ; return x ;}
ll least_bits(ll n ) { ll x= __builtin_ffs(n) ; return x ;}
ll gcd(ll x, ll y) { ll n=__gcd(x,y); return n;}
ll binpow(ll a, ll b, ll m=MOD) 
{
    a%=m;
    ll res=1;
    while (b>0) 
    {
        if (b&1)    res=res*a%m;
        a=a*a%m,b>>=1;
    }
    return res;
}
void I(vi &v, int n)
{
    ll a;
    rep(i,0,n)    cin>>a,v.pb(a);
}
void O(vi &v, int n)
{

    rep(i,0,n)    cout<<v[i]<<" ";
    cout<<endl;
}
ll get_second( pair<string, ll> i ){ return i.second; }
int main()
{    
    #ifndef ONLINE_JUDGE
    rocket
    #endif
    fast
    ll t=1;
    //cin>>t;
    while(t--)
    {    
        ll temp = 0 , flag = 0 , diff = 0 , sum = 0 , result = 0 , ct = 0 , cnt = 0 , found = 0;
        ll a = 0 , b = 0 , c = 0 , n = 0 , m = 0 , k = 0 , x = 0 , y = 0 ; 
        set<ll> s1;
        map<ll,ll> mapp;
        vi v,v1,v2;
        string s;
        //transform( mapp.begin(), mapp.end(), v1.begin(), get_second );
        cin >> n ;
        cin >> s ;
        ll size = sz( s );
        if( n < size )
        {
            rep( i , 0 , n ) cout<<s[ i ];
            cout<<"...";
        } 
        else cout << s ;
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 3648
N = int(input())
c = input()

dp = [0] * (N)

len_c_W = c.count('W')
len_c_R = c.count('R')
if (len_c_W == 0 or len_c_R == 0):
    print(0)
    exit()
cnt_W = 0
cnt_R = 0
for i in range(N):
    if c[i] == 'R':
        cnt_R += 1
    else:
        cnt_W += 1
    count = 0
    if (cnt_W <= (len_c_R - cnt_R)):
        count = len_c_R - cnt_R
    else:
        count = cnt_W

    dp[i] = count
print(min(dp))


Measured memory_bytes: 16804
#include <iostream>

using namespace std;

int main() {
    int A, B, K;
    cin >> A >> B >> K;
    int cnt = 0;
    int i = max(A, B);
    int num;
    while(cnt < K) {
        if(A % i == 0 && B % i == 0) {
            cnt++;
            num = i;
        }
        i--;
    }
    cout << num << endl;
    
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
const int N = 3010;
int a[N], b[N];
int f[N << 1];

int main()
{
    int n, t;
    scanf("%d %d", &n, &t);
    for (int i = 1; i <= n; ++i) {
        scanf("%d %d", &a[i], &b[i]);
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; ++j) {
            if (a[i] > a[j]) {
                swap(a[i], a[j]);
                swap(b[i], b[j]);
            }
        }
    }
    for (int i = 1; i <= n; ++i) {
        for (int j = t + a[i] - 1; j >= a[i]; --j) {
            f[j] = max(f[j], f[j - a[i]] + b[i]);
        }
    }
    int ans = 0;
    for (int i = 1; i <= 6000; ++i) {
        ans = max(ans, f[i]);
    }
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 256
n = gets.to_i
A = gets.split.map(&:to_i)

rate = {}
rate['gray'] = false
rate['brown'] = false
rate['green'] = false
rate['light_blue'] = false
rate['blue'] = false
rate['yellow'] = false
rate['orage'] = false
rate['red'] = false

free = 0
A.each do |a|
  case a
  when 1..399
    rate['gray'] = true
  when 400..799
    rate['brown'] = true
  when 800..1199
    rate['green'] = true
  when 1200..1599
    rate['light_blue'] = true
  when 1600..1999
    rate['blue'] = true
  when 2000..2399
    rate['yellow'] = true
  when 2400..2799
    rate['orage'] = true
  when 2800..3199
    rate['red'] = true
  else
    free += 1
  end
end

num = rate.count {|k, v| v}

if num <= 0
  min = 1
else
  min = num
end

max = num + free

puts "#{min} #{max}"


Measured memory_bytes: 1788
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<bitset>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;

#define repr(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) repr(i, 0, n)
#define INF 2e9
#define MOD 1000000007
#define LINF (long long)4e18

using ll = long long;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;


class DisjointSet{
    public:
        vector<ll> rank,p,siz;

        DisjointSet(){}
        DisjointSet(ll size){
            rank.resize(size,0);
            p.resize(size,0);
            siz.resize(size,1);
            rep(i,size) makeSet(i);
        }

        void makeSet(ll x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(ll x, ll y){
            return root(x) == root(y);
        }

    
        void unite(ll x, ll y){
            x = root(x);
            y = root(y);
            if(rank[x] > rank[y]){
                siz[x] += siz[y];
                p[y] = x;
            }
            else{
                siz[y] += siz[x];
                p[x] = y;
                if(rank[x] == rank[y]) rank[y]++;
            } 
        }
        ll root(ll x){
            if(x != p[x]){
                p[x] = root(p[x]);
            }
            return p[x];
        }

        ll size(ll x){
            return siz[root(x)];
        }

};


int main(){
  ll N,K,L; cin >> N >> K >> L;
  DisjointSet UF1(N),UF2(N);
  rep(i,K){
    ll p,q;
    cin >> p >> q;
    p--; q--;
    UF1.unite(p,q);
  }
  rep(i,L){
    ll r,s;
    cin >> r >> s;
    r--; s--;
    UF2.unite(r,s);
  }
  map<Pi,int> a;
  rep(i,N){
    a[Pi(UF1.root(i),UF2.root(i))]++;
  }
  rep(i,N){
    cout << a[Pi(UF1.root(i),UF2.root(i))];
    if(i != N-1) cout << " ";
  }
  cout << endl;
  


}


Measured memory_bytes: 21120
#include<bits/stdc++.h>
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
using namespace std;
#define F(i,L,R) for (int i = L; i < R; i++)
#define FE(i,L,R) for (int i = L; i <= R; i++)
#define getI(a) scanf("%d", &a)
#define getII(a,b) scanf("%d%d", &a, &b)
#define getIII(a,b,c) scanf("%d%d%d", &a, &b, &c)
#define VgetI(n) int (n); scanf("%d",&(n))
#define VgetII(n,m) int (n),(m); scanf("%d %d",&(n),&(m))
#define VgetIII(n,m,k) int (n),(m),(k); scanf("%d %d %d",&(n),&(m),&(k))
#define pb push_back
#define pii pair<int,int>
#define ll long long
#define INF 2000000000
#define PI 3.1415926535897932384626
const ll MOD=1e9+7;
int a[1005],b[1005];
int worst=100000000;
int dp[100000005];//dp[i]=maximum hp I can hit with i mp
int main(){
        int h,n;
        while(~getII(h,n)){
                F(i,0,n) getII(a[i],b[i]);
                FE(i,0,worst) dp[i]=0;
                F(i,0,n) FE(j,b[i],worst){
                                        dp[j]=max(dp[j],dp[j-b[i]]+a[i]);
                                        if(dp[j]>=h) break;
                                }
                int ans=INF;
                FE(i,0,worst) if(i<ans&&dp[i]>=h) ans=i;
                printf("%d\n",ans);
        }
}

Measured memory_bytes: 390912
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
using namespace std;
#define INF 100000000
typedef long long ll;

int ww[110], ID[110];
int W, Q;

int check(int w, int id) {
    for (int i = 0; i < W; i++) {
        int j;
        for (j = 0; j < w; j++) {
            if (i+j >= W || ww[i+j] != -1) break;
        }
        if (j == w) {
            for (j = 0; j < w; j++) {
                ww[i+j] = id;
            }
            return i;
        }
    }
    return -1;
}

void remove(int id) {
    int w = ID[id];
    int i;
    for (i = 0; i < W; i++) {
        if (ww[i] == id) break;
    }
    for (int j = 0; j < w; j++) {
        ww[i+j] = -1;
    }
}

int main(void) {
    while (1) {
        cin >> W >> Q;
        if (W == 0 && Q == 0) break;
        for (int i = 0; i < W; i++) ww[i] = -1;
        for (int i = 0; i < Q; i++) {
            char c;
            cin >> c;
            if (c == 's') {
                int id, w;
                cin >> id >> w;
                ID[id] = w;
                int ans = check(w, id);
                if (ans == -1) cout << "impossible" << endl;
                else cout << ans << endl;
            } else {
                int id;
                cin >> id;
                remove(id);
            }
        }
        cout << "END" << endl;
    }
    return 0;
}

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n), b(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> b[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> c[i];
  }
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());
  long long ans = 0;
  for (const auto& e : b) {
    long long upper = n;
    long long lower = -1;
    while (upper - lower > 1) {
      long long mid = (upper + lower) / 2;
      if (a[mid] < e) {
        lower = mid;
      } else {
        upper = mid;
      }
    }
    long long ok_a = lower + 1;
    upper = n;
    lower = -1;
    while (upper - lower > 1) {
      long long mid = (upper + lower) / 2;
      if (c[mid] > e) {
        upper = mid;
      } else {
        lower = mid;
      }
    }
    long long ok_c = n - upper;
    ans += ok_a * ok_c;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 4484
n=int(input())
a,b=map(int,input().split())
p=list(map(int,input().split()))
p1=[]
p2=[]
p3=[]
for i in p:
    if i<=a:
        p1.append(i)
    elif i<=b:
        p2.append(i)
    else:
        p3.append(i)
print(min(len(p1),len(p2),len(p3)))

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
#define llMAX 9223372036854775807
#define llMIN -9223372036854775808
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll x,y,a,b,c;

int main(){
  ll ans=0;
  cin >> x >> y >>a>>b>>c;
  
  vi p(a+1,llMAX),q(b+1,llMAX),r(c);
  REP(i,a)cin>>p[i];
  REP(i,b)cin>>q[i];
  REP(i,c)cin>>r[i];

  sort(p.begin(), p.end());
  sort(q.begin(), q.end());
  sort(r.begin(), r.end());
  int wp=a-x,wq=b-y,wr=c-1;

  REP(i,x+y){
    
    if (p[wp]<q[wq]){
      if (p[wp]<r[wr]){
        p[wp]=r[wr];
        wp++;
        wr--;
      }
    }else{
      if (q[wq]<r[wr]){
        q[wq]=r[wr];
        wq++;
        wr--;
      }
    }
    if (wr==-1)break;

  }



  REP(i,x){
    ans+=p[a-i-1];
  }
  REP(i,y){
    ans+=q[b-i-1];
  }
/*
  REP(i,a){
    cout<<p[i]<<" ";
  }
  cout<<endl;
  REP(i,b){
    cout<<q[i]<<" ";
  }
  cout<<endl;
*/




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

Measured memory_bytes: 2688
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <climits>
#include <map>
#include <functional>
#include <cmath>
#include <cassert>
#include <set>

using namespace std;

template<typename T>inline T get(){T x;cin>>x;return x;}

int main()
{
    string s = get<string>();
    int i;
    if (s[0] == 'A')
        ;
    else
        goto Reject;
    i = s.find("C", 2);
    if (i != string::npos && i <= s.size()-2)
        ;
    else
        goto Reject;
    for (int j = 1; j < s.size(); j++) {
        if (j == i)
            continue;
        if (s[j] >= 'a' && s[j] <= 'z')
            ;
        else
            goto Reject;
    }
    cout << "AC" << endl;
    return 0;
Reject:
    cout << "WA" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void) {
	int a, b, c, x, y, money=0;
	scanf("%d %d %d %d %d", &a, &b, &c, &x, &y);
	if (2 * c < a + b) {
		if (x < y) {
			money += c*x * 2;
			money += b*(y - x);
			if (money > c*y * 2)money = c*y * 2;
		}
		else {
			money += c*y * 2;
			money += a*(x - y);
			if (money > c*x * 2)money = c*x * 2;
		}
	}
	else {
		money += a*x + b*y;
	}
	printf("%d\n", money);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define mod 1000000007
#define mod998 998244353
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define mkp make_pair
typedef long long ll;
using namespace std;

int N, P[200000], a[200000];
bool vis[200000];
vector<int>rev[200000];

void dfs(int x) {
	if (a[x] != -1)return;
	set<int>st;
	for (int i : rev[x]) {
		dfs(i);
		st.insert(a[i]);
	}
	for (int i = 0;; ++i) {
		if (st.find(i) == st.end()) {
			a[x] = i;
			return;
		}
	}
}

int main() {
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> P[i];
		--P[i];
		rev[P[i]].push_back(i);
		a[i] = -1;
	}
	int p, q;
	p = 0;
	while (!vis[P[p]]) {
		p = P[p];
		vis[p] = true;
	}
	q = P[p];
	set<int>st;
	for (int i : rev[q]) {
		if (i == p)continue;
		dfs(i);
		st.insert(a[i]);
	}
	int t;
	for (int i = 0;; ++i) {
		if (st.find(i) == st.end()) {
			t = a[q] = i;
			break;
		}
	}
	dfs(p);
	if (a[q] != a[p]) {
		puts("POSSIBLE");
		return 0;
	}
	memset(a, -1, sizeof a);
	for (int i : rev[q]) {
		if (i == p)continue;
		dfs(i);
	}
	st.insert(t);
	for (int i = 0;; ++i) {
		if (st.find(i) == st.end()) {
			a[q] = i;
			break;
		}
	}
	dfs(p);
	if (a[p] == t) {
		puts("POSSIBLE");
		return 0;
	}
	puts("IMPOSSIBLE");
	return 0;
}


Measured memory_bytes: 28160
#include<bits/stdc++.h>
    #include <ext/pb_ds/assoc_container.hpp> 
  #include <ext/pb_ds/tree_policy.hpp>
  #pragma comment(linker, "/stack:200000000")
  #pragma GCC optimize("O3")
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("unroll-loops")
    using namespace std;
  using namespace __gnu_pbds;
    #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    #define int long long
    #define all(v) v.begin(),v.end()
    #define rep(i,a,b) for(int i = a; i <=b; i++)
    #define rep2(i,a,b) for(int i = a; i>=b; i--)
    #define PB push_back
    #define MP make_pair
    #define db long double
    #define trace1(x)                cerr<<#x<<": "<<x<<endl
    #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
    #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
    #define trace3race4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
    #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
    #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
    #define cases int testcases;cin>>testcases; while(testcases--)
    #define INF 2000000000
    const double PI = acos(-1);
    const int N = 100005;

    int dp[N];
    int arr[N];
    
  int32_t main() 
  {
    IOS



        int a, b;
        cin >> a >> b;

        cout << max(a - 2 * b,0LL);


    return 0;
      }

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

struct UnionFind{
   vector<int> par;
   UnionFind(int n):par(n,-1){}
   int find(int x){
       if(par[x]<0)return x;
       return par[x]=find(par[x]);
   }
   bool unite(int x,int y){
       x=find(x);
       y=find(y);
       if(x==y)return false;
       if(par[x]>par[y]){
           par[y]+=par[x];
           par[x]=y;
       }
       else{
           par[x]+=par[y];
           par[y]=x;
       }
       return true;
   }

   bool same(int x,int y){
       return find(x)==find(y);
   }
   int size(int x){
       return -par[find(x)];
   }
};

double x[12345],y[12345];
double dist(int i,int j){
    return sqrt(pow(x[i]-x[j],2)+pow(y[i]-y[j],2));
}

int main(){
    int n,m;
    cin>>n>>m;
    rep(i,n){
        cin>>x[i]>>y[i];
    }
    int u[m],v[m];
    double d[m];
    rep(i,m){
        cin>>u[i]>>v[i];
        --u[i];--v[i];
        d[i]=dist(u[i],v[i]);
    }
    vector<int> ord(m);
    iota(ord.begin(),ord.end(),0);
    sort(ord.begin(),ord.end(),[&](int i,int j){
        return d[i]>d[j];
    });
    double ans=0;
    UnionFind uf(n);
    for(auto i : ord){
        if(uf.unite(u[i],v[i])){
            continue;
        }
        else ans+=d[i];
    }
    cout<<fixed<<setprecision(12)<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3948
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=1e9+7;
ll gcd(ll a,ll b){
    if(min(a,b)==0)return max(a,b);
    if(max(a,b)%min(a,b)==0)return min(a,b);
    return gcd(min(a,b),max(a,b)%min(a,b));
}
int main(){
    ll t;cin>>t;
    while(t){
        t--;
        ll a,b,c,d;cin>>a>>b>>c>>d;
        bool f=1;
        if(a<b)f=0;
        else if(d<b)f=0;
        else if(a%b>c)f=0;
        else if(c<b-1){
            ll s=gcd(d,b);
            if(s){
                if((c+1-a%b)/s<(b-1-a%b)/s||(c+1-a%b)%s==0)f=0;
            }
        }
        cout<<(f?"Yes":"No")<<endl;
    }
}

Measured memory_bytes: 256
m, d = map(int, input().split())
ans = 0
for i in range(m):
    m = i+1
    for j in range(d-19):
      d = j+20
      d1 = int(d/10)
      d2 = d%10
      if d2 > 1 and m == d1*d2:
          ans += 1
print(ans)

Measured memory_bytes: 3060
n = gets.chomp.to_i
as = gets.chomp.split(" ").map(&:to_i);

result = 0
counter = 1

as.each do |a|
  if a == counter
    counter += 1
  else
    result += 1
  end
end

if n == result
  puts "-1"
else
puts result
end

Measured memory_bytes: 16772
/*  -*- coding: utf-8 -*-
 *
 * 2777.cc: Kitsuchiri
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;
const int MAX_M = MAX_N / 2; // = 250000
const int MAX_E2 = 1 << 19;  // = 524288
const int INF = 1 << 30;

/* typedef */

template <typename T, const int MAX_E2>
struct SegTreeSumMinMax {
  int n, e2, inf;
  T sums[MAX_E2], mins[MAX_E2], maxs[MAX_E2], ds[MAX_E2];
  SegTreeSumMinMax() {}

  void init(int _n, int _inf) {
    n = _n, inf = _inf;
    for (e2 = 1; e2 < n; e2 <<= 1);
    fill(sums, sums + MAX_E2, 0);
    fill(mins, mins + MAX_E2, inf);
    fill(maxs, maxs + MAX_E2, -inf);
    fill(ds, ds + MAX_E2, 0);
  }

  void set(int i, T v) { sums[e2 - 1 + i] = v; }
  
  void setall() {
    for (int i = e2 * 2 - 2; i >= e2 - 1; i--)
      mins[i] = maxs[i] = sums[i];
    for (int i = e2 - 2; i >= 0; i--) {
      int i0 = i * 2 + 1, i1 = i0 + 1;
      sums[i] = sums[i0] + sums[i1];
      mins[i] = min(mins[i0], mins[i1]);
      maxs[i] = max(maxs[i0], maxs[i1]);
    }
  }
  
  void add_range(int r0, int r1, T v, int k, int i0, int i1) {
    if (r1 <= i0 || i1 <= r0) return;
    if (r0 <= i0 && i1 <= r1) {
      sums[k] += v, mins[k] += v, maxs[k] += v, ds[k] += v;
      return;
    }

    int im = (i0 + i1) / 2, k0 = k * 2 + 1, k1 = k0 + 1;
    if (ds[k] != 0) {
      sums[k0] += ds[k], mins[k0] += ds[k], maxs[k0] += ds[k], ds[k0] += ds[k];
      sums[k1] += ds[k], mins[k1] += ds[k], maxs[k1] += ds[k], ds[k1] += ds[k];
      ds[k] = 0;
    }

    add_range(r0, r1, v, k0, i0, im);
    add_range(r0, r1, v, k1, im, i1);

    sums[k] = sums[k0] + sums[k1];
    mins[k] = min(mins[k0], mins[k1]);
    maxs[k] = max(maxs[k0], maxs[k1]);
  }
  void add_range(int r0, int r1, T v) { add_range(r0, r1, v, 0, 0, e2); }
};

/* global variables */

int as[MAX_N];
SegTreeSumMinMax<int,MAX_E2> st;

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d", &n);
  for (int i = 0; i < n; i++) scanf("%d", as + i);

  int m = n / 2;

  st.init(m, INF);
  for (int i = 0; i < m; i++) st.set(i, as[i] - as[n - 1 - i]);
  st.setall();

  int q;
  scanf("%d", &q);
  while (q--) {
    int l, r, x;
    scanf("%d%d%d", &l, &r, &x);
    l--;

    if (r <= m) st.add_range(l, r, x);
    else if (m <= l) st.add_range(n - r, n - l, -x);
    else {
      int l0 = m - l, r0 = r - m;
      if (l0 > r0) st.add_range(l, n - r, x);
      else if (l0 < r0) st.add_range(n - r, l, -x);
    }

    printf("%d\n", (st.mins[0] == 0 && st.maxs[0] == 0) ? 1 : 0);
  }
  return 0;
}



Measured memory_bytes: 13348
#include <bits/stdc++.h>
#define ll long long
#define ALL(x) x.begin(),x.end()
#define MOD (1000000000+7)
using namespace std;
#define PI 3.14159265359
#define tMOD 998244353
#define mkpr(x,y) make_pair(x,y)

int main(){
string s;

cin>>s;

for(ll i=0;i<s.size();i++){
  cout<<"x";
}
cout<<endl;

}

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

using namespace std;
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int64_t x;
  cin >> x;

  uint64_t elevens = x / 11;
  uint64_t mod = x % 11;
  if (mod == 0) {
    cout << (elevens * 2) << "\n";
  } else if (mod <= 6) {
    cout << (elevens * 2 + 1) << "\n";
  } else {
    cout << (elevens * 2 + 2) << "\n";
  }
}


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

using namespace std;
using ll = long long;

int main() {
    ll N = 0;
    cin >> N;
    vector<ll> x(N,0);
    vector<ll> y(N,0);
    vector<ll> da(N,0);
    vector<ll> db(N,0);
    for(ll i = 0; i < N; i++) {
        cin >> x.at(i);
        cin >> y.at(i);
        da.at(i) = x.at(i) + y.at(i);
        db.at(i) = 1000000000 + x.at(i) - y.at(i);
    }
    ll ans = 0;
    sort(da.begin(),da.end());
    sort(db.begin(),db.end());
    ll a, b;
    a = abs(da.at(0) - da.at(N - 1));
    b = abs(db.at(0) - db.at(N - 1));
    
    ans = max(a, b);

    cout << ans << endl;

    
    return 0;
}

Measured memory_bytes: 9544
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e6+1;
 
typedef long long ll;
typedef long double ld;
 
int main()
{
    IOS();
    
    ll i,a,b,c;
    string s,t,r="";
    cin>>a>>b;
    
    cout<<(a*b)/(__gcd(a,b))<<'\n';
    
    return 0;
}

Measured memory_bytes: 256
import itertools
N = int(input())
elist = list(map(int, input().split()))

result = 0
if len(elist) > 2:
    for comb in itertools.combinations(elist, 3):
        x, y, z = comb
        if x == y or y == z or z == x:
            continue
        m = max(x, y, z)
        if m < x+y+z - m:
            result += 1

print(result)


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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n, k; cin >> n >> k;
  vll a(n);
  REP(i, n) cin >> a[i];
  vll su(n);
  ll s = 0;
  REP(i, n) {
    s += a[i];
    su[i] = s;
  }
  vll posil(n);
  s = 0;
  REP(i, n) {
    if(a[i] > 0) {
      s += a[i];
    }
    posil[i] = s;
  }

  vll posir(n);
  s = 0;
  RFOR(i, n-1, 0) {
    if(a[i] > 0) {
      s += a[i];
    }
    posir[i] = s;
  }

  ll ans = 0;
  REP(i, n-k+1) {
    ll l = (i > 0) ? posil[i-1] : 0;
    ll r = (i < n-k) ? posir[i+k] : 0;
    // cout << i << ":" << l << ":" << r << endl;
    ans = max(ans, l + r + max(0ll, su[i+k-1] - su[i] + a[i]));
    // cout << ans << endl;
  }
  cout << ans << endl;
}


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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int v;
int cnt;

void insertionSort(int n,int g ,int *A){
    FOR(i,g,n){
        v=A[i];
        int j=i-g;
        while(j>=0&&A[j]>v){
            A[j+g]=A[j];
            j=j-g;
            cnt++;
        }
        A[j+g]=v;
    }
}

int main(){
int n;
cin>>n;
int A[n];
REP(i,n)cin>>A[i];
int m=100;
int G[m];
REP(i,m-1)G[i]=(n-1)/pow(2,i);
G[m-1]=1;
cnt=0;
REP(i,m){
    insertionSort(n,G[i],A);
}
cout<<m<<endl;
REP(i,m)cout<<G[i]<<(i==m-1?"\n":" ");
cout<<cnt<<endl;

REP(i,n)cout<<A[i]<<endl;
}


Measured memory_bytes: 7168
#include <stdio.h>
#include <stdlib.h>

struct number{
    int s;
    int num;
};

int dsc(const void *a, const void *b){
    struct number *A = (struct number *)a;
    struct number *B = (struct number *)b;
    return B->s - A->s;
}

int minimum(int a, int b){ return a < b ? a : b; }

int main(){
    int n, v[100000], i, temp;
    int cnt0, cnt1;
    struct number even[100001], odd[100001];

    scanf("%d", &n);
    for(i=0; i<100001; i++){
        even[i].s = 0;
        even[i].num = i;
        odd[i].s = 0;
        odd[i].num = i;
    }
    for(i=0; i<n; i++){
        if(i%2==0){
            scanf("%d", &temp);
            odd[temp].s++;
            v[i] = temp;
        }
        else{
            scanf("%d", &temp);
            even[temp].s++;
            v[i] = temp;
        }
    }

    qsort(even, 100001, sizeof(struct number), dsc);
    qsort(odd, 100001, sizeof(struct number), dsc);

    if(even[0].num == odd[0].num){
        cnt0=0; cnt1=0;
        for(i=0; i<n; i++){
            if(i%2==0){
                if(v[i] != odd[0].num)
                    cnt0++;
                
                if(v[i] != odd[1].num)
                    cnt1++;
            }
            else{
                if(v[i] != even[1].num)
                    cnt0++;

                if(v[i] != even[0].num)
                    cnt1++;
            }
        }
        printf("%d\n", minimum(cnt0, cnt1));
    }
    else{
        cnt0=0;
        for(i=0; i<n; i++){
            if(i%2==0){
                if(v[i] != odd[0].num)
                    cnt0++;
            }
            else{
                if(v[i] != even[0].num)
                    cnt0++;
            }
        }
        printf("%d\n", cnt0);
    }

    return 0;
}

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

int main(){

	int h,w,a,b;cin >> h >> w >> a >> b;
	int t[h][w],i,j;

	for (i=0 ; i<h ; i++)
		for (j=0 ; j<w ; j++){
			if (i < h-b && j < a) t[i][j] = 1;
			else if (i >= h-b && j >= a) t[i][j] = 1;
			else t[i][j] = 0;
		}

	for (i=0 ; i<h ; i++){
		for (j=0 ; j<w ; j++) cout << t[i][j];

		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 5120
#include<cstdio>
using namespace std;

int a[10005];
bool Find(int n, int key)
{
    int i=0;
    a[n]=key;
    while(a[i]!=key) i++;
    if(i!=n) return true;
    else return false;
}
int main()
{
    int n;
    scanf("%d", &n);
    for(int i=0; i<n; i++)
        scanf("%d", &a[i]);
    int q, key, cnt=0;
    scanf("%d", &q);
    for(int i=0; i<q; i++)
    {
        scanf("%d", &key);
        if(Find(n, key)) cnt++;
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 2708
#include <iostream>
#include <math.h>
using namespace std;
int main(){

	while (1){
		int n;
		int sum = 0;
		cin >> n;

		if (n == 0){
			return 0;
		}

		int s;
		int max = -1;
		int min = 9999;
		for (int i = 0; i < n; i++){
			cin >> s;
			sum += s;
			if (s >= max){
				max = s;
			}
			if (s <= min){
				min = s;
			}
		}
		int ans = floor((sum - max - min) / (n - 2));
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
from itertools import product

def next_sw(ox, sw, prev_sw):
    if (ox == 'o' and sw == 'S') or (ox == 'x' and sw == 'W'):
        return prev_sw 
    else:
        return 'W' if prev_sw =='S' else 'S'

N = int(input())
S = input()
ans = [None] * (N+1)
ok = False
for ans[0], ans[1] in product('SW', 'SW'):
    for i in range(1, N):
        ans[i+1] = next_sw(S[i], ans[i], ans[i-1])
    if ans[0] == ans[-1] and ans[1] == next_sw(S[0], ans[0], ans[-2]):
        ok = True
        break
if ok:
    print(''.join(ans[:N]))
else:
    print(-1)



Measured memory_bytes: 4852
#include <iostream>
#include <string>

using namespace std;

int main(){
    int n;cin>> n;
    double money = 0;
    for(int i = 0; i < n; i++){
        double x;string u;
        cin >> x >> u;
        if(u[0] == 'B')money += x*380000.0;
        else money += x;
    }
    cout << money << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n,m,now=0;
	string ic[257]={""},out,log[3]={"Opened by ","Closed by ","Unknown "};
	for(cin>>n;n>0;n--)cin>>ic[n];
	for(cin>>m;m>0;m--){
		bool kawa=0;
		cin>>out;
		for(int j=1;j<255&&!kawa;j++)if(ic[j]==out)kawa=1;
		if(kawa)cout<<log[now]+out<<endl;
		else cout<<log[2]+out<<endl;
		now=(now+kawa)%2;
	}
}

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

typedef long long LL;
typedef pair <int,int> pii;
const double pi = acos(-1.0);
const double eps = 1e-8;
const int mod = 1e9 + 7;
const int inf = 1e9;
const LL INF = 1e18;
const int N = 1e5 + 5;

int main() {
  ios_base::sync_with_stdio(0); cin.tie(0);
  #ifdef LOCAL
    freopen("input.txt", "r", stdin);
  #endif
  int n, m, x;
  cin >> n >> m >> x;
  int mn = inf;

  vector <int> c(n);
  vector <vector <int> > a (n, vector <int> (m, 0));

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

  for (int i = 1; i < (1 << n); i++) {
    int cost = 0;
    vector <int> temp(m, 0);
    for (int j = 0; j < n; j++) {
      if (i&(1 << j)) {
        cost += c[j];
        for (int k = 0; k < m; k++) temp[k] += a[j][k];
      }
    }
    bool ok = true;
    for (auto val: temp) ok &= (val >= x);
    if (ok) mn = min(mn, cost);
  }

  cout << (mn == inf ? -1 : mn) << endl;
  return 0;
}



Measured memory_bytes: 3660
#include<algorithm>
#include<climits>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<utility>
#include<vector>
 
#define lint long long
#define REP(i, x, n) for(int i = x ; i < n ; i++)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; i--)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())
#define IINF INT_MAX
#define LLINF LLONG_MAX

using namespace std;

const lint MOD = 1e9 + 7;

bool prime(int n){
    if(n <= 1){
        return false;
    }else if(n <= 3){
        return true;
    }else if(n % 2 == 0){
        return false;
    }else{
        for(int i = 3 ; i * i <= n ; i += 2){
            if(n % i == 0){
                return false;
            }
        }
        return true;
    }
}

int main(){
    int n;
    cin >> n;
    vector<int> pr;
    for(int i = 2 ; i <= n ; i++){
        if(prime(i)){
            pr.push_back(i);
        }
    }
    map<int, lint> mp;
    for(int i = 2 ; i <= n ; i++){
        int res = i;
        rep(j, pr.size()){
            while(res % pr[j] == 0){
                mp[pr[j]] = (mp[pr[j]] + 1) % MOD;
                res /= pr[j];
            }
        }
    }
    lint ans = 1;
    rep(i, pr.size()){
        ans = (ans * (mp[pr[i]] + 1)) % MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <math.h>
#include <stdio.h>

int main(void){
    double x=0;
    double y=0;
    double angle=90;
    int d,a;
    while(1){
        scanf("%d,%d",&d,&a);
        if(d==0 && a==0){
            printf("%d\n%d\n",(int)x,(int)y);
            return 0;
        }
        x+=d*cos(angle*2*M_PI/360);
        y+=d*sin(angle*2*M_PI/360);
        angle-=a;
    }

}



Measured memory_bytes: 2856
#include <iostream>
#define N (int) (1e5 + 200)
#define LIM (int) (1e5)

int main() {
    std::ios_base::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);

#if DEBUG_ON
    freopen("input", "r", stdin);
#endif

    bool arr[N] = { false };
    for (int i = 100; i <= 105; ++i) {
        arr[i] = true;
    }
    for (int i = 100; i <= LIM; ++i) {
        if (arr[i]) {
            for (int j = 100; j <= 105; ++j) {
                arr[i + j] = true;
            }
        }
    }
    int x;
    std::cin >> x;
    std::cout << (arr[x] ? 1 : 0) << '\n';
    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

#define N 255

int main() {
	char grid[N][N+1];
	int n;
	int i,j,k;
	int ones;
	int max_ones;
	
	while (1) {
		scanf("%d",&n);
		if (n == 0) {
			break;
		}
		for (i = 0;i != n;++i) {
			scanf("%s",grid[i]);
		}
		max_ones = 0;
		// horizontal
		for (i = 0;i < n;++i) {
			ones = 0;
			for (j = 0;j < n;++j) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// vertical
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0;i < n;++i) {
				if (grid[i][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		// diagonal
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k >= 0;++i,--k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = n-1;k < n;++k,--j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (j = 0;j < n;++j) {
			ones = 0;
			for (i = 0,k = j;k < n;++i,++k) {
				if (grid[i][k] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		for (i = 1;i < n;++i) {
			ones = 0;
			for (k = i,j = 0;k < n;++k,++j) {
				if (grid[k][j] == '1') {
					++ones;
				} else {
					if (ones > max_ones) {
						max_ones = ones;
					}
					ones = 0;
				}
			}
			if (ones > max_ones) {
				max_ones = ones;
			}
		}
		printf("%d\n",max_ones);
	}
	return 0;
}

Measured memory_bytes: 668
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
  int n;
  cin>>n;
  vector<ll> v;
  for(int i=0;i<n;i++){
      int a;
      cin>>a;
      v.push_back(a);
  }

  ll dp[n+1][5]={};

  for(int i=0;i<n;i++){
      ll z=dp[i][0];
      dp[i+1][0]=z+v[i];

      z=min(z,dp[i][1]);
      if(v[i]==0) dp[i+1][1]=z+2;
      else if(v[i]%2) dp[i+1][1]=z+1;
      else dp[i+1][1]=z;

      z=min(z,dp[i][2]);
      if(v[i]==0) dp[i+1][2]=z+1;
      else if(v[i]%2) dp[i+1][2]=z;
      else dp[i+1][2]=z+1;

      z=min(z,dp[i][3]);
      if(v[i]==0) dp[i+1][3]=z+2;
      else if(v[i]%2) dp[i+1][3]=z+1;
      else dp[i+1][3]=z;

      z=min(z,dp[i][4]);
      dp[i+1][4]=z+v[i];
  }

  ll ans=1e9;
  for(int i=0;i<=4;i++) ans=min(ans,dp[n][i]);
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

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

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;
  vector<int> a(M), b(M);

  int total = 1;
  for(int i = 0; i < N; i++){
    total = total * 2;
  }

  vector<ll> dp(total);
  for(int i = 0; i < total; i++){
    dp[i] = INF;
  }

  dp[0] = 0;
  int ta, tb, tc;

  int tmp = 0;
  for(int i = 0; i < M; i++){
    cin >> ta >> tb;
    tmp = 0;
    for(int j = 0; j < tb; j++){
      cin >> tc;
      tmp += (1 << (tc-1));
    }
    for(int j = 0; j < total; j++){
      chmin(dp[j | tmp], dp[j] + ta);
    }
  }

  if(dp[total-1] == INF){
    cout << -1 << endl;
  }else{
    cout << dp[total-1] << endl;
  }


  return 0;
}


Measured memory_bytes: 256
//#pragma GCC optimize("O3")

#include <bits/stdc++.h>
//#include <ctime>

using namespace std;

#define FAST_IO ios_base::sync_with_stdio(0); cin.tie(nullptr)
#define FOR(i, a, b) for(int i = (a); i <= (b); i++)
#define REP(n) FOR(O, 1, (n))
#define pb push_back
#define f first
#define s second
typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<pii> vii;
typedef vector<ll> vl;
typedef vector<piii> viii;
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int MAXN = 500100, MAXK = 20;
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ld PI = asin(1) * 2;

void setIO () {
    FAST_IO;
}

void setIO (string s) {
    setIO();
 	freopen((s+".in").c_str(),"r",stdin);
 	freopen((s+".out").c_str(),"w",stdout);
}



int main() {
    setIO();
	//setIO("lmio_1991_3e1_seka_01");

    ll k;
    cin >> k;
    ll cur = 7, cnt = 1;
    cur %= k;
    while (cur != 0) {
        cnt++;
        cur *= 10;
        cur += 7;
        cur %= k;
        if (cnt > 1e8) {
            cout << "-1\n";
            return 0;
        }
    }
    cout << cnt << "\n";

	return 0;
}


Measured memory_bytes: 3652
import java.io.*;
class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String line = br.readLine();
    int iNum = Integer.parseInt(line);
    int h = iNum / 3600;
    int m = (iNum % 3600) / 60;
    int s = (iNum % 3600) % 60;
    System.out.println(h + ":" + m + ":" + s);
  }
}

Measured memory_bytes: 24288
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9)+1;
const ll mod = ll(1e9)+7;
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()

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

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b;
}

ll factorial(ll n){
    ll t = 1;
    rep1(i, n)t *= i;
    return t;
}

ll combinations(ll n, ll k) {
    ll r = 1;
    rep1(i, k)r = r * n-- / i;
    return r;
}

int main(){
    ll n,xmax = 0,xmin = INF;
    cin >> n;
    vector<ll> x(n);
    rep0(i, n){
        cin >> x[i];
        xmax = max(xmax, x[i]);
        xmin = min(xmin, x[i]);
    }
    ll ans = INF,cnt;
    nfor(i, xmin, xmax + 1){
        cnt = 0;
        rep0(j, n){
            cnt += (x[j] - i) * (x[j] - i);
        }
        ans = min(cnt,ans);
    }
    pf(ans);
    return 0;
}


Measured memory_bytes: 256
a, b, c, x, y = list(map(int, input().split()))

if 2 * c >= a + b:
    print(x * a + y * b)
else:
    if x >= y:
        ans = y * 2 * c
        ans += (x - y) * a
    else:
        ans = x * 2 * c
        ans += (y - x) * b

    tmp = max(x, y) * (2 * c)
    print(min(tmp, ans))


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda :sys.stdin.readline().rstrip()
def resolve():
    n=int(input())
    if n%2==0: print(0.5)
    else: print((n//2+1)/n)
resolve()

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const ll mod=998244353;

#define pb push_back
#define mp make_pair


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

    ll t,m;
    double n;
    cout<<setprecision(12);
    cin>>n;
    cout<<pow(n/3,3);

    return 0;
}




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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n,r;
  cin>>n>>r;
  if(n>=10)cout<<r<<endl;
  else cout<<(r+100*(10-n))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
    double a,b,c,d,e,f,x,y;

    while(scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f)!=-1){
    y=(f-c*d/a)/(e-b*d/a);
    x=c/a-b*y/a;
    printf("%.3f %.3f\n",x+0.00005,y+0.00005);
    }
    return 0;
}

Measured memory_bytes: 656
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
// #include<unordered_map>
#include<set>
// #include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
#include<functional>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl
#define wl() cout << endl
const ll MAX_10p5 = 100010;
const ll MAX_10p9 = 1000000010;
const ll MAX_10p18 = 1000000000000000010;
const ll MOD = 1000000007;
const ll m4x[4] = { 1,0,-1,0 };
const ll m4y[4] = { 0,1,0,-1 };
const ll m8x[8] = { 1,1,0,-1,-1,-1,0,1 };
const ll m8y[8] = { 0,1,1,1,0,-1,-1,-1 };
const ll m9x[9] = { 1,1,0,-1,-1,-1,0,1,0 };
const ll m9y[9] = { 0,1,1,1,0,-1,-1,-1,0 };

struct edge {
	ll from, to, cost;
	bool operator<(const edge& right) const {
		return cost < right.cost;
	}
};
struct point {
	ll x, y, idx;
	bool operator<(const point& right) const {
		return x == right.x ? y < right.y : x < right.x;
	}
};

template<typename T>
T minT(T a, T b) {
	if (a < b) return a;
	else return b;
}

template<typename T>
T maxT(T a, T b) {
	if (a > b) return a;
	else return b;
}

template<typename T>
T absT(T a) {
	if (a < 0) a *= -1;
	return a;
}

template<typename T>
T powT(T a, T x) {
	T res = 1;
	while (x > 0) {
		if (x & 1) res = res*a;
		a = a*a;
		x >>= 1;
	}
	return res;
}

ll StoLL(string str) {
	ll ret = 0, ini = 0;
	if (str[0] == '-') ini = 1;
	repi(i, ini, str.length()) {
		ret *= 10;
		ret += (ll)(str[i] - '0');
	}
	if (ini) ret *= -1;
	return ret;
}

///////////////////////////////////////////////////////////////////////////////////////

int main() {
	ll n;
	cin >> n;
	if (n < 1000) wrln("ABC");
	else wrln("ABD");
	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/python
# -*- coding:utf-8 -*-

load_num, track_num = list(map(int, input().split(" ")))

loads = list()
for _ in range(load_num):
    loads.append(int(input()))

P = 10000 * 100000

def isMeet(p):
    i = 0

    for _ in range(track_num): # ??????????????°??°???????????????
        sum = 0 # ???????????????????????????
        while (sum + loads[i] <= p):
            sum += loads[i]
            i += 1
            if i == load_num:
                return True
    return False


def binary_search(P):
    left = 0 
    right = P
    while right - left > 0:
        mid = int((left+right)/2)
        if isMeet(mid):
            right = mid
        else:
            left = mid + 1
    return right

print(binary_search(P))

Measured memory_bytes: 11488