akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
using namespace std;

int main(int argc, char *argv[]) {
    string s, t;
    cin >> s;
    cin >> t;

    long long lcs[s.size() + 1][t.size() + 1];

    for (int i = 0; i < s.size() + 1; i++) {
        lcs[i][0] = 0;
    }
    for (int i = 0; i < t.size() + 1; i++) {
        lcs[0][i] = 0;
    }

    for (int i = 1; i < s.size() + 1; i++) {
        for (int j = 1; j < t.size() + 1; j++) {
            if (s[i - 1] == t[j - 1]) {
                lcs[i][j] = lcs[i-1][j-1] + 1;
            } else {
                lcs[i][j] = max(lcs[i-1][j], lcs[i][j-1]);
            }
        }
    }

    /*
    for (int i = 0; i < s.size(); i++) {
        for (int j = 0; j < t.size(); j++) {
            cout << lcs[i][j] << " ";
        }
        cout << endl;
    }
     */

    string answer = "";
    long i = s.size();
    long j = t.size();
    while (i > 0 && j > 0) {
        // lcs[i-1][j] --> lcs[i][j]
        if (lcs[i-1][j] == lcs[i][j]) {
            i--;
        }

        // lcs[i][j-1] --> lcs[i][j]
        else if (lcs[i][j-1] == lcs[i][j]) {
            j--;
        }

        else {
            answer = s[i - 1] + answer;
            i--;
            j--;
        }
        // cout << answer << " : " << answer.size() << endl;
    }

    cout << answer;
    return 0;
}

Measured memory_bytes: 70656
S = input()

check = 0
count = 0
for i in range(len(S)):
    if check == int(S[i]):
        count += 1
    check = 1-check

check = 1
count2 = 0
for i in range(len(S)):
    if check == int(S[i]):
        count2 += 1
    check = 1-check

print(len(S) - max(count, count2))

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

int main(){ 
    int a,b,k;
    int c=0;
    int d=0;
    cin>>a>>b>>k;
    for(int i=100;i>0;i--){
      if(a%i==0&&b%i==0){
        c++;
      }
      if(c==k){
        d=i;
        break;
      }
    }
    cout<<d;
    return 0;
}


Measured memory_bytes: 256
from collections import deque

K = int(input())
if K < 10:
    print(K)
else:
    K -= 9
    q = deque(list(range(1, 10)))
    while K:
        num = q.popleft()
        last_digit = str(num)[-1]
        if last_digit == '0':
            q.append(int(str(num) + '0')); K -= 1
            if K == 0: break
            q.append(int(str(num) + '1')); K -= 1
        elif last_digit == '9':
            q.append(int(str(num) + '8')); K -= 1
            if K == 0: break
            q.append(int(str(num) + '9')); K -= 1
        else:
            q.append(int(str(num) + str(int(last_digit) - 1))); K -= 1
            if K == 0: break
            q.append(int(str(num) + str(int(last_digit)))); K -= 1
            if K == 0: break
            q.append(int(str(num) + str(int(last_digit) + 1))); K -= 1
    print(q[-1])

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

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

}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define eb emplace_back
#define pb push_back
#define ll long long
#define mp make_pair
#define x first
#define y second
//# define INF 99999999999999999
#define mod 1000000007
#define mod1 1000000006
#define sc(a) scanf("%d",&a);
#define pc(x) putchar_unlocked(x)
#define PI  3.141592653589793
#define pp pair < ll , ll >
using namespace std;

int min(int a ,  int b)
{
  if(a<b) return a;
  else return b;
}
int max(int a ,  int b)
{
  if(a>b) return a;
  else return b;
}
int a[100005];

int cn[1000005];
int main()
{
	string s , r;
	cin >> s;
	cin >> r;
	int ans = 0;
	rep( i , 0 , s.size()) if(s[i] == r[i]) ans++;
	cout << ans << "\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000'000'000
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	//freopen("in", "r", stdin);
	ll n,k;
	cin >> n >> k;
	vector <int> a(n+1), start(n+1, INF), path;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	int cyc = 0;
	for(int timer = 0, i = 1; ; timer++, i = a[i]){
		if(start[i] >= timer)
			path.push_back(i), start[i] = timer;
		else{
			cyc = start[i];
			break;
		}
	}
	if(k <= cyc){
		cout << path[k] << endl;
	}
	else{
		int ln = path.size() - cyc;
		// (k - cyc) % ln + cyc
		cout << path[(k - cyc) % ln + cyc] << endl;
	}
	
	
	return 0;
}





Measured memory_bytes: 5816
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;

int n, S, G, d;
string line[31];

void print(){
  for(int i = 0 ; i < d ; i++){
    cout << line[i] << endl;
  }
  cout << endl;
}

bool solve(){
  int row = S;
  for(int i = 0 ; i < d ; i++){
    if(line[i][row] == '1') row++;
    else if(line[i][row-1] == '1') row--;
  }
  if(row == G) return true;
  else return false; 
}

int main(){
  while(cin >> n){
    if(n == 0) break;
    cin >> S >> G >> d;
    for(int i = 0 ; i < d ; i++){      
      cin >> line[i];
      line[i] = "0" + line[i] + "0";
    }
    
    if(solve()){
      cout << 0 << endl;
      continue;
    }
    
    bool flag = false;
    for(int i = 0 ; i < d ; i++){
      for(int j = 1 ; j < n ; j++){
	if(line[i][j] == '1' ||
	   line[i][j-1] == '1' || line[i][j+1] == '1') continue;
	line[i][j] = '1';
	if(solve()){
	  flag = true;
	  cout << i+1 << ' ' << j << endl;
	  i = d, j = n;
	}
	else line[i][j] = '0';
      }
    }
    if(!flag) cout << 1 << endl;
  }
  return 0;
}

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

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int n;
  cin>>n;
  int a[200005];
  int c[200005];
  for(int i=0;i<n;i++){
    cin>>a[i];
    c[i]=a[i];
  
  }
  sort(c,c+n);
  for(int i=0;i<n;i++){
    
    if(c[n-1]==a[i]){
      cout<<c[n-2]<<endl;
      
    }else{
          cout<<c[n-1]<<endl;
         
    }

  }




}



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

using namespace std;
typedef long long ll;
const ll INF = 1e9;
 
int main(void) {
    int N;
    cin >> N;
    vector<double> v(N);
    for (int i = 0; i < N; i++) { cin >> v[i]; }
    sort(begin(v), end(v));
    double sum = 0;
    for (int i = 0; i < N - 1; i++) {
        double avg = (v[i] + v[i + 1]) / 2.0;
        v[i+1] = avg;
    }
    cout << v[N - 1] << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

const int mod = 1000000007;
class mint {
    long long x;
public:
    mint(long long x=0) : x((x%mod+mod)%mod) {}
    mint operator-() const { 
      return mint(-x);
    }
    mint& operator+=(const mint& a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint& a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const  mint& a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint& a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint& a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint& a) const {
        mint res(*this);
        return res*=a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime mod
    mint inv() const {
        return pow(mod-2);
    }
    mint& operator/=(const mint& a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint& a) const {
        mint res(*this);
        return res/=a;
    }
 
    friend ostream& operator<<(ostream& os, const mint& m){
        os << m.x;
        return os;
    }
};

int main(){
    ll N;
    cin >> N;
    vector<ll> T(N),A(N),V(N),a(N),b(N);
    rep(i,N){
        cin >> T[i];
    }
    rep(i,N){
        cin >> A[i];
    }
    ll M = 0;
    ll M2 = 0;
    rep(i,N){
        if(M < T[i]){
            M = T[i];
            V[i]++;
            a[i]++;
        }
    }
    rep(i,N){
        if(M2 < A[N-1-i]){
            M2 = A[N-1-i];
            V[N-1-i]++;
            b[N-1-i]++;
        }
    }
    rep(i,N){
        if(V[i] >= 2){
            if(T[i] != A[i]){
                cout << 0 << endl;
                return 0;
            }
        }else if(V[i] >= 1){
            if(a[i]){
                if(T[i] > A[i]){
                    cout << 0 << endl;
                    return 0;
                }
            }else{
                if(A[i] > T[i]){
                    cout << 0 << endl;
                    return 0;
                }
            }
        }
    }
    mint ans = 1;
    rep(i,N){
        if(V[i] > 0){
            continue;
        }
        ans *= min(T[i], A[i]);
    }
    cout << ans << endl;
}

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

using namespace std;

typedef long long int64;
typedef pair< int64, int64 > Pi;
const int64 INF = 1LL << 60;

Pi operator-(Pi &a, Pi &b)
{
  return {a.first - b.first, a.second - b.second};
}


int64 cross(Pi a, Pi b)
{
  return (a.first * b.second - b.first * a.second);
}

vector< int64 > beet(vector< Pi > point)
{
  auto f = [](vector< Pi > st)
  {

    vector< int64 > area(st.size(), 0);
    vector< Pi > upper;
    upper.emplace_back(st[0]);
    upper.emplace_back(st[1]);
    for(int i = 2; i < st.size(); i++) {
      area[i] += area[i - 1];
      while(upper.size() >= 2) {
        int sz = (int) upper.size();
        if(cross(upper[sz - 1] - upper[sz - 2], st[i] - upper[sz - 1]) >= 0) break;
        if(upper.size() > 2) area[i] -= cross(upper[upper.size() - 2] - upper[0], upper.back() - upper[0]);
        upper.pop_back();
      }
      upper.push_back(st[i]);
      if(upper.size() > 2) area[i] += cross(upper[upper.size() - 2] - upper[0], upper.back() - upper[0]);
    }
    return (area);
  };

  vector< int64 > latte(point.size(), 0LL);
  auto lala = f(point);
  for(int i = 0; i < point.size(); i++) point[i].second *= -1;
  auto rara = f(point);
  for(int i = 0; i < point.size(); i++) latte[i] += lala[i];
  for(int i = 0; i < point.size(); i++) latte[i] += rara[i];
  return (latte);
}

int main()
{
  int N;
  scanf("%d", &N);
  vector< Pi > P(N);
  for(auto &p : P) scanf("%lld %lld", &p.first, &p.second);
  sort(begin(P), end(P));
  auto pp = beet(P);
  reverse(begin(P), end(P));
  auto qq = beet(P);
  sort(begin(P), end(P));
  reverse(begin(qq), end(qq));
  int64 ret = min(pp.back(), qq.front());
  for(int i = 1; i < N; i++) {
    if(P[i - 1].first != P[i].first) ret = min(ret, pp[i - 1] + qq[i]);
  }
  printf("%lld\n", (ret + 1) / 2);
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define X real()
#define Y imag()
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)
#define vary(type,name,size,init) vector< type> name(size,init)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define REP(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using dict = map<string,int>;
using comd = complex<double>;
using pii = pair<int,int> ;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

inline bool value(int x,int y,int w,int h){
  return (x >= 0 && x < w && y >= 0 && y < h);
}

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template<typename T>
void Unique(vector<T> &v){
  sort(all(v));
  v.erase(all(v),v.end());
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

void Ans(bool f){
  if(f) cout << "YES"<<endl;
  else cout << "NO"<<endl;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  double minv,v,t;
  while(cin >> minv){
    int N = 2,h;
    while(1){
      h = 5 * N - 5;
      t = sqrt(h/4.9);
      v = 9.8 * t ;
      if(minv <= v){
        cout << N<<endl;
        break;
      }
      else{
        ++N;
      }
    }
  }
  return 0;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
 
int main()
{
	long long int n,i,c=0,c1=0,j;
	cin>>n;
	for(i=1;i<=n;i+=2)
	{
	    c=0;
	    for(j=1;j<=i;j++)
        {
            if(i%j==0) c++;
        }
        if(c==8)
       {
           
           c1++;}
	}
	cout<<c1<<endl;
	return 0;
}


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


public class Main {
	public static void main(String[] args) {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));       
		try {
			String line;
			while((line = r.readLine())!=null){
				int V = Integer.parseInt(line.split(" ")[0]), d = Integer.parseInt(line.split(" ")[1]);
				if(V==1){
					System.out.println(1);
					continue;
				}
				int[] fib = new int[V];
				
				//obtain fibonacci sequence
				fib[0] = 2;
				fib[1] = 3;
				
				for(int i=2;i<V;i++){
					fib[i] = fib[i-2] + fib[i-1];
					fib[i] = fib[i] % 1001;
				}
				
				//sort
				Arrays.sort(fib);
				
				//count connected subsets
				int c = 1;
				for(int i=0;i<V-1;i++){
					if(fib[i+1] - fib[i] >= d){
						c++;
					}
				}
				System.out.println(c);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 21712
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    long n = Long.parseLong(sc.next());
    StringBuilder ans = new StringBuilder();
    while (n > 26) {
      char r = (char) (n % 26);
      n /= 26;
      if (r == 0) {
        r = 26;
        n--;
      }
      ans.append((char) (r + 'a' - 1));
    }
    char r = (char) n;
    ans.append((char) (r + 'a' - 1));
    pw.println(ans.reverse());
  }
}


Measured memory_bytes: 35720
#include<iostream>
#include<deque>
using namespace std;
int main () {
	int m,d,k1,k2,count=0;
	cin>>m>>d;
	for (int i=22;i<=d;i++) {
		k1=i%10;k2=i/10;
		if (k1>=2&&k2>=2) {
			if (k1*k2<=m) count++;
		}
	}
	cout<<count<<endl;
}

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

int main() {
    int n;
    cin >> n;
    int seki;
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0 && n / i <=9) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    
    return 0;
}

Measured memory_bytes: 3584
Q =input()
if Q.count('R')==3:
    print(3)
elif Q.count('R')==0:
    print(0)
elif Q.count('R')==1:
    print(1)
elif Q.count('R')==2:
    if Q[1] =='S':
        print(1)
    else :
        print(2)

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

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if(A==B)System.out.println(C);
        else if(B==C)System.out.println(A);
        else System.out.println(B);
    }
}

Measured memory_bytes: 25172
n = int(input())
ss = []
for i in range(n):
    ss.append(input())

m = int(input())
ts = []
for i in range(m):
    ts.append(input())

counter = dict()

for s in ss:
    counter.setdefault(s, 0)
    c = counter.get(s)
    counter[s] = c + 1
    
for t in ts:
    counter.setdefault(t, 0)
    c = counter.get(t)
    counter[t] =  c - 1
    
ans = max(counter.values())
if ans < 0:
    ans = 0
print(ans)


    


Measured memory_bytes: 3064
#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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)*}
    };
}

#[allow(unused_macros)]
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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

fn main() {
    input! {
        n: u64,
        vals: [[String; 2]; n],
    }
    let mut ans: f64 = 0.;
    for val in vals {
        let money: f64 = val[0].parse().unwrap();
        let money: f64 = match val[1].as_ref() {
            "JPY" => money,
            "BTC" => money * 380000.0,
            _ => panic!(),
        };
        ans += money;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

int dp[100000+10];
vector<int> vs;

int main(void) {
  vs.push_back(1);
  for(int c = 6; c <= 100000; c *= 6) {
    vs.push_back(c);
  }
  for(int c = 9; c <= 100000; c *= 9) {
    vs.push_back(c);
  }
  
  int n;
  cin >> n;
  REP(i, n+1) {
    dp[i] = i;
  }
  REP(i, n) {
    REP(j, vs.size()) {
      if(i+vs[j] <= n) {
        dp[i+vs[j]] = min(dp[i+vs[j]], dp[i] + 1);
      }
    }
  }
  cout << dp[n] << endl;
  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
#include<algorithm>
using namespace std;

int countUp(const string str, const string target)
{
    int cnt = 0;
    auto pos = str.find(target);
    while (pos != string::npos) {
        cnt++;

        pos = str.find(target, pos + target.size());
    }

    return cnt;
}

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

    vector<string> s(N);
    for (int i = 0; i < N; i++)
        cin >> s[i];

    int cntAB, cntxA, cntBx, cntBxA;
    cntAB = cntxA = cntBx = cntBxA = 0;
    for (int i = 0; i < N; i++) {
        cntAB += countUp(s[i], "AB");

        char top = s[i].front();
        char back = s[i].back();
        if (top == 'B' && back == 'A')
            cntBxA++;
        else if (top == 'B')
            cntBx++;
        else if (back == 'A')
            cntxA++;
    }

    //cntAB += max(0, cntBxA - 1);
    //cntBxA = 0;

    //if (cntxA > 0) {
    //    cntAB++;
    //    cntxA--;
    //}
    //if (cntBx > 0) {
    //    cntAB++;
    //    cntBx--;
    //}

    //int n = min(cntxA, cntBx);
    //cntAB += n;
    //cntxA -= n;
    //cntBx -= n;

    if (cntBxA == 0)
        cntAB += min(cntBx, cntxA);
    else if (cntBx + cntxA > 0)
        cntAB += cntBxA + min(cntBx, cntxA);
    else
        cntAB += cntBxA - 1;

    cout << cntAB << endl;

    return 0;
}


Measured memory_bytes: 768
// luogu-judger-enable-o2
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string a;
	cin>>a;
	int len=a.length();
	int place=-1;
	for(int i=0;i<=len-1;i++)
	{
		if(a[i]=='C')
		{
			place=i;
			break;
		}
	}
	if(place==-1)
	{
		cout<<"No"<<endl;
		return 0;
	}
	for(int i=place+1;i<=len-1;i++)
	{
		if(a[i]=='F')
		{
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

using namespace std;
using ll = long long;

template <int M, bool IsPrime = false> class Modulo {
  int n;
  static typename std::enable_if<IsPrime, ll>::type inv(ll a, ll p) {
    return (a == 1 ? 1 : (1 - p * inv(p % a, a)) / a + p);
  }

public:
  Modulo() : n(0) { ; }
  Modulo(int m) : n(m) {
    if (n >= M)
      n %= M;
    else if (n < 0)
      n = (n % M + M) % M;
  }
  Modulo(ll m) {
    if (m >= M)
      m %= M;
    else if (m < 0)
      m = (m % M + M) % M;
    n = m;
  }
  explicit operator int() const { return n; }
  explicit operator ll() const { return n; }
  bool operator==(const Modulo &a) const { return n == a.n; }
  Modulo &operator+=(const Modulo &a) {
    n += a.n;
    if (n >= M) n -= M;
    return *this;
  }
  Modulo &operator-=(const Modulo &a) {
    n -= a.n;
    if (n < 0) n += M;
    return *this;
  }
  Modulo &operator*=(const Modulo &a) {
    n = (ll(n) * a.n) % M;
    return *this;
  }
  Modulo operator+(const Modulo &a) const {
    Modulo res = *this;
    return res += a;
  }
  Modulo operator-(const Modulo &a) const {
    Modulo res = *this;
    return res -= a;
  }
  Modulo operator-() const { return Modulo(0) - *this; }
  Modulo operator*(const Modulo &a) const {
    Modulo res = *this;
    return res *= a;
  }

  Modulo operator^(ll m) const {
    if (m == 0) return Modulo(1);
    const Modulo a = *this;
    Modulo res = (a * a) ^ (m / 2);
    return m % 2 ? res * a : res;
  }
  typename std::enable_if<IsPrime, Modulo>::type
  operator/(const Modulo &a) const {
    return *this * inv(ll(a), M);
  }
  typename std::enable_if<IsPrime, Modulo>::type operator/=(const Modulo &a) {
    return *this *= inv(ll(a), M);
  }

  friend bool is_zero(const Modulo &x) { return int(x) == 0; }
  friend int abs(const Modulo &x) { return int(x); }

  static Modulo fact(int n, bool sw = true) {
    static std::vector<Modulo> v1 = { 1 }, v2 = { 1 };
    if (n >= (int)v1.size()) {
      const int from = v1.size(), to = n + 1024;
      v1.reserve(to);
      v2.reserve(to);
      for (int i = from; i < to; ++i) {
        v1.push_back(v1.back() * Modulo<M, true>(i));
        v2.push_back(v2.back() / Modulo<M, true>(i));
      }
    }
    return sw ? v1[n] : v2[n];
  }
  static Modulo comb(int a, int b) {
    if (b < 0 || b > a) return 0;
    return Modulo::fact(a, true) * Modulo::fact(b, false) *
           Modulo::fact(a - b, false);
  }
};
using Mod = Modulo<1000000007, true>;

int main(void)
{
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  Mod answer=0;
  REP(i,h-a) {
    answer += Mod::comb(h-a+b-1, i) * Mod::comb(a+w-b-1,h-i-1);
  }
  cout << (ll)answer << endl;
  return 0;
}



Measured memory_bytes: 1544
#include<iostream>
#include<algorithm>
using namespace std;
int n,arr[100005],dp[100005];
int main()
{
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>arr[i];
	}
	dp[1]=abs(arr[0]-arr[1]);
	for(int i=2;i<n;i++){
		dp[i]=min(abs(arr[i]-arr[i-1])+dp[i-1],abs(arr[i]-arr[i-2])+dp[i-2]);
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
using namespace std;
string a,b;
int main()
{
    cin>>a>>b;
    sort(b.begin(),b.end());
    reverse(b.begin(),b.end());
    sort(a.begin(),a.end());
    if(b>a)
        cout<<"Yes"<<endl;
    else 
        cout<<"No"<<endl;
    return 0;
}

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

int main()
{
  int a, b, c;

  cin >> a >> b >> c;

  if ( (a == b + c)
    || (b == a + c)
    || (c == a + b) )
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
N, M = list(map(int, input().split()))
D = []
for i in range(M):
    D.append(list(map(int, input().split())))
P = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    ok = True
    bit = list(map(int, list(bin(i)[2:].rjust(N, "0"))))
    for S, p in zip(D, P):
        c = len([j for j in range(S[0]) if bit[S[1:][j]-1] == 1])
        if ok and c % 2 != p:
            ok = False
    if ok:
        ans += 1

print(ans)

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

using ll = long long int;
using ull = unsigned long long int;
using P = pair<ll, ll>;
using P3 = pair<P,ll>;
using PP = pair<P, P>;
constexpr int INF = 1 << 30;


void chmin(int &a, int b){
    a = min(a, b);
}

bool valid(int l, int r){
    return l%3 <= r%3;
}

int dp[100001][9][9][2];

int solve(){
    string s;
    cin >> s;
    if(s == "#") return 1;
    int n = s.size();
    for(int i=1;i<=n;i++){
        for(int j=0;j<9;j++){
            for(int k=0;k<9;k++){
                dp[i][j][k][0] = INF;
                dp[i][j][k][1] = INF;
            }
        }
    }
    for(int i=0;i<n;i++){
        int d = s[i]-'0'-1;
        for(int l=0;l<9;l++){
            if(l==4) continue;
            for(int r=0;r<9;r++){
                if(r==4) continue;
                if(!valid(l,r)) continue;
                if(valid(d,r)){
                    chmin(dp[i+1][d][r][0], min(dp[i][l][r][0]+1, dp[i][l][r][1]));
                }
                if(valid(l,d)){
                    chmin(dp[i+1][l][d][1], min(dp[i][l][r][0], dp[i][l][r][1]+1));
                }
            }
        }
    }
    int ans = INF;
    for(int i=0;i<9;i++){
        for(int j=0;j<9;j++){
            chmin(ans, dp[n][i][j][0]);
            chmin(ans, dp[n][i][j][1]);
        }
    }
    cout << ans << endl;
    return 0;
}

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



Measured memory_bytes: 66552
import itertools


def main():
    n, m, k = [int(x) for x in input().split()]
    array_a = [0] + list(itertools.accumulate(int(x) for x in input().split()))
    array_b = [0] + list(itertools.accumulate(int(x) for x in input().split()))

    def generate_anses():
        from_b = m
        for from_a in range(n + 1):
            if array_a[from_a] > k:
                break
            while array_b[from_b] > k - array_a[from_a]:
                from_b -= 1
            yield from_a + from_b

    print(max(generate_anses()))


if __name__ == '__main__':
    main()


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

int cnt = 0;

int factors(int x) {
  int c = 0;
  for (int i = 1; i <= x; i++)
    if (x % i == 0 && i % 2 == 1)
      c++;
  return c;
}

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++)
    if (factors(i) == 8) {
      cnt++;
    }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
string s;
bool check(int a, int b){
    for (int i=a; i+1 <= b; i++){
        if ((s[i] == '#') && (s[i+1] == '#')) return false;
    }
    return true;
}
signed main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    int n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    a--, b--, c--, d--;
    cin >> s;
    if ((a<c) && (c<b) && (b<d)){
        bool res = check(a,c)&check(b,d);
        if (res) cout << "Yes";
        else cout << "No";
        return 0;
    }
    if ((a<b) && (b<c) && (c<d)){
        bool res = check(a,c)&check(b,d);
        if (res) cout << "Yes";
        else cout << "No";
        return 0;
    }
    if (!check(a, c)){
        cout << "No";
        return 0;
    }
    for (int i=b; i <= d; i++){
        if ((i-1 >= 0) && (i+1 < n) && (s[i] == '.') && (s[i-1] == '.') && (s[i+1] == '.')){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 592
#include <cmath>
#include <iostream>
using namespace std;
typedef long double ld;
typedef double db;
const int maxn = 100;
const ld g = 9.8;
const db eps = 1e-8;
int n, v, x, y;
int L[maxn], B[maxn], R[maxn], T[maxn];
db calc(db vy, db t)
{
    return vy * t - g * t * t / 2;
}
int c1(db l, db r, db a)
{
    if (a < l + eps)
        return -1;
    if (a > r - eps)
        return 1;
    return 0;
}
bool check(ld qx, ld qy)
{
    ld a = g * g / 4, b = (g * qy - v * v), c = qx * qx + qy * qy;
    ld delta = b * b - 4 * a * c;
    if (delta <= 0 && delta > -eps)
        delta = 0;
    if (delta < 0)
        return 0;
    for (int d = -1; d < 1; d += 2)
    {
        ld t2 = (-b + d * sqrt(delta)) / 2 / a;
        if (t2 <= 0)
            continue;
        ld t = sqrt(t2);
        ld vx = qx / t, vy = (qy + g * t * t / 2) / t;
        ld yt = calc(vy, x / vx);
        if (yt < y - eps)
            continue;
        bool ok = 1;
        for (int i = 1; i <= n; i++)
        {
            if (L[i] >= x)
                continue;
            if (R[i] == x && y <= T[i] && B[i] <= yt)
                ok = 0;
            int yl = c1(B[i], T[i], calc(vy, L[i] / vx));
            int yr = c1(B[i], T[i], calc(vy, R[i] / vx));
            int xh = c1(L[i], R[i], vx * (vy / g));
            int yh = c1(B[i], T[i], calc(vy, vy / g));
            if (xh == 0 && yh >= 0 && yl < 0)
                ok = 0;
            if (yl * yr <= 0)
                ok = 0;
        }
        if (ok)
            return 1;
    }
    return 0;
}
int main()
{
ios::sync_with_stdio(0);
    scanf("%d%d%d%d", &n, &v, &x, &y);
    for (int i = 1; i <= n; i++)
        scanf("%d%d%d%d", &L[i], &B[i], &R[i], &T[i]);
    for (int i = 1; i <= n; i++)
    {
        R[i] = min(R[i], x);
    }
    bool ans = check(x, y);
    for (int i = 1; i <= n; i++)
    {
        ans |= check(L[i], T[i]);
        ans |= check(R[i], T[i]);
    }
    puts(ans ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 3176
#include <iostream>
#include <vector>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <unordered_map>
#include <unordered_set>

#define REP(i,a,n) for(int i=a;i<n;++i)
#define rep(i,n) REP(i,0,n)
#define REV(i,a,n) for(int i=n;i>=a;--i)
#define all(e) e.begin(),e.end()
#define rall(e) e.rbegin(),e.rend()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define mod 1000000007
#define show(n) cerr<<#n<<" = "<<n<<endl
#define shows(n) for(auto z:n){cerr<<z<<", ";}cerr<<endl

//ここからAtCoder向けdefine
#define yes cout << "YES" << endl
#define no cout << "NO" << endl

using namespace std;

using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using pint = pair<int,int>;

const int INF = (1 << 30);

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

    int n, d, x;
    cin >> n;
    cin >> d >> x;
    vi vec(n);
    rep(i, n){ cin >> vec[i]; }
    ll ans = x;
    rep(i, n){
        for(int j = 0;j < d;j += vec[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 888
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long X = sc.nextLong();
        List<Long> x = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            x.add(sc.nextLong());
        }
        long d = Math.abs(X - x.get(0));
        for (int i = 1; i < n; i++) {
            d = gcd(d, Math.abs(X - x.get(i)));
        }

        System.out.println(d);
    }

    public static long gcd(long a, long b) {
        if (b == 0) {
            return a;
        }
        return gcd(b, a % b);
    }
}


Measured memory_bytes: 52220
n,a,b = map(int,input().split())
ans = 0
for i in range(1,n+1):
    t = str(i)
    l = len(t)
    total = 0
    for j in range(l):
        total += int(t[j])
    if a<=total<=b:
        ans += i
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
const int N=1e5+10;
const int M=1e9+7;
const int inf=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int t=0;while(x){t+=BIT[x];x-=x&-x;}return t;}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
string s;
int n;
int main(){Accel
	cin>>s;
	int n;cin>>n;
	REP(i,SZ(s))
		if(i%n==0)cout<<s[i];
	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>x>>y;
    if(x!=0&&y==0){
        if(x>=0)Cout(x+1);
        else Cout(x*-1);
    }
    else if(x>=0&&y>=0){
        if(x<=y)Cout(y-x);
        else Cout(x-y+2);
    }
    else if(x>=0&&y<=0){
        if(x<=y*-1)Cout(y*-1-x+1);
        else Cout(x-y*-1+1);
    }
    else if(x<=0&&y>=0){
        if(x*-1<=y)Cout(y-x*-1+1);
        else Cout(x*-1-y+1);
    }
    else{
        if(x<=y)Cout(x*-1-y*-1);
        else Cout(y*-1-x*-1+2);
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#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)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1e9;
const long double EPS = 1e-10;

struct Drug {
  int a, b, c;
};

int main() {
  int n, ma, mb;
  cin >> n >> ma >> mb;
  vector<Drug> d(n);
  rep(i, n) cin >> d[i].a >> d[i].b >> d[i].c;

  vector<vector<int>> dp(n * 10 + 1, vector<int>(n * 10 + 1, INF));
  dp[0][0] = 0;
  rep(i, n) {
    repr(j, n * 10) {
      if (j - d[i].a < 0) continue;
      repr(k, n * 10) {
        if (k - d[i].b < 0) continue;
        dp[j][k] = min(dp[j][k], dp[j - d[i].a][k - d[i].b] + d[i].c);
      }
    }
  }

  int ans = INF, t = min(n * 10 / ma, n * 10 / mb);
  FOR(i, 1, t + 1) {
    ans = min(ans, dp[ma * i][mb * i]);
  }
  cout << (ans == INF ? -1 : ans) << endl;








  
  return 0;
}

Measured memory_bytes: 896
// atcoder/abc164/A/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; for (auto& i: v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { for (auto& i: v) is >> i; return is; }
template<typename T> ostream& operator << (ostream& os, set<T> s) { os << "#{"; for (auto& i: s) os << i << ","; os << "}"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; for (auto& i: m) os << i << ","; os << "}"; return os; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

using lli = long long int;
using ull = unsigned long long;
using point = complex<double>;
using str = string;
template<typename T> using vec = vector<T>;

constexpr array<int, 8> di({0, 1, -1, 0, 1, -1, 1, -1});
constexpr array<int, 8> dj({1, 0, 0, -1, 1, -1, -1, 1});
constexpr lli mod = 1e9 + 7;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.setf(ios_base::fixed);
  cout.precision(15);

  int s, w;
  while (cin >> s >> w) {
    cout << (s <= w ? "unsafe" : "safe") << endl;
  }

  return 0;
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;
typedef long long int ll;

int main()
{
    int n;
    scanf("%d",&n);
    printf("%d\n",n/3);
    return 0;
}


Measured memory_bytes: 256
// Nurstan Duisengaliev
// ASA KONKRETNO KATAIMASH

/*#pragma GCC target ("avx2")
#pragma GCC optimize ("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimize("O3")*/                   
      
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp> 
 
#define ll long long
#define all(x) x.begin(), x.end()
#define in insert
#define mp make_pair
#define F first
#define S second
#define ppf pop_front
#define pb push_back
#define ppb pop_back
#define pf push_front
#define pii pair <int, int>
#define boost() ios_base::sync_with_stdio(0), cin.tie(0)
#define sz(x) (int)x.size()
 
using namespace std;
//using namespace __gnu_pbds;

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

const int N = (int)2e6 + 123;
const int mod = (int)1e9 + 7;
const ll INF = (ll)1e18 + 1;
int n;
ll pw2[N], pw8[N];
ll f[N];
ll binpow (ll x, ll y) {
	if (y == 0) return 1ll;
	if (y % 2 == 0) {
		ll o = binpow (x, y / 2);
		return o * o % mod;
	}
	return binpow (x, y - 1) * x % mod;
}
ll cnk (int n, int k) {
	ll x = f[n];
	ll y = (f[n - k] * f[k]) % mod;
	return (x * binpow (y, mod - 2)) % mod;
}
void solve () {
	cin >> n;
	pw2[0] = pw8[0] = f[0] = 1;
	for (int i = 1; i <= n; i ++) {
		pw2[i] = (pw2[i - 1] * 2) % mod;
		pw8[i] = (pw8[i - 1] * 8) % mod;
		f[i] = (f[i - 1] * i) % mod;
	}
	if (n == 1) {
		cout << 0;
		return;
	}
	ll ans = 0;
	for (int i = 0; i <= n - 2; i ++) {
		int x = n - i;
		ll sum = (pw2[x] + mod) - 2;
		sum %= mod;
		sum *= cnk (n, x);
		sum %= mod;
		sum *= pw8[i];
		sum %= mod;
		ans += sum;
		ans %= mod;	
	}
	cout << ans;
}   	
 
main () {
//	freopen (".in", "r", stdin);
//	freopen (".out", "w", stdout);
	boost ();
	int TT = 1;
//    cin >> TT;
	while (TT --) {
		solve ();
	}
	return 0;	
}

Measured memory_bytes: 27008
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)*}
    };
}

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, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

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

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

use std::cmp::min;

fn main() {
    input!{
        n: usize,
        w: usize,
        v: [[usize; 2]; n]
    }
    let mut tab: Vec<Vec<usize>> = vec![vec![0; 100001]; n + 1];
    for i in 1..100001 {
        tab[0][i] = usize::max_value();
    }
    for i in 1..n + 1 {
        for j in 1..100001 {
            tab[i][j] = tab[i - 1][j];
            if v[i - 1][1] <= j && tab[i - 1][j - v[i - 1][1]] < usize::max_value() {
                tab[i][j] = min(tab[i][j], tab[i - 1][j - v[i - 1][1]] + v[i - 1][0]);
            }
        }
    }
    for i in (0..100001).rev() {
        if tab[n][i] <= w {
            println!("{}", i);
            return;
        }
    }
}


Measured memory_bytes: 106876
using System;
using System.Linq;
using System.Collections.Generic;

namespace c
{
    class Program
    {
        static void Main(string[] args)
        {
            var _ = Console.ReadLine().Split();
            var n = int.Parse(_[0]);
            var m = int.Parse(_[1]);

            var l1 = new List<int>();
            var l2 = new List<int>();
            for(var i = 0; i < m; i++){
                var s = Console.ReadLine().Split();
                var a = int.Parse(s[0]);
                var b = int.Parse(s[1]);

                if(a == 1){
                    l1.Add(b);
                }else if(b == n){
                    l2.Add(a);
                }
            }

            var l = l1.Intersect(l2);
            Console.WriteLine(l.Any() ? "POSSIBLE" : "IMPOSSIBLE");
        }
    }
}


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






int main() {
  int a,b,c;
  cin>>a>>b>>c;
  int x=10*b+c;
  if(x%4==0){cout<<"YES"<<endl;}
  else{cout<<"NO"<<endl;}
}

Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N, K = map(int, input().split())
    X = list(map(int, input().split()))

    INF = float("inf")
    M = [INF] * N
    P = [INF] * N
    i_m, i_p = 0, 0
    for x in X:
        if x == 0:
            K -= 1
        elif x > 0:
            P[i_p] = x
            i_p += 1
        else:
            M[i_m] = -x
            i_m += 1

    if K <= 0:
        print(0)
        exit()

    M.sort()
    P.sort()
    ans = min(M[K - 1], P[K - 1])
    for n_M in range(1, K + 1):
        dist = 2 * M[n_M - 1] + P[K - n_M - 1]
        if ans > dist:
            ans = dist
    for n_P in range(1, K + 1):
        dist = 2 * P[n_P - 1] + M[K - n_P - 1]
        if ans > dist:
            ans = dist

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 20024
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

template <typename T>
void ri(T& x);

const int MAXN = 305, INF = 400, MAXM = MAXN*MAXN;

int n, m, l;
int to[MAXM<<1], nex[MAXM<<1], fir[MAXN], co[MAXM<<1], cur=0;

void addEdge(int a, int b, int c) {
    if (c > l) return;
    co[cur] = c; to[cur] = b; nex[cur] = fir[a]; fir[a] = cur++; 
    co[cur] = c; to[cur] = a; nex[cur] = fir[b]; fir[b] = cur++; 
}

struct D {
    int tim, lef;
    
    bool operator<(const D& o) const {
        if (tim != o.tim) return tim < o.tim;
        return lef > o.lef;
    }
    
    D go(int e) const {
        D res = *this;
        if (res.lef >= co[e]) res.lef -= co[e];
        else { ++res.tim; res.lef = l - co[e]; }
        return res;
    }
}f[MAXN][MAXN];

int src;

struct CMP {
    bool operator()(const int q, const int p) const {
        return f[src][p] < f[src][q];
    }
}cmp;

void dijk(int src) {
    ::src = src;
    priority_queue<D, vector<int>, CMP> q;
    static bool outQ[MAXN];
    while (!q.empty()) q.pop();
    memset(outQ, false, sizeof(outQ));
    
    D (&dis)[MAXN] = f[src];
    q.push(src);
    
    while (!q.empty()) {
        const int x = q.top();
        q.pop();
        if (outQ[x]) continue;
        outQ[x] = true;
        
        for (int i=fir[x]; i!=-1; i=nex[i]) {
            const D tmp = dis[x].go(i);
            if (tmp < dis[to[i]]) {
                dis[to[i]] = tmp;
                q.push(to[i]);
            }
        }
    }
}

int main() {
    #ifdef DEBUG
        freopen("in", "r", stdin);
        // freopen("out", "w", stdout);
    #endif

    ri(n); ri(m); ri(l);
    memset(fir, -1, sizeof(fir));
    
    for (int i=1; i<=n; ++i) {
        for (int j=1; j<=n; ++j)
            f[i][j] = {INF, 0};
        f[i][i] = {0, l};
    }
    
    for (int i=0; i<m; ++i) {
        int a, b, c;
        ri(a); ri(b); ri(c);
        addEdge(a, b, c);
        // if (c > l) continue;
        // D now = l==c ? D{1, 0} : D{0, l-c};
        // if (now < f[a][b]) f[a][b] = now;
        // if (now < f[b][a]) f[b][a] = now;
    }
    
    for (int i=1; i<=n; ++i)
        dijk(i);
    
    int Q;
    ri(Q);
    while (Q--) {
        int a, b;
        ri(a); ri(b);
        if (f[a][b].tim == INF) printf("-1\n");
        else printf("%d\n", f[a][b].tim);
    }

    return 0;
}





template <typename T>
void ri(T& x) {
    char c;
    bool minus = false;
    while ((c=getchar())<'0' || '9'<c)
        if (c == '-') minus = true;
    x = c-'0';
    while ('0'<=(c=getchar()) && c<='9')
        x = 10*x - '0' + c;
    if (minus) x = -x;
}

Measured memory_bytes: 2176