akhauriyash/Code-Regression huggingface dataset:
/*
Author: Hrujul Thumar
*/
#include <bits/stdc++.h>
#define int         long long
#define pb          push_back
#define pf          push_front
#define pii         pair<int,int>
#define vi          vector<int>
#define whilet()    int t; scanf("%d",&t); while(t--)
#define vp          vector<pair<int,int>,int>
#define pb          push_back
#define mii         map<int,int>
#define pii         pair<int,int>
#define msi         map<string,int>
#define psi         pair<string,int>
#define mpi         map<pair<int,int>,int>
#define fo(i,l,u)   for(i=l;i<u;i++)
#define rfo(i,l,u)  for(i=l;i>=u;i--)
#define ef          else if
#define MOD         1000000007
#define endl        '\n'
#define fastio       ios::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define pi          3.141592653589793238
const long long MAX_SIZE = 1000000000;
using namespace std;
int gcd(int a, int b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int power(int x,  int y, int p){
    int res = 1;      // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res*x) % p;
            y = y>>1; // y = y/2
            x = (x*x) % p;
    }
    return res;
}

int mod_inv(int a,int m){
    a=a%m;
    return power(a,m-2,m)%MOD;
}

int lcm(int a, int b){
    return (a*b)/gcd(a, b);
}

bool mod(double a,double b) {
    return a/b - floor(a/b);}

int logb(int base, int x) {
    return (log(x) / log(base));
}
char ToLower(char c)
{
    if ((c >= 'A') && (c <= 'Z')) return (char)((int)c - 'A' + 'a');
    else return c;
}

int Vowel(char c)
{
    c = ToLower(c);
    return (c == 'a') || (c == 'o') || (c == 'i') || (c == 'y') || (c == 'u') || (c == 'e');
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{
    if(a.first!=b.first)
    return a.first<b.first;
    return a.second>b.second;
}
int countSetBits(int x)
{
    if(x==0)return 0;
    else return 1+countSetBits(x&(x-1));
}
int fact(int n);

int nCr(int n, int r)
{
    return fact(n) / (fact(r) * fact(n - r));
}

// Returns factorial of n
int fact(int n)
{
    int res = 1;
    for (int i = 2; i <= n; i++)
        res = res * i;
    return res;
}
int n;
bool in_range(int x,int y)
{
    if(x>=0 && x<=n-1 && y>=0 && y<=n-1)return true;

    return false;
}
bool palindrom(string s)
{
    int len=s.length();
    bool okay=true;
    for(int i=0;i<=len/2;i++)
    {
        if(s[i]!=s[len-i-1]){okay=false; break;}
    }
    return okay;
}
signed main()
{
    fastio;
    int t;
    cin>>t;
    if(t>=30)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;

}


Measured memory_bytes: 3692
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner io = new Scanner(System.in);
		long N = io.nextLong();
		long M = io.nextLong();
		long ans = 0;
		if(N*2<=M){
			ans += N;
			M -= N*2;
			ans += M/4;
		}else{
			ans = M/2;
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22228
from collections import Counter

n=int(input())
*a,=map(int,input().split())

cnt=Counter(a)

mod=10**9+7

def modinv(x):
    return pow(x,mod-2,mod)

for k,v in cnt.items():
    if v==1:
        continue

    for i in range(n+1):
        if a[i]==k:
            left=i
            break
    
    for i in range(n,-1,-1):
        if a[i]==k:
            right=n-i
            break
    
    break

allcomb=1
lrcomb=[1]*(n+1)
for i in range(1,n+1):
    lrcomb[i]=(left+right-i+1)*modinv(i)*lrcomb[i-1]
    lrcomb[i]%=mod

for k in range(1,n+2):
    allcomb*=(n-k+2)*modinv(k)
    allcomb%=mod

    if left+right>=k-1:
        print((allcomb-lrcomb[k-1])%mod)
    else:
        print(allcomb)


Measured memory_bytes: 106048
import java.util.Scanner;
   
class Main{
 public static void main(String[] arge){
     
Scanner sc=new Scanner(System.in);

while (true){ 

int a=sc.nextInt();
int b=sc.nextInt();

if(a==0 && b==0)
{break;}


else{
for ( int i = 0; i < a; i++ ){
for ( int j = 0; j < b; j++ ){
        if((i+j)%2 ==1 ){
            System.out.print(".");
        } else {
            System.out.print("#");
        }
    }
    System.out.println("");
} 
}

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





Measured memory_bytes: 32284
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<iomanip>



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

using namespace std;
int a,b,c,d;
int k1,k2;
string s;

int main(){
  cin >> a >> b >> c >> d;
  if(a+b > c+d) cout << "Left" << endl;
  else if(a+b < c+d) cout << "Right" << endl;
  else cout << "Balanced" << endl;
  
  return 0;
}



Measured memory_bytes: 256
/*
name:       Egyptian Tourist
PlatForm:   CodeForces/SPOJ...etc
LANG:       C++
DIV:        Training
TIME:       *
RATE:       *
*/

/*
Time Consumed:*
Problem Topics: *
*/
#include <bits/stdc++.h>
#include <iostream>

using namespace std;
//----------------------------------//

typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

//-------------------------------------------------------//
#define rep(i,a,b) for (int i = (a), _b = (b); i <= _b; i++)
#define repr(i,a,b) for (int i = (a), _b = (b); i >= _b; i--)
#define lp(i,n) for (int i = 0, _n = (n); i < _n; i++)
#define lpr(i,n) for (int i = (n) - 1; ~i; i--)
#define foreach(it, ar) for ( typeof(ar.begin()) it = ar.begin(); it != ar.end(); it++ )
//-------------------------------------------------------------------------------------//

#define clr(ar, val) memset(ar, val, sizeof(ar))
//----------------------------------------------//

#define inn freopen("in.in","r",stdin)
#define outt freopen("out.out","w",stdout)
#define PI 3.1415926535897932385
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define pb push_back
#define pob pop_back
#define bit(n) (1<<(n))
#define Last(i) ( (i) & (-i) )
#define all(v) ((v).begin()), ((v).end())
#define sq(x) ((x) * (x))
#define INF INT_MAX
#define Ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

//-------------------------------------------------------------//
#ifndef DEBUG
#define debug(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1)
{
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args)
{
    const char* comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1<<" | ";
    __f(comma+1, args...);
}
#else
#define debug(...)
#endif
#define _ist_ cout << "\nSTART OF INPUT DISPLAYING CHECK\n";
#define _iend_ cout << "\nEND OF INPUT DISPLAYING CHECK\n";
//------------------------------------------------------------//
template<class T, class T2>
T _f_pow(T a, T2 b)
{
    T res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
#define N (int)1e5+5
ll dp[N];
ll n, s;
ll _w[105];
ll _v[105];
int main()
{
    Ios;
    //inn;//outt;
    //auto tt = clock();
    cin >> n >> s;
    clr(dp, 0x3f);
    ll mx_profit = 0;
    rep(i, 1, n)
    {
        cin >> _w[i] >> _v[i];
        mx_profit += _v[i];
    }
    ll ans = 0LL;
    dp[0] = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = mx_profit; j >= _v[i]; j--)
        {
            dp[j] = min(dp[j - _v[i]] + _w[i], dp[j]);
            if(dp[j] <= s)
            {
                //cout << dp[j] << "\t" << j <<"\n";
                ans = max(ans, (ll)j);
            }
        }
    }
    cout << ans << "\n";
    //cout << (double(clock() - tt)/CLOCKS_PER_SEC * 1.00) << endl;
    return 0;
}


Measured memory_bytes: 1024
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#include<bits/stdc++.h>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;


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

int a,b;

cin >> a>> b;

if ( a >= 13){
cout << b << endl;
}

if ( a >= 6 && a <= 12){
cout << b/2 << endl;
}

if( a <= 5){
cout<< 0 << endl;
}

//////////////////////////////////////////////////////
return 0;}

Measured memory_bytes: 256
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
        ($s:expr=>$($t:tt)*) => {
            let mut lines=$s.split("\n");
            $(
                line_parse!(lines,$t);
             )*
        };
    }

    macro_rules! line_parse {
        ($lines:expr,($($name:ident:$t:tt)*)) => {
            let mut line=$lines.next().unwrap().split_whitespace();
            $(value_def!(line,$name,$t);)*
        };

        //multiple lines
        ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
            values_def!($lines,$n,$name,$t);
        };
    }

    macro_rules! value_def {
        ($line:expr, $name:ident, $t:tt) => {
            let $name = value!($line, $t);
        };
    }

    macro_rules! values_def {
        ($lines:expr, $n:expr, $name:ident, $t:tt) => {
            let $name = {
                let mut vec = Vec::new();
                for i in 0..$n {
                    let mut next = $lines.next().unwrap().split_whitespace();
                    vec.push(value!(next, $t));
                }
                vec
            };
        };
    }

    macro_rules! value {
        //array
        ($line:expr,[$t:tt]) => {
            $line.map(|x|{
                let mut iter=::std::iter::once(x);
                value!(iter,$t)
            }).collect::<Vec<_>>()
        };
        //tuple
        ($line:expr,($($t:tt),*)) => {
            ($(value!($line,$t),)*)
        };
        //string
        ($line:expr,#) => {
            $line.next().unwrap()
        };
        //one number
        ($line:expr,$t:ty) => {
            $line.next().unwrap().parse::<$t>().unwrap()
        };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(a:usize b:usize));
    
    if a == b {
        return "Draw".to_string()
    }
    
    if a == 1 || (b != 1 && b < a) {
        "Alice".to_string()
    } else {
        "Bob".to_string()
    }

}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
             )*
        }
    }
}

tests! {
    test1: "8 6" => "Alice",
    test2: "1 1" => "Draw",
    test3: "13 1" => "Bob",
}



Measured memory_bytes: 4352
N=int(input())
D={}
from decimal import Decimal
A=[Decimal(input()) for _ in range(N)]
A=[int(i*10**9) for i in A]
for i in range(N):
  x=A[i]
  y=x
  tcnt,fcnt=0,0
  while x%2==0 and tcnt<18:
    tcnt+=1
    x//=2
  while y%5==0 and fcnt<18:
    fcnt+=1
    y//=5
  if (tcnt,fcnt) not in D:
    D[((tcnt,fcnt))]=1
  else:
    D[((tcnt,fcnt))]+=1

ans=0
for t1,f1 in D:
  for t2,f2 in D:
    if t1+t2>=18 and f1+f2>=18:
      if t1==t2 and f1==f2:
        ans+=D[(t1,f1)]*(D[(t1,f1)]-1)
      else:
        ans+=D[(t1,f1)]*D[(t2,f2)]
print(ans//2)

Measured memory_bytes: 308468
let () =
  let n = read_int () in
  let rec doit i m ans =
    if i >= n then ans
    else let r = read_int () in let x = r - m in doit (i + 1) (min m r) (max ans x)
  in
  Printf.printf "%d\n" (doit 1 (read_int ()) min_int)

Measured memory_bytes: 4432
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define sz(x) int (x.size());
using namespace std;
const int MOD=1000000007;

int main(){
  string s,t;
  cin>>s>>t;
  vector<vector<int>> c(26);
  ll ns,nt;
  ns=sz(s);nt=sz(t);
  rep(i,ns){
    ll now=s[i]-'a';
    c[now].push_back(i);

  }
  rep(i,ns){
    ll now=s[i]-'a';
    c[now].push_back(i+ns);

  }
  ll ans=0;
  ll pos=0;
  rep(i,nt){
    ll temp=t[i]-'a';
    if (c[temp].size()==0) {
      ans=-1;break;}
    pos=*lower_bound(c[temp].begin(),c[temp].end(),pos)+1;
    if (pos>=ns){
      pos-=ns;ans+=ns;
    }

  }
  if (ans!=-1)ans+=pos;

  cout<<ans;
return 0;
}


Measured memory_bytes: 1724
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2)
 
int main() {
  vi ABC(3);
  REP(i,3) cin >> ABC.at(i);
  sort(ABC.begin(), ABC.end());
  if(ABC.at(0) == ABC.at(2))
    cout << "No" << endl;
  else if (ABC.at(1) == ABC.at(0) || ABC.at(1) == ABC.at(2))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;    
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <stdlib.h>
#include <string>
#include <algorithm>
#include <map>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> P;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()


int main(){
  int N;
  cin >> N;
  vll A(N);
  rep(i, N){cin >> A[i];}
  vll B(N);
  copy(A.begin(), A.end(), B.begin());
  sort(B.begin(), B.end());
  int ans_l = B[N/2-1];
  int ans_r = B[N/2];
  rep(i, N){
    if (A[i] <= ans_l){
      cout << ans_r << endl;
    }
    else{
      cout << ans_l << endl;
    }
  }
}

Measured memory_bytes: 5376
x = int(input())
if 400 <= x <= 599:
    print(8)
elif 600 <= x <= 799:
    print(7)
elif 800 <= x <= 999:
    print(6)
elif 100 <= x <= 1199:
    print(5)
elif 1200 <= x <= 1399:
    print(4)
elif 1400 <= x <= 1599:
    print(3)
elif 1600 <= x <= 1799:
    print(2)
elif 1800 <= x <= 1999:
    print(1)

Measured memory_bytes: 9096
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <string>
#include <map>
#include <cerrno>
#include <stdio.h>
#include <stdlib.h>
#include <cfenv>
#include <stack>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int main(){

    string s1,s2;
    cin >> s1 >> s2;

    map<char,int> m1,m2;

    for(int i=0;i<s1.size();i++){
        m1[s1[i]];
        m1[s1[i]]++;
    }
    for(int i=0;i<s2.size();i++){
        m2[s2[i]];
        m2[s2[i]]++;
    }

    for(int i=0;i<s1.size();i++){
        if(m1[s1[i]]!=m2[s2[i]]){
            cout << "No" << endl;
            return 0;
        }
    }
    if(s1.size()==s2.size()){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
    return 0;
}

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

def main():
    n, k, q = map(int, input().split())
    a = [int(input()) for i in range(q)]
    n_list = [k-q]*n
    for i in a:
        n_list[i-1] += 1

    for i in n_list:
        if i>0:
            print("Yes")
        else:
            print("No")

main()


Measured memory_bytes: 10452
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <sstream>
#include <functional>
#include <map>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <deque>
#include <set>
#include <list>
#include <numeric>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const ll INF = 1LL<<29;
const ll mod = 1e9+7;
#define rep(i,n) for(int (i)=0;(i)<(ll)(n);++(i))
#define repd(i,n,d) for(ll (i)=0;(i)<(ll)(n);(i)+=(d))
#define all(v) (v).begin(), (v).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset((m),(v),sizeof(m))
#define chmin(X,Y) ((X)>(Y)?X=(Y),true:false)
#define chmax(X,Y) ((X)<(Y)?X=(Y),true:false)
#define fst first
#define snd second
#define UNIQUE(x) (x).erase(unique(all(x)),(x).end())
template<class T> ostream &operator<<(ostream &os, const vector<T> &v){int n=v.size();rep(i,n)os<<v[i]<<(i==n-1?"":" ");return os;}
#define N3 2155 // 10^(10/3)
#define N2 100010 // 10^(10/2)
#define N4 4641590 //10^(20/3)
bool p[N2];
vector<int> prime;
int n3, n2;

int main(){
	p[0] = p[1] = 1;
	for(int i = 2; i*i<N2; i++){
		if(p[i]) continue;
		for(int j = i*i; j<N2; j+=i){
			p[j] = 1;
		}
	}
	rep(i, N2){
		if(i==N3) n3 = prime.size();
		if(p[i]) continue;
		prime.push_back(i);
	}
	/*{
		ll sum = 1;
		rep(i, n3){
			sum *= prime[i];
			cerr<<sum<<endl;
		}
	}*/
	cerr<<prime[n3-1]<<" "<<prime[n3]<<endl;
	n2 = prime.size();
	int n;
	cin>>n;
	vector<ll> s(n), s2(n);
	map<ll, ll> cnt, cnt2;
	rep(i, n){
		ll x;
		cin>>x;
		ll x3 = 1, x4 = 1;
		bool o = false;
		rep(i, n3){
			ll y = prime[i];
			y = y*y*y;
			while(x%y==0) x /= y;
			if(x%prime[i]==0) x4 *= y;
			y = prime[i];
			while(x%y==0){
				x /= y;
				x3 *= y;
				x4 /= y;
			}
			if(x4>1e10) o = true;
		}
		s[i] = x*x3;
		++cnt2[s[i]];
		if(o) cerr<<"overflow"<<endl;
		if(o) continue;
		if(x<N4){
			if(x4*x*(double)x>1e10) continue;
			ll z = x*x*x4;
			++cnt[z];
			s2[i] = z;
		} else {
			ll t = sqrt(x);
			while(t*t<x) t++;
			if(t*t==x){
				ll z = t*x4;
				++cnt[z];
				s2[i] = z;
			}
		}
		cerr<<s2[i]<<endl;
	}
	rep(i, n) cerr<<s[i]<<endl;
	sort(all(s)); UNIQUE(s);
	ll res = 0;
	for(auto x: s){
		if(x==1){
			res += 2;
			continue;
		}
		if(cnt2[x]>cnt[x]) res += cnt2[x];
		if(cnt2[x]>=cnt[x]) res += cnt2[x];
	}
	res /= 2;
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 17408
import sys
from collections import deque
import copy
import math
def get_read_func(fileobject):
    if fileobject == None :
        return raw_input
    else:
        return fileobject.readline



def main():
    if len(sys.argv) > 1:
        f = open(sys.argv[1])
    else:
        f = None
    read_func = get_read_func(f);
    input_raw = read_func().strip().split()
    [N, K] = [int(input_raw[0]), int(input_raw[1])]
    print N - K + 1

if __name__ == '__main__':
    main()


Measured memory_bytes: 2932
// ConsoleApplication5.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

#include <iostream>
#include <string>
int main()
{
	std::string str;
	int n;
	int count = 0;
    std::cin >> n >> str;
  
	for (int i = 0; i < n; i++) {
		if (str[i] == 'A' && str[i + 1] == 'B' && str[i + 2] == 'C') {
			count++;
		}
	}
	std::cout << count << std::endl;
	return 0;
}



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

int main() {
  int h,w;
  cin>>h>>w;
  vector<vector<char>> vec(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>vec[i][j];
    }
  }
  vector<bool> H(h),W(w);
   for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(vec[i][j]=='#')H[i]=W[j]=true;
    }
   }
  for(int i=0;i<h;i++){
    if(!H[i])continue;
    for(int j=0;j<w;j++){
      if(!W[j])continue;
      cout<<vec[i][j];
    }
    cout<<endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii=pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c),end(c)
#define rall(c) rbegin(c),rend(c)
#define fore(x,c) for(auto &&x:c)
#define rep(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define rrep(i, a, n) for(int i=(int)(n-1);i>=a;--i)
#define sz(c) ((int)c.size())
#define contains(c,x) (c.find(x)!=end(c))
#define inseg(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(0);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N;
    cin >> N;
    int ba = 0;
    int xa = 0;
    int bx = 0;
    int ans = 0;
    rep(i, 0, N) {
        string s;
        cin >> s;
        if (s.front() == 'B' && s.back() == 'A') ba++;
        if (s.front() == 'B' && s.back() != 'A') bx++;
        if (s.front() != 'B' && s.back() == 'A') xa++;
        rep(i, 0, sz(s) - 1) {
            if (s[i] == 'A' && s[i + 1] == 'B') {
                ans++;
            }
        }
    }
    dump(ba, xa, bx, ans);
    if (ba > 0) {
        ans += ba - 1;
        if (xa > 0) {
            ans++;
            xa--;
        }
        if (bx > 0) {
            ans++;
            bx--;
        }
    }
    ans += min(xa, bx);
    cout << ans << endl;
    return (0^_^0);
}



Measured memory_bytes: 256
n=int(input())
*a,=map(int,input().split())
*b,=map(int,input().split())

l=sorted([j-i for i,j in zip(a,b)])[::-1]
t=0
ans=0

if sum(l)>0:
  print(-1)
else:
  for i in l:
    if i>0:
      t+=i
      ans+=1
    else:break

  for i in l[::-1]:
    if t+i>=0 and i<0:
      t=t+i
      ans+=1
    elif t:
      t=0
      ans+=1
    else:
      break

  print(ans)

Measured memory_bytes: 18708
// author: Saman Mahdanian
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>

using namespace std;
typedef pair<int, int> pii;

const int N = 2e3 + 10;

int n, k, par[N], u, v, ans;
vector <int> g[N];
queue <pii> bfs;
bool mark[N];

void input();
void dfs (int, int);
int check (int);

int main() {
	input();
	dfs(0, 0);
	ans = n + 2;
	for (int i = k & 1; i < n; i++)
		ans = min(ans, check(i));
	cout << ans << endl;
}

void input() {
	cin >> n >> k;
	for (int i = 0; i < n - 1; i++) {
		cin >> v >> u;
		v--; u--;
		g[v].push_back(u);
		g[u].push_back(v);
	}
}

void dfs (int v, int pv) {
	par[v] = pv;
	for (int u : g[v])
		if (u != pv)
			dfs(u, v);
}

int check (int v) {
	memset(mark, 0, sizeof mark);
	while (bfs.size())
		bfs.pop();
	bfs.push({v, 0});
	mark[v] = true;
	if (k & 1) {
		bfs.push({par[v], 0});
		mark[par[v]] = true;
	}

	int cnt = 0;
	while (bfs.size()) {
		auto h = bfs.front();
		// cout << "~~ " << h.first << endl;
		mark[h.first] = true;
		if (h.second < (k / 2)) {
			for (int u : g[h.first])
				if (!mark[u]) {
					// cout << "----> " << u << endl;
					bfs.push({u, h.second + 1});
				}
		}
		cnt++;
		bfs.pop();
	}
	// cout << cnt << ' ' << v << ' ' << par[v] << endl;
	return n - cnt;
}
// SamMHD :: Oct3-2018 :: Another Day With Shayan the gold...

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


using namespace std;

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REPR(i, n) for(ll i = n;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define FORR(i, m, n) for(ll i = m;i >= n;i--)
#define REPO(i, n) for(ll i = 1;i <= n;i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(),n.end()
#define MOD (ll)1000000007
#define P pair<ll, ll>



int main() {
	int n;
	cin >> n;
	cout << n * n * n <<endl;
}
	


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i,n[600]={0};
  char s[3],t[]={"ABCO"};
  while(scanf("%*d,%s",s)!=EOF){
    if(s[1])s[0]='C';
    n[s[0]]++;
  }
  for(i=0;i<4;i++)printf("%d\n",n[t[i]]);
  return 0;
}
	

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

using ll = long long int;
using llu = unsigned long long int;
using ld = long double;
const long long int NUM = 1000000;
const long double PI = 2*acos(0.0);
const int INF = 1e9 + 10 ;
const long long int maximum = (-1*INF);
#define LCM(a,b)            (a / __gcd(a,b)) * b
#define GCD(a,b)            __gcd(a,b)
#define dist(x1,y1,x2,y2)   sqrtl((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1))
#define sqr(a)              ((a)*(a))
#define fast                ios_base::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr)
#define precision(a)        fixed<<setprecision(a)
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define ub                  upper_bound
#define lb                  lower_bound
#define all(x)              x.begin(), x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define REP(i,b)            for(long long int i = 0; i < b; i++)
#define READ(f)             freopen("f", "r", stdin)
#define WRITE               freopen("out.txt", "w", stdout)

/*bool compare(const pair<ll, ll> &a, const pair<ll, ll> &b)
{
    if(a.ff == b.ff)
        return a.ss <= b.ss;
    return a.ff < b.ff;
}*/

/*map<char, ll> m = { {'q', 9}, {'r', 5}, {'b', 3}, {'n', 3},
                      {'p', 1}, {'k', 0}, {'.', 0} };*/

int main() {
    ll a, b, k;
    cin >> k >> a >> b;
    for (ll i = a; i <= b; i++) {
        if(i%k == 0) {
            cout << "OK";
            return 0;
        }
    }
    cout<< "NG";
    return 0;
}


Measured memory_bytes: 3648
fun main(args: Array<String>) {
    agc034b()
}

fun agc034b() {
    val s = readLine()!!.replace("BC", "D")

    var aCount = 0L
    var answer = 0L
    s.forEach {
        when (it) {
            'A' -> aCount++
            'D' -> answer += aCount
            else -> aCount = 0L
        }
    }

    println(answer)
}


Measured memory_bytes: 45424
#include<stdio.h>
#define N 200000
int main(void){
	int set;
	int i;
	int a[N];
	int max, min;
	int tmp;
	scanf("%d", &set);
	for(i=0;i<set;i++) {
		scanf("%d",&a[i]);
	}

	for(i=1;i<set;i++){
		if(i==1){
			max = a[1]-a[0];
			min = a[0];
		}
		tmp = a[i]-min;
		if(tmp>max)max = tmp;
		if(a[i]<min)min=a[i];
	}
	printf("%d\n", max);
	return 0;
}

Measured memory_bytes: 2556
open Batteries

let len = Scanf.scanf "%d\n" (
        fun k -> 
                Scanf.scanf "%d %d" (
                        fun a b -> 
                                List.range a `To b
                                |> List.filter (fun x -> x mod k = 0)
                )
) |> List.length
 
let () = Printf.printf "%s\n" (if len = 0 then
                                       "NG"
                               else
                                       "OK"
                              )

Measured memory_bytes: 4912
#include <bits/stdc++.h>
using namespace std;
int main(void){
  int A,B,C,cnt=0;
  cin>>A>>B>>C;
  for(int i=0;i<C;i++){
  	if(B>=A){
      B-=A;
      cnt++;
    }else break;
  }
  cout<<cnt<<endl;
}


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

using namespace std;

long long n;

bool check(long long a, long long b)
{
	return a % b == 0;
}

void work()
{
	for (long long i = 1; i <= 3500; i++)
	{
		for (long long j = i; j <= 3500; j++)
		{
			if (4*i*j-(i+j)*n <= 0) continue;
			if (check(i*j*n, 4*i*j-(i+j)*n))
			{
				printf("%I64d %I64d %I64d\n", i,j, (i*j*n)/(4*i*j-(i+j)*n));
				return;
			}
		}
	}
}

int main()
{
	scanf("%I64d", &n);
	work(); 
	return 0;
}

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

using namespace std;

typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)


bool func(int c, vector<int> h, int A, int B){
	int n = h.size();
	for (int i = 0; i < n; i++){
		h[i] -= B*c;
	}
	int cnt = 0;
	for (int i = 0; i < n; i++){
		if (h[i]>0)
			cnt += (int)ceil((double)h[i] / (A - B));
	}
	cerr << c << " " << (cnt <= c ? true : false) << endl;
	if (cnt <= c) return true;
	else return false;
}

signed main(){

	int N, A, B;
	vector<int> h;
	cin >> N >> A >> B;
	int sum = 0;
	for (int i = 0; i < N; i++){
		int t;
		cin >> t;
		h.push_back(t);
		sum += t / B+1;
	}
	sort(h.begin(), h.end(), greater<int>());

	int l = 0, r = sum;
	while (r - l > 1){
		int mid = (r + l) / 2;

		if (func(mid, h, A, B))
			r = mid;
		else
			l = mid;
	}

	if (func(r, h, A, B))
		cout << r << endl;
	else
		cout << l << endl;



	return 0;
}

Measured memory_bytes: 1908
import itertools
kouho = list(itertools.product([0,1],repeat=3))

ABCD = str(input())

result = ""

for i in kouho:
    
    cnt=0
    sum =0
    result=""
    
    for j in i:
        
        if j==0:
            
            if cnt==0:
                sum   += int(ABCD[cnt]) +int(ABCD[cnt+1])
                result +=ABCD[cnt] + "+" + ABCD[cnt+1]
            else:
                sum += int(ABCD[cnt+1])
                result += "+" + ABCD[cnt+1]
        else:
            
            if cnt==0:
                sum   +=  int(ABCD[cnt]) - int(ABCD[cnt+1])
                result +=  ABCD[cnt] +  "-" + ABCD[cnt+1]
            else:
                sum = sum - int(ABCD[cnt+1])
                result +="-"+ ABCD[cnt+1]
            
        cnt+=1
        
    if sum==7:
        result += "=7"
        print(result)
        break



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

s = [int(input())]
#print(s)

while len(s) == len(set(s)):
    if s[-1]%2==0:
        s.append(s[-1]//2)
#        print(s)
    else:
        s.append(s[-1]*3+1)
#        print(s)

print(len(s))


Measured memory_bytes: 2940
#include <cstdio>
#include <algorithm>
#define maxn 300005
using namespace std;

int n, ans = 999999999;
int sum[maxn];
char s[maxn];

int main()
{
	scanf("%d", &n);
	scanf("%s", s);
	for (int i = 1; i <= n; i++)
	{
		if (s[i - 1] == 'E') sum[i] = sum[i - 1] + 1;
		else sum[i] = sum[i - 1];
	}
	for (int i = 1; i <= n; i++)
		ans = min(ans, (i - 1 - sum[i - 1]) + (sum[n] - sum[i]));
	printf("%d", ans);
	return 0;
}

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

int main(){
	ll h,w; cin >> h >> w;
	char s[50][50];
	rep(i,h){
		rep(j,w)cin >> s[i][j];
	}
	ll white = 0;
	rep(i,h){
		rep(j,w){
			if(s[i][j] == '.')white++;
		}
	}
	ll dist[50][50];
	rep(i,h){
		rep(j,w)dist[i][j] = -1;
	}
	queue<P> que;
	dist[0][0] = 0;
	que.push(make_pair(0,0));
	vl vx = {1,0,-1,0};
	vl vy = {0,1,0,-1};

	while(!que.empty()){
		P v = que.front();
		que.pop();
		rep(i,4){
			if(v.first+vy[i] == -1 || v.first+vy[i] == h)continue;
			else if(v.second+vx[i] == -1 || v.second+vx[i] == w)continue;
			else if(dist[v.first+vy[i]][v.second+vx[i]] != -1)continue;
			else if(s[v.first+vy[i]][v.second+vx[i]] == '#')continue;
			else{
				dist[v.first+vy[i]][v.second+vx[i]] = dist[v.first][v.second] + 1;
				que.push(make_pair(v.first+vy[i],v.second+vx[i]));
			}
		}
	}
	dist[h-1][w-1] == -1 ? cout << -1 << endl : cout << white - dist[h-1][w-1] -1<< endl;
}

Measured memory_bytes: 256
H = int(input())
A = list(map(int, input().split()))
for i in range(H):
    s = f"node {i + 1}: key = {A[i]}, "
    if i != 0:
        s += f"parent key = {A[(i - 1) // 2]}, "
    if H > i * 2 + 1:
        s += f"left key = {A[i * 2 + 1]}, "
    if H > i * 2 + 2:
        s += f"right key = {A[i * 2 + 2]}, "
    print(s)



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,c,s=0;
    cin>>n;
    int i,temp;
    for(i=1;i<=n;i++)
    {
        temp=i;c=0;
        while(temp!=0)
        {
            temp=temp/10;
            c++;
        }
        if(c%2==1) s++;
    }
    cout<<s<<endl;
    return 0;
}





Measured memory_bytes: 256
/*  "Sahand Alitanloo"  */
#include <bits/stdc++.h>
#define F first
#define S second
#define fast() ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define per(i) cout<<fixed<<setprecision(i)
#define pb push_back
#define all(v) begin(v),end(v)
//#define endl '\n'
using namespace std;
typedef pair<int,int> pii;
typedef long double ld;
typedef long long ll;
const int MAX_N = 1e5+10;
const ll mod = 1e9+7;
const ll INF = 1e9;
inline ll bpow(ll t,ll n){ll ans=1;while(n>0){if(n&1)ans=(ans*t)%mod;t=(t*t)%mod,n>>=1;}return ans;}
/*
ll fact[MAX_N],ifact[MAX_N];
inline ll c(ll n,ll k){if(k>n||k<0)return 0;return (fact[n]*ifact[k]%mod*ifact[n-k])%mod;}
inline void get_fact(){fact[0]=1;ifact[0]=1;for(ll i=1;i<MAX_N;i++)fact[i]=(fact[i-1]*i)%mod,ifact[i]=bpow(fact[i],mod-2);}
*/

#define int ll
int k,a[MAX_N];
int get(int x,int y){
    if(x%y==0)
        return x/y;
    return x/y+1;
}
main(){
    fast();per(0);
    //get_fact();
    cin>>k;
    for(int i=1;i<=k;i++)
        cin>>a[i];
    if(a[k]!=2)
        return cout<<-1,0;
    int l=2,r=3;
    for(int i=k-1;i>=1;i--){
        l=get(l,a[i])*a[i];
        r=(r/a[i])*a[i]+a[i]-1;
     //   cout<<l<<" "<<r<<endl;
    }
    int curr=l;
	for(int i=1;i<=k;i++)
		curr-=(curr%a[i]);
	if(curr!=2)
        return cout<<-1,0;
	cout<<l<<" "<<r;
}


Measured memory_bytes: 1024
mod = 998244353


class Combination:
    """
    SIZEが10^6程度以下の二項係数を何回も呼び出したいときに使う
    使い方:
    comb = Combination(SIZE, MOD)
    comb(10, 3) => 120
    """

    def __init__(self, N, MOD=10 ** 9 + 7):
        self.MOD = MOD
        self.fact, self.inv = self._make_factorial_list(N)

    def __call__(self, n, k):
        if k < 0 or k > n:
            return 0
        res = self.fact[n] * self.inv[k] % self.MOD
        res = res * self.inv[n - k] % self.MOD
        return res

    def _make_factorial_list(self, N):
        fact = [1] * (N + 1)
        inv = [1] * (N + 1)
        MOD = self.MOD
        for i in range(1, N + 1):
            fact[i] = (fact[i - 1] * i) % MOD
        inv[N] = pow(fact[N], MOD - 2, MOD)
        for i in range(N, 0, -1):
            inv[i - 1] = (inv[i] * i) % MOD
        return fact, inv


if __name__ == "__main__":
    N, A, B, K = map(int, input().split())
    U = 3 * 10 ** 5 + 10
    comb = Combination(U, mod)

    ans = 0
    if A > B:
        A, B = B, A
    for i in range(N + 1):
        X = A * i
        if X > K:
            continue
        if (K - X) % B != 0:
            continue
        if (K - X) // B > N:
            continue
        j = (K - X) // B

        red = comb(N, i)
        blue = comb(N, j)
        ans = (ans + red * blue % mod) % mod
    print(ans)

Measured memory_bytes: 26740
#include "bits/stdc++.h"
#define ll long long
#define vl vector<ll>
#define pl pair<ll,ll>
#define mp make_pair
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define rep(i,b) for(ll i=0;i<b;i++)
#define per(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define all(v) (v).begin(),(v).end()
using namespace std;

pl f(ll x){
    ll a = x%10;
    ll b=0;
    while(x){
        b=x;
        x/=10;
    }
    return pl(a,b);
}

int main(){
    ll n;
    cin>>n;
    map<pl,ll>freq;
    rep(i,n){
        pl p= f(i+1);
        freq[p]++;
    }
    ll ans=0;
    rep(i,n){
        pl p=f(i+1);
        pl q(p.second,p.first);
        ans += freq[q];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
N = int(input())
ls = input().split()
sumh = 0
for n in range(len(ls)):
  if n == 0:
    h = int(ls[0])
  else:
    if h <= int(ls[n]):
      h = int(ls[n])
    else:
      sumh += h - int(ls[n])
print(sumh)

Measured memory_bytes: 25164
#include <iostream>
#include <algorithm>

using namespace std;

#define N 100001

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

    int A[N];
    for (int i = 0; i < n; i++) {
        cin >> A[i];
    }

    int q;
    cin >> q;
    int t;
    int count = 0;
    for (int i = 0; i < q; i++) {
        cin >> t;
        if (*lower_bound(A, A + n, t) == t) {
            count++;
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3472
//算数的な問題　

#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int inf{int(1e9)};

int f(int n){
  if (n == 0) return 1;
  else return n * f(n - 1);
}

int main(void){
  int N;
  cin >> N;
  vector <int> x(N), y(N);
  rep(i,N) cin >> x[i] >> y[i];
  //ラムダ式
  //点iと点jの距離
  auto dist = [&](int i, int j){
    double dx = x[i] - x[j];
    double dy = y[i] - y[j];
    return sqrt(dx * dx + dy * dy);
  };

  //順列を使わない方法
  double len = 0;
  rep(i,N)rep(j,i){
    len += dist(i,j);
  }
  double ans = (len * 2) / N;

  //順列を使う方法
  // vector <int> p(N);
  // rep(i,N) p[i] = i;
  // double len = 0;  //長さ
  // int cnt = 0;
  // do {
  //   rep(i,N-1){
  //     len += dist(p[i], p[i + 1]);
  //   }
  //   cnt ++;
  // } while (next_permutation(all(p)));
  // double ans = len/cnt;
  cout << fixed << setprecision(10) << ans << endl;
  return 0;
}


Measured memory_bytes: 3804
/*
 * Author: .-O_O-.
 */
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define rep0(a,b) for(int a=0;a<b;a++)
#define rep1(a,b) for(int a=1;a<=b;a++)
#define repp(a,b,c) for(int a=b;a<c;a++)
#define in insert
#define len length()
#define si size()
#define lb lower_bound
#define ub upper_bound
#define beg begin()
#define en end()
#define f first
#define s second
#define pr(a) cout<<a
#define pr2(a,b) cout<<a<<" "<<b<<"\n"
#define nx cout<<"\n"
#define int long long
// void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
                                                     
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]"<<endl;}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define deb(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define deb(x...)
#endif
const ll mod = 1000000007;
const ll N = 200005;
const ll mm = 1e+18;
void solve()
{
    int h,w;
    cin>>h>>w;
    char c[h][w];
    rep0(i,h)rep0(j,w) cin>>c[i][j];
    rep0(i,2*h){
        rep0(j,w) cout<<c[i/2][j];
        nx;
    }
}
signed main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int t=1;
    //cin>>t;
    rep1(_i,t){
        //cout<<"Case #"<<_i<<": ";
        solve();
        //nx;
    }
    return 0;
}


Measured memory_bytes: 3644
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
inline void add(int &x,int y){(x+=y)>=mod?x-=mod:0;}
inline int pl(int x,int y){return (x+=y)>=mod?x-mod:x;}
int kpow(int a,int b)
{
	int s=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1)s=1ll*s*a%mod;
	return s;
}
int n,a,b,f[5050][2],g[5050],dp[5050][2],ans;
int main()
{
	scanf("%d %d %d",&n,&a,&b);
	if(a>b)swap(a,b);
	if(b>=2)
	{
		f[0][0]=f[0][1]=1;
		for(int i=1;i<=b;++i)
			for(int j=1;j<=i;++j)
			{
				if(j>=a)add(f[i][0],f[i-j][1]);
				add(f[i][1],f[i-j][0]);
			}
		g[0]=1;
		for(int i=1;i<=b;++i)g[i]=pl(f[i][0],f[i][1]);
	//	for(int i=1;i<=b;++i)printf("%d ",g[i]);printf("\n");
		dp[0][0]=dp[0][1]=1;
		for(int i=1;i<=n;++i)
			for(int j=1;j<=i;++j)
			{
				if(j<b)dp[i][1]=(dp[i][1]+1ll*dp[i-j][0]*g[max(j-(i!=j)-(i!=n),0)])%mod;
				if(j<a)add(dp[i][0],dp[i-j][1]);
			}
	//	for(int i=1;i<=n;++i)printf("%d %d\n",dp[i][0],dp[i][1]);
		ans=pl(dp[n][0],dp[n][1]);
	}
	printf("%d",pl(kpow(2,n),mod-ans));
	return 0;
}

Measured memory_bytes: 1824
N = int(input())

def iter_nums():
    xs = "357"
    while 1:
        for x in xs:
            yield x
        xs = [n + x for n in "357" for x in xs]

result = 0
for s in iter_nums():
    n = int(s)
    if n > N:
        break
    if "3" in s and "5" in s and "7" in s:
        result += 1

print(result)

Measured memory_bytes: 8752
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		String[] str = s.split(" ");
		System.out.printf("%s%s\n", str[1], str[0]);
		r.close();
	}
}

Measured memory_bytes: 21332
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();   
        var H = input[0];
        var cnt = 1;
        for (var i = 1; i < N; i++) {
            if (input[i] >= H) {
                cnt++;
                H = input[i];
            }
        }
        Console.WriteLine(cnt);
    }
}


Measured memory_bytes: 13268
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>
#include <string.h>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<ll,ll> P;
#define REP(i,n) for(long long i = 0; i < (long long)(n); i++)
#define pb push_back // vectorに要素追加
#define INF (ll)1e18

ll mod = 1e9+7;
  
int main() {
	// 入力
	ll N, K;cin>>N>>K;
    string S;cin>>S;

	// 解法
    ll num_block = 1;
    REP(i,N-1){
        if (S[i]!=S[i+1]) num_block++;
    }
    // printf("num_black: %lld\n", num_block);
    num_block -= 2 * K;
    if (num_block<1) num_block = 1;
    // num_block = max(num_block, 1);
    ll ans = N - num_block;

	//出力
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  bool ok = false;
  
  int cnt=0;
  while(a>=b){
    b*=2;
    cnt++;
  }
  while(b>=c){
    c*=2;
    cnt++;
  }
  if(cnt<=k)ok=true;
  if(ok)cout<<"Yes" << endl;
  else cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 3644
import os
import sys

import numpy as np


def solve(n, kd, precalc_x, precalc_y):
    ans = np.full(n + 1, 10 ** 18, dtype=np.int64)

    for bit in range(1 << n):
        k = kd[bit]
        v = bit
        while v:
            ans[k] = min(ans[k], np.minimum(precalc_x[v], precalc_y[v ^ bit]).sum())
            v = (v - 1) & bit
        ans[k] = min(ans[k], np.minimum(precalc_x[0], precalc_y[bit]).sum())

    return ans


if sys.argv[-1] == 'ONLINE_JUDGE':
    from numba.pycc import CC

    cc = CC('my_module')
    cc.export('solve', '(i8, i8[:], i8[:,:], i8[:,:])')(solve)
    cc.compile()
    exit()

if os.name == 'posix':
    # noinspection PyUnresolvedReferences
    from my_module import solve
else:
    from numba import njit

    solve = njit('(i8, i8[:], i8[:,:], i8[:,:])', cache=True)(solve)
    print('compiled', file=sys.stderr)

inp = np.fromstring(sys.stdin.read(), dtype=np.int64, sep=' ')
n = inp[0]
xxx = inp[1::3]
yyy = inp[2::3]
ppp = inp[3::3]

bit_d = (((np.arange(1 << n)[:, None] & (1 << np.arange(n)))) > 0).astype(np.int64)
precalc_x = abs((xxx[None, :] * bit_d)[..., None] - xxx[None, None, :]).min(axis=1) * ppp[None, :]
precalc_y = abs((yyy[None, :] * bit_d)[..., None] - yyy[None, None, :]).min(axis=1) * ppp[None, :]
kd = bit_d.sum(axis=1)

ans = solve(n, kd, precalc_x, precalc_y)
print('\n'.join(map(str, ans)))


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

int main() {
    string n;
    int co = 1;
    cin >> n;
    int tmp = n[0];
    for (int i = 1; i < 4; ++i) {
        if (tmp == n[i])
            co++;
        if (co >= 3)
            break;
        if (tmp != n[i]) {
            tmp = n[i];
            co = 1;
        }
    }
    if (co >= 3)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using Graph = vector<vector<int>>;
signed main(){
  string a;
  cin>>a;
  int b=0;
  rep(i,4){
  if(a[i]=='2')
    b++;
  }
    cout<<b<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int64;

int64 sum_xor(int64 n) {
  switch (n % 4) {
    case 0:
      return 0 ^ n;
      break;
    case 1:
      return 1;
      break;
    case 2:
      return 1 ^ n;
      break;
    case 3:
      return 0;
      break;
  }
  return 0;
}

int main(int argc, const char *argv[])
{
  int64 a, b;
  scanf("%lld%lld", &a, &b);
  a = sum_xor(a - 1);
  b = sum_xor(b);
  printf("%lld\n", a ^ b);
  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>

using namespace std;

int main() {
	string a;
	cin >> a;
	if (a == "ARC") {
		cout << "ABC" << endl;
	}
	else {
		cout << "ARC" << endl;
	}

}

Measured memory_bytes: 3652