akhauriyash/Code-Regression huggingface dataset:
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <climits>
#include <cstdlib>
#include <vector>
#include <queue>
#include <unordered_map> 
#include <iomanip>
#include <random>
#include <future>
#include <thread>
#include <utility>
#include <set>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (INT_MAX/3)
#define INF_L (LLONG_MAX/3)
#define PSB push_back
#define PN 1000000007
typedef long long LL;
#define int long long


// booooooooooooost
// #include <boost/multiprecision/cpp_int.hpp>
// #include <boost/multiprecision/cpp_dec_float.hpp>
// namespace mp = boost::multiprecision;	//多倍長整数(mp::cpp_int), 多倍長小数(mp::cpp_dec_float_100)


signed main() {

	int N, M, K;
	cin >> N >> M >> K;
	vector<bool> ans;
	ans.assign(N * M + 1, false);

	for (int i = 0; i <= M; ++i) {
		for (int j = 0; j <= N; ++j) {
			int num = 0;
			num = N * i + M * j - i * j * 2;
			ans[num] = true;
		}
	}

	cout << (ans[K] ? "Yes" : "No") << endl;
	

	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MODADD(ADD_X,ADD_Y)  (ADD_X+ADD_Y)%MOD;
#define MODSUB(SUB_X,SUB_Y)  (SUB_X-SUB_Y)+MOD)%MOD;
#define MODMUL(MUL_X,MUL_Y)  (MUL_X*MUL_Y)%MOD;
#define LCM(LCM_X,LCM_Y) (LCM_X*LCM_Y)/__gcd(LCM_X,LCM_Y);
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
int dx[]= {1,0,-1,0,1,-1,1,-1};
int dy[]= {0,1,0,-1,1,-1,-1,1};
vector<int>pos[30];
int sz[30];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    ll f1[30]= {0},f2[30]= {0};
    string x,y;
    cin>>x>>y;
    ll l1=x.length();
    ll l2=y.length();
    for(int i=0; i<l1; i++)
    {
        f1[x[i]-'a']++;
        pos[x[i]-'a'].push_back(i);
        sz[x[i]-'a']++;
    }
    for(int i=0; i<l2; i++)
    {
        f2[y[i]-'a']++;
    }
    for(int i=0; i<26; i++)
    {
        if(f2[i] && !f1[i])
        {
            cout<<"-1"<<endl;
            return 0;
        }
    }
    ll it=-1;
    ll ans=0;
    for(int i=0; i<l2; i++)
    {
        int cur=y[i]-'a';
        int l=0,r=sz[cur]-1,res=-1;
        while(l<=r)
        {
            int mid=(l+r)>>1;
            if(pos[cur][mid]>it)
            {
                res=pos[cur][mid];
                r=mid-1;
            }
            else
                l=mid+1;
        }
        if(res==-1)
        {

            ans+=l1;
            it=pos[cur][0];
        }
        else
            it=res;
    }
    ans+=it+1;
    cout<<ans<<endl;





    return 0;
}


Measured memory_bytes: 4136
#include <iostream>
using namespace std;
typedef long long lli;
lli n;
lli a;
lli ans;
int main(){
    cin >> n;
    for(lli i = 1;i * i <= n;i++){
        if(n%i == 0) a = i;
    }
    lli b = n / a;
    lli r = 1;
    ans = 0;
    while(r <= b) r *= 10,ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner
import kotlin.system.exitProcess

fun main(args: Array<String>) {
	val scn = Scanner(System.`in`)
	val n = scn.nextInt()
	val m = scn.nextInt()
	val arr = IntArray(n){-1}
	repeat(m){
		val s = scn.nextInt()-1
		val c = scn.nextInt()
		if (arr[s]!=-1 && arr[s]!=c) impos()
		arr[s] = c
	}
	if (arr[0]==0 && n!=1) impos()
	if (arr[0]==-1) arr[0] = if (n==1) 0 else 1
	for (i in 1 until arr.size){
		if (arr[i]==-1) arr[i] = 0
	}
	print(arr.joinToString(separator = ""))
}

fun impos(){
	print(-1)
	exitProcess(0)
}

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

using namespace std;
using ll = long long;
using ld = long double;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) ((x).begin()), ((x).end())

#define READ(x) (cin >> (x))
#define WRITE_N(x) (cout << (x) << endl)
#define WRITE(x) (cout << (x))
#define WRITE_YESNO(x) (WRITE_N((x) ? "Yes" : "No"))

#define PRECISE_COUT std::cout << std::setprecision(15) << std::fixed

bool xor_logic(bool x, bool y) { return (x && y) || (!x && !y); }

int main() {
  // get values from input
  cin.tie(0);
  ios::sync_with_stdio(false);

    int A, B;
    cin >> A >> B;
    // main procedure

    // output
    WRITE_N(A * B);

    return 0;
}

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

Measured memory_bytes: 128
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  string s;
  cin >> s;
  bool mm1 = false, mm2 = false;
  if ("01" <= s.substr(0, 2) && s.substr(0, 2) <= "12") {
    mm1 = true;
  }
  if ("01" <= s.substr(2, 2) && s.substr(2, 2) <= "12") {
    mm2 = true;
  }
  string ans = "";
  if (mm1 && mm2) {
    ans = "AMBIGUOUS";
  } else if (mm1) {
    ans = "MMYY";
  } else if (mm2) {
    ans = "YYMM";
  } else {
    ans = "NA";
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3580
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>


using namespace std;
typedef long long unsigned int ll;

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

class BMinorChange {
public:
void solve(std::istream& cin, std::ostream& cout) {
    string a,b;
    int ans = 0;
    cin >> a;
    cin >> b;

    for(int i =0;i<a.size();i++){
        if(a[i] != b[i]){
            ans++;
        }
    }

    cout << ans << endl;
}
};


int main() {
	BMinorChange solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 1000000000 + 7;

int main(){
  cout << setprecision(10);
  ll N,K;
  cin >> N >> K;

  ll a,b;
  ll ans = 0;
  if(K==0){
    ans = N*N;
  } else{
    for(b = K+1; b <= N; b++){
      ll tmp = (N-b+1)/b;
      ans += (b-K) * (tmp+1);

      ll tmp2 = (tmp + 1) * b + K;
      if(tmp2 <= N){
        ans += N - tmp2 + 1;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define Y {puts("Yes");continue;}
#define N {puts("No");continue;}
int main()
{
	int T; ll A,B,C,D;
	cin>>T;
	while(T--)
	{
		cin>>A>>B>>C>>D;
		if(A<B) N
		if(D<B) N
		if(C>=B) Y
		ll t=A%B,s=__gcd(D,B);
		t+=(B-1-t)/s*s;
		if(t>C) N else Y
	}
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  string s;
  cin >> s;
  int appeared = 0;
  for(size_t i = 0; i < s.length(); ++i){
    int c = s[i] - 'a';
    appeared |= (1<<c);
  }
  for(int i = 0; i < 26; ++i){
    if(!((appeared>>i)&1)){
      cout << (char)('a' + i) << endl;
      return 0;
    }
  }
  cout << "None" << endl;
  return 0;
}


Measured memory_bytes: 512
//http://www.cplusplus.com/reference/algorithm/next_permutation/
//https://ravesli.com/urok-61-struktury/#toc-0
#include<bits/stdc++.h>
#define FILE
#define ll long long
#define pb push_back
#define pf push_front
#define fr first
#define sc second
#define r_0 return 0
#define ld long double
#define TIME ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;
    const ll N = 2e5 + 7;
    const ll mod = 1e9 + 7;

int main(){
    TIME
    #ifdef FILEs
        freopen("army.in", "r", stdin);
        freopen("army.out", "w", stdout);
    #endif
    string s;
    cin >> s;
    for(int i = 0; i < s.size(); i ++)cout << 'x';
}

///...


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>

using namespace std;
int main(){
    
double W,H;
double x,y;
cin >>W >> H >> x >> y;
double cx,cy;
cx=W/2;
cy=H/2;

double M=(H*W)/2;
int ans=0;

if(cx==x && cy ==y){
    ans=1;
}
cout <<M <<" "<<ans<<endl;

 return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};

const M: u64 = 998244353;

#[fastout]
fn main() {
    input! {in_n: usize, in_s: usize, in_a: [usize; in_n]};
    let mut v = [0 as u64; 3001];

    for a in &in_a {
        for i in (0..v.len()).rev() {
            v[i] += v[i];

            if i == 0 || i == *a {
                v[i] += 1;
            }

            if i >= *a {
                v[i] += v[i - *a];
            }

            v[i] = v[i] % M;
        }
    }

    println!("{}", v[in_s]);
}


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

int main()
{
    ll a,b,k;
    scanf("%lld%lld%lld",&a,&b,&k);
    for(ll i=1;i<=k;i++)
    {
        if(i%2)
        {
            if(a%2)
            {
                a--;
            }
            a=a/2;
            b+=a;
        }
        else
        {
            if(b%2)
            {
                b--;
            }
            b=b/2;
            a+=b;
        }
    }
    printf("%lld %lld\n",a,b);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define lli long long int
#define ulli unsigned long long int
#define ld long double
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define loop(i,a,b) for(lli i=a;i<b;i++)
#define initialize(array,size,value) for(lli i=0;i<size;i++) array[i]=value
#define couta(array,size) for(lli i=0;i<size;i++) cout<<array[i]<<" "
#define vl vector<lli>
#define vp vector< pair <lli,lli> >
#define sl set<lli>
#define msp multiset < pair < long long , long long > > S;
#define pll pair<lli, lli>
#define mll map<lli, lli>            //for( map<lli, lli>::iterator i=temp.begin();i!=temp.end();i++)cout<<i->fi<<" "<<i->se<<endl;
#define mvl map<lli, vl>
#define umll unordered_map<lli, lli>
#define vt vector<pair<lli, pll >  >
#define vf vector<pair<pll,pll > >
#define qu queue<lli>
#define pq priority_queue<lli>
#define dq deque <lli>
#define ptr vector<lli>::iterator
#define bs(array,x) binary_search(array.begin(),array.end(),x) // also valid for set and multiset
#define lb(array,x) lower_bound(array.begin(),array.end(),x)
#define ub(array,x) upper_bound(array.begin(),array.end(),x)
#define nobw(array,i,j) upper_bound(array.begin(), array.end(), j)-lower_bound(array.begin(), array.end(), i) //number of numbers between i & j
#define vc clear()
#define endl '\n'
#define sp system("pause");
#define INF 9223372036854775807
#define MINF -9223372036854775808
typedef tree<pll,null_type,less<pll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
//string binary = bitset<32>(n).to_string(); 
lli mod=1000000007;
int main()
{
 	ios::sync_with_stdio(0);
    cin.tie(0);
  lli n,m;
    cin>>n>>m;
    lli a[n][m];
    for(lli i=0;i<n;i++){
    	string st;
    	cin>>st;
    	for(lli j=0;j<m;j++){if(st[j]=='#')a[i][j]=0;
    		else a[i][j]=1;}
	}
	lli temp=0;
	lli b1[n][m];
	for(lli i=0;i<n;i++)for(lli j=0;j<m;j++)b1[i][j]=0;
	for(lli i=0;i<n;i++){
		lli temp=1;
		for(lli j=0;j<m;j++){
		if(a[i][j]==0){
			temp=0;
		}
		else{
			b1[i][j]=temp;
		}
		temp++;
	}
	}
	lli b2[n][m];
	for(lli i=0;i<n;i++)for(lli j=0;j<m;j++)b2[i][j]=0;
	for(lli i=0;i<n;i++){
		lli temp=1;
		for(lli j=m-1;j>=0;j--){
		if(a[i][j]==0){
			temp=0;
		}
		else{
			b2[i][j]=temp;
		}
		temp++;
	}
	}
	//for(lli i=0;i<n;i++){for(lli j=0;j<m;j++)cout<<b2[i][j]<<" ";cout<<endl;}
	lli b3[n][m];
	for(lli i=0;i<n;i++)for(lli j=0;j<m;j++)b3[i][j]=0;
	for(lli j=0;j<m;j++){
		lli temp=1;
		for(lli i=0;i<n;i++){
		if(a[i][j]==0){
			temp=0;
		}
		else{
			b3[i][j]=temp;
		}
		temp++;
	}
	}
	//for(lli i=0;i<n;i++){for(lli j=0;j<m;j++)cout<<b3[i][j]<<" ";cout<<endl;}
	lli b4[n][m];
	for(lli i=0;i<n;i++)for(lli j=0;j<m;j++)b4[i][j]=0;
	for(lli j=0;j<m;j++){
		lli temp=1;
		for(lli i=n-1;i>=0;i--){
		if(a[i][j]==0){
			temp=0;
		}
		else{
			b4[i][j]=temp;
		}
		temp++;
	}
	}
	lli maxi=0;
	for(lli i=0;i<n;i++)for(lli j=0;j<m;j++)maxi=max(maxi,b1[i][j]+b2[i][j]+b3[i][j]+b4[i][j]-3);
cout<<maxi;

	return 0;
}

Measured memory_bytes: 156544
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

pub trait BinarySearch<T> {
    fn lower_bound_by_key<B: Ord, F: FnMut(&T) -> B>(&self, x: &B, mut f: F) -> usize;
    fn lower_bound(&self, x: &T) -> usize;
}


impl<T: Ord + Clone> BinarySearch<T> for Vec<T> {
    fn lower_bound(&self, x: &T) -> usize {
        self.lower_bound_by_key(x, |y| y.clone())
    }

    fn lower_bound_by_key<B: Ord, F: FnMut(&T) -> B>(&self, x: &B, mut f: F) -> usize {
        let mut high = self.len();
        let mut low = 0;
        while low < high {
            let mid = (low + high) / 2;
            if  f(&self[mid]).lt(&x) {
                low = mid + 1;
            } else {
                high = mid;
            }
        }
        low
    }
}

fn solve(mut aa: Vec<u32>) -> (u32, u32) {
    aa.sort();
    let n = aa[aa.len()-1];
    aa.pop();

    let mut m = aa.lower_bound(&(n/2));

    if m >= aa.len() {
        m = m-1;
    } else {
        let f = (n as f32) / 2f32;
        let d1 = (aa[m-1] as f32 - f).abs();
        let d2 = (aa[m] as f32 - f).abs();
        if d1 < d2 {
            m = m-1;
        }
    }
    (n, aa[m])
}

fn main() {
    read_line!();

    let aa = parse_vec!(u32);

    let (a,b) = solve(aa);

    println!("{} {}", a, b);
}

#[test]
fn solve_test() {
    assert_eq!(solve(vec![6,9,4,2,11]), (11, 6));
    assert_eq!(solve(vec![100, 0]), (100, 0));
}


Measured memory_bytes: 4352
program main
  implicit none
  integer :: K
  integer :: out
  integer :: l,m,n
  integer t1, t2, t_rate, t_max, diff
  read(*,*) K
  !call system_clock(t1)   ! 開始時を記録  
  out = 0
  do n = 1,k
     do m = 1, K
        do l = 1,K
           out = out + gcd(gcd(l,m),n)
        end do
     end do
  end do
  write(*,'(i0)') out
!!  call system_clock(t2, t_rate, t_max)
!!  if ( t2 < t1 ) then
!!    diff = (t_max - t1) + t2 + 1
!!  else
!!    diff = t2 - t1
!!  endif
!!  print "(A, F10.3)", "time it took was:", diff/dble(t_rate)    
  stop
contains
  function gcd(a,b) result(ret)
    integer :: a,b
    integer :: m,n
    integer :: k
    integer :: ret
    m = a
    n = b
    do
       k = mod(m, n)
       if (k == 0) then
          ret = n
          return 
       end if
       ! step 4
       m = n
       n = k
    end do
  end function gcd
end program main


Measured memory_bytes: 2924
#include<bits/stdc++.h>
using namespace std;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int_fast64_t S, tmp;
    cin >> S;
    for (int_fast64_t i = sqrt(S);; i++) {
        if (i*i >= S) {
            tmp = i;
            break;
        }
    }
    printf("0 0 %d %d 1 %d\n", tmp, tmp*tmp-S, tmp);
    return 0;
}

Measured memory_bytes: 256
import Data.List (sortBy)
import Data.Array

main :: IO ()
main = do
    n <- readLn
    as <- (map read . words) <$> getLine
    print $ solve n as

solve :: Int -> [Int] -> Int
solve n as = sum [arr ! (2*i) | i <- [1 .. n]]
    where
        arr = array (1, 2*n) $ zip [1 .. 2*n] as'
        as' = take (2*n) $ sortBy (flip compare) as


Measured memory_bytes: 119164
#include<stdio.h>

int main() {
	int N; 
	scanf("%d", &N);
	double A[101];
	for (int i = 0; i < N; i++) {
		scanf("%lf", &A[i]);
	}


	double ans = 0;
	for (int i = 0; i < N; i++) {
		ans += 1 / A[i];
	}

	printf("%.16f", 1.0/ans);
}	

Measured memory_bytes: 128
#include<iostream>

using namespace std;

int main(){
 int a,b,c,d,e,f;
  cin >> a >> b >> c >> d >> e >> f;
   
  bool wat[f+1],sug[f+1];
  
         for(int i=0;i<=f;i++){        
           wat[i]=false;
           sug[i]=false;
         }
           
  for(int i=0;i<=f/(100*a);i++){
    for(int j=0;j<=(f-100*a*i)/(100*b);j++){
     wat[100*a*i+100*b*j]=true;
    }
  }
   for(int i=0;i<=f/c;i++){
    for(int j=0;j<=(f-c*i)/d;j++){
     sug[c*i+d*j]=true;
    }
  }
  
   double den=0;
   int liq=100*a,sol=0;
  
   for(int i=1;i<=f/100;i++){
    for(int j=0;j<=f-100*i;j++){
      
      if(wat[100*i]&&sug[j]&&i*e>=j&& double(100*j)/double(100*i+j)>den){
      
        den=double(100*j)/double(100*i+j);
        liq=100*i+j;
        sol=j;
        
      }
    }
  }
  
  cout << liq << " " << sol << endl;

}

Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;


const int D = 80 * 160 + 10;
const int D2 = D * 2;
typedef bitset<D2> bs;
bs dp[90][90];

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> A(H, vector<int>(W));
	vector<vector<int>> B(H, vector<int>(W));
	vector<vector<int>> AB(H + 1, vector<int>(W + 1));
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			cin >> A[n][m];
		}
	}
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			cin >> B[n][m];
		}
	}
	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			AB[n][m] = abs(A[n][m] - B[n][m]);
		}
	}

	const int D = 80 * 160 + 10;
	const int D2 = D * 2;
	typedef bitset<D2> bs;
	bs dp[90][90];
	//どこで落ちてる？ 
	dp[0][0][D - AB[0][0]] = 1;
	dp[0][0][D + AB[0][0]] = 1;

	for (int n = 0; n < H; ++n) {
		for (int m = 0; m < W; ++m) {
			if (n != 0) {
				dp[n][m] |= dp[n - 1][m] << AB[n][m];
				dp[n][m] |= dp[n - 1][m] >> AB[n][m];
			}
			if (m != 0) {
				dp[n][m] |= dp[n][m - 1] << AB[n][m];
				dp[n][m] |= dp[n][m - 1] >> AB[n][m];
			}
		}
	}
	int ans = D2;
	for (int n = 0; n < D2; ++n) {
		if (dp[H - 1][W - 1][n]) {
			ans = min(ans, abs(n - D));
		}
	}

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

Measured memory_bytes: 29032
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main()
{
    int N = 0;
    cin >> N;
    bool judge = false;
    for (int i = 1; i < 10; i++)
    {
        for (int j = 1; j < 10;j++)
        {
            if (i * j == N)
            {
                judge = true;
            }
        }
    }
    if(judge == true){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}

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

void Main()
{
    double l;
    cin >> l;
    double a = l / 3.0;
    double s = a*a*a;
    cout << std::setprecision(30) << s << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


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

const long long MOD = 1000000007;

long long modpow(long long a, long long n, long long mod) {
    if (n == 0) return 1;
    
    if (n == 1) return a % mod;
    
    if (n % 2 == 0) {
        long long half = modpow(a, n / 2, mod) % mod;
        return half * half % mod;
    }
    else return modpow(a, 1, mod) * modpow(a, n - 1, mod);
}

int main() {
    int n;
    cin >> n;
    vector<int> cnt(n);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        cnt.at(a)++;
    }
   
    int start;
    if (n % 2 == 1) {
        if (cnt.at(0) != 1) {
            cout << 0 << endl;
            return 0;
        }

        start = 2;
    }
    else {
        start = 1;
    }
    
    for (int i = start; i <= n - 1; i += 2) {
        if (cnt.at(i) != 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    
    cout << modpow(2, (n - n % 2) / 2, MOD) << endl;
}   

Measured memory_bytes: 640
#include <cctype>
#include <iostream>

using namespace std;

int todigit(char c) {
    int n;
    if (isdigit(c) == 0)
        n = c - 'A' + 10;
    else
        n = c;
    return n;
}

int main() {
    char x, y;
    cin >> x >> y;

    int xx, yy;
    xx = todigit(x);
    yy = todigit(y);

    if (xx > yy)
        cout << ">\n";
    else if (xx < yy)
        cout << "<\n";
    else
        cout << "=\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>

#define MAX_V 100001
#define INF (1<<29)

using namespace std;

typedef pair<int,int> P;

vector<int>G[MAX_V];
vector<P> bridge;
int pnum[MAX_V],lowest[MAX_V],num;
bool used[MAX_V];

int dfs(int v,int prev){
  pnum[v]=num,lowest[v]=num;
  num++;
  used[v]=true;

  for(int i=0;i<G[v].size();i++){
    int nx=G[v][i];
    if(!used[nx]){
      dfs(nx,v);
      lowest[v]=min(lowest[v],lowest[nx]);
      if(pnum[v]<lowest[nx])
        bridge.push_back(make_pair(min(v,nx),max(v,nx)));
    }
    else if(nx!=prev){
      lowest[v]=min(lowest[v],pnum[nx]);
    }
  }
}

void Bridge(void){
  fill(used,used+MAX_V,false);
  fill(lowest,lowest+MAX_V,INF);
  fill(pnum,pnum+MAX_V,INF);
  num=0;
  bridge.clear();
  dfs(0,-1);
  sort(bridge.begin(),bridge.end());
}

int main(void){
  int n,m;
  cin >> n >> m;
  for(int i=0;i<m;i++){
    int a,b;
    cin >> a >> b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  Bridge();

  for(int i=0;i<bridge.size();i++)
    cout << bridge[i].first << " " << bridge[i].second << endl;

  return 0;
}

Measured memory_bytes: 5996
n = int(input())
a = []
for i in range(n):
    a.append(int(input()))
for i in range(n):
    a[i]-=1
ans = 0
b = 0
while(True):
    b = a[b]
    ans+=1
    if b == 1: break
    if ans > n+1: 
        ans = -1
        break
print(ans)

Measured memory_bytes: 7084
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        xv: [usize; 5]
    };

    for (i, x) in xv.into_iter().enumerate() {
        if x == 0 {
            println!("{}", i + 1);
            return;
        }
    }
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2188
import java.util.*;
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(br.readLine());
		int[] a = new int[n];

		String s = br.readLine();
		String[] str = s.split(" ");
		for (int i=0; i<n; i++) {
			a[i] = Integer.parseInt(str[i]);
		}
		fSort(a,n,10000);

		StringBuilder sb = new StringBuilder();
		for (int i=0; i<n-1; i++) {
			sb.append(a[i]).append(" ");
		}
		System.out.println(sb.append(a[n-1]));

		br.close();
	}

	static void fSort(int[] a,int n,int max) {
        int[] f = new int[max+1];
        int[] b = new int[n];

        for(int i=0; i<n; i++) f[a[i]]++;
        for(int i=1; i<=max; i++) f[i] += f[i-1];
        for(int i=n-1; i>=0; i--) b[--f[a[i]]] = a[i];
        for(int i=0; i<n; i++) a[i] = b[i];
    }
}

Measured memory_bytes: 266136
#include <iostream>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>

using namespace std;

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

int main(){
    vector<vector<int>> cs(3, vector<int>(3, 0));
    vector<int> as(3, 0);
    vector<int> bs(3, 0);

    rep(i, 3){
        cin >> cs[i][0] >> cs[i][1] >> cs[i][2];
    }

    bs[0] = cs[0][0];
    bs[1] = cs[0][1];
    bs[2] = cs[0][2];
    as[1] = cs[1][0] - cs[0][0];
    as[2] = cs[2][0] - cs[0][0];

    rep(i, 3){
        rep(j, 3){
            if(cs[i][j] != as[i] + bs[j]){
                cout << "No" << endl;
                return 0;
            };
        }

    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 256
//
// Created by yamunaku on 2019/08/19.
//

#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repl(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perl(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD9 998244353
#define MOD1 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl
#define CNO cout<<"No"<<endl
#define CFS cin.tie(0);ios::sync_with_stdio(false)
#define CST(x) cout<<fixed<<setprecision(x)

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vector<int>> mti;
typedef vector<ll> vl;
typedef vector<vector<ll>> mtl;

int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    if(n<3200) cout << "red" << endl;
    else cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define speed ios_base::sync_with_stdio(0); cin.tie(0);
#define FL(i,a,n) for(ll i=a;i<n;i++)
#define even(x) (((x)%(2))==(0))
#define odd(x) (((x)%(2))==(1))
#define meme(x) memset(x, 0, sizeof(x))
#define mod 1000000007

#define pb push_back
#define mp make_pair
#define ff first
#define ss second

int main()
{
    speed
    
        int n;cin>>n;int ans;
        if(n>=400 && n<=599)
        ans=8;
        else if(n>=600 && n<=799)
        ans=7;
        else if(n>=800 && n<=999)
        ans=6;
        else if(n>=1000 && n<=1199)
        ans=5;
        else if(n>=1200 && n<=1399)
        ans=4;
        else if(n>=1400 && n<=1599)
        ans=3;
        else if(n>=1600 && n<=1799)
        ans=2;
        else if(n>=1800 && n<=1999)
        ans=1;

        cout<<ans;
        
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <set>
#include <algorithm>
#include <iomanip>
using namespace std;
int main()
{
	int x, y, z;
	cin >> x >> y >> z;
	int k;
	cin >> k;
	
	int coun = k;
	while (y <= x && coun>0) {
		y = y * 2;
		coun--;
	}
	z = z * pow(2, coun);
	if (y > x && z > y)cout << "Yes";
	else cout << "No";
}


Measured memory_bytes: 3128
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>

using namespace std;

#define FOR(i,a,b) for(int (i) = (a); (i) < (b); (i)++)
#define REP(i,n) FOR((i),0,(n))
#define FORCLS(i,a,b) for(int (i) = (a); i <= (b); (i)++)
#define REPCLS(i,n) FORCLS((i),1,(n))

using Int = long;
const int N_MAX = 200003;
Int as[N_MAX];
int n;
void solve() {
    cin >> n;
    REP(i, n) { cin >> as[i]; }
    deque<Int> q;
    int i = 0;
    if (n % 2 == 1){
        q.push_front(as[i]);
        i++;
    }
    while (i < n){
        q.push_back(as[i]);
        i++;
        q.push_front(as[i]);
        i++;
    }
    for(auto x : q) {
        cout << x << " ";
    }
    cout << endl;
}

#ifdef DEBUG
#define MAIN hoge
#else
#define MAIN main
#endif

int MAIN() {
    solve();
    
    return 0;
}


Measured memory_bytes: 5376
H,W=map(int,input().split())
l=[[0 if i=="." else 1 for i in input()] for _ in range(H)]
dp=[[0 for _ in range(W)] for _ in range(H)]
dp[0][0]=1
mod=1000000007

for i in range(H):
    for j in range(W):
        if l[i][j]:continue
        if i>0:dp[i][j]+=(dp[i-1][j]%mod)
        if j>0:dp[i][j]+=(dp[i][j-1]%mod)

print(dp[H-1][W-1]%mod)

Measured memory_bytes: 52392
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define FORL(i,x) for(int i=head[x];i;i=nxt[i])
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }



int main() {
    int n;
    cin >> n;
    int h[n];
    FOR(i,0,n-1) cin >> h[i];

    int hold = 0;
    int ans = 0;

    FOR(i,1,n-1){
        if(h[i-1]>=h[i]) {
            ++hold;
        }
        else {
            hold = 0;
        }

        // cout << hold << " " << ans << endl;
        if(ans<=hold) ans = hold;
        // cout << ans << endl;
    }

    cout << ans << endl;
}



Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <algorithm>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <iomanip>
#include <map>
#include <unordered_map>
#define REP(i,n) for (int i=0;i<(n);++i)
using namespace std;
using ll = long long;


int a[110000];
int b[110000];
int c[110000];
int dp[110000][3];

int main(){
        int n;
        cin>>n;
        for(int i=0;i<n;i++){
            cin>>a[i];
            cin>>b[i];
            cin>>c[i];
        }
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                dp[i][j]=INT_MIN;
                if(i==0){
                    if(j==0) dp[i][j]=a[i];
                    else if(j==1) dp[i][j]=b[i];
                    else dp[i][j]=c[i];
                }else{
                    for(int k=0;k<3;k++){
                        if(j==k) continue;
                        if(j==0) dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i]);
                        else if(j==1) dp[i][j]=max(dp[i][j],dp[i-1][k]+b[i]);
                        else dp[i][j]=max(dp[i][j],dp[i-1][k]+c[i]);
                    }
                }
            }
        }
int ans=INT_MIN;
ans=max(dp[n-1][0],ans);
ans=max(dp[n-1][1],ans);
ans=max(dp[n-1][2],ans);
cout<<ans;
return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
 
int main()
{

    int N;
    cin >> N;
 
    vector<int> d;
    for(int i = 0; i < N; i++){
        int input;
        cin >> input;
        d.push_back(input);
    }

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

    int before = d[N/2-1];
    int after = d[N/2];

    int count = 0;
    while(after > before){
        count++;
        after--;
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 892
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

Int dist[330][330];
Int new_dist[330][330];
Int n, m, l;
int a, b, c;
int main(){
    for(int i = 0;i < 330;i++){
        for(int j = 0;j < 330;j++){
            dist[i][j] = new_dist[i][j] = LINF;
        }
    }
    
    cin >> n >> m >> l;
    for(int i = 0;i < m;i++){
        cin >> a >> b >> c;a--,b--;
        dist[a][b] = dist[b][a] = c;
    }


    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int k = 0;k < n;k++){
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
                }
            }   
    }

    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            if(dist[i][j] <= l){
                new_dist[i][j] = 1;
            }
        }
    }
    
    for(int i = 0;i < n;i++){
        for(int j = 0;j < n;j++){
            for(int k = 0;k < n;k++){
                new_dist[j][k] = min(new_dist[j][k], new_dist[j][i] + new_dist[i][k]);
                }
            }   
    }

    int q;
    cin >> q;
    while(q--){
        cin >> a >> b;a--,b--;
        if(new_dist[a][b] == LINF)new_dist[a][b] = 0;
        cout << new_dist[a][b] - 1 << endl;
    }
    
    return 0;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

void solve() {
    int a, b;
    cin >> a >> b;

    int idx = 0, val = 2;
    vector<int> tower;
    tower.push_back(1);
    while (val < 1000) {
        tower.push_back(tower[idx] + val);
        idx++; val++;
    }

    int ans;
    for (int i = 1; i < tower.size(); i++) {
        if (tower[i] - tower[i-1] == b - a) {
            ans = tower[i-1] - a;
        }
    }

    cout << ans << endl;
}

int main() {
    solve();

    return 0;
}


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

#define ll long long 

int main() {
    ios::sync_with_stdio(0); 

    int n; cin >> n;
    string s; cin >> s;

    int left = 0;
    int right = n-1;
    int cnt = 0;
    while (left <= right) {
        if (s[left] == 'W') {
            while (right > left and s[right] == 'W') right--;
            if (right == left) break;
            swap(s[left], s[right]);
            cnt++;
        }
        left++;
    }

    //cout << "s: " << s << endl;
    //cout << "left: " << left << endl;
    for (int i = left; i < n; i++) {
        cnt += (s[i] == 'R');
    }

    cout << cnt << endl;



    return 0; 
}



Measured memory_bytes: 3700
import sys
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mod = 10**9 + 7

A, B = rl()

import math
for i in range(1, 2000):
    if math.floor(i*8/100) == A and math.floor(i*10/100) == B:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 38640
N, K = map(int, input().split())
A = list(map(int, input().split()))

mbl = len(format(max(A + [K]), 'b'))
cnt = [0] * mbl

for i in range(mbl):
    for a in A:
        if a & (1 << i):
            cnt[i] += 1

x = 0
for i in range(mbl - 1, -1, -1):
    if N // 2 >= cnt[i] and K >= x + (1 << i):
        x += (1 << i)

ans = 0
for a in A:
    ans += (x ^ a)

print(ans)


Measured memory_bytes: 14620
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll A, B, N, ans;
    cin >> A >> B >> N;
    // N のとき Max
    if ( N <= B - 1 ){
        ans = ( A * N ) / B;
    }
    else{
        ans = ( A * ( B - 1 ) ) / B;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <utility>
#include <queue>
using namespace std;

typedef pair<int,int> pxy;

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

int main()
{
  int t,n,ox,oy,sx,sy,x,y;

  for(;;){
    cin>>t>>n;
    if(!(t|n)) break;
    int map[200][200]={};
    for(int i=0;i<n;i++){
      cin>>ox>>oy;
      map[ox+100][oy+100]=1;
    }
    cin>>sx>>sy;

    int count=1;
    queue<pxy> q;
    
    q.push(pxy(sx+100,sy+100));
    map[q.front().first][q.front().second]=1;
    while(!q.empty()){
      x=q.front().first; y=q.front().second;
      q.pop();
      for(int i=0;i<6;i++){
	int next_x=x+dx[i],next_y=y+dy[i];
	if(map[next_x][next_y]) continue;
	map[next_x][next_y]=map[x][y]+1;
	count++;
	if(map[x][y]<t)
	  q.push(pxy(next_x,next_y));
      }
    }
    cout<<count<<endl;
  }
}


Measured memory_bytes: 1380
#include<iostream>
#include<cmath>
using namespace std;
int main(){
	while(true){
		int gold = 0;
		int n,m,p,mn;
		scanf("%d%d%d", &n, &m, &p);
		if( n == 0 && m == 0 && p == 0 )break;
		for(int i = 0; i < n; ++i){
			int t;scanf("%d", &t);gold += 100 * t;
			if(i==m-1)mn=t;
		}
		gold = (int)floor(gold * (1 - ((double)p/100)));
		printf("%d\n", mn > 0 ? (int)floor((double)gold / mn) : 0);
	}
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> c(h);
  for (int i = 0; i < h; i++) {
    cin >> c[i];
  }
  for (int i = 0; i < 2 * h; i++) {
    for (int j = 0; j < w; j++) {
      cout << c[i / 2][j];
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 3520
#include <stdio.h>
int pair(int n);
int main(){
	int n;
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",pair(n));
	}
	return 0;	
}

int pair(int n){
	int a,b,c,d,num=0;
	for(a=0;a<10;a++){
		for(b=0;b<10;b++){
			for(c=0;c<10;c++){
				for(d=0;d<10;d++){
					if(n==(a+b+c+d)) num++;
				}
			}
		}
	}
	return num;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
using namespace std;
 
int main()
{
 long int N,K;
  cin>>N>>K;
  
  long long int A[N],i;
  for(i=0;i<N;++i)
  {
    cin>>A[i];
  }
  sort(A,A+N);
  long long int tot=0;
  for(i=0;i<(N-K);++i)
  {
    tot+=A[i];
  }
 cout<<tot<<endl;
}

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

int main(void){
  int n;
  int fib[45];
  fib[0] = 1;
  fib[1] = 1;

  cin >> n;

  for(int i=2; i<=n; i++)
    fib[i] = fib[i-1] + fib[i-2];

  cout << fib[n] << endl;
  
  return 0;
}

Measured memory_bytes: 3072
#include<stdio.h>
int main(void)
{
	int a,s,d[1001][1001],g[1001],h[1001],i,j;
	scanf("%d",&a);
	scanf("%d",&s);
	for(i=1;i<=s;i++){
		scanf("%d",&g[i]);
	}
	for(i=1;i<=s;i++){
		for(j=1;j<=a;j++){
			scanf("%d",&d[i][j]);
		}
	}
	for(i=1;i<=s;i++){
		for(j=1;j<=a;j++){
			if(g[i]==d[i][j]){
				h[j]++;
			}
			else{
				h[g[i]]++;
			}
		}
	}
	for(i=1;i<=a;i++){
		printf("%d\n",h[i]);
	}
	return 0;
}

Measured memory_bytes: 1428
N, K = map(int, input().split())

MAX = 4 * 10 ** 5 + 1
MOD = 10 ** 9 + 7

# Factorial
fac = [0] * (MAX + 1)
fac[0] = 1
fac[1] = 1

# Inverse
inv = [0] * (MAX + 1)
inv[1] = 1

# Inverse factorial
finv = [0] * (MAX + 1)
finv[0] = 1
finv[1] = 1

for i in range(2, MAX + 1):
    fac[i] = fac[i - 1] * i % MOD
    inv[i] = MOD - inv[MOD % i] * (MOD // i) % MOD
    finv[i] = finv[i - 1] * inv[i] % MOD


def comb(n, k):
    if n < k or k < 0:
        return 0
    return (fac[n] * finv[k] * finv[n - k]) % MOD


if N - 1 <= K:
    print(comb(2 * N - 1, N - 1))
else:
    # zero: 0 ~ K
    ans = 0
    for n in range(K + 1):
        ans += comb(N, n) * comb(N - 1, n)
        ans %= MOD
    print(ans)


Measured memory_bytes: 79432
fn main() {
    let s = std::io::stdin();
    let mut sc = Scanner { stdin: s.lock() };
    let n: usize = sc.read();
    let a: Vec<Vec<char>> = (0..n).map(|_| sc.chars()).collect();

    if a.iter().all(|row| row.iter().all(|&c| c == '.')) {
        println!("-1");
        return;
    }

    let min = (0..n)
        .map(|row| {
            let white = a[row].iter().filter(|&&c| c == '.').count();
            if white == 0 {
                0
            } else if a.iter().any(|r| r[row] == '#') {
                white
            } else {
                white + 1
            }
        })
        .min()
        .unwrap();
    let white_cols = (0..n)
        .filter(|&col| a.iter().any(|row| row[col] == '.'))
        .count();
    println!("{}", min + white_cols);
}

pub struct Scanner<R> {
    stdin: R,
}

impl<R: std::io::Read> Scanner<R> {
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .stdin
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n')
            .take_while(|&b| b != b' ' && b != b'\n')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 4476
from collections import deque
h,w=map(int,input().split())
s=[input() for _ in range(h)]
d=[[1,0],[-1,0],[0,1],[0,-1]]
bcnt=0
for i in range(h):
    bcnt+=s[i].count('#')
dist=[[-1]*w for _ in range(h)]
r=deque()
r.append([0,0])
dist[0][0]=0
while r:
    x,y=r.popleft()
    for dx,dy in d:
        nx=x+dx
        ny=y+dy
        nd=dist[y][x]
        if nx>=0 and nx<=w-1 and ny>=0 and ny<=h-1:
            if dist[ny][nx]>-1 or s[ny][nx]=='#':
                continue
            dist[ny][nx]=nd+1
            r.append([nx,ny])
if dist[h-1][w-1]==-1:
    print(-1)
else:
    print(h*w-dist[h-1][w-1]-1-bcnt)

Measured memory_bytes: 3316
#include <algorithm>
#include <cassert>
// #include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
// #include <random>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

/*
unsigned seed1 = std::chrono::system_clock::now().time_since_epoch().count();
mt19937 g1.seed(seed1);
*/
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<pii, pii> ppiipii;
typedef pair<int, ppiipii> pippiipii;
typedef pair<int, pii> pipii;
typedef pair<pii, int> ppiii;
typedef pair<int, ppiii> pippiii;
typedef pair<int, ll> pill;
typedef pair<int, double> pid;
typedef pair<string, string> pss;
// note to self, the below two triggers someone
typedef pair<ll, ll> pll;
typedef pair<ll, int> plli;
typedef long double ld;

int main() {
  int a, b, c, d;
  scanf("%d%d%d%d", &a, &b, &c, &d);
  int ret = 0;
  for(int i = 0; i <= 100; i++) {
    if(i >= a && i < b && i >= c && i < d) ret++;
  }
  printf("%d\n", ret);
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    A = LI()
    want = 1
    cnt = 0
    for a in A:
        if a == want:
            want += 1
        else:
            cnt += 1
    if want == 1:
        cnt = -1
    print(cnt)

main()



Measured memory_bytes: 27388
#include<iostream>

using namespace std;

int main(){
  int N;
  int T;
  int c[1010];
  int t[1010];

  cin >> N >> T;
  for(int i = 0;i < N;i++) cin >> c[i] >> t[i];

  int min = 10000;
  int num = -1;
  for(int i = 0;i < N;i++){
    if(t[i] <= T){
      if(c[i] < min){
        num = i;
        min = c[i];
      }
    }
  }

  if(num == -1) cout << "TLE" << endl;
  else cout << c[num] << endl;

}


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

int main() {
    int n; cin >> n;
    pair<pair<string, int>, int> sp[n];
    rep(i, n) {
        cin >> sp[i].first.first >> sp[i].first.second;
        sp[i].first.second *= -1;
        sp[i].second = i+1;
    }
    sort(sp, sp+n);

    rep(i, n) {
        cout << sp[i].second << endl;
    }
    return 0;
}

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

using namespace std;

int main()
{
  int64_t N;
  cin >> N;
  vector<int64_t> a(N);
  for(int64_t i = 0;
      i < N;
      ++i)
    {
      cin >> a[i];
    }

  vector<int64_t> ans(N);
  vector<int64_t> sum(N);
  for(int64_t i = 0;
      i < N;
      ++i)
    {
      ans[i] = 0;
    }

  int64_t st = N/2;
  if(N % 2 == 1)
    {
      ++st;
    }
  int64_t count = 0;
  //cout << st << endl;
  for(int64_t i = st;
      i < N;
      ++i)
    {
      ans[i] = a[i];
      count += a[i];
    }

  for(int64_t i = st - 1;
     i >= 0;
     --i)
    {
      //cout << "i: " << i << endl;
      int64_t sum = 0;
      for(int64_t j = (i + 1);
          j <= N;
          j += (i + 1))
        {
          //          cout << j << endl;
          sum += ans[j - 1];
        }
      // cout << "sum: " <<  sum << endl;
      if((sum % 2) == a[i])
        {
          ans[i] = 0;
        }
      else
        {
          ans[i] = 1;
          ++count;
        }
    }

  cout << count << endl;
  if(count != 0)
    {
      for(int64_t i = 0;
          i < N;
          ++i)
        {
          if(ans[i] == 1)
            {
              cout << i + 1 << " ";
            }
        }
      cout << endl;
    }

  return 0;
}


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

int main(){
    int N;
    cin >> N;
    for(int i=1;i<10;i++){
        int r = N%i;
        if(r==0){
            int M = N/i;
            if(M<10) {
                cout << "Yes";
                break;
            }
        }
        if(i==9) cout << "No";
    }
   
    return 0;

}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using GraphI = vector<vector<int>>;
using GraphC = vector<vector<char>>;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int n;
  cin >> n;
  vector<vector<int>> a(2, vector<int>(n));
  rep(y, 0, 2) rep(x, 0, n) cin >> a[y][x];

  int ans = 0;
  rep(i, 0, n) {
    int tot = 0;
    repe(j, 0, i) tot += a[0][j];
    rep(j, i, n) tot += a[1][j];
    ans = max(ans, tot);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3624