akhauriyash/Code-Regression huggingface dataset:
use std::io;
use std::collections::HashMap;

const MOD: usize = (1e9 as usize) + 7;

fn main() {
    let (n, m) = {
        let i = read::<usize>();
        (i[0], i[1])
    };

    let mut ans: usize = 1;
    let modulo = Modulo::new(1_000_000, MOD);
    let pf = prime_factor(m);
    // println!("{:?}", pf);
    for v in pf.values() {
        // n H r = m C r, where m = n + r - 1
        ans *= modulo.comb(n + v - 1, *v);
        ans %= MOD;
    }
    println!("{}", ans);
}

pub struct Modulo {
    fact: Vec<usize>,
    inv_fact: Vec<usize>,
    modulo: usize
}

impl Modulo {
    pub fn new(n: usize, modulo: usize) -> Self {
        let mut fact = vec![0; n + 1];
        let mut inv = vec![0; n + 1];
        let mut inv_fact = vec![0; n + 1];
        inv[1] = 1;
        for i in 2..n + 1 {
            inv[i] = inv[modulo % i] * (modulo - modulo / i) % modulo;
        }
        fact[0] = 1;
        inv_fact[0] = 1;
        for i in 0..n {
            fact[i + 1] = fact[i] * (i + 1) % modulo;
        }
        for i in 0..n {
            inv_fact[i + 1] = inv_fact[i] * inv[i + 1] % modulo;
        }
        Modulo { fact: fact, inv_fact: inv_fact, modulo: modulo }
    }

    pub fn comb(&self, n: usize, r: usize) -> usize {
        self.fact[n] * self.inv_fact[r] %
            self.modulo * self.inv_fact[n - r] % self.modulo
    }
}

fn divide(n: usize) -> Option<usize> {
    for i in 2..(n as f64).sqrt().ceil() as usize + 1 {
        if n % i == 0 { return Some(i); }
    }
    None
}

pub fn prime_factor(n: usize) -> HashMap<usize, usize> {
    let mut x = n;
    let mut hm = HashMap::new();
    while let Some(f) = divide(x) {
        x /= f;
        *hm.entry(f).or_insert(0) += 1;
    }
    if x != 1 {
        *hm.entry(x).or_insert(0) += 1;
    }
    hm
}

#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

ll dp[100000*100+7];
ll weight[107], value[107];

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

    int n,w;
    cin>>n>>w;

    /// dp[i]-> maximum total value by taking items with sum of wights exactly i

    for( int i=0;i<n;i++ )
        cin>>weight[i]>>value[i];

    for( int i=0;i<n;i++ )
        for( int weight_already=w-weight[i];weight_already>=0;weight_already-- )
            dp[ weight_already+weight[i] ]= max( dp[ weight_already+weight[i] ], dp[ weight_already ]+value[i] );

    ll ans= 0;

    for( int i=0;i<=w;i++ )
        ans= max( ans, dp[i] );

    cout<< ans <<endl;
}


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

int main() {
  ll k;
  cin >> k;
  // 偶数NG
  // 下一桁 = 1,3,7,9 のみ (1*7, 3*) ?
  ll ans = 1;
  ll sum = 7;
  ll ten = 1;
  if (k % 10 == 1 || k % 10 == 3 || k % 10 == 7 || k % 10 == 9) {
    while (sum % k != 0) {
      ans++;
      ten = ten * 10 % k;
      sum += 7 * ten % k;
    }
  } else {
    ans = -1;
  }

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


Measured memory_bytes: 3632
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int count = 0;
        char scope = S.charAt(0);
        for(int i = 1; i < S.length(); i++){
            if(scope != S.charAt(i)){
                count++;
                scope = S.charAt(i);
            }
        }
        System.out.print(count);
    }
}

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


int main(){   
    string s,t;
    cin >> s >> t;
    int cnt = 0;
    for(int i=0;i<s.size(); i++){
        if(s[i] != t[i]){
            cnt++;
        }
    }
    cout << cnt << endl;
}


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit(b) (1ll << (b))
#define uniq(v) (v).erase(unique(all(v)), (v).end())
#define rsort(v) sort(all(v)); reverse(all(v))

using namespace std;

using i32 = int;
using i64 = long long;
using f80 = long double;
using vi32 = vector<i32>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << '\n'; exit(0); }
inline void no() { cout << "No" << '\n'; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { return a / gcd(a, b) * b; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }
template<typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template<typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template<typename T> inline void amax(T &x, T y) { if (x >= y) x = y; }
template<typename T> inline void amin(T &x, T y) { if (x <= y) x = y; }
template<typename T> inline T power(T x, i64 n) { T r = 1; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template<typename T> istream& operator>>(istream &is, vector<T> &v) { for (auto &x : v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }

void solve() {
  int n, m;
  cin >> n >> m;
  vector<bool> f(n);
  vi32 cnt(n, 1);
  f[0] = true;
  rep(i, m) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cnt[x]--, cnt[y]++;
    if (f[x]) f[y] = true;
    if (cnt[x] == 0) f[x] = false;
  }
  int ans = 0;
  rep(i, n) if (f[i]) ans++;
  cout << ans << '\n';
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cassert>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define INF (ll)1e18
#define MOD (ll)1e9 + 7
#define pb push_back

typedef long long ll;
typedef long long int llt;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

char dif = 'A' - 'a';

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m, c;
    cin >> n >> m >> c;
    int b[21];
    rep(i, m) cin >> b[i];
    int cnt = 0;
    rep(i,n){
        int a[21];
        int sum = 0;
        rep(j,m){
            cin >> a[j];
            sum += a[j] * b[j];
        }
        if(sum+c>0)
            cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
    ll n;
    std::cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }

    map<ll,ll> m;
    ll ans = 0;

    for (int i = 0; i < n; i++) {
        ans += m[i+1-a[i]];
        m[i+1+a[i]]++;
    }

    std::cout << ans << std::endl;
}


Measured memory_bytes: 27456
N, K = map(int, input().split())
D = set(input().split())
frag = True
ans = 0
N = N-1
for i in range(0, 1000000):
    N += 1
    if len(set(str(N)) & D) == 0:
        ans = N
        frag = False
        break
print(N)
        

Measured memory_bytes: 3060
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>

using namespace std;

typedef long long LL;

#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define rep(i,n) for (int i = 0; i < (n); ++i)

const int MOD = 1000000007;

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

    int N;
    cin >> N;

    int ans = 0;
    for (int i = 0; i*4 <= N; ++i) {
        if ((N-i*4)%7 == 0) {
            ++ans;
        }
    }

    cout << (ans ? "Yes" : "No") << endl;

    return 0;
}


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

template <typename T>
using Matrix = vector<vector<T>>;

template <typename T>
Matrix<T> matrix(int R, int C, T x = T()) { return Matrix<T>(R, vector<T>(C, x)); }

struct SparseTable
{
    int K;
    Matrix<int> jump;

    SparseTable(int N, int L, vector<int> locations)
    {
        K = 0; while (1<<K < N) K++;

        jump = matrix<int>(K+1, N);
        for (auto i = 0, j = 0; i < N; i++)
        {
            while (j+1 < N && locations[j+1]-locations[i] <= L) j++;
            jump[0][i] = j;
        }

        for (auto k = 1; k <= K; k++) for (auto i = 0; i < N; i++)
            jump[k][i] = jump[k-1][jump[k-1][i]];
    }

    int query(int i, int j)
    {
        auto days = 0;
        for (auto k = K; k >= 0; k--) if (jump[k][i] < j)
        {
            i = jump[k][i];
            days += 1<<k;
        }
        return days+1;
    }
};

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

    auto locations = vector<int>(N);
    for (auto& x : locations) cin >> x;

    int L; cin >> L;

    auto table = SparseTable(N, L, locations);

    int Q; cin >> Q;
    for (auto i = 0; i < Q; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        if (a > b) swap(a, b);

        cout << table.query(a, b) << endl;
    }
}


Measured memory_bytes: 8448
import math


n = int(input())
x_list = list(map(int, input().split()))


mi_stamina = 1000000000
for i in range(-1000, 1000):
    def _distance(x):
        return (x-i)**2
    double_list = list(map(_distance, x_list))
    stamina = sum(double_list)
    if mi_stamina > stamina:
        mi_stamina = stamina

print(mi_stamina)

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

using namespace std;
#define mp make_pair
#define pb push_back
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[100005], ord[100005];

inline bool cmp(const int &lhs, const int &rhs) {
    return a[lhs] < a[rhs];
}

int main() {
    scanf("%d", &n);
    forn(i, n) scanf("%d", a + i);
    forn(i, n) ord[i] = i;
    sort(ord, ord + n, cmp);
    int cnt = 0;
    forn(i, n) if (ord[i] % 2 != i % 2) {
        ++cnt;
    }
    cout << cnt / 2 << endl;
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int > pp;
typedef long long ll;
 
#define sz(x) (int)x.size() 
int const N=3e5+10,oo=1e9;
ll const OO=2e18;
double const eps=1e-8,PI=acos(-1);
int mod=oo+7;

int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  char c;
  cin>>c;
  if(c=='A')cout<<"T";
  else if(c=='T')cout<<"A";
  else if(c=='G')cout<<"C";
  else cout<<"G";
  return 0;
}


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

#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
#define rep2(i,s,n) for(long long i=(s); i<(long long)(n);i++)
#define mod 1000000007
typedef long long ll;

int main() {
    int k,x;cin>>k>>x;

    rep2(i,x-k+1,x+k){
        cout<<i<<endl;
    }
}


Measured memory_bytes: 256
fun main() {
    val mod = 1000000007L.toBigInteger()
    readLine()
    val x = readLine()!!.split(" ").map(String::toBigInteger)
    val s = x.toMutableList()

    (1 until x.size).forEach { i -> s[i] += s[i - 1] }

    x.indices.map { i -> (x[i] * (s.last() - s[i])).rem(mod) }
            .reduce { acc, i ->  (acc + i).rem(mod) }
            .let { println(it) }
}


Measured memory_bytes: 105944
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};
 
int main(void){
	string bS,bT;
	vector<char> S,T;

	cin>>bS>>bT;
	REP(i,(int)bS.length()) S.pb(bS[i]);
	REP(i,(int)bT.length()) T.pb(bT[i]);
	sort(S.begin(), S.end());
	sort(T.begin(),T.end(),greater<int>());
	if(T>S) puts("Yes");
	else puts("No");

	

	return 0;
}


Measured memory_bytes: 256
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readInt = fromIntegral . fst . fromJust . BS.readInteger
readIntList = map readInt . BS.words

getIntList = readIntList <$> BS.getLine

main = do
  [x1, y1, x2, y2] <- getIntList
  let dx = x2 - x1
  let dy = y2 - y1
  let x3 = x2 - dy
  let y3 = y2 + dx
  let x4 = x1 - dy
  let y4 = y1 + dx
  putStrLn $ unwords (map show [x3, y3, x4, y4])
  

Measured memory_bytes: 380
#include <stdio.h>
int main(void){
    int N[6];
    int i,X,Y,f;
    int num[5]={0};
    int flag=0;
    
    for(i=0;i<6;i+=2){
    scanf("%d %d",&N[i],&N[i+1]);
    }
    for(i=0;i<6;i+=2){
    //printf("%d %d ",N[i],N[i+1]);
    }
    
    for(i=0;i<6;i++){
        num[N[i]]+=1;    
    }
    for(i=1;i<5;i++){
    //printf("\n%d",num[i]);
        if(num[i]>2){
            flag+=1;
        }
    }
    
    if(flag==0){
        for(i=1;i<5;i++){
            if(num[i]==1){
                num[i]=0;
                X=i;
                break;
            }
        }
        for(i=1;i<5;i++){
            if(num[i]==1){
                Y=i;
                break;
            }
        }
        //printf("%d %d",X,Y);
    }
    
    for(i=0;i<6;i+=2){
        if(N[i]==X&&N[i+1]==Y){
            flag+=1;
        }
        else if(N[i]==Y&&N[i+1]==X){
            flag+=1;
        }
    }
    
    if(flag==0){
        printf("YES");
    }else{
        printf("NO");
    }
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <sstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cmath>
#define INF 0x3f3f3f3f
#define nmax 200
#define MEM(x) memset(x,0,sizeof(x))
using namespace std;
char num1[nmax],num2[nmax];
int len1,len2;
int main()
{
    //freopen("in.txt","r",stdin);
    scanf("%s",num1);
    scanf("%s",num2);
    len1 = strlen(num1);
    len2 = strlen(num2);
    bool isfind = false;
    if(len1>len2){
        isfind = true;
        printf("GREATER\n");
    }else if(len2>len1){
        isfind = true;
        printf("LESS\n");
    }else{

        for(int i =0 ; i<len1; ++i){
            if(num1[i]>num2[i]){
                isfind = true;
                printf("GREATER\n");
                break;
            }else if(num1[i] < num2[i]){
                isfind = true;
                printf("LESS\n");
                break;
            }
        }
    }
    if(isfind  == false) printf("EQUAL\n");
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 50;
 
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;

void solve(){
    int n;
    cin>>n;
    rep(i,n+5){
        if((int)(i*1.08)==n){
            cout<<i<<"\n";
            return;
        }
    }
    cout<<":(\n";
}
 
int main(){
	ios::sync_with_stdio(false);
    cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int,input().split()))
MOD = 10**9+7
if A[0] != 0:
    print(0)
    exit()

cs = [0]*3
ans = 1
for a in A:
    c = cs.count(a)
    if c==0:
        print(0)
        exit()
    ans *= c
    ans %= MOD
    i = cs.index(a)
    cs[i] += 1

print(ans)

Measured memory_bytes: 53132
#include <stdio.h>
#include <string.h>
int main()
{
    char s[22];
    int i,h,len,j,n,k;
        scanf(" %[^\n]", s);
    len=strlen(s);

        len=strlen(s);
        for(j=0;j<len;j++) {
            if (s[j] == ',') {
                s[j] =' ';
            }
        }
printf("%s\n",s);
    return 0;
}


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

using namespace std;

const int MOD = 1e9 + 7;
const int MAX = 1e5 + 10;
int n;
long long a[MAX], b[MAX];
pair<long long, bool> ab[MAX * 2];

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", a + i);
    }
    sort(a, a + n);
    for (int i = 0; i < n; i++) {
        scanf("%lld", b + i);
    }
    sort(b, b + n);
    long long ans = 1;

    for (int i = 0; i < n; i++) {
        ab[i] = make_pair(a[i], false);
    }
    for (int i = 0; i < n; i++) {
        ab[n + i] = make_pair(b[i], true);
    }
    sort(ab, ab + 2 * n);
    int cnt = 0;
    for (int i = 0; i < n * 2; i++) {
        if (ab[i].second) {
            // com
            if (cnt > 0) {
                (ans *= cnt) %= MOD;
            }
            cnt--;
        } else {
            // el
            if (cnt < 0) {
                (ans *= -cnt) %= MOD;
            }
            cnt++;
        }
    }

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 4992
#include <stdio.h>

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

Measured memory_bytes: 580
import java.util.Scanner;


public class Main {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int loop = sc.nextInt();

		for(int i=0;i<loop;i++){
			int n = sc.nextInt();
			int[] map = new int[n];
			for(int j=0;j<n;j++){
				map[j] = sc.nextInt();
			}

			int maxup=0;
			int maxdown=0;

			for(int j=0;j<n-1;j++){
				if(map[j] < map[j+1]){
					if(maxup < (map[j+1]-map[j])){
						maxup = map[j+1] - map[j];
					}
				}else{
					if(maxdown < (map[j]-map[j+1])){
						maxdown = map[j] - map[j+1];
					}
				}
			}

			System.out.println(maxup+" "+maxdown);
		}
	}

}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
#include <climits>

using namespace std;

int main() {
	int r, g, b, n , c = 0;
	cin >> r >> g >> b >> n;
	for (size_t i = 0; r * i <= n; i++)
	{
		for (size_t j = 0; g * j <= n; j++)
		{
			int k = (n - (r * i + g * j));
			if(k >= 0 && k % b == 0) {
				// cout << "ijk" << i << j << (n - (r * i + g * j)) / b << endl;
				c++;
			}
		}
		
	}
	cout << c << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
int n,t;
ll dp[3100][6100]; //dp[i][j]={i品目まで　食べ終わるのがj分まで の幸せの最大値}
vector<pair<ll,ll>> ab;

int main(){cout<<fixed<<setprecision(10);
		   cin>>n>>t;
           ll a,b;
           ab.resize(n+1);
           for(int i=1;i<=n;i++){
             cin>>a>>b;
             ab[i].first=a;
             ab[i].second=b;
           }
           //入力
           sort(all(ab));
           for(int i=1;i<=n;i++){
            for(int j=0;j<=t+3010;j++){
              if(i!=n){
                  dp[i][j]=dp[i-1][j];//i品目を食べない

                  if(j-ab[i].first>=0&&j-ab[i].first<t)//i品目を食べられるか
                    dp[i][j]=max(dp[i][j],dp[i-1][j-ab[i].first]+ab[i].second);//食べた
              }
              else{
                  dp[i][j]=dp[i-1][j];
                  if(j<t)dp[i][j]+=ab[i].second;
              }
            }
             
             
           }
           
           ll ans=0;
           
           rep(i,0,t+3010){
             
             ans=max(ans,dp[n][i]);
             
           }
           
           cout<<ans<<endl;
}

Measured memory_bytes: 146480
fun main(args: Array<String>){
    var n: List<String> = readLine()!!.split(" ")
    val a: List<String> = readLine()!!.split(" ")
    var num: Int = 0
    for(i in a){
        if(i.toInt() >= n[1].toInt()){
            num++
        }
    }
    println(num)
}


Measured memory_bytes: 46224
#include <iostream>
#include <cstdio>
#define int long long
using namespace std;
int n,sum,last_x;
int fzx_max(int x,int y) {
        return x<y ? y : x;
}
signed main()
{
        scanf("%lld",&n);
        for (int i=1; i<=n; i++) {
                int x=0;
                scanf("%lld",&x);
                // if (!(i^1)) continue;
                sum+=fzx_max(0,last_x-x);
                last_x=fzx_max(last_x,x);
                // cout<<sum<<endl;
        }
        cout<<sum<<"\n";
        return 0;
}


Measured memory_bytes: 3764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int n; cin >> n;
    int cnt[55][26] = {};

    REP(i,n)
    {
        string S; cin >> S;
        REP(j,S.length())
        {
            cnt[i][S[j] - 'a']++;
        }
    }

    REP(i,26)
    {
        int min = cnt[0][i];
        FOR(j,1,n)
        {
            if(cnt[j][i] < min) min = cnt[j][i];
        }

        cout << string(min, i + 'a');

    }
    cout << endl;


}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <complex>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

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

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
  if (!v.empty()) {
    os << v.front();
    for (int i = 1; i < v.size(); ++i)
      os << ' ' << v[i];
  }
  return os;
}

typedef complex<double> Cp;

const int L = 19, N = 1 << L;
const double PI = 3.1415926535897932384626;

Cp a[N], b[N], w[N];
int brev[N];

void fft(Cp* a, int lgn, int sgn) {
  int n = 1 << lgn;
  if (sgn == 1) {
    for (int i = 1; i < n; ++i)
      brev[i] = brev[i >> 1] >> 1 | (i & 1) << (lgn - 1);

    for (int i = 0; i < n; ++i)
      w[i] = Cp(cos(2 * PI * i / n), sin(2 * PI * i / n));
  }

  for (int i = 0; i < n; ++i)
    if (brev[i] < i)
      swap(a[i], a[brev[i]]);

  for (int i = 0; i < lgn; ++i) {
    for (int j = 0; j < n; j += 2 << i) {
      Cp* ar = a + j;
      for (int k = 0; k < 1 << i; ++k) {
        Cp a0 = ar[k], a1 = ar[k + (1 << i)], x = a1 * w[k << (lgn - i - 1)];
        ar[k] = a0 + x;
        ar[k + (1 << i)] = a0 - x;
      }
    }
  }

  if (sgn == -1) {
    reverse(a + 1, a + n);
    for (int i = 0; i < n; ++i)
      a[i] /= n;
  }
}


const int P = 200003, R = 2;

int pw[P], ind[P], cnt[P];
ll ans;

int main() {
#ifdef ELEGIA
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif
  ios::sync_with_stdio(false);
  cin.tie(nullptr);

  int q = 1;
  for (int i = 0; i < P - 1; ++i) {
    pw[i] = q;
    ind[q] = i;
    q = q * (ll)R % P;
  }

  int n;
  cin >> n;
  while (n--) {
    int x;
    cin >> x;
    if (!x)continue;
    ans -= x * (ll)x % P;
    ++cnt[ind[x]];
  }
  for (int i = 0; i < P - 1; ++i)
    a[i].real(cnt[i]);
  fft(a, 19, 1);
  for (int i = 0; i < 1 << 19; ++i)
    a[i] *= a[i];
  fft(a, 19, -1);
  q = 1;
  for (int i = 0; i < 1 << 19; ++i) {
    ll occ = a[i].real() + .5;
    ans += q * occ;
    q = q * (ll)R % P;
  }
  cout << ans / 2 << '\n';

#ifdef ELEGIA
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 24380
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define repX(i, n ,x) for (int i = x; i < (int)(n); ++i)
#define repBack(i, n) for (int i = n; i >= 0; --i)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int N,K;
    cin >> N >> K;
    string S;
    cin >> S;
    S[K - 1] = S[K - 1] + 0x20;
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
  m,f,r = map (int,input().split())
  if m ==-1 and f==-1 and r==-1:
      break
  if m== -1 or f ==-1:
      print("F")
  elif m+f>=80:
      print("A")
  elif m+f>=65:
      print("B")
  elif m+f>=50:
      print("C")
  elif m+f>=30:
    if r>=50:
       print("C")
    else:
       print("D")
  else:
      print("F")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
 
const int maxn=2005;
int n,a[maxn],l[maxn],r[maxn];
long long p=0,lq,rq,k;
 
int main(){
    memset(a,0,sizeof(a));
    memset(l,0,sizeof(l));
    memset(r,0,sizeof(r));
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
    }
    for(int i=1;i<=n;i++){
        for(int j=i+1;j<=n;j++){
            if(a[i]>a[j]) l[i]++;
        }
    }
    for(int i=1;i<=n;i++){
        for(int j=i-1;j>=1;j--){
            if(a[i]>a[j]) r[i]++;
        }
    }
    rq=k*(k-1)/2%1000000007;
    lq=(rq+k)%1000000007;
    for(int i=1;i<=n;i++){
        p+=l[i]*lq+r[i]*rq;
        p=p%1000000007;
    }
    printf("%lld",p);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define endl '\n'
#define all(x) (x).begin(),(x).end()
const int INF=1e9+5;
const int N=2e5+5;
const ll oo=1e18+5;
const ll mod=1e9+7;

int k;

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll sum=0;
	cin>>k;
	for(int i=1;i<=k;++i){
		for(int j=1;j<=k;++j){
			for(int d=1;d<=k;++d){
				sum+=__gcd(i,__gcd(j,d));
			}
		}
	}
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 3644
N, x = map(int, input().split())
a = list(map(int, input().split()))

ans = 0
for i in range(N):
  if i != N -1:
    if a[i] + a[i + 1] > x:
      ans += a[i] + a[i + 1] - x
      a[i + 1] -= min(a[i + 1], a[i] + a[i + 1] - x)
print(ans)

Measured memory_bytes: 14592
#include <iostream>

using namespace std;

int main(){
  int A, B, C;
  cin >> A >> B >> C;
  bool ans = false;
  for(int i = 1; i <= B; i++){
    if(A * i % B == C){
      ans = true;
      break;
    }
  }
  if(ans) cout << "YES";
  else cout << "NO";
}


Measured memory_bytes: 256
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
 
using namespace std;
 
typedef long long ll;
 
#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;
 
#define MOD 1000000007

int main(){
  ll n;
  cin>>n;
  vector<ll> v;
  ll mn = 1000000000;
  rep(i,0,n){
    ll a;
    cin>>a;
    v.pb(a);
  }
  ll ans = 0;
  rep(i,0,v.sz){
    if(v[i]<mn){
      ans++;
    }
    mn = min(mn,v[i]);
  }
  cout << ans << endl;
  return 0;
}

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

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var abc = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (a, b, c) = (abc[0], abc[1], abc[2]);
        var k = int.Parse(Console.ReadLine());

        while (k > 0 && a >= b)
        {
            --k;
            b *= 2;
        }
        while (k > 0 && b >= c)
        {
            --k;
            c *= 2;
        }

        Console.WriteLine(a < b && b < c ? "Yes" : "No");
    }
}


Measured memory_bytes: 28280
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define ll long long
#define IT iterator
#define PB push_back
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
#define ALL(a) a.begin(),a.end()
#define POB pop_back
#define ff fflush(stdout)
#define fastio ios::sync_with_stdio(false)
#define debug_pair(A) cerr<<A.FIR<<" "<<A.SEC<<endl;
#define biggest(A,B) A=max(A,B)
#define smallest(A,B) A=min(A,B)
using namespace std;
//const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int n,a[200000+2];
int main(){
	
	cin>>n;
	vector<int> a(n);
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	bool col=0;
	int it=0;
	ll res=0;
	for(int i=1;i<n;i++){
		res+=a[it];
		if(it==0){
			it++;
		}
		else
		{
		if(col==1){
			col=0;
			it++;
		}
		else{
			col=1;
		}
			
		}
		
	}cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 4064
# 解説AC

from collections import Counter as cnt

n=int(input())
a=list(map(int,input().split()))

s=[0 for i in range(n+1)]

for i in range(n+1):
    if i>0:
        s[i]=s[i-1]+a[i-1]

s.sort()
dic=cnt(s)
ans=0
for n in dic.values():
    ans+=n*(n-1)/2

print(int(ans))

Measured memory_bytes: 41692
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << endl;
#define CFYN(n) cout << ( (n) ? "YES":"NO") << endl;
#define OUT(n) cout << (n) << endl;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;

constexpr bool ygreater(const pii &a, const pii &b) {
    return a.second < b.second;
}

int main(void)
{
    IOS
    int n; cin >> n;
    vector<pii> r,b;
    REP(i,n) {
        int x, y;
        cin >> x >> y;
        r.push_back({x,y});
    }
    REP(i,n) {
        int x, y;
        cin >> x >> y;
        b.push_back({x,y});
    }
    sort(ALL(r));
    sort(ALL(b));
    int ans = 0;
    vector<bool> ruse(r.size());

    REP(i,n) {
        int maxry = -1;
        int maxryj = -1;
        REP(j,n) {
            if (b[i].first > r[j].first && b[i].second > r[j].second && !ruse[j]) {
                if (maxry < r[j].second) {
                    maxry = r[j].second;
                    maxryj = j;
                }
            }
        }
        if (maxryj != -1) {
            cerr << r[i].first << " " << r[i].second << " " <<b[maxryj].first << " " <<b[maxryj].second <<endl; 
            ruse[maxryj] = true;
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
template<typename T> using id_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update> ;
template<typename T> using id_setp = tree<pair<T,T>,null_type,less<pair<T,T>>,rb_tree_tag,tree_order_statistics_node_update> ;

#define f(i,x,n) for(i=x;i<n;i++)
#define fr(i,x,n) for(i=x;i>=n;i--)
#define pu push_back           
#define pp pop_back
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define SP(x) fixed<<setprecision(x)
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const long long MOD=1e9+7;
const long double PI = acos(-1);
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=1e6+1;
 
typedef long long ll;
typedef long double ld;
 
vector<ll> v[N];

int main()
{
   IOS();
   ll n,m,i,j,h,w;
   cin>>h>>w;
   char a[h+3][w+3];
   ll arr[h+3][w+3];
   f(i,0,w+3)
   {
      a[0][i]='#';
      a[h+1][i]='#';
   }
   f(i,0,h+3)
   {
      a[i][0]='#';
      a[i][w+1]='#';
   }
   ll zz=1;
   f(i,1,h+1)
   {
      f(j,1,w+1)
      {
         cin>>a[i][j];
         if(a[i][j]=='.')
         {
            arr[i][j]=zz;
            zz++;
         }
         else
            arr[i][j]=0;
      }
   }
   f(i,1,h+1)
   {
      f(j,1,w+1)
      {
         if(a[i][j]=='.')
         {
            if(a[i][j+1]=='.')
            {
               v[arr[i][j]].pu(arr[i][j+1]);
               v[arr[i][j+1]].pu(arr[i][j]);
            }
            if(a[i][j-1]=='.')
            {
               v[arr[i][j-1]].pu(arr[i][j]);
               v[arr[i][j]].pu(arr[i][j-1]);
            }
            if(a[i+1][j]=='.')
            {
               v[arr[i+1][j]].pu(arr[i][j]);
               v[arr[i][j]].pu(arr[i+1][j]);
            }
            if(a[i-1][j]=='.')
            {
               v[arr[i-1][j]].pu(arr[i][j]);
               v[arr[i][j]].pu(arr[i-1][j]);
            }
         }
      }
   }
   n=zz+2;
   ll adj[n+1][n+1]={0};
   f(i,0,n+1)
   {
      f(j,0,v[i].size())
      {
         adj[i][v[i][j]]=1;
         adj[v[i][j]][i]=1;

      }
   }  
   ll distance[n+1][n+1]={0};
   for(ll i = 1; i <= n; i++) 
   {
      for(ll j = 1; j <= n; j++) 
      {
         if(i == j) 
            distance[i][j] = 0;
         else if (adj[i][j]) 
            distance[i][j] = adj[i][j];
         else distance[i][j] = INF;
      }
   }
   for (ll k = 1; k <= n; k++) 
   {
      for (ll i = 1; i <= n; i++) 
      {
         for (ll j = 1; j <= n; j++) 
         {
            distance[i][j] = min(distance[i][j],distance[i][k]+distance[k][j]);
         }
      }
   }
   ll ans=0;
   f(i,1,n+1)
   {
      f(j,1,n+1)
      {
         if(distance[i][j]!=INF)
         {
            ans=max(ans,distance[i][j]);
         }
      }
   }
   cout<<ans<<'\n';
   return 0;
}

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

int main() {
  
  int N, M;
  cin >> N >> M;
  //dp
  vector<int> dp(N+1);  
  vector<bool> broke(N+1, false);
  
  for  (int i=0; i<M; ++i) {
    int a;
    cin >> a;
    broke.at(a) = true;
  }
  
  
  // 初期条件
  dp.at(0) = 1;
  if(broke.at(1)) dp.at(1) = 0;
  else dp.at(1) = 1;
  
  
  
  // 2段目から
  if(N>1) {
    for (int i=2; i<=N; ++i) {
      if (broke.at(i)) dp.at(i) = 0;
      else dp.at(i) = (dp.at(i-1) + dp.at(i-2)) % 1000000007;
    }
  }
  cout << dp.at(N) << endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define N 200003
#define LL long long
#define mod 998244353

int n,m,ans;
char s[N],t[N];

inline int read(){
	int X=0,w=0;
	char ch=0;
	while (ch<'0' || ch>'9')
	  w|=ch=='-',ch=getchar();
	while (ch>='0' && ch<='9')
	  X=(X<<3)+(X<<1)+(ch^48),ch=getchar();
	return w ? -X : X;
}

int main(){
	scanf("%s%s",s+1,t+1);
	if (s[1]==t[1]) ans++;
	if (s[2]==t[2]) ans++;
	if (s[3]==t[3]) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    int n, k;

    public static void main(String args[]) {
        new Main().run();
    }

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        k = sc.nextInt();
        int[] counts = new int[n];
        for (int i = 0; i < n; i++) {
            counts[sc.nextInt() - 1]++;
        }
        Arrays.sort(counts);
        int ans = 0;
        for (int i = 0; i < n - k; i++) {
            if (counts[i] > 0) {
                ans += counts[i];
            }
        }
        System.out.println(ans);
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 48476
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include<stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
const int inf = 1000000007;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % inf;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), inf - 2, inf) % inf * mod_pow(kai(y), inf - 2, inf) % inf;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

signed main() {	
	int n, m;
	cin >> n >> m;
	for (int i = m / n; i >= 1; --i) {
		if (m % i == 0) {
			cout << i << endl; return 0;
		}
	}
}

Measured memory_bytes: 256
N = int(input())
a = input().split()
a_list = []

for i in range(N):
    a_list.append(int(a[i]))

a_list.sort(reverse=True)

alice = 0
bob = 0

for i in range(N):
    if i % 2 == 1:
        bob += a_list[i]
    else:
        alice += a_list[i]

print(alice - bob)

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

double n;

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

    cout << fixed << setprecision(10);

    cin >> n;
    cout << (n / 3) * (n / 3) * (n / 3) << "\n";

    return 0;
}


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

#define MAXN 200010

int n,ans=1;
char s[MAXN],last;

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	last=s[1];
	for(int i=2;i<=n;++i)
	{
		if(s[i]==last)
		{
			if(i<n)++ans;
			++i;
			last=0;
		}
		else
		{
			++ans;
			last=s[i];
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)


int main(){
    int n;
    cin >> n;
    vector<double> t(n);
    vector<double> v(n);
    cin >> t[0];
    for(int i = 1; i < n; i++){
        cin >> t[i];
        t[i] += t[i-1];
    }
    double total = t[n-1];
    for(int i = 0; i < n; i++){
        cin >> v[i];
    }
    v.push_back(0);
    double tt = 0.0;
    double speed = 0.0;
    double ans = 0.0;
    for(int i = 0; i < n; i++){
        while(tt < t[i]){
            tt += 0.5;
            double limit = t[i] - tt + v[i+1];
            for(int j = i; j < n; j++){
                limit = min(limit, t[j] - tt + v[j+1]);
            }
            double old_speed = speed;
            speed = min(min(speed+0.5, limit),v[i]);
            ans += (old_speed + speed)*0.5*0.5;
        }
    }
    printf("%.12f\n",ans);
    return 0;
}


Measured memory_bytes: 256
//#pragma G++ optimize(3)
#include<iostream>
#include<cstdio>
#define re register
using namespace std;
int t[100000+10];
inline char nc() 
{
    static char buf[1000000], *p1 = buf, *p2 = buf;
    return p1 == p2 && (p2 = (p1 = buf) + fread (buf, 1, 1000000, stdin), p1 == p2) ? EOF : *p1++;
}
inline int read()
{
	re int n=0,ch=nc();
	while(ch<'0'||ch>'9')ch=nc();
	while(ch>='0'&&ch<='9')
		{
			n=(n<<3)+(n<<1)+ch-'0';
			ch=nc();
		}
	return n;
}
void write(int n)
{
	if(n>=10)write(n/10);
	putchar(n%10+'0');
}
int main()
{
	re int s=0,N,M;
	N=read();
	re int j;
	N-=4;
	for(j=1;j<=N;j+=4)
		{
			s+=t[j]=read();
			s+=t[j+1]=read();
			s+=t[j+2]=read();
			s+=t[j+3]=read();
		}
	for(;j<=N+4;++j)
		s+=t[j]=read();

	M=read();
	re int p,x;	
	re int k;
	M-=4;
	for(k=1;k<=M;k+=4)
		{
			p=read();
			x=read();
			write(s+x-t[p]);
			putchar('\n');
			p=read();
			x=read();
			write(s+x-t[p]);
			putchar('\n');
			p=read();
			x=read();
			write(s+x-t[p]);
			putchar('\n');
			p=read();
			x=read();
			write(s+x-t[p]);
			putchar('\n');
		}
	for(;k<=M+4;++k)
		{
			p=read();
			x=read();
			write(s+x-t[p]);
			putchar('\n');
		}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    int h1 = sc.nextInt();
    int m1 = sc.nextInt();
    int h2 = sc.nextInt();
    int m2 = sc.nextInt();
    int k = sc.nextInt();
    
    int result = (h2 - h1)*60  + (m2 - m1) - k;
    System.out.println(result);
  }
}

Measured memory_bytes: 35784
#include <iostream>
#include <typeinfo>

using namespace std;

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

int main() {
    int A, B;
    string M;
    cin >> A >> B;
    cin >> M;
    string str = "Yes";

    REP(i, M.length()) {
        if (i == A) {
            if (M[i] != '-') {
                str = "No";
                break;
            }
        } else {
            if (!('0' <= M[i] && M[i] <= '9')) {
                str = "No";
                break;
            }
        }
    }
    if(M.length() != A+B+1) str= "No";
    cout << str;
}

Measured memory_bytes: 256
#!/usr/bin/python3
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)


def main():
    n, m = map(int, input().split())
    ab = [list(map(int, input().split())) for _ in range(n)]
    cd = [list(map(int, input().split())) for _ in range(m)]

    for a, b in ab:
        arr = []
        for c, d in cd:
            arr.append(abs(a-c) + abs(b-d))
        print(arr.index(min(arr)) + 1)

if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>

//#define int long long
#define CONTAINS(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define MAX(a,b) (((a) > (b)) ? (a) : (b))
#define MIN(a,b) (((a) < (b)) ? (a) : (b))
#define REMOVE(v,a) v.erase(remove(v.begin(), v.end(), a), v.end())
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
using namespace std;

signed main()
{
	int N;
	cin >> N;
	int ans = 0;
	REP(i, N)
	{
		int l, r;
		cin >> l >> r;
		ans += (r - l) + 1;
	}
	cout << ans << endl;
}

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

using namespace std;

void solve()
{
	bitset<8> distribution;
	int N;
	cin >> N;
	int a = 0;
	while (N--)
	{
		int d;
		cin >> d;
		if (d >= 3200)
		{
			a++;
		}
		else distribution[d/400] = 1;
	}

	int ans = distribution.count();

	cout << max(min(a, 1), ans) << ' ' << ans+a << endl;

}

int main()
{
	solve();
	//cout << "yui(*-v・)yui" << endl;
	return 0;
}


Measured memory_bytes: 256