akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i = 0;i<((ll)(n));i++)
#define reg(i,a,b) for(ll i = ((ll)(a));i<=((ll)(b));i++)
#define irep(i,n) for(ll i = ((ll)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(ll i = ((ll)(b));i>=((ll)(a));i--)
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;

/*
f(n) = n人のグループ分けの場合の数
f(n,m) = n人をm人以下のグループに分ける場合の数
a<=i<=b人グループがc<=x<=d個
*/

template<int MOD>
struct ModInt {
	static const int Mod = MOD;
	unsigned x;
	ModInt() : x(0) { }
	ModInt(signed sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	ModInt(signed long long sig) { int sigt = sig % MOD; if (sigt < 0) sigt += MOD; x = sigt; }
	int get() const { return (int)x; }

	ModInt &operator+=(ModInt that) { if ((x += that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator-=(ModInt that) { if ((x += MOD - that.x) >= MOD) x -= MOD; return *this; }
	ModInt &operator*=(ModInt that) { x = (unsigned long long)x * that.x % MOD; return *this; }
	ModInt &operator/=(ModInt that) { return *this *= that.inverse(); }

	ModInt operator+(ModInt that) const { return ModInt(*this) += that; }
	ModInt operator-(ModInt that) const { return ModInt(*this) -= that; }
	ModInt operator*(ModInt that) const { return ModInt(*this) *= that; }
	ModInt operator/(ModInt that) const { return ModInt(*this) /= that; }

	ModInt inverse() const {
		signed a = x, b = MOD, u = 1, v = 0;
		while (b) {
			signed t = a / b;
			a -= t * b; std::swap(a, b);
			u -= t * v; std::swap(u, v);
		}
		if (u < 0) u += Mod;
		ModInt res; res.x = (unsigned)u;
		return res;
	}
};
typedef ModInt<1000000007> mint;
vector<mint> fact, factinv;
void nCr_computeFactinv(int N) {
	N = min(N, mint::Mod - 1);
	fact.resize(N + 1); factinv.resize(N + 1);
	fact[0] = 1;
	reg(i, 1, N) fact[i] = fact[i - 1] * i;
	factinv[N] = fact[N].inverse();
	for (int i = N; i >= 1; i --) factinv[i - 1] = factinv[i] * i;
}
mint nCr(int n, int r) {
	if (n >= mint::Mod)
		return nCr(n % mint::Mod, r % mint::Mod) * nCr(n / mint::Mod, r / mint::Mod);
	return r > n ? 0 : fact[n] * factinv[n - r] * factinv[r];
}
mint nPr(int n, int r) {
	if (r<0)return 0;
	return r > n ? 0 : fact[n] * factinv[n-r];
}
mint nHr(int n, int r) { return r == 0 ? 1 : nCr(n + r - 1, r); }


ll n,a,b,c,d;
mint ans,dp[1010],dp2[1010];

void init(){
	cin>>n>>a>>b>>c>>d;
	nCr_computeFactinv(n);
	dp[n]=1;
}

int main(void){
	init();
	ireg(i,a,b){
		reg(m,0,n)dp2[m]=0;
		reg(m,0,n){  // 残り人数
			mint tmp=1;
			rep(x,c)tmp*=factinv[i];
			dp2[m]+=dp[m];  // x=0
			reg(x,c,d){  // 大きさiのグループの人数
				if(m-i*x<0)break;
				dp2[m-i*x]+=dp[m]*fact[m]*factinv[m-i*x]*factinv[x]*tmp;
				tmp*=factinv[i];
			}
		}
		reg(m,0,n)dp[m]=dp2[m];
		// reg(m,0,n)cerr<<dp[m].get()<<" ";
		// cerr<<endl;
	}
	cout<<dp[0].get()<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var N = IO.GetInt();
            var A = IO.GetIntList();
            var B = IO.GetIntList();
            var C = IO.GetIntList();
            var ans = 0;
            for(int i = 0; i < N; i++)
            {
                ans += B[A[i] - 1];
                if (i == N - 1) break;
                if (A[i+1] - A[i] == 1) ans += C[A[i]-1];
            }

            

            Console.WriteLine(ans);
        }
    }


    static class IO
    {
        static public string GetString() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public List<string> GetStringList() { return Console.ReadLine().Split(' ').ToList(); }
        static public List<int> GetIntList() { return Console.ReadLine().Split(' ').Select(int.Parse).ToList(); }
        static public List<long> GetLongList() { return Console.ReadLine().Split(' ').Select(long.Parse).ToList(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteStrings<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }
    }
}

Measured memory_bytes: 11220
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void) {
  int N, K;
  cin >> N >> K;
  vector<int> l(N);

  for (auto& v : l) {
    cin >> v;
  }

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

  int ans = 0;
  for (int i = 0; i < K; ++i) {
    ans += l[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

struct city{
	int year;
	int belong;
	int index;
	int number;
};

int main(){
	int n, m;
	cin >> n >> m;
	vector<city> v(m);
	vector<int> num(n, 0);
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		v[i].year = y;
		v[i].belong = x;
		v[i].index = i;
	}
	sort( v.begin(), v.end(), []( auto &x, auto &y ){ return x.year < y.year; } );
	for( int i = 0; i < m; ++i ){
		num[v[i].belong-1]++;
		v[i].number = num[v[i].belong-1];
	}
	sort( v.begin(), v.end(), []( auto &x, auto &y ){ return x.index < y.index; } );
	for( int i = 0; i < m; ++i ){
		cout << setfill('0') << setw(6) << right << v[i].belong;
		cout << setfill('0') << setw(6) << right << v[i].number << endl;
	}
	return 0;
}

Measured memory_bytes: 3456
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Map;
import java.util.HashMap;
import java.io.IOException;
import java.util.InputMismatchException;
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;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();

            Map<Integer, Integer> dh = new HashMap<>();
            int ch = 0;
            for (int i = 1; i <= 999; i++) {
                ch += i;
                dh.put(i, ch);
            }

            out.println(dh.get(b - a) - b);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            if (bufLength == -1)
                throw new InputMismatchException();
            return buffer[bufPointer++];
        }

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

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

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

        public long nextLong() {
            long n = 0;

            boolean minus = false;
            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || b > '9')
                throw new NumberFormatException();

            while (true) {
                if (b >= '0' && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (isSpaceChar(b) || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

    }
}



Measured memory_bytes: 21332
import java.util.Scanner;

public class Main {

    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] d = new int[N+1];
        d[0] = 0;
        int count = 0;
        for (int i = 1; i < N+1; i++) {
            int li = sc.nextInt();
            d[i] = d[i-1]+li;
            if (d[i] <= X) {
                count++;
            }
        }
        System.out.println(count+1);
    }
}

Measured memory_bytes: 35800
def main():
  X, Y = map(int, input().split()) # スペース区切り入力
  if Y % 2 == 1:
    print('No')
  else:
    if Y <= X * 4 and Y >= X * 2:
      print('Yes')
    else:
      print('No')
    
if __name__ == '__main__':
  main()

Measured memory_bytes: 9168
#include <bits/stdc++.h>
#include<math.h>
#include<algorithm> 
#define rep(i,n) for (int i = 0; i < (n) ; ++i)
using namespace std;
using ll = long long ;
using P = pair<int, int> ;
#define PI 3.14159265358979323846264338327950
#define INF 1e18
#define mod 1000000007

ll modpow(ll a, ll n) {
    if(n == 0) return 1 ;
    if(n == 1) return a % mod ;
    if(n % 2) return (a*modpow(a, n-1)) % mod ;
    ll t = modpow(a, n/2) ;
    return (t * t)% mod ;
}
int main (){
    ll x, y ;
    cin >> x >> y ;
    ll a, b ;
    b = 2*x - y ;
    if(b % 3 != 0 || b < 0){
        cout << 0 << endl ;
        return 0 ;
    }
    b /= 3 ;
    a = x - 2 * b ;
    if(a < 0){
        cout << 0 << endl ;
        return 0 ;
    }
    ll t = a + b ;
    ll sum = 1 ;
    for(int i = 1 ; i <= t ; i++){
        sum *= i ;
        sum %= mod ; 
    }
    ll ta = 1 ;
    ll tb = 1 ;
    for(int i = 1 ; i <= a; i++){
        ta *= i ;
        ta %= mod ;
    } 
    for(int i = 1; i <= b ; i++){
        tb *= i ;
        tb %= mod ;
    }
    ll ans = ((sum * modpow(ta, mod - 2))%mod* modpow(tb, mod - 2)) % mod ;
    cout << ans << endl ; 
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define mod 1000000007
#define ll long long
#define ull unsigned long long
#define mem(a) memset(a,0,sizeof(a))

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


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

typedef pair<int, int> pii;

#define pb push_back
#define mp make_pair
#define F first
#define S second
#define aint(x) (x).begin(), (x).end()

const int mod = 1e9 + 7;
const double eps = 1e-9;

struct pyr {
	int x;
	int y;
	int h;
};

int main()
{
	int n;
	cin >> n;
	pyr p[n];
	for (int i = 0; i < n; i++)
		cin >> p[i].x >> p[i].y >> p[i].h;
	int x;
	for (int i = 0; i <= 100; i++)
		for (int j = 0; j <= 100; j++)
		{
			set<int> hh;
			for (int t = 0; t < n; t++)
			{
				if (p[t].h != 0) {
					int H = p[t].h + abs(i - p[t].x) + abs(j - p[t].y);
					hh.insert(H);
				}
			}
			if (hh.size() == 1) {
				int e = *hh.begin();
				if (e < 1)
					continue;

				int ok = 0;
				for (int t = 0; t < n; t++) 
				{
					int f = max(e - abs(p[t].x - i) - abs(p[t].y - j), 0);
					if (p[t].h != f)
						ok = 1;
				}

				if(!ok)
				{
					cout<<i<<" "<<j<<" "<<e<<endl;
					return 0;
				}
			}

		}

	for(int i=0;i<=100;i++)
	{
		for(int j=0;j<=100;j++)
		{
			for(int HH=1;HH<=300;HH++)
			{
				int ok = 0;
				set< int > stt;
				for (int t = 0; t < n; t++)
				{
					int ans = max(HH - abs(p[t].x - i) - abs(p[t].y - j), 0);
					stt.insert(ans);
				}
				if (stt.size() == 1)
				{
					int pp = *stt.begin();
					cout << i << ' ' << j << ' ' << HH;
					return 0;
				}

			}
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
namespace program{
    public class ABC167{
        public static void Main(string[] args){
            var input = Console.ReadLine().Split();
            var A = int.Parse(input[0]);
            var B = int.Parse(input[1]);
            var C = int.Parse(input[2]);
            var K = int.Parse(input[3]);
            if(A >= K){
                Console.WriteLine(K);
            }else{
                var a = K-A-B > 0 ? K-A-B : 0;
                Console.WriteLine(A - a);
            }
        }
    }
}


Measured memory_bytes: 27540
#include<stdio.h>
long long N,a,mini=10e16;
int main(void){
	scanf("%lld",&N);
	for(int i=0;i<5;i++){
		scanf("%lld",&a);
        mini=(mini>a?a:mini);
	}
	printf("%lld",5+(N+mini-1)/mini-1);
}


Measured memory_bytes: 128
#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
#define pll pair<ll,ll>
#define ld long double
#define ll long long
#define pb push_back
#define S second
#define F first
using namespace std;
ll n;
int main(){
    cin>>n;
    cout<<n/2+n%2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll k,t,l;
cin>>k>>t>>l;
ll m=0;
for(ll i=0; i<=k; i++){
for(ll o=0; o<=t; o++){
if(l==i*t-o*i+o*(k-i))
m++;}}
if(m>0)cout<<"Yes"<<endl;
else cout<<"No"<<endl;}

Measured memory_bytes: 3628
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <numeric>
typedef long long Int;
#define rep(i,a,b) for(Int i=a;i<b;++i)
#define rrep(i,a,b) for(Int i=a;i>=b;--i)
using namespace std;

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

    string s1, s2; cin >> s1 >> s2;
    reverse(s2.begin(), s2.end());
    if (s1 == s2) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3f
#define EPS (1e-10)
using namespace std;
typedef long long ll;
typedef pair<int,int>P;

int main(){
	int n;cin>>n;
	char c;
	set<string>se;
	rep(i,n){
		string w;cin>>w;
		if(se.count(w)){
			puts("No");return 0;
		}
		se.insert(w);
		if(i&&w[0]!=c){
			puts("No");return 0;
		}
		c=w.back();
	}
	puts("Yes");
}

Measured memory_bytes: 256
def solve():
    s = input()
    if s == 'SUN':
        print(7)
    elif s == 'MON':
        print(6)
    elif s == 'TUE':
        print(5)
    elif s == 'WED':
        print(4)
    elif s == 'THU':
        print(3)
    elif s == 'FRI':
        print(2)
    elif s == 'SAT':
        print(1)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
 
/*
#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> 
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
*/
using namespace std;
 
#define LL long long
#define LD long double
#define PB push_back
#define MP make_pair
#define all(x) x.begin(), x.end()
#define fi first
#define se second
const LL MOD = 1000000000 + 7;
const LD EPS = 0.0000001 ;
#define MPP(a, b, c) MP(MP(a, b), c)
#define PII pair<pair<LL,LL>, LL>
 
LL pows(LL a, LL b)
{
	if (b == 0) return 1LL;
	LL temp = pows(a, b / 2);
	temp = (temp * temp) % MOD;
	if (b % 2) temp = (temp * a) % MOD;
	return temp;
}

int main(void)
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, m; cin >> n >> m;
    char arr[n][m];
    for (int i = 0; i < n; i++){
    	for (int j = 0; j < m; j++){
    		cin >> arr[i][j];
    	}
    }

    LL dp[n][m];
    memset(dp, 0, sizeof(dp));

    dp[0][0] = 1;
    for (int i = 0; i < n; i++){
    	for (int j = 0; j < m; j++){
    		if (arr[i][j] == '#') continue;
    		if (i > 0) dp[i][j] = dp[i - 1][j];
    		if (j > 0) dp[i][j] = (dp[i][j] + dp[i][j - 1]) % MOD;
    	}
    }

    cout << dp[n - 1][m - 1] << endl;

	return 0;
}

Measured memory_bytes: 9088
n = int(input())
a_list = map(int, input().split())

ans_dict = {}
for a in a_list:
    if not(a in ans_dict):
        ans_dict[a] = 0
    ans_dict[a] += 1

for i in range(1, n+1):
    if i in ans_dict:
        print(ans_dict[i])
    else:
        print(0)

Measured memory_bytes: 45144
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdio>
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<vector>
#include<set>
#include<queue>
#include<map>
#include<sstream>
#include<iomanip>
#define forn(i,n) for(int (i)=0;i<(n);i++)
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int>pii;
typedef long long ll;
typedef pair<ll,ll> pll;
const int MAXN=100005;
const int INF=2147483647;
const ll LINF=9223372036854775807;
const int dx[]={1,-1,0,0},dy[]={0,0,1,-1};
string s;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>s;
	forn(i,s.size())
	{
		cin>>i;
		if(s[i]=='?')cout<<'D';
		else cout<<s[i];
	}
	return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<cmath>
#define int long long
using namespace std;
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
int a[114];
signed main(){
	int n,x;
	cin>>n>>x;
	int sum=0;
	rep(0,i,n){
		cin>>a[i];
		sum+=a[i];
		if(sum>x){
			c(i+1)
			return 0;
		}		
	}	
	cout<<n+1<<endl;
}	

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

void solve() {
    string S;
    cin >> S;
    int ans = 0, count = 0;
    for (int i = 0; i < S.size(); i++) {
        char c = S.at(i);
        if (c == 'A' || c == 'C' || c == 'G' || c == 'T') {
            count++;
        } else {
            ans = max(ans, count);
            count = 0;
        }
    }
    ans = max(ans, count);
    cout << ans << endl;
    return;
}

int main() {
    solve();
}

Measured memory_bytes: 256
($B,$A)=glob<>;$A--;$B--;
print"40 100\n";
for(1..10){
    $-=($A<50)?$A:50;
    print '#.'x$-,'..'x(50-$-),"\n","."x100,"\n";
    $A-=50;
}
for(1..10){
    $-=($B<50)?$B:50;
    print "#"x100,"\n",'#.'x$-,'##'x(50-$-),"\n";
    $B-=50;
}


Measured memory_bytes: 768
package main

import "fmt"

func main() {
	var N, K int
	fmt.Scanf("%d", &N)
	fmt.Scanf("%d", &K)
	var ans, h int
	for i := 0; i < N; i++ {
		fmt.Scanf("%d", &h)
		if (h >= K) {
			ans++
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 5504
object Main extends App {
    val abc = scala.io.StdIn.readLine()

    abc.split(" ")
    abc.split(" ")(0)

    val a = abc.split(" ")(0).toInt
    val b = abc.split(" ")(1).toInt
    val c = abc.split(" ")(2).toInt

    println(List(b/a, c).min)
}

Measured memory_bytes: 27200
// Charan Sriramula
 
#include<bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long int ll;
 
const ll lg=22;
const ll N=2e5+5;
const ll M=5e8;
const ll INF=1e18;
const ll mod=1e9+7;
const double PI = 3.14159265358979323846;
 
#define is(n) scanf("%d",&n)
#define io(n) printf("%d\n",n)
#define ls(n) scanf("%lld",&n)
#define lo(n) printf("%lld\n",n)
 
#define f first
#define s second
#define pb(x) push_back(x)
#define pf(x) push_front(x)
#define mp(x,y) make_pair(x,y)
#define GCD(a,b) __gcd((a),(b))
#define all(v) v.begin(),v.end()
#define bits(x) __builtin_popcount(x)
#define LCM(a,b) ((a)*(b))/GCD((a),(b))
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
template<typename T> T power(T x,T y,ll m){T ans=1;while(y>0){if(y&1LL) ans=(ans*x)%m;y>>=1LL;x=(x*x)%m;}return ans%m;}
 
inline ll mul(ll a, ll b, ll p){ return (a * 1ll * b) % p; }
inline ll sub(ll a, ll b, ll p){ ll c = a - b; if(c < 0) c += p; return c; }
inline ll add(ll a, ll b, ll p){ ll c = a + b; if(c > p) c -= p; return c; }
 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

ll n,a[22][22],dp[21][(1<<21)];

ll F(ll idx,ll mask)
{
    ll res=0;
    if(idx==n){return bits(mask)==n;}
    if(dp[idx][mask]!=-1){return dp[idx][mask];}
    for(ll i=0;i<n;i++)
    {
        if(mask&(1<<i)||a[idx][i]==0){continue;}
        res=add(res,F(idx+1,mask|(1<<i)),mod);
    }
    return dp[idx][mask]=res;
}

int main()
{
    cin>>n;
    memset(dp,-1,sizeof(dp));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++){cin>>a[i][j];}
    }
    cout<<F(0,0)<<endl;
}

Measured memory_bytes: 344320
n,c = map(int,input().split())
x = []
v = []
for i in range(n):
    xx,vv = map(int,input().split())
    x.append(xx)
    v.append(vv)

a = [v[0]-x[0]] #a[i]:始点から時計回りにx[i]までいった時の収支
for i in range(1,n):
    a.append(a[-1]+v[i] - x[i]+x[i-1])

b = [v[-1]-c+x[-1]] #反時計回り
for i in range(1,n):
    b.append(b[-1]+v[n-1-i]-x[n-i]+x[n-1-i])



maxa = [a[0]]
maxb = [b[0]]
for i in range(1,n):
    maxa.append(max(maxa[-1],a[i]))
    maxb.append(max(maxb[-1],b[i]))

ass = 0
res = [0]
for i in range(n):
    if i != n-1:
        ass = a[i]+max(0,maxb[n-2-i]-x[i])
    else:
        ass = a[i]
    res.append(ass)



for i in range(n):
    if i != n-1:
        ass = b[i]+max(0,maxa[n-2-i]-(c-x[n-1-i]))
    else:
        ass = b[i]
    res.append(ass)
print(max(res))

Measured memory_bytes: 31360
package main

import (
	"bufio"
	_ "container/heap"
	"fmt"
	"os"
	_ "sort"
	"strconv"
)

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []rune {
	return []rune(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

// Arithmetic
func max(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m < i {
			m = i
		}
	}
	return m
}

func min(nums ...int) int {
	m := nums[0]
	for _, i := range nums {
		if m > i {
			m = i
		}
	}
	return m
}

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

func pow(x, y int) int {
	res := 1
	for i := 0; i < y; i++ {
		res *= x
	}
	return res
}

func ceil(a, b int) int {
	if a%b == 0 {
		return a / b
	} else {
		return a/b + 1
	}
}

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

func lcm(a, b int) int {
	return a / gcd(a, b) * b
}

// Sort
type RuneSlice []rune

func (a RuneSlice) Len() int           { return len(a) }
func (a RuneSlice) Less(i, j int) bool { return a[i] < a[j] }
func (a RuneSlice) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }

// Main
const MOD = int(1e+9) + 7
const INF = 1 << 60

func main() {
	sc := NewScanner()
	wtr := bufio.NewWriter(os.Stdout)
	defer wtr.Flush()
	N, X, Y := sc.nextInt(), sc.nextInt(), sc.nextInt()
	minus := make(map[int]int)
	plus := make(map[int]int)
	//for i := 1; i <= X; i++ {
	//	for j := Y; j <= N; j++ {
	//		minus[j-i]++
	//		plus[X-i+1+j-Y]++
	//	}
	//}
	for i := 1; i < N; i++ {
		for j := i + 1; j <= N; j++ {
			org := j - i
			diff := abs(i-X) + abs(j-Y) + 1
			if diff < org {
				minus[org]++
				plus[diff]++
			}
		}
	}
	for i := 1; i < N; i++ {
		count := N - i
		fmt.Fprintln(wtr, count-minus[i]+plus[i])
	}
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(){
  int h, w, i, j;
  while(scanf("%d%d", &h, &w) && h || w){
    for(i = 0;i < h;i++){
      for(j = 0;j < w;j++){
        if(!i || !j || i == h - 1 || j == w - 1) putchar('#');
        else putchar('.');
      }
      puts("");
    }
    puts("");
  }
  return 0;
}


Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin>>n;
    cin>>s;
    vector<int>v;
    int count=0;
    for(int i=0;i<n;i++)
    {
        if(s[i]=='W'){
            v.push_back(i);
            count++;
        }
    }
    if(v.size()==0)
        cout<<"0";
    else
    {
        int c=0,i;
        for(i=0;i<v.size();i++)
        {
            if(v[i]>=n-count&&v[i]<n)
                c++;
        }
        cout<<count-c;
    }
    return 0;
}

Measured memory_bytes: 4500
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  ll n,a[20];
  cin >> n;
  rep(i,5)cin >> a[i];
  sort(a,a+5);
  printf("%lld",(n-1)/a[0]+5);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <cassert>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
const int INF = 1<<29;

int ba[101];
int n;
bool visited[101][101];
double memo[101][101];

double calc(int now, int t) {
  if (t == 0) return now == 0 ? 1.0 : 0.0;
  if (t < 0) return 0;

  if (visited[now][t]) return memo[now][t];
  visited[now][t] = 1;
  double res = 0;
  if (now == 0) {
    REP(i, n) {
      if (ba[i] == 2)
        res += calc(i, t);
    }
  } else{
    for (int i=1; i<=min(now,6); ++i) {
      double tmp = 0;
      if (ba[now-i] == 0) tmp = calc(now-i, t-1);
      else if (ba[now-i] == 1) tmp = calc(now-i, t-2);
      res += tmp/6;
    }
  }
  // cout << now << " " << t << endl;
  // cout << "res1 = " << res << endl;
  // cout << n << endl;
  if (now != n)
    for (int i=1; i<=min(n, 6-(n-now)); ++i) {
      //cout << i << endl;
      double tmp = 0;
      if (ba[n-i] == 0) tmp = calc(n-i, t-1);
      else if (ba[n-i] == 1) tmp = calc(n-i, t-2);
      res += tmp/6;
    }
  //cout << "res2 = " << res << endl;
  return memo[now][t] = res;
}

int main() {
  int t,l,b;
  while(cin>>n>>t>>l>>b,n||t||l||b) {
    memset(ba,0,sizeof(ba));
    REP(i, l) {
      int a; cin >> a;
      ba[a] = 1;
    }
    REP(i, b) {
      int a; cin >> a;
      ba[a] = 2;
    }
    memset(visited,0,sizeof(visited));
    double ans = 0;
    REP(i, t)
      ans += calc(n, i+1);
    printf("%.12f\n", ans);
  }
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int a[100001] = {};
int ruiseki[100001] = {};

int main(void) {

	int N, K, k = 0;
	cin >> N >> K;

	string str;
	cin >> str;

	a[0]++;

	for (int i = 1; i < str.size(); i++) {
		if (str[i - 1] != str[i]) {
			k++;
		}
		a[k]++;
	}

	ruiseki[0] = a[0];

	for (int i = 0; i < k; i++) {
		cerr << a[i] << " ";
		ruiseki[i + 1] = ruiseki[i] + a[i + 1];
	}
	cerr << endl;

	int result = 0;

	for (int i = 0; i < k + 1; i++) {
		result = max(result,ruiseki[min(i + K * 2 - ((str[0] == '0') ? (i + 1) % 2 : i % 2 ),k)] - ruiseki[i] + a[i]);
	}

	cout << result << endl;

	return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <set>

int main() {
    
  std::string S;
    
  std::cin >> S;
  std::multiset<char> mset;
    
  mset.insert(S[0]);
  mset.insert(S[1]);
  mset.insert(S[2]);
    
  std::size_t n = mset.count('o');
    
  int sum = 0;
  sum = 700 + n * 100;
    
  std::cout << sum << std::endl;
    
  return 0;
}   

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

int main(void){
	int n; string s;
	cin >> n >> s;
	int cnt = 0, ans = 0;
	for(auto u : s){
		if(u == 'I') cnt++;
		else cnt--;
		chmax(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
    static void Main(string[] args)
    {
        string[] KX = Console.ReadLine().Split(' ');
        int K = int.Parse(KX[0]);
        int X = int.Parse(KX[1]);
        int min = Math.Max(-1000000, X - K + 1);
        int max = Math.Min( 1000000, X + K - 1);
        for (var i = min; i <= max; i++)
        {
            Console.Write(i+" ");
        }
        Console.WriteLine();
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define task "text"
#define forinc(i,a,b) for (int i=a; i<=b; i++)
#define fordec(i,a,b) for (int i=a; i>=b; i--)
#define forv(i,u) for (int i=0; i<u.size(); i++)
#define pii pair<int,int>
#define ll long long
#define fs first
#define sc second
#define p_b push_back
#define maxN 312345
#define inf 11234567890123456

priority_queue<int> q;
int n,a[maxN];
ll f[maxN],g[maxN];

int main() {
    ll res = -inf;
    //freopen(task".inp","r",stdin);
    scanf("%d",&n);
    forinc(i,1,3*n) scanf("%d",&a[i]);
    forinc(i,1,n) {
        q.push(-a[i]);
        f[i] = f[i-1] + a[i];
    }
    forinc(i,n+1,2*n) {
        f[i] = f[i-1];
        q.push(-a[i]);
        f[i] += a[i];
        f[i] -= -q.top();
        q.pop();
    }
    while (!q.empty()) q.pop();
    fordec(i,3*n,2*n+1) {
        q.push(a[i]);
        g[i] = g[i+1] + a[i];
    }
    fordec(i,2*n,n) {
        g[i] = g[i+1];
        q.push(a[i]);
        g[i] += a[i];
        g[i] -= q.top();
        q.pop();
    }
    forinc(i,n,2*n) res = max(res, f[i]-g[i+1]);
    cout << res;
}


Measured memory_bytes: 5240
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

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

int main(void)
{
	vector<int> a(3);
	cin >> a[0] >> a[1] >> a[2];

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

	int cost = 0;

	cost += func(a[1] - a[0]);
	cost += func(a[2] - a[1]);

	cout << cost << endl;

	return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys
import subprocess
import json
import time
import math
import re
import sqlite3

def ok(S):
    if len(S) % 2 != 0: return False
    for i in range(len(S) // 2):
        if S[i] != S[len(S) // 2 + i]: return False
    return True

S = input()
for i in range(1, len(S)):
    if ok(S[:-i]):
        print(S[:-i], file=sys.stderr)
        print(len(S[:-i]))
        break


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

#define rep(i, x, y) for(int i = (x), _ = (y); i <= _; ++ i)
#define per(i, x, y) for(int i = (x), _ = (y); i >= _; -- i)
#define dprintf(...) fprintf(stderr, __VA_ARGS__)
#define disp(x) cout << #x << " = " << x << "; "

typedef long long LL;

template <class T> bool chkmin(T& a, T b) { return a > b ? a = b, true : false; }
template <class T> bool chkmax(T& a, T b) { return a < b ? a = b, true : false; }

template <class T> void read(T& a) {
	char c = getchar(); 
	T f = 1; 
	a = 0;
	for(; !isdigit(c); c = getchar()) if(c == '-') f = -1;
	for(; isdigit(c); c = getchar()) a = a * 10 + c - '0';
	a *= f;
}
/*}}}*/

const int maxN = 1e5 + 5, mo = 1e9 + 7;

int pow_mod(int x, int t)
{
	int ret = 1;
	while(t)
	{
		if(t & 1) ret = (LL) ret * x % mo;
		x = (LL) x * x % mo; t >>= 1;
	}
	return ret;
}

int N;
int A, B;
int a[maxN];
int fac[maxN];
int cnt[maxN];
int lala;

int C(int n, int m)
{
	if(n < m) return 0;
	return (LL) fac[n] * pow_mod(fac[m], mo - 2) % mo * pow_mod(fac[n - m], mo - 2) % mo;
}

int main()
{
#ifdef Leeson
	freopen("tmp.in", "r", stdin);
	freopen("tmp.out", "w", stdout);
#endif

	fac[0] = 1;
	rep(i, 1, 100001) fac[i] = (LL) fac[i - 1] * i % mo;
	read(N);
	rep(i, 1, N + 1)
	{
		read(a[i]);
		if((++cnt[a[i]]) == 2)
		{
			lala = a[i];
			break;
		}
	}
	rep(i, 1, N + 1) if(a[i] == lala)
	{
		A = i - 1;
		break;
	}
	per(i, N + 1, 1) if(a[i] == lala)
	{
		B = N + 1 - i;
		break;
	}
	rep(i, 1, N + 1)
	{
		int ans = (C(N + 1, i) - C(A + B, i - 1) + mo) % mo;
		printf("%d\n", ans);
	}

	return 0;
}


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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define uniqueV(x) sort(x.begin(), x.end()); x.erase(unique(x.begin(), x.end()), x.end());
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(value, size) cerr<<#value<<": "<<bitset<size>(value) << endl;
#define line() cerr << "---------------" << endl;

const int dx[] = {1, -1, 0, 0};
const int dy[] = {0, 0, -1, 1};
const double PI = 3.14159265358979323846;

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

ll get(ll n) {
   int ret = 0;
   while (n % 2 == 0) {
      ret++;
      n /= 2;
   }
   return ret;
}

int main() {
   int N;
   cin >> N;
   int ans = 0;
   rep (i, N) {
      ll a;
      cin >> a;
      ans += get(a);
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template <typename Q_type>
using smaller_queue = priority_queue<Q_type, vector<Q_type>, greater<Q_type>>;

const int MOD_TYPE = 1;
const ll MOD = (MOD_TYPE == 1 ? (ll)(1e9 + 7) : 998244353);
const int INF = (int)1e9;
const ll LINF = (ll)4e18;
const double PI = acos(-1.0);

#define REP(i, m, n) for (ll i = m; i < (ll)(n); ++i)
#define rep(i, n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define possible(n) cout << ((n) ? "possible" : "impossible") << endl
#define Yay(n) cout << ((n) ? "Yay!" : ":(") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x) cerr << #x << ":" << x << endl;

vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(50) << setiosflags(ios::fixed);
  map<string, int> mp;
  int n;
  cin >> n;
  rep(i, n)
  {
    string s;
    cin >> s;
    mp[s]++;
  }
  int Max = 0;
  for (auto p : mp)
  {
    Max = max(Max, p.second);
  }
  vector<string> ans;
  for (auto p : mp)
  {
    if (p.second == Max)
      ans.push_back(p.first);
  }
  sort(all(ans));
  for (auto ai : ans)
  {
    cout << ai << "\n";
  }

  return 0;
}


Measured memory_bytes: 25584
#include <bits/stdc++.h>
using namespace std;
 
#define ll long long
#define vvi vector< vector<int> >
#define vi vector<int>
#define All(X) X.begin(),X.end()
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define shosu(X) fixed << setprecision(X)
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
 
vi data[100000];
int main(){
  int n,m;
  cin >> n >> m;
  REP(i, n){
    int a, b;
    cin >> a >> b;
    data[a-1].pb(b);
  }
  ll int ans = 0;
  priority_queue<int> pq;
  for(int i = m-1; i >= 0; i--){
    //add job 
    REP(j, data[m-1-i].size()){
      pq.push(data[m-1-i][j]);
    }
    if(not pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5632
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int K = int.Parse(Console.ReadLine());
            int X = int.Parse(Console.ReadLine());
            int Y = int.Parse(Console.ReadLine());
            int ans = 0;
            if (N <= K)
            {
                ans = X * N;
            }
            else
            {
                ans = X * K + (Y * (N - K));
            }
            Console.WriteLine(ans);
        }
    }
}

Measured memory_bytes: 11092
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)

	sc.Scan()
	s := sc.Text()

	if s[len(s)-1] == 's' {
		fmt.Println(s + "es")
	} else {
		fmt.Println(s + "s")
	}
}


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

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

  ll N; cin >> N;
  ll K; cin >> K;
  ll S; cin >> S;
  vector<ll> A(N);
  for (int i = 0; i < K; i++) {
    A[i] = S;
  }
  ll t = S + 1;
  if (S == 1000000000) t = 1;
  for (int i = K; i < N; i++) {
    A[i] = t;
  }

  cout << A[0];
  for (int i = 1; i < N; i++) {
    cout << ' ' << A[i];
  }
  return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template<class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template<class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n;
    cin>>n;
    vector<int> a(n),dp(n,INF);
    cin>>a;
    REP(i,n) {
        *lower_bound(ALL(dp),a[i])=a[i];
    }
    cout<<distance(begin(dp),lower_bound(ALL(dp),INF))<<endl;
    return 0;
}

Measured memory_bytes: 4304
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#include<cmath>


#define REP(i,n) for (int i = 0; (i) < (n); ++ (i))
#define FOR(i,n) for (int i = 1; (i) <= (n); ++ (i))
#define dump(x)  cout << #x << " = " << (x) << endl;
#define pb push_back
#define int long long
//#define lint long long

const int INF = 1e18;
const int MOD = 1e9+7;
//const lint LINF = 1e18;
const double eps = 0.000000001;//もとの値の10^(-16)まで

using namespace std;

//typedef pair<int, int> P;
//priority_queue< P, vector<P>, greater<P> > q;//ダイクストラの時、greaterで小さい順
int a[400000];
int ans;

signed main(){
  int n;
  string s;
  cin >> n;
  cin >> s;
  int now = 0;
  int ans = 1;
  REP(i,s.size()){
    if(i%2==0){
      if(s[i]=='B'){
        now ++;
      }
      else{
        ans *= now;
        ans %= MOD;
        now --;
      }
    }
    else{
      if(s[i]=='W'){
        now ++;
      }
      else{
        ans *= now;
        ans %= MOD;
        now --;
      }
    }
  }
  if(now != 0){
    cout << 0 << endl;
    return 0;
  }
  else{
    REP(i,n){
      ans *= i+1;
      ans %= MOD;
    }
    cout << ans << endl;
    return 0;
  }
}


Measured memory_bytes: 640
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n=parseInt(readline())
    ans=10^10
    for i in 1:parseInt(sqrt(n))+1
        if n%i==0
            ans=min(ans,max(length(string(i)),length(string(div(n,i)))))
        end
    end
    println(ans)
end
main()

Measured memory_bytes: 109520
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using ld=long double;
const ld INF=1e10;
void solve(int d,int e){
  ld result=INF;
  for(int x=0;x<=d;x++){
    int y=d-x;
    ld dist=sqrt((ld)(x*x+y*y));
    ld error=abs(dist-e);
    if(result>error)
      result=error;
  }
  cout<<fixed<<setprecision(10)<<result<<endl;
}

int main(){ _;
  int d,e;
  while(cin>>d>>e,(d|e)!=0)
    solve(d,e);

}

Measured memory_bytes: 3152
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

void print_a(int a[100], int n){
	for(int i = 0;i < n; i++){
		cout << a[i];
		if(i!=n-1)
			cout << " ";
		if(i==n-1)
			cout << endl;
	}
}

void insertion_sort(int a[100], int n){
	for(int i = 1; i < n; i++){
		print_a(a, n);	
		int v = a[i];
		int j = i - 1;
		while( j>= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;
	}
	print_a(a, n);	
}

int main(){
	int a[100];
	int n;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> a[i];
	}
	insertion_sort(a, n);
	
	return 0;
}

Measured memory_bytes: 1160
/*
ye mera template hai
apna khud likho bc :P
*/

/*
Author : Sarvagya Agarwal
*/

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

//defines
#define openin freopen("input.txt","r",stdin)
#define openout freopen("output.txt","w",stdout)
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long
#define int long long
#define mod 1000000007
#define repr(i,x,y) for (__typeof(x) i=x;i>=y;i--)
#define rep(i,x,y) for (__typeof(x) i=x;i<=y;i++)
#define all(c) (c).begin(),(c).end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair

/* Print pair */
template <typename T,typename S>
ostream & operator << (ostream &os , const pair<T,S> &v) {
    os << "(" ;
    os << v.first << "," << v.second << ")" ;
    return os ;
}
/* Print vector */
template <typename T>
ostream & operator << (ostream &os , const vector<T> &v) {
    os << "[" ;
    int sz = v.size() ;
    for(int i = 0 ; i < sz ; ++i) {
        os << v[i] ;
        if(i!=sz-1)os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print set */
template <typename T>
ostream & operator << (ostream &os , const set<T> &v) {
    T last = *v.rbegin() ;
    os << "[" ;
    for(auto it : v) {
        os << it  ;
        if(it != last) os << "," ;
    }
    os << "]\n" ;
    return os ;
}
/* Print Map */
template <typename T,typename S>
ostream & operator << (ostream &os , const map<T,S> &v) {
    for(auto it : v) {
        os << it.first << " : " << it.second << "\n" ;
    }
    return os ;
}
int power(int a , int b)
{
    int res = 1 ;
    while(b)
    {
        if(b%2) {
            res = (res * a) % mod ;
        }
        b/=2 ;
        a = (a*a) % mod ;
    }
    return res ;
}

//debug
#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
		cout << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
		const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
int cnt[1005] ;
void go(int num)
{
    for(int i = 2 ; i*i <= num ; ++i) {
        if(num % i ==0) {
            int x = 0 ;
            while(num % i == 0) {
                x++ ;
                num /= i ;
            }
            cnt[i] += x ;
        }
    }
    if(num > 1) cnt[num] += 1 ;
}
int32_t main()
{
    fast;
    int n ;
    cin >> n ;
    rep(i,1,n) go(i) ;
    int ans = 1 ;
    rep(i,1,1000)
    {
        cnt[i] %= mod ; 
        ans = (ans * (cnt[i] + 1)) ;
        ans = ans % mod ; 
    }
    cout << ans << endl ;
    return 0;
}


Measured memory_bytes: 256