akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main(void){
    double a[2]={0.0};
    int A[2]={0},B[2]={0},C[2]={0},D[2]={0};

    while(scanf("%lf%lf",&a[0],&a[1]) != EOF){
    if(a[0] >= 1.1)A[0] += 1;
    else if(a[0] >= 0.6)B[0] += 1;
    else if(a[0] >= 0.2)C[0] += 1;
    else if(a[0] < 0.2)D[0] += 1;
    if(a[1] >= 1.1)A[1] += 1;
    else if(a[1] >= 0.6)B[1] += 1;
    else if(a[1] >= 0.2)C[1] += 1;
    else if(a[1] < 0.2)D[1] += 1;
    }
    printf("%d %d\n",A[0],A[1]);
    printf("%d %d\n",B[0],B[1]);
    printf("%d %d\n",C[0],C[1]);
    printf("%d %d\n",D[0],D[1]);

    return 0;
}

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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    if (k >= n) {
        cout << 0 << endl;
        return 0;
    }
    vector<int> h(n);
    for (auto &x: h) cin >> x;
    sort(h.begin(), h.end());
    long long all = 0;
    for (int i = 0; i < n-k; ++i) {
        all += h[i];
    }
    cout << all << endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        String s = in.next();
        System.out.println(s.charAt(2)==s.charAt(3)&&s.charAt(4)==s.charAt(5) ? "Yes" : "No");
    }
}


Measured memory_bytes: 22740
(defun flatten (x)
  (labels ((rec (x acc)
                (cond ((null x) acc)
                      ((atom x) (cons x acc))
                      (t (rec (car x) (rec (cdr x) acc))))))
    (rec x nil)))


(let* ((n (read))
       (l (remove-duplicates (flatten (loop for i from 0 to 100 by 4
                                            collect (loop for j from 0 to 100 by 7
                                                          when (<= (+ i j) 100)
                                                          collect (+ i j)))))))

  (format t "~A~%"
          (if (find n l)
            "Yes"
            "No")))


Measured memory_bytes: 23544
// AUTHOR - RUTVIK KOTHARI
// DAIICT , GANDHINAGAR

#include<bits/stdc++.h>
using namespace std;

#define ll long long int
#define ull unsigned long long
#define pll pair<ll,ll>
#define MS(x, y) memset(x, y, sizeof(x))
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define INFL LLONG_MAX
#define pb push_back
#define FIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const ll N = 1e5 + 5;
const ll M = 1e5 + 5;
const ll mod = 1e9 + 7;
const ll m1 = 1e9 + 7;
const ll m2 = 1e9 + 9;
const ll p1 = 402653189;
const ll p2 = 1610612741;
const int LN = 32;

ll powermodm(ll x,ll n,ll M){ll result=1;while(n>0){if(n % 2 ==1)result=(result * x)%M;x=(x*x)%M;n=n/2;}return result;}
ll power(ll _a,ll _b){ll _r=1;while(_b){if(_b%2==1)_r=(_r*_a);_b/=2;_a=(_a*_a);}return _r;}
ll gcd(ll a,ll b){if(a==0)return b;return gcd(b%a,a);}
ll lcm(ll a,ll b){return (max(a,b)/gcd(a,b))*min(a,b);}

ll dx[4]={-1,  1,  0,  0};
ll dy[4]={ 0,  0,  1, -1};

ll pw[LN],fact[N],invfact[N];

void pre()
{
    fact[0]=1;
    for(int i=0;i<LN;i++)pw[i]=power(2,i);
    for(int i=1;i<N;i++)fact[i]=(i*fact[i-1])%mod;
    for(int i=0;i<N;i++)invfact[i]=powermodm(fact[i],mod-2,mod);
}

ll ans[N];

int main()
{
    FIO;
    //pre();

    ll i,j;
    
    ll n,k;
    cin>>n>>k;
    
    ll a[n+1],sum = 0;
    for(i=1;i<=n;i++)
    {
        cin>>a[i];
        sum += a[i];
    }
    
    vector <ll> div;
    
    for(i=1;i*i<=sum;i++)
    {
        if(sum%i==0)
        {
            div.pb(i);
            if((i*i)!=sum)
                div.pb(sum/i);
        }
    }
    
    sort(all(div));
    reverse(all(div));
    
    for(auto it:div)
    {
    //ll it = 7;
        map <ll,ll> mp;
        
        for(i=1;i<=n;i++)
        {
            mp[a[i]%it]++;
        }
        
        vector <pll> tmp;
        ll pref = 0, suff = 0;
        
        for(auto it1:mp)
        {
            tmp.pb({it1.ff,it1.ss});
            suff += ((it-it1.ff)*(it1.ss));
        }
        
        ll mi = INFL;
        //cout<<suff<<"\n";
        for(i=0;i<tmp.size();i++)
        {
            //cout<<tmp[i].ff<<"  "<<tmp[i].ss<<"\n";
            ll x = (tmp[i].ff*tmp[i].ss);
            ll x1 = ((it-tmp[i].ff)*(tmp[i].ss));
            suff -= x1;
            
            ll val = (pref + x - suff);
            //cout<<val<<"\n";
            if(val%it == 0 && val>=0)
            {
                ll y = val/it;
                
                if(y<=tmp[i].ss)
                    mi = min(mi,pref+((tmp[i].ss-y)*tmp[i].ff));
            }
            pref += x;
        }
        //cout<<it<<"  "<<mi<<"\n";
        if(mi<=k)
        {
            cout<<it;
            return 0;
        }
    }
    
    
    
    return 0;
}

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

int main(){
    int h, w, n;

    cin >> h >> w >> n;

    int count;

    if(h > w){
        if(n % h != 0){
         count = n / h + 1;
        }else{
         count = n / h;
        }
    }else{
        if(n % w != 0){
         count = n / w + 1;
        }else{
         count = n / w;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
import sys

def q(i):
  print(i, flush=True)
  r = input()
  if r == 'Vacant':
    sys.exit()
  return r == 'Female'

n = int(input())

def go(a, b, ra):
  m = (a + b) // 2
  d = m - a + 1
  rm = q(m)
  if (ra == rm) == (d % 2 == 1):
    go(m, b, rm)
  else:
    go(a, m, ra)

ra = q(0)
rb = q(n - 1)
go(0, n - 1, ra)


Measured memory_bytes: 3660
lines = STDIN.gets.chomp

s = ['A', 'G', 'C', 'T']
count = 0;
result = 0;
lines.each_char do |c|
    if s.include?(c)
      count += 1
    else
      count = 0
    end
    if result < count 
      result = count
    end
end

print result;


Measured memory_bytes: 1788
//#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
//#include <queue>
//#include <stack>
#include <cstring>
#include <cassert>

using namespace std;

#ifdef LOCAL_DEBUG
#include <local_debug.h>
#define DEBUG(...) DBG2::print(#__VA_ARGS__, __LINE__, __VA_ARGS__)
#else
#define DEBUG(...)
#endif

#define SZ(a) int((a).size())
#define REP(i,n) for(int i=0,_n=(n);i<_n;++i)
#define FOR(i,a,b) for(int i=(a),_b=(b);i<=_b;++i)

typedef long long llong;
typedef vector<int> VI;
typedef vector<VI> VVI;



int main(int argc, char* argv[]) {
   ios_base::sync_with_stdio(false); 
   cin.tie(nullptr);

   int N;
   cin >> N;
   VI H(N+1);
   FOR(i, 1, N)
      cin >> H[i];

   llong res = 0;
   map<int,int> freq;
   FOR(i, 1, N) {
      int d = i - H[i];
      if (freq.count(d)) {
         res += freq[d];
      }
      ++freq[i + H[i]];
   }
   
   cout << res << '\n';

   return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
    ll N,res;
    bool up;
    cin>>N;
    vector<ll> A(N);
    REP(i,N)cin>>A[i];

    res = 1;
    start:;
    while(A.size()>1 && A[N-2]==A[N-1])
    {
        A.pop_back();    
        N--;
    }
    if(N==1)goto end;

    up = A[N-2] > A[N-1];
    A.pop_back();
    N--;
    while(A.size()>1)
    {
        if(up)
        {
            if(A[N-2]<A[N-1])
            {
                res++;
                A.pop_back();
                N--;
                goto start;
            }
        }
        else
        {
            if(A[N-2]>A[N-1])
            {
                res++;
                A.pop_back();
                N--;
                goto start;
            }
        }
        A.pop_back();
        N--;
    }

    end:;
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <iomanip>
#include <limits.h>

using namespace std;

int max(int x, int y)
{
	return x>y ? x : y;
}

int main()
{
	int capacity[8] = {4, 1, 4, 1, 2, 1, 2, 1};
	int index[8] = {3, 5, 1, 7, 4, 6, 2, 0};
	
	int p[8];
	while ( cin >> p[0] ) {
		for (int i=1; i<8; i++) cin >> p[i];
		
		int minWaiting = INT_MAX;
		int minWaitingIndex = 0;
		
		for (int j=0; j<8; j++) {
			int headIndex = index[j];
			int numOfWaiting = 0;
			for (int i=0; i<8; i++) {
				numOfWaiting += max(p[i] - capacity[(headIndex+i)%8], 0);
			}
			if (minWaiting > numOfWaiting) {
				minWaiting = numOfWaiting;
				minWaitingIndex = headIndex;
			}
		}
		
		for (int i=0; i<7; i++) {
			cout << capacity[(minWaitingIndex+i)%8] << " ";
		}
		cout << capacity[(minWaitingIndex+7)%8] << endl;
	}
	
	return 0;
}

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

int main() {
	char c;
	std::cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		std::cout << "vowel";
		return 0;
	}
	std::cout << "consonant";
	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define endl '\n'
#define fcin ios::sync_with_stdio(false); cin.tie(nullptr);
#define inf 0x3f3f3f3f
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

/* 
 * * stuff you should look for
 * * int overflow, array bounds
 * * special cases (n=1?), set tle
 * */

const int N = 2e5 + 5;
int n, u, v;
int dist[N][2];
vector<int> e[N];

void dfs(int u, int k, int d=0, int p=-1){
    dist[u][k] = d;
    for(int v : e[u]){
        if(v == p) continue;
        dfs(v, k, d+1, u);
    }
}

int main(){
    fcin;

    cin >> n >> u >> v;

    for(int i = 0; i < n - 1; i++){
        int a, b;
        cin >> a >> b;
        e[a].pb(b);
        e[b].pb(a);
    }

    dfs(u, 0);
    dfs(v, 1);

    int ans = 0;

    for(int i = 1; i <= n; i++){
        if(dist[i][0] < dist[i][1]){
            ans = max(ans, dist[i][1]);
        }
    }
    cout << ans - 1 << endl;
    return 0;
}



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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

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

    string S;
    cin >> S;

    if ((S.size()%2 == 1) == (S.front() == S.back())) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
}



Measured memory_bytes: 512
import math
A, B, H, M = map(int, input().split())

X1 = A * (math.sin(math.radians(0.5 * (H*60+M))))
Y1 = A * (math.cos(math.radians(0.5 * (H*60+M))))

X2 = B * (math.sin(math.radians(6 * M)))
Y2 = B * (math.cos(math.radians(6 * M)))

R = math.sqrt((X1-X2)**2 + (Y1 - Y2) ** 2)
print(R)


Measured memory_bytes: 9584
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;
use std::collections::HashSet;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

#[allow(dead_code)]
fn read_as_string() -> String{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main(){
    let s  = read_as_string().chars().collect::<Vec<char>>();
    let mut hash: HashSet<char> = HashSet::new();

    for c in &s{
        hash.insert(*c);
    }

    let mut ans = std::usize::MAX;
    for target in hash{
        //println!("target = {}", target);
        let mut t = s.clone();
        let mut cur_cost = 0;
        while !t.iter().all(|x| *x == target){
            //println!("t = {:?}", t);
            let mut tn: Vec<char> = vec!['A';t.len()-1];
            for i in 0..t.len()-1{
                if t[i] == target || t[i+1] == target{
                    tn[i] = target;
                }else{
                    tn[i] = t[i];
                }
            }
            //println!("tn = {:?}", tn);
            cur_cost += 1;
            t = tn;
        }
        ans = cmp::min(cur_cost, ans);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main {

    static int MOD = 1000000007;
    
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int n = Integer.parseInt(sc.next());
        int m = Integer.parseInt(sc.next());
        int[] a = new int[m];
        for(int i = 0; i < m; i++){
            a[i] = Integer.parseInt(sc.next());
        }
        
        int[] f = new int[n+1];
        f[0] = 1;
        f[1] = 1;
        for(int i = 2; i <= n; i++){
            f[i] = (f[i-2] + f[i-1]) % MOD;
        }
        
        long count = 1;
        int length;
        if(m == 0){
            count = f[n];
        }else{
            length = a[0];
            if(length != 0){
                count = (count * f[length -1]) % MOD;
            }
            for(int i = 0; i < m-1; i++){
                length = a[i+1] - a[i] -1;
                if(length == 0){
                    System.out.println(0);
                    return;
                }
                count = (count * f[length -1]) % MOD;
            }
            length = n - a[m-1];
            if(length != 0){
                count = (count * f[length -1]) % MOD;
            }
        }
        
        System.out.println(count);
    }
}

Measured memory_bytes: 48620
# 同じ文字を異なる位置から取り出すのは区別する
# 与えられた文字列の並び順は関係ない
from collections import Counter
N = int(input())
S = input()

ans = 1
mod = 10**9+7
count = Counter(S)
for v in count.values():
    ans *= (v+1) % mod
print((ans-1) % mod)


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

#define fs first
#define se second
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < n; ++i)

using pii = pair<int, int>;
using vi = vector<int>;
using lint = long long;

const int inf = 1001001001;
const lint linf = 1001001001001001001ll;
const int mod = 1e9 + 7;
const int dx[]{0, 1, 0, -1, -1, -1, 1, 1}, dy[]{1, 0, -1, 0, -1, 1, -1, 1};

template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; } return a > b; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; } return a < b; }
template<typename T> inline void print(const T &x, string s = "\n") { cout << x << s; }
template<typename T> inline void print(const vector<T> &v, string s = " ") 
{ rep(i, v.size()) cout << v[i] << (i + 1 == v.size() ? "\n" : s); }
inline bool inside(int y, int x, int H, int W) { return 0 <= y && y < H && 0 <= x && x < W; }
inline lint in() { lint x; std::cin>>x; return x; }

vi G[64];

int main() {
	int n = in(), m = in();

	rep(i, m) {
		int a = in() - 1, b = in() - 1;
		G[a].push_back(b);
		G[b].push_back(a);
	}

	rep(i, n) {
		cout << G[i].size() << endl;
	}
}



Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> lc(N), rc(N);
	for(int i = 0; i < N; ++i) {
		int id;
		cin >> id;
		cin >> lc[id] >> rc[id];
	}
	int root = 0;
	for(int i = 0; i < N; ++i) {
		root ^= i;
		if(lc[i] != -1) root ^= lc[i];
		if(rc[i] != -1) root ^= rc[i];
	}
	function<void(int, int)> recur = [&](int pos, int method) {
		if(method == 0) cout << ' ' << pos;
		if(lc[pos] != -1) recur(lc[pos], method);
		if(method == 1) cout << ' ' << pos;
		if(rc[pos] != -1) recur(rc[pos], method);
		if(method == 2) cout << ' ' << pos;
	};
	cout << "Preorder" << endl; recur(root, 0); cout << endl;
	cout << "Inorder" << endl; recur(root, 1); cout << endl;
	cout << "Postorder" << endl; recur(root, 2); cout << endl;
	return 0;
}


Measured memory_bytes: 3108
#include <stdio.h>

int main(void) {
	int W, H, x, y, r, tmp1, tmp2, tmp3, tmp4 = 0;
	scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
	//printf("%d %d %d %d %d", W, H, x, y, r);
	tmp1 = x+r;
	tmp2 = y+r;
	tmp3 = x-r;
	tmp4 = y-r;
	if((tmp1<=W) && (tmp4>=0)){
		if((tmp2<=H) && (tmp3>=0)){
			printf("Yes\n");
		}else{
			printf("No\n");
		}
	}
	else{
		printf("No\n");
	}
	return 0;
}




Measured memory_bytes: 2112
import java.util.Scanner;
 
class Main{
	
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		int e = sc.nextInt();
		int f = sc.nextInt();
		if((a*1+b*5+c*10+d*50+e*100+f*500)/1000 > 0)
		System.out.println(1);
		else
			System.out.println(0);
	}
}

Measured memory_bytes: 17316
#-------------
A,B,C = map(int, input().split())
K = int(input())
#-------------
card = []
for i in range(K):
  B_x = B*(2**i)
  C_x = C*(2**(K-i))
  card.append([A,B_x,C_x])

cnt = 0
for i in range(len(card)):
  if card[i][2] > card[i][1] > card[i][0] :
    cnt +=1

if cnt >= 1:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9200
#include<bits/stdc++.h>
using namespace std;
typedef  long long int ll; 


void solve()
{
	int n;
	cin >> n;
	vector<pair<int,int>> a;
	for(int i=0;i<n;++i)
	{
		int x,y;
		cin >> x >> y;
		a.push_back(make_pair(x,y));
	}
	int f=0;
	for(int i=0;i<n-2;++i)
	{
		if((a[i].first==a[i].second) && (a[i+1].first==a[i+1].second) && (a[i+2].first==a[i+2].second))
		{
			//cout << a[i+1].first << " " << a[i].first << " " << a[i+2].first << endl;
			f=1;
			cout << "Yes" << endl;
			break;
		}
	}
	if(f==0)
	{
		cout << "No" << endl;
	}
}

int main()
{
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
    // int t;
    // cin >> t;
    // while (t--)
    // {
    //     solve();
    // }
    
   solve();
    return 0;
    
}

Measured memory_bytes: 3652
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<string>
#include<vector>
using namespace std;

int main(void){
	ios::sync_with_stdio(false); cin.tie(0);
	
	
	int a[3];
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	if(a[0]==5&&a[1]==5&&a[2]==7)cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	
	
	
	
	
	
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <sstream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cassert>
using namespace std;

#define REP(i,n) for (int i = 0; i < n; i++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long ll;

int main ()
{
    int N; cin >> N;
    vector < ll > A(N);
    REP(i,N) cin >> A[i];

    ll sum = abs(A[0]) + abs(A[N - 1]);
    REP(i,A.size() - 1) {
        sum += abs(A[i] - A[i + 1]);
    }

    ll sumt = sum;
    REP(i,A.size()) {
        sum = sumt;
        if (i == 0) {
            cout << sum - abs(A[0] - A[1]) - abs(A[0]) + abs(A[1]) << endl;
        } else if (i == A.size() - 1) {
            cout << sum - abs(A[N - 2] - A[N - 1]) - abs(A[N - 1]) + abs(A[N - 2]) << endl;
        } else {
            ll diff = abs(A[i - 1] - A[i]) + abs(A[i] - A[i + 1]) - abs(A[i - 1] - A[i + 1]);
            cout << sum - diff << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2048
#include <iostream>
#include <math.h>


using namespace std;


int main(){
    int n,d;
    cin>>n>>d;
    double a[200000][3];
    double b[200000][3],c[200000];
    int cnt=0;

    for(int i=0;i<n;i++){
        for(int j=0;j<2;j++){
            cin>>a[i][j];
            b[i][j]=pow(a[i][j],2);
            c[i]+=b[i][j];
        }
    }

    for(int i=0;i<n;i++){
        c[i]=sqrt(c[i]);
        if(d>=c[i])
            cnt++;
    }
    cout<<cnt<<endl;
}

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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int r1 = a / d;
  if (a % d != 0) r1++;
  int r2 = c / b;
  if (c % b != 0) r2++;
  
  string result = r1 >= r2 ? "Yes" : "No";
  cout << result << endl;
  
  return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int n; cin >> n;
  vector<int> v(n); cin >> v;
  int sum = 0;
  for(int e:v)sum ^= e;
  for(int i = 0; i < n; ++i){
    if(i) cout << ' ';
    cout << (v[i]^sum);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 3980
import sys


def input():
    return sys.stdin.readline().rstrip()


def main():
    n = int(input())
    bits = [int(e) for e in input().split()]
    ans = set()
    for i in reversed(range(n)):
        for j in range(i + (i + 1), n, i + 1):
            bits[i] ^= bits[j]
        if bits[i] == 1:
            ans.add(i + 1)
    print(len(ans))
    print(*ans)


main()


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

  long long int dp[2][410][410] = {};

long long int gcd (long long int a, long long int b ) {

  long long int c;
  while( a != 0 ) {
    c = a;
    a = b % a;
    b = c;
  }
  return b;

}

int main() {

  long long int n, ma, mb;
  cin >> n >> ma >> mb;

  vector< long long int > a, b, c;

  for ( long long int i = 0; i < n; i++ ) {

    long long int aa, bb, cc;
    cin >> aa >> bb >> cc;

    a.push_back( aa );
    b.push_back( bb );
    c.push_back( cc );

  }

  dp[0][0][0] = 1;

  for ( long long int i = 0; i < n; i++ ) {

    for ( long long int aa = 409; aa >= 0; aa-- ) {
      for ( long long int bb = 409; bb >= 0; bb-- ) {
	dp[1][aa][bb] = 0;
      }
    }
    for ( long long int aa = 400; aa >= 0; aa-- ) {
      for ( long long int bb = 400; bb >= 0; bb-- ) {

	if ( dp[0][aa][bb] == 0 ) continue;
	long long int pa = aa + a[i];
	long long int pb = bb + b[i];
	long long int pc = dp[0][aa][bb] + c[i];
	if ( dp[1][pa][pb] == 0 || dp[1][pa][pb] > pc ) {
	  dp[1][pa][pb] = pc;
	}

      }
    }
    for ( long long int aa = 409; aa >= 0; aa-- ) {
      for ( long long int bb = 409; bb >= 0; bb-- ) {
	long long int pc = dp[1][aa][bb];
	if ( pc == 0 ) continue;
	if ( dp[0][aa][bb] == 0 || dp[0][aa][bb] > pc ) {
	  dp[0][aa][bb] = pc;
	}
      }
    }

  }
  
  long long int bb = 0;
  for ( long long int aa = ma; aa < 410; aa += ma ) {
    bb += mb;
    if ( bb >= 410 ) break;
    long long int pc = dp[0][aa][bb];
    if ( pc == 0 ) continue;
    if ( dp[0][ma][mb] == 0 || dp[0][ma][mb] > pc ) {
      dp[0][ma][mb] = pc;
    }
  }

  //  if ( dp[ma][mb] == 0 ) {
  //    cout << -1 << endl;
  //  }else {
    cout << dp[0][ma][mb] - 1 << endl;
    //  }

  return 0;

}


Measured memory_bytes: 2432
import sys
input = sys.stdin.readline
A,B,C,X,Y = [int(i) for i in input().split()]
money = A * X + B * Y
ans = money
m = min(X,Y)
M = max(X,Y)
d = M - m
if A + B > C * 2 :
    for i in range(m) :
        ans = ans -( A + B) + (2 * C)
    if m == X :
        if B * d > C * 2 * d :
            ans =ans - (B * d) + C * 2 * d
    else :
        if A * d > C * 2 * d :
            ans = ans -(A * d) + C * 2 * d
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define INF 2001
#define GRAY 0
#define WHITE 1
#define BLACK -1
#define N 100

void prim( int );

int n, color[N+1], d[N+1], adj[N+1][N+1], p[N+1];

int main(){
    int i, j, sum = 0, m;

    //input
    scanf("%d", &n);
    for( i=0; i<n; i++ ){
	for( j=0; j<n; j++){
	    scanf("%d", &m);
	    if( m == -1 ) adj[i][j] = INF;
	    else adj[i][j] = m;
	}
    }

    //calculate
    prim( 0 );

    //calculate sum
    for( i=0; i<n; i++ ){
	if( p[i] != -1 )
	    sum += adj[i][p[i]];
    }
    //print
    printf("%d\n", sum);

    return 0;
}

void prim( int start ){//1-origin
    int i, j, k, l, mincost;

    //initialize
    for(i = 0; i<n; i++){
	d[i] = INF;
	color[i] = WHITE;
	p[i] = -1;
    }
    d[start] = 0;

    //calculate
    while (1){
	mincost = INF;
	for(i = 0; i<n; i++){
	    if( color[i] != BLACK && d[i] < mincost ){
		mincost = d[i];
		k = i;
	    }
	}
	if( mincost == INF ) break;

	color[k] = BLACK;

	for( i=0; i<n; i++){
	    if( color[i] != BLACK && adj[k][i] != INF ){
		if( d[i] > adj[k][i] ){
		    d[i] = adj[k][i];
		    p[i] = k;
		    color[i] = GRAY;
		}
	    }
	}
    }
    return ;
}



Measured memory_bytes: 2132
N, M = map(int, input().split())

G = [[] for i in range(N)]
for i in range(M):
    a, b = map(int, input().split())
    G[a-1].append(b-1)
    G[b-1].append(a-1)

visited = [0]*N
visited[0] = 1

def dfs(v, visited):
    if 0 not in visited:
        return 1

    ans = 0
    for i in G[v]:
        if visited[i] == 0:
            visited[i] = 1
            ans += dfs(i, visited)
            visited[i] = 0

    return ans

print(dfs(0, visited))

Measured memory_bytes: 3064
import Control.Monad
import Control.Applicative
import Data.List
import Data.Array.IO

type Value = Int
type Weight = Int
type Item = (Weight, Value)
type ItemList = [Item]
type Capacity = Int

main :: IO ()
main = do
  input <- getContents
  let nums = map ((\x -> (last x, head x)) . map (read :: String -> Int) . words) . lines $ input
      capacity = fst . head $ nums
      items = tail nums

  memo <- newArray ((0, 0), (capacity, length items)) (0 - 1) :: IO (IOUArray (Int, Int) Int)
  dp (capacity, items) memo
  putStrLn . show . last =<< getElems memo

memoize :: ((Capacity, ItemList) -> IOUArray (Int, Int) Int -> IO (IOUArray (Int, Int) Int)) -> (Capacity, ItemList) -> IOUArray (Int, Int) Int -> IO Int
memoize f (c, i) t = do
  v <- readArray t (c, length i)
  if v < 0
    then do
      f (c, i) t
      return =<< readArray t (c, length i)
    else return v

dp :: (Capacity, ItemList) -> IOUArray (Int, Int) Int -> IO (IOUArray (Int, Int) Int)
dp (c, []) t = do
  writeArray t (c, 0) 0
  return t
dp (c, as@(i:is)) t
{-
  | c <= 0    = do
    writeArray t (0, length as) 0
    dp (c, is) t
    return t
    -}
  | c < fst i = do
    v <- memoize dp (c, is) t
    writeArray t (c, length as) v
    return t
  | otherwise = do
    x <- memoize dp (c, is) t
    y <- memoize dp (c - fst i, is) t
    writeArray t (c, length as) (max x $ y + snd i)
    return t

Measured memory_bytes: 95012
n = int(input())
A = list(map(int,input().split()))

B = []
if(n%2 == 1):
  p = n//2
  B.append(str(A[2*p]))
  for i in range(p):
   B.append(str(A[2*(p-1-i)]))
  for i in range(p):
    B.append(str(A[2*i+1]))

elif(n%2 == 0):
  p = n//2 
  for i in range(p):
   B.append(str(A[2*(p-1-i)+1]))
  for i in range(p):
    B.append(str(A[2*i]))

b = ' '.join(B) 
print(b)

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

#define rep(i, a, n)  for(ll i=a; i<n; i++)
#define per(i, a, n)  for(ll i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define LONGMAX 1e18
#define intMAX 1000000000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;

int n,l;

int main(){
  cin >> n >> l;
  int a = l;
  int b = l+n-1;

  int eat;
  if (b<=0)eat = b;
  else if(a>=0)eat = a;
  else eat = 0;

  int answer = (a+b)*n/2 - eat;
  cout << answer << endl;
  return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(void)
{
	long d,sum=0,x=0;
	while(~scanf("%d",&d))
	{
		while(x<600)
		{
			sum += ((x*x)*d);
			x+=d;
		}
		printf("%d\n",sum);
		x = 0;
		sum = 0;
	}
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    int ans = 0;
    
    for (int i = 0; i < n; i++) {
        for (int ii = 0; ii < n; ii++) {
            ans = max(ans, abs(a[i] - a[ii]));
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[10],temp;
  int i,j,n;
  for(i=0;i<3;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<2;i++){
    for(j=2;j>i;j--){
      if(a[j]<a[j-1]){
	temp=a[j];
	a[j]=a[j-1];
	a[j-1]=temp;
      }
    }
  }
  printf("%d %d %d",a[0],a[1],a[2]);
  printf("\n");
  return (0);
}

Measured memory_bytes: 600
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <algorithm>
#include <queue>
#include <utility>
#include <climits>
#include <bitset>
#include <cmath>
#include <map>
#include <tuple>
#include <complex>

#define MOD 1000000007

using namespace std;

typedef long long ll;

typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<string> vs;

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

typedef vector<pll> vpl;
typedef vector<pi> vpi;
typedef vector<vs> vvs;

typedef vector<pll> vvpl;
typedef vector<vpi> vvpi;

typedef queue<ll> ql;
typedef queue<int> qi;
typedef queue<pll> qpl;
typedef queue<pi> qpi;

template <typename T>
void printv(const vector<T>& v) {
    for (int i = 0; i < v.size(); ++i) {
        printf("[%d] %d\n", i, v[i]);
    }
}

template <typename T>
void printvv(const vector<T>& vv) {
    for (int i = 0; i < vv.size(); ++i) {
        for (int j = 0; j < vv[i].size(); ++j) {
            printf("[%d][%d] %d\n", i, j, vv[i][j]);
        }
    }
}

template <typename T, typename U>
void printp(const pair<T, U>& p) {
    cout << p.first << " " << p.second << endl;
}

template <typename T>
void printvp(const vector<pair<T, T>>& vp) {
    for (int i = 0; i < vp.size(); ++i) {
        printf("[%d] %d, %d\n", vp[i].first, vp[i].second);
    }
}

template <typename T>
void printvvp(const vector<vector<pair<T, T>>>& vvp) {
    for (int i = 0; i < vvp.size(); ++i) {
        for (int j = 0; j < vvp[i].size(); ++j) {
            printf("[%d][%d] %d, %d\n", i, j, vvp[i][j].first, vvp[i][j].second);
        }
    }
}

int main() {
    int N; cin >> N;
    vvi a(N, vi(3));
    for (int i = 0; i < N; ++i) for (int j = 0; j < 3; ++j) cin >> a[i][j];

    vvi dp(N+1, vi(3));
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < 3; ++j) {
            for (int k = 0; k < 3; ++k) {
                if (j == k) continue;
                dp[i+1][k] = max(dp[i+1][k], dp[i][j] + a[i][k]);
            }
        }
    }

    cout << max(max(dp[N][0], dp[N][1]), dp[N][2]) << endl;
    
    return 0;
}


Measured memory_bytes: 11136
#include <algorithm>
#include <cstdio>
#include <cstring>

const int N = 1e7 + 71, P = 998244353, div2 = (P + 1) / 2;

int pw(int x, int y) {
	int r = 1;
	for (; y; y >>= 1, x = 1ll * x * x % P)
		if (y & 1) r = 1ll * r * x % P;
	return r;
}
inline void $(int& x) { x += x >> 31 & P; }

int fac[N], ifac[N];
inline int C(int n, int m) { return 1ll * n[fac] * m[ifac] % P * (n - m)[ifac] % P; }

int n, ans, cur;
int main() {
	scanf("%d", &n);
	0 [fac] = 0 [ifac] = 1;
	for (int i = 1; i <= n; i++) i[fac] = 1ll * (i - 1)[fac] * i % P;
	n[ifac] = pw(n[fac], P - 2);
	for (int i = n - 1; i; i--) i[ifac] = (i + 1)[ifac] * (i + 1ll) % P;
	ans = pw(3, n), cur = pw(2, n / 2);
	for (int i = n / 2 + 1; i <= n; i++) {
		$(ans -= 1ll * cur * C(n, i) % P);
		cur = 1ll * cur * div2 % P;
	}
	printf("%d", ans);
}

Measured memory_bytes: 78336
#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)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;
template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 >& p) {
  os << "{" <<p.first << ", " << p.second << "}";
  return os;
}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll N, K;
    cin >> N >> K;

    if(N <= K){
        cout << min(N, abs(K - N)) << endl;
        return 0;
    }
    else{
        cout << min(N % K, K - (N%K)) << endl;
    }
}

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

int main(){
  int n,m,x,y;
  cin >> n >> m;
  x = 1900*m + 100*(n-m);
  y=1;
  for(int i=1;i<=m;i++){
    y = y*2;
  }
  
  cout << x*y << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define eb emplace_back
#define x first
#define y second

int n, m;
int qa[100000];
int qb[100000];
bitset<400> c[400], die;

int main()
{
	read(n, m);
	for(int i=0;i<m;++i)read(qa[i],qb[i]);
	for(int i=0;i<n;++i){
		auto&chk=c[i];
		chk.reset(); chk[i]=1;
		for(int j=m-1;0<=j;--j){
			int a=qa[j],b=qb[j];--a;--b;
			if(chk[a]&&chk[b]){die[i]=1;break;}
			else if(chk[a]) chk[b]=1;
			else if(chk[b]) chk[a]=1;
		}
	}
	int ans=0;
	for(int i=0;i<n;++i)if(!die[i])
	for(int j=i+1;j<n;++j)if(!die[j]) if((c[i]&c[j]).none())++ans;
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 1024
era = [1]*55556

era[0] = era[1] = 0
for i in range(2,int(55556**0.5)+1):
    if( era[i] == 1):
        for j in range(i*2,55556,i): era[j] = 0

v = [0]*5
n = int(input())
for i in range(55556):
    if(era[i] and i%5 == 1):
        print(i, end=" ")
        n -= 1
        if(n == 0): break
print()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/


signed main(){
	int n;
	cin>>n;
	vi a(n);
	rep(i,n) cin>>a[i];

	rep(i,n){
		if(i>0) cout<<' ';
		cout<<a[i];
	}
	cout<<endl;

	FOR(i,1,n-1){
		int v=a[i];
		int j=i-1;
		while(j>=0&&a[j]>v){
			a[j+1]=a[j];
			j--;
		}
		a[j+1]=v;

		rep(z,n){
			if(z>0) cout<<' ';
			cout<<a[z];
		}
		cout<<endl;
	}


	return 0;
}




Measured memory_bytes: 3132
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <deque>
#include <ctime>

using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define mp make_pair
#define all(r) (r).begin(),(r).end()
#define rall(r) (r).rbegin(),(r).rend()
#define fi first
#define se second

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const ll LINF = 1e18;
const ll MOD = 86400;
double EPS = 1e-8;
const double PI = acos(-1);

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

	if(a == 1){
		a += 13;
	}

	if(b == 1){
		b += 13;
	}

	if(a > b){
		cout << "Alice" << endl;
	}else if(a == b){
		cout << "Draw" << endl;
	}else{
		cout << "Bob" << endl;
	}
}

Measured memory_bytes: 256
def int_to_list(bit, n):
    l = []
    for i in range(n):
     if bit & (1 << i):
         l.append(i)
    return l

def solve():
    N, M = map(int, input().split())
    A = [list(map(int, input().split())) for _ in range(M)]
    p = list(map(int, input().split()))

    c = 0
    for i in range(1 << N):
        partial = int_to_list(i, N)
        b = True
        
        for j in range(M):
            d = 0
            for k in range(A[j][0]):
                if A[j][k+1]-1 in partial:
                    d += 1
            if d % 2 != p[j]:
                b = False

        if b:
            c += 1
        
    return c

print(solve())

Measured memory_bytes: 3064
def gcd(a,b):
    if b == 0:
        return a
    return gcd(b,a%b)
def inpl(): return [int(i) for i in input().split()]

N, X = inpl()
x = inpl()
x = [abs(x[i]-X) for i in range(N)]
ans = x[0]
for i in x:
    ans = gcd(ans,i)
print(ans)

Measured memory_bytes: 14480
import collections

N = int(input())
solution = []
S = []

for i in range(N):
  tmp = input()
  S.append(tmp)
  
c = collections.Counter(S)

d = c.most_common()

max_ = d[0][1]

for i,k in enumerate(d):
  if d[i][1] == max_:
    solution.append(d[i][0])
    
solution.sort()

for i in solution:
  print(i)

Measured memory_bytes: 47664
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long

int main() {
 int n;cin>>n;
 string s[110];
 rep(i,n)cin>>s[i];
 int m;cin>>m;
 string t[110];
 rep(i,m)cin>>t[i];
 map<string,int> num;
 int Max=0;
 rep(i,n){
     num[s[i]]++;
 }
 rep(j,m){
     num[t[j]]--;
 }
 rep(i,n){
     Max=max(Max,num[s[i]]);
 }
 if(Max<0)cout<<0<<endl;
 else cout<<Max<<endl;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

counter = 0

N_maxA = min( int(X // 500), A )

for i in range(N_maxA + 1):
	Res = X - (i * 500)
	N_maxB = min( int(Res // 100) , B )
	
	for j in range(N_maxB + 1):
		Res1 = Res - j*100
		if int(Res1 // 50) <= C:
			
			counter += 1

print(counter)



Measured memory_bytes: 3060
S = input()
K = int(input())
result = 0
if S[0] != S[-1]:
    t = None
    for i in range(len(S)):

        if i == 0:
            t = S[i]
            continue

        if t == S[i]:
            result += 1
            t = None
            continue

        t = S[i]

    print(result * K)
    exit()

else:

    t = S[0]
    count_a = 1
    for i in range(len(S)):
        if i == 0:
            continue

        if t == S[i]:
            count_a += 1
        else:
            break
    if count_a == len(S):
        print((len(S) * K) // 2)
        exit()
    count_b = 0

    for i in range(len(S)):
        if t == S[-i-1]:
            count_b += 1
        else:
            break

    T = S[count_a:-count_b]

    m = None
    for i in range(len(T)):

        if i == 0:
            m = T[i]
            continue

        if m == T[i]:
            result += 1
            m = None
            continue

        m = T[i]

    count = count_a + count_b
    change = count // 2
    change_a = count_a // 2
    change_b = count_b // 2

    print(change_a + change_b + (K - 1) * change + K * result)




Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

const int INF = 1e9;

int main() {
    int n, t;
    cin >> n >> t;
    VI a(n), b(n);
    REP(i,n){
        a[i] = in();
        b[i] = in();
    }
    VVI dp(n + 1, VI(t)), dp2(dp);
    REP(i,n){
        REP(j,t){
            chmax(dp[i + 1][j], dp[i][j]);
            if (j + a[i] < t){
                chmax(dp[i + 1][j + a[i]], dp[i][j] + b[i]);
            }
        }
    }
    reverse(ALL(a));
    reverse(ALL(b));
    REP(i,n){
        REP(j,t){
            chmax(dp2[i + 1][j], dp2[i][j]);
            if (j + a[i] < t) chmax(dp2[i + 1][j + a[i]], dp2[i][j] + b[i]);
        }
    }
    reverse(ALL(a));
    reverse(ALL(b));

    // REP(i,n+1){
    //     REP(j,t) cout << dp[i][j] << " ";
    //     cout << endl;
    // }
    // REP(i,n+1){
    //     REP(j,t) cout << dp2[i][j] << " ";
    //     cout << endl;
    // }

    int ans = dp[n][t - 1];
    REP(i,n){
        REP(j,t){
            chmax(ans, dp[i][j] + dp2[n - 1 - i][t - 1 - j] + b[i]);
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 70784
n,k=map(int,input().split())
candle=list(map(int,input().split()))
ans=2000000000
for i in range(n-k+1):
  if candle[i]<0 and candle[i+k-1]>0:
    temp=min(abs(candle[i]), candle[i+k-1])*2+max(abs(candle[i]), candle[i+k-1])
  elif candle[i+k-1]<=0:
    temp=abs(candle[i])
  elif candle[i]>=0:
    temp=candle[i+k-1]
  ans=min(temp, ans)
print(ans)

Measured memory_bytes: 14844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

ll N,Q;
vector<ll> G[200000];
vector<ll> result(200000,0);
vector<bool> F(200000,false);

void dfs(ll v,ll p=-1){
    if(!F[v]){
        F[v]=true;
        if(p!=-1){
            result[v] += result[p];
        }
        rep(i,G[v].size()){
            if(!F[G[v][i]]) dfs(G[v][i], v);
        }
    }
}

int main(){
    cin >> N >> Q;
    F.resize(N);
    rep(i,N-1){
        ll p, c;
        cin >> p >> c;
        G[p-1].push_back(c-1);
        G[c-1].push_back(p-1);
    }

    rep(i,Q){
        ll p,x;
        cin >> p >> x;
        result[p-1] += x;
    }
    dfs(0);
    rep(i,N) cout << result[i] << ' ';
    cout << endl;
    return 0;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
#define int long long
signed main()
{
    int n,k;cin >> n >> k;
    if(n%k == 0)cout << 0 << endl;
    else cout <<1 << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define lli long long int
#define endl '\n'
#define deb(x) cout << #x << " = " << x << endl
#define deb2(x, y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define deb3(x, y, z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define fastio 	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;

int main()
{
	fastio;

    string s;
    cin >> s;

    int sum = 0;

    for (int i = 0; i < s.length(); i++) {
        int x = s[i] - '0';
        sum += x;
    }

    if (sum % 9 == 0) {
        cout << "Yes\n";
    }
    else {
        cout << "No\n";
    }

	return 0;
}




Measured memory_bytes: 3760
#include <stdio.h>
#include <stdlib.h>

int cmpnum(const void * n1, const void * n2)
{
	if (*(long *)n1 > *(long *)n2)
	{
		return -1;
	}
	else if (*(long *)n1 < *(long *)n2)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}

int main(void)
{
	int n,i;
	long int d[100000]={0};
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%ld",&d[i]);
		}
	
	qsort(d, sizeof(d) / sizeof(d[0]), sizeof(long), cmpnum);
	printf("%ld",d[n/2-1]-d[n/2]);

	return 0;
}

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

int main(){
  long x,min,m;
  cin>>x;
  for(int i=1;i<=sqrt(x);i++){
    if(x%i==0){
        m=x/i;
        min=m-1+i-1;
    }
  }
  cout<<min;
}

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

#define rng(i, a, b) for (int i = int(a); i < int(b); i++)
#define rep(i, b) rng(i, 0, b)
#define gnr(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define per(i, b) gnr(i, 0, b)

using namespace std;

using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<P> xl(n);
  rep(i, n) {
    int x, l;
    cin >> x >> l;
    xl.at(i) = make_pair(x, l);
  }
  vector<P> ft(n);
  rep(i, n) {
    int x = xl.at(i).first;
    int l = xl.at(i).second;
    ft.at(i) = make_pair(x + l, x - l);
  }
  sort(ft.begin(), ft.end());
  int res = 0;
  int cur = INT_MIN;
  rep(i, n) {
    if (ft.at(i).second >= cur) {
      cur = ft.at(i).first;
      res++;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 4852
#pragma region Macros
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i, n) for(int i=(n); i>=0; --i)
#define FOR(i, n, m) for(int i=(m), i##_len=(n); i<i##_len; ++i)
#define FOREACH(i, v) for(const auto& i : v)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIGN(x) (((x)>0)?1:(((x)<0)?-1:0))
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; }
typedef long long ll;
#define vv(t) vector< t > 
#define CHC(mp, x) if(mp.end() != mp.find(x))
#define CHCV(mp, x) if(mp.end() != find(ALL(mp), x))
template<typename T>
inline T lcm(T a, T b) {return a / __gcd(a, b) * b;}
#define fi first
#define se second
#define el endl
#pragma endregion

const string YES = "YES";
const string NO = "NO";

void Main();
void solve();

int main(){
    std::cin.tie(nullptr);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}

void Main(){
    string s;
    cin >> s;
    int N = s.length();
    vv(ll) X(N, 0);
    int L_cnt = 0;
    int R_cnt = 0;
    REP(i, N){
        if(s[i]=='L'){
            L_cnt++;
            X[i-(L_cnt-(L_cnt%2))]++;
        }else{
            L_cnt = 0;
        }
    }
    REPR(i, N-1){
        if(s[i]=='R'){
            R_cnt++;
            X[i+(R_cnt-(R_cnt%2))]++;
        }else{
            R_cnt = 0;
        }
    }
    REP(i, N-1){
        cout << X[i] << " ";
    }
    cout << X[N-1] << el;
}



Measured memory_bytes: 1408