akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) rep(i,v.size())cout<<v[i]<<(i==v.size()-1?"\n":" ");
#define vout(v) VOUT(v,z);
#define vdbg(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL)
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
// template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
// template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
bool is_palindrome(string s){return s == string(s.rbegin(),s.rend());}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
typedef vector<vector<ll>> VV;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) { a = b; return true; }
    return false;
}
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) { a = b; return true; }
    return false;
}



int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    ll cnt=0;
    for (long long i = 0; i < N; i++) {
        int mas=i+1;
        if((mas&1) && (a[i]&1))cnt++;
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3672
import java.util.*;
import java.io.*;
class Main{
    public static void main(String[] args){
	try{
	    BufferedReader s = new BufferedReader(new InputStreamReader(System.in));
	    int n, count;
	    String ss;
	    while((ss=s.readLine())!=null){
		count=0;
		n=Integer.valueOf(ss);
		for(int a=0; a<10; a++)
		    for(int b=0; b<10; b++)
			for(int c=0; c<10; c++)
			    for(int d=0; d<10; d++)
				if(a+b+c+d==n)
				    count++;
		System.out.println(count);
	    }
	}catch(Exception e){
	    System.out.println("Error");
	}
    }
}

Measured memory_bytes: 9340
#include <bits/stdc++.h>
#include <bitset>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

const long double EPS = 1e-10; //要検証
long double add(long double x, long double y){
    if(abs(x + y) < EPS * (abs(x) + abs(y)) ) return 0;
    return x + y;
}
struct PL{
    long double x, y;
    PL() {}
    PL(long double x, long double y) : x(x), y(y) {
    }
    PL operator + (PL p){
        return PL(add(x, p.x), add(y, p.y));
    }
    PL operator - (PL p){
        return PL(add(x, -p.x), add(y, -p.y));
    }
    PL operator * (long double d){
        return PL(x * d, y * d);
    }
    long double dot(PL p){
        return add(x * p.x, y * p.y);
    }
    long double det(PL p){
        return add(x * p.y, -y * p.x);
    }
    long double norm(){
        return sqrt(add(x * x, y * y));
    }
    void rotate(){
        long double temp = x;
        x = -y;
        y = temp;
    }
};
/*bool cmp_x(const PL &p, const PL &q){
    if(p.x != q.x) return p.x < q.x;
    return p.y < q.y;
}*/

vector<PL> plot(50);
bool in_all(PL cen, long double r){
    r += EPS;
    rep(i,N){
        if(r < (cen - plot[i]).norm()) return false;
    }
    return true;
}

bool ok(long double r){
    rep(i,N){
        rep(j,i){
            PL a = plot[i], b = plot[j];
            PL c = (a + b) * 0.5, v = (b - a) * 0.5;
            long double dist = v.norm();
            long double len = r*r - dist*dist;
            if(len <= 0.0) return false;
            len = sqrt(len);
            v.rotate();
            v = v * (1.0 / v.norm());
            if(in_all(c + v * len, r)) return true;
            if(in_all(c - v * len, r)) return true;
        }
    }
    return false;
}

int main(){
    cin>>N;
    rep(i,N) cin>>plot[i].x>>plot[i].y;
    long double lb = 0, ub = 2e+3;
    while(ub - lb > 1e-9){
        long double cen = (ub + lb) / 2.0;
        (ok(cen) ? ub : lb) = cen;
    }
    cout<<fixed<<setprecision(10)<<ub<<endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<iostream>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll, int> plli;
typedef pair<int, pii> pipii;
typedef vector<vector<int> > mati;
typedef vector<vector<double> > matd;

#define rep(i,x,y) for(int i=(x); i<(y); ++i)
const int INF = (1<<30);
const ll INFLL = 1LL<<62;
const long double EPS = 1e-12;

template <typename T>
void vec_print(vector<T> VEC){
  rep(i, 0, VEC.size()){
    cout << VEC[i] << " ";
  }
  cout << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  rep(i, 0, MAT.size()){
    rep(j, 0, MAT[i].size()){
      cout << MAT[i][j] << " ";
    }
    cout << endl;
  }
};

class HOGE{
  public:
    ll index;
    ll value;
    HOGE(ll index, ll value){
      this->index = index;
      this->value = value;
    };
    ~HOGE(void){
      return;
    };

    void print(void){
      cout << "index : " << index << ", value : " << value << endl;
      return;
    };
    
    bool operator==(const HOGE &obj){
      return (this->value == obj.value);
    };
    bool operator<(const HOGE &obj){
      return (this->value < obj.value);
    };
    bool operator>(const HOGE &obj){
      return (this->value > obj.value);
    };
};

int main(){
  ll N;
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  vector<ll> A(N);
  ll A_max=0;
  ll A_max_i=0;
  rep(i, 0, N){
    cin >> A[i];
    if(A_max < A[i]){
      A_max = A[i];
      A_max_i = i;
    }
  }

  A[A_max_i] = A[N-1];
  A.pop_back();

  ll A_middle=0;
  ll A_middle_num=A_max;
  rep(i, 0, N-1){
    if(A_middle_num > abs((A_max/2)-A[i])){
      A_middle_num = abs((A_max/2)-A[i]);
      A_middle = A[i];
    }
  }

  cout << A_max << " " << A_middle << "\n";

  return 0;
}


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

long long c,a,b;

long long hehe(long long a1,long long a2)
{
	if(a1 % a2 == 0) return a2;
	else return hehe(a2,a1 % a2);
}

int main()
{
	cin>>a>>b;
	c = hehe(a,b);
	cout<<a * b / c;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

void ch(int *x, int *y){
	int temp = *x;
	*x = *y;
	*y =temp;
}

int main(void) {
	int a, b, c;
	scanf("%d %d %d", &a, &b, &c);
	
	if(c<b) ch(&b,&c);
	if(c<a) ch(&a,&c);
	if(b<a) ch(&a,&b);
	
	printf("%d %d %d\n", a, b, c);
		
	return 0;
}

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

int main()
{
    int n;
    cin >> n;

    vector<ll> a(n);
    rep (i, n)
        cin >> a[i];

    sort(a.begin(), a.end(), greater<ll>());

    ll ans = a[0];
    int i;
    for (i = 1; i <= (n - 2) / 2; i++)
        ans += a[i] * 2;

    if (n % 2)
        ans += a[i];

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


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

using namespace std;

typedef unsigned long long ull;
typedef long double ldbl;
typedef long long ll;
typedef double dbl;
const ldbl E = 2.71828182845904523536;
const ldbl pi = acos(-1);
const dbl eps = 1e-9;
const ll mod = 1e9+7;
const ll inf = 1LL<<30;
#define countones(x) __builtin_popcount (x);
int dcmp(double x, double y)
{
    return fabs(x - y) <= eps ? 0 : x < y ? -1 : 1;
};

string convertostring(long long  num)
{
    stringstream ss;
    ss << num;
    return ss.str();
}
void PLAY()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    cout << fixed << setprecision(2);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}
const int N=1e5+2;
int n;
ll mem[N][4];
vector<ll>v1,v2,v3;
ll sol(ll i,ll last)
{
    if(i==n)
        return 0;
    ll &ret=mem[i][last];
    if(ret!=-1)
        return ret;
    ret=0;
    if(last==1)
        ret=max(ret,max(v2[i]+sol(i+1,2),v3[i]+sol(i+1,3)));
    if(last==2)
        ret=max(ret,max(v1[i]+sol(i+1,1),v3[i]+sol(i+1,3)));
    if(last==3)
        ret=max(ret,max(v2[i]+sol(i+1,2),v1[i]+sol(i+1,1)));
    if(last==4)
        ret=max(ret,max(v1[i]+sol(i+1,1),max(v2[i]+sol(i+1,2),v3[i]+sol(i+1,3))));

    return ret;
}
int main()
{
    cin>>n;
    for(int i=0; i<n; i++)
    {
        ll a,b,c;
        cin>>a>>b>>c;
        v1.push_back(a);
        v2.push_back(b);
        v3.push_back(c);
    }

    memset(mem,-1,sizeof mem);
    cout<<sol(0,4);
}


Measured memory_bytes: 10592
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
typedef int64_t Int;

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

    vector<Int> A(N);
    rep(i,N){
        cin >> A[i];
        if(A[i] == 0) {cout << 0 << endl; return 0;}
    }

    Int ans = 1;
    rep(i,N){
        if(A[i] > (Int)1e18 / ans) {cout << -1 << endl; return 0;}
        ans *= A[i];
    }

    cout << ans << endl;
}

Measured memory_bytes: 3972
import itertools

N=int(input())
P=tuple(map(int,input().split()))
Q=tuple(map(int,input().split()))

l=list(range(1,N+1))

junretu=list(itertools.permutations(l, N))
a=0
for i in junretu:
    a+=1
    if P==i:
        break
b=0
for i in junretu:
    b+=1
    if Q==i:
        break

print(abs(a-b))

Measured memory_bytes: 8052
import scala.io.StdIn._
import scala.math._

object Main extends App with StdInHelper {
  val s = readLine()
  val t = readLine()

  var count = t.length
  for (i <- 0 to s.length - t.length) {
    val ss = s.substring(i, i + t.length)
    var c = 0
    for (i <- 0 to t.length - 1) {
      if (ss.charAt(i) != t.charAt(i)) {
        c += 1
      }
    }
    if (c < count) {
      count = c
    }
  }

  println(count)
}

trait StdInHelper {
  def readStrings = readLine.split(" ")
  def readInts = readStrings.map(_.toInt)
  def readLongs = readStrings.map(_.toLong)
  def readDoubles = readStrings.map(_.toDouble)
  def readBigInts = readStrings.map(BigInt.apply(_))
  def readBigDecimals = readStrings.map(BigDecimal.apply(_))
}


Measured memory_bytes: 54736
n, t = map(int, input().split())
c_list = []
for i in range(n):
    c, t_ = map(int, input().split())
    if t_ <= t:
        c_list.append(c)
if len(c_list) > 0:
    print(min(c_list))
else:
    print("TLE")

Measured memory_bytes: 3060
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
    }

    for i in 1..s.len() {
        if s[i - 1] == s[i] {
            return println!("{} {}", i, i + 1);
        }
    }

    for i in 2..s.len() {
        if s[i - 2] == s[i] {
            return println!("{} {}", i - 1, i + 1);
        }
    }
    println!("-1 -1");
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define MAX 10000
#define NIL -1
static const int N = 100;
static const int INFTY = 10000000;

int n,M[N][N];
int d[N];

void bfs(int s){
  queue<int> q;
  q.push(s);
  for(int i= 0;i<n;i++) d[i] = INFTY;
  d[s] = 0;
  int u;
  while( !q.empty()){
    u = q.front();
    q.pop();
    for(int v = 0;v<n;v++){
      if(M[u][v] == 0)continue;
      if(d[v] != INFTY) continue;
      d[v] = d[u] + 1;
      q.push(v);
    }
  }
  for(int i = 0;i<n;i++){
    cout << i+1 << " "<< ((d[i] == INFTY) ? (-1):d[i] ) <<endl;
  }
}

int main(){
  int u,k,v;
  cin >> n;
  for(int i = 0;i<n;i++){
    for(int j = 0;j<n;j++){
      M[i][j] = 0;
    }
  }
  for(int i  = 0;i<n;i++){
    cin >> u >> k;
    u--;
    for(int j = 0;j<k;j++){
      cin >> v;
      v--;
      M[u][v] = 1;
    }
  }
  bfs(0);

}


Measured memory_bytes: 3132
read A
read B
read C
read X

count=0

for (( a = 0; a <= A; a++ )); do
    for (( b = 0; b <= B; b++ )); do
        for (( c = 0; c <= C; c++ )); do
            : $(( count += (a * 500 + b * 100 + c * 50 == X) ? 1 : 0 ))
        done
    done
done

echo ${count}


Measured memory_bytes: 376
#include<iostream>
#include<math.h>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<queue>
#include<string>
#include<stdlib.h>
#include <set>
#include<iomanip>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)


int main(void)
{

	int n;
	cin >> n;
	vector<double> a(n);

	rep(i, n)
	{
		cin >> a[i];

	}

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


	double ans = a[0];

	for (int i = 1; i < n; i++)
	{
		ans = (ans + a[i]) / 2;
	}

	cout << ans << endl;
}

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

#define ll long long
#define REP(i,n) for(int i=0;i<n;++i)
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  if (n == m) {
    cout<< "Yes";
  }else{
    cout << "No";
  }
}


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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

li parent[100100];
vector<li> child[100100];

// [1,2,3,3] -> 4
// [3,3,3,3,3] -> 7?
// [0,0,0] -> 3
// [1,2,6] -> 6
inline li calc(vector<li>& v) {
    if (v.empty()) {
        return 0;
    }
    sort(allof(v));
    li res = sz(v);
    li add = 0;
    rep(i, sz(v)) {
        add = max(add, v[i] - i);
    }
    return res + add;
}

li dfs(li now) {
    li res = 0;
    vector<li> tmp;
    rep(i, sz(child[now])) {
        li next = child[now][i];
        tmp.pb(dfs(next));
    }
    //p2(now, calc(tmp));
    return calc(tmp);
}

inline li calc(li n) {
    li now = 1;
    li res = 0;
    while (n > now) {
        res++;
        now *= 2;
    }
    return res;
}

int main() {
    li n;
    cin >> n;
    parent[0] = -1;
    repp(i, 1, n) {
        cin >> parent[i];
        parent[i]--;
        child[parent[i]].pb(i);
    }

    li res = dfs(0);
    cout << max(res, calc(n)) << endl;


    return 0;
}

Measured memory_bytes: 14336
def KnapSack(val, wt, n, W): 
      
    # matrix to store final result  
    mat = [[0 for i in range(W + 1)]  
              for i in range(2)] 
    # iterate through all items  
    i = 0
    while i < n: # one by one traverse  
                 # each element  
        j = 0 # traverse all weights j <= W 
          
        # if i is odd that mean till  
        # now we have odd number of  
        # elements so we store result   
        # in 1th indexed row  
        if i % 2 == 0: 
            while j < W: # check for each value  
                j += 1
                if wt[i] <= j: # include element  
                    mat[1][j] = max(val[i] + mat[0][j - 
                                     wt[i]], mat[0][j]) 
                else: # exclude element 
                    mat[1][j] = mat[0][j] 
                      
        # if i is even that mean till  
        # now we have even number  
        # of elements so we store  
        # result in 0th indexed row  
        else: 
            while j < W: 
                j += 1
                if wt[i] <= j: 
                    mat[0][j] = max(val[i] + mat[1][j - 
                                     wt[i]], mat[1][j]) 
                else: 
                    mat[0][j] = mat[1][j] 
        i += 1
    # Return mat[0][W] if n is  
    # odd, else mat[1][W]  
    if n % 2 == 0: 
        return mat[0][W] 
    else: 
        return mat[1][W] 
  
# Driver code
n,W = map(int,input().split())
val = [] 
wt = []  
for i in range(n):
    a,b = map(int,input().split())
    val.append(b)
    wt.append(a)
    
print(KnapSack(val, wt, n, W)) 


Measured memory_bytes: 51184
from collections import defaultdict


def solve(s):
    if s[0] == s[-1]:
        if len(s) % 2 == 0:
            return "First"
        return "Second"
    else:
        if len(s) % 2 == 0:
            return "Second"
        return "First"


def main():
    s = input()
    print(solve(s))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3572
#include <stdio.h>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <math.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)

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

    int cnt = 0;
    rep(i,3)
        if(s.substr(i,1)=="1") ++cnt;

    cout << cnt << endl;
    return 0;
}

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

using ll = long long;

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i <= (n); ++i)
#define drep(i, n) for (int i = (n)-1; i >= 0; --i)
#define ddrep(i, n) for (int i = n; i > 0; --i)
#define srep(i, s, t) for (int i = s; i < t; ++i)
#define ssrep(i, s, t) for (int i = s; i <= t; ++i)

#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define pb push_back
#define eb emplace_back
#define fi first
#define se second

#define chmax(x, y) (x = max(x, y))
#define chmin(x, y) (x = min(x, y))

using pi = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using vs = vector<string>;
using vvs = vector<vs>;
using ld = long double;

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T> ostream &operator<<(ostream &os, const vector<T> &v) {
    os << "{";
    rep(i, (int)v.size()) {
        if (i)
            os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

template <typename T, size_t S> void printArray(const T (&array)[S]) {
    for (auto val : array)
        std::cout << val << ", ";
    std::cout << "\n";
}

const int mod = 1e9 + 7;
const int inf = 1e9 + 5;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::setprecision(10);

    int n, a, b; std::cin >> n >> a >> b;
    vi x(n); rep(i, n) std::cin >> x[i];

    ll ans = 0;
    rrep(i, n-1) {
        ll diff = x[i]-x[i-1];
        if (diff*a > b) ans += b;
        else ans += diff*a;
    }
    std::cout << ans << "\n";
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
char tmp[1000];
int a[1000];
int main()
{
	int n,tmp1,i,j,k,ans=999;
	scanf("%s",tmp);
	n=strlen(tmp); 
	for(i=0;i<n;i++)
	{
		a[i]=tmp[i]-'0';
	}
	for(i=0;i<n-2;i++)
	{
		ans=min(ans,abs(a[i]*100+a[i+1]*10+a[i+2]-753));
	}
	printf("%d",ans);
	return 0;
} 

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <numeric>
#include <queue>
#include <sstream>
#include <string>
#include <string.h>
#include <tuple>
#include <vector>

#define REP(i,x) for(int i{ 0 }; i < (int)(x); i++)
#define REPC(i,x) for(int i{ 0 }; i <= (int)(x); i++)
#define RREP(i,x) for(int i{ (int)(x) - 1 }; i >= 0 ;i--)
#define RREPC(i,x) for(int i{ (int)(x)}; i >= 0; i--)
#define REP1O(i,x) for(int i{ 1 }; i < (int)(x); i++)
#define REP1C(i,x) for(int i{ 1 }; i <= (int)(x); i++)

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()

using namespace std;

typedef int64_t ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvll;
typedef pair<int, int> pii;
typedef tuple<int, int, int> tupiii;
typedef tuple<ll, ll, ll> tuplll;

const int INTMAX = 2147483647;
const ll LLMAX = 9223372036854775807;
const int MOD = 1000000007;

template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
inline void swap(ll& a, ll& b) { a ^= b; b ^= a; a ^= b; }
inline void swap(int& a, int& b) { a ^= b; b ^= a; a ^= b; }



int main()
{
	ll a, b, x;
	cin >> a >> b >> x;

	ll left, right;

	if (!a)
		left = 0;
	else
		left = 1LL + (a - 1LL) / x;

	if (!b)
		right = 1;
	else
		right = 1LL + b / x;


	cout << right - left << endl;


}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define SF scanf
#define PF printf
#define MAXN 1000010
#define MOD 998244353
using namespace std;
typedef long long ll;
ll fac[MAXN],ifac[MAXN];
ll ans;
ll fsp(ll x,int y){
	ll res=1;
	while(y){
		if(y&1)
			res=res*x%MOD;
		x=x*x%MOD;
		y>>=1;
	}	
	return res;
}
void prepare(){
	fac[0]=1;
	for(int i=1;i<=1000000;i++)
		fac[i]=fac[i-1]*i%MOD;
	ifac[1000000]=fsp(fac[1000000],MOD-2);
	for(int i=1000000;i>=1;i--)
		ifac[i-1]=ifac[i]*i%MOD;
}
ll C(int n,int m){
	return fac[n]*ifac[m]%MOD*ifac[n-m]%MOD;	
}
int main(){
	int n,m;
	prepare();
	SF("%d%d",&n,&m);
	if(n<m)
		swap(n,m);
	for(int i=1;i<=m;i++)
		ans=(ans+C(2*i,i)*C(n+m-2*i,n-i)%MOD)%MOD;
	ans=ans*fsp(2ll*C(n+m,n)%MOD,MOD-2)%MOD;
	ans=(ans+n)%MOD;
	PF("%lld",ans);
}

Measured memory_bytes: 15744
#include <bits/stdc++.h>
using namespace std;
int main(){
int A,B,C;
cin>>A>>B>>C;
if(A==B&&A!=C){
    cout<<"Yes"<<endl;
}
else if(A==C&&A!=B){
    cout<<"Yes"<<endl;
}
else if(C==B&&B!=A){
    cout<<"Yes"<<endl;
}
else
cout<<"No"<<endl;
}


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


void solve(long long N, std::vector<std::string> S){
    if(count(S.begin(), S.end(), "Y") > 0) cout << "Four" << endl;
    else cout << "Three" << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<std::string> S(N);
    for(int i = 0 ; i < N ; i++){
        std::cin >> S[i];
    }
    solve(N, std::move(S));
    return 0;
}


Measured memory_bytes: 256
def main():
    n = int(input())
    c = [1 if x=="W" else 0 for x in list(input())]
    white_num = sum(c)
    white_num_of_left = 0
    for _c in c[:n-white_num]:
        if _c == 1:
            white_num_of_left += 1
    print(white_num_of_left)


if __name__ == "__main__":
    main()



Measured memory_bytes: 12316
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()
#define pb push_back

#define error(x) cout << #x << " = " << x << endl

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;

const int N = 400 + 20, M = 1e5 + 20;
int n, m;
vector <pii> g[N];

int ans;
int ff[N][M], tme[N];

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

	cin >> n >> m;

	for (int i = 0, x, y; i < m; i++)
	{
		cin >> x >> y;
		x--, y--;

		g[x].pb({i, y});
		g[y].pb({i, x});
	}

	memset(ff, -1, sizeof ff);

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < _sz(g[i]); j++)
		{
			int l = g[i][j].F, r = (j + 1 < _sz(g[i]) ? g[i][j + 1].F : m);

			for (int k = l + 1; k <= r; k++) ff[i][k] = j;
		}
	}

	for (int i = 0; i < n; i++)
	{
		for (int j = 0; j < i; j++)
		{
			bool ok = 1;

			memset(tme, -1, sizeof tme);
			queue <int> que;

			tme[i] = tme[j] = m;
			que.push(i), que.push(j);

			while (_sz(que))
			{
				int v = que.front();
				que.pop();
				
				int id = ff[v][tme[v]];

				while (id >= 0)
				{
					int u = g[v][id].S;
					if (tme[u] != -1)
					{
						ok = 0;
						break;
					}

					tme[u] = g[v][id].F;
					que.push(u);
					id--;
				}
				
				if (!ok) break;
			}

			ans += ok;
		}
	}
	
	cout << ans << '\n';
}


Measured memory_bytes: 166912
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define INIT(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define INIT2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

#define umap unordered_map
//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}

void func(ll *a, ll *b, ll *c){
  ll ah = *a/2;
  ll bh = *b/2;
  ll ch = *c/2;
  *a = bh+ch;
  *b = ah+ch;
  *c = ah+bh;
}


int main(){
  ll A,B,C; cin>>A>>B>>C;
  if(A==B && B==C){
    if(A%2==1){cout <<"0\n";}
    else{cout<<"-1\n";}
  }
  else{
    ll r = 0;
    while(1){
      if(A%2==0 && B%2==0 && C%2==0){
        func(&A,&B,&C);
        ++r;
      }else{break;}
    }
    cout << r;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
int n,m,q,cnt,ans;
int main()
{
	int i,s,a,b,j,k;
	scanf("%d",&n);
	for(i=1;i<=n;i++)scanf("%d%d",&a,&b),ans+=abs(a-b)+1;
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ( )
{
	int n,m;
	cin>>n>>m;
	int ans1=0;
	int ans2=0;
	for(int i=1;i<=n-1;i++)
	{
		ans1+=i;
	}
	for(int j=1;j<=m-1;j++)
	{
		ans2+=j;
	}
	cout<<ans1+ans2;
 } 

Measured memory_bytes: 256
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();
    let m: usize = iterator.next().unwrap().parse().unwrap();

    let ans = (n - 1) * (m - 1);
    return ans.to_string();
}


Measured memory_bytes: 2100
#include<stdio.h>
#define MAXN 101000
int N, M;
int f[MAXN], dis[MAXN];
void init()
{
	for (int i = 0; i <= N; i++)
	{
		f[i] = i;
	}
}
int find(int x)
{
	if (f[x] == x)
		return x;
	else
	{
		int r = find(f[x]);
		dis[x] = dis[f[x]] + dis[x];
		return f[x] = r;
	}
}
int find_father(int x,int y,int z)
{
	int fx = find(x);
	int fy = find(y);
	if (fx == fy)
	{
		return z == dis[y] - dis[x];
	}
	f[fy] = fx;
	dis[fy] = dis[x] + z - dis[y];
	return 1;
}
int main()
{
	int a = 1;
	scanf("%d %d", &N, &M);
	init();
	for (int i = 1; i <= M; i++)
	{
		int x, y, z;
		scanf("%d %d %d", &x, &y, &z);
		if (a)
			a = find_father(x, y, z);
	}
	if (a)
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pcc pair<char,char>
#define vi vector <int>
#define vl vector <ll>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d",x)
#define plld(x) printf("%lld",x)
#define pds(x) printf("%d ",x)
#define pllds(x) printf("%lld ",x)
#define pdn(x) printf("%d\n",x)
#define plldn(x) printf("%lld\n",x)
#define INF 2e9
#define INFLL 4e18
using namespace std;
ll powmod(ll base,ll exponent,ll mod){ // with mod < 1e9
	ll ans=1;
	while(exponent){
		if(exponent&1)ans=(ans*base)%mod;
		base=(base*base)%mod;
		exponent/=2;
	}
	return ans;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
const int upperlimit = 1e2+1;
const int mod = 1e9+7;
struct vctor
{
	int x=0,y=0;
};
double mag(vctor a){
	ll xsq=a.x;xsq*=a.x;
	ll ysq=a.y;ysq*=a.y;
	xsq+=ysq;
	double ans=sqrt(xsq);
	return ans;
}
ll cross(vctor a,vctor b){
	ll ans,calc;
	calc=a.y;calc*=b.x;
	ans=a.x;ans*=b.y;
	ans-=calc;
	return ans;
}
bool iseq(vctor a,vctor b){
	ll k1=a.x;k1*=b.x; ll k2=a.y;k2*=b.y;
	return((cross(a,b)==0)&&(k1>=0)&&(k2>=0));
}
vctor arr[upperlimit];
int main() {
	int n;
	sd(n);
	for(int i = 1; i <= n; i++){
		sd(arr[i].x);sd(arr[i].y);
	}
	vctor resultant;
	double ans=0;
	for(int i = 1; i <= n; i++){
		resultant=arr[i];
		for(int j = 1; j <= n; j++){
			if(j==i) continue;
			if((cross(arr[i],arr[j])>0)||(iseq(arr[i],arr[j]))){
				resultant.x+=arr[j].x;resultant.y+=arr[j].y;
			}
		}
		ans=max(ans,mag(resultant));
		for(int j = 1; j <= n; j++){
			if(iseq(arr[i],arr[j])){resultant.x-=arr[j].x;resultant.y-=arr[j].y;}
			else if(cross(arr[i],arr[j])==0){resultant.x+=arr[j].x;resultant.y+=arr[j].y;}
		}
		ans=max(ans,mag(resultant));
		resultant=arr[i];
		for(int j = 1; j <= n; j++){
			if(j==i) continue;
			if((cross(arr[i],arr[j])<0)||(iseq(arr[i],arr[j]))){
				resultant.x+=arr[j].x;resultant.y+=arr[j].y;
			}
		}
		ans=max(ans,mag(resultant));
		for(int j = 1; j <= n; j++){
			if(iseq(arr[i],arr[j])){resultant.x-=arr[j].x;resultant.y-=arr[j].y;}
			else if(cross(arr[i],arr[j])==0){resultant.x+=arr[j].x;resultant.y+=arr[j].y;}
		}
		ans=max(ans,mag(resultant));
	}
	printf("%0.18f\n", ans);
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(a) for a in input().split()]
B = [int(b) for b in input().split()]
C = [int(c) for c in input().split()]
total = B[A[0] - 1]
for i in range(1, N):
    total += B[A[i] - 1]
    if A[i-1] + 1 == A[i]:
        total += C[A[i-1] - 1]
print(total)

Measured memory_bytes: 3064
#include <stdio.h>

int main() {
  int N;
  int ans = 0;
  int i;
  
  scanf("%d", &N);
  for(i = 0; i < N; i++) {
    int l, r;
    scanf("%d %d", &l, &r);
    ans += r - l + 1;
  }
  
  printf("%d\n", ans);
  
  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int N, M;
  cin >> N >> M;

  string s;
  cin >> s;

  reverse(s.begin(), s.end());

  int start = 0;
  int can_go = 0;

  vector<int> ans;
  for(int now = 0; now <= N; now++){

    if(s[now] == '0'){
      can_go = now;
    }

    if(now - start == M || now == N){
      
      if(can_go == start){
        cout << -1 << endl;
        return 0;
      }

      ans.push_back(can_go - start);

      start = can_go;
    }
  }

  rep(i, ans.size()){
    cout << ans[ans.size()-1-i] << " ";
  }
  cout << endl;





  return 0;
}


Measured memory_bytes: 1096
/*  
    |\_/|
    |* *|
    \_+_/
*/
#include<bits/stdc++.h>

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  int a,b;

  cin>>a>>b;

  if(a%3==0||b%3==0||(a+b)%3==0){
    cout<<"Possible"<<endl;
  }else{
    cout<<"Impossible"<<endl;
  }
  
  return 0;

}




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

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

string S;
ll total = 0;
vector<string> split(const string &str, char sep)
{
	std::vector<std::string> v;        // 分割結果を格納するベクター
	auto first = str.begin();              // テキストの最初を指すイテレータ
	while (first != str.end()) {         // テキストが残っている間ループ
		auto last = first;                      // 分割文字列末尾へのイテレータ
		while (last != str.end() && *last != sep)       // 末尾 or セパレータ文字まで進める
			++last;
		v.push_back(std::string(first, last));       // 分割文字を出力
		if (last != str.end())
			++last;
		first = last;          // 次の処理のためにイテレータを設定
	}
	return v;
}

void count(string s)
{
	vector<string> v = split(s, '+');
	for (vector<string>::iterator it = v.begin(); it != v.end(); it++)
	{
		total += stoll(*it);
	}
}

void setPlus(int d, string s, int p)
{
	if (d == S.size() - 1)
	{
		count(s);
		return;
	}
	d++;
	string t = string(s);
	setPlus(d, t.insert(p, "+"), p + 2);
	setPlus(d, s, p + 1);
	d--;
}

int main()
{
	cin >> S;

	setPlus(0, S, 1);

	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in [0]*n]

cur = 0
visited = set()
count = 0
while cur != 1:
    if cur in visited:
        print(-1)
        break
    visited.add(cur)
    cur = a[cur] - 1
    count += 1

else:
    print(count)


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

typedef long long ll;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
#define SP << " " <<
#define D(a) cout<<#a<<":"<<a<<"\n"
#define D2(a,b) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<endl 
#define D3(a,b,c) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c <<endl
#define D4(a,b,c,d) cout<<#a<<":"<<a<<","<<#b<<":"<<b<<","<<#c<<":"<<c<<","<<#d<<":"<<d<<endl 
#define MOD 1000000007

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int N, K; cin >>N>>K;
    vector<bool> ng(10, false);
    rep(i, K) {
        int D; cin >>D;
        ng[D] = true;
    }

    int n;
    for (n = N;; n++) {
        int nchk = n;
        bool ok = true;
        while (nchk != 0) {
            if (ng[nchk%10]) {
                ok = false;
                break;
            }
            nchk /= 10;
        }
        if (ok)
            break;
    }

    cout << n << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
using namespace std;

int main(){
    long long N,A[2010],sum1=0,sum2=0;
    long long K;
    cin>>N>>K>>A[0];
    for(int i=1;i<N;++i){
        cin>>A[i];
        for(int j=0;j<i;++j)
            if(A[j]>A[i])++sum1;
    }

    for(int i=0;i<N;++i){
        for(int j=0;j<N;++j){
            if(A[j]>A[i])++sum2;
        }
    }

    long long p=(long long)pow(10,9)+7;
    long long q;
    if(K%2==0){q=(sum1*K)%p+(((sum2*(K-1))%p)*(K/2))%p;
               cout<<q%p<<endl;}
    else      {q=(sum1*K)%p+(((sum2*K)%p)*((K-1)/2))%p;
               cout<<q%p<<endl;}
    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <cstring>
using namespace std;

typedef long long ll;
pair<int, int> a[200001];
int main() {
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(NULL);
	
	int n; double d; cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		double x, y; cin >> x >> y;
		double cnt = x * x + y * y;
		cnt = sqrt(cnt);
		if (cnt <= d) {
			ans += 1;
		}
	}

	cout << ans << '\n';


}

Measured memory_bytes: 3184
import sys
sys.setrecursionlimit(10**9)

H, N = map(int, input().split())
magic = [_ for _ in range(N)]

for k in range(N):
  magic[k] = list(map(int, input().split()))
  magic[k].append(magic[k][0]/magic[k][1])

magic.sort(key = lambda x: x[2], reverse=True)
ans = [0 for _ in range(H+1)]
visited = [0]
anskouho = [float('inf')]

def solve(start, power, point, maryoku):
  if start == H:
    print(min(point, min(anskouho)))
    exit()
  elif start > H:
    anskouho.append(point)
    visited.sort(reverse=True)
    return 0
  elif ans[start] != 0:
    visited.sort(reverse=True)
    return 0
  else:
    visited.append(start)
    ans[start] = point
    solve(start+power, power, point+maryoku, maryoku)

for k in range(N):
  for item in visited:
    solve(item+magic[k][0], magic[k][0], ans[item] + magic[k][1], magic[k][1])

print(min(anskouho))

Measured memory_bytes: 82896
#include <queue>
#include <iostream>
#include <string>
using namespace std;

priority_queue<int> S; // priority queue in nonincreasing order
int k; // the integer to insert
int main() {
  string word; // insert, extract, or end
  while (cin >> word) {
    if (word == "insert") {
      cin >> k;
      S.push(k);
    }
    else if (word == "extract") {
      int n = S.top();
      S.pop();
      cout << n << endl;
    }
    else if (word == "end") break;
  }
}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (int i = 0; i < n; ++i)
#define reps(i, m, n) for (int i = m; i <= n; ++i)

using i64 = long long;
using pii = pair<i64, i64>;

template<class A, class B>inline bool chmax(A &a, const B &b){return b > a ? a = b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b < a ? a = b,1 : 0;}

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

signed main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  string s, t;
  cin >> s >> t;

  s += s;
  if (s.find(t) + 1) cout << "Yes" << "\n";
  else cout << "No" << "\n";

  return 0;
}

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

int expr(int l,int m,int r);
int term(int l,int m,int r);
int factor(int l,int m,int r);
int powexpr(int l,int m,int r);
int fraction(int l,int m,int r);
int primary(int l,int m,int r);
int digit(int l,int m,int r);

const int MOD = 2011;
string s[100];
int p,h,w;

int POW(int x,int n){
    int res=1;
    for(int i=0;(1<<i)<=n;i++){
        if((n>>i)&1) res=(res*x)%MOD;
        x=(x*x)%MOD;
    }
    return res;
}
int g_A(int l,int m,int r){
    for(;p<w;p++){
        for(int i=l;i<r;i++){
            if(s[i][p]!='.'){
                return expr(l,i,r);
            }
        }
    }
}
int expr(int l,int m,int r){
    int t=term(l,m,r);

    while(s[m][p]=='+' || s[m][p]=='-'){
        char tc=s[m][p];
        p+=2;
        int res=term(l,m,r);
        if(tc=='+') t=(t+res)%MOD;
        if(tc=='-') t=(t-res+MOD)%MOD;
    }

    return t;
}
int term(int l,int m,int r){
    int t=factor(l,m,r);

    while( s[m][p]=='*' ){
        p+=2;
        int res=factor(l,m,r);
        t=(t*res)%MOD;
    }

    return t;
}
int factor(int l,int m,int r){

    if(s[m][p]=='-'&&s[m][p+1]=='-'){
        return fraction(l,m,r);
    }

    else if(s[m][p]=='-'){
        p+=2;
        return (MOD - factor(l,m,r)) % MOD;
    }

    return powexpr(l,m,r);

}

int powexpr(int l,int m,int r){
    int t=primary(l,m,r);
    if(s[m][p]=='.'){
        if(m-1>=l && p && m && isdigit(s[m-1][p-1])){
            t=POW(t,s[m-1][p-1]-'0');
            p++;
        }
    }
    return t;
}

int primary(int l,int m,int r){
    if(s[m][p]=='('){
        p+=2;
        int t=expr(l,m,r);
        p+=2;
        return t;
    }
    else{
        int t=digit(l,m,r);
        p+=2;
        return t;
    }
}

int fraction(int l,int m,int r){
    int tmp=p;
    int A=g_A(l,0,m);
    p=tmp;
    int B=g_A(m+1,0,r);
    p=tmp;
    while(p<w && s[m][p]=='-') p++; p++;
    return ( A * POW(B,MOD-2) ) % MOD; 
}

int digit(int l,int m,int r){
    return s[m][p]-'0';
}

signed main(){
    while(cin>>h,h){
        p=0;
        for(int i=0;i<h;i++) cin>>s[i] , s[i]+="....@@" ;
        w=s[0].size()-5;
        cout<<g_A(0,0,h)<<endl;
    }
}


Measured memory_bytes: 3160
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    int N, M;
    cin>>N>>M;
    int sum = 0;
    int a;
    for(int i=0;i<M;++i){
        cin>>a;
        sum += a;
    }
    if(sum > N)cout<<-1<<endl;
    else cout<<N-sum<<endl;
}



Measured memory_bytes: 3636
#include <iostream>
#include <math.h>
#include <map>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	//入力を受け取る.
	//制約が1 <= A, B, T <= 20なので、int型で十分に格納できる.
	int A, B, T; cin >> A >> B >> T;
	//処理したいところだが...
	//今回の処理は、"T / A * B"だけなので、それをそのまま出力すれば良い.
	cout << T / A * B << endl;
	return 0;
}


Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
h,w=map(int,input().split())
infi=10**10
D=[list(input()) for i in range(h)]
kotae=[[infi]*(w) for _ in range(h)]
# D[i][j]はD[h-1][w-1]まで

cnt=0
if D[0][0]=='.':
    kotae[0][0]=0
else:
    kotae[0][0]=1
    cnt+=1
for i in range(1,h):
    if D[i][0]=='#' and D[i-1][0]=='.':
        cnt+=1
    kotae[i][0]=cnt

cnt=0
if D[0][0]=='.':
    kotae[0][0]=0
else:
    kotae[0][0]=1
    cnt+=1
for j in range(1,w):
    if D[0][j]=='#' and D[0][j-1]=='.':
        cnt+=1
    kotae[0][j]=cnt
for i in range(h-1):
    for j in range(w-1):
        kouho1 = kotae[i][j+1]
        if D[i][j+1]=='.' and D[i+1][j+1]=='#':
            kouho1+=1
        kouho2=kotae[i+1][j]
        if D[i+1][j]=='.' and D[i+1][j+1]=='#':
            kouho2+=1
        kotae[i+1][j+1]=min(kouho1,kouho2)
print(kotae[h-1][w-1])

Measured memory_bytes: 43248
def inv(x):
    z=1
    while z<=x:
        z<<=1
    return z-x

N=int(input())
A=list(map(int,input().split()))

d={}
for x in A:
    if x in d:
        d[x]+=1
    else:
        d[x]=1

l=sorted(d,reverse=True)

ans=0

for x in l:
    if d[x]>0:
        y=inv(x)
        if x==y:            
            ans+=d[x]//2
            d[x]%=2
        elif y in d and d[y]>0:
            ans+=min(d[x],d[y])
            d[x],d[y]=d[x]-min(d[x],d[y]),d[y]-min(d[x],d[y])
            
print(ans)

Measured memory_bytes: 111956
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stdio.h>
#include <cstring>
#include <queue>
#include <stack>
#include <functional>
#include <math.h>
#include <iomanip>
using namespace std;
#define Would
#define you
const int INF = 999999999;
const int MOD = 1e9 + 7;
const double pi = 3.141592653589793238;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a / b + a % b << endl;
}



Measured memory_bytes: 3124
#include <stdio.h>
int main(){
  int n,cnt=0;
  scanf("%d",&n);
  for (;n>0;n--){
    if (n<10) cnt++;
    else if(n>99 && n<1000) cnt++;
    else if(n>9999 && n<100000) cnt++;
  }
  printf("%d\n",cnt);
  return 0;
}


Measured memory_bytes: 128