akhauriyash/Code-Regression huggingface dataset:
using System;

namespace ABC159c
{
    class Program
    {
        static void Main(string[] args)
        {
            int L = int.Parse(Console.ReadLine());

            int w = (int)(L / 3);

            double max = 0;
            for (double i = w; i < w+1; i=i+0.001)
            {
                for (double j = w; j < w+1; j=j+0.001)
                {
                    double d = L - i - j;
                    double v = i * j * d;
                    if(max < v)
                    {
                        max = v;
                    }
                }
            }

            Console.WriteLine(max);
        }
    }
}


Measured memory_bytes: 11092
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main(void){

    int A, B, C, D;

    scanf("%d%d%d%d", &A, &B, &C, &D);

    if(B < C){
        printf("0\n");
    }else if(A <= C && B <= D){
        printf("%d\n", B - C);
    }else if(A <= C && D < B){
        printf("%d\n", D - C);
    }else if(B <= D){
        printf("%d\n", B - A);
    }else if(A < D){
        printf("%d\n", D - A);
    }else{
        printf("0\n");
    }

    return 0;
}

Measured memory_bytes: 1688
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <unordered_map>
#include <set>
#include <algorithm>
#include <utility>
#include <cmath>
using namespace std;

typedef long long llong;
typedef unsigned long long ullong;
// -2.1e-9 <= int <= 2.1e9
// -9.2e-18 <= long long <= 9.2e18
// 0 <= unsigned int <= 4.2e9
// 0 <= unsigned long long <= 18.4e18
// cout << fixed << setprecision(10);

int main() {
    uint N;
    cin >> N;
    vector<ullong> A(N+1);
    for (size_t i=1; i<A.size(); ++i) {
        cin >> A[i];
    }

    ullong deno = ullong(1e9+7);
    vector<ullong> subSum(N+1);
    subSum[A.size()-1] = A[A.size()-1];
    for (int j=A.size()-2;j>=2; --j) {
        subSum[j] = subSum[j+1] + A[j];
        if (subSum[j] >= deno)
            subSum[j] %= deno;
    }

    ullong sum = 0;
    for (size_t i=1; i<=N-1; ++i) {
        ullong mul = A[i] * subSum[i+1];
        if (mul >= deno)
            mul %= deno;
        sum = sum + mul;
        if (sum >= deno)
            sum %= deno;
    }

    cout << sum << endl;
    return  0;
}


Measured memory_bytes: 6428
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define loop(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  loop(i,0,n)
#define all(c) c.begin(),c.end()
#define rall(c) c.rbegin(),c.rend()
#define vi vector<int>
#define vl vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>

int main(){
    int a,b;
    cin>>a>>b;
    if(a>b){
        cout<<a+a-1<<endl;
    }
    else if(a==b)cout<<2*a<<endl;
    else cout<<b+b-1<<endl;
    
}

Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>

#define in std::cin
#define out std::cout

char S[100000000];
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);

	in >> S;
	int32_t count[4] = {};
	auto g = [](char c) {
		switch (c)
		{
		case 'N':return 0;
		case 'W':return 1;
		case 'S':return 2;
		case 'E':return 3;
		}
		return 0;
	};
	for (auto i = S;*i != '\0';++i)
	{
		++count[g(*i)];
	}

	if (
		(count[g('N')] > 0) == (count[g('S')] > 0) &&
		(count[g('W')] > 0) == (count[g('E')] > 0)
		) {
		out << "Yes";
	}
	else {

		out << "No";
	}
	out << endl;
	return 0;
}
#endif


Measured memory_bytes: 256
import math
mod=10**9+7
n=int(input())*2
S=list(input())
# Lを1、Rを0としてDP
dp=[0]*(n)
dp[0]=1
if S[0]=='W' or S[-1]=='W':
	print(0)
	exit()
for i in range(1,n):
	# print(S,i)
	if S[i]==S[i-1]:
		dp[i]=0 if dp[i-1] else 1
	else:
		dp[i]=1 if dp[i-1] else 0

count=1
counter=[0]*2
for i in range(n):
	if dp[i]==0:
		count*=counter[1]-counter[0]
		count%=mod
	counter[dp[i]]+=1
if counter[0]!=counter[1]:
	print(0)
	exit()

print((count*math.factorial(n//2))%mod)
# print(dp)




Measured memory_bytes: 63216
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        a: [usize; n],
    }
    if a[0] > 0 || (1..n).any(|i| a[i - 1] + 1 < a[i]) {
        println!("-1");
        return;
    }
    let mut result = a[n - 1];
    let mut r = n - 1;
    for i in (1..n - 1).rev() {
        if a[i] + (r - i) > a[r] {
            result += a[i];
            r = i;
        }
    }
    println!("{}", result);
}


Measured memory_bytes: 5328
const INF: i64 = 1 << 60;

fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    
    let n: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let m: usize = iter.next().unwrap().parse::<usize>().unwrap();
    let r_len: usize = iter.next().unwrap().parse::<usize>().unwrap();
    
    let mut r: Vec<usize> = (&mut iter).take(r_len).map(|x| x.parse::<usize>().unwrap() - 1).collect();

    let mut d = vec![vec![INF;n];n];
    for i in 0..n {
        d[i][i] = 0;
    }

    for _ in 0..m {
        let a: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let b: usize = iter.next().unwrap().parse::<usize>().unwrap()-1;
        let c: i64 = iter.next().unwrap().parse::<i64>().unwrap();
        d[a][b] = c;
        d[b][a] = c;
    }
    
    warshall_floyd(&mut d);

    let mut min = INF;
    r.sort();
    loop {
        let mut dist = 0i64;
        for i in 0..r_len-1 {
            dist += d[r[i]][r[i+1]];
        }
        min = std::cmp::min(min, dist);
        if !r.next_permutation() {break;}
    }
    println!("{}", min);
}

#[doc = " d[x][y] = cost or INF, d[i][i] = 0"]
pub fn warshall_floyd(d: &mut [Vec<i64>]) {
    let n = d.len();
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                d[i][j] = std::cmp::min(d[i][j], d[i][k] + d[k][j]);
            }
        }
    }
}

#[doc = " https://github.com/bluss/permutohedron"]
#[allow(dead_code)]
pub trait LexicalPermutation {
    #[doc = " Return `true` if the slice was permuted, `false` if it is already"]
    #[doc = " at the last ordered permutation."]
    fn next_permutation(&mut self) -> bool;
    #[doc = " Return `true` if the slice was permuted, `false` if it is already"]
    #[doc = " at the first ordered permutation."]
    fn prev_permutation(&mut self) -> bool;
}
#[allow(dead_code)]
impl<T> LexicalPermutation for [T]
where
    T: Ord,
{
    fn next_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] >= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        let mut j = self.len() - 1;
        while j >= i && self[j] <= self[i - 1] {
            j -= 1;
        }
        self.swap(j, i - 1);
        self[i..].reverse();
        true
    }
    fn prev_permutation(&mut self) -> bool {
        if self.len() < 2 {
            return false;
        }
        let mut i = self.len() - 1;
        while i > 0 && self[i - 1] <= self[i] {
            i -= 1;
        }
        if i == 0 {
            return false;
        }
        self[i..].reverse();
        let mut j = self.len() - 1;
        while j >= i && self[j - 1] < self[i - 1] {
            j -= 1;
        }
        self.swap(i - 1, j);
        true
    }
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

vll adj[MAXN]; ll visit[MAXN] = {};
int dx8[] = {0, 1, 1, 1, 0, -1, -1, -1}, dy8[] = {1, 1, 0, -1, -1, -1, 0, 1};
int dx4[] = {0, 1, 0, -1}, dy4[] = {1, 0, -1, 0};

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, x, m, y, k;
string s;


// <------------- Implement Functions Here ----------> //


// <------------- Start of main() -------------------> //

void MAIN() {
	cin >> s ;
	cin >> x >> y ;
	n = s.length();
	vll X, Y;
	ll t = 0, c = 0;
	set<ll> val,temp;

	for (ll i = 0; i < n; i++) {
		if (s[i] == 'F') {
			c++;
		}
		else {
			if (t % 2 == 0) {
				X.pb(c);
			} else {
				Y.pb(c);
			}
			c  = 0;
			t ^= 1;
		}
	}
	if (t % 2 == 0) {
		X.pb(c);
	} else {
		Y.pb(c);
	}

	if(X.size()) {
		val.insert(X[0]);
		for(ll i=1;i<X.size();i++) {
			for(auto it : val) {
				temp.insert(it + X[i]);
				temp.insert(it - X[i]);
			}
			val = temp;
			temp.clear();
		}
		if(val.count(x)==0) {
			cout<<"No\n";
			return;
		}
	}

	if(X.size()) {
		val.clear();
		temp.clear();
		val.insert(0);
		for(ll i=0;i<Y.size();i++) {
			for(auto it : val) {
				temp.insert(it + Y[i]);
				temp.insert(it - Y[i]);
			}
			val = temp;
			temp.clear();
		}
		if(val.count(y)==0) {
			cout<<"No\n";
			return;
		}
	}
	
	cout<<"Yes\n";
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 238400
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
LL n,a,b,c,d;
int T;
map<LL,LL>mp;
LL dfs(LL x,LL cost){
	if(x==0)return cost;
	if(x==1)return cost+d;
	LL res=2e18;
	if((1e18-cost)/x>d)res=min(res,x*d+cost);
	if(mp[x])return mp[x]+cost;
	
	for(LL i=-4;i<=4;i++){
		if((x+i)>0&&(x+i)%5==0&&(x+i)/5<x){ //cout<<x+i<<endl;
			res=min(res,dfs((x+i)/5,cost+c+abs(i)*d));
		}
	}
	for(LL i=-2;i<=2;i++){
		if((x+i)>0&&(x+i)%3==0&&(x+i)/3<x){//cout<<x+i<<endl;
			res=min(res,dfs((x+i)/3,cost+b+abs(i)*d));
		}
	}
	for(LL i=-1;i<=1;i++){
		if((x+i)>0&&(x+i)%2==0&&(x+i)/2<x){//cout<<x+i<<endl;
			res=min(res,dfs((x+i)/2,cost+a+abs(i)*d));
		}
	}
	mp[x]=res-cost;
	return res;
}
int main(){
	scanf("%d",&T);
	while(T--){
		mp.erase(mp.begin(),mp.end());
		scanf("%lld%lld%lld%lld%lld",&n,&a,&b,&c,&d);
		cout<<dfs(n,0)<<endl;
	}
}

Measured memory_bytes: 4552
#include<stdio.h>

int main(void){

	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a<=b&&b<=c){
	printf("%d %d %d\n",a,b,c);
	}
	else if(c<=b&&b<=a){
	printf("%d %d %d\n",c,b,a);
	}
	else if(b<=a&&a<=c){
	printf("%d %d %d\n",b,a,c);
	}
	else if(c<=a&&a<=b){
	printf("%d %d %d\n",c,a,b);
	}
	else if(a<=c&&c<=b){
	printf("%d %d %d\n",a,c,b);
	}
	else if(b<=c&&c<=a){
	printf("%d %d %d\n",b,c,a);
	}
	return 0;
}

Measured memory_bytes: 596
def binarySearch(n, a):
    ok = -1  # when minimize
    ng = len(a)  # when maximize
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if a[mid] == n:
            return 1
        elif a[mid] < n:
            ok = mid
        else:
            ng = mid
    return 0


def resolve():
    import sys
    input = sys.stdin.readline
    n = int(input())
    a = [int(i) for i in input().split()]
    q = int(input())
    kk = [int(i) for i in input().split()]
    for k in kk:
        if 0 == binarySearch(k, a):
            print(0)
            return
    print(1)


resolve()



Measured memory_bytes: 36516
import std.stdio;
import std.string;
 
void main()
{
    char[] s = readln.chomp.dup;
    char[] t = readln.chomp.dup;
    string ans = "No";

    foreach (i; 0..s.length){ 
        s = s[$ - 1] ~ s[0..$ - 1];
        if (s == t){
            ans = "Yes";
            break;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define int long long int
constexpr int INF = std::numeric_limits<int>::max();
constexpr int NINF = std::numeric_limits<int>::min();
using namespace std;

void solve() {
  int K, N;
  cin >> K >> N;

  vector<int> v(N);
  for (int &a: v) {
    cin >> a;
  }

  int ans = v.back() - v.front();
  for (int i = 1; i < v.size(); i++) {
    ans = min(ans, K-(v[i]-v[i-1]));
  }
  cout << ans << endl;
}

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 1792
/*input
7?4

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

// ALL DEFFINES HERE
#define ll long long int
#define ii pair<int, int>
#define mp make_pair

#define rep(i, n) for(int i=0; i < n; i++)
#define Rep(i, k, n) for(int i=k; i < n; i++)
#define pb push_back
#define vi vector<int>
#define vii vector< vector<int> >
#define vl vector<ll>
#define F first
#define S second
#define all(v) v.begin(), v.end()

// ALL declarations here const ints etc
const  ll mod = 1e9+7;
// const ll mod = 998244353; 
// const int MAXN = 1e5;

// IMPORTANT FUNCTION DECLARATIONS , 
//SORRY FOR THE BAD PRESENTATION
ll gcd(ll a, ll b)
{
	if ( b==0)
		return a;
	return gcd(b, a%b);
}
ll absl(ll a )
{
	return  a>= 0 ?a:-a;
}
ll maxl(ll a, ll b)
{
	return a >= b? a:b;
}
ll minl(ll a, ll b)
{
	return a <= b? a:b;
}
ll exp(ll a, ll n)
{
	if ( n==0)
		return 1;
	if ( n==1 )
		return a;
	if ( n & 1)
		return (a%mod * exp((a*a)%mod, n/2)%mod)%mod;
	else
		return exp((a*a)%mod, n/2)%mod;
}
// --->>> main starts here
// m*h >= l + k
double mi( double a , double b)
{
	return a < b? a : b;
}
double mx( double a , double b)
{
	return a >= b ? a : b;
}
void add(int &a, int b) {

	a += b;
	if (a >= mod) a -= mod;
	if (a < 0) a += mod;
	// return a;
}

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

// ll ceil( ll a  , ll b){  return ( a % b == 0 ? a/b : a/b +1); }

// int find( int i){ return (people[i] = i == people[i] ? i : find(people[i]));}

set<pair<int, int > > v;
int dx[4] = { 0 , 1, -1 , 0};
int dy[4] = { 1 , 0 , 0 , -1};

void solve()
{
	string s;
	cin >> s;
	int dp[100005][13]={{0}};
	int prev =0;
	dp[0][0]=1;
	for ( int i =0 ; i < s.length() ; i++)
	{
		int c;
		if ( s[i] == '?') c=-1;
		else c = s[i] -'0';

		for ( int j =0; j < 10; j++)
		{
			if ( c!= j && c!= -1)continue;
			
				for ( int k =0 ; k < 13; k++)
					add(dp[i+1][(10*k + j)%13], dp[i][k]);
			
		}
	}
	cout << dp[s.length()][5];

	
}
int main() 
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  #ifdef debug
   auto beginProgram = chrono::steady_clock::now();
  #endif
  // int t; cin >> t;
  // while (t--) 
  {
  	// cal();
    solve();
  }
  #ifdef debug
  auto endProgram = chrono::steady_clock::now();
  std::chrono::duration<double> diff = endProgram - beginProgram;
  cout << "\nTime: " <<diff.count()*1000 << " ms\n";
  #endif
  return 0;
}

Measured memory_bytes: 5584
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    boolean flag = false;
    
    for(int i = 1; i < b * a; i++){
      if((i * a - c) % b == 0){
        flag = true;
        break;
      }
    }
    
    if(flag){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 22996
#include <bits/stdc++.h>
typedef long long LL;
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
LL p = 1000000007ll;

int main(void)
{
  LL a,b;
  cin >> a >> b;
  if((a+b)%2) cout << "IMPOSSIBLE" << endl;
  else cout << (a+b)/2 << endl;
  return 0;
}


Measured memory_bytes: 256
n    = gets.to_i
ary  = gets.split.map(&:to_i)
aryC = Array.new(9, 0)

ary.each do |i|
  if i > 3200
    i = 3200
  end
  aryC[i / 400] += 1
end

changeable = aryC.pop
aryC.delete(0)

puts [[aryC.size, 1].max, aryC.size + changeable].join(" ")


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

#define ll long long int
#define endl '\n'
ll const mod = 1e9 + 7;

ll power(ll x, ll y, ll p){ //x^y % p
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {
        if (y & 1) // If y is odd, multiply x with result 
        res = (res*x) % p; 
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
}

ll MIN(ll a, ll b) {
    if(a<b) return a;   return b;
}

ll MAX(ll a, ll b) {
    if(a>b) return a;   return b;
}

int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    ll n, m;
    cin>>n>>m;
    
    ll sum=0;
    for(int i=0;i<m;i++)
    {
        ll x; cin>>x;
        sum+=x;
    }
    cout<<MAX(-1, n-sum);
    
	// your code goes here
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef long double ld;
#define MOD 1000000007
#define INF 1000000000
#define mp make_pair
#define pb push_back
#define ss second
#define ff first
#define endl '\n'
#define pl cout<<endl;
void fast() { ios_base::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL); }
const long long INFll=1ll*INF*INF;
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define debug(x) cout << x << endl;
#define sz(a) int((a).size())
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
    //unordered_map<long long, int, custom_hash>
    //gp_hash_table<long long, int, custom_hash>
};
long long genrand(long long L,long long R)
{
	return uniform_int_distribution<long long>(L, R)(rng);
}
int mul(int a, int b,int mod = MOD) {
	return int(a * 1ll * b % mod);
}
int norm(int a,int mod = MOD) {
	while(a >= mod) a -= mod;
	while(a < 0) a += mod;
	return a;
}
int powmod(int x,int y,int mod = MOD){
	int res = 1;
	while(y>0)
	{
		if(y&1)
			res = mul(res,x,mod);
		x = mul(x,x,mod);
		y=y>>1;
	}
	return res;
}
int inv(int a,int mod = MOD) {
	return powmod(a, mod - 2);
}
int main() {
	
	long double r; cin>>r;
	long double ans = 2 * PI * r;
	cout<<fixed<<setprecision(10)<<ans<<endl;
	
	return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, j, n) for (int i = j; i < n; i++)
#define out(ans) cout << ans << endl;
const ll mod = 1e9 + 7;


int main(){

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

  if(n==1){
    out(s[0]-'0');
    return 0;
  }

  reverse(s.begin(),s.end());

  bool e=true;
  rep(i,0,n-1){
    if(s[i]!='9'){e=false;break;}
  }
  if(e)out(s[n-1]-'0'+9*(n-1))
  else out((s[n-1]-'0'-1)+9*(n-1))

  return 0;
}


Measured memory_bytes: 256
import itertools
 
H, W, K = map(int, input().split())
S = []
for _ in range(H):
    S.append([int(s) for s in input()])
 
ans = 2000
for t in itertools.product([0, 1], repeat=H - 1):
    cnt = t.count(1)
    lst = [[s for s in S[0]]]
    for h in range(H - 1):
        if t[h]:
            lst.append(S[h + 1])
        else:
            lst[-1] = [lst[-1][i] + S[h + 1][i] for i in range(W)]
    L = len(lst)
    sum_lst = [0] * L
    for w in range(W):
        if max(lst[i][w] for i in range(L)) > K:
            break
        tmp = [sum_lst[i] + lst[i][w] for i in range(L)]
        if max(tmp) > K:
            cnt += 1
            sum_lst = [lst[i][w] for i in range(L)]
        else:
            sum_lst = tmp
    else:
        ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 3188
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		sc.next(); sc.next(); sc.next();
		System.out.println(sc.nextInt() == 1 ? 1 : 0);
	}
}


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

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;

int main() {
  ll N, M;
  cin >> N >> M;

  vector<ll> s0(N);
  vector<ll> s1(N);
  vector<ll> s2(N);
  vector<ll> s3(N);
  for (int i = 0; i < N; i++) {
    ll x, y, z;
    cin >> x >> y >> z;
    s0[i] = (x + y + z);
    s1[i] = (-x + y + z);
    s2[i] = (x - y + z);
    s3[i] = (x + y - z);
  }
  sort(s0.begin(), s0.end());
  sort(s1.begin(), s1.end());
  sort(s2.begin(), s2.end());
  sort(s3.begin(), s3.end());

  ll m00 = 0, m01 = 0;
  ll m10 = 0, m11 = 0;
  ll m20 = 0, m21 = 0;
  ll m30 = 0, m31 = 0;
  for (int i = 0; i < M; i++) {
    m00 += s0[i];
    m10 += s1[i];
    m20 += s2[i];
    m30 += s3[i];
  }
  for (int i = 0; i < M; i++) {
    m01 += s0[N - 1 - i];
    m11 += s1[N - 1 - i];
    m21 += s2[N - 1 - i];
    m31 += s3[N - 1 - i];
  }

  ll m0 = max(abs(m00), abs(m01));
  ll m1 = max(abs(m10), abs(m11));
  ll m2 = max(abs(m20), abs(m21));
  ll m3 = max(abs(m30), abs(m31));

  ll ans = max(m0, m1);
  ans = max(ans, m2);
  ans = max(ans, m3);
  cout << ans << "\n";
  return 0;
}

Measured memory_bytes: 256
n = int(input())
W = list(map(int, input().split()))
S = sum(W)

ans = abs(W[0] - (S - W[0]))
for i in range(1,n):
  k = abs(sum(W[0:i+1]) - (S - sum(W[0:i+1])))
  if k > ans:
    print(ans)
    exit()
  else:
    ans = k

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

int main() {
  int N, X, T;
  cin >> N >> X >> T;
  int count = 0;
  
  if (N % X != 0){
    count = (N / X) + 1;
  }
  else if (N % X ==0){
    count = N / X;
  }
  cout << count * T << endl;
}

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

using namespace std;

typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(0);
    ll n, x;
    cin >> n >> x;
    vector<ll> p(n + 1), b(n + 1);
    p[0] = 1;
    b[0] = 0;
    for (int i = 1; i < n + 1; ++i)
    {
        p[i] = 2 * p[i - 1] + 1;
        b[i] = 2 + 2 * b[i - 1];
    }
    ll odp = 0, lev = n;
    while (true)
    {
        --x;
        if (x == 0)
            break;
        if (b[lev - 1] + p[lev - 1] <= x)
        {
            x -= b[lev - 1] + p[lev - 1];
            odp += p[lev - 1];
            if (x == 0)
                break;
        }
        else
        {
            --lev;
            continue;
        }
        --x;
        ++odp;
        if (x == 0)
            break;
        if (b[lev - 1] + p[lev - 1] <= x)
        {
            x -= b[lev - 1] + p[lev - 1];
            odp += p[lev - 1];
            if (x == 0)
                break;
        }
        else
        {
            --lev;
            continue;
        }
        --x;
        if (x == 0)
            break;
    }
    cout << odp;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
		ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
		string a,b;
		cin>>a>>b;
		int j=0;
		for(int i=0;i<3;i++){
			j+=a[i]==b[i];
		}
		cout<<j;
		return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int X = sc.nextInt();

		if(X-A<=B&&X-A>=0){
			System.out.println("YES");
		}else{
			System.out.println("NO");
		}
	}

}


Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b;
  in(n);
  a = 0;
  b = 0;
  vector<ll> s(n + 1), t(n);
  rep(i, n + 1){
    in(s[i]);
    a += s[i];
  }
  rep(i, n)
    in(t[i]);
  rep(i, n){
    if(s[i] >= t[i]){
      s[i] -= t[i];
    }
    else{
      t[i] -= s[i];
      s[i] = 0;
      s[i + 1] = max(0ll, s[i + 1] - t[i]);
    }
  }
  rep(i, n + 1)
    b += s[i];
  out(a - b);
  memi;
}


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

int main(){
  int n, k;
  cin >> n >> k;

  int a;
  int one;
  for(int i = 0;i < n;i++){
    cin >> a;
    if(a == 1){
      one = i;
    }
  }

  int ans = INT_MAX;
  for(int i = 0;i < k;i++){
    int left = one-i;
    int right = left+k-1;
    ans = min(ans, 1 + (left+k-2)/(k-1) + (n-1-right+k-2)/(k-1));
  }

  cout << ans << endl;

  return 0;
}

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

#define N 1000
#define Q 1000000007

int main(void){
	int n, i, j;
	unsigned long long int num=1;
	char ar[N+1][N+1];
	int pf[N+1];
	int soe[N+1];

	scanf("%d", &n);
	for(i=2; i<=n; i++){
		soe[i] = 1;
	}
	for(i=2; i*i<=n; i++){
		if(soe[i] == 0) continue;
		for(j=i*2; j<=n; j+=i){
			soe[j] = 0;
		}
	}
	
	for(i=2; i<=n; i++){
		if(soe[i] == 0) continue;
		for(j=1; j*i<=n; j++){
			ar[i][j*i]=1;
			if(j%i == 0) ar[i][j*i] += ar[i][j];
		}
	}
	for(i=2; i<=n; i++){
		if(soe[i] == 0) continue;
		for(j=i; j<=n; j+=i){
			pf[i] += ar[i][j];
		}
	}
	for(i=2; i<=n; i++){
		if(soe[i] != 0){
			num = num * (pf[i]+1);
			num = num % Q;
		}
	}

	printf("%d\n", (int)num);

	return 0;
	
}

Measured memory_bytes: 768
N = int(input())
A = [_ for _ in map(int,input().split())]
B = [_ for _ in map(int,input().split())]
C = [_ for _ in map(int,input().split())]
Happy = 0
temp = -10**9
for i in range(N):
  Happy += B[A[i]-1]
  if A[i]-1 == (temp+1):
    Happy += C[temp]
  temp = A[i] - 1
print(Happy)

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

public class AtCoderA
{
    static void Main()
    {
        int k = int.Parse(Console.ReadLine());
        int[] nums = new int[] { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };

        int answer = nums[k - 1];
        Console.WriteLine(answer);
    }
}

Measured memory_bytes: 11092
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
         while(true){
         int H = sc.nextInt();
         int W = sc.nextInt();
         if(H == 0 && W == 0){
             break;
         }
         for(int i = 0; i < H; i++){
             for(int j= 0; j < W; j++){
                 if((0 != i % 2 && 0 == j % 2) || (0 == i % 2 && 0 != j % 2)){
                     System.out.print(".");
                 }else{
                 System.out.print("#");
             }
             }
             System.out.println("");
             }
             System.out.println("");
         }
}
}

Measured memory_bytes: 32752
#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() {
  int n, m;
  cin >> n >> m;
  int t=1;
  rep(i,m) t*=2;
  cout << (1900*m+(n-m)*100)*t << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
int main(void){
    string S;
int N;
cin >> N;
    cin >> S;
for(auto x:S){
    if(x+N-'A'>25)
      cout << char('A'+ N-('Z'-x)-1);
      
    else cout <<char( x+N);
}

    
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
vector<string> table(21);
int H,W;
int calc(int sy, int sx, int gy, int gx){
    queue<P> que;
    vector<vector<int> > dist(H, vector<int>(W,INF));
    dist[sy][sx] = 0;
    que.push(P(sy, sx));
    while(!que.empty()){
        auto p = que.front();
        que.pop();
        int dx[] = {1,-1,0,0};
        int dy[] = {0,0,1,-1};
        rep(i,0,4){
            int ny = p.first + dy[i];
            int nx = p.second + dx[i];
            if(ny < 0 || ny >= H || nx < 0 || nx >= W)continue;
            if(table[ny][nx] == '#')continue;
            if(dist[ny][nx] != INF)continue;
            if(dist[ny][nx] > dist[p.first][p.second]){
                dist[ny][nx] = dist[p.first][p.second] + 1;
                que.push(P(ny, nx));
            }

        }
    }
    if(dist[gy][gx] == INF)return -1;
    else return dist[gy][gx];
}
main(){
    cin >> H >> W;
    rep(i,0,H)cin >> table[i];
    int maxi = 0;
    rep(i,0,H)rep(j,0,W)rep(k,0,H)rep(l,0,W){
        if(table[i][j] == '#' || table[k][l] == '#')continue;
        maxi = max(maxi, calc(i,j,k,l));
    }
    cout << maxi << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int str_to_int(string str, int a[100]){
	int num = 0;
	int index = 0;
	for(int i = 0; i < str.size(); i++){
		if(str[i] == ','){
			a[index] = num;
			index++;
			num = 0;
		}else{
			num = num * 10 + (str[i] - '0');
		}
	}
	a[index] = num;
	index++;
	for(int i = index; i < 100; i++){
		a[i] = 0;
	}
	return index;
}

int main(){
	
	string str;
	int a[1000];
	int data[1000];
	
	for(int i = 0; i < 100; i++){
		a[0] = 0;
		data[i] = 0;
	}
	
	int pre_length = 0;
	
	while(true){
		cin >> str;
		if(cin.eof()){
			break;
		}
		int cur_length = str_to_int(str, a);
		if(pre_length > cur_length){
			for(int i = 0; i < 99; i++){
				a[i] = a[i] + max(data[i], data[i + 1]);
				//cout << a[i] << " ";
			}
			//cout << endl;
			for(int i = 0; i < 99; i++){
				data[i] = a[i];
			}
			data[99] = 0;
		}else{
			a[0] = a[0] + data[0];
			//cout << a[0] << " ";
			for(int i = 1; i < 100; i++){
				a[i] = a[i] + max(data[i], data[i - 1]);
				//cout << a[i] << " ";
			}
			//cout << endl;
			data[0] = a[0];
			for(int i = 1; i < 100; i++){
				data[i] = a[i];
			}
		}
		pre_length = cur_length;
		for(int i = 0; i < 10; i++){
			//cout << data[i] << " ";
		}
		//cout << endl;
	}
	
	cout << a[0] << endl;
	
	return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int p=1e9+7;
ll qmi(ll a,ll k)
{
    ll res=1;
    while(k)
    {
        if(k&1)
            res=res*a%p;
        a=a*a%p;
        k>>=1;
    }
    return res;
}
ll C(int a,int b)
{
    ll res=1;
    for(ll i=1,j=a;i<=b;i++,j--)
    {
        res=res*j%p;
        res=res*qmi(i,p-2)%p;
    }
    return res;
}
ll lucas(ll a,ll b)
{
    if(a<p&&b<p)
        return C(a,b);
    return
    C(a%p,b%p)*lucas(a/p,b/p)%p;
}
int main()
{
    ios::sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
	cout<<(qmi(2,n)-(lucas(n,a)%p+lucas(n,b)%p)%p-1+p)%p<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,i,a,four = 0,two = 0;scanf("%d",&N);
  for(i=0;i<N;i++){
    scanf("%d",&a);
    if(a%4==0) four++;
    else if(a%2==0) two++;
  }
  printf(four*2+max(0,two-1) >= N-1 ? "Yes\n":"No\n");
}

Measured memory_bytes: 3824
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define sz 200005
#define all(x) x.begin(),x.end()
#define l_b lower_bound
#define u_b upper_bound
#define pb push_back
#define MOD 1000000007
void fastio(void);

ll arr[sz];

bool poss(ll val, ll k, ll n){
    ll la, cnt=0;

    for(la=1;la<=n;la++){
        ll cur=arr[la]/val;
        if(arr[la]%val==0)
            cur--;
        cnt+=cur;
    }

    if(cnt<=k)
        return true;
    return false;
}

int main(){
    fastio();
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ll n,k,la,lb,mx=0;
    cin>>n>>k;
    for(la=1;la<=n;la++)
        cin>>arr[la], mx=max(mx, arr[la]);
    
    ll l=1, r=mx, ans=mx;

    while(l<=r){
        // cout<<l<<' '<<r<<endl;
        ll mid=(l+r)/2;
        if(poss(mid, k, n))
            ans=mid, r=mid-1;
        else
            l=mid+1;
    }

    cout<<ans<<endl;

    return 0;
}

void fastio(void){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

Measured memory_bytes: 5216
n=int(input())
#print(n)
s=''
k=1
if n==0:
    s='0'
else:
    while n!=0:
        if abs(n)%abs((-2)**k)!=0:
            n-=(-2)**(k-1)
            s='1'+s
        else:
            s='0'+s
        k+=1
    
print(s)
    

Measured memory_bytes: 2940
#include<iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<vector>
#include<limits>
#include<stdio.h>
using namespace std;
typedef long long ll;

void solve() {
	string str;
	ll N, K, Q;
	ll *score;
	cin >> N >> K >> Q;
	score = new ll[N];
	for (int i = 0;i < N;i++)score[i] = 0;
	for (int i = 0;i < Q;i++) {

		int j;
		cin >> j;
		score[j - 1]++;

	}
	for (int i = 0;i < N;i++) {
		if (Q - score[i] < K) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
		}
	}
	
}


int main() {
	solve();

}

Measured memory_bytes: 1408
#include <stdio.h>
int main()
{
    int a,b;
    scanf("%d %d",&a,&b);
    if(((a==1)||(a==2))&&((b==2)||(b==1))) printf("3\n");
    else if(((a==2)||(a==3))&&((b==2)||(b==3))) printf("1\n");
    else if(((a==1)||(a==3))&&((b==1)||(b==3))) printf("2\n");
    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

char map[1000][1000];

void dfs(char c, int x, int y)
{
    int i, j;

    if (map[y][x] == c){
        map[y][x] = 0;
        dfs(c, x - 1, y);
        dfs(c, x + 1, y);
        dfs(c, x, y - 1);
        dfs(c, x, y + 1);
    }
}

int main(void)
{
    int h, w;

    while (scanf("%d %d", &h, &w), h){
        int i, j;
        int cnt = 0;

        for (i = 0; i < h; i++) scanf("%s", map[i]);
        for (i = 0; i < h; i++){
            for (j = 0; j < w; j++){
                if (map[i][j] != 0){
                    cnt++;
                    dfs(map[i][j], j, i);
                }
            }
        }
        printf("%d\n", cnt);
    }

    return 0;
}

Measured memory_bytes: 1008
import java.io.*;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Task solver = new Task();
//        int t = in.nextInt();
        solver.solve(1, in, out);
        out.close();
    }

    static class Task {
        public void solve(int testNumber, InputReader in, PrintWriter out) throws IOException {
            int n = in.nextInt();
            int[] arr = new int[n];
            int min = Integer.MAX_VALUE;
            int max = Integer.MIN_VALUE;
            for (int i = 0; i < n; i++) {
                arr[i] = in.nextInt();
                if (arr[i] > max){
                    max = arr[i];
                }
                if (arr[i] < min){
                    min = arr[i];
                }
            }
            int sum = 0;
            int pos = 0;
            int min_sum = Integer.MAX_VALUE;
            for (int j = min; j <= max; j++) {
                sum = 0;
                for (int i = 0; i < n; i++) {
                    sum += Math.pow(arr[i] - j, 2);
                }
                if (sum < min_sum){
                    min_sum = sum;
                }
            }
            out.println(min_sum);
        }
    }

    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 long nextLong() {
            return Long.parseLong(next());
        }

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

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public char nextChar() {
            return next().charAt(0);
        }

        public String nextLine() throws IOException {
            return reader.readLine().trim();
        }
    }
}


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


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

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



int main()
{ios_base::sync_with_stdio(false);
//freopen("input.txt","r",stdin);
int n,m;
cin>>n>>m;
ll a[10][10];
rep(i,0,9)rep(j,0,9)cin>>a[i][j];

rep(k,0,9)rep(i,0,9)rep(j,0,9)a[i][j]=min(a[i][j],a[i][k]+a[k][j]);

ll ans=0;
rep(i,0,n-1)
{
	rep(j,0,m-1)
	{
		int x;
		cin>>x;
		if(x!=-1)
		{
			ans+=a[x][1];
		}
	}
}
ol(ans);
return 0;
}



Measured memory_bytes: 384
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
/*
cout<<setprecision(20)
cin.tie(0);
ios::sync_with_stdio(false);
*/
const llint mod=1000000007LL;
const llint big=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-15;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
llint LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
llint UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b;cin>>a>>b;
	cout<<(max(a,b)<=8?"Yay!":":(")<<endl;
	return 0;
}

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

#define MAX 2
int main(void)
{
	int a,b;
	char c;

	while (1) {
		cin >> a;
		cin >> c;
		cin >> b;

		if (c == '+') {
			printf("%d\n", a+b);
		}
		else if (c == '-') {
			printf("%d\n", a-b);
		}
		else if (c == '*') {
			printf("%d\n", a*b);
		}
		else if (c == '/') {
			printf("%d\n", a/b);
		}
		else {
			break;
		}
	}

	return 0;
}



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

#define int ll
#define endl '\n'
#define ends ' '
#define die(x) return cout << x << endl, 0
#define all(v) v.begin(), v.end()
#define sz(x) (int)(x.size())
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cerr << ends << H; debug_out(T...); }
#define debug(...) cerr << "{" << #__VA_ARGS__ << "}:", debug_out(__VA_ARGS__)
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;

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

const int N = 2e5 + 5;

int n, A[N], B[N], PS[N], FEN[N];

void Add(int p) { for(p++; p < N; p += p & -p) FEN[p]++; }
int Get(int p) {
	int res = 0;
	for (; p > 0; p -= p & -p) res += FEN[p];
	return res;
}

bool isVal(int x) {

	memset(FEN, 0, sizeof FEN);
	PS[0] = n;
	for (int i = 0; i < n; i++) B[i + 1] = (A[i] < x ? -1 : +1), PS[i + 1] = PS[i] + B[i + 1];
	ll cnt = 1LL * n * (n + 1) / 2, cnt1 = 0, cnt0 = 0;
	for (int i = 0; i <= n; i++) cnt1 += Get(PS[i] + 1), Add(PS[i]);
	cnt0 = cnt - cnt1;
	return cnt0 < cnt / 2 + 1;
}

int32_t main() {

	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> n;
	for (int i = 0; i < n; i++) cin >> A[i];
	int dw = 0, up = INF + 1;
	while (up - dw > 1) {
		int md = (dw + up) >> 1;
		if (isVal(md)) dw = md;
		else up = md;
	}
	cout << dw << endl;

	return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i=0 ; i<n ; i++)
    cin >> a.at(i);
  
  int m = 0;
  for (int i=0 ; i<n-1 ; i++){
    for (int j=i+1 ; j<n ; j++){
      if (abs(a.at(i) - a.at(j)) > m)
        m = abs(a.at(i) - a.at(j));
    }
  }
  
  cout << m << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define MOD 1000000007

int main(void){
    string a;
    cin >> a;
    int n = a.size();
    rep(i,n) cout << 'x';
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){

  int n, tmp, i, j ,k;

  scanf("%d",&n);

  int a[100];

  for( i = 1; i <= n; i++)scanf("%d",&a[i]);
  
  for( i = 1; i <= n; i++){    

    tmp = a[i];
    j = i-1;
    while( j > 0 && a[j] > tmp){
      a[j+1] = a[j];
      j--;
    }      
    a[j+1] = tmp;    
    for( k = 1; k <= n; k++){
      printf("%d",a[k]);
      if(k==n)break;
      printf(" ");
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 604
N, K = map(int, input().split())
H = [int(a) for a in input().split()]
C = [0] * N

for i in range(1, N):
    C[i] = 10**10
    for k in range(1, min(K, i)+1):
        C[i] = min(C[i], C[i-k]+abs(H[i]-H[i-k]))
print(C[N-1])

Measured memory_bytes: 52320
n = gets.to_i
nums = gets.split(" ").map(&:to_i)
even_num = nums.select{|item| item % 2 == 0}
check = []

even_num.each do |n|
  if n % 3 != 0 && n % 5 != 0
    check.push("NO")
  end
end

if check.empty?
  puts "APPROVED"
else
  puts "DENIED"
end

Measured memory_bytes: 1788
class Dice():
    def __init__(self):
        self.number = [i for i in range(6)]
        self.work = [i for i in range(6)]

    def setNumber(self, n0, n1, n2, n3, n4, n5):
        self.number[0] = n0
        self.number[1] = n1
        self.number[2] = n2
        self.number[3] = n3
        self.number[4] = n4
        self.number[5] = n5

    def roll(self, loc):
        for i in range(6):
            self.work[i] = self.number[i]

        if loc == 'E':
            self.setNumber(self.work[3], self.work[1], self.work[0],
                           self.work[5], self.work[4], self.work[2])
        elif loc == 'N':
            self.setNumber(self.work[1], self.work[5], self.work[2],
                           self.work[3], self.work[0], self.work[4])
        elif loc == 'S':
            self.setNumber(self.work[4], self.work[0], self.work[2],
                           self.work[3], self.work[5], self.work[1])
        elif loc == 'W':
            self.setNumber(self.work[2], self.work[1], self.work[5],
                           self.work[0], self.work[4], self.work[3])

    def get_Top(self):
        return self.number[0]


dice = Dice()
table = list(map(int, input().split()))
dice.setNumber(table[0], table[1], table[2], table[3], table[4], table[5])

loc_array = str(input())
for tmp_loc in loc_array:
    dice.roll(tmp_loc)

print("%d" % (dice.get_Top()))



Measured memory_bytes: 5616
#include <iostream>
using namespace std;
int main(){
  int n, x;
  int i = 1;
  cin >> x;
  while(1){
    n = i;
    if(n%3 == 0)
     cout << ' ' << i;
     else{
      while(1){
       if(n%10 == 3){
         cout << ' ' << i;
         break;
       }
       n /= 10;
       if(!(n))
         break;
      }
    }
    if(!(++i <= x))
        break;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 3084
using System;
using static System.Console;
class program{
  static void Main(string[] args){
    program p = new program();
    p.Run();
  }
  void Run(){
	int n = int.Parse(ReadLine());
    string s = ReadLine();
    int k = int.Parse(ReadLine());
    string ks = s.Substring(k-1,1);
    int i=0;
    while(i<n){
      if (s.Substring(i,1)!=ks){
        s=s.Remove(i)+"*"+s.Remove(0,i+1);
      }
      i++;
    }
    WriteLine(s);
  }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define all(n) begin(n), end(n)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int r,g,b;
    cin>>r>>g>>b;
    if((10*g+b) % 4 == 0)
    puts("YES");
    else puts("NO");
    return 0;
}

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

using namespace std;

int main() {
	string a, b;
	cin >> a >> b;
	int tmp = stoi(a + b);

	for (int i = 1; i <= 1000; i++) {
		if (i * i == tmp) {
			cout << "Yes" << endl;
			return 0;
		}
	}

	cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256