akhauriyash/Code-Regression huggingface dataset:
/* code by AbhiTaker
         ____
        /    \
       /  __  \              _______      __       _   _    _____    _____
      /  /  \  \            |__   __|    /  \     | | / /  |  ___|  |  _  \
     /  /____\  \     ___      | |      / /\ \    | |/ /   | |__    | |_)  )
    /  /______\  \   |___|     | |     / /__\ \   |   /    |  __|   |    _/
   /  /        \  \            | |    / /----\ \  | |\ \   | |___   | |\ \
  /__/          \__\           |_|   /_/      \_\ |_| \_\  |_____|  |_| \_\
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define M 1000000007
#define N 1000016
#define ff first.first
#define fs first.second
#define sf second.first
#define ss second.second
#define f first
#define s second
#define inf 9000000000000000000
ll a[N];

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    priority_queue< pair<ll, pair<ll, ll> > > pq;
    ll i,n,cnt = 0,u=0,d=0,x;
    cin>>n;

    for(i=0; i<n; i++)
        cin>>a[i];

    for(i=0; i<n; i++)
    {
        cin>>x;
        if(a[i]-x == 0)
            continue;
        pq.push({a[i]-x, {a[i], x} });
    }

    while(!pq.empty())
    {
        if(pq.top().f>0)
        {
            if(d>0)
            {
                if(d>=pq.top().f)
                    d -= pq.top().f;
                else
                {
                    u += pq.top().f - d;
                    d = 0;
                }
            }
            else
                u += pq.top().f;
            pq.pop();
        }
        else{
            x  = -pq.top().f;
            if(u>0)
            {
                if(2*u>= x)
                {
                        u -= x/2;
                }
                else
                {
                    d += (x- 2*u)/2;
                    u=0;
                }
            }
            else
                d += x/2;
                pq.pop();
        }
    }

    if(u==0)
        cout<<"Yes\n";
    else
        cout<<"No\n";


    return 0;
}


Measured memory_bytes: 832
/*
             much pretests
        ▄              ▄    
        ▌▒█           ▄▀▒▌   wow vectors
        ▌▒▒█        ▄▀▒▒▒▐   
       ▐▄█▒▒▀▀▀▀▄▄▄▀▒▒▒▒▒▐        heckin_TLE
     ▄▄▀▒▒▒▒▒▒▒▒▒▒▒█▒▒▄█▒▐   
   ▄▀▒▒▒░░░▒▒▒░░░▒▒▒▀██▀▒▌   
  ▐▒▒▒▄▄▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▀▄▒▌      beautiful graphs
  ▌░░▌█▀▒▒▒▒▒▄▀█▄▒▒▒▒▒▒▒█▒▐  
 ▐░░░▒▒▒▒▒▒▒▒▌██▀▒▒░░░▒▒▒▀▄▌ 
 ▌░▒▒▒▒▒▒▒▒▒▒▒▒▒▒░░░░░░▒▒▒▒▌  wow cp
▌▒▒▒▄██▄▒▒▒▒▒▒▒▒░░░░░░░░▒▒▒▐ 
▐▒▒▐▄█▄█▌▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▒▒▌        much time
▐▒▒▐▀▐▀▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒░▒▒▐ 
 ▌▒▒▀▄▄▄▄▄▄▀▒▒▒▒▒▒▒░▒░▒░▒▒▒▌     very memory
 ▐▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▒▄▒▒▐  
  ▀▄▒▒▒▒▒▒▒▒▒▒▒▒▒░▒░▒▄▒▒▒▒▌  
    ▀▄▒▒▒▒▒▒▒▒▒▒▄▄▄▀▒▒▒▒▄▀   much loops
      ▀▄▄▄▄▄▄▀▀▀▒▒▒▒▒▄▄▀     
         ▀▀▀▀▀▀▀▀▀▀▀▀     
         bugs do me a bamboozle
*/

#include<bits/stdc++.h>
#define int 			long long
#define fi 				first
#define sc 				second
#define pii 			pair<int,int>
#define vi 				vector<int>
#define mii 			map<int,int>
#define msi 			map<string,int>
#define si 				set<int>
#define mlem			main
#define all(v) 			v.begin(),v.end()
#define sz(v)  			int((v).size())
#define rep(i,a,b)    	for(int i=a;i<b;i++)
#define dep(i,a,b)    	for(int i=a;i>=b;i--)
#define isinarr(i,n) 	((i>=0)?((i<n)?1:0):0)
#define pb 				push_back
#define ppb 			pop_back
#define lb 				lower_bound
#define ub 				upper_bound
#define hell 			1000000007
#define PI 				3.14159265
#define mp 				make_pair
#define inparr(a,n) 	rep(i,0,n)cin>>a[i];
#define strwspaces(s) 	getline(cin,s)
#define give(x,y) 		cout<<x<<" "<<y<<endl;
#define setp(n) 		cout<<fixed<<setprecision(n);
#define endl   			'\n'
#define inp(n) 			int n;cin>>n;
#define inps(s) 		string s;cin>>s;
#define setmem(inde,k) 	memset(inde,k,sizeof(inde))
#define tr(a,m) 		for(auto a=m.begin();a!=m.end();a++)
using namespace std;

int i,j,k,l;

void woof()
{
	inps(s);
	if(s[s.size()-1]=='s')
		s+="es";
	else
		s+='s';
	cout<<s<<endl;
} 



signed mlem()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while(t--)
        woof();
    return 0;
}

Measured memory_bytes: 3644
package main

import "fmt"


func main(){
	var A, B, C int
	var K int

	fmt.Scan(&A, &B, &C, &K)

	
	if abs(A-B) > 1e18 {
		fmt.Printf("Unfair\n")
	}else{
		if K % 2 == 0{
		fmt.Println(A - B)
		}else {
			fmt.Println(B-A)
		}
	}
}

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

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
s.find_by_order(x) xth element in set
x.order_of_key(x) number of elements <x*/
#define ll long long
#define vi vector<int>
#define si set<int>
#define mii map<int,int>
#define pb push_back
#define pf push_front
#define PI acos(-1)
#define pii pair<int,int>
#define extract_word(s)  stringstream str(s); while(str>>word)
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SET(s) cout<<fixed<<setprecision(s)
#define set0(a) memset(a,0,sizeof(a))
#define endl "\n"
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define lower_string(s) transform(all(s),s.begin(),::tolower())
#define upper_string(s) transform(all(s),s.begin(),::toupper())
#define size(s) (int)s.size()
template<typename T,typename U>
bool compare(T x,U y){return(abs(x-y)<=1e-9);}
const int MOD=1e9+7;
void solve()
{
fastio
int p,q,r;
cin>>p>>q>>r;
cout<<min(p+q,min(p+r,q+r));
}
int main()
{
//code
fastio
int t;
t=1;
while(t--)
{
solve();
cout<<endl;
}
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void solve() {
	int n; cin >> n;
	vector<int> A(n), B(n);
	int max1 = 0, max2 = 0;
	rep(i, n) {
		scanf("%d", &A[i]);
		if (A[i] > max1) {
			max2 = max1;
			max1 = A[i];
		}
		else if (A[i] > max2) {
			max2 = A[i];
		}
	}

	rep(i, n) {
		if (A[i] == max1) printf("%d\n", max2);
		else printf("%d\n", max1);
	}
}

int main(void) {
	solve();
	return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define ri register
#define int long long
using namespace std; const int N=300010;
inline int read()
{
   	int s=0,w=1; ri char ch=getchar();
   	while(ch<'0'||ch>'9') {if(ch=='-') w=-1; ch=getchar(); }
   	while(ch>='0'&&ch<='9') s=s*10+ch-'0', ch=getchar();
   	return s*w;
}
int book[N],n,H,W,f[N],res;
struct Node{ int u,v,w; }e[N];
inline bool cp(Node x,Node y) { return x.w>y.w; }
inline int Find(int x) { return f[x]^x?f[x]=Find(f[x]):x; }
signed main()
{
	n=read(), H=read(), W=read();
	for(ri int i=1;i<=n;i++) e[i].u=read()+W, e[i].v=read(), e[i].w=read();
	for(ri int i=1;i<=H+W;i++) f[i]=i;
	sort(e+1,e+1+n,cp);
	for(ri int i=1;i<=n;i++)
	{
		int fx=Find(e[i].u), fy=Find(e[i].v);
		if(fx==fy)
		{
			if(book[fx]) continue;
			book[fx]=1, res+=e[i].w;
			continue;
		}
		if(book[fx] && book[fy]) continue;
		book[fx]|=book[fy], f[fy]=fx, res+=e[i].w;
	}
	printf("%lld\n",res);
	return 0;
} 

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

using namespace std;
using LL = long long;
using P = pair<int, int>;
using Tapris = tuple<int, int, int>;

#define REP(i, n) for(LL i = 0; i < n; ++i)
#define FOR(i, a, n) for(LL i = a; i < n; ++i)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

//#define int long long
bool isprime(LL x){
    if(x == 2) return true;
    if(x < 2 || x % 2 == 0) return false;
    LL i = 3;
    LL sqrtx = sqrt(x);
    while(i <= sqrtx){
        if(x % i == 0) return false;
        i += 2;
    }
    return true;
}
// maxまでの素数をvectorに入れて返す
vector<LL> eratos(LL max){
    vector<LL> primeVec;
    vector<bool> isprime;
    double sqrtmax = sqrt(max);
    isprime.resize(max + 1);
    isprime[0] = false; isprime[1] = false;
    FOR(i, 2, max + 1){
        isprime[i] = true;
    }
    FOR(i, 2, sqrtmax){
        if(isprime[i]){
            for(int j = 0; i * (j + 2) < max + 1; ++j){
                isprime[i * (j + 2)] = false;
            }
        }
    }
    REP(i, max + 1){
        if(isprime[i])  primeVec.pb(i);
    }
    return primeVec;
}
/*************** using variables ***************/
int n;
/**********************************************/

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

    vector<LL> sosuu_list = eratos(123456 * 2);
    while(cin >> n, n){
        auto s = upper_bound(all(sosuu_list), n);
        auto e = upper_bound(all(sosuu_list), 2*n);
        cout << e-s << endl;
    }
}



Measured memory_bytes: 3228
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: usize,
        m: usize,
        a: [usize; n],
        bc: [(usize, usize); m],
    }
    let mut bc = bc;
    bc.sort_by_key(|row| row.1);
    bc.reverse();
    let mut nums = vec![];
    for ai in a {
        nums.push(ai);
    }
    let mut count = 0;
    'outer: for (b, c) in bc {
        for j in 0..b {
            nums.push(c);
            count += 1;
            if count >= n {
                break 'outer;
            }
        }
    }
    nums.sort();
    nums.reverse();
    let mut sum = 0;
    for i in 0..n {
        sum += nums[i];
    }
    println!("{}", sum);
}


Measured memory_bytes: 12540
using System;
using System.Linq;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using static program.Input;
using static program.MyMath;
using static System.Console;

namespace program {
  class Program {
    static string Alp = "abcdefghijklmnopqrstuvwxyz";
    static void Main()
    {
      var a = ScanLongArray();
      if(a[0] >= a[2])
        WriteLine($"{a[0]-a[2]} {a[1]}");
      else 
        WriteLine($"0 {Math.Max(0, a[0]+a[1]-a[2])}");
    }
  }
  
  static class Input {
    static public int ScanInt() { return int.Parse(Console.ReadLine()); }
    static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
    static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
    static public long ScanLong() { return long.Parse(Console.ReadLine()); }
    static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
    static public int[] ScanIntArray() { return Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray(); }
    static public uint[] ScanUintArray() { return Console.ReadLine().Split().Select(x => uint.Parse(x)).ToArray(); }
    static public double[] ScanDoubleArray() { return Console.ReadLine().Split().Select(x => double.Parse(x)).ToArray(); }
    static public long[] ScanLongArray() { return Console.ReadLine().Split().Select(x => long.Parse(x)).ToArray(); }
    static public ulong[] ScanUlongArray() { return Console.ReadLine().Split().Select(x => ulong.Parse(x)).ToArray(); }

    static public string ScanStr() { return Console.ReadLine(); }
    static public string[] ScanStrArray() { return ScanStr().Split(); }
    static public string RegaxReplace(this string arg1, string pattern, string replacement)
    {
      return Regex.Replace(arg1, pattern, replacement);
    }
  }
  
  static class MyMath {
    public static int GCD(int a, int b) {
        Func<int, int, int> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static long GCD(long a, long b) {
        Func<long, long, long> gcd = null;
        gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
        return a > b ? gcd(a, b) : gcd(b, a);
    }
    public static ulong extGCD(ulong a, ulong b, ref ulong x, ref ulong y) {
      if(b==0) {
        x=1; 
        y=0;
        return a;
      }
      var d = extGCD(b, a%b, ref y, ref x);
      y -= a/b *x;
      return d;
    }
    public static int LCM(int a, int b) { return a * b / GCD(a, b); }
    public static long LCM(long a, long b) { return a * b / GCD(a, b); }
  }
}


Measured memory_bytes: 13396
from collections import Counter

input = raw_input

n = int(input())
words = [input() for i in range(n)]
c = Counter(words)

keys = c.keys()
res_keys = ["AC", "WA", "TLE", "RE"]
for key in res_keys:
    if key in keys:
        num = c[key]
    else:
        num = 0
    out_txt = "%s x %d" % (key, num)
    print(out_txt)

Measured memory_bytes: 78056
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <map>

using namespace std;

#define int long long

signed main(){
    map<string, int> m;
    m["C"] = 0;
    m["C#"] = 1;
    m["D"] = 2;
    m["D#"] = 3;
    m["E"] = 4;
    m["F"] = 5;
    m["F#"] = 6;
    m["G"] = 7;
    m["G#"] = 8;
    m["A"] = 9;
    m["A#"] = 10;
    m["B"] = 11;
    
    int t;
    cin >> t;

    for (int i = 0; i < t; i++) {
	int n, M;
	cin >> n >> M;

	vector<int> flr(n);
	vector<int> sng(M);
	for (int j = 0; j < n; j++) {
	    string str;
	    cin >> str;
	    flr[j] = m[str];
	}
	for (int j = 0; j < M; j++) {
	    string str;
	    cin >> str;
	    sng[j] = m[str];
	}

	bool flag = true;
	int pt = n-1;
	for (int j = M-1; j >= 0; j--) {
	    if (pt < 0) {
		flag = false;
		break;
	    }

	    int dif = sng[j] - flr[pt];

	    if (dif == 0) {
		pt--;
	    } else if (dif == 1 || dif == -11) {
		pt -= 2;
	    } else if (dif == -1 || dif == 11) {
		pt++;
	    } else {
		flag = false;
		break;
	    }

	    if (pt >= n || pt < -1) {
		flag = false;
		break;
	    }
	}

	bool flag2 = true;
	pt = n-2;
	for (int j = M-1; j >= 0; j--) {
	    if (pt < 0) {
		flag2 = false;
		break;
	    }

	    int dif = sng[j] - flr[pt];

	    if (dif == 0) {
		pt--;
	    } else if (dif == 1 || dif == -11) {
		pt -= 2;
	    } else if (dif == -1 || dif == 11) {
		pt++;
	    } else {
		flag2 = false;
		break;
	    }

	    if (pt >= n || pt < -1) {
		flag2 = false;
		break;
	    }
	}

	if (flag || flag2) {
	    cout << "Yes" << endl;
	} else {
	    cout << "No" << endl;
	}
    }

    return 0;
}

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;  // 2次元配列
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/
// ABC131 - E - FriendShips - 

/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
//    cout << fixed << setprecision(15);

    i32 n,k; cin >> n >> k;
    vii graph(n+1);
    /**
     * スターグラフが最大効率っぽい？
     * その場合でk = (n-1)*(n-2)/2
     * つまり K > (n-1)*(n-2)/2 ならば, False.
     * e.g. n = 5, k = 8 -> 8 > (5-1)*(5-2)/2 == 6
     * それ以下なら?
     * まずk_max = (n-1)*(n-2)/2 として
     * K = k_max-1を実現できる？ =>
     *
     * 以降解説AC...
     * スターグラフの外の頂点二つを繋ぐパスを作るとそのペアの最短距離が2->1になる。
     */

    if(k > (n-1)*(n-2)/2) {
        cout << -1 << '\n';
        return 0;
    }

    rep1(i,n) if(i != 1) {
        graph[1].push_back(i);
    }
    i32 kk = (n-1)*(n-2)/2;
    for(int i = 2; i < n && kk > k ; ++i) {
        for(int j = i+1; j <= n && kk > k; ++j, --kk) {
            graph[i].push_back(j);
        }
    }

    vec<PII> ans;
    for(auto i : graph[1]) ans.emplace_back(1, i);
    for(int i = 2; i <= n; ++i) for(auto v : graph[i]) ans.emplace_back(i, v);

    cout << ans.size() << '\n';
    for(auto p : ans) cout << p.first << ' ' << p.second << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 512
import java.util.*;

public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner sc = new Scanner (System.in);
		
		int n, n2;
		
		n = sc.nextInt();
		
		n2 = n * (n - 1) / 2;
		
		int [] team = new int [n];
		
		int i, j;
		int a, b, c, d;
		
		for (i = 0; i < n2; i++) {
			a = sc.nextInt();
			b = sc.nextInt();
			c = sc.nextInt();
			d = sc.nextInt();
			
			if (c > d) {
				team[a - 1] += 3;
			} else if (c < d) {
				team[b - 1] += 3;
			} else {
				team[a - 1] += 1;
				team[b - 1] += 1;
			}
		}
		
		for (i = 0; i < n; i++) {
			int count = 1;
			for (j = 0; j < n; j++) {
				if (team[i] < team[j]) {
					count++;
				}
			}
			System.out.println(count);
		}
		

	}

}

Measured memory_bytes: 42024
import sys
import heapq
input = lambda: sys.stdin.readline().rstrip()


def solve():
    N, M = map(int, input().split())
    AB = [[] for _ in range(M)]
    for i in range(N):
        a, b = map(int, input().split())
        if a <= M:
            AB[a - 1].append(b)

    for i in range(M):
        AB[i] = sorted(AB[i])

    # print(AB)

    reward = []
    heapq.heapify(reward)
    ans = 0
    for i in range(M):
        if AB[i]:
            r = (-1) * AB[i].pop(-1)
            heapq.heappush(reward, (r, i))
        if reward:
            r, ind = heapq.heappop(reward)
            ans += (-1) * r
            if AB[ind]:
                r = (-1) * AB[ind].pop(-1)
                heapq.heappush(reward, (r, ind))

    print(ans)


if __name__ == '__main__':
    solve()


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

int main() {
    cin.tie(0)->sync_with_stdio(false);

    ll a, b, c, k;
    cin >> a >> b >> c >> k;

    ll ans = 0;
    if (k % 2) ans = b - a;
    else ans = a - b;

    cout << ans << '\n';
    return 0;
}


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


int main(){
	
	int N;
	scanf("%d", &N) ;
	
	char S[N],T[N];
	
	scanf("%s %s",S,T);
	
	for(int i=0; i<N ; i++ ) {
		printf("%c%c",S[i],T[i]);
	}
	return 0;
	
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int n, k, r, s, p;
string t;
int main() {
    cin >> n >> k;
    cin >> r >> s >> p;
    cin >> t;
    bool a[n];//あいこになったらtrueにする
    for (int i = 0; i < n; i++) {
        a[i] = false;
    }
    int score = 0;
    for (int i = 0; i < n; i++) {
        if (i >= k && t[i] == t[i - k] && !a[i - k]) {
            a[i] = true;
            continue;
        }
        if (t[i] == 'r') {//pでかつ
            score += p;
        } else if (t[i] == 's') {//rでかつ
            score += r;
        } else {//sでかつ
            score += s;
        }
    }
    cout << score << endl;
}
//必ず勝利以上にはできる


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;

int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n; cin >>n;
	VI a(n), cv(n);
	rep(i,n) cin >> a[i], a[i]--;
	rep(i,n) cv[a[i]] = i;

	ll ans =0;
	set<int> st{-1, n};
	for(auto cr: cv){
		auto r = st.upper_bound(cr);
		ans += (a[cr] + 1LL) * (*r-cr) * (cr-*(--r));
		//printf("%d::%d:%d:%lld \n",cr,l,r,ans);
		st.insert(cr);
	}
	cout << ans <<endl;
	return 0;
}


Measured memory_bytes: 11264
n = int(input())

l = [int(i) for i in input().split()]
l.sort()
ans = 1000000000
b = 0
for i in range(1,l[-1]+1):
    b = 0
    for j in l:
        b += (i-j)**2
    if b <ans:
        ans = b
print(ans)


Measured memory_bytes: 38640
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
int a, b;
int main() {
    cin >> a >> b;
    cout << max(max(a + b, a - b), a * b) << endl;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	s := []int{0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0}
	var x, y int
	fmt.Scan(&x, &y)
	if s[x-1] == s[y-1] {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
x,k,d = map(int, input().split())
#print([x,k,d])
if x > 0 and k * d <= x:
    print(x - k * d)
elif x < 0 and (k * d) <= -x:
    print(-x - k * d)
else:
    r = abs(x) % d
    s = abs(x) // d
    if (k - s)  % 2  == 0 : 
        print(r)
    else :
        print(d-r)

Measured memory_bytes: 9188
#include <iostream>
#include <algorithm>
using namespace std;
const int MAXN = 2000 + 10;
int cnt[MAXN][MAXN], n;
void update(int x1, int x2, int y1, int y2) {
    while (x2 <= 0) {
        x2 += n; x1 += n;
    }
    while (y2 <= 0) {
        y2 += n; y1 += n;
    }
    if (x1 < 0) {
        update(0, x2, y1, y2);
        update(n+x1, n, y1, y2);
        return;
    }
    if (y1 < 0) {
        update(x1, x2, 0, y2);
        update(x1, x2, n+y1, n);
        return;
    }
    cnt[x1][y1]++; cnt[x1][y2]--; cnt[x2][y1]--; cnt[x2][y2]++;

    return;
}

int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int q; cin >> q;
    int k; cin >> k;
    n = 2 * k;
    int x, y;
    char c;
    while (q--) {
        cin >> x >> y >> c;
        x = x % n;
        y = y % n;
        if (c == 'W') {
            update(-x, k - x, k - y, n - y);
            update(k - x, n - x, -y, k - y);
        } else {
            update(-x, k - x, -y, k - y);
            update(k - x, n - x, k - y, n - y);
        }

    }
    for (int i = 0; i < n; i++) {
        for (int j = 1; j < n; j++) {
            cnt[i][j] += cnt[i][j - 1];
        }
    }

    for (int j = 0; j < n; j++) {
        for (int i = 1; i < n; i++) {
            cnt[i][j] += cnt[i - 1][j];
        }
    }
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ret = max(ret, cnt[i][j]);
        }
    }
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 16000
#include <iostream>
#include <vector>

using namespace std;

auto solve(int n, vector<int> a) {
    auto cnt = 0;
    for (int i = 0; i < n; i ++) {
        if ((i+1) % 2 == 1 && a[i] % 2 == 1) {
            cnt ++;
        }
    }

    return cnt;
}

int main() {
    int n;
    vector<int> a;
    cin >> n;

    for (int i = 0; i < n; i ++) {
        int t;
        cin >> t;
        a.emplace_back(t);
    }
    cout << solve(n, a) << endl;
    return 0;
}

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

int main(){
  int N;
  cin>>N;
  vector<ll>vec(N,0);
  cin>>vec[0];
  ll ans=vec[0];
  for(int i=1;i<N;i++){
    cin>>vec[i];
    ans=lcm(ans,vec[i]);
  }
  cout<<ans<<endl;
  return 0;
}


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

int main(void){
    // Your code here!
    int N, K;
    cin >> N >> K;
    
    string S;
    cin >> S;
    
    vector<int> nums;
    int now = 1;
    int cnt = 0;
    for (int i = 0; i < N; i++){
        if (S[i] == (char)(now + '0')) cnt++;
        else{
            nums.push_back(cnt);
            cnt = 1;
            now = 1 - now;
        }
    }
    if (cnt != 0) nums.push_back(cnt);
    
    if (nums.size() % 2 == 0) nums.push_back(0);
    
    vector<int> sums(nums.size() + 1);
    for (int i = 0; i < nums.size(); i++){
        sums[i + 1] = sums[i] + nums[i];
    }
    
    int Add = 2 * K + 1;
    int ans = 0;
    for (int i = 0; i < nums.size(); i += 2){
        int left = i;
        int right = min(i + Add, (int)nums.size());
        int tmp = sums[right] - sums[left];
        ans = max(ans, tmp);
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1272
#include <iostream>
#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
//#include <utility>
//#include <set>
//#include <map>
#include <queue>
//#include <deque>
//#include <bitset>
#include <math.h>
using namespace std ;
using ll = long long ;
using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
//using pll = pair<ll,ll> ;
//#define all(v) v.begin(),v.end()
//ll mod = 1000000007 ;
//long double pie = acos(-1) ;
//ll INF = 1000000000000 ;

//void yorn(bool a){if(a) cout << "Yes" << endl ; else cout << "No" << endl ;}
//void YorN(bool a){if(a) cout << "YES" << endl ; else cout << "NO" << endl ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
void fix_cout(){cout << fixed << setprecision(20) ;}

template<class F,class S,class T>
struct triple{
	F first ;
	S second ;
	T third ;
	triple(F f,S s,T t){
		first = f ;
		second = s ;
		third = t ;
	}
	triple(){}

	bool operator<(const triple<F,S,T> &right) const{
		if(first!=right.first) return first<right.first ;
		else if(second!=right.second) return second<right.second ;
		else return third<right.third ;
	}
	bool operator>(const triple<F,S,T> &right) const{
		return right<*this ;
	}
	bool operator<=(const triple<F,S,T> &right) const{
		return !(*this>right) ;
	}
	bool operator>=(const triple<F,S,T> &right) const{
		return !(*this<right) ;
	}
};

int main(){
	auto dis = [](ll a,ll b,ll c,ll d){
		return sqrt((a-c)*(a-c)+(b-d)*(b-d)) ;
	} ;

	fix_cout() ;
	ll sx,sy,gx,gy ;
	cin >> sx >> sy >> gx >> gy ;
	ll n ; cin >> n ;
	vector<triple<ll,ll,ll>> c(n+2) ;
	c.at(0).first = sx ; c.at(0).second = sy ; c.at(0).third = 0 ;
	for(int i=1;i<=n;i++) cin >> c.at(i).first >> c.at(i).second >> c.at(i).third ;
	c.at(n+1).first = gx ; c.at(n+1).second = gy ; c.at(n+1).third = 0 ;
	vector<vector<ld>> d(n+2,vector<ld>(n+2)) ;
	for(int i=0;i<n+2;i++){
		for(int j=0;j<n+2;j++){
			if(i==j) d.at(i).at(j) = 0 ;
			else{
				d.at(i).at(j) = max(0.0,dis(c.at(i).first,c.at(i).second,c.at(j).first,c.at(j).second)-c.at(i).third-c.at(j).third) ;
			}
		}
	}
	vector<ld> cnt(n+2,100000000000000.0) ;
	priority_queue<triple<ld,ll,ll>,vector<triple<ld,ll,ll>>,greater<triple<ld,ll,ll>>> pq ;
	cnt.at(0) = 0 ;
	for(int i=1;i<n+2;i++) pq.emplace(d.at(0).at(i),0,i) ;
	vll use(n+2,0) ;
	while(!pq.empty()){
		triple<ld,ll,ll> e = pq.top() ;
		pq.pop() ;
		if(use.at(e.third)) continue ;
//		cout << e.second << " " << e.third << " " << e.first << endl ;
		use.at(e.third) = 1 ;
		cnt.at(e.third) = e.first ;
		for(int i=0;i<n+2;i++) if(i!=e.third) pq.emplace(d.at(e.third).at(i)+cnt.at(e.third),e.third,i) ;
	}
	cout << cnt.at(n+1) << endl ;
//	for(auto i:cnt) cout << i << endl ;
}


Measured memory_bytes: 50788
// RAKSHIT KADAM
 
//  -- Declare array globally...
 #include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// #define ordered_set tree< int ,  null_type ,  less<int> ,  rb_tree_tag ,  tree_order_statistics_node_update>
// find_by_order returns iterator to  element present at that index...
// order_of_key returns no. of elements having value stricktly less than that given in the order_of_key();
#warning !!!check the size of arrayss!!!
 
// NUMERIC DEFINITIONS :
    #define INF 1000000000000000005
    #define inf 1000000003
    #define MOD  1000000007
    #define newMOD  998244353
    #define MAX 200006
    #define pi 3.1415926535897932384626433832795
#define ld long double
 #define ll long long
 #define int long long
 
 #define P(gg) for(auto rax:gg){cout<<rax<<" ";}cout<<endl;
 #define Need_for_speed(activated) ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
 #define satisfy ll t; cin>> t; while(t--)
 #define inp(n) int n;cin >> n
 #define mp make_pair
 #define pb push_back
 #define endl "\n"
 #define x first
 #define y second
 #define fore(i,a,b) for(ll i=a;i<b;i++)
 #define forci(i,n) for(ll i=0;i<n;i++)
 #define vi vector<ll>
 #define Endl endl
 #define lb lower_bound
 #define ub upper_bound
#define pii pair<ll,ll>
 
 #define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout)
 #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
using namespace std;
ll gcd(ll a, ll b){if (b == 0)return a;return gcd(b, a % b);}
int power(int x, unsigned int y, unsigned int m){ if (y == 0) return 1;int p = power(x, y/2, m) % m;  p = (p * p) % m;return (y%2 == 0)? p : (x * p) % m;}
ll modInverse(int a, int m){{ return power(a, m-2, m);}}
const int maxn = 500066;
int mod(string num, int a)
{
    // Initialize result
    int res = 0;
  
    for (int i = 0; i < num.length(); i++)
         res = (res*2 + (int)num[i] - '0') %a;
  
    return res;
}
ll get(ll num)
{
    ll x =__builtin_popcount(num);
    if(!x) return 0;
    ll ret = 0;
    while(num%x)
    {
        ret++;
        num%=x;
        x =__builtin_popcount(num);
    }
    return ret+1;
}
void solve()
{
    ll n;cin>>n;
    ll one = 0;
    string s;cin>>s;
    for(char c:s)
    {
        if(c=='1')one++;
    }
    ll ansn,ansp;
     ansp = mod(s,one+1);
    ll ans =0;
   if(one-1) ansn = mod(s,one-1);
    for(ll i=0;i<n;i++)
    {
       
        if(s[i]=='0')
        {
             ll p = power(2,n-i-1,one+1);
            
            ll x = (ansp+p)%(one+1);
             cout<<get(x)+1<<endl;
            
            
        }
        else
        {
            if(one==1)
            {
                cout<<0<<endl;continue;
            }
            ll p = power(2,n-i-1,one-1);
            ll x =(ansn-p+(one-1))%(one-1);
            cout<<get(x)+1<<endl;
        }
    }
    
    
    
   
}
 
signed main()
{
   Need_for_speed(activated);
 
//satisfy
//    {
//  solve();
//   }
 
    solve();
    return 0;
}


Measured memory_bytes: 3848
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

long long A[100000];
int main(){
    int N;
    cin >> N;
    long long total = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        total += abs(A[i]);
    }
    sort(A, A + N);

    int neg_num = 0;
    int pos_num;
    for(int i = 0; i < N; i++){
        if(A[i] < 0){
            neg_num++;
        } else {
            break;
        }
    }
    pos_num = N - neg_num;

    if(neg_num == 0){
        cout << total - 2 * A[0] << endl;
        if(N == 2){
            cout << A[1] << " " << A[0] << endl;
            return 0;
        }
        cout << A[0] << " " << A[1] << endl;
        long long cur_diff = A[0] - A[1];
        for(int i = 2; i < N - 1; i++){
            cout << cur_diff << " " << A[i] << endl;
            cur_diff -= A[i];
        }
        cout << A[N - 1] << " " << cur_diff << endl;
    } else if(pos_num == 0){
        cout << total + 2 * A[N - 1] << endl;
        long long cur_diff = A[N - 1];
        for(int i = 0; i < N - 1; i++){
            cout << cur_diff << " " << A[N - 2 - i] << endl;
            cur_diff -= A[N - 2 - i];
        }
    } else {
        cout << total << endl;
        long long cur_diff1 = A[0];
        for(int i = 0; i < pos_num - 1; i++){
            cout << cur_diff1 << " " << A[N - 2 - i] << endl;
            cur_diff1 -= A[N - 2 - i];
        }
        long long cur_diff2 = A[N - 1];
        for(int i = 0; i < neg_num - 1; i++){
            cout << cur_diff2 << " " << A[1 + i] << endl;
            cur_diff2 -= A[1 + i];
        }
        cout << cur_diff2 << " " << cur_diff1 << endl;
    }
    return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

template <typename T> inline int Chkmax (T &a, T b) { return a < b ? a = b, 1 : 0; }
template <typename T> inline int Chkmin (T &a, T b) { return a > b ? a = b, 1 : 0; }

template <typename T> inline T read(){
    T sum = 0;
    int fl = 1,ch = getchar();
    for(; !isdigit(ch); ch = getchar()) if(ch == '-') fl = -1;
    for(; isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) + ch - '0';
    return sum * fl;
}

const int maxn = 100000 + 5;

int n,W,sum = 0;
int dp[maxn];

struct node{
	int w;
	int v;
}a[maxn];

inline void Solve (){
	for(int i = 0; i <= sum; i++){
		dp[i] = 0x7fffffffffffff;
	}
	dp[0] = 0;
	for(int i = 1; i <= n; i++){
		for(int j = sum; j >= a[i].v; j--){
			dp[j] = min(dp[j],dp[j - a[i].v] + a[i].w);
		}
	}
	for(int i = sum; i >= 0; i--){
		if(dp[i] <= W){
			printf("%lld\n",i);
			return;
		}
	}
}

inline void Input (){
	n = read<int>();
	W = read<int>();
	for(int i = 1; i <= n; i++){
		a[i].w = read<int>();
		a[i].v = read<int>();
		sum += a[i].v;
	}
}

signed main(){
	Input();
	Solve();
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
    using namespace std;
     
    char c[55][55]; int H, W, cnt;
     
    int main() {
    	cin >> H >> W;
    	for (int i = 1; i <= H; i++) {
    		for (int j = 1; j <= W; j++) cin >> c[i][j];
    	}
    	for (int i = 1; i <= H; i++) {
    		for (int j = 1; j <= W; j++) {
    			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
    		}
    	}
    	if (cnt == 0) cout << "Yes" << endl;
    	else cout << "No" << endl;
    	return 0;
    }

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

int main() {
  string s;
  int n;
  cin >> n >>s;
  int ans = 0;
  for(int i=0;i<n;i++){
    if(s[i]=='A' && s[i+1]=='B' && s[i+2]=='C')ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
//Hey u r far away to know this
#include <bits/stdc++.h>
using namespace std;
#define     ff      	    	first
#define     pb 	         	push_back
#define     ss          		second
#define     ll      	    	long long
#define     MAX  	       	5000
#define     mpi         		map<int, int>
#define     mpll        		map<ll, ll>
#define     pll         		pair<ll, ll>
#define     plld        		pair<ll, double>
#define     SKILLER     		ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     vi          		std::vector<int>
#define     vll         		std::vector<ll>
#define     vs          		std::vector<string>
#define     vvi         		std::vector<std::vector<int>>
#define     vvll        		std::vector<std::vector<ll>>
#define     all(v)      		v.begin(), v.end()
#define     allr(v)      		v.rbegin(), v.rend()
#define     loop(i, a, b) 	for(int i = a; i < b; i++)
#define 	  debug(x) 		cout << x <<" " <<"\n";
#define 	  debug1(x, y) 	cout << x << " " << y  << "\n";
#define 	  debug2(x, y, z) 	cout << x << " " << y << " " << z<<"\n";
#define 	  int 			ll
const   int N = 1e6+5, Mod = 1e9 + 7;
int32_t main(){
    	SKILLER;
    
        int n; cin >> n;
        string s; cin >> s;
        int cnt = 0;
        int dp[200005];
        memset(dp, 0, sizeof(dp));
        for(int i = 1; i <= 2e5 + 2; i++){
        	int x = i;
        	while(x > 1){
        		int a = __builtin_popcount(x);
        		x = x%a;
        		dp[i]++;
        	}
        	if(x > 0)
        		dp[i]++;
        }
        for(int i = 0; i < n; i++){
        	if(s[i] == '1')
        		cnt++;
        }
        int rem1 = 0;
        int x1 = 1;
        int dps1[n];

        for(int i = n - 1; i >= 0; i--){
        	if(cnt == 0)
        		break;
        	dps1[i] = x1;

        	if(s[i] == '1'){
        		rem1 += x1;
        		rem1 %= (cnt + 1);
        	}
        	x1 *= 2;
        	x1 %= (cnt + 1);
        }

       	int rem2 = 0;
        int x2 = 1;
        int dps2[n];
        for(int i = n - 1; i >= 0; i--){
        	if(cnt == 1)
        		break;
        	dps2[i] = x2;
        	if(s[i] == '1'){
        		rem2 += x2;
        		rem2 %= (cnt - 1);
        	}
        	x2 *= 2;
        	x2 %= (cnt - 1);
        }
        for(int i = 0; i < n; i++){
        	if(s[i] == '0'){
        		if(cnt == 0){
        			cout << "1\n";
        			continue;
        		}
        		int ex = rem1;
        		ex += dps1[i];
        		ex %= (cnt + 1);
        		cout << dp[ex] + 1 <<'\n';
        	}
        	else{
        		if(cnt == 1){
        			cout << "0\n";
        			continue;
        		}
        		int ex = rem2;
        		ex -= dps2[i];
        		ex %= (cnt - 1);
        		ex += (cnt - 1);
        		ex %= (cnt - 1);
        		cout << dp[ex] + 1 << '\n';
        	}
        }
    	return 0;
}

Measured memory_bytes: 8412
// D

#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll mod=1e9+7;
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};

int main(){
  int N,K,ten[3];
  string T; 
  cin>>N>>K>>ten[0]>>ten[1]>>ten[2];
  cin>>T;
  ll ans(0);
  char te[3] = {'r','s','p'};
  ll dp[100000][3] = {0};
  //for (int i(0);i<K;i++){ //Kで割ったときの余りで独立
  //  //iはKで割ったときの余り
  //  int tmp;
  //  for (int j(i);j<N;j+=K){
  for (int i(0);i<N;i++){
      char kachi;
      if (T[i] == 'r') kachi = 'p';
      if (T[i] == 's') kachi = 'r';
      if (T[i] == 'p') kachi = 's';
      if (i<K){
        for (int k(0);k<3;k++){
          if (te[k] == kachi){
            dp[i][k] = ten[k];
          }
        }
        continue;
      }
      for (int k(0);k<3;k++){
        for (int ki(0);ki<3;ki++){
          if (k == ki) continue;
          if (kachi == te[k]){
            dp[i][k] = max(dp[i][k],dp[i-K][ki]+ten[k]);
          }else{
            dp[i][k] = max(dp[i][k],dp[i-K][ki]);
          }
        }
      }
    }
    for (int i(0);i<K;i++){
      ans += max(dp[N-1-i][0],max(dp[N-1-i][1],dp[N-1-i][2]));
    }
    cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define mp make_pair
#define si(x) int(x.size())
const int mod=998244353,MAX=100005;
const ll INF=1LL<<60;
ll dp[MAX][3];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N;cin>>N;
    vector<ll> A(N),B(N);
    cin>>A[0];
    for(int i=1;i<N;i++){
        char c;cin>>c;
        if(c=='-') B[i]=1;
        cin>>A[i];
    }
    
    for(int i=0;i<=N;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=-INF;
        }
    }
    dp[0][0]=0;
    
    for(int i=0;i<N;i++){
        if(!B[i]){
            chmax(dp[i+1][0],dp[i][0]+A[i]);
            chmax(dp[i+1][0],dp[i][1]-A[i]);
            
            chmax(dp[i+1][1],dp[i][1]-A[i]);
            chmax(dp[i+1][1],dp[i][2]+A[i]);
            
            chmax(dp[i+1][2],dp[i][2]+A[i]);
        }else{
            chmax(dp[i+1][0],dp[i][0]-A[i]);
            
            chmax(dp[i+1][1],dp[i][0]-A[i]);
            chmax(dp[i+1][1],dp[i][1]+A[i]);
            
            chmax(dp[i+1][2],dp[i][1]+A[i]);
            chmax(dp[i+1][2],dp[i][2]+A[i]);
        }
    }
    
    ll ans=-INF;
    
    for(int j=0;j<3;j++) chmax(ans,dp[N][j]);
    
    cout<<ans<<endl;
}


Measured memory_bytes: 4224
#include<stdio.h>
 int main(void){
  int a,b;
  double f;
  scanf("%d",&a);
  scanf("%d",&b);
  if(1<=a&&b<=1E+9){
   int d=a/b;
   int r=a%b;
   f=(double)a/b;
      printf("%d %d %lf\n",d,r,f);
  }  else{
   printf("error");
  }
 return 0;
}

Measured memory_bytes: 636
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL


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

    int n, c;
    cin >> n >> c;

    vector< vector<bool> > on(c, vector<bool>(100000, false));

    int s, t, C;
    int smin = (int)1e9;
    int tmax = 0;
    rep (i, n)
    {
        cin >> s >> t >> C;
        --s; --t; --C;
        for (int j = s; j <= t; ++j)
        {
            on[C][j] = true;
        }
        smin = MIN(smin, s);
        tmax = MAX(tmax, t);
    }

    int ans = 0;
    int cnt;
    for (int i = smin; i <= tmax; ++i)
    {
        cnt = 0;
        rep (j, c)
        {
            if (on[j][i]) ++cnt;
        }
        ans = MAX(ans, cnt);
    }

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



Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <string>
using namespace std;

int main() {
    int N, Q; cin >> N >> Q;
    string str; cin >> str;
    
    // 累積和を前計算
    vector<int> s(N+1, 0);
    for(int i = 0; i < N; ++i) {
        if(i+1 < N && str[i] == 'A' && str[i+1] == 'C') s[i+1] = s[i] + 1;
        else s[i+1] = s[i];
    }
    
    // クエリ処理
    for(int q = 0; q < Q; ++q) {
        int l, r; cin >> l >> r;
        --l, --r;
        cout << s[r] - s[l] << endl;
    }
}


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

int main()
{
    int r, D, x2000;
    cin >> r >> D >> x2000;
    long long x = x2000;
    for (int i = 0; i < 10; ++i)
    {
        cout << (r * x - D) << endl;
        x = (r * x - D);
    }

    return 0;
}


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

int main(){
  int A,B,cnt=0,K;
  cin >> A >> B >> K;
  for(int i=100;0<i;i--){
    if(A%i==0&&B%i==0)
      cnt++;
    if(cnt==K){
      cout << i << endl;
      break;
    }
  }
}

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

int main(void) {
    string N; cin >> N;
    bool is7 = false;
    for (int i = 0; i < N.size(); i++) {
        if (N[i] == '7') {
            is7 = true;
        }
    }
    if (is7) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


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

#define debug(x) cerr << #x << ": " << x << endl;

#define iosbase ios_base::sync_with_stdio(false)
#define tie cin.tie();cout.tie();

#define endl '\n'

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

ii cidades[8];

long long D(ii a, ii b){

  return ((a.first - b.first)*(a.first - b.first)) + ((a.second - b.second)*(a.second - b.second));
}

int n, m;
int main(){
  iosbase;
  tie;

  int n, a, b; cin >> n;
  for(int i = 0; i < n; i++){
    cin >> a >> b;
    cidades[i] = {a, b};
  }
  sort(cidades, cidades+n);
  double acum = 0.0;
  int cont = 0;
  do{
    double dist = 0.0;
    for(int i = 1; i < n; i++){
      dist+=sqrt( D(cidades[i], cidades[i-1]) );
    }

    acum += dist;
    cont++;
  }while( next_permutation(cidades, cidades+n) );

  double total = acum / (double) cont;
  cout << setprecision(10) << fixed << total << endl;
}


Measured memory_bytes: 256
def reverse(s): 
    return s[::-1] 
  
def isPalindrome(s): 
    rev = reverse(s) 

    if (s == rev): 
        return True
    return False
s = input()
N = len(s)
ans = isPalindrome(s) & isPalindrome(s[0:int((N-1)/2)]) & isPalindrome(s[int((N+1)/2):N])
  
if ans == True: 
    print("Yes") 
else: 
    print("No") 

Measured memory_bytes: 3060
import sys,math,copy,queue,itertools
from fractions import gcd
sys.setrecursionlimit(10**7)
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())
INF = 10**18
MOD = 10**9 + 7
DD = ((1,0),(0,1),(-1,0),(0,-1))
X,Y,A,B,C = LI()
p = LI()
q = LI()
r = LI()
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
pa =  [0] + list(itertools.accumulate(p))
qa =  [0] + list(itertools.accumulate(q))
p = [INF] + p
q = [INF] + q
red = X
green = Y
t = 0
pl = 0
while p[red] < r[t] or q[green] < r[t]:
    pl += r[t]
    t += 1
    if p[red] < q[green] :
        red -= 1
    else:
        green -= 1
    if t >=C or (green ==0 and red ==0): break
print (pa[red] + qa[green] + pl)

Measured memory_bytes: 120432
#include <bits/stdc++.h>
#include <iostream>
#include <set>
#include <vector>
#include <string>
#include <algorithm>

#define fr(i,b,e) for(int i=(b); i!=(e); ++i)
#define rep(i,e) for(int i=0; i!=(e); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long int li;
typedef long long ll;
using graph = vector<vector<int>>;
using edgedp = vector<vector<pair<int,ll>>>;
constexpr int INF=1000000;
//constexpr int MOD=998244353;
constexpr int MOD=1e9+7;



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

    string n;
    cin >> n;
    bool chk=false;
    fr(i,0,n.size()){
        if(n[i]=='7'){
            chk=true;
        }
    }
    if(chk==true){
        cout << "Yes" << "\n";
    }else{
        cout << "No" << "\n";
    }

}   

Measured memory_bytes: 3648
A, B, K = map(int, input().split())

    
if A>=1:
    if A>K:
        print(A-K, B)
    else:
        if B+A-K>0:
            print(0, B+A-K)
        else:
            print(0,0)
else:
    if B-K>0:
        print(0, B-K)
    else:
        print(0,0)

Measured memory_bytes: 3060