akhauriyash/Code-Regression huggingface dataset:
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let h = read::<usize>();
    let w = read::<usize>();

    let mut s = vec![vec!['a'; w]; h];

    for i in 0..h {
        s[i] = read::<String>().chars().collect::<Vec<char>>();
    }
    let range :Vec<(i32, i32)> = vec![(-1, 0), (1, 0), (0, -1), (0, 1)];
    for i in 0..h {
        for j in 0..w {
            if s[i][j] == '#' {
                let mut flag = 0;
                for k in 0..4 {
                    if 0 <= i as i32+range[k].0 && i as i32+range[k].0 < h as i32 && 0 <= j as i32+range[k].1 && j as i32+range[k].1 < w as i32 {
                        if s[(i as i32+range[k].0) as usize][(j as i32+range[k].1) as usize] == '#' {
                            flag = 1;
                        }
                    }
                }
                if flag == 0 {
                    println!("No");
                    return;
                }
            }
        }
    }
    println!("Yes");
}


Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<map>
#include<algorithm>
using namespace std;
long long a,b;
int main()
{
	scanf("%I64d %I64d",&a,&b);
	if(a%b==0)
	{
		printf("-1\n");
		return 0;
	}
	for(long long i=2;i*a<=1000000000000000000ll;i++)
	{
		if(a*i%b!=0)
		{
			printf("%I64d\n",a*i);
			return 0;
		}
	}
	printf("-1\n");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
    int n,m,A[200000],B[200000];
    cin>>n>>m;
    for(int i=0;i<m;i++) cin>>A[i];
    sort(A,A+m,greater<int>());
    for(int i=0;i<m-1;i++) B[i]=A[i]-A[i+1];
    sort(B,B+m-1,greater<int>());
    int ans=A[0]-A[m-1];
    for(int i=0;i<n-1;i++) ans-=B[i];
    cout<<ans;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
int main(void){
    int N; cin >> N;vector<vector<int>> imos(1010,vector<int>(1010,0));
    for(int i = 0; i < N;i++){
        int x1,y1,x2,y2; cin >> x1 >> y1 >> x2 >> y2;
        x1++;y1++;x2++;y2++;
        imos[x1][y1]++;imos[x1][y2]--;
        imos[x2][y1]--;imos[x2][y2]++;
    }
    int ans = 0;
    for(int i = 1; i< 1010;i++){
        for(int j = 1; j< 1010;j++){
            imos[i][j] += (imos[i-1][j]+imos[i][j-1]-imos[i-1][j-1]);
            ans = max(ans,imos[i][j]);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 6848
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN (ll)1e5+5

void solve(){
    ll n;
    cin>>n;
    ld a[n];
    ld sum = 0;
    loop(i,0,n){
        cin>>a[i];
        a[i] = 1/a[i];
        sum+=a[i];
    }
    ld ans = 1/sum;
    printPrec(ans);
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    

    ll t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
        
    
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <utility>
#include <iomanip>
using namespace std;
typedef long long ll;

const ll MOD = 1e9+7;
int main()
{
	int n;
	string s;
	ll ans=0;
	cin>>s;
	if(s=="SUN")
		ans=7;
	if(s=="MON")
		ans=6;
	if(s=="TUE")
		ans=5;
	if(s=="WED")
		ans=4;
	if(s=="THU")
		ans=3;
	if(s=="FRI")
		ans=2;
	if(s=="SAT")
		ans=1;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())

cnt = 0
for a in range(0, A+1):
    for b in range(0,  B+1):
        for c in range(0, C+1):
            if 500 * a + 100 * b + 50 * c == X:
                cnt += 1
print(cnt)

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

using namespace std;

int main() {
    long long a, b, c, d;
    cin >> a >> b >> c >> d;
    long long ac, ad, bc, bd;
    ac = a * c;
    ad = a * d;
    bc = b * c;
    bd = b * d;
    long long maxNum = ac;
    maxNum = max(maxNum, ad);
    maxNum = max(maxNum, bc);
    maxNum = max(maxNum, bd);
    cout << maxNum << endl;
    return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    string s;
    int k;
    cin >> s >> k;

    string t = s;
    int l = k;
    rep(i, s.size()) {
        if (t[i] == 'a') continue;
        if ('z' - t[i] + 1 <= l) {
            l -= 'z' - t[i] + 1;
            t[i] = 'a';
        }
    }

    int x = t[s.size() - 1] - 'a';
    x = (x + l) % 26;
    t[t.size() - 1] = x + 'a';

    cout << t << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>

#include <deque>

#include <stdio.h>

#include <cstdio>

#include <algorithm>

#include<bits/stdc++.h>

#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define sp <<" "
#define nw <<"\n"
#define ca "Case "<<tc++<<": "
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
#define ull unsigned LL
#define check cout<<"* ";
#define show_vector(i) for(int q=0;q<i.size();q++){cout<<i[q]<<" ";}
#define REP(i,n) for (int i=0;i<(n);++i)
#define N_MAX 26
#define rep(i, a, b) for(int i = a; i < b; i++)

const int inf=1<<30;
const long long int INF=1e10;
const int MOD=1e9+7;
const int maxn = 1e5+10;
int a[200005],b[1000005];

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
/*
int ck_prime(int n)
{
    int coun;
     coun=0;
     if(n>1){
      for(int i=2;i*i<=n;i++){
        if( n%i==0 ){
            coun++;
            break;
          }
        }
      }
     if(n==1){
       coun=coun;
         }
    if(coun==0){
           return 1; // n is prime
        }
    return 0;
}
*/
int main()
{
    int n;
    cin>>n;
    vector<int> a(n+1), b(n);
    rep(i, 0, n+1 ) cin >> a[i];
    rep(i, 0, n) cin >> b[i];

    long long int sum=0;
    rep(i, 0, n){
        int x=min(a[i],b[i]);
        sum+=x;
        a[i]=a[i]-x;
        b[i]=b[i]-x;
        x=min(a[i+1],b[i]);
        sum+=x;
        a[i+1]=a[i+1]-x;
        b[i]=b[i]-x;
    }
    cout<<sum nw;
}



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

using namespace std;

inline int inv(int n, int p) {
	int i = 1;
	for (int r = n; r > 1; r = p % r)
		i = p / r * long(p - i) % p;
	return i;
}
int f[1111111], g[1111111];
int main()
{
	int n;
	cin >> n;
	int p = 1e9 + 7;
	f[0] = 1, g[n - 1] = 1;
	for (int i = 1; i < n; i++) {
		f[i] = long(i)*f[i - 1] % p;
		g[n - 1 - i] = long(n - 1 - i)*g[n - i] % p;
	}
	int a = 0;
	for (int i = (n + 1) / 2; i < n - 1; i++)
		a = (a + (long(f[i])*f[i - 1]) % p*g[i * 2 - n + 1]) % p;
	cout << (long(n - 1)*f[n - 1] + long(p - a)*inv(f[n - 2], p)) % p << endl;
	return 0;
}


Measured memory_bytes: 8448
#include<bits/stdc++.h>
using namespace std;
long long a,b; 
int main()
{
    cin>>a>>b;
    if(a>0) cout<<"Positive";
    else if(a==0||(a<0&&b>0)) cout<<"Zero";
    else if((abs(b)-abs(a))%2!=0) cout<<"Positive";
    else cout<<"Negative";
    cout<<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        long K = Long.parseLong(scan.next());

        long count = 0;

        for(int i =0;i<S.length();i++) {

            if (S.charAt(i) != '1') {

                if (K < i + 1) {
                    System.out.println(1);
                    return;
                } else {
                    System.out.println(S.charAt(i));
                    return;
                }
            }
        }


        System.out.println(1);
    }
}

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

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void check(vi p)
{
	vi t=p;
	sort(t.begin(),t.end());
	for(int i=0;i<t.size();i++)
	{
		if(i==0) assert(t[i]==0);
		else assert(t[i]-t[i-1]==1);
	}
	for(int i=0;i+1<p.size();i++)
	{
		assert(__builtin_popcount(p[i]^p[i+1])==1);
	}
}

const int C = 18;

vi solve(int fullbit, int a, int b)
{
	int n = __builtin_popcount(fullbit);
	//cerr<<"CALL "<<fullbit<<' '<<a<<' '<<b<<'\n';
	if(n==1){return {a,b};}
	//cerr<<fullbit<<' '<<a<<' '<<b<<'\n';
	int xr = a^b; int difbit=-1;
	vi bits;
	for(int i=C;i>=0;i--)
	{
		if(fullbit&(1<<i))
		{
			if(xr&(1<<i))
			{
				difbit=i; break;
			}
		}
	}
	for(int i=0;i<=C;i++)
	{
		if(fullbit&(1<<i))
		{
			if(difbit==i) continue;
			bits.pb(i);
		}
	}
	int x=-1;
	bool flip=0;
	if(a&(1<<difbit))
	{
		flip=1; swap(a,b);
	}
	for(int i=0;i<(1<<(n-1));i++)
	{
		int num=0;
		for(int j=0;j<n-1;j++)
		{
			if(i&(1<<j)) num^=(1<<bits[j]);
		}
		//cerr<<num<<' '<<(1<<difbit)<<'\n';
		if(!(num&(1<<difbit)))
		{
			if(a!=num)
			{
				//cerr<<"NUM : "<<num<<' '<<__builtin_popcount(num)%2<<' '<<__builtin_popcount(a)%2<<'\n';
				if((__builtin_popcount(num)%2)!=(__builtin_popcount(a)%2))
				{
					x=num;
				}
			}
		}
	}
	//cerr<<"X : "<<x<<'\n';
	//cerr<<"SOLVE "<<a<<' '<<x<<' '<<(x^(1<<difbit))<<' '<<b<<'\n';
	vi p = solve(fullbit^(1<<difbit),a,x);
	vi R = solve(fullbit^(1<<difbit),x,b^(1<<difbit));
	//for(int v:p) cerr<<v<<' ';
	//for(int v:R) cerr<<v<<' ';
	//cerr<<'\n';
	for(int i=0;i<R.size();i++)
	{
		p.pb(R[i]^(1<<difbit));
	}
	if(flip) reverse(p.begin(),p.end());
	return p;
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,a,b; cin>>n>>a>>b;
	int cnt1=__builtin_popcount(a);
	int cnt2=__builtin_popcount(b);
	if(cnt1%2==cnt2%2)
	{
		cout<<"NO\n"; return 0;
	}
	cout<<"YES\n";
	vi p = solve((1<<n)-1,a,b);
	for(int i=0;i<(1<<n);i++)
	{
		cout<<p[i];
		if(i+1<(1<<n)) cout<<' ';
	}
	cout<<'\n';
	assert(p[0]==a); assert(p[(1<<n)-1]==b);
	check(p);
}


Measured memory_bytes: 2672
#include<bits/stdc++.h>
#define MIN(x,y) ((x)<(y)?(x):(y))
using namespace std;

int A,B,C;

int main(){
	cin>>A>>B>>C;
	int tmp;
	tmp = MIN(B,C);
	long int ans = tmp*2;
	//cout<<tmp<<" "<<ans<<"\n";
	B -= tmp;
	C -= tmp;
	
	tmp = MIN(A,C);
	ans += tmp;
	C -= tmp;
	A -= tmp;
	//cout<<tmp<<" "<<ans<<"\n";
	ans += B;
	if(C)
		ans++;
	cout<<ans<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
double v[50];
int main()
{
    double ans;
    int n;cin>>n;
    for(int i=1;i<=n;i++)cin>>v[i];
    sort(v+1,v+n+1);
    for(int i=2;i<=n;i++)
    {
        v[i]=(v[i]+v[i-1])/2;
    }
    printf("%.5f\n",v[n]);
    return 0;
}

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

int main(){
    int n;
    cin >> n;
    int t[110];
    rep(i,n){
        cin >> t[i];
    }
    int m;
    cin >> m;
    int S = 0;
    rep(i,n){
        S+=t[i];
    }
    rep(i,m){
        int p,x;
        cin >> p >> x;
        p--;
        int ans;
        ans = S - t[p] + x;
        cout << ans << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define REP2(i, n) for (Int i = 0, max_i = (n); i < max_i; i++)
#define REP3(i, a, b) for (Int i = (a), max_i = (b); i < max_i; i++)
#define OVERLOAD2(_1, _2, _3, name, ...) name
#define REP(...) OVERLOAD2(__VA_ARGS__, REP3, REP2)(__VA_ARGS__)
template <class T> inline bool chmax(T& a, const T& b) {
    if (a >= b) return false;
    a = b;
    return true;
}
template <class T> inline bool chmin(T& a, const T& b) {
    if (a <= b) return false;
    a = b;
    return true;
}
struct in {
    int n;
    in() {}
    in(int n_) : n(n_){};
    template <class T> operator T() {
        T ret;
        cin >> ret;
        return ret;
    }
    template <class T> operator vector<T>() {
        vector<T> ret(n);
        for (int i = 0; i < n; i++) cin >> ret[i];
        return ret;
    }
};
struct SetupIO {
    SetupIO() { cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(20); }
} setup_io;

#ifdef _MY_DEBUG
#include "/Users/knshnb/.competitive_local.hpp"
#else
#define dump(...)
#endif

/**
 *    author:  knshnb
 *    created: Sun Dec 22 21:00:17 JST 2019
 **/

signed main() {
    Int n = in();
    Int U = in(), V = in();
    U--, V--;
    vector<vector<Int>> g(n);
    REP(i, n - 1) {
        Int u = in(), v = in();
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<Int> depth(n), par(n);
    auto dfs1 = [&](auto f, Int v, Int prv) -> void {
        dump(v);
        for (Int s : g[v]) {
            if (s == prv) continue;
            par[s] = v;
            depth[s] = depth[v] + 1;
            f(f, s, v);
        }
    };
    dfs1(dfs1, V, -1);
    dump(depth);

    Int cur = U;
    vector<Int> path;
    while (cur != V) {
        path.push_back(cur);
        cur = par[cur];
    }
    path.push_back(V);
    dump(path);

    Int x = path[(path.size() - 1) / 2];
    Int ma = 1;
    auto dfs2 = [&](auto f, Int v, Int prv) -> void {
        if (depth[v] < depth[x]) return;
        chmax(ma, depth[v]);
        for (Int s : g[v]) {
            if (s == prv) continue;
            f(f, s, v);
        }
    };
    dfs2(dfs2, x, -1);
    cout << ma - 1 << endl;
}


Measured memory_bytes: 11520
import sys
from collections import defaultdict, Counter, namedtuple, deque
import itertools
import functools
import bisect
import heapq
import math
import copy
# from fractions import gcd

MOD = 10 ** 9 + 7
# MOD = 998244353
# sys.setrecursionlimit(10**8)


class Uf:
    def __init__(self, N):
        self.p = list(range(N))
        self.rank = [0] * N
        self.size = [1] * N

    def root(self, x):
        if self.p[x] != x:
            self.p[x] = self.root(self.p[x])

        return self.p[x]

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

    def unite(self, x, y):
        u = self.root(x)
        v = self.root(y)

        if u == v: return

        if self.rank[u] < self.rank[v]:
            self.p[u] = v
            self.size[v] += self.size[u]
            self.size[u] = 0
        else:
            self.p[v] = u
            self.size[u] += self.size[v]
            self.size[v] = 0

            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1

    def count(self, x):
        return self.size[self.root(x)]


h, w = map(int, input().split())
ch, cw = map(int, input().split())
dh, dw = map(int, input().split())
A = [input() for i in range(h)]

tree = Uf(h*w)
for i in range(h):
    for j in range(w):
        if A[i][j] == "#":
            continue
        if i > 0 and A[i-1][j] == ".":
            tree.unite(w*i+j, w*(i-1)+j)
        if i < h-1 and A[i+1][j] == ".":
            tree.unite(w*i+j, w*(i+1)+j)
        if j > 0 and A[i][j-1] == ".":
            tree.unite(w*i+j, w*i+(j-1))
        if j < w-1 and A[i][j+1] == ".":
            tree.unite(w*i+j, w*i+(j+1))

# print(tree.p)

par_list = set()
for i in range(h):
    for j in range(w):
        if A[i][j] == ".":
            par_list.add(tree.root(w*i+j))

# print(par_list)

node = dict()
for i, e in enumerate(par_list):
    node[e] = i

# print(node)

edge_list = set()
for i in range(h):
    for j in range(w):
        if A[i][j] == ".":
            for a in range(max(0, i - 2), min(h, i+3)):
                for b in range(max(0, j - 2), min(w, j + 3)):
                    if A[a][b] == "." and tree.root(w*i+j) != tree.root(w*a+b):
                        edge_list.add((node[tree.root(w*i+j)], node[tree.root(w*a+b)]))
                        edge_list.add((node[tree.root(w*a + b)], node[tree.root(w*i + j)]))

start = node[tree.root(w*(ch-1) + cw-1)]
goal = node[tree.root(w*(dh-1) + dw-1)]

g = [[] for i in range(len(node))]
for e in edge_list:
    g[e[0]].append(e[1])

# print(g, start, goal)

que = deque([(start, 0)])
seen = set()
seen.add(start)
while que:
    cur, time = que.popleft()
    if cur == goal:
        print(time)
        exit()
    for nxt in g[cur]:
        if nxt not in seen:
            seen.add(nxt)
            que.append((nxt, time+1))

print(-1)



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

int main(){
  int n,k,a=1,i;
  cin>>n>>k;
  for(i=0;i<n;i++){
  if(a*2<a+k)a*=2;
    else a+=k;
  }
  cout<<a<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int N, i, X_max=0, Y_max=0, MAX=0;
	int X[20], Y[20];

	scanf("%d", &N);

	for (i = 0; i < N; i++) {
		scanf("%d", &X[i]);
	}
	for (i = 0; i < N; i++) {
		scanf("%d", &Y[i]);
	}

	for (i = 0; i < N; i++) {
		if (X[i] - Y[i] > 0) {
			X_max = X_max + X[i];
			Y_max = Y_max + Y[i];
		}
	}

	MAX = X_max - Y_max;

	printf("%d", MAX);

	return 0;
}

Measured memory_bytes: 128
S = input()
l =[S[0]]
for i in S:
  if i not in l:
    l.append(i)
if len(l)==2:
  count1=0
  for i in range(4):
    for j in range (4):
      if S[i]==S[j]:
        count1+=1
  if count1 ==8:
    print("Yes")
  else:
    print("No")
else:
  print("No")

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

int main() {
  int P, Q, R;
  cin >> P >> Q >> R;
  int ans = P + Q + R - max(P, max(Q,R));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
import sys
from decimal import *

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    A, B, C = [int(x) for x in input().split()]

    if Decimal(A).sqrt() + Decimal(B).sqrt() < Decimal(C).sqrt():
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 5076
X = int(input())

if (X < 600):
    print(8)
elif (X < 800):
    print(7)
elif (X < 1000):
    print(6)
elif (X < 1200):
    print(5)
elif (X < 1400):
    print(4)
elif (X < 1600):
    print(3)
elif (X < 1800):
    print(2)
elif (X < 2000):
    print(1)


Measured memory_bytes: 61628
#include <stdio.h>
#include <vector>
#include <iostream>
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pair<int, int> > vpi;


int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int k, x, i;
    cin >> k >> x;
    for (i=x-(k-1);i<x+(k);i++){
        cout << i << " ";
    }
    cout << endl;
}


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

using namespace std;

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    vector<bool> alice(100);
    for(int i=a; i<b; i++) {
        alice[i] = true;
    }
    int result = 0;
    for(int i=c; i<d; i++) {
        if(alice[i]) result++; 
    }

    cout << result << endl;

    return 0;
    
}


Measured memory_bytes: 256
N=gets.to_i
A=gets.split.map(&:to_i)

def selectionSort(a, n, cnt)
  (N-1).times do |i|
    minj=i
    ((i).upto(N-1)).each do |j|
      if A[j] < A[minj]
        minj = j
      end
    end
    next if i == minj
    A[i], A[minj] = A[minj], A[i]
    cnt+=1
  end
  return A.join(" "), cnt
end

puts selectionSort(A, N, 0)



Measured memory_bytes: 6880
M=10**9+7
n,k,*a=`dd`.split.map(&:to_i)
m=(n+1).times.map{[0]*256}
m[0][0]=1
n.times{|i|(i+1).downto(1){|l|256.times{|j|
	m[l][j]+=m[l-1][a[i]^j]
}}}
r=0;q=1
1.upto(n){|l|r+=m[l][k]*q=q*l%M}
p r%M

Measured memory_bytes: 5384
N,M=map(int,input().split())
alist=list(map(int,input().split()))

blist=[False]*10
for a in alist:
  blist[a] = True

match=[6,2,5,5,4,5,6,3,7,6]
dp=[-1]*(N+1)

dp[0]=0
dp[1]=-1
for i in range(N+1):
  for j in range(1,10):
    if blist[j] and i+match[j]<=N:
      if dp[i+match[j]] < dp[i]+1:
        dp[i+match[j]] = dp[i]+1
#print(dp)

answer_str = ""
while(N>0):
  for i in reversed(range(1,10)):
    if blist[i] and N-match[i] >= 0 and dp[N-match[i]] == dp[N]-1:
      answer_str += str(i)
      N -= match[i]
      break
      
print(answer_str)

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define what_is(x) cerr << #x << " is " << x << endl;
#define MT make_tuple
#define eb emplace_back
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))

#define REP(i,a,b) for (int i = a; i <= b; i++)
#define FOR(i,n) for (int i=0;i < n ; i++)
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}
clock_t startTime;
long double getTime(){
	return (long double)(clock()-startTime)/CLOCKS_PER_SEC;
}

ll n,q,a,b;
std::vector<ll>* edges;
ll* sum, *finalsum, *parent;
bool *touched;





int main(){
	startTime=clock();
	cin >> n >> q;
	sum=new ll[n];
	finalsum=new ll[n];
	touched=new bool[n];
	edges=new std::vector<ll> [n];
	parent=new ll[n];
	parent[0]=0;

	FOR(i,n){
		sum[i]=0;
		finalsum[i]=0;
		touched[i]=false;
	}
	FOR(i,n-1){
		cin >> a >> b;
		edges[a-1].eb(b-1);
		edges[b-1].eb(a-1); 
	}

	FOR(i,q){
		cin >> a >> b;
		sum[a-1]+=b;
	}
	

	queue<ll>qu;
	qu.push(0);
	touched[0]=true;
	while(!qu.empty()){
		ll y=qu.front();
		qu.pop();
		for(auto x : edges[y]){
			if(!touched[x]){
				touched[x]=true;
				parent[x]=y;
				qu.push(x);
			}
		}
	}

	qu.push(0);
	FOR(i,n) touched[i]=false;
	finalsum[0]=sum[0];
	touched[0]=true;
	while(!qu.empty()){
		ll y=qu.front();
		qu.pop();
		for(auto x : edges[y]){
			if(!touched[x]){
				finalsum[x]=(x!=0) ? sum[x]+finalsum[parent[x]] : sum[x];
				qu.push(x);
				touched[x]=true;
			}
		}
	}
	FOR(i,n){
		cout << finalsum[i] <<" ";
	}
	

	return 0;
}

Measured memory_bytes: 22544
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  int a, b, c;
  cin>>a>>b>>c;
  int count = 0;
  if (a == b)
    count++;
  if (b == c)
    count++;
  if (a == c)
    count++;
  
  if(count == 1)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
  
  return 0;
}


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

int main() {
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  ll total = 0;
  ll ans = 100000000000000;
  rep(i,100001) {
    total = 2 * c * i + max(x-i,0) * a + max(y-i,0) * b;
    ans = min(ans,total);
  }
  cout << ans << endl;
}


Measured memory_bytes: 3532
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int box[200001];
int n;
int count(int x){//xの倍数の個数
int cnt=0;
for(int i=2;i*x-1<n;i++)cnt+=box[i*x-1];
return cnt;
}
int main(){
    cin>>n;
    vector<int>ans;
    int a[200001];
    rep(i,n)cin>>a[i];
    for(int i=n/2+1;i<=n;i++)box[i-1]=a[i-1];
    for(int i=2;i<=n;i++){
        for(int j=0;n/(i+1)<n/i-j;j++){
            box[n/i-j-1]=(count(n/i-j)+a[n/i-j-1])%2;
        }
    }
    rep(i,n){
        if(box[i]==1)ans.push_back(i+1);
    }
    cout<<ans.size()<<endl;
    rep(i,ans.size())cout<<ans[i]<<" ";
}

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

int main(void)
{
	int n, len, i, j, c; 
	char s[100000], next[100000], t[100000];
	
	while (scanf("%d", &n), n != 0){
		scanf("%s", s);
		for (i = 0; i < n; i++){
			next[0] = '\0';
			c = 1;
			len = strlen(s);
			for (j = 0; j < len; j++){
				if (s[j] == s[j + 1]){
					c++;
				}
				else {
					sprintf(t, "%d%c", c, s[j]);
					strcat(next, t);
					c = 1;
				}
			}
			strcpy(s, next);
		}
		printf("%s\n", s);
	}
	
	return (0);
}

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

int main(){
    string s;
    cin >> s;
    map<char,int> m;
    bool ans  = true;
    for(int i = 0; i < s.size(); i++){
        if(m[s[i]] != 0){
            ans = false;
            break;
        }else{
            m[s[i]]++;
        }
    }
    if(ans) cout << "yes" << endl;
    else cout <<  "no" << endl;
}

Measured memory_bytes: 256
Scanf.scanf "%d %d %d" (fun n ma mb ->
    let module M = Map.Make (struct type t = int * int let compare = compare end) in
    let map =
        let rec loop i map =
            if i = n then map else
                let map =
                    Scanf.scanf " %d %d %d" (fun a b c ->
                        M.fold (fun (ka, kb) v next ->
                            let key = (ka + a, kb + b) in
                            M.add key (min (v + c) (try M.find key next with _ -> max_int)) next
                        ) map map
                    )
                in
                loop (i + 1) map
        in
        loop 0 (M.add (0, 0) 0 M.empty)
    in
    let rec loop i mi =
        if i = 500 then (if mi = max_int then -1 else mi) else
            let key = (ma * i, mb * i) in
            let mi = min mi (try M.find key map with _ -> max_int) in
            loop (i + 1) mi
    in
    loop 1 max_int |> Printf.printf "%d\n"
)

Measured memory_bytes: 7168
def calc(num, value):
    for i in range(num + 1):
        for j in range(num - i + 1):
            k = num - i - j
            if i * 10000 + j * 5000 + k * 1000 == value:
                print(i, j, k)
                return True

    return False

num, value = input().split()
num = int(num)
value = int(value)

if not calc(num, value):
    print(-1, -1, -1)


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

int ans(0);
int dp[1 << 17];
int act[100010];
int maskact;

int mem(int mask)
{
    if (mask == 0 || dp[mask])
        return dp[mask];
    dp[mask] = 1e9;
    for (int i(0); i <= 15; i++) {
        if (!(mask & (1 << i)))
            continue;
        for (int j(0); j <= 15; j++) {
            if (!(mask & (1 << j)) || i == j)
                continue;
            /// xorate i, j by i
            int newmask = mask ^ (1 << i) ^ (1 << j) ^ (1 << (i ^ j));
            if (!(newmask & (1 << (i ^ j))))
                dp[mask] = min(dp[mask], 2 + mem(newmask));
            else
                dp[mask] = min(dp[mask], 1 + mem(newmask));
        }
    }
    return dp[mask];
}

int main()
{
    //cout << mem(2 + 4 + 8) << '\n';
    int n, a, b, c;
    cin >> n;

    for (int i(1); i < n; i++) {
        cin >> a >> b >> c;
        act[a] ^= c;
        act[b] ^= c;
    }
    for (int i(0); i < n; i++) {
        if (act[i] && (maskact & (1 << act[i])))
            ans++, maskact ^= (1 << act[i]);
        else if (act[i])
            maskact ^= (1 << act[i]);
    }

    cout << mem(maskact) + ans << '\n';
    return 0;
}


Measured memory_bytes: 896
n=int(input())
s=input()

w_l=[0]
s_l=[0]
for c in s:
    if c=='W':
        w_l.append(w_l[-1]+1)
        s_l.append(s_l[-1])
    else:
        w_l.append(w_l[-1])
        s_l.append(s_l[-1]+1)
ans=1145141919
for i in range(n):
    ans=min(ans, w_l[i]+s_l[-1]-s_l[i+1])
print(ans)


Measured memory_bytes: 18012
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file
//#include <ext/pb_ds/tree_policy.hpp>
//#include <functional> // for less
#define PI acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define nl printf("\n")
#define sf scanf
#define pf printf
#define INF (ll)1e15
#define mod 1000000007

///#define isValid(n,m,nx,ny)nx>=0&&nx<n&&ny>=0&&ny<m
///int kx[]={1, 1, -1, -1, 2, 2, -2, -2}; //knight moves
///int ky[]={2,-2,  2, -2, 1,-1,  1, -1}; //knight moves
///int dx[]={1,-1,0,0,1,-1,1,-1};//eight direction
///int dy[]={0,0,1,-1,1,-1,-1,1};//eight direction
 
///using namespace __gnu_pbds;
using namespace std;
 
///inline double toRad(double deg){return deg*PI/180;}
///inline double toDeg(double rad){return rad*180/PI;}
///typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;
 
const int S=123456;
int main()
{
    #ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    #endif
	int n;
	while(sf("%d",&n)==1)
	{
		int ara[n+5];
		memset(ara,0,sizeof ara);
		for(int i=0;i<n;i++)
		{
			int x;
			sf("%d",&x);
			ara[x]++;
		}

		bool zero=true,f=true;
		int two=0;
		for(int i=0;i<=n-1;i++)
		{
			if(i==0 && ara[i]>1)zero=false;
			else if(ara[i]>2)f=false;
			else if(ara[i]==2)two++;
		}

		if(zero && f)
		{
			ll ans=1;
			for(int i=1;i<=two;i++)ans=(ans*2)%mod;
			pf("%lld\n",ans);
		}
		else puts("0");
	}    
    return 0;
}
 









 




























Measured memory_bytes: 640
H, W = map(int, input().split())

black_h = []
black_w = []

a = []
for h in range(H):
  s = input()
  for si, sv in enumerate(list(s)):
    if sv == '#':
      black_h.append(h)
      black_w.append(si)
  a.append(list(s))

ans = []
for h in range(H):
  if h not in black_h:
    continue
  A = []
  for w in range(W):
    if w not in black_w:
      continue
    A.append(a[h][w])
  ans.append(A)
  
for v in ans:
  print(''.join(v))


Measured memory_bytes: 3444
def notExistOdd(lst):
    for i in lst:
        if i%2==1:
            return False
    return True

n=int(input())
a=[int(i)for i in input().split()]
res=0
div=lambda x:x/2
while notExistOdd(a):
    res+=1
    a=list(map(div,a))
print(res)

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

int d[101][101];
int t[101][101],c[101][101];
int n,m;
const int INF = 10000000;

void warshall_floyd() {

  for ( int k = 0; k <= m; k++ ) {
    for ( int i = 0; i <= m; i++ ) {
      for ( int j = 0; j <= m; j++ ) {
	t[i][j] = min( t[i][j], t[i][k] + t[k][j] );
	c[i][j] = min( c[i][j], c[i][k] + c[k][j] );
      }
    }
  }

}

int main() {

 
  while ( cin >> n >> m, n || m ) {
    for ( int i = 0; i < 101; i++ ) {
      for ( int j = 0; j < 101; j++ ) {
	if ( i == j ) {
	  t[i][j] = 0;
	  c[i][j] = 0;
	} else {
	  t[i][j] = INF;
	  c[i][j] = INF;
	}
      }
    }
  
    for ( int i = 0; i  < n; i++ ) {
      int a,b,cost,time; cin >> a >> b >> cost >> time;
      t[a][b] = t[b][a] = time;
      c[a][b] = c[b][a] = cost;
    }
    warshall_floyd();
    int k; cin >> k;
    for ( int i = 0; i < k; i++ ) {
      int p,q,r; cin >> p >> q >> r;
      if ( r == 0 ) {
	cout << c[p][q] << endl;
      } else if ( r == 1) {
	cout << t[p][q] << endl;
      }
    }

  }
  return 0;
}

Measured memory_bytes: 1244
package main

import "fmt"

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	for i := 0; i < len([]byte(s)); i++ {
		if s[i] != t[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}

Measured memory_bytes: 1756
import math
from decimal import Decimal

x = input().split()
a_ = x[0]
b = Decimal(x[1])

if len(a_)<=8:
    a = Decimal(a_)
    print(int(math.floor(a*b)))
else:
    a_div = (Decimal(a_)/(10**9))
    b_mul = b*100
    print(int(math.floor(a_div*b_mul*10**7)))

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

int main() {
    // input
    int n, m, a, b, c;
    cin >> n >> m;
    vector<pair<ll, int> > cb;
    rep(i, n) {
        cin >> a;
        cb.push_back(make_pair(a, 1));
    }
    rep(i, m) {
        cin >> b >> c;
        cb.push_back(make_pair(c, b));
    }    
    sort(cb.begin(), cb.end(), greater<pair<ll, int> >());

    // solve
    ll ans = 0;
    rep(i, cb.size()) {
        if (n > cb[i].second) {
            ans += cb[i].first * cb[i].second;
            n -= cb[i].second;
        } else {
            ans += cb[i].first * n;
            break;
        }
    }
    cout << ans << endl;
}

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

long long dp[110][100010];

int main()
{
    ios_base:: sync_with_stdio(false);
    cin.tie(0);

    int n,w;
    cin>>n>>w;


    for(int i=0;i<101;i++)
        for(int j=0;j<100001;j++)
            dp[i][j]=LONG_MAX;


    int val[n],weight[n];

    for(int i=0;i<n;i++)
        cin>>weight[i]>>val[i];

    dp[0][0]=0;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=100000;j++)
        {
            if(dp[i][j]==LONG_MAX)
                continue;
            else
            {
                dp[i+1][j]=min(dp[i][j],dp[i+1][j]);
                dp[i+1][j+val[i]]=min(dp[i+1][j+val[i]],dp[i][j]+weight[i]);
            }
        }
    }


    for(int i=100000;i>=0;i--)
    {
        if(dp[n][i]<=w)
        {
           cout<<i<<'\n';
            return 0;
        }
    }

    cout<<0<<'\n';

    return 0;

}


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

using namespace std;

int main(){
	string s;
	int win,lose;
	
	cin >> s;
	
	win=0;
	lose=0;
	for(int i=0; i<s.length(); i++){
		if(s[i]=='o')	win++;
		else	lose++;
	}
	
	if(15-s.length()+win >= 8)	cout << "YES" << endl;
	else	cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
import sys

read = sys.stdin.read
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7


def main():
    N = int(readline())
    A = list(map(int, readline().split()))
    R = 0
    G = 0
    B = 0
    ans = 1
    for a in A:
        if a == R == G == B:
            ans *= 3
            ans %= MOD
            R += 1
        else:
            if a == R == G:
                ans *= 2
                ans %= MOD
                R += 1
            elif a == G == B:
                ans *= 2
                ans %= MOD
                G += 1
            elif a == B == R:
                ans *= 2
                ans %= MOD
                B += 1
            else:
                if a == R:
                    R += 1
                elif a == G:
                    G += 1
                elif a == B:
                    B += 1
                else:
                    print(0)
                    sys.exit()
    print(ans % MOD)


if __name__ == '__main__':
    main()


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

int main(){
	int n;
	scanf("%d", &n);
	std::string s;
	std::cin >> s;
	std::string t;
	t = s;
	std::sort(t.begin(), t.end());

	int ans = 0;
	for(int i=0; i<n; i++){
		if(t[i]=='W') break;
		if(s[i]=='W') ans++;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 4004
#include <bits/stdc++.h>
using namespace std;
#define NewNode (ListNode *)malloc(sizeof(ListNode))
#define Mem(a,b) memset(a,b,sizeof(a))
const int N = 1e5 + 5;
const int INF = 0x3f3f3f3f;
const double EPS = 1e-10;
const unsigned long long mod = 998244353;
const double II = 3.1415926535;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    std::ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    int n;
    cin >> n;
    int vis[n+5] = {0};
    for(int i = 1,a;i < n;i++)
    {
        cin >> a;
        vis[a]++;
    }
    for(int i = 1;i <= n;i++)
        cout << vis[i] << endl;
}


Measured memory_bytes: 4436
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
#pragma GCC target ("avx2,tune=native")
#include<bits/stdc++.h>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/assoc_container.hpp>
#define pb push_back
#define __V vector
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define oit ostream_iterator
#define mod 1000000007ll
using namespace std;
void doin() {
	cin.tie();
	cout.tie();
	ios::sync_with_stdio(0);
#ifndef ONLINE_JUDGE
//	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
}
template<typename X, typename Y>
istream& operator>>(istream& in, pair<X, Y> &a) {
	in >> a.first >> a.second;
	return in;
}
template<typename T>
void getv(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv(vector<T>& v, int n, Ns ... ns) {
	v.resize(n);
	for (auto& i : v)
		getv(i, ns...);
}
template<typename T>
void getv1(T& i) {
	cin >> i;
}
template<typename T, typename ... Ns>
void getv1(vector<T>& v, int n, Ns ... ns) {
	v.resize(n + 1);
	for (int i = 1; i <= n; i++)
		getv1(v[i], ns...);
}
#ifdef _WIN32
#define getchar_unlocked() _getchar_nolock()
#define _CRT_DISABLE_PERFCRIT_LOCKS
#endif
inline void getch(char &x) {
	while (x = getchar_unlocked(), x < 33) {
		;
	}
}
inline void getstr(string &str) {
	str.clear();
	char cur;
	while (cur = getchar_unlocked(), cur < 33) {
		;
	}
	while (cur > 32) {
		str += cur;
		cur = getchar_unlocked();
	}
}
template<typename T> inline bool sc(T &num) {
	bool neg = 0;
	int c;
	num = 0;
	while (c = getchar_unlocked(), c < 33) {
		if (c == EOF)
			return false;
	}
	if (c == '-') {
		neg = 1;
		c = getchar_unlocked();
	}
	for (; c > 47; c = getchar_unlocked())
		num = num * 10 + c - 48;
	if (neg)
		num *= -1;
	return true;
}
template<typename a, typename b>
void minq(a& x, b y) {
	if (x > y)
		x = y;
}
template<typename a, typename b>
void maxq(a& x, b y) {
	if (x < y)
		x = y;
}
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef ll _I;
typedef pair<_I, _I> pi;
typedef pair<ld, ld> pd;
typedef map<_I, _I> mii;
typedef __V <_I> vi;
typedef __V <char> vc;
typedef __V <string> vs;
typedef __V <ld> vd;
typedef __V <vd> vvd;
typedef __V <pi> vpi;
typedef __V <__V<_I>> vvi;
typedef __V <__V<char>> vvc;
typedef __V <__V<pi>> vvpi;
using AntonTsypko = void;
using arsijo = AntonTsypko;
using god = arsijo;
//store differences, not the elements for rsq in fenwick or array(for write-only)
//SQRT-heuristic divide items into groups: >sqrt and <=sqrt and do something according to group(eg. trie for one, z-func for other) - 1202E
uniform_real_distribution<double> double_dist(0, 1);
//WHEN DOING MODULAR SUBTRACTION ALWAYS **ALWAYS** ADD MOD
//don't use AVX at AtCoder
//Trie: MAXDEPTH!=MAXSIZE
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	doin();
	int n;
	ld t, a =0;
	cin >> n;
	while(n--) {
		cin >> t;
		a += 1.0/t;
	}
	cout << fixed << setprecision(15) << (1.0/a);
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <cstring>
#include <string.h>
#include <sstream>
#include <iomanip>
#include <queue>
#include <stack>
#include <deque>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <tuple>
#include <vector>
#include <stdio.h>
#include <stdlib.h>
using namespace std;

#define F first
#define S second
#define siz(v) ((int)v.size())
#define rs(n) resize(n)
#define ALL(v) v.begin(),v.end()
#define reset(v) memset((v),0,sizeof(v))
#define EB emplace_back
#define MP make_pair
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,a,b) for(int i=(a);i<=(b);i++)
#define debug(x) cout << " > " << #x << ':' << x << endl;
#define kiyohime ios::sync_with_stdio(false);cin.tie(0);
#define endl '\n'

using ll = long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
template<typename T> using vec = vector<T>;
template<typename T> using Prior = priority_queue<T>;
template<typename T> using prior = priority_queue<T, vec<T>, greater<T>>;

const int INF = 1e9;
const ll LLINF = (ll)4*1e18;
const ll MOD = 1e9+7;
const double PI  = 3.14159265358;
const double EPS = 1e-8;
const int xx[8] = {0,1,0,-1,1,1,-1,-1};
const int yy[8] = {1,0,-1,0,1,-1,-1,1};

void pmod(ll &a, ll b) {a = (a+b)%MOD;}
void mmod(ll &a, ll b) {a = (a-b+MOD)%MOD;}
void tmod(ll &a, ll b) {a = (a*b)%MOD;}
ll POW(ll a, ll b) {ll res=1; do{if(b%2)tmod(res,a);tmod(a,a);}while(b>>=1); return res;}
template<typename T> void amax(T &a, T b) {if(a < b) a = b;}
template<typename T> void amin(T &a, T b) {if(a > b) a = b;}

#define N 100010

void solve(){
    int n, m, ipt;
    
    cin >> n >> m;
    
    vec<ll> v(m+1), d(m+1);
    v[0] = 1;
    while(n--){
        cin >> ipt;
        REP(i, 0, m){
            pmod(d[i], v[i]);
            if(i + ipt + 1 <= m)
                mmod(d[i+ipt+1], v[i]);
        }
        
        v.clear();
        v[0] = d[0];
        rep1(i, m)
            v[i] = (v[i-1] + d[i] + MOD) % MOD;
        fill(ALL(d), 0);
    }
    
    cout << v[m] << endl;
}

int main(){
//    kiyohime
    int T = 1;
    
//    cin >> T;
    while(T--){
        solve();
    }
}


Measured memory_bytes: 4832
def read_input():
    s1 = input()
    s2 = input()
    return s1, s2


def submit():
    s1, s2 = read_input()
    s2 = s2[::-1]

    if s1 == s2:
        print('YES')
    else:
        print('NO')

if __name__ == '__main__':
    submit()

Measured memory_bytes: 38256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
int main(){
  ll n,k;cin>>n>>k;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll dp[114514];
  rep(i,k+1)dp[i]=0;
  dp[0]=0;
  for(ll i=1;i<=k;i++){
    rep(j,n)if(i-a[j]>=0&&dp[i-a[j]]==0)dp[i]=1;
  }
  if(dp[k])cout<<"First"<<endl;
  else cout<<"Second"<<endl;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
int T[100000];
int k,n;
bool check(long long P)
{
    long long s = 0;
    int j = 0;
    for(int i=0; i<k; i++)
    {
        while(s + T[j] <= P)
        {
            s += T[j++];
            if(j == n)
                return true;
        }
        s = 0;
    }
    return j >= n;

}

int solve()
{
    long long right = n * 10000;
    long long left = 0;
    long long mid;
    while(right - left > 1)
    {
        mid = (right + left) / 2;
        if(check(mid))
            right = mid;
        else
            left = mid;

    }
    return right;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=0; i<n; i++)
        scanf("%d",&T[i]);
    printf("%d\n",solve());

    return 0;
}



Measured memory_bytes: 3124
n = int(input())
h = list(map(int,input().split()))
h.append(0)
cnt = 0
while h != [0]*(n+1):
  for i in range(n):
    if (h[i] != 0) and (h[i+1] == 0):
      h[i] -= 1
      cnt += 1
    elif h[i] != 0:
      h[i] -= 1
else:
  print(cnt)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
 
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;
 
const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;
 
const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main() {
    LL N, b, r;
    cin >> N >> b >> r;
    LL cnt = N / (b + r);
    LL cnt2 = N % (b + r);
    LL ans = cnt * b + min(cnt2, b);
    cout << ans << endl;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
int a[52], b[52];

bool available[52];

bool g[52][52];

bool check(){
  REP(i,52)REP(j,52)g[i][j] = false;
  REP(i,52)g[i][i] = true;
  REP(i,51)REP(j,51){
    FOR(k,1,51)if(available[k]){
      if(i%k == j){
        g[i][j] = true;
      }
    }
  }
  REP(k,52)REP(i,52)REP(j,52)g[i][j] = g[i][j] || (g[i][k] && g[k][j]);
  // REP(i,21){REP(j,21)printf("%d",g[i][j]);puts("");}puts("");
  REP(i,n)if(!g[a[i]][b[i]])return false;
  return true;
}

int main(){
  scanf("%d",&n);
  REP(i,n)scanf("%d",a+i);
  REP(i,n)scanf("%d",b+i);
  int maxval = 252521;
  FOR(i,1,51){
    available[i] = true;
    if(check()){
      maxval = i;
      break;
    }
  }
  if(maxval==252521){
    puts("-1");
    return 0;
  }
  FORR(i,1,maxval+1){
    available[i] = false;
    if(!check()){
      available[i] = true;
    }
  }
  ll ans = 0;
  FOR(i,1,maxval+1)if(available[i]){
    ans += 1ll<<i;
  }
  printf("%lld\n",ans);
  return 0;
}


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

int min(int A,int B){
    return A<B?A:B;
}

int main(void){
    int n,m,c,ans=0;
    scanf("%d%d%d",&n,&m,&c);
    int b[m];
    for (int i=0; i<m; i++){
        scanf("%d",&b[i]);
    }
    for (int i=0; i<n; i++){
        int a[m];
        for (int j=0; j<m; j++){
            scanf("%d",&a[j]);
        }
        int count=0;
        for (int j=0; j<m; j++){
            count+=a[j]*b[j];
        }
        if (count+c>0){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0 ;
}

Measured memory_bytes: 128