akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> a(N);
	for (int& i : a) cin >> i;
	if (any_of(a.begin(), a.end(), [](int& a) { return a % 2; })) cout << "first";
	else cout << "second";
}

Measured memory_bytes: 640
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-01-28 14:54:11
# @Description: You build it. You run it
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
int n , h , a, b;
int dp[maxn];
int main()
{
    cin >> h >> n;
    memset(dp , 0x3f , sizeof dp);
    dp[0] = 0;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        for(int j = 0; j <= h; j++){
            dp[a+j] = min(dp[a+j] , dp[j] + b);
            if(j+a >= h)if(dp[h] > dp[j+a])dp[h] = dp[j+a];
        }
    }cout << dp[h] << endl;
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 4344
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

int main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
typedef queue<P> Q;

#define _CRT_SECURE_NO_WARNINGS

int N;
bool IsP(int n) {
	for (int i = 2; i < n/2;i++) {
		if (n%i==0) {
			return false;
		}
	}
	return true;
}
int main() {
	scanf("%d",&N);
	int a = 0;
	for (int i = 2; i < 55555;i++) {
		if (i%5==1 && IsP(i)) {
			printf("%d ",i);
			a++;
			if (a==N) {
				break;
			}
		}
	}
	return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x, y; cin >> x >> y;
    ll ans = 0;
    while(x <= y){
        x *= 2;
        ans++;
    }
    cout << ans;
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let (A, B, T) = read!(i64, i64, i64);
    println!("{}", T / A * B)
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <cstdio>
#include <algorithm>
#include <array>
#include <cmath>

using namespace std;

using ll = long long int;

int main() {
 
    char str[(int)1e5] = {'\0'};
    
    cin >> str;

    string tile(str);

    int cnt_begin0 = 0;
    for (int i = 0; i < tile.size(); i++) {
        if (i%2 == 0 && tile.at(i) == '1') ++cnt_begin0;
        if (i%2 == 1 && tile.at(i) == '0') ++cnt_begin0;
    }
    

    int cnt_begin1 = 0;
    for (int i = 0; i < tile.size(); i++) {
        if (i%2 == 0 && tile.at(i) == '0') ++cnt_begin1;
        if (i%2 == 1 && tile.at(i) == '1') ++cnt_begin1;
    }

  
    cout << ((cnt_begin0 < cnt_begin1) ? cnt_begin0 : cnt_begin1);


    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <iomanip>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	long double ans = 0;
	std::vector<int> a(n);
	for(int i = 0; i < n; i++) {
		std::cin >> a[i];
	}
	for(int i = 0; i < n; i++) {
		ans += 1.0 / a[i];
	}
	std::cout << std::fixed << std::setprecision(10) << 1.0 / ans << '\n';
}

Measured memory_bytes: 256
import java.util.Scanner;

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

        int w = sc.nextInt();
        int h = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        sc.close();

        double ans = (double)w * (double)h / (double)2;
        if (x * 2 == w && y * 2 == h) {
            System.out.println(ans + " 1");
        } else if ((x * 2 == w && y * 2 != h) || (x * 2 != w && y * 2 == h)) {
            System.out.println(ans + " 0");
        } else {
            System.out.println(ans + " 0");
        }
    }
}


Measured memory_bytes: 23892
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


int main(){
    int N;
    cin >> N;
    int M=0;
    int ans=0;
    for(int i=0; i<N; i++){
        int H;
        cin >> H;
        if(H>=M){
            ans++;
            M=H;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int truss(int n){
	int cnt=0;
	while(n){
		n/=10;
		cnt++;
	}
	return cnt;
}
int main(void){
	long long n,i,min=11;
	scanf("%lld",&n);
	for(i=1;i*i<=n;i++){
		if(n%i==0){
			long long a=i,b=n/i,f;
			f=truss(a)<truss(b)?truss(b):truss(a);
			min=f<min?f:min;
		}
	}
	printf("%lld",min);
	return 0;
}

Measured memory_bytes: 128
mylist=[]

for i in range(5):
    a=int(input())
    mylist.append(a)

if mylist[0]<0:
    print(mylist[0]*mylist[2]*(-1)+mylist[3]+mylist[1]*mylist[4])
else:
    print((mylist[1]-mylist[0])*mylist[4])


Measured memory_bytes: 5600
#include<iostream>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    int h[n];
    rep(i, n) cin >> h[i];
    int ans = 0;
    rep(i, n) if (h[i] >= k)  ans++;
    cout << ans << endl;
}

Measured memory_bytes: 640
//https://onlinejudge.u-aizu.ac.jp/challenges/sources/JOI/Prelim/0566?year=2012

#include <bits/stdc++.h>

using namespace std;

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

    vector<int> pt(static_cast<unsigned long>(n + 1));//各チームの得点
    for (int i = 0; i < n * (n - 1) / 2; ++i) {
        int a, b, c, d;
        cin >> a >> b >> c >> d;

        if (c > d) {
            pt[a] += 3;
        } else if (c < d) {
            pt[b] += 3;
        } else if (c == d) {
            pt[a]++;
            pt[b]++;
        }
    }

    vector<int> vt;//順位計算用
    for (int i = 1; i <= n; ++i) {
        vt.emplace_back(pt[i]);
    }
    vt.emplace_back(100000);
    sort(vt.begin(), vt.end());

    for (int i = 1; i <= n; ++i) {
        auto tmp = upper_bound(vt.begin(), vt.end(), pt[i]);
        cout << n + 1 - (tmp - vt.begin()) << endl;
    }
    return 0;
}

/*
 *
 */


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

int main()
{   
    long long N;
    std::cin >> N;
    
    long long A;
    long long b[N];
    // init
    for(int i=0; i<N; i++){
        b[i] = 0;
    }

    for(int i=0; i<N-1; i++){
        cin >> A;
        b[A-1]++;
    }
    
    for(int i=0; i<N; i++){
        std::cout << b[i] << std::endl;
    }

    return 0;
}


Measured memory_bytes: 5184
//
//  main.cpp
//  1
//
//  Created by RISHAV SINGH MEHTA on 19/01/20.
//  Copyright © 2020 RISHAV SINGH MEHTA. All rights reserved.
//

#include <iostream>
#include <vector>
#include <algorithm>
#define ll long long
using namespace std;
int main(int argc, const char * argv[]) {
    // insert code here...
    ll int T,N,i,j,k,l,a,b,c,M;
    
    cin>>N>>M;
    if (N==M) {
        cout<<"Yes";
    }else{
        cout<<"No";
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
array=gets.chomp.split(" ").map(&:to_i)

def judege(array)
    kudari = false
    (0..array.count-2).each do |i| 
        x = array[i]
        y = array [i+1]
        if x - 1 > y 
            return false
        elsif x - 1 == y
            if kudari == false
                kudari = true
            else
                return false
            end
        elsif x == y
        elsif x < y
            kudari = false
        end
    end
    true
end

puts judege(array) ? 'Yes' : 'No'


Measured memory_bytes: 9604
import sys
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    sum_ = [0] * N
    sum_[0] = A[0]%M
    for i in range(1, N):
        sum_[i] = (sum_[i-1] + A[i]) % M
    
    ans = 0
    dic = {}
    for i in range(N):
        if sum_[i] in dic:
            if sum_[i] != 0:
                ans += dic[sum_[i]]
            dic[sum_[i]] += 1
        else:
            dic[sum_[i]] = 1
        if sum_[i] == 0:
            ans += dic[sum_[i]]
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 17028
#include <cstdio>
#include <iostream>
using namespace std;
typedef long long ll;
int main()
{

    int q,h,s,d;
    ll n;
    while(scanf("%d %d %d %d",&q,&h,&s,&d)==4)
    {
        scanf("%lld",&n);
        ll x=min(q*4,min(h*2,s)),ans=0;
        if(d<x*2)  ans=(n/2)*d+(n%2)*x;
        else       ans=n*x;
        printf("%lld\n",ans);
    }
    return 0;
}


Measured memory_bytes: 256
// Problem : E - Logs
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_e
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣠⣶⡾⠏⠉⠙⠳⢦⡀⠀⠀⠀
⠀⠀⠀⣴⠿⠏⠀⠀⠀⠀⠀⠀⢳⡀⠀
⠀⠀⢠⣟⣋⡀⢀⣀⣀⡀⠀⣀⡀⣧⠀
⠀⠀⢸⣯⡭⠁⠸⣛⣟⠆⡴⣻⡲⣿⠀
⠀⠀⣟⣿⡭⠀⠀⠀⠀⠀⢱⠀⠀⣿⠀
⠀⠀⠙⢿⣯⠄⠀⠀⠀⢀⡀⠀⠀⡿⠀⠀
⠀⠀⠀⠀⠹⣶⠆⠀⠀⠀⠀⠀⡴⠃⠀⠀
⠀⠀⠀⠀⠀⢸⣷⡦⢤⡤⢤⣞⣁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⢀⣤⣴⣿⣏⠁⠀⠀⠸⣏⢯⣷⣖⣦⡀⠀⠀⠀⠀⠀⠀
⢀⣾⣽⣿⣿⣿⣿⠛⢲⣶⣾⢉⡷⣿⣿⠵⣿⠀⠀⠀⠀⠀⠀
⣼⣿⠍⠉⣿⡭⠉⠙⢺⣇⣼⡏⠀⠀⠀⣄⢸⠀⠀⠀⠀⠀⠀
⣿⣿⣧⣀⣿.........⣀⣰⣏⣘⣆⣀⠀
*/
#include <bits/stdc++.h> 
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#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;
 
typedef long long   ll;
typedef long double ld;
typedef complex< ld > cd;
 
typedef pair<int, int> pi;
typedef pair<ll, ll>   pl;
typedef pair<ld, ld>   pd;
 
typedef vector< int > vi;
typedef vector< ld >  vd;
typedef vector< ll >  vl;
typedef vector< pi >  vpi;
typedef vector< pl >  vpl;
typedef vector< cd >  vcd;
 
#define l00p(i, a, b) for (int i=a; i<(b); i++)
#define loop(i, a)    for (int i=0; i<(a); i++)
#define rep1(i, a, b) for (int i = (b)-1; i >= a; i--)
#define rep(i, a)     for (int i = (a)-1; i >= 0; i--)
#define trav(a, x)    for (auto& a : x)
#define uid(a, b)     uniform_int_distribution<int>(a, b)(rng)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f  first
#define s  second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
//#define MOD 998244353
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy
vi a(1000000);
int n,k;
bool valid(int h)
{
	int val=0;
	loop(i,n)
	{
		if(a[i]>h)
			val+=(a[i]+h-1)/h-1;
	}
	return (k>=val)?true:false;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); 
	int l=1,r=0;
	cin>>n>>k;
	loop(i,n)
	{
		cin>>a[i];
		ckmax(r,a[i]);
	}
	int ans=INT_MAX;
	while(l<=r)
	{
		int mid =(l+r)/2;
		if(valid(mid))
		{
			ckmin(ans,mid);
			r=mid-1;
		}
		else
			l=mid+1;
		
	}
	cout<<ans<<nl;
	return 0;
}
// read the question correctly (ll vs int)
// template by bqi343

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

int main() {
    int x;
    cin >> x;
    if(x < 1200) {
        cout << "ABC";
    }
    else {
        cout << "ARC";
    }
    
    cout << endl;
    return 0;
}

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

int main() {
    int n, x;
    cin >> n >> x;
    int l;
    int d = 0;
    for (int i = 0; i < n; i++) {
        cin >> l;
        d += l;
        if (d > x) {
            cout << i+1 << endl;
            break;
        }
        else if (i == n-1) {
            cout << n+1 << endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int h,m,s;
	
	scanf("%d",&s);
	h=s/3600;
	s%=3600;
	m=s/60;
	s%=60;
	
	printf("%d:%d:%d\n",h,m,s);
	
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int fact(int n) {
	if (n == 0)return 1;
	return n * fact(n - 1);
}
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
bool prime(int n) {
	int cnt = 0;
	for (int i = 1; i <= sqrt(n); i++) {
		if (n%i == 0)cnt++;
	}
	if (cnt != 1)return false;
	else return n != 1;
}
int a[114514]; int n;
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	int ans = 0;
	rep(i, n) {
		if (a[i] % 2 == 1)ans++;
	}
	if (ans % 2 == 1)puts("NO");
	else puts("YES");
	getchar(); getchar(); return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
using namespace std;

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll A,B,C;
int main(){
  cin >> A >> B >> C;
  if (B+C-A>0) cout << B+C-A << endl;
  else cout << 0 << endl;
}


Measured memory_bytes: 888
#define INF 10000000000
#define MOD 1000000007

#if 1   // use_templates

#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <algorithm>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define rep(i, up) for (ll i = 0; i < (up); ++i)
#define repp(i, up) for (ll i = 0; i <= (up); ++i)
#define rrep(i, lo, up) for (ll i = (lo); i < (up); ++i)
#define rrepp(i, lo, up) for (ll i = (lo); i <= (up); ++i)
#define eep(i, lo, up) for ((i) = (lo); (i) < (up); ++(i))
#define eepp(i, lo, up) for ((i) = (lo); (i) <= (up); ++(i))
#define feach(it, vec) for (auto it = (vec).begin(); it != (vec).end(); ++it)


ll gcd(ll a, ll b);

ll gcd(ll a, ll b)
{
    if (a < b) {
        return gcd(b, a);
    }
    ll r;
    while (r = a % b) {
        a = b;
        b = r;
    }
    return b;
}

#endif  // end of use_templates


int main()
{
    ll n;
    cin >> n;
    string c;
    cin >> c;
    ll f;
    for (f = 0; f < n && c[f] != 'W'; ++f);
    ll cnt = 0;
    for (ll b = n - 1; f < b; --b) {
        if (c[b] == 'R') {
            c[f] = 'R';
            c[b] = 'W';
            ++cnt;
            for (; f < n && c[f] != 'W'; ++f);
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3488
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n+1;i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
typedef long long ll;
typedef pair<int,int> P;

int main(){
  int a,b,c,x,y;
  cin >>a>>b>>c>>x>>y;
  int ans = pow(10,9);
  for(int i=0;i<=max(x,y)*2;i += 2){
    int tmp_a = max(0,x-i/2);
    int tmp_b = max(0,y-i/2);
    ans = min(ans,tmp_a*a+tmp_b*b+i*c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <utility>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <set>

#define INF_LL 9000000000000000000
#define INF 2000000000

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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef pair<int, PII> PPII;
typedef pair<int, PPII> PPPII;

class Union_find{
private:
	vector<int> par;
	vector<int> rank;
	int n;

public:
	Union_find(int a){
		n = a;
		for(int i = 0;i < n;i++){
			par.push_back(i);
			rank.push_back(0);
		}
	}

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

	void unite(int x, int y){
		x = find(x);
		y = find(y);
		if(x == y) return;

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

	bool same(int x, int y){
		return find(x) == find(y);
	}
};

ll dp[2][3030] = {};
int main(void){
	int N, T, S;
	int A[3030], B[3030];
	cin >> N >> T >> S;
	REP(i, N){
		cin >> A[i] >> B[i];
	}
	int cur = 0;
	REP(i, N+1){
		REP(j, T+1){
			if(i-1 >= 0) dp[cur][j] = max(dp[cur][j], dp[1-cur][j]);
			if(i-1 >= 0 && j-B[i-1] >= 0 && !(j-B[i-1] < S && S < j)){
				dp[cur][j] = max(dp[cur][j], dp[1-cur][j-B[i-1]]+A[i-1]);
			}
		}
		cur = 1-cur;
	}
	ll res = 0;
	REP(i, 2){
		REP(j, T+1){
			res = max(res, dp[i][j]);
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
typedef long long ll;
#define f(i,a,b) for(long long i=a;i<b;i++)
#define F first
#define S second
#define pb(i) push_back(i)
#define mp(x,y) make_pair(x,y)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

vector<ll> v;
vector<pair<ll,ll> > vc;

ll sq(ll p){
	return p*p;
}

ll find(ll i,ll j){
	return sq(vc[i].F-vc[j].F)+sq(vc[i].S-vc[j].S);
}

int main(){
	ll n,a,b;
	cin>>n;
	v.resize(n);
	f(i,0,n) v[i]=i;
	f(i,0,n){
		cin>>a>>b;vc.pb(mp(a,b));
	}
	ll cnt=0;
	long double res=0.0;
	do{
		long double sum=0.0;
		f(i,1,v.size()){
			sum+=sqrt(find(v[i],v[i-1])*1.0);
		}
		res+=sum;
		cnt++;	
	}while(next_permutation(v.begin(),v.end()));
	res=res*1.0/cnt;
	cout<<fixed<<setprecision(9)<<res<<"\n";
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
  int N,M,p,cntAC=0,cntPen=0;
  string S;
  cin >> N >> M;
  vector<int> WA(N,0);
  for(int i=0;i<M;i++){
    cin >> p >> S;
    if(S=="AC" && WA[p-1]>=0){
      cntAC++;
      cntPen+=WA[p-1];
      WA[p-1]=-1;
    }
    if(S=="WA" && WA[p-1]>=0)WA[p-1]++;
  }
  cout << cntAC << " " << cntPen << endl;
  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), B(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    for (int i = 0; i < N; i++) cin >> B[i];
    int ans = -1;
    for (int i = 0; i < (1 << N); i++) {
        vector<pair<int, pair<int, int>>> p;
        for (int j = 0; j < N; j++) {
            if ((i >> j)&1) p.push_back({A[j], {j, j}});
            else p.push_back({B[j], {j, j+1}});
        }
        sort(p.begin(), p.end());
        /*
        for (int j = 0; j < N; j++) {
            cout << p[j].first << p[j].second << " ";
        }
        cout << endl;
        */
        int y = 0;
        bool check = true;
        for (int j = 0; j < N; j++) {
            if (j < N-1 && p[j].first == p[j+1].first) y++;
            else if (y == 0) {
                if ((p[j].second.second + j)%2 == 1) {
                    check = false;
                    break;
                }
            }else if (y > 0) {
                for (int k = j-y; k <= j; k++) {
                    if ((p[k].second.second + k)%2 == 0) continue;
                    for (int l = k+1; l <= j; l++) {
                        if ((p[l].second.second + p[k].second.second)%2==0) continue;
                        for (int m = l-1; m >= k; m--) {
                            swap(p[m], p[m+1]);
                        }
                        break;
                    }
                }
                y = 0;
            }
        }
        for (int j = 0; j < N; j++) {
            if ((p[j].second.second + j)%2 == 1) {
                check = false;
                break;
            }
        }
        if (!check) continue;
        int cand = 0;
        for (int j = 0; j < N; j++) {
            for (int k = j+1; k < N; k++) {
                if (p[j].second.first > p[k].second.first) cand++;
            }
        }
        if (ans < 0) ans = cand;
        else ans = min(ans, cand);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
import sys
s=int(input())
l=[]
def f(x):
  if x%2==0:
    return x//2
  else:
    return 3*x+1
  
l.append(s)

for i in range(10000000):
  s=f(s)
  l.append(s)
  for j in range(len(l)-1):
    if l[j]==s:
      print(i+2)
      sys.exit()

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int acs(const void *a, const void *b) { 
  return *(int*)a - *(int*)b;
} /* 1,2,3,4.. */
int des(const void *a, const void *b) {
  return *(int*)b - *(int*)a;
} /* 8,7,6,5.. */
int cmp_char(const void *a, const void *b) { 
  return *(char*)a - *(char*)b;
} /* a,b,c,d.. */
int cmp_str(const void *a, const void *b) {
  return strcmp(*(const char **)a, *(const char **)b);
} /* aaa,aab.. */
#define min(a,b) (a < b ? a : b)
#define max(a,b) (a > b ? a : b)
#define rep(i, l, r) for (int i = l; i < r; i++)
#define MAX 100001
#define MOD 1000000007
#define INF 1000000009
typedef long long int lli;

int main(void) {
  int n;
  scanf("%d", &n);

  lli sum = 0;
  rep(i, 1, n+1) {
    if (i % 3 == 0 || i % 5 == 0) continue;
    sum += i;
  }  
  printf("%lld\n", sum);
  return 0;
}


Measured memory_bytes: 1696
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl c(8, 0);
  ll cnt = 0;
  rep(i, n) {
    ll a;
    cin >> a;
    if(a < 3200)
      c[a / 400] = 1;
    else
      cnt++;
  }
  ll ans = accumulate(all(c), 0);
  cout << max(ans, 1LL) << ' ' << ans + cnt << endl;
}

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

long gcd(long a, long b) {
    while (b > 0) {
        long r = a % b;
        a = b;
        b = r;
    }
    return a;
}

inline long calc(long a, long c, long d) {
    return a - a / c - a / d + a / ((c * d) / gcd(c, d));
}

int main() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << calc(b, c, d) - calc(a - 1, c, d) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
char s[200000];
int main() {
	int n;
	scanf("%d", &n);
	scanf("%s", s);
	int w = 0, r = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'W') {
			w++;
		} else {
			r++;
		}
	}
	int ans = 0;
	for (int i = 0; i < r; i++) {
		if (s[i] == 'W') {
			ans++;
		}
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1920
N, M = map(int,input().split())
student = []
for i in range (N):
    a, b = map(int,input().split())
    student.append([a,b])
 
flags = []
for i in range (M):
    c, d = map(int,input().split())
    flags.append([c,d])
    
    
for n in range (N):
    x = student[n][0]
    y = student[n][1]
    lowest_score = 10**10
    lowest= 0
    for m in range (M):
        x_m  = flags[m][0]
        y_m  = flags[m][1]
        temp_score = abs(x-x_m) + abs(y-y_m) 
        if temp_score < lowest_score:
            lowest_score = temp_score
            lowest = m
    print(lowest+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, k;
    cin >> n >> k;
    vector<double> v(n);
    REP(i,n) {
        cin >> v[i];
        v[i] = (v[i] + 1) / 2;
    }
    double ans = 0,cur = 0;
    REP(i,n) {
        cur += v[i];
        if (i >= k) cur -= v[i-k];
        ans = max(ans,cur);
    }

    cout << fixed << setprecision(10) << ans << '\n';

    return 0;
}

Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;

int main() {
    int n, m;
    cin >> n >> m;
    int *p = new int[m];
    string *s = new string[m];
    bool *ac = new bool[n + 5];
    int *wa = new int[n + 5];
    for (int i = 0; i < m; i++) {
        cin >> p[i] >> s[i];
    }
    for (int i = 0; i < n + 5; i++) {
        ac[i] = false;
        wa[i] = 0;
    }
    for (int i = 0; i < m; i++) {
        if (ac[p[i]] == false) {
            if (s[i] == "AC") {
                ac[p[i]] = true;
            } else {
                wa[p[i]]++;
            }
        }
    }
    int accept = 0, wrong = 0;
    for (int i = 1; i <= n; i++) {
        if (ac[i]) {
            accept++;
            wrong += wa[i];
        }
    }
    cout << accept << " " << wrong << endl;
    return 0;
}

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

using namespace std;

using PII = pair<int, int>;

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

	vector<PII> bads(m);
	for (int i = 0; i < m; i++) {
		cin >> a >> b;
		bads[i] = make_pair(a, b);
	}
	sort(bads.begin(), bads.end(),
		[](PII &x, PII &y) {
			if (x.second == y.second) {
				return x.first > y.first;
			} else {
				return x.second < y.second;
			}
		});

	vector<double> removals;
	for (auto p: bads) {
		bool adds = true;
		for (int i = removals.size() - 1; i >= 0; i--) {
			if (p.first <= removals[i] && removals[i] <= p.second) {
				adds = false;
				break;
			} else if (removals[i] < p.first) {
				break;
			}
		}
		// printf("%d %d: adds? %d\n", p.first, p.second, adds ? 1 : 0);
		if (adds) {
			removals.emplace_back(-0.5 + p.second);
		}
	}

	cout << removals.size() << endl;
	return 0;
}


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

using namespace std ;

int main()
{
    int n , k ;
    cin >> n >> k ;
    int num = 1 ;

    for(int i = 0;i < n;i++){
        if((num * 2) >= (num + k))
        num = num + k ;
        else num = num * 2 ;
    }

    cout << num ;


    return 0 ;
}


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

int main() {

	int n; cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int ans = 0;
	for (int i = 0; i < n - 1; i++) {
		if (p[i] == i + 1) {
			swap(p[i], p[i + 1]);
			ans++;
		}
	}
	if (p[n - 1] == n) {
		swap(p[n - 2], p[n - 1]);
		ans++;
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std; using ll=long long; const ll LNF=1e18; const int INF = 1e9+1; const ll M = 1e9+7;
typedef pair<int,int> P;

int main() {
  string s; cin>>s;
  if (s[0] == s[1]) cout<<"Bad"<<endl;
  else if (s[1] == s[2]) cout << "Bad"<<endl;
  else if (s[2] == s[3]) cout << "Bad"<<endl;
  else cout <<"Good"<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A = 0, B = 0, C = 0, D = 0, L = 0, R = 0;
	scanf("%d %d %d %d\n", &A, &B, &C, &D);
	L = A + B;
	R = C + D;
	if(L > R){
		printf("Left");
	}else if(L == R){
		printf("Balanced");
	}else if(L < R){
		printf("Right");
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	if(N%2==0){
		printf("%d",N*(N-1)/2-N/2);
		for(int i=1;i<=N;++i){
			for(int j=i+1;j<=N;++j){
				if(i+j!=N+1){
					printf(" %d %d",i,j);
				}
			}
		}
	}else{
		printf("%d\n",N*(N-1)/2-N/2);
		for(int i=1;i<=N;++i){
			for(int j=i+1;j<=N;++j){
				if(i+j!=N){
					printf(" %d %d",i,j);
				}
			}
		}
	}
}


Measured memory_bytes: 128
#include <stdio.h>
void MRoy(){
    char s[5],t[6];
    scanf("%s %s",s,t);
    int Ans = 0;
    for(int i = 0;i<3;i++) if(s[i]==t[i]) Ans++;
    printf("%d\n",Ans);
}
int main(){
    MRoy();
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#define INF 1000000
void warshall_floyd(void);
int min(int,int);
int graph[101][101];
int n,c,d;

int main(void){
  int k,i,j,x,e,a,b;

  while(1){
    scanf("%d %d",&n,&k);
    if(n==0 && k==0)break;

    for(i=0;i<=n;i++)
      for(j=0;j<=n;j++)
	graph[i][j] = (i==j?0:INF);

    for(i=0;i<k;i++){
      scanf("%d",&x);
      
      if(x){
	scanf("%d %d %d",&c,&d,&e);
	if(graph[c][d]>e){
	graph[c][d]=graph[d][c]=e;
	warshall_floyd();
	}
      }
      else{
	scanf("%d %d",&a,&b);
	if(graph[a][b]<INF)printf("%d\n",graph[a][b]);
	else printf("-1\n");
      }
    }
  }
  return 0;
}

void warshall_floyd(void){
  int i,j;

    for(i=1;i<=n;i++){
      for(j=1;j<=n;j++){
	graph[i][j]=graph[j][i]=min(graph[i][j],graph[i][c]+graph[c][d]+graph[d][j]);
      }
    }
}

int min(int x,int y){
  return (x<y)?x:y;
}

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

using namespace std;

#define int long long

const int MAXN = 1e5 + 7;

vector<vector<int>> g(MAXN);

int used[MAXN];
int dist[MAXN];

void dfs(int u, int d)
{
    dist[u] = d;
    used[u] = true;
    for (auto v : g[u])
    {
        if (!used[v])
        {
            dfs(v, d + 1);
        }
    }
}

int ans = 0;

void dfs2(int u)
{
    ans = max(ans, dist[u]);
    used[u] = true;
    for (auto v : g[u])
    {
        if (!used[v])
        {
            dfs2(v);
        }
    }
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n, a, b;
    cin >> n >> a >> b;
    --a; --b;
    for (int i = 0; i < n - 1; ++i)
    {
        int u, v;
        cin >> u >> v;
        --u; --v;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    dfs(b, 0);
    for (int i = 0; i < n; ++i)
    {
        if (dist[i] > dist[a] / 2)
        {
            used[i] = false;
        }
    }
    dfs2(a);
    cout << ans - 1 << endl;
    return 0;
}


Measured memory_bytes: 9984
# include <bits/stdc++.h>
using namespace std;
int main(){
	long long n , m , sum = 0;
	cin >> n >> m;
	priority_queue < long long > p;
	for(int i = 1; i <= n; i ++){
		long long x;
		cin >> x;
		p.push(x);
	}
	while(m --){
		long long x = p.top();
		p.pop();
		p.push(x >> 1);
	}
	while(p.size()){
		sum += p.top();
		p.pop();
	}
	cout << sum << "\n";
}

Measured memory_bytes: 1400
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;

public class Main {

    private static long M = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        try (BufferedReader reader = new BufferedReader(new InputStreamReader(System.in))) {
            int[] array = readIntArray(reader);
            int N = array[0];
            int K = array[1];
            int[][] matrix = readIntMatrix(reader, N - 1);

            List<Integer>[] childrens = new List[N];
            for (int i = 0; i < N; i++) {
                childrens[i] = new ArrayList<>();
            }

            for (int i = 0; i < N - 1; i++) {
                int A = matrix[i][0] - 1;
                int B = matrix[i][1] - 1;
                childrens[A].add(B);
                childrens[B].add(A);
            }

            long ans = K * dfs(0, -1, childrens, K) % M;

            System.out.println(ans);
        }
    }

    public static long dfs(int vertex, int parent, List<Integer>[] childrens, int K) {
        long ans = 1;

        int c = (parent == -1) ? K - 1 : K - 2;
        for (int child : childrens[vertex]) {
            if (child == parent) {
                continue;
            }

            ans = ans * c % M;
            c--;
        }

        for (int child : childrens[vertex]) {
            if (child == parent) {
                continue;
            }

            ans = ans * dfs(child, vertex, childrens, K) % M;
        }

        return ans;
    }

    public static int readInt(BufferedReader reader) throws Exception {
        return Integer.parseInt(reader.readLine());
    }

    public static int[] readIntArray(BufferedReader reader) throws Exception {
        String[] str = reader.readLine().split(" ");
        int[] array = new int[str.length];
        for (int i = 0; i < str.length; i++) {
            array[i] = Integer.parseInt(str[i]);
        }
        return array;
    }

    public static int[][] readIntMatrix(BufferedReader reader, int N) throws Exception {
        int[][] matrix = new int[N][];
        for (int i = 0; i < N; i++) {
            matrix[i] = readIntArray(reader);
        }
        return matrix;
    }

}


Measured memory_bytes: 67688
// Problem : A - Plural Form
// Contest : AtCoder - AtCoder Beginner Contest 179
// URL : https://atcoder.jp/contests/abc179/tasks/abc179_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

/*

WINNERS NEVER QUIT AND QUITTERS NEVER WIN!!

Falling down is an accident, Staying down is a choice.

*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<long,long> pl;
typedef pair<ll,ll> pll;
typedef vector<long> vl;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vl> vvl;
typedef vector<vb> vvb;
typedef vector<vll> vvll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef unordered_map<ll,ll> umll;

#define FOR(i,a,b) for(long long i=a;i<b;++i)
#define REV(i,a,b) for(long long i=a;i>=b;i--)
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define tc ll tests;cin>>tests;while(tests--)
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define coutv(v) for(auto it: (v))cout<<it<<" ";newl;
#define cout2d(v) for(auto it: (v)) {for(auto j:it) cout<<j<<" ";newl;}
#define cinv(v,n) vll (v)(n);FOR(i,0,(n)){cin>>v[i];}
#define cinvg(v,n) (v).resize(n);FOR(i,0,(n)){cin>>v[i];}
#define cin2d(v,n,m) vvll (v)(n,vll(m,0));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define cin2dg(v,n,m) (v).resize(n,vll(m));FOR(i,0,n){FOR(j,0,m){cin>>v[i][j];}}
#define newl cout<<"\n"
#define mod 1000000007
#define INF LLONG_MAX/2

int main()
{
    io;
    string s;
    cin>>s;
    if(s[s.size()-1]=='s')
    {
    	FOR(i,0,s.size())
    	{
    		cout<<s[i];
    	}
    	cout<<"es";
    }
    else
    {
    	cout<<s<<"s";
    }
    return 0;
}



Measured memory_bytes: 3664
n,m=map(int,input().split())
x=list(map(int,input().split()))
x.sort()
if n>=m:
    print(0)
    exit()
z=[]
for i in range(1,m):
    z.append(x[i]-x[i-1])
z.sort()
if n==1:
    print(x[m-1]-x[0])
else:
    print(x[m-1]-x[0]-sum(z[-(n-1):]))


Measured memory_bytes: 57384
#include<stdio.h>

int Min(int a, int b) { if (a < b) { return a; }return b; }

int fa[52][26];//その文字の文字列内登場回数
int fb[26];//その文字の累計登場回数
int main() {
	int N;
	char S[52];
	int yes = 0;
	scanf("%d", &N);
	for (int i = 0; i < N; i++)//文字列
	{
		scanf("%s", S);
		for (int j = 0; j < strlen(S); j++)//アルファベット
		{
			fa[i][S[j] - 'a']++;
			fb[S[j] - 'a']++;
		}
	}

	for (int j = 0; j < 26; j++)//アルファベット
	{
		int cnt = 0;
		int cntmin = 60;//その文字は全ての文字列で最低何回登場しているのか
		for (int i = 0; i < N; i++)//文字列
		{
			if (fa[i][j] >= 1)//この文字列で登場している場合
			{
				cnt++;
				cntmin = Min(cntmin, fa[i][j]);//その文字は全ての文字列で最低何回登場しているのか
			}
			else //この文字列で登場していない場合
			{
				break;//この文字は対象外
			}
		}
		if (cnt == N)//その文字は全ての文字列で登場した場合
		{
			while (cntmin > 0) 
			{
				printf("%c", 'a' + j);
				cntmin--;
				yes++;
			}
		}
	}
	if (yes==0)
	{
		printf("\n");
	}
	return 0;
}

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

using namespace std;

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

const long long MOD = 1e9 + 7;
const int INF = 1e9;

int main() {
  int N;
  cin >> N;
  int mod2 = 0;
  int mod4 = 0;
  int mod0 = 0;
  for (int i = 0; i < N; ++i) {
    int a;
    cin >> a;
    if (a % 4 == 0) mod4++;
    else if (a % 2 == 0) mod2++;
    else mod0++;
  }
  if (mod2 == 0 && mod4 >= N / 2) cout << "Yes" << endl;
  else if (mod2 > 0 && mod4 >= (N - mod2 + 1) / 2) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

void solve(long long R) { printf("%.20lf\n", 2 * M_PI * R); }

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can
// remove this line by using your custom template)
int main() {
    long long R;
    scanf("%lld", &R);
    solve(R);
    return 0;
}


Measured memory_bytes: 3748
from collections import Counter

N = int(input())

C = Counter(
    x * x + y * y + z * z + x * y + y * z + z * x
    for x in range(1, 105) for y in range(1, 105) for z in range(1, 105)
)

for i in range(1, N + 1):
    print(C[i])

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

using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)

typedef long long ll;
typedef long long int64;

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

  double sum = 0.0;
  for(int i=0; i<n; i++){
    int tmp;
    cin >> tmp;
    sum += (double)1/tmp;
  }

  cout << 1/sum << endl;

  return 0;
}

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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define int long long

typedef pair<int, int> ii;

const int mod = 1e9 + 7;

const int N = 105;

const int M = 1e5 + 5;

int n, a[N], k, dp[M];

signed main() {
    cin.tie(0), ios::sync_with_stdio(0);
    cin >> n >> k;
    for(int i = 1; i <= n; i++)
        cin >> a[i];
    dp[0] = 0;
    for(int i = 0; i <= k; i++) {
        int ok = 0;
        for(int j = 1; j <= n; j++) {
            if(i - a[j] >= 0)
                ok |= (1 - dp[i - a[j]]);
        }
        if(ok)
            dp[i] = 1;
        else
            dp[i] = 0;
    }
    if(dp[k])
        cout << "First";
    else
        cout << "Second";
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

ll power(ll n, ll k){
  ll res = 1;
  while(k > 0){
    if (k & 1) 
      res = res * n % MOD;
    n = n * n % MOD;
    k >>= 1;
  }
  return res;
}

ll genfact(ll n, ll k){

  ll res = 1;
  while (k >= 0){
    res = (res * (n - k)) % MOD;
    k--;
  }

  return res;
}

ll inv(ll n){
  return power(n, MOD - 2);
}

ll fact(ll n){
  return genfact(n, n - 1);
}

ll nck(ll n, ll k){
  if (k == 0)
    return 1;

  return ((genfact(n, k) % MOD) * inv(fact(k))) % MOD;
}

ll gcd(ll a, ll b){
  ll c;
  if (a < b){
    c = a;
    a = b;
    b = c;
  }
  while(b != 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}


ll ret(ll a, ll d){
  return a/d;
}

int main(void){
  ll a, b;
  ll c, d;
  cin >> a >> b >> c >> d;

  cout << b - a + 1 - (ret(b, c) - ret(a - 1, c)) - (ret(b, d) - ret(a - 1, d)) + (ret(b, c*d/gcd(c, d)) - ret(a - 1, c*d/gcd(c, d))) << endl;

  return 0;
}


Measured memory_bytes: 256
//
//AtCoder Beginner Contest 142
//D - Disjoint Set of Common Divisors
//

#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <ctime>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <functional>
#include <cassert>

using namespace std;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define SIZE(x) (int)(x).size()
#define SIZEL(x) (ll)(x).size()
#define MSG(a) cout << #a << " " << a << endl;

using ll = long long;
using ld = long double;

const double PI = 3.14159265358979323846;

ll gcd(ll x, ll y) { return (x % y)? gcd(y, x % y): y; }    //最大公約数
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }            //最小公倍数

int main()
{
    ll a, b;

    cin >> a >> b;

    ll mg = gcd(a, b);
    int ans = 1;

    for(ll i = 2; i * i <= mg; i++) {
        bool isFirst = true;
        while(mg % i == 0) {
            if (isFirst) ans++;
            isFirst = false;
            mg /= i;
        }
    }
    if(mg != 1) ans++;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3636
N = int(input())
S = input()

r = S.count('R')
g = S.count('G')
b = S.count('B')
ans = r*g*b

for i in range(N):
  for j in range(i+1,N):
    k=2*j-i
    if k<N and S[i]!=S[j]!=S[k]!=S[i]:
      ans -= 1

print(ans)

Measured memory_bytes: 9180
#include <bits/stdc++.h>
using namespace std;
int mod = 998244353;
string s;
map<string, int>g;
map<string, int>f;

int F(string s);
int G(string s) {
	if (g.find(s) != g.end()) {
		return g[s];
	}
	int &re = g[s];
	if (s.size() == 1) {
		return re = s[0] - '0' + 1;
	}
	for (int i = 1; i < s.size(); i++) {
		if (s.size() % i == 0) {
			string t;
			for (int j = 0; j < i; j++) {
				int r = 1;
				for (int k = 0; k < s.size() / i; k++) {
					if (s[k * i + j] == '0') {
						r = 0;
					}
				}
				t += (char)(r + '0');
			}
			re += F(t);
			re %= mod;
		}
	}
	return re;
}

int F(string s) {
	if (f.find(s) != f.end()) {
		return f[s];
	}
	int &re = f[s];
	for (int i = 1; i <= s.size(); i++) {
		re += (long long)F(s.substr(0, s.size() - i)) * G(s.substr(s.size() - i, i)) % mod;
		re %= mod;
	}
	return re;
}
int main() {
	cin >> s;
	f[""] = 1;
	cout << F(s) << endl;
	return 0;
}

Measured memory_bytes: 12928
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    ll ary[n];
    rep(i,n) cin >> ary[i];

    ll ruiseki[n+1];
    ruiseki[0] = 0;
    rep(i,n)
    {
        ruiseki[i+1] = ruiseki[i] + ary[i] * 2;
    }

    ll mid = ruiseki[n]/2;
    auto itr = lower_bound(ruiseki, ruiseki+(n+1), mid);
    // cout << abs(*itr-mid) << endl;
    cout << min(abs(*itr-mid), abs(*(itr-1)-mid)) << endl;

    
    
}




Measured memory_bytes: 3328