akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
using P = pair<long, long>;

typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvinv(xs) sort(xs.begin(), xs.end(), std::greater<long>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)
#define index_of(as, x) \
  distance(as.begin(), lower_bound(as.begin(), as.end(), x))

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

const int mod = 1000000007;

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

  long n, m;
  cin >> n >> m;

  map<long, long> mp;

  vector<long> a(n);
  fillLong(a, n);

  vector<long> b(n+1);
  b[0] = 0;
  mp[0]++;

  rep(i, n) {
    b[i+1] = (b[i] + a[i])%m;
    mp[b[i+1]]++;
  }

  ll res = 0;
  for(auto x: mp) {
    if (x.second > 1) {
      res += (x.second * (x.second-1) / 2);
    }
  }

  cout << res << endl;
}


Measured memory_bytes: 5760
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define all(x) (x).begin(),(x).end()
#define rep(i, n) for(ll i = 0; i < n; i++)
const ll INF = 1LL << 60;

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

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


int main(){
    int A, B, C; cin >> A >> B >> C;
    map<int,int> m;
    m[A]++;
    m[B]++;
    m[C]++;
    if(m[5] == 2 && m[7] == 1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

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

void hanten(string s){
	int n = s.size();

	for(int i=0;i<n;i++){
		cout << s[n-i-1];
	}
}

int main()
{
	string s;
	int q,ex=0;
	cin >> s;
	cin >> q;

	string f,b;

	for(int i=0;i<q;i++){
		int tmp;
		cin >> tmp;

		if(tmp == 1){
			ex = (ex+1)%2;
		}else if(tmp == 2){
			cin >> tmp;

			char c;
			cin >> c;

			if(ex){
				if(tmp == 1){
					f+=c;
				}else if(tmp == 2){
					b+=c;
				}
			}else{
				if(tmp == 1){
					b+=c;
				}else if(tmp == 2){
					f+=c;
				}
			}
		}
	}

	if(ex){
		hanten(f);
		hanten(s);
		cout << b << endl;
	}else{
		hanten(b);
		cout << s << f << endl;
	}

	return 0;
}


Measured memory_bytes: 1216
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n,m;
	while(cin>>n>>m,n+m){
		vi a(n),b(m);
		rep(i,n)cin>>a[i];
		rep(i,m)cin>>b[i];
		map<int,int>in1;
		rep(i,n){
			int sum=0;
			loop(j,i,n){
				sum+=a[j];
				in1[sum]++;
			}
		}
		int co=0;
		rep(i,m){
			int sum=0;
			loop(j,i,m){
				sum+=b[j];
				co+=in1[sum];
			}
		}
		cout<<co<<endl;
		
		
	}
}

Measured memory_bytes: 19044
#include<bits/stdc++.h>
using namespace std;
int k,dis[100000];
vector<vector<int> > v;
int main() {
	scanf("%d", &k);
	queue<int> q;
	int p = 1;
	for (int i = 0; i < k; i++) {
		while (!dis[p]) {
			dis[p] = 1;
			q.push(p);
			p = p * 10LL % k;
		}
	}
	if (dis[0]) {
		puts("1");
		return 0;
	}
	while (!q.empty()) {
		int h = q.front();
		q.pop();
		int t = (h + 1) % k;
		while (!dis[t]) {
			dis[t] = dis[h] + 1;
			q.push(t);
			t = t * 10LL % k;
		}
	}
	printf("%d", dis[0]);
	return 0;
}

Measured memory_bytes: 1024
#数値を入力
N=input()
A=input()
N=int(N)
A=int(A)

#1円玉を500枚以上持っていたら任意のNで支払い可能
if A>=500:
    print("Yes")


#500枚未満の場合
else:
    if N%500<=A:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 2940
def sieve(n):
    primes = [True] * n
    primes[0] = primes[1] = False
    for i in xrange(2, int(n ** 0.5) + 1):
        if primes[i]:
            for j in xrange(i * i, n, i):
                primes[j] = False
    return [i for i in xrange(n) if primes[i]]

while 1:
    try:
        n = input()
    except EOFError:
        break
    primes = sieve(n * 2)
    small, big = -1, -1
    for prime in primes:
        if prime < n:
            small = prime
        if prime > n:
            big = prime
            break
    print small, big

Measured memory_bytes: 5556
package main

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

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt() int {
  n, _ := strconv.Atoi(NextLine())
  return n
}
func NextIntVec() []int {
  L := strings.Split(NextLine(), " ")
  N := make([]int, len(L))
  for i := range N {
    N[i], _ = strconv.Atoi(L[i])
  }
  return N
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func Output() {
  _ = writer.Flush()
}

type Food struct {
  A int
  B int
}
type Foods []Food
func (F Foods) Len() int { return len(F) }
func (F Foods) Less(i, j int) bool {
  if F[i].A == F[j].A { return F[i].B > F[j].B }
  return F[i].A < F[j].A
}
func (F Foods) Swap(i, j int) { F[i], F[j] = F[j], F[i] }

func Max(x, y int) int {
  if x < y { return y }
  return x
}
func Min(x, y int) int {
  if x < y { return x }
  return y
}

func main() {
  NT := NextIntVec()
  N, T := NT[0], NT[1]
  F := make([]Food, N)
  for i := range F {
    AB := NextIntVec()
    F[i] = Food{AB[0], AB[1]}
  }
  sort.Sort(Foods(F))
  DP := make([][]int, N)
  for i := range DP {
    DP[i] = make([]int, T)
  }
  for i := 1; i < N; i++ {
    for j := 1; j < T; j++ {
      DP[i][j] = Max(DP[i - 1][j], DP[i][j - 1])
      if F[i - 1].A <= j {
        DP[i][j] = Max(DP[i - 1][j - F[i - 1].A] + F[i - 1].B, DP[i][j])
      }
    }
  }
  H := 0
  for i, dp := range DP {
    H = Max(dp[T - 1] + F[i].B, H)
  }
  Write(H)
  Output()
}

Measured memory_bytes: 75520
import fractions
A, B, C, D = map(int, input().split())

def lcm(x,y):
    return ((x * y)//fractions.gcd(x, y))

C_comp = (B//C) - ((A-1)//C)
D_comp = (B//D) - ((A-1)//D)
CD_comp = (B//lcm(C,D)) - ((A-1)//lcm(C,D))

print((B - A + 1) - (C_comp + D_comp - CD_comp))


Measured memory_bytes: 5048
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

type Index = (usize, usize);

fn get_index(i: usize, j: usize) -> Index {
  if i < j { (i, j) } else { (j, i) }
}

use std::collections::{BTreeMap, BTreeSet};

fn longest_path(v: Index, adj: &BTreeMap<Index, Vec<Index>>, len: &mut BTreeMap<Index, usize>, active: &mut BTreeSet<Index>) -> Option<usize> {
  if let Some(l) = len.get(&v) {
    return Some(*l);
  }
  if active.contains(&v) {
    return None;
  }
  let mut l = 0;
  active.insert(v);
  if let Some(adj_v) = adj.get(&v) {
    for &next in adj_v {
      if let Some(nl) = longest_path(next, adj, len, active) {
        l = cmp::max(l, nl + 1);
      } else {
        return None;
      }
    }
  }
  len.insert(v, l);
  active.remove(&v);
  Some(l)
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: [[usize1; n-1]; n],
  }
  let mut adj = BTreeMap::new();
  for i in 0 .. n {
    for j in 0 .. n - 2 {
      let index = get_index(i, a[i][j]);
      let next = adj.entry(index).or_insert(vec![]);
      next.push(get_index(i, a[i][j+1]))
    }
  }
  let mut len = BTreeMap::new();
  let mut ans = 0;
  let mut active = BTreeSet::new();
  for &idx in adj.keys() {
    if let Some(l) = longest_path(idx, &adj, &mut len, &mut active) {
      ans = cmp::max(ans, l as i64 + 1);
    } else {
      ans = -1;
      break;
    }
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 107512
#include <bits/stdc++.h>
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
using namespace std;
ll dp[3005][3005][4];
vector<vector<ll>>v(3005,vector<ll>(3005,0));

ll solve(ll i,ll j,int k)
{
    if(k<0||k>3)
    return 1e18;
    if(i<0||j<0)
    return 0;
    if(dp[i][j][k]!=-1)
    return dp[i][j][k];
    if(k==0)
    {
        dp[i][j][k]=max(solve(i,j-1,0),max(solve(i-1,j,0),max(solve(i-1,j,2),max(solve(i-1,j,3),solve(i-1,j,1)))));
        
    }
    else if(k==1)
    {
        dp[i][j][k]=max(solve(i-1,j,0),max(solve(i-1,j,2),max(solve(i-1,j,3),solve(i-1,j,1))))+v[i][j];
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k-1)+v[i][j]);
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k));
    }
    else if(k==2)
    {
        
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k-1)+v[i][j]);
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k));
    }
    else
    {
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k-1)+v[i][j]);
        dp[i][j][k]=max(dp[i][j][k],solve(i,j-1,k));
    }
    return dp[i][j][k];
}
int main() {
    fast();
    // ll t;
    // cin>>t;
    // while(t--)			
    // {
    
    // } 
    ll n,m,k;
    cin>>n>>m>>k;
    for(int i=0;i<k;i++)
    {
        ll r,c,vl;
        cin>>r>>c>>vl;
        v[r-1][c-1]=vl;
    }
    for(int i=0;i<3005;i++)
    for(int j=0;j<3005;j++)
    for(int k=0;k<4;k++)
    dp[i][j][k]=-1;
    ll ans=max(solve(n-1,m-1,0),max(solve(n-1,m-1,2),max(solve(n-1,m-1,3),solve(n-1,m-1,1))));
    cout<<ans<<endl;
}

Measured memory_bytes: 357336
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int n, a, b, i;
    String as, bs;
    char[] ac, bc;

    for(n = sc.nextInt();n-- > 0;){
      as = sc.next(); bs = sc.next();
      ac = new char[as.length()]; bc = new char[bs.length()];
      for(i = 0;i < as.length();i++)ac[i] = as.charAt(i);
      for(i = 0;i < bs.length();i++)bc[i] = bs.charAt(i);
      a = getint(ac, as.length()); b = getint(bc, bs.length());
      solve(a + b);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int getint(char[] c, int n){
    int i, res = 0;
    for(i = 0;i < n;){
      if(c[i] >= '2' && c[i] <= '9'){
        if(c[i + 1] == 'm')res += 1000 * (int)(c[i] - '0');
        else if(c[i + 1] == 'c')res += 100 * (int)(c[i] - '0');
        else if(c[i + 1] == 'x')res += 10 * (int)(c[i] - '0');
        else res += (int)(c[i] - '0');
        i += 2;
      }else{
        if(c[i] == 'm')res += 1000;
        else if(c[i] == 'c')res += 100;
        else if(c[i] == 'x')res += 10;
        else res++;
        i++;
      }
    }
    return res;
  }
  private static void solve(int a){
    int d, i;
    String[] s;
    s = new String[4]; s[0] = "m"; s[1] = "c"; s[2] = "x"; s[3] = "i";
    i = 0;
    for(d = 1000;d > 0;d /= 10){
      if(a / d > 1)System.out.print((a / d) + s[i]);
      else if(a / d == 1)System.out.print(s[i]);
      a %= d; i++;
    }
    System.out.println();
    return;
  }
}

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

bool check( string s, string t)
{
	for(int i =0; i < s.size(); i++ )
		if(s[i] != t[i])
			return false;
	return true;
}

int main()
{
	// int T;
	// cin>>T;
	// while(T--)
	// 	cout<<T<<endl;
	// return 0;
	string s,t;
	cin>>s>>t;
	cout<< (check( s,t ) ? "Yes" : "No");

}

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

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

    a = (a==1 ? 14 : a);
    b = (b==1 ? 14 : b);

    cout << (a > b ? "Alice" : (a < b ? "Bob" : "Draw")) << endl;
}

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

int main() {
  int N, ans = 0;
  double ave;
  cin >> N;
  vector<int> vec(N);
  vector<double> dif(N);
  for (int i = 0; i < N; i++) cin >> vec.at(i);
  for (int x : vec) ave += x;
  ave = ave / N;
  for (int i = 0; i < N; i++) dif.at(i) = abs(vec.at(i) - ave);
  for (int i = 0; i < N - 1; i++) {
    if (dif.at(ans) > dif.at(i + 1)) ans = i + 1;
    if (dif.at(ans) == 0) break;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main(){
    cin>>n>>a>>b;
    if(a+b>n+1||a*b<n){
        cout<<-1;
        return 0;
    }
    while(n>0){
        long long x=min(a,n-b+1);
        for(long long i=n-x+1;i<=n;i++)cout<<i<<" ";
        n-=x;b--;
    }
    return 0;
}

Measured memory_bytes: 3620
#C
n = int(input())
p = list(map(int, input().strip().split()))

ans = 1
min_p = min(n+1,p[0])
for i in range(1,n):
    if p[i] < p[i-1] and p[i] < min_p:
        ans += 1
    min_p = min(min_p,p[i])

print(ans)

Measured memory_bytes: 24744
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  ll n;
  cin >> n;
  vector<pair<int, int>> prime;

  // nまでの素数を生成
  int check_num = (int)sqrt(n);
  vector<bool> is_prime(check_num + 1, true);
  for (int i = 0; i <= check_num; i++) {
    if (!is_prime.at(i)) continue;
    if (i == 0 || i == 1) is_prime.at(i) = false;
    if (is_prime.at(i)) {
      for (int j = 2; j * i <= check_num; j++) {
        is_prime.at(j * i) = false;
      }
    }
  }
  REP(i, check_num + 1) {
    if (is_prime.at(i)) prime.push_back(make_pair(i, 0));
  }

  // aを素因数分解
  for (auto &y : prime) {
    while (n % y.first == 0) {
      y.second++;
      n /= y.first;
    }
    if (n == 1) break;
  }
  if (n != 1) {
    prime.push_back(make_pair(n, 1));
  }

  ll ans = 0;
  for (auto x : prime) {
    if (x.second > 0) {
      double tmp = (-1 + sqrt(x.second * 8 + 1)) / 2.0;
      ans += (int)tmp;
    }
  }


  cout << ans << "\n";

  return 0;
}


Measured memory_bytes: 4448
import sys
def main():
    n = int(input())
    a = [int(i) for i in input().split()]
    if 0 in a:
        print('0')
        return
    ans = 1
    for hoge in a:
        ans *= hoge
        if ans > 10**18:
            print('-1')
            return
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 21640
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>
#include <iterator>
#include <regex>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

template <class T, template <class, class> class C, class charT = char>
void vdump(const C<T, allocator<T>> &v, const charT* delimiter = ", ",
           ostream &stream = cout) {
  copy(v.begin(), v.end(), ostream_iterator<T>(stream, delimiter));
  stream << endl;
}

int main() {
  ios::sync_with_stdio(false);
  int n, a;
  cin >> n >> a;
  cout << (n % 500 <= a ? "Yes" : "No") << endl;
  
  return 0;
}


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

int main(){
    int K, Q;
    cin >> K >> Q;
    vector<int> D(K);
    for(int i=0; i<K; i++) scanf("%d", &D[i]);

    while(Q--){
        int N, X, M;
        scanf("%d %d %d", &N, &X, &M);
        N--;
        X %= M;

        int L = N/K, R = N%K;

        int64_t sum = X;
        for(int i=0; i<K; i++){
            int64_t d = D[i] % M;
            if(d == 0) d = M;
            sum += (i<R ? L+1 : L)*d;
        }
        int ans = N-sum/M;
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
s = list(map(int,input().split()))
h = [int(input()) for i in range(s[0])]
h.sort()
min = 0
temp = 0
for i in range(s[0]-s[1]+1):
    temp = abs(h[i]-h[i+s[1]-1])

    if i == 0:
        min = temp
    elif temp < min:
        min = temp
print(min)


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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 58;


int main() {
  int N, M, X[100000];
  cin >> N >> M;
  for(int i = 0; i < M; i++) cin >> X[i];
  sort(X, X + M);

  vector< int > Y;
  for(int i = 1; i < M; i++) {
    Y.emplace_back(X[i] - X[i - 1]);
  }
  sort(begin(Y), end(Y));
  reverse(begin(Y), end(Y));
  int64 sub = 0;
  for(int i = 0; i + 1 < N && i < Y.size(); i++) sub += Y[i];
  cout << X[M - 1] - X[0] - sub << endl;
}




Measured memory_bytes: 1276
from collections import defaultdict
if __name__ == "__main__":
    x,n = map(int,input().split())
    l = list(map(int,input().split()))
    if n == 0 :
        print(x)
    else :
        l.sort()
        count = 0
        dist = 999
        ans = -100
        for i in range(-100,201) :
            if i in l :
                continue
            if dist > abs(x - i) :
                dist = abs(x - i)
                ans = i 
        print(ans)

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

int main()
{
        char letters[3];
        int i;
        int count=0;

        for(i=0;i<3;i++)
        {       
                scanf("%c",&letters[i]);
                if ( i==0 & letters[i] == 'R') count++;
                if (i>0 & letters[i] == 'R' & letters[i-1] == 'R') count++;
                if (i>0 & letters[i] == 'R' & count == 0) count = 1;
        }
        printf("%d\n",count);

        return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N);
  for(int i=0;i < N+1;i++) cin >> A.at(i);
  for(int i=0;i < N;i++) cin >> B.at(i);
  long long ans=0;
  for(int i=0;i < N;i++){
    ans += min(A.at(i),B.at(i));
    if(B.at(i) - A.at(i) > 0){
      ans += min(B.at(i) - A.at(i),A.at(i + 1));
      A.at(i+1) -= min(B.at(i) - A.at(i),A.at(i + 1));
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	int a,b,c,d;
	a=n%10;
	b=n/10%10;
	c=n/100%10;
	d=n/1000%10;
	if(a==b&&b==c&&c!=d)
	cout<<"Yes"<<endl;
	else if(a==b&&a==c&&c==d)
	 cout<<"Yes"<<endl;
	 else if(b==c&&c==d&&a!=b)
	 	cout<<"Yes"<<endl;
	 	else
	 	cout<<"No"<<endl;
} 

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

using namespace std;

#define ll long long
#define F first
#define S second
#define ii pair < int , int >



int main()
{
    vector<int> v;
    string s;
    int n;
    s+='*';
    s+='*';
    cin>>n;
    cin>>s;
    for(int i=0;i<n;i++){
        if(s[i]=='A')
            v.push_back(i);
    }
    int ans=0;
    for(auto x:v){
        if(s[x+1]=='B' && s[x+2]=='C')
        ans++;

    }
    printf("%d",ans);

}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (long long i = 0; i < n; i++)
#define RREP(i, n) for (long long i = n - 1, 0 <= i; i--)
#define FOR(i, start, end) for (long long i = start; i < end; i++)
#define RFOR(i, start, end) for (long long i = start - 1; 0 <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1'000'000'007
using ll = long long;
using namespace std;
const int INF32       = 1'050'000'000;
const long long INF64 = 4'000'000'000'000'000'000;
const int MOD7        = 1'000'000'007;
const int MOD9        = 1'000'000'009;
template <class T> inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
void print() { std::cout << '\n'; }
template <class H, class... T> void print(H &&head, T &&... args) {
    std::cout << head;
    sizeof...(args) == 0 ? std::cout << "" : std::cout << ' ';
    print(std::forward<T>(args)...);
}
template <class T> void print(std::vector<T> &v) {
    for (int i = 0; i < v.size(); i++) {
        std::cout << v[i];
        i == v.size() - 1 ? std::cout << '\n' : std::cout << ' ';
    }
}
template <class T> void print(std::vector<std::vector<T>> &v) {
    for (int i = 0; i < v.size(); i++) {
        for (int j = 0; j < v[i].size(); j++) {
            std::cout << v[i][j];
            j == v[i].size() - 1 ? std::cout << '\n' : std::cout << ' ';
        }
    }
}

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

    int N;
    cin >> N;
    vector<ll> h(N);
    for (auto &&i : h) {
        cin >> i;
    }

    vector<ll> dp(N);
    dp[0] = 0;
    FOR(i, 1, N) {
        dp[i] = INF64;
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (1 < i) {
            chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
        }
    }
    print(dp[N - 1]);

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long
#define f   first
#define s   second
#define pb          push_back
#define mod         1000000007
#define hell        998244353
#define inf         1000000000000000000LL
using namespace std;
ll n,k,m;
//ll dp[15][1005];
ll dp[105][100005];
void solve()
{   ll W;
    cin>>n>>W;
    vector<ll> w(n+1),v(n+1);
    for(int i=1;i<=n;i++) cin>>w[i]>>v[i];
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=W;j++)
        {
            if(j>=w[i])
                dp[i][j]=max(dp[i-1][j],v[i]+dp[i-1][j-w[i]]);
            else dp[i][j]=dp[i-1][j];
        }
    }
    cout<<dp[n][W];
}

int main()
{
    ll t=1;
    //cin>>t;
    while(t--)
        solve();

}

Measured memory_bytes: 79360
#include<stdio.h>
#define MAX 10000000
int dp[21][50001];
int main(void)
{
	int n,m;
	int d[10001];
	int i,j,k;
	
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
		scanf("%d",&d[i]);
	}
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++){
			dp[i][j]=MAX;
		}
	}
	dp[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(dp[i][j]!=MAX){
				if(dp[i+1][j]>dp[i][j]){
					dp[i+1][j]=dp[i][j];
				}
				if(dp[i][j]+1<dp[i][j+d[i]]){
					dp[i][j+d[i]]=dp[i][j]+1;
				}
			}
		}
	}
	printf("%d\n",dp[m][n]);
	return 0;
}

Measured memory_bytes: 5132
# -*- coding: utf-8 -*-

# 入力を整数に変換して受け取る
def input_int():
    return int(input())


# マイナス1した値を返却
def int1(x):
    return int(x) - 1


# 半角スペース区切り入力をIntに変換してMapで受け取る
def input_to_int_map():
    return map(int, input().split())


# 半角スペース区切り入力をIntに変換して受け取る
def input_to_int_tuple():
    return tuple(map(int, input().split()))


# 半角スペース区切り入力をIntに変換してマイナス1した値を受け取る
def input_to_int_tuple_minus1():
    return tuple(map(int1, input().split()))


def main():
    n = input_int()
    c_list = input()

    red_cnt = c_list.count("R")
    white_cnt = n - red_cnt

    pre = "R"
    is_out = False
    for c in c_list:
        if c != pre:
            is_out = True
            break
        pre = c

    if is_out:
        print(min(red_cnt, white_cnt, c_list[:red_cnt].count("W")))
    else:
        print(0)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9432
namespace ABC141.C
{
    using System.Collections.Generic;
    using System.Linq;
    using static System.Console;

    public class Program
    {

        public static void Main(string[] args)
        {
            var l = ReadInputsAsInt().ToArray();
            var n = l[0];
            var k = l[1];
            var q = l[2];


            Solve(n, k, ReadLinesAsInt(q).ToList())
                .ToList()
                .ForEach(x => WriteLine(x ? "Yes" : "No"));
        }

        public static IEnumerable<bool> Solve(int n, int k, List<int> a)
        {
            var additionalPointList = Enumerable.Repeat(0, n).ToList();
            foreach (var p in a)
            {
                additionalPointList[p - 1]++;
            }

            foreach (var item in additionalPointList)
            {
                yield return k - a.Count + item > 0;
            }
        }


        static IEnumerable<int> ReadInputsAsInt() => ReadLine().Split(' ').Select(x => int.Parse(x));


        static IEnumerable<int> ReadLinesAsInt(int n)
        {
            for (int i = 0; i < n; i++)
            {
                yield return int.Parse(ReadLine());
            }
        }
    }
}


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

#define pb(n) push_back(n)
#define fi first
#define se second
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(unique(all(v)),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}
const int PrimeMax = 1000000;
int is_prime[PrimeMax];
void Eratosthenes(int N){
  for(int i = 0; i < N; i++){
    is_prime[i] = 1;
  }
  is_prime[1] = 0;
  for(int i = 2; i*i < N ; i++){
    if(is_prime[i]){
      for(int j = 0; i * (j + 2) < N; j++){
        is_prime[i *(j + 2)] = 0;
      }
    }
  }
}
int ans[PrimeMax];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  Eratosthenes(PrimeMax);
  vary(int,v,0,0);
  v.clear();
  rep(i,PrimeMax){
    if(is_prime[i] != 0){
      v.pb(i);
    }
  }
  int n;
  while(cin >> n&&n){
    int res = 0;
    REP(i,0,v.size()){
      if(v[i] + *lower_bound(all(v),n - v[i]) == n){
        res++;
      }
      if(v[i] > n) break;
    }
    cout << (1+res)/2 << endl;
  }
  return 0;
}

Measured memory_bytes: 7224
function Main(input) {
  input=input.split("\n");
  const X=input[0]-0;
  console.log(X>=30?'Yes':'No');
}


//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
  



  


Measured memory_bytes: 29556
#include<cstdio>
#include<iostream>
#include<vector>
#include<tuple>
#include<queue>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>

using namespace std;

int main(int argc, char* argv[]){
  long long int n;
  long long int h[101];
  long long int p[101];
  long long int ans = 0;
  int cflg = 0;
  cin >> n;
  for(int i = 1; i < n+1; i++){
    cin >> h[i];
    p[i] = 0;
  }
  for(int i = 1; i<10001; i++){
    for(int left = 1; left < n+1; left++){
      int right = left;
      cflg = 0;
      for(;right < n+1; right++){
        left = right;
        if(p[right] == h[right]){
          if(cflg==0)break;
          else{
            ans++;
            break;
          }
        }
        if(right == n)ans++;
        p[right]++;
        cflg = 1;
       
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

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

int main() {
    int x[5];
    int res;
    rep(i,5){
        cin >> x[i];
        if(x[i]==0){
            res=i+1;
        }
    }

    cout << res << "\n";

}

Measured memory_bytes: 3620
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-22 19:45:32
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  int a[2]; cin >> a[0] >> a[1];
  sort(a, a + 2);

  if (a[0] == 1 && a[1] == 2) {
    cout << 3 << endl;
  } else if (a[0] == 1 && a[1] == 3) {
    cout << 2 << endl;
  } else {
    cout << 1 << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#define Max	100000
int main(void)
{

	int i,j,prime[Max]={0},n;
	prime[0]=1;
	prime[1]=1;
	for(i=2;i<sqrt(Max);i++){	//i<=j かつi*j<Max⇒i<sart(Max)
		for(j=2;i*j<Max;j++){
			prime[i*j]=1;		//xが素数⇒prime[x]=0,素数以外⇒prime[x]=1
		}
	}

	while(scanf("%d",&n)!=EOF){
		int Max_prime=0;
		int Min_prime=0;	   
		for(i=0;i<n;i++){
			if(prime[i]==0) Max_prime=i;
			}
		for(j=n+1;j<=50021;j++){			//50021が50000以上の最小の素数
			if(prime[j]==0){
				Min_prime=j;
				goto end;
			}
		}
		end:
		printf("%d %d\n",Max_prime,Min_prime);
	}
	return 0;		
}

Measured memory_bytes: 992
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll k,a,b;
    cin >> k >> a >> b;
    ll ans = 1;
    bool one = false;
    if(b-a<=2){
        ans += k;
    }else{
        while(k>0){
            if(ans>=a&&k>1&&one==false){
                ans-=a;
                one = true;
            }else if(one){
                ans += b;
                one = false;
            }else{
                ans++;
            }
            k--;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> l;
  for(int i = 0; i < 2 * N; i++){
    int t; cin >> t; l.push_back(t);
  }
  sort( l.begin(), l.end() );
  int ans = 0;
  for(int i = 0; i < 2*N; i+=2){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


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

int main(){
  int N;
  cin>>N;
  int ans = 0;
  if(N>=105){
    ans++;
    int c = 0;
    for(int i=107;i<N+1;i+=2){
      for(int j=1;j<=i;j++){
        if(i%j==0)c++;
      }
      if(c==8)ans++;
      c=0;

    }
  }

  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <deque>
#include <algorithm>

typedef long long ll;
typedef unsigned long long ull;
#define mod 1000000007
#define rep(i, n) for(int i = 0; i < n; ++i)

using namespace std;

struct edge {
	int source;
	int distination;
	ll length;
};

struct node {
	ll distance;
	int predecessor;
	bool distanceIsNotInf;
	bool distanceIsMinusInf;
	bool isInvalid;
};

//0始まりでフォーマットして入力すること.返値は距離と, 負の重みの閉路があればtrue.
pair<ll, bool> bellmanFord(node* nodes, int numOfNodes, edge* edges, int numOfEdges, int startAt, int endAt) {
	bool inf = false;
	
	//relax
	bool flag = false;
	for (int i = 0; i < numOfNodes*2; ++i) {
		for (int j = 0; j < numOfEdges; ++j) {
			int u = edges[j].source;
			int v = edges[j].distination;

			if (!nodes[u].distanceIsNotInf) continue;
			if (nodes[u].distanceIsMinusInf) {
				nodes[v].distanceIsMinusInf = true;
			}
			else if (!nodes[v].distanceIsNotInf || nodes[v].distance > nodes[u].distance + edges[j].length) {
				nodes[v].distance = nodes[u].distance + edges[j].length;
				nodes[v].predecessor = u;
				nodes[v].distanceIsNotInf = true;
				if (i >= numOfNodes) {
					nodes[v].distanceIsMinusInf = true;
				}
			}

			if (nodes[endAt].distanceIsMinusInf) {
				inf = true;
				break;
			}
		}
	}
	 
	return pair<ll, bool>(nodes[endAt].distance, inf);
}

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

	int n, m;
	ll p;
	edge* edges;
	cin >> n >> m >> p;
	edges = new edge[m];

	rep(i, m) {
		cin >> edges[i].source >> edges[i].distination >> edges[i].length;
		--edges[i].source;
		--edges[i].distination;
		edges[i].length = p - edges[i].length;
	}

	node* nodes;
	nodes = new node[n];
	memset(nodes, 0, sizeof(node)*n);
	nodes[0].distanceIsNotInf = true;



	pair<ll, bool> ans;
	ans = bellmanFord(nodes, n, edges, m, 0, n-1);

	if (ans.second) {
		cout << -1 << "\n";
	}
	else {
		if (ans.first > 0) {
			cout << 0 << "\n";
		}
		else {
			cout << 0 - ans.first << "\n";
		}
	}
 }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
bool isValid(int value){
    bool ret = false;
    for(int i = 2; i <= (value/2); i++){
        int tmp = value;
        while(true){
            if(tmp%i==0){
                tmp/=i;
            }else{
                if(tmp==1){
                    ret = true;
                    break;
                }else{
                    break;
                }
            }
        }
    }
    return ret;
}
int main(){
    int x;
    cin >> x;
    int ans = 1;
    for(int i = x; i > 1; i--){
        if(isValid(i)){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
int MAX_N=100110;
ll INF=MAX_N*4;
vector<int> G(MAX_N*3, INF);
vector<vector<int>> Way(MAX_N*3, vector<int>(0));
int main(){
    int N, M;
    cin>>N>>M;
    int S, T;
    vector<int> u(M), v(M);
    for(int i=0; i<M; i++){
        cin>>u[i]>>v[i];
        u[i]--;
        v[i]--;
        Way[3*u[i]].push_back(3*v[i]+1);
        Way[3*u[i]+1].push_back(3*v[i]+2);
        Way[3*u[i]+2].push_back(3*v[i]);
    }
    cin>>S>>T;
    S--;
    T--;
    G[S*3]=0;
    priority_queue<int, vector<int>, greater<int>> Q;
    Q.push(S*3);
    while(!Q.empty()){
        int Now=Q.top();
        Q.pop();
        int Sz=Way[Now].size();
        for(int i=0; i<Sz; i++){
            if(G[Way[Now][i]]>G[Now]+1){
                G[Way[Now][i]]=G[Now]+1;
                Q.push(Way[Now][i]);
            }
        }
    }
    cout<<(G[T*3]==INF?-1:G[T*3]/3)<<endl;
  	//for(int i=0; i<N*3; i++){
      	//cout<<G[i]<<endl;
    //}
    return 0;
}

Measured memory_bytes: 18560
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a,b;
    string s,t,u;
    cin >> s >> t;
    cin >> a >> b;
    cin >> u;
    
    if(u==s&&a!=0){a -=1;}
    if(u==t&&b!=0){b -=1;}
    
    cout << a << ' ' << b << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repe(i,n) for (int i = 0; i <= (n); ++i)
#define repe1(i,n) for (int i = 0; i <= (n); ++i)
#define all(x) (x).begin(),(x).end()
#define pb(x) push_back(x)
#define eb(k,v) emplace_back(k,v)
#define ct(res) cout << res << "\n";
#define vi vector<int>
#define vl vector<ll>
using namespace std;
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; }
const int INF = 1e9;
const ll MOD = 1000000007;
const double pi = 3.141592653589;
using Graph = vector<vector<int>>;
ll gcd(ll a, ll b) {return (a%b) ? gcd(b, a%b) : b;}
ll modPow(ll x, ll n) {
    if(n==0) return 1;
    ll res = modPow(x*x%MOD, n/2);
    if(n&1) res=res*x%MOD;
    return res;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;cin>>n;
    vi a(n);rep(i,n) cin >> a[i];
    ll sum = 0;
    rep(i,n) {
        sum += a[i];
    }
    cout << *min_element(all(a)) << " " << *max_element(all(a)) << " " << sum << "\n";
}


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

int main() {
  
  int N, M = 0, h = 0;
  cin >> N;
  M = N;
    
  for(int i = 0; i < 10; i++) {
    h += M % 10;
    M = M / 10;
    if(M == 0) {
      break;
    }
  }

  if(N % h == 0) {
  	cout << "Yes" << endl; 
  }
  
  else {
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 3596
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

LL gcd(LL a, LL b) {
	return b != 0 ? gcd(b, a % b) : a;
}



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

	LL seisu = s[0] - '0';
	LL syousu = (s[2] - '0') * 10LL + (s[3] - '0');

	LL hyaku = 100;
	LL g = gcd(hyaku, syousu);

	LL bunbo = hyaku/ g;
	LL bunsi = syousu / g;

	LL ans = a * seisu + (a*bunsi) / bunbo;
	cout << ans << endl;


	return 0;
}

Measured memory_bytes: 3620
n, q = map(int, input().split())

process = []
for _ in range(n):
    p, t = input().split()
    process.append([p, int(t)])
    
time_processed = 0
while process:
    p = process.pop(0)
    if p[1] > q: #仕事が終わらない
        p[1] = p[1] - q
        process.append(p)
        time_processed += q
    elif p[1] <= q: #仕事が終わる
        print(f"{p[0]} {time_processed + p[1]}")
        time_processed += p[1]
        
    


Measured memory_bytes: 12888
import java.util.Scanner;

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

        for(;;){
            int n=scan.nextInt();
            if(n==0){
                break;
            }
            int S=0;
            int s[]=new int[n];
            for(int i=0;i<n;i++){
                s[i]=scan.nextInt();
                S+=s[i];
            }
            double m=(double)S/n;
            double a=0;
            for(int j=0;j<n;j++){
                a+=(s[j]-m)*(s[j]-m)/n;
            }
            a=Math.sqrt(a);
            System.out.printf("%f\n",a);
        }
    }
}



Measured memory_bytes: 32016
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	static long INF = 1L << 60;
	static long[] h = new long [100010];
	static long[] dp = new long [100010];
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		for(int i=0;i<n;i++)h[i] = Long.parseLong(sc.next());
		sc.close();
		//初期化(INF)
		Arrays.fill(dp,INF);
		dp[0] = 0;

		for(int i=1;i<n;i++) {
			dp[i]=chmin(dp[i],dp[i-1]+Math.abs(h[i]-h[i-1]));
			if(i>1) {
				dp[i]=chmin(dp[i],dp[i-2]+Math.abs(h[i]-h[i-2]));
			}
		}
		System.out.println(dp[n-1]);

	}
	private static long chmin(long a, long b) {
		if (a < b) { return a; } return b;
	}
}


Measured memory_bytes: 49216
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn combination(n: usize, take: usize) -> usize {
    let a = (1..n + 1).rev().take(take).fold(1, |sum, i| sum * i);
    let b = (1..n + 1).take(take).fold(1, |sum, i| sum * i);
    a / b
}

#[test]
fn test() {
    assert_eq!(combination(2, 2), 1);
    assert_eq!(combination(10, 2), 45);
}

fn main() {
    input! {
        n: usize,
        mut ss: [chars; n],
    }
    for s in ss.iter_mut() {
        s.sort();
    }
    ss.sort();
    let mut v = vec![];
    let mut count = 1;
    for i in 1..ss.len() {
        if ss[i - 1] == ss[i] {
            count += 1;
        } else if count != 1 {
            v.push(count);
            count = 1;
        }
    }
    if count != 1 {
        v.push(count);
    }
    let ans = v
        .iter()
        .map(|x| combination(*x, 2))
        .fold(0, |sum, i| sum + i);
    println!("{}", ans);
}


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

int main() {
  int long long a,b,c,d;
  cin>>a>>b>>c>>d;
 int long long x,y,z;
 x=max(a*c,a*d);
 y=max(b*c,b*d);
 z=max(x,y);
  int long long k=0;
 if(a<=0 && b>=0){
     z=max(z,k);
 }
   if(c<=0 && d>=0){
     z=max(z,k);
   }
  cout<<z<<endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int A,B;
    cin>>A>>B;
    while(B--)
    {
    	int X;
    	cin>>X;
        A-=X;
    }
    cout<<max(A,-1)<<endl;
    return 0;
}

Measured memory_bytes: 3596