akhauriyash/Code-Regression huggingface dataset:
package main

import "fmt"

type item struct {
	w, v int
}

var (
	n, w  int
	items []item
	dp    [][]int
)

func main() {
	fmt.Scan(&n, &w)

	items = make([]item, 0, n)
	for range make([]struct{}, n) {
		var weight, value int
		fmt.Scan(&weight, &value)
		items = append(items, item{weight, value})
	}

	dp = make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, w+1)
		for j := range dp[i] {
			dp[i][j] = -1
		}
	}
	fmt.Println(recDp(0, w))
}

func recDp(i, left int) int {
	if i == n {
		return 0
	} else if dp[i][left] != -1 {
		return dp[i][left]
	}
	var res int
	if items[i].w > left {
		res = recDp(i+1, left)
	} else {
		res = max(
			recDp(i+1, left),
			recDp(i+1, left-items[i].w)+items[i].v,
		)
	}
	dp[i][left] = res
	return res
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}


Measured memory_bytes: 82304
import math

a, b, x = [int(n) for n in input().split()]

def to_deg(theta):
    return theta * 180 / math.pi

if x <= a**2 * b / 2:
    theta = math.atan((a * b**2) / (2*x))
else:
    theta = math.atan(2 * (a**2 * b - x) / a**3)

print(to_deg(theta))

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

int main(){
    int k;
    cin >> k;
    int x = 7%k;
    set<int> s;
    int c = 1;
    while(s.count(x) == 0){
        if(x == 0){
            cout << c << endl;
            return 0;
        }
        s.insert(x);
        x = (x*10 + 7)%k;
        c++;
    }
    cout << -1 << endl;
    return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    string n;
    cin>>n;
    string rev =n;
    reverse(all(rev));
    if(n == rev)
    {
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;

    return 0;
}

Measured memory_bytes: 256
n = int(input())
rs = [tuple(map(int, input().split())) for _ in range(n)]
bs = [tuple(map(int, input().split())) for _ in range(n)]

bs.sort()

#lambdaを使ってy座標でソート
#list.sort(key=lambda x:x[i])でi番目の要素によるソート
#lambda x : -x[1]とすることでrsを降順にできる
rs.sort(key=lambda x: -x[1])

ans = 0
for bx, by in bs:
    for rx, ry in rs:
        if rx < bx and ry < by:
            rs.remove((rx, ry))
            ans += 1
            break
        else:
            continue
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;
int x[MAXN], wt[MAXN];
int main(int argc, char const *argv[])
{
	int n, s;
	cin>>n>>s;
	for (int i = 0; i < n; ++i)
	{
		cin>>x[i]>>wt[i];
	}
	int lptr = 0, rptr = n - 1;
	long long int early_l = 0, early_r = 0;
	vector <int> A;
	while(lptr < n && x[lptr] < s && rptr >= 0 && x[rptr] > s)
	{
		if(early_l + wt[lptr] >= early_r + wt[rptr])
		{
			early_l+=(early_r + wt[rptr]);
			early_r = 0;
			A.push_back(rptr);
			rptr--;
		}
		else
		{
			early_r+=(early_l + wt[lptr]);
			early_l = 0;
			A.push_back(lptr);
			lptr++;
		}
	}
	while(lptr < n && x[lptr] < s)
	{
		A.push_back(lptr);
		lptr++;
	}
	while(rptr >= 0 && x[rptr] > s)
	{
		A.push_back(rptr);
		rptr--;
	}
	long long int ans = 0;
	for (int i = n - 1; i >= 0; --i)
	{
		ans+=abs(s - x[A[i]]);
		s = x[A[i]];
	}
	cout<<ans<<"\n";
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

#define mp make_pair
#define ff first
#define ss second
#define pb push_back
#define pf push_front
#define popb pop_back
#define popf pop_front
#define all(v) v.begin(),v.end()

const int maxn = 1e6 + 100;
const ll inf = 2e18, mod = 1e9 + 7;

int len;
char number[maxn];
set<int> posSet[10];

void oneUp() {
	for (int i = len - 1; i >= 0; i--) {
		if (number[i] == '9') {
			posSet[9].erase(i);
			posSet[0].insert(i);
			number[i] = '0';
		}
		else {
			posSet[number[i] - '0'].erase(i);
			posSet[number[i] - '0' + 1].insert(i);
			number[i]++;
			break;
		}
	}
}

char getNextBlock(char c) {
	int pos = maxn, res = -1, digit = c - '0';
	for (int i = 0; i < 10; i++) {
		if (digit != i && (!posSet[i].empty() && pos > *posSet[i].begin())) {
			pos = *posSet[i].begin();
			res = i;
		}
	}
	if (res == -1)
		res = 20;
	return res + '0';
}

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

	cin >> number;
	len = strlen(number);
	for (int i = 0; i < len; i++) {
		posSet[number[i] - '0'].insert(i);
	}

	int ans = 0;
	char last = '0';
	for (int i = 0; i < len; i++) {
		if (number[i] == last) {
			if (getNextBlock(number[i]) < last) {
				oneUp();
				ans++;
				last = '0';
				i--;
			}
			else {
				posSet[number[i] - '0'].erase(i);
				number[i] = '0';
			}
		}
		else if (number[i] > last) {
			last = number[i];
			posSet[number[i] - '0'].erase(i);
			number[i] = '0';
			if (getNextBlock(last) < last) {
				last = '0';
				oneUp();
				ans++;
			}
		}
	}
	ans += (last != '0');
	cout << ans << endl;
}



Measured memory_bytes: 24192
#include <iostream>
#include <map>
#include <string>
#include <cctype>
using namespace std; 

map<char,int> c_i;
map<int,char> i_c;
string str;

void init(){
  for(char ch = 'a' ; ch <= 'z' ; ch++){
    c_i[ch] = ch - 'a';
    i_c[ch-'a'] = ch;
  }
}

bool serch(string s){
  int a = s.find("that");
  int b = s.find("this");

  if(a != string::npos || b != string::npos) return true;
  return false;
}

char change(char ch,int a,int b){
  int num = c_i[ch];
  int nnum = (a*num+b) % 26;

  return i_c[nnum];
}

int main(){
  int n;
  init();

  cin >> n;
  cin.ignore();

  while(n--){
    getline(cin,str);

    for(int i = 0 ; i < 26 ; i++){
      for(int j = 0 ; j < 26 ; j++){
	string tmp = "";
	for(int k = 0 ; k < str.size() ; k++){
	  if(islower(str[k])){
	    tmp += change(str[k],i,j);
	  }
	  else tmp += str[k];
	}
	if(serch(tmp)){
	  cout << tmp << endl;
	  goto end;
	}
      }
    }
  end:;
  }

  return 0;
}

Measured memory_bytes: 1224
import java.util.*;

public class Main {
	public static void main(String[] args) {  
  		Scanner sc = new Scanner(System.in);
      	int R = sc.nextInt();
      
      	if(R < 1200) {
        	System.out.println("ABC");
        } else if(R >= 1200 && R < 2800) {
          	System.out.println("ARC");
        } else {
        	System.out.println("AGC");  
        }
    }
}

Measured memory_bytes: 21844
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    int ab = a + b;
    
    if (ab >= c) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

int a, b;
string t, u;
int Max = 0;
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return true;
}
void dfs(int p) {
	if (a == p) {
		string q = t; reverse(q.begin(), q.end());
		int c = stoi(t + u + q);
		if (is_prime(c))Max = max(Max, c);
		return;
	}
	rep(i, 10) {
		if (i == 0 && p == 0)continue;
		t += to_string(i);
		dfs(p + 1);
		t.pop_back();
	}
}
int main() {
	scanf("%d%d", &a, &b);
	if (b < 0) {
		if (a == 1)puts("11");
		else {
			rep(i, 2*a)printf("9");
			printf("\n");
		}
		return 0;
	}
	u = to_string(b);
	dfs(0);
	printf("%d\n", Max);
}

Measured memory_bytes: 3308
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int n;
		n = sc.nextInt();
		int[] a = new int[n + 1];
		int[] b = new int[n];
		for(int i = 0 ; i < n + 1 ; i++) {
			a[i] = sc.nextInt();
		}
		for(int i = 0 ; i < n ; i++) {
			b[i] = sc.nextInt();
		}
		long ans = 0;
		for(int i = 0 ; i < n ; i++) {
			if(a[i] >= b[i]) {
				ans += b[i];
			} else {
				ans += a[i];
				int zan = b[i] - a[i];
				if(a[i + 1] >= zan) {
					ans += zan;
					a[i + 1] -= zan;
				} else if(a[i + 1] < zan) {
					ans += a[i + 1];
					a[i + 1] = 0;
				}
			}
		}
		System.out.println(ans);
		sc.close();
	}

}


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

#define vt          vector
#define sz(x)       int((x).size())
#define all(x)      (x).begin(), (x).end()
#define rall(x)     (x).rbegin(), (x).rend()
#define fi          first
#define se          second

using ll = long long;
using pii = pair<int, int>;

void solve() {
    char c;
    cin >> c;
    cout << char(c + 1);
}

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

    int tcs = 1;
    for (int tc = 1; tc <= tcs; tc++) {
        // cout << "Case " << tc << ": ";
        solve();
    }
}


Measured memory_bytes: 3604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

std::string pad(int num)
{
    char buffer[4];
    std::snprintf(buffer, sizeof(buffer), "%03d", num);
    return buffer;
}

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

#ifdef _MSC_VER
#  include <intrin.h>
#  define __builtin_popcount __popcnt
#endif

struct Hashing {
    ull seed, mod;
    vector <ull> hs, pw;

    Hashing(ull seed = 31, ull mod = 1000173169) :
        seed(seed),
        mod(mod) {}

    void build(int n, const string& s) {
        hs.assign(n + 1, 0);
        pw.assign(n + 1, 1);
        pw[0] = 1;

        for (int i = 1; i <= n; ++i)
            pw[i] = pw[i - 1] * seed % mod;
        for (int i = 1; i <= n; ++i)
            hs[i] = (hs[i - 1] * seed + s[i]) % mod;
    }

    ull hash(int l, int r) {
        return (hs[r] - hs[l - 1] * pw[r - l + 1] % mod + mod) % mod;
    }
};

int solve()
{
    int H, N;

    std::cin >> H >> N;
    
    int sum = 0;
    for (int i = 0; i < N; ++i) {
        int tmp = 0;
        cin >> tmp;
        sum += tmp;
    }

    if (sum >= H)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define title "title"
#define ll long long
#define ull unsigned ll
#define fix(x) fixed<<setprecision(x)
#define pii pair<ll,ll>
#define vint vector<ll>
#define pb push_back
using namespace std;
void Freopen(){
	freopen(title".in","r",stdin);
	freopen(title".out","w",stdout);
}
ll read(){
	ll g=0,f=1;
	char ch=getchar();
	while(ch<'0'||'9'<ch){if(ch=='-')f=-1;ch=getchar();}
	while('0'<=ch&&ch<='9'){g=g*10+ch-'0';ch=getchar();}
	return g*f;
}
const ll N=1e5+5;
ll n,st,x[N],p[N];
ll calc(ll l,ll r,ll t){
	if(st<x[l])return x[r]-st;if(x[r]<st)return st-x[l];
	if(p[l]>=p[r])return p[l]+=p[r],calc(l,r-1,l)+(t==r?x[r]-x[l]:0);
	else return p[r]+=p[l],calc(l+1,r,r)+(t==l?x[r]-x[l]:0);
}
signed main(){
	n=read(),st=read();
	for(ll i=1;i<=n;i++)x[i]=read(),p[i]=read();
	return cout<<calc(1,n,p[1]<p[n]?1:n),signed();
}

Measured memory_bytes: 8948
/*
ID: learnin7
TASK: test
LANG: C++                 
*/
/* LANG can be C++11 or C++14 for those more recent releases */
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
        
    ios_base::sync_with_stdio(0);
    //ofstream fout ("test.out");
    //ifstream fin ("test.in");
    //fin >> a >> b;
    //fout << a+b << endl;
    string s;
    cin>>s;
    set<char> x;
    for(int i=0;i<s.length();i++){
        if(x.count(s[i])){
            cout<<"no\n";
            return 0;
        }
        else{
            x.insert(s[i]);
        }
    }
    cout<<"yes\n";
    return 0;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip>
using namespace std;
#define int long long

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


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

    int x,y; cin >> x >> y;
    if(y >= x && y >0 && x < 0 && abs(y)> abs(x)) cout << 1 + y + x << endl;
    else if(y >= x && y >0 && x < 0) cout << -y - x + 1 << endl;
    else if(y >= x) cout << y - x << endl;
    else if(y > 0) cout << 1 - y + x + 1 << endl;
    else if(y == 0) cout << 1 + x << endl;
    else if(x >= 0 && abs(x) >= abs(y)) cout << 1 + abs(x) - abs(y) << endl;
    else if(x >= 0) cout << abs(y) - abs(x) + 1 << endl;
    else if(x > y)cout << 1 + abs(y) - abs(x) + 1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define Yes                \
    cout << "Yes" << endl; \
    return 0;
#define No                \
    cout << "No" << endl; \
    return 0;
using namespace std;
using ll = long long;
const int INF = 1001001001;
const int MOD = 1000000007;
typedef long long ll;

template <typename T>
void print(const T &v);

int main()
{
    int N;
    cin >> N;
    int x = 800 * N;
    int y = 200 * (N / 15);
    cout << x - y << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << " ";
        cout << v[i];
    }
    cout << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int digit4 = N / 1000;
  int digit3 = (N % 1000) / 100;
  int digit2 = (N % 100) / 10;
  int digit1 = N % 10;
  
  if ((digit4 == digit3)
      && (digit4 == digit2)
     ){
    cout << "Yes" << endl;
  }
  else if ((digit3 == digit2)
      && (digit3 == digit1)
     ){
    cout << "Yes" << endl;
  }
  else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>
#include <sstream>
#include <bitset>
#include<stack>
#include<functional>
#include<unordered_set>
#include<unordered_map>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;
const long long ll_max = 9223372036854775807;
const long long ll_min = -9223372036854775807;
const int int_max = 2147483647;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> getPrimeFactor(T n) {
	map<T, T> ret;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			ret[i] ++;
			n /= i;
		}
	}
	if (n != 1) ret[n] = 1;
	return ret;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}

template<typename T>
T modinv(T a, T m) {
	T b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



// 繰り返し二乗法
ll pow2(ll n, ll p, ll mod) {
	if (p == 0 || n == 1) {
		return 1;
	}
	else {
		ll ret = pow2(n * n % mod, p / 2, mod);
		if (p % 2 == 1) {
			ret *= n;
		}
		return ret % mod;
	}
}


#define rep(i,s,e) for(ll i=s;i<e;i++)
#define repeq(i,s,e) for(ll i=s;i<=e;i++)


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

	vector<set<ll>> st(n+1);
	vll cnt(n + 1, 0);
	ll max_cnt = 0;
	ll max_num = 0;
	rep(i, 1, n) {
		ll a, b;
		cin >> a >> b;
		st[a].insert(b);
		st[b].insert(a);
		cnt[a]++;
		if (max_cnt < cnt[a]) {
			max_cnt = cnt[a];
			max_num = a;
		}
		cnt[b]++;
		if (max_cnt < cnt[b]) {
			max_cnt = cnt[b];
			max_num = b;
		}
	}

	priority_queue<ll> pq;
	rep(i, 0, n) {
		ll c;
		cin >> c;
		pq.push(c);
	}

	vll ans(n + 1,-1);
	ll ans_sum = -pq.top();
	queue<ll> q({ max_num });
	while (!(q.empty())) {
		queue<ll> r;
		while ((!q.empty())) {
			ans[q.front()] = pq.top();
			ans_sum += pq.top();
			pq.pop();
			for (auto x : st[q.front()]) {
				if (ans[x] < 0) {
					r.push(x);
				}
			}
			q.pop();
		}
		q = move(r);
	}
	cout << ans_sum << endl<<ans[1];
	repeq(i, 2, n) {
		cout << " " << ans[i];
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 5112
#include <bits/stdc++.h>
using namespace std;
#define ll          long long
#define mp	    make_pair
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define MOD        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define gcd(a,b)    __gcd((a),(b))
#define lcm(a,b)    ((a)*(b)) / gcd((a),(b))
#define rep(i,a,b)  for(int i=a;i<b;i++)
map<string, int>m;
void solve(){
	int a; cin>>a;
	rep(i,0,a){
		string s;
		cin>>s;
		m[s]++;
	}
	int b; cin>>b;
	rep(i,0,b){
		string s;
		cin>>s;
		m[s]--;
	}
	int mm = 0;
	for(auto it = m.begin(); it != m.end(); it++)
		mm = max(it->y, mm);	
	cout<<mm<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t;
    t =1;
//     cin>>t;
    while(t--){
        solve();
    }
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define MAX 100001
#define Mod 1000000007
typedef long long ll;
using namespace std;
ll ans, cnt;
ll fac[MAX], finv[MAX], inv[MAX];
void comInit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; i++) {
    fac[i] = fac[i - 1] * i % Mod;
    inv[i] = Mod - inv[Mod % i] * (Mod / i) % Mod;
    finv[i] = finv[i - 1] * inv[i] % Mod;
  }
}

ll com(ll n, ll r) {
  if (n < r)
    return 0;
  if (n < 0 || r < 0)
    return 0;
  return fac[n] * (finv[r] * finv[n - r] % Mod) % Mod;
}

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  rep(i, n)
  {
    cin >> a[i];
  }
  comInit();

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

  ll maxsum = 0;
  rep(i, n)
  {
    maxsum += (com(i, k - 1) * a[i]) % Mod;
    maxsum %= Mod;
  }

  reverse(a.begin(), a.end());
  ll minsum = 0;
  rep(i, n)
  {
    minsum += (com(i, k - 1) * a[i]) % Mod;
    minsum %= Mod;
  }

  cout << (maxsum - minsum) % Mod << endl;

  return 0;
}

Measured memory_bytes: 3328
#include <iostream>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong weight[MAX];

int check(int mid){
    llong sum = 0;
    int i = 0;
    for(int j = 0; j < k; j++){
        while(sum + weight[i] <= mid){
            sum += weight[i];
            i++;

            if (i == n){
                return n;
            }
        }
        sum = 0;
    }
    return i;
}

int solve(){
    llong left = 0;
    llong right = 100000 * 10000;
    llong mid;

    while(right - left > 1){
        mid = (right + left) /2;
        int v = check(mid);
        if(v >= n){
            right = mid;
        }else{
            left = mid;
        }
    }
    return right;
}



int main(void){
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> weight[i];
    }

    llong ans = solve();

    cout << ans << endl;

    return 0;

}


Measured memory_bytes: 3864
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>


#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S,False(1,-1);
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

template<typename A,size_t N,typename T>
void Fill(A(&array)[N],const T &val){
    fill((T*)array,(T*)(array+N),val);
}


ll gcd(ll a,ll b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}


int main(){
    int n, m;
    cin >> n >> m;
    int sum = 0;
    rep(i, m){
        int a;
        cin >> a;
        sum += a;
    }

    cout << max(n - sum, -1) << endl;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define SZ(v) int((v).size())
#define ALL(vec) begin(vec), end(vec)
using namespace std;
typedef long long i64;
template<typename T> inline bool uax(T &x, T y) {return (y > x) ? x = y, true : false;}
template<typename T> inline bool uin(T &x, T y) {return (y < x) ? x = y, true : false;}
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); \
  stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
string to_string(char c) { return "'" + string(1, c) + "'";}
string to_string(string s) { return '"' + s + '"';}
string to_string(const char* s) { return to_string((string) s);}
template<typename A> string to_string(A);
template<typename A, typename B> string to_string(pair<A, B> p){
  return "(" + to_string(p.first) + ": " + to_string(p.second) + ")";}
template<typename A> string to_string(A v) {bool f = false; string r = "{"; 
  for (auto x: v) {if (f) r += ", "; r += to_string(x); f = true;} return r += "}";}
template<typename A> string to_string(vector<vector<A>> v) {string r; 
  for (auto x: v) r += "\n" + to_string(x); return r;}
void err(istream_iterator<string>) { cerr << endl; }
template<typename T,typename... Args> void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " =: " << to_string(a) << "; "; err(++it, args...); }
template<typename T> void kek(T ans) {cout << ans << endl; exit(0);}
int const MOD = 1e9 + 7;
long long const INF = 1e18 + 42;
/*************************************/

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  
  char c;
  cin >> c;
  ++c;
  cout << c;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();

    int ap = 0;
    int bp = 0;
    for (int i = 0; i < n; i++) {
        int result = sc.next().compareTo(sc.next());
        ap += result > 0 ? 3 : result < 0 ? 0 : 1;
        bp += result > 0 ? 0 : result < 0 ? 3 : 1;
    }

    System.out.println(ap + " " + bp);
  }
}


Measured memory_bytes: 30232
#include<bits/stdc++.h>
using namespace std;
#define X           first
#define Y           second
#define N           1005
#define pb          push_back
#define pp          pop_back
#define mk          make_pair
#define PI          acos(-1)
#define EPS         1e-9
#define INF         1<<29
#define ln          '\n'
#define sp          ' '
#define redian      180/PI
#define all(x)      x.begin(),x.end()
#define Sort(x)     sort(all(x))
#define mem(a,b)    memset(a,b,sizeof(a))
#define lpa(p,v)    for(auto p:(v))
#define lp(a,b,c)   for(int a=(b);a<(c);a++)
#define lp0(a,n)    lp(a,0,n)
#define lpr(a,b,c)  for(int a=(b);a>=(c);a--)
#define faster      ios_base::sync_with_stdio(0);cin.tie(0);

const int MOD=1e9+7;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<int,string> psi;
typedef map<string,int>msi;
inline bool sc(int &_x){return scanf("%d",&_x)==1;}
inline bool sc(int &_x, int &_y){return sc(_x)&&sc(_y);}
inline bool sc(int &_x, int &_y, int &_z){return sc(_x)&&sc(_y)&&sc(_z);}
inline bool sc(int &_x, int &_y, int &_z, int &_zz){return sc(_x)&&sc(_y)&&sc(_z)&&sc(_zz);}
/*      direction
int x4[]= {1,-1,0,0};
int y4[]= {0,0,1,-1};
int x8[]= {0,0,+1,-1,-1,+1,-1,+1};
int y8[]= {-1,+1,0,0,+1,+1,-1,-1};
int kx[]={2,2,-2,-2,1,-1,1,-1};
int ky[]={1,-1,1,-1,2,2,-2,-2};*/
int a[26];
int main()
{
    string s;cin>>s;
    bool f=1;
    lp0(i,s.length())a[s[i]-'a']++;
    lp0(i,26)
        if(a[i]&1)
        {
            f=0;break;
        }
    if(f)cout<<"Yes\n";
    else cout<<"No\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}



int main(){
    int n;cin>>n;
    vector<int>v(n);
    vector<int>c(n);
    rep(i,n)cin>>v[i];
    rep(i,n)cin>>c[i];

    int res = 0;
    for(int bit=0;bit<(1<<n);bit++){
        vector<int>S = bitSearch(bit,n);
        int val = 0,cst = 0;
        for(auto s : S){
            val += v[s];
            cst += c[s];
        }
        res = max(res,val-cst);
    }
    cout<<res;
}



Measured memory_bytes: 256
def gcd(a, b)
    return a if b == 0
    gcd(b, a % b)
end

def solve(arr)    
    ans = arr.pop
    arr.each do |i|
        ans = gcd(ans, i)
    end
    ans
end

n = gets.to_i
a = gets.split.map(&:to_i).sort

puts solve(a)


Measured memory_bytes: 10104
#include<bits/stdc++.h>
using namespace std;
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define endl "\n"
#define test ll t; cin>>t; while(t--)
typedef long long int ll;
int main() {
    ll n;
    cin>>n;
    ll a=1,b=1,c=1;
    for(int i=0;i<n;i++){
       a=(a*(ll)10)%mod;
       b=(b*(ll)9)%mod;
       c=(c*(ll)8)%mod;
    }
    //cout<<a<<" "<<b<<" "<<c<<endl;
    a+=c;
    a%=mod;
    b*=2;
    b%=mod;
    a+=mod;
    a-=b;
    a%=mod;
    cout<<a<<endl;
	return 0;
}


Measured memory_bytes: 3616
#include<stdio.h>
#include<stdlib.h>
#define ll long long
ll max(ll x,ll y){return x<y?y:x;}
ll ceilll(ll x,ll y){if(x%y==0)return x/y;
else return x/y+1;}
int main(void){
	ll n,t,a,i,x,y,m;
	scanf("%lld",&n);
	scanf("%lld %lld",&t,&a);
	for(i=1;i<n;i++){
		scanf("%lld %lld",&x,&y);
		m=max(ceilll(t,x),ceilll(a,y));
		t=m*x;
		a=m*y;
	}
	printf("%lld",t+a);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<cstdlib>
#include<cstring>

struct Node{
	int key;
	Node *next, *prev;
};

Node *nil;

Node* listSerch( int key ){
	Node *cur = nil->next; //番兵の次の要素から辿る
	while( cur != nil && cur->key != key ){
		cur = cur->next;
	}
	return cur;
}

void init(){
	nil = (Node *)malloc(sizeof(Node));
	nil->next = nil;
	nil->prev = nil;
}

void printList(){
	Node *cur = nil->next;
	int isf = 0;
	while(1){
		if( cur == nil ) break;
		if( isf++ > 0 )printf(" ");
		printf("%d", cur->key);
		cur = cur->next;
	}
	printf("\n");
}

void deleteNode(Node *t){
	if( t == nil )return; //tが番兵の場合は処理しない
	t->prev->next = t->next;
	t->next->prev = t->prev;
	free(t);
}

void deleteFirst(){
	deleteNode(nil->next);
}

void deleteLast(){
	deleteNode(nil->prev);
}

void deleteKey(int key){
	//検索したノードを削除
	deleteNode(listSerch(key));
}

void insert(int key){
	Node *x = (Node *)malloc(sizeof(Node));
	x->key = key;
	//番兵の最後に要素を追加
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

int main(){
	int key, n, i;
	int size = 0;
	char com[20];
	int np = 0, nd = 0;
	scanf("%d", &n);
	init();
	for( i = 0; i < n; i++ ){
		scanf("%s%d", com, &key);//より高速な入力関数を使用
		if( com[0] == 'i' ){ insert(key); np++, size++; }
		else if( com[0] == 'd' ){
			if( strlen(com) > 6 ){
				if( com[6] == 'F')deleteFirst();
				else if( com[6] == 'L' )deleteLast();
			}else{
				deleteKey(key); nd++;
			}
			size--;
		}
	}
	
	printList();
	
	return 0;
}


Measured memory_bytes: 33948
#include <stdbool.h>
#include <stdio.h>

struct TRect
{
    int Width;
    int Height;
};

struct TCircle
{
    int CenterX;
    int CenterY;
    int Radius;
};

bool IsInsideOf(struct TCircle* Circle, struct TRect* Rect)
{
    if(Circle->CenterX < Circle->Radius) return false;
    if(Circle->CenterY < Circle->Radius) return false;
    if(Rect->Width < Circle->CenterX + Circle->Radius) return false;
    if(Rect->Height < Circle->CenterY + Circle->Radius) return false;
    return true;
}

int main()
{
    struct TRect Rect;
    struct TCircle Circle;
    scanf("%d %d", &(Rect.Width), &(Rect.Height));
    scanf("%d %d %d", &(Circle.CenterX), &(Circle.CenterY), &(Circle.Radius));
    if(IsInsideOf(&Circle, &Rect)){
        puts("Yes");
    }else{
        puts("No");
    }
    return 0;
}



Measured memory_bytes: 2124
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
int main(){
   ll x;
   cin >> x;
   
   ll mod = x%100;
   ll base = x/100;

   if(mod <= base*5)cout << 1 << endl;
   else cout << 0 << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;

namespace ALDS1_4_A {
    class Program {
        static void Main(string[] args) {
            Console.ReadLine();
            var S = Console.ReadLine().Split(' ').Select(int.Parse);
            Console.ReadLine();
            var T = Console.ReadLine().Split(' ').Select(int.Parse);
            int count = 0;
            foreach (var t in T) {
                foreach (var s in S) {
                    if (s == t) {
                        count++;
                        break;
                    }
                }
            }
            Console.WriteLine(count);
        }
    }
}

Measured memory_bytes: 9920
#include "bits/stdc++.h"
#pragma GCC optimize "03"
using namespace std;
 
#define int long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 1e5 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int a[N];

signed main() {
	IOS;
	int n, m;
	cin >> n >> m;
	int s = 0;
	for(int i = 1; i <= n; i++){
		cin >> a[i];
		s += a[i];
	}
	int x = (s - 1)/(4*m) + 1;
	for(int i = 1; i <= n; i++){
		if(a[i] >= x)
			m--;
	}
	if(m <= 0)
		cout << "Yes";
	else
		cout << "No";
	return 0;
}

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

using namespace std;

typedef long long LL;

string long_division(string number, LL divisor)
{
    string ret = "";
    LL temp = 0;
    queue<LL>q;

    for(int i=0; i<number.size(); i++)
    {
        temp = (temp * 10) + (number[i] - '0');
        q.emplace(temp/divisor);
        temp %= divisor;
    }

    if(q.empty()) return "0";

    while(q.front()==0) q.pop();
    while(!q.empty())
    {
        ret += q.front() + '0';
        q.pop();
    }
    return ret;
}

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

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //freopen("error.txt", "w", stderr);

    /*for(int i=0; i<=9; i++) cout<<"value["<<i<<"] = "<<i<<";\n";
    for(int i=10; i<=32; i++) cout<<"value["<<i<<"] = '"<<(char)(i+55)<<"';\n";*/

    //int t; cin>>t; while(t--) {
        int n;
        cin>>n;
        while(n)
        {
            if(n%10==7)
            {
                cout<<"Yes\n";
                return 0;
            }

            n /= 10;
        }

        cout<<"No\n";
    //}

    return 0;
}

Measured memory_bytes: 3620
#include<stdio.h>

int main(void){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  
  int min;
  min=400;
  int o,p,q;
  o=a+b;
  p=b+c;
  q=a+c;
  if(min>=o){
    min=o;
  }
  if(min>=p){
    min=p;
  }
  if(min>=q){
    min=q;
  }
  
  printf("%d",min);
  
  return 0;
}

Measured memory_bytes: 128
def f(heights,roads):
	r = [True] * len(heights)
	for u,v in roads:
		if heights[u - 1] <= heights[v - 1]: r[u - 1] = False
		if heights[u - 1] >= heights[v - 1]: r[v - 1] = False
	return len([v for v in r if v])

n,m = map(int, raw_input().split(' '))
print f(map(int,raw_input().split(' ')), [map(int, raw_input().split(' ')) for _ in range(m)] )


Measured memory_bytes: 94104
x = gets.split(" ").map{|k|k.to_i}

n = x[0]
q = x[1]
time = 0
hash = Hash.new
ans_hash = Hash.new

n.times do
    y = gets.split(" ")
    hash[y[0]] = y[1].to_i
end

until ans_hash.length == n
    key,value = hash.shift
    if value <= q
        time += value
        ans_hash[key] = time
    else
        time += q
        value -= q
        hash[key] = value
    end
end

ans_hash.each do |k,v|
    puts "#{k} #{v}"
end


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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<int> vi;
const ll MOD = 1e9 + 7;
const int maxn = 1e6 + 10;

int main() {
    int x;
    cin >> x;
    if (x == 3 || x == 5 || x == 7) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
    return 0;
}

static int speedUp = []() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    return 0;
}();

Measured memory_bytes: 256
#!/usr/bin/env python3
flip = { 'i': 'i', 'w': 'w', '(': ')', ')': '(' }
s = input()
result = 0
for i in range((len(s) + 1) // 2):
    result += (flip[s[i]] != s[len(s) - i - 1])
print(result)

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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    if (b <= a) cout << "delicious" << endl;
    else if (b - a <= x) cout << "safe" << endl;
    else cout << "dangerous" << endl;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }

    let ans = s.iter().filter(|c| **c == 'x').count() <= 7;

    println!("{}", if ans {"YES"} else {"NO"});
}


Measured memory_bytes: 4352
fn main() {
    let n: usize = io::readln();
    let mut dir: isize = if n % 2 == 0 { -1 } else { 1 };

    let a: Vec<usize> =
        io::read_line().split_whitespace().map(|num| num.parse().unwrap()).collect();
    let mut b: Vec<usize> = (0..n).map(|_| 0).collect();
    let mut pos = n / 2;
    for i in 0..n {
        let num = a[i];
        b[pos] = num;
        pos = (pos as isize + (i + 1) as isize * dir) as usize;
        dir = dir * -1;
    }
    for i in 0..b.len() {
        print!("{}", b[i]);
        if i != b.len() - 1 {
            print!(" ");
        }
    }
}

pub mod io {
    use std::io;

    pub fn read_line() -> String {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }

    pub fn readln<T: Read>() -> T {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        T::read(s.trim())
    }

    pub trait Read {
        fn read(s: &str) -> Self;
    }

    impl Read for String {
        fn read(s: &str) -> Self {
            s.to_string()
        }
    }

    impl<T: Read> Read for Vec<T> {
        fn read(s: &str) -> Self {
            s.split_whitespace().map(|w| T::read(w)).collect()
        }
    }

    macro_rules !def_read {
        ($t : ty) => {
            impl Read for $t {
                fn read(s : &str)->$t { s.parse().unwrap() }
            }
        }
    }

    macro_rules !def_read_tuple {
        ($($t : ident), *) => {
            impl<$($t : Read + Default), *> Read for ($($t), *) {
                fn read(s : &str)->Self {
                    let mut iter = s.split_whitespace();
                    ($($t::read(iter.next().unwrap())), *)
                }
            }
        };
    }

    def_read!(i32);
    def_read!(i64);
    def_read!(isize);
    def_read!(usize);
    def_read!(f32);
    def_read!(f64);
    def_read_tuple!(T0, T1);
    def_read_tuple!(T0, T1, T2);
    def_read_tuple!(T0, T1, T2, T3);
    def_read_tuple!(T0, T1, T2, T3, T4);
}

Measured memory_bytes: 9204
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func main() {
	line := nextLine()
	l := strings.Split(line, " ")
	L, _ := strconv.Atoi(l[0])
	R, _ := strconv.Atoi(l[1])

	ans := 2019
	for i := L; i <= min(R, L+2019); i++ {
		for j := L; j <= min(R, L+2019); j++ {
			if i >= j {
				continue
			}
			ans = min(ans, (i*j)%2019)
		}
	}
	fmt.Println(ans)
}


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

#define    Boost      ios_base::sync_with_stdio(false);cin.tie(NULL);
#define    end        '\n'
#define PI 3.14159

typedef   long long   ll ;

using namespace std;
int main()
{
    Boost;
    int r;
    cin>>r;
    double result=(2*PI*r);
    cout<<result<<endl;



}





Measured memory_bytes: 3796
tmp = ""
shuffleCnt = 0

while True:
    st=input()
    if(st=="-"):break
    if st.isalpha():
        if (tmp != ""):
            #カウントを進めて配列を進める
                startIndex=shuffleCnt%len(tmp)
                print(tmp[startIndex:]+tmp[:startIndex])
        tmp = st
        int(input())
        shuffleCnt=0
    if st.isdecimal():
        shuffleCnt+=int(st)

#カウントを進めて配列を進める
startIndex=shuffleCnt%len(tmp)
print(tmp[startIndex:]+tmp[:startIndex])


Measured memory_bytes: 5592
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt[ohara], ans[ohara], a, b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};
vector<ll> g[ohara];

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> n >> m;
    rep(i, n - 1 + m)
    {
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(b);
        cnt[b]++;
    }
    ll ne = 0;
    rep(i, n)
    {
        if (cnt[i] == 0)
            ne = i;
    }
    queue<ll> que;
    que.push(ne);
    while (!que.empty())
    {
        ll pa;
        pa = que.front();
        que.pop();
        rep(i, Size(g[pa]))
        {
            ll child;
            child = g[pa][i];
            if (cnt[child] == 1)
            {
                ans[child] = pa + 1;
                que.push(child);
            }
            cnt[child]--;
        }
    }
    rep(i, n) Cout(ans[i]);

    return 0;
}


Measured memory_bytes: 30592
n = int(input())
def count():
    count = 0
    result = ''
    for i in range(n):
        d1, d2 = map(int, input().split())
        if result == 'Yes':
            continue
        if d1 == d2:
            count += 1
            if count == 3:
                result = 'Yes'
        else:
            count = 0
            result = 'No'
    return result

print(count()) 

Measured memory_bytes: 9184
#include<bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define dbg(x) cout<<#x<<":"<<x<<endl
#define int long long
#define MOD 1000000007
typedef pair<int,int> P;
typedef pair<int,P> PP;

signed main(){
  int n=1;
  while(n){
    [&](){
    cin>>n;
    if(n==0)return;
    priority_queue<int,vector<int>,greater<int> > que[55];
    for(int i=0;i<n;i++){
	 int k;
	 cin>>k;
	 for(int j=0;j<k;j++){
	   int d;
	   cin>>d;
	   que[i].push(d);
	 }
    }
    vector<int> v(n);
    for(int i=0;i<n;i++){
	 v[i]=1LL<<i;
    }
  
    for(int i=1;i<31;i++){
	 int sum=0;
	 for(int j=0;j<n;j++){
	   if(que[j].empty())continue;
	   if(que[j].top()==i){
		sum|=v[j];
	   }
	 }
	 if(sum==(1LL<<n)-1){
	   cout<<i<<endl;
	   return;
	 }
	 for(int j=0;j<n;j++){
	   if(que[j].empty())continue;
	   if(que[j].top()==i){
		v[j]=sum;
		que[j].pop();
	   }
	 }
    }
    cout<<-1<<endl;
    }();
  }
  return 0;
}



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

#define int long long
#define fast_io(); ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define loop(i,a,b) for(int i=a;i<b;i++)
#define all(x) x.begin(),x.end()
#define pb push_back
#define ins insert
#define fi first
#define se second
#define _max max_element
#define _min min_element
#define tc(T) int T; cin>>T; while(T--)
#define q(q) int q; cin>>q; while(q--)
#define pi 3.1415926535897932384626433832
const int pinf=((int)9e18);
const int ninf=((int)-9e18);
const int mod=1000000007;

using namespace std;

int32_t main()
{
    fast_io();

    //FILE *fptr1=freopen("in.txt","r",stdin);
    //FILE *fptr2=freopen("out.txt","w",stdout);

    string s,t;
    cin>>s>>t;

    cout<<(s[0]==t[0])+(s[1]==t[1])+(s[2]==t[2]);


    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////

int n,m,ans[3];
signed main(){
  cin>>n>>m;
  rep(i,n)ans[i] = -1;
  rep(i,m){
    int s, c;cin>>s>>c;
    if(ans[s-1] == -1 || ans[s-1] == c){
      ans[s-1] = c;
    }else{
      cout << -1 << endl;return 0;
    }
  }
  int ret = 0;
  if(n == 1)ret = ans[0];
  if(n == 2){
    if(ans[0] == 0){
      cout << -1 << endl;return 0;
    }else if(ans[0] == -1){
      ans[0] = 1;
    }
    if(ans[1] == -1)ans[1] = 0;
    ret = ans[0]*10+ans[1];
  }
  if(n == 3){
    if(ans[0] == 0){
      cout << -1 << endl;return 0;
    }else if(ans[0] == -1){
      ans[0] = 1;
    }
    if(ans[1] == -1)ans[1] = 0;
    if(ans[2] == -1)ans[2] = 0;
    ret = ans[0]*100+ans[1]*10+ans[2];
  }
  if(n == 1 && m == 0)cout << 0 << endl;
  else cout << ret << endl;
}




Measured memory_bytes: 256
#include "stdio.h"

int main(int argc, char const *argv[]) {
  int N;
  scanf("%d", &N);
  int ans=0;
  for (size_t i = 0; i < 4; i++) {
    if (N%10==2) {
      ans++;
    }
    N=N/10;
  }
  printf("%d", ans);
  return 0;
}

Measured memory_bytes: 128
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

use std::cmp::max;
fn main() {
    input! {
        a: isize,
        b: isize,
    }
    println!("{}", max(0, a - b * 2));
}


Measured memory_bytes: 4352