akhauriyash/Code-Regression huggingface dataset:
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
#include <numeric>
#include <bitset>
#include <map>
#include <limits.h>

using namespace std;

/// 各桁の和
int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;    
    }
    return sum;
}
/// 最小公倍数 
int gcd(int x, int y){
      if(x<y){
          int temp = x;
          x = y;
          y = temp;
      }
      int r = x % y;
       while(r!=0){
           x = y;
           y = r;
           r = x % y;
       }
      return y;
   }



int main(){

int N;
cin >> N;
vector<int> h(N);
for(int i = 0; i < N; i++){
    cin >> h[i];
}
vector<int> H(N);
for(int i = 0; i < N; i++){
    if(i == 0){
        H[i] = h[i];
    }
    else if(h[i]  < h[i-1] ){
        H[i] = 0;
    }
    
    else{
    H[i] = h[i] - h[i-1];
}
}
cout << accumulate(H.begin(),H.end(),0) << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

class Main {

    public static void main(String[] args) throws Exception {

        try {

            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

            String[] input = br.readLine().split(" ");
            int firstCharToInt = input[0].charAt(0);
            int secondCharToInt = input[1].charAt(0);

            String result;
            if (firstCharToInt > secondCharToInt) {
                result = ">";
            } else if (firstCharToInt == secondCharToInt) {
                result = "=";
            } else {
                result = "<";
            }

            System.out.println(result);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }

    static void swap(List<String> list, int index1, int index2) {
        String tmp = list.get(index1);
        list.set(index1, list.get(index2));
        list.set(index2, tmp);
    }
}

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

using namespace std;

int N, T;

//1-idx
int dp1[3000 + 10][3000 + 10];//dp1[i][j] := [1, i]品目まで食べるかを選んで、jの時間がかかったときのおいしさの最大値 
int dp2[3000 + 10][3000 + 10];//dp2[i][j] := [i, N]品目まで食べるかを選んで、jの時間がかかったときのおいしさの最大値
vector<int> A, B;

int main() {
	cin >> N >> T;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		A.push_back(a), B.push_back(b);
	}
	
	dp1[0][0] = 0;
	for (int i = 1; i <= N; i++) {
		for (int j = 0; j <= T - 1; j++) {
			dp1[i][j] = dp1[i - 1][j];
			if (j - A[i - 1] >= 0)dp1[i][j] = max(dp1[i][j], dp1[i - 1][j - A[i - 1]] + B[i - 1]);
		}
	}

	dp2[N + 1][0] = 0;
	for (int i = N; i >= 1; i--) {
		for (int j = 0; j <= T - 1; j++) {
			dp2[i][j] = dp2[i + 1][j];
			if (j - A[i - 1] >= 0)dp2[i][j] = max(dp2[i][j], dp2[i + 1][j - A[i - 1]] + B[i - 1]);
		}
	}

	int ans = max(dp1[N][T - 1], dp2[1][T - 1]);
	for (int i = 0; i <= N - 1; i++) {
		for (int j = 0; j <= T - 1; j++) {
			ans = max(ans, dp1[i][j] + B[i] + dp2[i + 2][T - 1 - j]);
		}
	}
	cout << ans << endl;
	
	return 0;
}


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

void fast_io(){ios_base::sync_with_stdio(false); cin.tie(NULL);}
void test_here(){ freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);}

ll no_of_paths_bu(vector<vector<char> >& grid, ll r, ll c)
{
	vector< vector<ll> > dp(r+1, vector<ll>(c+1,0));

	dp[r][c]=1;

	for(ll i=r;i>=1;i--)
	{
		for(ll j=c;j>=1;j--)
		{
			if(i==r && j==c) continue;
			
			if(grid[i-1][j-1]!='.') dp[i][j]=0;
			else dp[i][j]= ((i+1<=r?dp[i+1][j]:0) + (j+1<=c?dp[i][j+1]:0))%M;			
		}
	}
	return dp[1][1];
}

void qH()
{
	ll h,w; cin>>h>>w;
	vector<vector<char> > grid(h+1, vector<char>(w+1));

	for(ll i=0;i<h;i++)
		for(ll j=0;j<w;j++) cin>>grid[i][j];
	cout<<no_of_paths_bu(grid,h,w);
/*
	vector< vector<ll> > dp(h+1, vector<ll>(w+1,-1));
	
	cout<<no_of_paths(grid,h,w,dp,0,0);*/
}


int main()
{
	//test_here();
	qH();
}


Measured memory_bytes: 12232
#include<bits/stdc++.h>
#define rep(i,n) for (int i=0; i<n; i++)
using namespace std;
int main(){
    int h,w,k;
    cin>>h>>w>>k;
    vector<string>C(h);
    rep(i,h) cin>>C[i];
    int ans = 0;
    rep(bit_a, 1<<h){
        rep(bit_b, 1<<w){
            int count = 0;
            rep (i,h){
                rep (j,w){
                     if (bit_a>>i&1) continue;
                     if (bit_b>>j&1) continue;
                     if (C[i][j] == '#') count++;
                }
            }
        	if (count == k) ans++;
        }
    }
    cout << ans;
    return 0;
}

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

int main()
{
	string s;
	cin>>s;
	
	int mod=0;
	for(int i=0;i<s.size();i++)
	{
		mod=(mod + s[i]-'0')%9;
	}
	
	if(mod==0)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#include<cctype>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
#define all(v) (v).begin(),(v).end()
typedef long long int ll;
#define pi 3.1415926535897932384
#define E9 1000000000
#define eps 1e-4
#define pii pair<int,int> 

int main(){
  int N, A, B; cin >> N >> A >> B;
  string S; cin >> S;

  int j=0, i=0;
  rep(k,N){
    if (S[k]=='a'){
      if (i+j<A+B) {
        cout << "Yes" << endl;
        j++;
      }
      else cout << "No" << endl;
    }
    else if (S[k]=='b'){
      if (i+j<A+B && i<B){
        cout << "Yes" << endl;
        i++;
      }
      else cout << "No" << endl;
    }
    else cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 896
def main():
    N = int(input())
    P = list(map(int, input().split(' ')))
    min_pj = N
    answer = 0
    for i in range(N):
        min_pj = min([min_pj, P[i]])
        if min_pj == P[i]:
            answer += 1
    print(answer)


if __name__ == '__main__':
    main()


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

int main()
{
	int R[200000];
	int n;
	int maxv, minv;
	
	cin >> n;
	for (int i = 0; i < n; i++) cin >> R[i];
	maxv = -2000000001;
	minv= R[0];
	for (int i = 1; i < n; i++) {
		maxv = max(maxv, R[i] - minv);
		minv = min(minv, R[i]);
	}
	cout <<maxv << endl;
	return 0;
}



Measured memory_bytes: 3868
S = input()

if 'N' in S:
    if 'S' not in S:
        print('No')
        exit()
if 'S' in S:
    if 'N' not in S:
        print('No')
        exit()
if 'E' in S:
    if 'W' not in S:
        print('No')
        exit()
if 'W' in S:
    if 'E' not in S:
        print('No')
        exit()

print('Yes')

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

#define all(x) (x).begin(), (x).end()
#define allp(x) (x)->begin(), (x)->end()

#define pb push_back


using namespace std;
void dout() { cerr << endl; }
typedef long long ll;
template <typename Head, typename... Tail>
void dout(Head H, Tail... T) {
    cerr << H << ' ';
    dout(T...);
}

#define debug(x) cout << #x " = " << (x) << endl


using ll = long long;
using hll = __int128;
using pii = pair<ll, ll>;
using ld = long double;
using pll = pair<long long, long long>;

template <typename T>
void do_uniq(vector<T> vec){
    sort(all(vec));
    vec.resize(unique(all(vec)) - vec.begin());
}


#ifdef _getchar_nolock
#else
#define _getchar_nolock getchar_unlocked
#endif

template <typename T>
void freadT(T &x) {
    x = 0;
    char ch = _getchar_nolock();
    ll sign = 1;

    while (!isdigit(ch)) {
        if (ch == '-')
            sign *= -1;
        ch = _getchar_nolock();
    }

    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = _getchar_nolock();
    }

    x *= sign;
}


#define solvsh
//#define multi

#ifdef solvsh

//const int MAXN = 1e2 + 2;

#define uint ll

uint ml(uint a, uint b){
    return (a*1ll * b);
}

uint add(uint a, uint b){
    return (a*1ll + b);
}

clock_t timestamp_start = clock();
void time_calc()
{
    cerr << (ld)(clock() - timestamp_start) / CLOCKS_PER_SEC << "\n";
}


void solve() {
    int n, k;
    cin >> n >> k;
    vector<ld> loggs;
    for (int i = 0; i < n; ++i) {
        int curr;
        cin >> curr;
        loggs.push_back(log(curr));
    }
    ld summ = 0;
    for (int i = 0; i < k; ++i) {
        summ += loggs[i];
    }
    for (int i = k; i < n; ++i) {
        ld curr_summ = summ + loggs[i] - loggs[i - k];
        if (curr_summ > summ) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
        summ = curr_summ;
    }
}

#else

void solve() {

}


#endif


void multisolve() {
//    prec();
    int t;
    cin >> t;

//    scanf("%d", &t);

    int i = 1;
    while (t--) {
        cout << "Case #" << (i++) << ":\n";
        solve();
//        cout << "\n";
    }
}

#define int int
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr), cout.tie(nullptr);
    cout << fixed << setprecision(20);

#ifdef multi
    multisolve();
#else
    solve();
//    gen();
#endif


}

Measured memory_bytes: 7876
/* Atcoder abc158b
 * See tasks at: https://atcoder.jp/contests/abc158/tasks/abc158_b
 */
#include <iostream>
#include <vector>
#include <algorithm>

#define until(symbol, max) for (int symbol = 0; (symbol) < (max); (symbol)++)

using namespace std;
using ll = long long;
int main()
{
    ll n, a, b;
    cin >> n >> a >> b;

    ll r = n / (a + b);
    ll ra = r * a;

    ll res;
    if (n > (r * (a + b) + a))
    {
        res = ra + a;
    }
    else
    {
        res = ra + (n - r * (a + b));
    }
    
    cout << res;

    return 0;
}


Measured memory_bytes: 256
package main

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

var (
	rdr   = bufio.NewReaderSize(os.Stdin, 1000000)
	reply string
)

func main() {
	var n, k, ans int
	fmt.Scan(&n, &k)
	h := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&h[i])
	}
	sort.Ints(h)
	for i := 0; i < n-k; i++ {
		ans += h[i]
	}
	fmt.Println(ans)
}

func readLine() string {
	buf := make([]byte, 0, 1000000)
	for {
		l, p, e := rdr.ReadLine()
		if e != nil {
			panic(e)
		}
		buf = append(buf, l...)
		if !p {
			break
		}
	}
	return string(buf)
}

func nextSlice() []string {
	return strings.Split(readLine(), " ")
}

func atoi(a []string) (b []int) {
	b = make([]int, len(a))
	for i := range a {
		b[i], _ = strconv.Atoi(a[i])
	}
	return
}

func atof(a []string) (b []float64) {
	b = make([]float64, len(a))
	for i := range a {
		b[i], _ = strconv.ParseFloat(a[i], 64)
	}
	return
}

func scanSlice2(n int) (a []int, b []int) {
	a = make([]int, n)
	b = make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

func scanFloatSlice2(n int) (a []float64, b []float64) {
	a = make([]float64, n)
	b = make([]float64, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i], &b[i])
	}
	return
}

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

func abs(a int) int {
	if a > 0 {
		return a
	}
	return -a
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func min(a ...int) int {
	min := a[0]
	for i := 1; i < len(a); i++ {
		if min > a[i] {
			min = a[i]
		}
	}
	return min
}

func max(a ...int) int {
	max := a[0]
	for i := 1; i < len(a); i++ {
		if max < a[i] {
			max = a[i]
		}
	}
	return max
}

func sum(a []int) (ans int) {
	for i := range a {
		ans += a[i]
	}
	return
}

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

func yesOrNo(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

func yesorNO(b bool) {
	if b {
		reply = "Yes"
		fmt.Println(reply)
		return
	}
	reply = "No"
	fmt.Println(reply)
}

Measured memory_bytes: 5120
/// ****** Property of vipulks ****** \

#include <stdio.h>
#include <limits.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define ll long long

int main(){
	ll t,n,i,j,k,ans,a,b,c,d;
	t=1;//scanf("%lld",&t);
	while(t--){
		scanf("%lld",&n);
		i=n%10;
		if(i==2 || i==4 || i==5 || i==7 || i==9)
			printf("hon\n");
		else if(i==0 || i==1 || i==6 || i==8)
			printf("pon\n");
		else if(i==3)
			printf("bon\n");
	}
	return 0;
}

Measured memory_bytes: 1660
n, m = map(int,input().split())
p = []
for i in range(n):
    p.append(list(map(int,input().split())))
s = set()
for i in range(p[0][0]):
    s.add(p[0][i+1])

for i in range(1,n):
    kar = set()
    for j in range(p[i][0]):
        kar.add(p[i][j+1])
    s = s & kar

print(len(s))

Measured memory_bytes: 3064
#!/usr/bin/env python3
import sys
from statistics import median
sys.setrecursionlimit(10**8)
INF = float("inf")


def main():
    N = int(input())
    A = [0]*N
    B = [0]*N
    for i in range(N):
        A[i], B[i] = map(int, input().split())
    mA = median(A)
    mB = median(B)
    if N % 2 == 1:
        print(mB-mA+1)
    else:
        print(int(2*(mB-mA)+1))

    return


if __name__ == '__main__':
    main()


Measured memory_bytes: 84516
object Main {
  def main(args: Array[String]): Unit = {
    import scala.io.StdIn.readLine
    val iobuf = readLine.split(" ").map(_.toInt).head
    var ans = false
    for (i <- (iobuf / 7) to 0 by -1; j <- 0 to (iobuf / 4)) {
      if (7 * i + 4 * j == iobuf) ans = true
    }
    println(if(ans) "Yes" else "No")
  }
}


Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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 ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> p(n),a(n),b(n);
    REP(i,n){
        cin >> p[i];
        p[i]--;
    }
    REP(i,n){
        a[p[i]]=n*(p[i]+1)+i;
        b[p[i]]=n*(n-p[i]);
    }
    REP(i,n){
        cout << a[i] << " ";
    }
    cout << endl;
    REP(i,n){
        cout << b[i] << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3760
process.stdin.resume();
process.stdin.setEncoding('utf8');

var g_input = '';
process.stdin.on('data', function(chunk) {
    g_input += chunk;
});
process.stdin.on('end', function() {
    main(g_input.split(/\r?\n/));
});

function main(inputs) {
  var a = inputs[0].split(" ").map(function(a){return parseInt(a);});
  var X = a[0];
  var A = a[1];
  var B = a[2];
  if(B <= A){
    console.log("delicious");
  }else if(B <= A + X){
    console.log("safe");
  }else{
    console.log("dangerous");
  }
}


Measured memory_bytes: 21192
#define watch5(a,b,c,d,e) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d << " | "<<#e<<": "<<e<<endl;
#define watch4(a,b,c,d) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl;
#define watch3(a,b,c) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<endl;
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define sharingan cerr << "\n-------------------------------------------\n\n";
#define watch2(a,b) cerr <<#a<<": "<<a<<" | "<<#b<<": "<<b<< endl;
#define Yup ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define watch(a) cerr <<#a<<": "<<a<<endl;
#define __gcd(a, b) __algo_gcd(a, b)
#define PI 3.14159265358979323846
#define mod 1000000007
#include "bits/stdc++.h"
using namespace std;
#define int long long

int32_t main(){
    int n;
    cin >> n;
    if( n == 1 ){
        cout << "0";
        return 0;
    }
    int ans = 1;
    int n9 = 1, e8 = 1;
    for( int i = 1; i <= n; i++ ){
        ans *= 10;
        ans %= mod;
        n9 *= 9;
        n9 %= mod;
        e8 *= 8;
        e8 %= mod;
    }
    n9 *= 2;
    n9 %= mod;
    n9 -= e8;
    while( n9 < 0 )n9 += mod;
    n9 %= mod;
    ans -= n9;
    while( ans < 0 )ans += mod;
    ans %= mod;
    cout << ans;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1001001001;
const vector<int> di = {-1,0,1,0};
const vector<int> dj = {0,-1,0,1};

int n, m;

int main(){
  cin >> n >> m;
  if (n == m) cout << "Yes" << endl;
  else cout << "No" << endl;
  }

Measured memory_bytes: 256
# coding: utf-8
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
A.sort()
bl = np.array([True] * (A[-1]+1), dtype=np.bool)
answer = 0
for i, a in enumerate(A):
    if i < N-1 and A[i+1] == a:
        pass
    elif bl[a]:
        answer += 1
    if bl[a]:
        bl[a::a] = False

print(answer)


Measured memory_bytes: 51728
module ABC125

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public :: task_D

  ! contained <subroutine>s and <function>s are below
  contains

  subroutine task_D

    ! variables for this <subroutine>
    integer(INT32) :: len_sequence
    
    ! arrays for this <subroutine>
    integer(INT64), allocatable :: val_sequence(:)
    integer(INT64), allocatable :: dp(:,:)

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! read out the length of the given sequence
    read(unit=INPUT_UNIT, fmt=*) len_sequence

    ! STEP.02
    ! allocate to store ...
    ! 1. the sequence of values
    ! 2. the process of the dynamic planning
    allocate( val_sequence(1:len_sequence) )
    allocate( dp(1:len_sequence+1, 1:2) )

    ! STEP.03
    ! read out the given sequence of values
    read(unit=INPUT_UNIT, fmt=*) val_sequence(1:len_sequence)

    ! STEP.04
    ! dynamic planning
    dp(1,1) = 0_INT64
    dp(1,2) = - sum( abs( val_sequence(1:len_sequence) ) )

    do itr = 1_INT32, len_sequence, 1_INT32
      dp(itr + 1, 1) = max( dp(itr, 1) + val_sequence(itr), dp(itr, 2) - val_sequence(itr) )
      dp(itr + 1, 2) = max( dp(itr, 1) - val_sequence(itr), dp(itr, 2) + val_sequence(itr) )
    end do

    ! STEP.05
    ! output the maximum value of the summation that can be realized in a given sequence
    write(unit=OUTPUT_UNIT, fmt='(I0)', advance='yes') dp(len_sequence + 1, 1)

    ! STEP.END
    return

  end subroutine task_D

end module ABC125


program main

  ! <module>s to import
  use, non_intrinsic :: ABC125

  ! require all variables to be explicitly declared
  implicit none

  call task_D

end program main

Measured memory_bytes: 3200
#include <cstdio>
#include <cstring>
#include <cassert>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

#define TRACE(x) cerr << #x << " = " << x << endl
#define REP(i, n) for (int i=0; i<n; i++)
#define FOR(i, a, b) for (int i=(a); i<(b); i++)
#define _ << " " <<

#define TRACE(x)

typedef long long ll;
typedef pair<int, int> P;
#define X first
#define Y second

const int MAX = 505;

int n;
char s[MAX][MAX];
int ima[MAX];

void load()
{
  scanf("%d", &n);
  REP(i, n) scanf("%s", s[i]);
}

void gen()
{
  memset(s, 0, sizeof s);
  REP(i, n) REP(j, n) {
    if (rand() & 1) 
      s[i][j] = '#';
    else
      s[i][j] = '.';
  }
}

int brute()
{
  int rje = 3 * MAX;
  REP(st, 10000) {
    char tmp[MAX][MAX];
    memcpy(tmp, s, sizeof s);
      
    for (int br=0; br<rje; br++) {
      int da = 1;
      REP(i, n) REP(j, n) if (tmp[i][j] != '#') da = 0;
      if (da) {
	rje = min(rje, br);
	break;
      }

      int red = rand() % n, stup = rand() % n;
      vector <int> T;
      REP(j, n) T.push_back(tmp[red][j]);
      REP(i, n) tmp[i][stup] = T[i];
    }
  }

  return rje < 3*MAX ? rje : -1;
}

int solve()
{
  memset(ima, 0, sizeof ima);
  int sum=0;
  REP(i, n) REP(j, n) if (s[i][j] == '#') {
    ima[j] = 1;
    sum++;
  }

  if (!sum)
    return -1;
  
  int cijelih = 0;
  REP(j, n) {
    int da = 1;
    REP(i, n)
      if (s[i][j] != '#') da = 0;
    
    cijelih += da;
  }

  int ret = MAX * MAX;
  
  REP(i, n) {
    int kol = 0;
    REP(j, n) if (s[i][j] == '#') kol++;
    TRACE(i _ kol _ ima[i] _ cijelih);
    ret = min(ret, n - kol + 1 - ima[i] + n - cijelih);
  }

  return ret;
}

int main()
{ 
  // for (;;) {
  //   gen();
  //   TRACE(n);
  //   REP(i, n) TRACE(s[i]);
  //   printf("\n");
    
  //   TRACE(brute() _ solve());
  //   assert(brute() == solve());
  // }

  load();
  cout << solve() << endl;
 
  return 0;
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		char[] a = in.next().toCharArray();
		char[] b = in.next().toCharArray();
		int[][] dp = new int[a.length+1][b.length+1];
		for(int i=0;i<=b.length;i++) {
			dp[0][i] = 0;
		}
		for(int i=0;i<=a.length;i++) {
			dp[i][0] = 0;
		}
		for(int i=1;i<=a.length;i++) {
			for(int j=1;j<=b.length;j++) {
				dp[i][j] = Math.max(Math.max(dp[i][j-1],dp[i-1][j]), dp[i-1][j-1]+(a[i-1]==b[j-1]? 1:0));
			}
		}
		/*
		for(int i=0;i<=a.length;i++) {
			System.out.println(Arrays.toString(dp[i]));
		}
		*/
		int i=a.length;
		int j=b.length;
		StringBuilder result = new StringBuilder("");
		while(i>0&&j>0) {
			if(dp[i][j]==dp[i][j-1]) {
				j--;
			}else {
				if(dp[i][j]==dp[i-1][j]) {
					i--;
				}else {
					result.insert(0,a[i-1]);
					i--;
					j--;
				}
			}
		}
		
		//System.out.println(dp[a.length][b.length]);
		System.out.println(result);
	}
}


Measured memory_bytes: 85068
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <climits>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <queue>


using namespace std;
#define INF 0x3f3f3f3f3f
#define ll long long
#define pr(x) (cerr << #x << ' ' << x << ' ')
#define prln(x) (cerr << #x << ' ' << x << endl)
const int maxn = 2e5 + 5;
int a[maxn];
int b[maxn];

int main()
{
	#ifdef LOCAL
		freopen("in.txt", "r", stdin);
	#endif // LOCAL

	int n;
	scanf("%d", &n);

	for (int i = 1; i <= n; ++i) {
		scanf("%d", &a[i]);
		b[i] = a[i];
	}
	int m = n / 2;

	sort(a + 1, a + 1 + n);
	for (int i = 1; i <= n; ++i) {
		if (b[i] <= a[m]) {
			printf("%d\n", a[m + 1]);
		}else {
			printf("%d\n", a[m]);
		}
	}

	return 0;
}

Measured memory_bytes: 3712
#include<bits/stdc++.h>
#define FOR0(i,n) for(i=0;i<n;i++)
#define FOR(i,j,n) for(i=j;i<n;i++)
#define FORD(i,j,k) for(i=j;i>=k;i--)
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define inf 1000000000
#define ninf -1000000000
#define endl '\n' 
#define she_told_me_dont_worry ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
// Use cout.flush() for interactive problems.
// Use this for increased stack size: g++ -o a.exe -Wl,--stack=256000000 -O2 source.cpp
inline long long  MAX2(long long  a, long long int b){return (a)>(b)?(a):(b);}
inline long long  MAX3(long long  a, long long  b,long long  c){return (a)>(b)?((a)>(c)?(a):(c)):((b)>(c)?(b):(c));}
inline long long  MIN2(long long  a, long long  b){return (a)<(b)?(a):(b);}
inline long long  MIN3(long long  a, long long b,long long c){return (a)<(b)?((a)<(c)?(a):(c)):((b)<(c)?(b):(c));}
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< ii > vii;
int n;
int k;
int v[55];
int dp[55][55][105];
int compute(int l, int r, int rem)
{
    if(r < l || rem == 0)
    {
        return 0;
    }
    if(dp[l][r][rem]!=-1) return dp[l][r][rem];
    int ans = ninf;
    int cur;
    cur = v[l] + compute(l+1, r, rem-1);
    ans = MAX2(ans, cur);
    if(rem>1)
    {
        cur = compute(l+1, r, rem-2);
        ans = MAX2(ans, cur);
    }
    cur = v[r] + compute(l, r-1, rem-1);
    ans = MAX2(ans, cur);
    if(rem > 1)
    {
        cur = compute(l, r-1, rem-2);
        ans = MAX2(ans, cur);
    }
    cur = compute(l, r, 0);
    ans = MAX2(ans, cur);
    return dp[l][r][rem] = ans;
}
int main()
{
    she_told_me_dont_worry
    memset(dp, -1, sizeof dp);
    cin>>n>>k;
    int i;
    FOR0(i, n) cin>>v[i];
    int ans = compute(0, n-1, k);
    //ans = MAX2(ans, 0);
    cout<<compute(0, n-1, k);
    cerr <<endl<< "Time elapsed : " << clock() * 1000.0 / CLOCKS_PER_SEC << " ms" << '\n';
}

Measured memory_bytes: 1536
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<algorithm>
#include<functional>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << "\n";
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << "\n";
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << "\n";
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll N;
  cin >> N;
  vector<ll> B(N, 0);
  ll sum = 0;
  rep(i, 0, N){
    cin >> B[i];
    B[i] -= (i+1);
    B[i] += 200000;
    sum += B[i];
  }

  sort(B.begin(), B.end());
  ll b1 = B[N/2];
  ll b2 = B[N/2+1];

  ll ans1=0, ans2=0;
  rep(i, 0, N){
    ans1 += abs(B[i]-b1);
    ans2 += abs(B[i]-b2);
  }

  cout << min(ans1, ans2) << "\n";

  return 0;
}


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

int main()
{
	int w,a,b;
	cin>>w>>a>>b;
	
	int ans;
	if(a<b){
		if(a+w<b) ans=b-(a+w);
		else ans=0;
	}else{
		if(b+w<a) ans=a-(b+w);
		else ans=0;
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)

k = int(input())
S = []
def dfs(s):
  if len(s)<10:
    for i in range(-1, 2, 1):
      a = str(min(9, max(0, int(s[0])+i)))+s
      S.append(a)
      dfs(a)

for i in range(10):
  S.append(i)
  dfs(str(i))
S = sorted(set([int(s) for s in S]))
print(S[k])

Measured memory_bytes: 47924
n,a,b=map(int, input().split()) 
total = 0
for i in range(1,n+1):
  m = i
  wa = 0
  while True:
    wa += m % 10
    m = m // 10
    if (m == 0):
      break
  if (wa >= a)and(wa <= b):
    total += i
print(total)


Measured memory_bytes: 2940
#include <stdio.h>
#include <vector>
using namespace std;
long long n, k;
int x, y;
long long ans = 1;
long long p = 1000000007;
vector<int>g[100000];
int c[100000];
void dfs(int f,int b,int r) {
	if (r == 0)ans = k;
	else ans *= (k - c[b] - 1);
	ans %= p;
	for (int i = 0; i < g[f].size(); i++) {
		if (g[f][i] != b) {
			c[g[f][i]]++;
			dfs(g[f][i], f, 1);
			c[f]++;
		}
	}
}
int main() {
	scanf("%lld%lld", &n, &k);
	for (long long i = 0; i < n - 1; i++) {
		scanf("%d%d", &x, &y);
		x--; y--;
		g[x].push_back(y);
		g[y].push_back(x);
	}
	dfs(0, -1, 0);
	printf("%lld\n", ans);
}

Measured memory_bytes: 10752
#include<iostream>
#include<string>
#include<cstdlib>
#include<math.h>
using namespace std;
int main(void){
    int x,y,a=0;
    cin >> x >> y;
    a=x+y;
    if(a<x-y){
        a=x-y;
    }
    if(a<x*y){
        a=x*y;
    }
    printf("%d",a);
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
  input()
}

func input() {
	var n, m int
	fmt.Scanf("%d%d", &n, &m)
	graph := make(map[int][]int)
	for i := 0; i < m; i++ {
		var from, to int
		fmt.Scanf("%d%d", &from, &to)
		targets, _ := graph[from]
		targets = append(targets, to)
		graph[from] = targets
	}
	ans := longestPath(n, graph)
    fmt.Println(ans)
}

func longestPath(nodes int, graph map[int][]int) int {
	var maxPath int = -1 << 32
	visited := make([]bool, nodes+1)
	dp := make([]int, nodes+1)
	for i := 1; i <= nodes; i++ {
		_, ok := graph[i]
		if !visited[i] && ok {
			path := dfs(i, graph, dp, visited)
			maxPath = int(math.Max(float64(maxPath), float64(path)))
		}
	}
	return maxPath
}

func dfs(source int, graph map[int][]int, dp []int, visited []bool) int {
	edges := graph[source]
	if visited[source] {
		return dp[source]
	}
	visited[source] = true
	for i := 0; i < len(edges); i++ {
		path := 1 + dfs(edges[i], graph, dp, visited)
		dp[source] = int(math.Max(float64(dp[source]), float64(path)))
	}
	return dp[source]
}


Measured memory_bytes: 29080
N = int(input())
ac = 0
wa = 0
tle = 0
re = 0
for i in range(N):
  s = input()
  if s == 'AC':
    ac += 1
  elif s == 'WA':
    wa += 1
  elif s == 'TLE':
    tle += 1
  else:
    re += 1
print('AC x {}'.format(ac))
print('WA x {}'.format(wa))
print('TLE x {}'.format(tle))
print('RE x {}'.format(re))

Measured memory_bytes: 9200
#include <algorithm>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <cctype>
#include <iostream>
#include <set>
#include <string>
#include <queue>
#include <map>
using namespace std;
int size(string x){
	string::size_type size=x.size();
	return size;
}
#define fu(l,k) for(int i=l;i<k;i++)
#define fd(l,k) for(int i=l;i>k;i--)
#define fi first
#define se second
typedef  vector<string> vs;
typedef  vector<int> vi;
double pi(){
	return M_PI;
}
typedef set<int> set_i;
typedef set<string> set_s;
int INF=1000000;
int main(){
	double s,a,b;
	cin>>a>>b;
	printf("%lf\n",a*b/3.305785);
}

Measured memory_bytes: 1232
// 問題URL
// https://atcoder.jp/contests/abc158/tasks/abc158_b

import java.util.Scanner;

public class Main
{
    public static void main(String [] args)
    {
        Scanner scaanner = new Scanner(System.in);
        long num = scaanner.nextLong();
        long blue = scaanner.nextLong();
        long red = scaanner.nextLong();

        // 赤と青を合計することでグループ化する
        // 割り切れる数値
        long divisible_group = (num / (blue+red));
        // 割り切れない数値
        long indivisible_group = (num % (blue+red));
        // 合計値
        long total =  divisible_group * blue;

        if (indivisible_group <= blue) {
            System.out.println(total+ indivisible_group);
        } else {
            System.out.println(total+ blue);
        }

    }
}

Measured memory_bytes: 25172
def slove():
    import sys, collections, itertools
    input = sys.stdin.readline
    n = int(input().rstrip('\n'))
    name = [str(input().rstrip('\n'))[0] for _ in range(n)]
    name = collections.Counter(name)
    name = dict(name.items())
    ls = list("MARCH")
    t = 0
    for i in itertools.combinations(ls, 3):
        if i[0] in name and i[1] in name and i[2] in name:
            t += (name[i[0]] * name[i[1]] * name[i[2]])
    print(t)


if __name__ == '__main__':
    slove()


Measured memory_bytes: 46812
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
long long modpow(long long a, long long n, long long mod) {
	long long res = 1; 
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int main() {
	int n;
	cin >> n;
	if (n % 1000 == 0) {
		cout << 0;
	}
	else {
		cout << 1000 - n % 1000;
	}
}

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans1 = Math.min(a, b);
        int ans2 = a + b - n;
        if (ans2 < 0) {
            ans2 = 0;
        }
        System.out.println(ans1 + " " + ans2);
    }
}

Measured memory_bytes: 22740
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(x),end(x)
#define show(obj) {for(auto x:obj)cout<<x<<' ';cout<<endl;}
#define line "----------"
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
const int inf = 1001001000;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
	int cnt[4] = {0};
	rep(k,6){
		int i;
		cin>>i;
		--i;
		cnt[i] ++;
	}
	bool ans = true;
	rep(i,4){
		if(cnt[i] == 0 || cnt[i] > 2)ans = false;
	}
	cout<<((ans)? "YES":"NO")<<endl;
	return 0;
}


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

int main()
{
    string s, t;
    cin >> s >> t;
    int sum = 0;
    rep(i, 3)
    {
        if (s[i] == t[i])
        {
            sum += 1;
        }
    }
    cout << sum << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define pb(a) push_back(a)
#define all(x) (x).begin(), (x).end()

#define FOR(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))

#define PRINT(str) printf(#str "\n")
#define yOUT PRINT(Yes)
#define nOUT PRINT(No)
#define YOUT PRINT(YES)
#define NOUT PRINT(NO)

//関数定義
//最大公約数
ll gcd(ll a, ll b);

//最小公倍数
ll lcm(ll a, ll b);

int main() {
  // ========================================================
  string s;
  cin >> s;
  bool f = 1;
  REP(i, s.size()) {
    if (i % 2 == 0 && s[i] == 'L') {
      f = 0;
      break;
    } else if (i % 2 != 0 && s[i] == 'R') {
      f = 0;
      break;
    }
  }
  if (f)
    yOUT;
  else
    nOUT;
}

//最大公約数
ll gcd(ll a, ll b) {
  if (!b) return a;
  return gcd(b, a % b);
}

//最小公倍数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); }

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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b&&a!=c) cout<<"Yes\n",exit(0);
    if(a==c&&a!=b) cout<<"Yes\n",exit(0);
    if(c==b&&a!=c) cout<<"Yes\n",exit(0);
    cout<<"No\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007
#define INF 1000000000
typedef pair<int64_t, int64_t> PII;
typedef vector<int64_t> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

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

int N; cin >> N;
VI A(N); rep(i, 0, N) cin >> A[i];
sort(ALL(A));

vector<bool> rem(N, false); 
rem.back() = true;
// rep(i, 0, N) 
//     if (A[i] * 2 >= A.back()) rem[i] = true;

VI psum(N); 
partial_sum(ALL(A), psum.begin());

Rrep(i, N-2, 0)
    if (psum[i] * 2 >= A[i+1] && rem[i+1]) rem[i] = true;

cout << accumulate(ALL(rem), 0) << endl;
}

// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり



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

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc1 = new Scanner(System.in);

		int n = sc1.nextInt();
		int[] a = new int[n];
		int[] b = new int[n];

		for (int i = 0 ; i < n ; i++ ) {
			a[i] = sc1.nextInt();
			b[i] = a[i];
		}

		Arrays.sort(b);

		int min = b[n/2 - 1];
		int max = b[n/2];

		for (int i = 0 ; i < n ; i++) {
			if(a[i] <= min) {
				System.out.println(max);
			}
			else {
				System.out.println(min);
			}
		}

		sc1.close();
	}

	static int[] sort(int[] num) {

		while (true) {
			boolean test = true;
			for (int index = 0; index < num.length - 1 ; index ++) {
				if (num[index] > num[index + 1]) {
					int a = num[index];
					int b = num[index+1];
					num[index] = b;
					num[index+1] = a;
					test = false;
				}
			}
			if ( test ) {
				return num;
			}
		}
	}

}

Measured memory_bytes: 94828
#include<cstdio>

const int S = 3;
char W[S];

void solve();

int main(){

    scanf("%s", W);

    solve();

    return 0;
}

void solve(){

    int ans = 0;

    if (W[0] == 'R'){
        if(W[1] == 'R'){
            if(W[2] == 'R'){
                ans = 3;
            }
            else{
                ans = 2;
            }
        }
        else{
            ans = 1;
        }
    }
    else{
        if(W[1] == 'R'){
            if(W[2] == 'R'){
                ans = 2;
            }
            else{
                ans = 1;
            }
        }
        else{
            if(W[2] == 'R'){
                ans = 1;
            }
            else{
                ans = 0;
            }
        }
    }

    printf("%d\n", ans);
}

Measured memory_bytes: 1736
// In the name of God

#include <bits/stdc++.h>

using namespace std;

const int N = 1e5+5;

int p[2 * N];

int find_set(int u) {
	if(p[u] == u) return u;
	return p[u] = find_set(p[u]);
}

void union_set(int u, int v) {
	int pu = find_set(u);
	int pv = find_set(v);
	p[pu] = pv;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	for(int i = 0; i < 2 * N; i++) p[i] = i;
	int n, m;
	cin >> n >> m;
	for(int i = 0; i < n; i++) {
		int k;
		cin >> k;
		for(int j = 0; j < k; j++) {
			int x;
			cin >> x;
			x--;
			union_set(i, n + x);
		}
	}
	set<int> s;
	for(int i = 0; i < n; i++) s.insert(find_set(i));
	if(s.size() == 1) cout << "YES";
	else cout << "NO";
	return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
#include<string.h>

int main()
{
    int n;
    scanf("%d",&n);
    char ch[n];
    for(int i=0;i<=n;i++){
        scanf("%c",&ch[i]);
    }
    int cnt=0;
    int i=0;
    while(ch[i]!='\0'){
        if(ch[i]=='A'&& ch[i+1]=='B'&& ch[i+2]=='C')
            cnt++;
            i++;
    }
    printf("%d\n",cnt);
    return 0;
}

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

int main(void){
    int W[10], K[10];
    for(int i = 0; i < 10; i++) cin >> W[i];
    for(int i = 0; i < 10; i++) cin >> K[i];

    sort(W, W + 10);
    sort(K, K + 10);

    cout << (W[7] + W[8] + W[9]) << " " << (K[7] + K[8] + K[9]) << endl;
}



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

int main() {
  int x,a,b;
  cin >> x >> a >> b;
  int check=b-a;
  if(check<=0) {
    cout << "delicious" << endl;
  }
  else if (check<x+1) {
    cout << "safe" << endl;
  }
  else {
    cout << "dangerous" << endl;
  }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define NIL -1

typedef struct node{
  int key;
  struct node *parent;
  struct node *left;
  struct node *right;
}Node;

void insert(Node **, Node *);
void find(Node*, int);
void print(Node *);
void inorderTreeWalk(Node *);
void preorderTreeWalk(Node *);

main(){
  int m, key, i;
  char string[10];
  Node *T, *node;

  T = NULL;

  scanf("%d", &m);
  for(i=0; i<m; i++){
    scanf("%s", string);
    if(strcmp(string, "insert")==0){
      scanf("%d", &key);
      node = malloc(sizeof(Node));
      node->key = key;
      node->left = NULL;
      node->right = NULL;

      insert(&T, node);
    }
    else if(strcmp(string, "find")==0){
      scanf("%d", &key);
      find(T, key);
    }
    else print(T);
  }

  return 0;
}

void insert(Node **T, Node *z){
  Node *x, *y;
  
  y = NULL;  //xの親
  x = *T;
  
  while(x != NULL){
    y = x;
    if(z->key < x->key) x = x->left;
    else x = x->right;
  }
  z->parent = y;
  
  if(y==NULL) *T = z;
  else if(z->key < y->key) y->left = z;
  else y->right = z;
}

void find(Node *T, int key){
  while(T != NULL && T->key != key){
    if(key < T->key) T = T->left;
    else T = T->right;
  }
  if(T == NULL) printf("no\n");
  else printf("yes\n");
}

void print(Node *T){
  inorderTreeWalk(T);
  printf("\n");

  preorderTreeWalk(T);
  printf("\n");
}

void inorderTreeWalk(Node *T){
  if(T == NULL) return;

  inorderTreeWalk(T->left);
  printf(" %d", T->key);
  inorderTreeWalk(T->right);
}

void preorderTreeWalk(Node *T){
  if(T == NULL) return;
  printf(" %d", T->key);
  preorderTreeWalk(T->left);
  preorderTreeWalk(T->right);
}

Measured memory_bytes: 19364
import collections

S = collections.deque(list(input()))
Q = int(input())
rev = 0
for i in range(0, Q):
    query = list(input().split())
    if query[0] == "1":
        rev = rev+1
    else:
        if query[1] == "1":
            if rev%2 == 0:
                S.appendleft(query[2])
            else:
                S.append(query[2])
        else:
            if rev%2 == 0:
                S.append(query[2])
            else:
                S.appendleft(query[2])
if rev%2 == 0:
    for i in S:
        print (i, end = "")
else:
    for i in reversed(S):
        print (i, end = "")

Measured memory_bytes: 7520
# -*- coding: utf-8 -*-
import numpy as np

#N個のリンゴ
#リンゴiの味＝L+i-1

#入力（数値）
spline = input().split()
N = int(spline[0])
L = int(spline[1])

#リンゴの味
taste = []
for i in range(1,N+1): #リンゴNは１から数える
    taste.append(L+i-1)  #味の設定
#print(taste)

#1つも食べなかった場合の味
taste_max = sum(taste)
#print("max"+str(taste_max))


#1つ食べた場合の味のリスト
taste_any = []
for k in range(0,N):
    taste_any.append(sum(taste) - taste[k])
#print(taste_any)

#maxとanyの差
#numpy配列にしてから計算
taste_any = np.asarray(taste_any)
diff = abs(sum(taste) - taste_any)
#numpy配列からリストに戻す（.indexメソッドが使いたいから）
diff_list = diff.tolist()
#print("diff_list"+str(diff_list))
#最小値のインデックスを取得する
coef = diff_list.index(min(diff_list))
#print(coef)

print(taste_any[coef])




Measured memory_bytes: 12508
#include<stdio.h>
#include<math.h>
int Sosu(int N){
  int i=3;
if(N==2)return 1;
if(N<2 || N%2==0)return 0;
while(i<=sqrt(N)){
  if(N%i==0)return 0;
  i=i+2;
}
return 1;
}
int main(void){
int N;
int n,i;
int S=0,c=0;
while(1){
scanf("%d",&n);
if(n>=1 && n<=10000)break;
}
for(i=0 ; i<n ; i++){
  while(1){
  scanf("%d",&N);
  if(N>=2 && N<=100000000)break;
  }
  S+=Sosu(N);
}
printf("%d\n",S);
return 0;
}


Measured memory_bytes: 2140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
const int MOD = 1e9+ 7;
const int INF = numeric_limits<int>::max() - (int)1e8;
const ll INFLL = numeric_limits<ll>::max() - (ll)1e17;

int main() {
    string S;
    cin >> S;
    cout << (S == "ABC" ? "ARC" : "ABC") << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = int(1e9) + 1;
const LL LLINF   = LL(1e18) + 1;
#define pow10(n) int(1e##n + n)

void solve()
{
    int N;
    cin >> N;
    vector<LL> B(N);
    LL sum      = 0;
    LL min_abs  = LLINF;
    int neg_odd = 0;

    REP0 (i, N)
    {
        cin >> B[i];
        min_abs = min(min_abs, abs(B[i]));
        neg_odd += (B[i] < 0);
        neg_odd %= 2;
        sum += abs(B[i]);
    }

    if (neg_odd)
    {
        sum -= min_abs * 2;
    }

    cout << sum << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <queue>
#include <stack>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define REPO(i, n) for(int i = 1;i <= n;i++)
#define ll long long
#define INF 1999999999
#define MINF -1999999999
#define INF64 1999999999999999999
#define ALL(n) n.begin(),n.end()
#define ABS(a,b) max(a,b) - min(a,b)

ll N, in, ans = 0, s[114514] = {};
vector<ll> a, b, c;
int main() {
	cin >> N;
	REP(i, N) {
		cin >> in;
		a.push_back(in);
	}
	REP(i, N) {
		cin >> in;
		b.push_back(in);
	}REP(i, N) {
		cin >> in;
		c.push_back(in);
	}
	sort(ALL(a));
	sort(ALL(b));
	sort(ALL(c));
	REPR(i, b.size() - 1) {
		auto t1 = upper_bound(ALL(c), b[i]);
		s[i] = c.end() - t1 + s[i + 1];
	}
	REP(i, a.size()) {
		auto t1 = upper_bound(ALL(b), a[i]);
		ans += s[t1 - b.begin()];
	}
	cout << ans << endl;
}

Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define fastIO (cin.tie(0), cout.tie(0), ios::sync_with_stdio(false))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define precise(i) fixed << setprecision(i)
using llint = long long int;
using namespace std;

int main() {
  fastIO;
  llint r, d, xi;
  cin >> r >> d >> xi;

  for(int i=0; i<10; ++i) {
    xi = r * xi - d;
    cout << xi << endl;
  }
}


Measured memory_bytes: 3524