akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] a = new int[N][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				a[i][j] = sc.nextInt();
			}
		}

		long[][] dp = new long[N + 1][3];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					if (j == k) continue;
					dp[i + 1][k] = Math.max(dp[i + 1][k], dp[i][j] + a[i][k]);
				}
			}
		}

		long res = 0;
		for (int i = 0; i < 3; i++) res = Math.max(res, dp[N][i]);
		System.out.println(res);
	}
}

Measured memory_bytes: 100964
/* ****AWARE**** */
#include<bits/stdc++.h>
#include <limits.h> 
#define cut ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll          long long
#define pb          push_back
#define endl        '\n'
#define pii         pair< ll, ll>
#define vi          vector< ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define rep(i,a,b)  for(  ll i=a;i<b;i++)
#define lbnd        lower_bound
#define ubnd        upper_bound
#define bs          binary_search
#define mp13       make_pair
using namespace std; 
#define MAX  3000
#define MODULO 2
using namespace std;   
#define hell 1000000007 
#define hell1 30000000000000000
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
#define mysizeof(i) (char*)(&i+1)-(char *)(&i);
ll T;
//double dp[MAX][MAX];
vector<ll>v;

void solve()
{    ll i,j,k,n,m,x=0,y=0,z=0;
     cin>>n>>k;
     ll a,b,c,d;
     bool dp[k]; //true if first player wins if there are i stones
     for(i=0;i<n;i++)
     { cin>>a,v.pb(a);
     }
      for(j=0;j<=k;j++)
      {  dp[j]=false;
      	for(i=0;i<n;i++)
      	{   if(j-v[i]>=0 && !dp[j-v[i]])
      		dp[j]=true;

      		
      	}
      }

     if(dp[k])
     	cout<<"First\n";
     else
     	cout<<"Second\n";
      		


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


Measured memory_bytes: 3764
N,A,B = map(int,input().split())
X = list(map(int,input().split()))

ans = 0
for i in range(1,N):
  if (X[i]-X[i-1])*A < B:
    ans += (X[i]-X[i-1])*A
  else:
    ans += B
print(ans)

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

int main() {
  string o;
  int a = 0;
  int b = 0;
  int s = 0;

  cin >> a;
  cin >> o;
  cin >> b;

  if(o == "+"){
    s = a + b;
  }
  else if(o == "-"){
    s = a - b;
  }
  cout << s << endl;
  return 0;
}


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

#define PI 3.1415926535897932
#define MOD 1000000007
#define INF 2e9

#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define FOR(i, start, end) for(int i = (start); i < (end); i++)
#define ALL(v) (v).begin(), (v).end()

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef vector<bool> vb;


void solve()
{
    int N; cin >> N;
    vi color(8, 0); 
    int n = 0, c = 0;
    REP(i, N)
    {
        int a; cin >> a;
        if(a >= 3200) n++;
        else color[a / 400]++;
    }
    REP(i, 8) if(color[i] > 0) c++;

    cout << max(c, 1) << " " << n+c << endl;
}

int main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REPoint(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;

const double EPS = 1e-8;
const double INF = 1e12;
const double PI = acos(-1.0);
typedef complex<double> Point;
namespace std {
  bool operator < (const Point& a, const Point& b) {
    return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
  }
}
double cross(const Point& a, const Point& b) {
  return imag(conj(a)*b);
}
double dot(const Point& a, const Point& b) {
  return real(conj(a)*b);
}

struct L : public vector<Point> {
  L(const Point &a, const Point &b) {
    push_back(a); push_back(b);
  }
};

typedef vector<Point> G;

struct C {
  Point p; double r;
  C(const Point &p, double r) : p(p), r(r) { }
};

int ccw(Point a, Point b, Point c) {
    b -= a; c -= a;
    if (cross(b, c) > 0)   return +1;       // counter clockwise
    if (cross(b, c) < 0)   return -1;       // clockwise
    if (dot(b, c) < 0)     return +2;       // c--a--b on line
    if (norm(b) < norm(c)) return -2;       // a--b--c on line
    return 0;
  }

vector<Point> convex_hull(vector<Point> ps) {
    int n = ps.size(), k = 0;
    sort(ps.begin(), ps.end());
    vector<Point> ch(2*n);
    for (int i = 0; i < n; ch[k++] = ps[i++]) // lower-hull
      while (k >= 2 && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    for (int i = n-2, t = k+1; i >= 0; ch[k++] = ps[i--]) // upper-hull
      while (k >= t && ccw(ch[k-2], ch[k-1], ps[i]) <= 0) --k;
    ch.resize(k-1);
    return ch;
  }

double ans[110];

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<Point> ps(n);
    map<P, int> mp;
    rep(i, 0, n){
        int x, y;
        cin >> x >> y;
        ps[i] = {x, y};
        mp[P(x, y)] = i;
    }
    if(n == 2){
        cout << 0.5 << endl << 0.5 << endl;
        return 0;
    }
    vector<Point> ch = convex_hull(ps);
    int sz = ch.size();
    rep(i, 0, sz){
        double a1 = arg(ch[i] - ch[(i - 1 + sz) % sz]);
        double a2 = arg(ch[(i + 1) % sz] - ch[i]);
        double th = abs(a1 - a2);
        if(th > PI) th = 2 * PI - th;
        ans[mp[P((int)real(ch[i]), (int)imag(ch[i]))]] = th;
    }
    rep(i, 0, n){
        printf("%.10f\n", ans[i] / (2.0 * PI));        
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
using namespace std;
typedef long long ll;
bool comp(ll &a,ll &b){
  return a>b;
}
int main()
{
  int n;
  cin >> n;
  vector<ll> a(n),b(n);
  ll suma = 0,sumb = 0;
  rep(i,n){
    cin >> a[i];
    suma += a[i];
  }
  rep(i,n){
    cin >> b[i];
    sumb += b[i];
  }

  if(suma>=sumb){
    ll buf = 0;
    int cnt = 0;
    rep(i,n){
      if(b[i]>a[i]){
	buf += b[i] - a[i];
	cnt++;
      }
    }
    vector<ll> c(n);
    rep(i,n){
      c[i] = a[i] - b[i];
    }
    sort(c.begin(), c.end(),comp);
    int index = 0;
    while(buf>0){
      if(buf<=c[index]){
	buf = 0;
	cnt++;
      }
      else{
	buf -= c[index];
	cnt++;
      }
      index++;
    }
    cout << cnt << "\n";
  }
  else{
    cout << -1 << "\n";
  }

  
  return 0;
}


Measured memory_bytes: 2940
n = int(input())
l = [int(x) for x in input().split()]
flag = 0

for x in l:
    if x % 2 == 0:
        if not (x % 3 == 0 or x % 5 == 0):
            flag = 1

print("APPROVED" if flag == 0 else "DENIED")

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

int main(){
int H, W; cin >> H >> W;
vector<vector<char>> data(H, vector<char>(W));
for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
        cin >> data.at(i).at(j);
    }
}

vector<bool> row(H, false);
vector<bool> col(W, false);
for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
        if (data.at(i).at(j) == '#') {
            row.at(i) = true;
            col.at(j) = true;
        }
    }
} 

for (int i = 0; i < H; i++) {
    if (row.at(i)) {
    for (int j = 0; j < W; j++) {
        if (col.at(j)) {
            cout << data.at(i).at(j);
        }
    }
    cout << endl;
    }
} 
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int x1,x2,y1,y2;
	scanf("%d%d%d%d",&x1,&y1,&x2,&y2);
	printf("%d %d %d %d\n",x2+(y1-y2),y2-(x1-x2),x1+(y1-y2),y1-(x1-x2));
	return 0;
}

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

a = X
path = [a]
done = set([a])
while True:
    na = pow(a, 2, M)
    if na in done:
        s = path.index(na)  # 繰り返しが始まる箇所
        break
    else:
        path.append(na)
        done.add(na)
        a = na

if N < s + 1:  # N項目がループが始まる箇所よりも前の場合
    ans = sum(path[:N])
else:
    rest = N - s  # ループに入った後の項目数
    x, y = divmod(rest, len(path) - s)  # x: ループを回る回数, y: 最後の1週に満たない項数

    ans = sum(path[:s])  # ループに入る前の和
    ans += sum(path[s:]) * x  # ループを繰り返す部分の和
    ans += sum(path[s: s + y])  # ループの最後の1週に満たない部分の和
print(ans)


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

int main(){
  int N,x;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> x;
    A[x] += 1;
  }
  if(N%2==0){
    for(int i=0;i<N;i++){
      if(i%2==0){
        if(A[i]!=0){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(A[i]!=2){
          cout << 0 << endl;
          return 0;
        }
      }
    }
    ll ans = 1;
    for(int i=0;i<N/2;i++){
      ans = (ans*2)%Q;
    }
    cout << ans << endl;
    return 0;
  }else{
    for(int i=0;i<N;i++){
      if(i==0){
        if(A[i]!=1){
          cout << 0 << endl;
          return 0;
        }
      }else if(i%2==0){
        if(A[i]!=2){
          cout << 0 << endl;
          return 0;
        }
      }else{
        if(A[i]!=0){
          cout << 0 << endl;
          return 0;
        }
      }
    }
    ll ans = 1;
    for(int i=0;i<N/2;i++){
      ans = (ans*2)%Q;
    }
    cout << ans << endl;
    return 0;
  }
}

Measured memory_bytes: 640
import math
n = int(input())
if n == 1:
    print(1)
else:
    sum = 0
    for i in range(1,n+1):
        for j in range(1,n+1):
            for k in range(1,n+1):
                sum += math.gcd(math.gcd(i,j),k)
    print(sum)

Measured memory_bytes: 67724
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (int i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll k;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> k;
	if (k % 5 == 0 || k % 2 == 0){
		cout << -1 << endl;
		return 0;
	}
	
	ll ans = 7;
	ans %= k;
	ll counter = 1;
	while (ans % k != 0){
		counter++;
		ans *= 10;
		ans += 7;
		ans %= k;
	}
	cout << counter << endl;
}

//cout.flush()

Measured memory_bytes: 3664
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

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

    int A, B;
    cin >> A >> B;
    int n = max(A, B);
    if (A == B) {
        cout << n + n << endl;
    }
    else {
        cout << n + n - 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 888
#include <iostream>
//#include <cctype>
#include <string>
//#include <iomanip>

using namespace std;
//#define

int main() {
	string ch;
	int ans = 0;

	while(1){
		cin >> ch;

		if(ch == "0") break;

		for(int i = 0; i < ch.size(); i++){
			ans += ch[i] - '0';
		}
		cout << ans << endl;
		ans = 0;
	}

	return 0;
}

Measured memory_bytes: 1188
package main

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

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

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

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

const INF int = 1e6

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

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()

	X, N := nextInt(), nextInt()

	ng := make([]bool, 102)
	for i := 0; i <= N; i++ {
		p := nextInt()
		ng[p] = true
	}

	best_d := X
	best_i := 0
	for i := 1; i <= 101; i++ {
		if !ng[i] && abs(i-X) < best_d {
			best_d = abs(i - X)
			best_i = i
		}
	}

	fmt.Fprintln(out, best_i)
}


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

int main(){
    int n;
    while(cin >> n, n){
        map<int, int> data;
        int m, a, b;

        for(int i = 0; i < n; i++){
            cin >> m >> a >> b;
            data[a] += m;
            data[b] -= m;
        }

        vector<pair<int,int>> v;
        for(map<int, int>::iterator it = data.begin(); it != data.end(); it++){
            v.push_back({*it});
        }

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

        int accum = 0;
        bool broken = false;

        for(int i = 0; i < v.size(); i++){
            accum += v[i].second;
            if(accum > 150){
                broken = true;
            }
        }

        if(broken){
            cout << "NG" << endl;
        }else{
            cout << "OK" << endl;
        }
    }
    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,X;
  cin>>N>>X;
  int ans=1;
  int D=0;
  REP(i,N){
    int L;
    cin>>L;
    D+=L;
    if(D<=X)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		TreeSet<Integer> set=new TreeSet<>();
		int n=in.nextInt();
		for(int i=0;i<n;i++) {
			set.add(in.nextInt());
		}
		
		int m=in.nextInt();
		for(int i=0;i<m;i++) {
			set.add(in.nextInt());
		}
		
		Iterator<Integer> itr=set.iterator();
		while(itr.hasNext()) {
			System.out.println(itr.next());
		}
	}

}



Measured memory_bytes: 190304
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

//WA

int main(void){
	int N,x,a[100010],b[100010];
	ll ans1=0,ans2=0;
	scanf("%d%d",&N,&x);
	rep(i,N){
		scanf("%d",&a[i]);
		b[i]=a[i];
	}
	//右と左からやる
	reg(i,0,N-2){
		int dif = a[i]+a[i+1]-x;
		if(dif>0){
			if(a[i+1]>=dif){
				a[i+1] -= dif;
			}else{
				a[i+1] = 0;
			}
			ans1 += dif;
		}
	};
	ireg(i,1,N-1){
		int dif = b[i]+b[i-1]-x;
		if(dif>0){
			if(b[i-1]>=dif){
				b[i-1] -= dif;
			}else{
				b[i-1] = 0;
			}
			ans2 += dif;
		}
	};
	printf("%lld\n",min(ans1,ans2));
	return 0;
}

Measured memory_bytes: 1024
N=int(input())
V=list(map(int,input().split()))
C=list(map(int,input().split()))
data=[]; ans=0
for i in range(N): data.append(V[i]-C[i])
for i in range(N): ans += 0 if data[i] <= 0 else data[i]
print(ans)

Measured memory_bytes: 3064
import java.util.*;

public class Main {
	public static void main (String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] arr = new int[n * 3];
		for (int i = 0; i < n * 3; i++) {
			arr[i] = sc.nextInt();
		}
		Arrays.sort(arr);
		long total = 0;
		for (int i = 0; i < n; i++) {
			total += (long)arr[3 * n - 2 - i * 2];
		}
		System.out.println(total);
	}
}


Measured memory_bytes: 93748
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <string>
#include <deque>
#include <queue>
#include <tuple>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#include <complex>
#include <iterator>
#include <array>
#include <memory>
#include <stack>
#define vi vector<int>
#define vvi vector<vector<int> >
#define ll long long int
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vb vector<bool>
#define vc vector<char>
#define vs vector<string>
#define ld long double
#define INF 1e9
#define EPS 0.0000000001
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define all(in) in.begin(), in.end()
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
#define MAX 9999999
using namespace std;
typedef pair<int, int> pii;
typedef pair<double,double>pdd;
typedef pair<ll,ll>pll;
int main(){
    ll n,lim;cin>>n>>lim;
    vl v(n),dp(n+1,0);
    rep(i,n){cin>>v[i];if(i)dp[i]+=v[i]+v[i-1];}
    ll ans=0;
    rep(i,n){
        if(!i)continue;
        if(v[i]+v[i-1]>lim){
            ll cnt=0,base=v[i]+v[i-1];
            ans+=base-lim;
            if(v[i]>base-lim)v[i]-=base-lim;
            else {
                v[i-1]-=base-lim-v[i];
                v[i]=0;
            }
        }
    }
    //rep(i,n)cout<<v[i]<<" ";
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin >> n >> s;
  
  char jad = s.at(0);
  int ans = 0;
  
  for(int i = 1 ; i < n ; i++){
    
    if(jad != s.at(i)){
      ans++;
      jad = s.at(i);
    }
  }
  
  cout << ans + 1 << endl;
}

Measured memory_bytes: 512
#include <stdio.h>


int main(){
	
	int a,b,k,i,j;
	
	scanf("%d %d %d",&a,&b,&k);
	
	for(i=0;a+i<a+k&&a+i<=b;i++){
		printf("%d\n",a+i);
	}
	
	
	
	for(j=k-1;b-j<=b;j--){
		if(a+i>b-j);
		else printf("%d\n",b-j);
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ll long long
#define ld long double
#define MOD 1000000007
#define nl cout << bl
#define rt ll Q[100005] = {0}
#define mp make_pair
#define test() \
    ull t;     \
    cin >> t;  \
    while (t--)
#define pb push_back
#define ff first
#define ss second
#define all(v) v.begin(), v.end()
#define s(ar, n) sort(ar, ar + n)
#define rs(ar, n) sort(ar, ar + n, greater<ll>())
#define oa(a, n)               \
    for (ll i = 0; i < n; i++) \
        cout << a[i] << " ";
#define cn(a, n)               \
    for (ll i = 0; i < n; i++) \
        cin >> a[i];
#define ov(a, n)                    \
    for (ll i = n - 1; i >= 0; i--) \
        cout << a[i] << " ";        \
    nl
#define ovp(a, n)              \
    for (ll i = 0; i < n; i++) \
        cout << a[i].ff << " " << a[i].ss << bl;
#define maxa(ar, N) *max_element(ar, ar + N)
#define mina(ar, N) *min_element(ar, ar + N)
#define present(c, x) ((c).find(x) != (c).end())
#define fastio()                  \
    ios_base::sync_with_stdio(0); \
    cin.tie(0);                   \
    cout.tie(0)
typedef pair<int, int> pii;
ll fast_exp(ll base, ll exp)
{
    ll res = 1;
    while (exp > 0)
    {
        if (exp % 2 == 1)
            res = (res * base) % MOD;
        base = (base * base) % MOD;
        exp /= 2;
    }
    return res % MOD;
}
ll fib(ll n)
{
    if (n < 2)
        return n;
    ll a = 0, b = 1, pre;
    int i = 1;
    while (i < n)
    {
        pre = (a + b) % MOD;
        a = b;
        b = pre;
        i++;
    }
    return pre;
}
ll fac(ll n)
{
    if (n % 2 == 0)
        return 2;

    for (ll i = 3; i * i <= n; i += 2)
    {
        if (n % i == 0)
            return i;
    }

    return n;
}
ll fact(ll n)
{
    if (n > 1)
        return n * fact(n - 1);
    else
        return 1;
}
long long moduloMultiplication(long long a,
                               long long b,
                               long long mod)
{
    long long res = 0; // Initialize result

    // Update a if it is more than
    // or equal to mod
    a %= mod;

    while (b)
    {
        // If b is odd, add a with result
        if (b & 1)
            res = (res + a) % mod;

        // Here we assume that doing 2*a
        // doesn't cause overflow
        a = (2 * a) % mod;

        b >>= 1; // b = b / 2
    }

    return res;
}
int main()
{
    fastio();
    string s;
    cin >> s;
    if (s.back() == 's')
    {
        s += "es";
    }
    else
    {
        s += "s";
    }
    cout << s;
}


Measured memory_bytes: 3648
#include <stdio.h>

int main(){
	int i=0, I=0, ii=0;
	int a[4], b[4];
	int Hit[100]={};
	int Blow[100]={};
	while(scanf("%d", &a[0])!=EOF)
	{
		for(i=1;i<4;i++)
		{
			scanf("%d", &a[i]);
		}
		for(i=0;i<4;i++)
		{
			scanf("%d", &b[i]);
		}
		for(i=0;i<4;i++)
		{
			for(I=0;I<4;I++)
			{
				if(i!=I)
				{
					if(a[i]==b[I])
					{
						Blow[ii]++;
					}
				}
			}
		}
		for(i=0;i<4;i++)
		{
			if(a[i]==b[i])
			{
				Hit[ii]++;
			}
		}
		ii++;
	}
	
	for(i=0;i<ii;i++)
	{
		printf("%d %d\n", Hit[i], Blow[i]);
	}
	return 0;
}

Measured memory_bytes: 596
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <map>
#include <set>
#include <cstdio>
#include <cmath>
#define rep(i,l,n) for(lint i=l;i<n;i++)
#define rer(i,l,n) for(lint i=l;i<=n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define pb(a) push_back(a)
#define mk(a,b) make_pair(a,b)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef vector<lint> vli;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string r="mcxi";
int x[4]={1000,100,10,1};

int sti(string s){
	int res=0;
	int now=1;
	rep(i,0,s.size()){
		rep(j,0,4){
			if(s[i]==r[j]){
				res+=now*x[j];
				now=1;
			}
		}
		if(s[i]-'0'>=0 && s[i]-'0'<=9){
			now=s[i]-'0';
		}
	}
	return res;
}

string its(int k){
	string res="";
	rep(i,0,4){
		if(k/x[i]){
			//o(k/x[i]);
			if(k/x[i]>1) res+=(char)('0'+(int)(k/x[i]));
			res+=r[i];
			k%=x[i];
		}
	}
	return res;
}


int main(){
	int n;
	cin>>n;
	rep(i,0,n){
		string s,t;
		cin>>s>>t;
		int a,b,c;
		a=sti(s);
		b=sti(t);
		c=a+b;

		o(its(c));
	}
}

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

bool check(string w, string f) {
    if(w.find(f) != string::npos) return true;
    return false;
}

int main() {
    string s, w;
    while(getline(cin, s)) {
        for(int i = 0; i < 26; i++) {
            w = s;
            for(int j = 0; j < s.size(); j++) {
                if(w[j] >= 'a' && w[j] <= 'z') {
                    w[j] = char((w[j] + i - 'a') % 26 + 'a');
                }
            }
            if(check(w, "the") || check(w, "this") || check(w, "that")) {
                cout << w << endl;
                break;
            }
        }
    }
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

ll dfs(ll i, ll n) {
    if(i*n < 10) return (n-1);
    ll base = 0, cur = 0;
    while(cur < 10){
        cur += i;
        base++;
    }
    cur -= 9;
    ll div = n / base;
    ll rem = n % base;
    ll res = dfs(cur, div) + div;
    rep(j, 0, rem){
        cur += i;
        res++;
        if(cur > 9) {
            cur -= 9;
            res++;
        }
    }
    return res;
}

int main(){
    ll m;
    cin >> m;
    vector<ll> d(m), c(m);
    rep(i, 0, m) cin >> d[i] >> c[i];
    ll digit = 0, sum = 0;
    rep(i, 0, m) {
        digit += c[i];
        sum += d[i] * c[i];
    }
    cout << digit - 1 + (sum - 1) / 9 << endl;
    return 0;
}

Measured memory_bytes: 6428
#pragma GCC optimize("O3")
#pragma GCC target("avx")
#include <bits/stdc++.h>
#define rep(i ,n) for(int i=0;i<(int)(n);++i)
#define repr(i ,n) for(int i=n;i>(int)(n);--i)
#define rep1(i ,n) for(int i=1;i<=(int)(n);++i)
#define ALL(a) a.begin(), a.end()
#define RSORT(a) sort(ALL(a),greater<>())
#define SORT(a) sort(ALL(a))
#define bit_check(bit, i) ((bit>>(i)) & 1)
#define PRINT(x) cout << (x) << endl;
#define ENDL cout << endl;
using namespace std;
typedef long long int i64;
typedef unsigned long long u64;
template<class T> using V = vector<T>;
using VI = V<int>;
const int INF = 2e9;
const i64 MOD = 1e9 + 7;

template <class T> inline bool chmin(T& a, T b){if(a>b){a=b; return true;} return false;}
template <class T> inline bool chmax(T& a, T b){if(a<b){a=b; return true;} return false;}
struct Init_On{
    Init_On(){
        cin.tie(nullptr);
        ios_base::sync_with_stdio(false);
        cout << fixed << setprecision(16);
    }
};

int n , m , x;
vector<int> c;
vector<int> power;
vector<int> cost;

int a[12][12];


signed main(){
    Init_On s;
    cin >> n >> m >> x;
    vector<int> c(n);
    vector<int> comp(m);
    int ans = INF;
    rep(i , n){
        cin >> c[i];
        rep(j ,m){
            cin >> a[i][j];
        }
    }
    rep(st , 1<<n){
        int cost = 0;
        comp.clear();
        comp.resize(m);
        rep(i ,n){
            if(st>>i&1) {
                rep(j , m){
                    comp[j] += a[i][j];
                }
                cost += c[i];
            }
        }
        bool f = true;
        rep( i , m){
            if(comp[i] < x) { f = false; break; }
        }
        if(f) ans = min( ans , cost);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;
int N,A;
set <int> s;;
int main(){
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A;
    if(s.count(A)){
      s.erase(A);
    }
    else{
      s.insert(A);
    }
  }
  cout << s.size() << endl;
  return 0;
}


Measured memory_bytes: 4864
sx,sy,tx,ty=map(int, input().split())
h=ty-sy
w=tx-sx
print("L"+"U"*(h+1)+"R"*(w+1)+"DR"+"D"*(h+1)+"L"*(w+1)+
      "U"*(h+1)+"R"*w+"D"*h+"L"*w)

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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n, x;
  std::cin >> n >> x;
  std::vector<int64_t> a(n);
  std::cin >> a;
  int64_t c = 0;
  if (x < a[0]) {
    c = a[0] - x;
    a[0] = x;
  }

  for (int64_t i = 1; i < n; i++) {
    const auto s = a[i] + a[i - 1];
    if (x < s) {
      c += s - x;
      a[i] -= s - x;
    }
  }

  std::cout << c << std::endl;
  return 0;
}


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

def solve():
    A, B = input().split()

    # 2進浮動小数点数(float)にしたら誤差が発生するので、整数のまま計算する
    A = int(A)
    B = int(B.replace(".", ""))

    ans = A*B//100
    print(ans)


def solve2():
    A, B = input().split()

    # 10進小数が扱えるdecimalモジュールを使う
    from decimal import Decimal
    A = int(A)
    B = Decimal(B)

    ans = (A*B)//1
    print(ans)


if __name__ == "__main__":
    solve2()


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

int main() {
    ll A, B, K;
    cin >> A >> B >> K;
    set<int> se;
    for (int i = A; i < A + K; i++) {
        if (i >= A && i <= B)
            se.insert(i);
    }

    for (int i = B; i > B - K; i--) {
        if (i >= A && i <= B)
            se.insert(i);
    }

    for (auto s : se) {
        cout << s << endl;
    }
}

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

using namespace std;

int main() {
	long long h, k;
	cin >> h >> k;
	if(h == 1 || k == 1) {
		cout << 1 << endl;
		return 0;
	}
	long long ans = h * (k / 2);
	if(k & 1) ans += (h + 1) / 2;
	cout << ans << endl;
	return 0;
}


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

int main() {
    string s;
    cin >> s;
    const int m=2019;
    int n=s.size();
    reverse(s.begin(),s.end()); //反転させて文字列の先頭を数値を1の位にする
    int x=1,tot=0; //totに累積和を求める
    vector<int> cnt(m);
    ll ans=0;
    rep(i,n) {
        cnt[tot]++; 
        /*1の位から10^nの位が2019の倍数であれば余りは0であるから
        次0が来た時の分を予めカウントしておく
        また、前のループででた余りも記録しておく(2019で割った余りよりcntの大きさは2019）*/
        tot+=(s[i]-'0')*x; 
        tot%=m; //オーバーフロー回避のため2018以内でおさえる
        ans+=cnt[tot]; //複数回目に出てきた余りであれば(出た回数-1)分追加
        x=x*10%m; //次のループで桁上げ、こっちも桁数を4桁でおさえる
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3344
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
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; }
using namespace std;

ll solve(ll n, vi const &a, string s){
    set<ll> base;
    for(ll i=n-1; i>=0; i--){
        ll x = a[i];
        set<ll>::reverse_iterator it = base.rbegin();
        while(it != base.rend()){
            ll num = *it++;
            if(x < (x^num)) continue;
            x ^= num;
        }
        if(x != 0){
            if(s[i] == '0') base.insert(x);
            else return 1;
        }
    }
    return 0;
}

int main(){
    Init();
    // テストケースの個数
    ll t; cin >> t;
    while(t--){
        // 初期入力
        ll n; cin >> n;
        vi a(n);
        rep(i, n) cin >> a[i];
        string s; cin >> s;
        cout << solve(n, a, s) << endl;
    }
}

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

int main(){
  long long K, X, Y;
  cin >> K >> X >> Y;
  if(abs(X)+abs(Y) == K){
    cout << 1 << endl;
    cout << X << " " << Y << endl;
    return 0;
  }
  long long t = max(2LL,(abs(X)+abs(Y)+K-1)/K);
  if(abs(t*K-abs(X)-abs(Y))%2) ++t;
  long long d = t*K - abs(X) - abs(Y);
  if(d%2){
    puts("-1");
    return 0;
  }
  d /= 2;
  cout << t << endl;
  long long x = 0, y = 0;
  for(int i = 0; i < t; ++i){
    long long sx = (abs(X-x) ? (X-x)/abs(X-x) : 1LL);
    long long sy = (abs(Y-y) ? (Y-y)/abs(Y-y) : 1LL);
    if(d >= K){
      d -= K;
      x -= sx*K;
    }else{
      long long k = K-d;
      if(abs(X-x) >= k){
        x += sx*k;
        y -= sy*d;
        d = 0;
      }else if(abs(Y-y) >= k){
        x -= sx*d;
        y += sy*k;
        d = 0;
      }else {
        long long dx = min(K,abs(X-x)), dy = min(K-dx,abs(Y-y));
        x += sx*dx;
        y += sy*dy;
      }
    }
    cout << x << " " << y << endl;
  }
}


Measured memory_bytes: 2304
#include <iostream>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    if (n==0)
        cnt += 1;
    while (n != 0)
    {
        n /= k;
        cnt += 1;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int m,n,a[100],ans;
bool cmp(int x,int y){
	return x>y;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=m;i++)
	ans+=a[i];
	cout<<ans;
	return 0;
}

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

int main() {
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d;
  e = a * b;
  f = c * d;
  cout << max(e, f) << endl;
}


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

const int N = 100000 + 10;
const long long oo = 0x3f3f3f3f3f3f3f3fll;

struct Node {
	long long flag;
	Node *ls, *rs;
}pool[N*4], *tail=pool, *root[2];

int n, e, t;
long long xx[N];
long long dp[N];

Node *build( int lf, int rg ) {
	Node *nd = ++tail;
	nd->flag = oo;
	if( lf < rg ) {
		int mid = (lf + rg) >> 1;
		nd->ls = build( lf, mid );
		nd->rs = build( mid+1, rg );
	}
	return nd;
}
long long query( Node *nd, int lf, int rg, int pos ) {
	if( lf == rg ) return nd->flag;
	int mid = (lf + rg) >> 1;
	if( pos <= mid )
		return min( query(nd->ls,lf,mid,pos), nd->flag );
	else
		return min( query(nd->rs,mid+1,rg,pos), nd->flag );
}
void modify( Node *nd, int lf, int rg, int L, int R, long long val ) {
	if( L <= lf && rg <= R ) {
		nd->flag = min( nd->flag, val );
		return;
	}
	int mid = (lf + rg) >> 1;
	if( L <= mid ) modify( nd->ls, lf, mid, L, R, val );
	if( R > mid ) modify( nd->rs, mid+1, rg, L, R, val );
}
inline long long cdp( int i ) {
	long long v0 = query(root[0],0,n,i);
	long long v1 = query(root[1],0,n,i);
//	printf( "%d v0 = %lld v1 = %lld\n", i, v0, v1 );
	return min( v0 + xx[i], v1 + xx[i] * 3 );
}
int main() {
	scanf( "%d%d%d", &n, &e, &t );
	for( int i = 1; i <= n; i++ ) 
		scanf( "%lld", xx + i );
	xx[0] = 0;
	root[0] = build( 0, n );
	root[1] = build( 0, n );
	modify( root[0], 0, n, 0, 0, -xx[0] );
	for( int i = 0; i < n; i++ ) {
		dp[i] = cdp(i);
//		printf( "dp[%d] = %lld\n", i, dp[i] );
		int j;
		int lf = i + 1, rg = n;
		while( lf < rg ) {
			int mid = (lf + rg + 1) >> 1;
			if( (xx[mid]<<1) <= (xx[i+1]<<1) + t )
				lf = mid;
			else
				rg = mid - 1;
		}
		j = lf;

		if( i + 1 <= j ) modify( root[0], 0, n, i + 1, j, t - xx[i] + dp[i] );
		if( j + 1 <= n ) modify( root[1], 0, n, j + 1, n, dp[i] - (xx[i+1]<<1) - xx[i] );
	}
	dp[n] = cdp(n);
	long long ans = dp[n] + e - xx[n];
	printf( "%lld\n", ans );
}



Measured memory_bytes: 11136
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		 Scanner sc = new Scanner(System.in);
	        int X = sc.nextInt();
	        int t = sc.nextInt();	        
			int a;
	        
	        a = X - t;
	        
	        if(a < 0){
	         a = 0;
	         }
	        
	        System.out.println(a);
	        
	}

}

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

int main() {
    string s;
    cin >> s;
    int cnt = 0, cnt1 = 0;
    rep(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] != '0')
                cnt++;
        } else {
            if (s[i] != '1')
                cnt++;
        }
    }

    rep(i, s.size()) {
        if (i % 2 == 0) {
            if (s[i] != '1')
                cnt1++;
        } else {
            if (s[i] != '0')
                cnt1++;
        }
    }

    cout << min(cnt, cnt1) << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp setprecision
#define pb(x) push_back(x)
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ld, ld> pdd;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = 1e8;
const ll INF = 1e16;
const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
    string s;
    cin >> s;
    int N = s.size();
    vector<int> vec;
    bool able = true;
    if(s[0] == '0' || s[N-1] == '1') able = false;
    rep(i, N-1){
        if(s[i] != s[N-2-i]) able = false;
        if(s[i] == '1') vec.pb(i+1);
    }
    if(!able){
        cout << -1 << endl;
        exit(0);
    }
    vec.pb(N);
    int n = vec.size();
    rep(i, n-1){
        cout << vec[i] << ' ' << vec[i+1] << endl;
        rep2(j, vec[i]+1, vec[i+1]-1){
            cout << j << ' ' << vec[i+1] << endl;
        }
    }
}

Measured memory_bytes: 2040
import java.util.Scanner;
import java.util.ArrayList;

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

    while (in.hasNext()) {
      int N = in.nextInt();
      int[] a = new int[N + 1];

      for (int i = 1; i < a.length; ++i) {
        a[i] = in.nextInt();
      }

      int[] ballNum = new int[N + 1];
      for (int i = a.length - 1; i >= 1; --i) {
        int sumOfMultiple = 0;

        for (int j = i; j < ballNum.length; j +=i) {
          sumOfMultiple += ballNum[j];
        }

        if (sumOfMultiple % 2 != a[i]) {
          ballNum[i] = 1;
        }
      }

      ArrayList<Integer> out = new ArrayList<Integer> ();
      for (int i = 0; i < ballNum.length; ++i) {
        if (ballNum[i] > 0) {
          out.add(i);
        }
      }

      System.out.println(out.size());
      if (out.size() > 0) {
        System.out.print(out.get(0));
        for (int i = 1; i < out.size(); ++i) {
          System.out.printf(" %d", out.get(i));
        }
        System.out.println();
      }
    }
  }
}

Measured memory_bytes: 100980
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def main():
    N = int(readline())

    ans = 0
    rate = 380000.0
    for _ in range(N):
        x, u = readline().split()
        if u == 'JPY':
            ans += int(x)
        else:
            ans += float(x) * rate

    print(ans)
    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 9080
#include <iostream>
#include<algorithm>

using namespace std;

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

long long 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

using llong = long long;
llong n, k;
llong maxx;
llong minx;
llong a[100005];
int main() {
  COMinit();
  cin >> n >>k;
  for (int i=0;i<n;i++){
    cin>>a[i];
    }
  sort(a,a+n);
  
  for(int i=0;i<n;i++){
    {
      llong m=i;
      if(m>=k-1) {
        maxx+=COM(m,k-1)*a[i];
        maxx%=MOD;
      }
      }
    {
      llong m=n-i-1;
      if(m>=k-1){
        minx+=COM(m,k-1)*a[i];
        minx%=MOD;
      }
      }
    }
  
  cout<<(maxx-minx+MOD)%MOD<<endl;
  }

Measured memory_bytes: 13056
#include <bits/stdc++.h>
using namespace std;
//mt19937 mrand(chrono::high_resolution_clock::now().time_since_epoch().count());
//int rnd(int x) { return mrand()%x;}
typedef long long ll;
ll gcd(ll a,ll b){return b==0?a:gcd(b,a%b);}
ll a[100100];ll n,m,v,p;

int jud(int x){
	ll cnt=a[x]+m;
	if(cnt<a[n-p+1]) return 0;
	if(v<=p-1+x) return 1;
	ll tmp=v-(p-1+x);
	if(tmp>=n-p+1-x) return 0;
	//while(!q.empty()) q.pop();
	vector<ll> v,pre;
	ll cap=0;
	ll su=0;v.clear();pre.clear();
	for(int i=n-p+1;i>=x+1;i--){
		if(cnt-a[i]){
			cap++;
			su+=cnt-a[i];
			v.push_back(cnt-a[i]);
			pre.push_back(su);
		} 
	}
	if((int)v.size()<tmp) return 0;
	su=0;
	ll r=0;
	for(int i=0;i<(int)v.size()-tmp;i++){
		r+=v[i];
	}
	ll ta=0;ll pt=0;
	for(int i=(int)v.size()-tmp;i<(int)v.size();i++){
		pt++;
		if(i==(int)v.size()-1){
			ta=max(ta,r/pt+v[i]);
		}
		else{
			ll ub=v[i+1];
			ta=max(ta,min(v[i+1],v[i]+r/pt));
			if(pt*(ub-v[i])>r) break;
			r-=pt*(ub-v[i]);
		}
	}
	return ta>=m;
	
}
int main(){
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+1+n);
	ll ans=p;
	int ub=n-p,lb=1;
	while(lb<=ub){
		int md=(lb+ub)>>1;
		if(jud(md)){
			ans=n-md+1;
			ub=md-1;
		}
		else{
			lb=md+1;
		}
	}
	printf("%lld\n",ans);
	return 0;
}


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

int main(){
  int N;
  int c=0;
  cin>>N;
int d[100][2];
  string s="No";
  for(int i=0;i<N;i++){
  cin>>d[i][0]>>d[i][1];
  }
  for(int i=0;i<N;i++){
   
  if(d[i][0]==d[i][1]){
  c++;
  }
    else{
    c=0;
    }
    if(c==3){
      s="Yes";
      break;
    }
    
   //cout<<c;
  }
  
  cout<<s<<endl;

}


Measured memory_bytes: 3604
N = int(input())
S = input()
a = ["SS","SW","WS","WW"]

for i in range(N):
  for j in range(4):
    a[j]+="SW"[::-1 if S[i]=="o" else 1][a[j][i]==a[j][i+1]]

for i in range(4):
  if a[i][1]==a[i][N+1] and a[i][0]==a[i][N]:
    print(a[i][1:N+1])
    break
else:
  print(-1)

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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)
int table[] = {0, 1, 2, 3, 5, 7, 8, 9};
void ex(int n)
{
  if(n >= 8){
    ex(n / 8);
  }
  printf("%d", table[n % 8]);
}
int main()
{
  int n;
  while (cin >> n, n){
    ex(n);
    cout << endl;
  }
}

Measured memory_bytes: 1176
#include <iostream>
#include <string>
#include <algorithm>
using namespace std ;
using ll = long long ;

string yorn(bool a){
    if(a) return "Yes" ;
    return "No" ;
}

int main(){
    string s,t ;
    cin >> s >> t ;
    t += t ;
    for(int i=0;i<s.size();i++){
        bool ok = true ;
        for(int j=0;j<s.size();j++){
            if(t.at(i+j)!=s.at(j)){
                ok = false ;
                break ;
            }
        }
        if(ok){
            cout << yorn(1) << endl ;
            return 0 ;
        }
    }
    cout << yorn(0) << endl ;
}


Measured memory_bytes: 256
/**********************************JAI SAI RAM*****************************************/
//HELP IN CODEFORCES ROUND 638 DIV 2

#include<bits/stdc++.h>
using namespace std;
#define endl "\n"
typedef long long int ll;
ll P=1000000007;
ll MAX=P*(P-7);
ll MIN=-1*MAX;
const int sizes=200001;
const int BLK = 1200;

int main()
{
    ll i,j,k,l,m,n,o,p,q,r,s,t,a[sizes],vis[sizes];
    cin>>n;
    map<ll,ll> mp;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
    }
    s=0;
    for(i=n;i>=1;i--)
    {
       s+=mp[a[i]+i];
       mp[i-a[i]]++;
    }
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 27904
inpl = lambda: list(map(int,input().split()))
H, N = inpl()
A = []
B = []
for _ in range(N):
    a, b = inpl()
    A.append(a)
    B.append(b)

Max = 10**9
dp = [Max] * (H+1)
dp[0] = 0
for h in range(H):
    if dp[h] >= Max:
        continue
    for n in range(N):
        k = h + A[n]
        if k > H:
            k = H
        dp[k] = min(dp[h]+B[n], dp[k])
print(dp[H])

Measured memory_bytes: 42044
#include<stdio.h>
int main()
{
int a[10];
int i,j,t;
for(i=0;i<10;i++){
  scanf("%d",&a[i]);}
for(j=0;j<9;j++){
  for(i=0;i<9-j;i++){
    if(a[i]<a[i+1])
      {t=a[i];a[i]=a[i+1];a[i+1]=t;}
                    }
                 }
for(i=0;i<3;i++)
   printf("%d\n",a[i]);

return 0;
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main() {
  int i,j,n,m,s,p,d[6000];
  while(cin >> n && n>0) {
	  s=p=0;
	  for (i=0;i<n;i++) { cin >> d[i]; s+=d[i];}
	  for (i=1,m=0;i<=100;i++) { m+=i; if (s==m) break;}
	  if (i<101) m=i; else { cout << -1 << endl; continue;}
	  for (i=0;i<=10000;i++) {
		  if (m==n && d[0]==1 && d[m-1]==m) { for (j=0;j<m;j++) if (d[j]!=j+1) j=9999;  if (j==m) break; }
		  for (j=0;j<n;j++) d[j]--;
		  for (j=0,p=0;j<n;j++) if (d[j]>0) d[p++]=d[j];
		  d[p]=n; n=p+1; 
	  } 	    
	  if (i>10000) cout << -1 << endl; else cout << i << endl;
  }
  return 0;
 } 

Measured memory_bytes: 1168
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#define EPS 1e-10
using namespace std;

double add(double a,double b){
	if(fabs(a+b)<EPS*(fabs(a)+fabs(b)))return 0.0;
	return a+b;
}

class P{
public:
	double x,y;
	P(double x=0.0,double y=0.0):x(x),y(y){}
	P operator +(P p){
		return P(add(x,p.x),add(y,p.y));
	}
	P operator -(P p){
		return P(add(x,-p.x),add(y,-p.y));
	}
	P operator *(double d){
		return P(x*d,y*d);
	}
	P operator /(double d){
		return P(x/d,y/d);
	}
	bool operator<(const P &p)const{
		if(fabs(add(x,-p.x))<EPS)return y<p.y;
		return x<p.x;
	}
};

typedef P Vector;
typedef vector<P> Polygon;

double norm(Vector p){
	return add(p.x*p.x,p.y*p.y);
}

double abs(Vector p){
	return sqrt(norm(p));
}

double dot(Vector a,Vector b){
	return add(a.x*b.x,a.y*b.y);
}

double cross(Vector a,Vector b){
	return add(a.x*b.y,-a.y*b.x);
}

int ccw(P p0,P p1,P p2){
	Vector a=p1-p0;
	Vector b=p2-p0;
	if(cross(a,b)>EPS)return 1;
	return -1;
}

Polygon andrewScan(Polygon s){
	Polygon u,l;
	if(s.size()<3)return s;
	sort(s.begin(),s.end());
	u.push_back(s[0]);
	u.push_back(s[1]);
	l.push_back(s[s.size()-1]);
	l.push_back(s[s.size()-2]);
	for(int i=2;i<s.size();i++){
		for(int n=u.size();n>=2 && ccw(u[n-2],u[n-1],s[i])!=-1;n--){
			u.pop_back();
		}
		u.push_back(s[i]);
	}

	for(int i=s.size()-3;i>=0;i--){
		for(int n=l.size();n>=2 && ccw(l[n-2],l[n-1],s[i])!=-1;n--){
			l.pop_back();
		}
		l.push_back(s[i]);
	}
	reverse(l.begin(),l.end());
	for(int i=u.size()-2;i>=1;i--){
		l.push_back(u[i]);
	}
	return l;
}

int main(void){
	int n;
	Polygon g;
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		P p;
		scanf("%lf %lf",&p.x,&p.y);
		g.push_back(p);
	}
	Polygon res=andrewScan(g);
	printf("%d\n",res.size());
	int f=0;
	for(int i=1;i<res.size();i++){
		if(res[f].y>res[i].y || (res[f].y==res[i].y && res[f].x>res[i].x)){
			f=i;
		}
	}
	for(int i=0;i<res.size();i++){
		printf("%d %d\n",(int)res[(i+f)%res.size()].x,(int)res[(i+f)%res.size()].y);
	}
	return 0;
}

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

int main ()
{
    int a, b, c;
    cin >> a >> b >> c;
    int sum1, sum2, sum3;
    sum1 = a+b;
    sum2 = a+c;
    sum3 = b+c;
    int an, ans;
    an = min (sum1, sum2);
    ans = min (an, sum3);
    cout << ans;
    return 0;
}

Measured memory_bytes: 256