akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

//#define max(a,b) a>b?a:b
//#define min(a,b) a>b?b:a

ll gcd(ll a, ll b) { return !b ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

int sum() { return 0; }

template<typename T, typename... Args>
T sum(T a, Args... args) { return a + sum(args...); }




/////////////////////////////////////////////////
//**************  F - LCS   *******************
////////////////////////////////////////////////////



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	string s,t;
	cin>>s>>t;
	int ns = s.length() , nt = t.length();
	//if(ns < nt) swap(s,t);swap(ns,nt);
	int dp[ns+4][nt+4];
	for (int i = 0; i <= ns; ++i)
	{
		dp[i][0] = 0;
	}
	for (int i = 0; i <= nt; ++i)
	{
		dp[0][i] = 0;
	}
	for (int i = 1; i <= ns; ++i)
	{
		for (int j = 1; j <= nt; ++j)
		{
			if(s[i-1] != t[j-1]){
				 dp[i][j] = max(dp[i-1][j] ,dp[i][j-1] );
			 }
			 else{
				 dp[i][j] = dp[i-1][j-1] + 1;
			 }
		}
	}
	int i = ns , j = nt;
	string ans = "";
	while (i > 0 && j> 0)
	{
		if(dp[i][j] == dp[i-1][j] || dp[i][j] == dp[i][j-1]){
			if(dp[i][j] == dp[i-1][j]) i = i-1;
			else if(dp[i][j] == dp[i][j-1]) j = j-1;
		}
		else{
			ans += s[i-1];
			i--;j--;
		}
	}
	//error(dp[ns][nt]);
	reverse(ans.begin() , ans.end());
	std::cout << ans << "\n";
	return 0;
}


Measured memory_bytes: 38764
import sys

input = sys.stdin.readline
n, x, y = map(int, input().split())
ans = [0] * (n-1)
for i in range(1, n+1):
    for j in range(1, n+1):
        if i < j:
            # iとjを固定、rangeでi<jを表現
            d = min(j-i, abs(x-i)+abs(j-y)+1, abs(y-i)+abs(x-j)+1)
            # 長さを示すところに+１
            ans[d-1] += 1
print(*ans, sep="\n")

Measured memory_bytes: 47068
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

int main() {
	Int N, M, V, P;
	cin >> N >> M >> V >> P;
	vector<Int> A(N);
	for (int i = 0; i < N; ++i) { cin >> A[i]; }

	sort(A.rbegin(), A.rend());
	auto check = [&](int m) -> bool {
		Int cnt = 0;
		for (int i = 0; i < N; ++i) {
			if (A[i] > A[m] + M) { ++cnt; }
		}
		if (cnt >= P) { return false; }

		Int sum = M;
		cnt = 1;
		for (int i = 0; i < N; ++i) {
			if (i == m) { continue; }
			if (cnt++ < P) { sum += M; }
			else { sum += min(M, A[m] + M - A[i]); }
		}
		return sum >= M * V;
	};

	int l = 0, r = N;
	while (r - l > 1) {
		int m = (r + l) / 2;
		(check(m) ? l : r) = m;
	}
	cout << l + 1 << "\n";

	return 0;
}


Measured memory_bytes: 4048
#include<set> 
#include<map> 
#include<stack> 
#include<cmath> 
#include<cstdio> 
#include<queue> 
#include<vector> 
#include<climits> 
#include<cstring> 
#include<iostream> 
#include<algorithm> 
using namespace std;
#define MAXN 100
#define LL long long 
#define INF INT_MAX 
int read(){ 
    int f=1,x=0; 
    char c=getchar(); 
    while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();} 
    while('0'<=c&&c<='9'){x=x*10+c-'0';c=getchar();} 
    return f*x; 
}
bool num[30];
char str[MAXN+5];
int main(){
	int n=read(),ans=0;
	scanf("%s",str+1);
	for(int i=1;i<=n;i++){
		int tmp=0;
		memset(num,0,sizeof(num));
		for(int j=1;j<=i;j++) num[str[j]-'a']=1;
		for(int j=i+1;j<=n;j++)if(num[str[j]-'a']) tmp++,num[str[j]-'a']=0;
		ans=max(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
from collections import defaultdict, deque
import sys
input = sys.stdin.readline
N = int(input())
ab = [list(map(int,input().split())) for i in range(N-1)]

g = defaultdict(list)

for a,b in ab:
    g[a].append(b)
    g[b].append(a)

dq = deque([1])
d = [10**6]*(N+1)
d[1] = 0
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if d[v] + 1 < d[nv]:
            d[nv] = d[v] + 1
            dq.append(nv)
m = max(d[1:])
s = d.index(m)

dq = deque([s])
d = [10**6]*(N+1)
d[s] = 0
while dq:
    v = dq.popleft()
    for nv in g[v]:
        if d[v] + 1 < d[nv]:
            d[nv] = d[v] + 1
            dq.append(nv)
diag = max(d[1:])

if diag % 3 == 1:
    print('Second')
else:
    print('First')


Measured memory_bytes: 145216
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cmath>
#include<queue>
#include<map>
#include<iomanip>
using namespace std;
 
typedef long long ll;

const ll MOD = 2019;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll l,r;
	cin >> l >> r;
//	map<ll,ll> ma;
	
	int ma[2019] = {0};
	for(int i=l;i<=r && i<=l+2019*4;++i){
		int m = i%MOD;
		ma[m]++;
	}
	
	ll res = 30000;
	for(int i=0;i<2019;++i){
		if(ma[i] == 0) continue;
		for(int j=0;j<2019;++j){
			if(ma[j] == 0) continue;
			if(i == j && ma[i] <= 1) continue;
			res = min(res,(i*j)%MOD);
			if(res == 0){
				cout << res << endl;
				return 0;
			}
		}
	}
	
	cout << res <<endl;
	
	
	
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <sstream>
#include <string>
#include <map>
using namespace std;

//ABC 145B
int main() {
	int n;
	string s;
	cin >> n >> s;

	if (n==1 || n%2!=0) {
		cout << "No" << endl;
		return 0;
	}

	for (int i=0; i<n/2; i++) {
		if (s[i] != s[n/2+i]) {
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

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

#define _USE_MATH_DEFINES

using namespace std;
using ll = long long;
using P = pair<int, int>;

const ll INF = 999999999;
const ll atcoder = 1000000007;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };

int main() {

	int n, k;
	int x[110];
	int ans = 0;
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> x[i];
		ans += 2 * min(x[i], k - x[i]);
	}

	cout << ans << endl;
		
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    n = ni()
    l = [ns() for _ in range(n)]
    d = Counter(l)
    for x in ['AC', 'WA', 'TLE', 'RE']:
        print(x, 'x', d.get(x, 0))
    return

solve()


Measured memory_bytes: 16580
#include <iostream>
using namespace std;
int main() {
    int N;
    cin >> N;
    __int128_t M = 1, INF = int64_t(1e18) + 1;
    while (N--) {
        int64_t a;
        cin >> a;
        M = min(M*a, INF);
    }
    if (M == INF) M = -1;
    cout << int64_t(M) << endl;
    return 0;
}

Measured memory_bytes: 3600
import java.util.*;
import static java.lang.System.*;
import static java.lang.Math.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	class Pos {
		int lx, ly, rx, ry;
		Pos(int _lx, int _ly, int _rx, int _ry) {
			lx = _lx;
			ly = _ly;
			rx = _rx;
			ry = _ry;
		}
	}
	
	void run() {
		boolean[][] rooml = new boolean[50][50];
		boolean[][] roomr = new boolean[50][50];
		boolean[][][][] used = new boolean[50][50][50][50]; 
		int dlx, dly, drx, dry, lx, ly, rx, ry;
		dlx = dly = drx = dry = lx = ly = rx = ry = 0;
		Queue<Pos> que = new LinkedList<Pos>();
		int[] dilx = {1, -1, 0, 0};
		int[] dily = {0, 0, 1, -1};
		int[] dirx = {1, -1, 0, 0};
		int[] diry = {0, 0, -1, 1};
		while (true) {
			int w = sc.nextByte(), h = sc.nextByte();
			if (w == 0 && h == 0) break;
			for (int i = 0; i < h; i++) {
				String l = sc.next(), r = sc.next();
				for (int j = 0; j < w; j++) {
					switch (l.charAt(j)) {
					case '.': rooml[i][j] = true; break;
					case '#': rooml[i][j] = false; break;
					case '%': 
						rooml[i][j] = true;
						dlx = i; dly = j;
						break;
					case 'L':
						rooml[i][j] = true;
						lx = i;
						ly = j;
						break;
					}
					switch (r.charAt(j)) {
					case '.': roomr[i][j] = true; break;
					case '#': roomr[i][j] = false; break;
					case '%': 
						roomr[i][j] = true;
						drx = i; dry = j;
						break;
					case 'R':
						roomr[i][j] = true;
						rx = i;
						ry = j;
						break;
					}
				}
			}
			
			que.clear();
			for (int i = 0; i < 50; i++)
				for (int j = 0; j < 50; j++)
					for (int k = 0; k < 50; k++)
						Arrays.fill(used[i][j][k], false);
			que.add(new Pos(lx, ly, rx, ry));
			used[lx][ly][rx][ry] = true;
			boolean flag = false;
			while (!que.isEmpty()) {
				Pos p = que.poll();
				int telx = p.lx, tely = p.ly;
				int terx = p.rx, tery = p.ry;
				if (telx == dlx && tely == dly && terx == drx && tery == dry) {
					flag = true;
					break;
				}
				if (telx == dlx && tely == dly && !(terx == drx && tery == dry)) {
					continue;
				}
				if (!(telx == dlx && tely == dly) && terx == drx && tery == dry) continue;
				for (int i = 0; i < 4; i++) {
					int lX = telx + dilx[i], lY = tely + dily[i];
					int rX = terx + dirx[i], rY = tery + diry[i];
					if (!(0 <= lX && lX < h && 0 <= lY && lY < w && rooml[lX][lY])) {
						lX = telx;
						lY = tely;
					}
					if (!(0 <= rX && rX < h && 0 <= rY && rY < w && roomr[rX][rY])) {
						rX = terx;
						rY = tery;
					}
					if (!used[lX][lY][rX][rY]) {
						used[lX][lY][rX][rY] = true;
						que.add(new Pos(lX, lY, rX, rY));
					}
				}
			}
			
			if (flag)
				out.println("Yes");
			else
				out.println("No");
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

Measured memory_bytes: 180780
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		int n = Integer.parseInt(sc.next());
		char[][] q = new char[2][n];
		for(int i = 0 ; i < 2 ; i++){
			String s = sc.next();
			for(int j = 0 ; j < n ; j++){
				q[i][j] = s.charAt(j);
			}
		}
		long yono = 0;
		for(int i = 0 ; i < n ; i++){
			if(i == 0){
				if(q[0][0] == q[1][0]) yono = 3;
				else{
					i++;
					yono = 6;
				}
			}else{
				if(q[0][i] == q[1][i] && q[0][i - 1] == q[1][i - 1]) yono *= 2;
				else if(q[0][i] != q[1][i]){
					if(q[0][i - 1] == q[1][i - 1]) yono *= 2;
					else yono *= 3;
					i++;
				}
				yono %= 1000000007;
			}
		}
		ou.println(yono);
		ou.flush();
	}
}

Measured memory_bytes: 35692
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
using namespace std;
#define rep2(x,from,to) for(int x=(from);(x)<(to);(x)++)
#define rep(x,to) rep2(x,0,to)
int n, cnt;
vector<int> v;
void insertionSort(int *a, int n, int g) {
	rep2(i,g,n) {
		int v = a[i];
		int j = i - g;
		while(j >= 0 && a[j] > v) {
			a[j+g] = a[j];
			j -= g;
			cnt++;
		}
		a[j+g] = v;
	}
}
void shellSort(int *a, int n) {
	cnt = 0;
	int h = 1;
	while(h <= n) {
		h = 3 * h + 1;
	}
	while(h) {
		h = (h - 1) / 3;
		if(h) v.push_back(h);
	}
	rep(i,v.size()) {
		insertionSort(a, n, v[i]);
	}
}
int main() {
	int a[1000010];
	cin >> n;
	rep(i,n) {
		cin >> a[i];
	}
	shellSort(a, n);
	cout << v.size() << endl;
	rep(i,v.size() - 1) {
		cout << v[i] << " ";
	}
	cout << v[v.size() - 1] << endl;
	cout << cnt << endl;
	rep(i,n) {
		cout << a[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 5120
program gathering_children
  implicit none
  integer :: n, a(100000) = 1, i
  character(100000) :: s
  read(*,*) s
  n = len_trim(s)
  do i = 1, n-2
    if (s(i:i) == "R" .and. s(i+1:i+1) == "R") then
      a(i+2) = a(i+2)+a(i)
      a(i) = 0
    end if
  end do
  do i = n, 3, -1
    if (s(i:i) == "L" .and. s(i-1:i-1) == "L") then
      a(i-2) = a(i-2)+a(i)
      a(i) = 0
    end if
  end do
  write(*,'(i0)',advance='no') a(1)
  do i = 2, n
    write(*,'(x,i0)',advance='no') a(i)
  end do
  write(*,*)
  stop
end program gathering_children

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)
#define ff first
#define ss second
#define sz(a) (lli)(a.size())
lli inf = (1e18 + 2);

int main()
{
	lli n;
	cin>>n;
	lli a[n+1];
	f(i,0,n)
		cin>>a[i];
	lli ans = 0;
	lli prevv = a[0];

	f(i,1,n)
	{
		if(a[i] < prevv)
		{
			ans += (prevv - a[i]);
		}

		else
			prevv = a[i];
	}

	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

constexpr char sp = ' ';
constexpr char cmm = ',';
constexpr int MOD = 1e9+7;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b){return a*b/gcd(a,b);}
inline void Yes(){cout << "Yes" << endl;}
inline void No(){cout << "No" << endl;}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){cout << "YES" << endl;}
inline void NO(){cout << "NO" << endl;}
inline void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
    
    ll n;
    scanf("%lld", &n);
    ll ok = 10000000, ng = -1;
    ll mid;
    while(abs(ok-ng) > 1){
        mid = (ok+ng)>>1;
        if((mid+1)*mid >= 2*n) ok = mid;
        else ng = mid;
    }

    set<int> ans;
    for(int i = 1; i <= ok; ++i) ans.insert(i);
    ans.erase((ok+1)*ok/2 - n);
    for(ll x : ans){
        printf("%lld\n", x);
    }
    
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>

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

using namespace std;

char solve(string str, int &index, size_t &pos){
	//cout << "solve : " << str << endl;
	int cnt = 1, len = str.length();
	if( str[0] == '(' ){
		str = str.substr(1);
		cnt = -1;
	}
	while( !str.empty() && cnt-- ){
		if( str[0] >= '0' && str[0] <= '9' ){
			size_t i, p;
			int num = stoi( str, &i );
			string s = str.substr(i);
			rep(k, num){
				char res = solve( s, index, p );
				if( res != '0' ) return res;
			}
			//cout << p << endl;
			str = s.substr(p);
		}else if( str[0] == ')' ){
			str = str.substr(1);
			break;
		}else{
			int i=0;
			while(str[i] < '0' || str[i] > '9'){
				if( str[i] == ')' ) break;
				if( index-- == 0 ) return str[i];
				i++;
			}
			str = str.substr(i);
		}
	}
	pos = len - str.length();
	return '0';
}

int main(){
	string s;
	int i;
	while(cin>>s>>i, s != "0" ){
		rep(j, s.length()){
			if( s[j] == '(' && ( j == 0 || s[j-1] < '0' || s[j-1] > '9') ){
				s = s.substr(0, j) + "1" + s.substr(j);
				j++;
			}
		}
		string ss = "1(" + s + ")";
		size_t p;
		cout << solve(ss, i, p) << endl;
	}
	return 0;
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
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;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    string S;
    cin >> S;
    sort(S.begin(), S.end());
    vector<char> c;
    REP(i, S.size()) { c.push_back(S[i]); }
    sort(c.begin(), c.end());
    c.erase(unique(c.begin(), c.end()), c.end());
    string test = "abcdefghijklmnopqrstuvwxyz";
    REP(i, test.size()) {
        if(c[i] != test[i]) {
            cout << test[i] << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int w,h,n;
  cin>>w>>h>>n;
  int x[n],y[n];
  for(int i=0;i<n;i++) cin>>x[i]>>y[i];
  int ans=0;
  for(int i=0;i<n-1;i++){
    if((x[i]-x[i+1])*(y[i]-y[i+1])>0)
      ans+=max(abs(x[i]-x[i+1]),abs(y[i]-y[i+1]));
    else
      ans+=abs(x[i]-x[i+1])+abs(y[i]-y[i+1]);
    
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3108
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <stack>
using namespace std;
typedef long long LL;
const int inf = 1 << 30;
const LL INF = 1LL << 60;

int A, B, C, D, E, F;

int main()
{
	while(scanf("%d %d %d %d %d %d", &A, &B, &C, &D, &E, &F) != EOF)
	{
		int water = 0, suger = 0;
		for(int i = 0; i * A * 100 <= F; i++) {
			for(int j = 0; j * B * 100 <= F; j++) {
				if((i * A * 100 + j * B * 100) > F) break;
				for(int k = 0; ; k++) {
					if((i * A * 100 + j * B * 100 + k * C) > F) break;
					for(int l = 0; ; l++) {
						int tw = i * A * 100 + j * B * 100;
						int ts = k * C + l * D;
						if(tw + ts > F) break;
						int most = (i * A + j * B) * E;
						if(ts <= most) {
							if(water == 0 && suger == 0) {
								water = tw, suger = ts;
							}
							else {
								if(ts * (water + suger) > suger * (tw + ts))
									water = tw, suger = ts;
							}
						}
					}
				}
			}
		}
		printf("%d %d\n", water + suger, suger);
	}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <vector>
#include <algorithm>


using namespace std;

int main(){
  char s;
  int ans=0;
  for(int i=0;i<4;i++){
    cin>>s;
    if(s=='+')ans++;
    else ans--;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <queue>
using namespace std;

const int N = 1e5 + 5;
const int M = N * 25;

int dis[N] ,n , m  , k , fir[N] , ne[M] , to[M] , C[M] , cnt;
bool vis[N];

void add(int x , int y , int z) {
	ne[++ cnt] = fir[x]; fir[x] = cnt; to[cnt] = y; C[cnt] = z;
}

struct NODE {
	int no , Dis;
	friend bool operator < (NODE xxx , NODE yyy) {
		return xxx.Dis > yyy.Dis;
	}
};

priority_queue<NODE>q;

#define Df(no , Dis) (NODE){no , Dis}
#define Foreachson(i , x) for(int i = fir[x];i;i = ne[i])

void dijkstra(void) {
	for(int i = 1;i <= 9;++ i) q.push(Df(i , i));
	while(!q.empty()) {
		while(!q.empty() && vis[q.top().no]) q.pop();
		if(q.empty()) break;
		NODE ind = q.top(); q.pop();
		vis[ind.no] = 1; dis[ind.no] = ind.Dis;
		Foreachson(i , ind.no) {
			int V = to[i];
			if(vis[V]) continue;
			q.push(Df(V , dis[ind.no] + C[i]));
		}
	}
	printf("%d\n" , dis[0]);
}

int main(void) {
	scanf("%d" , &n);
	for(int i = 1;i < n;++ i) {
		for(int j = 0;j <= 9;++ j) {
			add(i , (i * 10 + j) % n, j);
		}
	}
	dijkstra();
}

Measured memory_bytes: 23536
N=int(input())
if N<=111:
    print(111)
elif N<=222:
    print(222)
elif N<=333:
    print(333)
elif N<=444:
    print(444)
elif N<=555:
    print(555)
elif N<=666:
    print(666)
elif N<=777:
    print(777)
elif N<=888:
    print(888)
else:
    print(999)

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

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: usize = read();
    let b: usize = read();
    let mut x: Vec<i64> = vec![];
    let mut tmp: i64 = 0;

    for i in 0..1000 {
        tmp += i;
        x.push(tmp);
    }
    // println!("{:?}", x);

    println!("{}", x[b - a] - b as i64);
}


Measured memory_bytes: 4352
#include<stdio.h>
int main()
{
	int r, d, x;
	scanf("%d %d %d", &r, &d, &x);
	int i;
	for (i = 0; i < 10; i++)
	{
		x = r * x - d;
		printf("%d\n", x);
	}
	return 0;
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import bisect

def search_next_char(idxs, now, iter):
    l = len(idxs)
    next = bisect.bisect(idxs, now)
    if next >= l:
        iter += 1
        next = bisect.bisect(idxs, 0)
    return idxs[next], iter


s = input()
t = input()

set_s = set(s)
set_t = set(t)

if len(set_t - set_s) > 0:
    print(-1)
    exit()


c_idx = {}
for i, c in enumerate(s):
    if c in c_idx:
        c_idx[c].append(i+1)
    else:
        c_idx[c] = [i+1]

now = 0
iter = 0
for c in t:
    now, iter = search_next_char(c_idx[c], now, iter)

print(iter * len(s) + now)


Measured memory_bytes: 7796
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;
int main()
{
  int n;
  cin >> n;

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


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

  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
//#include <vector>
#include <string>
//#include <algorithm>
#include <math.h>
//#include <queue>
//#include <stack>
#include <iomanip>

// sometimes used
//#include <set>
//#include <map>
//#include <numeric>
//#include <list>
//#include <deque>
//#include <unordered_map>

//typedef long long LL;
//typedef long double LD;
using namespace std;
 
//#define MOD 1000000007
//#define MAX 200100
//#define NIL -1

int main() {
    double a;
    double b;
    double h;
    double m;
    double h_pi;
    double m_pi;
    double ans;
    cin >> a >> b >> h >> m;
    m_pi = m/60.0*2*M_PI;
    h_pi = (h/12.0+m/12.0/60.0)*2*M_PI;
    ans = a*a+b*b-2*a*b*cos(h_pi-m_pi);
    ans = sqrt(ans);

    cout << setprecision(16) << ans << endl;

    return 0;
}


Measured memory_bytes: 4212
import math
K, S = map(int, input().split())

"""
0<= X<= K でXを選ぶ
このとき Y+ Z= S- X
Yの最小値は，max(0, S- X- K)
Yの最大値は，min(K, S- X)
よってY, Zの選び方はmin(K, S- X)- max(0, S- X- K)+ 1 通り．
Xについて，0<= X<= Kで足し合わせればよい．
"""
ans = 0

for i in range(K+ 1):
  Y_min = max(0, S- i- K)
  Y_max = min(K, S- i)
  if(Y_max>= Y_min):
    ans+= Y_max- Y_min+ 1
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N,M; cin >> N >> M;
  int ans;
  ans = N * (N - 1) / 2 + M * (M - 1) / 2;
  cout << ans << endl;
}

Measured memory_bytes: 3624
module.exports=function(e){var r={};function t(n){if(r[n])return r[n].exports;var o=r[n]={i:n,l:!1,exports:{}};return e[n].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=r,t.d=function(e,r,n){t.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:n})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,r){if(1&r&&(e=t(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var n=Object.create(null);if(t.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var o in e)t.d(n,o,function(r){return e[r]}.bind(null,o));return n},t.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(r,"a",r),r},t.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},t.p="",t(t.s=0)}([function(e,r,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8"))},function(e,r){e.exports=function(e){for(var r=e.split("\n"),t=Number(r[0]),n=[],o=0;o<t;o++){var u=r[o+1].split(" ").map(function(e){return Number(e)});n.push({x:u[0],y:u[1],h:u[2]})}for(var a=0;a<=100;a++)for(var f=0;f<=100;f++){for(var i=-1,l=!0,c=[],s=0,p=n;s<p.length;s++){var b=p[s];if(0!=b.h){var d=b.h+Math.abs(a-b.x)+Math.abs(f-b.y);if(-1==i&&(i=d),i!=d){l=!1;break}}else c.push(b)}if(l){for(var v=!0,y=0,h=c;y<h.length;y++){var x=h[y];if(0!=Math.max(0,i-Math.abs(a-x.x)-Math.abs(f-x.y))){v=!1;break}}if(v)return void console.log(`${a} ${f} ${i}`)}}}},function(e,r){e.exports=require("fs")}]);

Measured memory_bytes: 10060
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define invrepr(i,a,b) for(int i=b-1;i>=a;i--)
#define invrep(i,n) invrepr(i,0,n)
#define repitr(itr,a) for(auto itr=a.begin();itr!=a.end();++itr)
#define P pair<int,int>
const int MOD=1e9+7;
const int INF=2e9;


int main() {
    ios_base::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<vector<ll>> d(n,vector<ll>(n));
    vector<vector<int>>  b(n,vector<int>(n,1));
    rep(i,n) {
        rep(j,n) cin >> d[i][j];
    } 
    bool flag=0;
    rep(i,n) {
        rep(j,n) {
            rep(k,n) {
                if (d[j][k]>d[j][i]+d[i][k]) flag=1;
                else if (d[j][k]==d[j][i]+d[i][k] && d[j][i]>0 && d[i][k]>0) b[j][k]=0;
            }
        }
    }
    if (flag) {
        cout << -1 << endl;
    } else {
        ll ans=0;
        rep(i,n) {
            rep(j,n) {
                if (b[i][j]==1) ans+=d[i][j];
            }
        }
        cout << ans/2 << endl;
    }


    return 0;   
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    cin >> N;
    vector<ll> A(N);
    for (auto& in : A)
        cin >> in;
    const int MAX_N = 1e5 + 1;
    vector<ll> C(MAX_N, 0);
    for (auto& v : A)
        C[v]++;
    sort(C.begin(), C.end(), greater<ll>());
    for (int i = 0; i < (int)C.size(); i++) {
        if (C[i] >= 3) {
            if (C[i] % 2 == 1)
                C[i] = 1;
            else
                C[i] = 2;
        }
    }
    sort(C.begin(), C.end(), greater<ll>());
    for (int i = 0; i < (int)C.size(); i++)
        if (C[i] == 2) {
            C[i] = 1;
            C[i + 1]--;
        }
    cout << accumulate(C.begin(), C.end(), 0LL) << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <stdio.h>
int main(){
  long N;
  long long ans = 0;
  scanf("%ld\n",&N);
  if (N==1) {
    printf("%ld\n",0 );
    return 0;
  }
  for (long i = 1; i < N; i++) {
    ans = ans + i;
  }
  ans = N*(N-1)/2;
  printf("%lld\n",ans);
  return 0;
}

Measured memory_bytes: 128
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var param = ReadLine().Split(' ').Select(long.Parse).ToArray();
    var a = param[0];
    var b = param[1];
    var c = param[2];
    var d = param[3];

    var lcm = Lcm(c, d);
    var ans = (b - a + 1) - (b / c - (a-1) / c) - (b / d - (a-1) / d) + (b / lcm - (a-1) / lcm);
    WriteLine(ans);
  }

  long Gcd(long a, long b) => b == 0 ? a : Gcd(b , a % b);
  long Lcm(long a, long b) => a * b / Gcd(a, b);
}

Measured memory_bytes: 13268
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;

int main()
{   ll n,l,i,j,digit,ans,cnt1=0,cnt2=0;
    cin>>n;
     do
     {
         digit = n % 10;
         if (digit==7)
         {
             cout<<"Yes";
             return 0;
         }
         n = n / 10;
     } while (n != 0);

    cout<<"No";
    return 0;
}


Measured memory_bytes: 3632
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    map<pair<string, string>, int> cnt;
    for (int i = 0; i < (1 << n); ++i) {
        string red  = "";
        string blue = "";
        for (int j = 0; j < n; ++j) {
            if (1 << j & i) {
                red += s[j];
            } else {
                blue = s[j] + blue;
            }
        }
        cnt[make_pair(red, blue)]++;
    }
    ll ret = 0;
    for (int i = 0; i < (1 << n); ++i) {
        string red  = "";
        string blue = "";
        for (int j = 0; j < n; ++j) {
            if (1 << j & i) {
                red = s[j + n] + red;
            } else {
                blue += s[j + n];
            }
        }
        ret += cnt[make_pair(red, blue)];
    }
    cout << ret << "\n";
    return 0;
}

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

int main(){
    int n;ll k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    sort(a.begin(),a.end());
    ll L = -INF,R = INF;
    while(L+1 < R){
        ll x = (L + R) / 2;
        bool ok = [&]{
            ll total = 0;
            rep(i,n){
                // negative
                if(a.at(i) < 0){
                    int l = -1,r = n;
                    while(l + 1 < r){
                        int c = (l + r) / 2;
                        if(a.at(i) * a.at(c) < x) r = c;else l = c;
                    }
                    total += n-r;
                //positive
                }else{
                    int l = -1,r = n;
                    while(l + 1 < r){
                        int c = (l + r) / 2;
                        if(a.at(i) * a.at(c) < x) l = c;else r = c;
                    }
                    total += r;
                }
                if(a.at(i) * a.at(i) < x) total--;
            }
            total /= 2;
            return total < k;
        }();
        if(ok) L = x;
        else R = x;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 4848
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

int gcd(int a, int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a, int b){
    return a/gcd(a,b)*b;
}


signed main(void) {
    int x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    if(x1 == x2){
        int d = abs(y1 - y2),x;
        if(y1 < y2){
            x = x1 - d;
        }else{
            x = x1 + d;
        }
        cout << x << " " << y2 << " " << x << " " << y1 << endl;
        return 0;
    }
    if(y1 == y2){
        int d = abs(x1 - x2),y;
        if(x1 < x2){
            y = y1 + d;
        }else{
            y = y1 - d;
        }
        cout << x2 << " " << y << " " << x1 << " " << y << endl;
        return 0;
    }
    int x3,x4,y3,y4;
    if(y1 > y2){
        x3 = y1 - y2 + x2;
        x4 = y1 - y2 + x1;
    }else{
        x3 = y1 - y2 + x2;
        x4 = y1 - y2 + x1;
    }
    if(x1 > x2){
        y3 = x2 - x1 + y2;
        y4 = x2 - x1 + y1;
    }else{
        y3 = x2 - x1 + y2;
        y4 = x2 - x1 + y1;
    }
    cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}
/*
if(y1 > y2) y1-y2 = x3-x2 = y4-y3 = x4-x1
if(y1 < y2) y2-y1 = x2-x3 = y3-y4 = x1-x4
if(x1 > x2) x1-x2 = y2-y3 = x4-x3 = y1-y4
if(x1 < x2) x2-x1 = y3-y2 = x3-x4 = y4-y1
*/


Measured memory_bytes: 256
#include <string>
#include <iostream>
using namespace std;
int main() {
	string s;
	cin >> s;
	for (int i = 0; i < s.size() - 1; i++) {
		for (int j = i + 1; j < s.size(); j++) {
			if (s[i] - s[j] == 0) {
				cout << "no" << endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

// #define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;

using P = pair<int, int>;


vector<int> to[100005];
int cost[100005];
signed main(){
    int a,b;
    cin >> a>> b;
    if(b==1) {
        cout << 0 << endl;
        return 0;
    }
    int ans = 1;
    while(ans*a-(ans-1) <b) ans++;
    cout << ans << endl;

    return 0;
}



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

using namespace std;

#define int long long

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

template <typename T> T gcd(T m, T n) { return n == 0 ? m : gcd(n, m % n); }
template <typename T> T lcm(T m, T n) { return n * m / gcd(n, m); }
template <typename T> T fact(T n) { return (n == 0 ? 1 : n * fact(n - 1)); }
template <typename T> T modpow(T a, T e, T m) { return (e == (T)0 ? 1 : ((a % m) * modpow((a % m), e - 1, m)) % m); }

constexpr int MOD = 1e9 + 7;

signed main(void) {
  int a, b;
  cin >> a >> b;
  if (a == 1) {
    if (b == 2)
      cout << 3 << endl;
    else
      cout << 2 << endl;
  } else if (a == 2) {
    if (b == 1)
      cout << 3 << endl;
    else
      cout << 1 << endl;
  } else { // a== 3
    if (b == 1)
      cout << 2 << endl;
    else
      cout << 1 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
const ll mod = 1000000007;
#define PI 3.1415926535
using Graph = vector<vector<int>>;
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;}
typedef pair<int, int> pair;
bool seen[505][505];

//dpTable
//bool dp[100050];

int main(){
    int N;
    cin >> N;
    vector<int> W(N);
    rep (i,N) cin >> W.at(i);
    int ans = 1000000;
    for (int i = 0; i < N; i++) {
        int a = 0,b = 0;
        for (int j = 0; j < i; j++) {
            a += W.at(j);
        }
        for (int j = i; j < N; j++) {
            b += W.at(j);
        }
        ans = min(ans,abs(a - b));
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
  string S;
  cin >> S;
  string s1 = S.substr(0, S.size() / 2);
  string s2 = S.substr(S.size() / 2);
  if (s1.size() < s2.size()) {
    s2.erase(s2.begin());
  }
  reverse(s2.begin(),s2.end());
  int ans = 0;
  for (int i = 0; i < s1.size(); ++i) {
    if (s1.at(i) != s2.at(i)) {
      ++ans;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
//2019.8.10 by ljz
#pragma GCC optimize(2)
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define gc getchar
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=1e5+10;
namespace MAIN{
    int n,m;
    Pair a[N];
    int ans;
    priority_queue<int> Q;
    inline void MAIN(){
        n=read(),m=read();
        for(res i=1;i<=n;i++){
            res x=read(),y=read();
            a[i]=mp(x,y);
        }
        sort(a+1,a+n+1);
        for(res t=m-1,i=1;~t;t--){
            while(i<=n&&a[i].fi+t<=m)Q.push(a[i].se),i++;
            if(Q.empty())continue;
            ans+=Q.top(),Q.pop();
        }
        printf("%d\n",ans);
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

Measured memory_bytes: 1660
#include <iostream>

using namespace std;

int main() {
    long int N, M;
    long int niti, sum = 0;
    cin >> N >> M;

    for (int i = 0; i < M; i++) {
        cin >> niti;
        sum += niti;
    }

    if (N - sum >= 0)
        cout << N - sum;
    else
        cout << -1;

    return 0;
}

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

void solve(long long N, long long K, std::vector<long long> p){
    std::sort(p.begin(), p.end());
    long long ans = 0;
    rep(i,K){
        ans += p[i];
    }
    cout << ans << endl;

}

// Generated by 1.1.7.1 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 N;
    scanf("%lld",&N);
    long long K;
    scanf("%lld",&K);
    std::vector<long long> p(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&p[i]);
    }
    solve(N, K, std::move(p));
    return 0;
}


Measured memory_bytes: 3696
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=100010;
const ll mod=1e9+7;

int main(){
  int n;
  vector<ll> a(3);
  cin >> n >> a[0] >> a[1] >> a[2];
  vector<string> s(n);
  rep(i,n){
    cin >> s[i];
  }
  vector<char> cm;
  rep(i,n){
    int x = s[i][0]-'A';
    int y = s[i][1]-'A';
    if(a[x]==0 && a[y]==0){ cout << "No" << endl; return 0;}
    if(a[x]==1 && a[y]==1 && i!=n-1){
      int nx = s[i+1][0]-'A';
      int ny = s[i+1][1]-'A';
      if(nx==x && ny==y){ a[x]++; a[y]--; cm.emplace_back((char)(x+'A')); continue; }
      int z = 3-x-y;
      if(nx==x && a[z]==0){ a[x]++; a[y]--; cm.emplace_back((char)(x+'A')); continue; } //A
      if(nx==x && a[z]!=0){ a[x]--; a[y]++; cm.emplace_back((char)(y+'A')); continue; }
      if(ny==y && a[z]==0){ a[y]++; a[x]--; cm.emplace_back((char)(y+'A')); continue; } //C
      if(ny==y && a[z]!=0){ a[y]--; a[x]++; cm.emplace_back((char)(x+'A')); continue; }

      if(nx==y && a[z]==0){ a[y]++; a[x]--; cm.emplace_back((char)(y+'A')); continue; } //B AB BC
      if(nx==y && a[z]!=0){ a[y]--; a[x]++; cm.emplace_back((char)(x+'A')); continue; } //B 
      if(ny==x && a[z]==0){ a[x]++; a[y]--; cm.emplace_back((char)(x+'A')); continue; } //B BC AB
      if(ny==x && a[z]!=0){ a[x]--; a[y]++; cm.emplace_back((char)(y+'A')); continue; } //B 
    }

    if(a[y]>a[x]){ a[x]++; a[y]--; cm.emplace_back((char)(x+'A')); continue; }
    a[x]--; a[y]++; cm.emplace_back((char)(y+'A')); continue;
  }

  cout << "Yes" << endl;
  for(auto ans:cm){
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 6712
#include<stdio.h>
#include<iostream>
 
int main(){
  long N, D;
  int ans = 0;
  
  std::cin>>N>>D;
  
  for(int i=0; i<N; i++){
    long x, y;
  	std::cin>>x>>y;
    
   	//std::cout<<labs(x)*labs(x)<<std::endl;
    
    if(labs(x)*labs(x)+labs(y)*labs(y) <= D*D){
    	ans +=1;
    }
    
  }
  
  std::cout<<ans;
  
  return 0;
}

Measured memory_bytes: 3588
(defun dice (n k)
  (let ((log2 (log 2)))
  (labels ((dice0 (n0 rv)
                  (if (or (= n0 k) (> n0 n)) rv
                    (let ((nx (ceiling (/ (log (/ k n0)) log2))))
                      ;(print `(:dice0 ,n0 ,nx))
                      (dice0 (+ n0 1) (+ rv (/ 1 (expt 2 nx))))))))
    (let ((p0 (/ (dice0 1 0) n)))
      (if (< n k) p0
        (+ p0
           (/ (+ (- n k) 1) n)))))))

#|
(print (dice 3 10))
(print (dice 100000 5))
(format t "~,12f" (coerce (dice 3 10) 'double-float))
(format t "~,10f" (dice 100000 5))
|#

(format t "~,12f" (coerce (dice (read) (read)) 'double-float))



Measured memory_bytes: 16868
#include <iostream>
#include <string>
using namespace std;
int main() {
    int N;
    string op;
    cin >> N;
    while (N != 0) {
        int oneFace = 1;
        int twoFace = 2;
        int sum = 1;
        for (int i = 0; i < N; i++) {
            cin >> op;
            int transID;
            if (op == "North") transID = 0;
            if (op == "East") transID = 1;
            if (op == "West") transID = 2;
            if (op == "South") transID = 3;
            if (op == "Right") transID = 4;
            if (op == "Left") transID = 5;
            int trans[36] = {5,1,3,4,6,2,3,2,6,1,5,4,4,2,1,6,5,3,2,6,3,4,1,5,1,4,2,5,3,6,1,3,5,2,4,6};
            oneFace = trans[transID * 6 + oneFace - 1];
            twoFace = trans[transID * 6 + twoFace - 1];
            if (oneFace == 1) sum += 1;
            else if (twoFace == 1) sum += 2;
            else if (twoFace == 6) sum += 5;
            else if (oneFace == 6) sum += 6;
            else if (oneFace == 2 && twoFace == 3 ||
                oneFace == 3 && twoFace == 5 ||
                oneFace == 5 && twoFace == 4 ||
                oneFace == 4 && twoFace == 2) sum += 3;
            else sum += 4;
        }
        cout << sum << endl;
        cin >> N;
    }
}

Measured memory_bytes: 3100
import java.io.PrintWriter
import java.util.*

fun main(args: Array<String>) {
    val out = PrintWriter(System.out)
    val sc = Scanner(System.`in`)
    val n = sc.nextLong()
    val m = sc.nextLong()
    val py = mutableListOf<City113>()
    (0 until m).forEach { i ->
        py.add(City113(i, sc.next().toInt(), sc.next().toLong()))
    }
    problem113c(n, m, py, out)
}

fun problem113c(
    n: Long,
    m: Long,
    py: MutableList<City113>,
    out: PrintWriter
) {
    var current = 0
    var count = 0
    py.sorted().forEachIndexed { i, city ->
        if (current != city.p) {
            count = 0
            current = city.p
        }
        count++
        var ps = current.toString()
        while (ps.length < 6) {
            ps = "0$ps"
        }
        var cs = count.toString()
        while (cs.length < 6) {
            cs = "0$cs"
        }
        city.ans = ps + cs
    }
    py.sortedBy { it.city }.forEach { out.println(it.ans) }
    out.flush()
}

class City113(val city: Long, val p: Int, val y: Long, var ans: String = "") : Comparable<City113> {
    override fun compareTo(other: City113): Int {
        val diff = this.p - other.p
        if (diff != 0) return diff
        return (this.y - other.y).toInt()
    }
}

Measured memory_bytes: 85184
#include<stdio.h>
#include<string.h>
int main(){
    int count = 0;
    char s[200002];
    char t[200002];
    scanf("%s",s);
    scanf("%s",t);
    
    for(int i = 0; i < strlen(s); i++){
        if(s[i] != t[i]) count++;
    }
    printf("%d\n",count);
}


Measured memory_bytes: 2128
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <thread>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)

using namespace std;

int main()
{
	int n; cin >> n;
	vector<int> hs(n);
	for (auto& h : hs) {
		cin >> h;
	}

	int sum = 0;
	FOR_LT(i, 0, n) {
		bool is_ok = true;
		FOR_LT(j, 0, i) {
			if (hs[j] > hs[i]) {
				is_ok = false;
				break;
			}
		}
		if (is_ok) sum++;
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256