akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int X1 = cin.nextInt();
        int Y1 = cin.nextInt();
        int X2 = cin.nextInt();
        int Y2 = cin.nextInt();

        int distX = X2 - X1;
        int distY = Y2 - Y1;

        int X3 = X2 - distY;
        int Y3 = Y2 + distX;
        int X4 = X3 - distX;
        int Y4 = Y3 - distY;

        WriteLine("{0} {1} {2} {3}", X3, Y3, X4, Y4);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int s[n];
  int ans=0;
  vector<int> t;
  for(int i=0; i<n; i++){
    cin >> s[i];
    ans+=s[i];
    if(s[i]%10 != 0){
      t.push_back(s[i]);
    }
  }
  if(ans%10 != 0){
    cout << ans << endl;
  }else{
    if(t.size()==0){
      cout << 0 << endl;
    }else{
      sort(t.begin(),t.end());
      cout << ans-t[0] << endl;
    }
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <queue>
#include <set>
using namespace std;

int main(){
  int A, B, K;
  /* read input */
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &K);
  
  for(int i = 0; i < K; i++){
    if(i%2 == 0){ // Takahashi's turn
      A = A/2;
      B += A;
    }
    else{ // Aoki's turn
      B = B/2;
      A += B;
    }
  }
  // print result
  printf("%d %d", A, B);
  
  return 0;
}


Measured memory_bytes: 128
k = int(input())
def gcd(p,q):
  if(p % q == 0):
    return q
  return gcd(q, p % q)
res = 0
for i in range(1, k+1):
  for j in range(1, k+1):
    for p in range(1, k+1):
      res = res + gcd(i,gcd(j,p))
print(res)

Measured memory_bytes: 74128
import sys
input = sys.stdin.readline
from collections import deque


def read():
    N, K = map(int, input().strip().split())
    LR = []
    for i in range(K):
        l, r = map(int, input().strip().split())
        LR.append((l, r))
    return N, K, LR


def solve(N, K, LR, MOD=998244353):
    LR.sort()
    q = deque()
    for l, r in LR:
        for a in range(l, r+1):
            q.append(a)
    dp = [0 for i in range(N+1)]
    dp[1] = 1
    sdp = [0 for i in range(N+1)]
    sdp[1] = 1
    for i in range(2, N+1):
        for l, r in LR:
            a = max(1, i-r)
            b = min(i-l, i-1)
            if a <= b:
                dp[i] += sdp[b] - sdp[a-1]
                dp[i] %= MOD
        sdp[i] = sdp[i-1] + dp[i]
        sdp[i] %= MOD
    return dp[N]


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


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

int main(void) {
  int N, ans = 0;
  cin >> N;
  for (int i = 1; i <= N; i++) {
    if (to_string(i).length() % 2 == 1) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
a=list(input().split())
for i in range(N):
    a[i]=int(a[i])
b=tuple(a)
a.sort()
A1=a[N//2-1]
A2=a[N//2]
med=(A1+A2)/2
for i in range(N):
    if b[i]<=med:
        print(A2)
    else:
        print(A1)

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

public class Main {

	public char[] c;

	public boolean[] plus;

	public int n;

	public long sum;

	void run() {
		Scanner sc = new Scanner(System.in);

		c = sc.next().toCharArray();
		n = c.length;

		plus = new boolean[n - 1];

		long a = 0;
		for (int i = 0; i < n; i++) {
			a *= 10;
			a += c[i] - '0';
		}
		sum = a;
		for (int i = 1; i < n; i++) {
			solve(0, 0, i);
		}
		System.out.println(sum);
	}

	void solve(int i, int num, int k) {
		// 基底
		if (num == k) {
			// System.out.println("k:" + k);
			// System.out.println("plus:" + Arrays.toString(plus));
			long a = 0;
			for (int j = 0; j < n - 1; j++) {
				a += c[j] - '0';
				if (plus[j]) {
					sum += a;
					a = 0;
				} else {
					a *= 10;
				}
			}
			a += c[n - 1] - '0';
			sum += a;
			// System.out.println("sum : " + sum);
			return;
		}
		if (i == n - 1) {
			return;
		}

		plus[i] = true;
		solve(i + 1, num + 1, k);
		plus[i] = false;
		solve(i + 1, num, k);
	}

	public static void main(String[] args) {
		new Main().run();
	}

}


Measured memory_bytes: 9556
n = int(input())
p = [int(s) for s in input().split()]

num_buf = []
idx_buf = []

for i in range(n):
    if i+1 != p[i]:
        num_buf.append(p[i])
        idx_buf.append(i)


if len(idx_buf)==0:
    print("YES")
elif len(idx_buf) == 2 and num_buf[0] == idx_buf[1] + 1:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3064
// Best practice
 
#include<bits/stdc++.h>
 
#define int         long long
#define pb          push_back
#define pf          emplace_front
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define pii 		pair<int,int>
#define psi 		pair<string,int>
#define vi 			vector<int>
#define vpii  		vector<pii>
#define vvi 		vector<vi>
#define sz(x)	    (int)(x).size()
#define x           first
#define y           second
#define endl        '\n'
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD         1000000007
#define hell        998244353
#define prec(n) 	fixed<<setprecision(n)
#define ini(a, i) 	memset(a, i, sizeof(a))
#define output(x)   cout << (x ? "YES" : "NO")<<endl;
using namespace std;
 
#define debug(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<i<<" "; cout<< "]" << endl
#define debugp(vec) cout<<(#vec)<<" : [ "; for (auto& i: vec) cout<<"("<<i.x<<","<<i.y<<")"<<" "; cout<< "]" << endl
#define trace(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout << endl; }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << "[" << *it << ": " << a << "]\t";
    err(++it, args...);
}
 
// const int dx[4] = { -1, 1, 0, 0};
// const int dy[4] = {0, 0, -1, 1};
// int dX[] = { -1, -1, -1, 0, 0, 1, 1, 1 };
// int dY[] = { -1, 0, 1, -1, 1, -1, 0, 1 };
 
 
// Code from Here -------------------------------------------------------------------------------

const int nax = 3e3+1;
int dp[nax][nax];	

signed main() {
	tezz
 
	// #ifndef ONLINE_JUDGE
	// 	freopen("input.txt", "r", stdin);
	// 	freopen("output.txt", "w", stdout);
	// #endif

	string s, t;
	cin >> s >> t;
	int n=s.length(), m=t.length();
	for(int i=1; i<=n; i++){
		for(int j=1; j<=m; j++){
			if(s[i-1]==t[j-1]){
				dp[i][j] = dp[i-1][j-1]+1;
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	string ans="";
	int i=n, j=m;
	while(i!=0 && j!=0){
		if(dp[i][j]==dp[i][j-1])j--;
		else if(dp[i][j]==dp[i-1][j])i--;
		else {
			ans+=s[i-1];
			i--;
			j--;
		}
	}
	reverse(all(ans));
	cout << ans << endl;
	// cout << dp[n][m];
 
	return 0;
}  

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii(n); out((n+1)/2);
}

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

int main(){
  int i,j,cnt=0;
  int a[4];
  for(i=0;i<4;i++)cin>>a[i];
  for(i=0;i<4;i++){
    if(a[i]==1)cnt++;
    if(a[i]==7)cnt+=10;
    if(a[i]==9)cnt+=100;
    if(a[i]==4)cnt+=1000;
  }
  if(cnt==1111)cout<<"YES";
  else cout<<"NO";
}

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

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      String op;
      String[] words;
      Tree tree = new Tree();
      StringBuilder buf = new StringBuilder();

      for(int i=0,k=0; i<n; i++,k=0){
        words = br.readLine().split(" ");
        op  = words[k++];
        if ( op.equals("insert") ) { 
          tree.insert(Integer.parseInt(words[k++]));
        }
        else {
          buf.append(tree.getRoundPath());
        }
      }

      System.out.print(buf);

    }
    catch(IOException e) {
      System.out.println("IOException!");
    }
  }
}

class Tree {

  static final BTreeNode NIL = new BTreeNode();
  BTreeNode root;
  StringBuilder buf;

  public Tree() {
    root = NIL;
    buf = new StringBuilder();
  }

  public void insert(int val) {
    BTreeNode y = NIL;
    BTreeNode x = root;
    BTreeNode z = new BTreeNode();
    z.key = val;

    while( !x.equals(NIL) ) {
      y = x;
      if( z.key < x.key )
        x = x.left;
      else
        x = x.right;
    }
    z.parent = y;

    if( y.equals(NIL) ){
      root = z;
    }
    else if( z.key < y.key )
      y.left = z;
    else
      y.right = z;
  } 
  void preParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      buf.append(" ").append(u.key);
      preParse(u.left);
      preParse(u.right);
    }
  }
  void inParse(BTreeNode u) {
    if( !u.equals(NIL) ) {
      inParse(u.left);
      buf.append(" ").append(u.key);
      inParse(u.right);
    }
  }

  String getRoundPath() {
    buf.setLength(0);

    inParse(root);
    buf.append("\n");
    preParse(root);
    buf.append("\n");

    return buf.toString();
  }
}

class BTreeNode {
  int key;
  BTreeNode parent,left,right;

  public BTreeNode() {
    this.key = -1;
    this.parent =
    this.left =
    this.right = Tree.NIL;
  }

  @Override
  public boolean equals(Object o) {
    if(o == this) return true;
    if(o == null) return false;
    if(!(o instanceof BTreeNode)) return false;

    BTreeNode node = (BTreeNode)o;
    if(!(this.key == node.key)) return false;

    return true;
  }
}


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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back
#define sqr(a) ((a) * (a))
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define forn(i, n) for(int i = 0; i < int(n); i++) 
#define fore(i, l, r) for(int i = int(l); i < int(r); i++)

typedef long long li;
typedef long double ld;
typedef pair<int, int> pt;

template <class A, class B> ostream& operator << (ostream& out, const pair<A, B> &a) {
	return out << "(" << a.x << ", " << a.y << ")";
}

template <class A> ostream& operator << (ostream& out, const vector<A> &v) {
	out << "[";
	forn(i, sz(v)) {
		if(i) out << ", ";
		out << v[i];
	}
	return out << "]";
}

mt19937 rnd(time(NULL));

const int INF = int(1e9);
const li INF64 = li(1e18);
const int MOD = int(1e9) + 7;
const ld EPS = 1e-9;
const ld PI = acos(-1.0);

const int N = 100 * 1000 + 13;

int n, k, s;

bool read () {
	if (scanf("%d%d%d", &n, &k, &s) != 3)
		return false;
	return true;
}

void solve() {
	if (s == INF){
		forn(i, k) printf("%d ", s);
		forn(i, n - k) printf("1 ");
		puts("");
	}
	else{
		forn(i, k) printf("%d ", s);
		forn(i, n - k) printf("%d ", s + 1);
		puts("");
	}
}

int main() {
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
	
	int tt = clock();
#endif
	
	cerr.precision(15);
	cout.precision(15);
	cerr << fixed;
	cout << fixed;

#ifdef _DEBUG
	while(read()) {	
#else
	if(read()) {
#endif
		solve();
		
#ifdef _DEBUG
	cerr << "TIME = " << clock() - tt << endl;
	tt = clock();
#endif

	}
}

Measured memory_bytes: 1280
from itertools import combinations
H,W,K = map(int,input().split())
grid=[[v for v in input()] for _ in range(H)]


ans=0
for h_bit in range(1<<H):
    for w_bit in range(1<<W):
        h_set=set()
        w_set=set()
        for i in range(H):
            if h_bit>>i&1:
                h_set.add(i)
        for i in range(W):
            if w_bit>>i&1:
                w_set.add(i)

        black=0
        for i in range(H):
            for j in range(W):
                if i not in h_set and j not in w_set and grid[i][j]=="#":
                    black+=1
        if black==K:
            ans+=1
print(ans)
        


Measured memory_bytes: 68716
#include<bits/stdc++.h>
using namespace std;
bool comp(pair<long long int,long long int>a,pair<long long int,long long int>b)
{
    if(a.first==b.first)
    {
        if(a.second<=b.second)
        return true;
        else
        return false;
    }
    if(a.first>b.first)
    return true;
    else return false;
}
long long int gcd(long long int bdda,long long int chota)
{
    if(chota==0)
        return bdda;
    return gcd(chota,bdda%chota);
}
void solve()
{
    long long int n,d,y;
    cin>>n>>d>>y;
    long long int a[n];
    for(auto &x:a)
    cin>>x;
    long long int ans=0;
    for(auto x:a)
    ans+=(d-1)/x+1;
    cout<<ans+y<<endl;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t;    
    t=1;

    //cin>>t;
    while(t--)
    {
        solve();
    }
}


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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_V 1000000

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

  int n, k;
  cin >> n >> k;
  int rsl = 0;
  rep(i, 0, n) {
      int h;
      cin >> h;
      if(h >= k) rsl++;
  }
  cout << rsl << endl;
}


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

int32_t main() 
{
      int n;
      cin>>n;
      int h[n+1]={0},i;
      for(i=2;i<=n;i++)
      {
            int a;
            cin>>a;
            h[a]+=1;
      }
      for(i=1;i<=n;i++)
      {
            cout<<h[i]<<endl;
      }





	return 0;
}


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

int main()
{
    int a,b,big,small,x=0;
    scanf("%d%d",&a,&b);
    if((0<=a<=pow(10,9))&&(0<=b<=pow(10,9)))
    if(a>b){big=a;small=b;}
    else {big=b;small=a;}
    for(;big>=small;big--){
        if(abs(a-big)==abs(b-big))x=big;
    }
    if(x==0)printf("IMPOSSIBLE");
    else printf("%d",x);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  ll N , W; cin >> N >> W;
  vector<ll> v(N);
  vector<ll> w(N);
  rep(i,N) cin >> v[i] >> w[i];
  vector<vector<ll> > dp(2, vector<ll>(W + 1, -INF));
  // dp[i][j] iこまででのjでの重さでの価値の最大値
  dp[0][0] = 0;

  rep(i, N){
    for(ll j = W + 1; j >= 0; j--){
      if(j < w[i]) dp[1][j] = dp[0][j];
      else{
        dp[1][j] = max(dp[0][j] , dp[0][j - w[i]] + v[i]);
      }
    }
    rep(j, W + 1) dp[0][j] = dp[1][j];
  }

  ll ans = 0;
  rep(i,W + 1) ans = max(ans , dp[0][i]);
  cout << ans << endl;

}



Measured memory_bytes: 3388
import itertools
n = int(input())
e = [[int(_) for _ in input().split()] for _ in range(n)]

for xi, yi, hi in e:
    if hi > 0:
        xp = xi
        yp = yi
        hp = hi
        break

for cx, cy in itertools.product(range(101), range(101)):
    ch = abs(cx - xp) + abs(cy - yp) + hp
    flag = True
    for xi, yi, hi in e:
        flag = flag and max(ch - abs(cx - xi) - abs(cy - yi), 0) == hi
    if flag:
        print("%d %d %d" % (cx, cy, ch))


Measured memory_bytes: 3064
/*
substrの(int startindex, int lastindex)について
lastindexは「未満」なので、例えば末尾を指す時は
lastindex=s.length()で実質末尾をさせる
−１しなくてよい
*/

import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.nextLine();
    int point = 0;
    int C_idx = 0;

    if(s.charAt(0) == 'A'){
      point++;
    }else{
      printAnswer(false);
    }

    if(s.indexOf('C') == s.lastIndexOf('C')){
      if(2 <= s.indexOf('C') && s.indexOf('C') <= s.length()-2 ){
        point++;
        C_idx = s.indexOf('C');
      }else{
        printAnswer(false);
      }
    }else{
      printAnswer(false);
    }

    String substr1 = s.substring(1, C_idx);
    String substr2 = s.substring(C_idx+1, s.length());
    //System.out.println(substr1);
    //System.out.println(substr2);

    for(int i = 0; i < substr1.length(); i++){
      if(!(97 <= substr1.charAt(i)) || !(substr1.charAt(i) <= 122)){
        printAnswer(false);
      }
    }

    for(int i = 0; i < substr2.length(); i++){
      if(!(97 <= substr2.charAt(i)) || !(substr2.charAt(i) <= 122)){
        printAnswer(false);
      }
    }

    point++;

    if(point == 3){printAnswer(true);}
  }

  public static void printAnswer(boolean ans){
    if(ans){
      System.out.println("AC");
    }
    else{
      System.out.println("WA");
      System.exit(0);
    }
  }

}


Measured memory_bytes: 21844
#include <cstdio>
#include <cctype>
using namespace std;

int main(void){
    
    char C;
    
    while(1){
        scanf("%c", &C);
        if( isalpha(C) ){
            if( islower(C) ) printf( "%c", toupper(C) );
            else printf( "%c", tolower(C) );
        } else printf( "%c", C);
        
        if ( C == '\n') break;
    }
    
    return 0;
}


Measured memory_bytes: 2556
fun main() {
  val (a,b,c,d) = readLine()!!.split(' ').map { it.toInt() }
  var takahasiHP = a
  var aokiHP = c
  while (true) {
    aokiHP -= b
    if (aokiHP <= 0) puts("Yes")
    takahasiHP -= d
    if (takahasiHP <= 0) puts("No")
  }
}

fun puts(s: String) {
  println(s)
  System.exit(0)
}

Measured memory_bytes: 36496
n = int(input())
h = [int(x) for x in input().split()]
ans = 0
count = 0
for i in range(n-1):
    if h[i]>=h[i+1]:
        count += 1
    else:
        ans = max(ans,count)
        count = 0
else:
    ans = max(ans,count)
print(ans)

Measured memory_bytes: 63984
import sys 
from collections import Counter
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N = int(readline())
A = list(map(int,readline().split()))
Q = int(readline())
sum = sum(A)
d = Counter(A)

for i in range(Q):
    b, c = map(int,readline().split())
    sum += (c-b)*d[b]
    d[c] += d[b]
    d[b] = 0
    print(sum)


Measured memory_bytes: 24564
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << (x) << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int ss = s.size();
    for (int i = 0; i < ss; i++) {
        if ('Z' < s[i] + n) {
            s[i] = (char)(s[i] + n - 26);
        } else {
            s[i] = (char)(s[i] + n);
        }
    }

    cout << s << endl;
    n++;

    return 0;
}

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

char s[3055], t[3055];
int dp[3055][3055];

bool type[3055][3055];
bool same[3055][3055];

int main() {
	scanf("%s", s);
	scanf("%s", t);
	
	int n = strlen(s);
	int m = strlen(t);
	
	for (int i = 0; i <= n; i++) for (int j = 0; j <= m; j++) {
		if (s[i] == t[j]) {
			dp[i + 1][j + 1] = dp[i][j] + 1;
			same[i + 1][j + 1] = true;
		}
		
		if (dp[i][j] >= dp[i + 1][j]) {
			dp[i + 1][j] = dp[i][j];
			type[i + 1][j] = false;
			same[i + 1][j] = false;
		}
		if (dp[i][j] >= dp[i][j + 1]) {
			dp[i][j + 1] = dp[i][j];
			type[i][j + 1] = true;
			same[i][j + 1] = false;
		}
	}
	
	int p = n, q = m;
	string res = "";
	
	while (p > 0 && q > 0) {
		if (same[p][q]) {
			res += s[p - 1];
			p--, q--;
		} else if (type[p][q] == false) {
			p--;
		} else {
			q--;
		}
	}
	
	reverse(res.begin(), res.end());
	
	cout << res;
}


Measured memory_bytes: 54272
// AtCoder ABC127: D - Integer Cards
// 2019.9.8 bal4u

#include <stdio.h>
#include <stdlib.h>

typedef long long ll;

//// 高速入力
#if 1
int getchar_unlocked(void);
#define gc() getchar_unlocked()
#else
#define gc() getchar()
#endif

int in() {   // 非負整数の入力
	int n = 0, c = gc();
	do n = 10 * n + (c & 0xf); while ((c = gc()) >= '0');
	return n;
}

typedef struct { int b, c; } T;
T t[100005];
int N, M;
int A[100005];

// a[i]>=key という条件を満たす最小のi
int lower_bound(int x) {
  int m, l = 0, r = N;
  while (l+1 < r) {
    m = (l+r) >> 1;
    if (A[m] < x) l = m; else r = m;
  }
  return A[l] < x? r: l;
}

int cmp_a(const void *u, const void *v) { return *(int *)u - *(int *)v; }
int cmp_t(const void *u, const void *v) {
	int t;
	if (t = ((T *)v)->c - ((T *)u)->c) return t;
	return ((T *)v)->b - ((T *)u)->b;
}

inline static ll sum(int l, int r) { ll s = 0; while (l < r) s += A[l++]; return s; }

int main()
{
	int i, w, pos; ll ans;
	
	N = in(), M = in();
	for (i = 0; i < N; i++) A[i] = in();
	qsort(A, N, sizeof(int), cmp_a);
	for (i = 0; i < M; i++) t[i].b = in(), t[i].c = in();
	qsort(t, M, sizeof(T), cmp_t);
	
	w = 0;
	for (i = 0; i < M && w < N; i++) {
		pos = lower_bound(t[i].c) - w;
		if (pos <= 0) break;
		if (t[i].b > pos) t[i].b = pos;
		w += t[i].b;
	}
	
	ans = 0, pos = 0;
	while (--i >= 0) ans += (ll)t[i].b * t[i].c, pos += t[i].b;
	ans += sum(pos, N);
	printf("%lld\n", ans);
	return 0;
}


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

int main() {
  int N,ans=1;
  string S;
  cin >> N >> S;
  
  for(int i=1;i<N;i++){
    if(S[i]!=S[i-1]) ans++;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll dp[100009][4]= {-1};
ll inf = -1*1e9;
ll n;
ll arr[100009][4];
ll dfs(int index,int j)
{
  ll choice1,choice2;
  if(index>=n-1)
  return 0;
if(dp[index][j]!=-1)
return dp[index][j];
if(j==1)
{
  choice1=arr[index+1][0]+dfs(index+1,0);
    choice2=arr[index+1][2]+dfs(index+1,2);
     
}
else if(j==2)
{
  choice1=arr[index+1][0]+dfs(index+1,0);
    choice2=arr[index+1][1]+dfs(index+1,1);
}
else
{
   choice1=arr[index+1][2]+dfs(index+1,2);
    choice2=arr[index+1][1]+dfs(index+1,1);
}
return dp[index][j] =max(choice1,choice2);

}

int main()
{
  cin >> n;
  memset(dp,-1,sizeof dp);
  for(int i=0;i<n;i++)
  {

    cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
  }  
  
 cout<<max(arr[0][0] +dfs(0,0),max(arr[0][1] +dfs(0,1),arr[0][2] +dfs(0,2)));

}

Measured memory_bytes: 11136
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline bool Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+" ";
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
constexpr const ll INF = 1e15;
constexpr const ll MOD = 1000000007;
constexpr const ll MAX = 1e9;
constexpr ll nx[4] = {1,0,-1,0};
constexpr ll ny[4] = {0,1,0,-1};
typedef pair<ll,ll> P;
int main(){
    int n,m;
    cin >> n >> m;
    ll l = 1,r = n;
    if (n%2){
        rep(i,m){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
    }
    else{
        int c = ((n-1)/2+1)/2;
        rep(i,min(c,m)){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
        r--;
        rep(i,m-c){
            cout << l << " " << r << endl;
            l++;
            r--;
        }
    }
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define res register int
#define ll long long
//#define cccgift
//#define getchar()(p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++)
//char buf[1<<21],*p1=buf,*p2=buf;
template<typename T>
inline void read(T &x)
{
    static char ch;bool f=1;
    for(x=0,ch=getchar();!isdigit(ch);ch=getchar()) if(ch=='-') f=0;
    for(;isdigit(ch);x=(x<<1)+(x<<3)+(ch^48),ch=getchar());x=f?x:-x;
}
template<typename T>
void print(T x)
{
    if (x<0) x=-x,putchar('-');
    if (x>9) print(x/10);
    putchar(x%10+48);
}
template<typename T>
inline void print(T x,char ap) {print(x);if (ap) putchar(ap);}
template<typename T>
inline void chkmax(T &x,const T &y) {x=x<y?y:x;}
template<typename T>
inline void chkmin(T &x,const T &y) {x=x<y?x:y;}
int n,m,ver[360001],nxt[360001],head[601],ans,x,y,du[601],du1[601],l,r,q[601];
long double f[601],minn,g[601],sum[601];
bool mp[601][601];
inline void toposort() {
	l=1,r=0;
	for(res i=1;i<=n;++i) if(!du[i]) q[++r]=i;
	while(l<=r) {
		x=q[l++];
		for(res i=head[x];i;i=nxt[i]) {
			f[ver[i]]+=(f[x]+1)/du1[ver[i]];
			if(du1[ver[i]]>1) sum[ver[i]]+=(f[x]+1)/(du1[ver[i]]-1);
			if(!(--du[ver[i]])) q[++r]=ver[i];
		}
	}
}
inline void add(int x,int y) {ver[++ans]=y,nxt[ans]=head[x],head[x]=ans;}
int main()
{
	read(n),read(m);
	for(res i=1;i<=m;++i) read(x),read(y),assert(x<y),add(y,x),++du[x],mp[x][y]=true;
	memcpy(du1,du,sizeof(du));
	toposort(),minn=f[1],g[1]=1;
	for(res i=2;i<=n;++i)
	  for(res j=1;j<i;++j) if(mp[j][i]) g[i]+=g[j]/du1[j];
	for(res i=n-1;i;--i)
	  for(res j=i+1;j<=n;++j) if(mp[i][j]&&du1[i]>1) chkmin(minn,f[1]-f[i]*g[i]+g[i]*(sum[i]-(f[j]+1)/(du1[i]-1)));
	printf("%.10Lf\n",minn);
	return 0;
}
/* stuff you should look for
    * int overflow, array bounds
    * special cases (n=1?), set tle
    * do something instead of nothing and stay organized
*/ 

Measured memory_bytes: 2048
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int H,W,K;
  cin >> H >> W >> K;
  v(string) G(H);
  rep(i,H) {
    cin >> G[i];
  }
  vi ids(W,-1);
  vvi ans(H,vi(W,0));
  int id = 1;
  int line = 0;
  rep(i,H) {
    rep(j,W) {
      if(G[i][j] == '#') {
        int last = j;
        srep(k,j,W) {
          if(G[i][k] == '#') {
            last = k;
          }
        }
        rep(k,last+1) {
          srep(l,line,i+1) {
            ans[l][k] = id;
          }
          if(G[i][k] == '#') {
            id++;
          }
        }
        srep(k,last+1,W) {
          srep(l,line,i+1) {
            ans[l][k] = id-1;
          }
        }
        line = i+1;
        break;
      }
    }
  }
  srep(l,line,H) {
    rep(j,W) {
      ans[l][j] = ans[line-1][j];
    }
  }
  rep(i,H) {
    rep(j,W) {
      cout << ans[i][j] << " ";
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1280
import sys

sys.setrecursionlimit(10 ** 7)
rl = sys.stdin.readline


def solve():
    N = int(rl())
    A = list(map(int, rl().split()))
    
    A.sort(reverse=True)
    B = [A[0]]
    for ai in A[1:]:
        B += [ai, ai]
    ans = sum(B[:N - 1])
    print(ans)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 125000
import sys


def input():
    return sys.stdin.readline().strip()


sys.setrecursionlimit(20000000)

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


def main():
    S = input()
    answer = 0
    ans_list = [0]
    for i in range(3):
        if S[i] == "R":
            answer += 1
        if S[i] == "S":
            ans_list.append(answer)
            answer = 0
    ans_list.append(answer)
    print(max(ans_list))


if __name__ == "__main__":
    main()


Measured memory_bytes: 9012
#include <iostream>
#include <cmath>
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <cstring>

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define ll long long
#define pii pair < int, int >
#define pll pair < long long, long long>
#define ull unsigned long long
#define vi vector < int >
#define vll vector < long long >
#define sz(a) (int)a.size()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it++)
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x))
#define fname "searching"

const int inf = (int)1e9;
const ll INF = (ll)1e18;
const double eps = 1e-9;
const double pi = acos(-1.0);
const int mod = (int)1e9 + 7;

int n;
int cnt[100][30];

string solve(){
    cin >> n;
    for(int i = 0; i < n; ++i){
        string s;
        cin >> s;
        for(int j = 0; j < sz(s); ++j) cnt[i][s[j] - 'a']++;
    }
    string ans = "";
    for(int i = 0; i < 26; ++i){
        int cur = inf;
        for(int j = 0; j < n; ++j){
            cur = min(cur, cnt[j][i]);
        }
        for(int j = 0; j < cur; ++j)
            ans += char(i + 'a');
    }
    return ans;
}

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

    cout << solve() << "\n";
    
    return 0;
}

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

int main() {
    vector<int> t(5);
    for (int i = 0; i < 5; i++) {
        cin >> t[i];
    }

    vector<int> menu = {0, 1, 2, 3, 4};
    int ans = 1e9;
    bool is_last = true;
    while (is_last == true) {
        int fin_time = 0;
        for (int i = 0; i < 5; i++) {
            fin_time += t[menu[i]];
            if (fin_time % 10 != 0 && i < 4) {
                fin_time += 10 - (fin_time % 10);
            }
        }
        ans = min(ans, fin_time);

        is_last = next_permutation(menu.begin(), menu.end());
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
//重みなしグラフの場合
vi p(100000);
vector<vector<int>> L(100000);      //隣接リスト
vector<bool> Visited(100000, false);   //頂点が訪問済みか否かを格納
vvi connect(100000), pos(100000);
//頂点数n, 枝数mのグラフの入力(重みなし)
void Graph_Input(int n, int m)
{
	for(int i=0; i<m; i++){
		int from, to;
		cin>>from>>to;
		from--; to--;
		L[from].push_back(to);
		//無向グラフの場合以下も追加
		L[to].push_back(from);
	}
}
//深さ優先探索(現在位置をiとする)
void DFS(int i, int k)
{
	Visited[i]=true;
	connect[k].push_back(p[i]);
	pos[k].push_back(i);

	for(int j=0; j<(int)L[i].size(); j++){
		if(Visited[L[i][j]]) continue;
		DFS(L[i][j], k);
	}
}
int main(void)
{
	int n, m;

	cin>>n>>m;

	rep(i, n){
		cin>>p[i];
		p[i]--;
	}

	Graph_Input(n, m);

	int t=0;
	rep(i, n){
		if(!Visited[i]){
			DFS(i, t);
			t++;
		}
	}
	int ans=0;
	rep(i, t){
		sort(all(pos[i]));
		/*rep(j, connect[i].size()){
			cout<<connect[i][j]<<" ";
		}
		cout<<endl;*/
		rep(j, connect[i].size()){
			if(binary_search(all(pos[i]), connect[i][j])) ans++;
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 15788
import collections
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
a = collections.Counter(d)
b = collections.Counter(t)

for i in b.keys():
	if i not in a:
		print ("NO")
		exit()
	if b[i] > a[i]:
		print ("NO")
		exit()
	#print(i,b[i])
print ("YES")

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

int main()
{
   int a,b,c;
   cin>>a>>b>>c;
   if ((a+b+c)>=22){
    cout<<"bust"<<endl;
   }
   else
   {
       cout<<"win"<<endl;
   }


    return 0;
}


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

int main(){
	int n,d1,d2,i,c=0,ans=0;
  	cin >> n;
  	for(i=0;i<n;i++){
     	cin >> d1 >> d2;
      	if(d1==d2) {
          c++;
        } else {
          c = 0; 
        }
      	if(c==3) {
         ans = 1; 
        }
    }
  	if(ans==1) {
     	cout << "Yes" << endl; 
    } else {
     	cout << "No" << endl; 
    }
}


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

using namespace std;

using ll = long long;
using Vi = vector<int>;
using Vl = vector<ll>;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

constexpr int I_INF = (1 << 30);
constexpr ll L_INF = (1ll << 62);

//==================================

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N, M;
    cin >> N >> M;

    Vi p(M), s(M);
    for (int i = 0; i < M; ++i) {
        int pi;
        string si;
        cin >> pi >> si;
        --pi;
        p[i] = pi;
        s[i] = (si == "AC") ? 1 : -1;
    }

    int ac = 0;
    int pena = 0;
    Vi penas(N);
    Vi acs(N);
    for (int i = 0; i < M; ++i) {
        if (s[i] == 1 && acs[p[i]] == 0) {
            ++ac;
            pena += penas[p[i]];
            acs[p[i]] = 1;
        }
        else {
            ++penas[p[i]];
        }
    }

    cout << ac << " " << pena << endl;
    
    return 0;
}

Measured memory_bytes: 1792
S = input()
N = len(S)+1
a = [0] * N
for i in range(N-1):
	if S[i] == '<':
		a[i+1] = a[i]+1
for i in range(N-2, -1, -1):
  if S[i] == '>':
    a[i] = max(a[i+1]+1,a[i])
 
print(sum(a))

Measured memory_bytes: 23336
import java.util.Scanner;
 
class Main{
  public static void main(String[] arg){
    int n, max = -1000000, min = 1000000, input;
    long sum = 0;

    Scanner in = new Scanner(System.in);
    n = in.nextInt();

    for(int i=0; i<n; i++){
        input = in.nextInt();
        if(input > max){
            max = input;
        }
        if( input < min){
            min = input;
        }
        sum += input;
    }
    
    System.out.println(min + " " + max + " " + sum);
  }
}

Measured memory_bytes: 41880
#include <bits/stdc++.h>
#define watch(x) std::cout << (#x) << " is " << (x) << std::endl
#define print(x) std::cout << (x) << std::endl
using LL = long long;

int main() {
	//freopen("in","r",stdin);
	std::ios::sync_with_stdio(false);
	std::cin.tie(nullptr);
	int n;
	std::cin >> n;
	std::vector<int> dp(n);
	for (int i = 1; i < n; ++i) {
		for (int j = 1; i * j < n; ++j) {
			++dp[i * j];
		}
	}
	std::cout << std::accumulate(dp.begin(), dp.end(), 0) << std::endl;
	return 0;
}

Measured memory_bytes: 7072
import sys
N=int(sys.stdin.readline().strip())
A=map(int, sys.stdin.readline().split())
A.sort(reverse=True)
N-=1
ans=0
for i,a in enumerate(A):
    if i==0:
        ans+=a
        N-=1
    else:
        if 2<=N:
            ans+=a*2
            N-=2
        elif N==1:
            ans+=a
            N-=1
        elif N==0:
            print ans
            quit()


Measured memory_bytes: 93784
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int a, b;
int main()
{
	scanf("%d%d", &a, &b);
	if (a <= 9 && b <= 9)
		printf("%d\n", a * b);
	else
		puts("-1");
}


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

typedef long long int ll;
typedef pair<int, int> pi;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

int main() {
  int n, m;
  cin >> n >> m;
  vector<pi> v(n);
  for (int i = 0; i < n; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  auto f = [](pi a, pi b) { return a.second < b.second; };
  priority_queue<pi, vector<pi>, decltype(f)> job(f);
  ll now = 0, ans = 0;
  for (int i = 1; i <= m; i++) {  // iは日付
    while (v[now].first <= i && now < n) {
      job.push(v[now]);
      now++;
    }
    if (!job.empty()) {  // 仕事があるなら
      ans += job.top().second;
      job.pop();
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 2168
use std::cmp;

fn main(){
    let mut sc = Scanner::new();
    while let Ok(n) = sc.wrapped() {
        let mut a = vec![0i32; n];
        for e in a.iter_mut() {
            *e = sc.next();
        }

        let solve = || {
            let mut cnt = vec![0; n+1];
            let mut max = 0;
            for i in 0..n {
                cnt[a[i] as usize] += 1;
                max = cmp::max(max, a[i]);
            }
            let mut k = max;
            while k >= (max + 1) / 2 {
                let c = & mut cnt[k as usize];
                if max%2 == 0 && k == (max + 1) / 2 {
                    if *c != 1 {
                        return false;
                    }
                    *c -= 1;
                } else {
                    if *c < 2 {
                        return false;
                    }
                    *c -= 2;
                }
                k -= 1;
            }
            k += 1;
            while k >= 0 {
                if cnt[k as usize] > 0 {
                    return false;
                }
                k -= 1;
            }
            true
        };
        println!("{}", if solve() { "Possible" } else { "Impossible" })
    }
}

#[allow(dead_code)]
struct Scanner {
    token_buffer : Vec<String>,
    index : usize,
}

#[allow(dead_code)]
impl Scanner {
    fn new() -> Scanner{
        Scanner { token_buffer: vec![], index: 0 }
    }

    fn wrapped<T>(& mut self) -> Result<T,&str> where T: std::str::FromStr {
        let s = try!(self.fetch_token());
        let t = try!(s.parse::<T>().map_err(|_| "Parse error"));
        Ok(t)
    }
    fn next<T>(& mut self) -> T where T: std::str::FromStr {
        self.wrapped::<T>().unwrap()
    }

    fn fetch_token(&mut self) -> Result<&String,&str> {
        while self.index >= self.token_buffer.len() {
            let mut st = String::new();
            while st.trim() == "" {
                match std::io::stdin().read_line(&mut st) {
                    Ok(l) if l > 0 => continue,
                    Ok(_)  => return Err("End of file"),
                    Err(_) => return Err("Failed to read line"),
                }
            }
            self.token_buffer = st.split_whitespace()
                .map(|x| x.to_string())
                .collect();
            self.index = 0;
        }

        self.index += 1;
        Ok(&self.token_buffer[self.index - 1])
    }
}


Measured memory_bytes: 380
import java.io.*;
import java.util.*;
import java.util.ArrayList;
 
class Main
{
  public static void main (String[] arg)
  {
    Scanner scan = new Scanner(System.in);
    
    int A = Integer.parseInt(scan.next()); //冷蔵庫    
    int B = Integer.parseInt(scan.next()); //電子レンジ
    int M = Integer.parseInt(scan.next()); //割引
    
    int[] ref = new int[A]; //冷蔵
    int[] mic = new int[B]; //レンジ
    
    //冷蔵庫の値段入れる
    for(int i = 0; i < A;i++){
      ref[i] = Integer.parseInt(scan.next());
    }
    
    //レンジの値段入れる
    for(int i = 0; i < B;i++){
      mic[i] = Integer.parseInt(scan.next());
    }
    
    int cost;
    
    int min_ref = 100001;
    int min_mic = 100001;
    
    
    for(int i = 0; i < A;i++){
      if(ref[i] < min_ref){
        min_ref = ref[i];
      }
    }
    for(int i = 0; i < B;i++){
      if(mic[i] < min_mic){
        min_mic = mic[i];
      }
    }
    
    cost = min_ref + min_mic;
    
    for(int i = 0; i < M ;i++){
      int point_a = Integer.parseInt(scan.next());
      int point_b = Integer.parseInt(scan.next());
      int discount = Integer.parseInt(scan.next());
      
      int tmp = ref[(point_a - 1)] + mic[(point_b - 1)] - discount;
      
      if(tmp < cost){
        cost = tmp;
      }
    }
    
    System.out.println(cost);
  }
}


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

int main() {

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a.at(i);
    int suma = 0;
    int sumb = 0;

    sort(a.begin(), a.end(), greater<int>());

    for(int i = 0 ; i < n; ) {

        if(n%2 == 0) {
            suma += a.at(i);
            sumb += a.at(i+1);
            i += 2;
        }else{
            if(i < n-1) {
            suma += a.at(i);
            sumb += a.at(i+1);
            i += 2;
            }else{
                suma += a.at(n-1);
                i += 2;
            }
        }
    }

    cout << suma-sumb << endl;

  	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int H,W;
  scanf("%d%d",&H,&W);
  char S[H+2][W+2];
  for (int i = 0; i < H+2; i++){
    for (int j = 0; j < W+2; j++){
      S[i][j]=0;
    }
  }
  for (int i = 1; i < H+1; i++){
    getchar();
    for (int j = 1; j < W+1; j++){
      scanf("%c[^\n]",&S[i][j]);
    }
  }
  
  for (int i = 1; i<H+1; i++){
    for (int j = 1; j<W+1; j++){
      if (S[i][j]=='#')
      {
        for (int a = 0; a < 3; a++){
          for (int b = 0; b < 3; b++){
            if (S[a+i-1][b+j-1]=='.')
            {
              S[a+i-1][b+j-1]=49;
            }else if (S[a+i-1][b+j-1]>=49)
            {
              S[a+i-1][b+j-1]++;
            }
          }
        }
      }
    }
  }

  for (int i = 1; i < H+1; i++){
    for (int j = 1; j < W+1; j++){
      if (S[i][j]=='.')
      {
        printf("%c",'0');
      }else
      {
        printf("%c",S[i][j]);
      }
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1660
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
   int A,B;
   string S,T,U;
   cin >> S >> T >> A >> B >> U;
   if(S == U){
       cout << A - 1 <<' '<< B << endl;
   }
   if(T == U){
       cout << A <<' '<< B - 1 << endl;
   }
}

Measured memory_bytes: 3200
S = io.read()
T = {}
for i = 1, 26 do
    T[i] = false
end
for i = 1, #S do
    AtoI = S:sub(i, i):byte() - 96
    T[AtoI] = true
end

flag = true
for i = 1, 26 do    
    if not T[i] then
        print(string.char(96+i))
        flag = false
        break
    end
end
if flag then
    print("None")
end

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define P pair<ll,ll>
#define rep(i,n) for(ll (i)=0; (i)<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;cin>>s;
  ll l=s.length(),snum=0,tnum=0,pos;
  rep(i,l) {
    pos=l-1-i;
    if(s[pos]=='T') tnum++;
    else {
      if(tnum>0) tnum--;
      else snum++;
    }
  }
  ll ans=snum+tnum;
  print(ans);
  return 0;
}

Measured memory_bytes: 720
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,a[55],p;
long long f[55][2]; 
int main(){
	scanf("%d%d",&n,&p);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]);
	f[0][0]=1;
	for (int i=1;i<=n;i++){
		f[i][0]=f[i-1][0];f[i][1]=f[i-1][1]; 
		f[i][a[i]%2]+=f[i-1][0];
		f[i][(a[i]+1)%2]+=f[i-1][1]; 
	}
	printf("%lld\n",f[n][p]);
	return 0;
}


Measured memory_bytes: 128