akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<map>
using namespace std;
int main() {
  int t1,t2,r1,r2;
  cin >> t1 >> t2 >> r1 >> r2;
  if(r1!=-1&&r2!=-1) {
    if(r1>r2) {
      cout << "Alice" << endl;
    }
    else if(r2>r1) {
      cout << "Bob" << endl;
    }
    else {
      cout << "Draw" << endl;
    }
  }
  else {
    if(t1>t2) {
      cout << "Bob" << endl;
    }
    else if(t2>t1) {
      cout << "Alice" << endl;
    }
    else {
      cout << "Draw" << endl;
    }
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    int a,b,c,d;
    cin >> a >> b >> c>> d;
    while(1)
    {
        c-=b;
        if(c<=0)
        {
            cout << "Yes" << endl;
            return 0;
        }
        a-=d;
        if (a <= 0)
        {
            cout << "No" << endl;
            return 0;
        }
    }
}

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

int main() {
    int N; 
    cin >> N;
    vector<int> vec(N);
    for(int i=0; i<N; i++){
        cin >> vec[i];
    }
    for(int i=N-1; i>0; i--){
        if(vec[i]<vec[i-1]){
            vec[i-1]--;
        }
    }
    bool hantei = true;
    for(int i=0; i<N-1; i++){
        if(vec[i]-vec[i+1]>0){
            hantei = false;
        }
    }

    if(hantei){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main() {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n;
  vector<int> v1(n);

  int tmp;
  for (int i = 0; i < n; i++) {
    cin >> tmp;
    v1[i] = tmp;
  }

  cin >> m;
  vector<int> v2(m);
  for (int i = 0; i < m; i++) {
    cin >> tmp;
    v2[i] = tmp;
  }

  vector<int> r;
  set_symmetric_difference(v1.begin(), v1.end(), v2.begin(), v2.end(), inserter(r, r.end()));

  for (int i = 0; i < r.size(); i++) {
    cout << r[i] << endl;
  }
}




Measured memory_bytes: 6584
#include<bits/stdc++.h>
#define ll long long
#define mo 1000000007
using namespace std;
ll n,m,ans;
int main(){
	scanf("%lld%lld",&n,&m);
	ans=min(n,m/2);
	n-=ans; m-=2*ans;
	printf("%lld",ans+m/4);
} 

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

typedef long long ll;

ll gcd(ll a, ll b){
    if(a<b) return gcd(b,a);
    ll r;
    while(r=a%b){
        a = b; b = r;
    }
    return b;
}
int main(){
    int N;
    cin >> N;
    int min_val = N+1;
    int ans = 0;
    for(int i = 0; i < N; i++){
        int tmp;
        cin >> tmp;
        if(tmp <=  min_val){
            ans++;
            min_val = tmp;
        }
    }
    cout << ans << endl;

}


Measured memory_bytes: 256
#include <iostream>
#include<math.h>
using namespace std;
int main(void){
    double x1,x2,y1,y2,l;
    double m;
   
    cin>>x1>>y1>>x2>>y2;
     l=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    m=sqrt(l);
    printf("%.8f",m);

    cout<<endl;
}


Measured memory_bytes: 3216
#include <iostream>
#include <numeric>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <iterator>
#include <math.h>
#include <cmath>
#include <set>   
#include <bitset>
//#include <boost/math/common_factor_rt.hpp>

#define ll long long
#define max 100000
using namespace std;
ll l = 1000000007;


int main()
{
	ll a, b, c;
	ll ans = 0;
	cin >> a >> b >> c;

	if (c >= b) {
		ans += b * 2;
		c = c - b;
		if (a >= c) {
			ans += c;
		}
		else {
			ans += a + 1;
		}
	}
	else if (b > c) 
	{
		ans += b + c;
	}

	cout << ans << endl;
	
	
	

	



	
	
}



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

using namespace std;
int arr[(int)1e5 + 4];

int main() {
    int n, k; cin >> n >> k;
    for(int i = 0; i < n; ++i) 
        cin >> arr[i];

    vector<int> dp(n, (int)1e9 + 10);
    dp[0] = 0;

    for(int i = 0; i < n - 1; ++i) {
        for(int j = 1; j <= k and i + j < n; ++j) {
            dp[i + j] = min(dp[i+j], dp[i] + abs(arr[i+j] - arr[i]));
        }
    }
    cout << dp[n-1] ;

}

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

using namespace std;

int main()
{
	int n;
	int* d;
	cin >> n;
	d = new int[n];
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	std::sort(d, d + n);
	cout << abs(d[n / 2 - 1] - d[n / 2]);
	return 0;
}


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

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);i<(int)(n);i++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;i>=(int)(m);i--)
#define REP(i,n) rep(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)
#define ll long long
#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;
constexpr long long MOD = (ll) 1e9 + 7;
typedef vector<ll> Array;
typedef vector<Array> Matrix;
constexpr int loose = 0;
constexpr int tight = 1;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

struct Edge {
	ll to, cap, rev;
	Edge(ll _to, ll _cap, ll _rev) {
	to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, ll from, ll to, ll cap, bool revFlag, ll revCap) {
	G[from].push_back(Edge(to, cap, (ll)G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, (ll)G[from].size() - 1));
}

void solve(){
	ll n;
	cin>>n;
	vector<P> hp(n);
	REP(i,n) cin>>hp[i].first>>hp[i].second;
	sort(all(hp),[&](P x,P y){
		return x.first+x.second<y.first+y.second;
	});
	
	Matrix dp(n+1,Array(n+1,INF));

	dp[0][0]=0;
	REP(i,n){
		ll h=hp[i].first;
		ll p=hp[i].second;
		REP(j,n){
			if(dp[i][j]==INF) break;
			if(dp[i][j]<=h) chmin(dp[i+1][j+1],dp[i][j]+p);
			chmin(dp[i+1][j],dp[i][j]);
		}
	}

	ll ans=0;
	REP(i,n+1) if(dp[n][i]!=INF) ans=i;
	cout<<ans<<en;
}

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

	solve();
    return 0;
}

Measured memory_bytes: 195968
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(i=0;i<n;i++)
#define pb push_back
#define all(a) a.begin(),a.end()
#define fi first
#define se second
int M=1e9+7;
int mm(int x,int y){x%=M,y%=M;return (x*y)%M;}//Modular Multiply
int po(int x,int y){ if(!y)return 1;int a=po(x,y/2)%M;if(y%2)return mm(a,mm(a,x));return mm(a,a);}//(x**y)%M

signed main(){
ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	//string s;
	int n,m,c=0,t=1,i,j,k,sum=0,ans,f=0,x,y,w;
	//cin>>t;
	while(t--){
		//vector<int> v;map<int,int> mp;set<int> st;
		cin>>n>>w;
		if(w>=n) cout<<"unsafe";
		else cout<<"safe";
		//int a[n];rep(i,n) cin>>a[i];

	}
	return 0;
}




Measured memory_bytes: 3656
import java.util.HashSet;
import java.util.Scanner;

public class Main {

    public Main() {
    }

    public static void main(String[] args) {
        new Main().solve();
    }

    private void solve() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashSet<Integer> set = new HashSet<Integer>();
        for (int i = 0; i < n; i++) {
            set.add(sc.nextInt());
        }

        System.out.println(set.size());
    }
}


Measured memory_bytes: 21844
s = input()
n = len(s)

if s[0] == '0' or s[-1] == '1':
    print(-1)
    exit()
for i in range(n-1):
    if s[i] != s[-2-i]:
        print(-1)
        exit()

path = {1:[v for v in range(2, n+1)]}

ans = []
u_cur, v_cur = 1, 2
n_prev = 0
for i in range(1, n//2):
    if s[i] == '1':
        for _ in range(i-n_prev):
            ans.append((u_cur, v_cur))
            v_cur += 1
        ans.append((v_cur, u_cur))
        u_cur, v_cur = v_cur, v_cur+1
        n_prev = i+1
for v in range(v_cur, n+1):
    ans.append((v_cur-1, v))
for a in ans:
    print(*a)


Measured memory_bytes: 20428
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using vl=vector<long long>;
using pii=pair<int,int>;
using pll=pair<long long,long long>;
#define ITR(i,c) for(auto i=begin(c);i!=end(c);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define REPW(i,n) for(i=0;i<(int)(n);++i)
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)   // c++14
#define SZ(c) ((int)c.size())
#define EXIST(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,v) os << *i << (i==end(v)-1 ? "" : "\n"); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,v) is >> * i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
        is >> p.first >> p.second; return is; }
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
//------------------------------------------------------------------------------
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
    }
} before_main_function;
//------------------------------------------------------------------------------

int x[3][3];
signed main() {
    cin>>x[0][0]>>x[0][1]>>x[1][1];
    for(int k=0;;k++) {
        x[0][2]=(k-(x[0][0]+x[0][1]));
        x[2][2]=(k-(x[0][0]+x[1][1]));
        x[2][1]=(k-(x[0][1]+x[1][1]));
        x[1][2]=(k-(x[0][2]+x[2][2]));
        x[2][0]=(k-(x[2][1]+x[2][2]));
        x[1][0]=(k-(x[0][0]+x[2][0]));
        if(x[0][2]+x[1][1]+x[2][0]!=k) continue;
        if(x[1][0]+x[1][1]+x[1][2]!=k) continue;
        break;
    }
    REP(i,3) {
        REP(j,3) {
            cout<<x[i][j];
            if(j!=3) cout<<" ";
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
def main():
    while True:
        n,a,b,c,x = map(int,input().split())
        if (n,a,b,c,x) == (0,0,0,0,0):
            return
        yy = list(map(int,input().split()))
        yi = 0
        for i in range(10002):
            if yi == len(yy):
                print(i-1)
                break
            elif i > 10000:
                print(-1)
                break
            if x == yy[yi]:
                yi += 1
            x = (a * x + b) % c

if __name__ == '__main__':
    main()



Measured memory_bytes: 5616
N, T = map(int, input().split())
ct = [list(map(int, input().split())) for _ in range(N)]
costs = list(filter(lambda x: x[1] <= T, ct))
if len(costs) == 0:
  print('TLE')
else:
  costs.sort(key=lambda x: x[0])
  print(costs[0][0])

Measured memory_bytes: 3060
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vector<ll>> mat;
ll p=pow(10,9)+7;

//行列のサイズ
int m;

//DPの更新
vec matmul(vec& dp,mat& mt){
    vec ret(m,0);
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++)
            ret[i]+=(mt[i][j]*dp[j])%p;
    }
    return ret;
}

//遷移行列の更新
mat update(mat& mt){
    mat ret(m,vec(m,0));
    for(int i=0;i<m;i++){
        for(int j=0;j<m;j++){
            for(int k=0;k<m;k++)
                ret[i][j]+=(mt[i][k]*mt[k][j])%p;
        }
    }
    return ret;
}

//累乗
void matpow(vec& dp,mat& mt,int k){
    m=dp.size();
    while(k>0){
        if(k & 1)dp=matmul(dp,mt);
        mt=update(mt);
        k/=2;
    }
}

int main(){
    int N;cin>>N;
    map<int,int> mp;
    for(int i=0;i<N;i++){
        int a;cin>>a;
        mp[a]++;
    }
    vec dp(1);
    mat mt(1,vec(1));

    dp[0]=1;mt[0][0]=2;

    if(N%2==0){
        bool b=true;
        int i=1;
        for(auto itr=mp.begin();itr!=mp.end();itr++){
            if(!(itr->first==i && itr->second==2)){
                b=false;
                break;
            }
            i+=2;
        }
        if(b){
            matpow(dp,mt,N/2);
            cout<<dp[0]<<endl;
            return 0;
        }
        else{
            cout<<0<<endl;
            return 0;
        }
    }
    else{
        auto itr=mp.begin();
        if(itr->first==0 && itr->second==1){
            bool b=true;
            int i=2;
            itr++;
            while(itr!=mp.end()){
                if(!(itr->first==i && itr->second==2)){
                    b=false;
                    break;
                }
                i+=2;
                itr++;
            }
            if(b){
                matpow(dp,mt,N/2);
                cout<<dp[0]<<endl;
                return 0;
            }
            else{
                cout<<0<<endl;
                return 0;
            }
        }
        else{
            cout<<0<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3200
import io, sys, atexit, os
import math as ma
from sys import exit
from decimal import Decimal as dec
from itertools import permutations
from itertools import combinations


def li ():
	return list (map (int, sys.stdin.readline ().split ()))


def num ():
	return map (int, sys.stdin.readline ().split ())


def nu ():
	return int (input ())


def find_gcd ( x, y ):
	while (y):
		x, y = y, x % y
	return x


def lcm ( x, y ):
	gg = find_gcd (x, y)
	return (x * y // gg)



mm = 1000000007
def solve ():
	t = 1
	for tt in range (t):
		n=nu()
		if(n%2==0):
			print(n//2-1)
		else:
			print(n//2)








if __name__ == "__main__":
	solve ()

Measured memory_bytes: 61548
#include <bits/stdc++.h>
using namespace std;
typedef long long int lld;
typedef pair<int,int> pi;
typedef pair<lld,lld> pl;
typedef vector<int> vit;
typedef vector<vit> vitt;
typedef vector<lld> vlt;
typedef vector<vlt> vltt;
typedef vector<pi> vpit;
typedef vector<vpit> vpitt;
typedef long double ld;
#define x first
#define y second
#define pb push_back
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define mk(a,b) make_pair(a,b)
bool isrange(int y,int x,int n,int m){
	 if(0<=y&&y<n&&0<=x&&x<m) return true;
	 return false;
}
int dy[4] = {1,0,-1,0},dx[4]={0,1,0,-1},ddy[8] = {1,0,-1,0,1,1,-1,-1},ddx[8] = {0,1,0,-1,1,-1,1,-1};
const lld INF = 1e18;
struct MCMF{
	struct Edge{
		int to,rev,cap;
		lld cost;
		Edge(int to, int rev, int cap, lld cost):to(to),rev(rev),cap(cap),cost(cost){
		}
	};
	vector<vector<Edge>> graph;
	vector<pi> par;
	int n,src,snk;
	MCMF(int n, int src, int snk):n(n),src(src),snk(snk){
		graph.resize(n+5);
		par.resize(n+5);
	}
	void push_edge(int a, int b, int capa, lld cst){
		graph[a].pb(Edge(b,graph[b].size(),capa,cst));
		graph[b].pb(Edge(a,graph[a].size()-1,0,-cst));
	}
	bool SPFA(){
		vector<int> inq;
		vector<lld> dst;
		inq.resize(n+5,0);
		dst.resize(n+5,INF);		
		queue<int> q;
		q.push(src); inq[src]=1; dst[src]=0;
		while(!q.empty()){
			int h=q.front(); q.pop();
			inq[h]=0;
			for(int i=0;i<(int)graph[h].size();i++){
				auto e=graph[h][i];
				if(e.cap<=0) continue;
				if(dst[h]<INF && dst[e.to]>dst[h]+e.cost){
					dst[e.to]=dst[h]+e.cost; par[e.to]={h,i};
					if(inq[e.to]==0){
						q.push(e.to);
						inq[e.to]=1;
					}
				}
			}
		}
		return dst[snk]!=INF;
	}
	pl flow(){
		lld work=0,money=0;
		while(SPFA()){
			lld c=0, f=INF;
			for(int i=snk;i!=src;i=par[i].x){
				auto &e=graph[par[i].x][par[i].y];
				f=min(f,(lld)e.cap);
				c+=e.cost;
			}
			work+=f;
			money+=f*c;
			for(int i=snk;i!=src;i=par[i].x){
				auto &e=graph[par[i].x][par[i].y];
				e.cap-=f;
				graph[e.to][e.rev].cap+=f;
			}
		}
		return {work,money};
	}
};
string arr[55];
int main(void){
	int n,m;
	cin >> n >> m;
	for(int e=0;e<n;e++) cin >> arr[e];
	int st = 0,en=n*m+50;
	MCMF gh = MCMF(n*m+100,st,en);
	for(int e=0;e<n;e++){
		for(int p=0;p<m;p++){
			if(arr[e][p]=='o') gh.push_edge(st,e*m+p+1,1,0);
			if(arr[e][p]!='#'){
				if(e!=n-1){
					if(arr[e+1][p]!='#'){
						gh.push_edge(e*m+p+1,(e+1)*m+p+1,101,-1);
					}
				}
				if(p!=m-1){
					if(arr[e][p+1]!='#'){
						gh.push_edge(e*m+p+1,e*m+p+2,101,-1);
					}
				}
				gh.push_edge(e*m+p+1,en,1,0);
			}
		}
	}
	printf("%lld",-gh.flow().y);
	return 0;
}


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

struct StoreInfo {
	int price;
	int num;
};

int main() {
	int N, M;
	std::cin >> N >> M;

	std::vector<StoreInfo> list(N);
	for(auto &e : list) {
		std::cin >> e.price >> e.num;
	}

	// 値段でソート
	std::sort(list.begin(), list.end(), [](const auto &a, const auto &b) {
		return a.price < b.price;
	});

	long long result = 0;
	int rest = M;
	while(rest > 0) {
		// 不足分　または　在庫全部
		const int numBuy = std::min(rest, list.front().num);

		// 購入
		result += (long long)list.front().price * numBuy;
		list.front().num -= numBuy;
		rest -= numBuy;

		// もし在庫がなくなったら消去
		if(list.front().num == 0) {
			list.erase(list.begin());
		}
	}

	std::cout << result << std::endl;

	return 0;
}


Measured memory_bytes: 1024
#include<stdio.h>
int a,b,c,d,ap,bp;
int main(){
	
	
	while(1){
		scanf("%d",&c);
		if(c==0)break;
		ap=0,bp=0;
		for(d=0;d<c;d++){
			scanf("%d %d",&a,&b);
			if(a>b)ap+=a+b;
			if(a<b)bp+=a+b;
			if(a==b)ap+=a,bp+=b;
		}
		printf("%d %d\n",ap,bp);
	}
	 
	return 0;
}

Measured memory_bytes: 0
// tsukasa_diary's programing contest code template
#include <bits/stdc++.h>
using namespace std;
#define TSUKASA_DIARY_S_TEMPLATE
// define
#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) int((a).size())
#define cauto const auto
// typedef
typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;
template< typename T > using Vec = vector< T >;
template< typename T > using Matrix = Vec< Vec< T > >;
template< typename T > using USet = unordered_set< T >;
template< typename T, class C > using MyUSet = unordered_set< T, C >;
template< typename T, typename F > using UMap = unordered_map< T, F >;
template< typename T, typename F, class C > using MyUMap = unordered_map< T, F, C >;
// hash
class PiiHash { public: size_t operator () (const pii& p) const { return (p.first << 16) | p.second; } };
// popcount
inline int POPCNT(int x) { return __builtin_popcount(x); }
inline int POPCNT(lint x) { return __builtin_popcount(x); }
// inf
const int iINF = 1L << 30;
const lint lINF = 1LL << 60;
// eps
const Double EPS = 1e-9;
const Double PI = acos(-1);
// inrange
template< typename T >
inline bool in_range(T v, T mi, T mx) { return mi <= v && v < mx; }
template< typename T >
inline bool in_range(T x, T y, T W, T H) { return in_range(x,0,W) && in_range(y,0,H); }
// neighbor clockwise
const int DX[4] = {0,1,0,-1}, DY[4] = {-1,0,1,0};
const int DX_[8] = {0,1,1,1,0,-1,-1,-1}, DY_[8] = {-1,-1,0,1,1,1,0,-1};
// variable update
template< typename T > inline void modAdd(T& a, T b, T mod) { a = (a + b) % mod; }
template< typename T > inline void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > inline void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > inline void maxUpdate(T& a, T b) { a = max(a, b); }
// converter
template< typename F, typename T >
inline void convert(F& from, T& to) {
	stringstream ss;
	ss << from; ss >> to;
}



lint n, m, x[100010], y[100010];
const lint mod = (lint)1e9 + 7;

void solve() {
	lint ansx = 0, ansy = 0;
	for_(i,0,n-1) modAdd(ansx, (x[i + 1] - x[i]) * (i + 1) * (n - i - 1), mod);
	for_(i,0,m-1) modAdd(ansy, (y[i + 1] - y[i]) * (i + 1) * (m - i - 1), mod);
	cout << (ansx * ansy) % mod << endl;
}

int main() {
	cin >> n >> m;
	for_(i,0,n) cin >> x[i];
	for_(i,0,m) cin >> y[i];
	solve();
}

Measured memory_bytes: 1792
import java.util.*;

import static java.lang.System.*;

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

        int[] X = new int[M];
        for (int i = 0; i < M; i++) {
            X[i] = sc.nextInt();
        }

        Arrays.sort(X);

        int[] xDiff = new int[M - 1];
        for (int i = 0; i < M - 1; i++) {
            xDiff[i] = Math.abs(X[i] - X[i+1]);
        }

        Arrays.sort(xDiff);
        int ans = 0;
        for (int i = 0; i < M - N; i++) {
            ans += xDiff[i];
        }

        out.println(ans);
    }
}


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int f(int n)
{
    return ((n & 1) ? 3 * n + 1 : n / 2);
}

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

    cout << (n + 110) / 111 * 111 << '\n';
    return 0;
}


Measured memory_bytes: 3532
// inputに入力データ全体が入る
function Main(input) {
	var tmp = input.split(" ");
	//文字列から10進数に変換するときはparseIntを使います
	var a = parseInt(tmp[0], 10);
	var b = parseInt(tmp[1], 10);
  	var r = a * b / 2;
  //出力
	console.log('%d',r);
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));


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

int main()
{
    long n;
    long long stool=0;
    long temp;
    cin >> n;
    long a[n];
    for(long i=0;i<n;i++){
        cin >> a[i];
    }
    for(long i=0;i<n-1;i++){
        if(a[i+1]<a[i]){
            temp = a[i]-a[i+1];
            stool = stool+temp;
            a[i+1]=a[i];
        }
    }
    cout << stool << "\n";
}

Measured memory_bytes: 4704
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	int n, m, i, j, k, ans, x, v;
	cin >> n >> m;
	vector<string> s(n);
	for (i = 0; i < n; i++) cin >> s[i];

	vector<vector<vector<int>>> dp(n, vector<vector<int>>(m, vector<int>(2, 10000000)));

	for (i = 0; i < n; i++) {
		for (j = 0; j < m; j++) {
			if (i + j == 0) {
				if (s[0][0] == '.') {
					dp[0][0][0] = 0;
					dp[0][0][1] = 100000;
				}
				else {
					dp[0][0][0] = 100000;
					dp[0][0][1] = 1;
				}
			}
			else {
				if (s[i][j] == '.') {
					x = 0;
					if (i > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i - 1][j][0], dp[i - 1][j][1]));
					if (j > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i][j - 1][0], dp[i][j - 1][1]));

					if (i > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1] + 1));
					if (j > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1] + 1));
				}
				else {
					x = 1;
					if (i > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1]));
					if (j > 0) dp[i][j][0] = min(dp[i][j][0], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1]));

					if (i > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i - 1][j][0] + 1, dp[i - 1][j][1]));
					if (j > 0) dp[i][j][1] = min(dp[i][j][1], min(dp[i][j - 1][0] + 1, dp[i][j - 1][1]));
				}
			}
		}
	}

	ans = min(dp[n - 1][m - 1][0], dp[n - 1][m - 1][1] + 1);
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 896
import java.util.*;

public class Main{
    
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        
        int h = sc.nextInt();
        int w = sc.nextInt();
        int d = sc.nextInt();
        
        int[][] pos = new int[h*w+1][2];
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                int idx = sc.nextInt();
                pos[idx] = new int[]{j, i};
            }
        }
        
        int[][] rsk = new int[d][h*w/d+1];
        for(int i=d+1; i<=h*w; i++){
            int dif = Math.abs(pos[i][0] - pos[i-d][0]) + Math.abs(pos[i][1] - pos[i-d][1]);
            rsk[i%d][i/d] = rsk[i%d][i/d-1] + dif;
        }
        
        int q = sc.nextInt();
        for(int i=0; i<q; i++){
            int l = sc.nextInt();
            int r = sc.nextInt();
            int di = l%d;
            int dl = l/d;
            int dr = r/d;
            System.out.println(rsk[di][dr] - rsk[di][dl]);
        }
    }
}


Measured memory_bytes: 98820
# print(str(I).replace(',','').replace('[','').replace(']',''))

def insertion_sort(A, N, g):
    cnt = 0
    for i in range(g, N):
        v = A[i]
        j = i - g
        while (j >= 0 and A[j] > v):
            A[j+g] = A[j]
            j -= g 
            cnt += 1
        A[j+g] = v
    return cnt
    
def shell_sort(A, N, G):
    cnt = 0
    for i in range(len(G)):
        cnt += insertion_sort(A, N, G[i])
    return cnt

def calc_g(N):
    h = 1
    G = []
    while True:
        if (h > N):
            break
        G.insert(0,h)
        h = 3 * h + 1
    return G

N = int(input())
A = [int(input()) for _ in range(N)]
G = calc_g(N)

cnt = shell_sort(A, N, G)

print(len(G))
print(str(G).replace(',','').replace('[','').replace(']',''))
print(cnt)
[print(x) for x in A]


Measured memory_bytes: 53196
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define eps 1e-6
#define mp make_pair
const long long INF=1e18+2;
const int MX=200353;
int N, M, k;
int arr[MX];
ll fact[MX];
ll inv[MX];
ll md=1e9+7;
ll pw(ll x, ll p)
{
    if(!p) return 1;
    ll ret=pw(x, p>>1);
    ret=(ret*ret)%md;
    if(p&1) ret=(ret*x)%md;
    return ret;
}
ll cl(int sx, int sy, int ex, int ey)
{
    int R=abs(sx-ex);
    int D=abs(sy-ey);
   // cout<<"h "<<R<<" "<<D<<'\n';
    ll ret=fact[R+D];
    ret*=inv[R];
    ret%=md;
    ret*=inv[D];
    ret%=md;
    return ret;
}
int n, m;
int f(int i, int j)
{
    if(i == n-1 && j == m-1) return 1;
    int ret=0;
    if(i+1 < n) ret+=f(i+1, j);
    if(j+1 < m) ret+=f(i, j+1);
    return ret;
}
int main()
{

    int h, w;
    scanf("%d%d%d%d", &N, &M, &h, &w);
    fact[0]=1;
    inv[0]=pw(fact[0], md-2);
    for(int i=1;i<MX-2;i++) fact[i]=(fact[i-1]*i)%md, inv[i]=pw(fact[i], md-2);
//    cout<<fact[11];
//    return 0;
    ll an=0;
    int i=N-h+1;
    for(int j=w+1;j<=M;j++)
    {
     //   cout<<i<<' '<<j<<" ";
        an+=cl(i, j, N, M)*cl(1, 1, i-1, j);
        an%=md;
    }
    cout<<an<<'\n';
    return 0;
}



Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_ll.hpp>
//typedef boost::multiprecision::cpp_ll ll;
typedef long double dd;
#define i_7 (ll)(1E9+7)
//#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E18;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define endl "\n"
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);



int main(){fastio
    ll n;cin>>n;
    ll x[n],y[n];
    rep(i,0,n-1){
        ll a,b;cin>>a>>b;
        x[i]=a+b;
        y[i]=a-b;
    }
    ll X[2]={inf,-inf};
    ll Y[2]={inf,-inf};
    rep(i,0,n-1){
        X[0]=min(X[0],x[i]);
        X[1]=max(X[1],x[i]);
        Y[0]=min(Y[0],y[i]);
        Y[1]=max(Y[1],y[i]);
    }
    cout<<max(Y[1]-Y[0],X[1]-X[0])<<endl;
    
    return 0;
}





Measured memory_bytes: 6764
#!/usr/bin/env ruby

def rotate(dice,direction)
    case direction
    when "N"
        return [dice[1],dice[5],dice[2],dice[3],dice[0],dice[4]]
    when "E"
        return [dice[3],dice[1],dice[0],dice[5],dice[4],dice[2]]
    when "W"
        return [dice[2],dice[1],dice[5],dice[0],dice[4],dice[3]]
    when "S"
        return [dice[4],dice[0],dice[2],dice[3],dice[5],dice[1]]
    when "Z"
        return [dice[0],dice[2],dice[4],dice[1],dice[3],dice[5]]
    end
end

def changetop(dice,i)
    case i
    when 0 
        return dice
    when 1 
        return rotate(dice,"N")
    when 2
        return rotate(dice,"W")
    when 3
        return rotate(dice,"E")
    when 4
        return rotate(dice,"S")
    when 5
        return rotate(rotate(dice,"N"),"N")
    end
end

def judge(diceA,diceB)
    6.times do |index|
        tempdice = changetop(diceB,index)
        if tempdice == diceA then
            return true
            exit
        end
        3.times do 
            tempdice = rotate(tempdice,"Z")
            if tempdice == diceA then
                return true
                exit
            end
        end
    end
    return false
end

loop_number = gets.to_i
dices = []
loop_number.times do
    dices << gets.split.map(&:to_i) 
end
dices = dices.combination(2).to_a

dices.count.times do |index|
    if judge(dices[index][0],dices[index][1]) == true then
        puts "No"
        exit
    end
end
puts "Yes"


Measured memory_bytes: 7100
S=input()
if S=="SUN":
  print(7)
elif S=="MON":
  print(6)
elif S=="TUE":
  print(5)
elif S=="WED":
  print(4)
elif S=="THU":
  print(3)
elif S=="FRI":
  print(2)
elif S=="SAT":
  print(1)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <vector>
#include <climits>
using namespace std;

int n, x, m = INT_MAX, gcd_;

int gcd(int a, int b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {
	int whe;
	cin >> n;
	vector<int> a;
	for (int i=0;i<n;i++) {cin >> x; a.push_back(x);}
	gcd_=gcd(a[0],a[1]); for (int i=0;i<n;i++) gcd_=gcd(a[i],gcd_);
	cout << gcd_ << endl;
	return 0;
}


Measured memory_bytes: 892
from collections import Counter
import numpy as np
n = int(input())
v = list(map(int,input().split()))

# v = [1, 1] * 5
# v += [2, 2] * 4
v = np.array(v)

if len(np.unique(v)) == 1:
    print(int(len(v)/2))
else:
    vodd = v[np.arange(0,len(v),2)]
    odd_count = Counter(vodd)

    veven = v[np.arange(1,len(v),2)]
    even_count = Counter(veven)
    

    d_odd = []
    odd_lis = list(odd_count.keys())
    for key in odd_count.keys():
        d_odd.append(odd_count[key])

    d_even = []
    even_lis = list(even_count.keys())
    for key in even_count.keys():
        d_even.append(even_count[key])

    
    if even_lis[np.argmax(d_even)] != odd_lis[np.argmax(d_odd)]:
        score = np.max(d_even) + np.max(d_odd)
    else:
#         print('a')
        score1 = d_even[np.argsort(d_even)[-1]] + d_odd[np.argsort(d_odd)[-2]]
        score2 = d_even[np.argsort(d_even)[-2]] + d_odd[np.argsort(d_odd)[-1]]
        score = max(score1,score2)
    print(len(v) - score)

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

int main() {
  int N;
  cin >> N;
  vector <int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A.at(i);
  int x = 0;
  for (int i = 0; i < N; i++) {
    if (A.at(i) % 2 == 0) {}
    else
      x++;
  }
  if (x % 2 == 0)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine());
        var seqA = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var seqB = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var seqC = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();

        var s = seqB[seqA[0] - 1];
        for (int i = 1; i < n; ++i)
        {
            s += seqB[seqA[i] - 1];
            if (seqA[i] == seqA[i - 1] + 1)
            {
                s += seqC[seqA[i - 1] - 1];
            }
        }
        Console.WriteLine(s);
    }
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    map<int,int> ma;
    for(int i=0;i<N;i++){
        cin >> a[i];
        for(int j=1;j<=8;j++){
            if(a[i]<400*j&&a[i]>=400*(j-1)){
                ma[j]++;
            }
        }
        if(a[i]>=3200) ma[9]++;
    }
    int ans=0;
    int tmp=0;
    for(auto it=ma.begin();it!=ma.end();it++){
        if(it->second!=0&&it->first!=9) ans++;
        if(it->second!=0&&it->first==9) tmp+=it->second;
    }
    cout << max(ans,1) << " " << ans+tmp << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define enld endl //* missspell check
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

void solve(long long N, std::vector<long long> A){
    N-=2;
    sort(ALL(A)); 
    ll ans = A.back(); A.pop_back();
    reverse(ALL(A));
    ll i;
    for(i = 1; 2*i <= N; i++){
        ans += A[i-1]*2;
    }
    if( N % 2) ans += A[i-1];
    cout<<ans<<endl;
}
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 4448
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
const ll M = 998244353;
ll n,x,m;
//string s;
int main()
{
    cin>>n>>x>>m;
    x%=m;
    vector<bool>vis(m,0);
    ll ans=0;
    ll cnt=0;
    while(1)
    {
        //cout<<x<<" ";
        if(vis[x] || cnt>=n)break;
        vis[x]=1;
        ans+=x;
        x=x*x%m;
        cnt++;
    }
    //cout<<n<<" "<<cnt<<" ";
    n-=cnt;
    ll tem=0;
    cnt=0;
    loop(i,0,m)vis[i]=0;
    //cout<<n<<" "<<ans;
    while(1)
    {
        if(vis[x] || cnt>=n)break;
        //cout<<"yup";
        vis[x]=1;
        tem+=x;
        x=x*x%m;
        cnt++;
    }
    //cout<<cnt<<" "<<tem<<" ";
    if(cnt<n)
    {
        ll k=n/cnt;
        ans+=tem*k;
        n%=cnt;
        while(n-->0)
        {
            ans+=x;
            x=x*x%m;
        }
    }
    else ans+=tem;
    cout<<ans;
}

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

int main() {
  LL n;
  cin >> n;
  vector<LL> a(n);
  vector<LL> b(n + 1);
  for (int i = 0; i < n; i ++) {
    cin >> a.at(i);
    b.at(i + 1) = b.at(i) + a.at(i);
  }

  LL cnt = 0;
  LL tmp = 1;
  sort(b.begin(), b.end());
  for (int i = 1; i <= n; i ++) {
    if (b.at(i) == b.at(i - 1)) {
      tmp ++;
    } else {
      cnt += (tmp * (tmp - 1)) / 2; //nC2の組み合わせ
      tmp = 1;
    }
  }
  cnt += (tmp * (tmp - 1)) / 2;

  cout << cnt << endl;
}


Measured memory_bytes: 3328
#coding: UTF-8
import math

def PF(a):
    for k in range(len(a)):
        area = ""
        H = int(a[k].split(" ")[0])
        W = int(a[k].split(" ")[1])
        if H == 0 and W == 0:
            break
        for j in range(H):
            if j == 0 or j == (H-1):
                for i in range(W):
                    area += "#"
            else:
                area = "#"
                for i in range(1,W-1):
                    area += "."
                area += "#"
            print(area)
            area = ""
        print("")

if __name__=="__main__":
    a = []
    for i in range(300):
        a.append(input())
        if a[i] == "0 0":
            break
    PF(a)    

Measured memory_bytes: 7792
from bisect import bisect_right

def main():
    N = int(input())
    A = list(map(int, input().split()))

    money = 1000
    stock = 0
    old_trend = 0
    trend = A[1] - A[0]
    buy_point = []
    bought_point = []

    for i in range(N-1):
        trend = A[i+1] - A[i]
        if trend * old_trend > 0 or trend == 0:
            continue
        else:
            if trend > 0:
                buy_point.append(i)
            if trend < 0:
                bought_point.append(i)
        old_trend = trend

    if len(buy_point) > len(bought_point):
        bought_point.append(N-1)

    for i in range(N):
        if i in buy_point:
            buy = money//A[i]
            stock += buy
            money -= buy*A[i]

        
        if i in bought_point:
            bought = stock
            stock = 0
            money += bought * A[i]
    print(money)
    


if __name__ == "__main__":
    main()

Measured memory_bytes: 9248
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!{
      s: chars,
    }
    let n = s.len();

    use std::collections::VecDeque;
    let mut ans = vec![0; n];
    let mut q = VecDeque::new();
    for i in 0..n {
        if s[i] == 'R' {
            q.push_back(i);
        } else {
            while let Some(idx) = q.pop_back() {
                ans[i - (i-idx)%2] += 1;
            }
        }
    }

    let mut q = VecDeque::new();
    for i in (0..n).rev() {
        if s[i] == 'L' {
            q.push_back(i);
        } else {
            while let Some(idx) = q.pop_back() {
                ans[i + (idx-i)%2] += 1;
            }
        }
    }
    for i in 0..n {
        let a = ans[i];
        if i != n-1 {
            puts!("{} ", a);
        } else {
            puts!("{}", a);
        }
    }
    puts!("{}\n", "");
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)
#define vvl(v,w,h,init) vector<vector<ll>> v(w,vector<ll>(h,init));

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;
using pll = pair<ll,ll> ;

const int mod = 1000000007;
constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0,1,-1,1,-1};
const int dx[] = {0,-1,0,1,1,-1,-1,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll a,b,c,d,l;
  cin >> l >> a >> b >> c >> d;
  if(a%c == 0) --a;
  if(b%d == 0) --b;
  l -= max(a/c,b/d)+1;
  cout << l << endl;
  return 0;
}

Measured memory_bytes: 3112
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;


int main()
{
    int n;scanf("%d",&n);
    for (int i=1;i<=n;++i){
        if ( i+i*8/100 == n ){
            printf("%d\n",i);
            return 0;
        }

    }
    printf(":(");
}





Measured memory_bytes: 128
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int n,k;
	cin>>n>>k;
	string s;
	cin>>s;
	int rr=0,rl=0,lr=0,ll=0;
	rep(i,n-1){
		if(s[i]=='R'){
			if(s[i+1]=='R') rr++;
			else rl++;
		}else{
			if(s[i+1]=='R') lr++;
			else ll++;
		}
	}
	int min =lr+rl;
	min = (k*2<min)?k*2:min;
	cout<<ll+rr+min<<endl;


	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main(){
  int i,N,cnt=0,f=1;
  string s;cin>>s;
  N=s.size();
  for(i=0;i<N;i++){
    if(i<N&&s[i]==s[i+1]&&f>0){
      i++;
      f=0;
    }else{
      f=1;
    }
    cnt++;
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <random>
#include <chrono>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111;
using namespace std;
using lint = long long;

int main() {

	int N;
	cin >> N;
	vector <int> a(N), memo;
	for (int i = 0; i < N; i++) cin >> a[i];

	memo.emplace_back(a[0]);

	for (int i = 1; i < N; i++) {
		
		if (memo.back() >= a[i]) memo.emplace_back(a[i]);
		else *upper_bound(memo.begin(), memo.end(), a[i], greater<int>()) = a[i];

	}

	cout << memo.size();

}


Measured memory_bytes: 1276
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define all(x) (x).begin(),(x).end()
#define INF 10000000
using ll = long long ;
ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}
template< int id > struct CompTupleBy
{
  template<class T> 
  bool operator()( const T& a, const T& b ) const {
    return std::get<id>(a) < std::get<id>(b);
  }
};

using namespace std;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int c[n];
    int s[n];
    int f[n];
    rep(i,n-1){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i=0;i<n-1;i++){
        int t=s[i]+c[i];
        for(int j=i+1;j<n-1;j++){
            if (t>s[j]){
                t += (f[j]-t%f[j])%f[j] + c[j];
            }else{
                t = s[j] + c[j];
            }
        }
        cout << t << endl;
    }
    cout << 0 << endl;

}

Measured memory_bytes: 256
# problem C
from collections import Counter

N = int(input())
ls = list(map(int, input().split()))

ls2 = []
for i in range(N):
    ls2.append(ls[i])
    ls2.append(ls[i]-1)
    ls2.append(ls[i]+1)

print(max(Counter(ls2).values())) # counts the elements' frequency   

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

int main() {
    unsigned long long N, K;
    cin >> N >> K;
    unsigned long long ans = 0;
    unsigned long long max, min;



    for (unsigned long long i=K; i<=N+1; i++) {
        max = i*(2*N-i+1)/2;
        min = i*(i-1)/2;
        ans += max - min + 1;
    }
    cout << ans%1000000007 << endl;
    return 0;
}

Measured memory_bytes: 3608