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

typedef long long ll;

// binary search
bool isPossible(ll k, vector<ll> a, ll B, ll A){
    // check if we can bomb everyone within k times.
    for(size_t i=0;i<a.size();i++){
        a[i] -= k*B;
    }
    // count how many times we need to do A-B
    // to zero-out a[i]s.
    ll counter = 0;
    for(size_t i=0;i<a.size();i++){
        if(a[i] > 0){
          counter += (a[i] + A-B-1) / (A-B);
        }
        if(counter > k){
          return false;
        }
    }
    return true;
}



int main(){
    int N;
    ll A,B;
    cin >> N >> A>> B;
    vector<ll> h;
    ll temp;
    ll h_max = 0;
    for(int i=0;i<N;i++){
      cin >>  temp;
      h.push_back(temp);
      if(h_max < temp){
        h_max = temp;
      }
    }

    // cout << isPossible(2, h, B, A) << endl;
    ll ub = h_max+1;
    ll lb = -1;
    ll mid;
    while(ub - lb > 1){
      mid = (ll)((ub+lb)/2);
      // cout << ub << " " << lb << " " << mid << endl;
      if(isPossible(mid, h, B, A)){
        ub = mid;
      }else{
        lb = mid;
      }
    } // ub is good;
    cout << ub << endl;

    return 0;
}

Measured memory_bytes: 1908
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define all(v) v.begin(), v.end()
#define allR(v) v.rbegin(), v.rend()
#define PRINT(v) for (auto x : (v)) cout <<x <<" " ; cout <<endl;
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
typedef pair<int,int> Pi;
const ll MOD = 1000000007;
const ll INF = 10000000000000000;
const int inf = 1001001001;
vector<int> x4 = {0, 1, 0, -1}, x8 = {0, 1, 1, 1, 0, -1, -1, -1};
vector<int> y4 = {1, 0, -1, 0}, y8 = {1, 1, 0, -1, -1, -1, 0, 1};
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;}
template<class T> inline T powerM(T a,T b){if (b==0) return 1;
T tmp = powerM(a,b/2); if (b%2==0) return tmp*tmp%MOD; else return tmp*tmp%MOD*a%MOD; }
template<class T> inline T power(T a,T b,T m=numeric_limits<T>::max()){ if (b==0) return 1;
  T tmp = power(a,b/2,m); if (b%2==0) return tmp*tmp%m; else return tmp*tmp%m*a%m; }
template<class T> inline T gcd(T a, T b){if (b==0) return a; return gcd(b, a%b);}
template<class T> inline T lcm(T a, T b){return a / gcd(a,b) * b;}
// ax+by=gcd(a,b)を解く
template<class T> inline T extgcd(T a,T b,T &x,T &y){if (b==0){x=1; y=0; return a;} T d=extgcd(b,a%b,y,x); y -= a/b*x; return d;}
void hey(){ cout <<"hey" <<endl; }

template<class T> struct edge { int to; T cost;};


int main() {
  int N; cin >>N;
  vector<int> B(N); rep(i, N) cin >>B[i];
  stack<int> res;
  rep(qq, N){
    bool ok = false;
    for (int i=B.size()-1; i>=0; i--){
      if (B[i] == i+1){
        B.erase(B.begin()+i);
        res.push(i+1);
        ok = true; break;
      }
    }
    if (!ok){
      cout <<-1 <<endl; return 0;
    }
  }
  while (!res.empty()){
    cout <<res.top() <<endl;
    res.pop();
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
using namespace std;
 
int main() {
  int count = 0;
  string w;
  string t;
  cin >> w;
   
  while (1) {
    cin >> t;
    if (t == "END_OF_TEXT")
      break;
    for (int i = 0; i < t.length(); i++) {
      t[i] = tolower(t[i]);
    }
    if (w == t) {
      count++;
    }
  }
  cout << count << endl;
}

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

namespace ARC097C_2 {
    class Program {
        static void Main(string[] args) {
            string s = Console.ReadLine();
            int K = int.Parse(Console.ReadLine());
            char[] str = s.ToCharArray();
            int len = s.Length;
            int num = 0;
            for (int i = 0; i < len; i++) {
                num += Math.Max(5, len - i);
            }
            List<string> a = new List<string>();
            for (int i = 0; i < len; i++) {
                for (int j = 0; j < 5; j++) {
                    if (i + j < len) {
                        a.Add(s.Substring(i, j + 1));
                    }
                }
            }
            a = a.Distinct().ToList();
            a.Sort();
            //for (int i = 0; i < a.Count(); i++) {
            //    Console.WriteLine(a[i]);
            //}
            Console.WriteLine(a[K - 1]);
        }
    }
}


Measured memory_bytes: 13152
#include<bits/stdc++.h>
#define int long long
const int inf=1145141919ll;
const int mod=1000000007ll;
const int dd[]={0,-1,0,1,0};
using namespace std;
int n,m,h,w;
int p[26];
signed main(){
	int i,j,k;
	string s;
	cin>>s;
	reverse(begin(s),end(s));
	int u=26;
	vector<int> ve;
	string t;
	j=0;
	ve.push_back(0);
	for(auto x:s){
		if(p[x-'a']==0){
			u--;
			p[x-'a']=1;
		}
		if(u==0){
			ve.push_back(j+1);
			fill(p,p+26,0);
			u=26;
		}
		j++;
	}
	char x;
	for(j=0;p[j];j++);
	x='a'+j;
	t.push_back(x);
	for(i=ve.size()-1;i>0;i--){
		fill(p,p+26,0);
		for(j=ve[i];s[j-1]!=x;j--);
		for(j--;j>ve[i-1];j--)
			p[s[j-1]-'a']=1;
		for(j=0;p[j];j++);
		x='a'+j;
		t.push_back(x);
	}
	cout<<t<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

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

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

void	solve()
{
	int a, p;
	cin >> a >> p;

	cout << (a * 3 + p) / 2 << endl;
}

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

	solve();
}


Measured memory_bytes: 256
mod = 998244353

n = int(input())
s = input()

ans = 1
R,G,B,RG,GB,BR = 0,0,0,0,0,0

if s[0] == 'R':
    R = 1
elif s[0] == 'G':
    G = 1
else:
    B = 1

for i in range(1,3*n):
    if s[i] == 'R':
        if GB > 0:
            ans = (ans * GB) % mod
            GB -= 1
        elif G > 0:
            ans = (ans * G) % mod
            G -= 1
            RG += 1
        elif B > 0:
            ans = (ans * B) % mod
            B -= 1
            BR += 1
        else:
            R += 1
    elif s[i] == 'G':
        if BR > 0:
            ans = (ans * BR) % mod
            BR -= 1
        elif R > 0:
            ans = (ans * R) % mod
            R -= 1
            RG += 1
        elif B > 0:
            ans = (ans * B) % mod
            B -= 1
            GB += 1
        else:
            G += 1
    else:
        if RG > 0:
            ans = (ans * RG) % mod
            RG -= 1
        elif R > 0:
            ans = (ans * R) % mod
            R -= 1
            BR += 1
        elif G > 0:
            ans = (ans * G) % mod
            G -= 1
            GB += 1
        else:
            B += 1
        
for i in range(n):
    ans = (ans * (i+1)) % mod

print(ans)

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

int main() 
{
    int N;
    cin >> N;
    vector<int> V;
  	vector<int> C;
    int count = 0;

    for( int i=0 ; i<N ; i++ ) 
    {
        int x; cin >> x;
        V.push_back(x);
    }

    for( int i=0 ; i<N ; i++ ) 
    {
        int x; cin >> x;
        C.push_back(x);
    }

    for( int i=0 ; i<N ; i++ ) 
    {
        int x = V[i] - C[i];

        if( x > 0 ) count += x;
    }


    cout << count << endl;

}

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

using namespace std;

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

    string s, t;
    cin >> s >> t;

    int dif = 0;
    int len = s.length();
    for(int i = 0; i < len; i++){
        dif += (s[i] != t[i]);
    }
    cout << dif << '\n';
    return 0;
}
/* take it easy */

Measured memory_bytes: 3820
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
const ll mod=998244353;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<pii> v(n);
  rep(i,n) cin >> v[i].first >> v[i].second;
  int ans=n;
  rep(i,n)rep(j,n)if(i!=j){
    int dx=v[j].first-v[i].first;
    int dy=v[j].second-v[i].second;
    int sub=0;
    rep(i2,n)rep(j2,n)if(i2!=j2){
      int dx2=v[j2].first-v[i2].first;
      int dy2=v[j2].second-v[i2].second;
      if(dx2==dx&&dy2==dy) sub++;
    }
    chmin(ans,n-sub);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define For(i, a, b)  for(int i = a; i <= b; ++i)
#define Ford(i, a, b) for(int i = a; i >= b; --i)
#define FileName      "test"
#define ll            long long
#define ld            long double
#define ull           unsigned long long
#define pb            push_back
#define X             first
#define Y             second
//#define Karma

using namespace std;

template <typename T> inline void Cin(T &x)
{
    char c;
    T sign = 1;
    x = 0;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        if (c == '-')
            sign = -1;
    for (; c >= '0' && c <= '9'; c = getchar())
        x = x * 10 + c - '0';
    x *= sign;
}

typedef pair<int, int> pii;
typedef pair<ll, int> plli;
const int N = 2e5 + 7;
const int nAlpha = 26;

string s;
int dem[50], odd, n, t[N], p[N];
vector<int> v[50];

int GetAns(int x)
{
    int res = 0;
    while(x > 0)
    {
        res += t[x];
        x -= (x & -x);
    }
    return res;
}

void Update(int x)
{
    while(x <= n)
    {
        ++t[x];
        x += (x & -x);
    }
}

void Enter()
{
    cin >> s;
    n = s.size();
    s = ' ' + s;
    For(i, 1, n) v[s[i] -= 'a'].pb(i);
    odd = 0;
    For(i, 0, nAlpha)
    {
        int m = v[i].size();
        odd += (m & 1);
        if(odd >= 2)
        {
            cout << -1;
            exit(0);
        }
        int l = 0, r = m - 1;
        while(l <= r)
        {
            p[v[i][l]] = v[i][r];
            ++l; --r;
        }
    }
}

void Solve()
{
    ll res = 0;
    int mid;
    For(i, 1, n)
    {
        if(p[i] && p[i] != i)
        {
           res += GetAns(p[i]) + GetAns(i);
           Update(p[i]);
        }
        else if(p[i] == i) mid = i;
    }
    if(odd)
    {
        For(i, 1, n)
        {
            if(p[i] && ((i < mid && p[i] < mid) || (i > mid && p[i] > mid))) ++res;
        }
    }
    cout << res;
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
#ifdef Karma
    freopen(FileName".inp", "r", stdin);
    freopen(FileName".out", "w", stdout);
#endif // Karma

    Enter();
    Solve();

    return 0;
}


Measured memory_bytes: 2640
#include<cstdio>
#include<cstring>
#include<algorithm>
#define rep(a,b,c) for (int a=b;a<=c;a++)
#define per(a,b,c) for (int a=b;a>=c;a--)
#define go(u) for (int o=ft[u],v;v=E[o].t;o=E[o].n)
#define fi first
#define se second
using namespace std;
typedef long long LL;
typedef double dob;
typedef pair<int,int> par;
const int N=5010,P=1000000007;
struct edge{int t,n;}E[N<<1];
int n,rt,ft[N],s[N],key[N],tot;
LL f[N],g[N],s1[N],s2[N],inv[N];
void add(int x,int y){
	E[++tot]=(edge){y,ft[x]},ft[x]=tot;
}
void dfs1(int u,int f=0){
	go(u) if (v!=f) dfs1(v,u),s[u]+=s[v];
	++s[u];
}
void dfs2(int u,int f=0){
	key[u]=n-s[u];
	go(u) if (v!=f) dfs2(v,u),key[u]=max(key[u],s[v]);
	if (key[u]<key[rt]) rt=u;
}
LL C(int n,int m){return s1[n]*s2[m]%P*s2[n-m]%P;}
void preset(){
	int lim=5000;
	inv[1]=s1[0]=s2[0]=1;
	rep(i,2,lim) inv[i]=inv[P%i]*(P-P/i)%P;
	rep(i,1,lim) s1[i]=s1[i-1]*i%P,s2[i]=s2[i-1]*inv[i]%P;
}
void upd(LL &x,LL y){x=(x+y)%P;}
int main(){
	preset();
	scanf("%d",&n);
	rep(i,2,n){
		int x,y;
		scanf("%d%d",&x,&y);
		add(x,y),add(y,x);
	}
	dfs1(1);
	key[0]=n+10;
	dfs2(1);
	if (n%2==0&&key[rt]==n/2){
		printf("%lld\n",s1[n/2]*s1[n/2]%P);
		return 0;
	}
	f[0]=1;
	memset(s,0,sizeof(s));
	dfs1(rt);
	go(rt){
		int sum=s[v];
		memset(g,0,sizeof(g));
		rep(i,0,n){
			LL fx=f[i];
			rep(j,0,sum) upd(g[i+j],fx*C(sum,j)%P*C(sum,j)%P*s1[j]%P);
		}
		swap(f,g);
	}
	LL ans=0;
	rep(i,0,n) upd(ans,f[i]*(i&1?-1:1)*s1[n-i]%P);
	ans=(ans+P)%P;
	printf("%lld\n",ans);
	return 0;
}


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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rep2(i,s,n) for(int i = (s); i < (n); ++i)
#define ll long long
#define ld long double
#define P pair<ll,ll>
#define all(v) v.begin(),v.end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

ll f(ll n)
{
    ll r=n%4;
    if(n<0) return 0;
    if(r==0) return n;
    else if(r==1) return 1;
    else if(r==2) return n+1;
    return 0;
}

int main(void)
{
    
    ll n,t,a; cin>>n>>t>>a;
    ll d=INF,ans=0;
    rep(i,n){
        ll h; cin>>h;
        ll tmp=1000*t-6*h;
        if(abs(d-1000*a) > abs(tmp-1000*a)){
            d=tmp;
            ans=i+1;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
long long ans,l,r;
int main()
{
    cin>>l>>r;
    if(r<3)
    {
        for(int i=l;i<=r;i++)
        {
            ans^=i;
        }
        cout<<ans;
        return 0;
    }
    while(l%4!=0)
    {
        ans^=l;
        l++;
    }
    while(r%4!=3)
    {
        ans^=r;
        r--;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if(s[0] == s[1] && s[1] != s[2] && s[2] == s[3]) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 3608
H, W = map(int, input().split())
S = [list(input()) for _ in range(H)]

count = [[100000] * W for _ in range(W)]
count[0][0] = 0 if S[0][0] == "." else 1


for i in range(H):
    for j in range(W):
        if i + j == 0:
            continue
        X, Y = 10**6, 10**6
        if i > 0:
            if S[i][j] == "#" and S[i-1][j] == ".":
                X = count[i-1][j] + 1
            else:
                X = count[i-1][j]
        if j > 0:
            if S[i][j] == "#" and S[i][j-1] == ".":
                Y = count[i][j-1] + 1
            else:
                Y = count[i][j-1]
        count[i][j] = min(X, Y)

print(count[H-1][W-1])

Measured memory_bytes: 42480
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 9007199254740997;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

const int w=6;
const int k=500;
const int n=26;
int d;

VI c(n);
VVI s(365,VI(n));

struct st{
	VI a;
	ll score;
	bool operator<(const st &another) const {return score < another.score;};
};

vector<st> f(st p){
	VI a=p.a; ll score=p.score;
	int now=a.size()+1;
	VI last(n,0);
	REP(i,a.size())
		last[a[i]]=i+1;
	VI down(n); ll downsum=0;
	REP(i,n){
		down[i]=c[i]*(now-last[i]);
		downsum+=down[i];
	}
	a.push_back(-1);
	vector<st> tmp;
	REP(i,n){
		a[now-1]=i;
		tmp.push_back({a,score-downsum+down[i]+s[now-1][i]});
	}
	sort(ALL(tmp));
	vector<st> ret;
	REP(i,w)
		ret.push_back(tmp[n-1-i]);
	return ret;
}


int main(){
	cin >> d;
	REP(i,n) cin >> c[i];
	REP(i,d)REP(j,n) cin >> s[i][j];
	priority_queue<st> q;
	VI a(0);
	q.push({a,0});
	REP(i,d){
		priority_queue<st> next;
		REP(j,k){
			if(q.empty())
				break;
			for(auto nx:f(q.top()))
				next.push(nx);
			q.pop();
		}
		q=next;
	}
	REP(i,d)
		cout << q.top().a[i]+1 << endl;
	return 0;
}

Measured memory_bytes: 24464
import collections
import sys
sys.setrecursionlimit(10**9)

def mi(): return map(int,input().split())
def ii(): return int(input())
def isp(): return input().split()
def deb(text): print("-------\n{}\n-------".format(text))

INF=10**20
def main():
    N = ii()

    memo = collections.defaultdict(lambda: 0)
    for i in range(N):
        S = list(input())
        S.sort()
        memo["".join(S)] += 1
    
    ans = 0
    for _,count in memo.items():
        ans += count * (count-1) // 2

    print(ans)
        


if __name__ == "__main__":
    main()

Measured memory_bytes: 98244
using System;
using static System.Console;
using System.Linq;
using System.Collections.Generic;

namespace AC
{
    class shiokara
    {
        static void Main(string[] args)
        {
            var N = int.Parse(ReadLine());
            int cnt=0;
            for(int i = 0; i < N; i++){
                var D = ReadLine().Split(' ').ToArray();
                if(D[0] == D[1]) cnt++;
                else cnt=0;

                if(cnt == 3){
                    WriteLine("Yes");
                    return;
                }
            }
            WriteLine("No");
        }
    }
}

Measured memory_bytes: 27976
use std::io::Read;

fn read<T: std::str::FromStr>() -> T {
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n: u32 = read();

    let odd = if n % 2 == 0 { n / 2 } else { n / 2 + 1 };
    println!("{}", odd as f32 / n as f32);
}


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

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	int H[N];

	for (int i = 0; i < N; i++)
	{
		cin >> H[i];
	}
	string ans = "Yes";
	for (int i = N-2; i >= 0; i--)
	{
		if(H[i+1]<H[i]){
			if(H[i]-H[i+1]==1) H[i]--;
			else ans = "No";
		}
	}
	
	cout << ans << endl;
	
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <bitset>
#include <map>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

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

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

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

	bool same(int x, int y){
		return find(x) == find(y);
	}
};
int main(){
	Union_find uf(100001);
	int n, m;
	cin >> n >> m;
	vector<int> L[100000];
	int k, l;
	REP(i, n){
		cin >> k;
		REP(j, k){
			cin >> l;
			L[i].push_back(l);
		}
		REP(j, L[i].size()-1){
			uf.unite(L[i][j], L[i][j+1]);
		}
	}
	REP(i, n){
		bool flag = false;
		REP(j, L[i].size()){
			if(uf.same(L[i][j], l)){
				flag = true;
				break;
			}
		}
		if(!flag){
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 6516
#include<bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
const int M = 1000000007;
 
int main() {
    while (1) {
        int n, m, l, k, a, h;
        cin >> n >> m >> l >> k >> a >> h;
        if (!n) return 0;
        vector<int> fr(l + 2);
        for (int i = 0; i < l; ++i) {
            cin >> fr[i];
        }
        fr[l] = a;
        fr[l + 1] = h;
 
        vector<vector<int>> d(n, vector<int>(n, M));
        for (int i = 0; i < k; ++i) {
            int x, y, t;
            cin >> x >> y >> t;
            d[x][y] = t;
            d[y][x] = t;
        }
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k)
                    d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
 
        vector<vector<int>> dist(n, vector<int>(n, M));
        for (int i : fr)
            for (int j : fr)
                if (d[i][j] <= m)
                    dist[i][j] = d[i][j];
 
        for (int i = 0; i < n; ++i)
            for (int j = 0; j < n; ++j)
                for (int k = 0; k < n; ++k)
                    dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
 
        if (dist[a][h] >= M) cout << "Help!\n";
        else cout << dist[a][h] + max(dist[a][h] - m, 0) << "\n";
    }
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
int main() 
{
  //input
  int N, M, C;
  cin  >> N >> M >> C;
  vector <int> B(M);
  for(int i = 0; i < M; i++)
  {
    cin  >> B[i];
  }
  vector <vector <int>> A(N, vector <int>(M));
  for(int i = 0; i < N; i++) 
  {
    for(int j = 0; j < M; j++)
    {
      cin  >> A[i][j];
    }
  }//compute
  int ans = 0;
  for(int i = 0; i < N; i++) {
    //checkwhetheri-thsourcecodesolvesthisproblem
    int sum = 0;
    for(int j = 0; j < M; j++)
    {
      sum += A[i][j] * B[j];
    }
    if(sum + C > 0) 
    {
      ++ans;
    }
  }
  //output
  cout  << ans  << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>

using namespace std;

typedef long long ll;
const ll mod=1e9+7;
const ll MAXN=1e5+10;
const ll INF=0x7fffffff;
int a[MAXN];
int main()
{
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n);
	int i=1;
	for(i;i<=n;i++){
		int r=i;
		while(a[r+1]==a[i]){
			r++;
		}
		int tot=r-i+1;
		if(tot%2==1){
			ans++;
		}
		i=r;
	}
	cout<<ans<<endl;
	return 0;
}	 


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

int main() {
  int n, t;
  cin >> n >> t;
  ll tm[n];
  for (int i = 0; i < n; i++) {
    cin >> tm[i];
  }

  if (n == 1) {
    cout << t << endl;
    return 0;
  }

  ll ans = 0;
  ll start = tm[0];
  for (int i = 1; i < n; i++) {
    ll diff = tm[i] - tm[i - 1];
    if (diff <= t) {
      // start 維持
      if (i == n - 1) {
        ans += (tm[i] - start + t);
      }
    } else {
      ans += (tm[i - 1] - start + t);
      start = tm[i];
      if (i == n - 1) {
        ans += t;
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 1920
h, w = map(int, input().split())

h_odd = (h+1)//2
h_even = h//2
w_odd = (w+1)//2
w_even = w//2

if h == 1 or w ==1:
    print(1)
else:
    ans = h_odd * w_odd + h_even *w_even
    print(ans)

Measured memory_bytes: 8972
#include<bits/stdc++.h>
#define REP(x,y,z) for(int x=y;x<=z;x++)
#define MSET(x,y) memset(x,y,sizeof(x))
#define M 
using namespace std;
int main()
{
    int n,k;
    long double ans;
    vector<long double> lds;
    while (~scanf("%d %d", &n,&k)) {
        lds.clear();
        ans = 0.0;
        REP(i,1,n) {
            int x=i, cnt=0;
            while (x<k) {
                cnt++;
                x *= 2;
            }

            lds.push_back ( pow(0.5, cnt) );
        }
        sort(lds.begin(), lds.end());

        for (auto i:lds) ans += i;

        printf("%.15f\n", (double)(ans/n));
    }
    return 0;
}


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

using namespace std;
typedef long long ll;

int a[100001], b[100001];

int main(void) {
    int n;
    cin >> n;
    for(int i=0; i<n; i++) scanf("%d%d", a+i, b+i);

    ll ans = 0;
    for(int i=n-1; i>=0; i--) {
        ll c = a[i] + ans;
        if(c % b[i]) ans += b[i] - c % b[i];
    }

    return !printf("%lld\n", ans);
}

Measured memory_bytes: 1024
#include <stdio.h>
#include <string.h>

int main(void)
{
	char S[4], tmp;
	scanf("%s", S);
	if (strlen(S) == 3) {
		tmp = S[0];
		S[0] = S[2];
		S[2] = tmp;
	}
	puts(S);
	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  int lH = H;
  int lW = W;
  vector<vector<char>> table(H, vector<char>(W));
  for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
          cin >> table[i][j];
      }
  }
  bool hasBlack = false;
  int i=0;
  int j=0;
  
  for(i=0;i<lH;i++){
      for(j=0;j<lW;j++)
        if(table[i][j] == '#') hasBlack = true;
    
      if(!hasBlack){
          lH -= 1;
          for(int p=i;p<lH;p++)
              for(int q=0;q<lW;q++)
                table[p][q] = table[p+1][q];
        i -= 1;
      }
      hasBlack = false;
  }
  
  for(i=0;i<lW;i++){
      for(j=0;j<lH;j++)
          if(table[j][i] == '#') hasBlack = true;

      if(!hasBlack){
          lW -= 1;
          for(int p=0;p<lH;p++)
              for(int q=i;q<lW;q++)
                table[p][q] = table[p][q+1];
        i -= 1;
      }
      hasBlack = false;
  }
  
    for(i=0;i<lH;i++){
      for(j=0;j<lW;j++)
          cout << table[i][j];
      cout << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define int long long
#define double long double
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define mod 1000000007
#define ceil(a,b) (a+b-1)/b
#define endl "\n"

#define oa(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define o1(a) cout<<" "<<#a<<" : "<<a<<"\n"
#define o2(a,b) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<"\n"
#define o3(a,b,c) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<"\n"
#define o4(a,b,c,d) cout<<" "<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<"\n"

 const int N=100005;
 const int inf=1e18;
 const double eps=1e-9;
int pow1(int a,int b){
    int res=1;
    while(b>0){
        if(b&1){
        	res=res*a;
		}
        a=a*a;
        b>>=1;
    }
    return res;
}
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	
	int n;
    cin>>n;
    vector<int>d;
    if(n==2){
        cout<<1;
        return 0;
    }
    int ans=1;
    for(int i=1;i<=sqrt(n);i++){
        if(n%i==0){
            if(n/i==i){
                d.pb(i);
            }else{
                d.pb(i);
                d.pb(n/i);
            }
        }else{
           
                if((n-1)%i==0){
                    if((n-1)/i==i){
                        ans++;
                    }else{
                        ans+=2;
                    }
                }
            
        }
    }
    // return 0;
    for(int x=0;x<d.size();x++){
        // cout<<d[x]<<" ";
        int z=n;
        int a=d[x];
        if(a==1){
            continue;
        }
        while(z%a==0&&z>=a){
            z=z/a;
        }
        if(z<a){
            if(z==1){
                ans++;
            }
        }else{
            int e=(z-a)/a+1;
            z=z-e*a;
            if(z==1){
                ans++;
            }
        }
    }
    cout<<ans;








	
return 0;
}


Measured memory_bytes: 384
import numpy as np
import sys
def main():
    line = sys.stdin.readline

    H, W = map(int, line().split())
    grid = np.zeros((H + 2, W + 2), np.int32)
    grid[1:-1, 1:-1] = (np.array([list(line().rstrip()) for _ in range(H)]).reshape(H, W) == '.') * 1
    left = np.zeros((H + 2, W + 2), np.int32)
    right = np.zeros((H + 2, W + 2), np.int32)
    up = np.zeros((H + 2, W + 2), np.int32)
    down = np.zeros((H + 2, W + 2), np.int32)

    # 下方向に照らせるマスの数（自分の場所含む）
    down[H] = grid[H]
    for i in range(H, 0, -1):
        down[i - 1] = (down[i] + 1) * grid[i - 1]

    up[1] = grid[1]
    for i in range(1, H):
        up[i + 1] = (up[i] + 1) * grid[i + 1]

    right[:, W] = grid[:, W]
    for i in range(W, 0, -1):
        right[:, i - 1] = (right[:, i] + 1) * grid[:, i - 1]

    left[:, 1] = grid[:, 1]
    for i in range(1, W):
        left[:, i + 1] = (left[:, i] + 1) * grid[:, i + 1]

    answer = (left + right + up + down) * grid
    print(np.max(answer) - 3)


if __name__ == '__main__':
    main()

Measured memory_bytes: 126104
from collections import deque
N, M, K = map(int, input().split())

flst = []
blst = []
glooplst = [i for i in range(N+1)]
colorlst = [0]*(N+1)
countlst = [0]*(N+1)
anslst = [0]*(N+1)
d = deque()

for i in range(N+1):
    flst.append([])
    blst.append([])


for i in range(M):
    a, b = map(int, input().split())
    flst[a].append(b) 
    flst[b].append(a)


for i in range(K):
    a, b = map(int, input().split())
    blst[a].append(b)
    blst[b].append(a)


for i in range(1, N+1):
    if colorlst[i] == 0:
        d.append(i)
        colorlst[i] = 1
        countlst[i] += 1
        while d:
            now = d.popleft()
            for j in flst[now]:
                if colorlst[j] == 0:
                    d.append(j)
                    colorlst[j] = 1
                    glooplst[j] = i
                    countlst[i] += 1

for i in range(1, N+1):
    cnt = countlst[glooplst[i]] - len(flst[i]) -1
    for j in blst[i]:
        if glooplst[i] == glooplst[j]:
            cnt -= 1

    print(cnt, end=' ')

print()


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

namespace 最高のピザ
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            int[] ab = Console.ReadLine().Split().Select(int.Parse).ToArray();
            int c = int.Parse(Console.ReadLine());
            int[] d = new int[n];
            for (int i = 0; i < n; i++)
            {
                d[i]= int.Parse(Console.ReadLine());
            }
            Array.Sort(d);
            int calSum = c, priSum = ab[0];
            double ans = calSum / (double)priSum;
            for (int i = n - 1; i >= 0; i--)
            {
                calSum += d[i];priSum += ab[1];
                ans = Math.Max(calSum / (double)priSum, ans);
            }
            Console.WriteLine(Math.Floor(ans));
        }
    }
}



Measured memory_bytes: 18380
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String num = sc.nextLine();
		String line = sc.nextLine();
		String[] word = line.split(" ",0);
      for(int i = 0; i < Integer.parseInt(num); i++){
        	System.out.print(word[0].charAt(i));
        	System.out.print(word[1].charAt(i));
        }
	}
}

Measured memory_bytes: 21844
#include<stdio.h>

#define MAX 200005

int main(){
  int i;
  int n,A[MAX];
  int maxv,minv=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

  minv = A[0];
  maxv = A[1]-A[0];
  for(i=1;i<n;i++){
    if(maxv < A[i]-minv){
      maxv=A[i]-minv;
    }
    if(minv > A[i]){
      minv=A[i];
    }
  }

  printf("%d\n",maxv);

  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1e9+7;
#define INF (1LL << 60)
#define REP(i,m,n) for(int i=(int)m; i < (int)n; ++i)
#define rep(i,n) REP(i,0,n)


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

    int n;
    string s;
    cin >> n >> s;

    vector<int> cntW(n), cntE(n);
    rep(i, n) {
        if(s[i] == 'W') cntW[i]++;
        if(i == 0) continue;
        cntW[i] += cntW[i-1];
    }
    string rs = s;
    for(int i = n-1; i >= 0; i--) {
        if(rs[i] == 'E') cntE[i]++;
        if(i == n-1) continue;
        cntE[i] += cntE[i+1];
    }

    int ans = 1e9;
    rep(i, n) {
        if(i == 0) ans = min(ans, cntE[i]);
        if(i == n-1) ans = min(ans, cntW[i]);
        ans = min(ans, cntW[i-1]+cntE[i+1]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3348
using System.Collections.Generic;
    using System.Collections;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System;

    namespace cysharp_test
    {
        class Program
        {
            static void Main (string[] args)
            {
                new Program ().solve ();
            }

            void solve ()
            {
                int N = int.Parse (Console.ReadLine ());
                var dic = new Dictionary<string, int> ();
                for (int i = 0; i < N; i++)
                {
                    var input = Console.ReadLine ();
                    if (dic.ContainsKey (input)) dic[input]++;
                    else dic.Add (input, 1);
                }

            //Console.WriteLine("~~~~~~~~~~~~~~~~~~~~");
            var max = dic.Values.Max ();
                var maxp = dic.Where (v => v.Value == max).Select (v => v.Key);
                var maxpeople = new List<string> ();
                foreach (var s in maxp) maxpeople.Add (s);

                var builder = new StringBuilder ();
                foreach (var s in maxpeople.OrderBy(str => str,StringComparer.Ordinal))
                {
                    builder.AppendLine (s);
                }
                Console.WriteLine (builder);
                Console.ReadKey ();

            }

        }

        struct Vector2
        {
            public Vector2 (long x, long y)
            {
                this.x = x;
                this.y = y;
            }

            public long x, y;

            public string ToString ()
            {
                return "(" + this.x + "," + this.y + ")";
            }

            public static Vector2 operator + (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x + b.x, a.y + b.y);
            }

            public static Vector2 operator - (Vector2 a, Vector2 b)
            {
                return new Vector2 (a.x - b.x, a.y - b.y);
            }

            public static Vector2 operator * (Vector2 a, long scala)
            {
                return new Vector2 (a.x * scala, a.y + scala);
            }

            public static bool operator == (Vector2 a, Vector2 b)
            {
                return a.x == b.x && a.y == b.y;
            }

            public static bool operator != (Vector2 a, Vector2 b)
            {
                return !(a.x == b.x && a.y == b.y);
            }
        }
    }

Measured memory_bytes: 51448
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e9);
const int mod = inf + 7;
const int N = 1e6 + 555; // TL MB
const double PI = acos(-1.0);
 
void mul(ll &x, ll y){
	x *= y;
	if(x >= mod) x %= mod;
}
 
void add(ll &x, ll y){
	x += y;
	if(x >= mod) x -= mod;
	if(x < 0) x += mod;
}
ll bp(ll a, ll n){
	ll r = 1;
	while(n){
		if(n & 1) mul(r, a);
		mul(a, a);
		n >>= 1;
	}
	return r;
}


void get(char &x){
	if(x == '1') x = '0';
	else x = '1';
}
ll cur[N], ans[N];

void solve()
{
	double n;
	cin >> n;
	cout << fixed << setprecision(10) << acos(-1.0) * n * 2; 
}



 
 
int main()
{
    Red;
  	// int T; cin >> T; while(T--)
    solve();
    return 0;

}

Measured memory_bytes: 3828
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

//

use std::io::Write;

fn run() {
    input! {
        a: u64,
        b: u64,
        c: u64,
    }
    if c <= a + b {
        println!("No");
        return;
    }
    let d = c - a - b;
    let l = 4 * a * b;
    if d * d > l {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <iostream>

using namespace std;

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

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

  int manipulate_count = 0;
  while(true){
    for(size_t i = 0; sizeof(numbers) / sizeof(int) > i; i++){
      int num = numbers[i];
      if(num % 2 == 0){
        numbers[i] = num / 2;
      }else{
        goto end;
      }
    }
    manipulate_count++;
  }

 end:
  cout << manipulate_count << endl;
}


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

using namespace std;

int main()
{
    int A,B,C; cin >> A >> B >> C;
    int min = (A < B) ? A : B;
    int max = (A > B) ? A : B;
    if (C < max && min < C){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int mod=1e9+7;
int f(int x,int y,int z){
  return 16*x+4*y+z;
}
int main() {
  int n,i,j,k,l,m,ans=0;
  cin>>n;
  vector<vector<int>> a(64,vector<int>(n+1));
  for(i=0;i<64;i++) a.at(i).at(3)=1;
  a.at(f(0,1,2)).at(3)=0;
  a.at(f(0,2,1)).at(3)=0;
  a.at(f(1,0,2)).at(3)=0;
  for(i=3;i<n;i++){
    for(j=0;j<4;j++){
      for(k=0;k<4;k++){
        for(l=0;l<4;l++){
          for(m=0;m<4;m++){
            if((j!=0||k!=1||m!=2)&&(j!=0||l!=1||m!=2)){
              a.at(f(k,l,m)).at(i+1)+=a.at(f(j,k,l)).at(i);
              a.at(f(k,l,m)).at(i+1)%=mod;
            }
          }
        }
      }
    }
    a.at(f(0,1,2)).at(i+1)=0;
    a.at(f(0,2,1)).at(i+1)=0;
    a.at(f(1,0,2)).at(i+1)=0;
  }
  for(i=0;i<64;i++) ans=(ans+a.at(i).at(n))%mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <queue>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int h, w;
vector<string> field;

int main() {
    cin >> h >> w;
    field.resize(h);
    vector<vector<int>> matrix(h, vector<int>(w, -1));

    rep(i, h) {
        cin >> field[i];
    }

    queue<pair<int, int>> next;

    rep(i, h) {
        rep(j, w) {
            if(field[i][j] == '#') {
                matrix[i][j] = 0;
                next.push(make_pair(i, j));
            }
        }
    }

    while(next.size() != 0) {
        int x = next.front().first;
        int y = next.front().second;
        rep(i, 4) {
            int nx = x + dx[i];
            int ny = y + dy[i];
            if(nx < 0 || h <= nx || ny < 0 || w <= ny) {
                continue;
            }
            if(matrix[nx][ny] >= 0) {
                continue;
            }
            matrix[nx][ny] = matrix[x][y] + 1;
            next.push(make_pair(nx, ny));
        }
        next.pop();
    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = (matrix[i][j] > ans ? matrix[i][j] : ans);
        }
    }

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

Measured memory_bytes: 13456
<?php 
  /*全探索
  for{
   上の段は進め多分の総和+
   下の段は、進め多分を全ての総和から引いたもの
   }
   max
  */
//fscanf(STDIN,"%s%s",$s,$t);
fscanf(STDIN,"%d",$n);

$a_1=explode(" ",trim(fgets(STDIN)));
$a_2=explode(" ",trim(fgets(STDIN)));
$a_part_sum=0;
$a2_part_sum=0;
$sum=0;
$b_sum=0;
for($i=0;$i<$n;$i++) $b_sum+=$a_2[$i];
array_unshift($a_2,0);//undefiend防止

for($i=0;$i<$n;$i++){
  $a_part_sum += $a_1[$i];
  $a2_part_sum += $a_2[$i];
  //echo $a_part_sum." ".$a2_part_sum."\n";
  $sum=max($sum,$a_part_sum+($b_sum-$a2_part_sum));
}


echo $sum."\n";


Measured memory_bytes: 4856
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    ll n;
    cin >> n;
    vector<ll> a(n);
    rep(i, n)cin >> a[i];
    ll ans = 1, m = 1000000000000000000;
    sort(all(a));
    rep(i, n){
        if(a[i] == 0){cout << 0 << endl; return 0;}
        if(ans > m / a[i]){
            cout << -1 << endl;
            return 0;
        }
        ans *= a[i];
    }
    cout << ans << endl;
}

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

#define ll long long
#define INF 99999999
#define rep(i,n) for(int i=0,temp=(int)(n);i<temp;++i) 
#define repi(i,start,end) for(int i=start,temp=(int)(end);i<end;++i)
#define rfor(v,x) for(const auto& x : v) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort(v, v+n)
#define vsort(v) sort(v.begin(), v.end())
#define vfsort(v,lambda) sort(v.begin(),v.end(),lambda)
#define vint vector<int>
#define vvint vector<vector<int>>
#define vin(v) rep(i,v.size()) {cin >> v[i];}
//最終奥義
//#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//(lambda (x y) (< x y)) => [](int x, int y) -> int { return x<y; }

signed main(void){
  int n,q;cin >> n >> q;
  vint super(n,-1);
  rep(i,n-1){
    int a,b;cin >> a >> b;
    super[b-1]=a-1;
  }
  vint c(n,0);
  rep(i,q){
    int p,x;cin >> p >> x;
    c[p-1]+=x;
  }
  rep(i,n-1)c[i+1]+=c[super[i+1]];
  rep(i,n)
    cout << c[i] << " ";
  cout << endl;
}


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

class UnionFind {
 public:
  vector<int> parent;
  UnionFind(int n) { parent = vector<int>(n, -1); }
  int root(int a) {
    if(parent[a] < 0) return a;
    return parent[a] = root(parent[a]);
  }
  int size(int a) { return -parent[root(a)]; }
  bool connect(int a, int b) {
    a = root(a);
    b = root(b);
    if(a == b) return false;
    if(size(a) < size(b)) swap(a, b);
    parent[a] += parent[b];
    parent[b] = a;
    return true;
  }
};

int main() {
  int n, m, k;
  scanf("%d %d %d", &n, &m, &k);
  vector<vector<int>> fr(n), bl(n);
  UnionFind uni(n);
  for(int i = 0; i < m; i++) {
    int a, b;
    scanf("%d %d", &a, &b);
    fr[--a].push_back(--b);
    fr[b].push_back(a);
    uni.connect(a, b);
  }
  for(int i = 0; i < k; i++) {
    int c, d;
    scanf("%d %d", &c, &d);
    if(uni.root(--c) == uni.root(--d)) {
      bl[c].push_back(d);
      bl[d].push_back(c);
    }
  }
  for(int i = 0; i < n; i++)
    printf("%d%c", uni.size(i) - 1 - (int)(fr[i].size() + bl[i].size()),
           (i == n - 1 ? '\n' : ' '));
}

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

struct ProblemSet {
  int num_problems;
  long long score;
  long long bonus;
};

void solve() {
  long long D, G;
  cin >> D >> G;
  vector<ProblemSet> problem_sets(D);
  vector<int> num_problems(D);
  for (int i = 0; i < D; ++i) {
    int num;
    long long bonus;
    cin >> num >> bonus;
    problem_sets[i] = { num, 100 * (i + 1), bonus };
    num_problems[i] = num;
  }

  // Try all 2^D options.
  int min_num_problems = numeric_limits<int>::max();
  for (int mask = 0; mask < (1 << D); ++mask) {
    long long score = 0;
    int num_problems_solved = 0;
    vector<int> num_problems_not_done(D);
    num_problems_not_done = num_problems;
    // Add all problems for which we solve the whole set.
    for (int j = 0; j < D; ++j) {
      if (mask & (1 << j)) {
        num_problems_not_done[j] = 0;
        score += problem_sets[j].bonus;
        score += problem_sets[j].score * problem_sets[j].num_problems;
        num_problems_solved += problem_sets[j].num_problems;
      }
    }
    // While we still have a score < G, greedily add the problems with the highest score.
    if (score < G) {
      for (int i = D - 1; i >= 0; --i) {
        if (num_problems_not_done[i] == 0) {
          continue;
        }
        while (score < G && num_problems_not_done[i] > 0) {
          --num_problems_not_done[i];
          score += problem_sets[i].score;
          ++num_problems_solved;
        }
        if (num_problems_not_done[i] == 0) {
          score += problem_sets[i].bonus;
        }
      }
    }
    min_num_problems = min(min_num_problems, num_problems_solved);
  }
  cout << min_num_problems << endl;
}

int main() {
  solve();
}

Measured memory_bytes: 256
T = input()
A = ["gp"[i%2] for i in range(len(T))]
A = "".join(A)

point = 0
for t,a in zip(T,A):
    if t == "g" and a == "p":
        point += 1
    elif t == "p" and a == "g":
        point -= 1

print(point)

Measured memory_bytes: 3956
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }


int solve()
{
    int L, R;
    const int MOD = 2019;

    cin >> L >> R;

    if (R / 2019 != L /2019)
    {
        return 0;
    }
    else
    {
        ll ans = 2019;

        for (ll i = L; i <= R; ++i)
        {
            for (ll j = i + 1; j <= R; ++j)
            {
                ans = std::min(ans, i * j % MOD);
            }
        }

        return ans;
    }
}

int main()
{
    std::cout << solve() << std::endl;

    return 0;
}

Measured memory_bytes: 256