akhauriyash/Code-Regression huggingface dataset:
// R I S E
/* Dedication has no limitation 
                   - Ulisses Jr.
*/
// 28 APRIL  2019
#include <bits/stdc++.h>
using namespace std;

int main(){
int a,b,t;
cin >> a >> b>> t;
if(t<a)cout << 0;
else{
  cout << (t/a)*b << endl;
}

}





 

Measured memory_bytes: 256
def main():
    n,x,y=map(int,input().split())
    cnt=[0]*(n-1)
    for i in range(n-1):
        for j in range(i+1,n):
            res=min(j-i,abs(x-1-i)+abs(y-1-j)+1)
            if res>0 and res<n:
                cnt[res-1]+=1
    for i in range(n-1):
        print(cnt[i])
if __name__=="__main__":
    main()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define irep(i, n) for(int i = n-1; i >= (int)0; i--)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
int main(){
    string s;
    std::cin >> s;
    if(s.size()<4)std::cout << "No" << std::endl;
    else if(s.substr(0,4)=="YAKI")std::cout << "Yes" << std::endl;
    else std::cout << "No" << std::endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define in std::cin
#define out std::cout
#define rep(i,N) for(LL i=0;i<N;++i)
typedef long long int LL;

int main()
{
	LL N;
	in >> N;
	std::vector<LL>W(N);
	rep(i, N) in >> W[i];

	std::vector<LL>W_imos(N + 1);
	rep(i, N) W_imos[i + 1] = W_imos[i] + W[i];

	LL ans = 114514;
	rep(i, N)
	{
		LL res = std::abs(W_imos[N] - W_imos[i + 1] - W_imos[i + 1]);
		ans = std::min(ans, res);
	}

	out << ans << std::endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool f(int x){
	int keta=0;
	while (x)
	{
		keta++;
		x/=10;
	}
	return keta%2==1;	
}
int main(){
	int n;
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)if(f(i))ans++;
	cout<<ans<<endl;
}

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

int main(void){
	int x, a, b;
  	cin >> x >> a >> b;
  	if(abs(x - a) < abs(x - b)){
    	cout << "A" << endl;
    }else{
    	cout << "B" << endl;
    }
  	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  	int h,a;
  	cin >> h >> a;
  	if(h%a==0) {cout << h/a <<endl; return 0;} 
  	cout << h/a + 1 << endl; 
  	return 0;
}

Measured memory_bytes: 256
//#include <cstdio>
#include <iostream>

#include <cstring>

#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cassert>

using namespace std;

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;

#define MAXN 100004

int N;
int H[MAXN][3];

int memo[MAXN][4];
int go(int n, int last) {
   if (n >= N) return 0;
   int& res = memo[n][last];
   if (res < 0) {
      res = 0;
      REP(k, 3) {
         if (k == last) continue;
         res = max(res, go(n+1, k) + H[n][k]);
      }
   }
   return res;
}

int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   cin >> N;
   REP(i, N) {
      REP(k, 3)
         cin >> H[i][k];
   }

   memset(memo, -1, sizeof(memo));
   int res = go(0, 3);
   cout << res << '\n';

   return 0;
}


Measured memory_bytes: 10752
s = gets.chomp.chars
x, y = gets.chomp.split(" ").map(&:to_i)

x_steps = []
y_steps = [y.abs]

x_first_move = true

x_move = true
f_count = 0

s << "T"
s.size.times do |i|
  if s[i] == "F"
    f_count += 1
  else
    if x_move
      if x_first_move
        x_steps << (x - f_count).abs
        x_first_move = false
      else
        x_steps << f_count
      end
    else
      y_steps << f_count
    end

    x_move = !x_move
    f_count = 0
  end
end

# pp s
# pp x, y
# pp x_steps
# pp y_steps

def f(steps, r, i)
  return true if r == 0
  return false if r < 0

  return false if i >= steps.size

  return true if f(steps, r - steps[i], i + 1)
  return true if f(steps, r, i + 1)
  false
end




def solve?(steps)
  # sum = steps.sum
  sum = 0
  steps.each do |s|
    sum += s
  end

  return false if sum.odd?
  half = sum / 2

  steps = steps.sort.reverse
  # f(steps, half, 0)
  size = steps.size

  dp = Array.new(size + 1) { Array.new(half + 1) }
  (half + 1).times do |j|
    dp[0][j] = (j == 0)
  end

  (size + 1).times do |i|
    next if i == 0
    (half + 1).times do |j|
      if dp[i-1][j]
        dp[i][j] = true
      else
        if j >= steps[i-1]
          dp[i][j] = dp[i-1][j-steps[i-1]]
        else
          dp[i][j] = false
        end
      end
    end
  end
  dp[-1][-1]
end


solved = solve?(x_steps) && solve?(y_steps)
if solved
  puts "Yes"
else
  puts "No"
end


Measured memory_bytes: 67064
#include<stdio.h>
//#pragma GCC optimize("Ofast","no-stack-protector","unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.2,popcnt,abm,mmx,avx")
//#include<bits/extc++.h>
//using namespace __gnu_pbds;
#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("%lf", &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 debug(x) cout<<(#x)<<"="<<x<<"\n";
#define qq cout<<"QQ\n";
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define f first
#define s second
#define ll long long
#define INF 2000000000
#define pi 3.14159265359
int main(){
	double r;
	while(~getI(r)){
		printf("%.6lf\n",pi*2*r);
	}
}


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

int main() {
  int n; cin>>n;
  int b[105];
  for (int i=0; i<n-1; i++) cin>>b[i];
  b[n-1]=b[n-2];
  int ans=b[0];
  for (int j=0; j<n-1; j++){
    ans+=min(b[j],b[j+1]);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    bool isBad = false;
    int cord;
    cin >> cord;
    
    int c1, c10, c100, c1000;
    c1 = cord%10;
    cord /= 10;
    c10 = cord%10;
    cord /= 10;
    c100 = cord%10;
    cord /= 10;
    c1000 = cord%10;
    cord /= 10;
    if((c1 == c10)||(c10 == c100)||(c100 == c1000)){
        cout << "Bad" << endl;
    }else{
        cout << "Good" << endl;
    }
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int CM = 1 << 17, CL = 12;
char cn[CM + CL], * ci = cn + CM + CL, * owa = cn + CM, ct;
const ll ma0 = 1157442765409226768;
const ll ma1 = 1085102592571150095;
const ll ma2 = 71777214294589695;
const ll ma3 = 281470681808895;
const ll ma4 = 4294967295;
inline int getint() {
	if (ci - owa > 0) {
		memcpy(cn, owa, CL);
		ci -= CM;
		fread(cn + CL, 1, CM, stdin);
	}
	ll tmp = *(ll*)ci;
	int dig = 68 - __builtin_ctzll((tmp & ma0) ^ ma0);
	tmp = tmp << dig & ma1;
	tmp = tmp * 10 + (tmp >> 8) & ma2;
	tmp = tmp * 100 + (tmp >> 16) & ma3;
	tmp = tmp * 10000 + (tmp >> 32) & ma4;
	ci += 72 - dig >> 3;
	return tmp;
}
const int dm = 1 << 20;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[10];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

int to[400004], ne[400004], he[100001];
int kotae[100001], Q[100001];
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);


	int N = getint(), M = getint();
	int k = 1;
	rep(i, M) {
		int a = getint(), b = getint();
		to[k] = b;
		ne[k] = he[a];
		he[a] = k++;
		to[k] = a;
		ne[k] = he[b];
		he[b] = k++;
	}

	int q = 0;
	Q[q++] = 1;
	kotae[1] = 1;
	rep(i, N) {
		int u = Q[i];
		for (int v = he[u]; v; v = ne[v]) {
			int To = to[v];
			if (!kotae[To]) {
				kotae[To] = u;
				Q[q++] = To;
			}
		}
	}
	printf("Yes\n");

	for (int i = 2; i <= N; i++) putint(kotae[i]);
	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 6416
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

int BipartiteGraph(const vector<vector<int>> &g) {
        int n = g.size();
        vector<int> color(n, -1);
        int white_cnt = 0;
        function<bool (int, int, int)> dfs = [&](int u, int prev, int c) {
                color[u] = c;
                if (c == 1) white_cnt ++;
                for (auto v : g[u]) if (v != prev) {
                        if (color[v] == -1) {
                                if (!dfs(v, u, 1 - c)) return false;
                        } else if (color[v] != 1 - c) {
                                return false;
                        }
                }
                return true;
        };
        if (!dfs(0, -1, 0)) return -1;
        return white_cnt;
}

int main() {
	int n,m; cin>>n>>m;
	vector<vector<int>> a(n);
	rep(i,0,m){
		int u,v; cin>>u>>v;
		u--; v--;
		a[u].push_back(v);
		a[v].push_back(u);
	}
	int cnt=BipartiteGraph(a);
	if(cnt==-1) printf("%lld",1LL*n*(n-1)/2-m);
	else printf("%lld",1LL*cnt*(n-cnt)-m);
  	return 0;
}


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


def main():
    N, M = map(int, input().split())
    result = [0] * N
    for _ in range(M):
        A, B = map(int, input().split())
        result[A - 1] += 1
        result[B - 1] += 1
    for m in result:
        print(m)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <functional>
#include <map>
#include <set>
#define Rep(i, n) for(int i=0;i<n;++i)
#define rep(i, n) for(int i=1;i<=n;++i)
#define ll long long int
#define INF 100000000
#define INFLL 100000000000
#define MOD 1000000007
#define PI 3.14159265359
#define All(a) (a).begin(), (a).end()

using namespace std;
using P = pair<ll, ll>;
 
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

struct Edge {
  int to;     
  ll weight; 
  Edge(int t, ll w) : to(t), weight(w) { }
};

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; }



int N;
ll a[210000];
ll d[210000];

int main () {
  cin >> N;
  rep(i, N) cin >> a[i];

  rep(i, N) {
    d[i] = d[i-1] + a[i];
  }

  ll cri = d[N] / 2;

  rep(i, N) {
    if (d[i] == cri) {
      if (d[N] % 2 == 0)
        cout << 0 << "\n";
      else
        cout << 1 << "\n";

      return 0;
    } else if (d[i] > cri) {
      ll res1 = abs((d[N] - d[i]) - d[i]);
      ll res2 = abs((d[N] - d[i-1]) - d[i-1]);
      cout << min(res1, res2) << "\n";

      return 0;
    }
  }
}

Measured memory_bytes: 3328
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
typedef long long ll;
int main(){
	int n,m;
	cin >>n>>m;
	vector<int> v1;
	vector<int> v2;
	int a,b;
	rep(i,m){
		cin >> a>>b;
		if (a==1) {
			v1.push_back(b);
		}
		else if (b==n) {
			v2.push_back(a);
		}
	}
/*	
	rep(i,v1.size()){
		cout << v1[i] << endl;
	}
	cout << "mqhi" << endl;
	rep(i,v2.size()){
		cout << v2[i] << endl;
	}
*/	
	//v1とv2のintersectionをとる
	//まずsortしておく
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	vector<int> inter;
//	set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),inserter(inter,inter.end()));
	set_intersection(v1.begin(),v1.end(),v2.begin(),v2.end(),back_inserter(inter));
	int l = inter.size();
	if(l) cout << "POSSIBLE" << endl;
	else cout << "IMPOSSIBLE" << endl;
	
	return 0;
}




Measured memory_bytes: 1276
def main():
    n, l = map(int, input().split())
    flavor = []
    for i in range(n):
        flavor.append(i + l)

    ans = 0
    if l >= 0 :
        for i in range(1, n):
            ans  += flavor[i]
    elif n + l - 1 < 0 :
        for i in range(0, n-1):
            ans  += flavor[i] 
    else :
        for i in range(n):
            ans  += flavor[i] 

    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  string a,b,c;
  cin>>a>>b>>c;
  printf("%c%c%c\n",a[0]-('a'-'A'),b[0]-('a'-'A'),c[0]-('a'-'A'));
}
	



Measured memory_bytes: 256
n,m,x = map(int,input().split())
ca = [list(map(int,input().split())) for _ in range(n)]
c = [ca[i][0] for i in range(n)]
a = [ca[i][1:] for i in range(n)]
ans = 0
cost = sum(c)
for i in range(2**n):
    kari = 0
    skill = [0] * m
    for j in range(n):
        if (i >> j) & 1:
            kari += c[j] 
            skill = [x + y for (x,y) in zip(skill,a[j])]
            
    if all([z >= x for z in skill ]):
        cost= min(cost,kari)
        ans += 1
        
if ans == 0:
    print(-1)
else:
    print(cost)

Measured memory_bytes: 9232
//g++  7.4.0

#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll T = 1;
    while(T--)
    {
        ll N; cin>>N;
        ll arr[N];
        ll ans = 0;
        
        for(ll i=0;i<N;++i)
            cin>>arr[i];
        
        sort(arr,arr + N);
        ll c = (N - 1);
        
        if(c != 0)
        {
            ans += arr[N - 1];
            c--;
        }
        
        for(ll i=(N - 2);i>0;--i)
        {
            if(c == 0)
                break;
            
            ans += arr[i];
            c--;
            
            if(c == 0)
                break;
            
            ans += arr[i];
            c--;
        }
        
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 5208
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
Scanner scan=new Scanner(System.in);
int a=scan.nextInt();
int b=scan.nextInt();
int c=a%500;
if(c<=b) {
	System.out.println("Yes");
}
else {
	System.out.println("No");
}
}
	}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int a,b,k;
	cin >> k >> a >> b;
	if((k - a%k)%k <= b-a) cout << "OK\n";
	else cout<<"NG\n";
}

Measured memory_bytes: 3636
S = input()
N = len(S)

ans = 0
flag = 0
for i in range(N):
    if i == 0:
        ans += 1
    else:
        if flag == 2:
            ans += 1
            flag = 1
        elif flag == 1:
            ans += 1
            flag = 0
        else:
            if S[i] == S[i-1]:
                flag = 2
            else:
                ans += 1

print(ans)


Measured memory_bytes: 40432
n, y = gets.strip.split.map(&:to_i)

found = false
_i, _j, _k = -1, -1, -1
for i in 0..n
    break if found
    for j in 0..n-i
        k = n - i - j
        total = 10000 * i + 5000 * j + 1000 * k
        if total == y
            found = true
            _i, _j, _k = i, j, k
            break
        end
    end
end

puts "#{_i} #{_j} #{_k}"


Measured memory_bytes: 1788
#include<iostream>
using namespace std;
int main() {
    string s;
    cin >> s;
    int counter = 0;
    if (s[0] == '1'){
      ++counter;
    }
    if (s[1] == '1') ++counter;
    if (s[2] == '1') ++counter;
    cout << counter << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
        sc.close();
    }
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

const int INF = 1e9;
const int NIL = 2e9;

int n, m;
int a[60], b[60];
int as[55], bs[55];

// ???????????????????????????????????????-1?????????????????????
int dp[52][52][52][52][3][2];

int sum(int l, int r, int *a){
    return a[r] - a[l];
}

// x, y: ?¬????????????????????????????
// lx, ly: ?¶???????????°??????????????????????
int rec(int x, int y, int lx, int ly, int p, int t){
    int &res = dp[x][y][lx][ly][p][t];
    if(res != NIL) return res;
    if(t == 0){
        res = -INF;
        if(x != n){
            int cand = rec(x+1, y, lx, (a[x] ? ly : y), 0, !t);
            res = max(res, cand);
        }
        int cand = sum(lx, x, as) - sum(ly, y, bs);
        if(p != 2){
            cand += rec(x, y, x, y, p+1, !t);
        }
        res = max(res, cand);
    } else {
        res = INF;
        if(y != m){
            int cand = rec(x, y+1, (b[y] ? lx : x), ly, 0, !t);
            res = min(res, cand);
        }
        int cand = sum(lx, x, as) - sum(ly, y, bs);
        if(p != 2){
            cand += rec(x, y, x, y, p+1, !t);
        }
        res = min(res, cand);
    }
    return res;
}

int main(){
    while(cin >> n >> m){
        rep(i, n){
            cin >> a[i];
            a[i] = max(0, a[i]);
            as[i+1] = as[i] + a[i];
        }
        rep(i, m){
            cin >> b[i];
            b[i] = max(0, b[i]);
            bs[i+1] = bs[i] + b[i];
        }
        fill((int*)begin(dp), (int*)end(dp), NIL);
        cout << rec(0, 0, 0, 0, 0, 0) << endl;
    }
}

Measured memory_bytes: 174460
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#ifndef ONLINE_JUDGE
 // freopen("input.txt","r",stdin);
#endif

  string s;
  cin>>s;
  int q;
  cin>>q;
  string pref="";
  string suff="";
  int rev=0;
  for(int i=0;i<q;i++)
  {
      int op;
      cin>>op;
      if(op==1)
      {
        swap(pref,suff);
        rev++;
      }
      else
      {
        int num;
        char ch;
        cin>>num>>ch;
        if(num==1)
          pref+=ch;
        else
          suff+=ch;
      }
  }
  if(rev%2!=0)
  {
    reverse(s.begin(),s.end());
  }
  reverse(pref.begin(),pref.end());
  cout<<pref+s+suff<<endl;
  return 0;
}

Measured memory_bytes: 4196
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var r = ReadLong();

            return r * r;
        }

        #region Console

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define SZ(x) (int)(x).size()
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> pii;
 
template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

const int N = 105;

int n;
int d[N][2];

int main(){
  scanf("%d", &n);
  bool ans = false;
  for(int i = 0; i < n; i++){
    scanf("%d %d", &d[i][0], &d[i][1]);
    if(i >= 2){
      int cnt = 0;
      for(int j = i - 2; j <= i; j++){
        if(d[j][0] == d[j][1]) cnt++;
      }
      if(cnt == 3) ans = true;
    } 
  }
  
  printf("%s\n", ans ? "Yes" : "No");
  
  return 0;
}


Measured memory_bytes: 3760
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	static long mod = 1000000007;

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		String[] t = sc.nextLine().split(" ");
		int  n = Integer.parseInt(t[0]);
		//long k = Long.parseLong(t[1]);

		String[] r = sc.nextLine().split(" ");
		BigInteger ans = BigInteger.ONE;
		BigInteger max = BigInteger.ONE;
		for (int i = 0; i < 18; i++) {
			max = max.multiply(BigInteger.valueOf(10));
		}

		for(int i = 0; i < n; i ++) {

			if (BigInteger.ZERO.equals(new BigInteger(r[i]))) {
				ans = BigInteger.ZERO;
				break;
			}
		}

		if(Integer.parseInt(ans.toString()) == 0) {
			System.out.println(ans);
			return;
		}

		for(int i = 0; i < n; i ++) {
			ans = ans.multiply(new BigInteger(r[i]));
			if(ans.compareTo(max) > 0) {

			ans = BigInteger.valueOf(-1);
			break;
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 70160
<?php
list($N) = ints();
$sum = 0;
for($i = 0; $i <= $N; $i++){
    if($i%3==0||$i%5==0){
        
    }else{
        $sum+=$i;
    }
}
printf("%d", $sum);

function str(){return trim(fgets(STDIN));}
function ints(){return array_map('intval',explode(' ',trim(fgets(STDIN))));}
function int(){return intval(trim(fgets(STDIN)));}
function chmax(&$a,$b){if($a<$b){$a=$b;return 1;}return 0;}
function chmin(&$a,$b){if($a>$b){$a=$b;return 1;}return 0;}
function popcount($x){$c=0;while($x){$x&=$x-1;++$c;}return$c;}
function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}
// 座圧対象の配列 -> [圧縮された配列,復元用のMap,圧縮用のMap]
function atsu($array){$a = array_flip($array);$fuku=array_flip($a);sort($fuku);$atsu = array_flip($fuku);foreach($array as $i=>$val)$array[$i]=$atsu[$val];return [$array, $fuku, $atsu];}
function gcdAll($array){$gcd=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$gcd=gcd($gcd,$array[$i]);}return $gcd;}
function gcd($m, $n){if(!$n)return $m;return gcd($n, $m % $n);}
function lcmAll($array){$lcm=$array[0];for($i=1,$I=count($array);$i<$I;++$i){$lcm=lcm($lcm,$array[$i]);}return $lcm;}
function lcm($a, $b) {return $a / gcd($a, $b) * $b;}

function dfs($current, $from = -1, $d = 0){
  global $G, $distance;
  $distance[$current] = $d;
  foreach($G[$current] as $to){
    if($from != $to){
      dfs($to, $current, $d + 1);
    }
  }
}

function loadTree($N = false){
  if($N === false)$N = $GLOBALS['N'];
  return loadGraph($N, $N-1);
}
function loadGraph($N = false, $M = false, $both = true){
  if($N === false)$N = $GLOBALS['N'];
  if($M === false)$N = $GLOBALS['M'];
  $G = array_fill(1, $N, []);
  for($i = 0; $i < $M; $i++){
    $values = ints();
    if(count($values) == 2){
      list($a, $b) = $values;
      $G[$a][] = $b;
      if($both)$G[$b][] = $a;
    }else{
      list($a, $b, $d) = $values;
      $G[$a][] = [$b, $d];
      if($both)$G[$b][] = [$a, $d];
    }
  }
  return $G;
}


Measured memory_bytes: 16188
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    long long n,a=0,b=1;
    cin >> n;
    while (1){

        if (b>=n+1) break;
        b=b*2;
         a++;
    }
    cout << a << endl;
}


Measured memory_bytes: 3108
#include <bits/stdc++.h>
using namespace std;
int dp[201][201];

int gcd(int a, int b){
  if(dp[a][b] != 0)
    return dp[a][b];
  else{
    int temp;
    while( b!= 0){
      temp = b;
      b = a % b;
      a = temp;
    }
    dp[a][b] = a;
    dp[b][a] = a;
    return a;
  }
}
int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  memset(dp, 0, sizeof(dp));
  int k;
  cin >> k;
  long long sum = 0;
  for(int i = 1; i <= k; i++){
    for(int j = 1; j <= k; j++){
      for(int x = 1; x <= k; x++){
        int res = gcd(i,j);
        sum += gcd(res,x);
      }
    }
  }
  cout << sum;
  return 0;
}

Measured memory_bytes: 3844
#include <bits/stdc++.h>
#define ll          long long int
#define uu          first
#define vv          second
#define pii         pair<int,int>
#define pll         pair<ll,ll>
#define fastio    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;


const int INF = 1e9;
const ll MOD = 1e9 + 7;
const int N = 1e3 + 3;

int main() {
    int l ,r, d;
    cin>>l>>r>>d;
    int cnt = 0;
    for(int i = l; i <=r ; i ++) {
        if(i%d ==0)cnt++;
    }
    cout<<cnt<<'\n';
    return 0;
}

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

int main(){
	int N,sum=0;
	cin>>N;
	
	if(N%10==1)
		sum+=1;
	
	if((N/10)%10==1)
		sum+=1;
	
	if(N/100==1)
		sum+=1;
	
	cout<<sum<<endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
#include <climits>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <iostream>
#include <math.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define str string
#define deb_arr(arr,n) for(ll i=0;i<(n);i++){ cout << (arr)[i] << " ";}
#define in_arr0(arr,n) for(ll i=0;i<(n);i++){ cin >> (arr)[i]; }
#define in_arr1(arr,n) for(ll i=1;i<=(n);i++){ cin >> (arr)[i];}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> pbds;
#define vll vector<ll> 
#define fr(n) for(i=0;i<(n);i++)
#define fr1(n) for(i=1;i<=(n);i++)
#define pll pair<ll,ll>
#define f first
#define s second
#define vpll vector<pll>
#define ump unordered_map
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define IN(a,b) ((a).find(b)!=(a).end())
#define pb push_back
#define mkp make_pair
#define PI M_PI
#define INF 1e18
#define deb(x) if(ON) cout << #x <<" : " << x << endl
#define fast ios_base::sync_with_stdio(false)
#define io cin.tie(NULL),cout.tie(NULL)
#define ON !false
ll dx[]={0,-1,0,1};
ll dy[]={1,0,-1,0};
const ll mod=1e9+7;
inline ll add(ll a,ll b){
    return  ((a%mod)+(b%mod)+mod)%mod;
}
inline ll mul(ll a,ll b){
    return ((a%mod)*(b%mod)+mod)%mod;
}
void pause(ll id){
    cout << "Waiting " << id << endl;
    cin >> id;
}

const int mxn=1e5+10;


void init(){

    return ;
}


signed main(){
    fast;
    io;
    if(!true){
        freopen("in.txt","r",stdin);
        freopen("out.txt","w",stdout);
    }
    init();
    ll i,j;
    ll a,b,c,k;
    cin >> a >> b >> c >> k;
    ll ans=0;
    if(k > 0){
        ans+=min(a,k);
        k-=min(a,k);
    }
    if(k > 0){
        ans+=0*(min(b,k));
        k-=min(b,k);
    }
    if(k > 0){
        ans-=(min(c,k));
        k-=min(c,k);
    }
    cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#define INF 1000000007
#define loop(x) for(int i = 0; i < x; i++)
using namespace std;

long long swapCount = 0;
void swap(vector<int> &arr, int i, int j) {
    if(i == j) {
        return;
    }

    int temp = arr[i];
    arr[i] = arr[j];
    arr[j] = temp;
    swapCount++;
}

int f(vector<int> arr) {
   vector<int> dp(arr.size(), 0);
   dp[0] = 0;
   dp[1] = dp[0] + abs(arr[1] - arr[0]);
   for(int i = 2; i < arr.size(); i++) {
       dp[i] = min(dp[i - 1] + abs(arr[i] - arr[i - 1]), dp[i - 2] + abs(arr[i] - arr[i - 2]));
   }
   return dp[arr.size() - 1];
}

int main() { 

   //code
   ios::sync_with_stdio(false);
   int t = 1;
    //cin>>t;
    //cin.ignore();
   while(t--) {
        int row, col;
        ////////////////FOR ARRAY
        // cin>>col;
        // vector<int> arr;
        // for(long long i = 0; i < col; i++) {
        //     int x;
        //     cin>>x;
        //     arr.push_back(x);
        // }
        // f(arr);

        //////////////FOR MATIX
        // vector<int> arr;
        // for(int i = 0; i < row; i++) {
        //     arr.push_back(vector<int>(col, 0));
        //     for(int j = 0; j < col; j++) {
        //         int x;
        //         cin>>x;
        //         arr[i].push_back(x);
        //     }
        // }
        // f(arr);

        ////////////FOR STRING
        // string s;
        // cin>>s;
        // cout<<f(s)<<endl;
         
         cin>>col;
        vector<int> arr;
        for(long long i = 0; i < col; i++) {
            int x;
            cin>>x;
            arr.push_back(x);
        }
        cout<<f(arr)<<endl;
        
    }
    return 0; 
}

Measured memory_bytes: 1528
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(int i = (s); i < (n); i++)
#define all(v) begin(v), end(v)
#define allg(v) begin(v), end(v), greater<int>()



int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  
  ll n;
  cin >> n;
   
  int it = 1;
  int a = 0;
  rep(i, 0, n) {
    int t; cin >> t;
    if(t == it) {
      a++;
      it++;
    }
  }
  
  if(a == 0)
    cout << -1 << "\n";
  else
    cout << n - a << "\n";

}


Measured memory_bytes: 256
#include<iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <iomanip>//setprecision
#include<math.h>
#include <functional>
#include<climits>
using namespace std;
template <typename T> bool chmax(T &u, const T z) { if (u < z) {u = z; return true;} else return false; }
template <typename T> bool chmin(T &u, const T z) { if (u > z) {u = z; return true;} else return false; }
#define ll  long long 
const ll INF=1LL<<60;
const ll MOD=1000000007;
#define rep(i, n)        for(ll i=0; i<(ll)(n); ++i)
int main(){
    ll a,ans=0;cin>>a;
    for (ll i = 1; i < a; i++)
    {
        for (ll o = 1; o < a/i+1;o++)
        {
            if(i*o<a)ans++;
        }
        
    }
    cout<<ans;
}

Measured memory_bytes: 3652
l,r=map(int,input().split())
mod=2019
if r-l>=3000:
    print(0)
else:
    ans=1111111111
    for i in range(l,r):
        for j in range(i+1,r+1):
            ans=min(ans,(i%mod)*(j%mod)%mod)
    print(ans)


Measured memory_bytes: 2940
S = input()
     
a = S.find('A')
c = S.find('C')
     
s1 = S[2:-1]
s_count = s1.count('C')
   
y = S[1:c-1]
z = S[c+1:]

if c == 2:
	y = S[1]   

if a != 0:
	print('WA')

elif s_count != 1:
	print('WA')
     
else:
	if y.islower() and z.islower():
			print('AC')
	else:
		print('WA')

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

int x_cubic(int x, int depth);

int main(void) {
  int x;
  cin >> x;
  cout << x_cubic(x, 3) << endl;

  return 0;
}

int x_cubic(int x, int depth) {
  if(depth == 1) {
    return x;
  } else {
    return x * x_cubic(x, depth - 1);
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define erep(i,a,b) for(int i=a;i<=(int)(b);++i)
#define per(i,a,b) for(int i=(a);i>(b);--i)
#define eper(i,a,b) for(int i=(a);i>=b;--i)
#define fore(x, a) for(auto &x : a)
#define pb push_back
#define mp make_pair
#define INF 100100100100
#define inf 2001001001
#define MOD 1000000007
#define ALL(x) begin(x),end(x)
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using vii = vector<int>;
using vll = vector<ll>;
template<class T>using vv = vector<T>;
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; }
template<class T>void show(const vector<T> &a) { for (int i = 0; i < (int)a.size(); ++i) cout << a[i] << (i != (int)a.size()-1 ? " " : "\n"); }
template<class T>T gcd(T a, T b){ return b ? gcd(b, a % b) : a; }
template<class T>T lcm(T a, T b){ return a / gcd(a, b) * b; }
int dy[]={0, 1, -1, 0};
int dx[]={1, 0, 0, -1};

int a, b;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
    char c;
    cin >> c;
    if (c == '1') cout << "Hello World" << endl;
    else {
      cin >> a >> b;
      cout << a + b << endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
using namespace std;
int main(void){
    int N;
    cin >> N;
    unordered_map<string, long long> map;
    string a;
    for(int n=0; n<N; n++){
        cin >> a;
        sort(a.begin(), a.end());
        map[a]++;
    }
    
    long long ans = 0;
    for(const auto &c : map){
        ans += c.second*(c.second-1)/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 10660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll INF = 3000000000000000000; //10^18
const int inINF = 1000000000; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;

int main(){
    string S, T;
    cin >> S >> T;
    int cnt;
    cnt = 0;
    for (int i = 0; i < S.length(); i++) {
        if(S[i] != T[i]){
            cnt++;
        }
    }
    printf("%d\n", cnt);


}

Measured memory_bytes: 3828
#include<stdio.h>
#include<string.h>
int main(){
	char str[2][205];
	int n;
	int x;
	scanf("%s",str[0]);
	while(str[0][0] != '-'){
		scanf("%d",&n);
		for(int i=0;i<n;i++){
			scanf("%d",&x);
			strcpy(str[(i+1)%2],&str[i%2][x]);
			str[i%2][x] ='\0';
			strcat(str[(i+1)%2],str[i%2]);
		}
		printf("%s\n",str[(n)%2]);
		scanf("%s",str[0]);
	}
	return 0;
}


Measured memory_bytes: 2600
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
 
int main() {
    int k, x;
    scan2Int(k, x);
    if (500 * k >= x) printYes();
    else printNo();
    return 0;
}

Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const int maxn=1e6+5;
vector<ll> V;
int pre[maxn];
int ac,wa,tle,re;
int main() {
    int n;cin>>n;
    for(int i=1;i<=n;i++) {
        string s;cin>>s;
        if(s=="AC") ac++;
        else if(s=="WA") wa++;
        else if(s=="TLE") tle++;
        else re++;
    }
    cout<<"AC x "<<ac<<endl;
    cout<<"WA x "<<wa<<endl;
    cout<<"TLE x "<<tle<<endl;
    cout<<"RE x "<<re<<endl;
    return 0;
}

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

int main() {
	int i, j, len,lenp, flg;
	char s[203] = "", p[101] = "";
	scanf("%s", s);
	strcat(p,s);
	strcat(s,p);
	scanf("%s", p);
	for( i = 0; i < strlen(s) / 2; i++) {
		flg = 1;
		for( j = 0; j < strlen(p); j++) {
			if(s[i + j] != p[j]) {
				flg = 0;
				break;
			}
		}
		if(flg == 1) break;
	}
	if(flg == 1) {
		printf("Yes\n");
	} else {
		printf("No\n");
	}
	return 0;
}

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




ANS=N
for a in range(1,N):
    FIRST=a%10+(a%100)//10+(a%1000)//100+(a%10000)//1000+(a%100000)//10000
    x=N-a
    SUB=x%10+(x%100)//10+(x%1000)//100+(x%10000)//1000+(x%100000)//10000

    SUM=FIRST+SUB

    if ANS!= SUM:
        ANS=min(ANS,SUM)

print(ANS)

Measured memory_bytes: 3064
function main()
  
  (N,M) = map(x -> parse(Int,x), split(readline()))
  
  s = zeros(Int,M)
  c = zeros(Int,M)
  ans = ["" for i in 1:N]
  
  for i in 1:M
    (s,c) = split(chomp(readline())," ")
    s = parse(Int,s)
    if ans[s] == "" || ans[s] == c
      ans[s] = c
    else
      ans[1] = "-1"
      break
    end
  end

  if N == 1
    if M > 0
      println(ans[1])
    else
      println(0)
    end
  elseif ans[1] == "0" || ans[1] == "-1"
    println(-1)
  else
    for i in 1:N
      if ans[1] == "" && i == 1
        print("1")
      elseif ans[i] == "" && i != 1
        print("0")
      else
        print(ans[i])
      end
    end
    println()
  end

end

main()

Measured memory_bytes: 115060
from heapq import heappush, heappop
T = int(input())

for _ in range(T):
    N = int(input())
    arr1 = []
    arr2 = []
    for _ in range(N):
        K, L, R = list(map(int, input().split()))
        if L > R:
            arr1.append((K, L, R))
        else:
            arr2.append((N-K, R, L))

    arr1.sort()
    baseS = 0
    diffS = 0
    q = []
    length = 0
    for K, L, R in arr1:
        baseS += R
        diff = L - R
        heappush(q, diff)
        diffS += diff
        length += 1
        while length > K:
            d = heappop(q)
            diffS -= d
            length -= 1
    ans = baseS + diffS

    arr2.sort()
    baseS = 0
    diffS = 0
    q = []
    length = 0
    for K, L, R in arr2:
        baseS += R
        diff = L - R
        heappush(q, diff)
        diffS += diff
        length += 1
        while length > K:
            d = heappop(q)
            diffS -= d
            length -= 1
    ans += baseS + diffS
    print(ans)


Measured memory_bytes: 111544
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<string>
#include<sstream>
#include<iomanip>
#include<utility>
#include<cmath>
#include<set>
#include<list>
#include<string>
#include<queue>
#include<stack>
#include<deque>
#include<map>
#include<set>
#include<cstring>
#include<iterator>
#include<bitset>
#include<assert.h>
//#include<chrono>
//#include<time.h>
//#include<windows.h>
using namespace std;
 
#define int ll
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef vector<int> VI;
typedef vector<long long int> VL;
static const int MOD = 1000000007;
//static const int INF = 2147483647;
//static const long long INF = 9223372000000000000;
//static const long long INF = 9223372000000000000/2;
//static const int INF = 1000010000;
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define FI first
#define SE second
#define NP next_permutation
#define PQ priority_queue
#define UB upper_bound
#define LB lower_bound
#define SZ(a) int((a).size())
#define LEN(a) int((a).length())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define REP1(i,x) for(int i=1;i<=(int)(x);i++)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREP1(i,x) for(int i=((int)(x));i>0;i--)
#define ALL(x) (x).begin(),(x).end()
#define YESNO(x) puts((x)?"YES":"NO")
struct edge {int /*from,*/to,cost;};

signed main(){
    int n,m;
    cin >> n >> m;
    int ans = 0;
    if(n==1&&m==1){
        puts("1");
        return 0;
    }
    if(n==1||m==1){
        printf("%d\n",max(n,m)-2);
        return 0;
    }

    ans += (m-2)*(n-2);

    printf("%lld\n",ans);

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{int a,b,x;
cin>>a>>b>>x;
if(a>x){
    cout<<"NO";
}
else if((a+b)<x){
    cout<<"NO";
}
else if((a+b)>x &&a<=x){
    cout<<"YES";
}
    return 0;
}





Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <algorithm>
#include <vector>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <string>
#include <functional>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iomanip>
#include <bitset>
#define pb push_back
#define YES cout<<"YES"<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define No cout<<"No"<<endl
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<30)
#define LLINF (1LL<<60)
#define MOD 1000000007
typedef long long ll;
using namespace std;

int main(){
    ll n;
    cin>>n;
    ll numPlusHeight[300005]={},numMinusHeight[300005]={};
    rep(i,n){
        ll t;
        cin>>t;
        if((i+1+t)<300005)numPlusHeight[i+1+t]++;
        if((i+1-t)>0)numMinusHeight[i+1-t]++;
    }
    ll ans=0;
    rep(i,300005){
        ans+=numPlusHeight[i]*numMinusHeight[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 8320
use std::io::*;
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! scan {
  ($e:expr; $t:ty) => {
    $e.get::<$t>()
  };
  ($e:expr; $($t:ty), *) => {
    ($($e.get::<$t>(),)*)
  };
  ($e:expr => $i:expr; $t:ty) => {
    (0..$i).map(|_| $e.get::<$t>()).collect::<Vec<$t>>()
  };
  ($e:expr => $row:expr, $col:expr; $t:ty) => {
    (0..$i).map(|_| scan!($e => $col; $t)).collect::<Vec<$t>>()
  }
}

struct Scanner<R: Read> {
  reader: R
}

#[allow(dead_code)]
impl<R: Read> Scanner<R> {
  fn new(reader: R) -> Scanner<R> {
    Scanner { reader: reader }
  }
  fn safe_get<T: FromStr>(&mut self) -> Option<T> {
    let token = self.reader.by_ref().bytes().map(|c| c.unwrap() as char)
      .skip_while(|c| c.is_whitespace())
      .take_while(|c| !c.is_whitespace())
      .collect::<String>();
    if token.is_empty() { None } else { token.parse().ok() }
  }
  fn get<T: FromStr>(&mut self) -> T {
    if let Some(v) = self.safe_get() { v } else {
      writeln!(stderr(), "Terminated with EOF").unwrap();
      std::process::exit(0);
    }
  }
}

trait Writable {
  fn write(&self, sep: &'static str) -> String;
}

impl<T: ToString> Writable for Vec<T> {
  fn write(&self, sep: &'static str) -> String {
    self.iter().map(|e| e.to_string()).collect::<Vec<String>>().join(sep)
  }
}

fn main() {
  let cin = stdin();
  let cin = cin.lock();
  let mut sc = Scanner::new(cin);
  let (r, g, b, n) = scan!(sc; i32, i32, i32, i32);
  let mut ans = 0;
  for rb in 0..(n / r) + 1 {
    for gb in 0..((n - r * rb) / g) + 1 {
      if (n - r * rb - g * gb) % b == 0 {
        ans += 1;
      }
    }
  }
  println!("{}", ans);
}


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

int main(){
    long h,w;
    cin>>h>>w;

    if(h==1 || w==1){
        cout<<1<<endl;
    }else if(w%2==0){
        cout<<w*h/2<<endl;
    }else{
        if(h%2==0){
            cout<<w*h/2<<endl;
        }else{
            cout<<w*h/2+1<<endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <chrono>
#include <random>
#include <functional>

using namespace std;

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

	int n, m;
	cin >> n >> m;
	vector<int> a(n);
	for (auto &t : a) {
		cin >> t;
	}
	vector<int> b(n, -1);
	while (m--) {
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		b[u] = max(b[u], a[v]);
		b[v] = max(b[v], a[u]); 
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += (a[i] > b[i]);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3972
import sys
import math as mas

li='abcdefghijklmnopqrstuvwxyz'
for t in sys.stdin:
	for i in range(30):
		a=t[:-1].translate(str.maketrans(li,li[i:]+li[:i]))
		if 1+a.find("this") or 1+a.find("that") or 1+a.find("the"):
			print(a)
			break
#for i in sys.stdin:
#	a,b=map(int,i.split())
#	print(gcd(a,b),lcm(a,b))

Measured memory_bytes: 7536