akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] S = sc.next().toCharArray();
		sc.close();
		int a = 0;
		int b = 0;
		for(int i = 0; i < S.length; i++) {
			if(S[i] == 'A') a++;
			if(S[i] == 'B') b++;
		}
		System.out.println(a > 0 && b > 0 ? "Yes" : "No");
	}
}


Measured memory_bytes: 23380
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <vector>

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, f, n) for (int i = (f); i < (n); i++)
ll const INF = 1LL << 60;

int main() {
    ll A, B;
    cin >> A >> B;

    ll total = 0;
    ll ans = 0;

    for (int i = 0; i < 100; i++) {
        if (i == 0)
            total = 1;
        else
            total += (A-1);
        
        if (total >= B) {
            ans = i;
            break;
        }
    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N,K=map(int,input().split())
A,F=[list(map(int,input().split())) for i in range(2)]
A.sort()
F.sort()
l,r=-1,10**18
while r-l>1:
    h=(l+r)//2
    k=0
    for i in range(N):
        k+=max(0,A[i]-h//F[-i-1])
        if k>K:
            k=-1
            break
    if k>=0:
        r=h
    else:
        l=h
print(r)

Measured memory_bytes: 120908
open Batteries

let scan fmt f =
  Scanf.sscanf (read_line ()) fmt f

let scan_list cnv =
  read_line ()
  |> String.split_on_char ' '
  |> List.map cnv

let scan_array n m e conv =
  let arr = Array.make_matrix n m e in
  Enum.Labels.iter (0 --^ n)
    ~f:(fun i -> arr.(i) <- Array.of_list @@ scan_list conv);
  arr

let rec zip xs ys =
  match xs, ys with
  | [], _ -> []
  | _, [] -> []
  | x::xs, y::ys ->
    (x, y) :: zip xs ys

let dbg x = Printf.eprintf "[debug]%s\n" @@ dump x; x

let n = scan "%d" identity
let s = scan "%s" identity

let () =
  Enum.Labels.map (0 --^ 1000)
    ~f:(fun i ->
        let d = String.to_list @@ Printf.sprintf "%03d" i in
        let (result, _) = List.Labels.fold_left d
            ~init:(true, 0) ~f:(fun (b, i) c ->
                if b then
                  let e = String.of_char c in
                  match String.Exceptionless.find_from s i e with
                  | Some i -> (true, i+1)
                  | None -> (false, i)
                else (false, i))
        in
        if result then 1 else 0)
  |> Enum.sum
  |> Printf.printf "%d\n"


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

using namespace std;
int main()
{
    bool ara['z'+9];
    memset(ara, 0, sizeof(ara));
    int i;
    string s;
    cin >> s;
    for(i=0;i<s.size();i++) ara[s[i]]=true;
    for(i='a';i<='z';i++) if(ara[i]==false) putchar(i), exit(0);
    puts("None");
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	vector<int> arr(n);
	vector<int> dp(n);
	for(int i=0;i<arr.size();i++)
	cin>>arr[i];
	
	
	dp[0] = 0;
	
	dp[1]= abs(arr[1]-arr[0]);
	
	for(int i=2;i<n;i++)
	{
	    dp[i] = min(abs(arr[i]-arr[i-1]) + dp[i-1] , abs(arr[i]-arr[i-2]) + dp[i-2]);
	    
	   // cout<<dp[i]<<" ";
// 	}
// 	cout<<endl;
    }
	cout<<dp[n-1]<<"\n";
	
	
	return 0;
}

Measured memory_bytes: 1024
/*  In the name of ALLAH */

#include<bits/stdc++.h>
using namespace std;
/*******  All Required define Pre-Processors and Constants    *******/

#define ll long long
#define ull unsigned long long 
#define ld long double
#define mem(a, b) memset(a, (b), sizeof(a))
#define rep(i, j, k) for (int i = j ; i < k ; ++i)
#define rrep(i, j, k) for (int i = j; i > k; --i)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define foreach(i, a) for(auto i: a)
#define forEach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define in(A, B, C) assert( B <= A && A <= C)
#define debug(a) cout << #a << ": " << a << endl
#define Flag(n) cout << "here " << n << endl
#define mp make_pair
#define pb push_back

#define endl '\n';
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const ll POSITIVE_INFINITY = 9223372036854775807;
const ll NEGATIVE_INFINITY = -9223372036854775807;
const ll MOD = 1000000007;
const ld PI = acos(-1.0);
 

#define TRACE
#ifdef TRACE
#define see(...) __f(#__VA_ARGS__,__VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr<<name<<" : "<<arg1<<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
#endif



int main() {
    io;
    // freopen("input.txt","r",stdin); 
    // freopen("output.txt","w",stdout);
  
    ll n;
    cin>>n;
    vector<ll> v(n,0);
    // rep(i,0,n)v[i]=0;
    rep(i,0,n-1){
        int e;
        cin>>e;
        v[e-1]++;
    }
    for(auto i:v){
        cout<<i<<" ";
    }
 
    
 
    
 
    return 0;
}



Measured memory_bytes: 4792
#include <cstdint>
#include<bits/stdc++.h>
using namespace std;
template <std::uint_fast64_t Modulus> class modint {
    using u64 = std::uint_fast64_t;

public:
    u64 a;

    constexpr modint(const u64 x = 0) noexcept : a(x % Modulus) {}
    constexpr u64 &value() noexcept { return a; }
    constexpr const u64 &value() const noexcept { return a; }
    constexpr modint operator+(const modint rhs) const noexcept {
	return modint(*this) += rhs;
    }
    constexpr modint operator-(const modint rhs) const noexcept {
	return modint(*this) -= rhs;
    }
    constexpr modint operator*(const modint rhs) const noexcept {
	return modint(*this) *= rhs;
    }
    constexpr modint operator/(const modint rhs) const noexcept {
	return modint(*this) /= rhs;
    }
    constexpr modint &operator+=(const modint rhs) noexcept {
	a += rhs.a;
	if (a >= Modulus) {
	    a -= Modulus;
	}
	return *this;
    }
    constexpr modint &operator-=(const modint rhs) noexcept {
	if (a < rhs.a) {
	    a += Modulus;
	}
	a -= rhs.a;
	return *this;
    }
    constexpr modint &operator*=(const modint rhs) noexcept {
	a = a * rhs.a % Modulus;
	return *this;
    }
    constexpr modint &operator/=(modint rhs) noexcept {
	u64 exp = Modulus - 2;
	while (exp) {
	    if (exp % 2) {
		*this *= rhs;
	    }
	    rhs *= rhs;
	    exp /= 2;
	}
	return *this;
    }
};

#include <utility>

template <class T, class U> constexpr T power(T x, U exp) {
    T ret = static_cast<T>(1);
    while (exp) {
	if (exp % static_cast<U>(2) == static_cast<U>(1))
	    ret *= x;
	exp /= static_cast<U>(2);
	x *= x;
    }
    return ::std::move(ret);
}

#include <iostream>
#include <vector>

int main() {
    using mint = modint<1000000007>;
    int N;
    mint K=0, ans=0, tmp=0, tmp2=0;
    cin >> N >> K.a;
    vector<int> a(N);
    for(int i=0; i<N; i++){
    	cin >> a[i];
    }
 
    for(int i=0; i<N; i++){
    	for(int j=i; j<N; j++){
    	    if(a[i]>a[j])
    		tmp+=1;
    	}
    	for(int j=0; j<N; j++){
    	    if(a[i]>a[j])
    		tmp2+=1;		
    	}
    }
    ans = tmp*K + (K-1)*K/2*tmp2;
    cout << ans.a << endl;
}


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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int main(){
  ll n,k;cin>>n>>k;
  vector<int >a(n);
  rep(i, n)cin>>a[i];

  ll sum=0;
  rep(i, n)sum += a[i];

  set<ll>c;
  for(ll i=1; i*i<=sum; i++){
    if(sum%i)continue;
    c.insert(i);
    c.insert(sum/i);
  }

  ll ans = 0;
  for(ll cc: c){
    vector<ll>ca(n);
    rep(i, n)ca[i] = a[i]%cc;
    sort(ca.begin(), ca.end());

    ll psum = 0, msum=0;
    rep(i, n)psum += ca[i];
//    if(psum <= k)ans = max<ll>(ans, cc);
    rrep(i, n){
      psum-=ca[i];
      msum += cc-ca[i];
      ll cans = max<ll>(psum, msum);
      if(cans<=k)ans = max<ll>(ans, cc);
//cout<<cc<<' '<<ans<<' '<<cans<<endl;
    }
  }

  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
int main(){
    int n, i;
    long  mx, mn;
    long sum = 0;
    scanf("%d", &n);
    long a[100000];
    for (i = 0; i < n; i++){
        scanf("%ld", &a[i]);
    }
    sum = a[0], mn = a[0], mx = a[0]; 
    for (i = 1; i < n; i++){
        if (a[i] > mx){
            mx = a[i];
        }
        else if (a[i] < mn){
            mn = a[i];
        }
        sum += a[i];
    }
    printf("%ld %ld %ld\n", mn, mx, sum);
    return 0;
}

Measured memory_bytes: 2764
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    X = int(input())

    ans = 0
    for i in range(A + 1):
        for j in range(B + 1):
            for k in range(C + 1):
                ans += 500 * i + 100 * j + 50 * k == X
    print(ans)


if __name__ == '__main__':
    main()


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

int N, x, y, b, p;

int main(){
    for(scanf("%d", &N); N--;){
        scanf("%d%d%d%d", &x, &y, &b, &p);
        printf("%d\n", min(x*b+y*p,
                           80*(x*max(b,5)+y*max(p,2))/100));
    }
    return 0;
}

Measured memory_bytes: 1188
#include <stdio.h>
// #include <string.h>
// #include <math.h>

int main() {
    int n,b,f,r,v,i,j,k,count[4][3][10]={0};
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        scanf("%d %d %d %d",&b,&f,&r,&v);
        count[b-1][f-1][r-1]+=v;
    }
    
    for(i=0;i<4;i++){
        for(j=0;j<3;j++){
            for(k=0;k<10;k++){
                printf(" %d",count[i][j][k]);
            }
            printf("\n");
        }
        if(i<3){
            printf("####################\n");
        }
    }
   
    return 0;
}


Measured memory_bytes: 2120
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

int dy[] = {0,1,0,-1};
int dx[] = {1,0,-1,0};
int dy8[] = {0,1,1,1,0,-1,-1,-1};
int dx8[] = {1,1,0,-1,-1,-1,0,1};

/*==================================================*/
/*variable*/
int N;
int P[200010];
int Q[200010];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;
    REP(i,0,N){
        cin>>P[i];
        Q[P[i]-1] = i;
    }

    int cnt = 1;
    int mx = 1;
    REP(i,1,N){
        if(Q[i-1] < Q[i]){
            cnt++;
        }else{
            cnt = 1;
        }
        mx = max(mx, cnt);
    }

    cout<<N-mx<<endl;

    return 0;
}


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

using namespace std;

constexpr long long INF64 = 1e18;

using Weight=long long;

struct Edge{
    int src,dst,ds,belong,st,kaisuu;
    Weight weight;
    Edge(int src,int dst,int ds,Weight weight,int belong,int st,int kaisuu):
    src(src),dst(dst),ds(ds),weight(weight),belong(belong),st(st),kaisuu(kaisuu){}
};

auto operator < (const Edge &e,const Edge &f){
    if(e.weight!=f.weight)return e.weight>f.weight;
    else return e.kaisuu>f.kaisuu;
}

using Edges=vector<Edge>;
using Graph=vector<Edges>;

pair<Weight,int> dijkstra(const Graph &g,int s,int t,int N,int T,int f){
    const int V=g.size();
	vector<Weight>dist(f+1,INF64);
	vector<int>prev(f+1,-1);
    priority_queue<Edge>q;
    for(q.emplace(-2,s,-1,-T,-1,-2,-1);!q.empty();){
        Edge e=q.top();q.pop();
        if(e.belong>=0){
			if(prev[e.ds]!=-1)continue;
			else prev[e.ds]=e.src;
		}
        if(e.dst==t)return make_pair(e.weight,e.kaisuu);
        for(auto ge:g[e.dst]){
			int plus=0;
			if(e.belong!=ge.belong || abs(e.st-ge.st)>1)plus=T;
            if(dist[ge.ds] > e.weight+ge.weight+plus){
                dist[ge.ds]=e.weight+ge.weight+plus;
				if(plus)plus=1;
                q.emplace(ge.src,ge.dst,ge.ds,dist[ge.ds],ge.belong,ge.st,e.kaisuu+plus);
            }
        }
    }
	return make_pair(-1,-1);
}


int main(){
	int N,T;
	cin>>N>>T;
	string A,B;
	cin>>A>>B;
	map<string,int>mp;
	int k=1,f=0;
	Graph g(100001);
	for(int i=0;i<N;++i){
		int a;
		cin>>a;
		int prev=-1;
		vector<int>station(a);
		for(int j=0;j<a;++j){
			string s;
			cin>>s;
			if(mp[s]==0)mp[s]=k++;
			station[j]=mp[s];
		}
		for(int j=0;j<a-1;++j){
			Weight t;
			cin>>t;
			g[station[j]].emplace_back(station[j],station[j+1],f+1,t,i,j+1,-1);
			g[station[j+1]].emplace_back(station[j+1],station[j],f,t,i,j+1,-1);
			f++;
		}
		f++;
	}
	pair<Weight,int>ans=dijkstra(g,mp[A],mp[B],N,T,f);
	if(ans.first==-1)cout<<"-1"<<endl;
	else cout<<ans.first<<" "<<ans.second<<endl;
}

Measured memory_bytes: 23060
n=int(input())
a=list(map(int,input().split()))
l=[0 for i in range(n)]
l[0]=a[0]
cnt=1
for i in range(1,n):
    l[i]=min(l[i-1],a[i])
    if l[i]==a[i]:
        cnt+=1
    
print(cnt)


Measured memory_bytes: 24744
#include <algorithm>
#include <bitset>
#include <climits>
#include <iostream>
#include <vector>
using namespace std;

int main() {
	int N, ans = INT_MIN;
	cin >> N;
	vector<vector<int>> F(N, vector<int>(10)), P(N, vector<int>(11));
	for (vector<int>& i : F) {
		for (int& j : i) cin >> j;
	}
	for (vector<int>& i : P) {
		for (int& j : i) cin >> j;
	}
	for (int i = 1; i < 1024; i++) {
		bitset<10> a = i;
		int b = 0;
		for (int j = 0; j < N; j++) {
			int c = 0;
			for (int k = 0; k < 10; k++) {
				if (F[j][k] == 1 && a[k]) c++;
			}
			b += P[j][c];
		}
		ans = max(ans, b);
	}
	cout << ans;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1LL << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
int dp[200][200];
int r[8];
int main() {
	int N, M, R;
	cin >> N >> M >> R;
	rep(i, R) {
		cin >> r[i]; r[i]--;
	}
	fill((int*)dp, (int*)(dp + 200), INF);
	rep(i, N) dp[i][i] = 0;
	rep(i, M) {
		int A, B, C;
		cin >> A >> B >> C;
		A--; B--;
		dp[A][B] = dp[B][A] = C;
	}
	rep(k, N) {
		rep(i, N) {
			rep(j, N) {
				dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
			}
		}
	}
	sort(r, r + R);
	LL ans = 1LL << 60;
	do {
		LL sum = 0;
		for (int i = 1; i < R; i++) {
			sum += dp[r[i - 1]][r[i]];
		}
		ans = min(ans, sum);
	} while (next_permutation(r, r + R));
	cout << ans << endl;
}

Measured memory_bytes: 384
n, k = gets.split.map!(&:to_i)
m = 10**9 + 7

def f(n, k)
  k * (n - k + 1) + 1
end

puts (k..n.succ).inject(0) { |cnt, i| (cnt + f(n, i)) % m }

load __FILE__ unless $stdin.eof?


Measured memory_bytes: 14320
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(v) v.begin(), v.end()
typedef long long ll;



int main() {
    int n, m;
  cin >> n >> m;
  ll sum = 0;
  ll x;
  rep(i,m){
    cin >> x;
    sum += x;
  }
  
  int ans = n-sum;
  if(ans < 0) dunk("-1");
  else dunk(ans);
  
  return 0;
}


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


ll int solve(ll int h[],ll int a[],int n){

    ll dp[n];
    map<ll,ll> meaningful;
    dp[0]=a[0];
    meaningful[h[0]]=dp[0];
    ll ans=a[0];

    for(int i=1;i<n;i++){

        dp[i]=a[i];

        auto it=meaningful.lower_bound(h[i]+1);

        if(it!=meaningful.begin()){
            it--;
            dp[i]+=it->second;
        }
        meaningful[h[i]]=dp[i];

        it=meaningful.upper_bound(h[i]);

        while(it!=meaningful.end() && it->second<=dp[i]){
            auto temp=it;
            temp++;
            meaningful.erase(it);
            it=temp;

        }

        ans=max(ans,dp[i]);


    }

    return ans;

}


int main() {
   int n;
   cin>>n;
   ll int h[n],a[n];

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

   }

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

   cout<<solve(h,a,n);


}


Measured memory_bytes: 20684
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include <bitset>
#include <cmath>
#include <stack>
#include <iomanip>
#include <map>
#include <math.h>
typedef long long ll;
using namespace std;
const int MOD = 1000000007;

ll GCD(ll a, ll b) { return b ? GCD(b, a%b) : a; }

int main() {
    int N, M; cin >> N >> M;
    long long ac = 0;
    long long pena = 0;
        
    vector<long long> wa(N, 0), isac(N, 0);
    for (int i = 0; i < M; ++i) {
        int p; string s;
        cin >> p >> s;
        --p;
        if (s == "AC") {
            if (!isac[p]) {
                ++ac;
                pena += wa[p];
                isac[p] = true;
            }
        }
        else wa[p]++;
    }
    cout << ac << " " << pena << endl;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3

MOD = 10**9
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    return divisors

N, M = map(int, input().split())
A = list(map(int, input().split()))

if sum(A) > N:
    print(-1)
else:
    print(N-sum(A))


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

using namespace std;

int dsum(int N){
  int tmp = 0;
  while(N != 0){
    tmp += N % 10;
    N /= 10;
  }
  return tmp;
}

int main(){
  int N;
  cin >> N;
  int a = dsum(N);
  
  if(N % a == 0) cout << "Yes";
  else cout << "No";

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}

int64_t calcmodcomb(int64_t n,int64_t r){
  return (((modfact.at(n)*modinvfact.at(r))%univMod)*modinvfact.at(n-r))%univMod;
}

int64_t calcmodpositive(int64_t n){
  return (n + ((abs(n)+univMod-1)/univMod)*univMod)%univMod;
}
  
    */


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int64_t a,b;
  cin >> a >> b;
  if(a <= 0 && 0 <= b){
    cout << "Zero" << endl;
  }else{
    int64_t minusnum = 0;
    if(a>0){
      cout << "Positive" << endl;
    }else{
      if((b-a+1) % 2 == 1){
        cout <<"Negative"  << endl;
      }else{
        cout << "Positive" << endl;
      }
    }
  }
      
      
      
  
}

Measured memory_bytes: 256
from collections import defaultdict
import queue
def dfs(i):
    global count
    if count >= N or ans[i] != 0:
        return
    
    for ii in A2B[i]:
        dfs(ii)
N, M = map(int, input().split())
A2B = defaultdict(list)
ans = [0 for i in range(N+1)] 
# ans[1] = 1
for m in range(M):
    a, b = map(int, input().split())
    A2B[a] += [b]
    A2B[b] += [a]
count = 0
q = queue.Queue()
q.put((1, 1))
while count < N:
    t, f = q.get()
    if ans[t] != 0:
        continue
    count += 1
    ans[t] = f
    for x in A2B[t]:
        q.put((x, t))
print('Yes')
for i in range(2, N+1):
    print(ans[i])



Measured memory_bytes: 125028
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int s;
  cin>>s;
  set<int> a;
  a.insert(s);
  REP(i,1e6+1){
    if(s%2==0)s/=2;
    else s=s*3+1;
    if(a.find(s)!=a.end()){
      cout<<i+2<<endl;
      break;
    }
    a.insert(s);
  }
  return 0;
}


Measured memory_bytes: 256
def main():
    n,m = map(int,input().split())
    
    sw = [ 0 for _ in range(m)]
    for i in range(m):
        _,*sl = map(int,input().split())
        for s in sl:
            sw[i] += 2 ** (s-1)
    p = list(map(int,input().split()))

    b = 0
    ans = 0
    while b < 2**n:
        ok = True
        for i in range(m):
            sc = 0
            for j in range(n):
                bit = int(2 ** (j))
                if (bit & b != 0):
                    continue
                if sw[i] & bit != 0:
                    sc += 1
            #print(sc)
            if sc % 2 != p[i]:
                ok = False
                continue
        if (ok):
            ans += 1
        b += 1
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
import math
from collections import deque
from collections import defaultdict

#自作関数群
def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()
def factorization(n):
	res = []
	if n%2==0:
		res.append(2)
	for i in range(3,math.floor(n//2)+1,2):
		if n%i==0:
			c = 0
			for j in res:
				if i%j==0:
					c=1
			if c==0:
				res.append(i)
	return res
def fact2(n):
	p = factorization(n)
	res = []
	for i in p:
		c=0
		z=n
		while 1:
			if z%i==0:
				c+=1
				z/=i
			else:
				break
		res.append([i,c])
	return res
def fact(n):#階乗
	ans = 1
	m=n
	for _i in range(n-1):
		ans*=m
		m-=1
	return ans
def comb(n,r):#コンビネーション
	if n<r:
		return 0
	l = min(r,n-r)
	m=n
	u=1
	for _i in range(l):
		u*=m
		m-=1
	return u//fact(l)
def combmod(n,r,mod):
	return (fact(n)/fact(n-r)*pow(fact(r),mod-2,mod))%mod
def printQueue(q):
	r=copyQueue(q)
	ans=[0]*r.qsize()
	for i in range(r.qsize()-1,-1,-1):
		ans[i] = r.get()
	print(ans)
class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1]*n

	def find(self, x): # root
		if self.parents[x]<0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self,x,y):
		x = self.find(x)
		y = self.find(y)

		if x==y:
			return

		if self.parents[x]>self.parents[y]:
			x,y = y,x

		self.parents[x]+=self.parents[y]
		self.parents[y]=x

	def size(self,x):
		return -1*self.parents[self.find(x)]

	def same(self,x,y):
		return self.find(x)==self.find(y)

	def members(self,x): # much time
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i)==root]

	def roots(self):
		return [i for i,x in enumerate(self.parents) if x<0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()} # 1~n
def bitArr(n):#ビット全探索
	x = 1
	zero = "0"*n
	ans = []
	ans.append([0]*n)
	for i in range(2**n-1):
		ans.append(list(map(lambda x:int(x),list((zero+bin(x)[2:])[-1*n:]))))
		x+=1
	return ans;
def arrsSum(a1,a2):
	for i in range(len(a1)):
		a1[i]+=a2[i]
	return a1
def maxValue(a,b,v):
	v2 = v
	for i in range(v2,-1,-1):
		for j in range(v2//a+1): #j:aの個数
			k = i-a*j
			if k%b==0:
				return i
	return -1
def copyQueue(q):
	nq = queue.Queue()
	n = q.qsize()
	for i in range(n):
		x = q.get()
		q.put(x)
		nq.put(x)
	return nq
def get_sieve_of_eratosthenes(n):
	#data = [2]
	data = [0,0,0]
	for i in range(3,n+1,2):
		data.append(i)
		data.append(0)
	for i in range(len(data)):
		interval = data[i]
		if interval!=0:
			for j in range(i+interval,n-1,interval):
				data[j] = 0
	#ans = [x for x in data if x!=0]
	ans = data[:]
	return ans

n,a,b = readInts()

ans = 0

for i in range(n+1):
	x=sum(list(map(lambda x:int(x), list(str(i)))))
	if x>=a and x<=b:
		#print(i)
		ans+=i

print(ans)

Measured memory_bytes: 3572
h, w = map(int, input().split())
matrix = []
for i in range(h):
  matrix.append(list(input()))
output = [''] * h
for i in range(h):
  matrix[i] = ['.'] + matrix[i] + ['.']
blank = ['.'] * (w + 2)
matrix = [blank] + matrix + [blank]
for i in range(h):
  for j in range(w):
    if (matrix[i + 1][j + 1] == '#'):
      output[i] += '#'
    else:
      o = ord('0')
      for k in range(3):
        for l in range(3):
          if (matrix[i + k][j + l] == '#'):
            o += 1
      output[i] += chr(o)
for i in range(h):
  print(output[i])

Measured memory_bytes: 3064
N = gets.to_i
playlist = []
N.times { playlist.push(gets.split) }
i = playlist.map { |p| p[0] }.index(gets.chomp)
puts i == N - 1 ? 0 : playlist.map { |p| p[1].to_i }[i + 1, N - i - 1].inject(:+)

Measured memory_bytes: 1788
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, start, end) for (int i = (start); i <= (int)(end); i++)

int main(){
  int s,w;
  cin >> s >> w;
  if(s <= w) cout << "unsafe" << endl;
  else cout << "safe" << endl;
}


Measured memory_bytes: 3632
import java.util.Scanner;
class Main
{
    public static void main(String args[])
    {
	Scanner scan=new Scanner(System.in);
	while(true)
	    {
	int x=scan.nextInt();
	if(x==0)break;
	int n,count=0;
	n=1000-x;
	count+=n/500;
	n%=500;
	count+=n/100;
	n%=100;
	count+=n/50;
	n%=50;
	count+=n/10;
	n%=10;
	count+=n/5;
	n%=5;
	count+=n;
	System.out.println(count);
	    }
    }
}

Measured memory_bytes: 17360
N, M = gets.chomp.split.map(&:to_i)

sumN = 0
if N > 1 then
    sumN = (1..N).to_a.combination(2).size
end

sumM = 0
if M > 1 then
    sumM = (1..M).to_a.combination(2).size
end

puts sumN + sumM


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

int main() {
  int a,b,c,d,e;
  cin>>a>>b>>c>>d>>e;
  
  if(a==0)  cout<<1<<endl;
  else if(b==0)  cout<<2<<endl;
  else if(c==0)  cout<<3<<endl;
  else if(d==0)  cout<<4<<endl;
  else if(e==0)  cout<<5<<endl;
  
}


Measured memory_bytes: 3592
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
        int a[] = new int[100];
        
        for(int i = 0; i < n; i++)
        {
            a[i] = sc.nextInt();
        }
        int s = x;
        
        for(int i = 0; i < n; i++)
        {
        	s += (d + a[i] - 1) / a[i];
        }
        
        System.out.println(s);
	}
}

Measured memory_bytes: 23508
# AtCoder Beginner Contest 132
# A - Fifty-Fifty

S=input()

a=S[0]
b=S[1]
c=S[2]
d=S[3]
l=[a,b,c,d]
l.sort()

if l[0]==l[1] and l[2]==l[3] and l[1]!=l[2]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9104
#include <iostream>
#define exp 1e-6
using namespace std;
const int maxn=2e5+10;
int a[maxn];
int n,k;
bool check(int x){
    int cnt=0;
    for(int i=1; i<=n; i++){
        if(a[i]>x&&x){
            cnt+=a[i]/x;
        }
        if(cnt>k)return false;
    }
    return true;
}
int main()
{
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n>>k;
    int l=1, r=0,ans=0;
    for(int i=1; i<=n; i++)cin>>a[i],r=max(r,a[i]);
    ans=r;
    if(k==0||r==1){
        cout<<ans<<endl;
        return 0;
    }
    while(l<=r){
        int mid=(l+r)>>1;
       // cout<<mid<<endl;
        if(check(mid))ans=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<ans<<endl;
    return 0;
}


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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

set<pair<int, int>> edges;

void addEdge(int a, int b) {
    edges.insert(make_pair(a, b));
}

int main(){
	ios::sync_with_stdio(0);
    int N;
    cin >> N;
    if (__builtin_popcount(N) == 1) {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
    vector<int> x(2*N+1);
    vector<int> parent(2*N+1);
    int pow2 = 1;
    while (2*pow2 < N+2)
        pow2 *= 2;
    map<int, vector<int>> rev;
    rep(i,1,pow2-1) {
        addEdge(i, i+1);
        addEdge(i+N, i+1+N);
        parent[i] = 2;
        parent[i+N] = 2;
        x[i] = x[i-1]^i;
        x[i+N] = x[i];
        rev[x[i]].push_back(i);
    }
    addEdge(pow2-1, 1+N);
    /*addEdge(1, 2);
    addEdge(2, 3);
    addEdge(3, 1+N);
    addEdge(1+N, 2+N);
    addEdge(2+N, 3+N);
    rep(i,1,4) {
        parent[i] = 2;
        parent[i+N] = 2;
    }
    x[1] = 1;
    x[2] = 3;
    x[3] = 0;
    x[1+N] = 1;
    x[2+N] = 3;
    x[3+N] = 0;*/
    //rev[1].push_back(1);
    /*rev[3].push_back(2);
    rev[0].push_back(3);*/
    rep(i,pow2,N+1) {
        if (__builtin_popcount(i) == 1) {
            parent[i] = i;
            parent[i+1] = i;
            parent[i+N] = i+N;
            parent[i+N+1] = i+N;
            addEdge(1, i);
            addEdge(i, i+1);
            addEdge(1, i+1+N);
            addEdge(i+N, i+1+N);
            x[i] = 1+i;
            x[i+1] = 0;
            x[i+N] = 0;
            x[i+1+N] = i;
            rev[x[i]].push_back(i);
            rev[x[i+1+N]].push_back(i+1+N);
            ++i;
        }
        else {
            bool ok = 0;
            rrep(j1,i-1,1) {
                if (ok)
                    break;
            for (int j = j1; j <= j1+N; j += N) {
                if (ok)
                    break;
                int desired = i^1^x[j];
                for (int k : rev[desired]) {
                    if (parent[k] == parent[j]) {
                        //cout << i << endl;
                        continue;
                    }
                    addEdge(j, i);
                    addEdge(k, i+N);
                    x[i] = x[j]^i;
                    x[i+N] = x[k]^i;
                    parent[i] = parent[j];
                    parent[i+N] = parent[k];
                    rev[x[i]].push_back(i);
                    rev[x[i+N]].push_back(i+N);
                    ok = 1;
                    break;
                }
            }
            }
            if (!ok) {
                assert(ok);
            }
        }
    }
    assert(sz(edges) == 2*N-1);
    for (auto it : edges) {
        cout << it.first << " " << it.second << endl;
    }
}


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

int main() {
    int a, b;
    cin >> a >> b;

    for(int i=1; i<=1250; i++) {
        int ibuff1=i*0.08;
        int ibuff2=i*0.10;
        if (ibuff1==a && ibuff2==b) {
            cout << i << endl;
            return 0;
        }
    }
    cout << "-1" << endl;

    return 0;
}

Measured memory_bytes: 3636
n, m, x = gets.strip.split.map(&:to_i)
ary = gets.strip.split.map(&:to_i)
low = 0
high = 0
ary.each do |i|
  if i > x
    high+=1
  else
    low+=1
  end
end
if high > low
  puts low
else
  puts high
end


Measured memory_bytes: 1788
#include <stdio.h>
#include <iostream>
#include <stack>
#include <algorithm>
using namespace std;
const int Q=1<<12,P=1<<16;
int ops;
int inc=1,Time;
int las[Q],e[P],nn[P];
int dfn[Q],low[Q];
int st[Q],tp=0;
int bel[Q];
int scc=0;
const int MOD=1e9+7;
int add(int a,int b)
{a+=b;return a>=MOD?a-MOD:a;}
int mul(int a,int b)
{return 1LL*a*b%MOD;}
int ksm(int a,int b)
{
	int ans=1;
	for(;b;b>>=1,a=mul(a,a))
		if(b&1)ans=mul(ans,a);
	return ans;
}
int C(int n,int m)
{
	int t1=1,t2=1;
	for(int i=0;i<m;i++){
		t1=mul(t1,n-i);
		t2=mul(t2,m-i);
	}
	return mul(t1,ksm(t2,MOD-2));
}
int gcd(int a,int b)
{return b?gcd(b,a%b):a;}
int k;
int Po(int x)
{
	int tmp=0;
	for(int i=1;i<=x;i++)tmp=add(tmp,ksm(k,gcd(i,x)));
	return mul(tmp,ksm(x,MOD-2));
}
int als=1;
void DEAL(int last,int x)
{
	++scc;
	int now;
	int lim=tp;
	do{
		now=st[tp--];
		bel[now]=scc;
	}while(now!=x);
	bel[last]=scc;
	int pn=lim-tp+1,pm=0;
	for(int i=tp;i<=lim;i++){
		int x=st[i];
		if(i==tp)x=last;
		for(int t=las[x];t;t=nn[t]){
			int y=e[t];
			if(bel[y]==scc)++pm;
		}
	}
	pm>>=1;
	if(pn==pm)als=mul(als,Po(pn));
	else if(pm<pn)als=mul(als,k);
	else als=mul(als,C(pm+k-1,k-1));
}
void dfs(int x)
{
	dfn[x]=low[x]=++Time;
	st[++tp]=x;
	for(int t=las[x];t;t=nn[t]){
		int y=e[t];
		if(!dfn[y]){
			dfs(y);
			if(dfn[x]<=low[y])DEAL(x,y);
			low[x]=min(low[x],low[y]);
		}
		else low[x]=min(low[x],dfn[y]);
	}
}
void ins(int x,int y)
{
	e[++inc]=y;
	nn[inc]=las[x];
	las[x]=inc;
}
int n,m;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1,x,y;i<=m;i++)
		scanf("%d%d",&x,&y),ins(x,y),ins(y,x);
	for(int i=1;i<=n;i++)
		if(!dfn[i])dfs(i);
	printf("%d",als);
	return 0;
}

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

using namespace std;

#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
// #define int ll
#define vi vector<ll>
#define vvi vector<vi>
#define pii pair<int, int>
#define vii vector<pii>
#define pb push_back
#define B begin()
#define E end()
#define sz(A) (ll)(A).size()
#define F first
#define S second
#define loop(z, v) for(auto &z: v)
#define sp << ' ' << 
#define sps << ' '
#define nl "\n"
// #define nl endl
#define fat 1000000007
// #define fat 998244353

int main()
{
    boost;
    ll tt = 1, n, m, k = 0, i, j;
    ll q, l = 0, r = 0, x, y, z, h, a, b, c, d;

    bool poss = true;
    string s;
    ll ans = 0;

    // cin >> tt;
    for(int _ = 1; _ <= tt; _++){
        // cout << "Case #" << _ << ": ";
        cin >> n >> m;

        vi hei(n, 0);
        loop(z, hei) cin >> z;
        vvi g(n);

        for(i = 0; i < m; i++){
            cin >> a >> b;
            a--, b--;
            g[a].pb(b);
            g[b].pb(a);
        }

        for(i = 0; i < n; i++){
            poss = true;
            loop(z, g[i]){
                if(hei[z] >= hei[i]){
                    poss = false;
                    break;
                }
            }
            if(poss){
                ans++;
            }
        }

        cout << ans << nl;
    }   
    return 0;
}

Measured memory_bytes: 9784
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;
using ll = long long;

int main()
{
    int h, w, k;
    cin >> h >> w >> k;
    vector<vector<char>> c(h, vector<char>(w));
    vector<vector<char>> tmp(h, vector<char>(w));
    for(int i = 0; i< h; i++){
        for(int j = 0; j < w; j++){
            cin >> c[i][j]; 
        }
    }
    int ans = 0;
    int to = 0;
    for(int bith = 0; bith < (1<<h); bith++){
        for(int bitw = 0; bitw < (1<<w); bitw++){
        tmp = c;
        
        for(int i = 0; i < h; i++){

            if(bith & (1 << i)){
                for(int a = 0; a < w; a++){
                    tmp[i][a] = 'r';
                }
            }
        }

            
                for(int j = 0; j < w; j++){
                    if(bitw & (1 << j)){
                        for(int a = 0; a < h; a++){
                            tmp[a][j] = 'r';
                        }
                    }
                    
                }
                int num = 0;
                    for(int l = 0; l< h; l++){
                        for(int b = 0; b < w; b++){
                            
                            //cout << tmp[l][b];
                            if(tmp[l][b] == '#') num++; 
                        }
                    }
                    //cout << endl
                    //cout << "--" << endl;
                    
                    if(num == k) ans++;
            }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include<stdio.h>

int main(void)
{
	int n;
	int i;
	int j;
	int k;
	int l;
	int count;
	
	while(scanf("%d", &n) !=  EOF){
		count = 0;
		for(i = 0;i <= 9;i++){
			for(j = 0;j <= 9;j++){
				for(k = 0;k <= 9;k++){
					for(l = 0;l <= 9;l++){
						if(i + j + k + l == n){
							count++;
						}
					}
				}
			}
		}
		printf("%d\n",count);
	}
	
	return (0);
}

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

int main(){
   cout << fixed << setprecision(12);
   double r;
   scanf("%lf", &r);
   double PI = acos(-1);
   double area = r * r * PI;
   double cir = 2 * r * PI;
   printf("%f %f\n", area, cir);
   return 0;
}



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

int main(int argc, char **argv)
{
	ll N, M; cin >> N >> M;
	vector<pll> P(M); for (ll i = 0; i < M; ++i)
					 {
						 ll a, b; cin >> a >> b;
						 P[i] = pll(a, b);
					 }

	sort(P.begin(), P.end(), [](pll &a, pll &b)
							 {
								 return a.second < b.second;
							 });

	ll res{0}, now{-(1ll<<60)};
	for (auto &p : P)
	{
		if (p.first < now) continue;
		++res;
		now = p.second;
	}
	std::cout << res << std::endl;
}

Measured memory_bytes: 1792
#include <iostream>
using namespace std;
int main (void) {
    int N;
    int ans = 0;

    cin >> N;
    for (int i = 0; i < N; i++) {
        int l;
        int r;
        cin >> l >> r;
        ans += r - l + 1;
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B &b) { if (a<b) {a = b; return 1;} return 0;}
template<typename A, typename B> inline bool chmin(A &a, B &b) { if (a>b) {a = b; return 1;} return 0;}
typedef long long ll;
typedef pair<int, int> pii;
const ll INF = 1e9+100;
const bool debug = 0;

int main() {
	int T, D, L;
	while (cin >> T >> D >> L, T || D || L) {
		int prevt = -1;
		int ans = 0;
		REP(i, T) {
			int x;
			scanf("%d", &x);
			if (x >= L) {
				if (prevt == -1) prevt = i;
				else {
					ans += min(i - prevt, D);
					prevt = i;
				}
			}
		}
		if (prevt != -1) ans += min(T - 1 - prevt, D);
		if (debug) printf("@ ");
		cout << ans << endl;
	}
	return 0;
}


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


using namespace std;
using namespace __gnu_pbds;

#define int long long int
#define pb push_back
#define M 1000000007
#define ff first
#define ss second
#define deb(x) cout< #x< " "< x< endl;
#define fo(i,n) for(int i=0;i<n;i++)
#define Fo(i,k,n) for(int i=k;i<=n;i++)
#define FORR(a,b,c) for(int a= b;a>=c;a--)
#define fa(arrr) for(auto x:arrr)
#define sz size()
// #define mp make_pair
#define mxm3(a,b,c) max(a, max(b,c))
#define mi3(a,b,c) min(a, min(b,c))
#define MAX 100005
#define PII pair<int,int>
#define all(v) v.begin(), v.end()
#define endl "\n"
#define fast ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);


typedef tree<pair<int, int>,
        null_type,
        less<pair<int, int>>,
        rb_tree_tag,
        tree_order_statistics_node_update> oset;

//126271
// 107897


int lcm(int a, int b) {
	int x = (a * b) % M;
	return x / __gcd(a, b);
}

int ceil(int a, int b) {
	if (a % b != 0) return a / b + 1;
	return a / b;
}

oset s;
int cnt = 0;

int freq(vector<int>arr, int l, int r, int x , map<int, vector<int>>mp) {
	int a = lower_bound(all(mp[x]), l) - mp[x].begin();
	int b = upper_bound(all(mp[x]), r) - mp[x].begin();

	return b - a;
}


int32_t main() {
	int t;
	// cin >> t;
	t = 1;
	while (t--) {
		int n, m; cin >> n >> m;
		vector<vector<char>>arr(n + 1, vector<char>(m + 1));
		vector<vector<int>>dp(n + 1, vector<int>(m + 1));
		for (int i = 1; i <= n; i++) {
			for (int j = 1; j <= m; j++) {
				cin >> arr[i][j];
				// if (arr[i][j] == '.') dp[i][j] = 0;
				// else dp[i][j] = -1;
			}
		}
		for (int i = 1; i <= n; i++) {
			for (int  j = 1; j <= m; j++) {
				if(arr[i][j] == '#') continue;
				if(i==1 && j==1) dp[i][j] = 1;
				else dp[i][j] = (dp[i-1][j]+dp[i][j-1])%M;
			}
		}
		cout << dp[n][m]%M << endl;
	}
}



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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,s,e) for(int (i)=(s);(i)<(e);i++)
#define endl "\n"

typedef long long ll;

void use_cio(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
}
//----------------------------------------//
int n,k;
vector<int> adj[2010];

int chk[2010];
int dist1[2010];
int dist2[2010];
vector<pair<int,int>> edg;

void dfs(int cur, int d, int *dd){
	chk[cur] = 1;
	dd[cur] = d;
	for(auto nxt : adj[cur]){
		if(chk[nxt]) continue;
		dfs(nxt, d+1, dd);
	}
}

int main(){
	use_cio();
	cin >> n >> k;
	rep(i,n-1){
		int u,v;
		cin >> u >> v;
		adj[u].push_back(v);
		adj[v].push_back(u);
		edg.push_back({u,v});
	}
	int ans = 1e9;
	if(k%2==0){
		for(int i = 1; i <= n ; i++){
			memset(chk+1, 0, sizeof(int)*n);
			memset(dist1+1, 0, sizeof(int)*n);
			dfs(i, 0, dist1);
			int cnt = 0;
			for(int j = 1; j <= n; j++){
				if(dist1[j] > k/2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else{
		for(auto e : edg){
			int u = e.first, v = e.second;
			memset(chk+1, 0, sizeof(int)*n);
			memset(dist1+1, 0, sizeof(int)*n);
			dfs(u, 0, dist1);
			memset(chk+1, 0, sizeof(int)*n);
			memset(dist2+1, 0, sizeof(int)*n);
			dfs(v, 0, dist2);
			int cnt = 0;
			for(int j = 1; j <= n; j++){
				if(min(dist1[j], dist2[j]) > k/2) cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	cout << ans;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		int ans = 0;
		for(var i=0;i<str.Length;i++){
			if(str.Substring(i,1)=="2"){
				ans++;
			}
		}
		Console.WriteLine(ans);
	}
}

Measured memory_bytes: 13140
#include<stdio.h>
int main(void)
{
    int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==b+c||b==a+c||c==a+b){
	    printf("Yes\n");
	}
	else{
	    printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define ll long long int
int main(void)
{
    ll N, A, B, C;
    ll d, e, ans = 0;
    scanf("%lld%lld%lld", &N, &A, &B);
    if (A == 0)
    {
        printf("0\n");
        return 0;
    }
    C = A + B;
    d = N / C;
    ans += d * A;
    e = N % C;
    if (e < A)
    {
        ans += e;
    }
    else
    {
        ans += A;
    }
    printf("%lld\n", ans);
    return 0;
}

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

 
int main() {
    int l,r,d;
    cin >> l >> r >> d;
    int ans = r/d - (l-1)/d;
    cout << ans << endl;
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
}

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

ll knapsack(ll weight[],ll value[],ll n,ll TotalWeight){

  ll dp[n+1][TotalWeight+1];

  //base case
  for(ll i=0;i<=n;i++){
    dp[i][0]=0;
  }
  for(ll j=0;j<=TotalWeight;j++){
    dp[0][j]=0;
  }

  //fill the dp array
  for(ll i=1;i<=n;i++){
    for(ll j=1;j<=TotalWeight;j++){
      dp[i][j]=dp[i-1][j];
      if(j-weight[i-1]>=0){
        dp[i][j]=max(dp[i][j],dp[i-1][j-weight[i-1]]+value[i-1]);
      }
    }
  }

  return dp[n][TotalWeight];

}


int main(){

  ll n,TotalWeight;
  cin>>n>>TotalWeight;

  ll weight[n];
  ll value[n];
  for(ll i=0;i<n;i++){
    cin>>weight[i]>>value[i];
  }

  ll ans=knapsack(weight,value,n,TotalWeight);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 79104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define fs first
#define sc second
#define _GLIBCXX_DEBUG

int dxy[4][2] = {{0,1},{0,-1},{1,0},{-1,0}};
int h, w;
vector<vector<bool>> visited(100, vector<bool>(100, false));
vector<vector<int>> s(100, vector<int>(100, 0));

vector<vector<int>> rotate(int k, vector<vector<int>> dice)
{
    if(k==1){
        dice[1][2] = dice[1][1];
        dice[1][1] = dice[1][0];
        dice[1][0] = 7-dice[1][2];
    }
    if (k == 0)
    {
        dice[1][0] = dice[1][1];
        dice[1][1] = dice[1][2];
        dice[1][2] = 7 - dice[1][0];
    }
    if (k == 3)
    {
        dice[2][1] = dice[1][1];
        dice[1][1] = dice[0][1];
        dice[0][1] = 7 - dice[2][1];
    }
    if (k == 2)
    {
        dice[0][1] = dice[1][1];
        dice[1][1] = dice[2][1];
        dice[2][1] = 7 - dice[0][1];
    }
    return dice;
}

void dfs(int x, int y, vector<vector<int>> dice)
{
    if(x == h-1 && y == w-1){
        cout << "YES\n";
        exit(0);
    }
    visited[x][y] = true;
    rep(i,4){
        int x2 = x+dxy[i][0];
        int y2 = y+dxy[i][1];
        if(0 <= x2 && x2 < h && 0 <= y2 && y2 < w){
            if(s[x2][y2] == dice[1+dxy[i][0]][1+dxy[i][1]] && !visited[x2][y2]){
                dfs(x2,y2,rotate(i,dice));
            }
        }
    }
}

int main(void){
    vector<vector<int>> dice(3, vector<int>(3, 0));
    dice[1][1] = 6;
    dice[1][0] = 4;
    dice[1][2] = 3;
    dice[0][1] = 5;
    dice[2][1] = 2;
    cin >> h >> w;
    rep(i,h){
        string tmp;
        cin >> tmp;
        rep(j,w){
            if(tmp[j] != '#'){
                s[i][j] = tmp[j] - '0';
            }
        }
    }
    dfs(0,0,dice);
    cout << "NO\n";
}



Measured memory_bytes: 4868
from collections import deque
import sys

k = int(input())

q = deque([i for i in range(1, 10)])
if k <= 9:
    print(q[k-1])
    sys.exit()

cnt = 0
while True:
    if cnt == k:
        print(x)
        break
    x = q.popleft()
    m = x % 10
    if m == 0:
        q.extend([10*x + m, 10*x + (m+1)])
    elif m == 9:
        q.extend([10*x + (m-1), 10*x + m])
    else:
        q.extend([10*x + (m-1), 10*x + m, 10*x + (m+1)])
    cnt += 1

Measured memory_bytes: 12404
#include <stdio.h>
#include <ctype.h>
#include <string.h>

int main(){
	int i,j,len,cnt;
	char str[1025],tmp[1025],ans[180][7];

	while(gets(str) != NULL){
		i = 0;
		cnt = 0;
		len = strlen(str);
		while(i <= len){
			j = 0;
			while(!(str[i] == '.' || str[i] == ' ' || str[i] == ',')){
				tmp[j] = str[i];
				i++;
				j++;
			}
			tmp[j] = '\0';
			while(i <= len && !isalpha(str[i])){
				i++;
			}
			if(strlen(tmp) >= 3 && strlen(tmp) <= 6){
				strcpy(ans[cnt],tmp);
				cnt++;
			}
		}

		for(i = 0;i < cnt;i++){
			printf("%s%c",ans[i],(i == cnt-1) ? '\n' : ' ');
		}
	}

	return 0;
}

Measured memory_bytes: 528