akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n';
void solve(){
	
		int a, b, c;
		cin >> a >> b >> c;
		a-=b;
		if(a>=c)
			{cout << 0 << endl;}
		else
		{cout << c-a << endl;}
	
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;

double dp[100005];
int N, K;

double solve(int i){
  if(2*i>=K) return dp[i] = 0.5;
  if(dp[i] >= 0) return dp[i];
  return dp[i] = 0.5 * solve(2*i);
}


int main(){

  cin >> N >> K;
  rep(i,100005) dp[i] = -1;

  for(int i=min(N, K-1); i>=1; i--){
    solve(i);
  }

  double ret = 0;
  if(K<=N) ret = (N-K+1)/(double)N;
  REP(i,1,min(N+1,K)){
    double t = 1.0/N;
    ret += t * dp[i];
  }
  printf("%.12lf\n", ret);
  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
#define ld long double
using namespace std;

int main() {
    int N, K;
    cin >> N >> K;
    int ans = K;
    for (int i = 1; i < N; i++) {
        ans *= (K - 1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits.h>

using namespace std;

int main()
{
    int n,mi=INT_MAX,ma=INT_MIN,x;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        ma=max(ma,x-mi);
        mi=min(mi,x);
    }
    cout<<ma<<endl;
    return 0;
}



Measured memory_bytes: 3116
#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 = 2e5 + 100, maxval = 2010;
const ll inf = 2e18, mod = 1e9 + 7;

int n, a[maxn], b[maxn], dp[maxval * 2][maxval * 2];
ll fact[maxn], invfact[maxn];

ll powmod(ll a, ll b)
{
	if (!b)
		return 1LL;
	ll tmp = powmod(a, b / 2);
	tmp = tmp * tmp % mod;
	if (b & 1)
		tmp = tmp * a % mod;
	return tmp;
}

void addmod(int& a, int b)
{
	a += b;
	if (a > mod)
		a -= mod;
}

ll comb(int n, int r)
{
	return fact[n] * (invfact[r] * invfact[n - r] % mod) % mod;
}

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

	fact[0] = 1;
	invfact[0] = powmod(fact[0], mod - 2);
	for (int i = 1; i < maxn; i++)
		fact[i] = fact[i - 1] * i % mod, invfact[i] = powmod(fact[i], mod - 2);

	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> a[i] >> b[i];
		dp[maxval - a[i]][maxval - b[i]]++;
	}
	for (int i = 0; i < maxval * 2 - 2; i++)
		for (int j = 0; j < maxval * 2 - 2; j++)
			addmod(dp[i + 1][j], dp[i][j]), addmod(dp[i][j + 1], dp[i][j]);
	ll ans = 0;
	for (int i = 0; i < n; i++)
		ans = (ans + dp[maxval + a[i]][maxval + b[i]]) % mod;
	for (int i = 0; i < n; i++)
		ans = (ans - comb(2 * a[i] + 2 * b[i], 2 * a[i]) + mod) % mod;
	ans = ans * powmod(2, mod - 2) % mod;
	
	cout << ans << endl;
}



Measured memory_bytes: 68096
#include <bits/stdc++.h>
#define INF (int)1e9
#define endl "\n"
#define ll long long
#define ull unsigned long long

using namespace std;

int main()
{
    vector<int> arr = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;

    cout << arr[k - 1] << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define MAX 1000000000
int dx[] = {1,0,-1,0};
int dy[] = {0,-1,0,1};
const ll INF = 10010010010001;
vector<vector<bool>> graph;
vector<bool> reached;

int main(){
    int A,B,C,D,E,F;
    cin >> A >> B >> C >> D >> E >> F;

    int water=0,suger=0,answ=0,anss=0;
    double sa = 0.0;
    for(int i=0;100*A*i<F;i++){
        for(int j=0;(A*i+B*j)*100<F;j++){
            water = (A*i+B*j)*100;
            if(water == 0) continue;
            for(int k=0;(A*i+B*j)*100+C*k<=F;k++){
                int l = ((water/100)*E - C*k)/D;
                suger = C*k+D*l;
                while(water+suger > F){
                    l--;
                    suger = C*k+D*l;
                }
                if(l < 0) break;
                if((water/100)*E-suger < 0) continue;
                if((double)(suger*100)/(water+suger) >= sa){
                    answ = water;
                    anss = suger;
                    sa = (double)(suger*100)/(water+suger);
                }
            }
        }
    }
    cout << answ+anss << ' ' << anss << endl;
}


Measured memory_bytes: 256
gyo1 = list(map(int,input().split()))
gyo2 = list(map(int,input().split()))
gyo3 = list(map(int,input().split()))
 
n = int(input())
for i in range(n):
  detame = int(input())
  if detame in gyo1:
    gyo1[gyo1.index(detame)] = -1
  elif detame in gyo2:
    gyo2[gyo2.index(detame)] = -1
  elif detame in gyo3:
    gyo3[gyo3.index(detame)] = -1
    
if gyo1.count(-1) == 3 or gyo2.count(-1) == 3 or gyo3.count(-1) == 3:
  print('Yes')
  exit()
 
for i in range(3):
  if gyo1[i] == -1 and gyo2[i] == -1 and gyo3[i] == -1 :
    print('Yes')
    exit()
    
if gyo1[0] == -1 and gyo2[1] == -1 and gyo3[2] == -1 : 
  print('Yes')
elif gyo1[2] == -1 and gyo2[1] == -1 and gyo3[0] == -1 : 
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a,b,c:Integer;
begin
  try
    { TODO -oUser -cConsole Main : わからん。 }
    Read(a);
    Read(b);
    Readln(c);

    if (a+b=c) or (a+c=b) or (b+c=a) then
      Writeln('Yes')
    else
      Writeln('No');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 128
fun main(args : Array<String>) {
    val n = readLine()!!.toInt()
    val p = readLine()!!.split(" ").map { it.toInt() }
    var count = 0
    (0..(n  - 3)).forEach { i ->
        val one = p[i]
        val two = p[i + 1]
        val three = p[i + 2]

        if ((one < two && two < three) || three < two && two < one) {
            count++
        }
    }

    println(count)
}

Measured memory_bytes: 37744
#ifdef LOCAL
//#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int mod = 998244353;

void add(int &a, int b)
{
	a += b;
	if (a >= mod)
		a -= mod;
}

void sub(int &a, int b)
{
	a -= b;
	if (a < 0)
		a += mod;
}

int mult(int a, int b)
{
	return ll(a) * b % mod;
}

void solve(istream &cin = std::cin, ostream &cout = std::cout)
{
	int a, b, c, d;

	while (cin >> a >> b >> c >> d)
	{
		vector<vector<vector<int>>> dp(c + 1, vector<vector<int>>(d + 1, vector<int>(3)));
		dp[a][b][0] = 1;

		for (int i = a; i <= c; i++)
			for (int j = b; j <= d; j++)
				for (int type = 0; type < 3; type++)
				{
					const int cur = dp[i][j][type];
					if (cur != 0)
					{
						if (i < c)
							add(dp[i + 1][j][1], mult(cur, j));
						if (j < d)
							add(dp[i][j + 1][2], mult(cur, type == 1 ? 1 : i));
					}
				}

		int ans = 0;
		for (auto &it : dp[c][d])
			add(ans, it);
		cout << ans << endl;
	}
}

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

#ifdef LOCAL
	auto st = clock();

	ifstream fin("../input.txt");
	solve(fin);

	cout << "clock: " << (clock() - st) / (double) CLOCKS_PER_SEC << endl;
#else
	solve();
#endif

	return 0;
}

Measured memory_bytes: 495920
import java.util.*;
import java.io.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);

    int N = Integer.parseInt(sc.next());;
    int M = Integer.parseInt(sc.next());;
    int[][] P = new int[M][4];
    
    for (int i = 0; i < M; i++) {
      P[i][0] = i;
      P[i][1] = Integer.parseInt(sc.next());;
      P[i][2] = Integer.parseInt(sc.next());;
      P[i][3] = 0; 
    }

    sc.close();

    Arrays.sort(P, (o1, o2) -> o1[1] == o2[1] ? o1[2] - o2[2] : o1[1] - o2[1]);

    
    int now = P[0][1];
    int count = 0;

    for (int i = 0; i < M; i++) {
      if (now == P[i][1]) {
        count++;
      } else {
        count = 1;
        now = P[i][1];
      }
      P[i][3] = count;
    }

    Arrays.sort(P, (a, b) -> Integer.compare(a[0],b[0]));

    PrintWriter out = new PrintWriter(System.out);
    for (int i = 0; i < M; i++) {
      out.println(String.format("%06d", P[i][1]) + String.format("%06d", P[i][3]));
    }
    out.flush();

  }

}

Measured memory_bytes: 119756
#include<bits/stdc++.h>
#define scf scanf
#define ptf printf
#define forp(i,j,k) for(int i=j;i<k;i++)
#define form(i,j,k) for(int i=j;i>k;i--)
#define sz(x) (int)x.size()
#define pb push_back
#define fst first
#define scd second
#define m_p make_pair
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;

const double pi=acos(-1.0);
double R,r;

double sqr(double x)
{
    return x*x;
}

double cc(double d)
{
//    double res=0,p,m,x,y,z;
//    if(d*d+r*r>R*R)
//    {
//        p=d;
//        m=(r*r-R*R)/d;
//    }
//    else
//    {
//        p=(R*R-r*r)/d;
//        m=-d;
//    }
//    x=(p+m)/2;
//    y=(p-m)/2;
//    z=sqrt(r*r-x*x);
//    res=acos(x/r)*r*r-z*x;
//    if(d*d+r*r<R*R)
//        res=pi*r*r-res;
//    z=sqrt(R*R-y*y);
//    res+=acos(y/R)*R*R-z*y;
//    return res;
	if(r+R<d)
		return 0;
	else if(R-r>d)
		return pi*r*r;
	else if(r-R>d)
		return pi*R*R;
	double q1 = acos((r*r+d*d-R*R)/(2*r*d));
	double q2 = acos((R*R+d*d-r*r)/(2*R*d));
	return (r*r*q1+R*R*q2-r*d*sin(q1));
}

int w,h;

double ok(double x,double y,double r)
{
    return x>=r-1e-4&&x+r<=w+1e-4&&y>=r-1e-4&&y+r<=h+1e-4;
}

int main()
{
    int a,b,ab;
    for(;scf("%d%d%d%d%d",&w,&h,&a,&b,&ab);)
    {
        int fg=0;
        if(!w&&!h&&!a&&!b&&!ab)
            break;
        if(a<b)swap(a,b),fg=1;
        double d;
        R=sqrt(a/pi);
        r=sqrt(b/pi);
        if(ab)
        {
            double l0=max(R-r,1e-7),r0=R+r,mid,t0;
            forp(ttt,0,101)
            {
                mid=(l0+r0)/2;
//                t0=cc(mid);
                if(cc(mid)<ab)
                    r0=mid;
                else
                    l0=mid;
            }
            d=mid;
        }
        else
            d=R+r;
        double W,H;
        W=R+r+d;
        H=2*R;
        double xA,yA,xB,yB;
        xA=yA=R;
        if(!ok(xA,yA,R))
        {
            puts("impossible");
            continue;
        }
        double x0=w-r,y0=h-r;
        double dis=sqrt(sqr(xA-x0)+sqr(yA-y0));
        xB=xA+(x0-xA)*d/dis;yB=yA+(y0-yA)*d/dis;
        if(ok(xB,yB,r))
           {
           		if(fg)
           		{
           			swap(xA,xB);
           			swap(yA,yB);
           			swap(r,R);
           		}
           		ptf("%.10f %.10f %.10f %.10f %.10f %.10f\n",xA,yA,R,xB,yB,r);
           	}
        else
            puts("impossible");
    }
    return 0;
}

Measured memory_bytes: 1316
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {
    
    public static void main(String[] args) throws IOException {
        
        BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
        String[] str = bf.readLine().split(" ");
        int N = Integer.parseInt(str[0]), K = Integer.parseInt(str[1]), max = 0;
        String[] S = bf.readLine().split("");
        ArrayList<Integer> data = new ArrayList<>();
        int value = Integer.parseInt(S[0]);
        if (value == 0) {
            data.add(0);
        }
        for (int i = 0; i < N; value = 1 - value) {
            int count = 0;
            while (i < N && Integer.parseInt(S[i]) == value) {
                count++;
                i++;
            }
            data.add(count);
        }
        if (value == 1) {
            data.add(0);
        }
        int size = data.size(), sum = 0;
        for (int i = 0; i < 2 * K + 1 && i < size; i++) {
            sum += data.get(i);
        }
        max = sum;
        for (int i = 3; i + 2 * K - 1 < size; i += 2) {
            sum += -data.get(i - 3) - data.get(i - 2) + data.get(i + 2 * (K - 1)) + data.get(i + 2 * K - 1);
            if (max < sum) {
                max = sum;
            }
        }
        System.out.println(max);
    }
}

Measured memory_bytes: 30284
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
template<class T>
void dmp(T a){
	rep(i,a.size()) cout << a[i] << " ";
	cout << endl;
}
template<class T>
bool chmax(T&a, T b){
	if(a < b){
		a = b;
		return 1;
	}
	return 0;
}
template<class T>
bool chmin(T&a, T b){
	if(a > b){
		a = b;
		return 1;
	}
	return 0;
}
int n,m,q;
vector<int>a,b;
int u[100005],v[100005];
int main(){
	scanf("%d%d%d",&n,&m,&q);
	rep(i,n){
		int x; scanf("%d",&x); a.pb(x); u[i+1] = x;
	}
	rep(i,m){
		int x; scanf("%d",&x); b.pb(x); v[i+1] = x;
	}
	SORT(a); SORT(b);
	int ans = a[0]+b[0];
	rep(i,q){
		int a,b,c; scanf("%d%d%d",&a,&b,&c);
		chmin(ans, u[a]+v[b]-c);
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 2040
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   int n;
   cin>>n;
   string s;
   cin>>s;
   int red=0;
   int blue=0;
   for(int i=0; i<s.size(); i++)
   {
       if(s[i]=='B') ++blue;
       if(s[i]=='R') ++red;
   }
   if(red>blue) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if((a + b) > (c + d)) cout << "Left" << endl;
  if((a + b) == (c + d)) cout << "Balanced" << endl;
  if((a + b) < (c + d)) cout << "Right" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[10000], min, max, n, i;
  long long sum = 0;
  scanf("%d", &n);//1以上が入力されるものとします
  for(i = 0; i < n; i++)
  {
    scanf("%d", &a[i]);
    sum += a[i];
  }
  max = min = a[0];//とりあえず最初の要素をセットしておく
  for(i = 1; i < n; i++)
  {//2番目以降の要素と比較
  if(a[i] > max)max = a[i];
  if(a[i] < min)min = a[i];
  }
  printf("%d %d %lld\n", min, max, sum);

  return 0;
}



Measured memory_bytes: 2104
#include <stdio.h>
#include <stdlib.h>
using namespace std;
 
int n,m,i,j,k,ans;
int a[305][305],b[305];
bool ban[305];
 
int main()
{
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;++i)
	for(j=1;j<=m;++j)
	scanf("%d",&a[i][j]);
	ans=n;
	for(i=1;i<=m;++i)
	{
		for(j=1;j<=m;++j)b[j]=0;
		for(j=1;j<=n;++j)
		for(k=1;k<=m;++k)
		if(!ban[a[j][k]])
		{
			++b[a[j][k]];
			break;
		}
		for(j=k=1;j<=m;++j)if(b[j]>b[k])k=j;
		ban[k]=true;
		if(b[k]<ans)ans=b[k];
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
    int n, temp;
    cin >> n;
    bool res = false;
    for (int i = 0; i < 3; i++)
    {
        temp = n % 10;
        n = n / 10;
        if (temp == 7)
            res = true;
    }
    if (res == true)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    // cout << 0 << endl;
    return 0;
}

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

int main(){
    long long int n, k;
    cin >> n >> k;
    vector<pair<long long int, long long int>> ab(n);
    for(int i = 0; i < n; i++){
        cin >> ab[i].first >> ab[i].second;
    }
    sort(ab.begin(),ab.end());
    long long int c = 0;
    for(int i = 0; i < n; i++){
        c += ab[i].second;
        if(c >= k){
            cout << ab[i].first << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;
using ll=long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, a, n) for(int i = (a); i < (n); i++)

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  ll a,b;cin>>a>>b;
  rep2(i,1,b+1){
    if((a*i)%b==0){
      cout<<a*i<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <cstdio>
#define max(a,b) (a>b?a:b)
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  for(int i=0;i<max(a,b);i++)printf("%d",a+b-max(a,b));
  printf("\n");
  return 0;
}

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

int main(){
    ll x;
	ll road= 0;
	cin >> x;
	rep(i,x+1) {
	 road += i;
	 if (road>=x) {
			cout<<i<<endl;
			break;
		}
	}
}


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

using namespace std;

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

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef long long LL;

typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<string, int> P;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define REP(i,n)  for(int i=0; i<(n); i++)

//constant
//--------------------------------------------
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const LL MOD = 1e9+7; 
//vector <vector<int>> x(20, vector<int> (20)), y(20,vector<int> (20));
/*int counter_1 (int x) {
    if(x == 0) return 0;
    return counter_1(x >> 1) + (x & 1);
}*/

//int Counter(int x)
/*int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}*/
int factorial(int n) {
    if (n > 0) {
        return n * factorial(n - 1);
    } else {
        return 1;
    }
}
LL sum(LL a, LL b){
    LL cnt=0;
    cnt=(b-a+1)*(a+b)/2;
    return cnt;
}
int main(){
    LL n, k;
    cin >> n >> k;
    LL ans=0, ma=sum(n-(k-1)+1, n), mi=sum(0, k-2);
    for(LL i = k; i<n+2; i++){
        ma+=n-(i-1);
        mi+=i-1;
        /*
        if(ma<=0||ma<=0){
            cout << "error" << ' ' << i << ' ' << ma << endl;
            break;
        }
        if(ma<mi){
            cout << "er" << ' ' << i << endl;
            break;
        }
        cout << ma << ' ' << mi << ' ' << ma-mi+1 << ' ' << i<< endl;*/
        ans+=ma-mi+1;
    }
    cout << ans%MOD << endl;
}
    




Measured memory_bytes: 3600
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

int a, b, c;
int dp[105][105][105];
int ans = 1e9;

int calc(int aa, int bb, int cc) {
  if (aa < 0 || bb < 0 || cc < 0 || aa < a || bb < b || cc < c) {
    return 1e9;
  }
  int& res = dp[aa][bb][cc];
  if (res != -1) {
    return res;
  }
  res = 1e9;
  res = min(res, 1 + calc(aa, bb, cc - 2));
  res = min(res, 1 + calc(aa - 2, bb, cc));
  res = min(res, 1 + calc(aa, bb - 2, cc));
  res = min(res, 1 + calc(aa - 1, bb - 1, cc));
  res = min(res, 1 + calc(aa - 1, bb, cc - 1));
  res = min(res, 1 + calc(aa, bb - 1, cc - 1));
  return res;
}

int main() {

  cin >> a >> b >> c;

  memset(dp, -1, sizeof(dp));
  dp[a][b][c] = 0;

  for (int i = 0; i <= 100; i++) {
    ans = min(ans, calc(i, i, i));
  }

  cout << ans << endl;

  return 0;
}


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

int main(){
    long r, d, x2000;
    cin >> r >> d >> x2000;
    
    long prev = x2000;
    for (int i = 0; i < 10; i++) {
        long buf = r * prev - d;
        cout << buf << endl;
        prev = buf;
    }
}


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

int main()
{
	long long int a, b, k, tmp = 0;
	cin >> a >> b >> k;
	
	tmp = a - k;
	
	if (a == 0 && b == 0)
	{
		cout << a << " " << b << endl;
		return 0;
	}
	
	if (tmp >= 0)
	{
		a = a - k;
		cout << a << " " << b << endl;
	}
	else
	{
		a = 0;
		tmp = abs(tmp);
		if (b - tmp >= 0)
		{
			cout << a << " " << b - tmp << endl;
		}
		else
		{
			b = 0;
			cout << a << " " << b << endl;
		}
	}
	
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
char c[1010];int a[1010],ret[1010];int now=100;
int calc(int L,int R){
	int res=0;
	for(int i=L;i<=R;i++)res+=(ret[i]!=a[i]);
	return res;
}
int main(){
	scanf("%s",c+1);int n=strlen(c+1);int m;cin>>m;
	for(int i=1;i<=n;i++)c[i+n]=c[i];
	for(int i=1;i<=2*n;i++){
		ret[i]=c[i]-'a'+1;
		if(ret[i]==a[i-1])a[i]=++now;
		else a[i]=c[i]-'a'+1;
	}
	if(m==1)cout<<calc(1,n);
	else if(m==2)cout<<calc(1,n+n);
	else {
		if(a[n+n]!=a[1])cout<<1ll*calc(1,n+n)*(m/2)+(m&1)*calc(1,n);
		else cout<<(ll)calc(1,n)+(ll)calc(n+1,n+n)*(m-1);
	}
    return 0;
}








Measured memory_bytes: 256
//   __                    .__              ________ .________ ________   ______  
//  |  | __  ____    ______|  |__   __ __  /  _____/ |   ____//   __   \ /  __  \ 
//  |  |/ /_/ __ \  /  ___/|  |  \ |  |  \/   __  \  |____  \ \____    / >      < 
//  |    < \  ___/  \___ \ |   Y  \|  |  /\  |__\  \ /       \   /    / /   --   \
//  |__|_ \ \___  >/____  >|___|  /|____/  \_____  //______  /  /____/  \______  /
//       \/     \/      \/      \/               \/        \/                  \/ 

#include<bits/stdc++.h>
#define range 100005
#define mod 1000000007
#define eps 1e-9
#define PI 3.14159265358979323846
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define ALL(V) V.begin(), V.end()
#define _ <<" "<<
#define int long long 
using namespace std;

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

signed main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//freopen("test.txt","r",stdin);
	int n;
	cin>>n;
	int output = (n*(n-1))/2;
	cout<<output;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e18;
typedef long long ll;
typedef vector<ll> vl;
#define rp(i, f, t) for (int i = f; i < t; i++)
#define pr(i, f, t) for (int i = t - 1; i >= f; i--)
#define ca(n, a) rp(ca_i, 0, n) cout << a[ca_i] << ((ca_i == n - 1) ? "\n" : " ")
#define za(n, a) rp(za_i, 0, n) a[za_i] = 0
#define be(a) a.begin(), a.end()
int main()
{
    ll n;
    cin >> n;
    ll a[n];
    rp(i, 0, n) cin >> a[i];
    ll ko[222222];
    za(222222, ko);
    rp(i, 0, n) ko[a[i] - 1]++;
    ll ans = 0;
    rp(i, 0, n) if (ko[i] >= 2) ans += ko[i] * (ko[i] - 1) / 2;
    rp(i, 0, n)
    {
        ll nn = ko[a[i] - 1];
        if (nn < 2)
        {
            cout << ans << endl;
        }
        else
        {
            if (nn - 1 >= 2)
            {
                cout << ans - nn * (nn - 1) / 2 + (nn - 1) * (nn - 2) / 2 << endl;
            }
            else
            {
                cout << ans - nn * (nn - 1) / 2 << endl;
            }
        }
    }
}

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; i++)
#define repo(i, n) for(int i=1; i<=n; i++)
#define INF 1001001001
#define INFll 100100100100100
// debug用
#define PrintVec(x) for (auto elementPrintVec: x) { cout << elementPrintVec << " "; } cout << endl;

using namespace std;
using ull = unsigned long long;
using ll = long long;
using P = pair<int, int>;
const int mod = 1000000007;

int main(){
  double a, b, h, m;
  cin >> a>> b>> h >>m;

  double zi=2*M_PI*(h+m/60.0)/12.0;
  double hun=2*M_PI*m/60.0;
  double theta;
  double costh=cos(zi-hun);
  double ans=sqrt(a*a+b*b-2*a*b*costh);
  cout << fixed << setprecision(11) <<  ans << endl;
  return 0;
}


Measured memory_bytes: 4228
#include<iostream>
#include<cstring>
#include<algorithm>
#include<set>
int times[110000];
const int mod=1e9+7;
long long quickPow(int a, int b, int c) {
	// 计算 a^b mod c
	long long res = 1, bas = a;
	while (b) {
		if (b & 1) res = (long long)res * bas % c;
		// 为避免溢出，进行转换
	bas = bas * bas % c;
	b >>= 1;
	}
	return res;
}
int main()
{
    memset(times,0,sizeof times);
    std::set<int> theset;
    int n,tin;
    std::cin>>n;
    for(int i=0;i<n;i++){
        std::cin>>tin;
        times[tin]++;
        if(times[tin]>2){
            std::cout<<0;
            return 0;
        }
        theset.insert(tin);
    }
    if((times[0]!=1&&n%2!=0)||(n%2==0&&times[0]!=0)){
        std::cout<<0;
        return 0;
    }
    for(auto it=theset.begin();it!=theset.end();it++){
        if(times[*it]!=2&&*it!=0){
            std::cout<<0;
            return 0;
        }
    }
    std::cout<<quickPow(2,n/2,mod);
    return 0;
}

Measured memory_bytes: 3072
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;


string str;
ll comb[301][301];
int n,k;
int group[81];
int assign[81];
bool used[81];
ll dp2[101][101];
ll ans;

bool isvalid(int v){
	int len=0;
	for(int i=0;i<v;i++){
		if(i!=0)len++;
		if(group[i]==1){
			len++;
		}else{
			len+=group[i]*2-3;
		}
	}
	if(len>n)return false;
	memset(assign,0,sizeof(assign));
	memset(used,false,sizeof(used));
	int cnt=0;
	for(int i=0;i<k;i++){
		if(cnt==v)break;
		if(str[i]=='r'){
			assign[cnt++]=i;
			used[i]=true;
		}
	}
	if(cnt<v)return false;
	for(int i=0;i<v;i++){
		if(group[i]>=2){
			bool flag=false;
			for(int j=assign[i]+1;j<k;j++){
				if(str[j]=='b' && !used[j]){
					assign[i]=j;
					used[j]=true;
					flag=true;
					break;
				}
			}
			if(!flag)return false;
		}
	}
	for(int i=0;i<v;i++){
		if(group[i]>=3){
			int rest=group[i]-2;
			for(int j=assign[i]+1;j<k;j++){
				if(!used[j]){
					used[j]=true;
					rest--;
				}
				if(rest==0)break;
			}
			if(rest!=0)return false;
		}
	}
	return true;
}

ll dp[2][71];

void dfs(int v,int now){
	if(v>0){
		if(!isvalid(v))return;
		memset(dp,0,sizeof(dp));
		int cur=0,nxt=1;
		dp[cur][v-1]=1;
		for(int i=0;i<v;i++){
			for(int j=0;j<=n;j++){
				if(group[i]==1){
					if(j+1<=n){
						dp[nxt][j+1]+=dp[cur][j];
						dp[nxt][j+1]%=MOD;
					}
				}else{
					int pl=(group[i]-1)*2-1;
					if(j+pl<=n){
						dp[nxt][j+pl]+=dp[cur][j];
						dp[nxt][j+pl]%=MOD;
					}
					pl=(group[i]-1)*2;
					if(j+pl<=n){
						dp[nxt][j+pl]+=dp[cur][j]*2LL;
						dp[nxt][j+pl]%=MOD;
					}
					pl=(group[i]-1)*2+1;
					if(j+pl<=n){
						dp[nxt][j+pl]+=dp[cur][j];
						dp[nxt][j+pl]%=MOD;
					}
				}
			}
			swap(cur,nxt);
			memset(dp[nxt],0,sizeof(dp[nxt]));
		}
		/*
		for(int i=0;i<v;i++){
			printf("%d ",group[i]);
		}
		printf("ok\n");
		*/
		ll pw=1;
		int len=1,rest=v;
		for(int i=1;i<v;i++){
			if(group[i]==group[i-1]){
				len++;
			}else{
				pw=pw*comb[rest][len]%MOD;
				rest-=len;
				len=1;
			}
		}

		for(int i=1;i<=n;i++){
			ll va=(dp[cur][i]*pw)%MOD;
			//printf("%lld ",dp[cur][i]);
			va=va*dp2[i+2][n-i]%MOD;
			ans+=va;
			ans%=MOD;
		}
		//printf("\n");
		//printf("%lld %lld\n",pw,ans);
	}
	for(int i=1;i<=now;i++){
		group[v]=i;
		dfs(v+1,i);
	}
}

int main(void){
	comb[0][0]=1;
	for(int i=1;i<=300;i++){
		for(int j=1;j<i;j++){
			comb[i][j]=(comb[i-1][j-1]+comb[i-1][j])%MOD;
		}
		comb[i][0]=1;
		comb[i][i]=1;
	}
	dp2[1][0]=1;
	for(int i=0;i<100;i++){
		for(int j=0;j<100;j++){
			dp2[i+1][j]+=dp2[i][j];
			dp2[i+1][j]%=MOD;
			dp2[i][j+1]+=dp2[i][j];
			dp2[i][j+1]%=MOD;
		}
	}
	scanf("%d%d",&n,&k);
	cin >> str;
	dfs(0,38);
	printf("%lld\n",(ans+1LL)%MOD);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		int price=sc.nextInt();		//114514円
		int syurui=    sc.nextInt();	//効果の種類　11種類
            	int[] kouka=new int[syurui];    //硬貨の値段 810 1919 931 893 114 514 4545 36 24 170 74
		int INF=1919810;
		for(int i=0; i<syurui; i++) {
			kouka[i]=sc.nextInt();
		}

		int[][] dp=new int[syurui+1][200000];

		for(int i=0; i<200000; i++) {
			for(int j=0; j<=syurui; j++) {
				dp[j][i]=0;
			}
		}


		for(int i=1; i<200000; i++) {
			dp[0][i]=INF;
		}
		for(int i=1; i<=syurui; i++) {
			for(int j=0; j<200000; j++) {
				if(j>=kouka[i-1]) {
					dp[i][j]=Math.min(dp[i-1][j], dp[i][j-kouka[i-1]]+1);
				}
				else {
					dp[i][j]=dp[i-1][j];
				}
			}
		}

		if(dp[syurui][price]>=INF) {
			System.out.println("Impossible.");
		}
		else {
			System.out.println(dp[syurui][price]);
		}
	}
}


Measured memory_bytes: 43496
@@=1..<>;/ .* /,$_[$`][$&]=$_[$&][$`]=$' for@M=<>;for$i(@@){/^/,map$_[$'][$_]=($%=$_[$'][$_]||1e9)<($==($_[$'][$i]||1e9)+($_[$i][$_]||1e9))?$%:$=,@@for@@}/ .* /,$\+=$_[$`][$&]<$' for@M;print

Measured memory_bytes: 1408
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};


int main() {
  int N;
  cin >> N;
  cout << N * (N + 1) / 2 << endl;
  return 0;
}

Measured memory_bytes: 256
N=int(input())
L=list(map(int, input().split()))

L.sort()
X=0
for i in range(N):
  for k in range(N-(i+1)):
    j=i+1+k
    s=L[i]+L[j]
    d=max(L[i]-L[j],L[j]-L[i])
    lb=0
    ub=N-1
    while lb<ub:
      mn=(lb+ub)//2
      if L[mn]<=d:
        lb=mn+1
      else:
        ub=mn
    dmin=lb
    
    lb=0
    ub=N-1
    while lb<ub:
      mn=(lb+ub)//2
      if mn*2 != lb+ub:
        mn=mn+1
      if L[mn]>=s:
        ub=mn-1
      else:
        lb=mn
    smax=lb
    a=smax-dmin+1
    if dmin<=i and i<=smax:
      a-=1
    if dmin<=j and j<=smax:
      a-=1
    X+=a
print(int(X/3))

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

int main(){
  ll n,x;
  cin>>n>>x;
  ll ans=n,a=n-x;
  ll px=x;
  while(x%a) ans+=2*(a*(x/a)),px=x,x=a,a=px%a;
  ans+=2*(a*(x/a))-a;
  cout <<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;
  cin>>H>>W;
  vector<string>S(H);
  vector<vector<int>>X(H,vector<int>(W,0));
  for(int i=0;i<H;i++){
    cin>>S.at(i);
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(S.at(i).at(j)=='.'){
        X.at(i).at(j)=0;
      }
      else{
        X.at(i).at(j)=-1;
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(X.at(i).at(j)!=-1){
        if(j+1<W){
          if(X.at(i).at(j+1)==-1){
            X.at(i).at(j)=X.at(i).at(j)+1;
          }
          if(i-1>=0){
            if(X.at(i-1).at(j+1)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
            }
          }
          if(i+1<H){
            if(X.at(i+1).at(j+1)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
            }
          }
        }
        if(j-1>=0){
          if(X.at(i).at(j-1)==-1){
            X.at(i).at(j)=X.at(i).at(j)+1;
          }
          if(i-1>=0){
            if(X.at(i-1).at(j-1)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
            }
          }
          if(i+1<H){
            if(X.at(i+1).at(j-1)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
            }
          }
        }
        if(i-1>=0){
          if(X.at(i-1).at(j)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
          }
        }
        if(i+1<H){
          if(X.at(i+1).at(j)==-1){
              X.at(i).at(j)=X.at(i).at(j)+1;
          }
        }
      }
    }
  }
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(X.at(i).at(j)!=-1){
        S.at(i).at(j)='0'+X.at(i).at(j);
      }
    }
  }
  for(int i=0;i<H;i++){
    cout<<S.at(i)<<endl;
  }
}

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

int main()
{
    int n, i, a[20], b[20];
    cin >> n;
    for(i = 0; i < n; i++)
        cin >> a[i];
    for(i = 0; i < n; i++)
        cin >> b[i];

    int ans = 0;

    for(i = 0; i < n; i++)
        ans += max(0, a[i] - b[i]);

    cout << ans;
}


Measured memory_bytes: 3564
#include "bits/stdc++.h"

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll po(ll a, ll n) {
	if (n == 0)return 1;
	ll d = po(a, n / 2);
	if (n & 1)return a * d%MOD*d%MOD;
	return d * d%MOD;
}

vl fact, rfact;

ll comb(ll n, ll r) {
	return fact[n] * rfact[r] % MOD*rfact[n - r] % MOD;
}
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vi cnt(n, -1);
	int p1 = 0, p2 = 0;
	REP(i, n+1) {
		int a;
		cin >> a;
		a--;
		if (cnt[a] != -1) {
			p1 = cnt[a];
			p2 = i;
		}
		else cnt[a] = i;
	}
	vl ans(n + 1);
	fact.resize(n + 1);
	rfact.resize(n + 1);
	fact[0] = 1;
	REP(i, n) {
		fact[i + 1] = fact[i] * (i + 1) % MOD;
	}
	REP(i, n + 1)rfact[i] = po(fact[i], MOD - 2);

	REP(i, n + 1) {
		if (i + 1 <= n - 1) ans[i] += comb(n - 1, i + 1);
		if (i <= n - 1)ans[i] += 2 * comb(n - 1, i);
		if (i <= p1 + n - p2)ans[i] += (MOD - comb(p1 + n - p2, i));
		if (i >= 1)ans[i] += comb(n - 1, i - 1);
		ans[i] %= MOD;
	}
	for (auto a : ans)cout << a << endl;

}

Measured memory_bytes: 3968
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n,m;
vector<vector<int> >V;
vector<int>ans;
bool used[5000];
void func(int x){
    if(used[x])return;
    used[x]=true;
    for(int i=0;i<V[x].size();i++)func(V[x][i]);
    ans.push_back(x);
    return;
}
int main(){
    cin>>n>>m;
    V.resize(n);
    for(int i=0;i<m;i++){
        int a,b;
        cin>>a>>b;a--;b--;
        V[a].push_back(b);
    }
    for(int i=0;i<n;i++)func(i);
    reverse(ans.begin(),ans.end());
    for(int i=0;i<n;i++){
        cout<<ans[i]+1<<endl;
    }
    bool flag=false;
    for(int i=0;i<n-1;i++){
        int a=ans[i],b=ans[i+1];
        if(find(V[a].begin(),V[a].end(),b)==V[a].end()&&find(V[b].begin(),V[b].end(),a)==V[b].end())flag=true;
    }
    if(flag)cout<<1<<endl;
    else cout<<0<<endl;
    return 0;
}

Measured memory_bytes: 2116
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x1,x2,x3,x4,x5;
    cin >> x1 >> x2 >> x3 >> x4 >> x5;
    if(x1 == 0) cout << 1;
    else if (x2 == 0) cout << 2;
    else if(x3 == 0) cout << 3;
    else if (x4 == 0) cout << 4;
    else cout << 5;
    cout << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
typedef long long ll;
#define ALL(vec) vec.begin(),vec.end()
#define rep(i,n) for(int i = 0;i<n;++i)
#define repc(bit,k,n) for (int bit = (1<<k)-1;bit < (1<<n); bit = next_combination(bit))
#define repi(itr,vec) for(auto itr = vec.begin();itr!=vec.end();++itr)
using namespace std;

const ll MOD = 1000000007;
const int limit = 1000000;
ll prime[limit];
void prime_init(){
  prime[1] = 1;
  prime[2] = 2;
  for(ll i = 3;i<limit;i++){
    prime[i] = i;
    for(ll j = 2;j<sqrt(i)+1;j++){
      if(i%prime[j]==0){
        prime[i] = prime[j];
        break;
      }
    }
  }
  return;
}

ll get_prime(ll p){
  if(p<limit) return prime[p];
  for(ll j = 2;j<sqrt(p)+1;j++){
    if(p%prime[j]==0){
      return prime[j];
    }
  }
  return p;
}
const int MAX = 510000;
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(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;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  prime_init();
  COMinit();
  ll n,m;cin>>n>>m;
  if(m==1){
    cout<<1<<endl;
    return 0;
  }
  vector<int> b;
  ll cur = get_prime(m);
  b.push_back(1);
  m/=cur;
  while(m>1){
    ll p = get_prime(m);
    if(cur != p){
      cur = p;
      b.push_back(1);
    }else{
      b.back()++;
    }
    m/=p;
  }
  ll ans = 1;
  repi(itr,b){
    ans = (ans*COM(*itr+n-1,*itr))%MOD;
  }
  cout<<ans<<endl;

  return 0;
}

Measured memory_bytes: 23440
#include<bits/stdc++.h>
using namespace std;
int main(){
  int H,W;cin>>H>>W;
  vector<vector<int>>A(H,vector<int>(W)),B(H,vector<int>(W));
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>A[i][j];
  for(int i=0;i<H;i++)for(int j=0;j<W;j++)cin>>B[i][j];
  //上の80*80*80は正の数
  vector<vector<bitset<80*80*80*2>>>DP(H,vector<bitset<80*80*80*2>>(W));
  
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(i==0&&j==0){
        DP[i][j].set(80*80*80+abs(A[i][j]-B[i][j]));
        DP[i][j].set(80*80*80-abs(A[i][j]-B[i][j]));
      }
      else if(i==0){
        DP[i][j]|=DP[i][j-1]<<abs(A[i][j]-B[i][j]);
        DP[i][j]|=DP[i][j-1]>>abs(A[i][j]-B[i][j]);
      }
      else if(j==0){
        DP[i][j]|=DP[i-1][j]<<abs(A[i][j]-B[i][j]);
        DP[i][j]|=DP[i-1][j]>>abs(A[i][j]-B[i][j]);
      }
      else {
        DP[i][j]|=(DP[i-1][j]|DP[i][j-1])<<abs(A[i][j]-B[i][j]);
        DP[i][j]|=(DP[i-1][j]|DP[i][j-1])>>abs(A[i][j]-B[i][j]);
      }
    }
  }
  for(int i=0;i<80*80*80;i++){
    //cout<<DP[H-1][W-1][80*80*80+i]<<DP[H-1][W-1][80*80*80-i]<<endl;
    if(DP[H-1][W-1][80*80*80+i]||DP[H-1][W-1][80*80*80-i]){
      cout<<i;return 0;
    }
  }
}

Measured memory_bytes: 810624
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
#include <stack>
#include <string>
#include <deque>
#include <map>
#include <algorithm>

using namespace std;
//--------------------
int gcd(int a, int b) {
    return b == 0 ? a : gcd(b, a % b);
}

void func() {
    long long N,A,B;
    cin >> N >> A >> B;
    long long ans = A * (N / (A + B));
    long long remains = N % (A + B);
    ans += min(A,remains);
    cout << ans << endl;
}

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

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

const int mod = 1e9 + 7, N = 200005;
int fact[N], rfact[N];

int binpow(int a, int m){
    int res = 1, now = a;
    for (; m; m >>= 1, now = (now * now) % mod){
    	if (m & 1){
    		res = (res * now) % mod;
    	}
    }
    return res;
}

int C(int n, int k){
	return ((fact[n] * rfact[k]) % mod * rfact[n - k]) % mod;
}

signed main(){
	int n, m, a, b, ans, t;
	cin >> n >> m >> a >> b;
	fact[0] = 1;
	for (int i = 1; i < N; i++){
		fact[i] = (fact[i - 1] * i) % mod;
	}
	for (int i = 0; i < N; i++){
		rfact[i] = binpow(fact[i], mod - 2);
	}
	for (int i = 1; i <= n - a; i++){
		t = C(b + i - 2, b - 1);
		ans += (t * C(n - i + m - b - 1, n - i)) % mod;
		ans %= mod;
	}
	cout << ans;
}

Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
const int mod= 1e9+7;
#define fastIO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define what_is(x) cerr << #x << " = " << x << endl;
typedef long long ll;
ll power(ll x, ll k)
{
	ll ret = 1;
	while (k){
		if (k & 1) ret = (ret*x) % mod;
		k >>= 1; x = (x*x) % mod;
	}
	return ret;
}
int main()
{
    fastIO

    int n;
    cin>>n;

    cout<<(((power(10,n)-2*power(9,n)+power(8,n))%mod)+mod)%mod;


}


Measured memory_bytes: 3604
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
#define maxn 150

bool bh[maxn],bw[maxn];
char s[maxn][maxn];
int main()
{
	int n,m,i,t,j;
	scanf("%d%d",&n,&m);
	memset(bh,false,sizeof(bh));
	memset(bw,false,sizeof(bh));
	for (i=1;i<=n;i++)
	 scanf("%s",s[i]+1);
	t=(n>m)?n:m;
	while (t--)
	{
		for (i=1;i<=n;i++) if (!bh[i])
		{
			bool bk=false;
			for (j=1;j<=m;j++)
			 if (!bw[j] && s[i][j]!='.') {bk=true;break;}
			if (!bk) bh[i]=true;
		}
		for (i=1;i<=m;i++) if(!bw[i])
		{
			bool bk=false;
			for (j=1;j<=n;j++)
			 if (!bh[j] && s[j][i]!='.') {bk=true;break;}
			if (!bk) bw[i]=true;
		}
	}
	for (i=1;i<=n;i++) if (!bh[i])
	{
		for (j=1;j<=m;j++) if (!bw[j])
		 printf("%c",s[i][j]);
		printf("\n");
	}
	return 0;
}
//.white #black


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    
    
    string s1,s2;
    cin>>s1>>s2;
    
    if(s2.length()!=(s1.length()+1))
    {cout<<"No"<<endl;return 0;}
    for(int i=0;i<s1.length();i++)
    {
        if(s1[i]!=s2[i])
        {cout<<"No"<<endl;return 0;}
    }
    cout<<"Yes"<<endl;
    
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
	int N;
	vector<int> ricecake;
	bool flag = true;

	cin >> N;
	
	vector<int> InVec;

	for (int i = 0; i < N; ++i)
	{
		int t;
		cin >> t;
		InVec.push_back(t);
	}

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

	InVec.erase(std::unique(InVec.begin(), InVec.end()), InVec.end());

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

	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
topcoder = 0
colors = []
for i in a:
    if i > 3199:
        topcoder += 1
    else:
        colors.append(i//400)
minimum = 1 if len(colors) == 0 else len(list(set(colors)))
maximum = len(list(set(colors)))+topcoder
print('{} {}'.format(minimum,maximum))


Measured memory_bytes: 3060
#include<iostream>
using namespace std;
int n;
int h[100];
int main(){
  cin >> n;
  for(int i=0;i<n;i++) cin >> h[i];
  int ans=0;
  int cnt;
  while(cnt<n){
    cnt=0;
    bool f=false;
    for(int i=0;i<n;i++){
      if(h[i]!=0){ 
	h[i]--;
	f=true;
      }
      else {
	if(f){
	  ans++;
	  f=false;
	}
	cnt++;
      }
    }
    if(f) ans++;
  }
  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		long N = sc.nextLong();
		
		long A = 0L;
		long B = 0L;
		long C = N;

		for (int i = 1; i <= Math.sqrt(N); i++) {
			if (N % i == 0) {
				if (i + (N/i) < C) {
					A = i;
					B = N/i;
					C = A + B;
				}
			}
		}
		if (A == 0) {
			System.out.println(N - 1);
		} else {
			System.out.println((A-1) + (B-1));
		}
		
	}

}


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

#define REP(i,s,n) for(int i=s;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define fst first
#define snd second
#define pb push_back
#define ALL(x) x.begin(),x.end()
#define EPS (1e-9)
#define equals(a,b) (fabs((a)-(b))<EPS)

using namespace std;

bool LT(double a,double b) { return !equals(a,b) && a < b; }
bool LTE(double a,double b) { return equals(a,b) || a < b; }

const string YES = "";
const string NO  = "";

typedef long long ll;

void solve() {

}

int main() {
  string s,t;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  string c;
  cin >> c;
  if( c == s ) --a;
  if( c == t ) --b;
  cout << a << " " << b << endl;
  return 0;
}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort.push(10**10)
b = gets.chomp.split.map(&:to_i).sort
c = gets.chomp.split.map(&:to_i).sort.push(10**10)

ans = 0
la,lc = 0,0
n.times do |i|
  while b[i] > a[la]
    la += 1
  end
  while b[i] >= c[lc]
    lc += 1
  end
  ans += la*(n-lc)
end

puts ans

Measured memory_bytes: 26804