akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
public class Main{
    public static void main(String[] args) throws IOException{
        MyReader rd = new MyReader();  
        int N, K; {int[] a = rd.ii(); N = a[0]; K = a[1];}
        long[] A = rd.ll();
        long S = 0;
        for(long a : A)
            S += a;
        ArrayList<Long> list = new ArrayList<>();
        double root = Math.sqrt(S);
        for(long i = 1; i < root; i++){
            if(S%i == 0){
                int j = list.size()/2;
                list.add(j, i);
                list.add(j+1, S/i);
            }
        }
        if(root%1 == 0)
            list.add(list.size()/2, (long)root);
        for(int i = list.size()-1; i >= 0; i--){
            long d = list.get(i);
            ArrayList<Long> rList = new ArrayList<>(); 
            for(int j = 0; j < N; j++){
                long r = A[j]%d;
                if(r > 0)
                    rList.add(r);                
            }
            rList.sort(null);  
            long left = 0;
            long right = d*rList.size();
            for(long re : rList)
                right -= re;
            for(int j = 0; j < rList.size(); j++){
                if(left <= K && right <= K){
                    println(d);
                    return;
                } else{
                    long re = rList.get(j);
                    left += re;
                    right -= d-re;
                }
            }
        }
        println(1);
    }
    static void print(Object o){
        System.out.print(o.toString());
    }
    static void println(Object o){
        System.out.println(o.toString());
    }
    static int Int(String s){
        return Integer.parseInt(s);
    }
    static long Long(String s){
        return Long.parseLong(s);
    }
    static class MyReader extends BufferedReader{
        MyReader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Integer.parseInt(ss[j]);
            return ii;
        }
        long l() throws IOException{
            return Long(s());
        }
        long[] ll() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            long[] ll = new long[size];
            for(int j = 0; j < size; j++) ll[j] = Long.parseLong(ss[j]);            
            return ll;
        }
    }
}

Measured memory_bytes: 40136
#include<stdio.h>
int main(void)
{
	int a[6];
	int i,j,cnt,n;
	for(i=0;i<6;i++){
		scanf("%d",&a[i]);
	}
	cnt=0;
	for(i=0;i<6;i++){
		for(j=0;j<5;j++){
			n=a[i]-a[j];
			if(a[5]<n){
				cnt++;
			}
		}
	}
	if(cnt==0){
		printf("Yay!\n");
	}
	else{
		printf(":(\n");
	}
	return 0;
}


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

using namespace std;

#ifdef DGC
#include "debug.h"
#else
#define debug(...) 9715
#endif
typedef long long ll;
typedef long double ld;
typedef complex<ld> point;
#define F first
#define S second



int main()
{
	#ifdef DGC
		//freopen("a.in", "r", stdin);
		//freopen("b.out", "w", stdout);
	#endif

	ios_base::sync_with_stdio(0), cin.tie(0);

	int n;
	string a, b;
	cin >> n >> a >> b;

	for (int i = 0; i < n; ++i)
	{
		cout << a[i] << b[i];
	}

	return 0;
}


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

const int INF = 1001001001;

int main() {
int n;
cin >> n;
vector<ll> vec(n);
for(int i = 0;i < n;i++) {
    cin >> vec.at(i);
}
ll ans = 0;

sort(vec.begin(),vec.end());
reverse(vec.begin(),vec.end());
for (int i = 0;i < n-2;i++) {
    for (int j = i+1;j < n-1;j++) {
        for (int k = j +1;k < n;k++) {
            if (vec[i] == vec[j] || vec[i] == vec[k] || vec[j] == vec[k]) {
                    continue;
                }
            if (vec.at(i) < vec.at(j) + vec.at(k)) {
                
                ans++;
            }
        }
    }
}

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


Measured memory_bytes: 3624
// #include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <climits>
#include <string>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <ctime>
#include <cassert>
#include <fstream>
#include <stack>
#include <random>

typedef long long ll;
typedef std::pair<int, int> Pii;
typedef std::pair<long long, long long> Pll;
typedef std::pair<double, double> Pdd;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define all(a) a.begin(), a.end()
#define MM << " " <<

template<typename T>
using MaxHeap = std::priority_queue<T>;
template<typename T>
using MinHeap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

template<typename T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

template<typename T>
void vdeb(std::vector<T> &da) {
    for (int i = 0;i < da.size();i++) {
        if (i == da.size() - 1) std::cout << da[i];
        else std::cout << da[i] << ' ';
    }
    std::cout << '\n';
}
template<typename T>
void vdeb(std::vector<std::vector<T>> &da) {
    for (int i = 0;i < da.size();i++) {
        std::cout << i << ' ';
        vdeb(da[i]);
    }
    std::cout << '\n';
}

using namespace std;

ll solve() {
    int n; cin >> n;
    vector<vector<int>> da(n, vector<int>(0));
    vector<Pll> score(n);
    rip(i,n,0) {
        int k;
        cin >> k >> score[i].first >> score[i].second;
        da[k-1].push_back(i);
    }
    ll ret = 0;
    rip(i,n,0) ret += min(score[i].first, score[i].second);
    MinHeap<ll> pq;
    rip(i,n,0) {
        rip(j,da[i].size(),0) {
            if(score[da[i][j]].first > score[da[i][j]].second) {
                pq.push(score[da[i][j]].first-score[da[i][j]].second);
            }
        }
        while(int(pq.size()) > i+1) {
            pq.pop();
        }
    }
    while(!pq.empty()) {
        ret += pq.top();
        pq.pop();
    }
    rip(i,n,1) {
        rip(j,da[n-i-1].size(),0) {
            if(score[da[n-i-1][j]].first < score[da[n-i-1][j]].second) {
                pq.push(score[da[n-i-1][j]].second-score[da[n-i-1][j]].first);
            }
        }
        while(int(pq.size()) > i) {
            pq.pop();
        }
    }
    while(!pq.empty()) {
        ret += pq.top();
        pq.pop();
    }
    return ret;
}

int main() {
    int t; cin >> t;
    vector<ll> ans(t);
    rip(i,t,0) ans[i] = solve();
    rip(i,t,0) printf("%lld\n", ans[i]);
}

Measured memory_bytes: 15588
#include <bits/stdc++.h>
using namespace std;
#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 all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
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;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

int main() {
    ll l, r;
    cin >> l >> r;
    if (r - l > 2019) {
        cout << 0 << endl;
        return 0;
    }
    ll ans = LINF;
    for (ll i = l; i <= r; i++) {
        for (ll j = i + 1; j <= r; j++) {
            chmin(ans, i * j % 2019);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>          // printf(), scanf()

#define MAX_N 100
#define min(a, b) ((a) < (b) ? (a) : (b))

const int INF = 100000000;

int
main(int argc, char** argv)
{
	int p[MAX_N + 1];
	int m[MAX_N + 1][MAX_N + 1];
	int n;
	int i, j, k, l;

	scanf("%d", &n);
	for (i = 1; i <= n; ++i)
		scanf("%d %d", &p[i - 1], &p[i]);

	for (i = 1; i <= n; ++i)
		m[i][i] = 0;

	for (l = 2; l <= n; ++l)
	{
		for (i = 1; i <= n - l + 1; ++i)
		{
			j = i + l - 1;
			m[i][j] = INF;
			for (k = i; k <= j - 1; ++k)
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
		}
	}

	printf("%d\n", m[1][n]);
	return 0;
}

Measured memory_bytes: 636
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define veci vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vec>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))


using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x:vec) is >> x;
    return is;
}
const ll mod=1e9+7;

struct Sieve{
    int n;
    vector<int> f, primes;
    //コンストラクタを定義
    Sieve(int n=1):n(n), f(n+1){//メンバ変数の初期化
        f[0]=f[1]=-1;
        for(ll i=2;i<=n;i++){
            if(f[i]) continue;
            primes.push_back(i);
            f[i]=i;
            for(ll j=i*i;j<=n;j+=i){
                if(!f[j]) f[j]=i;
            }
        }
    }
    bool isPrime(int x) { return f[x]==x;} //xが素数かどうかを判定
    vector<int> factorList(int x){//xの素因数を重複ありで小さい順に列挙
        vector<int> res;
        while(x!=1){
            res.push_back(f[x]);
            x/=f[x];
        }
        return res;
    }
    vector<pair<int,int>> factor(int x){//xの素因数と、その出現回数
        vector<int> fl=factorList(x);
        if(fl.size()==0) return {};
        vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
        for(int p : fl){
            if(res.back().first==p){
                res.back().second++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }
};

int main()
{
    int n;
    cin >> n;
    Sieve sieve(1000);
    map<int,int> m;
    for(int i=1;i<=n;i++){
        auto f=sieve.factor(i);
        for(auto x:f){
            m[x.first]+=x.second;
        }
        
    }
    ll ans=1;
    for(auto x:m){
        if(x.first==1) continue;
        //cout << x.second << endl;
        ans*=(ll)(x.second+1);
        ans%=mod;
    }
    cout << ans << endl;
    return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fo(i,a,b) for((i)=(a);i<=(b);i++)
#define rfo(i,a,b) for((i)=(a);i>=(b);i--)
#define inrange(x,y,z) (((x)>=(y))&&((x)<=(z)))
#define ALL(vec) ((vec).begin(),(vec).end())
#define SOR(vec) sort(ALL(vec))
#define UNI(vec) (vec).erase(unique(ALL(vec)),(vec).end())
using namespace std;
long long n,k,le,ri,res,MOD=1000000007LL;
int main(){
	#ifdef FILIN
		#ifndef LOCAL
			freopen(FILIN,"r",stdin);
			freopen(FILOUT,"w",stdout);
		#endif
	#endif
	ios::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	cin>>n>>k;
	for(int x=k;x<=n+1;x++){
		//pick i #'s
		le=x*(x-1LL)/2LL;
		ri=(n*2-x+1LL)*x/2LL;
		res=(res+(ri-le+1LL))%MOD;
	}
	cout<<res<<endl;
	return 0;
}


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

int main() {
  int n, k;
  cin >> n >> k;
  map<char, int> mp;
  int r, s, p;
  cin >> r >> s >> p;
  mp['r'] = p;
  mp['s'] = r;
  mp['p'] = s;
  string t;
  cin >> t;
  vector<int> vec(n);
  rep(i,n) {
    vec[i] = mp[t[i]];
    // cout << vec[i] << endl;
    if(i >= k) {
      if(t[i] == t[i-k]) {
        vec[i] = 0;
        t[i] = 'x';
      }
    }
  }
  int ans = 0;
  rep(i,n) ans += vec[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3836
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int k = sc.nextInt();

        if (k == 1) {
            System.out.println(0);
        } else {
            System.out.println(n - k);
        }
	}
}

Measured memory_bytes: 22868
#include<bits/stdc++.h>
#define maxn 100100
using namespace std;
vector<int>G[maxn];
int n,dp[maxn],len;
int dfs(int u,int f){
	int mx=0,y=0,z=0,s;
	for(int i=0,x;i<G[u].size();++i)if(G[u][i]!=f)
		s=dfs(G[u][i],u),mx=max(mx,__lg(y&s)),y|=s;
//	printf("<%d,%d>",u,mx);
	for(int i=mx;;i++)if(!(y>>i&1))
		return (y&(-1<<i))|(1<<i);
}
int main(){
	scanf("%d",&n);
	for(int i=2,u,v;i<=n;++i)
		scanf("%d%d",&u,&v),
		G[v].push_back(u),
		G[u].push_back(v);
	printf("%d",__lg(dfs(1,0)));
}

Measured memory_bytes: 11392
<?php

$residences = array(
    array(
        array_fill(0, 10, 0), array_fill(0, 10, 0), array_fill(0, 10, 0)
    ),
    array(
        array_fill(0, 10, 0), array_fill(0, 10, 0), array_fill(0, 10, 0)
    ),
    array(
        array_fill(0, 10, 0), array_fill(0, 10, 0), array_fill(0, 10, 0)
    ),
    array(
        array_fill(0, 10, 0), array_fill(0, 10, 0), array_fill(0, 10, 0)
    ),
);
$n = intval(trim(fgets(STDIN)));
for ($i = 0; $i < $n; $i++) {
    $stdin = preg_split('/ /', trim(fgets(STDIN)));
    $b = intval(array_shift($stdin));
    $f = intval(array_shift($stdin));
    $r = intval(array_shift($stdin));
    $v = intval(array_shift($stdin));
    $residences[$b-1][$f-1][$r-1] += $v;
}

for ($i = 0; $i < 4; $i++) {
    for ($j = 0; $j < 3; $j++) {
        for ($k = 0; $k < 10; $k++) {
            print(" " . $residences[$i][$j][$k]);
        }
        print("\n");
    }
    if ($i != 3) {
        print("####################\n");
    }
}

Measured memory_bytes: 6716
#include <cstdio>
#include <complex>
#include <vector>
#include <cmath>

using namespace std;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)

typedef complex<double> P;
typedef vector<P> VP;
const double EPF = 1e-9;

#define X real()
#define Y imag()
#define EQ(x,y) (abs(x-y) < EPF)

double dot(P a, P b) {
  return (conj(a)*b).X;
}
double cross(P a, P b) {
  return (conj(a)*b).Y;
}
double distPP(P a, P b) {
  return sqrt(dot(a-b,a-b));
}
P crosspoint(P a, P b, P c, P d) {//ac , bd
  double d1 = cross(d-b,b-a);
  double d2 = cross(d-b,c-a);
  if(EQ(d1,0) & EQ(d2,0)) return a;
  if(EQ(d2,0)) return a;
  return a + (c-a)*d1/d2;
}
P normal_vector(P a) {
  P b(-a.Y, a.X);
  return b;
}
P polar(double r, double theta) {
  P a(r*cos(theta),r*sin(theta));
  return a;
}

int main() {
  P pos(0,0);
  int angle = 90;
  while(1) {
    int dl,dangle;
    scanf("%d,%d", &dl, &dangle);
    if(dl == 0 && dangle == 0) break;
    P dpos = polar(dl,angle*M_PI/180);
    pos += dpos;
    angle -= dangle;
  }
  printf("%d\n%d\n",(int)pos.X,(int)pos.Y);
  return 0;
}

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

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

    int A[n][m];
    int b[m];

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            cin >> A[i][j];
        }
    }

    for (int i = 0; i < m; i++) {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++) {
        int ans = 0;
        for (int j = 0; j < m; j++) {
            ans += A[i][j] * b[j];
        }
        cout << ans << endl;
    }
}



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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//------------------------------------------------------------------

int main(void){
  int n, m;
  cin >> n >> m;
  vec check(n, 0);
  rep(i,m){
    int a, b;
    cin >> a >> b;
    a--; b--;
    check[a]++;
    check[b]++;
  }

  bool ok=true;
  rep(i,n){
    if(check[i]%2==1) ok=false;
  }
  prt(ok ? "YES" : "NO");
}


Measured memory_bytes: 3728
##templete
s = gets.chomp

leng = s.length


even = '0'
odd = '1'

count1 = 0
count2 = 0
for i in 0..leng-1 do
  if i % 2 == 0
    count1 += 1 if s[i] != even
    count2 += 1 if s[i] != odd
  else
    count1 += 1 if s[i] != odd
    count2 += 1 if s[i] != even
  end
end

ans = count1 > count2 ? count2 : count1
puts ans


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

using namespace std;

int sum[200005];

int main()
{
    int n,k;
    cin>>n>>k;
    for(int i=0;i<n;i++)
    {
        int a;
        scanf("%d",&a);
        sum[a]++;
    }
    sort(sum,sum+n+1);
    int ans=0;
    for(int i=n;i>n-k;i--)
    {
        ans+=sum[i];
    }
    cout <<n-ans<< endl;
    return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;
public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();

    int r = N;
    while(r > 0) {
      r = r - 1000;
    }
    System.out.println(-r);
  }
}

Measured memory_bytes: 35528
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string c[11] = {"",
		".,!? ",
		"abc",
		"def",
		"ghi",
		"jkl",
		"mno",
		"pqrs",
		"tuv",
		"wxyz"};
int main(void){
  int n;
  cin >> n;
  string s;
  for(int i = 0; i < n; i++){
    string res;
    cin >> s;
    char a = '0';
    int b = 0;
    for(int j = 0; j < (int)s.size(); j++){
      if(s[j] == a){
	b++;
      }else{
	if(a-'0')
	  res += c[a-'0'][b%(int)c[a-'0'].size()];
	a = s[j];
	b = 0;
      }
    }
    cout << res << endl;
  }
}

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

namespace ABC045A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, h, z;
    
            a = int.Parse(Console.ReadLine());
            b = int.Parse(Console.ReadLine());
            h = int.Parse(Console.ReadLine());
            z = (a + b) * h / 2;
            Console.WriteLine(z);
            Console.ReadKey();




        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;

int main() {
    int n, d;
    cin >> n >> d;
    cout << (n - 1) / (2 * d + 1) + 1 << endl;
}

/*
g++ -std=c++14 abc134/f.cpp
 */

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

string s, t;
int n, k, p;

int main(){
	cin >> s;
	n = s.size();
	k = 0;
	t = "";
	for (int i = 0; i < n; ++i){
		if (t != s.substr(i, 1)){
			k++;
			t = s.substr(i, 1);
		}
		else if (i < n-1){
				k++;
				t = s.substr(i, 2);
				i++;
		}
	}
	cout << k;
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cstdlib>
using namespace std;

int main(){
    string s;
    cin>>s;
    if((s[0]==s[1]&&s[1]==s[2])||(s[1]==s[2]&&s[2]==s[3])) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (1LL<<60)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
typedef unsigned long long int ull;
typedef long long lint;
 
int main(void){
  int N;
  cin >> N;
  int b[N];
  bool check=true;
  rep(i,N) cin >> b[i];
  int ans[N];
  for(int i=0;i<N;i++){
    bool able=false;
    for(int j=N-1-i;j>=0;j--){
      if(b[j]==j+1){
        ans[i]=j+1,able=true;
        for(int k=j;k<N-i;k++) b[k]=b[k+1];
        break;
      }
    }
    if(able==false) check=false;
  }
  if(check==true) reprev(i,N) cout << ans[i] << endl;
  else cout << "-1" << endl;
}

Measured memory_bytes: 256
import numpy as np
N, M = list(map(int, input().split()))
data = []
for i in range(N):
  data.append(list(map(int, input().split())))
data = np.asarray(data)
data = data[np.argsort(data[:, 0], axis=0)]

res = 0
for info in data:
  for i in range(info[1]):
    M -= 1
    res += info[0]
    if M==0:
      break
  if M==0:
    break
print(res)


Measured memory_bytes: 37880
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>
#include <tuple>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr r, l;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

constexpr int mx = 11;
std::vector<std::string> store;

void dfs(std::string now, int idx, bool begun) {
  if (idx == mx) {
    store.push_back(now);
    return;
  }
  for (char c = '0'; c <= '9'; ++c) {
    if (!begun) {
      now[idx] = c;
      dfs(now, idx + 1, c != '0');
    }
    else {
      if (std::abs(now[idx - 1] - c) <= 1) {
        now[idx] = c;
        dfs(now, idx + 1, true);
      }
    }
  }
}

int main() {
  dfs("00000000000", 1, false);
  int K;
  std::cin >> K;
  auto ans = store[K];
  int pos = 0;
  while (ans[pos] == '0') {
    ++pos;
  }
  std::cout << ans.substr(pos, ans.size() - pos) << '\n';
  return 0;
}


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

using namespace std;
vector <bool> a;
vector <int> s;
int main()
{
int n,m;
cin >> n >> m;
a.assign(n,false);
s.assign(n,0);

int ac=0,wa=0;
int id;
string now;
for (int i=0; i<m; i++)
{
    cin >> id >> now;
    id--;
    if (now=="WA") if (!a[id]) s[id]++;
    if (now=="AC") if (!a[id]){ ac++; a[id] = true; wa+=s[id];}

}
cout << ac << " " << wa;

}











Measured memory_bytes: 640
#include<stdio.h>
int main()
{
int a,b,c,k,i;

scanf("%d %d %d %d",&a,&b,&c,&k);
for(i=0;i<k;++i)
{
if(b<=a) b=b*2;
else if(c<=b) c=c*2;
}
if(a<b && b<c) printf("Yes"); 
else printf("No");
  
return 0;}

Measured memory_bytes: 1732
import Control.Monad
import Control.Applicative
import Data.List

toInt :: String -> Int
toInt x = read x :: Int
 
getInts = do
  x <- getLine
  let y = (map$toInt)$words x
  return y

area :: Int -> Int
area a = 3 * a * a

main :: IO()
main = do
  x <- getInts
  let r = head x :: Int
  print $ area r

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

using namespace std;

#define INF 1000007
#define MOD 1000000007
#define int long long int
#define maxn 100
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)

int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}

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

int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}

int counter(int x) //bit計算
{
    if (x == 0)
        return 0;
    return counter(x >> 1) + (x & 1);
}

vector<bool> prime(maxn + 1, true); //素数テーブル
void prime_table(void)
{
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i * i <= maxn; i++)
    {
        if (!prime[i])
        {
            continue;
        }
        for (int j = i + i; j <= maxn; j += j + i)
        {
            prime[j] = false;
        }
    }
}

bool IsPrime(int num) //素数判定
{
    if (num < 2)
        return false;
    else if (num == 2)
        return true;
    else if (num % 2 == 0)
        return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }

    return true;
}
vector<int> divisor(int n) //約数列挙
{
    vector<int> ret;
    for (int i = 1; i * i <= n; i++)
    {
        if (n % i == 0)
        {
            ret.push_back(i - 1);
            if (i * i != n)
            {
                ret.push_back((n / i) - 1);
            }
        }
    }
    sort(ret.begin(), ret.end());
    return (ret);
}
int max_n = 2001;
signed main()
{
    int a, b;
    cin>>a>>b;

    int i;
    for(i=1;i<=1000;i++){
        if(((int)(i*0.08)==a)&&((int)(i*0.1)==b)){
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}

Measured memory_bytes: 256
fn main(){
    let v:Vec<_> = getline().trim().split(' ').map(parse).collect();
    let vx = v[0] - v[2];
    let vy = v[1] - v[3];
    println!("{} {} {} {}", v[2] + vy, v[3] - vx, v[0] + vy, v[1] - vx);
}

fn parse(s: &str) -> i32 {
    s.parse::<i32>().unwrap()
}

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


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MP make_pair
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << '\n'; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
#else
  #define dbg(...)
#endif
void pt() {std::cout << '\n'; }
template<typename T, typename...Args>
void pt(T a, Args...args) {std::cout << a << ' '; pt(args...); }
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e6 + 15, MOD = 1e9 + 7;

int fac[N];

ll qpow(ll a, ll b) {
    ll ans = 1;
    while(b) {
        if(b & 1) ans = ans * a % MOD;
        a = a * a % MOD;
        b >>= 1;   
    }
    return ans;   
}

int C(int n, int m) {
    return 1ll * fac[n] * qpow(fac[n - m], MOD - 2) % MOD * qpow(fac[m], MOD - 2) % MOD;
}

void run(){
    fac[0] = 1;
    for(int i = 1; i < N; i++) fac[i] = 1ll * fac[i - 1] * i % MOD;
    int x, y;
    cin >> x >> y;
    if((x + y) % 3 != 0) {
        cout << 0;
        return;
    }
    int t = (x + y) / 3;
    if(y - t >= 0 && y - t <= t) {
        cout << C(t, y - t);
    } else cout << 0;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
	return 0;
}

Measured memory_bytes: 4224
import fractions
N=int(input())
A=list(map(int,input().split()))
ans=0  #更新用
#端っこの処理用
l=[0]*(N+1)
r=[0]*(N+1)
for i in range(N):
  l[i+1]=(fractions.gcd(l[i],A[i]))
  r[N-i-1]=(fractions.gcd(r[N-i],A[N-1-i]))
for j in range(N):
  ans=max(ans,fractions.gcd(l[j],r[j+1]))
print(ans)

Measured memory_bytes: 16136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

int main() {
    ll x, k, d; cin >> x >> k >> d;
    if (x<0) x *= -1ll;
    ll rem = x%d, rem2 = x%d-d;
    ll goal;
    if (abs(rem)<abs(rem2)) goal = rem;
    else goal = rem2;
    ll cnt = (x-goal)/d;
    if (k<cnt) cout << x-(k*d) << endl;
    else if ((k-cnt)%2==0) {
        cout << abs(goal) << endl;
    } else {
        if (goal==rem) cout << abs(rem2) << endl;
        else cout << abs(rem) << endl;
    }
}

Measured memory_bytes: 3596
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define MAX_N 5001


/* -----------------------------------------------------------------------------
	型とクラス定義
----------------------------------------------------------------------------- */

/* -----------------------------------------------------------------------------
	大域データ
----------------------------------------------------------------------------- */
int N;			// 文字列長
char 	s[MAX_N];	// 文字列
int		A[MAX_N];	// 共通接頭辞の長さの配列

// Z-algorithm
int ZA(char *s, int A[]);

int main () {

	int len = 0;

	// 個数の読込み
	scanf("%d %s", &N, s);
	
	for(int i = 0; i < strlen(s); i++) {
		ZA(s + i, A);
		for(int j = 1; j < strlen(s + i); j++)
			len =  std::max(len, std::min(A[j], j));
	}
	printf("%d\n", len);

	return 0;
}

// Z-algorithm
// S と S[i:N] の最長共通接頭辞の長さ
int ZA(char *s, int A[]) {
	A[0] = strlen(s);
	int i = 1, j = 0;
	while (i < strlen(s)) {
  		while (i+j < strlen(s) && s[j] == s[i+j]) ++j;
  		A[i] = j;
  		if (j == 0) { ++i; continue;}
  		int k = 1;
  		while (i+k < strlen(s) && k+A[k] < j) A[i+k] = A[k], ++k;
  		i += k; j -= k;
	}
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 100005;
const ll MOD = 1000000007;

int n;

vector<string> ans;
void dfs (string cur, char mx) {
    if (SZ(cur) == n) {
        ans.eb(cur);
    } else {
        cur += "a";
        for (char x='a';x<=mx+1; x++) {
            cur.back() = x;
            dfs(cur, max(mx, x));
        }

    }
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    cin >> n;

    dfs("a", 'a');
    debug(ans);

    for (auto s : ans) {
        cout << s << endl;
    }

}


Measured memory_bytes: 7796
#include<bits/stdc++.h>
 
using namespace std;
 
 
int main(){
 
  int n,c[256]={};
  string s;
  cin>>n>>s;
 
  for(int i=0;i<s.size();i++)
    c[s[i]]++;
 
  int cc[10]={},ans=0;
 
  for(int i='a';i<='z';i++)
    cc[c[i]]++;
 
  for(int i=1;i<=9;i++)
    if(i==1)ans+=cc[i]*2;
    else if(cc[i]>=2)ans+=cc[i]*2+4;
    else if(cc[i]==1)ans+=4;
  cout<<ans-1<<endl;
  return 0;
}

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

#define rep(i, n) for(int i=0; i<n; i++)

int N;
string s[22];
int hm[33];
int d[33];

inline int next(int c)
{
  int x = c & -c, y = c + x;
  return (((c & ~y) / x) >> 1) | y;
}

int main()
{
  while(cin >> N, N){
    rep(i, 33) hm[i] = 0;
    rep(i, 33) d[i] = 0;
    rep(i, N) cin >> s[i];
    rep(i, N){
      int pw = 1;
      rep(j, s[i].size()) pw *= 10;
      pw /= 10;
      rep(j, s[i].size()){
        if(i == N - 1) d[s[i][j] - 'A'] -= pw;
        else d[s[i][j] - 'A'] += pw;
        pw /= 10;
      }
    }

    vector<char> alpha;
    rep(i, N) rep(j, s[i].size()) alpha.push_back(s[i][j]);
    sort(alpha.begin(), alpha.end());
    alpha.erase(unique(alpha.begin(), alpha.end()), alpha.end());
    int n = alpha.size();
    int res = 0;
    for(int comb = (1 << n) - 1; comb < (1 << 10); comb = next(comb)){
      vector<int> can;
      rep(i, 10) if(comb & 1 << i) can.push_back(i);
      do{
        rep(i, n) hm[alpha[i] - 'A'] = can[i];
        bool ok = true;
        rep(i, N) if(hm[s[i][0] - 'A'] == 0 && s[i].size() != 1){ ok = false;  break; }
        if(!ok) continue;

        int sum = 0;
        rep(i, n) sum += hm[alpha[i] - 'A'] * d[alpha[i] - 'A'];
        if(sum == 0) res += 1;
      }while(next_permutation(can.begin(), can.end()));
    }

    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 1224
import math as m

A, B, H, M = map(int, input().split())
degreeH = H * 30 + M * 30 / 60
degreeM = 6 * M
degree = degreeH - degreeM
theta = m.radians(degree)

x2 = A ** 2 + B ** 2 - 2 * A * B * m.cos(theta)
ans = x2 ** 0.5
print(ans)


Measured memory_bytes: 9496
N=int(input())
Ln=list(map(int,input().split()))
Ln.sort(reverse=True)
Ans=0
left=0
right=0
 
for i in range(N-2):
    di=i+1
    for j in range(N-di-1):
        dj=di+j+1
        A=Ln[di-1]
        B=Ln[dj-1]
        if (B+Ln[dj])<A : break
 
        right=N-1
        left=dj
        while left<=right :
            mid=int((right+left)/2)
            if (B+Ln[mid])>A :
                left=mid+1
            else :
                right=mid-1
        Ans+=(left-1)-(dj-1)
 
print(Ans)

Measured memory_bytes: 43484
N = int(input())

n = 26
m = 1

while N > n:
    n = n * 26 + 26
    m += 1

e = n
result = ''

for i in range(m):
    a = N % 26
    if a == 0:
        a = 26
    result = chr(a + 96) + result
    N = (N - a) // 26

print(result)

Measured memory_bytes: 61580
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String op = sc.next();
		int b = sc.nextInt();
		int ans = op.equals("+") ? a + b : a - b;
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 21588
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  int a, b;
  cin >> a >> b;
  if (a % b) cout << a << '\n';
  else cout << -1 << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3592
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
#include<cmath>
#define LL long long
#define M 500
using namespace std;
int read(){
    int nm=0,fh=1; int cw=getchar();
    for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
    for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
    return nm*fh;
}
int n,m,e1,e2,h1,h2,cnt,in[M],ot[M],f[M]; bool vs[M];
int fd(int x){return x==f[x]?x:f[x]=fd(f[x]);}
int main(){
    n=read(),m=read();
    for(int i=1;i<=m;i++) f[i]=i,f[i+m]=i+m,vs[i]=vs[i+m]=false;
    for(int i=1;i<=n;i++){
        h1=read(),h2=read(),e1=read(),e2=read();
        int t1=e1>0?e1:-h1,t2=e2>0?-e2:h2; t1+=m,t2+=m;
        if(fd(t1)!=fd(t2)) f[fd(t1)]=fd(t2); in[t2]++,ot[t1]++;
    }
    for(int i=-m;i<0;i++) if(in[i+m]>ot[i+m]){puts("NO");return 0;}
    for(int i=1;i<=m;i++) if(in[i+m]<ot[i+m]){puts("NO");return 0;}
    for(int i=0;i<=m+m;i++) if(in[i]!=ot[i]) vs[fd(i)]=true;
    for(int i=0;i<=m+m;i++) if(in[i]&&ot[i]&&!vs[fd(i)]){puts("NO");return 0;}
    puts("YES"); return 0;
}

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

int main()
{
    struct Tbl {
        int rank;
        int bottom;
        int top;
    };

    Tbl tbl[8] = {
        {8, 400,   599},
        {7, 600,   799},
        {6, 800,   999},
        {5, 1000, 1199},
        {4, 1200, 1399},
        {3, 1400, 1599},
        {2, 1600, 1799},
        {1, 1800, 1999},
    };

    int X; cin >> X;

    for (auto& r : tbl)
    {
        if ((r.bottom <= X) && (X <= r.top))
        {
            cout << r.rank << endl;
            return 0;
        }
    }

    return 1;
}


Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length(), total = 0;
    for(int i=0;i<n;++i) {
        total += int(s[i] - '0');
    }
    cout << ((total % 9 == 0) ? "Yes" : "No") << endl;
}


Measured memory_bytes: 3724
#include<stdio.h>
int main()
{
	char s[16];
	int a,b,i;
	for(i=0;i<9;i++){
		scanf("%s%d%d",s,&a,&b);
		printf("%s %d %d\n",s,a+b,a*200+b*300);
	}
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
  int a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b){
        if(b<c){
            puts("Yes");
        }
        else{
            puts("No");
        }
    }
    else{
        puts("No");
    }

  return 0;
}


Measured memory_bytes: 2040
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cstdlib>
#include <cmath>
#include<stdio.h>
#include<queue>
#include<stack>
#include<set>
#define MAX 1000000000000000000LL
long long inf=1000000007;
using namespace std;
int main(){
    int n;cin>>n;
    int a=0,b=0,c=0;
    int num;
    for(int i=0; i<n; i++){
        cin>>num;
        if(num%4==0)b++;
        else if(num%2==0)a++;
        else c++;
    }
    if(a==0&&c-1<=b)cout<<"Yes"<<endl;
    else if(c<=b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
def nCr(n,r):
    a=1
    x=n
    while(x!=n-r):
      a*=x
      x-=1
    b=1
    x=r
    while(x!=0):
      b*=x
      x-=1
    return a//b

INF=10**9+7
N,m=map(int,input().split())


sum=1
yd = {}
i = 2
while m != 1:
  while m % i == 0:
    if i in yd:
      yd[i] += 1
    else:
      yd[i] = 1
    m //= i
  i += 1
for b in yd.values():
    if b<N-1:
        sum*=nCr(N-1+b,b)
    else:
        sum*=nCr(N-1+b,N-1)
    sum%=INF  
print(sum)


Measured memory_bytes: 40044
#include "bits/stdc++.h"
using namespace std;
#define int long long
#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 REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}
void _OUT() {}; template<class H, class... T> void _OUT(H &h, T &... t) { cout<<' '<<h; _OUT(t...); };
template<class H, class... T> void _P(H &h, T &... t) { cout<<h; _OUT(t...); };
#define _PN(...) _P(__VA_ARGS__); cout << endl;
#define EXEC(...) void exec() { (__VA_ARGS__ - 1) ? multi() : solve(0); }

void exec();
void solve(int t);
void multi() { int TT; cin>>TT; REP1(t,TT) solve(t); }
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    exec();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 10
#else
#define SIZE 223450
#endif

int N,M,S,T;
vector<pair<int,int>> E[SIZE],F[SIZE];

void solve(int _t) {
    cin>>N>>M>>S>>T;
    S--;T--;
    int u,v,a,b;
    REP(i,M) {
        cin>>u>>v>>a>>b;
        u--;v--;
        E[u].push_back({v,a});
        E[v].push_back({u,a});
        F[u].push_back({v,b});
        F[v].push_back({u,b});
    }
    vector<int> DP1(SIZE,LONG_LONG_MAX/2), DP2(SIZE,LONG_LONG_MAX/2);
    priority_queue<pair<int,int>> que;
    que.push({0,S});
    DP1[S]=0;
    while(que.size()) {
        auto [c,i] = que.top();
        c *= -1;
        que.pop();
        for (auto [t,cost]:E[i]) {
            int nc = c+cost;
            if (chmin(DP1[t], nc)) {
                que.push({-nc,t});
            }
        }
    }
    que.push({0,T});
    DP2[T]=0;
    while(que.size()) {
        auto [c,i] = que.top();
        c *= -1;
        que.pop();
        for (auto [t,cost]:F[i]) {
            int nc = c+cost;
            if (chmin(DP2[t], nc)) {
                que.push({-nc,t});
            }
        }
    }
    int ans = LONG_LONG_MAX/2;
    vector<int> ansv;
    RREP(i,N) {
        chmin(ans, DP1[i]+DP2[i]);
        ansv.push_back(ans);
    }
    int base = 1e15;
    RREP(i,N) {
        out("%lld\n",base-ansv[i]);
    }
}
EXEC(1)



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

int main() {
  long long n,w = 10,s = 0;
  cin >> n;
  while(w <= 10000000000){
    s += (n%w)/(w/10);
    w = w*10;
  }
  if(n%s == 0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}


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


int main(){
  int n;
  cin>>n;
  int a=0;
  lp(i,n){
    string s;
    cin>>s;
    if(s=="A"){
      a++;
    }
    else{
      a--;
      if(a<0){
        cout<<"NO"<<endl;
        return 0;
      }
    }
  }
  if(a==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}



Measured memory_bytes: 3120
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main { 

	public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int inputScore = Integer.parseInt(sc.nextLine());
    	String inputNumber = sc.nextLine();
    	
    	String result = "";
    	if(inputScore >= 3200) {
    		result = inputNumber;
    	}else {
    		result = "red";
    	}

    	
    	System.out.println(result);
    }
}

Measured memory_bytes: 21716
import sys
N = int(input())
array_word = [ input() for word in range(N) ]

before = array_word[0]
for I in array_word[1:]:
    if before[-1] == I[0] and array_word.count(I) == 1:
        before = I
        continue 
    else:
        print('No')
        sys.exit()
print('Yes')

Measured memory_bytes: 9100
from collections import defaultdict

N,M=map(int,input().split())
d=defaultdict(set)
for i in range(M):
    a,b=map(int,input().split())
    d[a].add(b)
    d[b].add(a)

for i in d[1]:
    if N in d[i]:
        print("POSSIBLE")
        exit()
print("IMPOSSIBLE")

Measured memory_bytes: 123608
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())





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

	int n;
	int k;
	int v[50];

	cin >> n >> k;
	rep(i, n)cin >> v[i];

	int ans = 0;

	for (int i = -1; i < n; i++) {
		for (int j = i + 1; j <= n; j++) {
			int rem = k - (i + 1 + n - j);
			if (rem < 0)continue;

			multiset<int> s;
			for (int x = 0; x <= i; x++)s.insert(v[x]);
			for (int x = j; x < n; x++)s.insert(v[x]);


			while (rem && !s.empty() && *s.begin() < 0) {
				s.erase(s.begin());
				rem--;
			}
			int sum = 0;
			for (int x : s) {
				sum += x;
			}
			ans = max(ans, sum);
		}
	}
	cout << ans << endl;



	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007LL;
const int INF = LLONG_MAX;

signed main(){

    int N;
    cin >> N;

    vector<int> dp(N + 1, INF);
    // 初期化
    dp[0] = 0;

    // 配る DP --- dp[n] から遷移を出して行く
    for (int n = 0; n < N; ++n) {
        for (int pow6 = 1; n + pow6 <= N; pow6 *= 6) {
            dp[n + pow6] = min(dp[n + pow6], dp[n] + 1);
        }
        for (int pow9 = 1; n + pow9 <= N; pow9 *= 9) {
            dp[n + pow9] = min(dp[n + pow9], dp[n] + 1);
        }
    }

    cout << dp[N] << endl;

    return 0;
}

Measured memory_bytes: 1024