akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s; cin >> s;
    int a[3] {};
    for(int i=0; i<s.size(); i++) a[s[i]-'a']++;
    sort(a, a+3);
    if(a[2]-a[0]<=1) cout << "YES";
    else cout << "NO";
    return 0;
}


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

#define int long long

int N;
vector<char> P;

char f(char a, char b) {
  if ( a == 'T' && b == 'T' ) return 'T';
  if ( a == 'T' && b == 'F' ) return 'F';
  if ( a == 'F' && b == 'T' ) return 'T';
  if ( a == 'F' && b == 'F' ) return 'T';
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  cin >> N;
  P = vector<char>(N);  
  for ( int i = 0; i < N; i++ ) {
    cin >> P[i];    
  }

  char c = P[0];  
  for ( int i = 1; i < N; i++ ) {
    c = f(c, P[i]);    
  }

  cout << c << endl;
  
  return 0;
}



Measured memory_bytes: 3236
#include<stdio.h>
int main(void)
{
    int a,b,c,d,e,k;
    
    scanf("%d%d%d%d%d%d",&a,&b,&c,&d,&e,&k);
  
    if((b-a>k)||(c-a>k)||(d-a>k)||(e-a>k))  printf(":(\n");
    else if((c-b>k)||(d-b>k)||(e-b>k))  printf(":(\n");
    else if((d-c>k)||(e-c>k))  printf(":(\n");
    else if(e-d>k)  printf(":(\n");
    else printf("Yay!\n");
  
    return 0;
}


Measured memory_bytes: 1628
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

long long int INF = 1e18;
int const TREE_SIZE = 1 << 21;
long long int seg_tree[TREE_SIZE] = {};
long long int c_diff[TREE_SIZE] = {}; // 子との差

// [a, b) の最小値を求める
// find(a, b + 1, 1, 0, 0, TREE_SIZE / 2)
long long int find(int a, int b, int index, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return INF;
	}
	if(a <= l && r <= b){
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, find(a, b, index * 2, c_diff[index], l, (l + r) / 2));
	ret = min(ret, find(a, b, index * 2 + 1, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return ret;
}

// [a, b) に num を足す
// add(a, b + 1, 1, num, 0, 0, TREE_SIZE / 2);
long long int add(int a, int b, int index, long long int num, long long int diff, int l, int r){
	seg_tree[index] += diff;
	c_diff[index] += diff;
	
	if(r <= a || b <= l){
		return seg_tree[index];
	}
	if(a <= l && r <= b){
		seg_tree[index] += num;
		c_diff[index] += num;
		return seg_tree[index];
	}
	
	long long int ret = INF;
	ret = min(ret, add(a, b, index * 2, num, c_diff[index], l, (l + r) / 2));
	ret = min(ret, add(a, b, index * 2 + 1, num, c_diff[index], (l + r) / 2, r));
	c_diff[index] = 0;
	return seg_tree[index] = ret;
}

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

    priority_queue<pair<P,P>, vector<pair<P,P>>, greater<pair<P,P>>> quel, quer;

    rep(i,m){
        int l, r, a;
        cin >> l >> r >> a;
        pair<P,P> p;
        p.first.first = l;
        p.first.second = r;
        p.second.first = a;
        p.second.second = 1;
        quel.push(p);
        p.first.first = r;
        p.first.second = l;
        p.second.second = -1;
        quer.push(p);
    }

    ll now = 0;
    srep(i,1,n+1){
        while(!quel.empty() && quel.top().first.first <= i){
            now += quel.top().second.first;
            quel.pop();
        }
        ll tmp = find(0,i,1,0,0,TREE_SIZE/2);
        add(i,i+1,1,tmp,0,0,TREE_SIZE/2);
        while(!quer.empty() && quer.top().first.first <= i){
            now -= quer.top().second.first;
            int l = quer.top().first.second;
            int r = quer.top().first.first;
            ll a = quer.top().second.first;
            add(l,r+1,1,-a,0,0,TREE_SIZE/2);
            quer.pop();
        }
    }

    ll ans = find(0,n+1,1,0,0,TREE_SIZE/2);
    cout << -ans << endl;
	
	return 0;
}



Measured memory_bytes: 22352
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
bool isnumber(char c){return ('0'<=c&&c<='9');}
bool isalpha(char c){return (isupper(c)&&islower(c));}
void printvi(vector<int> v){rep(i,0,v.size()){if(i)cout<<" ";cout<<v[i];}cout<<endl;}
void printvil(vector<int> v){rep(i,0,v.size()){cout<<v[i]<<endl;}}
void printvvi(vector<vector<int>> v){
    rep(i,0,v.size()){
        rep(j,0,v[i].size())cout<<v[i][j];
        cout<<endl;
    }
}
void printvstr(vector<string> v){
    rep(i,0,v.size()){
        cout<<v[i]<<endl;
    }
}

signed main (){
    int n;
    cin>>n;
    if(n==1)cout<<"Hello World"<<endl;
    else {
        int a,b;
        cin>>a>>b;
        cout<<a+b<<endl;
    }
    
}
/*

*/


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

int J[70000];

int main()
{
	int n;
	while (scanf("%d", &n), n){
		ll sum = 0;
		for (int i = 0; i < n; i++){
			int p;
			scanf("%d", &p);
			sum += p;
		}
		for (int i = 0; i < n - 1; i++){
			scanf("%d", &J[i]);
		}
		
		sort(J, J + n - 1, greater<int>());
		
		ll res = sum * n;
		for (int i = 0; i < n - 1; i++){
			res = max(res, (sum + J[i]) * (n - i - 1));
			sum += J[i];
		}
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 1456
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=100100100100100;


int main(){
    string s,t;
    cin>>s>>t;
    int n=s.length();
    for(int i=0;i<n;i++){
        if(s[i]!=t[i]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a;
	cin>>a;
	if(a<4) cout<<"No";
	else
	{
		for(int i=0;i<=a/4+1;i++)
		{
			for(int j=0;j<=a/7+1;j++)
			{
				if(i*4+j*7==a)
				{
					cout<<"Yes";
					return 0;
				}
			}
		}
		cout<<"No";
	}
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
int W,H,x,y,r;
cin >> W >> H >> x >> y >> r;

if(x<-100||100<x){
	cout << "エラー" << endl;
	return 0;
}

if(y<-100||100<y){
       cout<<"エラー"<<endl;
       return 0;
}

if(W<0||100<W){
       cout<<"エラー"<<endl;
       return 0;
}

if(H<0||100<H){
       cout<<"エラー"<<endl;
       return 0;
}

if(r<0||100<r){
       cout<<"エラー"<<endl;
       return 0;
}

int a=0,b=0;
if(x-r<0||x+r>W){
	//cout << "No" << endl;
       a=1;
}

if(x-r>=0&&x+r<=W){
	//cout << "Yes" << endl;
       a=2;
}
if(y-r<0||y+r>H){
       //cout << "No" << endl;
       b=1;
}
if(y-r>=0&&y+r<=H){
       //cout << "Yes" <<endl;
       b=2;
}

if(a==1||b==1){
       cout << "No" <<endl;
}
if(a==2&&b==2){
       cout << "Yes" <<endl;
}

return 0;
}

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

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

int main()
{
    int n;
    scanf("%d", &n);

    for (int i = 1; i < 11; i++) {
        if (1000 * i - n >= 0) {
            printf("%d\n", 1000 * i - n);
            return 0;
        }
    }

    return 0;
}


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

int main() {
    string s;
    cin >> s;
    int sum = 0;
    rep(i,s.size()) {
        sum += s[i] - '0';
    }
    if (sum%9 == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3748
import java.util.Scanner;
import java.util.Arrays;

public class Main{

    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);

        // input
        final int NUM = scan.nextInt();
        int[] price = new int[NUM];
        for(int i = 0; i < NUM; i++){
            price[i] = scan.nextInt();
        }

        // sort
        Arrays.sort(price);

        // calc
        int sum = price[NUM - 1] / 2;
        for(int i = 0; i < NUM - 1; i++){
            sum += price[i];
        }

        // answer
        System.out.println(sum);

    }
}

Measured memory_bytes: 22612
#include<stdio.h>
int main()
{
    int  a,b;
    scanf("%c %c",&a,&b);
    if(a==72){
        printf("%c",b);
    }
    else if(a==68){
        if(b==72){
            printf("D");
        }
        else{
            printf("H");
        }
    }
    else {
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  string X; cin >> X;
  int cnt_T = 0, cnt_S = 0;
  for (const auto& c : X) {
    if (c == 'S') {
      ++cnt_S;
    } else {
      if (cnt_S > 0) {
        --cnt_S;
      } else {
        ++cnt_T;
      }
    }
  }
  auto ans = cnt_T + cnt_S;
  cout << ans << CRLF;
  return;
}

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

  solve();

  return 0;
}


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

#define rep(i, n) for(long long i=0;i<(long long)(n);i++)
#define rep2(i, s, n) for(long long i=(s);i<(long long)(n);i++)
#define all(v) v.begin(), v.end()

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll INF = (1LL<<60);

int main(){

    ll r; cin >> r;

    cout << r*r << endl;

    return 0;
}

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

using namespace std;
using ll = long long;

int const N = 200 * 1000 + 16;

int a[N];
int n, k;

struct node {
  ll x;
  int s = 1;
  int y = rand();

  node* l = 0;
  node* r = 0;

  node(ll v) {
    x = v;
  }

  ~node() {
    delete l;
    delete r;
  }

  node* upd() {
    s = 1;
    s += l ? l->s : 0;
    s += r ? r->s : 0;
    return this;
  }
};

struct treap {
  node* root = 0;

  ~treap() {
    delete root;
  }

  node* join(node* l, node* r) {
    if(not l) return r;
    if(not r) return l;

    if(l->y < r->y) {
      l->r = join(l->r, r);
      return l->upd();
    } else {
      r->l = join(l, r->l);
      return r->upd();
    }
  }

  pair<node*,node*> split(node* p, ll x) {
    if(not p) return make_pair(nullptr,nullptr);

    if(x < p->x) {
      auto t = split(p->l, x);
      p->l = t.second;
      t.second = p->upd();
      return t;
    } else {
      auto t = split(p->r, x);
      p->r = t.first;
      t.first = p->upd();
      return t;
    }
  }

  void insert(ll x) {
    auto t = split(root, x);
    root = join(t.first, join(new node(x), t.second));
  }

  int query(ll x) {
    auto t = split(root, x);
    int cnt = t.first ? t.first->s : 0;
    root = join(t.first, t.second);
    return cnt;
  }
};

int main() {
  cin.tie(0);
  cin.sync_with_stdio(0);

  cin >> n >> k;
  copy_n(istream_iterator<int>(cin), n, a);

  treap t;
  t.insert(0);
  ll ans = 0;
  ll sum = 0;
  for(int i = 0; i < n; ++i) {
    sum += a[i] - k;
    ans += t.query(sum);
    t.insert(sum);
  }

  cout << ans << endl;
}

Measured memory_bytes: 10368
import sys
import math
import collections
import itertools
import array
import inspect

# Set max recursion limit
sys.setrecursionlimit(1000000)


# Debug output
def chkprint(*args):
    names = {
        id(v): k
        for k, v in inspect.currentframe().f_back.f_locals.items()
    }
    print(', '.join(
        names.get(id(arg), '???') + ' = ' + repr(arg) for arg in args))


# Binary converter
def to_bin(x):
    return bin(x)[2:]


def li_input():
    return [int(_) for _ in input().split()]


def gcd(n, m):
    if n % m == 0:
        return m
    else:
        return gcd(m, n % m)


def gcd_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = gcd(v, L[i])

    return v


def lcm(n, m):
    return (n * m) // gcd(n, m)


def lcm_list(L):
    v = L[0]

    for i in range(1, len(L)):
        v = lcm(v, L[i])

    return v


# Width First Search (+ Distance)
def wfs_d(D, N, K):
    """
    D: 隣接行列(距離付き)
    N: ノード数
    K: 始点ノード
    """

    dfk = [-1] * (N + 1)
    dfk[K] = 0

    cps = [(K, 0)]
    r = [False] * (N + 1)
    r[K] = True
    while len(cps) != 0:
        n_cps = []
        for cp, cd in cps:
            for i, dfcp in enumerate(D[cp]):
                if dfcp != -1 and not r[i]:
                    dfk[i] = cd + dfcp
                    n_cps.append((i, cd + dfcp))
                    r[i] = True

        cps = n_cps[:]

    return dfk


# Depth First Search (+Distance)
def dfs_d(v, pre, dist):
    """
    v:  現在のノード
    pre: １つ前のノード
    dist: 現在の距離

    以下は別途用意する
    D: 隣接リスト(行列ではない)
    D_dfs_d: dfs_d関数で用いる，始点ノードから見た距離リスト
    """

    global D
    global D_dfs_d

    D_dfs_d[v] = dist

    for next_v, d in D[v]:
        if next_v != pre:
            dfs_d(next_v, v, dist + d)

    return


def sigma(N):
    ans = 0
    for i in range(1, N + 1):
        ans += i
    return ans


class Combination:
    def __init__(self, n, mod):

        g1 = [1, 1]
        g2 = [1, 1]
        inverse = [0, 1]
        for i in range(2, n + 1):
            g1.append((g1[-1] * i) % mod)
            inverse.append((-inverse[mod % i] * (mod // i)) % mod)
            g2.append((g2[-1] * inverse[-1]) % mod)
        self.MOD = mod
        self.N = n
        self.g1 = g1
        self.g2 = g2
        self.inverse = inverse

    def __call__(self, n, r):
        if (r < 0 or r > n):
            return 0
        r = min(r, n - r)
        return self.g1[n] * self.g2[r] * self.g2[n - r] % self.MOD


# --------------------------------------------

dp = None


def main():
    r, g, b = li_input()
    n = r * 100 + g * 10 + b

    if n % 4 == 0:
        print("YES")
    else:
        print("NO")


main()


Measured memory_bytes: 4852
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define debug(x) cout<<x<<endl;
#define int ll
const ll INF = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 5;
 
int32_t main()
{
	#ifndef ONLINE_JUDGE
		freopen("a.in","r",stdin);
	#endif
	ios::sync_with_stdio(false);

 	int n,m;
 	cin>>n>>m;
 	vector<vector<bool> > empty(n, vector<bool>(m));
 	for(int i=0;i<n;i++)
 	{
 		for(int j=0;j<m;j++)
 		{
 			char x;
 			cin>>x;
 			empty[i][j] = x=='.';
 		}
 	}
 	vector<vector<int> > dp(n, vector<int>(m, 0));
 	dp[0][0] = 1;
 	for(int i=0;i<n;i++)
 	{
 		for(int j=0;j<m;j++)
 		{
 			if(!empty[i][j])
 				continue;
 			if(j-1>=0 && empty[i][j-1])
 				dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
 			if(i-1>=0 && empty[i-1][j])
 				dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
 		}
 	}

 	cout<<dp[n-1][m-1]<<endl;
 
	return 0;
}

Measured memory_bytes: 11312
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main()
{
	int n,m;
	while(1)
	{
		cin >> n;
		if(n==0)break;
		int cost[n][n];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
			{
				if(i==j)
				{
					cost[i][j]=0;
				}
				else
				{
					cost[i][j]=INF;
				}
			}
		}
		cin >> m;
		for(int i=0;i<m;i++)
		{
			int a,b,c;
			scanf("%d,%d,%d",&a,&b,&c);
			cost[a][b]=c/100-1;
			cost[b][a]=c/100-1;
		}
		int mincost[n];
		bool used[n];
		for(int i=0;i<n;i++)
		{
			mincost[i]=INF;
			used[i]=false;
		}
		mincost[0]=0;
		int res=0;
		while(1)
		{
			int v=-1;
			for(int u=0;u<n;u++)
			{
				if(!used[u]&&(v==-1||mincost[u] < mincost[v]))v=u;
			}
			if(v==-1)break;
			used[v]=true;
			res+=mincost[v];
			for(int u=0;u<n;u++)
			{
				mincost[u]= min(mincost[u],cost[v][u]);
			}
		}
		cout << res << endl;
	}
	return 0;
}

Measured memory_bytes: 1280
s=input()
n=len(s)
flag=1
j=0
a=[]
for i in range(1,n):
  if flag and s[i]=='L':flag=0
  elif not flag and s[i]=='R':
    a+=[s[j:i]]
    j=i
    flag=1
a+=[s[j:n]]
fans=[]
for i in a:
  cr=i.count('R')
  cl=i.count('L')
  ans=[0]*(cr+cl)
  if cr<cl:
    if cl%2:
      ans[cr-1]=(cr+cl)//2
      ans[cr]=(cr+cl+1)//2
    else:
      ans[cr-1]=(cr+cl+1)//2
      ans[cr]=(cr+cl)//2
  else:
    if cr%2:
      ans[cr-1]=(cr+cl+1)//2
      ans[cr]=(cr+cl)//2
    else:
      ans[cr-1]=(cr+cl)//2
      ans[cr]=(cr+cl+1)//2
  fans+=ans
print(*fans)

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

int main(){
  int n;
  cin >> n;
  vector<int>A(n);
  for(int i=0; i<n; i++){
    cin >> A[i];
    A[i]*=2;
  }
  sort(A.begin(), A.end());
  int fo=A[n-1], so;
  int mid=fo/2, mindif=2000000000;
  for(int i=0; i<n-1; i++){
    int tmp=abs(A[i]-mid);
    if(mindif>tmp){
      mindif = tmp;
      so = A[i];
    }
  }
  cout << fo/2 << ' ' << so/2;
  return 0;
}

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

int main(){
    int a,b;
    cin >> a >> b;
    
    int n = b - a;
    
    int h = n*(n+1)/2;
    
    cout << h - b;
    
}


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

using namespace std;

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
// cout << fixed << setprecision(20);

int N, K;
int A[220000];
int lg[220000], x[220000];
map<int, int> amap, bmap;

signed main() {
    cin >> N >> K;
    for (int i = 0; i < N; i++)cin >> A[i];
    A[N] = -1;
    lg[N - 1] = N - 1;
    lg[N] = N;
    amap[A[N - 1]] = N - 1;
    amap[-1] = -1;
    for (int i = N - 2; i >= 0; i--) {
        if (amap.count(A[i]) == 0) {
            lg[i] = i;
        } else {
            lg[i] = lg[amap[A[i]] + 1];
        }
        amap[A[i]] = i;
    }
    x[0] = -1;
    bmap[-1] = 0;
    int start = 0, cyc = 0;
    for (int i = 1; i < N + 200; i++) {
        x[i] = A[lg[amap[x[i - 1]] + 1]];
        if (bmap.count(x[i]) == 0) {
            bmap[x[i]] = i;
        } else {
            start = bmap[x[i]];
            cyc = i - start;
            break;
        }
    }

    for (int i = 0; i <= N; i++)cerr << x[i] << endl;
    cerr<<"start: "<<start<<" cyc: "<<cyc<<endl;
    int o;
    int k=K-1;
    if (start >= k)o = x[k];
    else o = x[start + (k - start) % cyc];
    cerr<<o<<endl;
    for (int i = lg[amap[o]+1]; i < N; i = lg[i + 1]) {
        cout << A[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 31360
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#pragma GCC optimize(4)
#include<bits/stdc++.h>
using namespace std;
#define y1 y11
#define fi first
#define se second
#define pi acos(-1.0)
#define LL long long
//#define mp make_pair
#define pb push_back
#define ls rt<<1, l, m
#define rs rt<<1|1, m+1, r
#define ULL unsigned LL
#define pll pair<LL, LL>
#define pli pair<LL, int>
#define pii pair<int, int>
#define piii pair<pii, int>
#define pdd pair<double, double>
#define mem(a, b) memset(a, b, sizeof(a))
#define debug(x) cerr << #x << " = " << x << "\n";
#define fio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//head

const int N = 2e3 + 10; 
const int MOD = 998244353;
char s[N];
int dp[N*2][N*2];
int sum[N], sm[N];
int main() {
	int n;
	scanf("%s", s+1);
	n = strlen(s+1);
	for (int i = 1; i <= n; ++i) sum[i] = sum[i-1] + s[i]-'0';
	dp[0][0] = 1;
	for (int i = 1; i <= 2*n; ++i) {
		int p = min(i, n);
		for (int j = 0; j < i; j++) {
			if(sum[p] > j) dp[i][j+1] = (dp[i][j+1] + dp[i-1][j]) % MOD;
			if(2*i - sum[p] > i-1-j) dp[i][j] = (dp[i][j] + dp[i-1][j]) % MOD; 
		}
	} 
	printf("%d\n", dp[2*n][sum[n]]);
	return 0;
}

Measured memory_bytes: 61568
import math
def distance(x,y,d):
  return math.sqrt(x*x +y*y)


n,d = input().split(' ')
n = int(n)
d = int(d)
c = 0
for i in range(n):
  x,y = input().split(' ')
  x = int(x)
  y = int(y)
  dis = distance(x,y,d)
  if dis <= d:
    c += 1
print(c)

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

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
int main(){
    int n,m;
    cin>>n>>m;
    if(n>=m){
        cout << 0 << endl;
        return 0;
    }
    vector<int> x(m);
    for(int i=0;i<m;++i){
        cin>>x[i];
    }
    sort(x.begin(),x.end());
    vector<int> b;
    for(int i=1;i<m;++i){
        b.push_back(abs(x[i-1] - x[i]));
    }
    sort(b.rbegin(),b.rend());
    ll sum = accumulate(b.begin() + n-1,b.end(),0);
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 1276
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <fstream>
#include <sstream>
using namespace std;

const unsigned long long BASE = 1e9 + 7;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    for (int i = 0; i < s.length(); i++)
    {
        int idx = s[i] - 'A';
        cout << char((int(s[i] - 'A') + n) % 26 + 'A');
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3612
/*
    author:ujwalll
*/
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std; 
#define rep(i,n) for(int i=0;i<(n);i++)
#define for1(i,n) for(int i=1;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
const int INF = 1<<29;
const int MOD=1e9+ 7;
#define pp pair<ll,ll>
#define ppi pair<int,int>
typedef long long int ll;
bool isPowerOfTwo (ll x)  
{  
    return x && (!(x&(x-1)));  
}
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
long long binpow(long long a, long long b) {
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
////////////////////////////////////////////////////////////////////

int main(){
    int tc=1;
    // cin>>tc;
    while(tc--){
        int n;
        cin>>n;
        ll a[n];
        ll sum=0;
        rep(i,n){
            cin>>a[i];
            sum+=a[i];
        }
        ll ans=0;
        rep(i,n){
            // cout<<sum<<"\n";
            sum-=a[i];
            // cout<<sum<<"\n";
            ans=(ans + (1LL*(a[i]%MOD)*(sum%MOD))%MOD)%MOD;
        }
        cout<<ans;
    }
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }

#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define VIN(x) for(auto&youso_: (x) )cin>>youso_
#define VOUT(x, delim) for(auto&youso_: (x) )cout<<youso_<<delim;cout<<endl

#define COUT(x) cout<<(x)<<endl
void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail){
    cin>>head;
    CINT(move(tail)...);
}
#define CIN(...) i64 __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    CIN(T1, T2, A1, A2, B1, B2);
    i64 C1 = B1 - A1;
    i64 C2 = B2 - A2;
    i64 d = C1 * T1 + C2 * T2;
    if (C1 > 0 && d > 0) COUT(0);
    else if (C1 < 0 && d < 0) COUT(0);
    else if (d == 0) COUT("infinity");
    else {
        if (C1 < 0) {
            C1 *= -1;
            C2 *= -1;
            d *= -1;
        }
        i64 cnt = 2 * ((C1 * T1) / abs(d) + 1);
        if ((C1 * T1) % abs(d) == 0) cnt--;
        cnt--;
        COUT(cnt);
    }

    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
#define speed                                                                  \
  ios_base::sync_with_stdio(0);                                                \
  cin.tie(0);                                                                  \
  cout.tie(0);
#define oprecision                                                             \
  cout.precision(30);                                                          \
  cerr.precision(7);
#define bb bool
#define ii int
#define ll long long
#define ff float
#define dd double
#define cc char
#define ss string
#define forn(sz) for (int i = 1; i <= sz; i++)
#define forni(i, sz) for (int i = 1; i <= sz; i++)
#define fornid(i, m, sz) for (int i = m; i <= sz; i++)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vii vector<ii>
#define vii64 vector<ll>
#define vb vector<bb>
using namespace std;
ii a, b;
ii main() {
  speed;
  oprecision;
  /*#ifndef ONLINE_JUDGE
    freopen("outd.txt", "rt", stdin);
  #endif*/
  // code
  cin >> a >> b;
  for (int i = b - a + 1; i <= b + (b - (b - a + 1)); i++) {
    cout << i << ' ';
  }
  // endl
#ifndef ONLINE_JUDGE
  cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}


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

int main() {
  int64_t a,b,n;
  cin >> a >> b >> n;
  int64_t ans1=a*n/b-a*(n/b);
  int64_t ans2=0;
  if(b!=1){
    if(n>=b-1) ans2=a*(b-1)/b;
  }
  cout << max(ans1,ans2) << endl;
    
}

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

int main(){
    int n;
    cin >> n;
    if(n/100 == 7){
        cout << "Yes" << endl;
        return 0;
    }
    n %= 100;
    if(n/10 == 7){
        cout << "Yes" << endl;
        return 0;
    }
    n %= 10;
    if(n == 7){
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3620
#include<stdio.h>
#include<iostream>
using namespace std;

int main()
{
	int N;
	
	scanf("%d",&N);
	
	int sum = 0, temp = N;
	while(temp!=0)
	{
		sum+= temp%10;
		temp/=10;
	}
	
	if(N%sum == 0 ) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

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

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	int a, b;
	cin >> a >> b;
	ansYes(a % 500 <= b);
}


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

int main()
{
    ll a,b,c,k;cin>>a>>b>>c>>k;
    while(b<=a && k--) b*=2;
    while(c<=b && k-->0) c*=2;
    if(b>a && c>b) cout<<"Yes";
    else cout<<"No";
}

Measured memory_bytes: 3540
s=input()
n=int(input())
for _ in range(n):
    tmp=list(map(str,input().split()))
    a,b=int(tmp[1]),int(tmp[2])+1
    if tmp[0]=="print":
        print(s[a:b])
    elif tmp[0]=="reverse":
        stmp=s[a:b]
        s=s[:a]+stmp[::-1]+s[b:]
    else:
        p=tmp[3]
        s=s[:a]+p+s[b:]


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

int	main() {
	int N;
	cin >>N;
	vector<int> a(N);
	for (int i=0; i<N; i++)
		cin >>a.at(i);
	int S=100*100*N;
	for (int i=-100; i<=100; i++) {
		int SS=0;
		for (int j=0; j<N; j++)
			SS +=(a.at(j)-i)*(a.at(j)-i);
		S = min(S, SS);
	}
	cout <<S <<endl;
	return 0;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define sz(a) a.size()
#define re return
#define all(a) a.begin(),a.end()
#define int long long
using namespace std;
const int dx[4]={-1,1,0,0};
const int dy[4]={0,0,-1,1};
signed main()
{
	string s;
	cin>>s;
	for (int i=0;i<sz(s);i++)  if (s[i]=='?')  s[i]='D';
	cout<<s;
	re 0;
}

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

using namespace std;

namespace jumpmelon
{
	typedef long long big;
	
	const int INF = 0x3f3f3f3f;
	const big INFLL = 0x3f3f3f3f3f3f3f3fLL;
	const int MAXN = 1000, MAXVC = (MAXN << 1) + 6, MAXEC = 10 * MAXN;
	struct edge { int v, f, c, next; } E[MAXEC << 1];
	bool Vis[MAXVC];
	int n, ec, vc, vs, vt, Head[MAXVC], Pre[MAXVC];
	big Dis[MAXVC], H[MAXVC];
	
	void add_edge(int u, int v, int f, int c)
	{
		E[ec] = (edge){v, f, c, Head[u]};
		Head[u] = ec++;
		E[ec] = (edge){u, 0, -c, Head[v]};
		Head[v] = ec++;
	}
	
	void SPFA()
	{
		queue<int> Q;
		fill(H, H + vc, -INFLL);
		H[vs] = 0;
		Q.push(vs);
		Vis[vs] = 1;
		while (!Q.empty())
		{
			int u = Q.front();
			Q.pop();
			Vis[u] = 0;
			for (int p = Head[u]; ~p; p = E[p].next)
				if (E[p].f && H[u] + E[p].c > H[E[p].v])
				{
					H[E[p].v] = H[u] + E[p].c;
					if (!Vis[E[p].v])
					{
						Q.push(E[p].v);
						Vis[E[p].v] = 1;
					}
				}
		}
	}
	
	bool Dijkstra()
	{
		typedef pair<big, int> pa;
		
		priority_queue<pa> Q;
		memset(Vis, 0, sizeof(bool[vc]));
		fill(Dis, Dis + vc, -INFLL);
		Q.push(pa(Dis[vs] = 0, vs));
		while (!Q.empty())
		{
			int u = Q.top().second;
			Q.pop();
			if (!Vis[u])
			{
				Vis[u] = 1;
				for (int p = Head[u]; ~p; p = E[p].next)
					if (E[p].f)
					{
						big w = H[u] + E[p].c - H[E[p].v];
						if (Dis[u] + w > Dis[E[p].v])
						{
							Pre[E[p].v] = p;
							Q.push(pa(Dis[E[p].v] = Dis[u] + w, E[p].v));
						}
					}
			}
		}
		return Dis[vt] > -INFLL;
	}
	
	big EK()
	{
		big ans = 0;
		SPFA();
		while (Dijkstra())
		{
			int f = INF;
			for (int x = vt; x != vs; x = E[Pre[x] ^ 1].v)
				if (E[Pre[x]].f < f)
					f = E[Pre[x]].f;
			for (int x = vt; x != vs; x = E[Pre[x] ^ 1].v)
			{
				E[Pre[x]].f -= f;
				E[Pre[x] ^ 1].f += f;
				ans += (big)f * E[Pre[x]].c;
			}
			for (int i = 0; i < vc; i++)
				H[i] += Dis[i];
		}
		return ans;
	}
	
	void work()
	{
		scanf("%d", &n);
		vc = (n << 1) + 6;
		vs = (n << 1);
		vt = (n << 1) + 1;
		memset(Head, -1, sizeof(int[vc]));
		for (int i = 0; i < n; i++)
		{
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			add_edge(vs, i, c, 0);
			add_edge(i, vt + 1, INF, +x + y);
			add_edge(i, vt + 2, INF, +x - y);
			add_edge(i, vt + 3, INF, -x + y);
			add_edge(i, vt + 4, INF, -x - y);
		}
		for (int i = n; i < (n << 1); i++)
		{
			int x, y, c;
			scanf("%d%d%d", &x, &y, &c);
			add_edge(vt + 1, i, INF, -x - y);
			add_edge(vt + 2, i, INF, -x + y);
			add_edge(vt + 3, i, INF, +x - y);
			add_edge(vt + 4, i, INF, +x + y);
			add_edge(i, vt, c, 0);
		}
		printf("%lld\n", EK());
	}
}

int main()
{
	jumpmelon::work();
	return 0;
}

Measured memory_bytes: 884
n=int(input())
dicsp={}
listp=[]
for i in range(n):
  s,p=map(str,input().split())
  listp.append([s,p])
  dicsp.setdefault(s,[]).append(p)
  
#print(dicsp)
s=sorted(list(dicsp.keys()))
listsp=[]
for i in s:
  t=list(map(int,dicsp[i]))
  t.sort(reverse=True)
  for j in t:
    listsp.append([i,j])

for i,j in listsp:
  print(listp.index([i,str(j)])+1)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>

using namespace std;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    int r_num = 0;
    int g_num = 0;
    int b_num = 0;
    for (int i=0; i<n; i++){
        if (s[i]=='R'){
            r_num += 1;
        }
        else if (s[i]=='G'){
            g_num += 1;
        }
        else if (s[i]=='B'){
            b_num += 1;
        }
    }
    long long sum = 0;
    for (int i=0; i<b_num; i++){
        sum += r_num * g_num;
    }
    for (int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            if (n > 2*j-i){
                if (s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i]){
                    sum -= 1;
                }
            }
        }
    }
    if (n<=3){
        sum = 0;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 2e9;

int main()
{
    int N;
    cin >> N;
    ll xdist_min = INF, xdist_max = -INF, ydist_min = INF, ydist_max = -INF;
    for (int i = 0; i < N; i++)
    {
        ll x, y;
        scanf("%lld %lld", &x, &y);
        xdist_min = min(xdist_min, x + y);
        xdist_max = max(xdist_max, x + y);
        ydist_min = min(ydist_min, x - y);
        ydist_max = max(ydist_max, x - y);
    }

    cout << max(xdist_max - xdist_min, ydist_max - ydist_min) << endl;
}

Measured memory_bytes: 3664
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long int ll;
static const int MAX_A = 55555;

int N;
bool is_prime[MAX_A + 1];

void eratosthenes(){
	fill(is_prime, is_prime + MAX_A + 1, true);
	is_prime[1] = false;
	for(int i = 2; i * i <= MAX_A; i++){
		if(is_prime[i]){
			for(int j = 2; j * i <= MAX_A; j++){
				is_prime[j * i] = false;
			}
		}
	}
	return ;
}
int main(){
	vector<int> ans;
	cin >> N;
	eratosthenes();
	int cnt = 0;
	for(int i = 1; i <= MAX_A; i++){
		if(i % 5 == 1 && is_prime[i]){
			ans.push_back(i);
			cnt++;
		}
		if(cnt == N) break;
	}
	for(int i = 0; i < N; i++){
		cout << ans[i];
		if(i == N - 1) cout << endl;
		else cout << ' ';
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/************************************************/
#define rep(i,n) for(int i=0;i<n;i++)
#define mp make_pair
#define pb push_back
#define fr first
#define se second
#define forn(i,a,n) for(int i=a;i<n;i++)
#define foreach(i,c) for(__typeof(c.begin())i=(c.begin());i!=(c).end();i++)
#define pii pair<int,int>
#define vi vector<int>
#define ll long long
#define sz(s) s.size()
#define all(s) s.begin(),s.end()
#define zero(x) memset(x,0,sizeof(x))
#define vii vector<pair<int,int> >
#define mpis map<int,string>
#define mpii map<int,int>
#define mpsi map<string,int>
#define re return
/************************************************/
using namespace std;

long long get(){
	char c=getchar();
	long long x=0LL;
	while(c<'0'||c>'9')
	c=getchar();
	while(c>='0'&&c<='9'){
		x*=10LL;
		x+=(c-'0');
		c=getchar();
	}
	return x;
}
long long n;
int main(){
	cin>>n;
	if(n%2){
		cout<<0;
		re 0;
	}
	ll ans=0ll;
	n/=10;
	ans+=n;
	while(n){
		n/=5;
		ans+=n;
	} 
	cout<<ans;
	re 0;
}


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

int main(){
  int n, tmp, ans=0;
  vector<int> length;

  cin >> n;

  for(int i=0;i<n;i++){
    cin >> tmp;
    length.push_back(tmp);
  }

  sort(length.begin(), length.end());

  int longest, second_longest;
  for(int i=2; i<n; i++){
    longest = length[i];
    for(int j=1; j<i; j++){
      second_longest = length[j];
      for(int k=0; k<j; k++){
        if(longest < (length[k]+second_longest) && (second_longest-length[k]) < longest){
          ans++;
        }
      }
    }
  }

  cout << ans;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <queue>
#include <stack>


int main(){
    int N;
    scanf("%d",&N);

    if(N==1){
        printf("Hello World\n");
    }else{
        int A,B;
        scanf("%d",&A);
        scanf("%d",&B);
        printf("%d\n",A+B);
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define speed_up ios_base::sync_with_stdio(false); cin.tie(NULL)
#define ll long long
#define ara(A,N) sort(A,A+N)
#define rev(A,N) sort(A,A+N,greater<long long>())
using namespace std;
int main()
{
  speed_up;
  ll n, m, i, j, k, x;
  ll M = 1e9 + 7;

    cin >> n;
    map<ll, ll> a;
    for(k = 2; k <= n; ++k)
    {
        ll cnt = 0;
        ll num = k;
        while(num % 2 == 0) {
            ++cnt;
            num /= 2;
        }
        if(cnt) a[2] += cnt;
        for(i = 3; i <= num; i += 2) {
            if(num % i == 0) {
                cnt = 0;
                while(num % i == 0) {
                    ++cnt;
                    num /= i;
                }
                a[i] += cnt;
            }
        }
        
    }

    ll tot = 1;
    for(auto t : a)
    {
        tot *= (t.second + 1);
        tot %= M;
    }
    cout << tot << endl;




return 0;
}



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

using namespace std;

bool solve(int, int, int, int*);

int main(){
	int n, q;
	vector<int> A, m;
	int i, j, k;
	int ain, min;
	bool exist;
	
	cin >> n;
	for(i=0;i<n;++i){
		cin >> ain;
		A.push_back(ain);
	}
	cin >> q;
	for(i=0;i<q;++i){
		cin >> min;
		m.push_back(min);
	}
	
	for(i=0;i<q;++i){
		exist = false;
		
		if(solve(0, m[i], n, &A[0]))exist = true;
		if(exist)cout << "yes\n";
		else cout << "no\n";
	}
	
	return 0;
}

bool solve(int i, int m, int n, int* tmp){
	int res;
	if(m == 0)return true;
	if(i>=n)return false;
	res = solve(i+1, m, n, tmp) || solve(i+1, m-tmp[i], n, tmp);
	return res;
}


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

int main(){
  int i,j,n,sum=0;

  while(scanf("%d",&n)!=EOF){
    j=0;
    for(i=2;i<=sqrt(n);i++){
      if(n%i==0){
	j=1;
	break;
      }
    }
    if(j==0)sum++;
  }
  printf("%d\n",sum);

  return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,s,e) for (int i=s;i<(e);i++)
#define All(v) (v).begin(),(v).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
using namespace std;
typedef long long llint;
typedef pair<int, int> P;
const int MOD = (int)1e9 + 7;
const int INF = 999999999;

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

    int a, b;
    cin >> a >> b;
    if(b == 100){
        a = 1000*a+b;
    }else if(b>=10){
        a = 100*a+b;
    }else{
        a = 10*a+b;
    }
    REP(i,100000){
        if(a == (i+1)*(i+1) ){
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<math.h>
#include<algorithm>
#include<utility>
#include<functional>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MOD = 1000000007;
const ll INF=2e18;

ll N,M,K,C;
ll a,b,c,d;
string s;
int main(){
    cin>>N>>s;
    ll ecnt=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='E')ecnt++;
    }
    ll ans=INF;
    ll wcnt=0;
    for(int i=0;i<s.length();i++){
        if(s[i]=='E')ecnt--;
        ans=min(ans,ecnt+wcnt);
        if(s[i]=='W')wcnt++;
    }
    cout<<ans<<endl;
    return 0;
}


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

typedef long long ll;

ll mod = 1000000007;

ll kai[3000010];
ll inv_kai[3000010];

ll beki(ll x, ll a)
{
	if(x==0) return 0;
	if(a==0) return 1;
	if(a==1) return x;
	ll tmp=beki(x, a/2);
	tmp=tmp*tmp%mod;
	if(a%2==0) return tmp;
	else return tmp*x%mod;
}

ll inv(ll x)
{
	return beki(x, mod-2);
}

ll cb(ll s, ll t)
{
	if(s==t) return 1;
	if(t==-1) return 0;
	ll tmp=kai[(int)s];
	tmp=(tmp*inv_kai[(int)t])%mod;
	return tmp*inv_kai[(int)s-(int)t]%mod;
}

int main() {
	kai[0]=1;
	inv_kai[0]=1;
	for(int i=1; i<=3000005; i++)
	{
		kai[i]=kai[i-1]*(ll)i%mod;
		inv_kai[i]=inv(kai[i]);
	}
	//cout << "aaaaaaa" << cb(0, 0) << endl;
	while (true) {
		ll a, b, c, sx, sy;
		cin >> a >> b >> c >> sx >> sy;
		if(a+b+c==0) break;

		ll ans=0;
		for(ll x=a; x<=sx; x++)
		{
			ll y=sy-(sx-x);
			if(y>=b)
			{
				ll tmp=1;
				tmp=(tmp*cb(x-1, a-1))%mod;
				tmp=(tmp*cb(y-1, b-1))%mod;
				tmp=(tmp*cb(sx-x+a+b+c-1, a+b+c-1))%mod;
				ans=(ans+tmp)%mod;
			}
		}
		ans=(ans*cb(a+b+c, a))%mod;
		cout << ans*cb(b+c, b)%mod << endl;
	}
}


Measured memory_bytes: 49876