akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.InputStreamReader;


public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int a = scanner.nextInt();
        if (a==3||a==5||a==7) {
        	System.out.println("YES");
        }else {
        	System.out.println("NO");
        }

    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
#include <iomanip>
#include <math.h>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60
const double PI = 3.14159265358979323846;

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

	int H, N; cin >> H >> N;
	int sum = 0;
	for (int i = 0; i < N; i++) {
		int tmp; cin >> tmp;
		sum += tmp;
	}
	if (sum >= H) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cassert>
using namespace std;
using VI = vector<long>;

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

void solve() {
    long a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b) {
        cout << "No" << endl;
        return;
    }
    if (d < b) {
        cout << "No" << endl;
        return;
    }
    if (c >= b - 1) {
        cout << "Yes" << endl;
        return;
    }
    
    if (d % b == 0) {
        if (a % b <= c) {
            cout << "Yes" << endl;
            return;
        }
        cout << "No" << endl;
        return;
    }
    
    long g = gcd(d % b, b);
    long m = ((b - a % b) / g) * g + a % b;
    assert(m <= b);
    if (m == b) m -= g;
    if (m <= c) {
        cout << "Yes" << endl;
        return;
    }
    cout << "No" << endl;
}

int main() {
    int t;
    cin >> t;
    for (int i = 0; i < t; i++) {
        solve();
    }
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var n = ReadLineInt();
			if (n==1) Console.WriteLine("0");
			else Console.WriteLine("1");
		}

		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n - 1, m - 1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s = ' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

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

using namespace std;

const int MAX = 1e5 + 5 ;

int lift[MAX][23] ;
int n , l ;
int arr[MAX] ;

void preprocess()
{
    lift[n][0] = n ;
    for(int i = 0 ; i < n ; ++i)
    {
        int idx = upper_bound(arr , arr + n , arr[i] + l) - arr ;
        idx-- ;
        if(arr[i] + l >= arr[n-1])
            idx = n ;
        lift[i][0] = idx ;
    }
    for(int j = 1 ; j < 23 ; ++j)
    {
        lift[n][j] = n ;
        for(int i = 0 ; i < n ; ++i)
        {
            lift[i][j] = lift[lift[i][j-1]][j-1] ;
            //cout<<i<<" "<<j<<" : "<<lift[i][j]<<"\n";
        }
    }
    return ;
}

int a , b ;

int query()
{
    int x = a ;
    int ans = 0 , ans2 = 1e9;
    for(int i = 21 ; i >= 0 ; --i)
    {
        if(lift[x][i] <= b)
            ans += (1 << i) , x = lift[x][i] ;
        else
            ans2 = min(ans2 , ans + (1 << i)) ;
    }
    if(x != b)
        ans++ ;
    return min(ans , ans2);
}

int main()
{
    scanf("%d" , &n) ;
    for(int i = 0 ; i < n ; ++i)
        scanf("%d" , &arr[i]) ;
    scanf("%d" , &l) ;
    preprocess() ;
    int q ;
    scanf("%d" , &q) ;
    while(q--)
    {
        scanf("%d %d" , &a , &b) ;
        if(a > b)
            swap(a , b);
        --a ;
        --b ;
        printf("%d\n" , query()) ;
    }
    return 0 ;
}


Measured memory_bytes: 10240
#include <stdio.h>
#include <math.h>
#define LL long long
long long n, m, i, j, k, x, y, s;
int main(){
	scanf("%lld", &x);
	for(i=-500; i<=500; i++){
		for(j=-500; j<=500; j++){
			if(i*i*i*i*i-j*j*j*j*j == x){
				printf("%lld %lld\n", i, j);
				return 0;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef string str;
typedef vector<ll> vel;
typedef vector<str> ves;
#define REP(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define rep(i, b) REP(i, 0, b)
const ll cd = 1000000007;
const double pi = 3.14159265358979;

int main() {
    ll N, K;
    cin >> N >> K;
    ll count = 0;
    vel sum(N + 2);
    sum[0] = 0;
    rep(i, N+1) {
        sum[i+1] = sum[i] + i;
    }
    REP(i, K, N+2) {
        ll max, min;
        max = sum[N+1] - sum[N+1-i];
        min = sum[i] - sum[0];
        count += max - min + 1;
    }
    cout << count % cd << endl;
}

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

using namespace std;

typedef long long LL;
#define N 1200000

const LL mod=998244353;
LL n,m,p,ans,fac[N],ifac[N],pwn[N],pwm[N];

LL inv(LL x){return x==1?1:(mod-mod/x)*inv(mod%x)%mod;}

void upd(LL &x,LL y){x=(x+y%mod+mod)%mod;}

LL C(LL x,LL y){return fac[x]*ifac[y]%mod*ifac[x-y]%mod;}

int main(){
	scanf("%lld%lld",&n,&m);
	p=n+m;
	fac[0]=1; for (LL i=1;i<=p;++i) fac[i]=fac[i-1]*i%mod;
	ifac[p]=inv(fac[p]); for (LL i=p-1;~i;--i) ifac[i]=ifac[i+1]*(i+1)%mod;
	pwn[0]=pwm[0]=1;
	for (LL i=1;i<=p;++i){pwn[i]=pwn[i-1]*(n+1)%mod; pwm[i]=pwm[i-1]*(m+1)%mod;}
	for (LL i=0;i<=min(n,m);++i)
		upd(ans,(i&1?-1:1)*C(n,i)*C(m,i)%mod*fac[i]%mod*pwn[m-i]%mod*pwm[n-i]);
	printf("%lld\n",ans);
	
	return 0;
}
			

Measured memory_bytes: 37120
def get_maximam_distance(k, positions):
    distance_tmp = 0
    for i in range(1, len(positions)):
        distance_tmp = max(distance_tmp, positions[i] - positions[i - 1])
    return max(distance_tmp, positions[0] + k - positions[len(positions) - 1])

params_0 = input().split()
params_1 = input().split()
param_K = int(params_0[0])
positions = list(map(lambda x: int(x), params_1))
print(param_K - get_maximam_distance(param_K, positions))

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

int main() {
	
	int k, x;
	cin >> k >> x;
	
	for(int i=x-k+1; i<k+x; i++) cout << i << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define SPEED ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define RFOR(i, b, a) for (ll i = b; i >= a; --i)
#define ALL(x) x.begin(), x.end()
#define DEBUG(args...) { string _s = #args; replace(ALL(_s), ' ', '\0');\
replace(ALL(_s), ',', ' ');\
stringstream _ss(_s); istream_iterator<string> _it(_ss); _debug(_it, args);}
#define endl "\n"
#define F first
#define S second
#define pb(x) push_back(x)a
#define mp(x, y) make_pair(x, y)

using namespace std;
using namespace __gnu_pbds;

template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void _debug(istream_iterator<string>) {}
template<typename T, typename... Args>
void _debug(istream_iterator<string> it, T first, Args... args) {
    cerr << ">> " << *it << " : " << first << endl; _debug(++it, args...);
}
template <typename T1, typename T2>
inline ostream& operator << (ostream& out, const pair<T1, T2>& p) {
    return out << "(" << p.F << ", " << p.S << ")";
}
template<typename T>
inline ostream& operator << (ostream& out, const vector<T>& v) {
    if (v.empty()) return out << "[]";
    else { out << '['; for (auto& e : v) { out << e << ", "; } return out << "\b\b]"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const set<T>& s) {
    if (s.empty()) return out << "{}";
    else { out << '{'; for (auto& e : s) { out << e << ", "; } return out << "\b\b}"; }
}
template<typename T>
inline ostream& operator << (ostream& out, const unordered_set<T>& s) {
    return out << set<T>(ALL(s));
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const map<T1, T2>& m) {
    if (m.empty()) return out << "{}";
    out << '{'; for (auto& p : m) { out << p << ", "; } return out << "\b\b}";
}
template<typename T1, typename T2>
inline ostream& operator << (ostream& out, const unordered_map<T1, T2>& m) {
    return out << map<T1, T2>(ALL(m));
}
template<typename T>
inline ostream& operator << (ostream& out, const ordered_set<T>& s) {
    return out << set<T>(ALL(s));
}

typedef long long ll;
typedef long double ld;
typedef vector<long long> vll;
typedef pair<ll, ll> pll;
typedef vector<pair<ll, ll>> vpll;
typedef unordered_map<ll, ll> STll;
/************************************** MAIN PROGRAM ********************************************/

int main()
{
    //freopen("input.txt", "r", stdin);
    SPEED
    ll a; string b;
    cin >> a;
    string bs;
    cin >> b;
    for (auto c : b) {
        if (c == '.') continue;
        bs += c;
    }
    //DEBUG(bs)
    ll B = stoll(bs);
    ll ans = a * B;
    cout << ans / 100;
}
/************************************** END OF PROGRAM ******************************************/
/** Stuff you should look for:
 * int overflow, array bounds, over-counting
 * special cases (n=1?), set/unordered_set TLE, multi-set/set error
 * do something instead of nothing and stay organized
 */


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

using namespace std;

int main() {
    cin.tie(nullptr); ios::sync_with_stdio(false);
	
    int n; cin>>n;
    vector<int> P(n);
    for (auto& p : P) cin >> p;
    
    int ans = 0;
    for (int i = 1; i < n-1; i++) {
        if (P[i-1] < P[i] and P[i] < P[i+1] or
            P[i-1] > P[i] and P[i] > P[i+1])
            ans++;
    }
    cout << ans << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
  int n,l,i,j,k,h[100],b;
  char s[100][101];
  bool u;
  scanf("%d%d",&n,&l);
  for (i=0;i<n;i++){
    scanf("%s",s[i]);
    h[i]=i;
  }
  for (i=0;i<n-1;i++){
    for (j=i+1;j<n;j++){
      u=false;
      for (k=0;k<l;k++){
        if ((int)s[h[i]][k]>(int)s[h[j]][k]){
          u=true;
          break;
        }else if ((int)s[h[i]][k]<(int)s[h[j]][k]) break;
      }
      if (u){
        b=h[i];
        h[i]=h[j];
        h[j]=b;
      }
    }
  }
  for (i=0;i<n;i++) printf("%s",s[h[i]]);
  return 0;
}

Measured memory_bytes: 128
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: u32,
        w: u32,
    }
    if s <= w {
        println!("unsafe");
    } else {
        println!("safe");
    }
}


Measured memory_bytes: 2164
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            String sArr[] = br.readLine().split(" ");
            int numArr[] = new int[sArr.length];
            numArr[0] = Integer.parseInt(sArr[0]);
            numArr[1] = Integer.parseInt(sArr[1]);
            numArr[2] = Integer.parseInt(sArr[2]);
            Arrays.sort(numArr);
            System.out.println(numArr[2] * 10 + numArr[1] + numArr[0]);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

}


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

int main() {
	ios_base::sync_with_stdio( false );
	
	int64_t K, A, B;
	cin >> K >> A >> B;

	if( B-A <= 2 || K <= A ) {
		cout << K+1 << endl;
		return 0;
	}

	K -= A-1;
	int64_t x = K/2;
	cout << A + x * (B-A) + (K & 1) << endl;

	return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
from math import *
from itertools import *
from collections import *
from functools import *
try:
    from math import gcd
except Exception:
    from fractions import gcd


def solve(N: int, i: int):
    return N - (i - 1)


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    i = int(next(tokens))  # type: int
    result = solve(N, i)
    print(result)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5140
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <iomanip>
#include <bitset>
#include <list>
#include <ctime>
using namespace std ;
#define SET(arr, what)  memset(arr, what, sizeof(arr))
#define FF(i, s, e)     for(int i=s; i<e; i++)
#define SD(a)           scanf("%d", &a)
#define SSD(a, b)       scanf("%d%d", &a, &b)
#define SF(a)           scanf("%lf", &a)
#define SS(a)           scanf("%s", a)
#define SLD(a)          scanf("%lld", &a)
#define PF(a)           printf("%d\n", a)
#define PPF(a, b)       printf("%d %d\n", a, b)
#define SZ(arr)         (int)arr.size()
#define SWAP(a,b)       a=a xor b;b= a xor b;a=a xor b;
#define READ            freopen("in.txt", "r", stdin)
#define WRITE           freopen("fracdec.out", "w", stdout)
#define SYNCOFF         std::ios_base::sync_with_stdio(false);
#define MAX             1<<30
#define ESP             1e-5
#define lson            l, m, rt<<1
#define rson            m+1, r, rt<<1|1
template<class T> inline T sqr(T a){return a*a;}
template<class T> inline void AMin(T &a,T b){if(a>b)a=b;}
template<class T> inline void AMax(T &a,T b){if(a<b)a=b;}
template<class T> inline T Min(T a,T b){return a>b?b:a;}
template<class T> inline T Max(T a,T b){return a>b?a:b;}

int t[1100000],flag[1100000],idx[1100000];
char query[1100000];
int n,q;


int find(int n)
{
    //if(n == 0)
//	int m = 1;
    if(flag[n] != 0)
    {
	return n;	    
    }

    else
    {	
	return t[n] = find(t[n]);    
    }
	
    

//    int node = n;
    //while(flag[t[node]] != 1 )
//	{
//	    node = t[node];
//	}
//    return t[node];
}

int main(int argc,char* argv[])
{
//#ifndef ONLINE_JUDGE
//    READ;
//#endif
    SYNCOFF;
    while( (std::cin>>n>>q) && !(n==0&&q==0))
    {
	int ii = 0;
	int root,tmp;
	long long ret = 0;
	char chs[100],ch;
	memset(flag,0,sizeof(flag));
	t[1] = 1;
	flag[1] = 1;
	for(int i = 2 ; i <= n ; i++)
	{
	    std::cin >> root;
	    t[i] = root;
	}

	for(int i = 0 ; i < q ; i++)
	{
	    cin.getline(chs,100);
	    ch = cin.get();
	    cin>>tmp;

	    query[i] = ch;
	    idx[i] = tmp;
	    
	    //if(ch == 'M')
	    //	flag[tmp] = 1;
	    //if(ch == 'Q')
	    //	ret = ret + find(tmp);
	}

	ii = ii + 1;
	if(ii == 5)
	    int m = 0;
	for(int i = q - 1 ; i >= 0; i--)
	{
	    if(query[i] == 'M' )  flag[idx[i]]++;
	}

	for(int i = q - 1; i >= 0 ; i--)
	{
	    if(query[i] == 'M') flag[idx[i]]--;
	    else ret = ret + find(idx[i]);
	    //std::cout<<idx[i]<<std::endl;
	    //if(idx[i] == 0)
	    //int m = 1;
	}
	
	std::cout<< ret <<std::endl;
    }
    return 0;
}

Measured memory_bytes: 7992
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++) 
#define rep(i,n); for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b); 
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define all(v) (v).begin(),(v).end()
#define pb push_back
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  int n,m;
  cin>>n>>m;
  if(2*n>=m){
    cout<<(m/2)<<endl;
  }else{
    cout<<n+(m-2*n)/4<<endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <cstdio>

using namespace std;

#define LL long long

LL f[60][2];
int a[60];

int main()
{
	int n,p;
	scanf("%d%d",&n,&p);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	f[0][0]=1;
	for(int i=0;i<n;i++)
	{
		f[i+1][0]+=f[i][0];
		f[i+1][1]+=f[i][1];
		f[i+1][a[i]&1]+=f[i][0];
		f[i+1][!(a[i]&1)]+=f[i][1];
	}
	printf("%lld\n",f[n][p]);
	return 0;
} 

Measured memory_bytes: 128
//Author: AnandRaj doubleux
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<pll> vpll; 

#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define test() int t;cin>>t;while(t--)
#define all(v) v.begin(),v.end()
#define prinp(p) cout<<p.first<<" "<<p.second<<endl
#define prinv(V) for(auto v:V) cout<<v<<" ";cout<<endl
#define take(V,f,n) for(int in=f;in<f+n;in++) cin>>V[in]
#define what(x) cerr<<#x<<" = "<<x<<endl
#define KStest() int t,t1;cin>>t;t1=t;while(t--)
#define KScout cout<<"Case #"<<t1-t<<": "
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
const int MOD = 1e9+7,MAX = 1e6+5;
const ll INF = 1e18+5;
/////////////////FastExp///////////////////
ll powN(ll a,ll p)
{
	if(p==0) return 1;
	ll z=powN(a,p/2);
	z=(z*z)%MOD;
	if(p%2) z=(z*a)%MOD;
	return z;
}
/////////////////FastExp///////////////////
///////////////////PnC/////////////////////
vl Fac(MAX),Inv(MAX);
void CalcFac()
{
	Fac[0]=Inv[0]=1;
	for(int i=1;i<MAX;i++)
	{
		Fac[i]=(Fac[i-1]*i)%MOD;
		Inv[i]=powN(Fac[i],MOD-2);
	}
}

ll NCR(int n,int r)
{
	if(r>n) return 0;
	return (((Fac[n]*Inv[r])%MOD)*Inv[n-r])%MOD;
}
///////////////////PnC/////////////////////
//////////////////Sieve////////////////////
vector<bool> is_prime(MAX, true);
vi MinDiv(MAX);
void Sieve()
{
	is_prime[0] = is_prime[1] = false;
	int i,j;
	for (i = 2; i*i <= MAX; i++) 
	{
    	if (is_prime[i]) 
    	{
    		MinDiv[i]=i;
        	for (j = i * i; j <= MAX; j += i)
            {
				is_prime[j] = false;
				MinDiv[j]=i;
    		}
    	}
	}
	for(int i=2;i<=MAX;i++) if(is_prime[i]) MinDiv[i]=i;
}
//////////////////Sieve////////////////////

int main()
{
	int h,w,k;
	cin>>h>>w>>k;
	int ans=0;
	vector<string> X(h);
	take(X,0,h);
	int tot = (1<<(h+w));
	for(int c=0;c<tot;c++)
	{
		set<int> R,C;
		int x=0;
		for(int i=0;i<h;i++)
		{
			if((c>>i)&1) R.insert(i);
		}
		for(int i=h;i<h+w;i++)
		{
			if((c>>i)&1) C.insert(i-h);
		}

		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(R.count(i)||C.count(j)) continue;
				else
				{
					if(X[i][j]=='#') x++;
				}
			}
		}
		if(x==k) ans++;
	}
	cout<<ans<<endl;
}	

Measured memory_bytes: 22960
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
INF =  float("inf")
import bisect
import statistics
mod = 10**9+7

def matrix_mul(a,b):
    n = len(a)
    c = [[0 for j in range(n)] for i in range(n)]
    for i in range(n):
        for j in range(n):
            for k in range(n):
                c[i][j] += (a[i][k]*b[k][j]) % mod

            c[i][j] = c[i][j] % mod

    return c

def mul_pow(x, k):
    n = len(x)
    c = [[0 for j in range(n)] for i in range(n)]

    for i in range(n):
        c[i][i] = 1

    while (k > 0):
        if k & 1: c = matrix_mul(c, x)
        x = matrix_mul(x, x)
        k = k >> 1
    return c

N, K = list(map(int, input().split()))
a = [[] for i in range(N)]

for i in range(N):
    a[i] = list(map(int, input().split()))

a = mul_pow(a, K)

ans = 0
for i in range(N):
    ans = (ans + sum(a[i])) % mod

print(ans % mod)





Measured memory_bytes: 73684
#include<iostream>
using namespace std;
int main(){
  int f[3]={1,1,1},n;
  cin >> n;
  while(1<n--){
    f[2]=f[0]+f[1];
    f[0]=f[1];    
    f[1]=f[2];
  }
  cout<<f[2]<<endl;
  return 0;
}

Measured memory_bytes: 1160
N = int(input())
H = list(map(int, input().split()))

ans = 0
count = 0

for i in range(N-1):
    if H[i+1] - H[i] <= 0:
        count += 1
    else:
        ans = max(ans,count)
        count = 0

ans = max(ans,count)
print(ans)

Measured memory_bytes: 14224
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;

int main(){
  ll n;
  cin >> n;
  ll a=0,b=0,c=0,d=0;
  for(ll i=0;i<n;i++){
    string str;
    cin >> str;
    if(str=="AC") a++;
    else if(str=="WA") b++;
    else if(str=="TLE") c++;
    else d++;
  }
  cout << "AC x " <<a << endl;
  cout << "WA x " <<b << endl;
  cout << "TLE x " <<c << endl;
  cout << "RE x " <<d << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")

#define rep(i,n) for(int i=0;i<n;i++)
const long long MOD = 1000000007;
typedef pair<int,int> P;
typedef long long ll;
ll n,m,k,ans;
string s;

int main(){
  string t[3]; rep(i,3) cin >> t[i];
  int i[3] = {};
  int tmp = 0;
  while(i[0] <= t[0].size() && i[1] <= t[1].size() && i[2] <= t[2].size()){
    i[tmp]++;
    if(i[0] > t[0].size()) {
      cout << "A\n"; break;
    }else if(i[1] > t[1].size()) {
      cout << "B\n"; break;
    }else if(i[2] > t[2].size()){
      cout << "C\n"; break;
    }
    tmp = (int)( t[tmp][i[tmp]-1] - 'a');
  }
}

Measured memory_bytes: 256
N,K=map(int,input().split())
S=input()
s=[S[i] for i in range(N)]
m=min(s)

if K>=14:
    ans=[m for i in range(N)]
    print("".join(ans))
elif K==1:
    res=["z"]*N
    s=s+s[::-1]
    for i in range(N+1):
        test=s[i:i+N]
        if res>test:
            res=test
    print("".join(res))
else:
    cnt=0
    for i in range(N-1,-1,-1):
        if s[i]==m:
            cnt+=1
        else:
            break
    res=cnt
    for i in range(N-1,-1,-1):
        if cnt<N:
            if s[i]==m:
                cnt+=1
            else:
                cnt=0
        else:
            if s[i]!=m:
                cnt=0
        res=max(res,cnt)

    test=[]
    cnt=0
    for i in range(N-1,-1,-1):
        if s[i]==m:
            cnt+=1
        else:
            break
    if res*2**(K-1)>=N:
        ans=[m]*N
        exit(print("".join(ans)))
    check=N-res*2**(K-1)
    if cnt==res:
        test.append(N-1)
    for i in range(N-1,-1,-1):
        if cnt<N:
            if s[i]==m:
                cnt+=1
            else:
                cnt=0
        else:
            if s[i]!=m:
                cnt=0
        if cnt==res:
            test.append(N-1+N-i)
    result=[]
    for t in test:
        temp=s+s[::-1]
        temp=temp[t+1-res-check:t+1-res]
        temp=temp[::-1]
        result.append(temp)
    ans1=min(result)
    ans=[m]*res*2**(K-1)+ans1
    print("".join(ans))

Measured memory_bytes: 108760
#include<bits/stdc++.h>
#define boom {puts("No"); return 0;}
using namespace std;
typedef long long ll;
ll n, a[100005][4], rev[2], inv[2];
vector<ll> x[2];

struct segtree {
	ll val[444444], lim;
	void init (ll X) {
		for(lim=1;lim<=X;lim<<=1);
		for(ll i=2*lim; --i; ) val[i] = 0;
	}
	void update (ll P, ll V) {
		P += lim;
		while(P) {
			val[P] += V;
			P >>= 1;
		}
	}
	ll query (ll S, ll E) {
		S += lim; E += lim;
		ll ret = 0;
		while(S <= E) {
			if(S % 2 == 1) ret += val[S++];
			if(E % 2 == 0) ret += val[E--];
			S >>= 1; E >>= 1;
		}
		return ret;
	}
} seg;

void solve (vector<ll> &V, ll &A) {
	seg.init(V.size());
	for(auto &T : V) {
		A += seg.query(T + 1, V.size());
		seg.update(T, 1);
	}
}

int main()
{
	scanf("%lld",&n);
	for(ll i=0;i<3;i++) for(ll j=1;j<=n;j++) {
		scanf("%lld",&a[j][i]);
	}
	for(ll i=1;i<=n;i++) {
		if(abs(a[i][1] - a[i][0]) != 1 || a[i][1] - a[i][0] != a[i][2] - a[i][1]) boom;
		if(a[i][1] - a[i][0] < 0) rev[i%2]++;
		ll mx = max(a[i][0], a[i][2]);
		if(mx % 3 != 0 || (mx/3) % 2 != i % 2) boom;
		x[i%2].push_back((mx/3+1)/2);
	}
	solve(x[0], inv[0]);
	solve(x[1], inv[1]);
	for(int i=0;i<2;i++) if((inv[i^1] + rev[i]) % 2) boom;
	puts("Yes");
}


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

int main(){
  int counts = 0;
  string s,t;
  cin >> s >> t;
  rep(i,s.size()){
   if(s.at(i) != t.at(i)) counts++; 
  }
  cout << counts << endl;
}

Measured memory_bytes: 3844
sub f{map{push@$_,$_[--$|]for@_=glob}<>;$Y[$_]=++$d;$Y[$_]//&f for@$_;--$d}@X=@Y,f@Y=0for(glob<>)[1,2];$X[$j++]<$_&&\$@[$_]for@Y;print@@-3

Measured memory_bytes: 161152
#include <cstdio>
#include <algorithm>
#include <cstring>
using namespace std;
const int maxn=15,INF=1e9;
int n,m,x,c[maxn],a[maxn][maxn];
int skill[maxn],sum;
int solve()
{
	int ans=INF;
	for(int j=0;j<1<<n;++j)
	{
		memset(skill,0,sizeof(skill));
		sum=0;
		for(int i=0;i<n;++i)if((1<<i)&j)
		{
			sum+=c[i];
			for(int k=0;k<m;++k) skill[k]+=a[i][k];
		}
		bool flag=true;
		for(int i=0;i<m;++i) if(skill[i]<x){flag=false;break;}
		if(flag) ans=min(ans,sum);
	}
	return ans;
}
int main()
{
	scanf("%d%d%d",&n,&m,&x);
	for(int i=0;i<n;++i)
	{
		scanf("%d",&c[i]);
		for(int j=0;j<m;++j) scanf("%d",&a[i][j]);
	}
	int ans=solve();
	if(ans>=INF) printf("-1");
	else printf("%d",ans);
	return 0;
}

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

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

using namespace std;

using ll = long long;
using P = pair<int , int>;
  
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);

  double a, b; cin >> a >> b;
  for(int i = 1; i <= 100100; ++i) {
    if(a == floor(i*0.08) && b == floor(i*0.1)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef long long ll;

const ll mod=1e9+7;

#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define rc(x)  return cout<<x<<"\n",0
#define sz(s)  (int) s.size()

#define pb push_back
#define mp make_pair
#define fr first
#define sc second

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

ll pow(ll a, ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2) res=(res*a)%mod;
		a=(a*a)%mod;
		b/=2;
	}
	return res;
}

int ugabuga()
{

	int n;
	cin>>n;

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

	vector<int>dp(n,2e9);
	dp[0]=0;

	for(int i=0;i<n;i++)
	{
		for(int j=i+1;j<i+3;j++)
			if(j<n)
			{
				dp[j]=min(dp[j],dp[i]+abs(a[i]-a[j]));
			}
	}

	cout<<dp[n-1];

	return 0;
}


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

    int t=1;
    //cin>>t;
    while(t--)
    {
        ugabuga();
    }

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = 1<<29;
typedef long long ll;

int dp[100][2][100];//dp[keta][未満である][0でない数の個数]

struct UnionFind {
  vi parent;
  UnionFind(int N) : parent(N) {
    rep(i, N)parent[i] = i;
  }

  int getRoot(int child){
    return ((parent[child] == child) ? child : parent[child] = getRoot(parent[child]));
  }
  void unite(int x, int y){
    int root_x = getRoot(x);
    int root_y = getRoot(y);
    if(root_x == root_y)return;
    parent[root_x] = parent[root_y];
  }
  bool isSame(int x, int y){
    return getRoot(x) == getRoot(y);
  }
};

int main(){
    int N;ll K;cin >> N >> K;
    pair<int, ll> A[N];
    rep(i, N){
        cin >> A[i].first >> A[i].second;
    }
    sort(A, A+N);
    rep(i, N){
        K -= A[i].second;
        if(K <= 0){
            cout << A[i].first << endl;;
            break;
        }
    }
}


Measured memory_bytes: 1792
import java.util.Scanner;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.List;
import java.util.Collections;

public class Main {
	public static void main(String args[]){
		    Scanner sc = new Scanner(System.in);	
			
			int n = sc.nextInt();
			int[] ar = new int[n];
			int mincost = Integer.MAX_VALUE;
			int sumcost = 0;
			for (int i = 0; i < n; i++) {
				ar[i] = sc.nextInt();
			}
			for (int i = -100; i <= 100; i++) {
				for (int j = 0; j < n; j++) {
					sumcost = sumcost + Math.abs(ar[j]-i)*Math.abs(ar[j]-i);
				}
				if (sumcost < mincost) {
					mincost = sumcost;
				}
				sumcost = 0;
			}
			System.out.println(mincost);


		    sc.close(); }

	public static boolean isEven(int n ) {
		if (n % 2 == 0) {
			return true;
		}else{
			return false;
		}
	}
}

Measured memory_bytes: 21844
N,M = map(int,input().split())
MOD = 10 ** 9 + 7

if abs(N-M) >= 2:
  print(0)
  exit()
  
N,M = max(N,M),min(N,M)
fctr_M = 1
for i in range(1,M+1):
  fctr_M *= i
  fctr_M %= MOD

ans = fctr_M * fctr_M
ans %= MOD
if N == M:
  ans *= 2
  ans %= MOD
else:
  ans *= N
  ans %= MOD

print(ans)
  
  


Measured memory_bytes: 9104
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
  int N;
  int Alice = 0, Bob = 0;

  cin >> N;
  vector<int> a(N, 0);
  for (int i = 0; i < N; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

    
  for (int i = 0; i < N; i++) {
    if (i%2 == 0){
      Alice += a.at(i);
    } else {
      Bob += a.at(i);
    }
  }
  cout << Alice - Bob << endl;


}

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

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; }
const ll INF = 1LL << 60;

//---main---------------------------------------------
int main(){
    //main
    ll L,R;
    cin >> L >> R;
    ll ans = 2020;
    ll imax;
    imax = min(L+4038,R);

    for(ll i = L; i<=imax; ++i){
        for(ll j = i+1; j<=imax; ++j) chmin(ans, (i*j)%2019 );
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3580
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)

using namespace std;

inline void inp( int &n ) { 
	n=0;    int ch=getcx();int sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

inline void inp1( LL &n ) { 
	n=0;    LL ch=getcx();LL sign=1;   
	while( ch < '0' || ch > '9' ){if(ch=='-')sign=-1; ch=getcx();} 
	while(  ch >= '0' && ch <= '9' )    
	n = (n<<3)+(n<<1) + ch-'0', ch=getcx();
	n=n*sign;
}

int main() {
	string s, t;
	cin>>s;
	cin>>t;
	
	if(s.length() != t.length() - 1) cout<<"No"<<endl;
	else {
		string x = t.substr(0, s.length());
		if(x.compare(s) == 0) cout<<"Yes"<<endl;
		else cout<<"No"<<endl;
	}
    return 0;
}



Measured memory_bytes: 3608
#include<bits/stdc++.h>
using namespace std;
long long MOD = (1e9+7);
int main()
{
  int n,m;
  cin >> n >> m;
  vector<string > grid(n);
  for(int i =0;i<n;i++)
  {
    cin >> grid[i];
  }
  vector<vector<long long> > dp(n,vector<long long>(m));
  dp[0][0] = 1;
  for(int i = 1;i<n;i++)
  {
    if(grid[i][0] == '#')
     	dp[i][0] = 0;
    else
    	dp[i][0] = dp[i-1][0];
  }
  for(int i = 1;i<m;i++)
  {
    if(grid[0][i] == '#')
     	dp[0][i] = 0;
    else
    	dp[0][i] = dp[0][i-1];
  }
      for(int i =1;i<n;i++)
  {
    for(int j = 1;j<m;j++)
    {
      if(grid[i][j] == '#')
        dp[i][j] = 0;
      else
        dp[i][j] = (dp[i-1][j] + dp[i][j-1] )%MOD;
    }
  }

  cout << (dp[n-1][m-1]%MOD) << endl;
  return 0;
}


Measured memory_bytes: 12892
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for(inti=a;i<=b;i++)

#define MOD 1000000009
typedef long long int ll;
typedef vector<int>vi;
typedef pair<int,int>pi;





int main()
{

int n ,k;
cin>>n>>k;

int ans = 0;
for(int index = 0 ;index < n ;index++)
{
    int x;
    cin>>x;

    ans +=min(2*x,2*abs(x-k));
}
cout<<ans<<endl;

 return 0;
}


Measured memory_bytes: 3608
#include <iostream>
#include <iomanip>
#include <cassert>

#include <cstring>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <limits>
#include <queue>
#include <unordered_map>
#include <list>
#include <set>
#include <numeric>
using namespace std;

using ll = long long;

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

template<typename T>
constexpr T divide_ceil(T a, T b)
{
	T remainder = a % b;
	return remainder == 0 ? a / b : (a + (b - remainder)) / b;
}


int main()
{
	ll N;
	vector<ll> A(5);

	cin >> N;
	ll min_ = numeric_limits<ll>::max();
	int min_i;
	rep(i, 5)
	{
		cin >> A[i];
		if (min_ > A[i])
		{
			min_ = A[i];
			min_i = i;
		}
	}

	cout << 4 + divide_ceil(N, min_) << endl;
	
}

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

#define ll long long
#define pi pair<int,int>
#define ppi pair<pi,pi>
#define mp make_pair
#define fr first
#define sc second

using namespace std;


int main(){
//    ios::sync_with_stdio(0);
//    cin.tie(0) , cout.tie(0);
    int n , m; cin >> n >> m;
    vector<int>v;
    int sum = 0;
    for(int i = 0;i < n;i++){
        int x; cin >> x;
        v.push_back(x);
        sum += x;
    }
    sort(v.begin(),v.end());
    reverse(v.begin(),v.end());
    int cnt = 0;
    for(int i = 0;i < n;i++){
        if((double)sum / (4 * m) > v[i])break;
        cnt++;
    }
    if(cnt >= m)cout << "Yes\n";
    else        cout << "No\n";
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = [input() for _ in range(n)]
for i in range(n):
  s[i] = ''.join(sorted(s[i]))
t = {}
for i in range(n):
  if s[i] in t:
    t[s[i]] += 1
  else:
    t[s[i]] = 1
print(sum(t[k] * (t[k] -1) // 2 for k in t))

Measured memory_bytes: 73048
N,K = map(int,input().split())
K = K-1
S = input()
S_list = list(S)
if S_list[K] == "A":
  S_list[K] = "a"
elif S_list[K] == "B":
  S_list[K] = "b"
else:
  S_list[K] = "c"

S_changed = "".join(S_list)
print(S_changed)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;
constexpr ll INF=1LL<<60;
const ll dx[]={1,0};
const ll dy[]={0,1};
int main()
{
  ll h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(auto&& e: s) 
  {
    cin>>e;
  }
  vector<vector<ll>> dp(h,vector<ll>(w,INF));
  dp[0][0]=s[0][0]=='#'?1:0;

  queue<pair<ll,ll>> nxt;
  nxt.push({0,0});
  while (!nxt.empty()) {
    ll x=nxt.front().first;
    ll y=nxt.front().second;
    nxt.pop();
    for (int i = 0; i < 2; ++i) {
      ll nx=x+dx[i];
      ll ny=y+dy[i];
      if (nx>=h||ny>=w) continue;
      if (dp[nx][ny]>dp[x][y]+((s[x][y]=='.'&&s[nx][ny]=='#')? 1:0)) {
        dp[nx][ny]=dp[x][y]+((s[x][y]=='.'&&s[nx][ny]=='#')? 1:0);
        nxt.push({nx,ny});
      }
    }
  }
  // for (int i = 0; i < h; ++i)
  // {
  //   for (int j = 0; j < w; ++j)
  //   {
  //     cout<<dp[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }
  cout<<dp[h-1][w-1]<<endl;
}

Measured memory_bytes: 3668
// dfmt off
T lread(T=long)(){return readln.chomp.to!T;}T[] lreads(T=long)(long n){return iota(n).map!((_)=>lread!T).array;}
T[] aryread(T=long)(){return readln.split.to!(T[]);}void arywrite(T)(T a){a.map!text.join(' ').writeln;}
void scan(L...)(ref L A){auto l=readln.split;foreach(i,T;L){A[i]=l[i].to!T;}}alias sread=()=>readln.chomp();
void dprint(L...)(lazy L A){debug{auto l=new string[](L.length);static foreach(i,a;A)l[i]=a.text;arywrite(l);}}
static immutable MOD=10^^9+7;alias PQueue(T,alias l="b<a")=BinaryHeap!(Array!T,l);import std, core.bitop;
// dfmt on

void main()
{
    long N, P;
    scan(N, P);
    auto A = aryread();
    long[2] cnt;
    foreach (a; A)
        cnt[a & 1]++;
    if (cnt[1] == 0 && P == 1)
    {
        writeln(0);
        return;
    }
    long ans = 2 ^^ cnt[0];
    dprint(cnt, ans);
    long tmp;
    foreach (x; 0 .. N + 1)
    {
        if (cnt[1] < 2 * x + P)
            break;
        tmp += combination(cnt[1], 2 * x + P);
    }
    writeln(ans * tmp);
}

/// Number of k-combinations
T combination(T = long)(T n, T k)
{
    assert(0 <= k);
    assert(0 <= n);
    if (n < k)
        return 0;
    k = min(n - k, k);
    if (k == 0)
        return 1;
    if (k == 1)
        return n;
    return memoize!(combination!T)(n - 1, k - 1) + memoize!(combination!T)(n - 1, k);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
//#define cerr if (false) cerr
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
template <typename A, typename B>
ostream& operator<<(ostream& os, const pair<A, B>& x) {
	return os << "(" << x.first << "," << x.second << ")";
}
typedef long long ll;
typedef long double ld;
int main() {
	int n, k;
	scanf("%d%d", &n, &k);
	printf("%d\n", k == 1 ? 0 : n - (k - 1) - 1);
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int add(string a,string b){//a+b
	int t=min(a.size(),b.size());
	int c=a.size();
	for(int i=t;i>=0;i--){
		bool h=true;
		rep(j,i)if(a[c-i+j]!=b[j])h=false;
		if(h)return b.size()-i;
	}
}
int main(){
	int n;
	while(cin>>n,n){
		vector<string>in(n);
		rep(i,n)cin>>in[i];
		sort(all(in));
		n=unique(all(in))-in.begin();
		vector<bool>ha(n,true);
		rep(i,n)rep(j,n)if(i!=j&&in[i].find(in[j])!=string::npos)ha[j]=false;
		vector<string>tmp;
		rep(i,n)if(ha[i])tmp.pb(in[i]);
		in=tmp;n=in.size();
		int w=(1<<n);
		vvi c(n,vi(n));
		rep(i,n)rep(j,n)c[i][j]=add(in[i],in[j]);
		vvi dp(w,vi(n,inf));
		rep(i,n)dp[1<<i][i]=in[i].size();
		loop(i,1,1<<n)rep(j,n)if(i&1<<j)rep(k,n)if((i&1<<k)==0){
			int t=i^1<<k;
			dp[t][k]=min(dp[t][k],dp[i][j]+c[j][k]);
		}
		w--;
		int out=inf;
		rep(i,n)out=min(out,dp[w][i]);
		cout<<out<<endl;
	}
}

Measured memory_bytes: 2588
import java.util.*;

class Main {
    public static void main(String[] args) throws java.lang.Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] an = new int[n + 1];
        int[] bn = new int[n];
        for (int i = 0; i < n + 1; i++) {
            an[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            bn[i] = sc.nextInt();
        }
        sc.close();

        long count = 0;
        for (int i = 0; i < n; i++) {
            if (an[i] >= bn[i]) {
                count += bn[i];
                continue;
            } else {
                count += an[i];
                bn[i] = bn[i] - an[i];
            }
            if (an[i + 1] > bn[i]) {
                count += bn[i];
                an[i + 1] = an[i + 1] - bn[i];
            } else {
                count += an[i + 1];
                an[i + 1] = 0;
            }
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 64912
#include <cstdio>
#include <iostream>
#include <sstream>

#include <deque>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////

struct unionfind{
    vi data;
    unionfind(int n):data(n, -1){};
    int root(int idx){
        return data[idx] < 0 ? idx : data[idx] = root(data[idx]);
    }
    bool same(int l, int r){
        return (l = root(l))==(r = root(r));
    }
    void join(int l, int r){
        l = root(l); r = root(r);
        if(l != r){
            if(data[l] > data[r])swap(l, r);
            data[l] += data[r];
            data[r] = l;
        }
    }
    int size(int idx){
        return -data[root(idx)];
    }
};


int main() {
  int h, w;
  cin >> h >> w;
  vector<string> s(h);
  for(auto&& x:s)cin >> x;
  // unionfind u(h*w+500), d(h*w+500), l(h*w+500), r(h*w+500);
  vvi u(h, vi(w)), d(u), l(u), r(u);
  for(int i=0;i<h;i++){
    for(int j=0, jj=0;j<=w;j++){
      if(j == w || s[i][j] == '#'){
        for(;jj<=j && jj < w;jj++){
          r[i][jj] = j;
        }
      }
    }
    
    for(int j=w-1, jj=w-1;j>=-1;j--){
      if(j == -1 || s[i][j] == '#'){
        for(;jj>=j && jj >= 0;jj--){
          l[i][jj] = j;
        }
      }
    }
  }
  for(int j=0;j<w;j++){
    for(int i=0, ii=0;i<=h;i++){
      if(i == h || s[i][j] == '#'){
        for(;ii<=i && ii < h;ii++){
          d[ii][j] = i;
        }
      }
    }
    for(int i=h-1, ii=h-1;i>=-1;i--){
      if(i == -1 || s[i][j] == '#'){
        for(;ii>=i && ii >= 0;ii--){
          u[ii][j] = i;
        }
      }
    }
  }
  int res = 0;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(s[i][j] == '#')continue;
      int ul = abs(u[i][j] - i);
      int dl = abs(d[i][j] - i);
      int ll = abs(l[i][j] - j);
      int rl = abs(r[i][j] - j);
      int light = ul + dl + ll + rl - 3;
      res = max(light, res);
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 67200
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

int main(void){
    int n; cin >> n;
    int x, y; cin >> x >> y;

    int offset = 150;
    vector<vi> dp[2];
    int d1 = x + 1, d2 = y + 300 + offset;
    rep(i, 2) dp[i] = vector<vi>(d1, vi(d2, -1));
    dp[0][x][y + offset] = 0;

    int i = 0;
    rep(loop, n){
        int a, b, c, d; scanf("%d %d %d %d", &a, &b, &c, &d);

        int pre = i;
        i = !i;
        rep(tako, d1){
            rep(fuga, d2){
                dp[i][tako][fuga] = -1;
            }
        }

        rep(tako, d1){
            rep(fuga, d2){
                if(dp[pre][tako][fuga] == -1) continue;
                int buta = dp[pre][tako][fuga];

                chmax(dp[i][tako    ][fuga    ], buta);

                if(fuga - c >= 0)
                chmax(dp[i][tako    ][fuga - c], buta + d);

                if(tako - a >= 0 and fuga + b < d2)
                chmax(dp[i][tako - a][fuga + b], buta);
            }
        }
    }

    int res = 0;
    rep(tako, d1){
        rep(fuga, d2){
            int buta = dp[i][tako][fuga];

            if(fuga >= offset){
                chmax(res, buta);
            }
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 4768
import scala.io.StdIn.readLine

object Main {

  def main(args: Array[String]) = {
      val n = readLine().split(" ").map(_.toInt)
      val (w,h,x,y,r) = (n(0),n(1),n(2),n(3),n(4))
      val s = if(x-r < 0 || y - r < 0 || x + r > w || y + r > h) "No" else "Yes"
      println(s)
  }
}

Measured memory_bytes: 43776
N, K = map(int, input().split())
d = []
A = []

for i in range(K):
    d.append(int(input()))
    A.append(list(map(int, input().split())))


count = 0
li = []
for i in range(K):
    for a in A[i]:
        if not a in li:
            count += 1
            li.append(a)

print(N - count)


Measured memory_bytes: 9280