akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

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

template<typename T>
void cmpmax(T* reference, T value) {
	*reference = max(*reference, value);
}

template<typename T>
void cmpmin(T* reference, T value) {
	*reference = min(*reference, value);
}

const ll mod = 998244353;

static const ll INF = 1e15;


int main() {
	int n;
	cin >> n;
	vector<ll> vs(n, 0);
	rep(i, n) {
		cin >> vs[i];
	}
	vector<vector<ll>> dp(n, vector<ll>(n, 0));
	if (n % 2 == 0) {
		rep(i, n) {
			dp[i][i] = -vs[i];
		}
	}
	else {
		rep(i, n) {
			dp[i][i] = vs[i];
		}
	}
	for (int len = 1; len < n; len++) {
		for (int left = 0; left + len< n; left++) {
			int right = left + len;
			int sign = (n - len - 1) % 2 == 0 ? 1 : -1;
			ll a = dp[left][right - 1] + vs[right] * sign;
			ll b = dp[left+1][right] + vs[left] * sign;
			if (sign > 0) {
				dp[left][right] = max(a, b);
			}
			else{
				dp[left][right] = min(a, b);
			}
		}
	}
	cout << dp[0][n - 1] << endl;
	return 0;
}
	

Measured memory_bytes: 70784
import sys
s2nn = lambda s: [int(c) for c in s.split(' ')]
ss2nn = lambda ss: [int(s) for s in ss]
ss2nnn = lambda ss: [s2nn(s) for s in ss]
i2s = lambda: sys.stdin.readline().rstrip()
i2n = lambda: int(i2s())
i2nn = lambda: s2nn(i2s())
ii2ss = lambda n: [sys.stdin.readline().rstrip() for _ in range(n)]
ii2sss = lambda n: [list(sys.stdin.readline().rstrip()) for _ in range(n)]
ii2nn = lambda n: ss2nn(ii2ss(n))
ii2nnn = lambda n: ss2nnn(ii2ss(n))

import numpy as np  # 1.8.2

def main():
    N, M = i2nn()
    LR = np.array(ii2nnn(M))
    L = LR[:,0]
    R = LR[:,1]
    n = np.min(R) - np.max(L) + 1
    n = max(n, 0)
    print(n)

main()


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

using namespace std;
const int INF=1e9+5;
const int MOD=1e9+7;
typedef long long ll;

int main(){
	int a,b;
	cin>>a>>b;
	if(a>b)  cout<<"safe\n";
	else cout<<"unsafe\n";
}


Measured memory_bytes: 3592
a = input()
b = input()
l = len(a)
flag = 0
for i in range(l):
    flag2 = 1
    for j in range(l):
        if a[(j+i)%l] != b[j]:
            flag2 = 0
    flag = flag | flag2
if flag:
    print("Yes")
else:
    print("No")
    


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9+7;
typedef pair<int, int> P;

signed main(){
    string n;
    cin >> n;
    int cnt=0;
    int ma = 0;
    rep(i,n.length()) {
        if(n[i]=='R') cnt++;
        else cnt=0;
        ma = max(cnt,ma);
    }
    cout << ma << endl;
    
    return 0;
}

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


int main(){

  int a,b,c;
  cin >> a >> b >> c;
  int ans = 0;
  // ???????????°?????????
  for(int i=a;i<=b;i++){
    if(c%i==0){
      ans++;
    }
  }
  cout << ans << endl;

}

Measured memory_bytes: 1164
#define _CRT_SECURE_NO_WARNINGS
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) (c).begin(), (c).end()
#define loop(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator<<(ostream & os, vector<T> const &);
template<int n, class...T> typename enable_if<(n>=sizeof...(T))>::type _ot(ostream &, tuple<T...> const &){}
template<int n, class...T> typename enable_if<(n< sizeof...(T))>::type _ot(ostream & os, tuple<T...> const & t){ os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t); }
template<class...T> ostream & operator<<(ostream & os, tuple<T...> const & t){ _ot<0>(os, t); return os; }
template<class T, class U> ostream & operator<<(ostream & os, pair<T,U> const & p){ return os << "(" << p.first << ", " << p.second << ") "; }
template<class T> ostream & operator<<(ostream & os, vector<T> const & v){ rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os; }
#ifdef DEBUG
#define dump(...) (cerr<<#__VA_ARGS__<<" = "<<mt(__VA_ARGS__)<<" ["<<__LINE__<<"]"<<endl)
#else
#define dump(...)
#endif

int const B = 1024;
template<class T>
struct RMQ {
    int n;
    enum : T { inf = INT_MAX };
    vector<T> Bmin;
    vector<vector<T>> dat;
    RMQ(int n_){
        n = n_;
        if(n%B) n += B-n%B;
        dat.assign(n/B,vector<T>(B,inf));
        Bmin.assign(n/B,inf);
    }
    void set(int k, T x){
        get(k) = x;
        Bmin[k/B] = inf;
        rep(i,B) Bmin[k/B] = min(Bmin[k/B], get(k/B*B+i));
    }
    int & get(int k){
        return dat[k/B][k%B];
    }
    int rmq(int l, int r){
        T res = inf;
        if(l/B != r/B){
            while(l%B){
                res = min(res, get(l));
                l++;
            }
            while(r%B){
                r--;
                res = min(res, get(r));
            }
            for(int i=l/B;i<r/B;i++){
                res = min(res, Bmin[i]);
            }
        } else {
            while(l<r){
                res = min(res, get(l));
                l++;
            }
        }
        return res;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    RMQ<int> rmq(n);
    rep(i,q){
        int c, x, y;
        cin >> c >> x >> y;
        if(c) cout << rmq.rmq(x,y+1) << endl;
        else rmq.set(x,y);
    }
}

Measured memory_bytes: 1528
K,A,B = (int(x) for x in input().split())
total = 0
if(B-A<3):
    print(K+1)
    exit()
else:
    if((K-(A+1))%2 == 0):
        print(B + (K-(A+1))//2*(B-A))
    else:
        print(B + (K-(A+1))//2*(B-A) + 1)

Measured memory_bytes: 3060
s = str(input())
#s = 'bakasakab'
x = len(s)

ck = 1
for i in range(x//2):
  if not s[i] == s[x-i-1]:
    ck = 0
    break
  if not s[i] == s[(x-1)//2-i-1]:
    ck = 0
    break
  if not s[i] == s[(x+3)//2+i-1]:
    ck = 0
    break

if ck:
  print('Yes')
else:
  print('No')


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

const int dev = 1e9+7;
typedef long long ll;
typedef pair<ll, ll> tp;

const int MAX_N = 1e6;

struct UnionFind{
    int N;
    int par[MAX_N];

    UnionFind(int N): N(N){
        for (int i=0;i<N;i++){
            par[i] = i;
        }
    }

    int root(int x){
        if(par[x] == x) return x;
        int rx = root(par[x]);
        par[x] = rx;
        return rx;
    }

    void unite(int x, int y){
        int rx = root(x);
        int ry = root(y);
        if(rx==ry) return;
        par[rx] = ry;
    }

    bool find(int x, int y){
        return root(x) == root(y);
    }
};

int main(){
	ll N, M;
	cin >> N >> M;
	vector<ll> p(N);
	REP(i, N) cin >> p[i];

	UnionFind uf(N);
	REP(i, M){
		ll x, y;
		cin >> x >> y;
		x--;y--;
		uf.unite(x, y);
	}
	ll res = 0;
	REP(i, N){
		res += uf.find(i, p[i]-1);
	}
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 3072
import numpy as np
from collections import deque
h,w = map(int,input().split())
s =["#"*(w+2)] + ["#" + str(input()) + "#" for i in range(h)] + ["#"*(w+2)]
s = np.array(s)
opt = [(1,0),(0,1),(-1,0),(0,-1)]
ans = 0

for i in range(h+2):
    for j in range(w+2):
        if s[i][j] == ".":
            temp = [[0]*(w+2) for i in range(h+2)]
            temp[i][j] = 1
            dq = deque([(i,j)])
            
            while dq:
                x,y = dq.popleft()
                for k in opt:
                    x1,y1 = x+k[0],y+k[1]
                    if s[x1][y1] == "." and temp[x1][y1] == 0:
                        temp[x1][y1] = temp[x][y] + 1
                        dq.append((x1,y1))
            ans = max(ans,np.max(temp))
print(ans-1)

Measured memory_bytes: 12440
import bisect

def Get_Sieve_of_Eratosthenes(N):
    prime_list = [2]
    limit = int(N ** 0.5)
    numeric_data = [i for i in range(3, N, 2)]
    while True:
        prime = numeric_data[0]
        if prime >= limit:
            return prime_list + numeric_data
        prime_list.append(prime)
        numeric_data = [x for x in numeric_data if x % prime != 0]

def Get_2017_like_number(N, prime_list):
    ans_list = []
    for p in prime_list:
        if (p+1)//2 in prime_list:
            ans_list.append(p)
    return ans_list


def main():
    N = 10 ** 5
    prime_list = Get_Sieve_of_Eratosthenes(N)
    like_number_list = Get_2017_like_number(N, prime_list)

    # 入力
    Q = int(input())
    Query = [list(map(int, input().split())) for _ in range(Q)]
    
    for q in Query:
        l = q[0]
        r = q[1]
        print(bisect.bisect_right(like_number_list, r) - bisect.bisect_left(like_number_list, l))


if __name__ == "__main__":
    main()

Measured memory_bytes: 77404
object Main extends App {

  import scala.io.StdIn._
  import scala.math._

  val Array(n, t) = readLine.trim.split(' ').map(_.toInt)
  val func = readLine.trim.toList match {
    case Poly(p) ⇒ p
    case _ ⇒ ???
  }

  println(
    func(n).map(_ * t).filter(_ <= 1000000000L).getOrElse("TLE")
  )

  def digit(number: Long): Int = {
    number match {
      case _ if number < 10 ⇒ 0
      case _ ⇒ digit(number / 10) + 1
    }
  }
  def exponent(base: Long, exp: Int): Long = {
    exp match {
      case 0 ⇒ 1L
      case 1 ⇒ base
      case _ ⇒ exponent(base, exp / 2).let{it ⇒ it * it * exponent(base, exp % 2)}
    }
  }
  object Poly{
    def unapply(arg: List[Char]): Option[Long ⇒ Option[Long]] = {
      arg match {
        case m Mono '+'::Poly(p) ⇒ Some({n ⇒
          (m(n), p(n)) match {
            case (Some(a), Some(b)) if a + b > 1000000000 ⇒ None
            case (Some(a), Some(b)) ⇒ Some(a + b)
            case _ ⇒ None
          }
        })
        case m Mono t ⇒ Some(m)
        case _ ⇒ None
      }
    }
  }
  object Mono{
    def unapply(arg: List[Char]): Option[(Long ⇒ Option[Long], List[Char])] = {
      arg match {
        case 'n'::'^'::(e Num t) ⇒ Some({ n ⇒
          if (digit(n) * e > 9) None
          else exponent(n, e).let{it ⇒
            if (it > 1000000000) None
            else Some(it)
          }
        }, t)
        case _ ⇒ None
      }
    }
  }
  object Num{
    def unapply(arg: List[Char]): Option[(Int, List[Char])] = {
      arg match {
        case h::t if h.isDigit ⇒ Some(h.asDigit, t)
        case _ ⇒ None
      }
    }
  }
  implicit class Extension[T](val value :T){
    def also(func: T ⇒ Unit): T = {
      func(value)
      value
    }
    def let[R](func: T ⇒ R): R = func(value)
  }
}


Measured memory_bytes: 44360
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int w, h, n;
  cin >> w >> h >> n;
  int b[] = {0, w, 0, h};
  REP(i, n){
    int x, y, a;
    cin >> x >> y >> a;
    a--;
    if(a == 0) chmax(b[0], x);
    if(a == 1) chmin(b[1], x);
    if(a == 2) chmax(b[2], y);
    if(a == 3) chmin(b[3], y);
  }
  cout << max(0, b[1]-b[0])*max(0, b[3]-b[2]) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
array = list(map(int,input().split()))
for dt in array:
    if dt==array[-1]:
        print(dt)
    else:print(dt,end=" ")
for n in range(1,N):
    for m in range(n-1,-1,-1):
        if array[m]>array[m+1]:
            tmp=array[m]
            array[m]=array[m+1]
            array[m+1]=tmp
    for dt in array:
        if dt==array[-1]:
            print(dt)
        else:print(dt,end=" ")


Measured memory_bytes: 5976
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
    int n;
    while(cin >> n, n){
    int len[] = {5, 7, 5, 7, 7};
    string w[44];
    for(int i = 0; i < n; i++) cin >> w[i];
    int ans = 0;
    for(int i = 0; i < n; i++){
        int cnt = 0, idx = 0;
        for(int j = i; j < n; j++){
        cnt += w[j].size();
        if(cnt == len[idx]){
            cnt = 0, idx++;
            if(idx == 5) break;
        }else if(cnt > len[idx]){ idx = -1; break;}
        }
        if(idx == 5){ ans = i; break;}
    }
    cout << ans+1 << endl;
    }
    return 0;
}

Measured memory_bytes: 1204
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    divisors.sort(reverse=1)
    return divisors

n,m = map(int,input().split())
y = make_divisors(m)
for i in y:
  if m // i >= n:
    print(i)
    exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
#define coutd(n) cout << fixed << setprecision(n)
#define ll long long int
#define vl vector<ll>
#define vi vector<int>
const int INF = 2147483647;
const ll MOD = 1000000007;

using namespace std;

int main() {
  int h, a;
  cin >> h >> a;
  cout << (h + a - 1) / a << endl;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int H,W;
    cin >> H >> W;
    if(H == 1 || W == 1) {
        cout << 1 << endl;
        return 0;
    }
    cout << (H*W+1)/2 << endl;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define all(x) x.begin(), x.end()
typedef vector<ll> vll;
typedef vector<int> vi;
const ll N = 2e6 + 10;
const int M = 1e9 + 7;
const double eps = 1e-9;

int main() {
    int a[5];
    for (int i = 0; i < 5; ++i) {
        cin >> a[i];
    }
    for (int j = 0; j < 5; ++j) {
        if (a[j] != j + 1)
            return cout << j + 1 << endl, 0;
    }
}




Measured memory_bytes: 3512
import sys

read = sys.stdin.read
M, D = map(int, read().split())

if D < 22:
    print(0)
    exit()

answer = 0
for i in range(1, M + 1):
    for j in map(str, range(22, D + 1)):
        a = int(j[0])
        b = int(j[1])
        if a >= 2 and b >= 2:
            if a * b == i:
                answer += 1

print(answer)


Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
#include "string"
#define int long long
#define pi pair <int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl '\n'

const int N = 5e5 + 5;
const int M = 998244353;
	
int mod( int m ,int mod = M) {
   m %= mod;
   return (m + mod) % mod;
}

int power(int x, int y) {
   int res = 1;
   x = mod(x);
   while (y > 0) {
      if (y & 1)
         res =mod(res * x);
      y = y / 2;
      x = mod(x * x);
   }
   return mod(res);
}

vector < int > pw, prw;

typedef struct seg_node {
	int sum = 0;
	int lazy = -1;
}sn;

sn merge(sn a, sn b) {
	sn tmp;
	tmp.sum = mod(a.sum + b.sum);
	return tmp;
}

int n;
class lazy_segment_tree{
private:
	vector< sn > tree;
	vector< int >a;
public:
	lazy_segment_tree(vector< int > &v){
		a = v;
		n = v.size();
		tree.resize(4 * v.size());
	}

	void lazy_update(int x, int ss, int ee) {
		if(tree[x].lazy == -1)
			return;
		tree[x].sum = mod(tree[x].lazy * mod(prw[n - ss] - prw[n - ee - 1]));
		if(ss != ee) {
			tree[2 * x].lazy = tree[x].lazy;
			tree[2 * x + 1].lazy = tree[x].lazy;
		}
		tree[x].lazy = -1;
	}

	void built(int x = 1,int ss = 0,int ee = n - 1) {
		if(ss == ee) {
			tree[x].sum =  a[ss] * pw[n - ss - 1];
			return;
		}
		int m = (ss + ee) / 2;
		built(2 * x, ss, m);
		built(2 * x + 1, m + 1, ee);
		tree[x] = merge(tree[2 * x],tree[2 * x + 1]);
	}

	void update(int l, int r, int val, int x = 1, int ss = 0, int ee = n - 1) {
		lazy_update(x, ss, ee);
		if(ss > r || ee < l || l > r)
			return;
		if(ss >= l && ee <= r) {
			tree[x].lazy = val;
			lazy_update(x, ss, ee);
			return;
		}
		int m = (ss + ee) / 2;
		update(l, r, val, 2 * x, ss, m);
		update(l, r, val, 2 * x + 1, m + 1, ee);
		tree[x] = merge(tree[2 * x],tree[2 * x + 1]);
	}

	sn query(int l, int r, int x = 1, int ss = 0, int ee = n - 1) {
		lazy_update(x, ss, ee);
		if(ss > r || ee < l || l > r)
			return tree[0];
		if(ss >= l && ee <= r)
			return tree[x];
		int m = (ss + ee) / 2;
		sn p= query(l, r, 2 * x, ss, m);
		sn q = query(l, r, 2 * x + 1, m + 1, ee);
		sn ans = merge(p, q);
		return ans;
	}
};

int32_t main() {
	boost;
	int q;
	cin >>  n >> q;
	
	pw.resize(n + 1, 0);
	pw[0] = 1;
	for(int i = 1; i  <= n; i++)
		pw[i] = mod(pw[i - 1] * 10);
	prw.resize(n + 2, 0);
	for(int i = 1; i <= n; i++)
		prw[i] = mod(prw[i - 1] + pw[i - 1]);

	vector < int > a(n, 1);

	lazy_segment_tree lst(a);
	lst.built();
	while(q--) {
		int l, r, d;
		cin >> l >> r >>d;
		lst.update(l - 1, r - 1, d);
		cout << lst.query(0, n - 1).sum << endl;
	}
}

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

using lld = long long int;

int32_t main() {
  lld a, b, b1, b2;
  scanf("%lld%lld.%lld", &a, &b1, &b2);

  b = b1 * 100LL + b2;
  printf("%lld\n", a * b / 100LL);

  return 0;
}


Measured memory_bytes: 3828
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N, T;
	List<Pair> dishes;
	Pair last;
	long maxScore = 0L;

	static class Pair {
		int A, B;

		Pair(String line) {
			String[] tokens = line.split(" ");
			this.A = Integer.parseInt(tokens[0]);
			this.B = Integer.parseInt(tokens[1]);
		}
	}

	long[][] dp;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		this.N = Integer.parseInt(tokens[0]);
		this.T = Integer.parseInt(tokens[1]);
		this.dishes = new ArrayList<>(N);
		for (int i = 0; i < N; ++i) {
			this.dishes.add(new Pair(in.readLine()));
		}
		// 食べる時間が早い順でソートしておく
		// 最終的にDPで組み合わせを計算することから，最後に残るものは完食までの時間が長いものになる．
		Collections.sort(this.dishes, new Comparator<Pair>() {
			@Override
			public int compare(Pair o1, Pair o2) {
				return Integer.compare(o1.A, o2.A);
			}
		});
		calc();
	}

	void calc() {
		// dp[i][j]: 0-i番目の料理でj分いないに完食できるおいしさの合計の最大値
		// T + Amaxの枠をとる
		int tMax = T + this.dishes.get(this.dishes.size() - 1).A;
		// 皿をAの昇順で食べた時の完食時間を計算しておく
		long[] thresholds = new long[N];
		long[] sums = new long[N];
		thresholds[0] = this.dishes.get(0).A;
		sums[0] = this.dishes.get(0).B;
		for (int i = 1; i < N; ++i) {
			thresholds[i] = thresholds[i - 1] + this.dishes.get(i).A;
			sums[i] = sums[i - 1] + this.dishes.get(i).B;
		}

		this.dp = new long[N][tMax + 1];
		// 0分ではどの料理も完食できないので0とする
		for (int i = 0; i < N; ++i) {
			this.dp[i][0] = 0L;
		}
		// 1つ目の料理だけを食べる場合の初期値を設定する
		Arrays.fill(this.dp[0], 0L);
		// dishes[0].A以上なら完食できる
		for(int i = this.dishes.get(0).A; i <= tMax; ++i) {
			this.dp[0][i] = (long)this.dishes.get(0).B;
		}
		for (int i = 1; i < N; ++i) {
			Pair dish = this.dishes.get(i);
			for (int j = 1; j <= tMax; ++j) {
				if (j > thresholds[i]) {
					// 全部食べられた
					this.dp[i][j] = sums[i];
				} else if (j < T) {
					int time = j - dish.A;
					if (time < 0) {
						// この皿を加える余地はない
						this.dp[i][j] = Math.max(this.dp[i - 1][j], this.dp[i][j - 1]);
					} else {
						// この皿を加えない場合と比べる
						this.dp[i][j] = Math.max(Math.max(this.dp[i - 1][j], this.dp[i][j - 1]),
								this.dp[i - 1][time] + dish.B);
					}
				} else {
					// j >= T
					int time = j - dish.A;
					if (time < 0) {
						// この皿を加える余地はない
						this.dp[i][j] = this.dp[i - 1][j];
					} else {
						// 最後の皿を食べる場合としか比べられない
						this.dp[i][j] = Math.max(this.dp[i][j - 1], this.dp[i - 1][time] + dish.B);
					}
				}
			}
		}
		// T + A[i]の値を見て，最大のものが解
		long max = 0L;
		for (int i = 0; i < N; ++i) {
			int time = T + this.dishes.get(i).A - 1;
			max = Math.max(max, this.dp[i][time]);
		}
		this.maxScore = max;
	}

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		System.out.println(ins.maxScore);
	}

}


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

using namespace std;

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

    int n;
    cin >> n;
    vector<int> as(n + 1);
    for (int i = 1; i <= n; i++) cin >> as[i];
    vector<int> ans(n + 1);
    for (int i = n; i >= 1; i--) {
        int cnt = 0;
        for (int j = 2; i * j <= n; j++) {
            if (ans[i * j]) cnt++;
        }
        ans[i] = cnt % 2 != as[i];
    }
    vector<int> out;
    for (int i = 1; i <= n; i++) {
        if (ans[i]) {
            out.push_back(i);
        }
    }
    bool ok = true;
    for (int i = 1; i <= n; i++) {
        int cnt = 0;
        for (int j = 1; i * j <= n; j++) {
            if (ans[i * j]) cnt++;
        }
        if (cnt % 2 != as[i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << out.size() << endl;
    for (int a : out) {
        cout << a << ' ';
    }
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>

using namespace std;

int main(void){
    string n;
    int count = 0;

    cin >> n;

    for(int i=0; i < n.length(); i++){
        if(n[i] == '2'){
            count++;
        }
    }

    cout << count << endl;

    return 0;
}

Measured memory_bytes: 764
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <cstring>
#include <numeric>
#include <algorithm>
#include <fstream>
#include <functional>
#include <array>
#include <map>
#include <queue>
#include <time.h>
#include <limits.h>
#include <set>
#include <stack>
#include <random>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#define rep(i,s,n) for(int i = (s); (n) > i; i++)
#define REP(i,n) rep(i,0,n)
#define RANGE(x,a,b) (min(a,b) <= (x) && (x) <= max(a,b)) //hei
#define DUPLE(a,b,c,d) (RANGE(a,c,d) || RANGE(b,c,d) || RANGE(c,a,b) || RANGE(d,a,b))
#define INCLU(a,b,c,d) (RANGE(a,c,d) && (b,c,d))
#define PW(x) ((x)*(x))
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MODU 1000000007LL
#define bitcheck(a,b)   ((a >> b) & 1)
#define bitset(a,b)      ( a |= (1 << b))
#define bitunset(a,b)    (a &= ~(1 << b))
#define MP(a,b) make_pair((a),(b))
#define Manh(a,b) (abs((a).first-(b).first) + abs((a).second - ((b).second))
#define pritnf printf
#define scnaf scanf
#define itn int
#define PI 3.141592653589


#define izryt bool
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
pll Dir[4] = {
	{ -1 ,0 },{ 0 , 1 },{ 1 ,0 },{ 0 ,-1 }
};

//[a, b)
#define Getsum(ar, a,b) (ar[b] - ar[a])
#define chmax(a,b) a = max(a,b)
#define chmin(a,b) a = min(a,b)

struct Edge {
	int from, to;
	ll w;
	bool operator<(const Edge& rhs) const {
		return MP(w, MP(from, to)) < MP(rhs.w, MP(rhs.from, rhs.to));
	}

};
typedef vector<vector<Edge>> Graph;

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

ll factorial(ll n) {//階乗
	ll ret = 1;
	rep(i, 1, n + 1)
		ret = (ret *i) % MODU;

	return ret;
}

ll mod_pow(ll x, ll n, ll mod) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x %mod;
		x = x * x%mod;
		n >>= 1;
	}
	return res;
}
ll divmod(ll a, ll b, ll m) { // a/b(mod m)
								  // a/b (mod m)
								  // a*b^-1
								  // b^-1 * b = 1
								  // b^(m-1) = 1 
								  // b^(m-2) * b = 1
								  // b^-1 = b^(m-2)

								  // a/b = a * b^(m-2)

	return (a * 1LL * mod_pow(b, m - 2, m)) % m;
}
ll ncr(ll n, ll r) {
	return divmod(factorial(n), (factorial(r) * (factorial(n - r))) % MODU, MODU);
}


signed main() {
	int n, u, v;
	cin >> n >> u >> v;
	u--, v--;
	Graph g(n);
	REP(i, n - 1) {
		int a, b;
		cin >> a >> b;
		a--, b--;
		g[a].push_back({ a,b });
		g[b].push_back({ b,a });
	}

	vector<int> depth(n), Maxd(n), par(n);

	function<int(int, int)> dfs = [&](int c, int p) {
		par[c] = p;
		depth[c] = depth[p] + 1;
		int Max = depth[c];
		for (auto itr : g[c]) {
			if (itr.to != p)
				Max = max(Max, dfs(itr.to, c));
		}
		return Maxd[c] = Max;
	};

	depth[v] = -2;
	dfs(v, v);

	int cur = u, dist = 0, ans = 0;
	while (1) {
		if (depth[cur] < dist) {
			break;
		}
		ans = Maxd[cur];
		dist++;
		cur = par[cur];
	}

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


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

int main(){
    string in;
    cin >> in;
    unsigned long long total = 0;
    char temp;
    stringstream ss(in);
    while(ss >> temp){
        total += temp - 48;
    }
    if(total % 9 == 0) cout << "Yes" << endl;
    else{cout << "No" << endl;}

}

Measured memory_bytes: 3864
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>
#include<set>

using namespace std;

#define int long long
#define endl "\n"

constexpr long long INF = (long long)1e18;
constexpr long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int n;
	set<int> s;
	
	cin>>n;
	
	for(int i = 0; i< n; i++){
		int a;
		
		cin>>a;
		
		s.insert(a);
	}
	
	
	cout<<s.size()<<endl;
	
	
	return 0;
}


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

int main() {
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  rep(i,n) {
    if (s[i] == 'A') {
      if (s[i+1] == 'B' && s[i+2] == 'C') {
        ans++;
        i += 2;
      }
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<pi, pi> pp;
typedef pair<ll, ll> pl;
const double EPS = 1e-9;
const ll MOD = 1000000007;
const int inf = 1 << 30;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;

int n;
int a[200000], b[200000];

int main() {
    cin >> n;
    rep(i,n) cin >> a[i];
    rep(i,n) b[i] = a[i];
    sort(b, b+n, greater<int>());
    rep(i,n) {
        if (a[i] == b[0]) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}


Measured memory_bytes: 3200
package main
import (
  "bufio"
  "os"
  "strconv"
  "strings"
  "fmt"
)

func Factorial(p int) (F, Finv, Inv []int) {
  F = make([]int, p + 1)
  Finv = make([]int, p + 1)
  Inv = make([]int, p + 1)
  F[0] = 1
  F[1] = 1
  Finv[0] = 1
  Finv[1] = 1
  Inv[0] = 1
  Inv[1] = 1
  for i := 2; i < p + 1; i++ {
    F[i] = F[i - 1] * i % p
    Inv[i] = p - Inv[p % i] * (p / i) % p
    Finv[i] = Finv[i - 1] * Inv[i] % p
  }
  return
}

func Comb(F, Finv *[]int, p int, A ...int) int {
  S := SumInt(A...)
  C := (*F)[S]
  for _, a := range A {
    C *= (*Finv)[a]
    C %= p
  }
  return C
}

func Solve() {
  var p int
  var A []int
  NextInt(&p)
  NextIntVec(&A)
  F, Finv, _ := Factorial(p)
  B := make([]int, p)
  for i := range B { B[i] = Comb(&F, &Finv, p, i, p - 1 - i) }
  C := make([][]int, p)
  for i := range C {
    C[i] = make([]int, p)
    C[i][0]++
    for j := range C[i][1:] { C[i][j + 1] = C[i][j] * (p - i) % p }
  }
  D := make([]int, p)
  for i, a := range A {
    for j := range D { D[j] = (D[j] - C[i][p - 1 - j] * B[j] * a % p + p) % p }
    D[0] = (D[0] + a) % p
  }
  WriteIntVec(D)
}

func main() {
  Solve()
  Output()
}

var reader = bufio.NewReaderSize(os.Stdin, 1000000)
var writer = bufio.NewWriter(os.Stdout)
func NextLine() string {
  buffer := make([]byte, 0)
  for true {
    line, isPrefix, err := reader.ReadLine()
    if err != nil { panic(err) }
    buffer = append(buffer, line...)
    if !isPrefix { break }
  }
  return string(buffer)
}
func NextInt(A ...*int) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.Atoi(L[i])
  }
}
func NextIntVec(A *[]int) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]int, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.Atoi(l)
  }
}
func NextFloat(A ...*float64) {
  L := strings.Split(NextLine(), " ")
  for i, a := range A {
    *a, _ = strconv.ParseFloat(L[i], 64)
  }
}
func NextFloatVec(A *[]float64) {
  L := strings.Split(NextLine(), " ")
  (*A) = make([]float64, len(L))
  for i, l := range L {
    (*A)[i], _ = strconv.ParseFloat(l, 64)
  }
}
func Write(s interface{}) {
  fmt.Fprintln(writer, s)
}
func WriteIntVec(A []int) {
  S := make([]string, len(A))
  for i, a := range A {
    S[i] = strconv.Itoa(a)
  }
  Write(strings.Join(S, " "))
}
func Output() {
  _ = writer.Flush()
}
func MaxInt(A ...int) int {
  max := A[0]
  for _, a := range A {
    if max < a { max = a }
  }
  return max
}
func MinInt(A ...int) int {
  min := A[0]
  for _, a := range A {
    if a < min { min = a }
  }
  return min
}
func SumInt(A ...int) int {
  sum := 0
  for _, a := range A {
    sum += a
  }
  return sum
}
func AbsInt(x int) int {
  if x < 0 { x = -x }
  return x
}

Measured memory_bytes: 75648
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
#include <queue>
#include <math.h>
using namespace std;
#define lol long long

int main()
{
	int n;
	cin >> n;
	vector<int> p(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	int count = 0;
	for (int i = 0; i < n - 2; i++) {
		if ((p[i] < p[i + 1] && p[i + 1] < p[i + 2]) || (p[i] > p[i + 1] && p[i + 1] > p[i + 2])) {
			count++;
		}
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<tuple>
#include<map>
#include<queue>
#include<math.h>
#include<iomanip>
#define rep(i, n) rep2(i,0,n)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define PI acos(-1);
typedef long long ll;
using namespace std;
#define MOD 1000000007
//scanf("%d", &a) '\n'

int main() {
	int x, y;
	cin >> x >> y;
	int ans = 0;
	if (x <= 3) ans += 400000-x * 100000;
	if (y <= 3) ans += 400000-y * 100000;
	if (ans == 600000) ans += 400000;
	cout << ans << endl;
}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD (int) 1e9+7
#define fio ios_base::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define vi vector<int>
int main()
{

#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif
	fio;
	int n, k;
	cin >> n >> k;
	vector<vector<int>> A(k);
	vector<bool> v(n + 1, false);
	for (int i = 0; i < k; i++)
	{
		int d;
		cin >> d;
		for (int j = 0; j < d; j++)
		{
			int x;
			cin >> x;
			v[x] = true;
		}
	}
	int count = 0;
	for (int i = 1; i <= n; i++)
	{
		if (v[i] == false)
			count++;
	}
	cout << count;
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
using lint = long long int;
long long int INF = 1001001001001001LL;
int inf = 1000000007;
long long int MOD = 1000000007LL;
double PI = 3.1415926535897932;

template<typename T1,typename T2>inline void chmin(T1 &a,const T2 &b){if(a>b) a=b;}
template<typename T1,typename T2>inline void chmax(T1 &a,const T2 &b){if(a<b) a=b;}

#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()

/* do your best */
int main() {
  
  lint n, k; cin >> n >> k;
  vector<lint> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    a[i]--;
  }

  // ダブリング前処理
  vector<vector<int>> doubling(62, vector<int> (n));

  for (int j = 0; j < n; j++) {
    doubling[0][j] = a[j];
  }

  for (lint i = 1; i < 62; i++) {
    // 2^i 個先は，2^{i - 1} 個先を二回
    for (int j = 0; j < n; j++) {
      doubling[i][j] = doubling[i - 1][doubling[i - 1][j]];
    }
  }

  int cur = 0;
  for (lint i = 0; i < 62; i++) {
    if(k & (1LL << i)) {
      cur = doubling[i][cur];
    }
  }
  cout << cur + 1 << endl;
  return 0;
}



Measured memory_bytes: 54184
#include"bits/stdc++.h"
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep3(i,m,n) for(int (i)=m;(i)<=(n);(i)++)
#define rep3rev(i,m,n) for(int (i)=m;(i)>=(n);(i)--)
#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define eb emplace_back

using ll = long long;
using vll = vector<ll>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using P = pair<int, int>;
using Pl = pair<ll, int>;

void Main() {
	int a, b, h, m;
	cin >> a >> b >> h >> m;
    long double theta1 = (60*h + m) / 2.0;
    long double theta2 = 6.0 * m;
    long double theta = abs(theta1 - theta2);
    if(theta > 180) theta = 360 - theta;
    
    long double c = cosl(theta / 180 * acos(-1));
    long double ans = a*a + b*b - 2*a*b*c;
    
    //cout << theta << endl;
    //cout << cos(theta * PI / 180) << endl;
    ans = sqrtl(ans);
    cout << ans << endl;
    return;
}

int main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	Main();
	return 0;
}

Measured memory_bytes: 4172
using System;

public class Program {
  public static void Main(string[] args) {
    var str = Console.ReadLine().Split(' ');
    var a = int.Parse(str[0]);
    var b = int.Parse(str[1]);
    if (b % a  == 0) {
      Console.WriteLine(a + b);
    } else {
      Console.WriteLine(b - a);
    }
  }
}

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

int main() {
  string S;
  cin >> S;
  int A = 0;
  for(int i = 0;i < 4;i++) {

  if(S[i] == '+'){
      A++;
  }
    
    else{
      A--;
  }
}
  cout << A << endl;
}


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

typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef vector< vector< vector<ll> > > vvvint;
typedef vector<string> vstring;
typedef vector< vector<string> > vvstring;
typedef vector<char> vchar;
typedef vector< vector<char> > vvchar;
typedef vector<long double> vdouble;
typedef vector< vector<long double> > vvdouble;
typedef vector< vector< vector<long double> > > vvvdouble;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;
typedef vector<bool> vbool;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define ALL(obj) (obj).begin(), (obj).end()
// #define LLONG_MAX 9223372036854775806
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())
#define MOD 1000000007
// #define MOD 998244353
// #define MOD LLONG_MAX
const double PI=3.14159265358979323846;
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 (b<a) { a=b; return 1; } return 0; }

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

void printv(vint &v){
    for(auto e:v) cout<<e<<" ";
        cout<<endl;
    }

// 繰り返し二乗法
ll power(ll a, ll b){
    if(a==1)return a;
    // if(a==0)re
    ll res=1;
    while(b>0){
        if(b&1) res=res*a%MOD;
        a=a*a%MOD;
        b>>=1;
    }
    return res;
}

const int MAX=2100000;

ll fact[MAX], fact_inv[MAX];

void init_fact(ll n){
    fact[0]=1;
    // 階乗の計算
    for(ll i=0; i<n; i++) fact[i+1]=fact[i]*(i+1)%MOD;
    fact_inv[n]=power(fact[n], MOD-2);
    // 逆元の計算
    for(ll i=n-1;i>=0;i--) fact_inv[i]=fact_inv[i+1]*(i+1)%MOD;
}

ll comb(ll n, ll r){
    return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

ll perm(ll n, ll r){
    return (fact[n]*fact_inv[n-r])%MOD;
}

int main() {
    cout<<fixed<<setprecision(10);

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

    bool ok = true;

    for(auto e:a){
        if(e%2==0 && (e%3 != 0 && e%5 != 0)){
            ok = false;
            break;
        }
    }

    if(ok) puts("APPROVED");
    else puts("DENIED");

    return 0;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<map>
#include<math.h>
#include<string>
#include <cctype>
#include <cstdlib>
#include<bitset>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl;
#define INF 1ll<<60;
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; }

using namespace std;
using ll = long long;
typedef pair<int, int> P;

int main(){
    int n, d; cin >> n >> d;
    int x[n][d];
    rep(i, n){
        rep(j, d){
            cin >> x[i][j];
        }
    }

    int ans=0;

    rep(i, n){
        reps(j, i+1, n){
            int dist = 0;
            rep(k, d){
                int diff = abs(x[i][k]-x[j][k]);
                dist += diff*diff;
            }

            int q,k = 1;
            while(dist>=k){
                if(dist==k*k){
                    ans++;
                }
                k++;
            }
        }
    }

    out(ans);
}

Measured memory_bytes: 3576
<?php
$num = trim(fgets(STDIN));
if ($num <= 599) {
  echo 8;
} elseif ($num <= 799) {
  echo 7;
} elseif ($num <= 999) {
  echo 6;
} elseif ($num <= 1199) {
  echo 5;
} elseif ($num <= 1399) {
  echo 4;
} elseif ($num <= 1599) {
  echo 3;
} elseif ($num <= 1799) {
  echo 2;
} else {
  echo 1;
}

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

using namespace std;

template <typename T>std::string NumberToString ( T Number ){std::ostringstream ss; ss << Number;return ss.str(); } // Usages NumberToString(3)
template <typename T>T StringToNumber ( const string &Text ){istringstream ss(Text);T result;return ss >> result ? result : 0;} // StringToNumber<int>("3")

int main(){

   ios::sync_with_stdio(0);
   cin.tie(0);

   int a,b,c,d;
   cin >> a >> b >> c >> d;

   while(true){

      c = c - b;
      if ( c <= 0) {
         cout << "Yes" << endl;
         break;
      }

      a = a - d;
      if(a <= 0){
         cout << "No" << endl;
         break;
      }


   }


   return 0;
}

Measured memory_bytes: 3612
# include <bits/stdc++.h>
# define rr register
const int N=100010,INF=0x3f3f3f3f;
int cnt[10];
inline int read(void){
	int res,f=1;
	char c;
	while((c=getchar())<'0'||c>'9')
		if(c=='-')f=-1;
	res=c-48;
	while((c=getchar())>='0'&&c<='9')
		res=res*10+c-48;
	return res*f;
}
int main(void){
	++cnt[read()],++cnt[read()],++cnt[read()];
	for(rr int i=1;i<=9;++i){
		if(cnt[i]==2){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;

#define ll long long
#define int ll

int ans;
int a, b;

signed main()
{
	cin >> a >> b;
	if ((b / a)*a == b) {
		cout << a + b << endl;
	}
	else {
		cout << b - a << endl;
	}

	//system("pause");
    return 0;
}



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

#define REP(i,n) for(int i=0;i<(n);i++)
#define REAP(i,a,n) for(int i=(a);i<(n);i++)
#define YES cout<<"Yes"<<endl
#define NO cout<<"No"<<endl
#define fr first
#define sc second
#define pb push_back
#define All(v) v.begin(),v.end()
typedef long long ll;

int main(){
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    cout << (n>=1000?"ABD":"ABC") << endl;
}


Measured memory_bytes: 256
from sys import stdin

inf = 10**3
n,m = [int(x) for x in stdin.readline().rstrip().split()]

li = [list(map(int,stdin.readline().rstrip().split())) for _ in range(m)]
nu = []

def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    #k：中継
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
point = 0
for i in range(m):
    d = [[inf for i in range(n)]for j in range(n)]
    lin = li[:i]+li[i+1:]
    for j in range(m-1):
        d[lin[j][0]-1][lin[j][1]-1] = 1
        d[lin[j][1]-1][lin[j][0]-1] = 1
    for k in range(n):
        d[k][k] = 0
    lis = warshall_floyd(d)
    for i in lis:
        if inf in i:
            point += 1
            break
print(point)

Measured memory_bytes: 43888
# -*- coding: utf-8 -*-

import sys

debug = False

def log(text):
    if debug:
        print(text)

def parse_input(lines_as_string = None):

    global debug
    lines = []
    if lines_as_string is None:
        debug = False
        lines.append(input())
    else:
        debug = True
        lines = [e for e in lines_as_string.split("\n")][1:-1]


    token = lines[0].split()
    a = int(token[0])
    b = int(token[1])

    return (a, b)


def solve(a, b):

    result = b
    if 13 <= a:
        result = b
    elif 6 <= a and a <= 12:
        result = int(b/2)
    else:
        result = 0
        
    return result




def main():
    # 出力

    print("%s" % solve(*parse_input()))

if __name__ == '__main__':

    main()
	

Measured memory_bytes: 3064
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let X: i64 = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    };

    let ans = if ((X / 105)..(X / 100 + 1)).any(|i| {
        let r = X - 100 * i;
        0 <= r && r <= 5 * i
    }) {
        1
    } else {
        0
    };

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


Measured memory_bytes: 4352
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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

ll n;

ll dfs(string s,int a,int b,int c){
    
    if(stol(s) > n)ret 0;
    int r = 0;
    if(a == 1 && b == 1 && c == 1)r ++;

    r += dfs(s+"3",1,b,c);
    r += dfs(s+"5",a,1,c);
    r += dfs(s+"7",a,b,1);
    
    ret r;
}
int main(){

    cin >> n;
    
    P(dfs("0",0,0,0));
    return  0;
}


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

const int MOD=1000000007;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;


int main() {
  ll n; cin>>n;
  ll k; cin>>k;
  vector<ll>a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  rep(i,n){
    ll cnt1=0,cnt2=0;
    rep(j,i){
      if(a[j]>a[i]) cnt1++;
    }
    rep(j,n){
      if(a[j]>a[i]) cnt2++;
    }
    ans+=cnt1*k+(cnt2%MOD)*((k*(k-1)/2)%MOD);
    ans%=MOD;
  }
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <regex>
#include "bits/stdc++.h"
#define FOR(i, s, e) for (int i = int(s); i < int(e); ++i)
#define REP(i, e) FOR(i, 0, e)
#define INF (INT_MAX / 2)
#define LINF (LLONG_MAX / 2)
#define EPS (1.0e-8)
const int MGN = 10;
const int ARY_SZ_MAX = (int)1e7;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>;
using vc = vector<char>; using vvc = vector<vc>;
using vb = vector<bool>; using vvb = vector<vb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>; using psl = pair<string, ll>;


ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
    ll g = gcd(a, b);
    return a / g * b;
}

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


  ll N,M; cin>>N>>M;
  vl A(N); REP(i,N) cin>>A[i];

  REP(i,N) A[i] /= 2;

  vi div(N,0);
  REP(i,N) {
    int t = A[i];
    while(t%2==0) {
      t/=2;
      div[i]++;
    }
  }
  FOR(i,1,N) {
    if (div[0] != div[i]) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll lm = A[0];
  FOR(i,1,N) lm = lcm(lm, A[i]);

  if (lm>M) {
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = ((M/lm)+1)/2;
  cout << ans << endl;


  return 0;
}

Measured memory_bytes: 1408
n, h = gets.chomp.split.map(&:to_i)
cut, throw = [], []
n.times { |i| cut[i], throw[i] = gets.chomp.split.map(&:to_i) }

max_c = cut.max
throw = throw.select { |x| x > max_c }
             .sort_by { |x| -x }

answer = 0
throw.each do |attack|
  h -= attack
  answer += 1
  if h <= 0
    puts answer
    exit
  end
end

puts (h / max_c.to_f).ceil + answer

Measured memory_bytes: 7404