akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);

int main() {
    ll n,k;
    cin>>n>>k;
    vector<ll> a(n);
    priority_queue<ll> q;
    vector<ll> f(n);

    vector<ll> fa(n);
    rep(i,n){cin>>a[i];}
    rep(i,n){cin>>f[i];}

    sort(a.rbegin(),a.rend());
    sort(f.begin(),f.end());
    rep(i,n){fa[i]=a[i]*f[i];}

    ll up = 1000000000001;
    ll down = 0;
    int nibu = 0;
    auto check =
            [&](ll med)-> ll{
                ll kk = k;
                bool flag=true;
                for(int j=0;j<n;j++){
                    ll kai = f[j]*a[j];
                    if(med<kai){
                        ll hiku = a[j]-(med/f[j]);
                        //ll hiku = (a[j]*f[j]-med-1)/f[j]+1;
                        kk-=hiku;
                        if(kk<0){
                            flag = false;
                            break;
                        }
                    }
                }
                return flag;

    };





    while(nibu<100){
        // cout<<up<<" "<<down<<endl;
        nibu++;
        ll med = (up+down)/2;
        if(check(med)){
            up = med;
        }else{

            down = med;
        }
    }
    cout<<up<<endl;








    return 0;
}


Measured memory_bytes: 4992
n = int(input())
s = str(input())
right = 0
left  = 0
a = ""
for i in range(n):
    if s[i]=="(":
        right +=1
    else:
        if right > 0:
            right -=1
        else:
            a +="("
ans = a + s + ")"*right
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define vec vector<int>
#define fo(i, n) for (int i = 0; i < n; i++)
#define foo(i, a, b) for (int i = a; i < b; i++)
#define mp make_pair
#define deb(x) cout << #x << "-->" << x << endl;
#define deb1a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        cout << it << " ";        \
    }                             \
    cout << endl;
#define deb2a(v)                  \
    cout << #v << "--->" << endl; \
    for (auto it : v)             \
    {                             \
        for (auto it1 : it)       \
        {                         \
            cout << it1 << " ";   \
        }                         \
        cout << endl;             \
    }
    #define mod 998244353
 
#define fi first
#define se second
int32_t main() 
{
   int n;
   cin >> n;
   while(n--)
   {
       int x;
       cin >> x;
       if(x%2==0){
           if(x%3!=0&&x%5!=0)
           {
               cout << "DENIED";
               return 0;
           }
       }
   }
   cout << "APPROVED";
} 


Measured memory_bytes: 256
a,b = map(int,input().split())
s = input()
num = [0,1,2,3,4,5,6,7,8,9]
num = list(map(lambda x: str(x), num))
for i in range(a):
    if s[i] not in num:
        print("No")
        exit()
for i in range(a+1,a+b+1):
    if s[i] not in num:
        print("No")
        exit()
if s[a] != "-":
    print("No")
    exit()
print("Yes")



Measured memory_bytes: 38436
import java.util.*;


import java.io.*;



public class Main 
{   
	static int dp[];
	public static void main(String[] args) throws IOException 
	{ 
		Scanner s=new Scanner(System.in);
		int n=s.nextInt();
		int k=s.nextInt();
		int ar[]=new int[n];
		
		for(int i=0;i<n;i++)
			ar[i]=s.nextInt();
		
		
		int dp[]=new int[n];
		Arrays.fill(dp, Integer.MAX_VALUE);
		
		dp[0]=0;
		dp[1]=Math.abs(ar[1]-ar[0]);
		for(int i=2;i<n;i++) {
			for(int j=1;j<=k;j++) {
				if(i-j>=0)
				dp[i]=Math.min(dp[i],dp[i-j]+Math.abs(ar[i]-ar[i-j]));
				
			}
			
		}
		System.out.println(dp[n-1]);

	}
}

Measured memory_bytes: 51492
#! usr/bin/env python
# -*- coding: utf-8 -*-


def main():
    n = int(input())
    w = [input() for i in range(n)]

    w_set = set()
    for i in range(n):
        if i == 0:
            w_set.add(w[i])
        else:
            wi, wii = w[i][-1], w[i-1][0]
            if w[i][0] == w[i-1][-1] and w[i] not in w_set:
                w_set.add(w[i])
            else:
                print("No")
                exit()

    print("Yes")



if __name__ == '__main__':
    main()


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

using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
	REP(i, v.size()) { if (i)os << " "; os << v[i]; }return os;
}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
	REP(i, v.size()) { if (i)os << endl; os << v[i]; }return os;
}

const ll INF = LLONG_MAX;
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

#define int long long

inline void my_io() {

	std::ios::sync_with_stdio(false);

	std::cin.tie(0);

	cout << fixed << setprecision(16);

	//cout << setprecision(10) << scientific << ans << endl;
}

signed main() {
	ll a, b;

	cin >> a >> b;

	cout << ceil((a + b) / 2.0) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
 int num=0,i;
 char buf[1000];
  
  fgets(buf,sizeof(buf),stdin);
  for(i=0;i<3;i++){
  if(buf[i] == '1') num++;
  }
  printf("%d",num);
 
  return 0;
}

Measured memory_bytes: 128
Module Module1

    Sub Main()
        'let
        Dim tmp As String() = Split(Console.ReadLine())
        Dim a As Long = tmp(0)
        Dim b As Long = tmp(1)

        'var
        Dim ans As String

        ans = If(a Mod 2 = 0 Or b Mod 2 = 0, "Even", "Odd")
        Console.WriteLine(ans)

    End Sub

End Module

Measured memory_bytes: 13536
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr long long INF = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



signed main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
   string s;
   cin>>s;
   cout << s[0];
   cout << s.size()-2;
   cout << s[s.size()-1];
   cout << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
bool news[4];

int main(){
  string str;

  cin >> str;
  for(int i = 0; i < str.size(); i++){
    if( str[i] == 'N' ) news[0] = true;
    if( str[i] == 'E' ) news[1] = true;
    if( str[i] == 'W' ) news[2] = true;
    if( str[i] == 'S' ) news[3] = true;
  }
  if( news[0] && news[1] && news[2] && news[3] ||
      news[0] && (!news[1]) && (!news[2]) && news[3] ||
      (!news[0]) && news[1] && news[2] && (!news[3])  ){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		int n = s.length;
		int[] a = new int[128];
		for(int i=0;i<n;i++) {
			a[s[i]]++;
		}
		int odd = 0;
		int sum = 0;
		for(int i=0;i<128;i++) {
			if (a[i] % 2 == 1) {
				odd++;
				a[i]--;
			}
			a[i] /= 2;
			sum += a[i];
		}
		if (odd >= 2) {
			System.out.println(0);
			return;
		}
		long[] fact = new long[41];
		fact[0] = 1;
		for(int i=1;i<=40;i++) {
			fact[i] = fact[i-1] * i;
		}
		long ans = fact[sum];
		for(int i=0;i<128;i++) {
			ans /= fact[a[i]];
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 17324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const static ll MOD = 1e9+7;
const static ll INF = 1e14;

ll N;
vector<vector<ll>> V(17, vector<ll>(17));
vector<ll> DP;

int main() {
    cin >> N;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            cin >> V[i][j];
        }
    }
    DP.resize(1<<N);
    for(int i = 0; i < (1<< N); i++){
        bitset<17> B = i;
        ll score = 0;
        for(int i = 0; i < N; i++){
            for(int j = i; j < N; j++){
                if(B[i] == 1 && B[j] == 1) score += V[i][j];
            }
        }
        DP[i] = score;
    }
    for(int i1 = 0; i1 < (1<<N); i1++){
        bitset<17> B = i1;
        ll cnt = B.count();
            for(int t = i1; t > 0; t = (t-1)&i1){
            //for(int t = (i1-1)&i1; t > 0; t = (t-1)&i1){
                DP[i1] = max(DP[i1], DP[t]+DP[i1-t]);
            }
    }
    cout << DP[(1<<N)-1] << endl;

}


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

int distance(int x, int y, int i, int j) {
    return min(abs(j-i), min(abs(x-i)+1+abs(j-y), abs(y-i)+1+abs(j-x)));
}

void solve() {
    int n, x, y;
    cin>>n>>x>>y;
    vector<int> v(n);
    for(auto &i : v) cin>>i;
    vector<int> ans(n+1);
    for(int i=1; i<n; ++i) {
        for(int j=i+1; j<=n; ++j) {
            //cout<<i<<":"<<j<<" "<<distance(x,y,i,j)<<"\n";
            ans[distance(x,y,i,j)]++;
        }
    }
    for(int i=1; i<n; ++i) cout<<ans[i]<<"\n";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}

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

const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main(void){
    ll n;
    cin>>n;
    mint sum=0;
    mint ans=0;
    vector<mint>a(n);
    rep(i,n){
        cin>>a[i];
        sum+=a[i];
    }
    rep(i,n){
        sum=sum-a[i];
        ans+=a[i]*sum;
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 4760
using System;
using System.Linq;
namespace Sample
{
  class Sample
  {
    static void Main(string[] args)
    {
    int N=int.Parse(Console.ReadLine());
    int tmp=N;
      int ans=0;
      while(tmp>=3){
       tmp-=3;
        ans++;
      }
      Console.WriteLine(ans);
    }
    
  }

}


Measured memory_bytes: 27532
#include<iostream>
using namespace std;
int main(){
    int n[101];
    int i;
    int num;
    cin >> num;
    for(i=0;i<num;i++)cin >> n[i];
    cout << n[num-1];
    for(i=1;i<num;i++)cout << " " << n[num-i-1];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3092
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
	"strings"
)

func main() {
	n := readi()
	k := readi()

	n = n % k
	fmt.Println(min(n, abs(n-k)))
}

func aokiOne(a, b int) int {
	return abs(a - b)
}

// IO---------------------------------------------------

func readi() (n int) {
	fmt.Scan(&n)
	return
}

func readf() (n float64) {
	fmt.Scan(&n)
	return
}

func reads() (n string) {
	fmt.Scan(&n)
	return
}

var rdr = bufio.NewReaderSize(os.Stdin, 1000000)

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func readSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func readSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func readFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func yesOrNo(b bool) {
	if b {
		fmt.Println("Yes")
		return
	}
	fmt.Println("No")
}

func yesorNO(b bool) {
	if b {
		fmt.Println("YES")
		return
	}
	fmt.Println("NO")
}

func yesorno(b bool) {
	if b {
		fmt.Println("yes")
		return
	}
	fmt.Println("no")
}

// calc---------------------------------------------------

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

func ave(a []int) (ave int) {
	for i := 0; i < len(a); i++ {
		ave += a[i]
	}
	ave /= len(a)
	return
}

func eq(a []string, b []string) bool {
	for i := 0; i < len(a); i++ {
		if a[i] != b[i] {
			return false
		}
	}
	return true
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func mid(a []int) int {
	sort.Ints(a)
	return a[len(a)/2]
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

using namespace std;

int main()
{
	cin.sync_with_stdio(false);

	int N;
	cin >> N;
	long long int p = 1;
	int count = 0;
	for (int i = 0;i < N;i++) {
		p = p*(i + 1);
		if (p > 1000000000+7) {
			p = p % (1000000000+7);
		}
	}
	p=p% (1000000000 + 7);
	cout << p << endl;

	return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int[] nr = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
        int N = nr[0];
        int R = nr[1];
        if (N < 10)
        {
            Console.WriteLine(R + 100 * (10 - N));
            return;
        }
        Console.WriteLine(R);
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  bool l=true;
  vector <int>vec(N);
  for (int X=0; X<N; X++){
    cin >> vec.at(X);
    if (vec.at(X)%2==0){
      if (vec.at(X)%3!=0 && vec.at(X)%5!=0){
        l=false;
      }
    }
  }
  if (l==false){
    cout << "DENIED" << endl;
  }
  else {
    cout << "APPROVED" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
 
using namespace std;
 
using ll = long long;
 
ll factorial(ll x) {
    if (x==0 || x==1) return 1;
    return ((x % 1000000007) * factorial(x-1)) % 1000000007;
}
 
int main() {
    ll n, m;
    cin >> n >> m;
    ll a = max(n, m);
    ll b = min(n, m);
    if ( a > b+1 ) {
        cout << 0 << endl;
    } else if ( a == b+1 ) {
        ll temp = factorial(b);
        cout << (temp* ((temp*a)%1000000007) ) % 1000000007 << endl;
    } else if(a == b) {
        ll temp = factorial(b);
        cout << (temp*temp*2)% 1000000007 << endl;
    }
}

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

using namespace std;

typedef long long int ll;
ll mabs(ll p){if(p>=0)return p; return -p;}

int main()
{
    ll a,b,c,k;
    ll s = 100000000000000000;
    scanf("%lld%lld%lld%lld",&a,&b,&c,&k);

    if(mabs(a-b)>=s)printf("Unfair");
    if(k%2)printf("%lld",b-a);
    else printf("%lld",a-b);

    return 0;
}


Measured memory_bytes: 256
/* Manish Pant - insider_pants */
    
#include <bits/stdc++.h>
using namespace std;
    
#define F first
#define S second
#define endl "\n"
#define pb push_back
    
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
    
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 2e5 + 5;
vector<ll> modulo(N, -1);
int n, p;
string s;

ll power(ll x, ll y, ll p)  
{  
    ll res = 1;     // Initialize result  
  
    x = x % p; // Update x if it is more than or  
                // equal to p  
  
    while (y > 0)  
    {  
        // If y is odd, multiply x with result  
        if (y & 1)  
            res = (res*x) % p;  
  
        // y must be even now  
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}  

void solve()
{
    if(p == 2 || p == 5)
    {
        ll ans = 0;
        for(int i = 0; i < n; i++)
        {
            if((s[i] - '0') % p == 0) ans += i + 1;
        }
        cout<<ans<<endl;
        return;
    }
    
    reverse(s.begin(), s.end());
    ll sum = 0;
    for(int i = 0; i < n; i++)
    {
        ll t = power(10, i, p);
        t *= (s[i] - '0');
        t %= p;
        sum += t;
        sum %= p;
        modulo[i] = sum;
    }

    map<ll, ll> m;
    m[0] = 1;
    ll ans = 0; 
    for(int i = 0; i < n; i++)
    {
        ll val = modulo[i];
        ans += m[val];
        m[val]++;
    }
    cout<<ans<<endl;
}

int main()
{
    fast();
    cin>>n>>p>>s;
    solve();
}

Measured memory_bytes: 2580
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

template <class T>
struct fenwick {
    vector<T> node;
    int n;

    fenwick(int _n)
        : n(_n) {
        node.resize(n);
    }

    void add(int x, T v) {
        while (x < n) {
            node[x] += v;
            x |= (x + 1);
        }
    }
    T get(int x) {  // [0, x]
        T v = 0;
        while (x >= 0) {
            v += node[x];
            x = (x & (x + 1)) - 1;
        }
        return v;
    }
    T get(int x, int y) {  // [x, y]
        return (get(y) - (x ? get(x - 1) : 0));
    }
    int lower_bound(T v) {
        int x = 0;
        int h = 1;
        while (n >= (h << 1)) {
            h <<= 1;
        }
        for (int k = h; k > 0; k >>= 1) {
            if (x + k <= n && node[x + k - 1] < v) {
                v -= node[x + k - 1];
                x += k;
            }
        }
        return x;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;
    vector<int> c(n);
    for (int i = 0; i < n; i++) {
        cin >> c[i];
        c[i]--;
    }
    vector<int> l(q), r(q);
    for (int i = 0; i < q; i++) {
        cin >> l[i] >> r[i];
        l[i]--, r[i]--;
    }
    vector<int> que(q);
    iota(que.begin(), que.end(), 0);
    sort(que.begin(), que.end(), [&](int i, int j) { return (r[i] == r[j] ? l[i] < l[j] : r[i] < r[j]); });
    vector<int> ans(q);
    vector<int> lst(n, -1);
    fenwick<int> bt(n);
    int j = -1;
    for (int i : que) {
        while (j < r[i]) {
            j++;
            if (lst[c[j]] != -1) {
                bt.add(lst[c[j]], -1);
            }
            lst[c[j]] = j;
            bt.add(j, 1);
        }
        ans[i] = bt.get(l[i], r[i]);
    }
    for (int i : ans) {
        cout << i << '\n';
    }
    return 0;
}

Measured memory_bytes: 17460
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int W = sc.nextInt();
		int h = sc.nextInt();
		int w = sc.nextInt();
		int ans = (H - h) * (W - w);
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

c1, c2 = [list(readline().decode().rstrip()) for _ in range(2)]
ans = 'YES' if c1 == c2[::-1] and c2 == c1[::-1] else 'NO'
print(ans)

Measured memory_bytes: 3060
//
// Created by 李青坪 on 2018/10/5.
//

#include "cstdio"

using namespace std;

int cmp(int a, int b){
    if (a == b) return 0;
    else return a > b ? 1: -1;
}
int binarySearch(int S[], int size, int key){
    int high = size - 1;
    int low = 0;
    int mid = (high + low)/2;
    while (low <= high){
        if (cmp(S[mid], key) == -1){
            low = mid + 1;
        } else if (cmp(S[mid], key)){
            high = mid - 1;
        } else return 1;
        mid = (high + low )/2;
    }
    return 0;
}


int main(){
    int n, q;
    scanf("%d", &n);
    int S[n];
    for (int i = 0; i < n; ++i) {
        scanf("%d", &S[i]);
    }
    scanf("%d", &q);
    int key, count = 0;
    for (int j = 0; j < q; ++j) {
        scanf("%d", &key);
        if (binarySearch(S, n, key)) ++count;
    }
    printf("%d\n", count);
}


Measured memory_bytes: 3156
#include <stdio.h>
int main(void){
    // Your code here!
    long long x;
    long long cnt;
    int rem;
    
    scanf("%lld",&x);
    
    rem = x % 11;
    cnt = (x / 11)*2;
    
    if(rem == 0);
    else if(rem <= 6){
        cnt += 1;
    }
    else if(rem <= 10){
        cnt += 2;
    }
    
    printf("%lld\n",cnt);
}


Measured memory_bytes: 128
#include <iostream> // cout, endl, cin
#include <iomanip>
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <numeric>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
const int INF = 1001001001;
const int BG = 1000000007;

int main()
{
    int a, b, c;
    cin >> a >> b >> c;
    if (b - a == c - b)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <istream>
using namespace std;

int main()
{
    int N, M;
    cin >> N >> M;

    vector<pair<int, int>> AB(N);

    for (int i = 0; i < N; i++)
    {
        cin >> AB[i].first >> AB[i].second;
    }

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

    long long ans = 0;

    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j < AB[i].second; j++)
        {
            ans += AB[i].first;
            M--;

            if (M == 0)
            {
                break;
            }
        }
        if (M == 0)
        {
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse2")

#include<bits/stdc++.h>
using namespace std;

#define int         long long
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define mp          make_pair
#define all(a)      (a).begin(),(a).end()
#define FF           first
#define SS           second
#define sz(x)       (int)x.size()
#define endl        '\n'
//#define hell          1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
// mp::cpp_int
//#define pp pair<pii,pii>
const int hell=1000000007;



int power(int a,int b)
{
  if(b==0)return 1;
  if(b==1)return a;
  int t=power(a,b/2);
  t%=hell;
  t*=t;
  t%=hell;
  if(b%2)return (t*a)%hell;
  else
     return t;
}


int solve( ){


int n,m;
cin>>n>>m;

vi a(n);
rep(i,0,n)cin>>a[i];
sort(all(a));
vii v(m);
rep(i,0,m)cin>>v[i].SS>>v[i].FF;
sort(all(v));
reverse(all(v));
int pos=0;
rep(i,0,m)
{
   for(int j=pos;j<pos+v[i].SS;j++)
   {
    if(a[j]<v[i].FF)
    {
      a[j]=v[i].FF;
    }
    else
    {
      int sum=0;
      rep(i,0,n)sum+=a[i];
      cout<<sum;
      return 0;
    }
   }
   pos=pos+v[i].SS;

}

 int sum=0;
      rep(i,0,n)sum+=a[i];
      cout<<sum;



return 0;
}

signed main()
{  int t=1;
 ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   cin.exceptions(cin.failbit);                                                                    


  clock_t time_req;

    // Without using pow function
                                                                                                                   

   // cin>>t;

    int k=1;
   while(t--)
     {
       //cout<<"case #"<<k<<":"<<" ";k++;
      solve();
     }

         time_req = clock() - time_req;
    //cout <<endl<< "Processor time taken is "
      //<< (double)time_req/CLOCKS_PER_SEC << " seconds" << endl;


    return 0;
} 

Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, res = 0;
    int home[1000];

    cin >> n;

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

    sort(home, home+n);

    for (int i=1; i<n; i++) {
        res += home[i] - home[i-1];
    }

    cout << res << endl;

    return 0;
}

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

using lint = long long;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<vector<T>>;
template <typename T> using VVV = vector<vector<vector<T>>>;
#define rep(i, n) for(int i = 0; i < int(n); i++)
#define repu(i, a, b, s) for(int i = int(a); i < int(b); i += int(s))
#define repd(i, a, b, s) for(int i = int(a); i > int(b); i += int(s))
#define endl "\n"
constexpr lint INF = 2e18;
constexpr lint MOD = 1e9 + 7;

void solve() {
    lint K;
    cin >> K;

    lint ans;
    if(K % 2 == 0) {
        ans = (K / 2) * (K / 2);
    } else {
        ans = (K / 2) * (K / 2 + 1);
    }

    cout << ans << endl;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    solve();
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    auto ans = 'x';
    if (a + b == 15) {
        ans = '+';
    } else if (a * b == 15) {
        ans = '*';
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.range, std.algorithm, std.container;
import std.math, std.random, std.bigint, std.datetime, std.format;
void main(string[] args){ if(args.length > 1) if(args[1] == "-debug") DEBUG = 1; solve(); } bool DEBUG = 0; 
void log(A ...)(lazy A a){ if(DEBUG) print(a); }
void print(){ writeln(""); } void print(T)(T t){ writeln(t); } void print(T, A ...)(T t, A a){ write(t, " "), print(a); }
string unsplit(T)(T xs){ return xs.array.to!(string[]).join(" "); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; } T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
T lowerTo(T)(ref T x, T y){ if(x > y) x = y; return x; } T raiseTo(T)(ref T x, T y){ if(x < y) x = y; return x; }

// ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- ----- //

void solve(){
    long k = scan!long;
    int q = scan!int;
    long[] ds = scan!long(k.to!int);
    foreach(_; 0 .. q){
        long n = scan!long, x = scan!long, m = scan!long;
        log("n:", n, "x:", x, "m:", m);

        long[] us;
        foreach(d; ds) us ~= (d % m)? (d % m): m;
        log("us:", us);

        long[] sums = [0];
        foreach(u; us) sums ~= sums[$ - 1] + u;
        log("sums:", sums);

        long sum = (x % m) + sums[k] * ((n - 1) / k) + sums[(n - 1) % k];
        log("sum:", sum);

        ((n - 1) - sum / m).print;
    }
}

/*
ds を m でわった余りにしておく。ただし余り 0 の場合は m にする。
ds の和を考える。sums とする。ただし n 項なので実際には計算はできない。
求めるものは sums[j] / m < sums[j + 1] / m となる回数を n からひいたもの。
それは n - sums[n] / m に他ならない。
sums[n] は、sums[k] * (n / k) + sums[n % k] で計算できる。
*/

Measured memory_bytes: 5372
n_1=input()
n_1_List=map(int,raw_input().split())
n_2=input()
n_2_List=map(int,raw_input().split())
n_1_List=set(n_1_List)
n_2_List=set(n_2_List)
print(len(n_1_List.intersection(n_2_List)))

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

/*==============変数宣言==============*/
int N;
const int M = 26;
int n;
int m = M;
const int def = 1000000;

int c[30];
int s[400][30];

void input(){
	scanf("%d", &N);
	n = N;

	for(int i = 0;i < M;i++) scanf("%d", &c[i]);

	for(int i = 0;i < N;i++)
		for(int j = 0;j < M;j++)
			scanf("%d", &s[i][j]);
	
	return;
}

/*================関数================*/
struct RandomNumberGenerator {
  mt19937 mt;

  RandomNumberGenerator() : mt(chrono::steady_clock::now().time_since_epoch().count()) {}

  int operator()(int a, int b) { // [a, b)
    uniform_int_distribution< int > dist(a, b - 1);
    return dist(mt);
  }

  int operator()(int b) { // [0, b)
    return (*this)(0, b);
  }
};

struct Timer {
  chrono::high_resolution_clock::time_point st;

  Timer() { reset(); }

  void reset() {
    st = chrono::high_resolution_clock::now();
  }

  chrono::milliseconds::rep get() {
    auto ed = chrono::high_resolution_clock::now();
    return chrono::duration_cast< chrono::milliseconds >(ed - st).count();
  }
};

Timer timer;
RandomNumberGenerator rnd;
/*====================================*/



void init(){
	input();
	return;
}


void output(short ans[]){
	for(int i = 0;i < n;i++){
		printf("%d\n", ans[i]+1);
	}
}

int sum(int i){
	return (i*(i+1))/2;
}

int getScore(short a[]){
	int last[30] = {};
	int ans = 0;
	for(int i = 0;i < n;i++){
		ans += s[i][a[i]]; 
		ans -= c[a[i]] * sum(i-last[a[i]]);
		last[a[i]] = i+1;
	}
	for(int j = 0;j < m;j++){
		ans -= c[j] * sum(n-last[j]);
	}
	return ans;
}

int main(){
	init();

	short now[365];
	short ans[365]; 

	for(int i = 0;i < n;i++){
		ans[i] = now[i] = rnd(26); 
	}

	int ans_score = getScore(ans);

	int fin = 1800;
	const double C = fin*1000.0;

	int now_time = 0;
	int AS = ans_score;
	short ANS[365];
	while((now_time = timer.get()) < fin){
		int idx = rnd(365);
		int old = now[idx];
		int nxt = rnd(26);
		if(now[idx] == nxt) continue;
		now[idx] = nxt;
		int now_score = getScore(now);

		double r = rnd(100000)/100000.0;

		double line = (fin-now_time)/C; 

		if(ans_score <= now_score || line > r){
			ans[idx] = nxt;
			ans_score = now_score;
			if(AS < ans_score){
				memcpy(ANS, ans, sizeof(ans));
				AS = ans_score;
				//cerr << AS << endl;
			}
		}else{
			now[idx] = old; 
		}
	}


	memcpy(now, ANS, sizeof(ANS));

	int idx = 0; 
	int nxt = 0;
	fin = 1990;
	while((now_time = timer.get()) < fin){
		int old = now[idx];
		now[idx] = nxt;
		int now_score = getScore(now);

		if(AS < now_score){
			ANS[idx] = nxt;
			AS = now_score;
			//cerr << " " << AS << endl;
		}else{
			now[idx] = old; 
		}
		nxt++;
		if(nxt == m){
			nxt = 0;
			idx++;
			if(idx == n) idx = 0;
		}
	}

	output(ANS);

	return 0;
}

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

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int inf = 1<<30;
constexpr ll inf2 = 1ll<<60;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    ll n,a,b;
    cin>>n>>a>>b;
    if((b-a)%2 == 0){
        cout << (b-a)/2ll << endl;
    }else {
        cout << (b-a+1)/2 + min(a-1,n-b) << endl;
    }
    return 0;
}

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

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define ALL(v) v.begin(), v.end()
#define SZ(x) ((int)(x).size())

const double PI  = acos(-1.0);
const double EPS = 1e-9;
const ll INF = 1e9+10;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
#define print(x) cerr << #x << " is " << x << endl;
//#define print(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl; 

ll n, mod = 1e9 + 7;
const ll MAX = 1e6 + 1;
vector<ll> v(MAX);

ll inv[MAX];

void init() {
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        //if (i < 100)fprintf(stderr, "%d, %d, %d\n", i, inv[i], inv[i] * i %mod);
    }
}



int main() {
    init();
    
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N)cin >> A[i];
    
    sort(ALL(A));
    ll ans = 0, nck = 1;
    
    for (n = K - 1; n <= N - 1; n++){
        //fprintf(stderr, "n = %d, (A[%d] - A[%d]) * %d = %d\n", n, n, N - n, nck,
        //(A[n] - A[N - 1 - n])* nck);
        //nck *= n + 1;
        //nck /= (n + 2 - K);

        ll tmp = (ll)(A[n] - A[N - 1 - n]) * nck % mod;
        (ans += tmp) %= mod;
        (nck *= n + 1) %= mod;
        (nck *= inv[n + 2 - K]) %= mod;
    }
    cout << ans;
    return 0;
}


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

#define all(x) begin(x), end(x)

using i64 = int_fast64_t;
using u64 = uint_fast64_t;
using f64 = double;
using p64 = pair<i64, i64>;

constexpr i64 INF = INT_FAST64_MAX / 2;

void solve() {
    i64 n;
    cin >> n;
    map<i64, i64> cnt;
    for (i64 i = 0; i < n; i++) {
        i64 l;
        cin >> l;
        cnt[l]++;
    }
    vector<i64> keys;
    for (auto& [ k, v ] : cnt) keys.emplace_back(k);
    n = keys.size();
    i64 ans = 0;
    for (i64 i = 0; i < n; i++) {
        for (i64 j = i + 1; j < n; j++) {
            for (i64 k = j + 1; k < n; k++) {
                if (keys[i] + keys[j] > keys[k]) ans += cnt[keys[i]] * cnt[keys[j]] * cnt[keys[k]];
            }
        }
    }
    cout << ans << endl;
}

int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}


Measured memory_bytes: 3656
import numpy as np

N=int(input())

restaurant={}

for i in range(N):
  temp=input().split()
  restaurant.setdefault(temp[0], []).append([int(i+1), int(temp[1])])
  
keys=[]
for key in restaurant:
  keys.append(key)
  
keys.sort()
for key in keys:
  temp=np.array(restaurant[key])
  temp=temp[np.argsort(temp, axis=0)[::-1, 1]]
  for i in range(temp.shape[0]):
    print(temp[i, 0])

Measured memory_bytes: 12392
#include <stdio.h>

int g1[7]={1,3,5,7,8,10,12};
int g2[4]={4,6,9,11};
int g3[1]={2};

int checker(int x)
{
	int chk;
	for(int i=0;i<7;++i)
	{
		if(g1[i]==x) chk=1;
	}
	for(int i=0;i<4;++i)
	{
		if(g2[i]==x) chk=2;
	}
	if(g3[0]==x) chk=3;
	return chk;
}

int main(){
	int x,y;
	scanf("%d %d\n",&x,&y);
	if(checker(x)==checker(y))
	{
		puts("Yes");
	}else{
		puts("No");
	}

}


Measured memory_bytes: 128
#include "bits/stdc++.h"
#define REP(i,n,N) for(ll i=(n); i<(N); i++)
#define RREP(i,n,N) for(ll i=(N-1); i>=n; i--)
#define CK(n,a,b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define p(s) cout<<(s)<<endl
#define p2(a,b) cout<<(a)<<" "<<(b)<<endl
typedef long long ll;
using namespace std;
const ll inf=1e18;

ll N,M;
ll dp[1010][1010][8];
int main(){
    while(cin>>N>>M){
        ll v[3][1010];

        REP(i,0,N){
            cin>>v[0][i]>>v[1][i]>>v[2][i];
        }
        REP(i,0,N+1) REP(j,0,M+1) REP(k,0,8) dp[i][j][k]=-inf;
        REP(k,0,8) dp[0][0][k]=0;
        REP(i,0,N){
            RREP(j,0,M+1){
                REP(mask,0,1<<3){
                    dp[i+1][j][mask] = max(dp[i+1][j][mask],dp[i][j][mask]);
                    if(j==M) continue;
                    ll tmp = 0;
                    REP(k, 0, 3){
                        if(mask & (1<<k)) tmp-=v[k][i];
                        else tmp+=v[k][i];
                    }
                    dp[i+1][j+1][mask] = max(dp[i+1][j+1][mask],dp[i][j][mask]+tmp);
                }

            }
        }
        ll ans=0;
        REP(k,0,8){
            //p(dp[N][M][k]);
            ans=max(ans,dp[N][M][k]);
        }
        p(ans);
        return 0;
    }

}

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

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

using namespace std;

int main(){
	int M, N, K, a, b, c, d, ansJ, ansO;
	char input[1003];
	int sumJ[1003][1003], sumO[1003][1003];
	
	cin >> M >> N >> K;
	
	REP(j,M+1){
		REP(k,N+1){
			sumJ[j][k] = 0;
			sumO[j][k] = 0;
		}
	}
	
	for (int j=1; j<=M; j++){
		cin >> input;
		for (int k=1; k<=N; k++){
			if (input[k-1]=='J') sumJ[j][k] = 1;
			if (input[k-1]=='O') sumO[j][k] = 1;
			//if (input[k-1]=='I') sum[j][k][2] = 1;
		}
	}
	/*REP(i,M+1){
		REP(j,N+1){
			cout << "(";
			REP(l,3) printf("%d,", sum[i][j][l]);
			cout << ") ";
		}
		cout << endl;
	}
	cout << endl;*/
	
	for (int j=1; j<=M; j++){
		for (int k=1; k<=N; k++){
			/*REP(l,3){
				sum[j][k][l] += sum[j][k-1][l];
			}*/
			sumJ[j][k] += sumJ[j][k-1];
			sumO[j][k] += sumO[j][k-1];
		}
	}
	/*REP(i,M+1){
		REP(j,N+1){
			cout << "(";
			REP(l,3) printf("%d,", sum[i][j][l]);
			cout << ") ";
		}
		cout << endl;
	}
	cout << endl;*/
	
	for (int k=1; k<=N; k++){
		for (int j=1; j<=M; j++){
			/*REP(l,3){
				sum[j][k][l] += sum[j-1][k][l];
			}*/
			sumJ[j][k] += sumJ[j-1][k];
			sumO[j][k] += sumO[j-1][k];
		}
	}
	
	/*REP(i,M+1){
		REP(j,N+1){
			cout << "(";
			REP(l,3) printf("%d,", sum[i][j][l]);
			cout << ") ";
		}
		cout << endl;
	}*/
	
	REP(i,K){
		cin >> a >> b >> c >> d;
		//REP(l,3) ans[l] = sum[a-1][b-1][l]+sum[c][d][l]-sum[a-1][d][l]-sum[c][b-1][l];
		ansJ = sumJ[a-1][b-1]+sumJ[c][d]-sumJ[a-1][d]-sumJ[c][b-1];
		ansO = sumO[a-1][b-1]+sumO[c][d]-sumO[a-1][d]-sumO[c][b-1];
		printf("%d %d %d\n", ansJ, ansO, (c*d+(a-1)*(b-1)-c*(b-1)-d*(a-1)-ansJ-ansO));
	}
	
	return 0;
}




Measured memory_bytes: 10844
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;
template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << ' '; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.first << ' ' << v.second; return os; }
// template <class T, class S> ostream& operator << (ostream &os, const unordered_map<T, S> &v) { for (auto i : v) os << '(' << i.first << "=>" << i.second << ')' << ' '; return os; }
 
#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <class Arg1> void __f(const char* name, Arg1&& arg1) { cerr << name << " : " << arg1 << endl; }
    template <class Arg1, class... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args) {
        const char* sep = strchr(names + 1, ',');
        cerr.write(names, sep - names) << " : " << arg1 << "  ";
        __f(sep + 1, args...);
    }
#else
#define trace(...) 0
#define _CRT_SECURE_NO_WARNINGS
#endif // ifndef ONLINE_JUDGE


typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define Mod 1000000007
#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll n,m;cin>>n>>m;
	vector<pii> input;
	For(i,0,n){
		ll a,b;cin>>a>>b;
		input.pb({a,b});
	}
	sort(input.begin(),input.end());
	priority_queue<ll> p;
	ll index = 0;

	ll ans = 0;

	For(d,1,m+1){
		while(index<n && input[index].fi==d) p.push(input[index++].se);

		if(p.size()==0) continue;

		ans += p.top();
		p.pop();
	}
	cout<<ans<<endl;































	
}

Measured memory_bytes: 3568
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long[] h = new long[n];
    long[] p = new long[n-1];

    for(int i=0; i<n; ++i)
      h[i] = sc.nextLong();

    for(int i=0; i<p.length; ++i) {
      if(h[i] < h[i+1]) p[i] = 0;
      else p[i] = 1;
    }

    int max1 = 0;
    int max2 = 0;
    for(int i=0; i<p.length; ++i) {
      if( p[i] == 1 ) {
        ++max1;
      }
      else {
        max2 = Math.max(max1, max2);
        max1 = 0;
      }
    }

    System.out.println(Math.max(max1, max2));
  }
}

Measured memory_bytes: 62408
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

data_list = [a,b,c,d,e]
least_number = 10
result = 0
for i in range (5):
    if int(str(data_list[i])[-1])<least_number and int(str(data_list[i])[-1])!=0:
        least_number = int(str(data_list[i])[-1])
    if int(str(data_list[i])[-1])==0:
        result += data_list[i]
    else:
        result += data_list[i] + 10 -int(str(data_list[i])[-1])

print(result + least_number -10)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long int len;
  cin>>len;
   cin.ignore(numeric_limits<streamsize>::max(), '\n');
  string s;
  getline(cin,s);
  string ne;
  for(int i=0;i<len;i++){
    ne.push_back(s[i]);
    ne.push_back(s[i+len+1]);
  }
  for(int i=0;i<ne.size();i++){
    cout<<ne[i];
  }
  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a = [0] + a + [0]
sa = 0
for i in range(n+1):
    sa += abs(a[i]-a[i+1])

for i in range(1, n+1):
    print(sa - (abs(a[i-1]-a[i]) + abs(a[i]-a[i+1])) + abs(a[i-1]-a[i+1]))

Measured memory_bytes: 14048
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

using namespace std;
using LLONG = long long;
const LLONG MOD = 1000000007;

int main()
{
    int N, M;
    cin >> N >> M;
    cout << (N == M ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <vector>

static const size_t N_MAX = 1000000;
static int A[N_MAX];

int main() {
  size_t N;
  scanf("%zu", &N);
  for (size_t i = 0; i < N; i++)
    scanf("%d", A + i);
  std::vector<size_t> G;
  for (auto i = 1; unsigned((1 << i) - 1) <= N; i++)
    G.push_back((1 << i) - 1);
  std::reverse(G.begin(), G.end());
  int c = 0;
  for (auto&& g : G)
    for (size_t i = g; i < N; i++) {
      auto v = A[i];
      size_t j = i;
      while (j >= g && A[j-g] > v) {
        A[j] = A[j-g];
        j -= g;
        c++;
      }
      A[j] = v;
    }
  printf("%zu\n", G.size());
  for (size_t i = 0; i < G.size() - 1; i++)
    printf("%zu ", G[i]);
  printf("%zu\n", G.back());
  printf("%d\n", c);
  for (size_t i = 0; i < N; i++)
    printf("%d\n", A[i]);
  return 0;
}

Measured memory_bytes: 6572
import java.util.Scanner;

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

	int n = scan.nextInt();
	long[] r = new long[n+1];
	r[0] = 2;
	r[1] = 1;

	for(int i = 2; i < n+1; i++){
	    r[i] = r[i-1]+r[i-2];
	}

	System.out.println(r[n]);
    }
}


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

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

    int max_cnt, cnt = 0;
    int c_n;
    int result = 1;
    for (int i = 1; i <= N; i++)
    {
        cnt = 0;
        c_n = i;
        while (c_n % 2 == 0) {
            c_n /= 2;
            cnt++;
        }
        // max_cnt = max(cnt, max_cnt);
        if (cnt > max_cnt) {
            max_cnt = cnt;
            result = i;
        }
    }
    cout << result << endl;
}

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

int main(){
  string S;
  cin >> S;
  if(S == "SUN"){
    cout << 7 << endl;
  }else if(S == "MON"){
    cout << 6 << endl;
  }else if(S == "TUE"){
    cout << 5 << endl;
  }else if(S == "WED"){
    cout << 4 << endl;
  }else if(S == "THU"){
    cout << 3 << endl;
  }else if(S == "FRI"){
    cout << 2 << endl;
  }else{
    cout << 1 << endl;
  }
    
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

type node struct {
	dist               int
	isVisited, isWhite bool
}

func intMin(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func main() {
	var H, W int
	fmt.Scan(&H, &W)
	INF := int(math.Pow10(5))

	Map := make([]string, H)
	for i := 0; i < H; i++ {
		fmt.Scan(&Map[i])
	}

	cntWhite := 0
	Dist := make([][]node, H)
	for i := 0; i < H; i++ {
		Dist[i] = make([]node, W)
		for j := 0; j < W; j++ {
			Dist[i][j].dist = INF
			if Map[i][j] == '.' {
				Dist[i][j].isWhite = true
				cntWhite++
			}
		}
	}

	Dist[0][0].dist, Dist[0][0].isVisited = 1, true
	queue := make([]int, 0)
	queue = append(queue, 0)
	for len(queue) > 0 {
		pno := queue[0]
		queue = queue[1:]
		x, y := pno/W, pno%W
		p := &Dist[x][y]
		if p.isWhite {
			if x > 0 {
				p.dist = intMin(p.dist, Dist[x-1][y].dist+1)
				if !Dist[x-1][y].isVisited && Dist[x-1][y].isWhite {
					queue = append(queue, (x-1)*W+y)
					Dist[x-1][y].isVisited = true
				}
			}
			if x < H-1 {
				p.dist = intMin(p.dist, Dist[x+1][y].dist+1)
				if !Dist[x+1][y].isVisited && Dist[x+1][y].isWhite {
					queue = append(queue, (x+1)*W+y)
					Dist[x+1][y].isVisited = true
				}
			}
			if y > 0 {
				p.dist = intMin(p.dist, Dist[x][y-1].dist+1)
				if !Dist[x][y-1].isVisited && Dist[x][y-1].isWhite {
					queue = append(queue, x*W+(y-1))
					Dist[x][y-1].isVisited = true
				}
			}
			if y < W-1 {
				p.dist = intMin(p.dist, Dist[x][y+1].dist+1)
				if !Dist[x][y+1].isVisited && Dist[x][y+1].isWhite {
					queue = append(queue, x*W+(y+1))
					Dist[x][y+1].isVisited = true
				}
			}
		}
	}

	if !Dist[H-1][W-1].isVisited {
		fmt.Println(-1)
		return
	}
	ans := cntWhite - Dist[H-1][W-1].dist
	fmt.Println(ans)
}


Measured memory_bytes: 1976