akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

const int N_MAX = 2e5+10;
const int n_MAX = 18;
string s;
int N;
vector<int>v(N_MAX);
int dp[n_MAX][N_MAX];

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> s;
  N = s.length();
  int n_2 = 1;
  int n = 0;
  while(n_2 < N){
    n_2*=2;
    ++n;
  }
  rep(j,N) dp[0][j] = (s[j] == 'R') ? j+1 : j-1;
  rep(i,n) rep(j,N) dp[i+1][j] = dp[i][dp[i][j]];

  rep(i,N) ++v[dp[n][i]];
  rep(i,N) cout << v[i] SPF;
  cout << endl;
  return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

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

    ll N = SZ(S);
    string T;
    REP(i,0,N) {
        if(S[i] != 'x') T.pb(S[i]);
    }

    bool f = true;
    REP(i,0,SZ(T)) {
        if(T[i] != T[SZ(T)-i-1]) f = false;
    }

    if(f) {
        S = "*" + S + "*"; 
        ll L = (SZ(T) + 1) / 2, R = (SZ(T) + 1) / 2;
        ll left = 0, right = N+1;
        while(L > 0) {
            ++left;
            if(S[left] != 'x') --L;
        }
        while(R > 0) {
            --right;
            if(S[right] != 'x') --R;
        }

        ll cnt = 0;
        while(left >= 1 && right <= N) {
            ll cl = 0, cr = 0;
            --left;
            ++right;
            while(S[left] == 'x') {
                ++cl;
                --left;
            }
            while(S[right] == 'x') {
                ++cr;
                ++right;
            }
            cnt += abs(cl - cr);
        }
        PR(cnt);
    }
    else PR(-1);

    return 0;
}

/*



*/

Measured memory_bytes: 3780
#include<bits/stdc++.h>
#define ll long long
#define mps make_pair
#define F first
#define S second
using namespace std;
const int N=200005;
int a[N],sum[N],eq[N];
map<int,int> cnt;
int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=1;i<=n;i++)
        cin>>a[i];
    for(int i=1;i<=n;i++)
        sum[i]=(sum[i-1]+a[i])%k;
    for(int i=1;i<=n;i++)
    {
        int x=sum[i]-i;
        if(x<0)
        {
            int y=abs(x/k);
            x+=k*(y+1);
        }
        if(x>=k)
            x%=k;
        eq[i]=x;
    }
    ll ans=0;
    for(int i=0;i<=n;i++)
    {
        if(i-k>=0)
            cnt[eq[i-k]]--;
        ans+=cnt[eq[i]];
        cnt[eq[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11904
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(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 pi M_PI

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int main(){
    VI a(3);
    REP(i,3) cin >> a[i];
    sort(a.begin(),a.end());
    string ans;
    if (a[0] == 5 && a[1] == 5 && a[2] == 7) ans = "YES";
    else ans = "NO";
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys, os, math, bisect, itertools, collections, heapq, queue
# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
from decimal import Decimal
from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, M = il()
    X = sorted(il())

    cnt = []
    for n in range(M - 1):
        cnt.append(abs(X[n] - X[n + 1]))
    cnt = sorted(cnt, reverse=True)
    print(sum(cnt[N-1:]))


if __name__ == '__main__':
    main()


Measured memory_bytes: 19876
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100000+10;

int n,a[maxn];
int flag;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  a[0]=0;flag=1;
  for(int i=1;i<=n;i++){
    if (a[i]-1>=a[i-1]) a[i]--;
    if (a[i-1]>a[i]){
      flag=0;break;
    }
  }
  if (flag==1) printf("Yes");
  else printf("No");
}


Measured memory_bytes: 640
#include<stdio.h>
#include<stdlib.h>
#include<math.h>

int main(void){
  int a[5];
  //  char c;

  for(int i=0;i<5;i++){
    scanf("%d ",&a[i]);
  }
  for(int i=0;i<5;i++){
    if(a[i] == 0){
      printf("%d",i+1);
      return 0;
    }
  }
  
  return 0;


}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

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;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    string o, e; cin >> o >> e;
    string s = "";
    rep(i, min(o.size(), e.size())) {
        s += o[i];
        s += e[i];
    }
    if (o.size() != e.size()) {
        s += o[(int)o.size() - 1];
    }
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 256
a, v = map(int, input().split())
b, w = map(int, input().split())
t = int(input())

if (b >= a):
  aa=a+v*t
  bb=b+w*t
  if (bb-aa >0):
    print ('NO')
  else:
    print ('YES')
else:
  aa=a-v*t
  bb=b-w*t
  if (bb-aa <0):
    print ('NO')
  else:
    print ('YES')

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

int main(){
    string s;
    cin >> s;
    int64_t total_sum = 0;

    // 2^(入力文字数の-1)だけ"+"が入る可能性がある
    // ex.) 111 なら  1 <+ or 無> 1 <+ or 無> 1
    for (int i = 0; i < 1 << (s.length() - 1); i++){

        // 式を作成する
        bitset<9> bs(i);
        string f = {s.at(0)};
        for (int j = 0; j < (s.length() - 1); j++){
            if (bs.test(j)){
                f.push_back('+');
            }
            f.push_back(s.at(j+1));
        }

        // 式の合計値を計算
        int64_t sum = 0;
        string tmp = "";
        for (int j = 0; j < f.length(); j++){
            if (f.at(j) == '+'){
                sum += stoll(tmp);
                tmp = "";
            }
            else
            {
                tmp.push_back(f.at(j));
            }
        }
        sum += stoll(tmp);

        // トータルに加算
        total_sum += sum;
    }
    cout << total_sum << endl;
}

Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    vector<int> cnt(100, 0);
    int num = a;
    while(true){
        if(num % b == c){
            cout << "YES" << endl;
            break;
        }
        else if(cnt[num % b] == 0){
            cnt[num % b]++;
        }
        else {
            cout << "NO" << endl;
            break;
        }
        num += a;
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <vector>
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <functional>
#include <queue>

using namespace std;

void Show(vector<vector<bool>> S) {
	for (int i = 0; i < S.size(); i++) {
		for (int j = 0; j < S[i].size(); j++) {
			if ((S[i][j])) {
				cout << '.';
			} else {
				cout << '#';
			}
		}
		cout << endl;
	}
}
int main() {
	int A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;
	int All_C = max(X, Y)*C * 2;
	int With_C = min(X, Y)*C * 2;
	With_C += (X > Y) ? (X - Y)*A : (Y - X)*B;
	int Palarell = A * X + B * Y;
	int Min = min(min(All_C, With_C), Palarell);
	cout << Min << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<algorithm>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<iomanip>
#define pb push_back
#define ff first
#define ss second
using namespace std;

int main(){
    long double n,k;
    cin>>n>>k;
    long double sum =0;
    long double c = 1/n;
    for(int i=1;i<=n;i++){
        long double d = i;
        int cnt =0;
        while(d<k){
            d = d*2;
            cnt++;
        }
        long double r = pow(0.5,cnt);
        sum += c*r;
    }
    cout<<fixed;
    cout<<setprecision(12)<<sum<<endl;
}

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

long n,m;long parent[100005];long size[100005];

struct Node{
  long from,to;
};

long getparent(long id) {
  if (parent[id]==id) return id;
  else {
    return getparent(parent[id]);
  }
}

bool issame(long a,long b) {
  return getparent(a)==getparent(b);
}

void unite(long a,long b) {
  long parent_a=getparent(a);
  long parent_b=getparent(b);
  if (parent_a==parent_b) return;
  else {
    if (size[parent_a]<size[parent_b]) {
      parent[parent_a]=parent_b;
      size[parent_b]+=size[parent_a];size[parent_a]=0L;
    }
    else {
      parent[parent_b]=parent_a;
      size[parent_a]+=size[parent_b];size[parent_b]=0L;
    }
  }
}

long getsize(long a) {
  long parent_a=getparent(a);
  return size[parent_a];
}

int main() {
  cin >> n >> m;
  Node nodes[m];long count[m];count[m-1]=0L;
  for (int i=0;i<m;i++) {
    cin >> nodes[i].from >> nodes[i].to;
  }
  for (int i=0;i<n;i++) {
    parent[i]=i;
    size[i]=1L;
  }
  for (int i=m-1;i>0;i--) {
    if (issame(nodes[i].from,nodes[i].to)) {
      count[i-1]=count[i];
    }
    else {
      count[i-1]=count[i]+getsize(nodes[i].from)*getsize(nodes[i].to);
      unite(nodes[i].from,nodes[i].to);
    }
  }
  long base=n*(n-1L)/2L;
  for (int i=0;i<m;i++) {
    cout << base-count[i] << endl;
  }
}

Measured memory_bytes: 5248
#include<iostream>
#include<string>
#include<vector>

using namespace std;

#define MOD 1000000007

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}
int main() {
	int n, m;
	cin >> n >> m;
	vector<long long> a(n);
	vector<long long> b(m);
	cin >> a >> b;
	long long asu = 0, bsu = 0;
	for (int i = 0; i < n; i++)
	{
		asu -= a[i] * (n - i - 1);
		asu += a[i] * i;
	}
	for (int i = 0; i < m; i++)
	{
		bsu -= b[i] * (m - i - 1);
		bsu += b[i] * i;
	}
	long long u = ((asu%MOD)*(bsu%MOD)) % MOD;
	cout << u << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;

#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

#define ll long long
#define ld long double
#define pb push_back
#define eb(a) emplace_back(a)

#define xx first
#define yy second
#define mp make_pair
#define pll pair<ll,ll>
#define mll map<ll,ll>
#define vll vector<ll>
#define pdd pair<double,double>
#define ALL(v) (v).begin(), (v).end()

const ll MOD=1e9+7; ;
const ll inf=1e18;

#define MODSET(d) if ((d) >= MOD) d %= MOD;
#define MODNEGSET(d) if ((d) < 0) d = ((d % MOD) + MOD) % MOD;
#define put(x) cout<<#x<<" = "<<x<<endl;

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

ll power(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a);
        n>>=1;
        a=(a*a);
    }
    return ans;
}


ll powerMod(ll a,ll n){
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%MOD;
        n/=2;
        a=(a*a)%MOD;
    }
    return ans;
}

ll powerMod1(ll a,ll n,ll mod){
	a = a%mod;
    ll ans=1;
    while(n){
        if(n&1)
            ans=(ans*a)%mod;
        n>>=1;
        a=(a*a)%mod;
    }
    return ans;
}

ll lcm(ll a,ll b){
    return a*(b/__gcd(a,b));
}

ll sumdigit(ll n){
    ll sum=0;
    while(n){
        sum+=n%10;
        n=n/10;
    }
    return sum;
}

ll countSetBit(ll a){
    return __builtin_popcount(a);
}
ll countBit(ll a){
    ll sum=0;
    while(a){
        sum++;
        a>>=1;
    }
    return sum;
}

ll length(ll a){
    ll ans=0;
    while(a){
        ans++;
        a=a/10;
    }
    return ans;
}

bool isVowel(char c){
	if(c=='a' or c=='e' or c=='i' or c=='o' or c=='u')
		return true;
	return false;
}
template <typename T>
void max_self(T &a, T b ){
	a = max(a, b);
}

int main()
{
    fast;
    int t;
    //~ cin>>t;
    t=1;
    
    while(t--){
			ll a,b;
			cin>>a>>b;
			cout<<((a*(a-1))/2)+(b*(b-1))/2;
    }
    return 0;
}


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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

struct Combination
{
    void init(ll n)
    {
        mNumTbl.resize(n + 1);
        mInverseNumTbl.resize(n + 1);
        mNumTbl[0] = 1;
        mInverseNumTbl[0] = 1;
        FOR(i, n + 1, 1)
        {
            mNumTbl[i] = (mNumTbl[i - 1] * i) % MOD;
        }
        FOR(i, n + 1, 1)
        {
            mInverseNumTbl[i] = modpow(mNumTbl[i]);
        }
    }

    ll get(ll n, ll r)
    {
        if (n < r || n < 0)
            return 0;
        return (((mNumTbl[n] * mInverseNumTbl[r]) % MOD) * mInverseNumTbl[n - r]) % MOD;
    }

    //! バイナリ方で累乗を計算
    ll modpow(ll n)
    {
        ll s = 1, p = n;
        for (ll i = 0; (1LL << i) <= MOD - 2; ++i, p = (p * p) % MOD)
        {
            if (((MOD - 2) & (1 << i)) == 0)
                continue;
            s *= p;
            s %= MOD;
        }
        return s;
    }

    vector<ll> mInverseNumTbl;
    vector<ll> mNumTbl;
};

int main()
{
    ll N, M, K;
    cin >> N >> M >> K;
    ll D = N * M;
    Combination cmb;
    cmb.init(D + 5);
    ll T = cmb.get(D - 2, K - 2);
    ll ans = 0;
    REP(i, D)
    {
        ll x = i % M;
        ll y = i / M;
        ll rn = (M - x) * (M - x - 1) / 2;
        ll ln = x * (x + 1) / 2;
        ll n = N - y;
        ll s = (n * rn + (n - 1) * ln + n * (n - 1) * M / 2) % MOD;

        ans = (ans + s * T % MOD) % MOD;
    }
    cout << ans << endl;
    return 0;
}

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


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

	int n , k ; 
	cin >> n >> k  ;
	vector<int> a(n) ; 
	for(int i = 0; i < n ;++i)
		cin >> a[i]; 
	int lo = 1, hi = 1e10 ;
	while(lo < hi)
	{
	 	int mid = (lo +hi)/2 , r = 0 ; 
	 	for(int i = 0 ; i < n ; ++i)
	 	{
	 		r +=ceil((double)a[i]/mid) ; 
	 		
	 	}
	 	if(r <= n + k )
	 	{
	 		hi = mid ;	
	 	}
	 	else 
	 		lo = mid +1 ; 
	}
	cout << hi ; 
}


Measured memory_bytes: 4764
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M;
  cin>>N>>M;
  vector<long long> a(N),b(N),c(M),d(M),ans(N);
  for(int i=0;i<N;i++){
    cin>>a.at(i)>>b.at(i);
  }
  for(int i=0;i<M;i++){
    cin>>c.at(i)>>d.at(i);
  }
  for(int i=0;i<N;i++){
    long long min_dis1=max(a.at(i),c.at(0))-min(a.at(i),c.at(0))+max(b.at(i),d.at(0))-min(b.at(i),d.at(0));
    int cnt=0;                                                                                      
    for(int j=0;j<M;j++){
      long long x_max=max(a.at(i),c.at(j));
      long long y_max=max(b.at(i),d.at(j));
      long long x_min=min(a.at(i),c.at(j));
      long long y_min=min(b.at(i),d.at(j));
      long long min_dis2=x_max-x_min+y_max-y_min;
      if(min_dis2<min_dis1){
        min_dis1=min_dis2;
        ans.at(i)=j+1;
        cnt++;
      }
    }
    if(cnt!=0){                                                                                      
      cout<<ans.at(i)<<endl;
    }
     else{
       cout<<1<<endl;
     }                                                                                     
  }
  return 0;
}

Measured memory_bytes: 256
N = int(input())
X=[list(map(int,input().split())) for i in range(N)]
#print(X)
dp = [[0] * 3 for _ in range(N+1)]
for i in range(N):
  for j in range(3):
    for k in range(3):
      if j==k:
        continue
      dp[i + 1][j] = max(dp[i + 1][j], dp[i][k] + X[i][j])	
ans=0
for j in range(3):
  ans=max(ans,dp[N][j])
print(ans)

Measured memory_bytes: 47344
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        for (int i = 1; ; i++) {
            int x = sc.nextInt();
            if (x == 0) {
                break;
            }
            System.out.println("Case " + i + ": " + x);
        }
    }
}

Measured memory_bytes: 42900
//config = { input: 'tmp', newline: '\r\n' }; // win
config = { input: '/dev/stdin', newline: '\n' }; // linux

line = require('fs').readFileSync(config.input, 'ascii')
  .trim()
  .split(config.newline)
  .map(function (line) { return line.split(' ').map(Number); });

n = line[0][0];
m = line[0][1];
q = line[m+1][0];

adj = new Array(n);
for (i = 0; i < n; i++) adj[i] = {'list': [i, null], 'length': 1};

for (i = 1; i <= m; i++) {
  obj0 = adj[line[i][0]];
  obj1 = adj[line[i][1]];
  if (obj0 === obj1) continue;
  if (obj0.length <= obj1.length) {
    min = obj0;
    max = obj1;
  } else {
    min = obj1;
    max = obj0;
  }
  max.length += min.length;
  cur = min.list;
  while (cur[1] !== null) {
    adj[cur[0]] = max;
    cur = cur[1];
  }
  adj[cur[0]] = max;
  cur[1] = max.list;
  max.list = min.list;
  min.list = null;
  min.length = 0;
}

for (i = m+2; i < (m+2) + q; i++)
  console.log((adj[line[i][0]] === adj[line[i][1]]) ? 'yes' : 'no');

Measured memory_bytes: 69828
#include <bits/stdc++.h>
#define all(v) (v).begin(),(v).end()
using namespace std;
using LL = long long;
const int INF = 1e9;

LL divisor(LL n) {
    LL x = n-1;
    for (LL i = 1; i * i <= n; i++) {
        if (n % i == 0 && i != 1) {
            x = min(x, i + n/i -2);
        }
    }
    return x;
}

int main(void)
{
    LL N;
    cin >> N;
    LL x = divisor(N);
    cout << x << endl;
    return 0;
}



Measured memory_bytes: 256
-- https://github.com/minoki/my-atcoder-solutions
{-# LANGUAGE TypeApplications #-}
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE NumericUnderscores #-}
import Data.Char (isSpace)
import Data.List
import Control.Monad
import Control.Monad.Trans.Maybe
import Control.Monad.ST
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector.Unboxed.Mutable as UM
import qualified Data.ByteString.Char8 as BS
import qualified Test.QuickCheck as QC
import Data.Coerce

isPairwiseCoprime_naive :: Int -> U.Vector Int -> Bool
isPairwiseCoprime_naive _mbound xs = and [ gcd x y == 1 | x:ys <- tails (U.toList xs), y <- ys ]

toHistogram :: Int -> U.Vector Int -> U.Vector Int
toHistogram mbound xs = U.create $ do
  m <- UM.replicate (mbound + 1) (0 :: Int)
  U.forM_ xs $ \x -> do
    UM.modify m (+ 1) x
  return m

isPairwiseCoprime :: Int -> U.Vector Int -> Bool
isPairwiseCoprime !mbound !xs = maybe False (const True) $ runST $ runMaybeT $ do
  let !m = toHistogram mbound xs
  sieve <- UM.replicate (mbound + 1) True
  UM.write sieve 0 False
  UM.write sieve 1 False
  forM_ [2..mbound] $ \i -> do
    t <- UM.read sieve i
    when t $ do
      let loop !j !u | u >= 2 = mzero -- break
                     | j > mbound = return ()
                     | otherwise = do
                         UM.write sieve j False
                         loop (j + i) (u + m U.! j)
      loop (2 * i) (m U.! i)
  return () -- The answer is "Yes" (pairwise coprime)

isSetwiseCoprime_naive :: U.Vector Int -> Bool
isSetwiseCoprime_naive xs = U.foldl' gcd 0 xs == 1

isSetwiseCoprime :: U.Vector Int -> Bool
isSetwiseCoprime !xs = loop 0 0 == 1
  where
    loop !acc !i | i >= U.length xs = acc
                 | acc == 1 = acc
                 | otherwise = loop (gcd acc (xs U.! i)) (i + 1)

main = do
  n <- readLn @Int
  xs <- U.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine
  let mbound = U.maximum xs
  if isPairwiseCoprime mbound xs then
    putStrLn "pairwise coprime"
  else if isSetwiseCoprime xs then
    putStrLn "setwise coprime"
  else
    putStrLn "not coprime"

prop_isPairwiseCoprime :: QC.NonEmptyList (QC.Positive Int) -> QC.Property
prop_isPairwiseCoprime xs' =
  let xs = U.fromList (coerce xs') :: U.Vector Int
      mbound = U.maximum xs
  in isPairwiseCoprime mbound xs QC.=== isPairwiseCoprime_naive mbound xs

prop_isSetwiseCoprime :: QC.NonEmptyList (QC.Positive Int) -> QC.Property
prop_isSetwiseCoprime xs' =
  let xs = U.fromList (coerce xs') :: U.Vector Int
  in isSetwiseCoprime xs QC.=== isSetwiseCoprime_naive xs

runTests :: IO ()
runTests = do
  QC.quickCheck $ QC.withMaxSuccess 1000 $ QC.mapSize (* 1000) prop_isPairwiseCoprime
  QC.quickCheck $ QC.withMaxSuccess 1000 $ QC.mapSize (* 1000) prop_isSetwiseCoprime


Measured memory_bytes: 40556
#include <set>
#include <map>
#include <queue>
#include <cstdio>
#include <vector>
#include <string>
#include <iomanip>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <unordered_map>
using namespace std;

const int MOD = 1e9 + 7;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
#define fst first
#define snd second

template<class T>
void Max(T &x, T y) {
    if (x < y) x = y;
}

template<class T>
void Min(T &x, T y) {
    if (x > y) x = y;
}

ll gcd(ll a, ll b) {
    return !b ? a : gcd(b, a % b);
}

ll mod_pow(ll a, ll b, ll c) {
    ll ans = 1;
    while (b > 0) {
        if (b & 1) ans = ans * a % c;
        a = a * a % c;
        b >>= 1;
    }
    return ans;
}


int main(void) {

    ios::sync_with_stdio(false);

    string s;
    cin >> s;
    bool flag = false, ans = false;
    for (char ch: s) {
        if (ch == 'C') flag = true;
        else if (ch == 'F' && flag) {
            ans = true;
            break;
        }
    }
    if (ans) cout << "Yes\n";
    else cout << "No\n";

    return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int a[110];
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=0;i<k;i++){
		int d;
		scanf("%d",&d);
		while(d--){
			int t;
			scanf("%d",&t);
			if(!a[t]++)n--;
		}
	}
	printf("%d",n);
}

Measured memory_bytes: 1728
/**
  @date Time-stamp: <2019-05-14 22:43:39 tagashira>
  @file b.cpp
  @title B - ATCoder
  @brief https://atcoder.jp/contests/abc122/tasks/abc122_b
**/

#include <algorithm>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <sstream> // std::ostringstream
#include <string>
#include <vector>

using namespace std;

vector<string> split(string& str, char sep) {
  vector<string> v;
  stringstream ss(str);
  string buffer;
  while (std::getline(ss, buffer, sep)) {
    v.push_back(buffer);
  }
  return v;
}

int main(int argc, char* argv[]) {
  string S;
  cin >> S;

  string tmp = "";
  for (int i = 0; i < S.length(); i++) {
    if (S[i] == 'A' || S[i] == 'G' || S[i] == 'C' || S[i] == 'T') {
      tmp += "1";
    } else {
      tmp += "0";
    }
  }
  // cout << tmp << "\n"; //for debug

  string for_split = "";
  vector<int> res;

  for (int i = 0; i < tmp.length(); i++) {
    if (tmp[i] == '1') {
      for_split += "1";
    } else {
      for_split += ":";
    }
  }
  // cout << for_split << "\n"; //for debug

  vector<string> splited = split(for_split, ':');

  for (int i = 0; i < splited.size(); i++) {
    // cout << splited[i].size() << "\n"; //for debug
    res.push_back(splited[i].size());
  }

  cout << *max_element(res.begin(),res.end()) << "\n";

  return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            String type = sc.next();
            if (type.equals("S")) {
                a[i] = sc.nextInt() + 100;
            } else if (type.equals("H")) {
                a[i] = sc.nextInt() + 200;
            } else if (type.equals("C")) {
                a[i] = sc.nextInt() + 300;
            } else if (type.equals("D")) {
                a[i] = sc.nextInt() + 400;
            }
        }
        Arrays.sort(a);
        for (int i = 1, j = 0; i <= 52; i++) {
            if (i <= 13) { //spade
                if (n > j && a[j] == 100 + i) {
                    j++;
                } else {
                    System.out.println("S " + i);
                }
            } else if (i <= 26) { //heart
                if (n > j && a[j] == 200 + i - 13) {
                    j++;
                } else {
                    System.out.println("H " + (i - 13));
                }
            } else if (i <= 39) { //club
                if (n > j && a[j] == 300 + i - 26) {
                    j++;
                } else {
                    System.out.println("C " + (i - 26));
                }
            } else { //dia
                if (n > j && a[j] == 400 + i - 39) {
                    j++;
                } else {
                    System.out.println("D " + (i - 39));
                }
            }
        }
    }
}

Measured memory_bytes: 26252
/**
*	created: 29.09.2020 20:10:31
**/
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
// #define endl '\n'
#define int long long
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define rrep(i,n) for (int i = (int)(n - 1); i >= 0; i--)
#define rep2(i,s,n) for (int i = (s); i < (int)(n); i++)
#define len(x) ll(x.size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
using ll = long long;
using P = pair<int,int>;
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1ll << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;
template<typename T> inline bool chmax(T &a, T b) {if (a < b) {a = b; return 1;} return 0;}
template<typename T> inline bool chmin(T &a, T b) {if (b < a) {a = b; return 1;} return 0;}
inline void print(P a) {cout << a.first << " " << a.second << endl;}
template<typename T> T bpow(T a, ll n) {T r(1); while(n) {if (n & 1) r *= a; a *= a; n >>= 1;} return r;}
struct faster_io {faster_io() {cin.tie(0); ios_base::sync_with_stdio(false);}} faster_io_;

signed main() {
    int n, a, b; cin >> n >> a >> b;
    vector<int> v(n);
    rep(i,n) cin >> v[i];
    int st = v[0];
    sort(all(v));
    int l = v[0], r = v[n-1];
    vector<int> d(n-1);
    rep(i,n-1) d[i] = v[i+1] - v[i];
    // 1 -> 左端 -> 右端
    int sum1 = min((st-l) * a, b);
    rep(i,n-1) sum1 += min(a*d[i],b);
    // 1 -> 右端 -> 左端
    int sum2 = min((r-st) * a, b);
    rep(i,n-1) sum2 += min(a*d[i],b);
    cout << min(sum1,sum2) << endl;
    return 0;
}

Measured memory_bytes: 4756
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define pb push_back
#define f(i,n) for(int i=0; i<n; ++i)
#define fi(i,st,n) for(int i=st; i<=n; ++i)
#define veci vector<int>
#define vecp vector<pair<int,int> >
#define vecl vector<ll>
int prime[100000+10];

ll lcm(ll a, ll b) {
	return a*b/__gcd(a,b);
}

ll power(ll a, ll n, ll mod) {
	ll res = 1;
	while(n > 0) {
		if(n&1) {
			res = (res*a)%mod;
		}
		a = (a*a)%mod;
		n = n/2;
	}
	return res;
}

ll sum(int arr[], int n) {
	ll res = 0;
	f(i,n) {
		res += arr[i];
	}
	return res;
}

void seive() {
	prime[1] = 0;
	for(int i=2; i<=100000; i++) {
		prime[i] = 1;
	}
	for(ll i=2; i<=100000; i++) {
		if(prime[i]) {
			for(ll j=i*i; j<=100000; j+=i) {
				prime[j] = 0;
			}
		}
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int t = 1;
//	cin>>t;
	while(t--){
		int n;
		cin>>n;
		int sum[n],diff[n];
		f(i,n) {
			int a,b;
			cin>>a>>b;
			sum[i] = a+b;
			diff[i] = a-b;
		}
		sort(sum,sum+n);
		sort(diff,diff+n);
		cout<<max(sum[n-1]-sum[0],diff[n-1]-diff[0])<<"\n";
 	}
 	return 0;
}


Measured memory_bytes: 5212
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 1001001001;
//stoi(s) : string→int stoll(s) :string→longlong


int main(){
    int k;
    cin >> k;
    string s;
    cin >> s;
    int n = s.size();
    if(n<=k){
        cout << s << endl;
    }else{
        for(int i=0;i<k;i++){
            cout << s[i];
        }
        cout << "..."<< endl;
    }
}

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

bool check(char c){
    if(c=='0'||c=='1'||c=='2'||c=='3'||c=='4'||c=='5'||c=='6'||c=='7'||c=='8'||c=='9'){
        return true;
    }
    return false;
}


int main(){
    int a,b;
    string s;
    cin >> a >> b;
    cin >> s;

    for(int i=0;i<a;i++){
        bool x = check(s[i]);
        if(!x){
            cout << "No" << endl;
            return 0;
        }
    }

    if(s[a]!='-'){
        cout << "No" << endl;
        return 0;
    }

    for(int i=a+1;i<a+b+1;i++){
        bool x = check(s[i]);
        if(!x){
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}

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

using namespace std;

typedef long long ll;

const int INF = 1e9;

int main()
{
  char p[128] = { '\0' }, s[128] = { '\0' };
  fscanf(stdin, "%s", s);
  fscanf(stdin, "%s", p);
  string ss = string(s) + string(s), pp(p);
  string ans = "No";
  if (ss.find(p, 0) != string::npos) {
    ans = "Yes";
  }
  fprintf(stdout, "%s\n", ans.c_str());
  return 0;
}

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

int main() {
  int n;
  cin>>n;
  int a[n][2];
  for(int i=0;i<n;i++){
    int k,l;
    cin>>k>>l;
    a[i][0]=k;
    a[i][1]=l;
  }
  double ans=0;
  for(int i=0;i<n-1;i++){
    for(int j=i+1;j<n;j++){
      ans+=sqrt((a[i][0]-a[j][0])*(a[i][0]-a[j][0])+(a[i][1]-a[j][1])*(a[i][1]-a[j][1]));
    }
  }
  cout << fixed << setprecision(7);
  cout<<ans*2/n<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int
main(int argc, char *argv[])
{
  int n; char s[101];
  scanf("%d%s", &n, s);
  int cnt, max = 0; int ans;

  for(int i = 0; i < n - 1; i++){
    ans = 0;
    for(int j = 'a'; j <= 'z'; j++){
      cnt = 0;
      for(int k = 0; k <= i; k++){
	if(s[k] == j){
	  cnt++;
	  break;
	}
      }
      for(int k = i + 1; k < n; k++){
	if(s[k] == j){
	  cnt++;
	  break;
	}
      }
      if(cnt == 2) ans++;
    }
    max = (max > ans ? max : ans);
  }

  printf("%d\n", max);

  return 0;
}


Measured memory_bytes: 128
/* 
   AOJ ICPC
   1186
   
 */
#include<stdio.h>
#include<stdlib.h>

struct node
{
  int height, width, diagonal;
  struct node *next;
};

struct node *head = NULL;

int target_height, target_width;

void trav()
{
  struct node *point;

  for(point = head; point != NULL; point = point->next)
    {
      printf("h %d, w %d, d %d\n", point->height, point->width, point->diagonal);
    }
}

void insert(int width, int height)
{
  int diagonal = height * height + width * width;
  struct node *new = malloc(sizeof(*new)), *next = head, *prev = head;
  if(head == NULL)
    {
      head = new;
      new->height = height;
      new->width = width;
      new->diagonal = diagonal;
      new->next = NULL;
    }
  else
    {
      while(next != NULL && next->diagonal <= diagonal)
	{
	  if(next->diagonal == diagonal && next->height > height)
	    {
	      break;
	    }
	  prev = next;
	  next = next->next;
	}
      prev->next = new;
      new->height = height;
      new->width = width;
      new->diagonal = diagonal;
      new->next = next;
    }
}


void make_up_list(void)
{
  int i, j;
  for(i = 1; i <= 150; i++)
    {
      for(j = 1; j < i; j++)
	{
	  insert(i, j);
	}
    }
  //  trav();
}

void search_ans(int height, int width)
{
  int diagonal = height * height + width * width;
  struct node *point = head;

  while(1)
    {
      if(height == point->height && width == point->width)
	{
	  break;
	}
      point = point->next;
    }
  target_height = point->next->height;
  target_width = point->next->width;
}

int main(void)
{
  make_up_list();

  int height, width;

  while(1)
    {
      scanf("%d %d", &height, &width);
      if(height == 0 && width == 0)
  	{
  	  break;
  	}
      search_ans(height, width);
      printf("%d %d\n", target_height, target_width);
    }
  return 0;
}

Measured memory_bytes: 944
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a * b / gcd(a, b);
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}

int main() {
	int n; cin >> n;
	int sum = 0;
	int t;
	vector<int> v(n), c(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	for (int i = 0; i < n; i++) {
		cin >> c[i];
	}
	for (int i = 0; i < n; i++) {
		if (v[i] - c[i] > 0) sum += v[i] - c[i];
	}
	cout << sum;


	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
const int N=2e5+2;
string s,p;

int main()
{
    ft
    int t,i,j,n,m,l,r;
    double in,d;
    cin>>in;
    d=in/3;
    cout<<fixed<<setprecision(12)<<(d*d*d)<<"\n";
    return 0;
}



Measured memory_bytes: 256
// garnab27
#include <bits/stdc++.h>
#define MP make_pair
#define PB push_back
#define ll int64_t
#define F first
#define S second
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
using namespace std;
ll modex(ll a,ll b,ll p){ll res=1;a%=p;while(b>0){if(b&1)res=(res*a)%p;a=(a*a)%p;b>>=1;}return res;}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
 
 
int main(){
	ios::sync_with_stdio(0);
	cin.tie(NULL);cout.tie(NULL);	
 
	int n,m;
	cin>>n>>m;

	int s=0;
	for(int i=0;i<m;i++) {
		int a;
		cin>>a;
		s+=a;
	}

	cout<<max(-1, n-s);
 
 
	return 0;
}

Measured memory_bytes: 3652
#include<iostream>
#include<string>
using namespace std;
int main(void){
    string a;
    
    string s="Sunny";
        
    string c="Cloudy";
    string r="Rainy";
    cin>>a;
    if(a==s){
        cout<<"Cloudy"<<endl;
    }else if(a==c){
        cout<<"Rainy"<<endl;
    }else if(a==r){
        cout<<"Sunny"<<endl;
    }else{}

   

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <list>
#include <queue>
using namespace std;

int inf = (1 << 30);
int mod = 1e9 + 7;
int64_t inf64 = (1LL << 60);

template <typename T>
T gcd(T a, T b) {
    if(b == 0) return a;
    else return gcd(b, a % b);
}

template <typename T>
T lcm(T a, T b) {
    T g = gcd(a, b);
    return a / g * b;
}

bool check(vector<int> a, int index, int key){
    if(a[index] >= key) return true;
    else return false;
}

int lower_bound(vector<int> a, int key){
    int left = -1, right = a.size();
    while(right - left > 1){
        int mid = left + (left + right) / 2;
        if(check(a, mid, key)) right = mid;
        else left = mid;
    }
    return right;
}

int main(){

    int W, a, b;
    cin >> W >> a >> b;

    if(a + W < b){
        cout << b - (a + W) << endl;
    }else if(b + W < a){
        cout << a - (b + W) << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys


def solve(A: int, B: int):
    if A == B:
        ret = A + B
    else:
        ret = max(A, B) * 2 - 1
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
def main():
    A, B = map(int, input().split())

    def prime_factorize(n):
        arr = []
        temp = n
        for i in range(2, int(-(-(n ** 0.5) // 1)) + 1):
            if temp % i == 0:
                cnt = 0
                while temp % i == 0:
                    cnt += 1
                    temp //= i
                arr.append([i, cnt])

        if temp != 1:
            arr.append([temp, 1])

        arr.append([1, 1])

        return arr

    a = prime_factorize(A)
    set_a = set(i for i, j in a)
    b = prime_factorize(B)
    set_b = set(i for i, j in b)

    ans = len(set_a & set_b)
    print(ans)



if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

int main()
{
	int n,m;
	int check[100000];
	int count=0;
  	int wa[100000];
  	int sum=0;
  
  	for(int l;l<100000;l++)
    {
      check[l]=0;
      wa[l]=0;
    }

	cin>>n>>m;

	vector<int> p(m);
	vector<string> s(m);

	for(int i=0;i<m;i++)
	{
		cin>>p[i]>>s[i];
		if(s[i]=="AC")
		{
			if(!(check[p[i]]==1000))
			{
              	sum=sum+wa[p[i]];
              	wa[p[i]]=0;
				count++;
				check[p[i]]=1000;
			}
		}
      	else
        {
          	if(!(check[p[i]]==1000))
            {
      			wa[p[i]]++;
            }
        }
	}


	cout<<count<<" "<<sum<<endl;

	return 0;
}

Measured memory_bytes: 6912
#include <stdio.h>
int main(void){
   double a, b, c, d, i1, j1, i2, j2, x, y;
   int n;
   scanf("%lf %lf %lf %lf", &a, &b, &c, &d);
   if(a != c && b != d){
       i1 = (d - b)/(c - a);
       j1 = b - i1 * a;
       i2 = -1 / i1;
       scanf("%d", &n);
       for(c = 0; c < n; c++){
           scanf("%lf %lf", &a, &b);
           j2 = b - i2 * a;
           x = (j1 - j2)/(i2 - i1);
           y = i2 * x + j2;
           printf("%.10f %.10f\n", x, y);
       }
    }else if(a == c){
        scanf("%d", &n);
        for(d = 0; d < n; d++){
           scanf("%lf %lf", &a, &b);
           printf("%.10f %.10f\n", c, b);
       }
    }else{
        scanf("%d", &n);
        for(c = 0; c < n; c++){
           scanf("%lf %lf", &a, &b);
           printf("%.10f %.10f\n", a, d);
       }
    }
    return 0;
}



Measured memory_bytes: 2148
#include<iterator>
#include<algorithm>
#include<bits/stdc++.h>
#define M 1000000007
#define C 998244353
using namespace std;
typedef unsigned long long int ll;
void solve(){
    ll n,m,t,res=0,i;
    string s;
    cin >> s;
    if(s[1]=='R'){
        cout << "ABC" << "\n";
    }
    else{
        cout << "ARC" << "\n";
    }
}

int main()
{
    ll t = 1;
    //cin >> t;
    //cin.ignore();
    for(ll f=0;f<t;f++){
        solve();
    }
}


Measured memory_bytes: 3624
dp = [[0 for _ in range(1001)] for _ in range(10)]
dp[1][0] = dp[0][0] = 1

for now in range(1, 101):
  for used in range(9, 0, -1):
    dpu = dp[used]
    dpu_1 = dp[used - 1]
    for s in range(now, 1001):
      dpu[s] = dpu_1[s - now] + dpu[s]

while True:
  n, s = map(int, input().split())
  if not n:
    break
  print(dp[n][s])


Measured memory_bytes: 5716
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def lcm(a, b):
    g = gcd(a, b)
    return b * a // g

def main():
    N, M = LI()
    A = LI()
    g = 1
    for i in range(N):
        A[i] //= 2
        g = lcm(g, A[i])

    for a in A:
        if g // a % 2 == 1:
            continue
        else:
            print(0)
            return
    shou = M // g
    if shou % 2 == 1:
        shou -= 1
        ans = shou // 2
        ans += 1
    else:
        ans = shou // 2
    print(ans)


main()



Measured memory_bytes: 91256
#include<iostream>
#include<vector>
using namespace std;

vector<int> ans;
int cnt;
void construct(long long n,int &k)
{
	if(n==1)
	{
		ans.push_back(1);
		k=1;
		return;
	}
	if(n%2)
	{
		construct((n-1)/2,k);
		k++;
		ans.push_back(k);
	}
	else 
	{
		construct(n-1,k);
		k++;
		ans.insert(ans.begin(),k);
	}
}

int main()
{	
	long long n;
	cin>>n;
	construct(n,cnt);
	for(int i=1;i<=cnt;i++)
		ans.push_back(i);
	cout<<ans.size()<<endl;
	for(int i=0;i<ans.size();i++)
	{
		cout<<ans[i]<<' ';
	}
	return 0;
}

Measured memory_bytes: 256