akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long N, K;
    cin >> N >> K;
    vector<long long> A(N);
    vector<long long> m(0), p(0);
    long long cz = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        if(A[i] < 0) m.push_back(-A[i]);
        else if(A[i] == 0) cz++;
        else p.push_back(A[i]);
    }
    sort(m.begin(), m.end());
    sort(p.begin(), p.end());
    sort(A.begin(), A.end());
    long long ub = 2e18, lb = -2e18;
    while(ub - lb > 1){
        long long count = 0;
        long long cen = (ub + lb) / 2;
        for(int i = 0; i < N; i++){
            long long temp = 0;
            if(A[i] != 0) temp = (abs(cen) + abs(A[i]) - 1) / abs(A[i]);
            if(cen < 0){
                if(A[i] > 0) count += m.end() - lower_bound(m.begin(), m.end(), temp);
                else if(A[i] < 0) count += p.end() - lower_bound(p.begin(), p.end(), temp);
            }
            else if(cen == 0){
                if(A[i] > 0) count += cz + m.size();
                else if(A[i] == 0) count += N;
                else count += cz + p.size();
            }
            else{
                if(A[i] > 0) count += cz + m.size() + (upper_bound(p.begin(), p.end(), cen / A[i]) - p.begin());
                else if(A[i] < 0) count += cz + p.size() + (upper_bound(m.begin(), m.end(), cen / abs(A[i])) - m.begin());
                else count += N;
            }
        }
        for(int i = 0; i < N; i++){
            if(A[i]*A[i] <= cen) count--;
        }
        if(count >= 2*K) ub = cen;
        else lb = cen;
    }
    cout << ub << endl;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;using ll=long long;using uint=unsigned int;using pii=pair<int,int>;using pll=pair<ll,ll>;using ull = unsigned long long;using ld=long double;template<typename T>void _(const char*s,T h){cerr<<s<<" = "<<h<<"\n";}template<typename T,typename...Ts>void _(const char*s,T h,Ts...t){int b=0;while(((b+=*s=='(')-=*s==')')!=0||*s!=',')cerr<<*s++;cerr<<" = "<<h<<",";_(s+1,t...);}// break continue pop_back 998244353
#define int ll
#define pii pll
#define f first
#define s second
#define pb emplace_back
#define forn(i,n) for(int i=0;i<(n);++i)
#define sqr(x) ((x)*(x))
struct init{init(){cin.tie(0);std::iostream::sync_with_stdio(0);cout<<std::fixed<<std::setprecision(10);cerr<<std::fixed<<std::setprecision(5);}~init(){
#ifdef LOCAL
#define dbg(...) _(#__VA_ARGS__,__VA_ARGS__)
cerr<<"Time elapsed: "<<(double)clock()/CLOCKS_PER_SEC<<"s.\n";
#else
#define dbg(...) 
#endif
}}init;template<typename T,typename U>void upx(T&x,U y){if(x<y)x=y;}template<typename T,typename U>void upn(T&x,U y){if(x>y)x=y;}

const int N=2e5+5;
int a[N];
// int dp[N][N];
int dp[N];
vector<int> v[N];

// int dp2[15][15];

int32_t main(){
    int n;
    cin>>n;
    v[0]={0};
    dp[0]=0;
    for(int i=1;i<=n+1;++i){
        if(i<=n)cin>>a[i];
        int d=a[i]-a[i-1];
        vector<int> po;
        for(int j:v[i-1]){
            po.pb(j);
            // po.pb(j-1);
            po.pb(j+d);
        }
        sort(po.begin(),po.end());
        po.resize(unique(po.begin(),po.end())-po.begin());
        while(po.back()>a[i])po.pop_back();
        reverse(po.begin(),po.end());
        while(po.back()<0)po.pop_back();
        reverse(po.begin(),po.end());
        int pv=-1;
        for(int j:po){
            vector<pii> b;
            b.pb(0,dp[i-1]);
            b.pb(j+1,+1);
            b.pb(j-d+1,+1);
            for(int k:v[i-1])if(k)b.pb(k,-1);
            sort(b.begin(),b.end());
            int val=0,cu=b[0].f,res=N;
            for(pii p:b){
                if(p.f!=cu){
                    if(cu>=0&&cu<=a[i-1]){
                        upn(res,val);
                    }
                }
                val+=p.s;
                cu=p.f;
            }
            if(cu>=0&&cu<=a[i-1]){
                upn(res,val);
            }
            if(!j)dp[i]=res;
            if(res!=pv)v[i].pb(j);
            pv=res;
        }
    }
    cout<<dp[n+1]<<'\n';
    // dbg("DP2");

    // forn(i,15)forn(j,15)dp2[i][j]=15;
    // dp2[0][0]=0;
    // for(int i=1;i<=n+1;++i){
    //     forn(j,a[i]+1){
    //         forn(k,a[i-1]+1){
    //             upn(dp2[i][j],dp2[i-1][k]+(int)(k>j)+(int)(a[i-1]-k<a[i]-j));
    //         }
    //     }
    //     dbg(dp2[i][0]);
    //     for(int j=1;j<=a[i];++j)
    //         if(dp2[i][j]<dp2[i][j-1])
    //             dbg(j);
    //     dbg("~~~~");
    // }

    return 0;
}


Measured memory_bytes: 17408
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}
use input::*;

fn main() {
    let n: usize;
    input!(n);
    let mut vf = vec![];
    let mut va = vec![];

    for _ in 0..n {
        vf.push(input_vector::<isize>());
    }
    for _ in 0..n {
        va.push(input_vector::<isize>());
    }

    let mut ans = -9999999999_isize;
    for i in 1..1024 {
        let mut ans_buf = 0_isize;
        for j in 0..n {
            let mut c = 0;
            let mut ib = i;
            let mut k = 0;
            while ib > 0 {
                if ib & 1 == 1 && vf[j][k] == 1 {
                    c += 1;
                }
                ib >>= 1;
                k += 1;
            }
            ans_buf += va[j][c];
        }
        ans = std::cmp::max(ans, ans_buf);
    }
    p(ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
 
using namespace std;
 
#define repr(i,a,b) for (int i=a; i<b; i++)
#define rep(i,n) for (int i=0; i<  n; i++)
 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
const long long INF = 1LL << 60;
#define PI 3.14159265359 
 
template<typename T>
void remove(std::vector<T>& vector, unsigned int index)
{
    vector.erase(vector.begin() + index);
}
 
int gcd(int a, int b){
    if(b == 0) return a;
    else return gcd(b, a%b);
}
 
long long lcm (int a, int b){
    return  (long long) a*b /gcd(a,b);
}

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


int main(){
    string S;
    cin >> S;

    long long ans=0;
    rep(i,S.size()){
        int k = S[i] - '0';
        ans += (long long )k;
    }

    if(ans %9 == 0)cout <<"Yes" << endl;
    else cout << "No" << endl;
}



Measured memory_bytes: 3752
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl '\n'
#define ff first
#define ss second
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define int long long 
#define all(a) a.begin(), a.end()
#define inf (1LL<<61)
#define print_time cerr << "Time elapsed: " << 1000.0 * clock() / CLOCKS_PER_SEC << "ms\n";
#define ull unsigned long long
#define debug1(x) cerr << #x << ": " << x <<'\n'
#define debug2(x, y) cerr << #x << ": " << x << '\t' << #y << ": " << y <<'\n'
#define debug3(x, y, z) cerr << #x << ": " << x << '\t' << #y << ": " << y << '\t' << #z << ": " << z <<'\n'
using namespace std;
int dx[]={1,0,-1,0};int dy[]={0,1,0,-1}; //4 Direction
//int dx[]={1,1,0,-1,-1,-1,0,1};int dy[]={0,1,1,1,0,-1,-1,-1};//8 direction
int gcd(int x,int y)
{
   // cout<<x<<' '<<y<<endl;
    if(y==0)
    return x;
    else
    return gcd(y,x%y);
}
int expo(int n,int m,int p)   //modULAR EXPONENTIATION
{
    int r=1;
    n=n%p;
    while(m>0)
    {
    if(m%2)
	r=(r*n)%p;
    n=(n*n)%p;
    m=m/2;
    }
    return r%p;
}
bool isPrime(int n)
{
    // Corner cases
    if (n <= 1)  return false;
    if (n <= 3)  return true;
 
    // This is checked so that we can skip 
    // middle five numbers in below loop
    if (n%2 == 0 || n%3 == 0) return false;
 
    for (int i=5; i*i<=n; i=i+6)
    if (n%i == 0 || n%(i+2) == 0)
       return false;
 
    return true;
}
vector<int> z_function(string s) {
    int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
    if (i <= r)
	z[i] = min (r - i + 1, z[i - l]);
    while (i + z[i] < n && s[z[i]] == s[i + z[i]])
	++z[i];
    if (i + z[i] - 1 > r)
	l = i, r = i + z[i] - 1;
    }
    return z;
}
int n;
int dp[100005][5];
struct day
{
	int a,b,c;
};
day aa[100005];
int solve(int i,int j)
{
	if(i==n)
		return 0;
	if(dp[i][j]!=-1)
		return dp[i][j];
	int ans=0;
	if(j==0)
	{
		ans=aa[i].a+solve(i+1,1);
		ans=max(ans,aa[i].b+solve(i+1,2));
		ans=max(ans,aa[i].c+solve(i+1,3));
	}
	else if(j==1)
	{
		ans=max(ans,aa[i].b+solve(i+1,2));
		ans=max(ans,aa[i].c+solve(i+1,3));
	}
	else if(j==2)
	{
		ans=max(ans,aa[i].a+solve(i+1,1));
		ans=max(ans,aa[i].c+solve(i+1,3));
	}
	else
	{
		ans=max(ans,aa[i].b+solve(i+1,2));
		ans=max(ans,aa[i].a+solve(i+1,1));
	}
	dp[i][j]=ans;
	return ans;
}
int32_t main()
{
   IOS;
   /*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin); 
   freopen("output.txt","w",stdout);
   #endif
   /********************* Code starts here ***********************/
   memset(dp,-1,sizeof(dp));
   cin>>n;
   for(int i=0;i<n;i++)
   {
   	cin>>aa[i].a>>aa[i].b>>aa[i].c;
   }
   cout<<solve(0,0)<<endl;
}                       

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

#include <fstream>
using namespace std;
int N, M, X;
vector<long long> cost(13);
vector<vector<long long>> kouka(13, vector<long long> (13));
long long minn = 99999999999;

void dfs(int k, vector<long long> rikaido, int sum){
  if(k == N){
    bool done = true;
    for(int i = 0; i < M; i++){
      if(rikaido[i] < X){
        done = false;
      }
    }
    if(done && sum < minn){
      minn = sum;
    }
    return ;
  }

  for(int i = 0; i < M; i++){
    rikaido[i] += kouka[k][i];
  }
  dfs(k+1, rikaido, sum + cost[k]);
  for(int i = 0; i < M; i++){
    rikaido[i] -= kouka[k][i];
  }
  dfs(k+1, rikaido, sum);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
  ifstream in("input.txt");
  cin.rdbuf(in.rdbuf());
  //*/
  cin >> N >> M >> X;
  for(int i = 0; i < N; i++){
    cin >> cost[i];
    for(int j = 0; j < M; j++){
      cin >> kouka[i][j];
    }
  }
  vector<long long> rikaido(13);
  dfs(0, rikaido, 0);
  if(minn == 99999999999){
    cout << -1 <<endl;
  } else{
    cout << minn <<endl;
  }
}


Measured memory_bytes: 3664
#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 x, y;
    cin >> x >> y;
    rep(i, x + 1) rep(j, x + 1)
    {
        if ((i + j == x) && (i * 2 + j * 4 == y))
        {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
}


Measured memory_bytes: 3648
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

LL modpow(LL a, LL b) {
  LL r = 1;
  while (b) {
    if (b % 2 == 1) r = r * a % kMod;
    a = a * a % kMod;
    b /= 2;
  }
  return r;
}

LL invmod(LL a) {
  return modpow(a, kMod - 2);
}

class Comb {
 public:
  void Init(int N) {
    fact.resize(N+1); inv.resize(N+1); finv.resize(N+1);
    fact[0] = fact[1] = 1LL;
    finv[0] = finv[1] = 1LL;
    inv[1] = 1;
    for (int i = 2; i <= N; i++){
        fact[i] = fact[i-1] * i % kMod;
        inv[i] = kMod - inv[kMod%i] * (kMod / i) % kMod;
        finv[i] = finv[i-1] * inv[i] % kMod;
    }
  }

  LL nCr(int n, int r) const {
    LL numerator = fact[n];
    LL denominator = finv[r] * finv[n-r] % kMod;
    return (numerator * denominator) % kMod;
  }

 private :
  vector<LL> fact;
  vector<LL> inv;
  vector<LL> finv;
};

struct Node {
  LL dp = 1;
  int size = 1;
};

LL N;
vector<vector<int>> G;
vector<Node> nodes;
Comb comb;

void dfs1(int v, int p = -1) {
  auto& node = nodes[v];
  for (int c : G[v]) {
    if (c == p) continue;
    dfs1(c, v);

    auto& child = nodes[c];
    node.size += child.size;
    node.dp = node.dp * child.dp % kMod;
    node.dp = node.dp * comb.nCr(node.size - 1, child.size) % kMod;
  }
}

void dfs2(int v, int p = -1) {
  auto& node = nodes[v];
  for (int c : G[v]) {
    if (c == p) continue;

    auto& child = nodes[c];
    int size = node.size - child.size;
    LL dp = node.dp * invmod(child.dp) % kMod;
    dp = dp * invmod(comb.nCr(node.size - 1, child.size)) % kMod;
    dp = dp * comb.nCr(size + child.size - 1, size) % kMod;

    child.size += size;
    child.dp = child.dp * dp % kMod;

    dfs2(c, v);
  }
}

int main() {
  cin >> N;
  G.resize(N);
  nodes.resize(N);
  comb.Init(N);

  for (int i = 0; i < N-1; ++i) {
    int a, b; cin >> a >> b;
    --a; --b;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs1(0);
  dfs2(0);
  for (int i = 0; i < N; ++i) {
    cout << nodes[i].dp % kMod << endl;
  }
}


Measured memory_bytes: 21748
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
int main() {
    int N; cin >> N;
    int z_max = INT_MIN, z_min = INT_MAX, w_max = INT_MIN, w_min = INT_MAX;
    for (int i = 0; i < N; i++) {
        int x, y; cin >> x >> y;
        z_max = max(z_max, x + y);
        z_min = min(z_min, x + y);
        w_max = max(w_max, x - y);
        w_min = min(w_min, x - y);
    }
    cout << max(z_max - z_min, w_max - w_min) << endl;
    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int h,w,m; cin >> h >> w >> m;
  int br[300001];
  int bc[300001];
  int cntr[300001] = {};
  int cntc[300001] = {};
  int maxr=0,maxc=0;
  for(int i = 0; i < m; ++i){
    cin >> br[i] >> bc[i];
    ChangeMax(maxr,++cntr[br[i]]);
    ChangeMax(maxc,++cntc[bc[i]]);    
  }
  bitset<300001>r,c;
  for(int i = 1; i <= h; ++i)if(maxr == cntr[i])r[i] = 1;
  for(int i = 1; i <= w; ++i)if(maxc == cntc[i])c[i] = 1;
  int cntd = 0;
  for(int i = 0; i < m; ++i)
    cntd += r[br[i]]&&c[bc[i]];
  cout << maxr + maxc - (cntd == (int)r.count()*(int)c.count()) << endl;
}


Measured memory_bytes: 8416
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#include <map>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<long long>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
int MOD=1e9+7;
int INF=1e9+7;
//
int main(){
  int N,A;
  int O=0;
  cin>>N;
  FOR(i,0,N){
    cin>>A;
    if(A%2){
      O++;
    }
  }
  if(O%2){
    YES(0);
  }else{
    YES(1);
  }
  return 0;
}


Measured memory_bytes: 256
n, k =map(int, input().split())
a = list(map(str, input().split()))


for i in range(n*10):
    z = 0
    x = n+i
    y = str(x)
    for i in range(len(y)):
        if y[i] in a:
            z+=1
            break
    if z == 0:
        print(x)
        break

Measured memory_bytes: 73232
#include<algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<string>
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define ll long long 
using namespace std;
int main(){
  int h,w;
  cin >>h>>w;
  vector<vector<char>> vec(h,vector<char>(w));
  rep(i,h) rep(j,w) cin >>vec[i][j];
  rep(i,h){
    rep(j,w-1){
      if((vec[i][j]=='#'||vec[i][j]=='0')&&(vec[i][j+1]=='#'||vec[i][j+1]=='0')){
        vec[i][j]='0';
        vec[i][j+1]='0';
      }
    }
  }
    
  rep(i,w){
    rep(j,h-1){
      if((vec[j][i]=='#'||vec[j][i]=='0')&&(vec[j+1][i]=='#'||vec[j+1][i]=='0')){
        vec[j][i]='0';
        vec[j+1][i]='0';
      }
    }
  }
  
  int key=0;
  rep(i,h){
    rep(j,w){
      if(vec[i][j]=='#') {
        key=1; 
      }
    }
  }
  if(key==1) cout <<"No"<<endl;
  else cout <<"Yes"<<endl;
}

Measured memory_bytes: 256
def seek_B(i):
    return 2*A_list[i-1] - B_list[i-1]

N =  int(input())
A_list =list(map(int, input().strip().split()))
B_list = [0 for i in range(N)]

n = N // 2

B_list[0] = A_list[0]
for m in range(1, n+1):
    B_list[0] -= A_list[2*m - 1]
    B_list[0] += A_list[2*m]
    
for b in range(1, N):
    B_list[b] = seek_B(b)
    
ans = ""
for b in B_list:
    ans += str(b) + " "
print(ans)

Measured memory_bytes: 14104
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
typedef long double ld;

constexpr int INF = 1e9;
constexpr ll BIGINF = 1e18;
constexpr double EPS = 1e-16;
constexpr int MOD = 1e9 + 7;

void preambule() {
  cin.tie(0);
  cout.precision(16);
  cout << fixed;
}

int a;
int b;
int k;

void input() {
  cin >> a >> b >> k;
}

int gcd(int a, int b) {
  while (b) {
    a %= b;

    swap(a, b);
  }

  return a;
}

void solve() {
  vector<int> ans;

  int upper = gcd(a, b);

  while (upper) {
    if (a % upper == 0 && b % upper == 0)
      ans.push_back(upper);

    --upper;
  }

  cout << ans[k - 1] << '\n';
}

int main() {
#ifdef _DEBUG
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif

  preambule();
  input();
  solve();
}


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

const int mod = 1e9 + 7;

long long dp[410][410];

void MAIN() {
    int n, c;
    scanf("%d%d", &n, &c);
    std::vector<std::pair<int, int> > limits(n);
    for(auto &now: limits) {
        scanf("%d", &now.first);
    }
    for(auto &now: limits) {
        scanf("%d", &now.second);
    }
    std::vector<std::vector<int> > powerSum(n, std::vector<int>(c));
    for(int i = 0; i < n; ++ i) {
        std::vector<int> num(limits[i].second - limits[i].first + 1);
        for(int j = 0; j < (int)num.size(); ++ j) {
            num[j] = limits[i].first + j;
        }
        std::vector<int> power(limits[i].second - limits[i].first + 1, 1);
        powerSum[i][0] = power.size();
        for(int j = 1; j <= c; ++ j) {
            for(int k = 0; k < (int)power.size(); ++ k) {
                power[k] = power[k] * 1ll * num[k] %mod;
                powerSum[i][j] = (powerSum[i][j] + power[k]) %mod;
            }
        }
    }
    dp[0][0] = 1;
    for(int i = 1; i <= n; ++ i) {
        for(int j = 0; j <= c; ++ j) {
            for(int k = 0; k <= j; ++ k) {
                dp[i][j] += dp[i - 1][j - k] * powerSum[i - 1][k] %mod;
            }
            dp[i][j] %= mod;
        }
    }
    printf("%lld\n", dp[n][c]);
}

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


Measured memory_bytes: 2176
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

import array
from bisect import *
from collections import *
import fractions
import heapq
from itertools import *
import math
import random
import re
import string
import sys

def solve_1(N):
    N_str = str(N)
    ans = 0
    for i, ch in enumerate(N_str):
        if i == 0:
            ans += int(ch)
        else:
            ans += 9
    return ans

def solve_2(N):
    N_str = str(N)

    # N = 70543 だとする

    # {1..6}XXXX:
    # XXXXのうち1箇所が1..9のどれか、他はすべて0
    ans = (int(N_str[0]) - 1) * 9 * (len(N_str) - 1)

    # 7XXXX:
    # XXXXの前から順に見ていく
    # ありえるパターンは 7{1..9}000, 70{1..9}00, 700{1..9}0, 7000{1..9}
    # 前から順に考えていく
    # 7{1..9}000 に関しては、1..9のどれも入れない。 +0通り
    # 70{1..9}00 に関しては、1..5のどれかが入れる。 +5通り
    # 700{1..9}0 に関しては、1..9の全部が入れる。この桁よりも前に非0の桁があったため。+9通り
    # 7000{1..9} に関しては、1..9の全部が入れる。 +9通り
    flag = False
    for ch in N_str[1:]:
        if flag:
            ans += 9
        else:
            ans += int(ch)
            if ch != '0':
                flag = True

    # XXXX:
    # 4箇所どこにも1..9の全部が入れる
    for i in range(1, len(N_str) - 1):
        ans += 81 * i

    return ans

def solve_slow_2(n):
    ans = 0
    for i in range(1, n + 1):
        i_str = str(i)
        cnt = 0
        for ch in i_str:
            cnt += ch != '0'
        ans += cnt == 2
    return ans

# for n in range(1, 10000):
#     mine = solve_2(n)
#     gt = solve_slow_2(n)
#     if mine != gt:
#         print("error! n, mine, gt = ", n, mine, gt)
#         sys.exit(0)
#     else:
#         print(n, "ok")


def solve_3(N):
    N_str = str(N)
    size = len(N_str)

    # N = 70543 だとする

    # {1..6}XXXX:
    # XXXXのうち2箇所が1..9のどれか、他はすべて0
    ans = (int(N_str[0]) - 1) * (((size - 1) * (size - 2)) // 2) * 81

    # 7XXXX:
    # "2つだけ非0でXXXXより小さい数"を数えればよい。solve_2を使うと解ける
    if size > 1:
        ans += solve_2(int(N_str[1:]))

    # X:
    # XX:
    # XXX:
    # XXXX:
    # の場合をループで順番に加算
    # 例えばXXXXの場合、
    # 最初の桁は{1..9}, 残り3桁のうちの2つが{1..9}なので
    # 場合の数は9 * 9 * 9 * 3C2
    for size in range(1, len(N_str)):
        ans += 9 * 9 * 9 * (size - 1) * (size - 2) // 2

    return ans

def solve_slow_3(n):
    ans = 0
    for i in range(1, n + 1):
        i_str = str(i)
        cnt = 0
        for ch in i_str:
            cnt += ch != '0'
        ans += cnt == 3
    return ans


# for n in range(1, 10000):
#     mine = solve_3(n)
#     gt = solve_slow_3(n)
#     if mine != gt:
#         print("error! n, mine, gt = ", n, mine, gt)
#         sys.exit(0)
#     else:
#         print(n, "ok")
        

def solve(N, K):
    if K == 1:
        return solve_1(N)
    elif K == 2:
        return solve_2(N)
    else:
        return solve_3(N)


N = int(input())
K = int(input())

print(solve(N, K))



Measured memory_bytes: 6796
#include <iostream>
#include <vector>
 
int main()
{
  int N;
  std::cin >> N;
  int sum = 0;
  for (int i = 0; i < N; i++)
  {
     int x;
     std::cin >> x;
     sum += x - 1;
  }
  
  std::cout << sum << std::endl;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// Edge :
type Edge struct {
	from, to, cost int
}

// Route :
type Route struct {
	path []int
}

const inf = math.MaxInt64 >> 10

// ベルマンフォード法
func bellmanFord(N, S int, edges []Edge) ([]int, []Route, bool) {
	d := make([]int, N+1)
	for i := 0; i <= N; i++ {
		d[i] = inf
	}
	d[S] = 0
	r := make([]Route, N+1)
	r[S].path = []int{S}

	negativeLoop := false
	for i := 0; i <= N*2; i++ {
		for _, e := range edges {
			if d[e.to] > d[e.from]+e.cost {
				d[e.to] = d[e.from] + e.cost
				r[e.to].path = append(r[e.from].path, e.to)
				if i > N && (e.to == N || e.from == N) {
					negativeLoop = true
				}
			}
		}
	}

	return d, r, negativeLoop
}

func main() {
	sc.Split(bufio.ScanWords)

	N, M := getInt(), getInt()
	edges := make([]Edge, M)
	for i := 0; i < M; i++ {
		f, t, c := getInt(), getInt(), getInt()
		edges[i] = Edge{f, t, -c}
	}
	S, D := 1, N

	// ここから
	d, _, negativeLoop := bellmanFord(N, S, edges)

	if negativeLoop == true {
		out("inf")
	} else {
		out(-d[D])
	}

}


Measured memory_bytes: 61440
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int INF = 1e9;
const int MAX_V = 1000;

int cost[MAX_V][MAX_V];
bool used[MAX_V];
int n;

int prim(){
    int res = 0;
    priority_queue<P, vector<P>, greater<P> > q;
    memset(used, false, sizeof(used));
    q.push(P(0, 0));
    while(!q.empty()){
        P p = q.top(); q.pop();
        int v = p.second;
        int d = p.first;
        if(used[v]) continue;
        used[v] = true;
        res += d;
        for(int i = 0; i < n; i++){
            q.push(P(cost[v][i], i));
        }
    }
    return res;
}

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n; j++){
            cin >> cost[i][j];
            if(cost[i][j] == -1) cost[i][j] = INF;
        }
    }
    cout << prim() << endl;
}

/* verified
https://onlinejudge.u-aizu.ac.jp/#/courses/lesson/1/ALDS1/12/ALDS1_12_A
*/


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

int FindSumOfDigits(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int n;
    cin >> n;
    
    int min = 100000;
    for(int a = 1; a < n; ++a) {
        int b = n - a;
        if(min > FindSumOfDigits(a) + FindSumOfDigits(b)) {
            min = FindSumOfDigits(a) + FindSumOfDigits(b);
        }
    }
    
    cout << min << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=a,I=b+1;i<I;++i)
#define fd(i,a,b) for(R int i=a,I=b-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
using namespace std;
char buf[1<<21],*p1=buf,*p2=buf;
inline char getc(){return p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<21,stdin),p1==p2)?EOF:*p1++;}
int read(){
    R int res,f=1;R char ch;
    while((ch=getc())>'9'||ch<'0')(ch=='-')&&(f=-1);
    for(res=ch-'0';(ch=getc())>='0'&&ch<='9';res=res*10+ch-'0');
    return res*f;
}
const int N=2005,P=1000000007;
inline int add(R int x,R int y){return x+y>=P?x+y-P:x+y;}
inline int dec(R int x,R int y){return x-y<0?x-y+P:x-y;}
inline int mul(R int x,R int y){return 1ll*x*y-1ll*x*y/P*P;}
int ksm(R int x,R int y){
    R int res=1;
    for(;y;y>>=1,x=mul(x,x))if(y&1)res=mul(res,x);
    return res;
}
const int mod = P;
int x[N],y[N],n,k,res;
int ans;
typedef long long LL;
void dfs(int v, int rmn, LL pro) {
	if(v == 2) {
		if(true) {
			ans = (ans + pro);//% mod;
		}
		return;
	}
	for(int i = 0; i <= rmn; i++) {
		for(int j = i + 1; i + j <= rmn; j++) {
			dfs(v + 1, rmn - i - j, pro * (LL)(j - i));// % mod);
		}
	}
}
LL dp[N][N];
int main(){

	memset(dp, 0, sizeof(dp));
	dp[0][0] = 1;
	int MX = 965;
	for(int i = 1; i <= 5; i++) {
		for(int j = 0; j <= MX; j++) {
			for(int k = 0; k + j <= MX; k++) {
				for(int l = k; l > k - l; l--) {
					dp[i][j + k] = (dp[i][j + k] + (LL)dp[i - 1][j] * (l - k + l));
				}
				dp[i][j + k] %= mod;
			}
		}
	}
	for(int j = 1; j <= MX; j++) {
		dp[5][j] = (dp[5][j - 1] + dp[5][j]) % mod;
	//	if(j <= 20) cout << j << ' ' << dp[5][j] << endl;
	}
	int tt;
	cin >> tt;
	//cout << tt << endl;
	for(int qq = 1; qq <= tt; qq++){
		int k;
		cin >> k;
		if(k <= 4) cout << 0 << endl;
		else{

			int rmn = k % 60;
			n = 16;
			for(int i = 1; i <= n; i++) {
				x[i] = 60 * (i - 1) + rmn;
				y[i] = dp[5][x[i]];
			}

			int ans = 0;
			//cout << k << endl;
			fp(i,1,n){
				res=1;fp(j,1,n)if(i!=j)res=mul(res,dec(x[i],x[j]));
				res=ksm(res,P-2);
				fp(j,1,n)if(i!=j)res=mul(res,dec(k,x[j]));
				res=mul(res,y[i]),ans=add(ans,res);
			}
			printf("%d\n",ans);
		}
	}
	//cout << clock() << endl;
}


Measured memory_bytes: 35172
#include <bits/stdc++.h>
#include <chrono>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repl(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define rep2l(i, s, n) for (ll i = (ll)(s); i < (ll)n; i++)

int main() {
    int N, M, K;
    cin >> N >> M >> K;
    bool ans = false;
    rep(i, M+1) {
        rep(j, N+1) {
            if (i*N+j*M-2*i*j == K) {
                ans = true;
                break;
            }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC target("avx2")
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <random>
#include <chrono>
#include <tuple>
#include <random>

using namespace std;

typedef long long ll;
typedef long double ld;
#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

const int maxn = 2e5 + 10;

vector<int> g[maxn];
int mt[maxn];
int used[maxn];
int cn = 1;
vector<ll> prm = { 0, 1 };
ll dsu[maxn * 2];
pair<ll, ll> c3[maxn * 2];

ll find(int v) {
	if (dsu[v] == v) return v;
	else return dsu[v] = find(dsu[v]);
}

void uni(int v, int u) {
	u = find(u);
	v = find(v);

	if (u != v) {
		dsu[u] = v;
		c3[v].first += c3[u].first;
		c3[v].second += c3[u].second;
	}
}

bool dfs(int v) {
	if (used[v] == cn) return false;

	used[v] = cn;

	ll rnd = rand() % 2;
	if (rnd == 1) {
		for (int i = 0; i < g[v].size(); i++) {
			int u = g[v][i];
			if (mt[u] == -1 || dfs(mt[u])) {
				mt[u] = v;
				return true;
			}
		}
	}
	else {
		for (int i = 0; i < g[v].size(); i++) {
			int u = g[v][1 - i];
			if (mt[u] == -1 || dfs(mt[u])) {
				mt[u] = v;
				return true;
			}
		}
	}


	return false;
}

int main()
{
	fastInp;

	ll n, h, w;
	cin >> n >> h >> w;

	ll vals = 0, ans = 0;
	vector<tuple<ll, ll, ll>> vec;
	for (int i = 0; i < n; i++) {
		dsu[i] = i;
		c3[i] = { 1, 0 };
	}
	for (int i = 0; i < h + w + 3; i++) mt[i] = -1;

	for (int i = n; i < n + h; i++) {
		dsu[i] = i;
		c3[i] = { 0, 1 };
	}
	for (int i = n + h; i < n + h + w; i++) {
		dsu[i] = i;
		c3[i] = { 0, 1 };
	}

	for (int i = 0; i < n; i++) {
		ll r, c, a;
		cin >> r >> c >> a;
		r--; c--;
		vec.push_back({ a, r, c });
	}

	sort(vec.rbegin(), vec.rend());

	ll cnt = 0;
	ll hw = h + w;
	for (int i = 0; i < n; i++) {
		ll r = get<1>(vec[i]), c = get<2>(vec[i]), a = get<0>(vec[i]);
		r += n;
		c += h + n;
		r = find(r);
		c = find(c);
		if (c == r) {
			if (min(c3[c].first + 1ll, c3[c].second) > min(c3[c].first, c3[c].second)) {
				ans += a;
				uni(c, i);
			}
		}
		else {
			if (min(c3[c].first, c3[c].second) + min(c3[r].first, c3[r].second) < min(c3[c].first + c3[r].first + 1ll, c3[c].second + c3[r].second)) {
				ans += a;
				uni(c, i);
				c = find(c);
				uni(c, r);
			}
		}
		/*if (mt[r] == -1 || mt[c + h + 1] == -1) {
			vals++;
			cnt++;
			g[i].push_back(r);
			g[i].push_back(c + h + 1);
			if (mt[r] == -1) {
				mt[r] = i;
			}
			else {
				mt[c + h + 1] = i;
			}
			ans += a;
			continue;
		}
		cn++;
		vals++;

		g[i].push_back(r);
		g[i].push_back(c + h + 1);
		cnt += dfs(i);

		if (cnt >= vals) {
			ans += a;
			continue;
		}
		else {
			vals--;
		}*/
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 18868
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
const int N=1<<15|1,p=1000000007;
int F[N],f[15][N],k[16*16],S[16],i,j,n,m,x,X;
char c;

inline char getc()
{
	#define VV 10000000
	static char s[VV],*l=s,*r=s;
	if (l==r)
		l=s,r=s+fread(s,1,VV,stdin);
	return l==r?0:*l++;
}

int read(){ int z=0; do c=getc(); while (c<'0'||c>'9'); while (c>='0'&&c<='9') z*=10,z+=c-'0',c=getc(); return z; }

void Plus(int &a,int b){ a+=b,a-=a<p?0:p; }

bool check(int s){ return !((s&1)^(s>>1&1)); }

void solve()
{
	n=read(),m=read(),X=(1<<n)-1,k[0]=1;
	for (register int i=1;i<=m;++i) x=read()-1,S[x]|=1<<read()-1,k[i]=(k[i-1]<<1)%p;
	for (register int s=1;s<=X;++s)
	{
		for (register int i=0;i<n;++i)
			if (!(s>>i&1))
				f[i][s]+=__builtin_popcount(S[i]&s);
	}
	F[0]=1;
	for (register int s1=0;s1<X;++s1)
		if (check(s1))
			for (register int s=X^s1,s2=s;s2;s2=s2-1&s)
				if (check(s2))
				{
					register int s3=s^s2,z=F[s1];
					for (register int i=0;i<n;++i)
					{
						if (s2>>i&1)
							z=(LL)z*k[f[i][s3]]%p;
						if (s3>>i&1)
							z=(LL)z*(k[f[i][s2]]-1)%p;
					}
					if (z)
						Plus(F[s1^s2],z);
				}
	printf("%d\n",(k[m]-F[X]+p)%p);
}

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

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

int main(){
  int n;
  cin >> n;
  int su=0;
  vector<int>omoi(n);
  for(int i=0;i<n;i++){
    cin >> omoi.at(i);
    su+=omoi.at(i);
  }
  int ans=10e4,a=0,b=su;
  for(int i=0;i<n;i++){
    a+=omoi.at(i);
    b-=omoi.at(i);
    ans=min(ans,abs(a-b));
  }
  cout << ans << endl;
  return 0;
}

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

typedef pair<int,int> int_pair;

int main(void){
    int n; cin >> n;
    int x[n],y[n];
    for(int i=0;i<n;i++) cin >> x[i] >> y[i];

    map<int_pair,int> m;
    int max_cnt = 0;

    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i!=j){
                int p = x[i]-x[j];
                int q = y[i]-y[j];
                max_cnt = max(max_cnt,++m[int_pair(p,q)]);
            }
        }
    }
    cout << n-max_cnt << endl;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define FASTINOUT ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const ll mod = 1e9+7;
const int N=2e5+9;
int main()
{
    FASTINOUT;
    int x;
    cin>>x;
    int z=x/15;
    cout<<x*800-z*200<<endl;
    return 0;
}


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

using namespace std;

typedef long long ll;
const int MAXN = 200010;

int n, a[MAXN], h[MAXN];
ll f[MAXN];

struct node{
	int l, r;
	ll val;
}t[MAXN<<2];
inline void pushUp(int k){
	t[k].val = max(t[k<<1].val, t[k<<1|1].val);
}
void build(int l, int r, int k)
{
	t[k].l = l; t[k].r = r; t[k].val = 0;
	if(l == r) return ;
	int mid = l+r>>1;
	build(l, mid, k<<1);
	build(mid+1, r, k<<1|1);
	pushUp(k);
}
void update(int x, ll v, int k)
{
	if(t[k].l == x && t[k].r == x){
		t[k].val = max(t[k].val, v);
		return ;
	}
	int mid = t[k].l+t[k].r>>1;
	if(x <= mid) update(x, v, k<<1);
	else update(x, v, k<<1|1);
	pushUp(k);
}
ll query(int x, int y, int k)
{
	if(t[k].l >= x && t[k].r <= y) return t[k].val;
	int mid = t[k].l+t[k].r>>1;
	ll res = 0;
	if(x <= mid) res = max(res, query(x, y, k<<1));
	if(y >= mid+1) res = max(res, query(x, y, k<<1|1));
	return res;
}

int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&h[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	build(1, n, 1);
	for(int i=1;i<=n;i++){
//		for(int j=1;j<i;j++){
//			if(h[j] < h[i])
//				f[i] = max(f[i], f[j]);
//		}
		if(h[i] > 1) f[i] = query(1, h[i]-1, 1);
		f[i] += a[i];
		update(h[i], f[i], 1);
	}
	ll ans = 0;
	for(int i=1;i<=n;i++)
		ans = max(ans, f[i]);
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 13824
import math
s = input().split()
n=int(s[0])
k=int(s[1])
ans=0
for i in range(1,n+1):
    a=math.log2(k/i)
    if a<0:
        a=0
    a=math.ceil(a)
    ans+=(1/n)*(1/2)**a

print(ans)

Measured memory_bytes: 9368
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
int main() {
	int N, K;
	cin >> N >> K;
	vector<bool> ok(N);
	for (int i = 0; i < K; ++i) {
		int d;
		cin >> d;
		while (d--) {
			int x;
			cin >> x; --x;
			ok[x] = true;
		}
	}
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		if (!ok[i]) {
			++ans;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define int long long
using namespace std;
vector<int>g[1000];
signed main()
{
    int l, r;
    cin >> l >> r;
    int mi = 8e18;
    for(int i = l; i <= min(l + 3000, r); ++i)
    {
        for(int j = i + 1; j <= min(l + 3000, r); ++j)
        {
            mi = min(mi, i * j % 2019);
        }
    }
    cout << mi;
    return 0;
}


Measured memory_bytes: 256
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

int N,h[110];

int main(){
  cin>>N;
  REP(i,N){
    cin>>h[i];
  }
  h[N]=0;
  int count=0;
  while(true){
    int t=count;
    REP(i,N){
      if(h[i]>0 && h[i+1]==0)count++;
      if(h[i]>0)h[i]--;
    }
    if(count==t)break;
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
/*
	Author: Hamza Hasbi
	Copyrights: "h.hamza" ==> "www.hamzahasbi.me"
	Date: 10/06/2017 13:07:23
*/
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define uld unsigned long double
#define ui unsigned int
#define ud unsigned double
#define uf unsigned float
#define pi 2*acos(0.0)
#define module cin.ignore()
#define rep(i,l,r) for(auto i=l;i<=r;i++)
#define range(x,y) for(auto x:y)
//inline lcm(int a,int b) {return a*b/__gcd(a,b);}
//inline gcd(ll a,ll b) {return 1LL*b == 0 ? a : gcd(1LL*b, a*1LL % b*1LL);}
using namespace std;

main()
{

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s="";
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	int sum=a*100+b*10+c;
	if(sum%4==0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rua system("pause")
using namespace std;
typedef long long ll;
inline int read()
{
	int x = 0, f = 1; char c = getchar();
	while (!isdigit(c)) {if (c == '-') f = -1; c = getchar();}
	while (isdigit(c)) {x = x * 10 + c - '0', c = getchar();}
	return x * f;
}

typedef pair<int, int> mypair;

const int MAXN = 2e6 + 10;
char buf[MAXN]; mypair st[MAXN];
int n, m, k, s[MAXN], t[MAXN], S[MAXN], T[MAXN];
#define fi first
#define se second

int main()
{
//	freopen("in30.txt", "r", stdin);
//	freopen("out30.txt", "w", stdout);
	scanf("%d%d%d", &n, &m, &k);
	scanf("%s", buf + 1), reverse(buf + 1, buf + 1 + n);
	for (int i = 1; i <= n; i ++) s[i] = buf[i] == '1';
	scanf("%s", buf + 1), reverse(buf + 1, buf + 1 + m);
	for (int i = 1; i <= m; i ++) t[i] = buf[i] == '1';
	int top = 0;
	for (int i = max(n, m); i; i --)
	{
		if (s[i] && t[i])
		{
			vector<mypair> foo(0);
			int now = k, x = 3, pos = i;
			s[i] = t[i] = 0;
			while (x && top)
			{
				auto cur = st[top];
				if (x == 3)
				{
					if (cur.fi - pos > now)
					{
						S[pos + now] = T[pos + now] = 1;
						now = -1;
						break;
					}
					else
					{
						now -= cur.fi - pos;
						foo.emplace_back(cur.fi, x ^ cur.se);
						x &= cur.se, pos = cur.fi;
					}
				}
				else
				{
					if (cur.fi - pos > 1)
					{
						foo.emplace_back(pos + 1, x);
						now = -1;
						break;
					}
					else
					{
						if ((x ^ cur.se) == 3) x = 3;
						else x &= cur.se;
						pos ++;
					}
				}
				top --;
			}
			if (now >= 0)
			{
				if (x == 3) S[pos + now] = T[pos + now] = 1;
				else if (x) foo.emplace_back(pos + 1, x);
			}
			reverse(foo.begin(), foo.end());
			for (auto cur : foo) st[++ top] = cur;
			foo.clear();
		}
		else if (s[i] || t[i])
			st[++ top] = mypair(i, s[i] << 1 | t[i]);
//		cerr << top << endl;
	}
	while (top)
	{
		auto cur = st[top --];
		S[cur.fi] = cur.se >> 1;
		T[cur.fi] = cur.se & 1;
	}
	int pos = 0;
	for (int i = max(n, m) + k + 1; i >= 0; i --) if (S[i]) {pos = i; break;}
	for (int i = pos; i >= 1; i --) putchar(S[i] + '0'); putchar(10);
	for (int i = max(n, m) + k + 1; i >= 0; i --) if (T[i]) {pos = i; break;}
	for (int i = pos; i >= 1; i --) putchar(T[i] + '0'); putchar(10);
	return 0;
}

Measured memory_bytes: 37632
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

const double pi = 3.14159265359;
const ll INF = 1e12;
const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


string s, t; int dp[3001][3001];

void solve()
{
    cin >> s >> t; string ans = "";
    int n = s.size(), m = t.size();
    for (int i=0; i<=n; i++) dp[0][i]=0;
    for (int j=0; j<=m; j++) dp[j][0]=0;

    for (int i=1; i<=n; i++) {
        for (int j=1; j<=m; j++) {
            if (s[i-1]==t[j-1]) dp[i][j] = 1 + dp[i-1][j-1];
            else dp[i][j] = max(dp[i][j-1], dp[i-1][j]);
        }
    }

    int i=n,j=m;
    while (i>0 && j>0) {
        if (s[i-1]==t[j-1]) {
            ans+=s[i-1]; i--; j--;
        }else if (dp[i-1][j] > dp[i][j-1]) {
            i--;
        }else j--;
    }
    reverse(ans.begin(),ans.end());
    nout(ans);
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    for (int i=1; i<=t; i++)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 38732
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  int k; cin>>k;
  rep(i,k) cout<<"ACL";
  cout<<endl;
}

signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
}


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

template<class T> inline bool chmin(T& a,T b){
    if (a > b) {
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a,T b){
    if(a < b) {
        a=b;
        return true;
    }
    return false;
}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define INF 999999999

    /*Solve*/
ll a[100010];
ll p[100010];

ll rec(ll n,ll x){
    if(x == 1){
        if(n == 0)return 1;
        return 0;
    }
    if(1 < x && x<= a[n-1]+1)return rec(n-1,x-1);
    if(a[n-1]+2 == x)return p[n-1]+1;
    if(a[n-1]+2 < x && x <= 2*a[n-1]+2)return p[n-1]+1+rec(n-1,x-2-a[n-1]);
    if(2*a[n-1]+3 == x)return 2*p[n-1]+1;
    return -1;
}

int main(){
    ll n,x;
    cin >> n >> x;
    a[0]=1;
    p[0]=1;
    for(int i=1;i<=n+1;i++){
        a[i]=2*a[i-1]+3;
        p[i]=2*p[i-1]+1;
    }
    
    ll ans = rec(n,x);
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
		int n = Integer.parseInt(scan.next());
		int m = Integer.parseInt(scan.next());
		if(n == m) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 22992
import java.util.*

fun main(args: Array<String>) {
  val sc = Scanner(System.`in`)
  val a = sc.nextLong()
  val b = sc.nextLong()
  val c = sc.nextLong()
  val k = sc.nextLong()

  val ans = a(a, b, c, k)
  println(ans)
}

private fun a(a: Long, b: Long, c: Long, k: Long): String {
  var ans = 0L
  if (k % 2L == 0L) {
    ans = a - b
  } else {
    ans = b - a
  }

  val max = 1000000000000000000
  if (ans > max) return "Unfair"

  return ans.toString()
}


Measured memory_bytes: 29352
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

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 int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------

int N;
string S;
using ull = unsigned long long;
ull csum[5010];
ull pow3[5010];

bool can(int i, int j, int x) {
  if (j + x >= S.size()) {
    return false;
  }

  if (i + x >= j) {
    return false;
  }

  ull h1 = csum[i + x + 1] - csum[i];
  ull h2 = csum[j + x + 1] - csum[j];
  return h1 * pow3[j - i] == h2;
}

bool can2(int x) {
  rep(i, 0, N) {
    rep(j, i + 1 + x, N) {
      if (S[i] != S[j]) continue;

      if (can(i, j, x)) {
        return true;
      }
    }
  }
  return false;
}

int main() {
  cin >> N;
  cin >> S;

  pow3[0] = 1;
  rep(i, 1, 5010) { pow3[i] = pow3[i - 1] * MOD; }

  rep(i, 0, N) { csum[i + 1] = csum[i] + S[i] * pow3[i]; }

  int ans = 0;
  int low = 0;
  int high = S.size();
  while (high - low > 1) {
    int mid = (low + high) / 2;
    if (can2(mid)) {
      low = mid;
      chmax(ans, low + 1);
    } else {
      high = mid;
    }
  }

  cout << ans;
}


Measured memory_bytes: 3752