akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <string>
#include <algorithm>
#include <string.h>
#include <ctype.h>
#include <math.h>
#include <float.h>
#include <iomanip>
#include <iostream>
using namespace std;
 
int gcd(int x,int y){
    if(y==0)return x;

    return gcd(y,x%y);
}
int lcm(int x,int y){
    return x*y/gcd(x,y);
}

int main(){

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

    sort(N,N+4);
//1974
    if(N[0]==1
    &&N[1]==4
    &&N[2]==7
    &&N[3]==9){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }


    return 0;
}

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

using namespace std;
using ll = long long;
const int mod = 1e9 + 7;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }

    mint &operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }

    mint operator+(const mint a) const { return mint(*this) += a; }

    mint operator-(const mint a) const { return mint(*this) -= a; }

    mint operator*(const mint a) const { return mint(*this) *= a; }

    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }

    mint &operator/=(const mint a) { return *this *= a.inv(); }

    mint operator/(const mint a) const { return mint(*this) /= a; }
};

istream &operator>>(istream &is, const mint &a) { return is >> a.x; }

ostream &operator<<(ostream &os, const mint &a) { return os << a.x; }

struct combination {
    vector<mint> fact, ifact;

    combination(int n) : fact(n + 1), ifact(n + 1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
    }

    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n - k];
    }
};

struct UnionFind {
    vector<int> d;

    UnionFind(int n = 0) : d(n, -1) {}

    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }

    bool unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }

    bool same(int x, int y) { return find(x) == find(y); }

    int size(int x) { return -d[find(x)]; }
};

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

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


int main() {
    ll a;
    double b;
    cin >> a >> b;
    ll k = b * 100 + 1e-9;
    cout << ll(a * k / 100) << endl;
    return 0;
}


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

using namespace std;

#define ll long long
#define INF (ll)1e18
#define SINF (ll)1e9

int main()
{
    int N;
    cin >> N;
    ll mul = 1;
    vector<ll> vll(N);
    for (int i = 0; i < N; i++)
    {
        ll A;
        cin >> A;
        if (A == 0)
        {
            cout << 0 << endl;
            return 0;
        }
        vll[i] = A;
    }

    for(int i=0;i<N;i++){
        if(mul > INF / vll[i]){
            cout << -1 << endl;
            return 0;
        }else{
            mul *= vll[i];
        }
    }

    cout << mul << endl;
    return 0;
}

Measured memory_bytes: 4036
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  vector<int> ABC(3);
  cin >> ABC[0] >> ABC[1] >> ABC[2];

  sort(ABC.begin(), ABC.end());

  cout << ABC[0] + ABC[1] +(ABC[2] * 10) << endl;
 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string str; int min = INT_MAX;
	cin>>str;
	for(int i = 0; i<str.length()-2; i++){
		int a = str[i]-48, b = str[i+1]-48, c = str[i+2]-48;
		//cout<<a<<b<<c<<endl;
		int nu = a*100+b*10+c;
		int diff = abs(753-nu);
		if(diff<min) min = diff;
		
	}
	cout<<min<<endl;
	return 0;
}

Measured memory_bytes: 256
N = [int(x) for x in input()]


def solve(N):
    # n円の場合、n+1円の場合
    # 繰り上げる方がいいのか繰り上げない方がいいのか判断している
    dp = 0, 1
    for n in N:
        # 繰り上げた方が小さいのか繰り上げない方が小さいのか
        a = min(dp[0] + n, dp[1] + 10 - n)
        # 一個下の位を繰り上げた場合に、今の位までにかかる枚数
        b = min(dp[0] + n + 1, dp[1] + 10 - (n + 1))
        dp = a, b
    return dp[0]


print(solve(N))


Measured memory_bytes: 14700
#include <iostream>
#include <string>
#include <map>
#include <cstdint>

int main()
{
	typedef std::map<char, std::uint32_t> RomanToInt;
	RomanToInt roman_map;
	roman_map.insert(std::make_pair('I', 1U));
	roman_map.insert(std::make_pair('V', 5U));
	roman_map.insert(std::make_pair('X', 10U));
	roman_map.insert(std::make_pair('L', 50U));
	roman_map.insert(std::make_pair('C', 100U));
	roman_map.insert(std::make_pair('D', 500U));
	roman_map.insert(std::make_pair('M', 1000U));

	std::string input;
	while (std::getline(std::cin, input)) {
		std::uint32_t value = 0;
		bool prev_minus = false;
		for (std::uint32_t i = 0; i < input.size(); ++i) {
			std::uint32_t num = roman_map[input[i]];
			if ((not prev_minus) and (i + 1 < input.size())) {
				if (num < roman_map[input[i + 1]]) {
					num = -num;
					prev_minus = true;
				}
			}
			else {
				prev_minus = false;
			}
			value += num;
		}
		std::cout << value << std::endl;
	}

	return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<string>
#include<algorithm>
#include<math.h>
#include<set>
using namespace std;

const int N=1e5+5;
struct node
{
	int a,b,c;
};
node que[N];
int n,x,y,z;
long long pre[N],suf[N];
multiset<pair<int,pair<int,int> > > S;

bool cmp(node x,node y)
{
	if(x.a-x.b!=y.a-y.b) return x.a-x.b>y.a-y.b;
	return x.a>y.a;
}

void init()
{
	scanf("%d%d%d",&x,&y,&z);n=x+y+z;int i;
	for(i=1;i<=n;++i) scanf("%d%d%d",&que[i].a,&que[i].b,&que[i].c);
	sort(que+1,que+n+1,cmp);
}

void prework_pre()
{
	int i;
	for(i=1;i<=x;++i) S.insert(make_pair(que[i].a-que[i].c,make_pair(que[i].a,que[i].c))),pre[x]+=que[i].a;
	for(i=x+1;i<=n-y;++i)
	{
		pair<int,pair<int,int> > xx=*S.begin();
		pre[i]=pre[i-1];
		if(que[i].a-que[i].c>xx.first)
		{
			pre[i]-=xx.second.first;
			pre[i]+=xx.second.second;
			pre[i]+=que[i].a;
			S.erase(S.find(xx));
			S.insert(make_pair(que[i].a-que[i].c,make_pair(que[i].a,que[i].c)));
		}
		else pre[i]+=que[i].c;
	}
}

void prework_suf()
{
	S.clear();int i;
	for(i=n;i>n-y;--i) S.insert(make_pair(que[i].b-que[i].c,make_pair(que[i].b,que[i].c))),suf[n-y+1]+=que[i].b;
	for(i=n-y;i>x;--i)
	{
		pair<int,pair<int,int> > xx=*S.begin();
		suf[i]=suf[i+1];
		if(que[i].b-que[i].c>xx.first)
		{
			suf[i]-=xx.second.first;
			suf[i]+=xx.second.second;
			suf[i]+=que[i].b;
			S.erase(S.find(xx));
			S.insert(make_pair(que[i].b-que[i].c,make_pair(que[i].b,que[i].c)));
		}
		else suf[i]+=que[i].c;
	}
}

void work()
{
	int i;long long ans=0;
	for(i=x;i<=n-y;++i) ans=max(ans,pre[i]+suf[i+1]);
	printf("%lld\n",ans);
	
}

int main()
{
	init();prework_pre();prework_suf();work();
	return 0;
}

Measured memory_bytes: 7424
#include<stdio.h>
int main(void){
  char s[4];
  int i;
  int a=0,b=0,c=0;
  
  scanf("%s",s);
  for(i=0;i<3;i++){
    if(s[i]=='a') a=1;
    if(s[i]=='b') b=1;
    if(s[i]=='c') c=1;
  }
  if(a==1 && b==1 && c==1){
    printf("Yes");
  }else printf("No");
   
  return 0;
  
}

Measured memory_bytes: 128
#![allow(unused_imports, unused_variables, dead_code)]
use std::io::*;
use std::fmt::*;
use std::str::*;
use std::cmp::*;
use std::collections::*;

trait InputValue {
    fn parse(s: &str) -> Self;
}

fn read<T: InputValue>() -> T {
    let mut buf = String::new();
    let _ = stdin().read_line(&mut buf);
    T::parse(&buf.trim())
}

fn readnc<T: InputValue>() -> Vec<T> {
    let mut vec = vec![];
    let line: String = read();
    for token in line.split_whitespace() {
        vec.push(T::parse(token));
    }
    vec
}

fn readn<T: InputValue>(n: usize) -> Vec<T> {
    let mut vec = vec![];
    for _ in 0..n {
        vec.push(read());
    }
    vec
}

macro_rules! parse_single_value {
    ($($t:ty),*) => {
        $(
            impl InputValue for $t {
                fn parse(s: &str) -> $t { s.parse().unwrap() }
            }
        )*
	}
}
parse_single_value!(i32, i64, f32, f64, usize, String);

macro_rules! parse_tuple {
	($($t:ident),*) => {
		impl<$($t),*> InputValue for ($($t),*) where $($t: InputValue),* {
			fn parse(s: &str) -> ($($t),*) {
				let mut tokens = s.split_whitespace();
				let t = ($($t::parse(tokens.next().unwrap())),*);
				t
			}
		}
	}
}
parse_tuple!(A, B);
parse_tuple!(A, B, C);

// ===

fn main() {
    let n: usize = read();
    let q: Vec<(usize, usize)> = readn(n);

    let mut a = q[0].0;
    let mut b = q[0].1;
    for i in 1..n {
        let mul = max((a + q[i].0 - 1) / q[i].0, (b + q[i].1 - 1) / q[i].1);
        a = q[i].0 * mul;
        b = q[i].1 * mul;
    }
    println!("{}", a + b);
}



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

typedef long long lint;
#define fint register int
#define flint register lint

inline int ty()
{
	register int a=0,b=1,c=getchar();
	while(!isdigit(c))b^=c=='-',c=getchar();
	while(isdigit(c))a=a*10+c-48,c=getchar();
	return b?a:-a;
}

const int _ = 200007 , _e = 999999;

struct edges
{
	int a,b,v;
	edges(int _a=0,int _b=0,int _v=0)
	{
		a=_a,b=_b,v=_v;
	}
	inline friend int operator < (edges a,edges b)
	{
		return a.v<b.v;
	}
}e[_e];
int ecnt=0;
inline void adde(int a,int b,int c)
{
	e[++ecnt]=edges(a,b,c);
}

int bfa[_];
inline int findbfa(int x)
{
	return bfa[x]==x?x:bfa[x]=findbfa(bfa[x]);
}
inline void link(int a,int b)
{
	a=findbfa(a),b=findbfa(b);
	if(a==b)return;
	bfa[a]=b;
}

int n,qq;

lint kuro()
{
	sort(e+1,e+ecnt+1);
	for(fint i=0;i<n;i++)bfa[i]=i;
	flint ans=0;
	for(fint i=1;i<=ecnt;i++)
	{
		fint a=e[i].a,b=e[i].b,c=e[i].v;
		if(findbfa(a)==findbfa(b))continue;
		link(a,b),ans+=c;
	}
	return ans;
}

int midis[_];

int main()
{
	memset(midis,63,sizeof(midis));
	
	n=ty(),qq=ty();
	for(fint i=1;i<=qq;i++)
	{
		fint a=ty(),b=ty(),c=ty();
		midis[(a+1)%n]=min(midis[(a+1)%n],c+1);
		midis[(b+1)%n]=min(midis[(b+1)%n],c+2);
		e[++ecnt]=edges(a,b,c);
	}

	for(fint i=0;i<n+n+n;i++)
	{
		fint a=i%n;
		midis[a]=min(midis[a],midis[(a-1+n)%n]+2);
	}

	for(fint i=0;i<n;i++)e[++ecnt]=edges((i-1+n)%n,i,midis[i]);

	printf("%lld\n",kuro());

	return 0;
}


Measured memory_bytes: 15360
#include<cstdio>
//#include<iostream>
#include<climits>
using namespace std;
#define MAX 500000
int cnt = 0;
int A[MAX], L[MAX/2 + 2], R[MAX/2 + 2];
void Merge(int A[], int left, int mid, int right)
{
  int n1 = mid - left;
  int n2 = right - mid;
  for(int i=0; i<n1; i++)
  {
    L[i] = A[left+i]; //from left to mid-1
  }
  for(int i=0; i<n2; i++)
  {
    R[i] = A[mid+i];// from mid to right-1
  }
  L[n1] = INT_MAX;
  R[n2] = INT_MAX;
  int i = 0, j = 0;
  for(int k=left; k<right; k++)
  {
    cnt++;
    if(L[i] <= R[j])
    {
      A[k] = L[i];
      i++;
    }
    else
    {
      A[k] = R[j];
      j++;
    }
  }
}

void MergeSort(int A[], int left, int right)
{
  if(left + 1 < right)
  {
    int mid = (left+right)/2 ;
    MergeSort(A, left, mid);
    MergeSort(A, mid, right);
    Merge(A,left, mid, right);
  }
}
int main()
{
  int n;
  scanf("%d", &n);
  for(int i=0; i<n; i++)
  {
    scanf("%d", &A[i]);
  }
  MergeSort(A, 0, n);
  for(int i=0; i<n; i++)
  {
    if(i) printf(" ");
    printf("%d", A[i]);
  }
  printf("\n%d\n", cnt);

  return 0;
}



Measured memory_bytes: 6460
#include <iostream>
#include <string>
#include <cstdio>

int main()
{
    const int MAXTOWN = 20;

    int number_town;//????????????
    int number_way;//????????°
    int min_cost[MAXTOWN + 1][MAXTOWN + 1];//i????????????j??????????§?????????????????????????????????????????´?

    for (int i = 0; i <= MAXTOWN; i++) {
        for (int j = 0; j <= MAXTOWN; j++) {
            min_cost[i][j] = 999999;//??¨????????§???????????§????????????
        }
    }

    std::cin >> number_town;//????????°????????±???????????????
    std::cin >> number_way;//????????°????????±???????????????

    for (int way = 0; way < number_way; way++) {//??????????????????????§??????????????????????????????????
        int from_way, to_way, cost, back_cost;
        scanf("%d, %d, %d, %d", &from_way, &to_way, &cost, &back_cost);

        min_cost[from_way][to_way] = cost;
        min_cost[to_way][from_way] = back_cost;
    }   

    for (int medium_town = 1; medium_town <= number_town; medium_town++) {//??????????????±????????????????????????????????????????????§?????????
        for (int start_town = 1; start_town <= number_town; start_town++) {
            for (int end_town = 1; end_town <= number_town; end_town++) {
                int start_medium_end_long = min_cost[start_town][medium_town] + min_cost[medium_town][end_town];
                if (min_cost[start_town][end_town] > start_medium_end_long) {//??????????????±????????????????????´???
                    min_cost[start_town][end_town] = start_medium_end_long;
                }   
            }
        }
    }

    int start_town, end_town;
    int get_money, lost_money;
    scanf("%d, %d, %d, %d", &start_town, &end_town, &get_money, &lost_money);//????????????????????????????????????????????????
    int profit;
    //?????????????????\?????£????????????????????????
    profit = get_money - lost_money - min_cost[start_town][end_town] - min_cost[end_town][start_town];

    std::cout << profit << std::endl;
    return 0;
}

Measured memory_bytes: 1240
#include<bits/stdc++.h>
using namespace std;
#define ll                 long long
#define ff                 first
#define ss                 second
#define mp                 make_pair
#define pb                 push_back
#define io                 ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pie                acos(-1)
#define loop(i,a,n)        for(ll i=a;i<n;i++)
#define vi                 vector<int>
#define vl                 vector<ll>
#define vvi                vector<vector<int>>
#define pll                pair<ll,ll>
#define pii                pair<int,int>
#define vpi                vector<pii>
#define vpl                vector<pll>
#define endl               "\n"
#define se(x)              cout<<#x<<" " <<x<<endl;
#define see(x,y)           cout<<#x<<" " <<x<<" "<<#y<<" "<<y<<endl;
#define seee(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define all(v)             v.begin(),v.end()
#define scan(a,n)          loop(i,0,n)cin>>a[i];
#define sig                exit(0);  
#define flush              fflush(stdout);
#define present(a,b)       a.find(b)!=a.end()        
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
const int e = 100005;
const ll INF = 9e18+5;
const ll M = 1e9+7;
vector<ll>fact;
vector<ll>invfact;
template<typename T>void show(T &a , int n)
{
    loop(i,0,n)
        cout<<a[i]<<" ";
    cout<<endl;
}
template<typename T>void mod(T& a , T b)
{
    a = (a%b+b)%b;
}
template<typename T> T mpow(T a , T b)
{
    T ans = 1;
    while(b)
    {
        if(b&1)
        ans = ans*a;
        mod(ans,(T)M);
        a = a*a;
        mod(a,(T)M);
        b>>=1;
    }
    mod(ans,(T)M);
    return ans;
}
template<typename T> T modinv(T a)
{
    return mpow(a,(T)M-2);
}
void factorial()
{
    fact.resize(e);
    invfact.resize(e);
    fact[0] = 1;
    invfact[0] = 1;
    loop(i,1,e)
    {
        fact[i] = fact[i-1]*i;
        mod(fact[i],M);
    }
    loop(i,1,e)
    {
        invfact[i] = modinv(fact[i]);
        mod(invfact[i],M);
    }
}
ll ncr(ll n , ll r)
{
    ll ans ;
    ans = fact[n]*invfact[n-r];
    mod(ans,M);
    ans = ans*invfact[r];
    mod(ans,M);
    return ans;
}
void solve();
void pre();
int main() {
	// your code goes here
	io;
	int t  =1;;
	//cin>>t;
	while(t--)
    solve();
	return 0;
}
void pre()
{
    //initialize properly before each testcase
    // change value of e always as per the constraints
    // overflow
}

//Solution starts here;
void solve()
{
    pre();
    vi a(5);
    scan(a,5);
    loop(i,0,5)
    {
        if(a[i]==0)
        cout<<i+1<<endl;
    }
}


Measured memory_bytes: 3612
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las



main = do
    (a, b) <- readTuple2
    let aFilter = (== a) . floor . (*0.08) . fromIntegral
    let bFilter = (== b) . floor . (*0.1) . fromIntegral
    let lst = filter aFilter . filter bFilter $ [1..2000]
    case lst of
        [] -> putStrLn "-1"
        a:ax -> print a




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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
ld pi = acos(-1);

int main()
{

    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

    ll n , m , sum=0;
    cin >> n >> m;
    for(int i=1; i<=m; i++)
    {
        ll x;
        cin >> x;
        sum += x;
    }
    if (sum > n) cout << "-1\n";
    else cout << n-sum << '\n';



    return 0;
}

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll (x);cin >>(x);
#define stin(x) str (x);cin >>(x);
#define vllin(x,n) vll (x)(n);FOR(i,0,n-1){cin >>(x)[i];}
#define vllin2(a,b,n) vll (a)(n);vll (b)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vllin3(a,b,c,n) vll (a)(n);vll (b)(n);vll (c)(n);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >>(x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >>(a)[i]>>(b)[i]>>(c)[i];}
#define vpl4in(x,n) vpl4 (x)((n),mp(0,0));FOR(i,0,n-1){cin >>x[i].fi>>x[i].se;}
#define FOR(i,a,b) for(ll i = a ; i <= b ; i++)
#define rFOR(i,b,a) for(ll i = a; i >= b ; i--)
#define SORT(x) sort(x.be, x.en)
#define rSORT(x) sort(x.rbegin(), x.rend())
#define say(x) cout<<(x);
#define sal(x) cout<<(x)<<endl;
#define says(x) cout<<(x)<<(' ');
#define sas cout<<(' ');
#define sayR(x) cout<<fixed<<setprecision(10)<<(x);
#define salR(x) cout<<fixed<<setprecision(10)<<(x)<<endl;
#define yn(a) cout <<((a)?"yes":"no")<<endl;
#define Yn(a) cout <<((a)?"Yes":"No")<<endl;
#define YN(a) cout <<((a)?"YES":"NO")<<endl;
#define Imp(a) cout <<((a)?"Possible":"Impossible")<<endl;
#define IMP(a) cout <<((a)?"POSSIBLE":"IMPOSSIBLE")<<endl;
#define pow(a,b) ll(pow(a,b))

ll MOD=1000000007;

signed main(){
    stin(s);
    if(s[0]=='S') sal("Cloudy")
    if(s[0]=='C') sal("Rainy")
    if(s[0]=='R') sal("Sunny")
}


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

int main() {

    ll N;
    cin >> N;

    ll MOD = 1e9 + 7;
    ll a = 1;
    ll b = MOD - 1;
    ll c = 1;

    rep(i, N) {
        a = (a*10) % MOD;
        b = (b*9) % MOD;
        c = (c*8) % MOD;
    }

    ll ans = (a + 2*b + c) % MOD;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#n=int(input())
a,b=map(int,input().split())
#l=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]
ans=a-1
for day in range(1,b+1):
    if a==day :
        ans+=1
print(ans)




Measured memory_bytes: 9132
N,M,X,Y=list(map(int,input().split()))
x=list(map(int,input().split()))
y=list(map(int,input().split()))

a=max(x)+1
b=min(y)

def judge(a,b):
    if(a>b):
        return print("War")
    else:
        z=range(a,b+1)
        for i in z:
            if(i>X and i<=Y):
                return print("No War")
        else:
            return print("War")
        
judge(a,b)

Measured memory_bytes: 3064
/*
AuThOr Gwj
*/
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define LL long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n;
const int MAXN=1<<18;
int v[MAXN],w[MAXN],q;
int f[1<<9][100000+1];
void calc(int now,int depth){
//	cout<<"MM"<<now<<endl; 
	if(now>n||depth>9){
		return;
	} 
//	cout<<"MM"<<now<<endl;
	rb(i,0,100000)
		f[now][i]=f[now>>1][i];
	rl(i,100000,w[now])
		f[now][i]=max(f[now][i],f[now][i-w[now]]+v[now]);
	calc(now<<1,depth+1);
	calc((now<<1)+1,depth+1);
}
int main(){
	fastio;
	cin>>n;
	rb(i,1,n) cin>>v[i]>>w[i];
	calc(1,1);
	cin>>q;
	const int bound=(1<<9)-1;
//	bound;
	rb(i,1,q){
		int V,l;
		cin>>V>>l;
		if(V<=bound){
			int res=f[V][l];
			cout<<res<<endl;
		}
		else{
			int res=0;
			vector<int> ve;
			ve.PB(V);
			V>>=1;
			while(V>bound){
				ve.PB(V);
				V>>=1;
			} 
			rep(mask,1<<(ve.size())){
				int tmp=0,tmp2=0;
				rep(j,ve.size()){
					if(mask&(1<<j)){
						tmp+=w[ve[j]];
						tmp2+=v[ve[j]];
					}
				}
				if(tmp<=l){
					res=max(res,f[V][l-tmp]+tmp2);
				}
			}
			cout<<res<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 205316
from collections import defaultdict

N = int(input())
S = defaultdict(int)
for n in range(N):
  key = input()
  S[key] += 1

  
M = int(input())
T = defaultdict(int)
for n in range(M):
  key = input()
  T[key] += 1

ans = 0
## 青いカードにカウントされているカードごとに計算する
for key in S:
  if key in T:
    _ = S[key] - T[key]
  else:
    _ = S[key]
  
  ans = max(ans,_)

print(ans)

Measured memory_bytes: 3316
#include <iostream>
#include <vector>
#include <array>
#include <set>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
typedef long long ll;
using namespace std;
int main() {
    // input
    int h, w, n; cin >> h >> w >> n;
    vector<int> a(n), b(n); repeat (i,n) { cin >> a[i] >> b[i]; -- a[i]; -- b[i]; }
    // compute
    set<pair<int,int> > exists;
    repeat (i,n) exists.emplace(a[i], b[i]);
    set<pair<int,int> > used;
    auto is_on_field = [&](int y, int x) { return 0 <= y and y <= h-3 and 0 <= x and x <= w-3; };
    array<ll,10> ans = {};
    ans[0] = (h-2) *(ll) (w-2);
    repeat (i,n) {
        for (int dy : { -2, -1, 0 }) {
            for (int dx : { -2, -1, 0 }) {
                int y = a[i] + dy;
                int x = b[i] + dx;
                if (is_on_field(y, x) and not used.count(make_pair(y, x))) {
                    int cnt = 0;
                    used.emplace(y, x);
                    for (int dy2 : { 0, 1, 2 }) {
                        for (int dx2 : { 0, 1, 2 }) {
                            int y2 = y + dy2;
                            int x2 = x + dx2;
                            cnt += exists.count(make_pair(y2, x2));
                        }
                    }
                    if (cnt) {
                        ans[cnt] += 1;
                        ans[0] -= 1;
                    }
                }
            }
        }
    }
    // output
    repeat (i,10) cout << ans[i] << endl;
    return 0;
}


Measured memory_bytes: 47872
#include<bits/stdc++.h>
using namespace std;
char s[128];
int main()
{
    int i,cnt=0;
    scanf("%s",s);
    int l=strlen(s);
    for(i=0;i<l;i++)
    {
    	if(s[i]!=s[l-1-i])
    		cnt++;
	}
	cout<<cnt/2;
    return 0;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
	val input = (readLine() ?: return).split(" ").map { it.toInt() }.toIntArray()
	if (input[0] <= input[1] && input[0] <= input[2] && input[1] >= input[2]) println("Yes")
	else if (input[0] >= input[1] && input[0] >= input[2] && input[1] <= input[2]) println("Yes")
	else println("No")
}

Measured memory_bytes: 36036
#include <stdio.h>

int main(void) {
	int n,i,a[100];

	scanf("%d",&n);

	for(i=1;i<=n;i++){
		scanf("%d",&a[i]);
	}
	for(i=n;i>=1;i--){
		printf("%d",a[i]);
		if(i!=1){
			printf(" ");
		}
		else{
			printf("\n");
		}

	}
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cmath>
#include <functional>
#include <queue>
//#include <stack>
#include <climits>
#include <map>
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<endl;
#define all(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
using namespace std;
typedef long long ll;
//typedef unsigned long long ull;
typedef pair<int, int> P;

class modulo{
public:
    //x,y,mod>0を想定している
    ll x,y,mod;
    vector<ll> factable = {1};
    vector<ll> invtable = {1};
    ll pro(ll x,ll y){
        return ((x%mod)*(y%mod))%mod;
    }
    ll sum(ll x,ll y){
        return ((x%mod)+(y%mod))%mod;
    }
    ll dif(ll x,ll y){
        ll d =((x%mod)-(y%mod))%mod;
        if(d>=0)return d;
        else return d+mod;
    }
    ll pow(ll x,ll y){
        //x^y mod mod
        if(y<=0)return 1;
        if(y%2==0){
            ll d = pow(x,y/2);
            return ((d%mod)*(d%mod))%mod;
        }else{
            return (x*pow(x,y-1))%mod;
        }
    }
    ll quo(ll x, ll y){
        //x/y mod mod =x*y^(mod-2) mod mod
        return pro(x,pow(y,mod-2));
    }
    ll fac(ll x){
        //x! mod mod
        if(factable.size()<=x){
            ll s = factable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return factable[x];
    }
    ll facinv(ll x){
        if(invtable.size()<=x){
            ll s = invtable.size();
            FOR(i,s,x+1){
                factable.push_back(pro(i,factable.back()));
                invtable.push_back(quo(1,factable.back()));
            }
        }
        if(x<0) return 1;
        else return invtable[x];
    }
    ll com(ll x,ll y){
        //xCy mod mod = x!/((x-y)!*y!) mod mod
        if(x-y<y)return com(x,x-y);
        return pro(fac(x),pro(facinv(x-y),facinv(y)));
    }
};

ll w,h,a,b;

int main() {
    cin >> h >> w >> a >> b;
    modulo m;
    m.mod = 1e9+7;
    ll res = 0;
    FOR(i,1,h-a+1){
        res = m.sum(res,m.pro(m.com(b+i-2,i-1),m.com(w-b+h-i+1-2,h-i+1-1)));
    }
    put(res);
    return 0;
}




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

typedef long long ll;
int n,a[21],m=0;
ll p=1e9+7,d[21][(1<<21)],z=1;

ll f(int v, int s){
    if(v==n-m)return z;
    int k=a[v]&s;
    if(d[v][s]!=-1)return d[v][s];
    d[v][s]=0;
    for(int i=0;i<n;i++){
        if(((k>>i)&1)==1){
            if(v==n-1)d[v][s]++;
            else d[v][s]+=f(v+1, s-(1<<i));
        }
    }
    return d[v][s]%=p;
}

int main(void){
    cin>>n;
    for(int i=0;i<n;i++){
        a[i]=0;
        for(int j=0;j<n;j++){
            int b;
            cin>>b;
            a[i]+=(b<<j);
        }
        fill(d[i], d[i]+(1<<21), -1);
        if(a[i]==(1<<n)-1){
            m++;
            z=(z*(ll)m)%p;
        }
    }
    sort(a, a+n);
    ll ans=f(0, (1<<n)-1);
    cout<<ans<<endl;
}


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

using namespace std;

#define INF LLONG_MAX
typedef long long ll;

int M, N;
vector<ll> tw, tt;
vector<ll> c, b;

void init()
{
    tw.resize(M+2); tt.resize(M+2);
    tw[0] = tt[0] = 0;
    tw[M+1] = tt[M+1] = INF;
    c.resize(N); b.resize(N);
}

int solve()
{
    int dp[1<<15];
    memset(dp, -1, sizeof(dp));
    dp[0] = 0;
    
    for (int i = 0; i < (1<<N); i++) {
        if (dp[i] == -1) continue;        
        for (int j = 0; j < N; j++) {
            if (i >> j & 1) continue;                        
            int ni = i | (1<<j);
            int p1 = upper_bound(tw.begin() + dp[i], tw.end(), c[j] + tw[dp[i]]) - (tw.begin()) - 1;
            int p2 = upper_bound(tt.begin() + dp[i], tt.end(), b[j] + tt[dp[i]]) - (tt.begin()) - 1;
            dp[ni] = max(dp[ni], min(p1, p2));
        }
    }

    return dp[(1<<N)-1];
}

int main()
{    
    cin >> M >> N;
    init();
    for (int i = 1; i <= M; i++) {
        cin >> tw[i] >> tt[i];
        tw[i] += tw[i-1];
        tt[i] += tt[i-1];
    }    
    for (int i = 0; i < N; i++) {
        cin >> c[i] >> b[i];
    }
    cout << solve() << endl;
    return 0;
}

Measured memory_bytes: 4440
#include <cstdio>
#include <iostream>

using namespace std;

unsigned long long fac(int n) {
	if (n == 1 || n == 0) return 1;
	return fac(n - 1) * n;
}

int main() {
	int n;
	while (~scanf("%d", &n)) {
		printf ("%llu\n", fac(n));
	}
	return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<algorithm>
#include<list>
#include<cmath>
#include<iomanip>
#include<queue>
#include<functional>
#include<climits>
#include<iterator>
#include<unordered_set>
#include<unordered_map>
using namespace std;

const double pi=4*atan(1.0);

long long func(long long b,long long n){
	return n<b ? n : func(b,n/b)+n%b;
}

int main() {
	long long n,s;
	long long ans=0;
	cin>>n>>s;

	if(n==s)cout<<n+1<<endl;
	else if(n<s)cout<<-1<<endl;
	else{
		for(long long i=2;i<sqrt(n)+1;++i){
			if(s==func(i,n)){
				ans=i;
				break;
			}
		}

		if(ans==0){
			for(long long p=sqrt(n)+1;p>0;--p){
				if((n-s)%p==0){
					long long tmp=(n-s)/p+1;
					if(s==func(tmp,n)){
						ans=tmp;
						break;
					}
				}
			}
		}

		if(ans>0)cout<<ans<<endl;
		else cout<<-1<<endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
int main(){
    int h,w,c[10][10],A[200][200],dp[10];
    cin>>h>>w;
    ll ans=0;
    rep(i,10)rep(j,10) cin>>c[i][j];
    rep(i,h)rep(j,w) cin>>A[i][j];
    rep(i,10) dp[i]=c[i][1];
    rep(i,100)rep(j,10)rep(k,10) dp[j]=min(dp[j],dp[k]+c[j][k]);
    rep(i,h)rep(j,w) if(A[i][j]>=0) ans+=dp[A[i][j]];
    cout<<ans;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
template <class T> void chmax(T &x, T y) { if (x < y) x = y; }
int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> dp(N + 1), zeros;
    for (int i = 0; i < N; i++) {
        int zs = zeros.size();
        chmax(dp[i + 1], dp[i]);
        if (S[i] == '1') {
            // 111110[1]
            if (!zeros.empty() && zeros[zs - 1] == i - 1) {
                for (int j = i - 2; j >= 0 && S[j] == '1'; j--) {
                    chmax(dp[i + 1], dp[j] + i - j - 1);
                }
            }
            // 101111[1]
            if ((zs == 1 && zeros[zs - 1] != 0) ||
                (zs >= 2 && zeros[zs - 1] - 1 != zeros[zs - 2])) {
                chmax(dp[i + 1], dp[zeros[zs - 1] - 1] + i - zeros[zs - 1]);
            }
        } else {
            zeros.push_back(i);
        }
    }
    cout << dp[N] << '\n';
    return 0;
}


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

namespace
{
int iCntN[ 60 ];
}

int main( int argc, char *argv[] )
{
int i;
int N;
int M;
int a;
int b;

	cin >> N;
	cin >> M;
	for( i = 0; i < M; i++ )
	{
		cin >> a;
		cin >> b;
		iCntN[ a ]++;
		iCntN[ b ]++;
	}

	for( i = 1; i <= N; i++ )
		cout << iCntN[ i ] << endl;

	return 0;
}






Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int t = cin.Int();
			var a = cin.ArrayLong(n);
			long min = a[0];
			int minCount = 0;
			int maxCount = 0;
			long dif = 0;
			int ans = n - 1;
			bool first = true;
			int tempMinCount = 0;
			for (int i = 1; i < n; i++) {
				if (a[i] < min) {
					min = a[i];
					tempMinCount = 1;
					first = true;
				} else if (a[i] == min) {
					if (first) {
						++tempMinCount;
					} else {
						++minCount;
					}
				} else {
					if (a[i] - min > dif) {
						dif = a[i] - min;
						maxCount = 1;
						minCount = 1;
					} else if(a[i] - min == dif) {
						if (first) {
							minCount += tempMinCount;
							first = false;
						}
						++maxCount;
					}
				}
			}

			ans = Math.Min(ans, Math.Min(minCount, maxCount));
			Console.WriteLine(ans);
		}
	}

	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 20960
x=int(input())

if 400<=x<=599:
    a=8
elif 600<=x<=799:
    a=7
elif 800 <= x <= 999:
    a = 6
elif 1000 <= x <= 1199:
    a = 5
elif 1200 <= x <= 1399:
    a = 4
elif 1400 <= x <= 1599:
    a = 3
elif 1600 <= x <= 1799:
    a = 2
elif 1800 <= x <= 1999:
    a = 1

print(a)

Measured memory_bytes: 61840
a, b, k = map(int, input().split())
if a - k > 0:
    c = a - k
elif a - k <= 0:
    c = 0
    if b - (k - a) > 0:
        b -= (k - a)
    elif b - (k - a) <= 0:
        b = 0
print(c, b)

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<utility>
#include<array>
#include<cassert>
#include<list>
#include<experimental/any>
#include<cstring>
#include<cctype>
#include<ctime>
#include<cstdbool>
#include<cstdint>
#include<cstddef>
#include<set>
#include<unordered_set>
#include<bitset>

using namespace std;
using experimental::any;

#define SPEEDY cin.tie(0);ios::sync_with_stdio(false);

#define REP(i,n) for(int i=0;i<(n);i++)
#define ARREP(i,n,X) for(int i=0;i<(n);i++)cin>>X[i]
#define FOR(i,X,n) for(int i=(X);i<(n);i++)
#define EREP(i,n) for(int i=1;i<=n;i++)

#define MODE 0
#define DEB(X) if(MODE)cout<< #X <<": "<<X<<" ";
#define DEB2(X) if(MODE)cout<<X<<" ";
#define ARDEB(i,X) if(MODE)cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define TFDEB(f) if(MODE){(f)? cout<<"true ":cout<<"false ";}
#define FORDEB(n,X) if(MODE)for(int i=0;i<(n);i++)ARDEB(i,X)
#define END if(MODE)cout<<endl;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
#define ALL(X) X.begin(),X.end()
struct edge{int to,cost;};
struct P2{int x,y;};
//struct edge{int from,cost,to;};
#define Endl endl

const int MOD7=1000000007;
const int INF=100000000;
const int SET=1000;

int main(){
	string s;
	int ans=0;
	cin>>s;
	REP(i,s.size()){
		if(s[i]=='1'){
			ans++;
		}
	}
	cout<<ans<<Endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
int main()
{
    int n, k;
    cin >> n >> k;
    int num = 1;
    rep(i, n)
    {
        // cout << num << endl;
        if (k < num)
        {
            num += k;
        }
        else
        {
            num *= 2;
        }
    }
    cout << num << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
#define cyes cout<<"YES"<<endl
#define cno cout<<"NO"<<endl
#define sp <<" "<<
#define CST(x) cout<<fixed<<setprecision(x)
#define PI 3.14159265359
#define MOD 1000000007
using namespace std;
using ll = long long;
using ld = long double;
using Graph = vector<vector<int>>;
using que_a = priority_queue<int, vector<int>, greater<int> >;
using que_d = priority_queue<int>;
using pint = pair<int,int>;

vector<int> dx = {1,0,-1,0};
vector<int> dy = {0,1,0,-1};
int h,w;
vector<string> fi(110);
vector<vector<int>> dist(110,vector<int>(110));


int main(){

    cin >> h >> w;
    int wnum = 0;
    rep(i,h){
        cin >> fi.at(i);
        rep(j,w) if(fi.at(i).at(j) == '.') wnum++;
    }
    rep(i,110) rep(j,110) dist.at(i).at(j) = -1;
    dist.at(0).at(0) = 0;

    queue<pint> que;

    que.push(pint(0,0)); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        pint cur = que.front(); // キューから先頭頂点を取り出す
        que.pop();
        int x = cur.first;
        int y = cur.second;
        // v から辿れる頂点をすべて調べる
        for (int dir = 0; dir < 4; dir++) {

            int nx = x + dx.at(dir);
            int ny = y + dy.at(dir);
            if(nx < 0 || nx >= h || ny < 0 || ny >= w) continue;

            if(fi.at(nx).at(ny) == '#') continue;

            if (dist.at(nx).at(ny) == -1){

                dist.at(nx).at(ny) = dist.at(x).at(y) + 1;
                que.push(pint(nx,ny));

            }

        }
    }
    int ans = dist.at(h-1).at(w-1) == -1 ? -1:wnum - dist.at(h-1).at(w-1) -1;
    cout << ans << endl;
 


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define MMP(a, b, c) make_pair(make_pair(a, b), c)
#define MAX 1000000000
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define PI 3.14159265359

int main(){
    iostream::sync_with_stdio(false);
    int M,N;
    cin >> M >> N;
    string S,T;
    cin >> S >> T;
    S += " "; T += " ";
    int dp[2002][2002][2] = {};//i番目、j番目以降のを全部使うとしたときの最長、先頭がIorO
    int ans = 0;
    for(int i=M; i>=0; i--){
        for(int j=N; j>=0; j--){
            if(S[i] == 'I') dp[i][j][0] = dp[i+1][j][1] + 1;
            if(T[j] == 'I') dp[i][j][0] = max(dp[i][j][0], dp[i][j+1][1] + 1);
            if(S[i] == 'O') dp[i][j][1] = dp[i+1][j][0] + 1;
            if(T[j] == 'O') dp[i][j][1] = max(dp[i][j][1], dp[i][j+1][0] + 1);
            ans = max(ans, dp[i][j][0]);
        }
    }
/*
    cout << endl;
    for(int i=0; i<=M; i++){
        for(int j=0; j<=N; j++){
            cout << dp[i][j][0] << "\t";
        }
        cout << endl;
    }
    cout << endl;
    for(int i=0; i<=M; i++){
        for(int j=0; j<=N; j++){
            cout << dp[i][j][1] << "\t";
        }
        cout << endl;
    }
    cout << endl;
*/
    if(ans > 0 && ans%2 == 0) ans--;
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 34552
A,B,C,D = map(int, input().split())

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a%b)

lcm=C*D//gcd(C,D)
con1=B//C - (A-1)//C
con2=B//D - (A-1)//D
con3=B//lcm - (A-1)//lcm

print(B-(A-1)-(con1+con2-con3))

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <utility>
#include <set>

using namespace std;
typedef long long lint;

string solve(const string& s, const int x, const int y) {
    const string yes = "Yes", no = "No";
    vector<vector<int> > moves(2);
    int axis = 0, cur = 0;
    for (const char c : s) {
        if (c == 'T') {
            moves[axis].push_back(cur);
            axis ^= 1;
            cur = 0;
        } else {
            cur += 1;
        }
    }
    moves[axis].push_back(cur);
    const vector<int> target = {x, y};
    for (int axis = 0; axis < 2; ++axis) {
        set<int> S;
        if (!axis) {
            S.insert(moves[axis][0]);
        } else {
            S.insert(0);
        }
        for (int i = (axis^1); i < moves[axis].size(); i++) {
            set<int> next;
            const int move = moves[axis][i];
            for (const int pos : S) {
                next.insert(pos + move);
                next.insert(pos - move);
            }
            S = next;
        }
        if (S.find(target[axis]) == S.end()) {
            return no;
        }
    }
    return yes;
}

int main() {
    string s;
    cin >> s;
    int x, y;
    cin >> x >> y;
    cout << solve(s, x, y) << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


int main(){
  int N, K, Q;
  cin >> N >> K >> Q;
  vector<int> v(N, K-Q);
  rep(i,Q){
    int a;
    cin >> a;
    a--;
    v[a]++;
  }

  rep(i,N){
    if(v[i]>0) cout << "Yes" << endl;
    else cout << "No" << endl;
  }
  
  return 0;
}



Measured memory_bytes: 1024
D, G = list(map(int, input().split()))
pc = [list(map(int, input().split())) for _ in range(D)]

ans = sum([i[0] for i in pc])

for i in range(2**D):
    search_index = format(i, '0' + str(D) + 'b')
    complete_answered = [i for i, c in enumerate(search_index[::-1]) if c == '1']
    incomplete_answered = list(set(range(D)) - set(complete_answered))
    answered_number = 0
    remaining_score = G
    for j in complete_answered:
        answered_number += pc[j][0]
        remaining_score -= (100 * (j + 1) * pc[j][0] + pc[j][1])
    incomplete_answered = sorted(incomplete_answered, reverse=True)
    for j in incomplete_answered:
        question_number = pc[j][0]
        while remaining_score > 0:
            answered_number += 1
            remaining_score -= 100 * (j + 1)
            question_number -= 1
            if question_number <= 0:
                remaining_score -= pc[j][1]
                break
    if answered_number < ans:
       ans = answered_number
print(ans)

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,a,b) for(ll i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()

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

    ll a = 0, b = 0, c = 0;
    rep(i, 0, s.size()){
        if(s[i] == 'a'){
            a++;
        }else if(s[i] == 'b'){
            b++;
        }else{
            c++;
        }
    }

    ll x = 0;
    x = min(min(a, b), c);
        if(a > x + 1){
            cout << "NO" << endl;
            return 0;
        }
        if(b > x + 1){
            cout << "NO" << endl;
            return 0;
        }
        if(c > x + 1){
            cout << "NO" << endl;
            return 0;
        }

    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 512