akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#include <bitset>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long N;
  cin >> N;
  unordered_map<long, long> mp;
  rep (i, N) {
    long A;
    cin >> A;
    mp[A]++;
  }
  long ans = 0;
  for (auto it: mp) {
    if (it.second <= 2) continue;
    if (it.second % 2 == 0) {
      ans += (it.second - 2) / 2;
      mp[it.first] = 2;
    } else {
      ans += (it.second - 1) / 2;
      mp[it.first] = 1;
    }
  }
  long twos = 0;
  for (auto it: mp) if (it.second == 2) twos++;

  ans += twos / 2;
  twos %= 2;
  ans += twos;

  ans = N - ans * 2;
  cout << ans << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 4388
n=int(input())

a=[]
for i in range(n):
    a.append(int(input()))

a_max=max(a)
a_max_cnt=a.count(a_max)

for i in range(n):
    if (a[i]!=a_max or a_max_cnt>1):
        print(a_max)
    else:
        print(max(a[:i]+a[i+1:]))


Measured memory_bytes: 19860
loop do
  n, x = gets.split.map(&:to_i)
  break if n.zero? && x.zero?

  c = 0
  (1..n).each do |i|
    (i + 1..n).each do |j|
      (j + 1..n).each do |k|
        c += 1 if (i + j + k) == x
      end
    end
  end

  puts c
end



Measured memory_bytes: 8872
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int LINF=1e18;

signed main(){
	int N,K;cin>>N>>K;
	vector<int> a(N),f(N);
	for(int i=0;i<N;i++)cin>>a[i];
	for(int i=0;i<N;i++)cin>>f[i];
	sort(a.begin(),a.end());
	sort(f.rbegin(),f.rend());
	int l=-1,r=LINF;
	while(r-l>1)
	{
		int m=(r+l)>>1;
		int cnt=0;
		for(int i=0;i<N;i++){
			if(a[i]*f[i]>m){
				cnt+=(a[i]*f[i]-m)/f[i];
				if((a[i]*f[i]-m)%f[i])cnt++;
			}
		}
		if(cnt>K)l=m;
		else r=m;
	}
	cout<<r<<endl;
}

Measured memory_bytes: 3328
from functools import reduce
from operator import add

N = int(input())
li = list(map(int,input().split()))
s_all = reduce(add,li)
a = 0
b = s_all
ans = s_all
for t in range(N):
    a += li[t]
    b -= li[t]
    if abs(a-b) < ans:
        ans = abs(a-b)
print(ans)


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <bitset>
#include <functional>
using namespace std;
const constexpr int INF = 1e9;
typedef std::pair<std::string,double> P;

int L, N, sum; 
string s;
vector<int> v;
int dist[1000];
bool dp[11000];
string alph="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
void solve(){
    bool f1=true, f2=false, f3=true;
    int cnt=0;
    if(s[0]!='A') f1=false;
    s[0]='a';
    for(int i=2; i<=s.size()-2; ++i){
        if(s[i]=='C') {
            cnt++;
            s[i]='c';
        }
    }
    if(cnt==1) f2=true;
    cnt=0;   
    for(int i=0; i<s.size(); ++i){
        for(int j=0; j<26; ++j){
            if(s[i]==alph[j]) {
                f3=false; break;
            }
        }
    }
    if(f1&&f2&&f3) cout << "AC" << endl;
    else cout << "WA" << endl;
}
int main() {
    cin >> s;
    solve();
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int b[3];
	int i;
	
	for (i = 0; i < 3; i++){
		scanf("%d", &b[i]);
	}
	
	if (b[2] == 1){
		printf("Open\n");
	}
	else if (b[0] == 1 && b[1] == 1){
		printf("Open\n");
	}
	else {
		printf("Close\n");
	}
	
	return (0);
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
int main() {
  int k;
  cin >> k;
  string s;
  cin >> s;
  if (s.size() <= k) {
    cout << s << endl;
  } else {
    string t = s.substr(0,k);
    cout << t << "..." << endl;
  }
}

Measured memory_bytes: 3628
/*																													   
 Templatka c++ Kacper Fis																							   																											   //
*/																													  
																								   
#include <bits/stdc++.h>																							   
																													   
using namespace std; 																								   
		
const double eps = 1e-9;																							   
const int INF = 1000000001;																						   
const float PI = 3.14;																								   
typedef long long LL;																								   
																													   
typedef vector<int> vi;																								   
typedef list<int> li;																								   
typedef queue<int> qi; 																								   
typedef pair<int,int> ii; 																							   
typedef map<string,int> msi; //np msi['nazwa'] = 'liczba'															   
typedef vector<ii> vii; //vector par<int>, do tworzenia tablicy dla grafów wagowych #dijkstra #Bellman_Ford			   
typedef priority_queue< ii, vector<ii>, greater<ii> > pq; //kolejka priorytetowa vectorów par(top()=min) #dijkstra	   
																													   																				   
vector<ii>::iterator iter;																							   
																													   																				   
#define print_list(x) for(it = (x).begin(); it != (x).end(); it++) {cout << *it << " ";}							   
#define print_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++) {cout << *it2 << " ";}						   
#define search_list(x) for(it = (x).begin(); it != (x).end(); it++)													   
#define search_vector(x) for(it2 = (x).begin(); it2 != (x).end(); it2++);											   
#define pb(x) push_back(x) 																							   
#define pf(x) push_front(x)																							   
#define mp(x, y) make_pair(x, y)                                                                                       
///////////////////////////////////////////////GLOBAL DEFINITIONS////////////////////////////////////////////////////////



///////////////////////////////////////////////////FUNCTIONS/////////////////////////////////////////////////////////////


/////////////////////////////////////////////////////MAIN////////////////////////////////////////////////////////////////
int main(int argc, char* argv[])																					 
{ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);                  												       
/////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
	
	int n, k;
	cin >> n >> k;
	
	int m = n / k;
	int t = (n + k/2) / k;
	LL ans = 0;
	ans = pow(m, 3);
	if(k % 2 == 0) ans += pow(t, 3);
	cout << ans << endl;
	
	
	
	
	
	
	
	
	
	
	
	return 0;
}


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

int main()
{
	int N;
	cin >> N;
	vector<int> D(N);
	for (int i = 0; i < N; ++i)
		cin >> D[i];
	int sum = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = i + 1; j < N; j++)
		{
			sum += D[i] * D[j];
		}
	}
	cout << sum << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <climits>
#include <iomanip>
#include <algorithm>
#include <queue>
#include <map>
#include <tuple>
#include <iostream>
#include <deque>
#include <array>
#include <set>
#include <functional>

int main() {
	int h, w; std::cin >> h >> w;
	std::vector<std::string> state(h);
	for (auto& line : state) std::cin >> line;
	std::vector<std::vector<int>> up(h, std::vector<int>(w, -1));
	std::vector<std::vector<int>> down(h, std::vector<int>(w, h));
	std::vector<std::vector<int>> right(h, std::vector<int>(w, w));
	std::vector<std::vector<int>> left(h, std::vector<int>(w, -1));
	for (auto i = 0; i < h; ++i) {
		for (auto j = 0; j < w; ++j) {
			if (state[i][j] == '#') {
				up[i][j] = i;
				left[i][j] = j;
			}
			else {
				if (i > 0) {
					up[i][j] = up[i - 1][j];
				}
				if (j > 0) {
					left[i][j] = left[i][j - 1];
				}
			}
		}
	}
	for (auto i = 1; i <= h; ++i) {
		for (auto j = 1; j <= w; ++j) {
			if (state[h - i][w - j] == '#') {
				down[h - i][w - j] = h - i;
				right[h - i][w - j] = w - j;
			}
			else {
				if (i > 1) {
					down[h - i][w - j] = down[h - i + 1][w - j];
				}
				if (j > 1) {
					right[h - i][w - j] = right[h - i][w - j + 1];
				}
			}
		}
	}
	int max = 0;
	for (auto i = 0; i < h; ++i) {
		for (auto j = 0; j < w; ++j) {
			if (state[i][j] != '#') {
				auto count = down[i][j] - up[i][j] + right[i][j] - left[i][j] - 3;
				if (max < count) {
					max = count;
				}
			}
		}
	}
	std::cout << max << std::endl;
};

Measured memory_bytes: 67200
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

  int main(){
    ll n;
    cin >> n;
    ll u=0,r=0;
    for (ll i=1LL;i*i <= n;i++){
      if (n%i==0) {
        u=i;r=n/i;
      }
    }
    cout << u+r-2 << endl; 
  }


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<vector>
#include<set>
#include<algorithm>
#include<tuple>
#include<utility>
#include<cctype>
#include<climits>
#include<map>
#include<queue>
#include<functional>

using namespace std;
template<class T> void chmax(T& a, T b) {if(a < b){a=b;}}
template<class T> void chmin(T& a, T b) {if(a > b){a=b;}}

#define REP(i,a,n) for(int i=a;i<n;++i)
#define RUP(a,b) ((a+b-1)/(b))
#define ENT "\n"
#define REV(v) reverse(v.begin(),v.end())
#define SRTV(v) sort(v.begin(),v.end())
#define SRTAG(a,n) sort(a,a+n,greater<>())
#define MOD 1000000007

typedef long long ll;
typedef tuple<int,int,bool> Tb;

int atcoder(){
    //入力
    int n;
    cin >> n;
    ll ans[110000];
    ans[0]=1;
    //処理
    REP(i,1,n+1){
        ans[i]=(ans[i-1]*i)%MOD;
    }
    //出力
    cout << ans[n] << ENT;
    return 0;
}

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


Measured memory_bytes: 1024
MOD = 10 ** 9 + 7
table_len = 500010

fac = [1, 1]
for i in range(2, table_len):
    fac.append(fac[-1] * i % MOD)
    
finv = [0] * table_len
finv[-1] = pow(fac[-1], MOD - 2, MOD)
for i in range(table_len-1, -1, -1):
    finv[i-1] = finv[i] * i % MOD

def comb(n, k):
    return fac[n] * finv[k] * finv[n-k] % MOD

def perm(n, k):
    return fac[n] * finv[n-k] % MOD

N, M = map(int, input().split())

print(sum( ((-1)**k * comb(N, k) * perm(M, k) * perm(M-k, N-k)**2 % MOD ) for k in range(N+1)) % MOD)

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

const int N = 1e5 + 5;
const int MOD = 1e9 + 7;

int dp[N][2];
vector<int> adj[N];
int n;

void read() {
  scanf("%d", &n);
  for (int i = 1 ; i < n ; i++) {
    int u, v;
    scanf("%d %d", &u, &v);
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
}

int solve(int pos, int color, int prv) {
  int &ret = dp[pos][color];
  if (ret != -1) return ret;

  ret = 1;
  for (int nex : adj[pos]) {
    if (nex == prv) continue;

    int ways = solve(nex, 0, pos);
    if (color == 0) {
      ways = (ways + solve(nex, 1, pos)) % MOD;
    }

    ret = 1ll * ret * ways % MOD;
  }

  return ret;
}

int work() {
  memset(dp, -1, sizeof dp);
  
  int ret = (solve(1, 0, -1) + solve(1, 1, -1)) % MOD;
  return ret;
}

int main() {
  read();
  cout << work() << endl;
  return 0;
}

Measured memory_bytes: 14848
#include <bits/stdc++.h> 
using namespace std; 
  
#define rep(i,k,n)  for (int i = k; i < n; ++i)
#define repr(i,k,n) for (int i = k; i >= n; --i)
typedef long long ll;
const ll bound = 1e18;
int main(void) {
    int n;
    ll result = 1;
    cin >> n;
    bool zero = false;
    vector<ll> vec(n);
    rep(i,0,n) {
        cin >> vec[i];
        if (vec[i] == 0) zero = true;
    }
    if (zero) {
        cout << 0;
        return 0;
    }
    rep(i,0,n) {
        if (result > bound / vec[i]) {
            result = -1;
            break;
        }
        result *= vec[i];
    }
    cout << result << "\n";
    return 0;
}


Measured memory_bytes: 4036
import java.io.*;
import java.lang.*;
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;

public class Main {
	public static void main(String[] args){
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		String buf;
		try {
			for(;;){
				buf = br.readLine();
				Scanner scanner = new Scanner(buf);
				int n = scanner.nextInt();
				int r = scanner.nextInt();
				if(n == 0 && r == 0){
					return;
				}
				ArrayList<Integer> cards = new ArrayList<Integer>();
				int i, p = 0, c;
				for(i = n; i > 0; i--){
					cards.add(i);
				}
				for(i = 0; i < r; i++){
					buf = br.readLine();
					scanner = new Scanner(buf);
					p = scanner.nextInt();
					c = scanner.nextInt();

					ArrayList<Integer> bList = new ArrayList<Integer>(cards.subList(0, p - 1));
					ArrayList<Integer> oList = new ArrayList<Integer>(cards.subList(p - 1, p - 1 + c));
					ArrayList<Integer> rList = new ArrayList<Integer>(cards.subList(p - 1 + c, n));
					cards = new ArrayList<Integer>();
					cards.addAll(oList);
					cards.addAll(bList);
					cards.addAll(rList);
					//System.out.println(cards.toString());
				}
				System.out.println(cards.get(0));
			}
		}
		catch(IOException e) {
			System.out.println("Read error.");
			return;
		}
	}
}

Measured memory_bytes: 88564
import math
def saidai(x, y):
    x, y = math.fabs(x), math.fabs(y)
    y, x = max(x, y), min(x, y)
    if x == 0:
        return y

    return saidai(x, y % x)

def saisyo(x, y):
    spam = saidai(x, y)
    return spam * (x / spam) * (y / spam)

# a,b,c,d,e,f  = list(map(int,'1 2 3 4 5 6'.split()))
try:
    while 1:

        a,b,c,d,e,f  = list(map(int,input().split()))
        s = saidai(a, d)

        k1 = d / s * -1
        k2 = a / s

        y = (k1*c + k2 * f) / (k1 * b + k2 * e)
        x = (c - b*y) / a
        print("{:.3f} {:.3f}".format(x, y))
except Exception:
    pass

Measured memory_bytes: 7852
#include<iostream>
#include <complex>
#include <vector>
using namespace std;
int main() {
	typedef struct {
		int time;
		int x;
		int y;
	}coord;
	int N;
	cin >> N;
	vector<coord> I;

	I.resize(N+1);
	I[0].time = 0;
	I[0].x = 0;
	I[0].y = 0;
	for (int i = 1; i < N+1; i++) {
		cin >> I[i].time >> I[i].x >> I[i].y;
	}
	int flag = 1;
	for (int i = 0; i<N ; i++) {
		int A = abs(I[i + 1].x - I[i].x) + abs(I[i + 1].y - I[i].y);
		int delt = I[i + 1].time - I[i].time;
		if (A == 0 && delt%2 == 0) {
			continue;
		}
		if (A == 0 && delt % 2 != 0) { flag = -1; break; }
		if(A > delt) { flag = -1; break; }
		if ((delt % A) % 2 != 0) { flag = -1; break; }
	}
	if (flag == 1)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

#define int long long 

signed main(){

	int n;
	cin >> n;

	queue<int> q;
	q.push(0);

	vector<int> ans;

	while (!q.empty()) {
		int t = q.front();
		q.pop();

		if (t <= n) {
			int u = t;
			bool is_used[10] = { };
			while (u > 0) {
				is_used[u % 10] = true;
				u /= 10;
			}
			if (is_used[3] && is_used[5] && is_used[7]) {
				ans.push_back(t);
			}
		} else {
			continue;
		}
		
		for (auto num : {3, 5, 7}) {
			int a = t * 10 + num;
			q.push(a);
		}
	}

	cout << ans.size() << endl;

	return 0;
}


Measured memory_bytes: 892
#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 (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
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() {
    int M1, D1, M2, D2;
    cin >> M1 >> D1;
    cin >> M2 >> D2;
    if(M1 != M2) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
// AOJ ALDS1_2_C Stable Sort
// 2018.4.27 bal4u

#include <stdio.h>
#include <string.h>

typedef struct { char c; int a; int id; } DATA;

void bubble_sort(int n, DATA *a)
{
	int i, f;
	DATA x;

	do {
		f = 0;
		for (i = n-1; i > 0; i--) {
			if (a[i].a < a[i-1].a) {
				x = a[i], a[i] = a[i-1], a[i-1] = x;
				f = 1;
			}
		}
	} while (f);
}

void selection_sort(int n, DATA *a)
{
	int i, j, minj;
	DATA x;

	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j].a < a[minj].a) minj = j;
		}
		if (i != minj) {
			x = a[i], a[i] = a[minj], a[minj] = x;
		}
	}
}


//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

DATA a[102], b[102];

int main()
{
	int N, i, f;

	N = in();
	for (i = 0; i < N; i++) {
		a[i].c = getchar_unlocked();
		a[i].a = getchar_unlocked();
		a[i].id = i;
		getchar_unlocked();			// skip
	}
	memcpy(b, a, sizeof(DATA)*N);

	bubble_sort(N, a);
	f = 0;
	putchar(a[0].c), putchar(a[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(a[i].c), putchar(a[i].a);
		if (a[i-1].a == a[i].a && a[i-1].id > a[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");

	selection_sort(N, b);
	f = 0;
	putchar(b[0].c), putchar(b[0].a);
	for (i = 1; i < N; i++) {
		putchar(' ');
		putchar(b[i].c), putchar(b[i].a);
		if (b[i-1].a == b[i].a && b[i-1].id > b[i].id) f = 1;
	}
	putchar('\n');
	puts(f? "Not stable": "Stable");
	return 0;
}



Measured memory_bytes: 2100
N, M = list(map(int, input().split()))
TENBOUDAI = list(map(int, input().split()))
# linked_list = { i: set() for i in range(N)}

_list = {i:1 for i in range(1,N+1)}
for m in range(M):
    i,j= list(map(int, input().split()))
    # if i in _list and j in _list:
    if TENBOUDAI[i-1] <= TENBOUDAI[j-1]:
        # _list.remove(i)
        _list[i] =0
    if TENBOUDAI[j-1] <= TENBOUDAI[i-1]:
        # _list.remove(j)
        _list[j] =0


# print(_list)
print(sum(_list.values()))

Measured memory_bytes: 24512
#include <iostream>
#include <vector>
#include <iterator>
 
/**
 * @brief ??°????????¨???
 * @param [in] start  ??°????????????
 * @param [in] end    ??°????????????
 * @return none
 */
void outputSequence(std::vector<int>::iterator start,std::vector<int>::iterator end)
{
	using namespace std;
	
	vector<int>::iterator iter;
	for( iter = start; iter != end; iter++ )
	{
		cout << *iter;
		if( iter != (end-1) )
		{
			cout << " ";
		}
	}
	cout << endl;
	return;
}
 
/**
 * @brief ????????????????????????
 * @param [in]  start  ??°????????????
 * @param [in]  end    ??°????????????
 * @param [out] start  ??°????????????
 * @param [out] end    ??°????????????
 * @return swapCnt     ???????????°
 */
int bubbleSort(std::vector<int>::iterator start,std::vector<int>::iterator end)
{
	using namespace std;
	
	int swapCnt = 0;
	vector<int>::iterator count, swap_a, swap_b;
	 
	for(count = start; count != end; count++)
	{
		for(swap_a = end-1; swap_a != count; swap_a--)
		{
			swap_b = swap_a;
			advance( swap_b , -1 );
			if( *swap_b > *swap_a )
			{
				iter_swap( swap_a, swap_b );
				swapCnt++;
			}
		}
	}
	return swapCnt;
}
 
int main(void){
	using namespace std;

	int numData;
	cin >> numData;
	 
	/* ??°?????\??? */
	vector<int> vectorInt;
	vectorInt.reserve(100);
	int input;
	while( cin >> input )
	{
		vectorInt.push_back( input );
	}
	 
	/* ???????????????????????? */
	int swapCnt = bubbleSort( vectorInt.begin(), vectorInt.end() );
	outputSequence( vectorInt.begin(), vectorInt.end() );
	cout << swapCnt << endl;
	 
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <string>
#include <utility> // pairとか
#include <vector>
#include <array>
#include <list>
#include <deque>
#include <map>
#include <algorithm> // sortとか findとか
#include <functional> // algorithmに渡せる関数
#include <cmath>
#include <cstdio>
#include <numeric> // gcd,lcmとか

#define rep(iter, beg, end, step) for (long(iter) = (beg); (iter) < (end); (iter) += (step))

using namespace std;
int main() {
	int a, b;
	cin >> a;
	cin >> b;

	int diff = b - a;
	int sum = 0;
	rep(i, 1, diff, 1) {
		sum += i;
	}
	cout << sum - a << "\n";
	return 0;
}


Measured memory_bytes: 256
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
fn main(){
    let n=read::<i32>();
    let x=read::<i32>();
    for i in 0..n+1{
        for j in 0..n+1{
            if i+j>n{continue}
            let k=n-i-j;
            if i*1000+j*5000+k*10000==x{
                println!("{} {} {}",k,j,i);
                return;
            }
        }
    }
    println!("-1 -1 -1");
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std ;
typedef long long ll ;
const ll N = 5055;
ll dp[N][N], A, B;
int n, cnt[N][N], p[N], pos[N]; 
int main()
{
	scanf("%d%lld%lld", &n, &A, &B) ;
	for(int i = 1 ; i <= n ; i ++){
		scanf("%d", &p[i]) ;
		pos[p[i]] = i ; 
	}
	for(int i = 2 ; i <= n ; i ++)
		for(int j = p[i]+1 ; j <= n ; j ++)	
			cnt[i][j] = cnt[i][j-1] + (pos[j] < i) ;
	for(int i = 1 ; i <= n ; i ++)
		for(int j = 1 ; j <= n ; j ++)
			if(p[i] > j) dp[i][j] = dp[i-1][j] ;
			else dp[i][j] = min(dp[i-1][j]+B, cnt[i][j]*A+dp[i-1][p[i]-1]) ; 
	cout << dp[n][n] ;
}

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

using ll=long long; 

void solve(){
	int n;
	cin>>n;
	vector<int>L(n);
	for(int i=0; i<n; i++)cin>>L[i];
	int sum=accumulate(L.begin(), L.end(), 0);
	for(int i=0; i<n; i++){
		int tmp=sum;
		tmp-=L[i];
		//cout<<tmp<<" "<<L[i]<<endl;
		if(tmp<=L[i]){
			cout<<"No"<<endl;
			return;
		}
	}
	cout<<"Yes"<<endl;
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
using namespace std;
#define INF (1<<29)

int main(void) {
    int N, W, ans = 0;
    scanf("%d %d", &N, &W);
    int v[N], w[N], t[W+1];
    for (int i = 0; i < N; i++) {
        scanf("%d %d", &v[i], &w[i]);
    }

    for (int i = 0; i <= W; i++) t[i] = 0;

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= W - w[i]; j++) {
            t[j + w[i]] = max(t[j + w[i]], t[j] + v[i]);
            ans = max(ans, t[j + w[i]]);
        }
    }

    printf("%d\n", ans);

    return 0;
}

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

using namespace std;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define ll long long int
#define mod 1000000007
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define prec(n) fixed << setprecision(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int>>
#define PI 3.1415926535897932384626
#define bits(n) __builtin_popcount(n)


void solve()
{
    int a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k)
    cout<<k;
    else
    {
        if(b>=k-a)
        cout<<a;
        else
        {
            if(c>=k-a-b)
            cout<<a-(k-a-b);
        }        
    }   

}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input1.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output1.txt", "w", stdout);
#endif

    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, l;
  cin >> n >> l;
  vector<string> s(n);
  for (int i = 0; i < n; i++) {
  	cin >> s[i];
  }
  sort(s.begin(), s.end());
  string min = "";
  
  for (int i = 0; i < n; i++) {
  	min += s[i];
  }
  cout << min << endl;
}

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

int main() {
  int n; cin >> n;
  
  vector<int> odd(100001);
  vector<int> even(100001);
  for (int i = 0; i < n; i++) {
    int a; cin >> a;
    if (i % 2) odd[a]++;
    else even[a]++;
  }
  
  int o1 = 0;
  int o2 = 0;
  int io;
  int e1 = 0;
  int e2 = 0;
  int ie;
  
  for (int i = 0; i <= 100000; i++) {
    if (odd[i] > o2) {
      if (odd[i] > o1) {
        o2 = o1;
        o1 = odd[i];
        io = i;
      } else {
        o2 = odd[i];
      }
    }
    if (even[i] > e2) {
      if (even[i] > e1) {
        e2 = e1;
        e1 = even[i];
        ie = i;
      } else {
        e2 = even[i];
      }
    }
  }
  
  int ans;
  if (io != ie) ans = n - o1 - e1;
  else ans = min(n - o1 - e2, n - o2 - e1);
  
  cout << ans << endl;
}

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

public class Main {
    static final Scanner sc    = new Scanner(System.in);
    static final int     MOD   = (int) 1E9 + 7;
    static final long    INF_L = (long) 4E18;
    static final int     INF   = Integer.MAX_VALUE;
    
    public static void main(String[] args) {
        char c = nstr().charAt(0);
        System.out.println((char)(c + 1));
    }
    
    @Deprecated
    static int nint() {
        return sc.nextInt();
    }

    @Deprecated
    static int[] nints(int N) {
        return nints(N, 0, 0);
    }

    @Deprecated
    private static int[] nints(int N, int padL, int padR) {
        int[] a = new int[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nint();
        return a;
    }

    static long nlong() {
        return sc.nextLong();
    }

    static long[] nlongs(int N) {
        return nlongs(N, 0, 0);
    }

    static long[] nlongs(int N, int padL, int padR) {
        long[] a = new long[padL + N + padR];
        for (int i = 0; i < N; i++)
            a[padL + i] = nlong();
        return a;
    }

    static double ndouble() {
        return sc.nextDouble();
    }

    static double[] ndoubles(int N) {
        return ndoubles(N, 0, 0);
    }

    static double[] ndoubles(int N, int padL, int padR) {
        double[] d = new double[N + padL + padR];
        for (int i = 0; i < N; i++) {
            d[padL + i] = ndouble();
        }
        return d;
    }

    static String nstr() {
        return sc.next();
    }

    static char[] nchars() {
        return sc.next().toCharArray();
    }

    static char[] nchars(int padL, int padR) {
        char[] temp = sc.next().toCharArray();
        char[] ret = new char[temp.length + padL + padR];
        System.arraycopy(temp, 0, ret, padL, temp.length);
        return ret;
    }

    static char[][] nchars2(int H, int W) {
        return nchars2(H, W, 0, 0);
    }

    static char[][] nchars2(int H, int W, int padLU, int padRD) {
        char[][] a2 = new char[H + padLU + padRD][W + padLU + padRD];
        for (int i = 0; i < H; i++)
            System.arraycopy(nchars(), 0, a2[padLU + i], padLU, W);
        return a2;
    }

    static long min(long... ls) {
        return Arrays.stream(ls).min().getAsLong();
    }

    static long max(long... ls) {
        return Arrays.stream(ls).max().getAsLong();
    }

    static long abs(long a) {
        return Math.abs(a);
    }
}


Measured memory_bytes: 21204
N, M = map(int,input().split())
X = list(map(int,input().split()))

if N >= M:
    print(0)
else:
    X.sort()
    diff = []

    for i in range(M-1):
        diff.append(X[i+1]-X[i])

    diff.sort(reverse=True)

    ans = X[M-1]-X[0] - sum(diff[:N-1])
    print(ans)

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

int main() {
  int D,N; cin >>D >>N;
  int temp=pow(100,D);
  if (N<=99) cout <<temp*N <<endl;
  else cout <<temp*101 <<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<queue>
#include<list>
#include<vector>
#include<cmath>

using namespace std;

int main(){

    int n, W;
    cin >> n >> W;

    int w[n], v[n];
    for(int i=0;i<n;i++)cin >> w[i] >> v[i];

    unsigned long long dp[W+1];
    for(int i=0;i<=W;i++)dp[i] = 0;
    for(int i=0;i<n;i++){
        for(int j=0;j<=W;j++){
            if(j>=w[i]){
                dp[j-w[i]] = max(dp[j-w[i]], dp[j]+v[i]);
            }
        }
    }
    //for(int i=0;i<=W;i++)cout << dp[i] << ", ";
    sort(dp, dp+W+1);
    cout << dp[W] << endl;
}


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

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    if(a>b){
        cout << 0 << endl;
    }else{
        if(n==1){
            if(a!=b){
                cout << 0 << endl;
            }else{
                cout << 1 << endl;
            }
        }else{
            cout << static_cast<long int>(n - 2) * static_cast<long int>(b - a) + 1 << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
	using namespace std;
	#define IOS ios::sync_with_stdio(false), cin.tie(0)
	#define REP(i, n) for (int i = 0; i < n; i++)
	#define FOR(i, a, b) for (int i = a; i < b; i++)
	#define ALL(x) (x).begin(), (x).end()
	#define dump(x) cout << (x) << endl
	#define LMAX 9223372036854775807LL
	#define LMIN -9223372036854775807LL

	using ll = long long;
	template<typename T>
	using vec = vector<T>;
	using P = pair<ll, ll>;

	template <typename A, size_t N, typename T>
	void Fill(A (&array)[N], const T &val)
	{
		fill((T *)array, (T *)(array + N), val);
	}
	
	ll pas[51][52];
	const ll INF = 1e18;
	const ll mod = 1e9 + 7;

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

	void setpascal(int n){
		pas[0][0] = 1;
		for(int i = 1;i <= n;i++){
			for(int j = 0;j <= i;j++){
				if(j == 0 || j == i){
					pas[i][j] = 1;
				}
				else pas[i][j] = pas[i - 1][j - 1] + pas[i - 1][j];
			}
		}
	}
	int main(){
		IOS;
		setpascal(50);
		ll n, a, b;
		cin >> n >> a >> b;
		vec<ll> v(n);
		map<ll,ll,greater<ll>> mp;
		REP(i,n){
			cin >> v[i];
			mp[v[i]]++;
		}
		sort(ALL(v),greater<ll>());
		
		ll cnt = 0;
		ll kosuu = 0;
		ll sum = 0;
		if(mp[v[0]] >= a){
			cout << fixed << setprecision(6) << (double)v[0] << endl;
			ll ans = 0;
			for(int i = a;i <= min(b,mp[v[0]]);i++){
				ans += pas[mp[v[0]]][i];
			}
			dump(ans);
			return 0;
		}
		for(auto it = mp.begin();it != mp.end();it++){
			if(cnt + it->second >= a){	
				sum += it->first * (a - cnt);
				cnt += it->second;
				kosuu = pas[it->second][cnt - a];
				break;
			}
			else {
				sum += it->first * it->second;
				cnt += it->second;
			}
		}
		double ans = (double)sum / a;
		cout << fixed << setprecision(6) << ans << endl;
		dump(kosuu);
	}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
 ll a[105],w[105],n;
 ll dp[105][100007];
 ll solve(ll i,ll c)
 {
     if(dp[i][c]!=-1)
     return dp[i][c];
     if(i==n)
     return 0;
     ll ans1,ans2;
     ans1=solve(i+1,c);
     if(c-w[i]>=0)
     {
         ans2=solve(i+1,c-w[i])+a[i];
     }
     else
     ans2=ans1;
     dp[i][c]= max(ans1,ans2);
     return dp[i][c];
 }
int main()
{
     for(ll i=0;i<105;i++)
     for(ll j=0;j<100007;j++)
     dp[i][j]=-1;
    ll c;
    cin>>n>>c;
   
    for(ll i=0;i<n;i++)
    {
        cin>>w[i]>>a[i];
    }
    cout<<solve(0,c);
    return 0;
}


Measured memory_bytes: 82304
program A320C
    implicit none
    integer(8)::N,i,j,k,C(5),ans
    character(10),allocatable,dimension(:)::S
    read*,N
    allocate(S(N))
    read*,S
    C=0
    ans=0
    do i=1,N
        if(S(i)(1:1)=="M")C(1)=C(1)+1
        if(S(i)(1:1)=="A")C(2)=C(2)+1
        if(S(i)(1:1)=="R")C(3)=C(3)+1
        if(S(i)(1:1)=="C")C(4)=C(4)+1
        if(S(i)(1:1)=="H")C(5)=C(5)+1
    end do
    do i=1,3
        do j=i+1,4
            do k=j+1,5
                ans=ans+C(i)*C(j)*C(k)
            end do
        end do
    end do

    print'(i0)',ans
end program A320C

Measured memory_bytes: 1792
'use strict';
const main = input => {
  const s = input[0];
  for (let i = 0; i < s.length; i++) {
    if ((((i+1)%2 == 1) && (s[i] == 'L')) || (((i+1)%2 == 0) && (s[i] == 'R'))) {
      console.log('No');
      return;
    }
  }
  console.log('Yes');
}
main(require("fs").readFileSync("/dev/stdin", "utf8").split('\n'));

Measured memory_bytes: 7372
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using Enu = System.Linq.Enumerable;
using System.Numerics;

public class Program
{
    static readonly int Mod = (int)1e9 + 7;

    public void Solve()
    {
        int N = Reader.Int();
        var A = Reader.IntArray(N);
        var B = Reader.IntArray(N);
        Console.WriteLine(SolveIt(N, A, B));
    }

    long SolveIt(int N, int[] A, int[] B)
    {
        var known = new int[N];
        known[0] = A[0];

        for (int i = 1; i < N; i++)
            if (A[i] > A[i - 1])
            {
                known[i] = A[i];
                if (B[i] < A[i]) return 0;
            }
            else if (A[i] < A[i - 1]) return 0;

        if (known[N - 1] != 0 && known[N - 1] != B[N - 1]) return 0;
        known[N - 1] = B[N - 1];
        for (int i = N - 2; i >= 0; i--)
            if (B[i] > B[i + 1])
            {
                if (A[i] < B[i]) return 0;
                if (known[i] == 0) known[i] = B[i];
                else if (known[i] != B[i]) return 0;
            }
            else if (B[i] < B[i + 1]) return 0;

        long ans = 1;
        for (int i = 1; i < N - 1; i++)
            if (known[i] == 0)
                ans = ans * Math.Min(A[i], B[i]) % Mod;

        return ans;
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    static string[] Split(string s) { return s.Split(separator, op); }
    static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 24528
#include <stdio.h>
#include <string.h>

int main(void)
{
	char str[1001],p[1001],t[8],tmp;
	int q,a,b,i,j,k;
	scanf("%s%d",str,&q);
	for(i=0;i<q;i++){
		scanf("%s%d%d",t,&a,&b);
		if(strcmp(t,"print")==0){
			for(j=a;j<=b;j++)printf("%c",str[j]);
			puts("");
		}
		else if(strcmp(t,"reverse")==0){
			for(j=a;j<b;j++){
				for(k=b;k>j;k--){
					tmp=str[k-1];
					str[k-1]=str[k];
					str[k]=tmp;
				}
			}
		}
		else{
			scanf("%s",p);
			j=a;
			k=0;
			while(j<=b){
				str[j]=p[k];
				j++;
				k++;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 2108
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P);
P dequeue();
int minimum(int,int);

int main(){
  int elaps = 0, c;
  int i, q;
  P u;

  scanf("%d %d", &n, &q);

  head=1;
  tail=n+1;

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  while(head != tail){
    u = dequeue();
    c = minimum(q,u.t);//使う時間をマイナスにならないように、持っている時間と引くべき時間を比べて、小さいほうを返す
    u.t = u.t - c;//上でもってきた時間を引いて、残り時間を計算する
    elaps = elaps + c;//それぞれの処理にかかった時間（を加算する）
    if(u.t>0) enqueue(u);//0以上なら最後尾に並んでもう一周
    else{
      printf("%s %d\n",u.name,elaps);//0になったら出力
    }
  }
  return 0;
}

void enqueue(P x){
  Q[tail]=x;
  if(tail+1 == LEN) tail=0;
  else tail++;
}

P dequeue(){
  P x = Q[head];
  if(head+1 == LEN) head=0;
  else head++;
  return x;
}

int minimum(int a,int b){
  if(a<b)return a;
  else return b;
}


Measured memory_bytes: 11952
#include<stdio.h>
#include<stdlib.h>
#include<string.h>

#define SIZE 20000

int Stack1[SIZE] = { 0 };
int tail = 0;
int Stack2[SIZE][2];	//(\pos,S)
int tail2 = 0;

void Push(int key) {
	Stack1[tail] = key;
	tail++;
}

int Pop() {
	tail--;
	return Stack1[tail];
}

void Push2(int pos, int S) {
	Stack2[tail2][0] = pos;
	Stack2[tail2][1] = S;
	tail2++;
}

int main() {
	char ch;
	int cnt = 0;
	int buffPop, buff;
	int SUM = 0, count = 0;
	while (1) {
		scanf("%c", &ch);
		if (ch == '\n')break;

		if (ch == '\\') {
			Push(cnt);
		}
		if (ch == '/') {
			if (tail != 0) {
				buffPop = Pop();
				Push2(buffPop, cnt - buffPop);
				while (Stack2[tail2 - 2][0] > buffPop) {
					buff = Stack2[tail2 - 1][1];
					tail2 -= 2;
					Push2(buffPop, Stack2[tail2][1] + buff);
				}
			}
		}
		cnt++;
	}

	for (int i = 0; i < tail2; i++) {
		SUM += Stack2[i][1];
		count++;
	}
	printf("%d\n", SUM);
	printf("%d", count);
	if (count)printf(" ");
	for (int i = 0; i < tail2; i++) {
		printf("%d", Stack2[i][1]);
		if (i != tail2 - 1)printf(" ");
	}
	printf("\n");
	return 0;
}


Measured memory_bytes: 2744
#include <cstdio>
#include <cmath>

#define MAX_N 30
#define MAX_W 30

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

int main(){
    int w,n,ans[MAX_W];
    int a[MAX_N], b[MAX_N];

    scanf("%d",&w);
    scanf("%d", &n);
    for(int i = 0; i < n; i++){
        scanf( "%d, %d", &a[i], &b[i]);
    }

    // Initialize
    for(int i = 0; i < w; i++){
        ans[i] = i + 1;
    }

    // Solve
    for(int i = 0; i < n; i++){
        swap(&ans[ a[i] - 1 ], &ans[ b[i] - 1 ]);
    }

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



    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
int main(){
    int Like[31] = {0};
    int Tabemono;
    int People;
    int i,j;
    int num;
    int k;
    int result=0;
    scanf("%d %d", &People, &Tabemono);
    for(i=0; i<People; i++){
        scanf("%d", &k);
        for(j=0; j<k; j++){
            scanf("%d", &num);
            Like[num]++;
        }
    }
    for(i=1; i<=Tabemono; i++){
        if(Like[i]==People) result++;
    }
    printf("%d", result);
    return 0;
}

Measured memory_bytes: 128
s = ''.join(list(reversed(input())))
t = ''

while True:
    n = len(t)
    if len(s) <= n:
        if s == t:
            print('YES')
        else:
            print('NO')
        break
    if s[n] == 'm':
        t += ''.join(list(reversed('dream')))
    elif s[n] == 'e':
        t += ''.join(list(reversed('erase')))
    elif s[n:n+3] == 'rem':
        t += ''.join(list(reversed('dreamer')))
    elif s[n:n+3] == 'res':
        t += ''.join(list(reversed('eraser')))
    else:
        print('NO')
        break

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

int main(){
  string S;
  cin >> S;
  bool p = S[0]=='R';
  bool q = S[1]=='R';
  bool r = S[2]=='R';
  
  if(p and q and r)
    cout << 3 << endl;
  else if((p and q) or (q and r))
    cout << 2 << endl;
  else if(p or q or r)
    cout << 1 << endl;
  else
    cout << 0 << endl;
  return 0;
}

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

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define rep(i,s,g) for(ll (i) = (s);(i) < (g);++i)
#define rrep(i,s,g) for(ll (i) = (s);i >= (g);--(i))
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;

int main(){
	int n,m;cin >> n >> m;
	vector<pair<int,int>> v;
	REP(i,n){
		int a,b;
		scanf("%d %d",&a,&b);
		v.PB(MP(a,b));
	}
	
	sort(ALL(v));
	int a,b,c,d;
	int ans;
	
	REP(i,m){
		scanf("%d %d %d %d",&a,&b,&c,&d);
		int st = 0;
		ans = 0;
		for(int i = st;i < n;i++){
			if(v[i].FI > c)break;
			if(v[i].FI >= a && v[i].SE >= b && v[i].SE <= d)ans++;
		}
		
		printf("%d\n",ans);
	}
	
	return 0;
}


Measured memory_bytes: 3328
/*
  Contest 066
  A - ringring
  Rakesh Kumar --> 01/09/2020
 */

#include <bits/stdc++.h>

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

    int a = 0, b = 0, c = 0;
    std::cin >> a >> b >> c;
    std::cout << std::min(a + b, std::min(b + c, a + c)) << std::endl;

    return 0;
}


Measured memory_bytes: 3592
import sys

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()
    a = n
    for i in range(n-1):
        a += (i+1) * (n-i)
        u, v = nm()
        if u > v:
            u, v = v, u
        a -= u * (n - v + 1)
    print(a)
    return

solve()


Measured memory_bytes: 9216
S = input()

i = 0
if len(S) % 2 != 0:
    print('No')
    exit()

while i + 1 <= len(S):
    if S[i] == 'h' and S[i+1] == 'i':
        i += 2
    else:
        break

if i == len(S):
    print('Yes')
else:
    print('No')


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


int main() {
 
    int N, M;
    cin >> N >> M;
    int sum = 0;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
        sum+=A.at(i);
    }
    
    int ans = 0;
    for (int i = 0; i < N; i++) {
        if (sum <= A.at(i) * (4*M)) {
            ans++;
        }
        if(ans == M){
            cout << "Yes" << endl;
            return 0;
        }
    }
    
    cout << "No" << endl;
}

Measured memory_bytes: 256
#[allow(non_snake_case)]

fn main() {
    let mut _line = String::new();
    std::io::stdin().read_line(&mut _line).unwrap();
    let mut A = String::new();
    std::io::stdin().read_line(&mut A).unwrap();
    A.pop();
    let mut A: Vec<_> = A.split(' ').map(|s| s.parse::<u32>().unwrap()).collect();
    let mut i = 0;
    while A.iter().all(|a| a%2 == 0) {
        A = A.iter().map(|a| a/2).collect();
        i += 1;
    }

    println!("{}", i);
}

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

int main() {
	int H, W, N; cin >> W >> H >> N;
	int minx = 0,maxx = W,miny = 0,maxy = H;
	for( int i = 0 ; i < N ; i++ ){
		int x, y, a; cin >> x >> y >> a;
		if( a == 1 ) minx = max(minx, x);
		if( a == 2 ) maxx = min(maxx, x);
		if( a == 3 ) miny = max(miny, y);
		if( a == 4 ) maxy = min(maxy, y);
	}
	
	cout << max(maxx - minx,0) * max(maxy - miny,0) << endl;
	
}

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

int main(){
  string inStr;
  
  cin >> inStr;
  
  if(inStr[2]==inStr[3]&&inStr[4]==inStr[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
    
  }
  
  return 0;
}

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

int main(){
  
  int h,w; cin >> h >> w; int n ; cin >> n;
  int sr,sc; cin >> sr >> sc;
  
  string S,T; cin >> S >> T;
  
  sr--; sc--;
  
  int x = sr; int y = sc; 
  
  //右
  for(int i = 0; i < n; i++){
      if( S[i] == 'R'){
        y++; 
        if( y >= w){ cout << "NO" << endl; return 0;}
      }
    
      if( T[i] == 'L'){ 
        if( y > 0){ y--;}
      }
    
  }
  
  x = sr; y = sc; 
  
  //左
  for(int i = 0; i < n; i++){
    
      if( S[i] == 'L'){
        y--; 
        if( y < 0 ){ cout << "NO" << endl; return 0;}
      }
      if( T[i] == 'R'){ 
        if( y < w-1){ y++;}
      }
    
  }
 
  x = sr; y = sc; 
  
  //上
  for(int i = 0; i < n; i++){
    
      if( S[i] == 'U'){
         x--;
        if( x < 0 ){ cout << "NO" << endl; return 0;}
      }
      if( T[i] == 'D'){ 
        if( x < h-1){ x++;}
      }
    
  }
 
  x = sr; y = sc; 
  
  //下
  for(int i = 0; i < n; i++){
      if( S[i] == 'D'){
        x++; 
        if( x >= h){ cout << "NO" << endl; return 0;}
      }
      if( T[i] == 'U'){ 
        if( x > 0){ x--;}
      }
    
  }
 
  
  cout << "YES" << endl;
  
  return 0;
}
  
 
        
                       

Measured memory_bytes: 776
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
#include <random>
#include <cassert>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 4e2 + 10;
LL cnt[N];
int dp[2][N];
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n;
	cin >> n;
	if (n == 3 || n == 5 || n == 7) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
H, W, K = map(int, input().split())

D = [list(list(input())) for _ in range(H)]


import numpy as np
D = np.array(D)

count = 0
for bit_H in range(2**H):
    for bit_W in range(2**W):
        C = D.copy()
        for h in range(H):
            mask = 1 << h
            if bit_H & mask:
                C[h, :] = 'h'    
        for w in range(W):
            mask = 1 << w
            if bit_W & mask:
                C[:, w] = 'w'
            
        if np.count_nonzero(C == '#') == K:
            count += 1
#            print(C)
print(count)

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

int main(void)
{
	int d[2][10];

	for(int i = 0; i < 2; i++)
		for(int j = 0; j < 10; j++)
			cin >> d[i][j];

	int o[2] = {};

	for(int i = 0; i < 2; i++){
		sort(d[i],d[i]+10);
		for(int j = 9; j >= 7; j--)
			o[i] += d[i][j];
	}

	cout << o[0] << ' ' << o[1] << endl;

	return 0;
}

Measured memory_bytes: 1172
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if (a == b && b == c)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256