akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())
 
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const ll MOD = (ll)1000000007;//10^9+7
const ll INF2 = (ll)100000000000000000;//10^18

ll f(ll b, ll n){
    if(n<b) return n;
    return f(b,n/b) + n%b;
}

int main() {
    ll n,s;
    cin>>n>>s;
    if(n<s){
        cout<<-1<<endl;
        return 0;
    }

    if(n==s){
        cout<<n+1<<endl;
        return 0;
    }
    for(ll b=2;b<=sqrt(n)+1;b++){
        if(f(b,n)==s){
            cout<<b<<endl;
            return 0;
        }
    }

    for(ll p= sqrt(n)-1; p>0;p--){
        ll b = (n-s)/p + 1;
        if(b>1){
            if(f(b,n)==s){
                cout<<b<<endl;
                return 0;
            }
        }
    }

    cout<<"-1"<<endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <cstring>
using namespace std;

int main()
{
	int n;
	int s[1000];
	int e[1000];
	
	while (scanf("%d", &n), n){
		int m = 0;
		
		for (int i = 0; i < n; i++){
			int a;
			scanf("%d", &a);
			
			if (i == 0){
				s[m] = a;
				e[m] = a;
			}
			
			else if (e[m] + 1 == a){
				e[m] = a;
			}
			else {
				m++;
				s[m] = a;
				e[m] = a;
			}
		}
		
		for (int i = 0; i <= m; i++){
			if (i > 0){
				printf(" ");
			}
			
			if (s[i] == e[i]){
				printf("%d", s[i]);
			}
			else {
				printf("%d-%d", s[i], e[i]);
			}
		}
		puts("");
	}
	
	return 0;
}

Measured memory_bytes: 1052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

int main(){
    int n,m;
    cin >> n >> m;
    int t = m;
    int power = 1;
    while(t--){
        power *= 2;
    }
    ll ans = (ll)(n*100 + m*1800) * (ll)power;
    cout << ans << endl;
}

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

vector<int> ans;

bool check(string s){

  reverse(s.begin(), s.end());
  
  int cd=0;
  
  for(int i=1;i<=11;i++){
    if(i<=6) cd+=(s[i]-'0')*(i+1);
    else cd+=(s[i]-'0')*(i-5);
  }
  
  cd%=11;
  
  if(cd==1) cd=0;
  
  cd=11-cd;
  
  cd%=11;
  
  return cd==s[0]-'0';
}

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

  for(int i=0;i<s.size();i++){
    
    if(s[i]=='?'){
      
      for(int j='0';j<='9';j++){
	s[i]=(char)j;
	if(check(s)) ans.push_back(j-'0');
      }
      
    }
  }
  
  if(ans.size()>=2) cout<<"MULTIPLE"<<endl;
  else cout<<ans[0]<<endl;
  
  return 0;
}



Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int H, W;
    cin >> H >> W;
    vector<vector<char> > field(H, vector<char>(W));
    vector< vector<vector<int> > > cnt(2, vector<vector<int> >(H, vector<int>(W)));
    for (int i = 0; i < H; i++) for (int j = 0; j < W; j++) cin >> field[i][j];

    for (int i = 0; i < H; i++) {
        int tmp = 0, r = 0;
        for (int l = 0; l < W; l++) {
            while (r < W && field[i][r] == '.') { r++; }
            int d = r - l;
            while (l < r) {cnt[0][i][l++] = d;}
            r++;
        }
    }
    for (int i = 0; i < W; i++) {
        int tmp = 0, r = 0;
        for (int l = 0; l < H; l++) {
            while (r < H && field[r][i] == '.') { r++; }
            int d = r - l;
            while (l < r) {cnt[1][l++][i] = d;}
            r++;
        }
    }

    for (int i = 0; i < H; i++) {
        for (int j = W - 1; j > 0; j--) {
            if (cnt[0][i][j - 1] == 0) continue;
            cnt[0][i][j - 1] = max(cnt[0][i][j], cnt[0][i][j - 1]);
        }
    }
    for (int i = 0; i < W; i++) {
        for (int j = H - 1; j > 0; j--) {
            if (cnt[1][j - 1][i] == 0) continue;
            cnt[1][j - 1][i] = max(cnt[1][j][i], cnt[1][j - 1][i]);
        }
    }
    int ans = 0;
    for (int i = 0; i < H; i++) {
        for (int j = 0; j < W; j++) {
            ans = max(ans, cnt[0][i][j] + cnt[1][i][j] - 1);
        }
    }
    cout << ans << '\n';
}


Measured memory_bytes: 53248
#include <bits/stdc++.h>
using namespace std;
#define test(t) int t; cin>>t; while(t--)
#define p1(x) { cout << " [" << #x << ": " << x << "]\n"; }
#define p2(x) { cout << " [" << #x << ": "; for(auto it:x) cout << it << " "; cout << "]\n"; }
 
void solve()
{
	int x, y;
	cin>>x>>y;
	int a=(4*x-y)/2, b=(y-2*x)/2;
	
	if(y%2 || (a<0 || b<0) || (a==0 && b==0)) {
		cout<<"No"<<endl;
		exit(0);
	}
	cout<<"Yes"<<endl;
}
 
int main() {
	// your code goes here
	// test(t)
		solve();
	return 0;
}
 

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

int main() {
	string s, t;
	cin >> s >> t;
	string u = s + t;
	int n = stoi(u);
	for (int i = 1;i <= n;i++) {
		if (i*i == n) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N=I()
    A=LI()
    A.sort(reverse=True)
    
    pl=A[0]#負のものはこちらから引いていく
    mi=A[-1]#正のものはこちらから引いていく
    
    ans=[]
    
    for i in range(N-2):
        a=A[i+1]
        if a>=0:
            ans.append([mi,a])
            mi-=a
        else:
            ans.append([pl,a])
            pl-=a
            
    ans.append([pl,mi])
    print(pl-mi)
    for i in range(len(ans)):
        print(' '.join(map(str, ans[i])))
    

main()


Measured memory_bytes: 89108
#[allow(unused_macros)]
macro_rules! get {
    ([$t:ty] ; $n:expr) => {
        (0..$n)
        .map(|_| get!([$t])).collect::<Vec<_>>()
    };
    ($($t:ty),+ ; $n:expr) => {
        (0..$n).map(|_| get!($($t),+)).collect::<Vec<_>>()
    };
    ([$t:ty]) => {
        rl().split_whitespace()
        .map(|x| x.parse().unwrap())
        .collect::<Vec<$t>>()
    };
    ($t:ty) => {
        rl().parse::<$t>().unwrap()
    };
    ($($t:ty),*) => {
        {
            let line =rl();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap()),*)
        }
    };
}
fn rl() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

const MOD: usize = 1000000007;

fn f(bit: usize, w: u32) -> bool {
    for i in 0..w - 2 {
        let a = 2_usize.pow(w - 2 - i);
        let b = 2_usize.pow(w - 2 - i - 1);
        if bit & a == a && bit & b == b {
            return false;
        }
    }
    true
}

fn main() {
    let (h, w, k) = get!(usize, usize, usize);
    if w == 1 {
        println!("1");
        return;
    }
    let mut dp = vec![vec![0; w + 1]; h + 1];
    dp[0][0] = 1;
    for i in 0..h {
        for j in 0..w {
            for bit in 0..1 << (w - 1) {
                if !f(bit, w as u32) {
                    continue;
                }
                //eprintln!("bit: {:08b}", bit);
                if 1 <= j && bit >> j - 1 & 1 == 1 {
                    dp[i + 1][j - 1] += dp[i][j];
                    dp[i + 1][j - 1] %= MOD;
                } else if j <= w - 2 && bit >> j & 1 == 1 {
                    dp[i + 1][j + 1] += dp[i][j];
                    dp[i + 1][j + 1] %= MOD;
                } else {
                    dp[i + 1][j] += dp[i][j];
                    dp[i + 1][j] %= MOD;
                }
            }
        }
    }
    //for i in 0..h {
    //    eprintln!("{:?}", dp[i]);
    //}
    //eprintln!("{:?}", dp);
    println!("{}", dp[h][k - 1]);
}


Measured memory_bytes: 4352
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [int(input()) for _ in range(N)]

p = 1
answer = 0
for a in A:
    if a == p:
        p += 1
        continue
    answer += (a-1)//p
    if p == 1:
        p += 1

print(answer)

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

int main(){
  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  x %= b;
  cout << x << endl;
  return 0;
}

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

#define MAX(p,q) ((p>q)?(p):(q))
#define MIN(p,q) ((p<q)?(p):(q))



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

int gcd(int a,int b);

int main(void)
{
  int n;
  scanf("%d",&n);
  int a[100];
  int i;
  int min=10000000000,max=0;
  REP(i,n)
  {
    scanf("%d",&a[i]);
    min=MIN(min,a[i]);
    max=MAX(max,a[i]);
  }
  printf("%d",max-min);
  return 0;
}

int gcd(int a,int b)
{
  int max,min,tmp;
  max = MAX(a,b);
  min = MIN(a,b);
  if(max%min==0) return min;
  else
  {
    tmp = min;
    min = max%min;
    max = tmp;
    return gcd(max,min);
  }
}



    

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define gc getchar
typedef long long LL;
typedef long double LD;
typedef pair<int,int> pii;
int main()
{
	LL n,a,b,ans;
	cin>>n>>a>>b;
	ans=((n-1)*b+a)-((n-1)*a+b)+1;
	if(a>b)
		ans=0;
	else if(n==1)
	{
		if(a==b)
			ans=1;
		else
			ans=0;
	}
	cout<<ans<<endl;
}

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

int n,c,crs[14],ans[52];

bool dfs(int s, int t)
{
	if(s==0) return true;

	for(int i=1; i<=13; i++)
	{
		if(crs[i])
		if((s-i)%i == 0)
		{
			ans[t]=i;
			crs[i]--;
			if(dfs(s-i,t+1))
			{
				return true;
			}
			crs[i]++;
		}
	}
	return false;
}


int main()
{
	while(cin >> n, n)
	{
		int s=0;
		memset(crs,0,sizeof(crs));
		for(int i=0; i<n; i++)
		{
			cin >> c;
			s+=c; crs[c]++;
		}

		if(dfs(s,0))
		{
			for(int i=n-1; i>=0; i--)
			{
				cout << ans[i] << (i ? " ":"\n");
			}
		}
		else
		{
			cout << "No" << endl;
		}
	}
}

Measured memory_bytes: 864
from sys import stdin

k, n = [int(x) for x in stdin.readline().rstrip().split()]

l = [int(x) for x in stdin.readline().rstrip().split()]
#print(k)
#print(n)
#print(l[0])

mylist = []

for i in range(n):
    if i == n-1:
        mylist.append( k - l[i] + l[0])
    else:
        mylist.append(l[i+1]-l[i])

#print(mylist)

sortlist = sorted(mylist)
length = 0
for i in range(n-1):
    length += sortlist[i]

print(length)

Measured memory_bytes: 26444
import sys

read = sys.stdin.buffer.read
input = sys.stdin.buffer.readline
inputs = sys.stdin.buffer.readlines

# rstrip().decode('utf-8')
# map(int,input().split())
# import numpy as np


def main():
	n=int(input())
	A=list(map(int,input().split()))
	A.sort(reverse=True)
	ans=0
	cnt=0
	li=[]
	for i in range(n-1):
		if A[i+1]==A[i]:
			cnt+=1
			if cnt==3:
				ans=A[i]**2
				break
			if cnt==1:
				li.append(A[i])
				if len(li)==2:
					ans=li[0]*li[1]
					break
		else:
			cnt=0
	print(ans)
	
	

if __name__ == "__main__":
	main()


Measured memory_bytes: 12992
let rec fold_for a b v f = if a >= b then v else fold_for (a+1) b (f a v) f

let rec pow ( * ) z a n =
  if n = 0 then z
  else if n mod 2 = 1 then a * (pow ( * ) z a (n-1))
  else let h = pow ( * ) z a (n/2) in h * h

let rec intpow = pow ( * ) 1

let i3 = [| [|1; 0; 0|]; [|0; 1; 0|]; [|0; 0; 1|] |]

let () =
  Scanf.scanf "%d %d %d %d" @@ fun l a b modulo ->
  
  let (+@) a b = (a + b + modulo) mod modulo in
  let modmul a b = (a * b) mod modulo in
  let modpow = pow modmul 1 in

  let matmul a b =
    let m = Array.length b in
    Array.init (Array.length a) (fun i ->
    Array.init (Array.length b.(0)) (fun j ->
      fold_for 0 m 0 (fun k s -> s +@ modmul a.(i).(k) b.(k).(j))))
  in

  let rec loop d z =
    if d > 18 then z else
    let i = (intpow 10 (d-1) - a + b - 1) / b |> max 0 in
    let j = (intpow 10 d - a + b - 1) / b |> min l in
    let r = [| [| z; a +@ modmul b i; 1 |] |] in
    let m = [| [| modpow 10 d; 0; 0 |]; [| 1; 1; 0 |]; [| 0; b mod modulo; 1 |]; |] in
    let mc = pow matmul i3 m (j-i) in
    let r' = matmul r mc in
    loop (d+1) r'.(0).(0)
  in
  loop 1 0 |> Printf.printf "%d\n"


Measured memory_bytes: 1280
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<string>
#include<cstring>
#include<climits>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<deque>
#include<tuple>
#include<list>
#include<unordered_map>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define lb lower_bound
#define pb push_back
#define mp make_pair
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep2(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define all(x) x.begin(),x.end()
#define INF (1 << 30) - 1
#define LLINF (1LL << 61) - 1
// #define int ll
using namespace std;
const int MOD = 1000000007;
const int MAX = 510000;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n[4];
    map<ll,ll> mp;
    rep(i,4){
        cin>>n[i];
        mp[n[i]]++;
    }
    if(mp[1]&&mp[9]&&mp[4]&&mp[7]){
        cout<<"YES"<<endl;
    } else{
        cout<<"NO"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cctype>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;

#define ll long long
#define reg register
#define rep(i, a, b) for (reg int i = (a), i##end = (b); i <= i##end; ++i)
#define dep(i, a, b) for (reg int i = (a), i##end = (b); i >= i##end; --i)

template <typename _typer> inline _typer read() {
    _typer init = 0;
    char ch = getchar(), k = 0;
    for ( ; !isdigit(ch); ch = getchar()) k = (ch == '-');
    for ( ; isdigit(ch); ch = getchar())
        init = (init << 3) + (init << 1) + (ch ^ 48);
    return k ? -init : init;
}
const ll N = 0, INF = 1e9;

/*******************************************************************************
 *
 *
 *
 ******************************************************************************/

int main() {
    int a = read<int>(), b = read<int>();
    cout << a / (2 * b + 1) + (a % (2 * b + 1) != 0) << endl;
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

struct task {
  i64 duration;
  i64 due;
};

namespace std {
  std::istream& operator>>(std::istream& is, task& self) {
    return is >> self.duration >> self.due;
  }
}

int main() {
  i64 N;
  std::cin >> N;
  std::vector<task> tasks;
  tools::read(tasks, N);

  std::sort(tasks.begin(), tasks.end(), [](const task& lhs, const task& rhs) { return lhs.due < rhs.due; });
  i64 time = 0;
  for (const task& task : tasks) {
    time += task.duration;
    if (time > task.due) goto FAILED;
  }

  std::cout << "Yes" << std::endl;
  return 0;

FAILED:
  std::cout << "No" << std::endl;
  return 0;
}

Measured memory_bytes: 3328
/*
Author: Hamza Hasbi
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore(),
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline long long lcm(ll a,ll b) {return a*b/__gcd(a,b);}
//inline long long gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
void READ() {
    #ifndef ONLINE_JUDGE
    freopen("input.in", "r", stdin);
    #endif
}
using namespace std;
bool distance(int a,int c,int b,int d){
    return (abs(a - c) <= d or (abs(a - b) <= d and abs(b - c) <= d));
}
int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(distance(a,c,b,d)) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int h[100][100];
int t[100][100];
int c[6][4]={{4,2,3,5},{1,3,6,4},{5,6,2,1},{6,2,1,5},{3,6,4,1},{5,4,2,3}};
int d[6][4]={{5,4,2,3},{3,6,4,1},{6,2,1,5},{5,6,2,1},{1,3,6,4},{4,2,3,5}};
struct dice{
	int U,D,F,B,L,R;
	dice(int a,int b){
		U=a;
		F=b;
		D=7-a;
		B=7-b;
		for(int i=0;i<6;i++)
			for(int j=0;j<4;j++)if(a==c[i][j]&&b==d[i][j])L=i+1;
		R=7-L;
	}
};

void N(dice &a){
	int q=a.U;a.U=a.F;a.F=a.D;a.D=a.B;a.B=q;
}
void E(dice &a){
	int q=a.U;a.U=a.L;a.L=a.D;a.D=a.R;a.R=q;
}
void W(dice &a){
	int q=a.U;a.U=a.R;a.R=a.D;a.D=a.L;a.L=q;
}
void S(dice &a){
	int q=a.U;a.U=a.B;a.B=a.D;a.D=a.F;a.F=q;
}
int main(){
	int a;
	while(scanf("%d",&a),a){
		for(int i=0;i<100;i++)
			for(int j=0;j<100;j++)
				h[i][j]=t[i][j]=0;
		for(int i=0;i<a;i++){
			int x,y;
			scanf("%d%d",&x,&y);
			dice s=dice(x,y);
			int row=50;
			int col=50;
			bool ok=false;
			do{
				ok=false;
				for(int j=6;j>=4&&!ok;j--){
					if(h[row][col]>h[row-1][col]&&s.B==j){
						row--;
						N(s);
						ok=true;
					}else if(h[row][col]>h[row+1][col]&&s.F==j){
						row++;
						S(s);ok=true;
					}else if(h[row][col]>h[row][col-1]&&s.L==j){
						col--;
						W(s);ok=true;
					}else if(h[row][col]>h[row][col+1]&&s.R==j){
						col++;
						E(s);ok=true;
					}
				}
			}while(ok);
			h[row][col]++;
			t[row][col]=s.U;
		}
		for(int i=1;i<=6;i++){
			int ret=0;
			for(int j=0;j<100;j++)
				for(int k=0;k<100;k++)if(t[j][k]==i)ret++;
			printf("%d",ret);
			if(i<6)printf(" ");
			else printf("\n");
		}
	}
}

Measured memory_bytes: 1108
#include<iostream>
#include<stdio.h>
#include<math.h>
using namespace std;
int main(){
    int n,a[1000];
    while(1){
        cin>>n;
        if(n==0)break;
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        double sum = 0.0;
        for( int i=0;i<n;i++){
            sum += a[i];
        }
        double ave = sum/n;
        double bun = 0.0;
        for(int i=0;i<n;i++){
            bun += (ave-a[i])*(ave-a[i]);
        }
        printf("%lf\n",sqrt(bun/n));
        
    }
}


Measured memory_bytes: 3116
/**
 *    created by : PawPaw       
**/

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

#define F(i,a,b) for(int i = (int)(a); i <= (int)(b); i++)
#define RF(i,a,b) for(int i = (int)(a); i >= (int)(b); i--)

int solve(){
  int a, b;
  cin >> a >> b;
  if(a >= 1 && a <= 9 && b >= 1 && b <= 9) cout << a*b << '\n';
  else cout << "-1\n";
  return 0;
}

void fun(){
  int t = 1;
  // cin >> t;
  while(t--) solve();
} 

int main(){
  ios::sync_with_stdio(false); 
  cin.tie(0);
  // #ifndef ONLINE_JUDGE
  //   freopen("fi", "r", stdin);
  //   freopen("fo", "w", stdout);
  //   clock_t startClock, endClock;
  //   startClock = clock();
  // #endif

  fun();

  // #ifndef ONLINE_JUDGE
  //   endClock = clock(); 
  //   cout << "Time taken by program is : " << fixed <<  double(endClock - startClock) / double(CLOCKS_PER_SEC) << setprecision(5) << " sec " << endl; 
  // #endif
  
  return 0;
}

Measured memory_bytes: 892
def kai(s):
  n = len(s)
  for i in range(n):
    if s[i]!=s[n-i-1]:
      return False
  else:
    return True
  
s = input()
n = len(s)
if kai(s) and kai(s[:(n-1)//2]) and kai(s[(n+1)//2]):
  print('Yes')
else:
  print('No')


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main (){
  float n;
  cin >> n;
  vector<float> A(n);
  float sum = 0;
  for(int i=0; i<n; i++){
    cin >> A[i];
    sum += A[i];
  }
  float ave = sum/n;
  float mi = 99999999;
  int ind;
  for(int i=0; i<n; i++){
    if(abs(A[i]-ave) < mi){
      mi = abs(A[i]-ave);
      ind = i;
    }
  }
  //cout << ave << endl;
  cout << ind << endl;
}

Measured memory_bytes: 256
#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 s;
	cin >> s;
	int ans = 700;
	if (s[0] == 'o') ans += 100;
	if (s[1] == 'o') ans += 100;
	if (s[2] == 'o') ans += 100;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vi;
typedef long double td;
typedef vector<td> vd;
typedef pair<ll,ll> ii;
typedef vector<ii> vii; typedef vector<bool> vb;
#define FIN ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define forr(i, a, b) for(ll i = ll(a); i < (ll)(b); i++)
#define forn(i, n) forr(i, 0, n)
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define DBG(x) cerr << #x << " = " << (x) << endl
#define show(v,n) cerr << #v << " = "; forn(i,n) cerr << v[i] << " "; cerr << endl;
#define esta(x,c) ((c).find(x) != (c).end())
#define RAYA cerr << "===============================" << endl
int MAXN = 500005;
int INF = (int)(1e9+7);

struct flower
{
	ll h, b;
};

vector <ll> tree(4*MAXN,0);

void actualizar(int pos)
{
	tree[pos]=max(tree[2*pos+1],tree[2*pos+2]);
}
 
ll mayor_segtree(int a, int b, int x, int y, int pos)
{
  if(x>b || y<a) return 0LL;
  if(x<=a && b<=y) return tree[pos];
  int med=(a+b)/2;
  return max(mayor_segtree(a,med,x,y,2*pos+1),mayor_segtree(med+1,b,x,y,2*pos+2));
}
 
void modificar_segtree(int a, int b, int pos, int y, ll m)
{
  if(a==b) {tree[pos]=m; return;}
  int med=(a+b)/2;
  if(y<=med) modificar_segtree(a,med,2*pos+1,y,m);
  else modificar_segtree(med+1,b,2*pos+2,y,m);
  actualizar(pos);
}
 
void construir_segtree(int a, int b, int pos, vector <ll> &v)
{
  if(a==b) {tree[pos]=v[a]; return;}
  int med=(a+b)/2;
  construir_segtree(a,med,2*pos+1,v);
  construir_segtree(med+1,b,2*pos+2,v);
  actualizar(pos);
}

void construir(vector <ll> &v, int n)
{
	construir_segtree(0,n-1,0,v);
}

void modificar(int pos, ll val, int n)
{
	modificar_segtree(0,n-1,0,pos,val);
}

ll mayor(int l, int r, int n)
{
	return mayor_segtree(0,n-1,l,r,0);
}
 
int main()
{ 	
	FIN;
	#ifdef input
		freopen("T3.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	vector <flower> v(n);
	forn(i,n) cin >> v[i].h;
	forn(i,n) cin >> v[i].b;
	ll ans = 0;
	forn(i,n)
	{
		ll aux = mayor(0,v[i].h-1,n);
		ans = max(ans,aux+v[i].b);
		modificar(v[i].h,aux+v[i].b,n);
	}
	cout << ans << "\n";
	
	
    return 0;
}


Measured memory_bytes: 21936
#include<cstdio>
#include<cstring>

int Check(int x){
    char s[10];
    sprintf(s+1,"%d",x);
    int len=strlen(s+1);
    for(int i=1;i<=len/2;i++)
        if(s[i]!=s[len-i+1])
            return 0;
    return 1;
}

int main(){
    int A,B,Ans=0;
    scanf("%d%d",&A,&B);
    for(int i=A;i<=B;i++)
        Ans+=Check(i);
    printf("%d",Ans);
}


Measured memory_bytes: 128
#

# import sys
# input=sys.stdin.readline

def main():
    S=input()
    Z1=["1" if i%2==0 else "0" for i in range(len(S))]
    c1=0
    c2=0
    for i in range(len(S)):
        if S[i]!=Z1[i]:
            c1+=1
        else:
            c2+=1
    print(min(c1,c2))
    
if __name__=="__main__":
    main()


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

int N;
vector<pair<int, int>> r;
vector<pair<int, int>> b;
vector<int> used;
int ans;

void solve() {
  for (int i = 0; i < N; ++i) {
    for (int j = N - 1; j >= 0; --j) {
      if (used[j] == 1) continue;
      if (b[i].first > r[j].second && b[i].second > r[j].first) {
        used[j] = 1;
        ++ans;
        //printf("(%d,%d)(%d,%d)\n", r[j].second, r[j].first, b[i].first, b[i].second);
        break;
      }
    }
  }
  cout << ans << endl;
}

int main() {
  cin >> N;
  r.resize(N);
  b.resize(N);
  used.resize(N);
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    r[i] = make_pair(y, x);
  }
  for (int i = 0; i < N; ++i) {
    int x, y;
    cin >> x >> y;
    b[i] = make_pair(x, y);
  }
  sort(r.begin(), r.end());
  sort(b.begin(), b.end());
  solve();
}

Measured memory_bytes: 256
import jdk.nashorn.internal.ir.CallNode;

import java.util.Scanner;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int k = scanner.nextInt();
        final int[] array = {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};
        System.out.println(array[k - 1]);
    }
}


Measured memory_bytes: 24148
# coding: utf-8
# Your code here!

N = int(input())
S = input()
ans = []
for i in range(N-1):
    c=0
    #print(S[0:i+1],S[i+1:])
    for j in list(set(S[0:i+1])):
        if j in list(set(S[i+1:])):
            c+=1
    ans.append(c)
print(max(ans))

Measured memory_bytes: 3060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;

int l;
long long ans;
double a,b,c;

int main()
{
	scanf("%d",&l);
	
	a=l*1.0/3;
	
	printf("%.12lf",a*a*a);
	
	return 0;
}

Measured memory_bytes: 256
import math
import collections
import fractions
import itertools
import functools
import operator

def solve():
    n = int(input())
    a = list(map(int, input().split()))
    ans = 0
    for i in range(n):
        if (i+1) % 2 == 1 and a[i] % 2 == 1:
            ans += 1
    print(ans)
    return 0

if __name__ == "__main__":
    solve()


Measured memory_bytes: 10332
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String s [] = S.split("");
		//System.out.println(s[0].equals("A"));
		
		int l = S.length();
		
		int i=0;
		int ans = 0;
		while (i<l){
			int cnt = 0;
			if (s[i].equals("A")!=true && s[i].equals("T")!=true && s[i].equals("C")!=true && s[i].equals("G")!=true){
				i++;
			}
			
			else {
				cnt++;
				i++;
				
				while (i<l){
					if (s[i].equals("A")==true || s[i].equals("T")==true || s[i].equals("C")==true || s[i].equals("G")==true){
						i++;
						cnt++;
					}
					else
						break;
						
				}
			}
			ans = Math.max(ans,cnt);
			
		}
		System.out.println(ans);

	}

}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define pob pop_back
#define vl vector<ll>
#define mp make_pair
#define sz size()
#define fast ios::sync_with_stdio(0);cin.tie(0)
#define maxx 100005
#define inf 1000000009
#define edge pair<ll,ll>
using namespace std;
 

 
// ¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++¦¦¦++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦¦¦¦¦¦¦¦¦+++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦+++++++¦++¦¦
// ¦¦¦¦¦¦¦¦++¦¦¦¦¦¦++++++¦¦¦¦+++++++++++++¦
// ¦¦¦¦¦¦¦++++++¦¦¦++++++¦¦++++++++++++++¦¦
// ¦¦¦¦¦¦¦+++++++¦¦¦+++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++¦¦¦¦¦¦¦¦+++++++¦ 
// ¦¦¦¦¦¦¦¦¦¦++¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦++++¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦ 
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++++++¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++¦¦+¦++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++¦¦+++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦¦+++¦¦¦¦++++++¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++¦¦+¦¦¦¦¦+++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++++++++++¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++++++++++¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++++¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+¦¦¦+++++++++++¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦+++++++++¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++++¦¦¦¦¦¦¦¦¦¦
// ¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦¦++++++¦¦¦¦¦¦¦¦¦¦¦¦

int main()
{
	ll n;
	cin>>n;
	ll a[n],b[n],c[n];
	ll i;
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
	}
	ll dp[n+1][3];
	dp[0][0]=a[0];
	dp[0][1]=b[0];
	dp[0][2]=c[0];
	
	for(i=1;i<n;i++)
	{
		dp[i][0]=max(dp[i-1][1]+a[i],dp[i-1][2]+a[i]);
		dp[i][1]=max(dp[i-1][0]+b[i],dp[i-1][2]+b[i]);
		dp[i][2]=max(dp[i-1][0]+c[i],dp[i-1][1]+c[i]);
	}
	ll ans=0;
	ans=max(dp[n-1][0],dp[n-1][1]);
	ans=max(ans,dp[n-1][2]);
	cout<<ans<<endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
typedef long long int ll;
using namespace std;
#define sz 1000009
#define mod 1000000007
ll n,m,i,j,k,t,tt,a[sz],b[sz],d,arr[sz],l,x,y;
int main()
{
scanf("%lld",&n);
for(i=1;i<=n;i++)
{
    scanf("%lld",&arr[i]);
    if(i>2)
        j^=arr[i];
}
l=arr[1]+arr[2];
k=l-j;
i=k/2;
if(k<0 || k%2==1 || i>arr[1])
{
    printf("-1\n");
    return 0;
}
l=0;
while(i)
{
    a[l++]=i%2;
    i/=2;
}
l=0;
d=1;
while(j)
{
    b[l++]=j%2;
    j/=2;
    d*=2;
}
for(t=0;t<l;t++)
{
    if(a[t]==b[t] && b[t]==1)
    {
        printf("-1\n");
        return 0;
    }
}
x=arr[1];
y=max(0ll,(k/2)-arr[2]);
arr[1]=arr[1]-y-(k/2);
tt=arr[1];
for(t=l-1;t>=0;t--)
{
    d/=2;
    if(b[t]==1 && d<=tt)
        tt-=d;
}
printf("%lld\n",tt==x?-1:tt+y);
}


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

class data{
	public:
	int che[3];
	bool result;
};
int main(){
	int a,b,c,n;
	while(1){
		cin>>a>>b>>c;
		if(a==0)	return 0;
		cin>>n;
		vector<int> ans(a+b+c);
		fill(ans.begin(),ans.end(),2);
		data re[n];
		int w;
		for(int i=0;i<n;i++){
			cin>>re[i].che[0]>>re[i].che[1]>>re[i].che[2]>>w;
			for(int j=0;j<3;j++)	re[i].che[j]--;
			if(w)	re[i].result=true;
			else 	re[i].result=false;
		}
		for(int i=0;i<n;i++){
			if(re[i].result){
				ans[re[i].che[0]]=1;
				ans[re[i].che[1]]=1;
				ans[re[i].che[2]]=1;
			}
		}
		for(int i=0;i<n;i++){
			if(!re[i].result){
				for(int j=0;j<3;j++){
					if(ans[re[i].che[j]]==2){
						bool falseflag=true;
						for(int k=0;k<3;k++){
							if(k==j)	continue;
							if(ans[re[i].che[k]]!=1)	falseflag=false;
						}
						if(falseflag)	ans[re[i].che[j]]=0;
					}
				}
			}
		}
		for(int i=0;i<(int)ans.size();i++){
			cout<<ans[i]<<endl;
		}
	}
}

Measured memory_bytes: 1208
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000009
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main() {
    fastio;
	long long int k,t,l=0,p=99999,j=1,i;
	cin>>t>>k>>l;
	
	cout<<min(t*k,l)<<"\n";
	return 0;
}

Measured memory_bytes: 256
"""
author : halo2halo
date : 24, Jan, 2020
"""

import sys

# import itertools
# import numpy as np

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

A, B = map(int, readline().split())

ans = 0
for i in range(A, B + 1):
    M = str(i)
    if M == M[::-1]:
        ans += 1
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x ;
  cin >> x ;
  if (x == 'a' || x == 'e' || x == 'i' || x == 'o' || x == 'u' ){
    cout << "vowel" << endl;
  }else cout << "consonant" << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int main(){
  const int N = 2000000;
  int a[N];
  int n;
  cin >> n;
  int front = 0, back = 0;
  string o;
  int x;
  for(int i = 0; i < n; i++){
    cin >> o;
    if(o == "insert"){
      cin >> x;
      a[front++] = x;
    }else if(o == "delete"){
      cin >> x;
      for(int j = front-1; j >= back; j--){
        if(a[j] == x){
          int k = j;
          while(k >= back){
            a[k] = a[k-1];
            k--;
          }
          back++;
          break;
        }
      }
    }else if(o == "deleteFirst"){
      if(front > back)front--;
    }else if(o == "deleteLast"){
      if(back < front)back++;
    }
  }
  for(int i = front-1; i >= back; i--){
    cout << a[i];
    if(i == back){
      cout << endl;
    }else{
      cout << ' ';
    }
  }
}


Measured memory_bytes: 6972
N, K = map(int, input().split())
S = input()

change = [0]
pre = S[0]
for i in range(1, N):
    if pre != S[i]:
        change.append(i)
        pre = S[i]

change.append(len(S))

ans = 0
len_ = len(change)
for i in range(len_-1):
    if S[change[i]] == "1":
        ans = max(ans, change[min(len_-1, i+2*(max(1, K-1)))] - change[i])
    else:
        ans = max(ans, change[min(len_-1, i+2*K)] - change[max(0, i-1)])

print(ans)


Measured memory_bytes: 7160
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

int main() {
    vec a(9);
    rep(i,9) cin>>a[i];
    vector<bool> ok(9, false);
    cin>>N;
    rep(i,N){
        cin>>A;
        rep(j,9) if(a[j] == A) ok[j] = true;
    }
    bool yes = false;
    rep(i,3){
        bool temp = true;
        rep(j,3) temp = temp && ok[i + j * 3];
        yes = temp || yes;
    }
    rep(i,3){
        bool temp = true;
        rep(j,3) temp = temp && ok[j + i * 3];
        yes = temp || yes;
    }
    if(ok[0] && ok[4] && ok[8]) yes = true;
    if(ok[2] && ok[4] && ok[6]) yes = true;
    cout<<(yes ? "Yes" : "No")<<endl;
    //rep(i,9) cout<<ok[i];
}

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


int kisu[246915]={0};

int main(){
	
	int n;
	
	
	for(int i = 2;i<=246915;i++){
		for(int j = 2; i*j < 246915 ; j++){
			kisu[i*j] = 1;
			
		}
	}
	
	
	
	while(cin >> n ,n){
		int count = 0;
		
		for(int i = n+1 ;i <= 2*n ;i++){
			if(kisu[i] == 0){
				count++;
			}
		}
	cout << count << endl;
	
	}
	
	
}

Measured memory_bytes: 2124
#include<bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(NULL);
	char S[15] , T[15] ;
	bool flag = false ;  
	cin >> S >> T ; 
	if(strlen(T) == strlen(S) + 1)	
	{
		flag = true ; 
		for(int i = 0 ; i < strlen(S) ; ++i)
		{
			if(S[i] != T[i])
			{
				flag = false ; 
				break ; 
			}
		}
	} 
	if(flag)
	{
		cout << "Yes" ; 
	}
	else
	{
		cout << "No" ; 
	}
}

Measured memory_bytes: 3612
// Created by martinezdiego on 23/4/19

#include <bits/stdc++.h>

using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  int n;
  string s;
  cin >> n >> s;
  vector<int> blacks(n,0), whites(n,0);
  for (int i = 1; i < n; i++) {
    if (s[i-1] == '#') blacks[i]++;
    if (s[i] == '.') whites[i-1]++;
  }
  for (int i = 1; i < n; i++) {
    blacks[i] += blacks[i-1];
  }
  for (int j = n-2; j >= 0; j--) {
    whites[j] += whites[j+1]; 
  }
  int ans = 2e5 + 1;
  for (int i = 0; i < n; i++)  {
    ans = min(blacks[i] + whites[i], ans);
  }
  cout << ans << '\n';
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;

const int INT_INF = 2147483646;
const ll LL_INF = 9223372036854775807;


const int SIZE = 1e5+100;
string s, ss;

int main(){
    cin >> s;
    ss = "AKIHABARA";

    int f = 1;
    ll num = 0, num1 = 0;
    while(true){
        if(s[num] != ss[num1]){
            if(ss[num1] != 'A'){
                f = 1;
                break;
            }
            ++num1;
        }
        else{
            if(num < s.length())    ++num;
            if(num1 < ss.length())  ++num1;
        }
        if(num == s.length() && num1 == ss.length()){
            f = 0;
        }
        if(num == s.length() && num1 == ss.length()){
            break;
        }
        
    }

    if(f == 0){
        cout << "YES\n";
    }
    else{
        cout << "NO\n";
    }
}

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

typedef long long ll;
const int mx = 1e5 + 5;

int a[mx], n;
int b[mx], m;
int c[mx];

void input(){
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        b[i] = a[i];
    }
    sort(b,b+n);
    m = unique(b,b+n) - b;
}

struct BIT{
    int a[mx * 3], k;
    BIT(int k):k(k){memset(a,0,sizeof(a));}
    int sum(int i){
        int ret = 0;
        for(;i;i &= i-1) ret += a[i];
        return ret;
    }
    void upd(int i, int v){
        for(;i <= k; i += (i&-i)) a[i] += v;
    }
};

bool pro(int x){
    ll ans = 0;
    BIT F(3*n);
    int v = b[x];
    for(int i = 0; i < n; i++){
        c[i+1] = (a[i] >= v) + c[i];
    }
    F.upd(n + (0),1); //n as offset
    for(int i = 1; i <= n; i++){
        ans += F.sum(n + (2*c[i] - i));
        F.upd(n + (2*c[i] - i), 1);
    }
    return ans * 4LL >= (ll)n * (n+1);
}

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);
    input();
    int lo = 0, mi, hi = m-1;
    while(lo < hi){
        int mi = (lo + hi + 1) >> 1;
        if(pro(mi)) lo = mi;
        else hi = mi - 1;
    }
    cout << b[lo] << '\n';
}


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

using namespace std;
using ll = long long;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++)cin >> a[i];
    sort(a.begin(), a.end());
    int sum = accumulate(a.begin(), a.end(), 0);
    cout << (sum - a[n - 1] > a[n - 1] ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
const ll mod =1000000007;
int main(){
    int h,w;
    cin>>h>>w;
    vector<string> s(h);
    for(int i=0; i<h; i++){
        cin>>s.at(i);
    }
    vector<vector<int>> can(h,vector<int>(w,-1));  
    for(int i=0; i<h; i++){
        int start=-1;
        string ss = s.at(i);
        for(int j=0; j<w; j++){
            if(ss[j]=='.'){
                if(start == -1) start =j;
            }
            else if(ss[j] =='#'){
                if(start!=-1){
                    int count = j-start-1;
                    for(int k =start; k< j; k++){
                        can[i][k]=count;
                    }
                    start =-1;
                }
            }
            if(j==w-1){
                if(start!=-1){
                    int count = j-start;
                    for(int k =start; k< j+1; k++){
                        can[i][k]=count;
                    }
                    start =-1;
                }
            }
        }
    }
    int m =0;
    for(int j=0; j<w; j++){
        int start=-1;
        for(int i=0; i<h; i++){
            if(s[i][j]=='.'){
                if(start == -1) start =i;
            }
            else if(s[i][j] =='#'||i==h-1){
                if(start!=-1){
                    int count = i-start;
                    for(int k =start; k< i; k++){
                        can[k][j] +=count;
                        m = max(m, can[k][j]); 
                    }
                    start =-1;
                }
            }
            if(i==h-1){
                if(start!=-1){
                    int count = i-start+1;
                    for(int k =start; k< i+1; k++){
                        can[k][j] +=count;
                        m = max(m, can[k][j]); 
                    }
                }
            }
        }
    }
    cout<<m<<endl;
}

Measured memory_bytes: 20096
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <vector>
#define LL long long
#define mk make_pair
#define pb push_back
#define pii pair<int, int>
#define ArrayDebug(a, l, r) for(int i = l; i <= r; ++i) printf("%d%c", a[i], (i==r)?'\n':' ')
const int maxn = 2e5+7;
const LL mod = 998244353;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1);
const double EPS = 1e-8;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;

int n, m, k, x, y, ans[maxn], color[maxn], num[maxn];
vector<int> fri[maxn], blo[maxn];
// int pre1[maxn], pre2[maxn];

void init(int n)
{
    // for(int i = 1; i <= n; ++i) pre1[i] = pre2[i] = i;
    memset(color, -1, sizeof(color));
    memset(num, 0, sizeof(num));
}

// int findPre(int *pre, int x)
// {
//     return x == pre[x] ? x : pre[x] = findPre(pre, pre[x]);
// }

// void uni(int *pre, int x, int y)
// {
//     x = findPre(pre, x), y = findPre(pre, y);
//     if(x == y) return ;
//     pre[x] = pre[y];
// }

void dfs(int u, int c)
{
    color[u] = c;
    for(auto x : fri[u]) {
        if(color[x] == -1) dfs(x, c);
    }
}

int main()
{
    scanf("%d%d%d", &n, &m, &k);
    init(n);
    for(int i = 1; i <= m; ++i) {
        scanf("%d%d", &x, &y);
        // uni(pre1, x, y);
        fri[x].pb(y);
        fri[y].pb(x);
    }
    for(int i = 1; i <= k; ++i) {
        scanf("%d%d", &x, &y);
        // uni(pre2, x, y);
        blo[x].pb(y);
        blo[y].pb(x);
    }
    int id = 0;
    for(int i = 1; i <= n; ++i)
        if(color[i] == -1) dfs(i, ++id);
    // ArrayDebug(color, 1, n);
    for(int i = 1; i <= n; ++i) num[color[i]]++;
    for(int i = 1; i <= n; ++i) {
        ans[i] = num[color[i]] - fri[i].size() - 1;
        for(auto x : blo[i]) 
            if(color[x] == color[i]) ans[i]--;
    }
    for(int i = 1; i <= n; ++i) printf("%d ", ans[i]);
    puts("");
}   

Measured memory_bytes: 18432
#include <iostream>
#include <vector>
#include <string>
using namespace std;
int main(){

  string S,T;
  cin >> S >> T;
  vector<int> start(26,-1);
  vector<int> goal(26,-1);

  for(int i = 0;i < S.size();i++){
    int a = S[i] - 'a';//a->b
    int b = T[i] - 'a';//b->a

    if(start[a] != -1 || goal[b] != -1){
      if(start[a] != b || goal[b] != a){
        cout << "No" << endl;
        return 0;
      }
    }
    else{
      start[a] = b;
      goal[b] = a;//置換と逆置換の対応を付ける.
    }
  }


  cout << "Yes" << endl;
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);
#define MOD 1000000007

ll dp[100005];
ll a[100005];

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

    for(i=0;i<n;i++)
    	cin>>a[i];
    
    for(i=1;i<=k;i++)
    {
    	for(j=0;j<n;j++)
    	{
    		if(i>=a[j]&&dp[i-a[j]]==0)
    		{
               	dp[i]=1;
    		}
    	}
    }
   /* 
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=k;j++)
    		cout<<dp[i][j]<<" ";
    	    cout<<"\n";
    	}
    */		
    if(dp[k]==1)
    	cout<<"First\n";
    else
    	cout<<"Second\n";
 	return 0;
}

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


int main(){
	int a[32] = {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 k;
	scanf("%d",&k);
	printf("%d\n",a[k-1]);
	return 0;
}

Measured memory_bytes: 128
// Author - Abhishek giri

#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 100000000007
#define V(type) vector<type> 
#define all(c) ((c).begin(),(c).end())
#define in(var) cin>>(var)
#define out(var) cout<<(var)
#define on(var) cout<<var<<"\n"
#define f(i,n) for(ll i = 0 ; i < n ;i++)
#define mfor(i,init,n,b) for(ll i = (init) ; i < (n) ; i+= (b))
#define cfor(i,c) for(auto i = (c).begin() ; i!= (c).end(); i++)

/*##################################################################################*/


/*
bitset<10000000> prime ;
void calculateprime()
{
    //calculating primes
    prime[0] = prime[1] = 1 ;
    for(int i = 2 ; (ll)i*i <= 10000000 ; i++)
    {
        if(prime[i] == 0)
        {
            for(ll j = i*i ; j <= 10000000 ; j += i )
            {
                prime[j] = 1 ;
            }
        }
    }
}
*/

bool isprime(long n)
{
    for(int i = 2 ; (ll) i*i <= n ; i++)
    {
        if(n % i == 0){
            return false;
        }
    }
    return true;
}


/*
ll fib(int n) 
{ 
  ll a = 0, b = 1, c, i; 
  if( n == 0) 
    return a; 
  for (i = 2; i <= n; i++) 
  { 
    c = (a + b); 
    a = b; 
    b = c; 
  } 
  return b; 
}
*/


ll gcd(ll a, ll b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 


ll findgrouplcm(ll arr[], ll n) 
{ 
    ll ans = arr[0]; 
  
    for (ll i = 1; i < n; i++) 
        ans = (arr[i] * (ans/(gcd(arr[i], ans))));
  
    return ans; 
}



ll powerwithmod(ll x, unsigned ll y, ll p)  
{  
    ll res = 1;    
  
    x = x % p; 
   
    if (x == 0) return 0;
  
    while (y > 0)  
    {  
        if (y & 1)  
            res = (res*x) % p;  
   
        y = y>>1; // y = y/2  
        x = (x*x) % p;  
    }  
    return res;  
}



int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t =1;
    //cin>>t;
    while(t--)
    {
        ll a,b ,n;
        in(a)>>b>>n;
        ll res ;
        if(n < b){
            res = (a*n)/b;
        }
        else{
            res = (a*(b-1))/b;
        }
        out(res);
    }
    return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    int n, i;
    cin >> n >> i;
    OP(n - i + 1);
    return 0;
}

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

signed main(){
  int N,A,B;
  cin>>N>>A>>B;
  int ans=0;
  ans=N/(A+B)*A+min(A,N%(A+B));
  cout<<ans<<endl;
}

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

long long A, B, C, N, Y, D, E;

main(){
    cin >> N >> Y;
    Y /= 1000;
    A = Y / 10;
    for(long long int i = 0; i <= A; ++i){
        D = (Y - i * 10) - (N - i);
        if(D < 0)break;
        if(D % 4 == 0){
            B = D / 4;
            C = Y - i * 10 - B * 5;
            if(C < 0)continue;
            return 0 & printf("%lld %lld %lld", i, B, C);
        }
    }
    puts("-1 -1 -1");
}

Measured memory_bytes: 256
s=input()
s=s+'0'
list=[]
a=0
b=0
c=0
d=0
e=0
f=0
for i in range(len(s)-1):
  if s[i]=='<':
    b+=1
  if s[i]=='>':
    c+=1
  if (s[i]=='>' and s[i+1]=='<') or i==len(s)-2:
    e=max(b,c)
    f=min(b,c)
    d+=(e*(e+1))/2
    d+=(f*(f-1))/2
    b=0
    c=0
print(int(d))

Measured memory_bytes: 4116