akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<bitset>

using namespace std;

#define M 1000000007
#define pb push_back
#define f first
#define s second
#define rep(i, st, ed) for(int i=st; i<ed; i++)
#define repn(i, st, ed) for(int i=st; i<=ed; i++)


typedef long long ll;
typedef unsigned long long int llt;

const int N = 5e5 + 10;

vector<int> g[N];
bool viss[N];
int vis[N];

void dfs(int curr, int par)
{
  for(auto x: g[curr])
    if(x != par)
      dfs(x, curr);
}

void dfs1(int curr, int par)
{
  viss[curr] = 1;
  for(auto x: g[curr])
    if(!viss[x])
      dfs1(x, curr);
}

void dfs2(int curr, int par, int num)
{
  vis[curr] = num;
  for(auto x: g[curr])
    if(vis[x] == 0)
      dfs2(x, curr, num);
}

ll fxor(ll n)
{
  if(n < 0) return 0;
  if(n % 4 == 3) return 0;
  else if(n % 4 == 0) return n;
  else if(n % 4 == 1) return n^(n-1);
  else if(n%4 == 2) return n^(n-1)^(n-2);
}

llt ppow(llt x, llt y)
{
  llt res = 1;
  while(y > 0){
    if(y&1)
      res = (res * x)%M;
    y = y >> 1;
    x = (x * x)%M;
  }
  return res;
}

string ans ="";
void convert10tob(llt N, int b)
{
     if (N == 0)
        return;
     int x = N % b;
     N /= b;
     if (x < 0)
        N += 1;
     convert10tob(N, b);
     ans += to_string(x);
     return;
}

llt convertback(string a, int b)
{
  llt aa = 0;
  llt mul = 1;
  for(int i=a.length()-1; i>=0; i--)
  {
    int curr = a[i] - '0';
    aa += (curr * mul);
    mul *= b;
  }
  return aa;
}

int main()
{
  int c5 = 0;
  int c7 = 0;
  int a;
  rep(i, 0, 3){
    cin>>a;
    if(a == 5)
    {
      c5++;
    }
    if(a == 7)
    {
      c7++;
    }
  }
  if(c5 == 2 && c7 == 1)
  puts("YES");
  else puts("NO");
  return 0;
}


Measured memory_bytes: 12416
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
template<class T>
class UnionFind
{
private:
	vector<T> parentNo;
	vector<T> parentRank;
	vector<T> parentSize;

public:
	// コンストラクタ
	UnionFind(int n) 
	{
		parentNo.resize(n);
		parentRank.resize(n, 0);
		parentSize.resize(n, 1);
		for (int i = 0; i < n; i++) {
			// 始めは全部ROOT
			parentNo[i] = i;
		}
	}

	int root(T x) 
	{
		if (parentNo[x] == x) {
			return x;
		} else {
			T rootParentNo = root(parentNo[x]);
			parentNo[x] = rootParentNo;
			return rootParentNo;
		}
	}

	bool same(T x, T y) 
	{
		return root(x) == root(y);
	}

	int size(T x) 
	{
		return parentSize[root(x)];
	}

	void unite(T xc, T yc) 
	{
		T xr = root(xc);
		T yr = root(yc);
		if (xr == yr) {
			return;
		}
		if (parentRank[xr] < parentRank[yr]) {
			parentNo[xr] = yr;
			parentSize[yr] += parentSize[xr];
		} else {
			parentNo[yr] = xr;
			parentSize[xr] += parentSize[yr];
			if (parentRank[xr] == parentRank[yr]) {
				parentRank[xr]++;
			}
		}
	}
};


int main()
{
	int N, K, L;
	cin >> N >> K >> L;

	vector<int> p(K), q(K), r(L), s(L);
	REP(i, K) {
		cin >> p[i] >> q[i];
		p[i]--; q[i]--;
	}
	REP(i, L) {
		cin >> r[i] >> s[i];
		r[i]--, s[i]--;
	}

	UnionFind<int> uFindR(N + 1);
	UnionFind<int> uFindT(N + 1);
	REP(i, K) {
		uFindR.unite(p[i], q[i]);
	}
	REP(i, L) {
		uFindT.unite(r[i], s[i]);
	}
	
	// 各都市の所属先
	map<P, int> mp;
	REP(i, N) {
		mp[make_pair(uFindR.root(i), uFindT.root(i))]++;
	}
	
	REP(i, N) {
		cout << mp[make_pair(uFindR.root(i), uFindT.root(i))] << " ";
	}
	cout << endl; 
	return 0;
}


Measured memory_bytes: 18048
//code by lynmisakura.wish to be accepted!
/*************************/
#include<iostream>
#include<iomanip>
#include<math.h>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<algorithm>
#include<bitset>
#include <climits>
#include<set>
#include<bitset>
using namespace std;
/***************************/
typedef long long ll;
typedef long long ijt;
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vpi;

const long long INF = 1LL << 55;

#define itn int
#define endl '\n'
#define pb push_back
#define mp make_pair
#define ss second
#define ff first
#define dup(x,y) ((x) + (y) - 1)/(y)
#define mins(x,y) x = min(x,y)
#define maxs(x,y) x = max(x,y)
#define all(x) (x).begin(),(x).end()
#define Rep(n) for(int i = 0;i < n;i++)
#define rep(i,n) for(int i = 0;i < n;i++)
#define rrep(i,n) for(int i = n - 1;i >= 0;i--)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll qp(ll a, ll b) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; }
ll qp(ll a, ll b, int mo) { ll ans = 1; do { if (b & 1)ans = 1ll * ans*a%mo; a = 1ll * a*a%mo; } while (b >>= 1); return ans; }

#define _GLIBCXX_DEBUG
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<typename T> // T: type of cost
struct BIT {
	int n;
	vector<T> d;
	BIT(int n = 0) :n(n), d(n + 1) {}
	void add(int i, T x = 1) {
		for (i++; i <= n; i += i & -i) {
			d[i] += x;
		}
	}
	T sum(int i) {
		T x = 0;
		for (i++; i; i -= i & -i) {
			x += d[i];
		}
		return x;
	}

	long long inversion(vector<ijt> a) {
		long long ans = 0;
		for (int j = 0; j < a.size(); j++) {
			ans += j - sum(a[j]);
			add(a[j], 1);
		}
		return ans;
	}
};

int main(void) {
	int n;cin >> n;
	vector<int> a(n),b(n);
	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b[i] = a[i];
	}
	sort(all(b));
	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		int d = lower_bound(all(b),a[i]) - b.begin();
		if(d %2 != i %2) ans++;
	}
	cout << ans / 2 << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define rep(I, N) for (int I = 1; I <= (N); ++I)
#define repp(I, N) for (int I = 0; I < (N); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORR(I, A, B) for (int I = (A); I >= (B); I--)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
const int N = 2e5 + 5;
const double eps = 1e-7;
const int mod = 1e9 + 7;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
LL gcd(LL a,LL b){return b>0?gcd(b,a%b):a;}
LL ksm(LL a,LL b){LL ans = 1;while(b){if(b&1) ans = ans * a % mod;a = a * a % mod;b >>= 1;}return ans % mod;}
int solve(int n)
{
    int ans = 0;
    while(n)
    {
       n /= 10;
       ans++;
    }
    return ans;
}
int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n;i++)
    {
        if(solve(i) % 2)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,i,count=0;
  scanf("%d",&n);
  int a[n+1];
  for(i=0;i<n;i++)
    scanf("%d",&a[i]);
  for(i=0;i<n;i++){
    while(a[i]%2==0){
      a[i]/=2;
      count++;
    }
  }
  printf("%d\n",count);
  return 0;
}


Measured memory_bytes: 256
#C
n = int(input())
a = [[0 for i in range(3)] for j in range(n)]
for i in range(n):
    a[i] = list(map(int,input().split()))

dp = [[0 for i in range(3)] for j in range(n)]
for i in range(n):
    if i == 0:
        for j in range(3):
            dp[i][j]=a[i][j]
        continue
    for j in range(3):
        for k in range(3):
            if j != k:
                dp[i][j] = max(dp[i-1][k]+a[i][j],dp[i][j])
print(max(dp[n-1]))

Measured memory_bytes: 47248
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#define PII pair<int,int>
#define MP make_pair
#define fir first
#define sec second
#define PB push_back
#define db long double
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}

const int N=2e5+10;
int f[N][2],n;
char s[N];
bool cmp(int x,int y,int len) {
	len++;
	if(x<len) return 1;
	for(int k=0;k<len;++k) if(s[x-k]!=s[y-k]) return 1;
	return 0;
}
int main() {
	scanf("%s",s+1); n=strlen(s+1);
	for(int i=1;i<=n;++i)
		for(int j=0;j<2;++j) {
			if(i<j+1) continue;
			f[i][j]=max(f[i][j],f[i-j-1][j^1]+1);
			if(cmp(i,i-j-1,j)) f[i][j]=max(f[i][j],f[i-j-1][j]+1);
		}
	printf("%d\n",max(f[n][0],f[n][1]));
	return 0;
}

Measured memory_bytes: 2048
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 1000000000;
const long long int llINF = 1000000000000000000;

using namespace std;
using ll = long long int;
using vv = vector<vector<ll>>;
using edge = struct {
  int to;
  int cost;
};
#define REP(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end());
#define MIN(vec) *std::min_element(vec.begin(), vec.end());
#define BIT(n, num) std::bitset<(n)>((num)).to_string()
#define REV(T) greater<T>()

typedef pair<ll, ll> Pair;
bool pairCompare(const Pair &firstElof, const Pair &secondElof) {
  return firstElof.second > secondElof.second;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n)
        ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

map<ll, int> prime_factor(ll n) {
  map<ll, int> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1)
    ret[n] = 1;
  return ret;
}

ll factorial(int n) {
  ll ans = 1;
  for (int i = 2; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll P(int n, int m) {
  ll ans = 1;
  for (int i = m + 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  return ans;
}
ll power(int n, int m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = power(n, m / 2);
    return (tmp * tmp) % MOD;
  } else {
    return (n * power(n, m - 1)) % MOD;
  }
}
ll C(int n, int m) {
  return (P(n, n - m) * power(factorial(m), MOD - 2)) % MOD;
}
ll GCD(ll a, ll b) {
  if (b == 0)
    return a;
  return GCD(b, a % b);
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
  ll N = 0;
  ll po = 0;
  ll yo = 0;
  ll bo = 0;
  cin >> N;
  REP(i, N) {
    ll a = 0;
    cin >> a;
    if (a % 2 == 1)
      po++;
    else if (a % 4 == 0)
      yo++;
    else
      bo++;
  }
  if (yo >= po || (bo == 0 && yo >= po - 1))
    cout << "Yes";
  else
    cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<iomanip>
#include<map>
#include<utility>
#include<string>

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

using namespace std;

#define min_3(a, b, c) min(a, min(b, c))
#define max_3(a, b, c) max(a, max(b, c))
typedef long long ll;


int main()
{
    int n; cin >> n;
    vector<int> d(n);
    for(int i = 0; i < n; i++) cin >> d[i];
    sort(d.begin(), d.end());

    cout << d[(n+1)/2] - d[(n-1)/2] << endl;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  for (int i = 0; i < n; ++i) cin >> a[i];
  for (int i = 0; i < n; ++i) cin >> b[i];
  for (int i = 0; i < n; ++i) cin >> c[i];
  sort(a.begin(), a.end());
  sort(c.begin(), c.end());

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    int k = b[i];
    int aidx = lower_bound(a.begin(), a.end(), k) - a.begin() - 1;
    int cidx = upper_bound(c.begin(), c.end(), k) - c.begin();
    ans += (long long)(aidx + 1) * (n - cidx);
  }
  cout << ans << '\n';
  return 0;
}


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

using namespace std;

int main()
{
    int n;

    cin >> n;

    int sum = 0;
    bool ans = true;
    for (int ii = 0; ii < n; ii++)
    {
        char c;
        int x;
        int add;
        cin >> c >> x;
        if (c == '(')
        {
            add = 1;
        }
        else
        {
            add = -1;
        }
        sum += (add * x);
        if (sum < 0)
        {
            ans = false;
            break;
        }
    }
    if (sum != 0)
        ans = false;

    if (ans == true)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 3120
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  std::cout.precision(20);
  int A,B,H,M;
  cin >> A >> B >> H >> M;
static const double pi = 3.141592653589793;
  std::cout << std::fixed;
double a,b,c,d;//ab長針
  a=cos(pi/2-M*pi/30);
  b=sin(pi/2-M*pi/30);
  c=cos(pi/2-(60*H+M)*pi/360);
  d=sin(pi/2-(60*H+M)*pi/360);
  
  double x,y,z,w;
  x=(B*a-A*c)*(B*a-A*c);
  y=(B*b-A*d)*(B*b-A*d);
  z=x+y;
  w=sqrt(z);
  std::cout << w << std::endl;
}


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

int main() {
	string a; int ans = 0;
	cin >> a;
	for (int i = 0; i < 3; i++) {
		if (a[i] == '1') {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <iostream>
#include <queue>
using namespace std;

inline int calc() {
	priority_queue<int> que;
	for(int i = 0; i < 10; ++i) {
		int in;
		cin >> in;
		que.push(in);
	}

	int res = 0;
	for(int i = 0; i < 3; ++i, que.pop())
		res += que.top();

	return res;
}

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

	int score_w = calc(), score_k = calc();
	cout << score_w << " " << score_k << endl;

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1220
#include<iostream>
#include<queue>
#include<string>
#include<vector>

using namespace std;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int Max = 100000;
int main() {
	int h, w;
	cin >> h >> w;
	//vertex = 0..h h..h+w
	int n = h + w+2;
	int start = h + w;
	int end = h + w + 1;
	vvi E(n, vi(n, 0));
	string s;
	int ans = 0;
	int si, sj, ti, tj;
	for (int i = 0; i < h; i++) {
		cin >> s;
		for (int j = 0; j < w; j++) {
			if (s[j] == 'o') {
				E[i][h + j] = 1;
				E[h + j][i] = 1;
			}
			if (s[j] == 'S') {
				si = i; sj = j;
				E[i][start] = Max;
				E[start][i] = Max;
				E[j+h][start] = Max;
				E[start][j+h] = Max;
			}
			if (s[j] == 'T') {
				ti = i; tj = j;
				E[i][end] = Max;
				E[end][i] = Max;
				E[j+h][end] = Max;
				E[end][j+h] = Max;
			}
		}
	}
	if (si == ti || sj == tj) {
		cout << -1 << endl;
		return 0;
	}
	
	vvi F(n, vi(n, 0));
	vvi G(n, vi(n, 0));
	//for (int i = 0; i < n; i++) {
	//	for (int j = 0; j < n; j++) {
	//		cout << G[i][j] << " ";
	//	}
	//	cout << endl;
	//}
	//return 0;
	vi preV(n, -1);
	while (true) {
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < n; j++) {
				G[i][j] = E[i][j] - F[i][j];
			}
		}
		for (int i = 0; i < n; i++) {
			preV[i] = -1;
		}
		queue<int> que;
		que.push(start);
		vi path;//end .. v .. start
		bool getPath = false;
		while (!que.empty()) {
			int v = que.front(); que.pop();
			for (int i = 0; i < n; i++) {
				if (E[v][i] >0 && G[v][i] > 0 && preV[i]==-1) {
					int nv = i;
					preV[nv] = v;
					if (nv == end) {
						int pv = end;
						while (true) {
							path.push_back(pv);
							if (pv == start) {
								getPath = true;
								break;
							}
							pv = preV[pv];
						}
					}
					que.push(nv);
					if (getPath)break;
				}
			}
			if (getPath)break;
		}
		if (!getPath)break;
		//for (int i = 0; i < path.size(); i++) {
		//	cout << path[i] << " ";
		//}
		////return 0;
		for (int i = 0; i < path.size() - 1; i++) {
			int a = path[i];
			int b = path[i + 1];
			F[a][b]--;
			F[b][a]++;
		}
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 768
#include <vector>
#include <cmath>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <iostream>
#include <algorithm>

typedef long long LL;
typedef unsigned long long uLL;

#define fir first
#define sec second
#define SZ(x) (int)x.size()
#define MP(x, y) std::make_pair(x, y)
#define PB(x) push_back(x)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define GO debug("GO\n")
#define rep(i, a, b) for (register int i = (a), i##end = (b); (i) <= i##end; ++ (i))
#define drep(i, a, b) for (register int i = (a), i##end = (b); (i) >= i##end; -- (i))
#define REP(i, a, b) for (register int i = (a), i##end = (b); (i) < i##end; ++ (i))

inline int read() {
    register int x = 0; register int f = 1; register char c;
    while (!isdigit(c = getchar())) if (c == '-') f = -1;
    while (x = (x << 1) + (x << 3) + (c xor 48), isdigit(c = getchar()));
    return x * f;
}
template<class T> inline void write(T x) {
    static char stk[30]; static int top = 0;
    if (x < 0) { x = -x, putchar('-'); }
    while (stk[++top] = x % 10 xor 48, x /= 10, x);
    while (putchar(stk[top--]), top);
}
template<typename T> inline bool chkmin(T &a, T b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, T b) { return a < b ? a = b, 1 : 0; }

#define int LL

using namespace std;

const int maxn = 1e5 + 2;
const int MOD = 1e9 + 7;

LL a[maxn], n;
LL inv[maxn], sum[maxn];

void Input() {
    n = read();
    rep (i, 1, n) a[i] = read();
}

void Init() {
    inv[0] = 0;
    inv[1] = 1;
    sum[1] = inv[1];
    rep (i, 2, n) {
        inv[i] = (MOD - (MOD / i) * inv[MOD % i] % MOD) % MOD;
        sum[i] = (sum[i - 1] + inv[i]) % MOD;
    }
}

int factor(int n) {
    int ans = 1;
    rep (i, 2, n) ans = ans * i % MOD;
    return ans;
}

void Solve() {
    LL ans(0);
    rep (i, 1, n) {
        ans = (ans + a[i] * ((sum[i] - sum[0] + sum[n - i + 1] - sum[1] + MOD) % MOD) % MOD ) % MOD;
    }
    cout << ans * factor(n) % MOD << endl;
}

signed main() 
{
    
    Input();

    Init();

    Solve();

    return 0;
}

Measured memory_bytes: 2560
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

  static class DSumOfLargeNumbers {
    private static final int MOD = 1000000007;

    public void solve(int testNumber, InputReader in, PrintWriter out) {
      int n = in.nextInt(), k = in.nextInt(), ans = 0;
      for (int i = k; i <= n + 1; i++) {
        long upper = (long) i * (2 * n - i + 1) / 2;
        long lower = (long) i * (i - 1) / 2;
        ans = (int) ((ans + upper - lower + 1) % MOD);
      }
      out.println(ans);
    }

  }


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

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

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

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

  }
}



Measured memory_bytes: 25864
//Jay Shree Krishna

#include"bits/stdc++.h"
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define ll long long int
#define inf 1e18+5
#define sr string
#define M 1000000007
#define start int t;cin>>t;while(t--)
#define db(x) cout<<#x<<"="<<x<<"\n"
#define db2(a,b)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<< endl;
#define db3(a,b,c)cout<<#a<<": "<<a<<" , "<<#b<<": "<<b<<" , "<<#c<<": "<<c<<endl;
#define forr(i, n) for (int i = 0; i < n; i++)
#define fr(i, n) for (int i = 1; i <= n; i++)
#define rep(i,j,k) for(int i = j; i < k; i++)
#define rp(i,j,k) for(int i = j; i <=k; i++)
#define nn "\n"
#define en "\n"
#define vvi vector<vector<int>>
#define vi vector<int>
#define si set<int>
#define mlsi multiset<int>
#define vc vector<char>
#define vli vector<long long int>
#define vpii vector<pair<ll,ll>>
#define pii pair<ll,ll>
#define mii map<ll,ll>
#define msi map<string,int>
#define mci map<char,int>
#define umii unordered_map<int,int>
#define umsi unordered_map<string,int>
#define umci unordered_map<char,int>
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define sortv(x) sort(x.begin(),x.end())
#define sorta(x,n) sort(x,x+n)
#define sorted(x) is_sorted(x.begin(),x.end())
#define print_all(x) for(auto t:x) cout<<t<<" ";cout<<en;
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define ub upper_bound
#define lb lower_bound
#define go(x) for(auto &[u,v]:x)
#define in(x) cin>>x
#define in2(x,y) cin>>x>>y
#define in3(x,y,z) cin>>x>>y>>z
#define in4(x,y,z,v) cin>>x>>y>>z>>v
#define oo(x) cout<<x<<en
#define oo2(x,y) cout<<x<<" "<<y<<en
#define oo3(x,y,z) cout<<x<<" "<<y<<" "<<z<<en
#define ood(n,x) cout<<fixed<<setprecision(n)<<x<<"\n"
#define sz(x) x.size()
#define ff first
#define ss second
#define ooy cout<<"YES\n"
#define oon cout<<"NO\n" 
#define rr return
#define cc continue

using namespace std;

template<class T> bool ckmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<class T> bool ckmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
 
void read(vli &a,int n){
    a.resize(n);
    forr(i,n) cin>>a[i];
}

bool fine=0;
vli a,b;
ll n,m;
ll ans=0;

void solve(){
    in(n);
    sr s(n,'A');
    sr s1(n,'C');
    sr s2(n,'L');
    forr(i,n){
        cout<<s[i]<<s1[i]<<s2[i];
    }
}

int main(){
   #ifndef ONLINE_JUDGE 
    freopen("input1.txt", "r", stdin); 
    freopen("error.txt", "w", stderr); 
    freopen("output1.txt", "w", stdout); 
    #endif
    fast;
    if(fine){
        start{
            solve();
        }
   }
   else solve();
    return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
    for(auto &e:t) fill_v(e,v);
}

int main() {
  string s; cin >> s;

  int n = (int)s.length();

  if(n == 2){
    if(s[0] == s[1]) cout << 1 << " " << 2 << endl;
    else cout << -1 << " " << -1 << endl;

    return 0;
  } else {
    REP(i, n-2){
      string t = s.substr(i, 3);
      if(t[0] == t[1] || t[1] == t[2] || t[2] == t[0]){
        cout << i + 1 << " " << i + 3 << endl;
        return 0;
      }
    }
  }

  cout << -1 << " " << -1 << endl;

  return 0;
}


Measured memory_bytes: 512
import sys
A, B, C = map(int, input().split())

def isodd(x):
    if x % 2 == 1:
        return True
    else:
        return False

if isodd(A) or isodd(B) or isodd(C):
    print(0)
    sys.exit()
res = 0
while not isodd(A) and not isodd(B) and not isodd(C):
    if A == B == C:
        print(-1)
        sys.exit()
    tA, tB, tC = A, B, C
    A = tB//2 + tC//2
    B = tA//2 + tC//2
    C = tA//2 + tB//2
    res += 1
print(res)

Measured memory_bytes: 61932
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){
  Int n;
  cin>>n;
  vector<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];
  sort(d.begin(),d.end());
  d.erase(unique(d.begin(),d.end()),d.end());
  cout<<d.size()<<endl;
  return 0;
}


Measured memory_bytes: 764
#「与えられた数列の、広義単調減少列の長さの最大値 L」
from bisect import bisect_left, bisect_right
n = int(input())
INF = 1010101010
dp = [INF] * n
a = [int(input()) for _ in range(n)]
a.reverse()
for i in a:
    dp[bisect_right(dp, i)] = i
print(bisect_left(dp, INF))

Measured memory_bytes: 13776
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
a,b,k = map(int, input().split(' '));

for i in range(k):
    if (i % 2 == 0):
        if (a % 2 == 1):
            a -= 1
        b += int(a/2)
        a = int(a/2)
    else:
        if (b % 2 == 1):
            b -= 1
        a += int(b/2)
        b = int(b/2)
print(a,b)



Measured memory_bytes: 3060
n,m = map(int,input().split())
ab_list = [list(map(int,input().split())) for nesya in range(n)]
s_list = sorted(ab_list)
cost = 0
for ab in s_list:
  a = ab[0]
  b = ab[1]
  if b <= m:
    m -= b
    cost += a*b
  else:
    cost += a*m
    m = 0
print(cost)

Measured memory_bytes: 28236
if __name__=="__main__":
    n = int(input())
    A, B = [int(i) for i in input().split(' ')]
    C = [int(i) for i in input().split(' ')]
    l = 0
    mid = 0
    r = 0
    for i in C:
        if i <= A:
            l += 1
        elif i <= B:
            mid += 1
        else:
            r += 1
    print(min(l, min(mid, r)))

Measured memory_bytes: 3064
//k_k_dubey_
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
#define inf 999999999999
#define mx 200005
#define gcd __gcd
#define pb push_back
#define mk make_pair
#define bs binary_search
#define ub upper_bound
#define lb lower_bound
#define endl "\n"
#define vl vector<ll>
#define vs vector<string>
#define non __builtin_popcount
#define ml map<ll, ll> 
#define ms map<string , ll> 
using namespace std;

bool isp[mx];

void sv(){

	ll i,j;
	memset(isp, true, sizeof(isp));
	
	isp[1]= false;
	for(i=2;i*i<mx;i++){
		if(isp[i]){
			for(j=i*i;j<mx;j+=i)
			isp[j]= false;
		}
	}
}

ll powr(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1)res=(res*a)%mod;
		a=(a*a)%mod;
		b>>=1;
	}
	return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	//sv();
	
	ll n,i,j,d[mx];
	cin>>n;
	map<ll, ll> mp;
	for(i=0; i< n; i++)
	{
	    cin>>d[i];
	    mp[d[i]]++;
	}
	
	auto it = mp.begin();
	ll tmp=0;
	while(it!= mp.end()){
	    tmp += (it->second);
	    if(tmp== n/2)
	    break;
	    it++;
	}
	ll ans;
	if(it== mp.end())
	ans= 0;
	else{
	    ll k1= it->first;
	    it++;
	    ll k2= it->first;
	    ans= k2- k1;
	}
	
	cout<<ans;
	
    return 0;
}























Measured memory_bytes: 4992
#include<iostream>
#include <bits/stdc++.h>
#include<vector>
#include<cstdlib>

using namespace std;

int main(){
  int a,b,c,cnt=0;
  int x[3];
  int y[101]={};
  cin>>x[0]>>x[1]>>x[2];
  for(int i=0;i<3;i++){
      if(y[x[i]]!=0)cnt++;
      y[x[i]]++;
  }
  cout<<3-cnt<<endl;
  return 0;
  }


Measured memory_bytes: 256
fn main() {
    loop {
        match read_n_x() {
            (0, 0) => break,
            (n, x) => println!("{}", how_many_ways(n, x)),
        }
    }
}

fn read_n_x() -> (usize, usize) {
    let handle = std::io::stdin();
    let mut n_x = String::new();
    handle.read_line(&mut n_x).unwrap();
    let info: Vec<usize> = n_x
        .split_whitespace().map(|a| a.parse().unwrap()).collect();
    (info[0], info[1])
}

fn how_many_ways(n: usize, x: usize) -> usize {
    let mut count = 0;
    for i in 1..n-1 {
        for j in i+1..n {
            for k in j+1..n+1 {
                if i+j+k == x {
                    count += 1;
                    break;
                }
            }
        }
    }
    count
}


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

# 1 "<stdin>"
# 1 "<built-in>"
# 1 "<command-line>"
# 31 "<command-line>"
# 1 "/usr/include/stdc-predef.h" 1 3 4
# 32 "<command-line>" 2
# 1 "<stdin>"

using namespace std;

# 1 "../IO/io.h" 1
inline int readInt() {
    int v;
    int r = scanf("%d", &v);
    return v;
}

inline long long readLong() {
    long long v;
    int r = scanf("%lld", &v);
    return v;
}

inline vector<int> readVecInt(int n) {
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        a[i] = readInt();
    }
    return a;
}


inline void printLine(int v) {
    printf("%d\n", v);
}

inline void printLine(long long v) {
    printf("%lld\n", v);
}

inline void printLine(const vector<int> &a) {
    for (int v: a) {
        printf("%d ", v);
    }
    printf("\n");
}

inline void printLine(const string &s) {
    printf("%s\n", s.c_str());
}
# 5 "<stdin>" 2

int main() {
    int n = readInt();
    vector<int> a(n+1);
    for (int x = 1; x < 100; x++) {
        for (int y = 1; y < 100; y++) {
            for (int z = 1; z < 100; z++) {
                int v = x*x + y*y + z*z + x*y + y*z + z*x;
                if (v <= n) {
                    a[v]++;
                }
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        printLine(a[i]);
    }
}


Measured memory_bytes: 3748
//region Template
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = max(lhs, rhs.val); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = min(lhs, rhs.val); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion

signed main() {
    FASTIO

    int n; cin>>n;
    FOR(i,n)
    cout<<"ACL";
    cout<<endl;

}

Measured memory_bytes: 3672
#include<iostream>
#include<queue>
using namespace std;
class state {
public:
	int c[12][12];
	int time;
};
int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};
int X, Y;
void DFS(state& copy,int x,int y,int oldcolor,int newcolor) {
	if (copy.c[x][y] != oldcolor)
		return;
	else{
		copy.c[x][y] = newcolor;
	}
	for (int i = 0; i < 4; i++) {
		DFS(copy, x + dx[i], y + dy[i], oldcolor,newcolor);
	}
	return;
}
int main() {
	while (true) {
		bool breakflg = false;
		state num;
		cin >> X >> Y;
		if (X == 0 && Y == 0)
			break;
		for (int x = 0; x < 12; x++) {
			for (int y = 0; y < 12; y++) {
				num.c[x][y] == -1;
			}
		}
		for (int y = 1; y <= Y; y++) {
			for (int x = 1; x <= X; x++) {
				char data;
				cin >> data;
				if (data == 'R')
					num.c[x][y] = 1;
				else if (data == 'G')
					num.c[x][y] = 2;
				else if (data == 'B')
					num.c[x][y] = 3;
			}
		}
		num.time = 0;
		queue<state> q;
		q.push(num);
		bool flg1 = true;
		for (int y = 1; y <= Y; y++) {
			for (int x = 1; x <= X; x++) {
				if (num.c[1][1] != num.c[x][y]) {
					flg1 = false;
					break;
				}
			}
			if (!flg1)break;
		}
		if (flg1) {
			cout << num.time << endl;
			continue;
		}
		while (true) {
			state tmp;
			tmp = q.front();
			q.pop();
			for (int i = 1; i <= 3; i++) {
				bool flg = true;
				state copy = tmp;
				if (i == copy.c[1][1])continue;
				else {
					DFS(copy, 1, 1, copy.c[1][1], i);
					copy.time++;
					for (int y = 1; y <= Y; y++) {
						for (int x = 1; x <= X; x++) {
							if (copy.c[1][1] != copy.c[x][y]) {
								flg = false;
								break;
							}
						}
						if (!flg)break;
					}
					if (flg) {
						cout << copy.time << endl;
						breakflg = true;
						break;
					}
					q.push(copy);
				}
			}
			if (breakflg)
				break;
		}
	}
	return 0;
}


Measured memory_bytes: 73880
#include<iostream>
#include<algorithm>
using namespace std;
int S, N, U, M, V, D;//?????????HP, ?????¬???????????°?????°, ?????\??????????????°, ?????????????????°, ?????\????????????????????????
int e[200], c[200], h[200], a[200];
int dp[200][200][600], dp2[100000], dp3[600], dp4[200][200];
int main() {
	cin >> S >> N >> U >> M >> V >> D;
	for (int i = 0; i < N; i++)cin >> e[i] >> c[i];
	for (int i = 0; i < M; i++)cin >> h[i] >> a[i];
	for (int i = 0; i < 200; i++) { for (int j = 0; j < 200; j++) { for (int k = 0; k < 200; k++) { dp[i][j][k] = -999999999; } } }
	dp[0][0][0] = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < 600; k++) {
				if (dp[i][j][k] < 0 || k + e[i] >= 600)continue;
				dp[i + 1][j + 1][k + e[i]] = max(dp[i + 1][j + 1][k + e[i]], dp[i][j][k] + c[i]);
				dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);
			}
		}
	}
	for (int i = 0; i < 600; i++)dp3[i] = dp[N][U][i];
	for (int i = 1; i < 600; i++)dp3[i] = max(dp3[i], dp3[i - 1]);
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 100000; j++) {
			if (j + a[i] >= 100000)continue;
			dp2[j + a[i]] = max(dp2[j + a[i]], dp2[j] + h[i]);
		}
	}
	for (int i = 0; i < 200; i++) { for (int j = 0; j < 200; j++)dp4[i][j] = -999999999; }
	dp4[0][S] = 0;
	for (int i = 0; i < D; i++) {
		for (int j = 0; j <= S; j++) {
			for (int k = 0; k <= j; k++) {
				if (dp3[k] < 0)continue;
				int HP = min(S, j - k + V);
				dp4[i + 1][HP] = max(dp4[i + 1][HP], dp4[i][j] + dp2[dp3[k]]);
			}
		}
	}
	int maxn = -999999999; for (int i = 0; i <= S; i++)maxn = max(maxn, dp4[D][i]);
	if (maxn < 0)maxn = -1;
	cout << maxn << endl;
	return 0;
}

Measured memory_bytes: 97432
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
from fractions import gcd
import sys
def input(): return sys.stdin.readline().rstrip()
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')
# ----------------------------------------------------------- #

a, b = Is()
ans = 0
if a > b:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1
if a > b:
    ans += a
    a -= 1
else:
    ans += b
    b -= 1
print(ans)

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

#define int long long
#define pb push_back 
#define pf push_front 
#define mp make_pair
#define fr first
#define sc second
#define Rep(i,n) for(int i=0;i<(n);i++)
#define All(v) v.begin(),v.end()

typedef pair<int, int> Pii; typedef pair<int, Pii> Pip;
const int INF = 1107110711071107;


signed main()
{
  int h, w;
  while ( cin >> h >> w, h | w ) {
    int mi = INF, mi_h = INF;
    for ( int i = 1; i < 150; i++ ) {
      for ( int j = i + 1; j < 151; j++ ) {
	if ( i*i + j*j > h*h + w*w || ( i*i + j*j == h*h + w*w && i > h ) ) {
	  if ( i*i + j*j < mi ) {
	    mi = i*i + j*j;
	    mi_h = i;
	  }
	  if ( i*i + j*j == mi && i < mi_h ) {
	    mi = i*i + j*j;
	    mi_h = i;
	  }
	}
      }
    }

    cout << mi_h << " " << sqrt(mi - (mi_h*mi_h)) << endl;
  }
}

Measured memory_bytes: 3276
#dp[i]denotes who will win if i stones left
l=input().split()
n=int(l[0])
k=int(l[1])
l=input().split()
li=[int(i) for i in l]
hashi=dict()
for i in li:
	hashi[i]=1
m=min(li)
dp=[0 for i in range(k+1)]
dp[0]=2
for i in range(1,k+1):
	if(i<m):
		dp[i]=2
	done=0
	for j in hashi:
		if(i>=j and dp[i-j]==2):
			done=1
			break
	dp[i]=2-done
if(dp[k]==1):
	print("First")
else:
	print("Second")


Measured memory_bytes: 45040
N = int(input())
a = [int(input()) for i in range(N)]

on, ans, flg = 0, 0, 0

for i in range(N):
    now = a[on]-1
    ans += 1
    if now == 1:
        flg = 1
        break
    else:
        on = now

if flg == 1:
    print(ans)
else:
    print(-1)

Measured memory_bytes: 7084
N,K = map(int,input().split())
V = list(map(int,input().split()))
W = [0]*N
aplus = [0]
bplus = [0]
anslist = []
for i in range(min(N,K)):
    aplus.append(aplus[i]+V[i])
    bplus.append(bplus[i]+V[N-i-1])
for i in range(min(N+1,K+1)):
    minuslist = []
    for l in range(i+1):
        if (l > 0)&(V[l-1] < 0):
            minuslist.append(V[l-1])
    for j in range(min(N-i+1,K+1)):
        if i + j > K:
            break
        if (j > 0)&(V[-j] < 0):
            minuslist.append(V[-j])
        minuslist.sort()
        if K-i-j > len(minuslist):
            anslist.append(aplus[i]+bplus[j]-sum(minuslist))
        else:
            minus = 0
            anslist.append(aplus[i]+bplus[j])
            for k in range(K-i-j):
                minus += minuslist[k]
                anslist.append(aplus[i]+bplus[j]-minus)
print(max(anslist))

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

using namespace std;

double k(int xi,int yi,int xj,int yj){
	double re;
	re = sqrt((xi-xj)*(xi-xj) + (yi-yj)*(yi-yj));
	return re;
}

int main(void){
	int N;
	cin >> N;
	int x[N],y[N];
	int i,j;
	for(i = 0; i < N;i++){
		cin >> x[i];
		cin >> y[i];
	}
	double kyori[N*N];
	int w = 0;
	for(i = 0; i < N-1; i++){
		for(j = i+1; j < N; j++){
			kyori[w] = k(x[i],y[i],x[j],y[j]);
			w++;
		}
	}
	double ans = 0.0;
	for(i = 0; i < w;i++){
		ans += kyori[i];
	}
	ans = ans / w;
	ans = ans * (N-1);
	//cout << "w = "<<w<<"  N = "<<N<<endl;
	printf("%lf",ans);
	
	
	return 0;
}






Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <queue>
#include <string>
#include <vector>
#include <math.h>

using namespace std;

#define INF 210000000
#define int long long

static long long gcd(long long a, long long b) {
  int amari = a % b;
  int c = b;
  if (amari == 0) {
    return b;
  } else {
    return gcd(b, amari);
  }
}

static long long lcm(long long a, long long b) { return a * b / gcd(a, b); }

signed main() {
    int n;
    cin >> n;
    vector<int> w;
    int sum = 0;
    for(int i=0;i<n;i++){
        int tmp;
        cin >> tmp;
        w.push_back(tmp);
        sum += tmp;
    }
    int ans = INF;
    for(int i=1;i<w.size();i++){
        int tmp = 0;
        for(int j=0;j<i;j++){
            tmp += w[j];
        }
        if (abs(sum - tmp * 2) < ans ){
            ans = abs(sum - tmp * 2);
        }
    }
    cout << ans;
}


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

#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<vector<int> > f(n, vector<int>(10));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
        }
    }
    vector<vector<ll> > p(n, vector<ll>(11));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }

    ll ans = -(1 << 30);
    for(int bit = 1; bit < (1 << 10); bit++){
        int cc = 0;
        for(int i = 0; i < n; i++){
            int c = 0;
            for(int j = 0; j < 10; j++){
                if(bit & (1 << j) && f[i][j]) c++;
            }
            cc += p[i][c];
        }
        if(ans < cc) ans = cc;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, W;
	cin >> N >> W;
	int w[100000], v[100000];
	rep(i, N) cin >> w[i] >> v[i];

	ll dp[101][100001] = {};
	rep(i, N + 1) rep(j, 100001) dp[i][j] = 1e18;

	rep(i, N) {
		dp[i + 1][v[i]] = w[i];
		rep1(j, 100000) {
			if (dp[i][j] != (long long)1e18) {
				dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
				dp[i + 1][j + v[i]] = min(dp[i + 1][j + v[i]], dp[i][j] + w[i]);
			}
		}
	}

	ll kotae = 0;
	rep1(i, 100000) {
		if (dp[N][i] <= W) {
			kotae = i;
		}
	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 79872
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}

int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    ll a,b;cin>>a>>b;
    ll c=gcd(a,b);
    cout<<(a*b)/c<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<bitset>
#define lson node<<1,st,mid
#define rson node<<1|1,mid+1,ed
#define mem(a,x) memset(a,x,sizeof(a))
#define me(a) memset(a,0,sizeof(a))
#define IOS ios::sync_with_stdio(false)
#define lowbit(x) x&(-x)
#define up(i,x,y) for(long long i=x;i<y;i++)
#define down(i,x,y) for(long long i=x;i>=y;i--)
#define in freopen("in.txt","r",stdin)
#define out freopen("out.txt","w",stdout)   
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9+7;
const ll inf = 0x3f3f3f3f;
const ll maxn = 1e6 + 5;
const ll N=1e3+5;
const double pi = acos(-1.0);
const double eps=1e-9;
using namespace std;


int main(){
   ll d,t,s;
   cin>>d>>t>>s;
   if(t*s>=d) cout<<"Yes"<<endl;
   else cout<<"No"<<endl;
}

Measured memory_bytes: 3652
N = list(map(int,list(input())))
K = int(input())
L = len(N)
dp1 = [[0 for i in range(K+1)] for j in range(L+1)]
dp2 = [[0 for i in range(K+1)] for j in range(L+1)]
dp1[0][0] = 1

for i in range(L):
    for j in range(K+1):
        if N[i] == 0:
            dp1[i+1][j] += dp1[i][j]
        else:
            dp2[i+1][j] += dp1[i][j]
            if j > 0:
                dp1[i+1][j] += dp1[i][j-1]
                dp2[i+1][j] += dp1[i][j-1] * (N[i] - 1)
        if j > 0:
            dp2[i+1][j] += dp2[i][j-1] * 9
        dp2[i+1][j] += dp2[i][j]

ans = dp1[L][K] + dp2[L][K]

print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>
#include<queue>


#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000001
using namespace std;
typedef long long ll;

int w,h;
int c[51][51];

void dfs(int y,int x){
  if(y<1||51<=y||x<1||51<=x||c[y][x]==0)return;
  c[y][x]=0;
  dfs(y-1, x-1);
  dfs(y-1, x);
  dfs(y-1, x+1);
  dfs(y, x-1);
  dfs(y, x+1);
  dfs(y+1, x-1);
  dfs(y+1, x);
  dfs(y+1, x+1);
}

int main(){
  while(true){
    std::cin >> w>>h;
    if(w==0&&h==0)break;
    rep(i,1,h+1){
      rep(j,1,w+1){
        std::cin >> c[i][j];
      }
    }
    int res=0;
    rep(i,1,h+1){
      rep(j,1,w+1){
        // std::cout << c[1][1] << '\n';
        if(c[i][j]==1){
          // std::cout << "/* message */" << '\n';
          dfs(i,j);
          res++;
        }
      }
    }
    std::cout << res << '\n';
  }
  return 0;
}



Measured memory_bytes: 3212
#include<iostream>
#include<cstdlib>
#include<string>
#include<map>
#include<algorithm>
#include<vector>
#include<cmath>
#include<iomanip>
#define rep(i,n) for(int i(0);i<n;i++)

using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> l;
    rep(i,n){
        int len;
        cin >> len;
        l.push_back(len);
    } 

    sort(l.begin(),l.end());
    
    int ans(0);
    for(int i(0);i<n-2;i++){
        for(int j(i+1);j<n-1;j++){
            for(int k(j+1);k<n;k++){
                if(l[i] + l[j] <= l[k]) break;
                else if(l[i] < l[j] + l[k] && l[j] < l[i] + l[k]) ans += 1;
            }
        }
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define speed ios::sync_with_stdio(false)
#define pb push_back
#define mp make_pair
#define precision(x,d) cout<<fixed<<setprecision(d)<<x
#define all(x) (x).begin(), (x).end()
#define uint usigned int
typedef vector <ll> vi;
ll mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n,m,k,x,i,y,j,z,ans=0,sum=0,c=0;
	string s;
	cin>>s;
	for(i=0;i<s.length();i++){
	    
	    if(s[i]=='A' ||s[i]=='T' ||s[i]=='C' ||s[i]=='G'){
	        ans++;
	    }
	    else{
	        sum=max(ans,sum);
	        ans=0;
	        
	    }
	}
	sum=max(ans,sum);
	cout<<sum;
    return 0; 
}

Measured memory_bytes: 256