akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

int main(){
  string s; cin >> s;
  int len = s.size();
  bool ok = true;
  if(s.at(0) != 'A') ok = false;
  int cntc = 0;
  for(int i = 1; i < len; i++){
    if(isupper(s.at(i))){
      if(i == 1 || i == len - 1 || s.at(i) != 'C') ok = false;
      if(s.at(i) == 'C') cntc++;
    }
  }
  if(cntc != 1) ok = false;
  if(ok) cout << "AC" << endl;
  else cout << "WA" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using VI = vector<int>;
using VL = vector<LL>;
using PII = pair<int, int>;
using PLL = pair<LL, LL>;

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define F first
#define S second
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define FILL(a, b) memset(a, b, sizeof(a))

void dout() { cerr << endl; }

template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k;
    cin >> n >> k;
    vector<double> a = {0};
    FOR(i, 0, n)
    {
        int x;
        cin >> x;
        a.PB(a.back() + (x + 1.0) / 2);
    }
    double ans = 0;
    for (int i = 0; i + k < SZ(a); i++)
    {
        ans = max(ans, a[i + k] - a[i]);
    }
    cout << fixed << setprecision(9) << ans;
    return 0;
}

Measured memory_bytes: 2420
#include <stdio.h>
#include <algorithm>
#include <string>
#include <vector>
#include <numeric>

const int mod = 1000000007;
const int M = 200005;

int main() {
	char s[M];
	scanf("%s", s);
	int l;
    for(int i=0;i<M;i++){
      if(s[i]==0){
        l=i;
      }
    }
	long long r = 0;
	int A = 0;
	for (int i = 0; i < l; i++) {
		if (s[i] == 'A') {
			A++;
		}
		else if (s[i] == 'B'&&s[i + 1] == 'C') {
			r += A;
			i++;
		}
		else{
			A = 0;
		}
	}
	printf("%lld", r);
}





Measured memory_bytes: 384
#include <stdio.h>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    scanf("%d %d",&a,&b);
    if(a<b){
        printf("a < b\n");
    }else if(a>b){
        printf("a > b\n");
    }else{
        printf("a == b\n");
    }
}



Measured memory_bytes: 2692
#include<bits/stdc++.h>
#include<iomanip>
#include<numeric>

using namespace std;
using ll = long long;
constexpr int mo = 1e9+7;
constexpr int  mod = mo;
constexpr int inf = 1<<30;
constexpr int mo2 = 998244353;
constexpr ll infl = 1ll<<60;

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

    int n;
    cin>>n;
    ll rank = 0;
    ll ans = 0;
    ll sum = 0;
    for(int i=0;i<n;++i){
        ll d,c;
        cin>>d>>c;
        rank += c;
        sum += d*c;
    }
    ans = rank-1;
    if(sum > 9) ans += (sum+8)/9 - 1;
    cout << ans << endl;
    return 0;
}



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

int main()
{	
  	int a, b, c, d;
    cin >> a >> b >> c >> d;
    int X = c - a;
    int Y = d - b;

    cout << c - Y << " "  << d + X << " " << a - Y <<  " " << b + X << endl;
  
}

Measured memory_bytes: 256
# @oj: atcoder
# @id: hitwanyang
# @email: 296866643@qq.com
# @date: 2020-06-05 17:33
# @url:https://atcoder.jp/contests/abc169/tasks/abc169_c
import sys,os
from io import BytesIO, IOBase
import collections,itertools,bisect,heapq,math,string
from decimal import *
# region fastio

BUFSIZE = 8192

BUFSIZE = 8192

class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
# ------------------------------
def main():
    ab=list(map(str,input().split()))
    a,b=int(ab[0]),int(str(ab[1]).replace(".",""))
    print (a*b//100)
if __name__ == "__main__":
    main()

Measured memory_bytes: 72728
use contest::io::Scanner;

fn main() {
    let mut sc = Scanner::new(std::io::stdin());
    let n = sc.next::<usize>();
    let m = sc.next::<usize>();
    let c = sc.next::<i32>();
    let mut b = vec![];
    for _ in 0..m {
        b.push(sc.next::<i32>());
    }

    let mut res = 0;
    for _ in 0..n {
        let mut v = c;
        for i in 0..m {
            let a = sc.next::<i32>();
            v += a * b[i];
        }
        if v > 0 {
            res += 1;
        }
    }
    println!("{}", res);
}
pub mod contest {
pub mod io {
/// Scanner
///
/// # Example
/// ```
/// use contest::io::Scanner;
/// let mut sc = Scanner::new("1 2 \n\n \r\t \n 3.5".as_bytes());
/// assert_eq!("1".to_string(), sc.next::<String>());
/// assert_eq!(2, sc.next());
/// assert_eq!(3.5, sc.next());
///
/// // To create a scanner from stdin:
/// Scanner::new(std::io::stdin());
/// ```

use std;
use std::io;
use std::io::BufRead;

pub struct Scanner<R: io::Read> {
    br: io::BufReader<R>,
    // Read tokens are stored in reversed order per line.
    buf: Vec<String>,
}

pub fn new<R: io::Read>(r: R) -> Scanner<R> {
    Scanner::new(r)
}

impl<R: io::Read> Scanner<R> {
    #[inline]
    pub fn new(r: R) -> Scanner<R> {
        Scanner {
            br: io::BufReader::new(r),
            buf: vec![],
        }
    }
    #[inline]
    pub fn next<T>(&mut self) -> T
        where T: std::str::FromStr,
              T::Err: std::fmt::Debug
    {
        self.next_string().map(|s| s.parse::<T>().expect("Parse failed: ")).expect("Unexpected EOF")
    }
    #[inline]
    pub fn next2<T1,T2>(&mut self) -> (T1,T2)
        where T1: std::str::FromStr,
              T2: std::str::FromStr,
              T1::Err: std::fmt::Debug,
              T2::Err: std::fmt::Debug
    {
        (self.next(), self.next())
    }
    fn next_string(&mut self) -> Option<String> {
        self.buf.pop().or_else(|| match self.update() {
            true => self.next_string(),
            false => None,
        })
    }
    #[inline]
    fn update(&mut self) -> bool {
        let mut s = String::new();
        let res = self.br.read_line(&mut s);
        match res.expect("I/O error.") {
            0 => false,
            _ => {
                self.buf = s.split_whitespace().map(|x| x.to_string()).rev().collect();
                true
            }
        }
    }
}

#[test]
fn test_next() {
    let mut sc = new("hoge".as_bytes());
    let s: String = sc.next();
    assert_eq!("hoge", s);
}
}
}


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

using namespace std;

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

ll n, a, b, mod;

inline ll add(ll x, ll y) {
  return (x % mod + (y % mod)) % mod;
}

inline ll mul(ll x, ll y) {
  return (ll) x % mod * (y % mod) % mod;
}

inline ll fe(ll x, ll k) {
  ll res = 1;
  while(k) {
    if(k & 1LL)
      res = mul(res, x);
    x = mul(x, x);
    k >>= 1LL;
  }
  return res;
}

ll len(ll x) {
  ll ans = 0;
  while(x) {
    ans++;
    x /= 10;
  }
  return ans;
}

pair<pair<ll,ll>, ll> solve(ll n, ll a, ll b) {
  if(n == 1)
    return {{a % mod, fe(10, len(a))}, 1};
  auto lf = solve(n / 2, a, b);
  auto rg = lf;
  // printf("n = %lld a = %lld b = %lld\n", n, a, b);
  rg.first.first = add(rg.first.first, mul(mul(b, (n / 2)), lf.second));
  // auto rg = solve(n - (n / 2), a + b * (n / 2), b);
  // printf("---- lf.ff = %lld rg.ff = %lld\n", lf.first.first, rg.first.first);
  auto ans = lf;
  ans.first.first = add(mul(lf.first.first, rg.first.second), rg.first.first);
  ans.first.second = mul(lf.first.second, rg.first.second);
  ans.second = add(mul(lf.second, rg.first.second), rg.second);
  // printf("---- ans = %lld %lld %lld\n", ans.first.first, ans.first.second, ans.second);
  if(n % 2LL) {
    ll x = a + (n - 1) * b;
    ans.first.first = add(mul(ans.first.first, fe(10, len(x))), x);
    ans.first.second = mul(ans.first.second, fe(10, len(x)));
    ans.second = add(mul(ans.second, fe(10, len(x))), 1);
  }
  // printf("---- ans = %lld\n", ans.first.first);
  return ans;
}

int main() {
  cin >> n >> a >> b >> mod;
  pair<ll,ll> ans = {0, 1};
  while(n) {
    ll l = 1, r = n;
    // printf("!!!!!! len(a) = %lld\n", len(a));
    while(l < r) {
      ll m = (l + r + 1) / 2;
      // printf("try = %lld len = %lld verdict = %d\n", a + (m - 1) * b, len(a + (m - 1) * b), (len(a + (m - 1) * b) <= i));
      if(len(a + (m - 1) * b) > len(a))
        r = m - 1;
      else
        l = m;
    }
    // printf("l = %lld a = %lld b = %lld len = %lld\n", l, a, b, len(a + (l - 1) * b));
    auto res = solve(l, a, b);
    // printf("getres = %lld reslen = %lld\n", res.first.first, res.first.second);
    ans.first = add(mul(ans.first, res.first.second), res.first.first);
    // ans.second = mul(ans.second, res.first.second);
    // printf("new ans = %lld new_a = %lld\n", ans.first, a + b * l);
    a += b * l;
    n -= l;
  }
  printf("%lld\n", ans.first);
  return 0;
}

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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var p = new List<int>();
            for(var i=0; i<N; i++)
            {
                p.Add(cin.ReadInt);
            }

            p.Sort();
            p.Reverse();
            p[0] /= 2;

            WriteLine(p.Sum());
        }

        static long GcdArray(long[] array)
        {
            var ans = array[0];
            for(var i=1; i<array.Length; i++)
            {
                ans = Gcd(ans, array[i]);
            }
            return ans;
        }

        static long Gcd(long a, long b)
        {
            var v = new[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }

        static long Lcm(long a, long b)
        {
            return a / Gcd(a, b) * b;
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a , b ;
  cin >> a >> b ;
  int s;
  if(a!=3&&b!=3)
    s=3;
  if(a!=1&&b!=1)
    s=1;
  if(a!=2&&b!=2)
    s=2;
  cout << s << endl ;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(x) for x in input().split()]
B = [0] * N
C = []
for i in range(N,0,-1):
  parity = 0
  j = 2
  while(i * j <= N):
    parity += B[i * j - 1]
    j += 1
  B[i - 1] = (A[i - 1] - parity) % 2
print(sum(B))
for i in range(N):
  if(B[i] == 1):
    C.append(str(i + 1))
if(C != []):
  print(" ".join(C))


Measured memory_bytes: 69468
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;

int main(int argc, const char * argv[]) {
    
    // cinを高速にするためのおまじない
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    /////////////////////
    // Write code below /
    /////////////////////
    int N;
    cin >> N;
    vector<int>A(N),B(N),C(N-1);

    for (int i = 0; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i = 0; i < N; i++) {
        cin >> B.at(i);
    }
    for (int i = 0; i < N - 1; i++) {
        cin >> C.at(i);
    }

    int satisfaction = 0;
    int previous_i   = -1; // 直前の料理
    for (int a_i = 0; a_i < A.size(); a_i++) {
        int i = A.at(a_i) - 1;
        satisfaction += B.at(i);
        if (i != 0 && previous_i == i - 1) {
            satisfaction += C.at(i-1);
        }
        previous_i = i;
    }
    
    cout << satisfaction << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>


int main(){

  int n, i, j, cnt, max=0;
  int p[100];

  scanf("%d", &n);

  for(i=0;i<n;i++) scanf("%d", &p[i]);

  for(i=1;i<=100;i++){
    cnt=0;
    for(j=0;j<n;j++){
      if(i<=p[j]) cnt++;
    }
    if(cnt>=i&&max<i) max=i;
  }

  printf("%d\n", max);

  return 0;
}

Measured memory_bytes: 596
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#define DEBUG_OUT(...)  (printf(__VA_ARGS__))
#else
#define VS_ENDPAUSE()
#define DEBUG_OUT(...)
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
//#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
    func();
    VS_ENDPAUSE();
    return 0;
}


void func(void)
{
//DEBUG_OUT("----\n");
    string s;
    cin >> s;

    int len = s.size();
    for(int i=0; i<len-1; i++){
        if(s[i]=='A' && s[i+1]=='C'){
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    
    return;
}



Measured memory_bytes: 256
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 

 
int main()
{
    int n,m;cin>>n>>m;
    long long int ans = (n*(n-1))/2 + (m*(m-1))/2;
    cout<<ans<<endl;
}

// nc2 || mc2
 //


Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
int main(){
 
  int N;
  cin >> N;
 
  vector<int> A(N);
  
  for(int i = 0;i < N;++i){
    cin >> A[i];
  }
  
  sort(A.begin(),A.end());
  
  int num = 0;
  for(int i = 0;i < N - 1;++i){
    if(A[i] == A[i + 1]){
      num++;
    }
  }
  
  if(num == 0){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  
}


Measured memory_bytes: 1024
n=int(input())
b=list(map(int,input().split()))
a=[0]*n
a[n-1]=b[n-2]
a[0]=b[0]
for i in range(n-2,0,-1):
    if(b[i]<=b[i-1]):
        a[i]=b[i]
    else:
        a[i]=b[i-1]
print(sum(a))

Measured memory_bytes: 3064
package main

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

const BUFSIZE = 10000000

var rdr = bufio.NewReaderSize(os.Stdin, BUFSIZE)

func main() {
	var N, k int
	var ans float64 = 0
	fmt.Scanf("%d %d", &N, &k)

	for i := 1; i < N+1; i++ {
		var n int = i
		var j = 0
		for {
			if n >= k {
				break
			}
			j += 1
			n = n * 2
		}
		ans += float64(1) / float64(N) * math.Pow(0.5, float64(j))
	}
	fmt.Println(ans)
}

func NextLineInt() []int {
	buf := make([]byte, 0, BUFSIZE)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}

		buf = append(buf, l...)

		if !p {
			break
		}
	}
	str := strings.Split(string(buf), " ")
	l := len(str)

	ret := make([]int, l)

	for i := range str {
		// ret[i], ok = strconv.Atoi(str[i])
		v, ok := strconv.Atoi(str[i])

		if ok == nil {
			ret[i] = v
		}
	}

	return ret
}

func Bool2Int(b bool) int {
	if b {
		return 1
	} else {
		return 0
	}
}

func Abs(v int) int {
	if v < 0 {
		return -v
	}
	return v
}

func Min(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

func Max(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func Distance(a, b int) int {
	return Abs(a - b)
}


Measured memory_bytes: 2944
use std::io;
//use std::collections::HashMap;
//use std::collections::BinaryHeap;
//use std::collections::HashSet;
//use std::mem; // mem::swap(&mut x,&mut y);
use std::cmp; // cmp::max,cmp::min

// Rust memo: https://hackmd.io/i0lQY1OKTDW1t66TECOmiw?both

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

#[allow(dead_code)]
fn read_charvec() -> Vec<char>{
    read_line().chars().collect()
}

#[allow(dead_code)]
fn read_ints() -> Vec<i64>{
    let s = read_line();
    let split:Vec<&str> = s.split(" ").collect();
    split.iter().map(|&x| x.to_string().parse().unwrap()).collect()
}

#[allow(dead_code)]
fn read_int() -> i64{
    read_ints()[0]
}

#[allow(dead_code)]
fn reverse(s: &String) -> String{
    s.chars().rev().collect::<String>()
}

#[allow(dead_code)]
fn read_lines(n:i64) -> Vec<String>{
    let mut xs = Vec::new();

    for _i in 0..n{
        xs.push(read_line());
    }

    xs
}

#[allow(dead_code)]
fn read_ints2(n:i64) -> Vec<i64>{
    read_lines(n).iter().map(|x| x.parse().unwrap()).collect()
}

#[allow(dead_code)]
fn arange(start:i64,end:i64,step:i64) -> Vec<i64>{
    let mut ret = Vec::new();
    let mut i = start;

    while i < end{
        ret.push(i);
        i += step;
    }

    ret
}

#[allow(dead_code)]
const DXS : [i64; 4] = [0,0,1,-1];
#[allow(dead_code)]
const DYS : [i64; 4]  = [1,-1,0,0];
#[allow(dead_code)]
const INF : i64 = 999999999;

////////////////////////////////////////////////

fn dist(maximum:&i64,t:&i64)->i64{
    if maximum % 2 == 0{
        let mid = maximum / 2;

        cmp::max(t-mid,mid-t)
    }else{
        let mid1 = (maximum+1)/2;
        let mid0 = mid1-1;
        
        if *t <= mid0 {
            mid0-t
        }else{
            t-mid1
        }
    }

}

fn main(){
    let _ = read_int() as usize;
    let xs = read_ints();

    let maximum = xs.iter().fold(-1,|a,&b| cmp::max(a,b));
    let xs :Vec<i64> = xs.into_iter().filter(|&n|n!=maximum).collect();
    let middlest = xs.iter().fold(
        xs[0],
        |m,&o| if dist(&maximum,&m) > dist(&maximum,&o){
            o
        }else{
            m
        }
    );

    println!("{} {}",maximum,middlest);
}

Measured memory_bytes: 10492
import java.util.*;

public class Main {
    void run() {
        Scanner sc = new Scanner(System.in);
        long a = sc.nextLong();
        long b = sc.nextLong();
        long n = sc.nextLong();

//        for (int i = 0; i < n; i++) {
//            long target = (long) Math.floor(a * i / b) - a * (long) Math.floor(i / b);
//            debug(i, target);
//        }
        long ans;
        if (b > n) {
            ans = (long) Math.floor(a * n / b) - a * (long) Math.floor(n / b);
        } else {
ans =                (long) Math.floor(a * (b - 1) / b) - a * (long) Math.floor((b - 1) / b);
        }
        System.out.println(ans);




//        long left = -1;
//        long right = n;
//        long max = Integer.MIN_VALUE;
//        long idx = -1;
//        while (right - left > 1) {
//            long middle = (right + left) / 2;
//            long target = (long) Math.floor(a * middle / b) - a * (long) Math.floor(middle / b);
//            if (max < target) {
//                max = target;
//                idx = middle;
//                left = middle;
//            } else {
//                right = middle;
//            }
//        }
//        System.out.println(max);

    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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


Measured memory_bytes: 27100
// clang-format off
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
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;}
// clang-format on

void solve(long long N, std::vector<long long> A) {
  vector<ll> a(N);
  rep1(i, N) { a[A[i - 1] - 1] = i; }
  rep(i, N) {
    cout << a[i];
    if (i != N - 1)
      cout << " ";
  }
  cout << endl;
}

int main() {
  long long N;
  scanf("%lld", &N);
  std::vector<long long> A(N);
  for (int i = 0; i < N; i++) {
    scanf("%lld", &A[i]);
  }
  solve(N, std::move(A));
  return 0;
}


Measured memory_bytes: 2432
import os

def main():
	k,n = map(int, input().split())
	a_list = list(map(int, input().split()))
	min_total = 1000000
	for i in range(n):
		if i == 0:
			a_total = a_list[i-1] - a_list[i]
			b_total = a_list[i] + k - a_list[i+1]	
		else:
			if i == n-1:
				a_total = k - a_list[i] + a_list[i-1]
				b_total = a_list[i] - a_list[0]
			else:
				a_total = k - a_list[i] + a_list[i-1]
				b_total = a_list[i] + k - a_list[i+1]

		if (a_total < min_total) or (b_total < min_total):
			if a_total <= b_total:
				min_total = a_total
			else:
				min_total = b_total
	print(min_total)

if __name__ == "__main__":
	main()


Measured memory_bytes: 26444
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.B
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var N = ReadLong();
            var a = ReadLongs().OrderByDescending(x => x).ToArray();
            long sum = 0;
            for(var i = 0; i < N; i++)
            {
                if(i % 2 == 0)
                {
                    sum += a[i];
                }
                else
                {
                    sum -= a[i];
                }
            }
            return sum;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 28436
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9

int main(){
    string s;
    cin >> s;
    string t = s;
    int n = s.size();

    rep (i, n) {
        rep(j, n) {
            if(i!=j) {
                if(s[i] == t[j]) {
                    cout << "no" << endl;
                    return 0;
                }
            }
        }
    }

    cout << "yes" << endl;

    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>	// require sort next_permutation count __gcd reverse etc.
#include <cstdlib>	// require abs exit atof atoi 
#include <cstdio>		// require scanf printf
#include <functional>
#include <numeric>	// require accumulate
#include <cmath>		// require fabs
#include <climits>
#include <limits>
#include <cfloat>
#include <iomanip>	// require setw
#include <sstream>	// require stringstream 
#include <cstring>	// require memset
#include <cctype>		// require tolower, toupper
#include <fstream>	// require freopen
#include <ctime>		// require srand
#define rep(i,n) for(int i=0;i<(n);i++)
#define ALL(A) A.begin(), A.end()

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
int block[105];

int main()
{
//	cut here before submit 
//	freopen ("testcase.saizo", "r", stdin );
	int t;
	scanf ("%d", &t );
	while (t-- ){
		memset (block, 0, sizeof (block ) );
		int n;
		scanf ("%d", &n );
		rep (i, n ){
			scanf (" %d", &block[i] );
		} // end rep
		int max_u = 0, max_d = 0;
		for (int i = 1; i < n; i++ ){
			if (block[i-1] < block[i] ){
				max_u = max (max_u, block[i] - block[i-1] );
			}else
			if (block[i-1] > block[i] ){
				max_d = max (max_d, block[i-1] - block[i] );
			} // end if
		} // end for
		printf ("%d %d\n", max_u, max_d );
	} // end while

	return 0;
}

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

using namespace std;

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

	vector< pair<int,int> > data(N);
	int nmin = 1000001;
	int nmax = 0;
	for (int i = 0; i < N; ++i) {
		cin >> data[i].first >> data[i].second;
		nmin = min(nmin,data[i].first);
		nmax = max(nmax,data[i].second);
	}
	nmax = min(N+1,nmax);

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

	bool find = false;
	int res = 0;
	for (int i = nmax; !find && i >= nmin; --i) {
		int count = 0;
		for (int j = 0; j < N; ++j) {
			if (data[j].first <= i && data[j].second >= i) {
				++count;
			}
		}
		if (count >= i-1) {
			find = true;
			res = i-1;
		}
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <map>
#include <string>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <algorithm> 
#include <ctime>

#define INF 2140000000

using namespace std;

int Min=INF,Max=0,X,N;

int main()
{
	cin>>N;
	for(int i=1;i<=N;i++)
	{
		cin>>X;
		Min=min(X,Min);
		Max=max(Max,X);
	}
	cout<<Max-Min;
	return 0;
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define sz(x) (int)((x).size())
# define F first
# define S second
# define pb push_back
# define ub upper_bound
# define lb lower_bound
# define all(x) x.begin(), x.end()
# define pqueue priority_queue
# define mset multiset
# define umap unordered_map
# define Speed() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
# define rep(i,n) for(int i=0;i<n;++i)
# define forn(i,n) for(int i=1;i<=n;++i)
# define lr(i,l,r) for(int i=l;(l>r?i>=r:i<=r);(l>r?--i:++i))

using namespace std;

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

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

const int dx[]={1,0,-1,0,-1,-1,1,1},dy[]={0,1,0,-1,-1,1,-1,1}; 
const int mod = 1e9+7;
const ll N = 2e5+5;


void solve(){
	ll n,ans=0;
	cin>>n;
	int a[n+1];
	forn(i,n)cin>>a[i];
	map<int,int>cnt;
	forn(i,n){
		ans+=cnt[i-a[i]];
		cnt[i+a[i]]++;
	}
	cout<<ans;

}

int main(){
	Speed();
	int T=1; 
	//cin>>T;	
	while(T--)
		solve();
	return 0;
}

Measured memory_bytes: 21352
K =int(input())
A = list(map(int,input().split()))
right = sum(A)
length = len(A)
maxi = 3
mini = 2
temp1 = 2
temp2 = 2
test = A[0]

for a in A[K-2::-1]:
        if(temp1 == a and temp2 == a):
            maxi = maxi
        elif(maxi%a == a-1):
            maxi += a
        else:
            maxi += (a-1-maxi%a)
        
        if(mini%a != 0):
            mini += (a - mini%a)
        temp2 = temp1
        temp1 = a
test1 = mini
test2 = maxi
for a in A:
        test1 = test1 - test1%a
        test2 = test2 - test2%a

if(test1 == 2 and test2 == 2):
        print(mini,maxi)
else:
        print(-1)

Measured memory_bytes: 14428
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/
int main()
{
ll n,i,j,r=0,c=0,a,b;
vector<pair<ll,ll> >v;
map<pair<ll,ll >,ll>mp;
ll x,y;
//pair<ll,ll>p;
cin>>n;
for(i=0;i<n;i++)
{
    cin>>x>>y;
    v.pb({x,y});
}
for(i=0;i<n;i++)
{
    for(j=0;j<n;j++)
    {
        if(i==j)
            continue;
        a=(v[i].ff-v[j].ff);
        b=(v[i].ss-v[j].ss);
        mp[{a,b}]++;
        if(mp[{a,b}]>c)
            c=mp[{a,b}];
    }
}
cout<<n-c<<endl;
//cout<<p.ff<<" "<<p.ss;
}



Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	ll N, k; cin >> N >> k;
	ll now = 0;
	for (int i = 1; i < N;i++) {
		now += (now/ (k - 1)) + 1;
	}
	cout << now << endl;
}

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

int main(){
  string X;
  cin>>X;
  int ans=0;
  ll S_counter=0;
  int N=X.size();
  for(int i=0;i<N;i++){
    if(X.at(i)=='S'){
      S_counter++;
    }else{
      if(S_counter==0){
        ans++;
      }else{
        S_counter--;
      }
    }
  }
  cout<<2*ans<<endl;
}


Measured memory_bytes: 640
import collections
import sys
n = int(input())
a = sorted(list(map(int,input().split())))
c = collections.Counter(a)
s = len(set(a))
c = sorted(c.items(), reverse=True)

for i in range(s):
  if c[i][1]>=4:
    print(c[i][0]**2)
    sys.exit()
  elif c[i][1] >=2:
    for j in range(i+1,s):
      if c[j][1]>=2:
        print(c[i][0]*c[j][0])
        sys.exit()
print("0")
  

Measured memory_bytes: 22816
/*Shivam Bhalla */
  /* f2016941@pilani.bits-pilani.ac.in */



  #include <iostream>
  #include <cstdio>
  #include <cstring>
  #include <cstdlib>
  #include <cctype>
  #include <algorithm>
  #include <map>
  #include <vector>
  #include <list>
  #include <set>
  #include <queue>
  #include <deque>
  #include <stack>
  #include <iostream>
  #include <string>
  #include <cmath>
  #include <cassert>
  #include <bits/stdc++.h>
  #define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
  using namespace std;
  long long maxv = 1e9;


  int main()
  {
      long long N;
      cin>>N;
      long long maxi=N;
      int flag=0;
      for(int i=2;i<=((int)sqrt(N));i++){
        if(N%i==0){
            flag=1;
            long long A=i+(N/i);
            if(A<maxi)
                maxi=A;
        }
      }
      if(flag==1)
        cout<<maxi-2;
      else
        cout<<maxi-1;
      return 0;
  }


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

const int N = 1e5;  // limit for array size

bool prime[N+5];
int c[N+5];

void SieveOfEratosthenes(int n)
{
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p])
        {
            for (int i=p*2; i<=n; i += p)
                prime[i] = false;
        }
    }
}

int main()
{
    SieveOfEratosthenes(N);
    for(int i=3; i<=100000; i+=2)
        if(prime[i]&&prime[(i+1)/2])
            c[i]++;
    for(int i=3; i<=100000; i++)
        c[i]+=c[i-1];
    int t;
    cin>>t;
    while(t--)
    {
        int i, j;
        cin>>i>>j;
        printf("%d\n", c[j]-c[i-1]);
    }
    return 0;
}


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

const int INF = 1000000000;

int main() {
    int N;
    cin >> N;
    vector<int> G[N];
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].push_back(b); G[b].push_back(a);
    }

    queue<int> que1;
    vector<int> dist1(N, INF);
    que1.push(0);
    dist1[0] = 0;
    while (!que1.empty()) {
        int u = que1.front(); que1.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (dist1[v] != INF) continue;
            que1.push(v);
            dist1[v] = dist1[u] + 1;
        }
    }

    queue<int> que2;
    vector<int> dist2(N, INF);
    que2.push(N - 1);
    dist2[N - 1] = 0;
    while (!que2.empty()) {
        int u = que2.front(); que2.pop();
        for (int i = 0; i < G[u].size(); i++) {
            int v = G[u][i];
            if (dist2[v] != INF) continue;
            que2.push(v);
            dist2[v] = dist2[u] + 1;
        }
    }

    int f_cnt = 0, s_cnt = 0;
    for (int i = 0; i < N; i++) {
        if (dist1[i] <= dist2[i]) {
            f_cnt++;
        } else {
            s_cnt++;
        }
    }

    if (f_cnt > s_cnt) {
        cout << "Fennec" << endl;
    } else {
        cout << "Snuke" << endl;
    }
    return 0;
}

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

typedef long long ll;
const ll mod = 1e9 + 7, maxn = 1e5 + 5, INF = 1 << 60;

vector<ll>fac(maxn), finv(maxn), inv(maxn), a(1e5 + 5);

ll comb(ll n, ll k) {
	if (n < k || n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}

int main() {
	ll n, v; cin >> n;
	map<ll, ll>mp;
	for (int i = 0; i < n + 1; i++) {
		cin >> a[i]; mp[a[i]]++;
		if (mp[a[i]] == 2)v = a[i];
	}

	ll L = -1, R;
	for (int i = 0; i < n + 1; i++) {
		if (a[i] == v && L == -1)L = i;
		else if (a[i] == v)R = i;
	}
	fac[0] = fac[1] = finv[0] = finv[1] = inv[1] = 1;
	for (ll i = 2; i < maxn; i++) {
		fac[i] = fac[i - 1] * i % mod;
		inv[i] = mod - inv[mod % i] * (mod / i) % mod;
		finv[i] = finv[i - 1] * inv[i] % mod;
	}
	for (ll i = 0; i < n + 1; i++) {
		ll k = comb(L + (n - R), i); ll p = (comb(n + 1, i + 1) - k + mod) % mod;
		cout << p << endl;
	}

	return 0;
}

Measured memory_bytes: 10624
#include <iostream>

using namespace std;

int main() {
	int n, p1 = 0, p2 = 0;
	string t1, t2;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> t1 >> t2;
		if (t1 > t2) {
			p1 += 3;
		}
		else if (t1 < t2) {
			p2 += 3;
		}
		else {
			p1 += 1;
			p2 += 1;
		}
	}
	cout << p1 << " " << p2 << endl;
	return 0;
}

Measured memory_bytes: 1208
n , d =map(int,input().split())
x = [list(map(int,input().split())) for i in range(n)]
count = 0
for i in range(n):
    for j in range(i + 1, n):
        s = 0
        for k in range(d):
            s += (x[i][k] - x[j][k])**2
        s = s ** 0.5
        if int(s) == s:
            count += 1
print(count)

Measured memory_bytes: 9388
#include<stdio.h>
#include <sysexits.h>
#include<stdlib.h>
#include<math.h>
int main(void){
  int sum,N,i,max,k,H,W;
  sum=0;
  max=0;
  int p[1000]={};
  int q[1000]={};
  if(scanf("%d%d%d",&N,&H,&W)>3){
    exit(0);
  }
    for(i=0;i<N;i++){
      if(scanf("%d%d",&p[i],&q[i])>2){
    exit(0);
  }
    }
   for(i=0;i<N;i++){
     if(p[i] >= H && q[i] >= W){
     sum+=1;
    }
   }
    printf("%d",sum);
  return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<string>
using namespace std;
int main() {
	char a;
	int b;
	int c;
	int d;
	int e;
	cin >> a;
	if (a == 'a' || a == 'i' || a == 'u' || a == 'o' || a == 'e') {
		cout << "vowel" << "\n";
	}
	else {
		cout << "consonant" << "\n";
	}
	cin >> e;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define rep(i, a, b) for(int i=a; i<b; i++)
#define per(i, a, b) for(int i=b-1; i>=a; i--)
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;
int main(){
	int h,w,n;
	cin>>h>>w>>n;
	int a=max(h,w);
	int b=n%a;
	if(b!=0)a=n/a+1;
	else a=n/a;
	cout<<a<<endl;
} 

Measured memory_bytes: 256
#include <cstdlib>
#include <functional>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>

#define ll long long int

using namespace std;

ll factorial(ll x) {
  if (x == 0) {
    return 1;
  }

  ll ret = 1;
  for (ll i = 1; i <= x; i++) {
    ret *= i;
  }
  return ret;
}

int main(int argc, char *argv[])
{
  ll N;
  cin >> N;

  ll sum = 0;

  for(ll i = 1; i <= N; i++) {
    sum += i;
  }

  cout << sum;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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(vec) vec.begin(), vec.end()
#define rALL(vec) vec.rbegin(), vec.rend()
using namespace std;
using ll = long long;
 
int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if ((C + B - 1)/B <= (A + D - 1)/D) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
struct ii {
    int a, b;
    bool operator < (ii o) const {
        return tie(a, b) < tie(o.a, o.b);
    }
};
struct iii {
    int a, b, c;
    bool operator < (iii o) const {
        return tie(a, b, c) < tie(o.a, o.b, o.c);
    }
};

const int MOD = 1000000007;
const int INF = 1000000000;
const int MAXN = 1000005;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    
    ll N, D;
    cin >> N >> D;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        ll x, y;
        cin >> x >> y;
        if (x*x + y*y <= D*D) ans++;
    }
    cout << ans << "\n";
    
}


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

#define fi first
#define se second
#define pb push_back
#define sz(a) (int)(a).size()
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;

const ll MOD = 1e9 + 7;
const ll INF = 1e18;
const ll IINF = INT_MAX;

const int N = 2e4 + 5;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int h, n;
    cin >> h >> n;
    vll a(n), b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    vll dp(N, IINF);
    dp[0] = 0;
    for (int i = 0; i <= h; i++) {
        for (int j = 0; j < n; j++) {
            dp[i + a[j]] = min(dp[i + a[j]], dp[i] + b[j]);
        }
    }
    ll ans = IINF;
    for (int i = h; i < N; i++) {
        ans = min(ans, dp[i]);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 384
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000

int ans[100010];
int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S; cin >> S;
    int n = S.length();
    vector<int> v;
    int cnt = 0;
    rep(i, n) {
        if (v.size() % 2 == 0) {
            if(S[i] == 'R') cnt++;
            else {
                v.push_back(cnt);
                cnt = 0;
                i--;
            }
        }
        else if (v.size() % 2 == 1) {
            if (S[i] == 'L') cnt++;
            else {
                v.push_back(cnt);
                cnt = 0;
                i--;
            }
        }
    }
    if(cnt > 0) v.push_back(cnt);
    int x = 0;
    for(int i = 0; i < v.size(); i += 2) {
        cnt = v[i] + v[i + 1];
        ans[x + v[i] - 1] = (v[i] + 1) / 2 + v[i + 1] / 2;
        ans[x + v[i]] = (v[i]) / 2 + (v[i + 1] + 1) / 2;
        x += cnt;
        //cout << v.size() << " " << v[i] << " " << v[i + 1] << endl;

    }
    rep(i, n) {
        if (i != 0) cout << " ";
        cout << ans[i];
    }
    cout << endl;


    return 0;
}


Measured memory_bytes: 1480
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static long MOD = 1_000_000_007;

	public static void main(String[] args) {
		int N = sc.nextInt();
		boolean[][] A = new boolean[N][N];
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < N; j++) {
				A[i][j] = sc.nextInt() == 1;
			}
		}
		int[] dp = new int[1 << N];
		dp[0] = 1;
		for (int i = 0; i < N; i++) {
			for (int j = 0; j < (1 << N); j++) {
				if (Integer.bitCount(j) != i) continue;
				for (int k = 0; k < N; k++) {
					if (!A[i][k]) continue;
					int next = j | (1 << k);
					if (next == j) continue;
					dp[next] += dp[j];
					if (dp[next] >= MOD) dp[next] -= MOD;
				}
			}
		}
		System.out.println(dp[(1 << N) - 1]);
	}
}

Measured memory_bytes: 31956
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,a,b) for(int i=0;i<(b);i++)
#define trav(a,x) for(auto& a:x)
#define all(x) x.begin(),x.end()
#define sz(x)(int)(x).size();
const ll MAX =1e18;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<int> vi;
int a[300000];
int main()
{
       ios_base::sync_with_stdio(false);
       cin.tie(NULL);
       cout.tie(NULL);
       int n;
       cin>>n;
       int l=1;
       ll ans=0;
       ll sum=0;
       for(int r=1;r<=n;r++){
          cin>>a[r]; 
          while((sum^a[r])!=sum+a[r]){
              sum^=a[l];
              l++;
          }
          sum^=a[r];
          ans+=r-l+1;
        }
    cout<<ans;
    return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
const int nax=1e5+5;
const int mod=1e9+7;
#define ll long long

void add_self(int &a,int b)
{
    a+=b;
    if(a>=mod)
    a-=mod;
}

void sub_self(int &a,int b)
{
    a-=b;
    if(a<0)
    a+=mod;
}


int main()
{
    int n,k;
    cin >> n >> k;
    
    vector<int> dp(k+1);
    
    dp[0]=1;
    
    for(int child=0;child<n;++child)
    {
        int a;
        cin >> a;
        vector<int> fake(k+1);
        for(int candies=k;candies>=0;--candies)
        {
            int tmp=dp[candies];
            int l=candies+1;
            int r = candies + min(a,k-candies);
            
            if(l<=r)
            add_self(fake[l],tmp);
            if(r+1<=k)
            sub_self(fake[r+1],tmp);
        }
    int pref_sum=0;
    for(int i=0;i<=k;++i)
    {
        add_self(pref_sum,fake[i]);
        add_self(dp[i],pref_sum);
    }
    }
    cout << dp[k] << endl;
    
    return 0;
} 

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,Q;
int A[101010],B[101010];
int D[101010];
int yes[101010];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>Q;
	FOR(i,N) D[i]=i;
	yes[0]=1;
	yes[1]=1;
	int cur=0;
	FOR(i,Q) {
		cin>>A[i]>>B[i];
		A[i]--,B[i]--;
		if(A[i]==cur) cur=B[i];
		else if(B[i]==cur) cur=A[i];
		swap(D[A[i]],D[B[i]]);
		if(cur) yes[D[cur-1]]=1;
		if(cur<N-1) yes[D[cur+1]]=1;
	}
	
	cout<<count(yes,yes+N,1)<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C;
  cin >> A >> B >> C;
  bool answer = false;
  for (int i = 1; i <= A; i++){
    if ((B * i + C) % A == 0){
      answer = true;
    }
  }
  if (answer == true){
    cout << "YES" << endl;
  }
  else {
    cout << "NO" << endl;
  }
}

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

using namespace std;
typedef long long ll;

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

    for (int i = 0; i < s.size(); i++) {
        if (s[i] == t[i]) continue;
        else {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


Measured memory_bytes: 3624
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <time.h>
#define _USE_MATH_DEFINES
#define LL long long
#define UN unsigned
using namespace std;
const double PI = acos(-1.0);

int max_num(int ary[], int length) {
	int max = ary[0];
	for (int i = 1; i < length; i++)
		if (max < ary[i]) max = ary[i];
	return max;
}

int max_ord(int ary[], int length) {
	int max;
	max = max_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == max) return i;
	}
	return -1;
}

int min_num(int ary[], int length) {
	int min = ary[0];
	for (int i = 1; i < length; i++)
		if (min > ary[i]) min = ary[i];
	return min;
}

int min_ord(int ary[], int length) {
	int min;
	min = min_num(ary, length);
	for (int i = 0; i < length; i++) {
		if (ary[i] == min) return i;
	}
	return -1;
}

int mp[10000][10000];

int main() {
	int h, w, n, a[10000], big = 1, small = 1;
	cin >> h >> w >> n;
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < h; i++) {
		if (i % 2 == 0)
			for (int j = 0; j < w; j++, small++) {
				mp[i][j] = big;
				if (small == a[big - 1]) {
					big++;
					small = 0;
				}
			}
		else
			for (int j = w - 1; j >= 0; j--, small++) {
				mp[i][j] = big;
				if (small == a[big - 1]) {
					big++;
					small = 0;
				}
			}
	}

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cout << mp[i][j];
			cout << ' ';
		}
		cout << endl;
	}

	return 0;
	return 0;
}


Measured memory_bytes: 2560