akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1e18

int main() {
    int N, K;
    cin >> N >> K;
    int ans = 1;
    while (N >= K) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b)
{
    return b ? gcd(b, a % b) : a;
}
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

void func(long long N)
{
    if (N % 2 == 0)
        cout << N / 2 << endl;
    else
        cout << (N / 2) + 1 << endl;
}

int main()
{
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld", &N);
    func(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

//vector<string> s;
int max_n;

void dfs(int n, string t, int m) {
    char tmp;
    for (int i = 0; i < (max_n - n) + 1 ; i++) {
      tmp = 97 + i;
      if (i <= m + 1) {
          string p = t + tmp;
          int k = n - 1;
          if (!k) cout << p << endl;
          if (k > 0) dfs(k, p, max(i,m));
      }
      else break;
    }
}

int main(){
  cin >> max_n;
  string t = "";
  dfs(max_n, t, 0);
  //for (int i = 0; i < s.size(); i++) cout << s.at(i) << endl;
  return 0;
}


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

int main(){
  char s[20] = {};
  char t[20] = {};
  scanf("%s", s);
  for(int i = 0; i < strlen(s); i++){
    if(strlen(t) == 0){
      if(s[i] == '0' || s[i] == '1'){
        t[0] = s[i];
      }
    }else{
      if(s[i] == '0' || s[i] == '1'){
        t[strlen(t)] = s[i];
      }else{
        t[strlen(t)-1] = 0;
      }
    }
  }
  printf("%s\n", t);
  return 0;
}


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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if (a>c && a>b) cout << b+c << endl;
  else if (b>c && b>a) cout << a+c << endl;
  else if (a>c) cout << b+c << endl;
  else if (b>c) cout << a+c << endl;
  else cout << a+b << endl;
}

Measured memory_bytes: 256
n = int(input())
e = [[i for i in input().split()] for i in range(n)]
sum_ = 0
for i in range(n):
  if e[i][1] == "JPY":
    sum_ += int(e[i][0])
  else:
    sum_ += 380000*float(e[i][0])
print(sum_)

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,2){
        cin >> A[i];
    }
    // sort(A,A+3);
    cout << (A[0]<9&&A[1]<9 ? "Yay!" : ":(") << endl;
}

Measured memory_bytes: 504
#include<bits/stdc++.h>
#define pb push_back
using namespace std;
const int DN=1005,M=1e9+7;
int n,m,dp[DN][DN];
char a[DN][DN];
int main()
{
    cin>>n>>m;
    for(int i=0;i<=n;i++)
    	cin.getline(a[i]+1,DN);
    for(int i=1;i<=n;i++)
    	for(int j=1;j<=m;j++)
    	{
    		if(a[i][j]=='#')
    			continue;
    		if(i==1&&j==1)
    		{
    			dp[i][j]=1;
    			continue;
    		}
    		dp[i][j]=(dp[i-1][j]+dp[i][j-1])%M;
    	}
    cout<<dp[n][m];
}


Measured memory_bytes: 5120
import java.util.*;
import java.io.*;
 
public class Main {
    public static void main (final String[] args) {
        final Scanner sc = new Scanner(System.in);
      	double a = Double.parseDouble(sc.next());
        double b = Double.parseDouble(sc.next());
      	double h = Double.parseDouble(sc.next());
      	double m = Double.parseDouble(sc.next());
        
      	h = 2*Math.PI*h/12 + 2*Math.PI*m/720;
      	m = 2*Math.PI*m/60;
      
      	if (Math.abs(h - m) > Math.PI) h = 2*Math.PI - Math.abs(h - m);
      	else h = Math.abs(h - m);
      	
      	double result = Math.sqrt(a*a + b*b - 2*a*b*Math.cos(h));
      	System.out.println(result);
    }
}

Measured memory_bytes: 35748
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<algorithm>
#include<numeric>
#include<map>
#include<unordered_map>
#include<queue>
#include<deque>
 
using namespace std;
using ll=long long;
#define rep(i,n)  for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()

#define MOD 1000000007

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

    if(n&1)cout << "No";
    else {
        string t = "", t2 = "";
        rep(i, n){
            if(i<n/2)t+=s[i];
            else t2+=s[i];
        }
        if(t == t2)cout << "Yes";
        else cout << "No";
    }
}

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

const long long MXN = 1e2 + 20, MXV =  1e5 + 20;

long long n, w, dp[MXN][MXV], ans;
vector<pair<long long, long long>> wv;

void npt() {
	cin >> n >> w;
	for (int i = 0; i < n; i++) {
		int ww, vv;
		cin >> ww >> vv;
		wv.push_back({ww, vv});
	}
}

void slv() {
	for (int i = 0; i < n; i++)
		for (int j = 0; j < MXV; j++)
			dp[i][j] = 1e12 + 20;
	dp[0][0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j < MXV; j++)
			if (wv[i].second <= j)
				dp[i + 1][j] = 
					min(wv[i].first + 
							dp[i][j - wv[i].second],
						   	dp[i][j]);
			else
				dp[i + 1][j] = dp[i][j];
	for (int j = 0; j < MXV; j++)
		if (dp[n][j] <= w)
			ans = j;
}

void tpt() {
	cout << ans << endl;
}

int main() {
	npt();
	slv();
	tpt();
	return 0;
}


Measured memory_bytes: 80256
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v), std::end(v)
#define REP(i, k) for (decltype(k) i = 0; i < k; i++)
#define LOOP(k) REP (ngtkana_is_a_genius, k)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main() {
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 n, k; std::cin >> n >> k;
    vec<i64> a(n);
    for (i64& x: a) std::cin >> x;

    auto move = [&] {
        vec<i64> b(n+1);
        for (i64 i=0; i<n; i++) {
            b.at(std::max(i64{0}, i - a.at(i)))++;
            b.at(std::min(i64{n}, i + a.at(i) + 1))--;
        }
        std::partial_sum(ALL(b), b.begin());
        b.pop_back();
        a = b;
    };
    LOOP (k) {
        move();
        if (std::all_of(ALL(a), [n](i64 x){ return x==n; })) break;
    }
    for (i64 i=0; i<n; i++) std::cout << (i ? " " : "") << a.at(i); std::cout << '\n';
}


Measured memory_bytes: 6368
#include <bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(long long i=a; i<b; i+=1)
#define repr(i,a,b) for(long long i=a; i<=b; i+=1)
#define vec vector<ll>
#define pb push_back
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())

using namespace std;
int main() {
  string S,T,U;
  cin>>S>>T;
  int A,B;
  cin>>A>>B;
  cin>>U;
  if(U==S)
    A-=1;
  if(U==T)
    B-=1;
  cout<<A<<" "<<B<<endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#include <regex>
#include <map>
#include <set>
using namespace std;
int main(){
   int N,M;
   cin >> N >> M;
   int a[100001] = {};
   for(int i=0;i<M;i++){
       cin >> a[i];
   }
   int dp[100001] = {1};
   
   bool broken[100001];
   for(int i=0;i<M;i++){
       broken[a[i]] = true;
   }
   
   if(broken[1] == true){
       dp[1] = 0;
   }else{
       dp[1] = 1;
   }
   for(int i=2;i<=N;i++){
       if(broken[i] == true){
           continue;
       }
       dp[i] = dp[i-1]+dp[i-2];
       dp[i] %= 1000000007;
       
   }
   
   cout << dp[N] << endl;
   return 0;
   
}

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

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

using namespace std;

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

  int num = 3 * N;

  long long a[num];
  rep(i, num){
    cin >> a[i];
  }

  sort(a, a + num, greater<int>());

  long long ans = 0;
  for(int i = 0; i < 2 * N; i++){
    if(i%2 == 1){
      ans += a[i];
    }
    
  }

  cout << ans << endl;

  return 0;

}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned int u32;
typedef pair<int, int> p;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
int Inf = (1<<30);
ll inf = (1LL<<60);
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int main() {
	int n;
	cin >> n;
	ll ans = 0;
	int i;
	map<string, int> mp;
	for (i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		mp[s]++;
	}
	for (auto b : mp) {
		ll x = b.second;
		ans += x * (x - 1) / 2;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i];if(i<len-1) s<<" ";
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){
	int len=d.size();
	rep(i,len){
		s<<d[i]<<endl;
	}
	return s;
}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){
	s<<"{ ";
	for(auto itr=v.begin();itr!=v.end();++itr) {
		if (itr!=v.begin()) {s<< ", ";}
		s<<(*itr);
	}
	s<<" }";
	return s;
}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){
	s<<"{"<<endl;
	for(auto itr=m.begin();itr!=m.end();++itr){
		s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;
	}
	s<<"}"<<endl;
	return s;
}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

struct mint {
	ll x;
	mint(ll x=0):x((x%mod+mod)%mod){}
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod-a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res+=a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res-=a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res*=a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t>>1);
		a *= a;
		if (t&1) a *= *this;
		return a;
	}
	// for prime mod
	mint inv() const {
		return pow(mod-2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res/=a;
	}
};

struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
	assert(n < mod);
	fact[0] = 1;
	for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
	ifact[n] = fact[n].inv();
	for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
	if (k < 0 || k > n) return 0;
	return fact[n]*ifact[k]*ifact[n-k];
  }
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	combination comb(3*n);
	if(k>=n-1){
		cout<<comb(2*n-1,n).x<<endl;
		return 0;
	}
	mint ans=0;
	FOR(i,1,k+1){
		mint now=comb(n,i)*comb(n-1,i);
		ans+=now;
	}
	ans+=1;
	cout<<ans.x<<endl;
}

Measured memory_bytes: 9600
L, R = map(int, input().split())
a = 2020

for i in range(L,R+1):
    for j in range(i+1,R+1):
        ans = i*j%2019
        if(a > ans):
            a = ans
        if ans == 0:
            print(a)
            exit(0)
print(a)


Measured memory_bytes: 38896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

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

int n,a,b,c,d;
ll dp[1010][1010],fac[1010],inv[1010][1010],nCk[1010][1010];

ll f(int i,int l){
	if(i==b+1){
		if(!l) return 1;
		return 0;
	}
	ll &ret = dp[i][l];
	if(ret!=-1) return ret;
	ret = f(i+1,l);
	int e = c;
	while(e<=d && e*i<=l){
		ret = (ret + f(i+1,l-e*i)*nCk[l][e*i]%mod*fac[e*i]%mod*inv[i][e]%mod*inv[e][1]%mod)%mod;
		e++;
	}
	return ret;
}

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	REP(i,1010){
		nCk[i][0]=1;
		REPP(j,1,i+1){
			nCk[i][j]=(nCk[i-1][j-1]+nCk[i-1][j])%mod;
		}
	}
	fac[0]=inv[0][0]=1;
	REP(i,1010) inv[0][i]=1;
	REPP(i,1,1010){
		fac[i]=fac[i-1]*i%mod;
		inv[i][0]=1;
		inv[i][1]=power(fac[i],mod-2);
		REPP(j,2,1010) inv[i][j]=inv[i][j-1]*inv[i][1]%mod;
	}
	scanf("%d %d %d %d %d",&n,&a,&b,&c,&d);
	FILL(dp,-1);
	printf("%lld\n",f(a,n));
	return 0;
}




Measured memory_bytes: 23296
import Foundation

func readWords<T>(_ f: (Substring) -> T) -> [T] {
    return readLine()!.split(separator: " ").map(f)
}
struct PriorityQueue<T: Comparable> {
    private var data: [T]
    private var ordered: (T, T) -> Bool
    
    public var isEmpty: Bool {
        return data.isEmpty
    }
    
    public var count: Int {
        return data.count
    }

    init(_ order: @escaping (T, T) -> Bool) {
        self.data = []
        self.ordered = order
    }

    init<Seq: Sequence>(_ seq: Seq, _ order: @escaping (T, T) -> Bool) where Seq.Element == T {
        self.data = []
        self.ordered = order
        
        for x in seq {
            push(x)
        }
    }
    
    public mutating func pop() -> T? {
        return data.popLast().map { item in
            var item = item
            if !isEmpty {
                swap(&item, &data[0])
                siftDown()
            }
            return item
        }
    }
    
    public mutating func push(_ item: T) {
        let oldLen = count
        data.append(item)
        siftUp(oldLen)
    }
    
    private mutating func siftDown() {
        var pos = 0
        let end = count
        
        data.withUnsafeMutableBufferPointer { bufferPointer in
            let _data = bufferPointer.baseAddress!
            swap(&_data[0], &_data[end])
            
            var child = 2 * pos + 1
            while child < end {
                let right = child + 1
                if right < end && ordered(_data[child], _data[right]) {
                    child = right
                }
                swap(&_data[pos], &_data[child])
                pos = child
                child = 2 * pos + 1
            }
        }
        siftUp(pos)
    }
    
    private mutating func siftUp(_ pos: Int) {
        var pos = pos
        while pos > 0 {
            let parent = (pos - 1) / 2;
            if ordered(data[pos], data[parent]) {
                break
            }
            data.swapAt(pos, parent)
            pos = parent
        }
    }
}

extension PriorityQueue: Sequence, IteratorProtocol {
    mutating func next() -> T? {
        return pop()
    }
}

    let nm = readWords { Int($0)! }
    let n = nm[0]
    let m = nm[1]

    let ab: [(Int, Int)] = (1...n).map { _ in 
        let ab = readWords { Int($0)! }
        return (ab[0], ab[1])
    }.sorted(by: <)

    var ans = 0
    var pq = PriorityQueue<Int>(<=)
    var i = 0
    for day in 1...m {
        while i < n && ab[i].0 <= day {
            pq.push(ab[i].1)
            i += 1
        }
        if let b = pq.pop() {
            ans += b
        }
    }

    print(ans)




Measured memory_bytes: 16988
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define fre
#define DEBUG
using namespace std;
int sy[3];
int main()
{
    scanf("%d%d%d", &sy[0], &sy[1], &sy[2]);
    sort(sy, sy + 3);
    if (sy[0] == 5 && sy[1] == 5 && sy[2] == 7) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	string S;
	cin >> S;
	
	// 解法 
	ll ans = 0;
	for (ll i = 0; i < 6; ++i){
		if (S[i]=='1') ans++;
	}
	
	//出力
	printf("%lld\n", ans); // lld としないとオーバーフローする
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define USE_LLONG_AS_INT
#ifdef USE_LLONG_AS_INT
#define int long long
#define inf (1ll<<60)
#else
#define inf (1<<30)
#endif
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,a,b) for(int i=a;i<b;i++)
#define REP(i,a,b) for(int i=a;i<=b;i++)
#define rev(i,n) for(int i=n-1;i>=0;i--)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define pi pair<int,int>
#define vp vector<pair<int,int>>
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define MEMSET(a) memset(a,0,sizeof(a))
#define Yes(f) cout<<(f?"Yes":"No")<<endl
#define yes(f) cout<<(f?"yes":"no")<<endl
#define YES(f) cout<<(f?"YES":"NO")<<endl
#define SORT(v) sort(all(v))
#define RSORT(v) sort(all(v), greater<int>())

using namespace std;

const int mod=1e9+7;
const string sp=" ";

void run();

void init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout<<fixed<<setprecision(12);
}

signed main(){
    init();
    run();
    return 0;
}

void run(){
    int h,w,a,b;
    cin>>h>>w>>a>>b;
    rep(i,h){
        rep(j,w)cout<<((i<b)^(j<a));
        cout<<endl;
    }
}

Measured memory_bytes: 1280
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
  long double a,b,x;
  cin >> a >> b >> x;
  long double ans=M_PI/2.0-atanl(a*a*a/(long double)(2.0*a*a*b-2.0*x));
  if(2*x<a*a*b){
    ans=M_PI/2.0-atanl((2.0*x)/(a*b*b));
  }
  cout << setprecision(10) << ans*180.0/(long double)M_PI << endl;
return 0;}


Measured memory_bytes: 384
sx,sy,tx,ty = map(int,input().split())
dx = tx-sx
dy = ty-sy
print(dx*"R"+dy*"U"+dx*"L"+(dy+1)*"D"+(dx+1)*"R"+(dy+1)*"U"+"L"+"U"+(dx+1)*"L"+(dy+1)*"D"+"R")

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(2e5 + 5);
const double EPS = 1e-8;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    while(1){
        ll n, dp[45][55]{};
        bool f[45][55]{};
        cin >> n;
        if(n==0)break;
        REP(i,n){
            int m;
            cin >> m;
            REP(j,m){
                int t;
                cin >> t;
                f[t][i] = true;
            }
        }
        REP(i,n) dp[0][i] = (1LL<<i);
        REP(i,40){
            ll tmp = 0;
            REP(j,n){
                if(f[i+1][j]) tmp |= dp[i][j];
            }
            //cout << tmp << endl;
            if(tmp == (1LL<<n)-1){
                cout << i+1 << endl;
                break;
            }
            else if(i>30){
                cout << -1 << endl;
                break;
            }
            REP(j,n){
                if(f[i+1][j]) dp[i+1][j] = tmp;
                else dp[i+1][j] = dp[i][j];
            }
            
        }
    }
    return 0;
}



Measured memory_bytes: 3028
from bisect import bisect_left as bl
A,B,Q=map(int,input().split())
S=[]
T=[]
X=[]
INF=10**18
S.append(-INF)
T.append(-INF)
for i in range(A):
    S.append(int(input()))
for i in range(B):
    T.append(int(input()))
S.append(INF)
T.append(INF)
for i in range(Q):
    x=int(input())
    b,d=bl(S,x),bl(T,x)
    res=INF
    for s in [S[b-1],S[b]]:
        for t in [T[d-1],T[d]]:
            d1,d2=abs(s-x)+abs(t-s),abs(t-x)+abs(s-t)
            res=min(res,d1,d2)
    print(res)


Measured memory_bytes: 77400
# include <bits/stdc++.h>
using namespace std;
int s[100];
int main ()
{
    int a,b,c;
    cin>>a>>b>>c;
    int t=min (a,b);
    int j=1;
    for (int i=t;i>=1;--i)
       {
       	 if (a%i==0&&b%i==0)
       	    {
       	    	s[j]=i;
       	    	j++;
			}
	   }
	printf ("%d",s[c]);
	return 0;
 } 

Measured memory_bytes: 256
def main():
    N, K = map(int, input().split())
    A = [0 for c in range(N)]

    for k in range(K):
        D = int(input())
        d_list = [int(_) for _ in input().split()]
        
        for d in range(D):
            i = d_list[d]
            A[i-1] +=  1

    out = A.count(0)
    print(out)
main()

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

int main() {
  int N;
  cin>>N;
  vector<int> p;
  int a;
  cin>>a;
  p.insert(p.begin(),a);
  for(int i=1;i<N;i++){
    int a;
    cin>>a;
    if(p.at(0)>=a){
      p.insert(p.begin(),a);
    }
    else if(p.at(p.size()-1)<a){
      p.at(p.size()-1)=a;
    }
    else{
      int b=lower_bound(p.begin(),p.end(),a)-p.begin();
      p.at(b-1)=a;
    }
  }
  cout<<p.size()<<endl;
    
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
 
vector<char> judge(vector<int> &vec){
  vector<char> sym(3,'+');
  if (vec.at(0) + vec.at(1) + vec.at(2) + vec.at(3)==7){
    return sym;
  }
  if (vec.at(0) - vec.at(1) + vec.at(2) + vec.at(3)==7){
    sym.at(0) = '-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) - vec.at(2) + vec.at(3)==7){
    sym.at(1) ='-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) + vec.at(2) - vec.at(3)==7){
    sym.at(2) = '-';
    return sym;
  }
  if (vec.at(0) - vec.at(1) - vec.at(2) + vec.at(3)==7){
    sym.at(0) = '-';
    sym.at(1) = '-';
    return sym;
  }
  if (vec.at(0) + vec.at(1) - vec.at(2) - vec.at(3)==7){
    sym.at(2) = '-';
    sym.at(1) ='-';
    return sym;
  }
  if (vec.at(0) - vec.at(1) + vec.at(2) - vec.at(3)==7){
    sym.at(0) = '-';
    sym.at(2) = '-';
    return sym;
  }
}
 
int main(){
  int n;
  cin>>n;
  vector<int> vec(4);
  vec.at(0)=n/1000;
  vec.at(1)=(n/100)%10;
  vec.at(2)=(n%100)/10;
  vec.at(3)=n%10;
  
  vector<char> sym =judge(vec);
  for (int i=0;i<3;i++){
    cout<<vec.at(i)<<sym.at(i);
  }
  cout<<vec.at(3)<<"=7"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
#include <utility>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
 
using namespace std;
typedef long long ll;
 
int main(){
  int N,M;
  cin >> N >> M;

  vector<int> r(N);

  int p;
  string s;
  for(int i=0;i<M;i++){
    cin >> p >> s;
    if(r[p-1]<=0){
      r[p-1]--;
      if(s=="AC"){
	r[p-1]*=-1;
      }
    }
  }

  int nac=0, npenalty=0;
  for(int i=0;i<N;i++){
    if(r[i]>0){
      nac++;
      npenalty+=r[i]-1;
    }
  }

  cout << nac << " " << npenalty << endl;
  
}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cmath>
#include <string>
#include <queue> 
#include <cassert>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <set>
#include <map>

#define INF 2000000000
#define MOD 1000000007

using namespace std;

int n;
vector <int> t[100000];
int dist[100000][2];

void dfs(int cur, int par, int d, int which) {
	dist[cur][which] = d;
	for (int i = 0; i < t[cur].size(); i++) {
		if (t[cur][i] == par)
			continue;
		dfs(t[cur][i], cur, d + 1, which);
	}
}

int main() {
	cin >> n;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		t[a - 1].push_back(b - 1);
		t[b - 1].push_back(a - 1);
	}
	int f = 0, s = 0;
	dfs(0, -1, 0, 0);
	dfs(n - 1, -1, 0, 1);
	for (int i = 0; i < n; i++)
		if (dist[i][0] <= dist[i][1])
			f++;
		else
			s++;
	if (f > s) {
		cout << "Fennec" << endl;
	} else
		cout << "Snuke" << endl;
	return 0;
}	

Measured memory_bytes: 14336
s = input()

#a1はs内の奇数番の1の個数と偶数番の0の個数を求める
a1 = s[::2].count("1") + s[1::2].count("0")
#a2はs内の奇数番の1の個数と偶数番の1の個数を求める
a2 = s[::2].count("0") + s[1::2].count("1")

print(min(a1,a2))

Measured memory_bytes: 3188
#include <stdio.h>
  
int main(){
 
   int n, x, y, z = 0, r;
   int N[10000];
  
   scanf("%d", &n);
 
   for (x = 0; x < n; x++)
     scanf("%d", &N[x]);
   for (x = 0; x < n; x++){
     y = 1;
     for (r = 2; r <= sqrt(N[x]) && y != 0; r++){
         y = N[x] % r;
         if (y == 0) z++;
     }
   }
          
   printf("%d\n", n - z);
  
   return 0;
  
}

Measured memory_bytes: 1800
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int M, D;
    cin >> M >> D;
    int ans = 0;
    REP(i, 1, M) {
        REP(j, 1, D) {
            int d1 = j % 10;
            int d2 = (j - d1) / 10;
            if (d1 < 2 || d2 < 2) continue;
            if (i == d1 * d2) ans++;
            //cout << i <<  " " << d1 << " " << d2 << endl;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
<?php

(new Main)->excute();

class Main
{
    public function excute()
    {
        while (true) {
            fscanf(STDIN, '%d %d', $height, $width);
            if ($height == 0 && $width == 0) { break; }
            
            $chessBoard = (new ChessBoard($height, $width, '#', '.'))->make();
            Self::draw($chessBoard);
        }
    }
    
    public static function draw($object)
    {
        echo $object, PHP_EOL;
    }
}


class ChessBoard
{
    private $height;
    private $width;
    private $char1;
    private $char2;
    
    
    public function __construct($height, $width, $char1, $char2)
    {
        $this->height = $height;
        $this->width  = $width;
        $this->char1  = $char1;
        $this->char2  = $char2;
    }
    
    public function make()
    {
        $chessBoard = [];
        for ($i = 0; $i < $this->height; $i++) {
            if ($i % 2 == 0) {
                $chessBoard[] = $this->makeOddLine();
            } else {
                $chessBoard[] = $this->makeEvenLine();
            }
        }
        
        return implode(PHP_EOL, $chessBoard).PHP_EOL;
    }
    
    private function makeOddLine()
    {
        $line = '';
        for ($i = 0; $i < $this->width; $i++) {
            if ($i % 2 == 0) {
                $line .= $this->char1;
            } else {
                $line .= $this->char2;
            }
        }
        
        return $line;
    }
    
    private function makeEvenLine()
    {
        $line = '';
        for ($i = 0; $i < $this->width; $i++) {
            if ($i % 2 == 0) {
                $line .= $this->char2;
            } else {
                $line .= $this->char1;
            }
        }
        
        return $line;
    }
}

Measured memory_bytes: 15500
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,k;
    cin>>n>>k;
    int*a=new int[n];
    for(int i=0;i<n;i++)
    cin>>a[i];
    int* dp=new int[n];
    for(int i=0;i<n;i++)
    dp[i]=INT_MAX;
    dp[n-1]=0;
    for(int i=n-2;i>=0;i--)
    {
        for(int j=1;j<=k && i+j<n;j++)
        {
            dp[i]=min(dp[i],abs(a[i]-a[i+j])+dp[i+j]);
        }

    }
    cout<<dp[0];
}


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

typedef long long ll;

int main(){

    ll num;
    cin >> num;


    ll sum = 0;

    ll times = num/500; 

    sum += 1000 * times;

    num -= times*500;

    sum += 5 * (num/5);

    cout << sum << endl;

    return 0;
}


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

using namespace std;

int diff(char a, char b, char c){
	int sum = 0;
	int n = (a-'0')*100 + (b-'0')*10 + c-'0';
	sum = abs(n-753);
	return sum;
	
	}
int main(){
	string a, b;
	cin>>a;
	b = "753";
	int did = 999;
	for(int i =0; i< a.size()-2; i++){
		did = min(did, diff(a[i],a[i+1],a[i+2]));
		
		}
	cout<<did;
	
	
	return 0;
	}


Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split(" ").map!{|i| i.to_i}
y = 0
1.upto(n-1) do |u|
  y += a[u]
end
x = a[0]
min = (x -y).abs

1.upto(n-2) do |j|
  x += a[j]
  y -= a[j]
  if (x-y).abs < min
    min = (x-y).abs
  end
end
puts min


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

int main() {
  int N;
  cin >> N;
  unsigned long long ans = 1;
  for (int i = 1; i <= N; i++) {
    ans *= i;
    ans %= 1000000000 + 7;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  string ans = "No";
  for (int i = 9; i > 0; i--) {
    if (n%i == 0 && n/i < 10) {
      ans = "Yes";
      break;
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;
class Main
{
    public static void main(String[] args) throws IOException
    {
        Reader in = new Reader();
        int n = in.nextInt();
        int k = in.nextInt();
        long[] A = new long[n];
        for (int i=0;i<n;i++)   A[i] = in.nextLong();
		Arrays.sort(A);
      long sum = 0L;
        for (int i=0;i<k;i++)   sum += A[i];
        System.out.println(sum);
    }
}
class Reader
{
    final private int BUFFER_SIZE = 1 << 16;
    private DataInputStream din;
    private byte[] buffer;
    private int bufferPointer, bytesRead;

    public Reader()
    {
        din = new DataInputStream(System.in);
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public Reader(String file_name) throws IOException
    {
        din = new DataInputStream(new FileInputStream(file_name));
        buffer = new byte[BUFFER_SIZE];
        bufferPointer = bytesRead = 0;
    }

    public String readLine() throws IOException
    {
        byte[] buf = new byte[64]; // line length
        int cnt = 0, c;
        while ((c = read()) != -1)
        {
            if (c == '\n')
                break;
            buf[cnt++] = (byte) c;
        }
        return new String(buf, 0, cnt);
    }

    public int nextInt() throws IOException
    {
        int ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do
        {
            ret = ret * 10 + c - '0';
        }  while ((c = read()) >= '0' && c <= '9');

        if (neg)
            return -ret;
        return ret;
    }

    public long nextLong() throws IOException
    {
        long ret = 0;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();
        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');
        if (neg)
            return -ret;
        return ret;
    }

    public double nextDouble() throws IOException
    {
        double ret = 0, div = 1;
        byte c = read();
        while (c <= ' ')
            c = read();
        boolean neg = (c == '-');
        if (neg)
            c = read();

        do {
            ret = ret * 10 + c - '0';
        }
        while ((c = read()) >= '0' && c <= '9');

        if (c == '.')
        {
            while ((c = read()) >= '0' && c <= '9')
            {
                ret += (c - '0') / (div *= 10);
            }
        }

        if (neg)
            return -ret;
        return ret;
    }

    private void fillBuffer() throws IOException
    {
        bytesRead = din.read(buffer, bufferPointer = 0, BUFFER_SIZE);
        if (bytesRead == -1)
            buffer[0] = -1;
    }

    private byte read() throws IOException
    {
        if (bufferPointer == bytesRead)
            fillBuffer();
        return buffer[bufferPointer++];
    }

    public void close() throws IOException
    {
        if (din == null)
            return;
        din.close();
    }
}


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

int main() {
  int N,P,W,G,Y;
  P = W = G = Y = 0;
  string S;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> S;
    if(S == "P" && P == 0)
      P++;
    else if(S == "W" && W == 0)
      W++;
    else if(S == "G" && G == 0)
      G++;
    else if(S == "Y" && Y == 0)
      Y++;
  }
  int c = P + W + G + Y;
  if(c == 3)
    cout << "Three";
  if(c == 4)
    cout << "Four";
}


Measured memory_bytes: 256
import numpy as np

n,k = map(int, input().split())

def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p

for i in range(k):
    print(int(comb(k-1,i, pow(10, 9) + 7) * comb(n-k+1,i+1, pow(10, 9) + 7)) % (pow(10, 9) + 7))

Measured memory_bytes: 20852
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

typedef long long int ll;
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cout.tie(0);cin.tie(0);

typedef tree< pair < ll, ll >, null_type, less< pair < ll, ll > >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const ll mod = 998244353;
const ll MAXN = 1e5+5;
const ll inf = 1e18;

int main()
{
    fastio;
    string s;
    cin >> s;
    ll n = s.length() + 1;
    vector < ll > a(n);
    vector < bool > p(n, true);
    set < ll > st;
    if(s[0] == '<'){
        a[0] = 0;
        st.insert(0);
    }
    if(s[n - 2] == '>'){
        a[n - 1] = 0;
        st.insert(n - 1);
    }
    for(int i = 0; i < n - 2; i++){
        if(s[i] == '>' && s[i + 1] == '<'){
            a[i + 1] = 0;
            st.insert(i + 1);
        }else if(s[i] == '<' && s[i + 1] == '>'){
            p[i + 1] = false;
        }
    }
    for(auto i : st){
        for(int j = i - 1; j >= 0; j--){
            if(p[j]){
                a[j] = i - j;
            }else break;
        }
        for(int j = i + 1; j < n; j++){
            if(p[j]){
                a[j] = j - i;
            }else break;
        }
    }
    for(int j = 1; j <= n; j++){
        if(!p[j]){
            a[j] = max(a[j - 1], a[j + 1]) + 1;
        }
    }
    ll ans = 0;
    for(auto i : a){
        ans += i;
    }
    cout << ans << endl;
}


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

int main(int argc, char *argv[]) {
  int N; cin>>N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A[i];

  vector<double> B(N);
  for (int i = 0; i < N; i++) {
    B[i] = 1.0 / A[i];
  }

  double C = 0.0;
  for (int i = 0; i < N; i++) {
    C += B[i];
  }

  double D = 1.0 / C;

  cout << fixed << setprecision(6) << D << endl;

  return 0;
}


Measured memory_bytes: 256
function Main(input) {
    input = input.split("\n");
    for (i=0; i < input.length-1; i++) {
        tmp = input[i].split(" ")
        var a = parseInt(tmp[0])
        var op = tmp[1]
        var b = parseInt(tmp[2])
        if (op === "?") {
            break;
        } else if (op === "+") {
            console.log(a + b)
        } else if (op === "-") {
            console.log(a - b)
        } else if (op === "*") {
            console.log(a * b)
        } else if (op === "/") {
            console.log(Math.floor(a / b))
        }
    }
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 15412
/*
Pradyumn Sinha 
Delhi Technological University
*/
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> OST;
using namespace std;
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pf push_front
#define vi vector<int>
#define vl vector<ll>
#define vii vector<pii >
#define vll vector<pll>
#define pll pair<ll,ll>
#define pii pair<int,int>
#define pi 3.14159265358979
#define EL printf("\n")
#define OK printf("OK");
#define foreach(i,t) for(auto i =t.begin();i!=t.end();i++) 
#define pdn(n) printf("%d\n",n)
#define pln(n) printf("%lld\n",n)
#define psn(n) printf("%s\n",n)
#define pcn(n) printf("%c\n",n)
#define sl(n) scanf("%lld",&n)
#define sd(n) scanf("%d",&n)
#define ss(n) scanf("%s",&n)
#define pn printf("\n")
#define  omap unordered_map
#define SZ(x) ((int)(x.size()))
#define foi(i,a,n) for(int (i)=int(a);(i)<=int(n);++(i))
#define fod(i,a,n) for(int (i)=int(a);(i)>=int(n);--(i))
#define PI 3.14159265
#define inf 1e18
#define mod 1000000007
#define precise(n,k) fixed<<setprecision(k)<<n
#define DBG(c) cout << #c << " = " << c << endl;
#define RTIME ((double)clock()/(double)CLOCKS_PER_SEC)
#define fequal(a,b) (fabs(a - b)<(1e-9))
int toint(const string &s) { stringstream ss; ss << s; int x; ss >> x; return x; }
string tostring ( int number ){  stringstream ss; ss<< number; return ss.str();}

typedef long long ll;
typedef long double lf;

ll pw(ll a,ll b) 
{if(b==0) return 1; if(b==1) return a;  ll ans=pw(a,b/2); if(b&1) 
return (((ans*ans)%mod*a)%mod); 
 return (ans*ans)%mod; }	
ll gcd(ll a,ll b){return (b==0)? a:gcd(b,a%b); }
void nope(int dec = 0){if(!dec) cout<<"NO"<<endl;else cout<<"YES"<<endl;exit(0);}

int cnt[4]={0};
int main()
{
	int n;
	sd(n);
	for(int i=1;i<=n;i++)
	{
		int no;
		sd(no);
		if(no%4==0)
			cnt[2]++;
		else if(no%2==0)
			cnt[1]++;
		else
			cnt[0]++;
	}
	if((cnt[0]<=cnt[2])||(cnt[1]==0&&cnt[0]==cnt[2]+1))
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void) {
  const int Nmax = 1e5 + 2;
  vector<bool> isPrime(Nmax + 1, true);
  for (int i = 2; i * 2 < Nmax; ++i) {
    for (int j = 2; i * j <= Nmax; ++j) isPrime[i * j] = false;
  }

  vector<int> Sum(Nmax + 1, 0);
  Sum[1] = 0;
  for (int i = 3; i <= Nmax; i += 2) {
    bool like2017 = isPrime[i] & isPrime[(i + 1) / 2];
    Sum[i] = Sum[i - 2] + (like2017 ? 1 : 0);
  }

  int Q;
  cin >> Q;
  vector<int> answer(Q);
  rep(i, Q) {
    int l, r;
    cin >> l >> r;
    answer[i] = Sum[r] - Sum[l - 2];
  }
  rep(i, Q) cout << answer[i] << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>*/
 
#define pll              pair <long long,long long>
#define pb               push_back
#define ll               long long
#define ff               first
#define ss               second
#define D(x)             cerr<<#x " = "<<(x)<<endl
#define vll              vector <ll>
#define IOS              ios_base::sync_with_stdio(0); cin.tie(NULL);
#define endl             '\n'   
using namespace std;
const ll MOD=1e9+7;
ll add(ll a, ll b)
{
	ll res = a + b;
	if(res >= MOD)
		return res - MOD;
	return res;
}

ll mult(ll a, ll b)
{
	ll  res = a;
	res *= b;
	if(res >= MOD)
		return res % MOD;
	return res;
}

int main()
{
    IOS
    string s;
    cin>>s;
    ll a[s.size()];
    ll sm[s.size()+1],bg[s.size()+1];
    sm[s.size()]=1;
    bg[s.size()]=0;
    ll ptr=0;
    for(char c:s)
    {
        a[ptr++]=c-'0';
    }
    for(ll i=s.size()-1;i>=0;i--)
    {
        if(a[i])
        {
            sm[i]=add(bg[i+1],mult(3,sm[i+1]) );                        ///0-0,0-1,1-0
            bg[i]=mult(2,bg[i+1]);
        }
        else
        {
            sm[i]=sm[i+1];                        ///0-0,0-1,1-0
            bg[i]=add(mult(3,bg[i+1]),mult(2,sm[i+1]) );                                 
        }
    }
    cout<<sm[0]<<endl;
    return 0;
}


Measured memory_bytes: 2768
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define mp make_pair
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define REP(i, s, n) for(int i = s; i < n; i++)
#define rRep(i, n) for(int i = n - 1; i >= 0; i--)
#define pii pair<int, int>
#define vii vector<pair<int, int>>
#define vi vector<int>
#define all(x) (x).begin(), (x).end()
#define endl "\n"


int32_t main() {
	FAST
	//ofstream fout ("test.out");
    //ifstream fin ("test.in");
    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int sum = 0;
    if(k <= a) {
    	cout << k << endl;
    }
    else if(k <= a + b) {
    	cout << a << endl;
    }
    else {
    	cout << a - (k - a - b) << endl;
    }
}

Measured memory_bytes: 3652
N, M = map(int, input().split())
A = []
B = []
for _ in range(N):
    A.append(input())
for _ in range(M):
    B.append(input())

for i in range(N - M + 1):
    for j in range(N - M + 1):
        flag = True

        for x in range(M):
            if A[j+x][i:i+M] != B[x]:
                flag = False
                break

        if flag == True:
            print('Yes')
            exit()

print('No')

Measured memory_bytes: 3064
#include <stdio.h>

int map[20][20];
int W,H;

int head,tail;
typedef struct{
    int x;
    int y;
} step;

step queue[900];
char line[30];

int pop(step **next){
    if(head==tail)return 0;
    *next=&(queue[head]);
    head++;
    return 1;
}

void push(int x,int y){
    queue[tail].x=x;
    queue[tail].y=y;
    tail++;
}

void clear(void){
    head=0;
    tail=0;
}

int isEmpty(void){
    if(head==tail){
        return 1;
    }
    return 0;
}

int isChecked(int x,int y){
    if(map[x][y]&16||map[x][y]&1){
        return 1;
    }else{
        return 0;
    }
}

void setChecked(int x,int y){
    map[x][y]|=16;
}

int main(void){
    while(scanf("%d %d",&W,&H),W||H){
        int x,y,count;
        step* next;
        for(y=0;y<20;y++){
            for(x=0;x<20;x++){
                map[x][y]=0;
            }
        }
        clear();
        for(y=0;y<H;y++){
            scanf("%s", line);
            for(x=0;x<W;x++){
                if(line[x]=='#'){
                    map[x][y]=1;
                }else if(line[x]=='@'){
                    push(x,y);
                    setChecked(x,y);
                }
            }
        }
        count=0;
        while(pop(&next)){
            count++;
            x=next->x;
            y=next->y;
            if(x+1<W){
                if(!isChecked(x+1,y)){
                    push(x+1,y);
                    setChecked(x+1,y);
                }
            }
            if(x>0){
                if(!isChecked(x-1,y)){
                    push(x-1,y);
                    setChecked(x-1,y);
                }
            }
            if(y+1<H){
                if(!isChecked(x,y+1)){
                    push(x,y+1);
                    setChecked(x,y+1);
                }
            }
            if(y>0){
                if(!isChecked(x,y-1)){
                    push(x,y-1);
                    setChecked(x,y-1);
                }
            }
        }
        printf("%d\n",count);
    }
    
    return 0;
}

Measured memory_bytes: 612