akhauriyash/Code-Regression huggingface dataset:
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;
using namespace __gnu_pbds;

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, r;
	cin >>n >>r;
	if(n >= 10) {
		cout <<r;
	}
	else {
		cout <<r + 100 * (10 - n);
	}
	return 0;
}


Measured memory_bytes: 256
def main():
  import sys
  n = int(input())
  a = tuple(map(int,sys.stdin.readline().split()))
  b = tuple(map(int,sys.stdin.readline().split()))
  
  count=0
  buffer=0
  
  for c,h in zip(a,b):
    count += min(buffer,c)
    g = max(0,c-buffer)
    count += min(h,g)
    buffer=max(0,h-g)
  else:
    count+=min(buffer,a[-1])
    
    
  print(count)
  
if __name__=="__main__":
  main()

Measured memory_bytes: 19376
/*================================================================
Love China, Love YALI, Love OI!
*   
*   File Name：C.cpp
*   Author：YaliKiWi
*   Date：2019年09月11日
*   Discribe：
*
================================================================*/


#include<bits/stdc++.h>
using namespace std;
#define fo(i,s,e) for(register int i=s;i<=e;i++)
#define max_(x,y) ((x)>(y)?(x):(y))
#define min_(x,y) ((x)<(y)?(x):(y))
#define dd double
#define ull unsigned long long
#define ll long long
#define maxn 110
#define inf 0x3f3f3f3f
int a[maxn],b[maxn],n,ans;
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	fo(i,2,n)
		cin>>b[i];
	b[n+1]=inf;
	a[1]=b[2];
	ans=a[1];
	fo(i,2,n){
		a[i]=min_(b[i],b[i+1]);
		ans+=a[i];
	}
	cout<<ans;
	return 0;
}

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

#[allow(dead_code)]
fn read_as_vec<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()

}

//21:10
fn main(){
    let n: usize = read_as_vec()[0];
    let mut a: Vec<i64> = vec![0];
    a.append(&mut read_as_vec());
    a.push(0);
    let mut origin_cost = 0;

    for i in 1..a.len(){
        origin_cost += (a[i] - a[i-1]).abs();
    }

    for i in 1..a.len()-1{
        if (a[i-1] < a[i] && a[i] < a[i+1]) || (a[i-1] > a[i] && a[i] > a[i+1]){
            println!("{}", origin_cost);
        }else{
            println!("{}", origin_cost - (a[i]-a[i-1]).abs()
                     - (a[i] - a[i+1]).abs() + (a[i+1] - a[i-1]).abs());
        }
    }
}


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

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n, mult = 1, di; cin >> n;
  for (int i = 1; i <= n-2; ++i) mult *= i;
  di = mult*n*(n-1);
  mult *= 2*(n-1);
//  cout << mult << " " << di << "\n";
  vector <pair<int,int>> coord(n);
  for (int i = 0; i < n; ++i){
	cin >> coord[i].first >> coord[i].second;
  }
  double ans = 0;
  for (int i = 0; i < n; ++i){
	for (int j = i; j < n; ++j){
			int x = coord[i].first - coord[j].first;
			int y = coord[i].second - coord[j].second;	
			ans += mult*sqrt(x*x + y*y);
	}
  }
	cout << fixed << setprecision(9) << ans/di << "\n"; 
return 0;
}


Measured memory_bytes: 3800
#include<stdio.h>
int main(void){
    char n;
    scanf("%c", &n);
    if((n >= 'a')&&(n <= 'z')){
        printf("a\n", n);
    }else if((n >= 'A')&&(n <= 'Z')){
        printf("A\n", n);
    }
}

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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

bool loop(string s) {
    string t = s;
    reverse(ALL(t));
    return t == s;
}

int main() {
    string S;
    cin >> S;
    bool p = true;
    p = p && loop(S);
    int N = S.size();
    p = p && loop(S.substr(0, N/2));
    p = p && loop(S.substr(N/2 + 1, N/2));
    if(p) {
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}


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

int main()
{
  int n;
  cin >> n;
  
  vector<double> a(n);
  for (int i = 0; i < n; i ++)
    cin >> a.at(i);
  
  sort(a.begin(), a.end());
  
  double tmp = (a.at(0) + a.at(1)) / 2;
  for (int i = 2; i < n; i ++)
    tmp = (tmp + a.at(i)) / 2;
  
  cout << tmp;
  
  return 0;
}


Measured memory_bytes: 256
il1 = input().split()
il2 = [int(k) for k in input().split()]
S = il1[0]
T = il1[1]
A = il2[0]
B = il2[1]
U = input()
if (S.find(U) >= 0):
    A = A-1
if (T.find(U) >= 0):
    B = B-1
print(str(A) + " " + str(B))


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#define min(x, y) ((x)>(y) ? (y) : (x))

int main(){
  int n;  scanf("%d", &n);
  int table[55][30] = {0};

  for(int i=1; i<=n; i++){
    char s[55];  scanf("%s", s);
    int len = strlen(s);
    for(int j=0; j<len; j++)
      table[i][(int)s[j]-(int)'a']++;
  }

  int ans[30] = {0};
  for(int i=0; i<=(int)'z'-(int)'a'; i++){
    int mini = 555;
    for(int j=1; j<=n; j++)
      mini = min(mini, table[j][i]);
    ans[i] = mini;
  }
  
  for(int i=0; i<=(int)'z'-(int)'a'; i++)
    for(int j=0; j<ans[i]; j++)
      printf("%c", (char)(i+(int)'a'));
  puts("");

  return 0;
}


Measured memory_bytes: 1672
#MLE注意！ not は使わず !=
#0や1のケースに注意

def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    import math

    #inf = 10**17
    #mod = 10**9 + 7

    n = input().rstrip()
    n = n[::-1]
    res = [0]*2019
    res[0] += 1
    b = 1
    c = 0
    for i in range(len(n)):
        a = int(n[i])
        c += a*b
        c %= 2019
        res[c] += 1
        b = b*10%2019
    ans = 0
    for i in res:
        if i>=2:
            ans += i*(i-1)//2
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9548
// jai shri ram
 //**********************************
 //**********************************
 //**********************************
 /**      BU_Excalibur      **/
/**  ABES college   **/

#include <bits/stdc++.h>
using namespace std;
#define pr(x) cerr << "\n" << (#x) << " is " << (x) << endl
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
#define Toggle(n,i) (n^(1<<i))
#define Check(n,i) (n&(1<<i))
#define Set(n,i) (n|(1<<i))
#define Reset(n,i) (n&(~(1<<i)))
#define fo(a,x,y) for(int i=(x);i<=(y);++i){cout<<a[i]<<" ";}cout<<endl;
#define me(arr,val) memset(arr,val,sizeof arr)
#define inf 10e8
#define infl LLONG_MAX
#define mod 1000000007
#define f first
#define  g(t,a)  (get<a>(t))
#define pra(a) for(auto i:a){cout<<i<<endl;}
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
 int main()
 {   IOS
     ll t,i,j;
     
     long long int n,e=INT_MAX,x=0,d=0,k,p,q,r,c,sum=1,l,ii;
       cin>>n;
       ll a[10000000]={0};
        for(i=2;i<=sqrt(1000000000000);i++)
        { for(j=i;j<=10000000;j+=i)
             a[j]++;
        }
        for(i=n;i<=10000000;i++)
         { if(a[i]==1)
            {cout<<i<<endl;
             break;
         }
        }
      }



Measured memory_bytes: 81748
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(g);(i)--)
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double PI = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
ll mod = 1e9 + 7;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);

	ll n, m,ans = 1;
	cin >> n >> m;
	if (abs(n - m) > 1) {
		puts("0");
		return 0;
	}
	
	ll nx = 1, ny = 1;
	for (int i = 1; i < n + 1;i++) {
		nx = (nx * i) % mod;
		//cout << nx << " ";
	}
	//cout << endl;
	for (int j = 1; j < m + 1; j++) {
		ny = (ny * j) % mod;
	}
	//cout << nx << " " << ny << endl;
	ans *= nx * ny % mod;
	if (n == m) {
		ans = (ans * 2) % mod;
	}
	cout << ans << endl;
	return 0;
}

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

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

  char S[N], T[N];
  cin >> S >> T;
  
  for (int i = 0; i < N; i++)
  {
    cout << S[i];
    cout << T[i];
  }
  
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int h, w, syo,n,d,a,b;
	int date[33][33];
	cin >> h >> w;
	for (int z = 1; z <= h; z++) {
		for (int i = 1; i <= w; i++) {
			cin >> date[z][i];
		}
	}
	n= 0;
	syo = 9999999999;
	for (int z = 1; z <= h; z++) {
		for (int i = 1; i <= w; i++) {
			n = 0;
			for (int zz = 1; zz <= h; zz++) {
				for(int ii=1;ii<=w;ii++){
					a = zz - z;
					b = ii - i;
					if (a < 0) {
						a = a * -1;
					}
					if (b < 0) {
						b = b * -1;
					}
					d = min(a, b);
					d = d * date[zz][ii];
					n= n + d;
				}
			}
			if (syo >= n) {
				syo = n;
			}
		}
	}
	cout << syo << endl;
}


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

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

char g[1100][1100];
int h, w;
llint dp[1100][1100];

int main() {
    cin >> h >> w;
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cin >> g[i][j];
        }
    }

    dp[h - 1][w - 1] = 1;
    for (int i = h - 1; i >= 0; i--) {
        for (int j = w - 1; j >= 0; j--) {
            if (g[i][j] == '.') {
                if (i + 1 < h && g[i + 1][j] == '.')
                    dp[i][j] = (dp[i][j] + dp[i + 1][j]) % MOD;
                if (j + 1 < w && g[i][j + 1] == '.')
                    dp[i][j] = (dp[i][j] + dp[i][j + 1]) % MOD;
            }
        }
    }

    cout << dp[0][0] % MOD << endl;

    return 0;
}


Measured memory_bytes: 10368
S = input()

ctr = [0, 0]
for i in range(len(S)):
    if i % 2 == 0:
        ctr[0] += int(S[i]) == 0
        ctr[1] += int(S[i]) == 1
    else:
        ctr[0] += int(S[i]) == 1
        ctr[1] += int(S[i]) == 0

print(min(ctr))


Measured memory_bytes: 68388
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

using namespace std;

int main(void)
{
	int n;
	while(cin >> n && n != 0)
	{
		vector<int> a(n+1);
		a[0] = 1;a[1] = 1;a[2] = 2;

		for (int i = 3; i <= n; i++)
			a[i] = a[i-1] + a[i-2] + a[i-3];

		double year;
		year = ceil((double)a[n] / 3650);
		cout << year << endl;
	}

	return 0;
}


Measured memory_bytes: 3256
package main

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

func main() {
	io, flush := NewIO()
	defer flush()
	n := io.ScanInt()
	docs := io.ScanInts(n)
	for _, d := range docs {
		if d%2 == 0 && (d%3 != 0 && d%5 != 0) {
			fmt.Println("DENIED")
			return
		}
	}
	fmt.Println("APPROVED")
}

type IO struct {
	scanner *bufio.Scanner
	writer  *bufio.Writer
}

func NewIO() (*IO, func()) {
	io := &IO{
		scanner: newScanner(),
		writer:  newWriter(),
	}
	return io, func() { io.writer.Flush() }
}

func newScanner() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Buffer(make([]byte, 10000000), 10000000)
	s.Split(bufio.ScanWords)
	return s
}

func newWriter() *bufio.Writer {
	return bufio.NewWriter(os.Stdout)
}

func (io *IO) ScanBytes() []byte {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Bytes()
}

func (io *IO) ScanString() string {
	if !io.scanner.Scan() {
		panic("scan string failed")
	}
	return io.scanner.Text()
}

func (io *IO) ScanStrings(n int) []string {
	strs := make([]string, n)
	for i := 0; i < n; i++ {
		strs[i] = io.ScanString()
	}
	return strs
}

func (io *IO) Scan2DStrings(y, x int) [][]string {
	strings := make([][]string, y)
	for i := 0; i < y; i++ {
		strings[i] = io.ScanStrings(x)
	}
	return strings
}

func (io *IO) Scan2DGraph(y int) [][]string {
	strs := make([][]string, y)
	for i := 0; i < y; i++ {
		strs[i] = strings.Split(io.ScanString(), "")
	}
	return strs
}

func (io *IO) ScanInt() int {
	return int(io.ScanInt64())
}

func (io *IO) ScanInts(n int) []int {
	ints := make([]int, n)
	for i := 0; i < n; i++ {
		ints[i] = io.ScanInt()
	}
	return ints
}

func (io *IO) Scan2DInts(y, x int) [][]int {
	ints := make([][]int, y)
	for i := 0; i < y; i++ {
		ints[i] = io.ScanInts(x)
	}
	return ints
}

func (io *IO) ScanInt64() int64 {
	i, err := strconv.ParseInt(io.ScanString(), 10, 64)
	if err != nil {
		panic(err)
	}
	return i
}

func (io *IO) ScanFloat64() float64 {
	i, _ := strconv.ParseFloat(io.ScanString(), 64)
	return i
}

func (io *IO) ScanFloat64s(n int) []float64 {
	floats := make([]float64, n)
	for i := 0; i < n; i++ {
		floats[i] = io.ScanFloat64()
	}
	return floats
}

func (io *IO) Println(a ...interface{}) {
	fmt.Fprintln(io.writer, a...)
}


Measured memory_bytes: 4992
// khodaya khodet komak kon
#include <bits/stdc++.h>
#define pb push_back
#define ers erase
#define ins insert
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define debug(x)  cerr << #x << " = " << x << endl
#define kill(x) return cout << x, 0;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;

typedef long long ll;
typedef long double ld;
typedef string str;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;
typedef vector<pll> vpl;

const ld Pi = 3.14159265359;
const ll MOD = 1000 * 1000 * 1000 + 7;
const ll N = 4e6 + 10;
const ll INF = 1e18;
const ll LOG = 20;
ll a[N], sum, n;
bitset<N> dp;
bitset<N> dp1;
int main(){
	IOS;
	cin >> n;
	for (int i = 1; i <= n; i++){
		cin >> a[i];
		sum += a[i];
	}
	dp[0] = 1;
	ll sum1 = 0;
	for (int i = 1; i <= n; i++){
		dp1 = dp << a[i];
		dp = dp | dp1;
		//cout << dp[a[i]] << '\n';
	}
	
	
	
	for (int i = sum / 2 + (sum % 2); i <= sum; i++){
		if (dp[i]) kill(i);
	}
	
	
	
	
	return 0;
}






/*
     ,---,           ___                 ,--,
    '  .' \        ,--.'|_             ,--.'|                             ,--,
   /  ;    '.      |  | :,'            |  | :                           ,--.'|    ,---.        ,---,
  :  :       \     :  : ' :            :  : '                 .--.--.   |  |,    '   ,'\   ,-+-. /  |
  :  |   /\   \  .;__,'  /    ,--.--.  |  ' |     ,--.--.    /  /    '  `--'_   /   /   | ,--.'|'   |
  |  :  ' ;.   : |  |   |    /       \ '  | |    /       \  |  :  /`./  ,' ,'| .   ; ,. :|   |  ,"' |
  |  |  ;/  \   \:__,'| :   .--.  .-. ||  | :   .--.  .-. | |  :  ;_    '  | | '   | |: :|   | /  | |
  '  :  | \  \ ,'  '  : |__  \__\/: . .'  : |__  \__\/: . .  \  \    `. |  | : '   | .; :|   | |  | |
  |  |  '  '--'    |  | '.'| ," .--.; ||  | '.'| ," .--.; |   `----.   \'  : |_|   :    ||   | |  |/
  |  :  :          ;  :    ;/  /  ,.  |;  :    ;/  /  ,.  |  /  /`--'  /|  | '.'\   \  / |   | |--'
  |  | ,'          |  ,   /;  :   .'   \  ,   /;  :   .'   \'--'.     / ;  :    ;`----'  |   |/
  `--''             ---`-' |  ,     .-./---`-' |  ,     .-./  `--'---'  |  ,   /         '---'
                            `--`---'            `--`---'                 ---`-'
*/




Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define pb push_back
#define pob pop_back
#define pf push_front
#define pof pop_front
#define nd second
#define st first
using namespace std;
using ll=long long;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
using vi=vector<int>;
using vl=vector<ll>;
using mii=map<int,int>;
using si=set<int,int>;
using vpi=vector<pii>;
using vpl=vector<pll>;

const int N=(int)1e5+5;

int n,m,a,b,c,q,wynik,dp[N];
vi G[N];
stack<int>Topo;
bool odw[N];

int R(int l, int p){
	return rand()%(p-l+1)+l;
}

void wczytaj(){
	cin>>n>>m;
	for (int i=0; i<m; ++i){
		cin>>a>>b;
		G[a].pb(b);
	}
}

void DFS(int v){
	odw[v]=1;
	for (int i:G[v]){
		if (!odw[i]) DFS(i);
	}
	Topo.push(v);
}

void topo(){
	for (int i=1; i<=n; ++i){
		if (!odw[i])DFS(i);
	}
}

void solve(){
	while (Topo.size()){
		int v=Topo.top();
		Topo.pop();
		for (int i:G[v]){
			dp[i]=max(dp[i],dp[v]+1);
		}
		wynik=max(wynik,dp[v]);
	}
	cout<<wynik<<'\n';
}

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int ilosc_przypadkow_testowych=1;
//	cin>>ilosc_przypadkow_testowych
	for (int i=1; i<=ilosc_przypadkow_testowych; ++i){
		wczytaj();
		topo();
		solve();
	}
}

Measured memory_bytes: 8704
#include <stdio.h>

int main(void){
    int i, n, count;
    long min, max, sum;
    max = -1000000;
    min = 1000000;
    sum = 0;
    scanf("%d", &count);
    for (i = 0; i < count; i++){
        scanf("%d",&n);
        if (max < n) max = n;
        if (min > n) min = n;
        sum += n;
    }
    printf("%ld %ld %ld\n",min,max,sum);
    return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;
  double A;
  cin>>N>>T>>A;
  vector<double>H(N);
  for(int i=0;i<N;i++){
    cin>>H.at(i);
    H.at(i)=T-H.at(i)*0.006;
  }

  vector<vector<double>>NN(N,vector<double>(2));
  for(int i=0;i<N;i++){
    NN.at(i).at(0)=max(A,H.at(i))-min(A,H.at(i));
    NN.at(i).at(1)=i;
  }
  sort(NN.begin(),NN.end());
  cout<<NN.at(0).at(1)+1<<endl;
}

Measured memory_bytes: 256
import math
n = int(input())
x_down = math.floor(n/1.08)
x_up = math.ceil(n/1.08)

if math.floor(x_down*1.08) == n:
    print(x_down)
elif math.floor(x_up*1.08) == n:
    print(x_up)
else:
    print(":(")

Measured memory_bytes: 38512
#include <iostream>

using namespace std;

int calc(int n) {
    
    int temp = 0;
    
    for (int i=1; i <= n; i++) {
        temp += i;
    }
    
    return temp;
}

int main() {

    int a, b;
    cin >> a >> b ;
    

    for (int i=0; i<1000; i++) {

        //int sa = calc(i) + ricalc(i+1) - a - b;
        if ((calc(i) - a == (calc(i+1) - b)) ) {
            cout << calc(i) -a  << endl;
            return 0;
        }
    }
    
    return 0;
}


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

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using pll = pair<ll,ll>;

#define INF (1LL << 60)
#define MOD 1000000007
#define PI 3.14159265358979323846

#define REP(i,m,n) for(ll (i)=(m),(i_len)=(n);(i)<(i_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define PR(x) cout << (x) << endl
#define PS(x) cout << (x) << " "
#define SZ(x) ((ll)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define REV(x) reverse(ALL((x)))
#define ASC(x) sort(ALL((x)))
#define DESC(x) ASC((x)); REV((x))
#define pb push_back
#define eb emplace_back

int main()
{
    string S;
    cin >> S;

    ll cnt1 = 0, cnt2 = 0, N = SZ(S);
    REP(i,0,N) {
        if(S[i] == '0' && i % 2 == 0) ++cnt1;
        else if(S[i] == '1' && i % 2 == 1) ++cnt1;
        else if(S[i] == '0' && i % 2 == 1) ++cnt2;
        else ++cnt2;
    }
    PR(MIN(cnt1,cnt2));

    return 0;
}

/*



*/

Measured memory_bytes: 3756
//#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<cstdio>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#include<utility>
#include<algorithm>
#include<cstring>
#include<sstream>
#include <iomanip>

using namespace std;

typedef long long ll ;
typedef double db;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef vector< pair<int,int> > vii;
const double pi = 2*acos(0) ;

#define pf		  	printf
#define sf			  scanf
#define pb(a)         push_back(a)
#define mp			make_pair
#define fi			 first
#define se			 second
#define for0(i,n)        for(int i=0;i<n;i++)
#define for1(i,n)        for(int i=1;i<=n;i++)
#define forab(i,a,b)       for(int i=a;i<=b;i++)
#define lcm(a, b)     ((a)*((b)/gcd(a,b)))
#define sq(a)		   (a)*(a)
#define nw				"\n"
#define abs(x)		fabs(x)
#define pcase(z,x)    cout<<"Case "<<z<<": "<<x<<"\n"

int main()
{
	int n,p,q;
	cin>>n;
	vi num,x(n),y(n);
	for0(i,n){
		cin>>x[i];
		cin>>y[i];
		num.pb(i);
		}
	int cnt=0;
	db ans,total=0;
	do{
		cnt++;
		db res=0;
		for0(i,n-1){
			p = x[num[i]] - x[num[i+1]];
			q = y[num[i]] - y[num[i+1]];
			res += sqrt(p*p + q*q);
			}
		total += res;
		} while(next_permutation(num.begin(),num.end()));
		
		ans=total/((db)cnt);
		pf("%.9lf\n",ans);
	return 0;
}

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

int main(){
    int S,W;
    cin >> S >> W;
    if(W>=S){
        cout << "unsafe" << endl;
    }else{
        cout << "safe" << endl;
    }
    return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define MOD 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()
#define CIN(v) cin >> v;
#define COUT(v) cout << v << "\n";

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

  ll A, B, K;

  CIN(A >> B >> K);

  if (K <= A) {
    COUT(A - K << " " << B)
    return 0;
  }

  if (K - A <= B) {
    COUT(0 << " " << B - (K - A));
    return 0;
  }

  COUT(0 << " " << 0);

  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.nio.CharBuffer;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        SimpleScanner scanner = new SimpleScanner(System.in);
        PrintWriter writer = new PrintWriter(System.out);

        int n = scanner.nextInt();
        int[] p = new int[n];
        for (int i = 0; i < n; ++i)
            p[i] = scanner.nextInt();
        int ans = 0;
        for (int i = 1; i < n - 1; ++i) {
            if ((p[i] > p[i - 1] && p[i + 1] > p[i]) || (p[i] < p[i - 1] && p[i + 1] < p[i]))
                ++ans;
        }
        writer.println(ans);

        writer.close();
    }

    private static class SimpleScanner {

        private static final int BUFFER_SIZE = 10240;

        private Readable in;
        private CharBuffer buffer;
        private boolean eof;

        SimpleScanner(InputStream in) {
            this.in = new BufferedReader(new InputStreamReader(in));
            buffer = CharBuffer.allocate(BUFFER_SIZE);
            buffer.limit(0);
            eof = false;
        }


        private char read() {
            if (!buffer.hasRemaining()) {
                buffer.clear();
                int n;
                try {
                    n = in.read(buffer);
                } catch (IOException e) {
                    n = -1;
                }
                if (n <= 0) {
                    eof = true;
                    return '\0';
                }
                buffer.flip();
            }
            return buffer.get();
        }

        void checkEof() {
            if (eof)
                throw new NoSuchElementException();
        }

        char nextChar() {
            checkEof();
            char b = read();
            checkEof();
            return b;
        }

        String next() {
            char b;
            do {
                b = read();
                checkEof();
            } while (Character.isWhitespace(b));
            StringBuilder sb = new StringBuilder();
            do {
                sb.append(b);
                b = read();
            } while (!eof && !Character.isWhitespace(b));
            return sb.toString();
        }

        int nextInt() {
            return Integer.valueOf(next());
        }

        long nextLong() {
            return Long.valueOf(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21204
#include<bits/stdc++.h>
#define IOS ios::sync_with_stdio(0),cin.tie(0);
#define ll long long
#define int ll
#define pii pair<int,int>
#define pb push_back
#define fi first
#define se second
#define all(n) (n).begin(),(n).end()
using namespace std;
signed main(){
	IOS;
	int n,a,b,c,d;
	cin>>n>>a>>b>>c>>d;
	int dif = abs(a-b);
	n -- ;
	int l = c * n , r = d * n;
	
	bool ok = 0;
	for(int i = 0;i < n;i++){
		if(dif>=l && dif <=r) ok =1;
		l -= c+d , r -= c+d;
	}
	cout<<(ok?"YES\n":"NO\n");
	
}


Measured memory_bytes: 256
#include <cstdio>

int N, A[100010];

int gcd(int x, int y){
  if(x == 0 || y == 0) return x + y;
  if(x == 1 || y == 1) return 1;

  for(;;){
    int t = x % y;
    if(t == 0) return y;
    x = y; y = t;
  }

  return -1;
}

bool sim(){ // can first win?
  int s = 0;
  for(int i = 0; i < N; i++){
    s = (s + A[i]) % 2;
  }

  if(N % 2 == 1 && s == 0) return true;
  if(N % 2 == 0 && s == 1) return true;
  if(N % 2 == 0 && s == 0) return false;

  int oc = 0, oi = -1;
  for(int i = 0; i < N; i++){
    if(A[i] % 2 == 1){ oc++; oi = i; }
  }

  if(oc != 1 || A[oi] == 1) return false;

  A[oi]--;

  int g = 0;
  for(int i = 0; i < N; i++) g = gcd(g, A[i]);
  for(int i = 0; i < N; i++) A[i] /= g;

  return !sim();
}

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

  puts(sim() ? "First" : "Second");

  return 0;
}


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

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

  string s,t, u;
  int a,b;
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if (s == u) a--;
  else if (u == t) b--;
  cout << a << " " << b;

}


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

string s;
stack<char> st;
int main(){
  cin>>s;
  for(int i=0;i<(int)s.size();i++){
    if(s[i]=='S'){
      st.push( s[i] );
    }else{
      if(!st.empty() && st.top()=='S'){
        st.pop();
      }else{
        st.push('T');
      }
    }
  }
  cout<<st.size()<<endl;
  return 0;
}


Measured memory_bytes: 644
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int H, W, a[101][11], c;
int main() {
	while (true) {
		cin >> H; if (H == 0)break; if (c)cout << endl; cin >> W;
		vector<pair<int, int>>v;
		for (int i = 0; i <= H; i++) {
			for (int j = 0; j <= W; j++) {
				string S; cin >> S; if (S == "?") { a[i][j] = -(1 << 30); v.push_back(make_pair(i, j)); }
				else a[i][j] = stoi(S);
			}
		}
		for (int i = 0; i <= H*W; i++) {
			for (int j = 0; j < W; j++) {
				int f = 0, g = 0, h = 0;
				for (int k = 0; k < H; k++) { if (a[k][j] == -(1 << 30)) { g++; h = k; } else { f += a[k][j]; } }
				if (g == 1) { a[h][j] = a[H][j] - f; }
			}
			for (int j = 0; j < H; j++) {
				int f = 0, g = 0, h = 0;
				for (int k = 0; k < W; k++) { if (a[j][k] == -(1 << 30)) { g++; h = k; } else { f += a[j][k]; } }
				if (g == 1) { a[j][h] = a[j][W] - f; }
			}
		}
		bool flag = true; for (int i = 0; i <= H; i++) { for (int j = 0; j <= W; j++) { if (a[i][j] == -(1 << 30))flag = false; } }
		if (flag == false) cout << "NO" << endl;
		else { for (pair<int, int> i : v)cout << a[i.first][i.second] << endl; }
		c++;
	}
	return 0;
}

Measured memory_bytes: 2956
N, M = map(int, input().split())
INF = 10 ** 9
adjs = [[INF] * N for _ in range(N)]
for i in range(N):
    adjs[i][i] = 0
edges = []
for _ in range(M):
    a, b, c = map(lambda x: int(x) - 1, input().split())
    c += 1
    edges.append((a, b, c))
    adjs[a][b] = adjs[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            adjs[i][j] = min(adjs[i][j], adjs[i][k] + adjs[k][j])

print(sum(adjs[a][b] != c and adjs[b][a] != c for a, b, c in edges))


Measured memory_bytes: 3436
def check_broken(width, height, maps, strength)
  count = 0
  (-1..1).each do |i|
    (-1..1).each do |j|
      next if i ==0 && j == 0
      if maps[width + i][height + j].zero?
        strength -= 1 
      end
      if strength < 1
        return true
      end
    end
  end
  return false
end

def check_can_break_area(start_width, end_width, start_height, end_height, maps)
  can_break_area = []
  for i in (start_width..end_width)
    for j in (start_height..end_height)
      strength = maps[i][j]
      next if strength.zero?
      can_break_area << [i, j] if 1 <= strength && strength < 9
    end
  end
  can_break_area
end

w, h = gets.split(" ").map(&:to_i)
maps = []
w.times do |i|
  chara = []
  gets.chomp.each_char do |char|
    if char == "." || (char.to_i) > 0
      chara << char.to_i
    end
  end
  maps << chara
end
can_break_area = check_can_break_area(1, w - 2, 1, h - 2, maps)
wave = 0
while true
  next_can_break_area = []
  can_break_area.each do |width, height|
    strength = maps[width][height]
    next_can_break_area << [width, height] if check_broken(width, height, maps, strength)
  end
  can_break_area = []
  next_can_break_area.each do |width, height|
    maps[width][height] = 0
  end
  next_can_break_area.each do |width, height|
    can_break_area += check_can_break_area(-1 + width, 1 + width, -1 + height, 1 + height, maps)
  end
  if next_can_break_area.length > 0
    wave += 1
  else
    break
  end
  can_break_area.uniq!
end

puts wave


Measured memory_bytes: 114652
#include<vector>
#include<map>
#include<algorithm>
#include<set>
#include<iostream>
#include<string>
#include<set>
#include<queue>
#include<random>

using namespace std;

#pragma GCC optimize("Ofast")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")

#define pb push_back
#define ld long double
#define ll long long
#define mp make_pair

int32_t main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
    int k;
    cin >> k;
    int sum = 0;
    for (int i = 1; i <= k; i++){
        for (int j = 1; j <= k; j++){
            for (int l = 1; l <= k; l++){
                sum += __gcd(i, __gcd(l, j));
            }
        }
    }
    cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
int main(){
int bingo[3][3];
  for(int i=0;i<3;i++){
  	for(int j=0;j<3;j++){
    	cin>>bingo[i][j];
    }
  }
  int N;
  cin>>N;
  for(int i=0;i<N;i++){
  	int a;
    cin>>a;
    for(int i=0;i<3;i++){
  		for(int j=0;j<3;j++){
    		if(bingo[i][j]==a){
            bingo[i][j]=12345;
            }
   		}
  	}
  }
  bool nazo=false;
 for(int i=0;i<3;i++){
 	if(bingo[i][0]==bingo[i][1] && bingo[i][1]==bingo[i][2]){
    nazo=true;
    }
   	if(bingo[0][i]==bingo[1][i] && bingo[1][i] ==bingo[2][i]){
    nazo=true;
    }
 }
  if(bingo[0][0]==bingo[1][1] && bingo[1][1]==bingo[2][2]){
  nazo=true;
  }
  if(bingo[0][2]==bingo[1][1] && bingo[1][1]==bingo[2][0]){
  nazo=true;
  }
  if(nazo){
  cout<<"Yes";
  }
  else{
  cout<<"No"<<endl;  
  }
}

Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
 
int32_t main(){
    ios_base::sync_with_stdio(0); 
    cin.tie(0);
    int n;
  cin>>n;
  if(n>=30){
  cout<< "Yes\n";
  }
  else{
  cout<< "No\n";}
 
 
    
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int x = scan.nextInt();
		int a = scan.nextInt();
		int b = scan.nextInt();
		scan.close();
		x-=a;
		while(x>=b) {
			x-=b;
		}
		System.out.println(x);

	}
}


Measured memory_bytes: 22996
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

//long long int ar[100013];
long int gcd(long int a, long int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
//int sieve(long long int a)
//{
//    long long int i,j;
//    memset(ar,0,sizeof(ar));
//    for(i=2; i<=a; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=a; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//    if(ar[a]==0)
//        return 1;
//    else
//        return 0;
//}

void Ok()
{
    long int a,b,c,h,t,i = 0,j = 0,k = 0,l,m,n,lo,hi,r;
    long int ans_1,ans_2,ans_3,cnt = 0,Max,Min,flag = 0,temp,sum;
    long double aa,bb,cc,dd,ee,ff,gg;
    char aaa[1013],bbb[1013],ccc,ddd;
    string spc,in[113],rev;

    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c<<endl;

    return;
}

int main()
{
    Ok();

    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long a;
        a = sc.nextLong();
        long b;
        b = sc.nextLong();

        final Solver solver = new Solver();
        solver.solve(a, b);
    }
}

class Solver {
    public void solve(long a, long b) {
        int small = (int) Math.min(a, b);
        int large = (int) Math.max(a, b);
        for (int i = 0; i < large; i++) {
            System.out.print(small);
        }
        System.out.println();
    }
}



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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int n, h, w;
  std::cin >> n >> h >> w;
  std::cout << (n - h + 1) * (n - w + 1) << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <cmath>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <stack>
#include <unordered_map>
#include <utility>
#include <vector>

// Aliases
using i32 = int32_t;
using i64 = int64_t;
using u32 = uint32_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;
using ll = long long;
using ull = unsigned long long;

using std::cout;
using std::cerr;
using std::cin;
using std::endl;
using std::string;
using std::vector;
using std::array;
template <class T>
using matrix = vector<vector<T>>;
template <class T>
constexpr T inf = std::numeric_limits<T>::max();
template <class T>
constexpr T neg_inf = -std::numeric_limits<T>::max();
template <class T>
constexpr T pi = static_cast<T>(3.141592653589793);

template <class T = i64>
vector<T> read_vector(const u64 n)
{
    vector<T> vec;
    vec.reserve(n);
    for (u64 i = 0; i < n; i++)
    {
        T v;
        cin >> v;
        vec.emplace_back(v);
    }

    return vec;
}

template <class T>
void print(const vector<T>& vec, const bool new_line = false)
{
    const u64 n = vec.size(); 
    if (new_line)
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << '\n'; }
        }
    }
    else
    {
        for (u64 i = 0; i < n; i++)
        {
            cout << vec[i];
            if (i != n - 1) { cout << ' '; }
        }
    }

    cout << endl;
}

int main()
{
    u32 n;
    cin >> n;
    auto vec = read_vector<u32>(n);
    std::sort(vec.begin(), vec.end());

    u32 sum = 0;
    for (u32 i = 0; i < n; i++)
    {
        for (u32 j = i + 1; j < n; j++)
        {
            u32 p = vec[i] + vec[j];
            u32 k = j + 1;
            auto itr = std::lower_bound(vec.begin() + k, vec.end(), p);
            u32 d = std::distance(vec.begin() + k, itr);
            sum += d;
        }
    }

    cout << sum << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repr(i,n) for(int i=(n)-1;i>=0;i--)
#define repf(i,j,n) for(int i=(j);i<(n);i++)


signed main(){
	int h,w;cin>>h>>w;
	vector<string>s(h);
	for(auto&& u:s)cin>>u;

	vector<vector<int>>l(h+2,vector<int>(w+2,0));
	vector<vector<int>>r(h+2,vector<int>(w+2,0));
	vector<vector<int>>u(h+2,vector<int>(w+2,0));
	vector<vector<int>>d(h+2,vector<int>(w+2,0));

//  int l[h+2][w+2],r[h+2][w+2],u[h+2][w+2],d[h+2][w+2];



	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
		if(s[i-1][j-1]=='.'){
		l[i][j]=l[i][j-1]+1;
		u[i][j]=u[i-1][j]+1;
		}
	}

  for(int i=h;i>=1;i--)for(int j=w;j>=1;j--){
		if(s[i-1][j-1]=='.'){
		r[i][j]=r[i][j+1]+1;
		d[i][j]=d[i+1][j]+1;
	}
	}

  int ret=0;
	for(int i=1;i<=h;i++)for(int j=1;j<=w;j++){
	if(s[i-1][j-1]=='.')ret=max(ret,l[i][j]+u[i][j]+r[i][j]+d[i][j]-3);
	}
	cout<<ret<<endl;

}


Measured memory_bytes: 129920
#include <iostream>
#define N 100001
using namespace std;
int Search(int);
int Check(int);
int n,k,w[N];
int main(){
  int r,sum=0,i;
  cin >> n >> k;
  for(i=0;i<n;i++) cin >> w[i],sum+=w[i];
  r=Search(sum);
  cout << r << endl;
  return 0;
}
int Search(int right){
  int r,left=0,mid,flag=0;
  while(1){
    mid=(left+right)/2;
    r=Check(mid);
    if(r==0) left=mid;
    else if(r==1) right=mid; 
    if(left+1==right) break;
  }
  return right;
}
int Check(int m){
  int sum=0,cnt=0,i,j;
  for(i=0;i<n;i++){
    j=i;
    while(1){
      if(w[j]>m) return 0;
      if(j<=n-1&&sum+w[j]<=m){
	sum+=w[j];
	j++;
      }else break;
    }
    sum=0;
    i=j-1;
    cnt++;
  }
  if(cnt<=k) return 1;
  return 0;
}

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

using namespace std;

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,t;
    cin >> n >> t;
    vector<pair<int, int> > ab(n+1);
    vint a(n);
    vint b(n);
    REP(i,n){
        cin >> a[i] >> b[i];
        ab[i+1] = make_pair(a[i],b[i]);
    }
    vvint dp(n+1, vint(t,0));
    for(int i=1;i<=n;i++){
        auto p = ab[i];
        REP(j,t){
            if(j>=p.fi){
                dp[i][j] = max(dp[i-1][j], dp[i-1][j-p.fi]+p.se);
            }else{
                dp[i][j] = max(dp[i-1][j], dp[i-1][j]);
            }
        }
    }
    vvint rdp(n+2, vint(t,0));
    for(int i=n;i>=1;i--){
        auto p = ab[i];
        REP(j,t){
            if(j>=p.fi){
                rdp[i][j] = max(rdp[i+1][j], rdp[i+1][j-p.fi]+p.se);
            }else{
                rdp[i][j] = max(rdp[i+1][j], rdp[i+1][j]);
            }
        }
    }
    int ans = 0;
    for(int i=1;i<=n;++i){
        REP(j,t){
            int tmp = 0;
            tmp += dp[i-1][j];
            tmp += rdp[i+1][t-1-j];
            tmp += b[i-1];
            ans = max(tmp, ans);
        }
    }
    
    cout << ans << endl;
    return 0;
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

const int dx[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy[8] = { 0,1,1,1,0,-1,-1,-1 };


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d))cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
string s;
cin>>s;
ll a[3]={};
ll n=s.size();
for(ll i=0; i<n; i++){
if(s.at(i)=='a'){
a[0]++;}
else if(s.at(i)=='b'){
a[1]++;}
else{
a[2]++;}}
sort(a,a+3);
if(a[2]-a[0]<=1){
cout << "YES" << endl;}
else{
cout << "NO" << endl;}}

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;
    vector<int> ans(n, 0);
    int x;
    n--;
    while (n--){
      cin >> x;
      ans[x-1]++;
    }

    for (auto i : ans) cout << i << '\n';

    return 0;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  	string s;
  	int cnt(0);
  
  	cin >> s;
    for(int i = 0;i < 3;i++){
      if(s.at(i) == 'o'){
        cnt++;
      }
    }
  cout << 700 + cnt*100;
      
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
    string st;
    cin >> st;
    rep(i, 19) if(st.at(i) == ',') st.at(i) = ' ';
    cout << st << endl;
    return 0;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())
    A = list(map(int, input().split()))

    res = 0
    for i in range(1, n):
        if A[i - 1] > A[i]:
            res += A[i - 1] - A[i]
            A[i] = A[i - 1]
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 31584
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
#include <stack>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

int dx4[4]={1,0,-1,0};
int dy4[4]={0,-1,0,1};
int dx8[8]={1,0,-1,1,-1,1,0,-1};
int dy8[8]={1,1,1,0,0,-1,-1,-1};
int dx9[9]={0,1,0,-1,1,-1,1,0,-1};
int dy9[9]={0,1,1,1,0,0,-1,-1,-1};

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;
typedef pair<ll, ll> PLL;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;
// << fixed << setprecision
// --------------------------------------
int x, y;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> x >> y;

  bool f = false;
  REP(i, x + 1) {
    if((y - ((x - i) * 2)) % 4 == 0 && (y - ((x - i) * 2)) / 4 == i) f = true;
  }

  cout << (f ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3652
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.sql.SQLOutput;
import java.util.*;
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    static void bin(int n) {
        if (n > 1)
            bin(n/2);

        System.out.print(n % 2);
    }
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }
    static class Pair<a , b>{
        a v1;
        b v2;
        Pair(a v1 , b v2){
            this.v1 = v1;
            this.v2 = v2;
        }
    }
    static class TaskA {
        static int lastdigit(int a){
            while (a/10>0){
                a/=10;
            }
            return a%10;

        }
        public void solve(int testNumber, InputReader in, PrintWriter out){
            int n = in.nextInt();
            int[][] count = new int[10][10];
            for (int i = 1; i <=n;i++) {
                count[lastdigit(i)][i%10]++;
            }
            long ans=0;
            for (int i = 1; i <10; i++){
                for (int j = 1; j <10;j++) {
                    ans+=count[i][j]*count[j][i];
                }
            }
            System.out.println(ans);






        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }
        public int nextInt(){return  Integer.parseInt(next());}
        public long nextLong() {
            return Long.parseLong(next());
        }

    }
}

Measured memory_bytes: 21460
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  vector<ll> s(n + 1, 0);
  for (int i = 0; i < n; ++i) {
    s[i + 1] = s[i] + a[i];
  }
  map<ll, ll> mp;
  for (int i = 0; i <= n; ++i) {
    mp[s[i] % m]++;
  }
  ll ans = 0;
  for (auto a : mp) {
    ans += a.second * (a.second - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 5376
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

string S;

int main(){
	cin >> S;
	if(S[0] == 'R' && S[1] == 'R' && S[2] == 'R') {
		cout << 3 << endl;
	} else if ((S[0] == 'R' && S[1] == 'R') || (S[1] == 'R' && S[2] == 'R')) {
		cout << 2 << endl;
	} else if (S[0] == 'R' || S[1] == 'R' || S[2] == 'R') {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}

}

Measured memory_bytes: 3620