akhauriyash/Code-Regression huggingface dataset:
import numpy as np
import numba


@numba.njit
def count(a_arr, bar):
    # <= bar
    res_arr = ((a_arr - 1) // bar)
    new_bar = (a_arr / (res_arr + 1)).max()
    return res_arr.sum(), np.int(np.ceil(new_bar))


def solve(n, k, a_arr):
    left_bar = ((a_arr - 1) // (k + 1)).min()
    right_bar = a_arr.max()
    while True:
        mid_bar = (left_bar + right_bar) // 2
        # print(left_bar, right_bar, mid_bar)
        m, mid_bar_new = count(a_arr, mid_bar)

        if m > k:
            left_bar = mid_bar
        else:
            right_bar = mid_bar_new

        if left_bar > right_bar - 2:
            break
    return right_bar


def main():
    n_, k_ = map(int, input().split())
    n = np.int32(n_)
    k = np.int32(k_)
    a_arr = np.array(list(map(int, input().split())), dtype=np.int32)
    res = solve(n, k, a_arr)
    print(res)


def test():
    assert solve(2, 3, np.array([7, 9])) == 4
    assert solve(3, 0, np.array([3, 4, 5])) == 5
    assert solve(10, 10, np.array([
        158260522, 877914575, 602436426, 24979445, 861648772,
        623690081, 433933447, 476190629, 262703497, 211047202
    ])) == 292638192


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 138496
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <iostream>
#include <vector>
#include <queue>
#include <unordered_map>
#include <random>
#include <stack>
#include <set>
#include <unordered_set>

#define bug(x) cout<<"zdongdebug1: "<<x<<endl;
#define bug2(x, y) cout<<"zdongdebug2: "<<x<<" "<<y<<endl;
#define bug3(x, y, z) cout<<"zdongdebug3: "<<x<<" "<<y<<" "<<z<<endl;
using namespace std;
typedef long long ll;
const int maxn = 200005;
const int mod = 1000000007;

ll gcd(ll x, ll y){
  if(y==0)return x;
  return gcd(y, x % y);
}

ll p[maxn];

int main() {
#ifdef suiyuan2009
  freopen("/Users/suiyuan2009/CLionProjects/icpc/input.txt", "r", stdin);
  //freopen("/Users/suiyuan2009/CLionProjects/icpc/output.txt", "w", stdout);
#endif
  int n;
  cin>>n;
  p[0] = 1;
  for(int i=1;i<=n;i++)p[i] = p[i-1]*2%mod;
  map<pair<ll,ll>, int> mp;
  for(int i=0;i<n;i++){
    ll x,y;
    cin>>x>>y;
    if(x==0) {
      if(y!=0){
        y = 1;
      }
    } else{
      if(y==0){
        x = 1;
      } else {
        ll tt = gcd(abs(x), abs(y));
        x/=tt, y/=tt;
        if(x<0){
          x = -x;
          y = -y;
        }
      }
    }
    mp[make_pair(x,y)]++;
  }
  ll ret = 1;
  set<pair<ll,ll>>vis;
  for(auto pr: mp){
    //bug2(pr.first.first, pr.first.second)
    if(pr.first == make_pair(0LL, 0LL)) {
      continue;
    }
    if(vis.find(pr.first)!=vis.end())continue;
    auto tt = pr.first;
    vis.insert(pr.first);
    auto tt2 = make_pair(tt.second, -tt.first);
    if(tt2.first < 0){
      tt2.first = -tt2.first;
      tt2.second = -tt2.second;
    }
    if(mp.find(tt2)==mp.end()) {
      //bug(pr.second)
      ret = ret *  p[pr.second] % mod;
    } else {
      //bug2(pr.second, mp[tt2])
      ret = ret * (p[pr.second] + p[mp[tt2]] + mod - 1)%mod;
      vis.insert(tt2);
    }
  }
  ret = (ret + mod - 1)%mod;
  if(mp[make_pair(0LL, 0LL)]){
    ret = (ret + mp[make_pair(0LL, 0LL)])%mod;
  }
  cout<<ret<<endl;
  return 0;
}

Measured memory_bytes: 30180
#include <bits/stdc++.h>
#define INF 2147483647
#define INF_LL 9223372036854775807
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	int N;
	cin >> N;
	vector < pair < ll, pair < ll, ll > > > info(N);
	for (int i = 0; i < N; i++) {
		cin >> info[i].second.first >> info[i].second.second >> info[i].first;
	}
	sort(info.begin(), info.end());
	reverse(info.begin(), info.end());
	if (N == 1) {
		cout << info[0].second.first << " " << info[0].second.second << " " << info[0].first << endl;
		return 0;
	}
	for (int i = 0; i <= 100; i++)for (int j = 0; j <= 100; j++) { //中心がi,jであるとき条件を満たすか確認
		bool flag = false;
		ll H = info[0].first + abs(info[0].second.first - i) + abs(info[0].second.second - j); // 最高高度の候補を決めておく
		if (H <= 0)continue;
		for (int k = 1; k < N; k++) {
			if (info[k].first != max(H - abs(info[k].second.first - i) - abs(info[k].second.second - j),0LL)) {
				break;
			}
			if (k == N - 1) flag = true;
		}
		if (flag) {
			cout << i << " " << j <<  " " << H << endl;
			return 0;
		}
	}
	return 0;
}

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

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

    int n, m;
    cin >> n >> m;

    int ans = n * (n - 1) / 2 + m * (m - 1) / 2;
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    md = 998244353
    n = int(input())
    x = input()
    dd = []
    for d0 in range(1, n + 1):
        if n % d0 == 0:
            d1 = n // d0
            if d0 % 2: dd += [d0]
            if d1 % 2: dd += [d1]
        if d0 ** 2 >= n: break
    if len(dd) > 1 and dd[-1] == dd[-2]:
        del dd[-1]
    dd.sort(reverse=True)
    pp = []
    ori = int(x, 2)
    for i, d in enumerate(dd):
        k = n // d
        a = x[:k]
        pp += [int(a, 2)]
        na = "".join("0" if c == "1" else "1" for c in a)
        cor = int((a + na) * (d // 2) + a, 2)
        if cor <= ori: pp[-1] += 1
        for j in range(i):
            dj = dd[j]
            if dj % d == 0:
                pp[i] -= pp[j]
    # print(dd)
    # print(pp)
    ans = 0
    for d, p in zip(dd, pp):
        k = n // d
        ans = (ans + 2 * k * p) % md
    print(ans)

main()


Measured memory_bytes: 5736
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<string>
#include<string.h>
#include<vector>
#include<map>
#include<math.h>
using namespace std;

#define ll long long

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

template<class S, class T> inline void chmax(S &a, T b){ if (a < b)a = b; }
template<class S, class T> inline void chmin(S &a, T b){ if (a > b)a = b; }

int main(){
	int ans(0);
	int N;
	cin >> N;
	vector<int> a(N);
	for (int i = 0; i < N; i++){
		cin >> a[i];
	}
	int min(100000000);
	for (int i = -100; i <= 100; i++){
		int temp(0);
		for (int j = 0; j < N; j++){
			temp += (a[j] - i)*(a[j] - i);
		}
		chmin(min,temp);
	}
	cout << min << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P  = pair<int, int>;
int main() {
    string s;
    cin >> s;
    int a, b, c, d;
    a = s[0] - '0';
    b = s[1] - '0';
    c = s[2] - '0';
    d = s[3] - '0';
    for (int op = 0; op < 8;++op){
        int ev = a;
        ev += (op & 1 ? b : -b);
        ev += (op & 2 ? c : -c);
        ev += (op & 4 ? d : -d);
        if(ev==7){
            cout << a << (op & 1 ? "+" : "-") << b << (op & 2 ? "+" : "-") << c
                 << (op & 4 ? "+" : "-") << d << "=7";
            exit(0);
        }
    }
    return 0;
}

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

int main(void){
  int n, m;
  cin >> n >> m;
  vector<int> c(m);
  vector<int> dp(n+1);
  for(int i=0; i < m; i++)
    cin >> c[i];
  
  for(int i=0; i <= n; i++)
    dp[i] = INT_MAX/2;

  dp[0] = 0;

  for(int p = 0; p < m; p++){
    for(int q=c[p]; q <= n; q++){
      dp[q] = min(dp[q], dp[q-c[p]] + 1);
    }
  }
  cout << dp[n] << endl;
  return 0;
}

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


using namespace std;

map <long long, char> mp;

inline char check(long long x) {
     cout << "?" << " " << x << endl;
    // fflush(stdout);
     char ch;
     cin >> ch;
     return ch;
}

int main() {
  //  fstream cin("B.in");
  //  ofstream cout("B.out");
    int rez, pas, i;
    ios::sync_with_stdio(false);
    long long x;
    if(check(1e9) == 'Y') {
        x = 2;
        while(check(x) == 'N')
            x *= 10;
        cout << "!" << " " << x / 2 << endl;
        return 0;
    }
    x = 1;
    int sz = 1;
    while(check(x) == 'Y') {
        x = x * 10;
        sz++;
    }
    sz--;
    x = 0;
    for(i = 1; i < sz; i++) {
        rez = 0;
        for(pas = 1 << 3; pas; pas >>= 1)
          if(rez + pas < 10)
              if(check(x * 10 + rez + pas) == 'Y')
                 rez += pas;
        x = x * 10 + rez;
    }
    rez = -1;
    for(pas = 1 << 3; pas; pas >>= 1)
       if(rez + pas < 10 && check(x * 100 + (rez + pas) * 10) == 'N')
           rez += pas;
    cout << "!" << " " << x * 10 + (rez + 1) << endl;
  //  cin.close();
  //  cout.close();
    return 0;
}


Measured memory_bytes: 596
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef pair<int,int>pii;

const int pps=1e9+7;

int n,m,ans;
vector<pii>q[305];
int f[305][305][305];
vector<pii>::iterator it;

int read() {
	int x=0,f=1;char ch=getchar();
	for(;ch<'0'||ch>'9';ch=getchar())if(ch=='-')f=-1;
	for(;ch>='0'&&ch<='9';ch=getchar())x=x*10+ch-'0';
	return x*f;
}

int main() {
	n=read(),m=read();
	for(int i=1;i<=m;i++) {
		int l=read(),r=read(),x=read();
		q[r].push_back(make_pair(l,x));
	}f[0][0][0]=1;
	for(int i=1;i<=n;i++) {
		for(int j=0;j<i;j++)
			for(int k=0;k<=j;k++) {
				f[i][j][k]=(f[i][j][k]+f[i-1][j][k])%pps;
				f[i][i-1][k]=(f[i][i-1][k]+f[i-1][j][k])%pps;
				f[i][i-1][j]=(f[i][i-1][j]+f[i-1][j][k])%pps;
				for(it=q[i].begin();it!=q[i].end();it++) {
					int tmp=(j>=(*it).first)+(k>=(*it).first)+1;
					if(tmp!=(*it).second)f[i][j][k]=0;
				}
			}
	}
	for(int i=0;i<n;i++)
		for(int j=0;j<=i;j++)
			ans=(ans+f[n][i][j])%pps;
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 108928
N = int(input())
c = [[0]*10 for _ in range(10)]
for k in range(1,N+1):
    tmp = str(k)
    i = int(tmp[0])
    j = int(tmp[-1])
    c[i][j] += 1
ans = 0
for i in range(10):
    for j in range(10):
        ans += c[i][j] * c[j][i]
print(ans)

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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

int main() {
  // std::cout << std::fixed << std::setprecision(10);
  priority_queue<int, vector<int>, less<int>> q;
  ll N, M;
  scanf("%lld %lld", &N, &M);

  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    q.push(v);
  }

  for (ll i = 0; i < M; i++) {
    ll p = q.top();
    q.pop();

    q.push((p / 2));
  }

  ll ans = 0;
  for (;;) {
    if (q.size() == 0) {
      break;
    }
    ll p = q.top();
    ans += p;
    q.pop();
  }
  cout << ans << endl;
}


Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC146A
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var S = NS;
            if (S == "SUN") Console.WriteLine(7);
            else if (S == "MON") Console.WriteLine(6);
            else if (S == "TUE") Console.WriteLine(5);
            else if (S == "WED") Console.WriteLine(4);
            else if (S == "THU") Console.WriteLine(3);
            else if (S == "FRI") Console.WriteLine(2);
            else Console.WriteLine(1);
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 14688
#include <iostream>
#include <map>

using namespace std;

int main() {
	int A, B, K;
	map<int, bool> table;

	cin >> A >> B >> K;

	for (int i = 0; i < K; i++) {
		if (A+i <= B) table[A+i] = true;
		if (B-i >= A) table[B-i] = true;
	}

	for (auto itr = table.begin(); itr != table.end(); itr++) {
		cout << itr->first << "\n";
	}
	cout << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N; cin >> N; 
	pair<int, int> A[100010] = {}; 
	for(int i = 0; i < N; i++){
		cin >> A[i].first; A[i].second = i + 1; 
	} 
	sort(A, A+N); 
	for(int i = 0; i < N; i++){
		cout << A[i].second << " "; 
	}
	cout << endl; 
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1000000007;
constexpr ll INF = 1ll<<60;

int main(int argc, char **argv)
{
	ll N; cin >> N;
	vector<ll> A(N);
	for (ll i = 0; i < N; ++i) cin >> A[i];
	sort(A.begin(), A.end(), greater<ll>());

	vector<ll> rec;
	for (ll i = 0; i < N;)
	{
		if (rec.size() >= 2) break;
		ll j = i+1;
		while (j < N && A[i] == A[j]) {++j;}
		for (ll k = 0; k < (j-i)/2; ++k)
			rec.push_back(A[i]);
		i = j;
	}

	if (rec.size() < 2)
		std::cout << 0 << std::endl;
	else
		std::cout << rec[0] * rec[1] << std::endl;
	
}


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

using namespace std;
using llint = long long;

int Q, H, S, D;
int N;

int main() {
  scanf("%d%d%d%d", &Q, &H, &S, &D);
  scanf("%d", &N);
  H = min(2 * Q, H);
  S = min(2 * H, S);
  D = min(2 * S, D);
  llint t = N;
  printf("%lld\n", t / 2 * D + t % 2 * S);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <math.h>
#include <cmath>
#include <ctime>
#include <stdlib.h>


using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#pragma once
typedef pair<int, int> P;
typedef long double ld;
typedef long long ll;

const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
long long modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

bool chmax(int& xx, int yy) {
	if (xx < yy) {
		xx = yy;
		return true;
	}
	return false;
}
bool chmin(int& xx, int yy) {
	if (xx > yy) {
		xx = yy;
		return true;
	}
	return false;
}
double dist(int x, int y) {
	return sqrt(x * x + y * y);
}
double dist(int xx1, int xx2, int yy1, int yy2) {
	return sqrt(abs(xx1 - xx2) * abs(xx1 - xx2) + abs(yy1 - yy2) * abs(yy1 - yy2));
}
ll mypow(int nn, int kk) {
	ll xx = 1;
	rep(i, kk) {
		xx *= nn;
	}
	return xx;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n,a=1;
	string s;
	cin >> n;
	while (n > mypow(26, a)) {
		n -= mypow(26, a);
		a++;
	}
	n--;
	rep(i, a) {
		s = (char)(n % 26 + 'a') + s;
		n /= 26;
	}
	cout << s << endl;
}

Measured memory_bytes: 3724
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new Scanner(System.in);
		while(true){
			int x=in.nextInt();
			int y=in.nextInt();
			if(x==0 && y==0)
				break;
			if(x<y)
				System.out.println(x+" "+y);
			else
				System.out.println(y+" "+x);
		}
	}
}

Measured memory_bytes: 35080
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, s, n) for (int i = s; i < (int)(n); i++)
#define out(x) cout << x << endl
#define INF 1000000;
#include <map>
#include <math.h>
 
using ll = long long;
using namespace std;

ll n, k;
const ll mod = 1000000007;

int main(){
   int a, b;
   cin >> a >> b;

   if(a+b>=10) out("error");
   else out(a+b);

}


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

using ll = long long;
const ll amari = 1e9+7;
const char BC = 'A' - 'a';
#define ben(a) a.begin(),a.end()
#define pb(a,b) a.push_back(b)

int main(){
	int n,k;
	cin >> n >> k;
	ll ans = k;
	for(int i = 0; i < n - 1; i++){
		ans *= k - 1;
	}
	cout << ans << endl;
	return 0; 
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
	"sort"
)

func main() {
	n, w := scInt2()
	wlist, vlist := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		wlist[i], vlist[i] = scInt2()
	}

	// DPテーブルの初期化
	// dp[i][sumV] := i-1 番目までの品物から価値が sumV 以上を達成するように選んだときの、重さの総和の最小値
	// vi <= 10**3, N<=100なので 100001 あれば十分
	// 重さの最小を求めるので、infで初期化する
	dp := make([][]int, n+1)
	inf := math.MaxInt32
	maxV := 100001
	for i := 0; i < n+1; i++ {
		// 重さの範囲内でテーブルを作る
		values := make([]int, maxV)
		for j := 0; j < maxV; j++ {
			values[j] = inf
		}
		dp[i] = values
	}

	// 初期条件
	dp[0][0] = 0

	for i := 0; i < n; i++ {
		// i番目の商品の重さごとの価値を確認する
		for sumV := 0; sumV < maxV; sumV++ {
			// i番目の商品を選択できる場合
			if sumV-vlist[i] >= 0 {
				// i番目の商品を選択する場合
				nw := dp[i][sumV-vlist[i]] + wlist[i]
				dp[i+1][sumV] = min(dp[i+1][sumV], nw)
			}
			dp[i+1][sumV] = min(dp[i+1][sumV], dp[i][sumV])
		}
	}
	ans := 0
	for sumV := 0; sumV < maxV; sumV++ {
		if dp[n][sumV] <= w {
			ans = sumV
		}
	}
	fmt.Println(ans)
}

func scStr() string {
	var s string
	fmt.Scan(&s)
	return s
}

func scInt() int {
	var x int
	fmt.Scan(&x)
	return x
}

func scInt2() (int, int) {
	var x, y int
	fmt.Scan(&x, &y)
	return x, y
}

func scInt3() (int, int, int) {
	var x, y, z int
	fmt.Scan(&x, &y, &z)
	return x, y, z
}

func scInts(n int) (slice []int) {
	slice = make([]int, n)
	for i := range slice {
		fmt.Scan(&slice[i])
	}
	return slice
}

func hw(h int, w int, init int) [][]int {
	hw := make([][]int, h)
	for i := 0; i < h; i++ {
		hw[i] = make([]int, w)
		for j := 0; j < w; j++ {
			hw[i][j] = init
		}
	}
	return hw
}

func sum(slice []int) (sum int) {
	sum = 0
	for i := range slice {
		sum += slice[i]
	}
	return
}

func uniqueInts(ints []int) (unique []int) {
	m := map[int]bool{}
	for _, v := range ints {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func uniqueStrs(strs []string) (unique []string) {
	m := map[string]bool{}
	for _, v := range strs {
		if !m[v] {
			m[v] = true
			unique = append(unique, v)
		}
	}
	return unique
}

func min(x, y int) int {
	if x > y {
		return y
	}
	return x
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func minInts(ints []int) int {
	sort.Ints(ints)
	return ints[0]
}

func maxInts(ints []int) int {
	sort.Ints(ints)
	n := len(ints)
	return ints[n-1]
}

func powi(x, pow int) int {
	return int(math.Pow(float64(x), float64(pow)))
}


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

using namespace std;

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

  string s;
  cin >> s;
  int sz = s.size();
  int res = 0;
  for (int i = 1; i < sz; ++i) {
    if ((sz-i)%2 > 0) continue;
    bool ok = true;
    for(int j = 0; j < (sz-i)/2; ++j) {
      if (s[j] != s[j+(sz-i)/2]) {
        ok = false;
        break;
      }
    }
    if (ok) {
      res = sz-i;
      break;
    }
  }
  cout << res << endl;

  return 0;
}



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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
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; }
const ll MOD = 1e9+7;

ll memo[200100];
ll N;
ll H[200100];
ll A[200100];
int X[200100];

class SegmentTree{
    int n;
    vector<ll> node;
    
    public:
    SegmentTree(vector<ll> v){
        int sz = v.size();
        n = 1;
        while(n < sz) n *= 2;
        node.resize(2*n-1);

        for(int i = 0; i < sz; i++)
            node[i+n-1] = v[i];
        for(int i = 0; i < n; i++)
            node[i] = max(node[2*i+1], node[2*i+2]);
    }

    void update(int x, ll val){
        x = x + n - 1;
        node[x] = val;

        while(x > 0){
            x = (x-1) / 2;
            node[x] = max(node[2*x+1], node[2*x+2]);
        }
    }

    //[a, b)
    ll getmax(int a, int b, int k=0, int left=0, int right=-1){
        if(right < 0)
            right = n;

        if(right <= a || b <= left)
            return 0;

        if(right <= b && a <= left)
            return node[k];

        ll lv = getmax(a, b, 2*k+1, left, (left+right)/2);
        ll rv = getmax(a, b, 2*k+2, (left+right)/2, right);
        return max(lv, rv);
    }

};

int main(){
    cin >> N;
    REP(i,N){
        ll h;
        cin >> h;
        h--;
        H[i] = h;
        X[h] = i;
    }
    REP(i,N){
        ll a;
        cin >> a;
        A[i] = a;
    }

    vector<ll> memo(N, 0);
    SegmentTree tree(memo);

    ll ans = 0;
    for(int i = N-1; i >= 0; i--){
        int idx = X[i];
        ll tmp = tree.getmax(idx+1, N);
        tmp += A[idx];
        tree.update(idx, tmp);
        chmax(ans, tmp);
        //printf("%d %lld %lld %lld\n", idx, H[idx]+1, tmp, ans);
    }

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


Measured memory_bytes: 11520
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define P pair<int,int>
#define pb push_back
int main(){
	int n,k;
	cin>>n>>k;
	double pos=0;
	for(int i=1;i<n+1;i++){
		int j=i;
		double p=1;
		while(j<k){
			j*=2;
			p/=2;
		}
		pos+=p;
	}
	pos/=n;
	cout<<setprecision(20)<<pos<<endl;
}


Measured memory_bytes: 3744
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1LL << 60;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

ll mod = 998244353;
string X;
int N;

vector<ll>dv;
vector<ll>dv2;
void divisor(ll n) {
	for (ll i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			if (i == n / i) {
				dv.push_back(i);
			}
			else {
				dv.push_back(i);
				dv.push_back(n / i);
			}
		}
	}
}

ll modnum(string S) {
	ll cur = 1;
	ll ret = 0;
	reverse(all(S));
	for (int i = 0; i < S.size(); i++) {
		if (S[i] - '0' == 1)ret += cur;
		cur *= 2;
		cur %= mod;
		ret %= mod;
	}
	return ret;
}

ll F(ll d) {
	string Xtemp;
	int len = N / d;
	for (int i = 0; i < len; i++)Xtemp += X[i];
	ll ret = modnum(Xtemp);
	string Xcomp;
	for (int i = 0; i < N; i++) {
		if ((i / len) % 2 == 0) {
			if (X[i%len] == '0')Xcomp += '0';
			else Xcomp += '1';
		}
		else {
			if (X[i%len] == '1')Xcomp += '0';
			else Xcomp += '1';
		}
	}


	int ok = 0;
	vector<string>dic;
	dic.pb(Xcomp);
	dic.pb(X);
	sort(all(dic));
	if (dic[0] == Xcomp)ok = 1;
	ret += ok;
	return ret;
}

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

	cin >> N >> X;
	divisor(N);
	fore(x, dv)if (x % 2)dv2.pb(x);
	sort(all(dv2));


	vector<ll>cnt;
	fore(x, dv2)cnt.pb(F(x));

	int D = dv2.size();
	for (int i = D - 1; i >= 0; i--) {
		for (int j = 0; j < i; j++) {
			if (dv2[i] % dv2[j] == 0) {
				cnt[j] -= cnt[i];
				cnt[j] += mod;
				cnt[j] %= mod;
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i < D; i++) {
		ll len = N / dv2[i];
		ans += len*cnt[i];
		ans %= mod;
	}
	ans *= 2LL;
	puts(ans%mod);


	return 0;
}

Measured memory_bytes: 1292
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      String[] nyu=sc.nextLine().split("");
//     String nyu=sc.nextLine();

HashSet<String> list=new HashSet<>();

for(String temp:nyu)
list.add(temp);

if(list.size()!=2){
System.out.println("No");

}else{
int count=0;
for(int i=0;i<4;i++){
if(nyu[0].equals(nyu[i]))count++;
}

if(count==2){
System.out.println("Yes");

}else{
System.out.println("No");

}
}

//int num=Integer.parseInt(nyu);
//int numnext=Integer.parseInt(nyu[1]);
//int numend=Integer.parseInt(nyu[2]);

//System.out.println(numend);

//System.out.println(a/b);


	}
}

Measured memory_bytes: 23124
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>

typedef struct node *link;
struct node { 
    int item;
    link next;
};
static link head;

void Stackinit (int maxN) { head = NULL; }
int Stackenpty (void) { return head == NULL; }
int Stackpop (void) {
    int item = head->item;
    link t = head->next;
    free(head);
    head = t;
    return item;
}
link NEW(int item, link next) {
    link x = malloc(sizeof *x);
    x->item = item;
    x->next = next;
    return x;
}
void Stackpush (int item) {
    head = NEW(item, head);
}

int main(void) {
    int result = 0, x1, x2;
    char s[11];
    Stackinit(1000);
    while (scanf(" %10s", s) != EOF) {
        if (s[0] == '+') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 + x1);
        } else if (s[0] == '-') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 - x1);
        } else if (s[0] == '*') {
            x1 = Stackpop();
            x2 = Stackpop();
            Stackpush(x2 * x1);
        } else if (isdigit(s[0])){
            x1 = (int) strtol(s, NULL, 10);
            Stackpush(x1);
        } else break;
    }
    result = Stackpop();
    printf("%d\n", result);
    return 0;
}

Measured memory_bytes: 1832
N=int(input())
A=[0]*N
B=[0]*N
for i in range(N):
    A[i],B[i]=map(int,input().split())

A.sort()
B.sort()

if N%2==1:
    print(abs(A[N//2]-B[N//2])+1)
else:
    print(abs(A[N//2]+A[N//2-1]-B[N//2]-B[N//2-1])+1)

Measured memory_bytes: 25348
/*  ex9_2
    pptenshi  */

#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define SIZE 100000


typedef struct stack {
    char elem;
    struct stack *next;
}stack;


void push(stack **first, char elem)  {
    stack *new = calloc(1, sizeof(stack));
    if (new == NULL) exit(1);

    new->elem = elem;
    new->next = *first;
    *first = new;
}


char pop(stack **first) {
    char elem;
    stack *tmp = *first;

    if (tmp == NULL) exit(1);

    elem = tmp->elem;
    *first = tmp->next;
    free(tmp);
    return elem;
}


int main(void) {
    char string[SIZE];    // S
    int len_string;       // N
    int num_remove = 0;   // 取り除く数
    stack *first = NULL;  // キューブを積むスタック


    // input 
    scanf("%s", string);
    len_string = strlen(string);

    
    // calculate
    for (int i = 0; i < len_string; i++) {
        
        // スタックに要素がない場合
        if (first == NULL) {
            push(&first, string[i]);
            continue;
        }

        // スタックの先頭と積み木のi番目を比較
        char first_elem = first->elem;
        if (first_elem != string[i]) {
            // 異なる場合は先頭を削除しカウント
            pop(&first);
            num_remove += 2;
        } else {
            // 同じ場合は追加
            push(&first, string[i]);
        }

    }


    // output
    printf("%d\n", num_remove);

    return 0;
}


Measured memory_bytes: 4836
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var stdin = bufio.NewScanner(os.Stdin)

func main() {
	arr := scanArrayInt()
	a, b, c := arr[0], arr[1], arr[2]
	for i := 1; i <= b; i++ {
		d := a * i % b
		if d == c {
			fmt.Println("YES")
			return
		}
	}
	fmt.Println("NO")
}
func scanArrayInt() []int {
	var ret = []int{}
	stdin.Scan()
	for _, s := range strings.Split(stdin.Text(), " ") {
		i, _ := strconv.Atoi(s)
		ret = append(ret, i)
	}
	return ret
}

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

int main() {
  int N, A, amari;
  cin >> N >> A;

  amari = N % 500;

  if (amari <= A) {
    cout << "Yes" << endl;
  }
  else{
    cout <<"No"<<endl;
  }  
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (int)(k); i < (int)(n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
typedef long long ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
const int MOD = 1000000007;
const int INF = MOD + 1;
const ld EPS = 1e-12;
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

/*--------------------template--------------------*/

int main()
{
	cin.sync_with_stdio(false); cout << fixed << setprecision(10);
	vi a(7);
	REP(i, 7) cin >> a[i];
	ll I = a[0], O = a[1], J = a[3], L = a[4];
	ll ans = 0;
	chmax(ans, O + I / 2 * 2 + J / 2 * 2 + L / 2 * 2);
	if (I > 0 && J > 0 && L > 0)
	{
		ll i = I - 1, j = J - 1, l = L - 1;
		chmax(ans, O + 3 + i / 2 * 2 + j / 2 * 2 + l / 2 * 2);
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  //入力
  int A, B, K;
  cin >> A >> B >> K;

  //処理
  int count = 0;
  for (int i = min(A, B); i > 0; i--) {
    if (A % i == 0 && B % i == 0) {
      count++;
      if (count == K) {
        cout << i << endl;
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define int long long
 
#define pii pair<int, int>
 
#define x1 x1228
#define y1 y1228
 
#define left left228
#define right right228
 
#define pb push_back
#define eb emplace_back
 
#define mp make_pair                                                                
                                                                                                                                        
#define ff first                                                                  
#define ss second   
 
#define matr vector<vector<int> > 
 
#define all(x) x.begin(), x.end()
 
 
using namespace std;
typedef long long ll; 
typedef long double ld; 
                                                                                                   
const int maxn = 3e5 + 7, mod = 998244353, inf = 1e18, MAXN = 1e6 + 1;
const double eps = 1e-9;
mt19937 rnd(time(0));
int n; 
int cnt[maxn]; 
int have[MAXN]; 
pii ms[MAXN]; 

int fp(int a, int b) {
    if (b == 0) return 1; 
    int t = fp(a, b / 2); 
    t *= t; 
    t %= mod;
    if (b & 1) {
        t *= a; 
        t %= mod;
    } 
    return t; 
}

int get1[MAXN]; 

void solve() { 
    cin >> n; 
    for (int i = 0; i < n; ++i) {
        int a; cin >> a; 
        have[a]++; 
    }
    for (int i = 1; i < MAXN; ++i) {        
        for (int j = i; j < MAXN; j += i) {
            ms[i].ff += j * have[j];
            ms[i].ff %= mod;
            int add = j * j * have[j]; 
            add %= mod;
            ms[i].ss += add;              
            ms[i].ss %= mod; 
        }
    }
    for (int i = 1; i < MAXN; ++i) {
        get1[i] = (ms[i].ff * ms[i].ff - ms[i].ss + mod) % mod; 
    }
    int ans = 0; 
    for (int i = MAXN - 1; i >= 1; --i) {
        for (int j = i + i; j < MAXN; j += i) {
            get1[i] -= get1[j]; 
            if (get1[i] < 0) get1[i] += mod; 
        }
        int add = get1[i] * fp(i, mod - 2); 
        add %= mod;
        ans += add;
        ans %= mod;
    }          
    ans *= fp(2, mod - 2);
    ans %= mod; 
    cout << ans; 
}                                
   
signed main() {
#ifdef LOCAL
    freopen("TASK.in", "r", stdin);
    freopen("TASK.out", "w", stdout);
#else 
    
#endif // LOCAL
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20); 
    cout << fixed; 
    int t = 1; 
    for (int i = 0; i < t; ++i) {              
        solve();
    }
    return 0;
}  

Measured memory_bytes: 33024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const int IINF = INT_MAX;
const ll LLINF = LLONG_MAX;
const int MAX_N = int(1e5 + 5);
const double EPS = 1e-10;
const int di[] = {0, 1, 0, -1}, dj[] = {1, 0, -1, 0};
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()


ll N, M, K, S, p, q;
ll dmin[MAX_N];
vector<ll> c;
vector<vector<P> > g;
bool zomb[MAX_N];
bool zz[MAX_N];

void bfs(){
    ll d[MAX_N];
    fill(d,d+N,IINF);
    for(auto s : c){
        zz[s] = true;
        d[s] = 0;
        queue<P> que;
        que.push(P(s,0));
        while(!que.empty()){
            P pi = que.front();
            que.pop();
            ll u=pi.first, dt=pi.second;
            if(d[u]<dt)continue;
            if(dt>S)continue;
            for(auto qi : g[u]){
                ll v = qi.first;
                if(d[v]>dt+1){
                    que.push(P(v,dt+1));
                    //cout << "push" << v << " " << dt+1 << endl;
                    d[v] = dt+1;
                }
            }
        }
    }
    REP(i,N){
        //cout << "d" << i << "=" << d[i] << endl;
        if(d[i]<=S) zomb[i] = true;
    }
}

void dijkstra(int s){
    priority_queue<P, vector<P>, greater<P> > que;
    fill(dmin, dmin + N, LLINF);
    dmin[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top();
        que.pop();
        ll v = p.second;
        //cout << "v=" << v << endl;
        if (dmin[v] < p.first) continue;
        for (auto &e : g[v]) {
            //cout << e.first << endl;
            if (dmin[e.first] > dmin[v] + e.second) {
                dmin[e.first] = dmin[v] + e.second;
                //cout << "u=" << e.first << endl;
                que.push(P(dmin[e.first], e.first));
            }
        }
    }
}

int main() {
    cin >> N >> M >> K >> S >> p >> q;
    c.resize(K);
    g.resize(N);
    REP(i,K) {
        cin >> c[i];
        c[i]--;
    }
    REP(i,M){
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        g[a].push_back(make_pair(b,0));
        g[b].push_back(make_pair(a,0));
    }

    bfs();
    //cout << "bfs" << endl;

    REP(i,N){
        for(auto &e : g[i]){
            if(zz[e.first]){
                e.second = LLINF/4;
            }
            else if(zomb[e.first]){
                e.second = q;
            }
            else if(e.first != N-1){
                e.second = p;
            }
            if(e.first == N-1)e.second = 0;
            //cout << "e" << i << " " << e.first << " " << e.second << endl;
        }
    }
    dijkstra(0);
    cout << dmin[N-1] << endl;
    //REP(i,N) cout << i << "=" << dmin[i] << endl;
    //cout << "zom" << endl;
    //REP(i,N) if(zomb[i]) cout << i << endl;

    return 0;
}


Measured memory_bytes: 17576
h,k = map(int,input().split())
a = list(map(int,input().split()))
if k>h or k==h:
    att = 0
else:
    a2 = sorted(a)
    sum = 0
    for i in range(-1,-(k+1),-1):
        sum = sum + a2[i]
    count = 0
    for j in range(0,h,1):
        count = count+a[j]
    lastSum = count-sum
    att = lastSum//1
print(att)

Measured memory_bytes: 25768
i = input()

if "S" in i and "N" not in i:
    print("No")
elif "N" in i and "S" not in i:
    print("No")
elif "E" in i and "W" not in i: 
	print("No")
elif "W" in i and "E" not in i: 
	print("No")
else:
  	print("Yes")

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


int main (){
    int N, M, C;
    cin>>N>>M>>C;
    int Count=0;
    for(int i=N; i>0;i--){
        if(N%i==0&&M%i==0){
            Count ++;
        }
        if(Count==C){
            cout<<i<<endl;
            break;
        }
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<complex>
#include<string.h>
#include<algorithm>
#include<set>
#include<map>
#include<cmath>
#define MS(ptr,val) memset(ptr,val,sizeof(ptr));
#define INPUT(n,m) int n,m;scanf("%d%d",&n,&m);

using namespace std;
typedef long long ll;

int main()
{
	int n;
	
	scanf("%d", &n);
	
	if (n & 1)
	{
		double res = n;
		res = (res + 1) / 2 / res;
		printf("%f", res);
	}
	else
	{
		double res = n;
		res = res / 2 / res;
		printf("%f", res);
	}
	return 0;
}

Measured memory_bytes: 256
using System;

namespace testes
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            bool flag = false;

            for(int i = 1; i < 10; i++)
            {
                for(int j = 1; j < 10; j++)
                {
                    if (N == i * j) flag = true;
                }
            }

            if (flag) Console.WriteLine("Yes");
            else Console.WriteLine("No");
        }
    
    /*
        public static void func(int L, int R, bool x, bool y)
        {
        }
        public static int LIS(int[] c)
        {
            // 部分数列和
            int count = 1;
            int N = c.Length;
            int[] array = new int[N];
            array[0] = c[0];

            for (int i = 1; i < N; i++)
            {
                //for (int p = 0; p < N; p++) Console.Write($"{array[p]},");
                // Console.WriteLine("");
                if (array[count - 1] < c[i])
                {
                    array[count] = c[i];
                    count++;
                    continue;
                }
                for (int j = count - 2; j >= 0; j--)
                {
                    if (array[j] < c[i])
                    {
                        array[j + 1] = c[i];
                        break;
                    }
                }
                if (array[0] > c[i]) array[0] = c[i];
            }
            return count;
        }
        public static void Rotation(char[] array, int l, int r)
        {


        }

    */


    }


}

/*
int a, b, c;
int a = int.Parse(Console.ReadLine()); 
string[] str = Console.ReadLine().Split(' ');
int b = int.Parse(str[0]);  
int c = int.Parse(str[1]);
string S = Console.ReadLine();
char[] C = new char[N];
C = S.ToCharArray();
Console.Write("改行なし a = {0} b = {1} c = {2}", a, b, c)//改行なし出力
Console.WriteLine("改行あり a = {0} b = {1} c = {2}", a, b, c);//改行付き出力

string[] str = Console.ReadLine().Split(' ');
int[] a = new int[N];
for(int i = 0; i < N; i++) a[i] = int.Parse(str[i]);
 */


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define Repr(i, n, a) for (int i = (n); i >= (a); i--)
#define rep(i, n) Rep(i, 0, n)
#define repr(i, n) Repr(i, n, 0)
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

int f(int n)
{
    return n * (n + 1) / 2;
}

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

    string s;
    cin >> s;
    int cnt[26] = {};
    rep(i, s.size()) cnt[s[i] - 'a']++;
    int ans = f(s.size()) + 1;
    rep(i, 26) ans -= f(cnt[i]);
    cout << ans << endl;
}

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

using Point=System.Tuple<long,long>;

public static class Program {
    public static void Main() {
        int[]hn=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int h=hn[0];
        int n=hn[1];
        h-=Console.ReadLine().Split().Select(int.Parse).Sum();
        Console.WriteLine(h<=0?"Yes":"No");
    }
}


Measured memory_bytes: 18656
use proconio::*;
use std::cmp::max;

fn main() {
    input! {
        n: usize,
        m: usize,
        k: i64,
        mut a: [i64; n],
        mut b: [i64; m],
    };
    a.push(1 << 40);
    b.push(1 << 40);

    let mut acc = 0;
    let mut i = 0;
    let mut j = 0;
    let mut ans;
    let mut now_ans;

    while acc + a[i] <= k {
        acc += a[i];
        i += 1;
    }

    ans = i;
    now_ans = ans;
    i = i.wrapping_add(!0);

    loop {
        if acc + b[j] <= k {
            acc += b[j];
            now_ans += 1;
            j += 1;
        } else if i < a.len() {
            acc -= a[i];
            i = i.wrapping_add(!0);
            now_ans -= 1;
        } else {
            break;
        }

        ans = max(ans, now_ans);
    }

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


Measured memory_bytes: 9588
n, m = list(map(int, input().split()))

maxDivisor = 1
for i in range(1, 100001):
    if m % i == 0:
        if i >= n:
            print(m // i)
            exit()
        else:
            if (m // i) >= n: 
                maxDivisor = i
else:
    print(maxDivisor)

                


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if ((A*B)%2==0) cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

void show(vector<ll> &A){
    for(int i=0;i<A.size();i++){
        cout<<A[i];
        if(i+1!=A.size()){cout<<" ";}
    }
    cout<<endl;
}


int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++){cin>>a[i];}
    show(a);
    for(int i=1;i<n;i++){
        ll key=a[i];
        for(int t=i-1;t>=0;t--){
            if(a[t]>a[t+1]){swap(a[t],a[t+1]);}
        }
        show(a);
    }
    
    
    
    return 0;
}



Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <string>
#include <cstdint>

int main() {
  std::int64_t N;
  std::cin >> N;
  std::string name;
  do {
    --N;
    name.push_back('a' + N % 26);
    N /= 26;
  } while (N > 0);
  std::reverse(name.begin(), name.end());
  std::cout << name << std::endl;
  return 0;
}


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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
template<typename T> T gcd(T a, T b) { return (b ? gcd(b, a % b) : a); }
template<typename T> T lcm(T a, T b) { return (a / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

template<typename T>
vector<T> makeVector(size_t a, T b) { return (vector<T>(a, b)); }
template<typename... Ts>
auto makeVector(size_t a, Ts... ts) { 
	return (vector<decltype(makeVector(ts...))>(a, makeVector(ts...)));
}

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	ll N; cin >> N;
	vll A(N); cin >> A;
	ll ans = 0;

	int j = 0;
	vll cnt(22, 0);
	for (int i = 0; i < N; i++) {
		auto check = [&]() {
			bool flag = true;
			for (int b = 0; b < 22; b++) {
				int c = cnt[b];
				if (j < N) c += ((A[j]>>b)&1);
				flag &= (c <= 1);
			}
			return (flag);
		};
		while (j < N && check()) {
			for (int b = 0; b < 22; b++) {
				cnt[b] += ((A[j]>>b)&1);
			}
			j++;
		}
		ans += j-i;
		for (int b = 0; b < 22; b++) {
			cnt[b] -= ((A[i]>>b)&1);
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 4764
N=int(input())
T,A=map(int,input().split())

for i in range(N-1):
    t,a=map(int,input().split())
    if t>=T and a>=A:
        T=t
        A=a
    elif T/t < A/a:
        if A%a==0:
            T=A//a*t
        else:
            A=(A//a+1)*a
            T=A//a*t
    else:
        if T%t==0:
            A=T//t*a
        else:
            T=(T//t+1)*t
            A=T//t*a
print(T+A)

Measured memory_bytes: 3192