akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>

using namespace std;

#define REP(i,n) for(int i=0;i<int(n);i++)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
typedef long long ll;
typedef pair<int,int> P;

int s[100010],c[100010];
int n,m;

int main(void){
	int i;

	cin.tie(0);
	ios_base::sync_with_stdio(false);

	cin >> n >> m;
	for(i=1;i<=n;i++) s[i]=1;
	c[1]=1;

	for(i=1;i<=m;i++){
		int x,y;
		cin >> x >> y;
		if(s[x]==1 && c[x]==1){
			s[x]--;
			c[x]=0;
			s[y]++;
			c[y]=1;
		}
		else if(s[x]>=2 && c[x]==1){
			s[x]--;
			s[y]++;
			c[y]=1;
		}
		else{
			s[x]--;
			s[y]++;
		}
	}

	int ans=0;
	for(i=1;i<=n;i++) ans+=c[i];

	cout << ans << endl;



	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int i,n,sum = 0;
    string s;
    cin >> s;
    n = stoi(s);
    for(i=0; i<s.length(); i++){
        sum += (int)(s[i]-'0');
    }
    if(n%sum == 0){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = int(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = int(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = int(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = int(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = int(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    lint n, k;
    cin >> n >> k;

    lint ans = 0;
    for(lint b = 1 ; b <= n ; ++b){
        if(b <= k){
            continue;
        }
        ans += (n / b) * (b - k);
        ans += max(n - (n / b * b + k) + 1LL, 0LL);
        if(k == 0LL){
            --ans;
        }
    }
    cout << ans << endl;

    return 0;
}

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

struct TCoordinate
{
	double X;
	double Y;
};

TCoordinate GetSplitMiddle(TCoordinate A, TCoordinate B)
{
	TCoordinate C = {(A.X + B.X) / 2, (A.Y + B.Y) / 2};
	C.X += (sqrt(3) / 6) * (A.Y - B.Y);
	C.Y += (sqrt(3) / 6) * (B.X - A.X);
	return C;
}

void StdOutput(const TCoordinate& Point)
{
	cout << Point.X  << ' ' << Point.Y  << endl;
}

void Koch(int n, const TCoordinate& Start, const TCoordinate& End)
{
	if(n == 0){
		return;
	}
	n--;
	
	TCoordinate SplitStart  = { (2 * Start.X + End.X) / 3, (2 * Start.Y + End.Y) / 3};
	TCoordinate SplitMiddle = GetSplitMiddle(Start, End);
	TCoordinate SplitEnd    = { (Start.X + 2 * End.X) / 3, (Start.Y + 2 * End.Y) / 3};
	
	Koch(n, Start,       SplitStart);
	StdOutput(SplitStart);
	Koch(n, SplitStart,  SplitMiddle);
	StdOutput(SplitMiddle);
	Koch(n, SplitMiddle, SplitEnd);
	StdOutput(SplitEnd);
	Koch(n, SplitEnd,    End);
}

int main()
{
	//??????2?????¨??°???????????°??????????????\???????????????????????????????§?????????????????????¨???
	int n;
	cin >> n;
	TCoordinate Start = {  0, 0};
	TCoordinate End   = {100, 0};
	StdOutput(Start);
	Koch(n, Start, End);
	StdOutput(End);
	return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
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; }
//-------------------
int a,b,c,d,e;
vector<PII> v;

int main(){
    FOR(i,1,5){
        int a; cin >> a; 
        int resi;
        if(a%10 == 0) resi = 10;
        else resi = a%10;
        v.push_back(MP(resi,a));
    }
    sort(ALL(v));
    int ans = 0;
    FOR(i,1,4){
        if(v[i].SE%10 != 0){
            ans += (v[i].SE/10 + 1)*10;
        }else{
            ans += (v[i].SE/10)*10;
        }
    }
    ans += v[0].SE;
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
using ld = long double;
const ll mod =  998244353 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

int bsearch(const vector<ll>& a, ll x){
  int lft = 0;
  int rgt = a.size();
  while (rgt - lft > 1) {
    int mid = (lft + rgt) / 2;
    if(a[mid] < x) {
      lft = mid;
    }
    else {
      rgt = mid;
    }
  }
  return lft;
}
signed main() {
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int bit_length = ceil(log2(n));
  vector<vector<ll>> g(n ,vector<ll>(n));
  REP(k, bit_length) {
    int bit = 1 << k;
    REP(i, n) {
      REP_FROM(j, i+1, n) {
        if((i & bit) != (j & bit)) {
          g[i][j] = k + 1;
        }
      }
    }
  }
  REP(i, n) {
    REP_FROM(j, i+1, n) {
      cout << g[i][j] << " ";
    }
    cout << endl;
  }
  return 0; 
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll
#define INF 1e16
#define mod 1000000007
int main(){
    ll a,b;
    cin>>a>>b;
    if(a < 10 and b < 10) cout<<a*b<<endl;
    else cout<<-1<<endl;
    return 0;
}


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

#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define st first
#define nd second
#define endl '\n'
#define what_is(x) cerr << #x << " is " << x << endl;
#define what_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << e << ' '; cerr << '\n'; //vector, set
#define what_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << x[i] << ' '; cerr <<  '\n'; //n first element of array
#define cerr_pair(x) '{' << x.st << ", " << x.nd << '}'
#define pwhat_is(x) cerr << #x << " is " << cerr_pair(x) << endl;
#define pwhat_is_v(x) cerr << #x << " is "; for(auto&e: (x)) cerr << cerr_pair(e) << ' '; cerr << '\n'; //vector, set
#define pwhat_is_a(x, n) cerr << #x << " is "; for(int i=0;i<n;i++) cerr << cerr_pair(x[i]) << ' '; cerr <<  '\n'; //n first element of array
// #define int long long
// #define pow mypow

typedef pair<int,int> pii;
const int N = 1e5+5;
const int INF = 1e9+5;
const int MOD = 1e9+7;

int n, cnt[N];
long long sum = 0LL;
int32_t main()
{
	IOS
	// freopen("input.txt", "r", stdin);
	cin >> n;
	for(int i=0; i<n; i++) {
		int a; cin >> a;
		cnt[a]++;
		sum += a;
	}
	int q; cin >> q;
	while(q--){
		int b, c; cin >> b >> c;
		sum += 1LL*(c-b)*cnt[b];
		cout << sum << endl;
		cnt[c] += cnt[b];
		cnt[b] = 0;
	}
	
	return 0;
}


Measured memory_bytes: 4004
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<cstring>
#include<queue>
#include<map>
#include<climits>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
using namespace std;
typedef pair<int, int> P;
typedef long long int ll;
typedef pair<ll,ll> LLP;
//#define INF 1000000007
#define ARRAY_MAX 100005
const ll INF = 1e17;

struct SegmentTree{

    int N;
    vector<P> node;
    const int INF = INT_MAX;

    void init(int siz){
        N = 1;
        while(N < siz){
            N *= 2;
        }
        node.resize(2*N-1);
        for(int i = 0;i < N;i++){
            node[i+N-1] = {0,-(i+1)};//釣った数と釣った人の番号
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = max(node[2*i+1],node[2*i+2]);
        }
    }

    /*void build(vector<int>& dat){
        for(int i = 0;i < dat.size();i++){
            node[i+N-1] = dat[i];
        }
        for(int i = N-2;i >= 0;i--){
            node[i] = min(node[2*i+1],node[2*i]+2);
        }
    }*/

    void update(int k,int x){
        k += N-1;
        node[k].first += x;
        while(k > 0){
            k = (k-1)/2;//親
            node[k] = max(node[2*k+1],node[2*k+2]);
        }
    }

    P getMax(int a,int b,int k,int l,int r){
        if(r <= a || b <= l){
            return {-INF,0};
        }
        if(a <= l && r <= b){
            return node[k];
        }
        P vl = getMax(a,b,k*2+1,l,(l+r)/2);
        P vr = getMax(a,b,k*2+2,(l+r)/2,r);
        return max(vl,vr);
    }

    P getMax(int a,int b){
        return getMax(a,b,0,0,N);
    }
};

int main(){

    SegmentTree segt;
    int n,q;
    cin >> n >> q;
    segt.init(n);
    REP(i,q){
        int x,y;
        cin >> x >> y;
        segt.update(x-1,y);
        P ans = segt.getMax(0,n);
        cout << abs(ans.second) << " " << ans.first << endl;
    }



    return 0;
}


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

int main()
{
	string S;
	cin >> S;
	bool flag = false;
	for (int i = 0; i < 3; ++i)
	{
		if (S[i] == S[i+1])
		{
			flag = true;
		}
	}

	if (flag)
	{
		cout << "Bad" << endl;
	}
	else
	{
		cout << "Good" << endl;
	}
	return 0;
}

Measured memory_bytes: 888
using System;

public class AtCoderA
{
    static void Main()
    {
        string s;
        string t;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            s = words[0];
            t = words[1];
        }

        int a;
        int b;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = int.Parse(words[0]);
            b = int.Parse(words[1]);
        }

        string u = Console.ReadLine();

        if (u.Equals(s))
        {
            a--;
        }
        else
        {
            b--;
        }

        Console.WriteLine(a + " " + b);
    }
}

Measured memory_bytes: 11220
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;



int main(){
    string s; cin >> s;
    ll n = s.size();
    bool flag = true;
    rep(i,n){
        if((i+1) % 2 == 0){
            if(s[i]=='L'||s[i]=='U'||s[i]=='D') flag = true;
            else{
                puts("No");
                return 0;
            }
        }else{
            if(s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
                puts("No");
                return 0;
            }
        }
    }
    puts("Yes");
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef  long double ld;
#define inc(i,a,b)  for(long long int i=a;i<=b;i++)
#define dec(i,a,b)  for(long long int i=a;i>=b;i--)
#define fast   ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define pb  push_back
#define all(c)  (c).begin(),(c).end()
#define lv  vector<ll>
#define cv  vector<char>
#define dv  vector<ld>
#define rall(c)  (c).rbegin(),(c).rend()
#define lpr pair<ll,ll>
#define mp make_pair
#define input(c) ll c;cin>>c;
#define lmap map<ll,ll>
#define vinp(a,n) inc(i,1,n){ input(k); a.pb(k); }
#define LIM 1000000007
#define F first
#define S second
#define fr(n) inc(i,0,n-1)
#define fri(n,a) inc(i,0,n-1){ cin>>a[i]; }
void solve()
{
	ll i,j;
	ll a,b;
	cin>>a>>b;
	if(a-2*b<0)
		cout<<0;
	else
		cout<<a-2*b;
}
int main()
{
	fast;
	ll t=1;
    //cin>>t;
	while(t--)
    solve();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;
#define ll long long
#define N 1000000007

int c[10][10];

int main()
{
    int n;
    cin >> n;
    for (int k = 0; k <= 6; k++) {
        int b = pow(10, k);
        for (int i = b; i < min(n + 1, 10 * b); i++) {
            c[i / b][i % 10]++;
        }
    }
   ll cnt = 0;
    for (int i = 1; i < 10; i++) {
        for (int j = 1; j < 10; j++) {
            cnt += c[i][j] * c[j][i];
        }
    }
   cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 4088
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>
#include <bitset>

using namespace std;

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    int n;
    cin >> n;
    ll sum = 0;
    ll minb = INFL;
    bool same = true;
    while(n--) {
        ll a, b;
        cin >> a >> b;
        sum += a;
        if(a > b) chmin(minb, b);
        if(a != b) same = false;
    }
    ll ans = 0;
    if(!same) ans = sum - minb;
    cout << ans << endl;
}

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

Measured memory_bytes: 3552
// 17-07-19
// Ad-Hoc
// 3

#include <bits/stdc++.h>

#define all(A) begin(A), end(A)
#define rall(A) rbegin(A), rend(A)
#define sz(A) int(A.size())

using namespace std;

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

int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  string s;
  cin >> s;
  int prefix = 0;
  long long ans = 0;
  for (int i = 0; i < sz(s); i++) if (s[i] == 'W') ans += i - prefix, prefix++;
  cout << ans << endl;
  return (0);
}


Measured memory_bytes: 720
#include <stdio.h>

int main() {
	int a[101][101];
	int r,c,i,j=0;

	for(i=0;i<101;i++)
	{
		for(j=0;j<101;j++)
		{
			a[i][j]=0;
		}
	}
	
	scanf("%d %d",&r,&c);

	for(i=0;i<r;i++)
	{
		for(j=0;j<c;j++)
		{
			scanf("%d",&a[i][j]);
			a[i][c]+=a[i][j];
			a[r][j]+=a[i][j];
			a[r][c]+=a[i][j];
		}
	}
	
	   for (i=0; i<r+1; i++) {
        for (j=0; j<c+1; j++) {
            if (j) printf(" ");
            printf("%d",a[i][j]);
        }
        printf("\n");
	}
	return 0;
}


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

typedef long long ll;

/* メモリ食い過ぎ注意 */
#define int ll
#define ALL(v) v.begin(), v.end()
#define _REP(i, n) for (int i = 0; i < n; i++)
#define REP(n) _REP(i, n)

/* define const */
const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;
/* end defineing */

signed main()
{
    int n, k;
    ll arr[51] = {};
    cin >> n >> k;

    cout << n - k + 1 << endl;
}

Measured memory_bytes: 256
public class Main {


  private static void solve() {
    long n = ni();
    long m = ni();
    char[] s = ns();
    char[] t = ns();
    int gcd = (int)gcd(n, m);
    long lcm = n / gcd * m;

    for (int i = 0, j = 0; i < n && j < m; i += lcm / m, j += lcm / n) {
      if (s[i] != t[j]) {
        System.out.println(-1);
        return;
      }
    }
    System.out.println(lcm);
  }

  public static long gcd(long a, long b) {
    while (b > 0){
        long c = a;
        a = b;
        b = c % b;
    }
    return a;
  }
  
  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,n,a) for(ll i=n-1;i>=a;i--)
#define nl "\n"
#define LLMAX 1e18
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pll pair<ll,ll>
#define fastread cin.tie(0); cout.tie(0); ios::sync_with_stdio(false);
#define online_judge

const ll MOD=1e9+7;

ll pow(ll n, ll e){
  if(e==0)
    return 1;
  else if(e==1)
    return n;
  else if(e%2==0)
    return pow(n,e/2);
  else
    return pow(n,e/2)*n;
}

bool prime(ll n){
  ll ct=0;
  rep(i,2,sqrt(n)+1){
    if(n%i==0)
      return false;
  }
  return true;
}

void solve(){
  fastread;
  ll n,m,temp,mi,q,ma=0,t;
  cin >> n;
  string s;
  getline(cin,s);
  getline(cin,s);
  ll r=0;
  rep(i,0,n)
    if(s[i]=='R')
      r++;
  temp=0;
  rep(i,0,r)
    if(s[i]=='R')
      temp++;
  cout << r-temp; 
}

int main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  freopen("error.txt", "w", stderr);
  #endif
  clock_t start, end;
  start = clock();
  solve();
  end=clock();
  double time_taken = double(end - start) / double(CLOCKS_PER_SEC); 
    cerr << "Time taken by program is : " << fixed  
         << time_taken << setprecision(5); 
    cerr << " sec " << endl;
  return 0;
}

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

void solve(long long N, std::vector<long long> a, std::vector<long long> b, std::vector<long long> c)
{
    long long dp[N + 1][3] = {{0}};
    for (size_t i = 1; i <= N; i++)
    {
        dp[i][0] = max(dp[i - 1][1] + a[i], dp[i - 1][2] + b[i]);
        dp[i][1] = max(dp[i - 1][2] + b[i], dp[i - 1][0] + c[i]);
        dp[i][2] = max(dp[i - 1][0] + c[i], dp[i - 1][1] + a[i]);
    }
    cout << max(max(dp[N][0], dp[N][1]), dp[N][2]) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    long long N;
    scanf("%lld", &N);
    std::vector<long long> a(N + 1, 0);
    std::vector<long long> b(N + 1, 0);
    std::vector<long long> c(N + 1, 0);
    for (int i = 1; i <= N; i++)
    {
        scanf("%lld", &a[i]);
        scanf("%lld", &b[i]);
        scanf("%lld", &c[i]);
    }
    solve(N, std::move(a), std::move(b), std::move(c));
    return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int w[105];
int ans=100000;
int main(int argc,char const* argv[])
{
  int n;
  cin >> n;
  for(int i=0;i<n;i++)
    {
      cin >> w[i];
    }
  for(int i=0;i<n;i++)
    {
      int s1=0,s2=0;
      for(int j=0;j<n;j++)
	{
	  if(j<=i)
	    {
	      s1+=w[j];
	    }
	  else
	    {
	      s2+=w[j];
	    }
	}
      ans=min(ans,abs(s1-s2));
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
vector<pair<int,int> > V[100005];
vector<pair<int,string> > Ans;

string AddLeadingZeros( string Str ){
	int rem = 6 - int(Str.size());
	string New = "";

	for( int i = 0 ; i < rem ; ++i )
		New.push_back( '0' );

	New += Str;
	return New;
}

int main(){
	int N , m , i , j , p , y;
	scanf( "%d%d" , &N , &m );

	for( i = 1 ; i <= m ; ++i ){
		scanf( "%d%d" , &p , &y );
		V[p].emplace_back( make_pair( y , i ) );		
	}

	for( i = 1 ; i <= N ; ++i )
		sort( V[i].begin() , V[i].end() );

	string pref , Temp;

	for( i = 1 ; i <= N ; ++i ){
		Temp = to_string( i );
		pref = AddLeadingZeros( Temp );

		for( j = 0 ; j < V[i].size() ; ++j ){
			Temp = to_string( j + 1 );
			Temp = AddLeadingZeros( Temp );
			Temp = pref + Temp;
			Ans.emplace_back( make_pair( V[i][j].second , Temp ) );
		}
	}	

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

	for( i = 0 ; i < m ; ++i )
		printf( "%s\n" , Ans[i].second.c_str() );

	return 0;
}

Measured memory_bytes: 13168
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1'010'000'000'000'000'017LL;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()

int main() {
    // Atcoder
    // template: cpp
    ll n, l;
    cin >> n >> l;
    ll sum = 0;
    ll cnt = INF;
    for(ll i = 1; i < n + 1; i++) {
        sum += l + i - 1;
        if(abs(cnt) > abs(l + i - 1))
            cnt = l + i - 1;
    }
    cout << sum - cnt;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#include <fstream>
#include <random>
#include <map>
#include <unordered_map>
#include <cstdlib>
#include <functional>
#include <random>
#include <time.h>
#include <chrono>
#include <sstream>
#include <iomanip>
#include <numeric>
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define MOD 1000000007
#define SORT(s) sort(s.begin(), s.end());
#define REVERSE(s) reverse(s.begin(), s.end());
#define SUM(s) accumulate(s.begin(), s.end(), 0LL);
#define P pair<int,int>
#define mp make_pair
#define valid(x,y,h,w) (0<=x&&x<h&&0<=y&&y<w)
//#define int ll
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int ndx[8] = { 0,1,0,-1, 1,1,-1,-1 };
int ndy[8] = { 1,0,-1,0, 1,-1,-1,1 };
using namespace std;
int POW(int x, int y) { return int(pow(double(x), double(y))); }
double log(double a, double b) { return log(b) / log(a); }


vector<vector<int>> e;
//indexをrootとする個数
vector<ll> b, bw;

//条件を満たす個数
ll f(int root, int parent, bool isOkBlack) {

	if (isOkBlack && bw[root] != 0) {
		return bw[root];
	}
	else if(!isOkBlack && b[root] != 0){
		return b[root];
	}

	ll white = 1;
	ll black = 1;
	auto list = e[root];

	if (list.size() == 1 && parent >= 0) {
		if (isOkBlack) return 2;
		else return 1;
	}

	rep(i, list.size()) {
		if (list[i] == parent) {
			continue;
		}

		white *= f(list[i], root, true);
		white %= MOD;
		if (isOkBlack) {
			black *= f(list[i], root, false);;
			black %= MOD;
		}
	}
	if (isOkBlack) {
		bw[root] = (white + black) % MOD;
		return (white + black) % MOD;
	}
	else {
		b[root] = white;
		return white;
	}
}


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

	if (n == 1) {
		cout << 2 << endl;
		return 0;
	}

	e.resize(n);
	b.resize(n);
	bw.resize(n);
	rep(i, n - 1) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		e[x].push_back(y);
		e[y].push_back(x);
	}

	cout << f(0, -1, true) << endl;
}




Measured memory_bytes: 18432
#include <stdio.h>
int main(void){
    int n,x,i,j,k;
    
    while(1)
    {
        int a=0;
        scanf("%d %d\n",&n,&x);
        if (n==0 && x==0)
        break;
        
        for (i=0; i<n; i++)
        {
            for (j=0; j<n; j++)
            {
                for (k=0; k<n; k++)
                {
                    if (i+j+k+3 == x && i!=j && j!=k && k!=i)
                    a = a + 1;
                }
            }
        }
        a = a / 6;
        printf("%d\n",a);
    }
    
    return 0;
}



Measured memory_bytes: 2108
loop do
    h, w = gets.split.map &:to_i
    break if h == 0
    a = (1..h).map { [nil] + gets.chomp.scan(/./) + [nil] }
    a.unshift [nil] * (w + 2)
    a << [nil] * (w + 2)
    count = 0
    (1..h).each do |i|
        (1..w).each do |j|
            next unless a[i][j]
            count += 1
            sym = a[i][j]
            stack = [[i, j]]
            until stack.empty?
                y, x = stack.pop
                next unless a[y][x] == sym
                a[y][x] = nil   
                stack += [[y+1,x],[y-1,x],[y,x-1],[y,x+1]]
            end
        end
    end
    p count
end 

Measured memory_bytes: 94968
def s0():return input()
def s1():return input().split()
def s2(n):return [input() for x in range(n)]
def s3(n):return [input().split() for _ in range(n)]
def s4(n): return [[x for x in s] for s in s2(n)]
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
def t3(n):return [tuple(int(x) for x in input().split()) for _ in range(n)]
def p0(b,yes="Yes",no="No"): print(yes if b else no)
# from sys import setrecursionlimit
# setrecursionlimit(1000000)
from collections import Counter,deque,defaultdict
# import itertools
# import math
# import networkx
# from bisect import bisect_left,bisect_right
# from heapq import heapify,heappush,heappop
n=n0()
s=s2(n)
d=defaultdict(int)

for line in s:
    a=[0]*26
    c=set((Counter(line)).items())
    for t in c:
        a[ord(t[0])-97]=t[1]
    d[tuple(a)]+=1

ans=0
for i in d.values():
    if i>=2:
        ans+=i*(i-1)//2
print(ans)

Measured memory_bytes: 43368
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>
#include<stack>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<string> vstring;
typedef vector<pint> vpint;

struct Edge{int to,from,cost;};

#ifdef DEBUG
#define debug cout
#else
stringstream __ss__;
#define debug __ss__
#endif

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) debug << *i << " "; debug << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

#define rep(i,n) for(int i=0;i<(n);++i)
#define repd(i,n) for(int i=(n)-1;i>=0;i--)
#define repn(i,m,n) for(int i=(m);i<=(n);++i)
#define repnd(i,m,n) for(int i=(n)-1;i>=(m);i--)
#define rep0(i,n) for(i=0;i<(n);++i)
#define all(n) n.begin(),n.end()
#define sz(n) ((int)(n).size())
#define IL for(;;)
#define MP make_pair
#define PB push_back
#define SS stringstream
#define X second
#define Y first
#define PUTLINE debug<<"LINE:"<<__LINE__<<endl;

const int INF = 2147483647/3;
const double EPS = 1e-10;
const double PI = acos(-1.0);

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



int main() {
	int a[5];
	rep(i,5)cin>>a[i];
	cout<<min(min(a[0],a[1]),a[2])+min(a[3],a[4])-50<<endl;
	return 0;
}

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

using ll = long long;

int dig (int x) {
	int sum = 0;
	while (x) {
		sum += x%10;
		x /= 10;
	}
	return sum;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int n, ans = 1e9;
	cin >> n;
	for (int i=1; i<n; i++) {
		ans = min(ans, dig(i)+dig(n-i));
	}
	cout << ans;
	return 0;
}


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

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

  std::vector<std::string> sn;
  for(int i=0; i<N; i++)
  {
    std::string si;
    std::cin >> si;
    std::sort(si.begin(), si.end());
    sn.push_back(si);
  }
  std::sort(sn.begin(), sn.end());

  long long count = 0;
  std::string last;
  int samecount =0;
  for(int i=0; i<sn.size(); i++)
  {
    if(last != sn[i] )
    {
      samecount =0;
      last = sn[i];
    }
    else
    {
      samecount += 1;
      count += samecount;
    }
  }

  std::cout << count;
}

Measured memory_bytes: 5748
import sys
from io import StringIO
import unittest
import os

# 再帰処理上限(dfs作成時に設定するのが面倒なので限度近い値を組み込む)
sys.setrecursionlimit(999999999)


# 実装を行う関数
def resolve(test_def_name=""):
    h, w, k = map(int, input().split())
    s_s = [list(input()) for i in range(h)]

    # パターン数分の情報を作成(横に切る = 最大2^10個)
    # 全パターンの・・横に切る回数、と切る場所
    side = []
    for i in range(1 << h - 1):
        cut_cnt = 0
        point_s = []
        # パターンの桁数分ループ
        for j in range(h - 1):
            # フラグが立つ(bitが1)の場合の処理を以下に記載。
            if i & 1 << j:
                cut_cnt += 1
                point_s.append(j + 1)

        point_s.append(h)
        # 得た情報をリストに追加
        side.append([point_s, cut_cnt])

    ## 横切り必須にもかかわらず、横木入りしていないパターンを排除できていない・・と思われる。
    x_s_s = list(zip(*s_s))
    ans = 999999
    for side_cut_point_s, cut_cnt in side:
        # 横切りを実施した後の塊を取得
        cnt_s = [0 for i in range(cut_cnt + 1)]

        for x_s in x_s_s:
            start = 0
            for cnt, side_cut_point in enumerate(side_cut_point_s):
                cnt_s[cnt] += x_s[start: side_cut_point].count("1")
                start = side_cut_point
            # 切る必要がある場合は切る
            if max(cnt_s) > k:
                cut_cnt += 1
                start = 0
                for cnt, side_cut_point in enumerate(side_cut_point_s):
                    cnt_s[cnt] = x_s[start: side_cut_point].count("1")
                    start = side_cut_point
            if max(cnt_s) > k:
                cut_cnt += 99999
        ans = min(ans, cut_cnt)

    print(ans)


# テストクラス
class TestClass(unittest.TestCase):
    def assertIO(self, assert_input, output):
        stdout, sat_in = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(assert_input)
        resolve(sys._getframe().f_back.f_code.co_name)
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, sat_in
        self.assertEqual(out, output)

    def test_input_1(self):
        test_input = """3 5 4
11100
10001
00111"""
        output = """2"""
        self.assertIO(test_input, output)

    def test_input_2(self):
        test_input = """3 5 8
11100
10001
00111"""
        output = """0"""
        self.assertIO(test_input, output)

    def test_input_3(self):
        test_input = """4 10 4
1110010010
1000101110
0011101001
1101000111"""
        output = """3"""
        self.assertIO(test_input, output)

    # 自作テストパターンのひな形(利用時は「tes_t」のアンダーバーを削除すること
    def test_1original_1(self):
        test_input = """10 10 1
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000
1000000000"""
        output = """9"""
        self.assertIO(test_input, output)


# 実装orテストの呼び出し
if __name__ == "__main__":
    if os.environ.get("USERNAME") is None:
        # AtCoder提出時の場合
        resolve()

    else:
        # 自PCの場合
        unittest.main()


Measured memory_bytes: 83224
#include<iostream>
#include<vector>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = 0;
	if (b >= a*c) cout << c << endl;
	else cout << b / a << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <unordered_map>

int main() {
  int n;
  std::unordered_map<int, int> counter;
  std::cin >> n;
  for (int ni = 0; ni < n; ++ni) {
    int a;
    std::cin >> a;
    ++counter[a];
  }
  int ans = 0;
  for (const auto &p : counter) {
    ans += p.first > p.second ? p.second : p.second - p.first;
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 4128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<algorithm>
using namespace std;
string s;
int a[101],b[101];
int main()
{
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='C')
		{
			a[i]=1;
		}  
		if(s[i]=='F')
		{
			b[i]=1;
		}		  
	}
	for(int i=0;i<s.length();i++)
	{
		if(b[i]==1)
		{
			for(int j=0;j<i;j++)
			{
				if(a[j]==1)
				{
					printf("Yes");
					return 0;
				}
			}
		 } 
	}
	printf("No");
	return 0;
 } 

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    N, K = map(int, input().split())
    *A, = map(lambda x: int(x) - 1, input().split())

    t = 0
    while K:
        if K & 1:
            t = A[t]
        nA = [0] * N
        for i in range(N):
            nA[i] = A[A[i]]
        A = nA
        K >>= 1
    print(t + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 169484
#include <string>
#include<fstream>
#include<iostream>
#include <vector>
#include<cmath>
#include <algorithm>
#include <string>

using namespace std;

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

  for(int j = 0; j < s.length(); ++j)
  {
    if(s[j] == s[s.length()-1-j])
      continue;
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }

  string sec = "";
  sec = s.substr(0,(s.length()-1)/2);
  for(int j = 0; j < sec.length(); ++j)
  {
    if(sec[j] == sec[sec.length()-1-j])
      continue;
    else
    {
      cout << "No" << endl;
      return 0;
    }
  }

  string n= "";
  n = s.substr((s.length()+3)/2-1, s.length()-(s.length()+3));
  for(int j = 0; j < n.length(); ++j)
  {
    if(n[j] == n[n.length()-j-1])
      continue;
    else 
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  

}  


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
 int a , b ,c ;
 cin >>a >> b >> c;
 if(a >= c && c>=b){
   cout << "Yes" <<endl;
   }
   else if  (a <= c && c <=b ){
     cout << "Yes" << endl;
     }
     else {
       cout << "No" << endl;
       }
       }

Measured memory_bytes: 256
fun main(args: Array<String>) {
    // Your code here!
    var (a,b,c) = readLine()!!.split(" ").map{it.toInt()}
    var msg = "Yes"
    
    if((a == c && a == b) || (a != c && a != b && c != b)){
        msg = "No"
    }
    println(msg)
}


Measured memory_bytes: 37736
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<map>
#include<cmath>
#include<set>
#include<stack>
#define ll long long
#define pb push_back
#define max(x,y) ((x)>(y)?(x):(y))
#define min(x,y) ((x)>(y)?(y):(x))
#define cls(name,x) memset(name,x,sizeof(name))
#define fs first
#define sc second
#define mp make_pair
#define L(x) (1<<x)
#define next Next
using namespace std;
const int inf=1e9+10;
const ll llinf=1e16+10;
const int maxn=1e5+10;
const int maxm=1e3+10;
const int mod=1e9+7;
int n;
int A[maxn];
int main()
{
    //freopen("in.txt","r",stdin);
    while(~scanf("%d",&n))
    {
        for(int i=1;i<=n;i++)
            scanf("%d",&A[i]);
        int ans=0;
        for(int i=1;i<=n;i++)
        {
            if(A[i]==i)
            {
                if(i<=n-1 && A[i+1]!=i)
                    swap(A[i],A[i+1]);
                else if(i>=1 && A[i-1]!=i)
                    swap(A[i],A[i-1]);
                ans++;
            }
        }
        printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ll long long;
using namespace std;
char a[1002][10002];
bool v[1002][1002];
long long int ans[1002][1002];
long long ma=1e9+7;
int n,m;
long long fun(int i,int j)
{
    if(i<1||i>n||j<1||j>m||a[i][j]=='#')
     return 0;
    if(i==n&&j==m)
     return 1;
    
    if(v[i][j]==true)
     return ans[i][j];
     
    v[i][j]=true;
     a[i][j]='#';
     
   
      ans[i][j]=(ans[i][j]%ma+fun(i+1,j)%ma)%ma;
  
  
      ans[i][j]=(ans[i][j]%ma+fun(i,j+1)%ma)%ma;
      
    

       a[i][j]='.';
     return ans[i][j];
    
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    cin>>n>>m;
    
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=m;j++)
         cin>>a[i][j];
    }
   long long int k=fun(1,1);

    cout<<ans[1][1]<<"\n";
    
}

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

int main() 
{
  int x;
  scanf("%d", &x);
  long long ans = 0;
  ans += ((x / 500) * 1000);
  x -= ((x / 500) * 500);
  ans += ((x / 5) * 5);
  printf("%lld\n", ans);
  return (0);
}

Measured memory_bytes: 256
# import math
# import decimal
# import queue
# import bisect
# import heapq
# import time
# import itertools

mod = int(1e9+7)

def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    x = [0]
    _sum = 0
    for i in range(1,max(p)+1):
        _sum += i
        x.append(_sum)
    v = []
    ans = 0
    res = 0
    for i in range(n):
        v.append(x[p[i]]/p[i])
        if i >= k:
            res += v[i] - v[i-k]
        else:
            res += v[i]
        ans = max(ans,res)
    print(ans)
    return

if __name__=='__main__':
    main()


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

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

    for (int i=1; i <= 10000; i++) {
        if (int(float(i) * 0.08) == a && int(float(i) * 0.10) == b) {
            cout << i << endl;
            return 0;
        }
    }

    cout << -1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int ketasum(int n) {
	int ans = 0, x = 10, i = 1;
	while (n > 0) {
		ans += ((n % x) / i);
		n -= (n % x);
		x *= 10;
		i *= 10;
	}
	return ans;
}
int main() {
	ll n, m, ans = 0, A[10101];
	cin >> n;
	if (n != 10 && n != 100 && n != 1000 && n != 10000 && n != 100000)
		cout << ketasum(n) << endl;
	else
		cout << 10 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;

struct UnionFind{
    vector<int> par, sz;
    vector<long long> sum;
    UnionFind(){}
    UnionFind(int n, vector<long long> x):par(n), sz(n, 1), sum(x){
        iota(par.begin(), par.end(), 0);
    }
    int find(int x){
        if(x == par[x]) return x;
        return find(par[x]);
    }
    bool same(int x, int y){
        return find(x) == find(y);
    }
    void unite(int x, int y){
        x = find(x); y = find(y);
        if(x == y) return;
        if(sz[x] < sz[y]) swap(x, y);
        sz[x] += sz[y];
        sum[x] += sum[y];
        par[y] = x;
    }
    void split(int x, int y){
        sz[x] -= sz[y];
        sum[x] -= sum[y];
        par[y] = y;
    }
};

struct edge{
    int u, v, w;
    bool operator<(const edge &e)const{
        return w < e.w;
    }
};

int main(){
    int n, m, ans = 0;
    cin >> n >> m;
    vector<long long> x(n);
    for(int i = 0; i < n; i++) cin >> x[i];
    UnionFind uf(n, x);
    vector<edge> es(m);
    for(int i = 0; i < m; i++){
        int u, v, w;
        cin >> u >> v >> w;
        es[i] = {u - 1, v - 1, w};
    }
    sort(es.begin(), es.end());
    vector<T> h;
    for(auto e : es){
        int u = uf.find(e.u);
        int v = uf.find(e.v);
        if(u == v) continue;
        if(uf.sz[u] < uf.sz[v]) swap(u, v);
        uf.unite(u, v);
        h.push_back(T(u, v, e.w));
    }
    reverse(h.begin(), h.end());
    for(auto e : h){
        int u, v, w;
        tie(u, v, w) = e;
        if(uf.sum[uf.find(u)] < w) uf.split(u, v);
    }
    for(auto e : es){
        if(uf.sum[uf.find(e.u)] < e.w) ans++;
    }
    cout << ans << endl;
}

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

struct Point{
	int h,w;
	Point(){};
	Point(int h_,int w_){
		h=h_,w=w_;
	};
};

Point operator+(const Point& a,const Point& b){return Point(a.h+b.h,a.w+b.w);}

struct Board{

	int H,W;
	vector<string>s ;
	vector<Point>near;
	queue<Point> que;
	vector<vector<int>> dist;
	vector<vector<bool>> visited;
	int ans;
	int bk;
	int wt;

	Board(){};
	Board(int h_,int w_){
		H=h_,W=w_;
		s.resize(H);
		near={{-1,0},{1,0},{0,-1},{0,1}};
		init_dist();
		init_visited();
	};

	bool in_board(Point p){if(0<=p.h && p.h<H && 0<=p.w && p.w<W)return true;else return false;} 
	char get_char(Point p){return s[p.h][p.w];}
	vector<Point> get_near(Point p){vector<Point>ret;for(auto&& u:near)ret.emplace_back(p+u);return ret;}

	int  get_dist(Point p){return dist[p.h][p.w];}
	int  set_dist(Point p,int i){dist[p.h][p.w]=i;}
	void init_dist(){dist.assign(H,vector<int>(W,-1));}

	bool  is_visited(Point p){return visited[p.h][p.w];}
	void  set_visited(Point p,bool i){visited[p.h][p.w]=i;}
	void init_visited(){visited.assign(H,vector<bool>(W,false));}


	void dfs(Point p){
		if(is_visited(p))return;
		set_visited(p,true);
		for(auto&& u:get_near(p)){
		if(in_board(u) && !is_visited(u) && get_char(p)!=get_char(u)){
				 
				if(get_char(u)=='.'){wt++;}
				else if(get_char(u)=='#'){bk++;}
				dfs(u);
		}
		}
	}

	int do_all_dfs(){
		ans=0;
		init_visited();
		for (int i;i<H;i++)for(int j=0;j<W;j++){
		wt=0,bk=0;
		Point p(i,j);
		if(get_char(p)=='#' && ! is_visited(p)){
		bk++;
	//		cout<<"b "<<p.h<<" "<<p.w<<endl;
		dfs(p);
		ans+=bk*wt;
		}}
		return ans;
	}

	void bfs(){
		while(! que.empty()){
		Point p=que.front();que.pop();	
		for(auto&& u:get_near(p)){
		if(in_board(u) &&get_dist(u)==-1){
			set_dist(u,get_dist(p)+1);
			if(get_char(u)=='.')ans++;
			que.push(u);
		}}
		}}

	void do_all_bfs(){for (int i;i<H;i++)for(int j=0;j<W;j++){
		Point p(i,j);
		if(get_dist(p)==-1){
			que.push(p);bfs();
		}
	}
	}
	

};


signed main(){
	int h,w;cin>>h>>w;
	Board bd(h,w);
	for(auto&& u:bd.s)cin>>u;
//	for(auto&& u:bd.s)cout<<u<<endl;
	cout<<bd.do_all_dfs()<<endl;
}


Measured memory_bytes: 29312
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin>>s;
    int ans=0;
    int n=s.length();
    int count=0;
    int i;
    for(i=0;i<n;i++){
        count=0;
        while(s[i]=='R'){
            count++;
            if(count>ans)
                ans=count;
            
            i++;
        }
    }cout<<ans<<endl;
    
    
}

Measured memory_bytes: 3568
object Main extends App{
  import scala.io.StdIn.readLine
  
  val x = readLine.split(" ")(1).toInt
  val children = readLine.split(" ").map(_.toInt).sortWith(_ < _)
  
  val maxpoint = (1 to children.length).map(a =>children.take(a).sum).indexWhere(_ > x)
  
  if(maxpoint == -1){
    if(x == children.sum){println(children.length.toString)}
    else {println((children.length - 1).toString)}
  }
  else println(maxpoint.toString)
}


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

using namespace std;
typedef long long ll;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;

#define out(a) cout << a << endl
#define out1(a) cout << a
#define in(a) cin >> a
#define in2(a, b) cin >> a >> b
#define in3(a, b, c) cin >> a >> b >> c
#define rep(i, N) for (ll i = 0; i < (ll)N; i++)
#define rep1(i, N) for (ll i = 1; i <= (ll)N; i++)
#define repi(i, j, N) for (ll j = (ll)i + 1; j < (ll)N; j++)
#define all(v) v.begin(), v.end()

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

constexpr int inf = 1e9;
constexpr ll linf = 1e18;
constexpr ll mod = 1e9 + 7;

void solve();

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

void solve()
{
    int a, b, c;
    in3(a, b, c);
    if (a == b && a != c)
    {
        out("Yes");
    }
    else if (a == c && a != b)
    {
        out("Yes");
    }
    else if (b == c && a != b)
    {
        out("Yes");
    }
    else
    {
        out("No");
    }
}

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

res = 0
j = 0
prev = A[0]
for i in range(1, N):
  if A[i] <= prev:
    j += 1
    prev = A[i]
  else:
    res = max(res, j)
    j = 0
    prev = A[i]

print(max(res, j))

Measured memory_bytes: 63856