akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int gcd(int a,int b) {return b ? gcd(b,a%b) : a;}
int main()
{
    int n,k,g=0,mx=0,a;
    cin >> n >> k;
    while (n--) {
        cin >> a;
        g = gcd(g,a);
        mx = max(mx,a);
    }
    cout << ((k % g == 0 && k <= mx) ? "POSSIBLE\n" : "IMPOSSIBLE\n");
}


Measured memory_bytes: 256
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>
#include <climits>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;#include <stdio.h>
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;


int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N, M, K;
	string S;
	vector<int> A, L, R;
	//for (int i = 0; i < N; i++) {
	//	int temp;
	//	cin >> temp;
	//	A.emplace_back(temp);
	//}

	cin >> N;
	int ans;
	if (N % 2 == 0) {
		cout << N / 2 - 1;
	}
	else {
		cout << N / 2;
	}


}



Measured memory_bytes: 256
#include<iostream>
#include<cstring>
using namespace std;
char a[110];
int n;
int x=-1,y;
int main()
{
	cin>>a;
	n=strlen(a);
	for(int i=0;i<n;i++)
		if(a[i]=='C')
		{
			x=i;
			break;
		}
	if(x==-1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=x+1;i<n;i++)
		if(a[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = 1e9 + 7;

int n, m, k, x, y, v;
int dat[3000][3000];
long long dp[3000][3000][4];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> m >> k;
	for (int i = 0; i < k; i++) {
		cin >> x >> y >> v;
		x--; y--;
		dat[x][y] = v;
	}
	for (int r = 1; r < 4; r++)
		dp[0][0][r] = dat[0][0];
	for (int j = 1; j < m; j++) {
		for (int r = 1; r < 4; r++) {
			dp[0][j][r] = max(dp[0][j - 1][r - 1] + dat[0][j], dp[0][j - 1][r]);
		}
	}
	for (int i = 1; i < n; i++) {
		for (int r = 0; r < 4; r++) {
			dp[i][0][0] = max(dp[i][0][0], dp[i - 1][0][r]);
			dp[i][0][1] = max(dp[i][0][1], dp[i - 1][0][r] + dat[i][0]);
			dp[i][0][2] = max(dp[i][0][2], dp[i - 1][0][r] + dat[i][0]);
			dp[i][0][3] = max(dp[i][0][3], dp[i - 1][0][r] + dat[i][0]);
		}
	}
	for (int i = 1; i < n; i++) {
		for (int j = 1; j < m; j++) {
			dp[i][j][0] = dp[i][j - 1][0];
			for (int r = 0; r < 4; r++) {
				dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][r]);
			}
			dp[i][j][1] = max(dp[i][j - 1][0] + dat[i][j], dp[i][j - 1][1]);
			dp[i][j][2] = max(dp[i][j - 1][1] + dat[i][j], dp[i][j - 1][2]);
			dp[i][j][3] = max(dp[i][j - 1][2] + dat[i][j], dp[i][j - 1][3]);
			for (int r = 0; r < 4; r++) {
				dp[i][j][1] = max(dp[i][j][1], dp[i - 1][j][r] + dat[i][j]);
				dp[i][j][2] = max(dp[i][j][2], dp[i - 1][j][r] + dat[i][j]);
				dp[i][j][3] = max(dp[i][j][3], dp[i - 1][j][r] + dat[i][j]);
			}
		}
	}
	long long ans = 0;
	for (int r = 0; r < 4; r++) {
		ans = max(ans, dp[n - 1][m - 1][r]);
	}
	cout << ans << E;
	//system("pause");
	return 0;
}

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

int main() {
  int n,m,k;
  while(cin >> n >> m >> k && (n||m||k)) {
    int price=0,a=0;
    for(int i=1; i<=n; i++) {
      int x;
      cin >> x;
      price+=x*100;
      if(i==m) a=x;
    }
    price-=price*k/100;
    if(a) cout << price/a << endl;
    else cout << 0 << endl;
  }
  return 0;
}


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

class Main {

	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		long[] a = new long[n];
		for (int i = 0; i < n; i++) {
			a[i] = scanner.nextLong();
		}
		Arrays.sort(a);
		int ans = 1;
		long o = a[0];
		for (int i = 1; i < n; i++) {
			long b= a[i]%2;
				if (o>=(a[i]/2+b)){
					ans++;
					o+=a[i];
			}else{
				ans = 1;
				o+=a[i];
			}

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

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

using namespace std;
using ll = long long;

int main() {
	string S;
	vector<int> rl;
	int tmp = 0;
	int ans;
	cin >> S;
	
	for(int i=0; i<S.length()-1; i++) {
		if (S[i] == 'R' && S[i+1] == 'L') {
			rl.push_back(i);
		}
	}
	//for(int i=0; i<rl.size(); i++) cout << rl[i] << endl;
	vector<int> mass(S.length(), 0);
	
	auto itr = rl.begin();
	for(int i=0; i<S.length(); i++) {
		ans = *itr + abs(*itr - i) % 2;
		mass[ans]++;
		//printf("[%d] %d\n", i, ans);
		if(i < S.length()-1 && S[i] == 'L' && S[i+1] == 'R') {
			itr++;
		}
	}
	
	for(int i=0; i<mass.size(); i++) {
		printf("%d ", mass[i]);
	}
	
	return 0;
}


Measured memory_bytes: 1280
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=1e5+2;
int cnt[N],pref[N],query[N];
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,sz,q;
	cin>>n>>q;
	sz=0;
	query[1]=n;
	sz++;
	for(i=1;i<=q;i++){
		cin>>query[++sz];
		while(sz>1&&query[sz]<=query[sz-1]){
			query[sz-1]=query[sz];
			query[sz]=0;
			sz--;
		}
	}
	cnt[sz]=1;
	for(i=sz;i>=1;i--){
		j=query[i];
		while(true){
			k=upper_bound(query+1,query+i,j)-query-1;
			if(!k){
				break;
			}
			cnt[k]+=cnt[i]*(j/query[k]);
			j=j%query[k];
		}
		pref[j]+=cnt[i];
	}
	for(i=n;i>0;i--){
		pref[i]+=pref[i+1];
	}
	for(i=1;i<=n;i++){
		cout<<pref[i]<<'\n';
	}
}

Measured memory_bytes: 5964
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  long long int n;
  cin>>n;
  string s="";
  
  while(n){
    if(n%2){
      n--;
      s='1'+s;
    }
    else {
      s='0'+s;
    }
    
    n/=-2;
 
  }
  if(s=="")
    cout<<0;
  cout<<s<<endl;
  return 0;

}

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

int main(void) {
	int K, S;
	cin >> K >> S;
	int ans = 0;
	for (int X = 0; X <= K; X++) {
		for (int Y = 0; Y <= K; Y++) {
			if ((S - (X + Y)) <= K && (S-(X+Y)) >= 0) ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let n = read::<usize>();
    let mut a = read_vec::<i64>();
    let mut ans = 0;
    for i in 1..n {
        if a[i] < a[i - 1] {
            ans += a[i - 1] - a[i];
            a[i] = a[i - 1];
        }
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 6496
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int> A(N + 2), cost(N + 2);

	A[N + 1] = A[0] = cost[0] = 0;
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
		cost[i] = cost[i - 1] + abs(A[i] - A[i - 1]);
	}
	cost[N + 1] = cost[N] + abs(A[N]);

	for (int i = 1; i <= N; i++) {
		int ans;
		ans = cost[i - 1] + abs(A[i - 1] - A[i + 1])
			+ cost[N + 1] - cost[i + 1];
		cout << ans << endl;
	}

	return 0;
}

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

using namespace std;

int main()
{
    size_t N;
    vector<size_t> a;

    cin >> N;
    a.resize(N+1);
    for(size_t i = 0; i <= N; ++i)
    {
        cin >> a[i];    
    }

    vector<size_t> b(N+1, 0);

    // 0 での初期化
    if(a[0] >= 2)
    {
        cout << "-1" << endl;
        return 0;    
    }
    b[0] = 1 - a[0];    
    
    for(size_t i = 1; i <= N; ++i)
    {
        if( a[i] > 2*b[i-1])
        {
            cout << "-1" << endl;
            return 0;    
        }

        size_t s = 2 * b[i-1] - a[i];
        size_t t = 0;
        for(size_t j = i+1; j <= N; ++j)    
        {
            t += a[j];
        }
        
        b[i] =  (s < t) ? s : t;
        if(b[i-1] > a[i] + b[i])
        {
            cout << "-1" << endl;
            return 0;    
        }
    }

    size_t total = 0;
    for(size_t i = 0; i <= N; ++i)
    {
        total += b[i] + a[i];
    }

    cout << total << endl;
    return 0;    
    
}

Measured memory_bytes: 4844
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))

cnt = 0

for i in range(n):
    if a[i] < b[i]:
        cnt += (b[i] - a[i]) // 2
    else:
        cnt -= (a[i] - b[i])

print("Yes" if cnt >= 0 else "No")


Measured memory_bytes: 40560
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		while (true){
			try{
				String uketori=br.readLine();
				StringTokenizer st=new StringTokenizer(uketori," ");
				int[] a=new int[3];
				int[] b=new int[3];
				int i=0;
				while (st.hasMoreTokens()) {
					if(i<3)a[i]=Integer.parseInt(st.nextToken());
					else b[i-3]=Integer.parseInt(st.nextToken());
					i++;
				}
				i=0;


				int[] c=renh3(a,b,0);
				int[] d=renh3(a,b,1);

				float y_ans=((float)c[2])/((float)c[1]);
				float x_ans=((float)d[2])/((float)d[0]);

				if( x_ans == -0.0 )
					x_ans = 0.0f;
				if( y_ans == -0.0 )
					y_ans = 0.0f;
				System.out.println((String.format("%4.3f",x_ans))+" "+(String.format("%4.3f",y_ans)));
			}

			catch(Exception e){
				System.exit(0);
			}
		}
	}

	public static int[] renh3(int[] a,int[] b,int c){		//c 0=a 1=b 2=c 3=d 4=e 5=sum
		int[] res=new int[3];
		int mltp_a=b[c];
		int mltp_b=a[c];

		for(int i=0; i<3; i++){
			res[i]=a[i]*mltp_a-b[i]*mltp_b;
		}
		return res;

	}
}

Measured memory_bytes: 24604
import sys

def warshall_floyd(v_count, matrix):
    for i in range(v_count):
        for j, c2 in enumerate(matrix[j][i] for j in range(v_count)):
            for k, (_, c3) in filter(lambda x: x[1][0] > c2+x[1][1], enumerate(zip(matrix[j], matrix[i]))):
                matrix[j][k] = c2+c3
    return matrix


def has_negative_cycle(a) -> bool:
    return any(row[i] < 0 for i, row in enumerate(a))


V, E = map(int, input().split())
inf = float("inf")
matrix = [[inf]*V for _ in [0]*V]
for i in range(V):
    matrix[i][i] = 0
for s, t, d in (map(int, l.split()) for l in sys.stdin):
    matrix[s][t] = d
warshall_floyd(V, matrix)
if has_negative_cycle(matrix):
    print("NEGATIVE CYCLE")
else:
    for row in matrix:
        print(" ".join(map(lambda n: str(n) if n!=inf else "INF", row)))


Measured memory_bytes: 6236
#include<bits/stdc++.h>
using namespace std;
const int maxx=1e5+2;
typedef long long ll;
vector<int> a[maxx];
priority_queue<int> q;
int main(){
    int n,m; cin>>n>>m;
    for(int i=1;i<=n;i++){
        int x,y; scanf("%d%d",&x,&y);
        a[x].push_back(y);
    }
    ll ans=0;
    for(int i=1;i<=m;i++){
        for(auto x:a[i]){
            q.push(x);
        }
        if(!q.empty()){
            ans+=q.top(); q.pop();
        }
    }
    cout<<ans<<endl;
}


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


int main(){
    int ans;cin>>ans;
    bool isEnd = false;

    while(1){
        if(ans == 2){
            break;
        }else if(ans%2==0){
            ans++;
            continue;
        }

        for(int i=2;i<ans;i++){
            if(ans % i == 0) break;
            if(i == ans-1) isEnd = true;
            //cout << ans << endl;
        }
        
        if(isEnd) break;

        ans++;

        
    }

    cout << ans << endl;
}

Measured memory_bytes: 3600
import java.util.*;

class Main{
    static int[] nums = new int[3];
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int num = sc.nextInt();
        
        int cnt = 0;
        for(int i = 0; i < num; i++){
            next();
            nums[0] = sc.nextInt();
            if(i > 1){
                if(nums[1] == median3()){
                    ++cnt;
                }
            }
        }
        System.out.println(cnt);
    }

    public static int median3(){
        int[] tmpArr = {nums[0], nums[1], nums[2]};
        Arrays.sort(tmpArr);
        return tmpArr[1];
    }

    public static void next(){
        nums[2] = nums[1];
        nums[1] = nums[0];
    }
}


Measured memory_bytes: 23764
S = gets.chomp

odd = ['R', 'U', 'D']
even = ['L', 'U', 'D']

easy = 1
S.each_char.with_index do |string, index|
  if (index % 2).zero?
    if odd.index(string).nil?
      easy = 0
      break
    end
  elsif even.index(string).nil?
    easy = 0
    break
  end
end

puts easy.zero? ? 'No' : 'Yes'

Measured memory_bytes: 3836
n=int(input())
a=[int(i) for i in input().split()]
ans=0
d={}
for i in a:
    if i-1 in d:
        d[i-1]+=1
    else:
        d[i-1]=1
    if d[i-1]>ans: ans=d[i-1]
    if i in d:
        d[i]+=1
    else:
        d[i]=1
    if d[i]>ans: ans=d[i]
    if i+1 in d:
        d[i+1]+=1
    else:
        d[i+1]=1
    if d[i+1]>ans: ans=d[i+1]
print(ans)

Measured memory_bytes: 19724
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>

using namespace std;

bool IsPrime[1000000];
vector<int> Prime;
void PrimeCalc()
{
	memset(IsPrime, 1, sizeof(IsPrime));
	IsPrime[0] = IsPrime[1] = false;
	for(int i = 2; i < 1000000; ++i)
	{
		if(IsPrime[i])
		{
			Prime.push_back(i);
			for(int j = 2 * i; j < 1000000; j += i)
			{
				IsPrime[j] = false;
			}
		}
	}
}

void solve()
{
	PrimeCalc();
	int N, P;
	while(cin >> N >> P)
	{
		if(N == -1 && P == -1)
		{
			break;
		}
		int pos = 0;
		while(Prime[pos] <= N)
		{
			++pos;
		}
		vector<int> Vec;
		for(int i = 0; i < 100; ++i)
		{
			for(int j = i; j < 100; ++j)
			{
				Vec.push_back(Prime[pos + i] + Prime[pos + j]);
			}
		}
		sort(Vec.begin(), Vec.end());
		cout << Vec[P - 1] << endl;
	}
}

int main()
{
	solve();
	return(0);
}

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

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

######Factorization######
def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])
    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])
    return arr

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

S = list(inputS())
N = len(S)

r = []
for i in range(N)[::-1]:
  n = int(S[i])
  if r == []:
    r.append(n)
  else:
    r.append((r[-1]+n*pow(10,N-i-1,2019))%2019)

import collections

c = collections.Counter(r)

res = 0
for i in c.items():
  res += i[1]*(i[1]-1)/2
  if i[0]==0:
    res += i[1]

print(int(res))

Measured memory_bytes: 93256
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;



int main(){
  int a,b,c;
  cin >> a>>b >>c;
  int ans=0;
  if(a*c<=b){cout << c << endl;}else{cout << b/a << endl;}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <chrono>
#include <regex>
using namespace std;
#define len(_x) (sizeof((_x)) / sizeof(_x)[0])
#define ll long long
#define fastIO  ios_base::sync_with_stdio(false); cin.tie(0); 
#define Ichar(_x) char _x=_getchar_nolock();
#define Iint(_x) int _x;scanf("%d",&_x); 
#define Ill(_x)  ll _x;scanf("%lld",&_x);
#define inc(a,b,x)(x)>=a && (x)<=b	
#define incE(a,b,x)(x)>=a && (x)<=b	
#define fileIO 	freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
//#define DEBUG


ll modo(ll a)
{
	return a % (int)(1e9+7);
}

int main()
{
	Iint(n);
	std::cout << n/3;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << x << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){return o<<"("<<p.fs<<","<<p.sc<<")";}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){o<<"sz = "<<vc.size()<<endl<<"[";for(const T& v:vc) o<<v<<",";o<<"]";return o;}
typedef long long ll;
int N;
ll a[300000];
int main(){
	cin>>N;
	rep(i,3*N) cin>>a[i];
	sort(a,a+3*N);
	ll ans=0;
	rep(i,N) ans+=a[3*N-2-2*i];
	cout<<ans<<endl;
}


Measured memory_bytes: 2560
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
int ans=0;
rep(i,0,n/2-1)
{
	if(s[i]!=s[n-1-i])ans++;
}
ol(ans);
return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
int bubbleSort(int *a, int n);
int main(int argc, char** argv) {
    int number;
    int readScan = scanf("%d", &number);
    int array[number];
    for(int i = 0; i< number; i++)
    {
        int reasScan = scanf("%d", &array[i]);
    }
    int count;
    count = bubbleSort(array, number);
    for(int i= 0; i< number; i++)
    {    
        if(i<number-1)
        {
            printf("%d ", array[i]);
        }
        if(i==number-1)
        {
               printf("%d", array[i]);
        }
    }
    printf("\n");
   
    printf("%d\n", count);
    return (EXIT_SUCCESS);
}

int bubbleSort(int *a, int n)
{
    int b;
    int count = 0;
	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < n-i-1; j++)
		{
			if (a[j]>a[j+1])
			{
                            b = a[j];
                            a[j] = a[j+1];
                            a[j+1] =b;
                            count++;
			}
                      
		}
	}
    return count;
}


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

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

//------------------------------------------------------

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

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

    rep(i, n - 1) {
        ll t;
        cin >> t;
        time = time / gcd(t, time) * t;
    }

    cout << time << endl;

    return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main()
{
	char s[128];
	int now;
	
	while (scanf("%s", s) && s[0] != '#'){
		now = 'A';
		
		for (int i = 0; s[i] != '\0'; i++){
			switch (now){
				case 'A':
					if (s[i] == '0'){
						now = 'X';
					}
					else {
						now = 'Y';
					}

					break;
				
				case 'X':
					if (s[i] == '1'){
						now = 'Z';
					}
					else now = -1;
					break;
				
				case 'Y':
					if (s[i] == '0'){
						now = 'X';
					}
					else now = -1;
					break;
				
				case 'Z':
					if (s[i] == '0'){
						now = 'W';
					}
					else {
						now = 'B';
					}
					break;
				
				case 'W':
					if (s[i] == '0'){
						now = 'B';
					}
					else {
						now = 'Y';
					}
					break;
				
				case 'B':
					if (s[i] == '0'){
						now = 'Y';
					}
					else {
						now = 'X';
					}
					break;
			}
		}
		
		if (now == 'B'){
			printf("Yes\n");
		}
		else printf("No\n");
	}
	
	return (0);
}

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

using namespace std;

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	if (N <= K) {
		cout << N*X << endl;
	}
	else {
		cout << K*X + (N - K)*Y << endl;
	}

	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		for(int i=0;i<=N;i++){
			for(int j=0;j<=N;j++){
				int k = N - i - j;
				if(k < 0) continue;
				if(10000 * i + 5000 * j + 1000 * k == Y){
					Console.WriteLine("{0} {1} {2}",i,j,k);
					return;
				}
			}
		}
		
		Console.WriteLine("{0} {1} {2}",-1,-1,-1);
		
		
	}
	int N;
	long Y;
	public Sol(){
		var d = ria();
		N = d[0]; Y = d[1];
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
#define MOD 1000000007
#define INF 1000000007
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define req(i, j, n) for(int i = j; i <= (int)(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}



int main() {
ll n;
  cin>>n;
  ll val[n+1];
  ll dis[n];
  for(int i=1;i<=n;i++){
    val[i]=0;
    cin>>val[i];}
  for(int i=1;i<=n-1;i++){
    dis[i]=val[i+1]-val[i];
  }
  
  ll ans=0;
  
  ll kai[n+2];
  kai[1]=1;
  kai[2]=2;
  for(int i=3;i<=n+1;i++){
    ll p=i;
    kai[i]=0;
    kai[i]=kai[i-1]*p;
    kai[i]%=MOD;}
  
  ll ba[n+1];
  ll wa[n+1];
  ll mae[n+1];
  
  for(int i=0;i<=n;i++){
    ba[i]=0;
    wa[i]=0;
    mae[i]=0;}
  
  
  ba[1]=kai[n-1];
  ba[1]%=MOD;
  mae[1]=ba[1];
  wa[1]=ba[1];
  ba[2]=3*kai[n-1];
  ba[2]=ba[2]*modinv(2, MOD);
  ba[2]%=MOD;
  mae[2]=ba[2]*2;
  mae[2]%=MOD;
  wa[2]=wa[1]+ba[2];
  wa[2]%=MOD;
  for(int i=3;i<=n-1;i++){
    ll p=i;
    ba[i]=wa[i-1]*modinv(p, MOD)+kai[n-1];
    ba[i]%=MOD;
    mae[i]=kai[i]*p;
    mae[i]%=MOD;
    wa[i]=wa[i-1]+ba[i];
    wa[i]%=MOD;
  }
  
  for(int i=1;i<=n-1;i++){
    ans+=ba[i]*dis[i];
    ans%=MOD;
  }
 
  
  cout<<ans<<endl;
  
  
  
  
  
  
  

}


Measured memory_bytes: 4992
#include <stdio.h>

int main()
{
  int N, i, j, A[100], minj, a, c = 0;
  

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

  for(i = 0; i <= N - 1; i++){
    minj = i;
    for(j = i; j <= N - 1; j++){
      if(A[j] < A[minj]) {
	minj = j;
      }
    }
    a = A[i];
    A[i] = A[minj];
    A[minj] = a;
    if(i != minj)   c++;
  }
  
  for(i = 0; i < N; i++){
    printf("%d", A[i]);
    if(i != N - 1) printf(" ");
  }
  printf("\n%d\n", c);
  return 0;
}

Measured memory_bytes: 604
#include<bits/stdc++.h>
#define faster_io ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define mem(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define ll long long
#define pb push_back
#define pll pair<ll, ll>
using namespace std;
const ll N = 1e6 + 7, M = 1e5 + 7, mod = 998244353, inf = 1e18 + 7;
ll tc, n, m, q, a, b, c, d, i, j, k, ans;
//ll ar[N];
string s;
vector < ll > vec;
map <string, ll> mp;

int main()
{
    faster_io;
    cin >> n;
    ll sum = 0;
    while(n--)
    {
        cin >> s >> m;
        sum += m;
        mp[s] = sum;
    }
    cin >> s;
    cout << sum - mp[s] << endl;
}


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

using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) ll(x.size())
typedef long long ll;
//typedef pair<int, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
//const ll INF = 10e15;
const ll MINF = -10e10;
const int INF = INT_MAX;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)


//ifstream myfile("~/Downloads/02.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);

typedef priority_queue<P, vector<P>, greater<P>> PQ_ASK;
const int mod = 1000000007;


int main() {

    int n;
    cin >> n;


    ll ans = 0;
    rep(i,  n){
        ll l, r;
        cin >> l >> r;

        ans += r - l + 1;

    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=1; i<=(int)(n); i++)
#define pb push_back
#define all(v) v.begin(),v.end()
#define fi first
#define se second
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<string> vs;
typedef vector<char> vc;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int K,S;
    cin>>K>>S;
    int counter=0;
    for(int i=0; i<=K; i++) {
        for(int j=0; j<=K; j++) {
            int z=S-i-j;
            if(0<=z&&z<=K) counter++;
        }
    }
    cout<<counter<<endl;
}

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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

// ZeroSumRange 版

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  string s; cin>>s;
  ll n=s.size();
  
  // 下位の桁から見ていき、1桁目から現在までの桁の値と mod2019 の累積和を保持する
  // 累積和が同じ値になる箇所が複数ある場合、その区間が mod2019 が0になる区間となる(ZeroSumRange)
  vll sum(n+1);
  
  // 下位の桁から見ていく
  reverse(all(s));
  // 10^(今見ている桁)を保持する
  ll x=1;
  rep(i,n){
    ll num=s[i]-'0';
    sum[i+1]=(sum[i]+num*x)%2019;
    (x*=10)%=2019;
  }
  map<ll,ll> m;
  rep(i,n+1){
    m[sum[i]]++;
  }
  
  ll ans=0;
  for(auto e: m){
    ans+=(e.second-1)*e.second/2;
    ans%=MOD;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 5000
package main

import (
	"fmt"
)

func main() {
	var nn int
	fmt.Scanf("%d", &nn)
	var aa string
	fmt.Scanf("%s", &aa)

	const zb byte = byte('Z')
	const ab byte = byte('A')
	var bb []byte = []byte(aa)
	var result []byte = []byte(aa)
	for ii := 0; ii < len(bb); ii++ {
		cc := bb[ii] + byte(nn)
		if cc > zb {
			cc = cc - zb + ab - 1
		}
		result[ii] = cc
	}

	resultString := string(result)
	// fmt.Fprintf(os.Stderr, "%s\n", resultString)
	fmt.Printf("%s\n", resultString)
}


Measured memory_bytes: 768
#include <cstdio>
#include <vector>
#include <algorithm>

using int64 = long long;

const int mod = 1e9 + 7;

int64 pow_mod(int64 a, int64 n) {
  int64 r = 1;
  for (; n; n >>= 1) {
    if (n & 1) r = r * a % mod;
    a = a * a % mod;
  }
  return r;
}

int main() {
  int n, x, y;
  scanf("%d%d%d", &n, &x, &y);
  std::vector<std::vector<int>> c(n);
  for (int i = 0; i < n; ++i) {
    int a, b;
    scanf("%d%d", &a, &b);
    c[a - 1].push_back(b);
  }
  for (int i = 0; i < n; ++i) {
    std::sort(c[i].begin(), c[i].end());
  }
  std::sort(c.begin(), c.end(), [](const std::vector<int> &a, const std::vector<int> &b) {
    if (a.empty()) return false;
    if (b.empty()) return true;
    return a[0] < b[0];
  });
  while (c.back().empty()) c.pop_back();
  n = c.size();
  std::vector<int> ca(n), cb(n);
  int m = 0;
  for (int i = 0; i < n; ++i) {
    int a = 0, b = 0;
    while (a < c[i].size() && c[i][0] + c[i][a] <= x) ++a;
    if (i) {
      while (b < c[i].size() && c[0][0] + c[i][b] <= y) ++b;
    } else if (n > 1) {
      while (b < c[i].size() && c[1][0] + c[i][b] <= y) ++b;
    }
    ca[i] = a, cb[i] = b;
    if (b) m = i;
  }
  n = 0;
  for (int i = 0; i <= m; ++i) n += std::max(ca[i], cb[i]);
  std::vector<int64> fac(n + 1, 1), ifac(n + 1, 1);
  for (int i = 1; i <= n; ++i) {
    fac[i] = fac[i - 1] * i % mod;
    ifac[i] = pow_mod(fac[i], mod - 2);
  }
  int64 ret = fac[n];
  for (int i = 0; i <= m; ++i) {
    ret = ret * ifac[std::max(ca[i], cb[i])] % mod;
  }
  printf("%lld\n", ret);
  return 0;
}


Measured memory_bytes: 12928
#include <stdio.h>
int main ()
{
  int i,j,v,N,k;
  scanf("%d",&N);
  int A[N];
  for(i = 0;i < N;i++)
    {
      scanf("%d",&A[i]);
    }
  for(i = 0;i < N;i++)
    {
      printf("%d",A[i]);
      if(i != N -1)
	     {
	       printf(" ");
	     }
    }
  printf("\n");
  for(i = 1;i <= N-1;i++)
    {      
      v = A[i];
      j = i - 1;
      while(j >= 0 && A[j] > v)
	{
	  A[j + 1] = A[j];
	  j--;
	}
      A[j + 1] = v;
       for(k = 0;k < N;k++)
	 {
	   printf("%d",A[k]);
	   if(k != N -1)
	     {
	       printf(" ");
	     }
	 }
       printf("\n");
    }
  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define ALL(i) i.begin(),i.end()
#define SZ(i) ll(i.size())
#define MEM(i,n) memset(i,(n),sizeof(i))
#define X first
#define Y second
#define eb emplace_back
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);_do(__VA_ARGS__);
template <typename T> void _do(T &&x){cerr<<x<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define debug(...)
#define endl '\n'
#endif

const ll INF = 0x3f3f3f3f3f3f3f3f;
ll n,m;
ll x[100003],d[100003];
int main () {
	IOS();
	cin >> n >> m;
	REP (i,m) {
		cin >> x[i];
	}
	sort(x,x+m);
	REP1 (i,m-1) {
		d[i-1] = x[i] - x[i-1];
	}
	
	sort(d,d+m-1);
	
	ll ans = 0;
	
	REP (i,m-n) {
		ans += d[i];
	}
	
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
s = input()
t = input()
ratio = []
cnt = 0
if len(s) == len(t):
    for i in range(len(t)):
        if s[i] == t[i]:
            cnt += 1
    ratio.append(cnt)
else:
    for k in range(len(s) - len(t)):
        for i in range(len(t)):
            if s[i + k] == t[i]:
                cnt += 1
        ratio.append(cnt)
        cnt = 0
res = len(t) - max(ratio)
print(res)

Measured memory_bytes: 9088
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
using namespace std;

int main()
{
	int S,ans=2;
	vector<bool> num(10000,1);
	cin>>S;
	num.at(S-1)=0;
	while(true){
		if(S%2==0){
			S/=2;
		}else{
			S=3*S+1;
		}
		if(num.at(S-1)){
			num.at(S-1)=0;
		}else{
			break;
		}
		ans++;
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

const int N = 1234567;
const int mod = (int) 1e9 + 7;

int h, w, a, b;
int fact[N], ifact[N];

int add(int a, int b) {
  int ret = a + b;
  if (ret >= mod) ret -= mod;
  return ret;
}

int mul(int a, int b) {
  return (long long) a * b % mod;
}

int c(int n, int k) {
  if (n < k) return 0;
  if (n < 0) return 0;
  int ret = fact[n];
  ret = mul(ret, ifact[n - k]);
  ret = mul(ret, ifact[k]);
  return ret;
}

int power(int x, int e) {
  int ret = 1;
  int res = x;
  while (e) {
    if (e & 1) ret = mul(ret, res);
    res = mul(res, res);
    e >>= 1;
  }
  return ret;
}

int inv(int x) {
  return power(x, mod - 2);
}

int solve() {
  int ret = 0;
  for (int i = b; i < w; i++) {
    int xw = i;
    int xh = h - a - (i + 1 - b);
    int x = c(xh + xw, xw);
    int yw = w - i - 1;
    int yh = a + i - b;
    int y = c(yh + yw, yw);
    ret = add(ret, mul(x, y));
  }
  return ret;
}

int main() {
  scanf("%d %d %d %d", &h, &w, &a, &b);
  fact[0] = 1;
  ifact[0] = 1;
  for (int i = 1; i < N; i++) fact[i] = mul(i, fact[i - 1]);
  for (int i = 1; i < N; i++) ifact[i] = mul(inv(i), ifact[i - 1]);
  int ans = solve();
  printf("%d\n", ans);
  return 0;
}

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

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

Measured memory_bytes: 256
use std::str::FromStr;
use std::fmt::Debug;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let x : Vec<u32> = read_line();
    if x[0] == x[1] && x[1] == x[2] {
        print!("Yes");
    } else {
        print!("No");
    }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll arr[120];
ll KK1(ll n, ll r)
{
    ll C[r+1];
    memset(C, 0, sizeof(C));
    C[0] = 1;
    for (ll i = 1; i <= n; i++)
    {
        for (ll j = min(i, r); j > 0; j--)
            C[j] = (C[j] + C[j-1]);
    }
    return C[r];
}
/*
ll KK2(ll n, ll m)
{
	ll ans=1;
	for(int i=1;i<=m;i++)
	{
		ans=ans/i*(n-m+i);
	}
	return ans;
}
*/
int main()
{
    ll tot=0;
    long double ans=0,sum=0,cnt=0;
    map<ll,int>N,R;
    int n,a,b;
    cin>>n>>a>>b;
    for(int i=0; i<n; i++){
       	cin>>arr[i];
		N[arr[i]]++;
	}
    sort(arr,arr+n);
    ll last ;
    for(int i=n-1; i>=0; i--)
    {
        sum+=arr[i];
        R[arr[i]]++;
        cnt++;
        if(cnt>b) break;
        if(cnt==a)
        {
            last = arr[n-1];
            ans=sum/cnt;
        }
        if(cnt>=a)
        {
            if(cnt==a)	tot+=KK1(N[arr[i]],R[arr[i]]);
            else if(arr[i]==last)	tot+=KK1(N[arr[i]],R[arr[i]]);
            //cout<<arr[i]<<"----------------"<<cnt<<"-------------"<<tot<<endl;
        }
    }
        cout<<setprecision(6)<<fixed<<ans<<endl;
        cout<<tot<<endl;
        return 0;
    }


Measured memory_bytes: 3752
#include <iostream>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <vector>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <queue>
#include <cmath>
#include <cstdio>
using namespace std;
int main(){
int x;
cin>>x;
if(x<1200)
cout<<"ABC";
else
cout<<"ARC";
system("pause");
return 0;
}

Measured memory_bytes: 504
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
#include <iomanip>
#include <stack>
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define vint vector<int>
#define vdbl vector<double>
#define vstr vector<string>
#define push_back pb
using namespace std;

#include<map>
#include<set>
#include<queue>

typedef long long ll;
typedef unsigned long long ull;

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

	ll N;
	cin >> N;

	ll A[N];
	rep(i,N) cin >> A[i];

	ll L[N];
	stack<ll> st;
	rep(i,N){
		while(st.size() && A[st.top()] >= A[i]) st.pop();
		if(st.size()) L[i] = st.top();
		else L[i] = -1;
		st.push(i);
	}

	ll R[N];
	st = stack<ll>();
	rrep(i,N){
		while(st.size() && A[st.top()] > A[i]) st.pop();
		if(st.size()) R[i] = st.top();
		else R[i] = N;
		st.push(i);
	}
	
	ll ans = 0;
	rep(i,N){
		
		ans += A[i] * (i-L[i]) * (R[i]-i);
	}

	cout << ans << endl;
}

Measured memory_bytes: 6656
fun main(args:Array<String>){
    val strS = readLine()!!
    for(i in 0..strS.length-1 step 2){
        if(strS[i] == 'L'){
            print("No")
            return
        }
    }
    for(j in 1..strS.length-1 step 2){
        if(strS[j] == 'R'){
            print("No")
            return
        }
    }
    print("Yes")
}

Measured memory_bytes: 34872
#include <iostream>
using namespace std;
long long a[100001];
int f(int l1,int r1){
	int j,k,r,l,m;
	l=l1;r=r1;
	m=(a[l]+a[r])/2;
	while(l<=r){
		while(a[l]<m) l++;
		while(a[r]>m) r--;
		if(l<=r){
			swap(a[l],a[r]);
			l++;r--;
		}
	}
	if(l1<r) f(l1,r);
	if(l<r1) f(l,r1);
}
int main(){
	long long i,j,k,n,ans=0;
	cin>>n;
	for(i=1;i<=n;i++) cin>>a[i];
	f(1,n);
	for(i=1;i<n;i++) if(a[i]==a[i+1]) a[i]=0,a[i+1]=0;
	for(i=1;i<=n;i++) if(a[i]>0) ans++;
	cout<<ans<<endl; 
} 

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

int main() {
  int n; cin >>n;
  int count=0;
  long long sum=0;
  for(int i=1;i<=n;i++){
    count++;
    sum+=i;
    if(sum>=n)break;
  }
  cout<<count<<endl;
  return 0;
}

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

// どのボタンが光るかを順にシミュレートしていく
// 「いつまで経ってもボタン2が光らない」ことを有限回のシミュレートでは確かめられない
// N回ボタンを押してもボタン2が光らなかったとき，その間にN+1回いずれかのボタンが光るので
// そのうちある2つは同じボタンのはずで，同じボタンが光った状態から光っているボタンを押し続けても
// ボタンの光る順番は周期的になるはず．よって永遠にボタン2は光らないと言える．

int main() {
    int n; cin >> n;
    vector<int> a(n+1, 0);
    for (int i = 1; i <= n; i++) {
        cin >> a.at(i);
    }
    int lighting = 1;
    int cnt = 0;
    while (1) {
        if (lighting == 2) {
            cout << cnt << endl;
            break;
        }
        if (n <= cnt) {
            cout << -1 << endl;
            return 0;
        }
        cnt++;
        lighting = a.at(lighting);
    }
    return 0;
}


Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<ll> v(3, 0);
	rep(i, n){
		char now = s[i];
		if(now == 'R') v.at(0)++;
		else if(now == 'G') v.at(1)++;
		else v.at(2)++;
	}
	ll ans = v.at(0)*v.at(1)*v.at(2);
	rep(i, n-1)rep2(j, i+1, n){
		if(s.at(i) == s.at(j)) continue;
		int nxi = i + 2*(j - i);
		if(nxi >= n) continue;
		if(s.at(i) != s.at(nxi) && s.at(j) != s.at(nxi)) ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const double PI=3.14159265358979323846;
const int64_t waru = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x))
#define vec1(a,n) vector<in> a(n);rep(i,n)cin>>a[i]
vector<char> ci={'0','1','2','3','4','5','6','7','8','9'};

int cii(char x){
rep(i,10) if(ci[i]==x) return i;
}

int nC2(int n){
  int ret=n*(n-1)/2;
  return ret;
}

int cnt1(int x,string n){
 int ret= 9*(x-1)+cii(n.at(0));
  return ret;
}

int cnt2(int x,string n){
  int ret=(x-2)*(x-1)/2*81+9*(cii(n[0])-1)*(x-1);
  if(x==1) return ret;
  while(n.size()>=1){
    n =n.substr(1);
    x=n.size();
    if(n[0]!='0') break;
  }
  if(x==0) return ret;
  ret += cnt1(x,n);
  return ret;
}

int cnt3(int x,string n){
   int ret= 0;
  for(int i=2;i<=x-2;i++){
     ret += 9*9*9*nC2(i);
  }
  ret += (cii(n[0])-1)*nC2(x-1)*81;
  while(n.size()>=1){
    n =n.substr(1);
    x=n.size();
    if(n[0]!='0') break;
  }
  if(x<=2) return ret;
  ret += cnt2(x,n);
  return ret;
}


int main(){
string n;
  int k;
  cin>>n>>k;
int x =n.size();
  
if(k==1)
 cout<<cnt1(x,n)<<endl;
  
if(k==2)
   cout<<cnt2(x,n)<<endl;
  
if(k==3)
 cout<<cnt3(x,n)<<endl;
  
}


Measured memory_bytes: 256
#include <stdio.h>
int main (void){
    int a,b,c;
    int max = 0;
    int ans = 0; 
    int count = 0;
    scanf("%d %d %d",&a,&b,&c);
    max = a;
    if(max <b) max = b;
    if(max <c) max = c;

    if(a != max){
        ans += a;
    }else{
        count++;
    }

    if(b != max || count > 0){
        ans += b;
    }else{
        count++;
    }

    if(c != max || count > 0){
        ans += c;
    }else{
        count++;
    }
    printf("%d\n",ans);
    //printf("%d\n",count);
    return 0;
}

Measured memory_bytes: 128
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from scipy.sparse.csgraph import floyd_warshall
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations, combinations_with_replacement
from heapq import heappop, heappush, heapify
from fractions import gcd
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

def main():
    s = input()
    print(s[:3])
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 10784
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N,M;
vector<int> G[SIZE];
int C[SIZE]; //0:未定 1,-1:色

bool twoColor;
ll cnt[10]; //0と2


void dfs(int v,int c){
	if(C[v]==c)return; //塗られていた
	if(C[v]==(-1)*c){ //違う色になってた
		twoColor=false;
		return;
	}
	//初
	C[v]=c;
	cnt[c+1]++;
	for(int i=0;i<G[v].size();i++){
		dfs(G[v][i],(-1)*c);
	}
}


int main()
{
	scanf("%d%d",&N,&M);
	int a,b;
	for(int i=0;i<M;i++){
		scanf("%d%d",&a,&b);
		G[a].push_back(b);
		G[b].push_back(a);
	}
	twoColor=true;
	dfs(1,1);
	ll ans = 0;
	ll lN = (ll)N;
	if(twoColor){ //二部グラフ
		ans += cnt[0]*cnt[2] - M;
	}else{
		ans += lN*(lN-1)/2 - M;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 9216
#include <fstream>
#include <iostream>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;

int main() {
  int a[4], b[4];
  while (cin >> a[0] >> a[1] >> a[2] >> a[3]) {
    cin >> b[0] >> b[1] >> b[2] >> b[3];
    int hit = 0;
    int blow = 0;
    for (int i = 0; i < 4; i++) {
      if (a[i] == b[i]) hit++;
    }
    for (int i = 0; i < 4; i++) {
      if (find(a, a+4, b[i]) != a+4) blow++;
    }
    blow -= hit;
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 1160
#include <iostream>

using namespace std;
int main(void)
{
	int a, b, c;
	
	cin >> a >> b >> c;
	if (a < b && b < c) {
		cout << "Yes" << "\n";
	}
	else {
		cout << "No" << "\n";
	}

	return 0;
}



Measured memory_bytes: 3080