akhauriyash/Code-Regression huggingface dataset:
Option Strict On

Module Module1
    Dim S As String
    Dim i, ans As Int32

    Sub Main()
        'let'
        S = Console.ReadLine()

        'var'
        ans = 700

        For i = 0 To Len(S) - 1
            If S(i) = "o"c Then ans += 100
        Next

        Console.WriteLine(ans)

    End Sub
End Module

Measured memory_bytes: 11348
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}

ll LCM(ll x, ll y) {
    return x / GCD(x, y) * y;
}

ll wazu = 1000000007;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (wazu - inv(wazu % x) * (wazu / x)) % wazu;
        if (a >= 0) { return a; }
        else { return wazu + a; }
    }
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

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

    int z,j=0;

    for (int x = 0; x <= K; ++x) {
        for (int y = 0; y <= K; ++y) {
            z = S - x - y;
            if (z >= 0 && z <= K) { ++j; }
        }
    }

    cout << j << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <string>
using namespace std;

int main()
{
    int n,x,sum,mi,t;
    cin>>n>>x;
    cin>>t;mi=t;sum=t;
    for(int i=1;i<n;i++)
    {
        cin>>t;
        sum+=t;
        if(t<mi)mi=t;
    }
    cout<<n+(x-sum)/mi;
    return 0;
}


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

using namespace std;
typedef long long int ll;
typedef long double ld;
#define EPS 0.0000000001
#define pb push_back
#define space " "
#define ar array
#define pi pair<int,int>
#define ff first
#define ss second
void solve() {
   ld d , t , s ;
   cin >> d >> t >> s ;
   if(abs(d/s - t ) < EPS || d/s <= t ) {
       cout << "Yes" <<endl ;
   }else {
       cout << "No" <<endl;
   }

}

int main() {
//    freopen("input.txt" , "r" , stdin) ;
//    freopen("output.txt" , "w" , stdout) ;
    int q = 1;
    // cin >> q;
    while (q--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3724
#![allow(unused, non_snake_case, dead_code, non_upper_case_globals)]
use {
    proconio::{marker::*, *},
    std::{cmp::*, collections::*, mem::*},
};
macro_rules! chmax {
    ($base:expr, $($cmps:expr),+ $(,)*) => {{
        let cmp_max = max!($($cmps),+);
        if $base < cmp_max {
            $base = cmp_max;
            true
        } else {
            false
        }
    }};
}
macro_rules! max {
    ($a:expr $(,)*) => {{
        $a
    }};
    ($a:expr, $b:expr $(,)*) => {{
        std::cmp::max($a, $b)
    }};
    ($a:expr, $($rest:expr),+ $(,)*) => {{
        std::cmp::max($a, max!($($rest),+))
    }};
}
#[fastout]
fn main() {
    input! {//
        r:usize,
        c:usize,
        k:usize,
        rcv:[(Usize1,Usize1,usize);k],
    }
    let mut rcvs = vec![vec![0; c]; r];
    // dbg!(&rcv);
    for &(r, c, v) in rcv.iter() {
        rcvs[r][c] = v;
    }
    // dbg!(&rcvs);
    // rcv.sort();
    let mut dp = vec![vec![vec![0; 4]; c]; r]; // dp[r][c][k]
    let mut ans = 0;

    for rr in 0..r {
        for cc in 0..c {
            for i in 0..=3 {
                if rr + 1 < r {
                    chmax!(dp[rr + 1][cc][0], dp[rr][cc][i]);
                    if i < 3 {
                        chmax!(dp[rr + 1][cc][0], dp[rr][cc][i] + rcvs[rr][cc]);
                    }
                }
                if cc + 1 < c {
                    chmax!(dp[rr][cc + 1][i], dp[rr][cc][i]);
                    if i < 3 {
                        chmax!(dp[rr][cc + 1][i + 1], dp[rr][cc][i] + rcvs[rr][cc]);
                    }
                }
            }
        }
    }
    let mut ans = dp[r - 1][c - 1][3];
    for i in 0..3 {
        chmax!(ans, dp[r - 1][c - 1][i] + rcvs[r - 1][c - 1]);
    }
    println!("{}", ans);
}


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

int main()
{
	int h, w;
	bool b[500][500];

	cin >> h >> w;

	for (int i = 0; i < h; i++)
		for (int j = 0; j < w; j++) {
			int a;
			cin >> a;
			b[i][j] = a % 2;
		}

	bool f = 0;
	vector<int> p, q, r, s;

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w - 1; j++) {
			int u, v;

			if (i % 2 == 0) {
				u = j;
				v = j + 1;
			}
			else {
				u = w - j - 1;
				v = w - j - 2;
			}

			if ((!f && b[i][u]) || (f && !b[i][u])) {
				p.push_back(i + 1);
				q.push_back(u + 1);
				r.push_back(i + 1);
				s.push_back(v + 1);
				f = 1;
			}
			else if (f && b[i][u])
				f = 0;
		}

		if (i < h - 1) {
			int u;

			if (i % 2 == 0)
				u = w - 1;
			else
				u = 0;

			if ((!f && b[i][u]) || (f && !b[i][u])) {
				p.push_back(i + 1);
				q.push_back(u + 1);
				r.push_back(i + 2);
				s.push_back(u + 1);
				f = 1;
			}
			else if (f && b[i][u])
				f = 0;
		}
	}

	cout << p.size() << endl;

	for (int i = 0; i < p.size(); i++)
		cout << p[i] << " " << q[i] << " " << r[i] << " " << s[i] << endl;

	return 0;
}


Measured memory_bytes: 4452
#include <iostream>

int main(){
  int sum = 0;
  int n, m;
  std::cin >> n >> m;

  int a[n][m];
  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      std::cin >> a[i][j];
    }
  }

  int b[m];
  for(int i=0; i<m; i++){
    std::cin >> b[i];
  }

 for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      sum += a[i][j] * b[j];
    }
    std::cout << sum << std::endl;
    sum = 0;
  }
  return 0;
}



Measured memory_bytes: 3104
#include <bits/stdc++.h>
//debug
#define vecprint(v) cout << "  vector: ";rep(i,v.size())cout << v[i] << " ";cout << endl;
#define setprint(s) cout << "  set: ";for(auto i=s.begin();i!=s.end();i++)cout << *i << " ";cout << endl;
#define mappairprint(s) cout << "  map: ";for(auto i=s.begin();i!=s.end();i++)cout << i->first << " " << i->second << endl;cout << endl;
//reader
#define r1(a) cin>>(a)
#define r2(a,b) cin>>(a)>>(b)
#define r3(a,b,c) cin>>(a)>>(b)>>(c)
//writer
#define w1(a) cout<<(a)<<" "
#define w2(a,b) cout<<(a)<<" "<<(b)<<" "
#define w3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<" "
#define wl1(a) cout<<(a)<<endl
#define wl2(a,b) cout<<(a)<<" "<<(b)<<endl
#define wl3(a,b,c) cout<<(a)<<" "<<(b)<<" "<<(c)<<endl
//variable definition
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
//roop
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep1(i,n) for (int i = 1; i <= (n); ++i)
#define all(c) c.begin(),c.end()
//term
#define elif else if
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
using namespace std;
using ll = long long;
//const
constexpr double PI = 3.141592653589793238462643383279;
vector<int> dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};


std::string ReplaceString
(
      std::string String1   // 置き換え対象
    , std::string String2   // 検索対象
    , std::string String3   // 置き換える内容
)
{
    std::string::size_type  Pos( String1.find( String2 ) );
 
    while( Pos != std::string::npos )
    {
        String1.replace( Pos, String2.length(), String3 );
        Pos = String1.find( String2, Pos + String3.length() );
    }
 
    return String1;
}
 

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

  string str = ReplaceString(s, "?", "D");
  
  cout << str << endl;
  
  
}

Measured memory_bytes: 3864
n = int(input())
l = input().split(" ")
l1=[0]*n
for i in range(len(l)):
    l[i]=int(l[i])
    l1[l[i]]+=1
if l1[0]>0 and n%2==0:
    print(0)
elif l1[0]>1 and n%2==1:
    print(0)
else:
    c = set(l)
    mod = int(1e9) +7
    for k in range(1,len(l1)):
        if l1[k]%2!=0:
            print(0)
            exit()
    if(l1[0]):    
        print(pow(2,len(c)-1,mod))
    else:
        print(pow(2,len(c),mod))

Measured memory_bytes: 13300
// https://atcoder.jp/contests/abc175/tasks/abc175_c
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) FOR(i, 0, n)
#define REPR(i, n) for (int i = n - 1; i >= 0; i--)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()
#define CEIL(a, b) ((a - 1) / b + 1)

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int X, K, D;
    cin >> X >> K >> D;
    // if (abs(X) >= K * D) {
    if (K <= abs(X) / D) {
        cout << abs(X) - K * D << endl;
    } else {
        // 正の絶対値が最小
        int b = abs(X) - abs(X) / D * D;
        // 負の絶対値が最小
        int c = abs(abs(X) - (abs(X) / D + 1) * D);
        // 移動回数の偶奇によって分岐
        int bMove = abs(X) / D;
        if ((K - bMove) % 2 == 0) {
            cout << b << endl;
        } else {
            cout << c << endl;
        }
        // if ((K - abs(X) / D) % 2 == 0)
        //     cout << abs(X) - (abs(X) / D) * D;
        // else
        //     cout << abs(abs(X) - (abs(X) / D) * D - D);
    }

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    int ans = 0, a[3] = {3, 5, 7};
    set<int> st;
    for (int i = 0; i <= 100010; i++)
    {
        rep(l, 10)
        {
            int m = i, num = 0, ok[3] = {}, x = 1;
            rep(j, l)
            {
                int p = m % 3;
                num = x * a[p] + num;
                x *= 10;
                ok[p] = 1;
                m /= 3;
            }
            if (ok[0] * ok[1] * ok[2] != 0 && st.find(num) == st.end() && num <= n)
            {
                ans++;
                st.insert(num);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1536
#include <iostream>
#include <vector>

#define MAX_VALUE 10001

void counting_sort(std::vector<int>& a) {
    std::vector<int> c(MAX_VALUE, 0);
    for (int i=0; i<a.size(); i++) {
        c[a[i]]++;
    }
    for (int i=1; i<c.size(); i++) {
        c[i] = c[i] + c[i-1];
    }
    std::vector<int> b(a.size());
    for (int i=0; i<a.size(); i++) {
        b[c[a[i]]-1] = a[i];
        c[a[i]]--;
    }
    a.swap(b);
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i=0; i<n; i++) {
        std::cin >> a[i];
    }
    
    counting_sort(a);
    
    for (int i=0; i<n-1; i++) {
        std::cout << a[i] << " ";
    }
    std::cout << a[n-1] << std::endl;
}

Measured memory_bytes: 18396
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp15
{
    class Class402
    {
        static int[] num = new int[3] { 7, 5, 3 };
        static long N;
        static void Main()
        {
            N = long.Parse(Console.ReadLine());
            int ans = DFS(0, 0,false,false,false);
            Console.WriteLine(ans);
        }
        static int DFS(long value, int leng,bool f7,bool f5,bool f3)
        {
            int ans = 0;
            if (f7 && f5 && f3) ans++;
            for(int i = 0; i < 3; i++)
            {
                long n = value + num[i]*(long)Pow(10,leng);
                if (n > N) continue;
                if (i == 0)
                {
                    ans += DFS(n, leng + 1, true, f5, f3);
                }
                if (i == 1)
                {
                    ans += DFS(n, leng + 1, f7, true, f3);
                }
                if (i == 2)
                {
                    ans += DFS(n, leng + 1, f7, f5, true);
                }
            }
            return ans;
        }
    }
}


Measured memory_bytes: 27680
inpl = lambda: list(map(int,input().split()))
N, K = inpl()
H = [0] + inpl() + [0]
dp = [[0]*(K+1) for _ in range(N+2)]
for n in range(1,N+2):
    for k in range(K+1):
        if k >= n-1:
            dp[n][k] = H[n]
        else:
            dp[n][k] = min(dp[n-1-l][k-l] + max(0,H[n]-H[n-1-l]) for l in range(k+1))
print(dp[-1][-1])

Measured memory_bytes: 44892
N, M, X = map(int,input().split())
A = list(map(int,input().split()))

roots = [0] * (N+1)

for i in range(M):
    roots[A[i]] = 1

ans_s = 0
for i in range(0,X):
    ans_s += roots[i]
ans_g = 0
for i in range(X+1,N+1):
    ans_g += roots[i]
print(min(ans_s,ans_g))

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
    int N;
    std::string A, B, C;
    std::cin >> N >> A >> B >> C;

    int distance = 0;
    for (int i = 0; i < N; ++i) {
        char a = A[i];
        char b = B[i];
        char c = C[i];
        if (a == b and b == c) {
            // all the same
        } else if (a == b or b == c or c == a) {
            // change one
            distance += 1;
        } else {
            distance += 2;
        }
    }

    std::cout << distance << std::endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    map<Int,Int> M; 
    rep(i, N){
        Int A; cin >> A;
        M[A]++;
    }

    Int ans = 0;
    for(auto it = M.begin(); it != M.end(); it++){
        pair<Int,Int> p = *it;
        if(p.first <= p.second) ans += p.second - p.first;
        else ans += p.second;
    }

    cout << ans << endl;
}

Measured memory_bytes: 6272
#ABC178-d
import sys,math,collections,itertools
input = sys.stdin.readline
m = 10**9+7
S=int(input())
dp = [0]*(2001)
dp[3]=1
dp[4]=1
dp[5]=1
for i in range(6,2001):
    tmp = 0
    for j in range(3,i):
        tmp = (tmp + dp[i-j])%m
    dp[i] = tmp+1
print(dp[S])
        


Measured memory_bytes: 67784
#include <iostream>
using namespace std;
int main() {
  int N, a, ans=0;
  cin >> N;

  for (auto i=0; i<N; i++) {
    cin >> a;
    if (i%2 == 0 && a%2 == 1) ans++;
  }
  cout << ans << endl;
  
  return 0;
}

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

int n,m;
int f,r;
vector<int> g[100100];
set<int> t;
int out[300000];

bool find(int x){
	for(int i=0;i<g[x].size();i++){
		if(t.find(g[x][i])==t.end())return false;
	}
	return true;
}

void func(int a,int b){
	t.insert(a);
	out[f--]=a;out[r++]=b;
	t.insert(b);
	while(!find(a)){
		for(int i=0;i<g[a].size();i++){
			if(t.find(g[a][i])==t.end()){
				a=g[a][i];
				t.insert(a);
				out[f--]=a;
				break;
			}
		}
	}
	while(!find(b)){
		for(int i=0;i<g[b].size();i++){
			if(t.find(g[b][i])==t.end()){
				b=g[b][i];
				t.insert(b);
				out[r++]=b;
				break;
			}
		}
	}
}

int main(){
	
	f=150000,r=150001;
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;i++){
		cin>>a>>b;
		g[a].push_back(b);
		g[b].push_back(a);
	}
	func(a,b);
	cout<<t.size()<<endl;
	for(int i=f+1;i<r;i++){
		if(out[i]!=0) cout<<out[i]<<' ';
	}
	return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

ll dp[100003];

int main() {
  ll n, ans = 0;
  cin >> n;
  vector<ll> h(n);
  rep(i, n) cin >> h[i];
  dp[1] = abs(h[0] - h[1]);
  for (int i = 2; i < n; ++i)
    dp[i] =
        min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));

  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=100005,INF=1<<30;

int main(){
    
    ll L,R;cin>>L>>R;
    
    ll dp[80][2][2][2];
    
    memset(dp,0,sizeof(dp));
    
    dp[0][1][1][1]=1;
    
    for(int i=0;i<62;i++){
        
        dp[i+1][0][0][0]+=3*dp[i][0][0][0];
        
        dp[i+1][0][0][0]+=dp[i][0][0][1];
        dp[i+1][0][0][1]+=dp[i][0][0][1];
        
        if(L&(1LL<<(61-i))){
            if(R&(1LL<<(61-i))){
                dp[i+1][1][0][0]+=dp[i][1][0][0];
                
                dp[i+1][1][0][0]+=dp[i][1][0][1];
                
                dp[i+1][0][0][0]+=dp[i][0][1][0];
                dp[i+1][0][1][0]+=2*dp[i][0][1][0];
                
                dp[i+1][0][0][1]+=dp[i][0][1][1];
                dp[i+1][0][1][0]+=dp[i][0][1][1];
                
                dp[i+1][1][1][0]+=dp[i][1][1][0];
                
                dp[i+1][1][1][0]+=dp[i][1][1][1];
                
            }else{
                dp[i+1][1][0][0]+=dp[i][1][0][0];
                
                dp[i+1][1][0][0]+=dp[i][1][0][1];
                
                dp[i+1][0][1][0]+=dp[i][0][1][0];
                
                dp[i+1][0][1][1]+=dp[i][0][1][1];
                
            }
        }else{
            if(R&(1LL<<(61-i))){
                
                dp[i+1][1][0][0]+=2*dp[i][1][0][0];
                dp[i+1][0][0][0]+=dp[i][1][0][0];
                
                dp[i+1][1][0][1]+=dp[i][1][0][1];
                dp[i+1][0][0][0]+=dp[i][1][0][1];
                
                dp[i+1][0][0][0]+=dp[i][0][1][0];
                dp[i+1][0][1][0]+=2*dp[i][0][1][0];
                
                dp[i+1][0][1][0]+=dp[i][0][1][1];
                dp[i+1][0][0][1]+=dp[i][0][1][1];
                
                dp[i+1][1][0][0]+=dp[i][1][1][0];
                dp[i+1][1][1][0]+=dp[i][1][1][0];
                dp[i+1][0][1][0]+=dp[i][1][1][0];
                
                dp[i+1][0][1][0]+=dp[i][1][1][1];
                dp[i+1][1][0][1]+=dp[i][1][1][1];
                
            }else{
                dp[i+1][1][0][0]+=2*dp[i][1][0][0];
                dp[i+1][0][0][0]+=dp[i][1][0][0];
                
                dp[i+1][0][0][0]+=dp[i][1][0][1];
                dp[i+1][1][0][1]+=dp[i][1][0][1];
                
                dp[i+1][0][1][0]+=dp[i][0][1][0];
                
                dp[i+1][0][1][1]+=dp[i][0][1][1];
                
                dp[i+1][1][1][0]+=dp[i][1][1][0];
                
                dp[i+1][1][1][1]+=dp[i][1][1][1];
            }
        }
        
        for(int j=0;j<2;j++){
            for(int k=0;k<2;k++){
                for(int l=0;l<2;l++){
                    dp[i+1][j][k][l]%=mod;
                }
            }
        }
    }
    
    ll ans=0;
    
    for(int j=0;j<2;j++){
        for(int k=0;k<2;k++){
            for(int l=0;l<2;l++){
                ans+=dp[62][j][k][l];
                ans%=mod;
            }
        }
    }
    
    cout<<ans<<endl;
}


Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class A {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            // 入力
            int a = Integer.parseInt(in.next());
            int b = Integer.parseInt(in.next());
            int c = Integer.parseInt(in.next());
            boolean ok = false;
            if (a == b && b == c && c == a) ok = true;
            out.println(ok ? "Yes" : "No");

        }

    }
}



Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define All(v) v.begin(), v.end()
using namespace std;
typedef long long lint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;

const int MAX_N = (int)4e5 + 5, C = (int)2e5;
int parent[MAX_N], r[MAX_N], X[MAX_N], Y[MAX_N];
int M[MAX_N], used[MAX_N];
unordered_set<int> CX[MAX_N], CY[MAX_N];

void init(int n){
    for(int i=0;i<n;i++){
        parent[i] = i;
        r[i] = 0;
    }
}

int find(int x){
    if(parent[x] == x) return x;
    else return parent[x] = find(parent[x]);
}

void unite(int x, int y){
    x = find(x); y = find(y);
    if(x == y) return;
    if(r[x]<r[y]) parent[x] = y;
    else{
        parent[y] = x;
        if(r[x] == r[y]) r[x]++;
    }
}


int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int N;
    cin>>N;
    init(MAX_N);
    for(int i=0;i<N;i++){
        cin>>X[i]>>Y[i], X[i]--, Y[i]--;
        unite(X[i], C+Y[i]);
    }
    for(int i=0;i<N;i++){
        CX[find(X[i])].emplace(X[i]);
        CY[find(C+Y[i])].emplace(Y[i]);
        M[find(X[i])]++;
    }
    lint ans = 0;
    for(int i=0;i<N;i++){
        int p = find(X[i]);
        if(used[p]) continue;
        used[p] = 1;
        ans += 1LL * CX[p].size() * CY[p].size() - M[p];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 57728
using System;
using System.Linq;
using System.Collections.Generic;
class P
{
    static void Main()
    {
        Dictionary<string, int> dict = new Dictionary<string, int>();
        dict.Add("ecasdqina", 0);
        int n = int.Parse(Console.ReadLine());
        string[] s = Enumerable.Repeat(0, n).Select(_ => Console.ReadLine()).ToArray();
        int m = int.Parse(Console.ReadLine());
        string[] t = Enumerable.Repeat(0, m).Select(_ => Console.ReadLine()).ToArray();
        foreach (var item in s)
        {
            if (!dict.ContainsKey(item)) dict.Add(item, 0);
            dict[item]++;
        }
        foreach (var item in t)
        {
            if (!dict.ContainsKey(item)) dict.Add(item, 0);
            dict[item]--;
        }
        Console.WriteLine(dict.Max(x => x.Value));
    }
}

Measured memory_bytes: 13408
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
       Scanner scan= new Scanner(System.in);

        for(int i=0;;i++){
            int H=scan.nextInt();
            int W=scan.nextInt();
            if(W==0 && H==0){
                break;
            }

            for(int j=0;j<H;j++) {
                for (int k = 0; k < W; k++) {
                    if(j==0 || j==H-1){
                        System.out.print("#");
                    }else {
                        if(k==0 || k==W-1){
                            System.out.print("#");
                        }else{
                            System.out.print(".");
                        }
                    }

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



Measured memory_bytes: 33304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

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

    static class TaskB {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            int n = in.nextInt();
            int t = in.nextInt();

            int min = Integer.MAX_VALUE;
            for (int i = 0; i < n; i++) {
                int cc = in.nextInt();
                int ct = in.nextInt();
                if (ct <= t)
                    min = cc < min ? cc : min;
            }
            out.println(min == Integer.MAX_VALUE ? "TLE" : min);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 22740
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = /*1'000'000'007;*/998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 100'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<int> a(n);
  int mx1 = 0;
  int mx2 = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    if (a[i] > mx1) {
      mx2 = mx1;
      mx1 = a[i];
    }
    else if (a[i] > mx2) {
      mx2 = a[i];
    }
  }
  for (int val : a) {
    if (val == mx1) {
      cout << mx2 << '\n';
    }
    else {
      cout << mx1 << '\n';
    }
  }
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lb;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n,j) for (int i = n; j<=i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;
typedef pair<ll,ll> P;

int main(){
  int N;cin>>N;
  vector<int> H(N);
  REP(i,0,N){cin>>H[i];}

  int give_water=0,cnt,idx;
  while(true){
    cnt=idx=0;
    while(idx<N){
      cnt+=H[idx];
      if(H[idx]){
        give_water++;
        while(idx<N&&H[idx]){
          H[idx]--;
          idx++;
        }
      }
      idx++;
    }
    if(cnt==0){break;}
  }
  print(give_water)

}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265359
using ull = unsigned long long;
using ll = long long;
using namespace std;

int main()
{
  int n, k; cin >> n >> k;
  vector<int> d(k);
  vector<int> count(n); rep(i, n) count[i] = 0;
  vector<vector<int>> a(k);
  int ans = 0;
  rep(i, k) {
    cin >> d[i];
    a[i] = vector<int>(d[i]);
    rep(j, d[i]) cin >> a[i][j];
  }

  rep(i, k) 
    rep(j, d[i])
      count[a[i][j]-1]++;
  rep(i, n)
    if (count[i] == 0) ans++;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <iostream>
#include <complex>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
#define mp make_pair
inline double sq(double a) { return a*a; }

int N, M, C;
int u[2000], v[2000], w[2000], next[2000], head[200];
int dp[200][1024];

int main() {
    for(;;) {
        scanf("%d%d%d", &N, &M, &C);
        if(N==0) return 0;
        memset(head, -1, sizeof(head));
        rep(i, M) {
            scanf("%d%d%d", u+i, v+i, w+i);
            u[i]--, v[i]--;
            next[i] = head[u[i]];
            head[u[i]] = i;
        }
        typedef pair<int, int> node;
        priority_queue<pair<int, node> > q;
        memset(dp, -1, sizeof(dp));
        q.push(mp(0, mp(0, 0)));
        while(!q.empty()) {
            pair<int, node> vv(q.top());
            q.pop();
            const int cw = -vv.first;
            const int cat = vv.second.first;
            const int cdel = vv.second.second;
            if(dp[cat][cdel]!=-1) continue;
            dp[cat][cdel] = cw;
            for(int x=head[cat]; x!=-1; x=next[x]) {
                if(cdel<M) q.push(mp(-cw, mp(v[x], cdel+1)));
                if(dp[v[x]][cdel]==-1) q.push(mp(-cw-w[x], mp(v[x], cdel)));
            }
        }
        rep(i, M+1) if(dp[N-1][i]<=C) {
            printf("%d\n", i);
            break;
        }
    }
}

Measured memory_bytes: 12000
#include<stdio.h>
#include<cstdio>
#include<stdlib.h>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cmath>
#include<vector>

#include<stack>
#include<queue>
#include<time.h>
#include<set>
#include<map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i>b;i--)
#define vint vector<int> 
#define vvint vector<vint>
#define ct(a) cout<<a<<endl
using namespace std;
typedef long long ll;
const ll INF = 1e9 + 7;
const ll mod = 998244353;


ll N;
map<ll, ll> P;
ll ans = 0;
int main() {
	
	cin >> N;
	ll curM = -INF;
	ll cntF = 0;
	FOR(i, 0, N) {
		ll A;
		cin >> A;
		
		if (A < 0) {
			curM = max(curM, A);
			cntF++;
			ans -= A;
		}
		if (A > 0) {
			ans += A;
			curM = max(curM, -A);
		}
		if (A == 0 || i == N - 1) {
			if (A!=0&&cntF % 2 == 1) {
				ans += 2*curM;
			}

			cntF = 0;
			curM = -INF;
		}
	}


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

Measured memory_bytes: 256
#define FOR(i,j,n) for (int i=(j);i<(n);i++)
#define REP(i,n) for (int i=0;i<(n);i++)
#define REPN(i,n) for (int i=(n);i>=0;i--)
#define I(n) scanf("%d", &(n))
#define LL(n) scanf("%lld", &(n))
#define pb(n) push_back((n))
#define mp(i,j) make_pair((i),(j))
#include <bits/stdc++.h>
using namespace std;

//------------------------------typedef集
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef vector<vi> vvi;
typedef vector<vpi> vvpi;
typedef vector<vvi> vvvi;

int n,f[100],p[100][11],ret,tmp;

const int BITS_COUNT_TABLE[256] = {
    0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    1, 2, 2, 3, 2, 3, 3, 4, 2, 3, 3, 4, 3, 4, 4, 5,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    2, 3, 3, 4, 3, 4, 4, 5, 3, 4, 4, 5, 4, 5, 5, 6,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    3, 4, 4, 5, 4, 5, 5, 6, 4, 5, 5, 6, 5, 6, 6, 7,
    4, 5, 5, 6, 5, 6, 6, 7, 5, 6, 6, 7, 6, 7, 7, 8,
};

int numofbits2(int bits)
{
    int num  = 0;

    num += BITS_COUNT_TABLE[((unsigned char*)&bits)[0]];
    num += BITS_COUNT_TABLE[((unsigned char*)&bits)[1]];
    num += BITS_COUNT_TABLE[((unsigned char*)&bits)[2]];
    num += BITS_COUNT_TABLE[((unsigned char*)&bits)[3]];

    return num;
}

int main(){
    I(n);
    REP(i,n) { REP(j,10) { I(ret) ; f[i] = f[i] << 1 | ret; } }
    REP(i,n) REP(j,11) I(p[i][j]);
    ret = -1000000001;
    FOR(open,1,1<<10){
        tmp = 0;
        REP(i,n) tmp += p[i][ numofbits2(f[i]&open) ];

        ret = max(ret,tmp);
    }
    cout << ret << endl;
}


Measured memory_bytes: 256
N, A, B, C, D = map(int, input().split())
s = input()

if C > D:
    if "##" in s:
        print("No")
    else:
        if "..." in s[B-2:D+1]:
            print("Yes")
        else:
            print("No")
else:
    if "##" in s[min(A,B)-1:D]:
        print("No")
    else:
        print("Yes")

Measured memory_bytes: 40560
#include <stdio.h>

int main(void){
 int a, b, c;

 scanf("%d %d %d", &a, &b, &c);

 if(a <= b && b <= c){
  printf("%d %d %d\n", a, b, c);

 }else if(a <= c && c <= b){
  printf("%d %d %d\n", a, c, b);

 }else if(b <= a && a <= c){
  printf("%d %d %d\n", b, a, c);

 }else if(b <= c && c <= a){
  printf("%d %d %d\n", b, c, a);

 }else if(c <= a && a <= b){
  printf("%d %d %d\n", c, a, b);

 }else if(c <= b && b <= a){
  printf("%d %d %d\n", c, b, a);

 }

 return 0;
}

Measured memory_bytes: 596
io = STDIN
hh,ww,d=io.gets.split.map(&:to_i)
$hash={}
$memo=Array.new(hh*ww+1,0)
hh.times do |h|
  row=io.gets.split.map(&:to_i)
  row.each_with_index do |n,w|
    $hash[n]=[h,w]
  end
end
require 'pp'
((d+1)..hh*ww).each do |xy|
  i,j=$hash[xy-d]
  x,y=$hash[xy]
  $memo[xy]=$memo[xy-d]+(x-i).abs+(y-j).abs
end
q=io.gets.to_i
q.times do
  l,r=io.gets.split.map(&:to_i)
  puts $memo[r]-$memo[l]
end


Measured memory_bytes: 17020
import numpy as np
n=int(input())
w=[int(x) for x in input().split()]
list=[]
list2=[]
for i in range(n):
  list.append(sum(w[:i+1]))
  list2.append(sum(w[i+1:]))
comb = [x - y for (x, y) in zip(list, list2)]
ans=np.abs(comb)
print(min(ans))

Measured memory_bytes: 12448
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef unsigned int uint;
typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main()
{
    ullong X; cin >> X;
    ullong year = 0;
    ullong Y = 100;
    while (Y < X) {
        Y = Y * 1.01;
        ++year;
    }
    cout << year << endl;
}


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

#define ld long double
#define ll long long
#define ALL(a)  (a).begin(),(a).end()
#define spa << " " <<
#define MP make_pair
ll MOD = 1e9+7;
//ll MOD = 998244353;
ll INF = 1e18;
void chmin(ll &a, ll b) { if (a > b) a = b; }
void chmax(ll &a, ll b) { if (a < b) a = b; }
void ans1(bool x){
  if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){
  if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){
  if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
void ans(bool x, ll y, ll z){
  if(x) cout<<y<<endl;else cout<<z<<endl;}   


int main(){
  ll i,j;
  //ll n; cin>>n;
  //ll a,b,c,d,e,f; cin>>a>>b;
  //ll a,b,c,d,e,f; cin>>a>>b>>c;
  //ll a,b,c,d,e,f; cin>>a>>b>>c>>d;
  string s; cin >> s;
  ll result = 0;
  ll buf = 0;
  bool judge = true;
  //cout<<<<endl;
  s[3] = '8';
  cout<<s<<endl;

  /*
  vector<ll> a(n);
  for(i=0;i<n;i++){
    cin >> a[i];
  }
  for(i=0;i<n;i++){

  }
  */

  return 0;
}

Measured memory_bytes: 256
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1000000000
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};

int main(){

    int x, y, z;
    scanf("%d%d%d", &x, &y, &z);

    int i = 1;
    while(true){
        if(x<(y*i+z*i+z)) break;
        i++;
    }
    cout << i-1 << endl;
    return 0;
}

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

int main() {
	long long N, A, B;
	cin >> N >> A >> B;
	long long divide = N / (A + B), ans = 0;
	ans += A * divide;
	long long remain = N % (A + B);
	if (remain >= A) {
		ans += A;
	} else {
		ans += remain;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)
var out = bufio.NewWriter(os.Stdout)

func main() {
	buf := make([]byte, 1024*1024)
	sc.Buffer(buf, bufio.MaxScanTokenSize)
	sc.Split(bufio.ScanWords)
	defer out.Flush()
	A, B, K := nextInt(), nextInt(), nextInt()
	AV, BV := A/K, B/K
	if A%K == 0 {
		AV--
	}
	fmt.Fprintln(out, BV-AV)
}

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	a, _ := strconv.Atoi(next())
	return a
}

func nextInts(n int) []int {
	ret := make([]int, n)
	for i := 0; i < n; i++ {
		ret[i] = nextInt()
	}
	return ret
}

func nextStrings(n int) []string {
	ret := make([]string, n)
	for i := 0; i < n; i++ {
		ret[i] = next()
	}
	return ret
}

func chars(s string) []string {
	ret := make([]string, len([]rune(s)))
	for i, v := range []rune(s) {
		ret[i] = string(v)
	}
	return ret
}


Measured memory_bytes: 640
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <bitset>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
using namespace std;

char str[1000005];

int main(int argc, char* argv[])
{
    int n,Q;
    scanf("%d%s%d", &n, str, &Q);

    int q;
    for(q=0; q<Q; q++) {
        int K;
        scanf("%d", &K);

        ll ans=0;
        int cnt0=0, cnt1=0;
        ll cnt01=0;

        int i;
        for(i=0; i<n; i++) {
            if(i>=K) {
                if(str[i-K]=='D') {
                    cnt0--;
                    cnt01 -= cnt1;
                }
                else if(str[i-K]=='M') {
                    cnt1--;
                }
            }

            if(str[i]=='D') {
                cnt0++;
            }
            else if(str[i]=='M') {
                cnt1++;
                cnt01+=cnt0;
            }
            else if(str[i]=='C') {
                ans+=cnt01;
            }
        }
        printf("%lld\n", ans);
    }
    
    return 0;
}


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

using namespace std;
#define ll long long
#define mod 1000000007

double dp[3001][3001];
vector<double> v;

double f(int i, int j) {
    if (i == v.size() && !j) return 1;
    else if (i == v.size()) return 0;

    if (dp[i][j] != 2) return dp[i][j];

    double ans;
    ans = (1.0 - v[i]) * f(i + 1, j);
    if (j) {
        ans += v[i] * f(i + 1, j - 1);
    }
    dp[i][j] = ans;
    return ans;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    v.resize(n);

    for (int i = 0; i <= 3000; i++) {
        for (int j = 0; j <= 3000; j++) {
            dp[i][j] = 2;
        }
    }

    for (auto &i : v) {
        cin >> i;
    }

    double ans = 0;
    for (int i = n; i > n / 2; i--) {
        ans += f(0, i);
    }
    cout << setprecision(12) << ans << "\n";
}


Measured memory_bytes: 74288
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[2][101];
int dp[3][101];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			scanf("%d",&a[i][j]);
		}
	}
	dp[0][0]=a[0][0];
	for(int i=0;i<2;i++){
		for(int j=0;j<n;j++){
			dp[i+1][j]=max(dp[i+1][j],dp[i][j]+a[i+1][j]);
			dp[i][j+1]=max(dp[i][j+1],dp[i][j]+a[i][j+1]);
		}
	}
	printf("%d\n",dp[1][n-1]);
	return 0;
}

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

using PP = pair<long, long>;
const long inf = 1e18;
int n, m, p;
vector<PP> G[2500];

long dist[2500];
bool neg[2500];
void update() {
  for (int from = 0; from < n; ++from) {
    if (dist[from] == inf) continue;
    for (auto e : G[from]) {
      int to = e.first;
      int c = e.second;
      dist[to] = min(dist[to], dist[from] + c);
    }
  }
}

void prop() {
  for (int from = 0; from < n; ++from) {
    if (dist[from] == inf) continue;
    for (auto e : G[from]) {
      int to = e.first;
      int c = e.second;
      if (neg[from] || dist[from] + c < dist[to]) {
        neg[to] = true;
      }
    }
  }
}

int main() {
  cin >> n >> m >> p;
  for (int j = 0; j < m; ++j) {
    int a, b, c;
    cin >> a >> b >> c;
    --a; --b;
    G[a].push_back(PP(b, p - c));
  }
  
  fill(dist, dist + n, inf);
  dist[0] = 0;
  
  for (int z = 0; z < n; ++z) update();
  for (int z = 0; z < n; ++z) prop();
  
  if (neg[n - 1]) {
    cout << -1 << endl;
  } else {
    cout << max(0l, -dist[n - 1]) << endl;
  }
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    vector<string> a = {"Sunny", "Cloudy", "Rainy"};
    string s; cin >> s;
    for (int i = 0; i < 3; i++) {
        if (a[i] == s) {
            cout << a[(i + 1) % 3] << "\n";
        }
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
#define M 1000000007
signed main()
{
    IOS
    int n,m; cin>>n>>m;
    char arr[n+1][m+1];
    for(int i=1;i<=n;i++)
    {
      for(int j=1;j<=m;j++)
      {
        cin>>arr[i][j];
      }
    }
    int dp[n+1][m+1];
    bool flag = false;
    for(int i=1;i<=n;i++)
    {
      if(arr[i][1] == '#') flag = true;
      if(flag == true) dp[i][1] = 0;
      else dp[i][1] = 1;
    }
    flag = false;
    for(int j = 1;j<=m;j++)
    {
      if(arr[1][j] == '#') flag = true;
      if(flag) dp[1][j] = 0;
      else dp[1][j] = 1;
    }
    for(int i = 2;i<=n;i++)
    {
      for(int j = 2;j<=m;j++)
      {
        if(arr[i][j] == '#') dp[i][j] = 0;
        else{
          dp[i][j] = (dp[i-1][j] + dp[i][j-1])%M;
        }
      }
    }
    cout<<dp[n][m];
    return 0;
}

Measured memory_bytes: 9088
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Read();

            var ans = 0;
            var tmp = 0;
            for (int i = 0; i < 3; i++)
            {
                if (s[i] == 'R')
                {
                    tmp++;
                }
                else
                {
                    ans = Max(ans, tmp);
                    tmp = 0;
                }
            }
            ans = Max(ans, tmp);
            WriteLine(ans);
        }

        private static string Read() { return ReadLine(); }
        private static string[] Reads() { return (Read().Split()); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 25852