akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
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; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
 
#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (int i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
 
 
 
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  ll n,x;
  cin >> n >> x;
  ll m[n];
  ll sai =INF;
  rep(i,n){
    cin >> m[i];
    chmin(sai,m[i]);
    x-=m[i];
  }
  pri(x/sai+n);
  
  return 0;
}


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

int main(void)
{
    int n, i, count;
    double d, r;
    double x[200000];
    double y[200000];
    count = 0;
    cin >> n;
    cin >> d;
    for (i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
        r = sqrt(x[i] * x[i] + y[i] * y[i]);
        if (r <= d)
        {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

int main() {
  string s;
  cin >> s;
  for (int i = 1; i < s.size(); i++) {
    if (s[i - 1] == s[i]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
}

Measured memory_bytes: 256
N, M = map(int, input().split())
H = list(map(int, input().split()))
W = []

for i in range(M):
  A, B = map(int, input().split())
  if H[A-1] == H[B-1]:
    W.append(A)
    W.append(B)
  elif H[A-1] >= H[B-1]:
    W.append(B)
  else:
    W.append(A)

print( N - len(set(W)) )

Measured memory_bytes: 20116
#define _CRT_SECURE_NO_WARNINGS

#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<map>
#include<tuple>
#include<algorithm>
#include<numeric>
#include<math.h>

#define REPS(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

const int mod = 1e9 + 7;
const long double pi = 3.141592653589793238462643383279502884197;
const long double eps = 1e-7;

vector<ll> av;

int main() {
	int N;
	cin >> N;
	REP(i, N) {
		ll num;
		cin >> num;
		av.push_back(num);
	}
	sort(av.begin(), av.end());

	ll ans = 0;
	ll targetNum = av[0];
	ll count = 1;

	if (av.size() == 1 && av[0] != 1) ans = 1;
	REPS(i, 1, av.size()) {
		if (targetNum == av[i]) {
			count++;
		}
		else {
			if (count < targetNum) ans += count;
			else ans += count - targetNum;
			targetNum = av[i];
			count = 1;
		}
		if (i == av.size() - 1) {
			if (count < targetNum) ans += count;
			else ans += count - targetNum;
		}
	}
	cout << ans;
	system("pause");
	return 0;
}

Measured memory_bytes: 1400
#include<bits/stdc++.h>//头文件
using namespace std;
int a,b,c;
int main(){
    cin>>a>>b>>c;
    if(a-b==b-c)cout<<"YES";//如果符合条件
    else cout<<"NO";//否则
    cout<<endl;//别忘了回车
    return 0;//完美结束
}
////////////**//////

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

llong cnt=0;

int main(void) {
  llong N, cnt=0;
  cin >> N;

  llong div = 10;

  if (N%2==0) {
    while(div<=N) {
      cnt += N/div;
      div *= 5;
    }
  }

  cout << cnt << endl;

  return (0);
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <map>

using namespace std;

int m[2][2];
int max_next[2][2];


int main() {
  int n;
  scanf("%d", &n);

  map<int, int> count[2];
  int v[n];
  for (int i = 0; i < n; i++) {
    scanf("%d", v + i);

    count[i%2][v[i]]++;
  }
  
  for (int i = 0; i < 2; i++) {
    for(auto itr = count[i].begin(); itr != count[i].end(); ++itr) {
      if (m[i][1] < itr->second) {
        max_next[i][0] = m[i][0];
        max_next[i][1] = m[i][1];

        m[i][0] = itr->first;
        m[i][1] = itr->second;
      } else if (max_next[i][1] < itr->second) {
        max_next[i][0] = itr->first;
        max_next[i][1] = itr->second;
      }


  // printf("%d %d\n", m[0][0], m[1][0]);
  // printf("%d %d\n", m[0][1], m[1][1]);
  //     printf("i:%d k:%d, v:%d\n",i, itr->first, itr->second);
    }
  }

  // printf("%d %d\n", m[0][0], m[1][0]);
  // printf("%d %d\n", m[0][1], m[1][1]);
  if (m[0][0] == m[1][0]) {
    int res1 = n - m[0][1] - max_next[1][1];
    int res2 = n - m[1][1] - max_next[0][1];

    if (res1 < res2) {
      printf("%d\n", res1);
    } else {
      printf("%d\n", res2);
    }
  } else {
    printf("%d\n", (n/2 - m[0][1]) + (n/2 - m[1][1]));
  }

  return 0;
}


Measured memory_bytes: 5376
N,L = map(int,input().split())

taste = [0]*N
for i in range(N):
  taste[i] = L + i

min_val = 10**3
min_idx = 0
for i in range(N):
  if min_val > abs(taste[i]):
    min_val = abs(taste[i])
    min_idx = i

ans = sum(taste)-taste[min_idx]
print(ans)

Measured memory_bytes: 9184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC_C
{
    class C095
    {
        static void Main(string[] args)
        {
            string[] a0 = Console.ReadLine().Split(' ');
            int A = int.Parse(a0[0]);
            int B = int.Parse(a0[1]);
            int C = int.Parse(a0[2]);
            int X = int.Parse(a0[3]), Y = int.Parse(a0[4]);

            int min = int.MaxValue;
            int maxAB = Math.Max(X, Y);
            for (int i = 0; i <= maxAB; i++)
            {
                int cost = i * C * 2; //ABピザ2i毎
                cost += Math.Max((X - i),0) * A;
                cost += Math.Max((Y - i),0) * B;
                if (cost < min) min = cost;
            }
            Console.WriteLine(min);
        }

    }
}


Measured memory_bytes: 13140
using System;
using System.Linq;

class Procon
{
    public Procon() { }
    static void Main(string[] agrs)
    {
        new Procon().Do();
    }

    Scanner cin;

    public void Do()
    {
        cin = new Scanner();
        int A = cin.nextInt();
        int B = cin.nextInt();
        int K = cin.nextInt();

        int count = 0;
        int i = Math.Min(A, B);
        while (true)
        {
            if (A % i == 0 && B % i == 0)
            {
                count++;
            }

            if (count == K)
            {
                break;
            }

            i--;
        }

        Console.WriteLine(i);
    }
}


class Scanner
{
    string[] s;
    int i;
    int max_i;

    public Scanner()
    {
        s = new string[0];
        max_i = 0;
        i = 0;
    }

    public string nextString()
    {
        if (i >= s.Length)
        {
            s = Console.ReadLine().Split(' ');
            max_i = s.Length;
            i = 0;
            if (max_i == 0)
            {
                return "";
            }
            return s[i++];
        }
        else
        {
            return s[i++];
        }
    }

    public int nextInt()
    {
        return int.Parse(nextString());
    }


    public long nextLong()
    {
        return long.Parse(nextString());
    }

    public double nextDouble()
    {
        return double.Parse(nextString());
    }

    public string[] arrayString()
    {
        return Console.ReadLine().Split(' ');
    }

    public int[] arrayInt()
    {
        string[] str = Console.ReadLine().Split(' ');
        int[] array = new int[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = int.Parse(str[i]);
        }
        return array;
    }

    public long[] arrayLong()
    {
        string[] str = Console.ReadLine().Split(' ');
        long[] array = new long[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = long.Parse(str[i]);
        }
        return array;
    }

    public double[] arrayDouble()
    {
        string[] str = Console.ReadLine().Split(' ');
        double[] array = new double[str.Length];
        for (int i = 0; i < str.Length; i++)
        {
            array[i] = double.Parse(str[i]);
        }
        return array;
    }
}


Measured memory_bytes: 13140
// 答えを見た
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

const MOD: i64 = 2019;

fn main() {
    input! {
        S: String,
    }

    // 2019 = 3 * 673
    // まずはNaive解を書いてみる
    // O(N^2) なので4*10^10 アウト
    // let mut ans = 0;
    // for i in 0..S.len() {
    //     for j in i + 1..S.len() {
    //         let s: &str = &S[i..j + 1];

    //         let num: i64 = s.parse().unwrap();
    //         if num % 2019 == 0 {
    //             ans += 1;
    //         }
    //     }
    // }

    // println!("{}", ans);

    // (i, j)が2019で割れるとはどういうことか
    // (i, N-1) % 2019 == (j+1, N-1) % 2019
    // ここで、「割り切れる」ではなくて「余りが同じ」という関係に持ち込んでいるのがポイント
    // 「割り切れる」だと当てはまるものが少ない。問題を分割したいのにサイズが小さくなっていない感じ

    let N = S.len();
    let mut Tmod2019s: Vec<i64> = Vec::with_capacity(N + 1);
    Tmod2019s.resize(N + 1, 0);

    let mut Rs: Vec<i64> = Vec::with_capacity(MOD as usize);
    Rs.resize(MOD as usize, 0);

    // 最初、「DPで~」ということが分かっていなかった。
    // |S|<=200000なので、Sは20万桁の数になりうる。
    // よって、Sそのものをparse()するとあふれてエラーになる。
    // そこで、剰余の性質を使って求めていく

    // (a * 10^n) % 2019 を求める必要があるが、
    // ・大きすぎてparseして % 2019 を計算することができない
    // ・10倍して % 2019 して、とすると全部でN^2の計算が必要なので間に合わない
    // よって、配列に直前の値を覚えておいてO(N)で求める

    // pow_mods[i] = (10^i) % 2019
    let mut pow_mods: Vec<i64> = Vec::with_capacity(N * 2);
    pow_mods.resize(N * 2, 0);

    pow_mods[0] = 1;
    for i in 1..N * 2 {
        pow_mods[i] = (pow_mods[i - 1] * 10) % MOD;
    }

    for i in (0..N).rev() {
        // これは収まらない
        // let s: &str = &S[i..N];
        // let num: i64 = s.parse().unwrap();

        // これもあふれる
        // Tmod2019s[i] = S[i..i+1] * 10^(N-i-1) + Tmod2019s[i+1];

        let mut num: i64 = (&S[i..i + 1]).parse().unwrap();
        // あああああああ、しれっとループが…
        // for _ in 0..(N - i - 1) {
        //     num = (num * 10) % MOD;
        // }

        // → なので、pow_mods[]として10^n % 2019を持っておく
        num = (num * pow_mods[N - i - 1]) % MOD;

        num = (num + Tmod2019s[i + 1]) % MOD;
        Tmod2019s[i] = num;

        Rs[Tmod2019s[i] as usize] += 1;
    }

    // 2019の倍数であるような部分文字列は、引かなくてもそれ単体で2019の倍数
    // これを見逃していて、数時間困っていた。
    let mut ans = Rs[0];

    // ペアにして引いて2019の倍数を作る
    for i in 0..MOD as usize {
        ans += Rs[i] * (Rs[i] - 1) / 2;
    }

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


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

typedef pair<int,int> pii; 

void solve()
{
    int n;cin >> n;
    vector<int> a(n);
    for(int i=0;i<n;++i)
    {
        int u,v;cin >> u >> v;
        if(u == v) a[i] = 1;
        else       a[i] = 0;
    }

    int cSum = 0;
    bool ok = 0;
    for(int i=0;i<n;++i)
    {
        if(a[i] == 1)
        {
            cSum += 1 ;
        } else {
            cSum = 0;
        }

        if(cSum == 3)
        {
            ok = 1;
        }
    }

    if(ok)
    {
        cout << "Yes" << '\n';
    } else {
        cout << "No" << '\n';
    }
}
 
signed main()
{
     int test_cases;test_cases=1;
     //cin >> test_cases;
     while(test_cases --> 0) solve();
}

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

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int T; cin >> T;

    while(T--){
        lint A, B, C, D; cin >> A >> B >> C >> D;
        if(A<B or B>D) {cout << "No" << endl; continue;}
        if(B<=C) {cout << "Yes" << endl; continue;}
        lint g = __gcd(B, D);
        if(B-g+A%g>C) cout << "No" << endl;
        else cout << "Yes" << endl;
    }
    
    return 0;
}

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

#[fastout]
fn main() {
    input! {a: u8, b: u8, c:u8};
    if a == b && b == c {
        println!("No")
    } else if a == b || a == c || c == b {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using Graph=vector<vector<pair<int,int>>>;
#define MOD 1000000007
#define INF 1000000000

int main(){
  string S;
  cin>>S;
  int sum=0;
  for(int i=0;i<S.size();i++){
    int x=S[i]-'0';
    sum+=x;
  }
  if(sum%9==0){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 3720
#include <cstdio>
#include <cmath>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

using ll = long long;

constexpr ll MAX_N = 100010;

ll N, K;
ll A[MAX_N];

int main()
{
  scanf( "%lld%lld", &N, &K );
  rep( i, N )
    scanf( "%lld", A+i );

  printf( "%lld\n", (ll)ceil(double(N-K)/(K-1))+1 );
  
  return 0;
}

Measured memory_bytes: 896
a = int(input())
k = 1
if a == 4 or a == 2 or a == 1:
  print(4)
  exit()
for i in range(1000000):
  if a % 2 == 0:
    a = a // 2
    k = k + 1
  else:
    a = 3 * a + 1
    k = k + 1
  if a == 4:
    print(k + 3)
    break

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
int n ,i ,j, temp,max ;
int m[100]={0};
int a=0,b=0;

scanf("%d",&n);
for(i=0;i<n;i++)
	scanf("%d",&m[i]);


//途中結果表示用
//for (i =0 ; i < n ; i++ )
 //printf ("%d ", m[i]);
 //printf ("\n");


//降順にソートする
for (j=0 ; j< n ; j++)
{	
	for (i=0 ; i+1 < n; i++)
	{
		if( m[i] < m[i+1] )
			{
			temp = m[i+1];
			m[i+1] = m[i];
			m[i] = temp;
			}
	}
	
}

//途中結果表示用
//for (i =0 ; i < n ; i++ )
// printf ("%d ", m[i]);
// printf ("\n");

for ( i=0 ; i < n+2 ; i+=2 )
	{
		a += m[i];
		b += m[i+1];
		}
		
printf("%d",a-b);
		
return 0;
}


Measured memory_bytes: 128
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using vi = vector<int>;
using vl = vector<int64_t>;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64_t INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

bool sorted(vector<int> &a) {
  vector<int> b = a;
  sort(all(b));
  for (size_t i = 0; i < a.size(); ++i) {
    if (a[i] != b[i]) {
      return false;
    }
  }
  return true;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

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

  rep(i, n) {
    rep(j, n) {
      //if (i == j) continue;
      if (1) {
        swap(a[i], a[j]);
        if (sorted(a)) {
          cout << "YES" << '\n';
          return 0;
        }
        swap(a[j], a[i]);
      }
    }
  }
  print("NO");

  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n), b(n), p(n), q(n);
    for (int i = 0; i < n; ++i)
        cin >> a[i];
    for (int i = 0; i < n; ++i)
        cin >> b[i];
    iota(p.begin(), p.end(), 0);
    iota(q.begin(), q.end(), 0);
    sort(p.begin(), p.end(), [&](int i, int j) {return a[i] < a[j];});
    sort(q.begin(), q.end(), [&](int i, int j) {return b[i] < b[j];});
    for (int i = 0; i < n; ++i) {
        if (a[p[i]] > b[q[i]]) {
            cout << "No" << endl;
            return 0;
        }
    }
    vector<int> r(n);
    for (int i = 0; i < n; ++i)
        r[p[i]] = q[i];
    int x = 0, c = 0;
    do {
        ++c;
        x = r[x];
    } while (x != 0);
    if (c < n - 1) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0, j = 0; i < n; ++i) {
        if (j < i)
            j = i;
        while (j + 1 < n && b[q[j]] >= a[p[j + 1]])
            ++j;
        if (b[p[i]] >= a[p[i]] && b[p[i]] <= b[q[j]]) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
} 

Measured memory_bytes: 2176
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <string>
#include <map>
#include <sstream>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <stdexcept>
#include <utility>
// #include <bits/stdc++.h>
#define ll long long
#define ld long double
#define rep(i,h) for(int i = 0; i < h; ++i)
#define rep1(i,h) for(int i = 0; i <= h; ++i)
#define rep2(i,n,h) for(int i = n; i < h; ++i)
#define rep3(l,n,h) for(int l = n; l <= h; ++l)
using namespace std;


    int main() {
    vector<char> first(3);
    vector<char> second(3);
    int count = 0;
    rep(i,3) cin >> first.at(i);
    rep(i,3) cin >> second.at(i);
    rep(i,3) {
        if(first.at(i) == second.at(2 - i)) {
            count++;
        }
    }
    if(count == 3) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }

        return 0;
    }


Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int n, G[N][N], c[N], d[N], f[N], t;

void dfs_v(int u){
  int v;
  c[u] = 1;
  d[u] = ++t;
  for( v = 0 ; v < n ; v++ ){
    if( G[u][v] == 0 ) continue;
    if( c[v] == 0 ) dfs_v(v);
  }
  c[u] = 2;
  f[u] = ++t;
}

void dfs(){
  int u;
  for( u = 0 ; u < n ; u++ ) c[u] = 0;
  t = 0;

  for( u = 0 ; u < n ; u++ ){
    if( c[u] == 0 ) dfs_v(u);
  }

  for( u = 0 ; u < n ; u++ ) printf("%d %d %d\n", u+1,d[u],f[u]);
}

int main(){
int u, v, k, i, j;

scanf("%d", &n);
for( i = 0 ; i < n ; i++ ){
for( j = 0 ; j < n ; j++ ){
G[i][j] = 0;
}
}

for( i = 0 ; i < n ; i++ ){
scanf("%d%d",&u,&k);
u--;
for( j = 0 ; j < k ; j++ ){
scanf("%d",&v);
v--;
G[u][v] = 1;
}
}
dfs();
return 0;
}



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

int main()
{
  int n,k;
  cin >> n >> k;
  vector<int> a(n);
  for(int &x: a) cin >> x;
  vector<bool> dp(k+1);
  for(int i=1; i<=k; i++){
  	for(int j = 0; j<n; j++){
    	if(i>=a[j] && !dp[i-a[j]]){
        	dp[i] = true;
        }
    }
  }
  (dp[k]==1)? cout << "First\n" : cout << "Second\n";
  return 0;
}

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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




void solve() {
    int N, Q; cin >> N >> Q;
    string s; cin >> s;
    vec l(Q), r(Q);
    rep(i, Q){
        cin >> l[i] >> r[i];
        l[i]--; r[i]--;
    }
    vec ss(N+1, 0);
    rep(i, N){
        if(s[i] == 'A' && s[i+1] == 'C') ss[i+1] = ss[i] + 1;
        else ss[i+1] = ss[i];
    }

    rep(i, Q){
        int res = ss[r[i]] - ss[l[i]];
        // if(ss[l[i]] == ss[l[i]-1]) res++;
        cout << res << endl;
    }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 6352
#include <bits/stdc++.h>
using namespace std;
char S[321123];
int ECUM[321123], WCUM[321123];

int main(){

    // 1. 入力情報取得.
    int N;
    scanf("%d", &N);
    scanf("%s", S);
    
    // 2. i番目(0-index)までの人に着目して, 'E', 'W' の 人数 の 累計和 を 取る.
    if(S[0] == 'E') ECUM[0] = 1;
    if(S[0] == 'W') WCUM[0] = 1;
    for(int i = 1; i < N; i++){
        ECUM[i] = ECUM[i - 1];
        WCUM[i] = WCUM[i - 1];
        if(S[i] == 'E') ECUM[i] = ECUM[i - 1] + 1;
        if(S[i] == 'W') WCUM[i] = WCUM[i - 1] + 1;
    }
    
    // 3. リーダーのいる方向に向く人数は？
    int ans = min(ECUM[N - 1] - ECUM[0], WCUM[N - 2]);
    for(int i = 1; i < N - 1; i++){
        // i番目(0-index) を リーダーとした場合を計算.
        // 0       ～ (i - 1)番目: 'W' を 向いている人を 'E' に 向かせるようにする.
        // (i + 1) ～ (N - 1)番目: 'E' を 向いている人を 'W' に 向かせるようにする.
        ans = min(ans, WCUM[i - 1] + ECUM[N - 1] - ECUM[i]);
    }
    
    // 4. 出力 ～ 後処理.
    printf("%d\n", ans);
    return 0;

}

Measured memory_bytes: 2944
use std::collections::HashMap;

fn main() {
    let n = read();
    let mut v = Vec::new();
    for _ in 0..n {
        let s = read_line_str();
        v.push(s);
    }

    let mut m : usize = 0;
    let mut a : usize = 0;
    let mut r : usize = 0;
    let mut c : usize = 0;
    let mut h : usize = 0;
    for i in &v {
        let s = i.chars().nth(0).unwrap();
        if s == 'M' {
            m += 1;
        }
        if s == 'A' {
            a += 1;
        }
        if s == 'R' {
            r += 1;
        }
        if s == 'C' {
            c += 1;
        }
        if s == 'H' {
            h += 1;
        }
    }

    let P : [usize; 10] = [0, 0, 0, 0, 0, 0, 1, 1, 1, 2];
    let Q : [usize; 10] = [1, 1, 1, 2, 2, 3, 2, 2, 3, 3];
    let R : [usize; 10] = [2, 3, 4, 3, 4, 4, 3, 4, 4, 4];

    let mut D : [usize; 5] = [0; 5];
    D[0] = m;
    D[1] = a;
    D[2] = r;
    D[3] = c;
    D[4] = h;

    let mut res : usize = 0;
    for d in 0..10 {
        res += D [ P [ d ]]* D [ Q [ d ]]* D [ R [ d ]];
    }

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

fn read() -> i32 {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_line_str() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s;
}


Measured memory_bytes: 9720
#include<stdio.h>
int main(void)
{
	int n,p,q,i,l,a[4],b,m,k,flg;
	scanf("%d",&n);
	while(1){
		if(n==0) break;
		p=0;q=0;m=0;flg=0;
		while(1){
			l=n;
			if(l==6174) break;
			flg=1;
			k=1000;
			for(i=0;i<4;i++){
				a[i]=n/k;
				n-=a[i]*k;
				k/=10;
			}
			for(i=0;i<3;i++){
				for(b=i+1;b<4;b++){
					if(a[i]<a[b]){
						k=a[i];
						a[i]=a[b];
						a[b]=k;
					}
				}
			}
			for(i=0;i<3;i++) if(a[i]!=a[i+1]) flg=0;
			if(flg==1) break;
			p=a[0]*1000+a[1]*100+a[2]*10+a[3];
			q=a[3]*1000+a[2]*100+a[1]*10+a[0];
			l=p-q;
			n=l;
			m++;
		}
		if(flg==1) printf("NA\n");
		else printf("%d\n",m);
		scanf("%d",&n);
	}
}


Measured memory_bytes: 2764
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp>
#define int long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
  cerr << *it << " = " << a << endl;
  err(++it, args...);
}
int max(int a , int  b){
  if(a > b) return a;
  else return b;

}
int min(int a , int b){
  if(a < b) return a;
  else return b;
}

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}
int gcd(int a , int b){
  if (b == 0) 
        return a; 
    return gcd(b, a % b);
}
int inv(int a , int b){
  return binpow(a,b-2,b);
}
int32_t main() 
{ 
  fast;
  int n;
  cin >> n;
  map < string  , int > sd;
  for(int i = 0 ; i < n ; i++){
    string s;
    cin >> s;
    sd[s]++;
  }
  cout <<  "AC x " << sd["AC"] << "\n"; 
  cout <<  "WA x " << sd["WA"] << "\n";
  cout <<  "TLE x " << sd["TLE"] << "\n";
  cout <<  "RE x " << sd["RE"] << "\n";
  return 0; 
}

Measured memory_bytes: 3660
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for (int i = 0; i < n; i++) {
            String line = sc.next();
            System.out.println(solve(line));
        }
    }

    static int solve(String s) {
        ArrayList<String> list = new ArrayList<>();
        list.add(s);
        for (int i = 1; i < s.length(); i++) {
            String a = s.substring(0, i);
            String b = s.substring(i);
            String revA = new StringBuilder(a).reverse().toString();
            String revB = new StringBuilder(b).reverse().toString();
            String[] res = new String[] {
                    a + revB,
                    revA + revB,
                    revA + b,
                    b + revA,
                    revB + revA,
                    revB + a,
                    b + a
            };
            for (String r: res) {
                if (!list.contains(r)) {
                    list.add(r);
                }
            }
        }
        return list.size();
    }
}

Measured memory_bytes: 62096
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define ANS cout << ans << endl
#define RETURN(x)    \
  cout << x << endl; \
  return 0
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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

signed main() {
  init();
  ll N, D, X;
  cin >> N >> D >> X;
  rep(i, N) {
    ll a;
    cin >> a;
    X += D / a + 1;
    if (D % a == 0) X--;
  }
  COUT(X);
  return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;
ll ans,c[410][4],h[410],v[4],tmp[4];
unordered_map<ll,int>mp;
void upd(ll x,int d){
    for(int i=0;i<4;i++,x=((x&1023ll)<<30ll)|(x>>10ll))
        mp[x]+=d;
    return;
}
ll Hash(ll *a){
    ll ret=0;
    for(int i=0;i<4;i++)
        ret|=(a[i]<<(i*10ll));
    return ret;
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld%lld%lld%lld",c[i],c[i]+1,c[i]+2,c[i]+3);
        h[i]=Hash(c[i]);
        upd(h[i],1);
    }
    for(int i=1;i<=n-5;i++){
        upd(h[i],-1);
        for(int j=i+1;j<=n;j++){
            upd(h[j],-1);
            for(int k=0;k<4;k++){
                ll res=1;
                for(int l=0;l<4;l++){
                    ll tmp[]={c[i][(l+1)&3],c[i][l],c[j][(3-l+k)&3],c[j][(6-l+k)&3]};
                    v[l]=Hash(tmp);
                    if(!mp.count(v[l]))
                        goto to;
                }
                for(int l=0;l<4;l++){
                    res*=mp[v[l]];
                    upd(v[l],-1);
                }
                ans+=res;
                for(int l=0;l<4;l++)
                    upd(v[l],1);
                to: ;
            }
            upd(h[j],1);
        }
    }
    printf("%lld",ans);
    return 0;
}

Measured memory_bytes: 384
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.FilterInputStream;
import java.io.BufferedInputStream;
import java.io.InputStream;

/**
 * @author khokharnikunj8
 */

public class Main {
    public static void main(String[] args) {
        new Thread(null, new Runnable() {
            public void run() {
                new Main().solve();
            }
        }, "1", 1 << 26).start();
    }

    void solve() {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        ScanReader in = new ScanReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AX solver = new AX();
        solver.solve(1, in, out);
        out.close();
    }

    static class AX {
        public void solve(int testNumber, ScanReader in, PrintWriter out) {
            int a = in.scanInt();
            int b = in.scanInt();
            out.println(Math.max(a + b, Math.max(a - b, a * b)));
        }

    }

    static class ScanReader {
        private byte[] buf = new byte[4 * 1024];
        private int index;
        private BufferedInputStream in;
        private int total;

        public ScanReader(InputStream inputStream) {
            in = new BufferedInputStream(inputStream);
        }

        private int scan() {
            if (index >= total) {
                index = 0;
                try {
                    total = in.read(buf);
                } catch (Exception e) {
                    e.printStackTrace();
                }
                if (total <= 0) return -1;
            }
            return buf[index++];
        }

        public int scanInt() {
            int integer = 0;
            int n = scan();
            while (isWhiteSpace(n)) n = scan();
            int neg = 1;
            if (n == '-') {
                neg = -1;
                n = scan();
            }
            while (!isWhiteSpace(n)) {
                if (n >= '0' && n <= '9') {
                    integer *= 10;
                    integer += n - '0';
                    n = scan();
                }
            }
            return neg * integer;
        }

        private boolean isWhiteSpace(int n) {
            if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1) return true;
            else return false;
        }

    }
}



Measured memory_bytes: 23508
#include <stdio.h>
int main(void){
    int n,i,j,s1=0,s2=0,min,d;
    min = 10000;
    scanf("%d",&n);
    int w[n];
 
    for(i=0;i<n;i++){
        scanf("%d",&w[i]);
    }
 
    for(i=0;i<n;i++){
        s1 = 0; s2 =0;
        for(j=0;j<=i;j++){
            s1 += w[j];
        }
        for(j=i+1;j<n;j++){
            s2 += w[j];
        }
        d = s1 - s2;
        if(d<0) d = d * -1;
        if(d<min) min = d;
    }
    printf("%d\n",min);
}

Measured memory_bytes: 128
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
#define MOD 1000000007
using namespace std;

signed main() {
  vector<int> prime(1000000, 0);
  for (int i = 2; i < prime.size(); i++) {
    if (prime[i] == 0) {
      prime[i] = 1;
      for (int j = i*2; j < prime.size(); j+=i) {
        prime[j] = -1;
      }
    }
  }
  prime[0] = -1;
  prime[1] = -2;
  int a, d, n;
  while (cin >> a >> d >> n, a+d+n) {
    int cnt = 0, ans = 0;
    while (cnt < n) {
      if (prime[a] == 1) {
        cnt++;
        ans = a;
      }
      a += d;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 10532
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;//*
inline int rd() {
	int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
	while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
inline char rc(){char c;while((c=getchar())!='Y'&&c!='N');return c;}
bool que(ll x){
	printf("? %lld\n",x);
	fflush(stdout);
	return rc()=='Y';
}
int main(){
	ll l,r;
	if(que(10000000000)){
		for(r=2;;r*=10)if(que(r))
			return cout<<"! "<< r/2<<endl,0;
	}
	for(r=10;;r*=10)if(!que(r))break;
	l=r/10,r--;
	while(l<r){
		ll mid=l+r>>1;
		if(que(mid*10))r=mid;
		else l=mid+1;
	}
	cout<<"! "<<l<<endl;
}

Measured memory_bytes: 596
/******************************************************************************

Welcome to GDB Online.
GDB online is an online compiler and debugger tool for C, C++, Python, Java, PHP, Ruby, Perl,
C#, VB, Swift, Pascal, Fortran, Haskell, Objective-C, Assembly, HTML, CSS, JS, SQLite, Prolog.
Code, Compile, Run and Debug online from anywhere in world.

*******************************************************************************/
#include <bits/stdc++.h>
using namespace std;

int main()
{
    int x, n;
    cin >> x >> n;
    set<int> st;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        st.insert(a);
    }
    for (int l = 0; ; l++)
    {
        if (st.find(x - l) == st.end())
        {
            cout << x - l << endl;
            break;
        }
        else if (st.find(x + l) == st.end())
        {
            cout << x + l << endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3608
#include <algorithm>
#include <bits/stdc++.h>
#include <unordered_map>
#include <unordered_set>
using namespace std;
#define mod (int)(1e9 + 21)
#define all(a) a.begin(),a.end()
#define for0(i, n) for (int i = 0; i < n; i++)
#define for1(i, n) for (int i = 1; i <= n; i++)
#define loop(i,a,b) for (int i = a; i < b; i++)
#define bloop(i,a,b) for (int i = a ; i>=b;i--)
#define tc(t) int t; cin >> t; while (t--)
#define int long long
#define ll long long 
#define pb emplace_back
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
#define in(x) scanf("%intd", &x)
#define rr return 0
#define prec(n) fixed<<setprecision(n)
#define maxheap priority_queue<int>
#define minheap priority_queue<int, vector<int>, greater<int> >
#define inf (int)(1e18)
#define ini(a, i) memset(a, i, sizeof(a))
#define fi first
#define se second
#define kitna se
#define endl "\n"
#define pi pair<int, int>
#define LL long long 
const int MAXN = (int)((1e5) + 10);
int gcd(int a,int b) { if (a == 0) return b; return gcd(b%a, a);}
int max(int a,int b){if(a>b) return a; else return b;}
int min(int a,int b){if(a<b) return a; else return b;}  
bool isPrime(int N){ for(int i=2;i*i<=N;++i){if(N%i==0) return false;}return true;}
int cbrt(int x){ int lo=1,hi=min(2000000ll,x);while(hi-lo>1){int mid=(lo+hi)/2;if(mid*mid*mid<x){lo=mid;}else hi=mid;}if(hi*hi*hi<=x) return hi;else return lo;} 
const int dx[4] = {-1, 1, 0, 0};
const int dy[4] = {0, 0, -1, 1};
const int nax =  (int)(1*1e5+10);
 
// int SPF[N+5];
 
// void SOF()
// {
//     SPF[1] = 1;
//     for (int i=2; i<N; i++)
//         SPF[i] = i;
//     for (int i=4; i<N; i+=2)
//         SPF[i] = 2;
 
//     for (int i=3; i*i<N; i++)
//         {
//         if (SPF[i] == i)
//             {
//             for (int kon=i*i; kon<N; kon+=i)
//                 if (SPF[kon]==kon)
//                    SPF[kon] = i;
//             }
//         }
// }
int a[nax];
int n; 
int dp[nax]; 
int k;
int func(int ind)
{
	if(ind==(n-1))
		return 0;
	else if(dp[ind]!=-1) return dp[ind];
	else
	{
		int ans = 1e9+5; 
		for(int i = 1;i<=k;i++)
		{
			if(ind+i<n)
				ans = min(ans,abs(a[ind+i]-a[ind]) + func(ind+i));
 
		}
		return dp[ind] = ans; 
	}
 
}
 
 
 
 
 
signed main(){
 
int t=1; 
//cin >> t;
// string s; 
// getline(cin,s);
 
while(t--)
{
    cin >> n >> k;
    for0(i,n) cin >> a[i]; 	
    ini(dp,-1); 
    cout << func(0); 
 
}
 
rr;
}

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

a, b = [0], [0]
for i in range(N):
    a.append(a[i]+A[i])
for i in range(M):
    b.append(b[i]+B[i])

ans, j = 0, M
for i in range(N+1):
    if a[i] > K: break
    while a[i] + b[j] > K:
        j -= 1
    ans = max(ans, i+j)
    
print(ans)

Measured memory_bytes: 47372
using System;
using System.Collections.Generic;
using static System.Console;
using System.Linq;


class Program
{
    static void Main(string[] Args) {
        var lis = new List<string>(ReadLine().Split(' ')).Select(int.Parse).ToList();
        string Result = "";

        //Path1
        /*
        for (int i = 0; i < lis[2] - lis[0]; i++)
            Result += 'L';
        for(int i = 0;i < lis[3] - lis[1];)
        */


        //Path1
        
        int x_diff = lis[2] - lis[0]; //tx - sx
        int y_diff = lis[3] - lis[1]; //ty - sy
        char add_c_x = (x_diff <= 0) ? 'L' : 'R';
        char add_c_y = (y_diff <= 0) ? 'D' : 'U';
        for (int i = 0; i < Math.Abs(x_diff); i++)
            Result += add_c_x;
        for (int i = 0; i < Math.Abs(y_diff); i++)
            Result += add_c_y;

        //Path2
        x_diff = -(lis[2] - lis[0]); //tx - sx
        y_diff = -(lis[3] - lis[1]); //ty - sy
        add_c_x = (x_diff <= 0) ? 'L' : 'R';
        add_c_y = (y_diff <= 0) ? 'D' : 'U';
        for (int i = 0; i < Math.Abs(x_diff); i++)
            Result += add_c_x;
        for (int i = 0; i < Math.Abs(y_diff); i++)
            Result += add_c_y;

        //Path3
        Result += (lis[3] - lis[1] <= 0) ? 'U' : 'D';
        x_diff = lis[2] - lis[0]; //tx - sx
        y_diff = lis[3] - lis[1]; //ty - sy
        add_c_x = (x_diff <= 0) ? 'L' : 'R';
        add_c_y = (y_diff <= 0) ? 'D' : 'U';
        for (int i = 0; i <= Math.Abs(x_diff); i++)
            Result += add_c_x;
        for (int i = 0; i <= Math.Abs(y_diff); i++)
            Result += add_c_y;
        Result += (lis[2] - lis[0] <= 0) ? 'R' : 'L';

        //Path4
        Result += (lis[3] - lis[1] <= 0) ? 'D' : 'U';
        x_diff = -(lis[2] - lis[0]); //tx - sx
        y_diff = -(lis[3] - lis[1]); //ty - sy
        add_c_x = (x_diff <= 0) ? 'L' : 'R';
        add_c_y = (y_diff <= 0) ? 'D' : 'U';
        for (int i = 0; i <= Math.Abs(x_diff); i++)
            Result += add_c_x;
        for (int i = 0; i <= Math.Abs(y_diff); i++)
            Result += add_c_y;
        Result += (lis[2] - lis[0] <= 0) ? 'L' : 'R';
        
        WriteLine(Result);

        ReadLine();
    }
}


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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long N, long long x, std::vector<long long> a) {
    long long ans1 = 0;
    auto cp = a;
    loop (i, 1, N) {
        if (a[i-1] + a[i] > x) {
            auto d = a[i-1] + a[i] - x;
            a[i] -= d;
            ans1 += d;
            if (a[i] < 0) a[i] = 0;
        }
    }

    long long ans2 = 0;
    a = cp;
    reverse(a.begin(), a.end());
    loop (i, 1, N) {
        if (a[i-1] + a[i] > x) {
            auto d = a[i-1] + a[i] - x;
            a[i] -= d;
            ans2 += d;
            if (a[i] < 0) a[i] = 0;
        }
    }

    cout << min(ans1, ans2) << endl;
}

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


Measured memory_bytes: 4836
#include <bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    int ans=0;
    for(int i=0;i<n;i++){
        int a;
        cin>>a;
        while(true){
            if(a%2!=0){
                break;
            }
            ans++;
            a/=2;
        }
    }
    cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c = sc.next();

    if (c.equals("a") || c.equals("e") || c.equals("i") || c.equals("o") || c.equals("u")) {
      System.out.println("vowel");
    } else {
      System.out.println("consonant");
    }
  }
}


Measured memory_bytes: 21716
n = int(input())
a = [int(input()) for _ in range(n)]
 
if a[0] != 0:
	print(-1)
else:
	ans = 0
	muri = 0
 
	for i in range(1, n):
		if a[i] > a[i-1] + 1:
			muri = 1
		elif a[i] < a[i-1] + 1:
			ans += a[i-1]
			if i == n - 1:
				ans += a[i]
		elif i == n - 1:
			ans += a[i]
 
	if muri:
		print(-1)
	else:
		print(ans)

Measured memory_bytes: 11052
#include<cstdio>
#include<cmath>
using namespace std;
int x[100005],y[100005],t[100005];
int main()
{
	int n,f=1;scanf("%d",&n);
	for(int i=1;i<=n&&f;i++)
	{
		scanf("%d%d%d",&t[i],&x[i],&y[i]);
		int s=t[i]-t[i-1]-abs(x[i]-x[i-1])-abs(y[i]-y[i-1]);
		if(s<0||s&1) f=0;
	}
	if(f) printf("Yes");else printf("No");
	return 0;
}

Measured memory_bytes: 1280
#include<stdio.h>
#include<string.h>
#define N 1001
  
int LCS_Length(char [] ,char []);
char X[N],Y[N];
int c[N][N];
int x,y;
int main(void){
  int i;
  int n;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++){
    scanf("%s %s",X,Y);
  
    printf("%d\n",LCS_Length(X,Y));
    
}
   
   
  return 0;
}
 
int LCS_Length(char X[] ,char Y[]){
  int i,j;
  x = strlen(X);
  y = strlen(Y);
   
  for(i=1;i<=x;i++){
    c[i][0] = 0;
  }
  for(j=0;j<=y;j++){
    c[0][j] = 0;
  }
   
  for(i=1;i<=x;i++){
    for(j=1;j<=y;j++){
      if(X[i-1]==Y[j-1]){
    c[i][j]=c[i-1][j-1]+1;
      }
      else if(c[i-1][j]>=c[i][j-1]){
    c[i][j]=c[i-1][j];
      }
      else{
    c[i][j]=c[i][j-1];
      }
    }
  }
  return c[x][y];
}
 

Measured memory_bytes: 4524
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

ll a, b;

ll oddsolve(ll a){ return (a+1)/2 %2; }

ll solve(ll a){
  if(a%2 == 1) return oddsolve(a);
  else return oddsolve(a+1)^(a+1);
}

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

  cin >> a >> b;
  if(a == b) {
    cout << a << endl;
    return 0;
  }

  ll ans = solve(b);
  ans^=solve(a-1);
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int i, j, k, n, ans = 0, a, b, c, tmp, now = 0;
  scanf("%d%d%d%d", &n, &a, &b, &c);
  int t[n];
  for(i = 0; i < n; ++i) scanf("%d", &t[i]);
  for(i = 0; i < n; ++i) for(j = i + 1; j < n; ++j) if(t[i] < t[j]) tmp = t[i], t[i] = t[j], t[j] = tmp;
  for(i = 0; i < n; ++i) {
    now += t[i];
    if((c + now) / (a + b * (i + 1)) > ans) ans = (c + now) / (a + b * (i + 1));
  }
  printf("%d\n", ans);
  return 0;
}


Measured memory_bytes: 2740