akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0LL,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0LL,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define COUNT2(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0LL)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 2222222222222222222LL;
const ll mod = 1000000007LL;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111


int main(void) {
  cin >> n;
  vll a(n);
  rep(i, n)scan(a[i]);
  rep(i, n - 1) {
	if (a[i] == a[i + 1]) {
	  a[i + 1] = inf;
	  ans++;
	}
  }
  cout << ans << endl;


  return 0;
}

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

using namespace std;
typedef long long ll;
const ll INF=100000000000000LL;

int main() {
	int n;
	ll a[200001];
	cin>>n;
	ll t=0;
	for(int i=0;i<n;++i){
		cin>>a[i];
		t+=a[i];
	}
	ll t1=0;
	ll r=INF;
	for(int i=0;i<n-1;++i){
		t-=a[i];
		t1+=a[i];
		r=min(r,abs(t1-t));
	}
	cout<<r<<endl;
		return 0;
}


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

    /*
    ||||||||||||||||||||||||||||||||||||||||||||||||
       |      |||         |      ||||    ||||  |   |
      | |     |   |      | |     |   |  |      |   |
     |   |    |    |    |   |    |   |  |      |   |
    |||||||   |    |   |||||||   |||     |||   |||||
    |     |   |   |    |     |   | |        |  |   |
    |     |   |||      |     |   |  ||  ||||   |   |
    ||||||||||||||||||||||||||||||||||||||||||||||||

    */
    using namespace std;
    #define ff first
    #define ss second
    #define mp make_pair
    #define all(v) v.begin(),v.end()
    #define int long long
    #define ll long long
    #define M 1000000007

    #define mii  map<ll ,ll >
    #define msi  map<string,ll >
    #define mis  map<ll int, string>
    #define rep(a,b)    for(ll i=a;i<b;i++)
    #define rep0(n)    for(ll i=0;i<n;i++)
    #define repi(i,a,b) for(ll i=a;i<b;i++)
    #define pb push_back
    #define vi vector<ll>
    #define mp make_pair
    #define vs vector<string>
    #define ppb pop_back
    #define endl '\n'
    #define asdf ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    #define r0 return 0;
    #define FORD(i, a, b) for (int i = (int) (a); i >= (int) (b); --i)
    #define FORE(it, c) for (__typeof((c).begin()) it = (c).begin(); it != (c).end(); ++it)
    #define inputoutput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #define input freopen("input.txt", "r", stdin);
    #define Set(a, s) 4(a, s, sizeof (a))
    #define FOR repi
    //#define float long double
    ll max(ll a, ll b) { return (a > b)? a : b;}
    int min(int a, int b) { return (a < b)? a : b;}


     int solve()
     {
        string s;
        cin>>s;
        int n=s.size();
        int ans=0,ans2=0,t=1;
        rep0(n){
            if(i%2){
                if(s[i]=='0') ans++;
                else ans2++;
            }
            else
            {
                if(s[i]=='0') ans2++;
                else ans++;
            }
        }

        cout<<min(ans,ans2);
     }
    signed main()
    {   
        
        int t=1;
        //cin>>t;
        while(t--)
        {
            solve();
        }     
        
}

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

using namespace std;
using ll = long long;

string s;
string t;

pair<int, int> nexty[3005][3005];
int dp[3005][3005];

int solve(int i, int j) {
  if (i == s.size() || j == t.size()) {
    return 0;
  }
  int& res = dp[i][j];
  if (res != -1) {
    return res;
  }
  if (s[i] == t[j]) {
    nexty[i][j] = {i + 1, j + 1};
    return res = 1 + solve(i + 1, j + 1);
  }
  int ss = solve(i + 1, j);
  int tt = solve(i, j + 1);
  if (ss > tt) {
    nexty[i][j] = {i + 1, j};
  } else {
    nexty[i][j] = {i, j + 1};
  }
  return res = max(ss, tt);
}

int main() {
  cin >> s >> t;
  fill(&dp[0][0], &dp[0][0] + 3005 * 3005, -1);
  int len = solve(0, 0);
  vector<char> res;
  auto pp = make_pair(0, 0);
  set<pair<int, int>> seen;
  while (pp.first != s.size() && pp.second != t.size()) {
    assert(!seen.count(pp));
    seen.insert(pp);
    if (s[pp.first] == t[pp.second]) {
      res.push_back(s[pp.first]);
    }
    pp = nexty[pp.first][pp.second];
  }
  for (char c : res) {
    cout << c;
  }
  cout << '\n';
  return 0;
}


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

int main() {

  string S;
  cin >> S;

  if(S.at(2)==S.at(3)&&S.at(4)==S.at(5)){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}



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

struct P
{
    int x,y;

    bool operator<(const P &a)const{
        if(x!=a.x)
              return x>a.x;
        return y>a.y;
    }

};

vector<int> v[111111],v1;

//bitset<4001000> b;
int i,n,d,m,k,a,b,c,h;

int o[1111];
long long l[3][100511];
int j[1];
int e;


//int dx[10]={2,2,-2,-2,1,1,-1,-1},dy[10]={1,-1,1,-1,2,-2,2,-2};

int dx[10]={0,1,0,-1,1,1,-1,-1},dy[10]={1,0,-1,0,1,-1,1,-1},dz[10]={0,0,0,0,1,-1};
long long mod=1000000007,mod2=1000000009,mod3=2017;
long long x,z,y;
double pi=3.14159265;
P u[1];
stack<int> s;
//set<int> s[222][22];
priority_queue<long long,vector<long long>,greater<long long> > q;
//queue<int> q;
//2147483647
//'1'==49;
//'A'==65;
//'a'==97;
//unordered_
//map<int,int> p;
/*
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
unordered_map<long long, int, custom_hash> safe_map;
*/
//list<int> l;

//string r,r1;
//char r[2];
//deque<int> de;
//srand((int)time(NULL));
/*bool as(P a,P b)
{
    if(a.x!=b.x)
    return a.x<b.x;
    return a.y<b.y;
}*/



bool as(P a,P b)
{
    if(a.x!=b.x)
        return a.x<b.x;
    return a.y<b.y;

}


long long f(int n,int p,int m)
{

    if(l[n][m]>=0) return l[n][m];
    long long x=1,y=1;
    if(n)
    {
        for(int h=0;h<v[m].size();h++)
            if(v[m][h]!=p)
                x*=f(0,m,v[m][h]),x%=mod;
            y=0;
    }
    else
    {
        for(int h=0;h<v[m].size();h++)
            if(v[m][h]!=p)
            x*=f(0,m,v[m][h]),y*=f(1,m,v[m][h]),y%=mod,x%=mod;
    }
    return l[n][m]=(x+y)%mod;
}

int main()
{
    memset(l,-1,sizeof(l));
    scanf("%d",&a);
    for(int t=1;t<a;t++)
    {
        scanf("%d %d",&n,&m);
        v[n].push_back(m);
        v[m].push_back(n);
    }
    printf("%lld",f(0,0,1));
}





Measured memory_bytes: 16640
N = int(input())
h = list(map(int, input().split())) + [0]
ans = 0
#  最大h×N本の全探索
#  連続が途切れる数を下からカウントすれば答えとなる
for i in range(max(h)):
    for j in range(N):
        if h[j] - i > 0 and h[j + 1] - i <= 0:
            ans += 1
print(ans)

Measured memory_bytes: 39152
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <cstring>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 62;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll conbinationMemo[100][100];

ll cmemoInit(){
    rep(i, 100){
        rep(j, 100){
            conbinationMemo[i][j] = -1;
        }
    }
}
 
ll nCr(ll n, ll r){
    if(conbinationMemo[n][r] != -1) return conbinationMemo[n][r];
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return conbinationMemo[n][r] = (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
//-----------------------ここから-----------
int main(void){
    int k, a, b;
    cin >> k >> a >> b;

    for(int i = a; i <= b; i++){
        if(i % k == 0){
            cout << "OK" << endl;
            return 0;
        }
    }

    cout << "NG" << endl;
}


Measured memory_bytes: 3592
#include <iostream>

int main () {
  int n;
  std::cin >> n;
  
  bool a = true;
  
  for(auto i=0; i<n; ++i) {
    int tmp;
    std::cin >> tmp;
    
    if(tmp %2 == 0)
    if (!(tmp % 3 == 0 || tmp % 5 == 0))
    {
      a = false;
    }
  }
  if(a)
  std::cout << "APPROVED\n";
  else
   std::cout << "DENIED\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <math.h>
#include <bitset>

#define P pair
#define X first
#define Y second
#define VSORT(v) sort(v.begin(), v.end())
#define VREV(v) reverse(v.begin(), v.end())
#define VMAX_P(v) max_element(v.begin(), v.end())
#define VMIN_P(v) min_element(v.begin(), v.end())
#define VMAX_IDX(v) distance(v.begin(), VMAX_P(v))
#define VMIN_IDX(v) distance(v.begin(), VMIN_P(v))
#define VCOPY(src, dst) copy(src.begin(), src.end(), back_inserter(dst))
#define SUPPER(src, dst) transform(src.begin(), src.end(), dst.begin(), toupper);
#define SLOWER(src, dst) transform(src.begin(), src.end(), dst.begin(), tolower);

using namespace std;
using ll = long long;

int main(int argc, const char *argv[])
{
    int n, k;
    cin >> n >> k;
    if (k == 1)
    {
        cout << 0 << endl;
    }
    else
    {
        cout << n - k << endl;
    }
}


Measured memory_bytes: 256
o,f,i=998244353,[1],1
while i<2500100:f.append(f[-1]*i%o);i+=1
c=lambda n,k:f[n]*pow(f[n-k],o-2,o)*pow(f[k],o-2,o)
n,m=map(int,input().split())
w,u=3*m,n-1
a=c(w+u,u)-n*c(n+m-2,u)
if u>m:
 for i in range(m+1,min(w,n)+1):
  if w-i+1&1:a-=c(n,i)*c((w-i)//2+u,u) 
print(a%o)

Measured memory_bytes: 109192
nm=list(map(int, input().split(" ")))
n=nm[0]
m=nm[1]
votes=list(map(int, input().split(" ")))
can=sorted(votes,reverse=True)
#print(can)
stan=0
for vote in votes:
    stan+=vote
#print(stan)
if can[m-1]<stan/4/m:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int mod = 1e9+7;
const double eps = 1e-11;
const double PI = 2 * acos(0.0);
typedef long long int ll;
typedef unsigned long long ull;
typedef map<int,int> mii;
typedef map<string,int> msi;
typedef map<string,string> mss;
typedef pair<int,int> pii;
typedef pair<string,string> pss;
#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sortVA(v) sort(v.begin(),v.end())
#define sortVD(v) sort(v.begin(),v.end(),greater<int>())
#define ASC(a,n) sort(a,a+n);
#define DESC(a,n) sort(a,a+n,greater<int>());
#define out(x) cout <<x<<endl
#define outt(x,y) cout <<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))
#define gcd(a,b) __gcd(a,b);
#define lcm(a, b) ((a)*((b)/gcd(a,b)))

int main()
{
    fast_io
    int w,a,b;
    cin >>w>>a>>b;
    int aa=w+a;
    //if(aa>=b){out(0);}
    if(a<b){
        if((w+a)>=b){out(0);}
        else{out(b-(w+a));}
    }
    else{
        if((w+b)>=a){out(0);}
        else{out(a-(w+b));}
    }
    return 0;
}








Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define ins insert
#define int long long int
#define pb push_back
#define mp make_pair
#define f(i,n) for(int i = 0 ; i < n ; i++ )
#define f1(i,n) for(int  i = 1 ; i <= n ; i++)
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);
#define test() int t;cin>>t;while(t--)
int mpower(int x, int y, int p){int res = 1;x = x % p;while(y > 0){if(y & 1) res = (res*x) % p;y = y>>1;x = (x*x) % p;}return res;}
int power(int x, int y){int res = 1;while (y > 0){if (y & 1) res = res*x;y = y>>1;x = x*x;}return res;}
bool isPrime(int n){if (n <= 1)  return false;if (n <= 3)  return true;if (n%2 == 0 || n%3 == 0) return false;int p=sqrt(n);for(int i=5;i<=p;i=i+6)if (n%i == 0 || n%(i+2) == 0)return false;return true;}


int32_t main()
{
	fast();

	/*test()
	{
	}*/
    int n , cap;
    cin >> n >> cap;
    
    int weight[n+1] = {0};
    int value[n+1] = {0};
    
    f1(i,n)
    {
        cin >> weight[i];
        cin >> value[i];
    }
    
    int dp[n+1][cap+1] ;
    memset(dp, 0 ,sizeof(dp));
    
    f(i,n+1)
    {
        f(j,cap+1)
        {
            if(i == 0 || j == 0)
                continue;
            else if(weight[i] > j )
            {
                dp[i][j] = dp[i-1][j];
            }
            else
            {
                dp[i][j] = max(value[i] + dp[i-1][j-weight[i]] , dp[i-1][j]);
            }
        }
    }
    
    
    cout<<dp[n][cap];
    

	return 0;
}

Measured memory_bytes: 79232
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"
int main()
{
	string a,b,s;
	cin>>a;
	cin>>b;
	int x = a.size();
	int y = b.size();
	int n = min(x,y);
	for0(i,n){
		s += a[i];
		s += b[i];
		}
	if(x>y) s+=a[x-1];
	else if(y>x) s+=b[y-1];
	
	
	cout<<s<<nw;
	
	return 0;
}

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

#define MAX 100
#define WHITE 0
#define GRAY 1
#define BLACK 2

int n;
bool G[MAX + 1][MAX + 1];
int col[MAX + 1];
int d[MAX + 1];

void init(int n) {
	for (int i = 1; i <= n; i++) {
		col[i] = WHITE;
		d[i] = -1;
		for (int j = 1; j <= n; j++)
			G[i][j] = 0;
	}
}

void bfs(int u) {
	queue<int> Q;
	Q.push(u);
	col[u] = GRAY;
	d[u] = 0;
	while (!Q.empty()) {
		int v = Q.front();
		Q.pop();
		for (int i = 1; i <= n; i++) {
			if (G[v][i] && col[i] == WHITE) {
				Q.push(i);
				col[i] = GRAY;
				d[i] = d[v] + 1;
			}
		}
		col[v] = BLACK;
	}
}

int main() {
	cin >> n;
	init(n);
	for (int i = 0; i < n; i++) {
		int u, k;
		cin >> u >> k;
		for (int j = 0; j < k; j++) {
			int v;
			cin >> v;
			G[u][v] = 1;
		}
	}
	bfs(1);
	for (int u = 1; u <= n; u++) {
		cout << u << " " << d[u] << endl;
	}
	return 0;
}



Measured memory_bytes: 3100
long a[3000],dp[3001][3001];
i,j;
main(n)
{
	for(scanf("%d",&n);~scanf("%d",a+j++););
	for(;i++<n;)
	{
		for(j=i;j--;)
		{
			dp[j][i]=fmax(a[j]-dp[j+1][i],a[i-1]-dp[j][i-1]);
		}
	}
	printf("%ld",dp[0][n]);
}

Measured memory_bytes: 70016
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<int, lint> pil;
typedef pair<lint, lint> pll;
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T>bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod*mod;
constexpr int MAX = 100010;

int main(){
    int s;
    scanf("%d", &s);
    int a = s/100;
    int b = s%100;
    if(1<=a && a<=12){
        if(1<=b && b<=12) printf("AMBIGUOUS\n");
        else printf("MMYY\n");
    }
    else{
        if(1<=b && b<=12) printf("YYMM\n");
        else printf("NA\n");
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define Open(s) freopen(s".in","r",stdin);freopen(s".out","w",stdout);
#define inl inline
#define reg register
#define i64 long long 
#define int long long 
using namespace std;
inl int read(){int x=0,f=0;char ch=0;while(!isdigit(ch))f|=(ch=='-'),ch=getchar();while(isdigit(ch))(x*=10)+=(ch^48),ch=getchar();return f?-x:x;}
inl void Ot(reg int x){if(x<0)x=-x,putchar('-');if(x>=10)Ot(x/10);putchar(x%10+'0');}
inl void Print(reg int x,char til='\n'){Ot(x);putchar(til);}
inl int Max(reg int x,reg int y){return x>y?x:y;}
inl int Min(reg int x,reg int y){return x<y?x:y;}
inl int Abs(reg int x){return x<0?-x:x;}
const int MAXN=105060;
int n,k;
int Smin,Smax;
int a[MAXN],ans;
int sum[MAXN];
int fac[MAXN],inv[MAXN];
const int Mod=1e9+7;
inl int qpow(int x,int y=Mod-2){
	int ret=1;
	for(;y;y>>=1,x=x*x%Mod)if(y&1)ret=ret*x%Mod;
	return ret;
}
void Init(){
	inv[0]=fac[0]=1;
	for(reg int i=1;i<=n;i++)fac[i]=(fac[i-1]*i)%Mod;
	inv[n]=qpow(fac[n]);
	for(reg int i=n-1;i>=1;i--)inv[i]=inv[i+1]*(i+1)%Mod;
}
int C(int n,int m){return fac[n]%Mod*inv[m]%Mod*inv[n-m]%Mod;}
signed main(){
	#ifndef ONLINE_JUDGE
		//freopen("../../data.in","r",stdin);
	#endif
	cin>>n>>k;
	if(k==1)return puts("0"),0;
	Init();
	for(reg int i=1;i<=n;i++)
		cin>>a[i];
	sort(a+1,a+n+1);
	// cout<<C[n]<<endl;
	// for(reg int i=1;i<=n;i++)
		// printf("C(%lld,%lld)=%lld\n",i,k-1,C[i]);
	for(reg int i=1;i<=n-k+1;i++)
		Smin=(C(n-i,k-1)*a[i]%Mod+Smin)%Mod;
	for(reg int i=n;i>=k;i--)
		Smax=(C(i-1,k-1)*a[i]%Mod+Smax)%Mod;
	// cout<<Smax<<" "<<Smin<<endl;
	cout<<((Smax-Smin)%Mod+Mod)%Mod<<endl;
	return 0;
}

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

int main(){
	int H,W;
	cin >> H >> W;
	bool s[H+2][W+2];

	bool canDo = true;
	for(int h = 0; h <= H+1; h++){
		for(int w = 0; w <= W+1; w++){
			s[h][w] = false;
		}
	}
	for(int h = 1; h <= H; h++){
		string tmp;
		cin >> tmp;
		for(int w = 1; w <= W; w++){
			if(tmp[w-1] == '#'){
				s[h][w] = true;
			}
		}
	}
	for(int h=1; h <= H; h++){
		for(int w = 1;w <= W;w++){
			if(s[h][w]){
				if(s[h-1][w] || s[h+1][w] || s[h][w-1] || s[h][w+1]){
					continue;
				}else{
					canDo = false;
					break;
				}
			}
		}
	}
	if(canDo){
		cout << "Yes" << endl;
	}else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

int main() {
    long w, n, ans = -1e9;
    string s;
    cin >> n >> w;
    vector<long> ws(n), vs(n);
    vector<vector<long>> dp(n + 1, vector<long>(w + 1, -1e9));
    // dp[i][j] most value of items for wieght j
    for (long i = 0; i < n; i++) {
        cin >> ws[i];
        cin >> vs[i];
    }
    for (long j = 0; j <= w; j++) {
        dp[0][j] = 0;
    }
    for (long i = 1; i <= n; i++) {
        for (long j = 0; j <= w; j++) {
            if (j - ws[i - 1] < 0) {
                dp[i][j] = max(dp[i - 1][j], dp[i][j]);
                continue;
            }
            dp[i][j] = max({dp[i - 1][j], dp[i][j], dp[i - 1][j - ws[i - 1]] + vs[i - 1]});
        }
    }
    for (long j = 0; j <= w; j++) {
        ans = max(ans, dp[n][j]);
    }
    cout << ans << endl;
}

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

int main()
{
    int n, c[20], v[20], ans = 0;
    cin >> 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) ans += v[i]-c[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {

   int r,D,x_s;
   
   scanf("%d%d%d",&r,&D,&x_s);

   int i,x;
   for (i = 0; i < 10; i++) {
      x = r*x_s - D;
      printf("%d\n",x);
      x_s = x;
   }

  return 0;
}


Measured memory_bytes: 128
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "inposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define ushi int
#define tapu main
#define nichia (
#define kunn void
#define wara )

using ll = long long;

const int INF = 1073741823;
const int MINF = -1073741823;
const ll LINF = ll(4661686018427387903);
const ll MOD = 1000000007;
const double PI = acos(-1);

using namespace std;

void scans(string& str) {
	char c;
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

/*-----------------------------------------ここからコード-----------------------------------------*/

int main(){

	int a;
	scanf("%d", &a);
	string s;
	scans(s);
	printf("%s\n", a >= 3200 ? s.c_str() : "red");

	Please AC;
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
  int N;
  int p[20000];
  cin>>N;
  int i;
  for(i=0;i<N;i++){
    cin>>p[i];
  }
  int a[20000];
  int b[20000];
  
  for(i=0;i<N;i++){
    a[i]=i*20000+1;
    b[i]=(N-i)*20000+1;
  }
  for(i=0;i<N;i++){
    b[p[i]-1]+=i;
  }
  for(i=0;i<N;i++){
    cout<<a[i]<<" ";
  }
  cout<<endl;
  for(i=0;i<N;i++){
    cout<<b[i]<<" ";
  }
  cout<<endl;
  return 0;
  
}


Measured memory_bytes: 896
from collections import Counter
N = int(input())
A = list(map(int,input().split()))
c = Counter(A)
op = []
for a, cnt in c.items():
    for _ in range(cnt // 2):
        op.append(a)
op.sort(reverse=True)
if len(op) < 2:
    print(0)
else:
    print(op[0]*op[1])

Measured memory_bytes: 18600
import java.util.*;

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: 41856
import std.conv, std.stdio, std.string, std.typecons, std.math;

alias Tuple!(int,int) p;

void main() {
	int [] hwd = readln().chomp().split().to!(int[]);
	int H = hwd[0], W = hwd[1];
	int D = hwd[2];
	int [][] A;
	p [] crd;
	A.length = H;
	crd.length = H*W+1;
	foreach(i; 0..H) {
		A[i] = readln().chomp().split().to!(int[]);
		foreach(j; 0..W) {
			crd[A[i][j]] = p(i,j);
		}
	}

	int [][] cost;
	cost.length = 20;
	cost[0].length = H*W+1;
	foreach(i; 1..H*W+1) {
		if(i+D <= H*W) {
			cost[0][i] = to!(int)(abs(crd[i][0] - crd[i+D][0]) + abs(crd[i][1] - crd[i+D][1]));
		}
		else {
			cost[0][i] = -1;
		}
	}
	foreach(i; 1..20) {
		cost[i].length = H*W+1;
		foreach(j; 1..H*W+1) {
			if(j+D*to!(long)(1<<i) <= H*W) {
				cost[i][j] = cost[i-1][j] + cost[i-1][j+D*(1<<(i-1))];
			}
			else {
				cost[i][j] = -1;
			}
		}
	}
	int Q = readln().chomp().to!(int);
	foreach(i; 0..Q) {
		int [] lr = readln().chomp().split().to!(int[]);
		int it = (lr[1] - lr[0]) / D;
		int j = 0, k = lr[0];
		long res = 0;
		while(it) {
			if(it & 1) {
				res += cost[j][k];
				k += D*(1 << j);
			}
			j++;
			it /= 2;
		}

		writeln(res);
	}
}


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

int main() {

int N;
  cin >>N;
  int sum=0;
  vector<int> vec(N);
  vector<int> sa(N);
  for(int i=0;i<N;i++){
    cin >>vec[i];
    sum+=vec[i];
  }
 
  int S2=0;
  int S3=0;
  for(int i=0;i<N;i++){int S1=0;
    for(int j=0;j<=i;j++){ 
      
      S1+=vec[j];}
      S2=sum-S1;
      S3=abs(S1-S2);
//cout<<S1<<S2<<S3<<endl;
    
    sa[i]=S3;
  //  cout <<sa[i]<<endl;
  }
  sort(sa.begin(),sa.end());
  cout<<sa[0]<<endl;
      
      
            
  
}


Measured memory_bytes: 256
//The Shortest Path on A Rhombic Path
#include<bits/stdc++.h>
using namespace std;

int stoi(string s){
  int ret=0;
  for(int i=0; i<s.length(); i++)
    ret=ret*10+(s[i]-'0');
  return ret;
}

int main(){
  vector<vector<int> > v;
  string s;
  int n=0;//行数
  while(getline(cin, s)){
    vector<int> tmp;
    string t;
    stringstream ss(s);
    while(getline(ss, t, ','))
      tmp.push_back(stoi(t));
    v.push_back(tmp);
    n++;
  }

  for(int i=0; i<n-1; i++){
    if(i<n/2){
      for(int j=0; j<v[i+1].size(); j++){
        if(j==0)v[i+1][j]+=v[i][j];
        else if(j==v[i+1].size()-1)v[i+1][j]+=v[i][j-1];
        else v[i+1][j]+=max(v[i][j-1], v[i][j]);
      }
    }
    else{
      for(int j=0; j<v[i+1].size(); j++){
        v[i+1][j]+=max(v[i][j], v[i][j+1]);
      }
    }
  }
  cout<<v[n-1][0]<<endl;
  return 0;
}

Measured memory_bytes: 1244
from sys import stdin


def get_result(data):
#    return 'x' * len(data[0])
    return 'x' * len(data)


if __name__ == '__main__':
#     data = list(map(str, stdin.readline().split(' ')))
    data =  input()
    result = get_result(data)
    print(result)


Measured memory_bytes: 2940
using System;
class Mainclass
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        int k = int.Parse(Console.ReadLine());
        int x = int.Parse(Console.ReadLine());
        int y = int.Parse(Console.ReadLine());
        x *= k < n ? k : n;
        y *= k < n ? n - k : 0;
        Console.WriteLine(x+y);
    }
}

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define rbf(i, v) for (auto& (i) : (v))
#define All(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COL(x) cout << x << endl
#define CO(x) cout << x
#define upsort(x) sort((x).begin(),(x).end())
#define downsort(x) sort((x).begin(),(x).end(),greater<int>())
#define int long long

template<typename T> inline constexpr auto sqr(T x) { return (x) * (x); }
void printd(double x) { printf("%.10lf\n", x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const double PI = 3.141592653589793;
const int MOD = 1000000007;
const int INF = INT_MAX;

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

	VI H(N);
	rbf(h, H) cin >> h;

	downsort(H);

	int ans=0;
	rbf(h, H) {
		if (K > 0) K--;
		else ans += h;
	}

	COL(ans);

	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 1000000009
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

int main(){
  ll A, B;
  cin >> A >> B;
  rep(i, 1010){
    if(i*8/100 == A && i*10/100 == B){
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n = 0;
  cin >> n;
  vector<int> H(n,0);
  vector<int> Kaisuu(n,0);
  for(int i = 0; i < n; i++){
    cin >> H[i];
  }
  int count = 0;
  for(int i = 0; i < n-1; i++){
    if(H[i] >= H[i+1]){
      count++;
    }
    if(H[i] < H[i+1]){
      Kaisuu[i] = count;
      count = 0;
    }
  }
  Kaisuu[n-1] = count;
  sort(Kaisuu.begin(), Kaisuu.end());
  reverse(Kaisuu.begin(), Kaisuu.end());
  cout << Kaisuu[0];
}

Measured memory_bytes: 1024
#include <iostream>
#include <complex>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <cmath>
#include <bitset>
#include <cassert>
#include <queue>
#include <stack>
#include <deque>
#include <random>
#include <iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<P,P> PP;
const ll MOD=998244353;
const ll MAX_N=500010;
const ll INF=4999999996000000001;


int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++) cin>>a[i];
    sort(a.begin(),a.end(),greater<ll>());
    ll ans=a[0];
    n--;
    for(int i=1;i<=n/2;i++){
        ans+=a[i]*2;
    }
    if(n%2==0) ans-=a[n/2];
    cout<<ans<<endl;

}

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

int main(){

int N;
  cin >> N;
long long L[N];
L[0] = 2;
L[1] = 1;  
  
  if(N > 1){
    for(int i = 2;i <= N;i++) L[i] = L[i - 2] + L[i - 1];
  }
  
  cout  << L[N] << endl;

return 0;
  
}

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

using namespace std;

template<typename S, typename T>
ostream& operator<<(ostream& out, const pair<S, T> p) {
    out << "(" << p.first << "," << p.second << ")";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const vector<T>& v) {
    for (auto a: v)
        out << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const set<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename T>
ostream& operator<<(ostream& out, const multiset<T>& S) {
    for (auto a: S)
        cout << a << " ";
    return out;
}

template<typename S, typename T>
ostream& operator<<(ostream& out, const map<S, T>& M) {
    for (auto m: M)
        cout << "(" << m.first << "->" << m.second << ") ";
    return out;
}

template<typename S, typename T>
pair<S, T> operator+(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first + b.first, a.second + b.second);
}

template<typename S, typename T>
pair<S, T> operator-(pair<S, T> a, pair<S, T> b) {
    return make_pair(a.first - b.first, a.second - b.second);
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    cout << !n << endl;
    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<58;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

struct edge{
    int to,cap,rev;
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
};

void solve(){
    while(true){
        int n,m;
        cin >> n >> m;
        if(n==0 and m==0) break;
        vector<long double> x(n),y(n),v(n),x_(m),y_(m);
        rep(i,0,n) cin >> x[i] >> y[i] >> v[i];
        rep(i,0,m) cin >> x_[i] >> y_[i];

        auto ok=[&](const long double k){
            vector<vector<edge>> graph(n+m+2);
            vector<bool> used(n+m+2);
            auto add_edge=[&](int from,int to,int cap){
                graph[from].emplace_back(edge(to,cap,graph[to].size()));
                graph[to].emplace_back(edge(from,0,graph[from].size()-1));
            };
            rep(i,0,n) add_edge(n+m,i,1);
            rep(i,0,m) add_edge(n+i,n+m+1,1);
            rep(i,0,n) rep(j,0,m) if((x[i]-x_[j])*(x[i]-x_[j])+(y[i]-y_[j])*(y[i]-y_[j])<=k*k*v[i]*v[i]) add_edge(i,n+j,1);
            function<int(int,int,int)> dfs=[&](int v,int t,int f){
                if(v==t) return f;
                used[v]=true;
                rep(i,0,graph[v].size()){
                    edge& e=graph[v][i];
                    if(!used[e.to] and e.cap>0){
                        int d=dfs(e.to,t,min(f,e.cap));
                        if(d>0){
                            e.cap-=d;
                            graph[e.to][e.rev].cap+=d;
                            return d;
                        }
                    }
                }
                return 0;
            };
            auto max_flow=[&](int s,int t){
                int flow=0;
                while(true){
                    fill_n(used.begin(),n+m+2,false);
                    int f=dfs(s,t,inf);
                    if(f==0) return flow;
                    flow+=f;
                }
            };
            return max_flow(n+m,n+m+1)==m;
        };

        long double lb=0,ub=inf;
        rep(i,0,64){
            const long double mid=(lb+ub)/2;
            if(ok(mid)) ub=mid;
            else lb=mid;
        }
        cout << ub << endl;
    }
}

int main(){
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    cout << fixed << setprecision(8);
    solve();
    return 0;
}

Measured memory_bytes: 3476
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>

using namespace std;
int main(){
    long long unsigned int a,b,c,d,x,y,z,gcd_cd,total,devided;
    cin >> a >> b >> c >> d;
    x=c;
    y=d;
    while(x!=0){
        z = x;
        x = y%x;
        y = z;
 //       cout << x << y<<endl;
    }
    gcd_cd=c*(d/y);
//    cout<< gcd_cd <<endl;
    total =b-a+1;
    devided=(b/c+b/d-b/gcd_cd)-((a-1)/c+(a-1)/d-(a-1)/gcd_cd);
    cout << total-devided << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>

typedef long long llint;

using namespace std;

const int MAXN = 55;
const int MOD = 1e9 + 7;

char up[MAXN], down[MAXN];

int n;

vector<int> state; 

inline int mul(int a, int b) {
  return (llint) a * b % MOD;
}

int main(void) {
  scanf("%d", &n);
  scanf("%s%s", up, down);
  
  for (int i = 0; i < n; ++i) {
    if (up[i] == down[i]) {
      state.push_back(1);
      continue;
    }
    state.push_back(2);
    ++i;
  }
  
  int sol = 3 * state[0];
  for (int i = 1; i < (int) state.size(); ++i) {
    if (state[i] == 1) {
      if (state[i - 1] == 2) continue;
      sol = mul(sol, 2);
    } else {
      if (state[i - 1] == 1)
        sol = mul(sol, 2);
      else
        sol = mul(sol, 3);
    }
  }
  
  printf("%d\n", sol);
  
  return 0;
}

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

//int ans[305][305];

int main()
{


     ios_base::sync_with_stdio(false);
     cin.tie(NULL);
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
   */
 int n,k;
 cin>>n>>k;
 double total=0.0000000000000;

 for(int i=1;i<=n;i++)
 {
    double temp=1.0000000000000;
    int j=i;
    while(j<k)
    {
      j*=2;
      temp=temp*0.5000000000;
    }

    total+=temp;
 }

 //cout<<total<<endl;
 cout<<fixed<<setprecision(20)<<(total/n)<<endl;

   return 0;
    
}

Measured memory_bytes: 3764
#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(obj)   (obj).begin(),(obj).end()

#define debug(var)  do{std::cout << __LINE__ << "> " << #var << ": ";view(var);}while(0)
template<typename T> void view(T e){std::cout << e << std::endl;}
template<typename T> void view(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void view(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ view(v); } }

using namespace std;
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

void Main() {
	int N; cin >> N;
	vi place(N + 1);
	FOR(i, 1, N + 1) {
		int a; cin >> a;
		place[a] = i;
	}
	ll res = 0;
	set<int> st = {0, N + 1};
	FOR(i, 1, N + 1) {
		auto itr = st.lower_bound(place[i]);
		int r = *itr;
		int l = *(--itr);
		res += (ll)i * (place[i] - l) * (r - place[i]);
		st.insert(place[i]);
	}
	cout << res << endl;
}

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


Measured memory_bytes: 10368
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>

void dfs(const std::vector<std::vector<size_t>>& g, size_t v,
         std::vector<bool>& vis) {

  if (vis[v]) return;
  vis[v] = true;
  for (size_t u: g[v]) dfs(g, u, vis);
}

bool connected(const std::vector<std::vector<size_t>>& g) {
  size_t N = g.size();
  std::vector<bool> vis(N);
  dfs(g, 0, vis);
  return std::all_of(vis.begin(), vis.end(), [](bool f) { return f; });
}

int main() {
  size_t N, M;
  scanf("%zu %zu", &N, &M);

  std::vector<size_t> a(M), b(M);
  for (size_t i = 0; i < M; ++i) {
    scanf("%zu %zu", &a[i], &b[i]);
    --a[i];
    --b[i];
  }

  int res = 0;
  for (size_t i = 0; i < M; ++i) {
    std::vector<std::vector<size_t>> g(N);
    for (size_t j = 0; j < M; ++j) {
      if (j == i) continue;
      g[a[j]].push_back(b[j]);
      g[b[j]].push_back(a[j]);
    }
    if (!connected(g)) ++res;
  }
  printf("%d\n", res);
}

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

long s[200010];

int main()
{
    int n, K; cin>>n>>K;

    for(int a, i=0; i<n; ++i) {
        cin>>a;
        s[i+1]=s[i]+a;
    }

    map<int, int> mp;
    long res=0;
    for(int i=0; i<=n; ++i) {
        s[i]=(s[i]-i+K)%K;
        res+=mp[s[i]]++;
        if (i+1>=K) mp[s[i+1-K]]--;
    }
    cout<<res<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;

struct UnionFind {
  vector<int> par;  // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
  vector<int> rank;

  UnionFind(int N) : par(N), rank(N) {  //最初は全てが根であるとして初期化
    for (int i = 0; i < N; i++) {
      par[i] = i;
      rank[i] = 0;
    }
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  void unite(int x, int y) {  // xとyの木を併合
    x = root(x);
    y = root(y);
    if (x == y) return;

    if (rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (rank[x] == rank[y]) rank[x]++;
    }
  }

  bool same(int x, int y) {  // 2つのデータx, yが属する木が同じならtrueを返す
    int rx = root(x);
    int ry = root(y);
    return rx == ry;
  }
};

int main() {
  int n, q;
  cin >> n >> q;

  UnionFind u(n);

  for (int i = 0; i < q; i++) {
    int p, a, b;
    cin >> p >> a >> b;
    if (p == 0) {
      u.unite(a, b);
    } else {
      cout << (u.same(a, b) ? 1 : 0) << endl;
    }
  }
}

Measured memory_bytes: 4708
import sys
sys.setrecursionlimit(10**6)
from math import floor,ceil,sqrt,factorial,log
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
from operator import itemgetter
from fractions import gcd
mod = 10 ** 9 + 7
 
#整数input
def ii(): return int(sys.stdin.readline().rstrip()) #int(input())
def mii(): return map(int,sys.stdin.readline().rstrip().split())
def limii(): return list(mii()) #list(map(int,input().split()))
def lin(n:int): return [ii() for _ in range(n)]
def llint(n: int): return [limii() for _ in range(n)]
#文字列input
def ss(): return sys.stdin.readline().rstrip() #input()
def mss(): return sys.stdin.readline().rstrip()
def limss(): return list(mss()) #list(input().split())
def lst(n:int): return [ss() for _ in range(n)]
def llstr(n: int): return [limss() for _ in range(n)]

#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？
#本当に貪欲法か？ DP法では？？

n,c,k=mii()
arr=lin(n)
arr.sort()

bas_cnt=1
pep_cnt=0
time=arr[0]+k

for i in range(n):
    #時間の判別or更新
    arri=arr[i]
    if arri <= time:
        if pep_cnt < c:
            pep_cnt+=1
        else:
            bas_cnt+=1
            pep_cnt=1
            time=arri+k
            
    else:
        bas_cnt+=1
        pep_cnt=1
        time=arri+k
    #print(bas_cnt,pep_cnt,time)
print(bas_cnt)

Measured memory_bytes: 69336
//john_doe 

#include <iostream>
#include <vector>
#include <string>
int main(){
    int N;
    std::cin>>N;

    std::string S;
    std::cin>>S;

    int cnt=0;
    for(int i=0;i<N;i++){
        if(S[i]=='O'&&S[i-1]=='X'){
            cnt++;
        }else if(S[i]=='O'&&S[i+1]=='X'){
            cnt++;
            S[i+1]='-';
        }
    }
    std::cout<<cnt<<'\n';
    return 0;
}


Measured memory_bytes: 3332
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <numeric>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int MOD = 1e9+7;

int main(){
  int N;
  string S1, S2;
  cin >> N >> S1 >> S2;
  ll ans = 1;
  bool prev;
  rep(i, N) {
    if(S1[i] == S2[i]) {
      if(i) {
        if(!prev)
          ans = ans*2%MOD;
      }
      else
        ans = 3;
      prev = 0;
    } else {
      if(i) {
        if(prev)
          ans = ans*3%MOD;
        else
          ans = ans*2%MOD;
      }
      else
        ans = 6;
      i++;
      prev = 1;
    }
  }
  cout << ans << endl;
  return 0;
}

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

#define ll long long

using namespace std; 

const int N = 200505;

int da[] = {0,0,0,-1,-1,-1,-2,-2,-2};
int db[] = {0,-1,-2,0,-1,-2,0,-1,-2};
ll h,w,z;
ll arr[12];
map<pair<int,int>,int> m;

int check(int a,int b){
	if(a <= 0 || a>h-2 || b <= 0 || b > w-2) return 0;
	return 1;
}

int main(){
	scanf("%lld %lld",&h,&w);
	int q; scanf("%d",&q);
	while(q--){
		int a,b; scanf("%d %d",&a,&b);
		for(int i=0;i<9;i++){
			if(check(a+da[i] , b+db[i])){
				m[{a+da[i],b+db[i]}]++;
			}
		}
	}
	z = (h-2)*(w-2);
	for(auto i:m){
		z--;
		if(i.second < 10) arr[i.second]++;
	}
	printf("%lld\n",z);
	for(int i=1;i<=9;i++) printf("%lld\n",arr[i]);
	return 0;
}

Measured memory_bytes: 56448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long N){
	ll n = (N/2);
	double d = 1.0-1.0*n/N;
	printf("%.16f\n",d);
}

int main(){	
	long long N;
	scanf("%lld",&N);
	solve(N);
	return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <memory.h>
#include <cstring>
#include <vector>
#include <deque>
#include <cstdlib>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <functional>
#include <iostream>
#include <set>
#include <list>
#include <map>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
using namespace std;

typedef unsigned long long llu;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<string, int> psi;
const ll MOD = 1e9 + 7;
const long double PI = 3.141592653589793238462643383279502884197;

priority_queue<int, vector<int>, greater<int> > pq;
vector<pii> v[100000];

int dist[100000];
void go(int o, int val) {
	if (dist[o] != -1) {
		if (dist[o] != val) {
			printf("No\n");
			exit(0);
		}
		else return;
	}
	else dist[o] = val;

	for (int i = 0; i < sz(v[o]); i++)
		go(v[o][i].second, val + v[o][i].first);
}

int main() {
	memset(dist, -1, sizeof(dist));
	int n, m;
	scanf("%d %d", &n, &m);

	int a, b, c;
	while (m--) {
		scanf("%d %d %d", &a, &b, &c);
		a--; b--;
		v[a].push_back({ c, b });
		v[b].push_back({ -c, a });
	}

	for (int i = 0; i < n; i++)
		if(dist[i] == -1) go(i, 1000000000);

	printf("Yes\n");
}

Measured memory_bytes: 12032
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e5 + 5;

int d[N];

int solve(int x)
{
    deque<int> q;
    q.push_back(1);
    memset(d, -1, sizeof(d));
    d[1] = 1;
    while(!q.empty())
    {
        int u = q.back(); q.pop_back();
        int v = (u + 1) % x;
        if(d[v] == -1 || d[v] > d[u] + 1)
        {
            d[v] = d[u] + 1;
            q.push_front(v);
        }
        v = (u * 10) % x;
        if(d[v] == -1 || d[v] > d[u])
        {
            d[v] = d[u];
            q.push_back(v);
        }
    }
    return d[0];
}

int main()
{
    int n;
    scanf("%d", &n);
    printf("%d\n", solve(n));
    return 0;
}


Measured memory_bytes: 896