akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;

class Dice{
	public:
		Dice(){
			num = new int[6];
			s = new int[6];
		};
	void setlabel(int n,int number){
		num[n] = number;
	}
	void roll(char ch){
	            for(int i=0;i<6;i++){
	                s[i] = num[i];
	            }
	            switch(ch){
	                case 'N':
	                    changenum(s[1],s[5],s[2],s[3],s[0],s[4]);
	                    break;
	                case 'E':
	                    changenum(s[3],s[1],s[0],s[5],s[4],s[2]);
	                    break;
	                case 'S':
	                    changenum(s[4],s[0],s[2],s[3],s[5],s[1]);
	                    break;
	                case 'W':
	                    changenum(s[2],s[1],s[5],s[0],s[4],s[3]);
	                    break;
	                case 't':
	                    changenum(s[0],s[2],s[4],s[1],s[3],s[5]);
	                    break;
	            }
	};

	int right(){
		return num[2];
	}
	int left(){
		return num[3];
	}
	int front(){
		return num[1];
	}
	int top(){
		return num[0];
	}
	public:
		bool cheak(int a[6]){
			for(int i=0;i<6;i++)
				if(a[i]!=num[i]) return false;
			return true;
		};
	private:	
		void changenum(int n1,int n2,int n3,int n4,int n5,int n6){
			num[0] = n1;
			num[1] = n2;
			num[2] = n3;
			num[3] = n4;
			num[4] = n5;
			num[5] = n6;
		};
		
	private:
		int* num;
		int* s;
};
	 
int main() {
	Dice dice;
	int label,diceB[6];
	bool ans = false;
 
	for(int i=0;i<6;i++){
		cin >> label;
		dice.setlabel(i,label);
	}
	for(int i=0;i<6;i++){
		cin >> label;
		diceB[i] = label;
	}
	for(int k=0;k<=4;k++){
		dice.roll('t');
	for(int i=0;i<4;i++){
			dice.roll('E');
			for(int j=0;j<4;j++){
				dice.roll('N');
				if(diceB[0]==dice.top()&&diceB[1]==dice.front()&&dice.cheak(diceB)) ans=true;
			}
	}
	}
	
	cout << (ans?"Yes":"No") << endl;
	return 0;
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <tuple>
#include <queue>
#include <stack>
#include <set>
#include <map>

#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second

typedef long long ll;

int N,M,H,W,K,A,B;

using namespace std;

int main() {
    cin >> H >> W>>N;
    int sr,sc;
    cin >>sr>>sc;
    string S,T;
    cin >> S >> T;

    vector<int> u={1,0,0,0},l = {0,1,0,0},d={0,0,1,0},r={0,0,0,1},n = {0,0,0,0};
    vector<int> vecs,vect;
    vector<int> Du(N*2+2,0),Dd(N*2+2,0),Dr(N*2+2,0),Dl(N*2+2,0);
    
    int k;
    for(int i = N*2;i >= 0; i--){
        if(i%2 == 0){
            vecs = n;
        }else{
            k = (i-1) /2;
            if(S.at(k) == 'U') vecs = u;
            if(S.at(k) == 'L') vecs = l;
            if(S.at(k) == 'D') vecs = d;
            if(S.at(k) == 'R') vecs = r;
        }
        if(i%2 == 1 || i == 0){
            vect = n;
        }else{
            k = i/2 - 1;
            if(T.at(k) == 'U') vect = u;
            if(T.at(k) == 'L') vect = l;
            if(T.at(k) == 'D') vect = d;
            if(T.at(k) == 'R') vect = r;
        }
        Du.at(i) = Du.at(i+1) + vecs.at(0) - vect.at(2);
        Dd.at(i) = Dd.at(i+1) + vecs.at(2) - vect.at(0);
        Dl.at(i) = Dl.at(i+1) + vecs.at(1) - vect.at(3);
        Dr.at(i) = Dr.at(i+1) + vecs.at(3) - vect.at(1);
        if(Du.at(i) < 0) Du.at(i) = 0;
        if(Dd.at(i) < 0) Dd.at(i) = 0;
        if(Dr.at(i) < 0) Dr.at(i) = 0;
        if(Dl.at(i) < 0) Dl.at(i) = 0;
        //cout << Dr.at(i) << endl;
    }

    if(sr <=Du.at(0)){
        cout << "NO" << endl;
        return 0;
    }
    if(sc <=Dl.at(0)){
        cout << "NO" << endl;
        return 0;
    }
    if(H - sr + 1 <=Dd.at(0)){
        cout << "NO" << endl;
        return 0;
    }
    if(W - sc + 1 <=Dr.at(0)){
        cout << "NO" << endl;
        return 0;
    }
    
    rep(i,N*2+2){
        if(Dd.at(i) + Du.at(i) >= H){
            cout << "NO" << endl;
            return 0;
        }
        if(Dl.at(i) + Dr.at(i) >= W){
            cout << "NO" << endl;
            return 0;
        }
    }
    
    cout << "YES" << endl;
}

Measured memory_bytes: 7048
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int o(int x){
  if(x == 2)
    ret 2;
  else if(x == 4 || x == 6 || x==9 || x==11)
    ret 1;
  else
    ret 0;
}

int main(){
  int a,b;
  cin >> a >> b;
  if(o(a) == o(b))
    Yes;
  else
    No;
  ret 0;
}

Measured memory_bytes: 256
#102_C
def Mid(A):
    A=sorted(A)
    N=len(A)
    return A[N//2]
def Sad(A,b):
    return sum([abs(A[i]-b) for i in range(len(A))])
N=int(input())
A=list(map(int,input().split()))
Ai=[A[i]-(i+1) for i in range(N)]
print(Sad(Ai,Mid(Ai)))

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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

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

signed main(){
	IOS
	forn(i,5){
		int x;cin>>x;
		if(!x)
			cout<<i+1;
	}
}

Measured memory_bytes: 3620
x, y = map(int, input().split())
a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
if (x == 2 or y == 2) or (x in a and y not in a) or (x in b and y not in b):
    print('No')
else:
    print('Yes')

Measured memory_bytes: 9176
#include <stdio.h>
#include <iostream>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)

using namespace std;

typedef int64_t ll;

const ll MOD = 1000000007;
const int MAX_N = 2010;

int ns, nt;
int s[MAX_N], t[MAX_N];
ll cum[MAX_N][MAX_N];

int main()
{
	cin >> ns >> nt;
	REP(i, ns) scanf("%d", s + i);
	REP(j, nt) scanf("%d", t + j);

	REP(i, MAX_N)
		cum[1][i] = cum[i][1] = 1;

	REP(i, ns)
		REP(j, nt)
	{
		ll dp = 0;
		if (s[i] == t[j])
			dp = cum[i + 1][j + 1];

		cum[i + 2][j + 2] = dp + cum[i + 1][j + 2] + cum[i + 2][j + 1] - cum[i + 1][j + 1];
		cum[i + 2][j + 2] = (cum[i + 2][j + 2] + MOD) % MOD;
	}

	cout << cum[ns + 1][nt + 1] << endl;
}


Measured memory_bytes: 31744
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <map>
#include <vector>
#include <iomanip>

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  int p[N];
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }
  double s = 0;
  double s_max = 0;
  for (int i = 0; i < K; i++) {
    s += double(1 + p[i]) / 2;
  }
  s_max = s;
  for (int i = 0; i < N - K; i++) {
    s = s + double(1 + p[K + i]) / 2 - double(1 + p[i]) / 2;
    if (s > s_max) {
      s_max = s;
    }
  }
  cout << fixed << setprecision(10) << s_max << endl;
  return 0;
}


Measured memory_bytes: 1024
import java.io.*;
import java.util.*;
import java.math.*;
// import java.awt.Point;

public class Main {
    public Main(){
        Scanner sc=new Scanner(System.in);
        char[] S=sc.next().toCharArray();

        char[] keyence=new char[]{'k','e','y','e','n','c','e'};
        int index=0;
        for(index=0;index<7;index++){
            if(S[index]!=keyence[index]){
                break;
            }
        }
        if(index==7){
            System.out.println("YES");
            return;
        }
        for(int i=0;i<7-index;i++){
            if(S[S.length-1-i]!=keyence[6-i]){
                System.out.println("NO");
                return;

            }
        }
        System.out.println("YES");
        return;

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

}


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

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

template <int mod>
struct ModInt {
    ll x;
    ModInt() : x(0) {}
    ModInt(ll y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
    ModInt &operator+=(const ModInt &p) { if((x += p.x) >= mod) x -= mod; return *this; }
    ModInt &operator-=(const ModInt &p) { if((x += mod - p.x) >= mod) x -= mod; return *this; }
    ModInt &operator*=(const ModInt &p) { x = 1LL * x * p.x % mod; return *this; }
    ModInt &operator/=(const ModInt &p) { *this *= p.inverse(); return *this; }
    ModInt operator-() const { return ModInt(-x); }
    ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
    ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
    ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
    ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
    bool operator==(const ModInt &p) const { return x == p.x; }
    bool operator!=(const ModInt &p) const { return x != p.x; }
    ModInt inverse() const {
        ll a = x, b = mod, u = 1, v = 0, t;
        while(b > 0) {
            t = a / b;
            swap(a -= t * b, b);
            swap(u -= t * v, v);
        }
        return ModInt(u);
    }
    ModInt pow(ll n) const {
        ModInt ret(1), mul(x);
        while(n > 0) {
            if(n & 1) ret *= mul;
            mul *= mul;
            n >>= 1;
        }
        return ret;
    }
    friend ostream &operator<<(ostream &os, const ModInt &p) {
        return os << p.x;
    }
    friend istream &operator>>(istream &is, ModInt &a) {
        int64_t t;
        is >> t;
        a = ModInt<mod>(t);
        return (is);
    }
};
const int mod = 1000000007;
using mint = ModInt<mod>;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    ll mv = 0;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        chmax(mv, a[i]);
    }

    int len = 0;
    while (mv > 0){
        mv >>= 1;
        len++;
    }

    mint res = 0;
    for (int i = 0; i < len; ++i) {
        int x = 0, y = 0;
        for (int j = 0; j < n; ++j) {
            if (a[j] & 1) x++;
            else y++;
            a[j] >>= 1;
        }
        res += mint(x) * mint(y) * mint(1LL<<i);
    }
    cout << res << endl;
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"
#define PI 3.14159265358979
#define MOD 1000000007 // = 10^9 + 7

using namespace std;
using ll = long long;


void solve()
{
	int n, m;
	cin >> n >> m;

	cout << (n == m ? "Yes" : "No");
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 256
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int INF = 1000000007;
const int MAX_V = 201;
int now = 0;
int deco[1000];

void Sequence() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a == b && b == c) {
		cout << 1 << endl;
	}
	else if (a == b || b == c || a == c) {
		cout << 2 << endl;
	}
	else {
		cout << 3 << endl;
	}

}
int main() {
	Sequence();
	return 0;
}



Measured memory_bytes: 256
#! python3
# dice_iii.py

class dice():
    def __init__(self, arr):
        self.top = arr[0]
        self.south = arr[1]
        self.east = arr[2]
        self.west = arr[3]
        self.north = arr[4]
        self.bottom = arr[5]

    def rotate(self, ope):
        if ope == 'S':
            self.top, self.north, self.bottom, self.south = self.north, self.bottom, self.south, self.top
        elif ope == 'N':
            self.top, self.south, self.bottom, self.north = self.south, self.bottom, self.north, self.top
        elif ope == 'E':
            self.top, self.west, self.bottom, self.east = self.west, self.bottom, self.east, self.top
        elif ope == 'W':
            self.top, self.east, self.bottom, self.west = self.east, self.bottom, self.west, self.top
        elif ope == 'R': # clockwise
            self.south, self.east, self.north, self.west = self.east, self.north, self.west, self.south
        elif ope == 'L': # reversed clockwise
            self.south, self.east, self.north, self.west = self.west, self.north, self.east, self.south
        else:
            pass

    def get_surfaces(self):
        return [self.top, self.south, self.east, self.north, self.west, self.bottom]

dc1 = dice([int(x) for x in input().split(' ')])
dc2 = dice([int(x) for x in input().split(' ')])

judged = False
if len((dc1.get_surfaces() and dc2.get_surfaces())) == 6:
    opes = ['', 'S', 'E', 'S', 'E', 'S']
    for op in opes:
        dc2.rotate(op)
        for i in range(4):
            if dc1.get_surfaces() == dc2.get_surfaces():
                judged = True
                break
            dc2.rotate('R')
        if judged: break

if judged:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 5612
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000

int main() {
    int N;
    cin >> N;
    vector<int> ans;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    while (N != 1) {
        if (N % 2 < 0) {
            ans.push_back(N % 2 + 2);
            N /= -2;
            N += 1;
        } else {
            ans.push_back(N % 2);
            N /= -2;
        }
    }
    ans.push_back(1);

    reverse(all(ans));
    for (auto a : ans) {
        cout << a;
    }
    cout << endl;
    return 0;
}

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

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    char a,b;
    cin >> a >> b;
    string s={},t={};
    for(i=0;i<a-'0';i++){
        s+=b;
    }
    for(i=0;i<b-'0';i++){
        t+=a;
    }
    if(s<t){
        cout << s << endl;
    }else{
        cout << t << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    vector<ll> a(n);
    rep(i,n) cin>>a[i];
    ll tmp=0;
    rep(i,n){
        if(i%2==0) tmp+=a[i];
        else tmp-=a[i];
    }
    cout<<tmp<<' ';
    rep(i,n-1){
        tmp=a[i]-(tmp/2);
        tmp*=2;
        cout<<tmp<<' ';
    }
    cout<<endl;
    return 0;
}

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

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> inline T sqr(T x) {return x*x;}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define all(a)  (a).begin(),(a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define pb push_back
#define mp make_pair
#define each(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define exist(s,e) ((s).find(e)!=(s).end())
#define range(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  range(i,0,n)
#define clr(a,b) memset((a), (b) ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

const double eps = 1e-10;
const double pi  = acos(-1.0);
const ll INF =1LL << 62;
const int inf =1 << 29;

const int mmax=10010;
double dp[50][10010];


int main(void){
	int n,m,k;
	while(cin >> n >> m >> k){
		if(n==0)
			break;
		rep(i,50)rep(j,mmax) dp[i][j]=0.0;
		dp[0][0]=1.0;
		rep(i,n)rep(j,mmax){
			range(l,1,m+1)
				if(j+l<mmax)
					dp[i+1][j+l]+=1.0*dp[i][j]/m;
		}
		double ans=0.0;
		rep(j,mmax)
			ans+=(1.0*max(1,j-k)*dp[n][j]);
		cout.precision(9);
		cout << fixed << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5144
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	static double a, b, x;

	public static void main(String[] args) {

		FastScanner sc = new FastScanner();
		a = (double) sc.nextInt();
		b = (double) sc.nextInt();
		x = (double) sc.nextInt();
		double theta;

		if (x >= a * a * b / 2)
			theta = keisan();

		else
			theta = keisan2();

		System.out.println(theta);

	}

	public static double keisan() {
		return Math.toDegrees(Math.atan((2 * (a * a * b - x)) / (a * a * a)));

	}

	public static double keisan2() {
		return Math.toDegrees(Math.atan(a * b * b / (2 * x)));

	}

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
const ll mod = 1000000007;
ll inv[100100];
ll FactorialInv[100100];
ll Factorial[100100];
ll beki(ll a, ll b){
    if(b == 0){
        return 1;
    }
    ll ans = beki(a, b / 2);
    ans = ans * ans % mod;
    if(b % 2 == 1){
        ans = ans * a % mod;
    }
    return ans;
}
void init_combination(){
    const int MAX = 10002;
    Factorial[0] = 1;
    inv[0] = 1;
    for(int i = 1; i <= MAX; i++){
        Factorial[i] = Factorial[i - 1] * i % mod;
    }
    FactorialInv[MAX] = beki(Factorial[MAX], mod - 2);
    for(ll i = MAX - 1; i >= 0; i--) {
        FactorialInv[i] = FactorialInv[i+1] * (i+1) % mod;
    }
    for(int i = 1; i <= MAX; i++) {
        inv[i] = FactorialInv[i] * Factorial[i-1] % mod;
    }
}
ll combination(ll a, ll b){
    if((a == b) || (b == 0)){
        return 1;
    }
    if(a < b) return 0;
    ll ans = Factorial[a] * FactorialInv[b] % mod;
    ans = ans * FactorialInv[a - b] % mod;
    return ans;
}
int N;
int dp[4005][4005];
int A[200050], B[200050];

int main() {
    //cout.precision(10);
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N;
    init_combination();
    for(int i = 1; i <= N; i++) {
        cin >> A[i] >> B[i];
        dp[2000-A[i]][2000-B[i]]++;
    }
    for(int i = 0; i <= 4000; i++) {
        for(int j = 0; j <= 4000; j++) {
            if(i > 0) dp[i][j] += dp[i-1][j];
            dp[i][j] %= mod;
            if(j > 0) dp[i][j] += dp[i][j-1];
            dp[i][j] %= mod;
        }
    }
    ll ans = 0;
    for(int i = 1; i <= N; i++) {
        ans += dp[2000+A[i]][2000+B[i]];
        ans %= mod;
        ans -= combination(2*A[i]+2*B[i], 2*A[i]);
        ans %= mod;
        ans += mod;
        ans %= mod;
    }
    //ans *= beki(2, mod - 2);
    //ans %= mod;
    ll answer = (ll)ans * beki(2, mod - 2);
    answer %= mod;
    cout << answer << endl;
    return 0;
}


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

int main() {
  string s, t;
  cin >> s >> t;
  int ls = s.size();
  int lt = t.size();
  int ans = ls;
  for (int i = 0; i + lt - 1 < ls; ++i) {
    int c = 0;
    rep(j, lt) {
      if (s[i+j] != t[j]) ++c;
    }
    ans = min(ans, c);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
// Problem : 
// 			B - Making Triangle
// 			Editorial
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize "trapv"//  WA to RE int!!
#include <bits/stdc++.h>
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORR(i,n) for(int i=n;i>=0;i--)
#define pb push_back
#define vlli vector<int>
#define slli set<int>
#define mlli map<int,int>
#define plii pair< int,int >
#define int long long int 
#define test int tt1234; cin>>tt1234;while(tt1234--)
#define endl "\n"
#define SI(a,n) int a[n];FOR(i,n) cin>>a[i];
#define input(a,n) int n;cin>>n; SI(a,n)
#define all(zz) zz.begin(),zz.end()
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define error(x) cerr << #x <<" is " << x << endl;
#define Error(a,b) cerr<<"( "<<#a<<" , "<<#b<<" ) = ( "<<(a)<<" , "<<(b)<<" )\n";
#define precision(x) cout<<fixed<<setprecision(x);
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define present(container, element) (container.find(element)!=container.end())
#define fint fast;test
#define set(a,x) memset(a,x,sizeof(a))
#define L(x)	((x)<<1)
#define R(x)	(((x)<<1)+1)
#define ft first
#define se second
#define MOD 1000000007
using namespace std;
template<typename... T> void rd(T&... args) { ((cin >> args), ...); }
template<typename... T> void pp(T... args) { ((cout << args << " "), ...); cout<<"\n"; }
void solve(){
	input(arr,n);
	int ans=0;
	FOR(i,n-2){
		rep(j,i+1,n-1){
			rep(k,j+1,n){
				if((arr[i]==arr[j]) || (arr[j]==arr[k]) || (arr[i]==arr[k]))continue;
				else if(arr[i]>=(arr[j]+arr[k]))continue;
				else if(arr[j]>=(arr[i]+arr[k]))continue;
				else if(arr[k]>=(arr[j]+arr[i]))continue; 
				else ans++;
			}
		}
	}	
	pp(ans);
	return;	
}


int32_t main() {
    // fint{
    	fast;
    	solve();
    // }
    return 0;
}


Measured memory_bytes: 3628
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head


const int N = 1e6+10;
int L, n, a[N], d[N];
ll ans;
void solve() {
	ll tot = 0;
	PER(i,1,n) {
		d[i] = a[i], tot += d[i];
		int len = n-i+1, p;
		if (len&1) p = n-len/2;
		else {
			p = n-len/2+1;
			tot -= d[p];
			d[p] = L-d[p];
			tot += d[p];
		}
		ans = max(ans, tot*2-d[p]);
	}
}

int main() {
	scanf("%d%d",&L,&n);
	REP(i,1,n) scanf("%d",a+i);
	solve();
	REP(i,1,n) a[i] = L-a[i];
	reverse(a+1,a+1+n);
	solve();
	printf("%lld\n", ans);
}


Measured memory_bytes: 5120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
#define INF 1e18

#define nax 1000005

int temp[nax];

void solve(){
	
	int n;
	cin>>n;
	int count=0;
	std::map<int, int> m;
	rep(i,0,n){
		int x;
		cin>>x;
		m[x]++;
	}
	for(auto x:m){
		if(temp[x.F]==0 && x.S==1)
			count++;
		if(temp[x.F]==0){
			for(int j=2*(x.F);j<nax;j+=(x.F))
				temp[j]=1;
		}
	}
	cout<<count<<endl;


}
signed main(){
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    srand (static_cast <unsigned> (time(0)));
    int t;
    t=1;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 23828
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.stream.IntStream;
import java.util.Arrays;
import java.io.IOException;
import java.util.stream.Collectors;
import java.io.InputStreamReader;
import java.util.Objects;
import java.util.stream.Stream;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            TaskC.Num[] X = new TaskC.Num[N];
            for (int i = 0; i < N; i++) {
                X[i] = new TaskC.Num(i, in.nextInt());
            }

            Arrays.sort(X, (n1, n2) -> n1.val - n2.val);

            int[] ANS = new int[N];

            for (int i = 0; i < N; i++) {
                ANS[X[i].idx] = (i < N / 2 ? X[N / 2].val : X[(N - 1) / 2].val);
            }

            out.println(Arrays.stream(ANS).mapToObj(Objects::toString).collect(Collectors.joining("\n")));
        }

        static class Num {
            int idx;
            int val;

            public Num(int idx, int val) {

                this.idx = idx;
                this.val = val;
            }

        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 71332
import collections as co
n = int(input())
a = list(map(int,input().split()))
q = int(input())
bc = [list(map(int,input().split())) for i in range(q)]
c = co.Counter(a)
ans = sum(a)
for i in range(q):
    ans += (c[bc[i][0]] * (bc[i][1]-bc[i][0]))
    print(ans)
    c[bc[i][1]] += c[bc[i][0]]
    c[bc[i][0]] = 0


Measured memory_bytes: 104616
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

int main()
{
    string N; cin >> N;
    deque<char> S;
    rep (i, 0, N.size()) S.push_back(N[i]);
    while (true) {
        if (S.size() == 1) break;
        if (S.front() != S.back()) {
            cout << "No" << endl;
            return 0;
        }
        S.pop_front(); 
        S.pop_back();
    }
    cout << "Yes" << endl;
}

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

using namespace std;

int main()
{
	string s;
	int nmsl=0;
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			nmsl=1;
		}
		if(s[i]=='F'&&nmsl==1)
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 764
import collections

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

c = collections.Counter(a)
most_count = c.most_common()[0][1]
most_values = []
for i in c.items():
    if i[1] == most_count:
        most_values.append(i[0])

print("\n".join(sorted(most_values)))

Measured memory_bytes: 45040
#include<bits/stdc++.h>
using namespace std;
long long num[45];
vector<int>v;
void cal(long long x)
{
    v.clear();
    while(x)
    {
        v.push_back(x%2);
        x>>=1;
    }
    long long t=0;
    for(int i=0;i<v.size();i++)
    {
        //cout<<v[i]<<' '<<i<<' '<<t<<endl;
        if(v[i]==1)
        {
            for(int j=0;j<i;j++)
                num[j]+=(1ll<<i)/2;
            num[i]+=t+1;
        }
        t+=v[i]*(1ll<<i);
    }
}
int main()
{
    for(int i=1;i<=122;i++)
    {
        for(int j=0;j<=20;j++)
            if(1<<j&i) num[j]++;
    }
    //for(int j=0;j<=20;j++)
    //    cout<<num[j]<<' ';
    //cout<<endl;
    memset(num,0,sizeof(num));
    long long a,b,ans=0;
    scanf("%lld%lld",&a,&b);
    cal(b);
    for(int i=0;i<=40;i++)
        num[i]*=-1;
    if(a) cal(a-1);
    for(int i=0;i<=40;i++)
        num[i]*=-1,ans+=num[i]%2*(1ll<<i);
    printf("%lld\n",ans);
}


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

int main(){
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;
    if(x < 0 || y < 0 || x + r > W || y + r > H || x - r < 0 || y - r < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
return 0;
}
    

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

int main(){
    long n,m,l,i,j,k,s,t,u,v;
    long A[1000][1000]={},B[1000][1000]={},C[1000][1000];
    cin>>n>>m>>l;
    for(i=0;i<n;i++){
        for(j=0;j<m;j++){
            cin>>A[i][j];
        }
    }
    for(k=0;k<m;k++){
        for(s=0;s<l;s++){
            cin>>B[k][s];
        }
    }
    for(t=0;t<n;t++){
        for(u=0;u<l;u++){
            for(v=0;v<m;v++){
                C[t][u]+=A[t][v]*B[v][u];
            }
            if(u==l-1){
                cout<<C[t][u];
            }else{
                cout<<C[t][u]<<" ";
            }
        }
        cout<<endl;
    }
    return 0;
    
}



Measured memory_bytes: 19200
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
using bint = boost::multiprecision::cpp_int;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repSE(i,s,n) for (int i = (s); i < (n); i++)
#define ssort(v) sort(v.begin(), v.end())
#define gsort(v) sort(v.rbegin(), v.rend())
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }

map<ll, ll> memo;
ll solve(ll n) {
    if (n==1) return 1;
    if (memo.count(n)) return memo[n];
    ll res = 2 * solve(n/2) + 1;
    memo[n] = res;
    return res;
}

int main()
{
    ll h;
    cin >> h;
    ll ans = solve(h);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 3580
#include <stdio.h>

int main(void)
{
  int s;
  int n, a, b;
  int c;
  int t;
  int i;
  s = 0;
  scanf("%d %d %d", &n, &a, &b);
  for ( i=1; i<=n; i++ ) {
    t = i;
    c = 0;
    while ( t > 0 ) {
      c += t % 10;
      t /= 10;
    }
    if ( a <= c && c <= b ) {
      s += i;
    }
  }
  printf("%d\n", s);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
int main()
{
	using namespace std;
	string s;
	int c = 0;
	cin >> s;
	for (int i = 0; i < s.length(); ++i) {
		if (s[i] == 'o') {
			c++;
		}
	}

	cout << 700 + c*100 << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define Re register
#define fo(i, a, b) for (Re int i = (a); i <= (b); ++i)
#define fd(i, a, b) for (Re int i = (a); i >= (b); --i)
#define edge(i, u) for (Re int i = head[u], v = e[i].v; i; i = e[i].nxt, v = e[i].v)
#define pb push_back
#define F first
#define S second
#define ll long long
#define inf 1000000007
#define mp std::make_pair
#define lowbit(x) (x & -x)
#define eps 1e-4
#define itset std::set<node>::iterator
#define lb lower_bound
#define N 1000005
#define M 4000005
int n, f[N][2], a[N], tmp[2];
inline void update (int s, int x)
{
    if (f[s][0] < x)
        f[s][1] = f[s][0], f[s][0] = x;
    else
    if (f[s][1] < x)
        f[s][1] = x;
}
int main ()
{
    scanf("%d", &n);
    int up = (1 << n) - 1;
    fo (i, 0, up) {scanf("%d", &a[i]); f[i][0] = a[i]; f[i][1] = -inf;}
    fo (i, 1, n)
    {
        fo (s, 1, up)
        {
            if (!(s & 1 << i - 1)) continue;
            int pre = s ^ 1 << i - 1;
            update(s, f[pre][0]);
            update(s, f[pre][1]);
        }
    }
    int ans = 0;
    fo (i, 1, up)
    {
        ans = std::max(ans, f[i][0] + f[i][1]);
        printf("%d\n", ans);
    }
    return 0;
}

Measured memory_bytes: 8192
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long int n;
long long int a[22][22];
long long int v[21][1<<21];
long long int ans=0;
long long int dp[21][1<<21];
long long int  solve(long long int index,long long int mask)
{
    if(index==n)
      return 1;
    if(v[index][mask]!=0)
    return dp[index][mask];
    v[index][mask]=1;
    if(1)
    {
        long long int ans=0;
        for(long long int i=0;i<n;i++)
        {
            if(a[index][i]==1 && (!(mask & (1<<i))))
            {
               ans=(ans+solve(index+1,mask^(1<<i)))%mod;
            }
        }
        return dp[index][mask]=ans;
    }
}
int main()
{
    long long int i,j,k,x,y,z;
    cin>>n;
    for(i=0;i<n;i++)for(j=0;j<n;j++)cin>>a[i][j];
    cout<<solve(0,0);
}

Measured memory_bytes: 616704
#include <bits/stdc++.h>
using namespace std;
#define M 1000000000
#define f(i,a,b) for(long long i=a;i<b;i++)
#define tc long long t;cin>>t;while(t--)
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define input(a,n) for(ll i=0;i<n;i++) cin>>a[i];
#define output(a,n) for(ll i=0;i<n;i++) cout<<a[i]<<" ";
#define up upper_bound
#define lo lower_bound
#define endl "\n"
#define mem(a) memset(a,-1,sizeof(a))
#define ll long long
#define umap unordered_map

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

    ll n,d;
    cin>>n>>d;
    ll c=0;

    while(n--){
        ll x,y;
        cin>>x>>y;

        if(sqrt(pow(x,2)+pow(y,2))<=d) c++;
    }

    cout<<c<<endl;


    
}

Measured memory_bytes: 3672
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int mod = 998244353;

inline int addMod(int a, int b) {
	return (a += b) >= mod ? a - mod : a;
}

inline ll quickpow(ll base, ll pw) {
	ll ret = 1;
	while (pw) {
		if (pw & 1) ret = ret * base % mod;
		base = base * base % mod, pw >>= 1;
	}
	return ret;
}

template <class T>
inline void read(T &x) {
	x = 0;
	char ch = getchar(), w = 0;
	while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
	while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
	x = w ? -x : x;
	return;
}

int main() {
	int x;
	double PI = acos(-1);
	read(x);
	printf("%.15lf\n", 2 * x * PI);
	return 0;
}

Measured memory_bytes: 3764
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int last = sc.nextInt();
        int res = last;
        for(int i = 0;i<n-2;i++)
        {
            int t = sc.nextInt();
            res+=Math.min(t,last);
            last = t;

        }
        System.out.println(res+last );
    }
}


Measured memory_bytes: 21972
#include<stdio.h>

int main()
{
    int n, m, i, sum = 0, h;
    scanf("%d %d", &n, &m);
    int array[m];
    for(i = 0; i < m; i++){
        scanf("%d", &array[i]);
        sum = sum + array[i];
    }
    if(sum > n){
        printf("-1");
    }
    else{
        h = n - sum;
        printf("%d", h);
    }

    return 0;
}


Measured memory_bytes: 1764
n = gets.to_i
arr = gets.split(" ").map(&:to_i)

arr.push(0) if n.odd?

groupedArr = arr.inject(Hash.new(0)) { |h,e| h[e] += 1; h}.sort

check = n.odd? ? 0 : 1
able = true

groupedArr.each{|pair|
 if pair[0] != check || pair[1] != 2 then
  able = false
  break
 else
  check += 2
 end
}

if able then
 p (2**(n/2)) % (10**9+7)
else
 p 0
end

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

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

    int64_t m;
    for (int64_t i = 1; i * i <= n; i++) {
        if (n % i == 0) m = n / i;
    }

    int i = 1;
    for (int64_t t = 10; m >= t; t *= 10) i++;
    cout << i << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    n, m = [int(i) for i in input().split()]
    e = [[int(i) for i in input().split()] for i in range(n)]

    e = sorted(e, key=lambda x: x[0])

    count = p_sum = 0
    for shop in e:
        for i in range(shop[1]):
            count += 1
            p_sum += shop[0]
            if count >= m:
                return p_sum


if __name__ == "__main__":
    print(main())

Measured memory_bytes: 23516
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[200010];
    rep(i, N) cin >> A[i];
    if (A[0] != 0) {cout << -1 << endl; return 0;}
    rep(i, N - 1) {
        if (A[i + 1] - A[i] >= 2) {
            cout << -1 << endl;
            return 0;
        }
    }
    ll ans = 0;
    rep(i, N - 1) {
        if (A[i] < A[i + 1]) ans++;
        else if (A[i] >= A[i + 1]) ans += A[i + 1];
    }
    cout << ans << endl;



    return 0;
}
// 0 1 2 3 3
// 0   1 2 3
//   1 2 3

// 0 1 2 1
// 0 0 0 1
//

Measured memory_bytes: 1024
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	const K = parseInt(input[0])
	const S = input[1]
	var ans = ""
	if (S.length > K) {
		ans = S.slice(0, K) + '...'
	} else {
		ans = S		
	}

	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 29556
#include <iostream>
#include <cstdio>

using namespace std;

int N, K;
int A[200005];

void solve() {
  for (int i = 0; i < N-K; i++) {
    puts(A[i] < A[K+i] ? "Yes" : "No");
  }
}

int main() {
  scanf("%d %d", &N, &K);
  for (int i = 0; i < N; i++) {
    scanf("%d", A+i);
  }
  solve();
}


Measured memory_bytes: 4540
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
    String[] lines = getStdin();
    String id = lines[0];
    char[] s = id.toCharArray();
    String newid = lines[1];
    char[] t = newid.toCharArray();
    
    if(s.length + 1 != t.length){
        System.out.println("No");
        return;
    }
    
    for (int i = 0; i < t.length -1; i++){
        if (s[i] != t[i]){
            System.out.println("No");
            return;
        }
        
    } System.out.println("Yes");
    }
  
  private static String[] getStdin() {
    Scanner scanner = new Scanner(System.in);
    ArrayList<String> lines = new ArrayList<>();
    while (scanner.hasNext()) {
      lines.add(scanner.nextLine());
    }
    return lines.toArray(new String[lines.size()]);
  }
  
}

Measured memory_bytes: 35708
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define f(i,a,b) for(int i=a;i<b;i++)
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
int ketasuu(int x){
  int n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}


ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

int main(){
  int n;
  cin>>n;
  vector<pair<int,int>> a(n);
  rep(i,n) {int p ;cin>>p; a[i]= make_pair(p,i);}
  sort(all(a));
  rep(i,n) cout<< a[i].second+1<<" ";
}




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

int main() {
	int N, l, r;
	int R = 0;
	cin >> N;
	for (int i = 0; N > i; i++) {
		cin >> l >> r;
		R += r - l + 1;
	}
	cout << R;
}

Measured memory_bytes: 3640
use proconio::{input, fastout};

const MAX: i64 = 1_000_000_000;

macro_rules! min {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::min($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::min($a, min!($($rest),+))
    }};
}

macro_rules! chmin {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_min = min!($($cmps),+);
        if $base > cmp_min {
            $base = cmp_min;
            true
        } else {
            false
        }
    }};
}

#[fastout]
fn main() {
    input! {
        n: usize,
        h: [i64; n],
    }

    let mut dp = vec![MAX; n];
    dp[0] = 0;
    for i in 0..n {
        if i + 1 < n {
            chmin!(dp[i+1], dp[i] + (h[i+1] - h[i]).abs());
        }
        if i + 2 < n {
            chmin!(dp[i+2], dp[i] + (h[i+2] - h[i]).abs());
        }
    }
    println!("{}", dp[n-1]);
}


Measured memory_bytes: 3908
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int a,b,c;
    cin>>a>>b>>c;
    cout<<c/a*b;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
typedef long long ll;

int main(void) {
  ll i, j, k, n, ans = 0;
  scanf("%lld", &n);
  ll a[n + 1], b[n];
  for(i = 0; i <= n; ++i) scanf("%lld", &a[i]);
  for(i = 0; i < n; ++i) scanf("%lld", &b[i]);
  for(i = 0; i < n; ++i) {
    if(a[i] <= b[i]) ans += a[i], b[i] -= a[i];
    else ans += b[i], b[i] = 0;
    if(a[i + 1] <= b[i]) ans += a[i + 1], a[i + 1] = 0;
    else ans += b[i], a[i + 1] -= b[i];
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, pair<ll, ll> > P3;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, ma=0, mi=IINF;
    cin >> n;
    REP(i,n){
        int a;
        cin >> a;
        ma = max(ma,a);
        mi = min(mi,a);
    }
    cout << ma-mi << endl;
    return 0;
}

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

int main(){
  int a,b,c,f;
 cin>>a>>b>>c;
  vector<int>d(b+1),e(b+1);
  d[0]=0;
  e[0]=0;
  f=0;
  for(int i=0;i<b;i++){
  cin>>d[i+1];
    }
  for(int i=0;i<a;i++){
    for(int j=0;j<b;j++){
    cin>>e[j+1];
      e[j+1]=e[j+1]*d[j+1]+e[j];
      }
   
    if(e[b]+c>0){
      f++;
        }
    }
  
  cout<<f<<endl;
}


Measured memory_bytes: 256