akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Security;
using System.Xml.Serialization;

namespace AtCoderCs
{

    class Program
    {

        const int Mod = 1000000007;

        static void Main()
        {

            var args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            var books = new int[args[0]][];
            var algolisms = args[1];
            var target = args[2];
            var value = new int[args[0]];
            var valuesMIN = int.MaxValue;
            var result = new int[algolisms];

            for (int i = 0; i < books.Length; i++)
            {

                args = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                value[i] = args[0];
                books[i] = new int[algolisms];
                Array.Copy(args, 1, books[i], 0, algolisms);

            }

            Solve(0, 0, new int[algolisms]);

            void Solve(int index, int values, int[] result)
            {

                if (index < books.Length)
                {

                    Solve(index + 1, values, result);

                    var bought = new int[algolisms];
                    for (int i = 0, l = bought.Length; i < l; i++)
                        bought[i] = result[i] + books[index][i];

                    if (bought.Any(x => x < target))
                        Solve(index + 1, values + value[index], bought);
                    else if (values + value[index] < valuesMIN)
                        valuesMIN = values + value[index];

                }

            }

            Console.WriteLine(valuesMIN == int.MaxValue ? -1 : valuesMIN);
            
        }



    }
}


Measured memory_bytes: 28940
/**
*   author:  akifpathan
*   created: Sunday 27.09.2020 06:04:08 PM
**/

/*
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#ifdef LOCAL
#include "debug.h"
#else
#include<bits/stdc++.h>
using namespace std;
#define debug(x...)
#endif
 
/*
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<class T> 
using ordered_set= tree<T, null_type, 
		less<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
template<class T> 		
using ordered_mset= tree<T, null_type, 
		less_equal<T>, 
		rb_tree_tag, tree_order_statistics_node_update> ;
		
*/
 
/*
 
PBDS
-------------------------------------------------
			0 based indexing
-------------------------------------------------			 
1) insert(value)
2) erase(value)
3) order_of_key(value) // Number of items strictly smaller than value
4) *find_by_order(k) : K-th element in a set (counting from zero)
 
*/
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
 
//mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());	

const int mx=1e5+5;

int color[mx];
vector<int>g[mx];

void dfs(int u)
{
	color[u]=1;
	for(int v: g[u]) if(!color[v]) dfs(v);
}

void solve()
{
	int n,m;
	cin>>n>>m;
	
	for(int i=0;i<m;i++) 
	{
		int u,v;
		cin>>u>>v;
		
		g[u].push_back(v);
		g[v].push_back(u);
	}
	
	int ans=-1;
	
	for(int i=1;i<=n;i++)
	{
		if(!color[i])
		{
			ans++;
			dfs(i);
		}
	}
	
	cout<<ans;
}		

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0); cout.tie(0);
	
	int testcase=1;
	//cin>>testcase;
	
	for(int i=1;i<=testcase;i++)
	{
		//cout<<"Case "<<i<<": ";
		solve();
	}
	
	#ifdef LOCAL
	cerr<<"\nTime elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << " ms\n";
	#endif
	
	
	return 0;
}



Measured memory_bytes: 10016
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <iomanip>
#include <map>
#include <sstream>
#include <utility>
#include <stack>
#include <queue>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(vecto) vecto.begin(), vecto.end()
#define max3(a, b, c) max(a, max(b, c))
#define min3(a, b, c) min(a, min(b, c))
using ll = long long;

//const int MOD = 1e9 + 7;

template <class T>
T GCD(T a, T b)
{
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}

template <class T>
T LCM(T a, T b)
{
    return (a * b) / GCD(a, b);
}

template <class T>
T max_(std::vector<T> vec)
{
    std::sort(all(vec));
    return vec.at(vec.size() - 1);
}
template <class T>
T min_(std::vector<T> vec)
{
    std::sort(all(vec));
    return vec.at(0);
}

void ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
}

void Ans(bool t_or_f)
{
    if (t_or_f == true)
        std::cout << "YES" << std::endl;
    else
        std::cout << "NO" << std::endl;
}

using namespace std;

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

int main(){
    int sum = 0;
    int n;
    cin >> n;
    int s[n];
    rep(i, n) cin >> s[i];
    int q;
    cin >> q;
    int t[q];
    rep(i, q) cin >> t[i];
    rep(i,q){
        rep(j,n){
            if(t[i]==s[j]){
                sum++;
          		break;}
        }
    }
    cout << sum << endl;
}


Measured memory_bytes: 3152
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>

using namespace std;

const int MAX_N = 1e5 + 5;

int a [MAX_N];
int b [MAX_N];

vector<int> p;

int vis [MAX_N];
void dfs (int u, int src) {
  vis[u] = src;
  if (!vis[p[u]]) {
    dfs(p[u], src);
  }
}

int root [MAX_N];
int find (int u) {
  if (root[u] != u) {
    root[u] = find(root[u]);
  }
  return root[u];
}

void merge (int u, int v) {
  u = find(u);
  v = find(v);
  root[u] = v;
}

int main () {
  for (int i = 0; i < MAX_N; i++) {
    root[i] = i;
  }
  
  int n;
  cin >> n;

  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    a[0] ^= a[i];
  }

  for (int i = 1; i <= n; i++) {
    cin >> b[i];
    b[0] ^= b[i];
  }

  vector<int> sa, sb;
  for (int i = 0; i <= n; i++) {
    sa.push_back(a[i]);
    sb.push_back(b[i]);
  }
  sort(sa.begin(), sa.end());
  sort(sb.begin(), sb.end());
  if (sa != sb) {
    cout << -1 << endl;
    return 0;
  }

  vector<int> va, vb;
  for (int i = 0; i <= n; i++) {
    if (i == 0 || a[i] != b[i]) {
      va.push_back(a[i]);
      vb.push_back(b[i]);
    }
  }

  map<int, int> seenb;
  map<pair<int, int>, int> pos;
  int K = va.size();
  for (int i = 0; i < K; i++) {
    if (seenb.count(vb[i]) == 0) {
      seenb[vb[i]] = 0;
    }
    pos[make_pair(vb[i], seenb[vb[i]])] = i;
    seenb[vb[i]]++;
  }

  map<int, int> seena;
  for (int i = 0; i < K; i++) {
    if (seena.count(va[i]) == 0) {
      seena[va[i]] = 0;
    }
    p.push_back(pos[make_pair(va[i], seena[va[i]])]);
    
    seena[va[i]]++;
  }

  /*
  for (int i = 0; i < K; i++) {
    cout << p[i] << " " ;
  }
  cout << endl;
  */

  vector<int> ids;
  for (int i = 0; i < K; i++) {
    if (!vis[i]) {
      dfs(i, i + 1);
      ids.push_back(i + 1);
    }
  }

  for (auto it = seenb.begin(); it != seenb.end(); it++) {
    int id = it->first;
    int cnt = it->second;
    for (int i = 0; i < cnt - 1; i++) {
      merge(vis[pos[make_pair(id, i)]], vis[pos[make_pair(id, i + 1)]]);
    }
  }

  int cc = 0;
  for (int id : ids) {
    if (find(id) == id) {
      cc++;
    }
  }

  cout << K + cc - 2 << endl;
}


Measured memory_bytes: 22900
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;
constexpr ll LL_MAX = numeric_limits<ll>::max();
constexpr ull ULL_MAX = numeric_limits<ull>::max();

template<typename T>
vector<T> make_vec_nd(T init, ll size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, ll size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrep(i, a, b) for (ll i = (a)-1; i >= (b); i--)

int main() {
    ll N, K, Q;
    cin >> N >> K >> Q;
    vector<ll> As(N);
    rep(i,0,N) {
        cin >> As[i];
    }
    vector<ll> Bs = As;
    sort(Bs.begin(), Bs.end());
    ll ans = numeric_limits<ll>::max();
    for (ll b : Bs) {
        using Queue = priority_queue<ll, vector<ll>, greater<ll>>;
        auto compare_queue = [](Queue& lhs, Queue& rhs){ return lhs.top() > rhs.top(); };
        priority_queue<Queue, vector<Queue>, decltype(compare_queue)> groups(compare_queue);
        ll i = 0;
        while (i < N) {
            Queue queue;
            while (i < N && As[i] >= b) {
                queue.push(As[i]);
                i++;
            }
            if (queue.size() >= K) {
                groups.push(move(queue));
            }
            i++;
        }
        ll cnt = 0;
        ll mn = numeric_limits<ll>::max();
        ll mx = numeric_limits<ll>::min();
        while (groups.size() > 0) {
            cnt++;
            Queue moved = (Queue&&)groups.top();
            groups.pop();
            ll elem = moved.top();
            mn = min(mn, elem);
            mx = max(mx, elem);
            moved.pop();
            if (moved.size() >= K) {
                groups.push(move(moved));
            }
            if (cnt >= Q) {
                break;
            }
        }
        if (cnt >= Q) {
            ans = min(ans, mx - mn);
        }
    }
    cout << ans << endl;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int N, M;
	cin >> N >> M;
	//int ans = 0;
	
	cout << N*(N-1)/2 + M*(M-1)/2;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
string a,b;
int h = 0;
int main(){
    cin >> a;
    cin >> b;
    for (int i=0; i<b.length();i++){
        if (a[i] == b[i]){
            h++;
        }
    }
    cout << h;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
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; }

int bubbleSort(vector<int> &A) {
	int ret = 0;
	int n = A.size();
	for (int i = 0; i < n; i++)
		for (int j = n - 1; j > i; j--)
			if (A[j - 1] > A[j])
				swap(A[j - 1], A[j]), ret++;
	return ret;
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> v(N); rep(i, 0, N) {
		cin >> v[i];
	}
	int r = bubbleSort(v);
	cout << v[0]; rep(i, 1, v.size()) { cout << " " << v[i]; } cout << endl;
	cout << r << endl;
	return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<algorithm>
#include<string>
#define F(n) for(int i=0;i<n;i++)
using namespace std;
int a, b, c, x, y;
long money[3];
int main() {
	cin >> a >> b >> c >> x >> y;
	money[0] = a * x + b * y;
	money[1] = c *2*max(x, y);
	money[2] = c * 2 * min(x, y);
	money[2] += x > y ?a * (x - y) : b * (y - x);
	sort(money, money + 3);
	cout << money[0] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
typedef long long int ll;
typedef unsigned long long ull;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define pll pair<ll,ll>
#define pii pair<int,int>
#define len(s) s.length()
#define all(v) v.begin(),v.end()
const ll INF = LONG_MAX;
const int N = 2e5 + 5;
const ll mod = 1000000007 ;
using namespace std;

ld dp[15][15];

int main() {


	ios_base::sync_with_stdio(false);
	cin.tie(NULL), cout.tie(NULL);


	ll tc = 1;
	// cin >> tc;

	while (tc--) {

		ll m;
		ll i, j;

		ll n;
		ll k;
		ll h1, m1, h2, m2;
		cin >> h1 >> m1 >> h2 >> m2 >> k;

		ll ans = (h2 * 60 + m2 - (h1 * 60 + m1) - k);

		cout << ans << endl;


	}
}

Measured memory_bytes: 3532
n, m = map(int, input().split())
h = list(map(int, input().split()))

l = [1] * n
for i in range(m):
    a, b = map(int, input().split())
    if h[a - 1] <= h[b - 1]:
        l[a - 1] = 0
    if h[b - 1] <= h[a - 1]:
        l[b - 1] = 0

print(sum(l))


Measured memory_bytes: 20124
#ifdef _MSC_VER
#include <__msvc_all_public_headers.hpp>
#undef min
#undef max
#else
#define NDEBUG
#include <bits/stdc++.h>
#endif

using namespace std;
using large = long long;

static large solve(large N) {
    if (N % 2 == 1)
        return 0;
    if (N < 10)
        return 0;

    auto fives = 0LL;
    for (auto x = 10LL; x <= 1'000'000'000'000'000'000; x *= 5) {
        fives += N / x;
    }
    return fives;
}

int main() {
    large N;
    cin >> N;
    cout << solve(N) << endl;
    return 0;
}


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

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

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

int main() {
	int a[3],b[3];
    int d[4]={0};

    REP(i,3){
        cin>>a[i]>>b[i];
        d[a[i]-1]++;
        d[b[i]-1]++;
    }

    int x=0,y=0;
    REP(i,4){
        if(d[i]==1){
            x++;
        }
        else if(d[i]==2){
            y++;
        }
    }
    if(x==2&&y==2){
        cout<<"YES"<<endl;
    }
    else{
        cout<<"NO"<<endl;
    }
	
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int N  = keyboard.nextInt();
		
		int[]P = new int[N];
		
		for(int i = 0; i < N; i++) {
				P[i] = keyboard.nextInt();	
		}
		
		int a = 0;
		int b = 0;
		int count = 0;
		
		for(int i = 1; i < N-1; i++) {
			if(P[i-1] > P[i+1]){
				a = P[i-1];
				b = P[i+1];
			}else {
				a = P[i+1];
				b = P[i-1];
			}
			if(a > P[i] && P[i] > b) {
				count++;
			}
		}
		System.out.println(count);
		keyboard.close();	
	}
}

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

using namespace std;

int main()
{
    string s;
    cin >> s;

    int smax=0;
    for(int i=0;i<s.length();i++){
        if(s[i]!='A' && s[i]!='C' && s[i]!='G' && s[i]!='T') continue;
        
        bool check=false;
        for(int j=i;j<s.length();j++){
            if(s[j]!='A' && s[j]!='C' && s[j]!='G' && s[j]!='T'){
                smax=max(smax,j-i);
                check=true;
                break;
            }
        }
        if(!check){
            smax=max(smax,(int)s.length()-i);
        }
    }

    cout << smax << endl;
}

Measured memory_bytes: 256
import sys
from collections import defaultdict, deque
import math

# import copy
from bisect import bisect_left, bisect_right
# import heapq

# sys.setrecursionlimit(1000000)

# input aliases
input = sys.stdin.readline

getS = lambda: input().strip()
getN = lambda: int(input())
getList = lambda: list(map(int, input().split()))
getZList = lambda: [int(x) - 1 for x in input().split()]

INF = 10 ** 20
MOD = 10**9 + 7
divide = lambda x: pow(x, MOD-2, MOD)

def solve():
    n = getN()
    for i in range(1, 10000):
        if i * (i + 1) / 2 >= n:
            mx = i
            break
    # print(mx)
    ans = []
    for i in ([i for i in range(1, mx+1)[::-1]]):
        if n >= i:
            ans.append(i)
            n -= i


    if n != 0:
        sys.exit(1)

    for an in ans:
        print(an)


def main():
    n = getN()
    for _ in range(n):
        solve()


if __name__ == "__main__":
    # main()
    solve()

Measured memory_bytes: 74488
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 int main(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin>>s;
    if(s=="Sunny")
        cout<<"Cloudy\n";
    if(s=="Cloudy")
        cout<<"Rainy\n";
    if(s=="Rainy")
        cout<<"Sunny\n";        
	return 0;
}

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

int main() {
    string my_str, temp, my_command, p;
    int q, a, b;

    cin >> my_str;
    cin >> q;

    for (int i = 0; i < q; i++) {
        cin >> my_command >> a >> b;
        if (my_command == "print") {
            cout << my_str.substr(a, b - a + 1) << endl;
        } else if (my_command == "reverse") {
            temp = my_str.substr(a, b - a + 1);
            for (int i = 0; i < b - a + 1; i++) {
                my_str[a + i] = temp[b - a - i];
            }
        } else if (my_command == "replace") {
            cin >> p;
            for (int i = 0; i < b - a + 1; i++) {
                my_str.replace(a, b - a + 1, p);
            }
        }

    }

	return 0;
}


Measured memory_bytes: 3236
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define Cout(s) cout << s << endl;
using ll = long long;
using P = pair<int, int>;

const ll INF = 1ll << 60;
ll MOD = 1e9 + 7;

int main()
{

    int n;
    cin >> n;

    vector<pair<double, string>> p(n);
    REP(i, n)
    {
        double a;
        string b;
        cin >> a >> b;
        p[i] = make_pair(a, b);
    }

    double ans = 0;
    REP(i, n)
    {

        if (p[i].second == "BTC")
            ans += p[i].first * 380000.0f;
        else
            ans += p[i].first;
    }
    Cout(ans);

    return 0;
}

Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Santa on 2016/10/16.
 */
public class Main {

    static int N;
    static int M;
    static int A;
    static long B;
    static long C;
    static int[] map = new int[1000000];
    static int min = 9999999;




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

        N = scanner.nextInt();
        M = scanner.nextInt();
        min = -1;
        for (int i = 0; i < N; i++) {
            map[i] = scanner.nextInt();
            if(map[i] == 1)min = i;
        }
//        System.out.println(min);



        M--;

        int temp = min + N - min - 1;

        int ans = (temp + M - 1) / M;


        System.out.println(ans);





    }

}



Measured memory_bytes: 67072
using System;

namespace AOJ.Volume2
{
    public class NumberOfChairs
    {
        public static int Main()
        {
            var input = Console.ReadLine().Split(' ');
            int desc = int.Parse(input[0]);
            int chair = int.Parse(input[1]);

            Console.WriteLine(desc * chair);
            return 0;
        }
    }
}

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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            //入力読取。
           string strWord = Console.ReadLine();
           string strContains = Console.ReadLine();
           
           //文字を連結。
           string strAddWord = strWord + strWord;
           
           string strAnswer = "";
           if(0 <= strAddWord.IndexOf(strContains)){
               strAnswer = "Yes";
           }else{
               strAnswer = "No";
           }

            //出力
            Console.WriteLine(strAnswer);  
            
        }
    }

}



Measured memory_bytes: 20304
#include<stdio.h>
int main(void)
{
  int n;
  char s[300100];
  scanf("%d",&n);
  scanf("%s",s);

  int east[300100]={0},west[300100]={0};
  east[0]=0;
  west[0]=0;
  for(int i=1;i<=n;i++){
    east[i]=east[i-1];
    west[i]=west[i-1];
    if(s[i-1]=='W'){
      west[i]++;
    }else{
      east[i]++;
    }
  }

  // for(int i=0;i<=n;i++){
  //   printf("%d %d\n",east[i],west[i]);
  // }
  int min=n;
  for(int i=1;i<=n;i++){
    int sum=0;
    sum+=(west[i-1]-west[0])+(east[n]-east[i]);
    if(sum<min){
      min=sum;
    }
  }

  printf("%d\n",min);
  return 0;
}


Measured memory_bytes: 4364
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<stdbool.h>
#include<tgmath.h>
#include<time.h>
#define ll long long
#define min(a,b) ((a)>(b)?(b):(a))
#define max(a,b) ((a)>(b)?(a):(b))
#define miin(a,b,c) min((a), min((b), (c)))
#define maax(a,b,c) max((a), max((b), (c)))
ll n, a[222222], b[222222] = {}, c = 0;

main(){
    scanf("%lld", &n);
    for(int i=0; i<n; i++){
        scanf("%lld", &a[i]);
        b[a[i]]++;
    }
    for(int i=0; i<222222; i++){
        c += b[i] * (b[i]-1) / 2;
    }
    for(int i=0; i<n; i++){
        printf("%lld\n", c - b[a[i]]*(b[a[i]]-1)/2 + (b[a[i]]-1)*(b[a[i]]-2)/2);
    }
    return 0;
}

Measured memory_bytes: 4608
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
  cin >> a >> b>>c;
   int* h = new int[a]; 
   double* t = new double[a]; 
   double* f= new double[a]; 
 int i;
  for(i=0;i<a;i++){
    cin>>h[i];
  }
int j;
  for(j=0;j<a;j++){
     t[j]=b-h[j]*0.006;
  }
  int k;
  for(k=0;k<a;k++){
     if(t[k]>=c){
        f[k]=t[k]-c;
     }else{
       f[k]=c-t[k];
    }
  }
   double min=1000.0;int index;
int x;
for (x =0; x<a; x++) {
        if (min>f[x]) {
            min = f[x];
            index = x+1;
        }
    }
   cout <<index<< endl;
    return 0;
}

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

int main(void){
    string s;
    cin >> s;

    int c0=0,c1=0;
    for(int i=0;i<s.size();i++)
    {
        if(s[i]=='0')c0++;
        else c1++;
    }
       
    cout << 2*min(c0,c1) << endl;
}


Measured memory_bytes: 512
N = int(input())
xy = [tuple(map(int,input().split())) for i in range(N)]

import itertools

len_list = list(itertools.combinations(xy,2))

length = 0

for i in range(len(len_list)):
    x = len_list[i][0][0] - len_list[i][1][0]
    y = len_list[i][0][1] - len_list[i][1][1]
    length += (x**2+y**2)**0.5
    
print(length/N*2)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static Atcoder;
using System.Threading.Tasks;
using System.ComponentModel;

public class Hello
{

    public static void Main()
    {
        int[] n = SpRead(' ').Select(a => int.Parse(a)).ToArray();
        if (n[0] < 9 && n[1] < 9) Console.WriteLine("Yay!");
        else Console.WriteLine(":(");
    }
}


public class Atcoder
{
    static void Swap<T>(ref T a, ref T b)
    {
        var t = a;
        a = b;
        b = t;
    }
    public static int LCM(int a, int b)
    {
        int c = a * b;
        if (a < b) Swap(ref a, ref b);
        int d = a % b;
        while (d != 0)
        {
            a = b;
            b = d;
            d = a % b;
        }
        return c / b;
    }
    public static string strReverce(string s)
    {
        return new string(s.Reverse().ToArray());
    }
    public static int intRead()
    {
        return int.Parse(Console.ReadLine());
    }
    public static bool IsPrime(int n)
    {
        if (n < 2) return false;
        if (n == 2) return true;
        if (n % 2 == 0) return false;

        //double sqrtNum = Math.Sqrt(n);
        for (int i = 3; i < n; i += 2)
        {
            if (n % i == 0) return false;
        }
        return true;
    }
    public static string[] SpRead(char c)
    {
        return Console.ReadLine().Split(c);
    }

}


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

const int MOD = 1000000007;

typedef pair<int, int> P;

int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) cin >> p[i].second >> p[i].first;
    sort(p.begin(), p.end());

    ll t = 0;
    rep(i, N) {
        t += p[i].second;
        if (t > p[i].first) {
            puts("No");
            return 0;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 1792
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <climits> // FOO_MAX, FOO_MIN
#include <cmath> 
#include <cstdlib> // abs(int)
#include <numeric>
#include <iomanip>
#include <map>
#include <set>

using namespace std;

#define roundup(n,d) ( ((n) + ((d)-1)) / (d) )
#define assign_max(into, compared) (into = max((into), (compared)))
#define assign_min(into, compared) (into = min((into), (compared)))
#define rep(i,n) for(long long i = 0;i < n;++i)
#define v_in(v) for(auto&& i : v) cin >> i
#define FAST_IO ios::sync_with_stdio(false); cin.tie(nullptr);
#define fix(n) fixed << setprecision(n)
#define ALL(v) v.begin(),v.end()

#define PI 3.14159265358979323846

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


int main(void){
    FAST_IO
    
    string s;
    ll n;
    cin >> n >> s;
    ll x = 0;
    ll max_x = 0;
    rep(i,n){
        if(s[i] == 'I'){
            x++;
        } else {
            x--;
        }
        assign_max(max_x,x);
    }
    cout << max_x << endl;
    return 0;
}

Measured memory_bytes: 3092
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String info = br.readLine();
		Integer witdh = Integer.parseInt(info.split(" ")[0]);
		Integer height = Integer.parseInt(info.split(" ")[1]);
		Integer x = Integer.parseInt(info.split(" ")[2]);
		Integer y = Integer.parseInt(info.split(" ")[3]);
		Integer r = Integer.parseInt(info.split(" ")[4]);
		if (witdh >= (x + r) && (x-r) >= 0 && height >= (y + r) && (y-r) >= 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}

Measured memory_bytes: 17088
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll; const ll MM = 1000000000;ll mod = MM + 7;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
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;}
const ll INF = 1LL << 60;

bool sort_p(pair<double, string> a, pair<double, string> b) {
    if(a.first != b.first) return a.first > b.first;
    else return a.second < b.second;
}

int main() {
    while(1) {
    int n; cin >> n;
    if(n == 0) return 0;
    vector<pair<double, string>> v(n);
    rep(i, n) {
        string l;
        double res;
        double p, a, b, c, d, e, f, s, m;
        cin >> l >> p >> a >> b >> c >> d >> e >> f >> s >> m;
        if(m == 1) res = (f*s - p) / (a+b+c+d+e);
        else res = (f*s*m - p) / (a+b+c+d*m+e*m);
        v[i].first = res;
        v[i].second = l;
    }
    sort(all(v), sort_p);
    rep(i, n) cout << v[i].second << endl;
    cout << '#' << endl;
    }
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define all(x) x.begin(), x.end()
#define reverse(x) reverse(x.begin(), x.end())
#define pb push_back
#define pii pair<int, int>
#define pll pair<long long,long long>
#define f first
#define s second
typedef long long ll;
const int mod = 1e9+7;
const int N = 1005;
using namespace std;
ll x, y, z ,K;
ll a[N], b[N], c[N], n;

int main(){
	ll i, j, k;
	cin >> x >> y >> z;
	cin >> K;
	for(i=0;i<x;i++)cin >> a[i];
	for(i=0;i<y;i++)cin >> b[i];
	for(i=0;i<z;i++)cin >> c[i];

	sort(a,a+x, greater<ll>());
	sort(b,b+y, greater<ll>());
	sort(c,c+z, greater<ll>());

	vector<ll> vec;
	for(i=0;i<x;i++){
		for(j=0;j<y;j++){
			for(k=0;k<z;k++){
				if((i+1)*(j+1)*(k+1) <= K)vec.pb(a[i]+b[j]+c[k]);
				else break;
			}
		}
	}
	sort(all(vec), greater<ll>());
	for(i=0;i<K;i++){
		printf("%lld\n",vec[i]);
	}
	return 0;
}


Measured memory_bytes: 1400
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-24 17:09:05
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << "\033[1m\033[36m" << #_ << ": " << (_) << "\033[0m" << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

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

  int m; cin >> m;
  int64 sum = 0;
  int64 digit = 0;

  for (int i = 0; i < m; ++i) {
    int64 d, c; cin >> d >> c;
    sum += d * c;
    digit += c;
  }

  //debug(sum); debug(digit_sum);

  cout << digit - 1 + (sum - 1) / 9 << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define MT make_tuple
#define MAXN 100001
#define MOD -1
#define INF 1e9+5
#define FastCin	ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef long long ll;

void swap(int *a, int *b){
    int t = *a;
    *a = *b; *b = t;
}

int main(){
    int n;
    vi h(MAXN, INF);
    vi dp(MAXN, INF);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf("%d", &h[i]);
    }
    dp[0] = 0;
    for(int i = 0; i < n; ++i){
        for(int j : {i+1, i+2}){
            if( j < n ){
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
    return 0;
}



Measured memory_bytes: 1024
N = gets.to_i
sum = 0
min = 100
N.times{
    s = gets.to_i
    sum += s
    if s % 10 != 0 && s < min
        min = s
    end
}
warn sum
if sum % 10 == 0
    sum -= min
    if sum % 10 == 0
        sum = 0
    end
end
puts sum


Measured memory_bytes: 3836
#include<map>
#include<cmath>
#include<stack>
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
template<class Read>void in(Read &x){
    x=0;
    int f=0;
    char ch=getchar();
    while(ch<'0'||ch>'9'){
        f|=(ch=='-');
        ch=getchar();
    }
    while(ch>='0'&&ch<='9'){
        x=(x<<1)+(x<<3)+(ch^48);
        ch=getchar();
    }
    x=f?-x:x;
    return;
}
const double M=1.000000000000;
int n;
double f[305][305][305];
double dfs(int x,int y,int z){
    if(x==0&&y==0&&z==0)return x;
    if(f[x][y][z]!=0)return f[x][y][z];
    double sum=M*n/(x+y+z);
    if(x>0)sum+=(1.0*x/(x+y+z))*dfs(x-1,y,z);
    if(y>0)sum+=(1.0*y/(x+y+z))*dfs(x+1,y-1,z);
    if(z>0)sum+=(1.0*z/(x+y+z))*dfs(x,y+1,z-1);
    f[x][y][z]=sum;
    return f[x][y][z];
}
int main(){
    in(n);
    int x=0,y=0,z=0;
    for(int i=1;i<=n;i++){
        int g;
        in(g);
        if(g==1)x++;
        if(g==2)y++;
        if(g==3)z++;
    }
    printf("%.10f\n",dfs(x,y,z));
	return 0;
}


Measured memory_bytes: 219392
def find_sum_of_digits(num)
  sum = 0
  while (num > 0)
    sum += num % 10
    num /= 10
  end

  sum
end

n, a, b = gets.chomp.split(" ").map(&:to_i)

total_sum = (1..n)
              .map { |i| [i, find_sum_of_digits(i)] }
              .select { |d| d[1] >= a && d[1] <= b }
              .inject(0) { |sum, d| sum + d[0] }

puts "#{total_sum}"


Measured memory_bytes: 2300
import heapq
n, m = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n):
    a[i] *= -1
heapq.heapify(a)
while(m):
    heapq.heapreplace(a, int(a[0] / 2))
    m -= 1
res = -sum(a)
print(res)

Measured memory_bytes: 14180
var n,i:Longint;s:array[0..99]of char;
begin
read(n);
if n=0 then begin
	writeln(0);
	exit;
end;
i:=0;
while n<>0 do begin
	if n mod 2=0 then s[i]:='0'
	else s[i]:='1';
	inc(i);
	if n>0 then n:=-(n div 2)
	else n:=-((n-1)div 2);
end;
while i>0 do begin
	dec(i);
	write(s[i]);
end;
end.


Measured memory_bytes: 128
main(){
  long long i,n,a,b,x,y,t=0;
  scanf("%ld%ld%ld%ld",&n,&a,&b,&x);
  for(i=0;i<n-1;i++){
    scanf("%ld",&y);
    t+=(a*(y-x)>b?b:a*(y-x));
    x=y;
  }
  printf("%ld",t);
}

Measured memory_bytes: 1660
n, k = map(int, input().split())

a = map(int, input().split())

res = 0
num = dict()

key = 0

for i in a:
    if i in num:
        num[i] += 1
    else:
        num[i] = 1
        key += 1

if key - k <= 0:
    print("0")
    exit(0)

num2 = sorted(num.items(), key = lambda x: x[1])

for i in range(key - k):
    res += num2[i][1]

print(res)

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

int main() {
  int A, B;
  cin >> A >> B;
  
  if((A + B) % 2 == 1) {
    cout << "IMPOSSIBLE" << endl;
  }
  
  else {
    cout << (A + B) / 2 << endl;
  }
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
#from math import gcd
import bisect
from collections import defaultdict
from collections import deque
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def I(): return int(input().strip())
def S(): return input().strip()
def IL(): return list(map(int,input().split()))
def SL(): return list(map(str,input().split()))
def ILs(n): return list(int(input()) for _ in range(n))
def SLs(n): return list(input().strip() for _ in range(n))
def ILL(n): return [list(map(int, input().split())) for _ in range(n)]
def SLL(n): return [list(map(str, input().split())) for _ in range(n)]

######OUTPUT######
def P(arg): print(arg); return
def Y(): print("Yes"); return
def N(): print("No"); return
def E(): exit()
def PE(arg): print(arg); exit()
def YE(): print("Yes"); exit()
def NE(): print("No"); exit()

#####Shorten#####
def DD(arg): return defaultdict(arg)


#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0: 
        cnt+=1 
        temp //= i
      arr.append([i, cnt])
  if temp!=1:
    arr.append([temp, 1])
  if arr==[]:
    arr.append([n, 1])
  return arr

#####MakeDivisors######
def make_divisors(n):
  divisors = []
  for i in range(1, int(n**0.5)+1):
    if n % i == 0:
      divisors.append(i)
      if i != n // i: 
        divisors.append(n//i)
  return divisors

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#####BitCount#####
def count_bit(n):
  count = 0
  while n:
    n &= n -1
    count += 1
  return count

#####ChangeBase#####
def base_10_to_n(X, n):
  if X//n:
    return base_10_to_n(X//n, n)+[X%n]
  return [X%n]

def base_n_to_10(X, n):
  return sum(int(str(X)[-i])*n**i for i in range(len(str(X))))

#####IntLog#####
def int_log(n, a):
  count = 0
  while n>=a:
    n //= a
    count += 1
  return count

#############
# Main Code #
#############

L,R = IL()
R = min(L+2019,R)
MIN = INF
for i in range(L,R+1):
  for j in range(i+1,R+1):
    MIN = min(MIN,(i*j)%2019)
print(MIN)

Measured memory_bytes: 3700
N = int(input())
a = list(map(int, input()))
if N == 2:
    print(abs(a[0]-a[1]))
    exit()
a1 = [abs(a[i]-a[i+1]) for i in range(N-1)]
if 1 in a1:
    s = 0
    for i in range(len(a1)):
        if ((len(a1)-1) | i) == (len(a1)-1):
            s += a1[i] % 2
    print(s % 2)
else:
    s = 0
    for i in range(len(a1)):
        if ((len(a1)-1) | i) == (len(a1)-1):
            s += a1[i] // 2
    print((s % 2) * 2)



Measured memory_bytes: 119716
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  V<> a(n); for (int i = 0; i < n; ++i) cin >> a[i];
  VV< V<double> > dp; assign(dp, n + 1, n + 1, n + 1, 0);
  int n1 = count(begin(a), end(a), 1);
  int n2 = count(begin(a), end(a), 2);
  int n3 = count(begin(a), end(a), 3);
  for (int i3 = 0; i3 <= n; ++i3) for (int i2 = 0; i2 <= n; ++i2) for (int i1 = 0; i1 <= n; ++i1) {
    if (i1 + i2 + i3 > n) continue;
    if (i1 > 0) dp[i1][i2][i3] += dp[i1 - 1][i2][i3] * i1 / n;
    if (i2 > 0) dp[i1][i2][i3] += dp[i1 + 1][i2 - 1][i3] * i2 / n;
    if (i3 > 0) dp[i1][i2][i3] += dp[i1][i2 + 1][i3 - 1] * i3 / n;
    if (i1 + i2 + i3) (dp[i1][i2][i3] += 1) *= 1.0 * n / (i1 + i2 + i3);
  }
  cout << fixed << setprecision(15) << dp[n1][n2][n3] << '\n';
}

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

using namespace std;

typedef long long int ll;

int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	int n, m, c = INT_MAX, d = 0;
	int a, b, x, y;
	
	cin >> n >> m;
	cin >> a >> b;
	
//	c = min(a, b);
//	d = max(a, b);
	
	for(int i = 0; i < m - 1; i++){
		cin >> x >> y;
		
//		c = min(min(x, y), c);
//		d = max(max(x, y), d);
		
		if(x >= a && y <= b){
			a = x, b = y;
		}
		else if(x >= a && y >= b){
			a = x;
		}
		else if(x <= a && y <= b){
			b = y;
		}
	}
	
	cout << max(b - a + 1, 0) << endl;
	
	return 0;
}

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

struct str{
	int x0;
	int y0;
	int dist;
};
bool operator<(str a, str b)
{
	return a.dist>b.dist;
}

std::priority_queue<str> Q;
int x[2500010],check[510][510],check2[510][510];
int direX[5]={1,0,-1,0},direY[5]={0,1,0,-1};
int main()
{
	int a;
	scanf("%d",&a);
	for(int i=1;i<=a*a;i++) scanf("%d",&x[i]);
	for(int i=1;i<=a;i++)
	{
		for(int j=1;j<=a;j++)
		{
			int s1 = (i-1)<(a-i)?(i-1):(a-i);
			int s2 = (j-1)<(a-j)?(j-1):(a-j);
			check[i][j] = s1<s2?s1:s2;
			check2[i][j] = 1;
		}
	}
	
	long long int sum = 0;
	for(int i=1;i<=a*a;i++)
	{
		int s = (x[i]-1)/a+1;
		int t = (x[i]-1)%a+1;
		check2[s][t] = 0;
		sum += check[s][t];
		
		for(int j=0;j<4;j++)
		{
			if(check[s][t] < check[s+direX[j]][t+direY[j]])
			{
				check[s+direX[j]][t+direY[j]] = check[s][t];
				Q.push({s+direX[j],t+direY[j],check[s][t]});
			}
		}
		while(!Q.empty())
		{
			int x0 = Q.top().x0;
			int y0 = Q.top().y0;
			int dist = Q.top().dist;
			Q.pop();
			
			for(int j=0;j<4;j++)
			{
				if(check[x0][y0]+check2[x0][y0] < check[x0+direX[j]][y0+direY[j]])
				{
					check[x0+direX[j]][y0+direY[j]] = check[x0][y0]+check2[x0][y0];
					Q.push({x0+direX[j],y0+direY[j],check[x0][y0]+check2[x0][y0]});
				}
			}
		}
	}
	printf("%lld",sum);
}

Measured memory_bytes: 7316
#include "bits/stdc++.h"

using namespace std;

int main() {
    /*int A,B,C,D,seconds,minutes;
    cin >> A >> B >> C >> D;
    seconds = A + B + C + D;
    minutes = seconds / 60;
    seconds = seconds - minutes *60;
    cout << minutes << endl << seconds << endl;*/
    
    /*int AB,BC,CA,answer;
    cin >> AB >> BC >> CA;
    answer = AB * BC / 2;
    cout << answer << endl;*/
    
    int X,Y,sum;
    cin >> X >> Y;
    sum = X + Y/2;
    cout << sum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>
#include<list>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

ll mypow(ll x,ll n,ll mod = MOD){
    ll ret = 1;
    while(n > 0){
        if(n&1){
            ret = (ret*x)%mod;
        }
        x = (x*x)%mod;
        n >>= 1;
    }
    return ret;
}

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

ll twoPow(ll shiftNum){
    return (1LL << (shiftNum - 1));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
 
    ll n,m;
    cin >> n >> m;

    vector<ll> a(m),b(m);
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
    }

    ll s,t;
    cin >> s >> t;

    vector<list<ll>> edge(n+1);
    for(int i = 0; i < m; i++){
        edge[a[i]].push_back(b[i]);
    }

    

    vector<vector<ll>> vertex(n+1,vector<ll>(3,INF));

    vertex[s][0] = 0;

    priority_queue<tuple<ll,ll,ll>,vector<tuple<ll,ll,ll>>,greater<tuple<ll,ll,ll>>> pq;

    pq.push(make_tuple(0,s,0));

    vector<vector<bool>> used(n+1,vector<bool>(3,false));

    while(!pq.empty()){
        auto x = pq.top();
        pq.pop();
        ll dist = get<0>(x);
        ll v = get<1>(x);
        ll state = get<2>(x);
        if(used[v][state]){
            continue;
        }
        used[v][state] = true;
        for(auto itr = edge[v].begin(); itr != edge[v].end(); itr++){
            if(state != 2){
                if(!used[*itr][state+1] && dist < vertex[*itr][state+1]){
                    vertex[*itr][state+1] = dist;
                    pq.push(make_tuple(dist,*itr,state+1));
                }
            }else{
                if(!used[*itr][0] && dist + 1 < vertex[*itr][0]){
                    vertex[*itr][0] = dist + 1;
                    pq.push(make_tuple(dist+1,*itr,0));
                }
            }
        }
    }

    if(vertex[t][0] < INF){
        cout << vertex[t][0] << endl;
    }else{
        cout << -1 << endl;
    }

    

    return 0;
}

Measured memory_bytes: 19072
#include <bits/stdc++.h>
using namespace std;
/* 
   kD_Tree
   build:O(n log^2(n))
   search:O(n^(1-1/K)+A)
   K:次元数 A:領域に含まれる点の数
*/


/*AOJのkD_Treeが消えたため正しく動くか未検証だが多分大丈夫*/
class KDT{
public:
  typedef long long ll; /*型に注意!!!!*/
  struct node{
    vector<ll> point;
    int l,r;
    node(){}
    node(vector<ll> point):point(point){l=r=-1;}
  };
  int K;// K:次元数
  vector<vector<ll> > P;// それぞれの要素はK+1個(各次元の値と固有ID)
  vector<node> G;
  int ok = 0;

  KDT(int K=2):K(K),ok(0){};
  
  void add_point(vector<ll> a/*座標*/){ 
    static int id = 0;
    if((int)a.size() < K+1) a.push_back(id++);
    assert((int)a.size() == K+1);
    P.push_back(a);
  }
  
  int build(int depth=0,int l=0,int r=-2){
    if(r == -2) r = (int)P.size()-1,ok = 1;
    if(l>r) return -1;
    int D=depth%K; // D:ソートする基準の次元
    sort(P.begin()+l,P.begin()+r+1,[&](const vector<ll> &A,const vector<ll> &B){return A[D]<B[D];});

    int m=(l+r)/2,res=G.size();
    G.push_back(node(P[m]));
    int vl=build(depth+1,l,m-1);
    int vr=build(depth+1,m+1,r);
    G[res].l=vl; G[res].r=vr;
    return res;
  }

  vector<vector<ll> > points;//searchの座標集合と固有ID
  void search(int x,int depth,const vector<ll> &ld,const vector<ll> &ru){
    if(P.empty()) return;
    bool f=true;
    for(int i=0;i<K;i++)
      if(G[x].point[i]<ld[i]||ru[i]<G[x].point[i]) f=false;
    
    if(f) points.push_back(G[x].point);
    
    int D = depth%K;// D:ソートする基準の次元
    if(G[x].point[D]<=ru[D]&&G[x].r!=-1) search(G[x].r,depth+1,ld,ru);
    if(ld[D]<=G[x].point[D]&&G[x].l!=-1) search(G[x].l,depth+1,ld,ru);
  }

  
  //[0,K)の要素が座標,K番目の要素が固有IDになっている。
  vector<vector<ll> > search(vector<ll> ld/*左下*/,vector<ll> ru/*右上*/){
    assert(ok);
    points.clear();
    search(0,0,ld,ru);
    return points;
  }
};

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

  KDT kdt;
  for(int i=0;i<n;i++){
    int x,y;
    scanf("%d%d",&x,&y);
    kdt.add_point({x,y});
  }

  kdt.build();
  int q;
  cin>>q;
  while(q--){
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    auto point = kdt.search({a,c},{b,d});
    vector<int> ans;
    for(auto &p:point) ans.push_back(p.back());
    sort(ans.begin(),ans.end());
    for(int i=0;i<(int)ans.size();i++) printf("%d\n",ans[i]);
    cout<<endl;

  }
  
}



Measured memory_bytes: 60128
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define all(v) (v).begin(),(v).end()
#define endl "\n"
#define deb(x) cout<<#x<<" : "<<x<<endl;
template<class A>ostream&operator<<(ostream&out,const vector<A>&a){for(const A &it:a)out<<it<<" ";return out;}
template<class A>istream&operator>>(istream&in,vector<A>&a){for(A &i:a)in>>i;return in;}


signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    
    int n,m;
    cin>>n>>m;

    string a = string(n,(char)m+'0');
    string b = string(m,(char)n+'0');

    cout<<min(a,b)<<endl;

}

Measured memory_bytes: 256
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    S=input()
    
    if "RRR" in S:
        print(3)
    elif "RR" in S:
        print(2)
    elif "R" in S:
        print(1)
    else:
        print(0)

main()


Measured memory_bytes: 61716
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>

using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

int main() {
    // 入力
    double A;
    double B;
    cin >> A >> B;
//    double b = B*100;
//    ll out = A*(ll)b/100;
    double out = A*B;
    cout << (ll)out << endl;
    return 0;
}


Measured memory_bytes: 3724
M=10**9+7
H=Hash.new{_1[_2]=0,0}
$<.drop(s=o=1).map{a,b=_1.split.map &:to_r
b==0?a==0?o-=1:H[b][1]+=1:a*b<0?H[-b/a][1]+=1:H[a/b][0]+=1}
H.map{|v|v[t=-1].map{t+=2.pow _1,M};s=s*t%M}
p (s-o)%M

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

using namespace std;

typedef long long ll;

const int MAX_N = 123;
const ll MOD = 1e9 + 7;

ll sq(ll x) { return x * x % MOD; }
ll qpow(ll a, ll b) { return b ? sq(qpow(a, b / 2)) * (b & 1 ? a : 1) % MOD : 1; }
ll inv(ll x) { return qpow(x, MOD - 2); }

int N, H[MAX_N];
ll F[MAX_N];

int main() {
    scanf("%d", &N);
    for (int i = 1; i <= N; i++) scanf("%d", &H[i]);
    H[0] = H[N + 1] = 1;
    F[0] = 2;
    for (int i = 1; i <= N; i++) {
        ll sum = 0; int prev = H[i + 1];
        for (int j = i; j; j--) {
            int l = max(H[j - 1], prev), r = H[j];
            if (r > l) {
                sum += r - l;
            }
            prev = min(prev, H[j]);
            (F[i] += F[j - 1] * qpow(2, sum)) %= MOD;
        }
    }
    printf("%lld\n", F[N]);
}


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

void solve(long long M)
{
    cout << 48 - M << endl;
}

// Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long M;
    scanf("%lld", &M);
    solve(M);
    return 0;
}


Measured memory_bytes: 256