akhauriyash/Code-Regression huggingface dataset:
#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() {
  int N, K;
  cin >> N >> K;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  int ng = 0, ok = 1e+9;
  while (ok - ng > 1) {
    int mid = (ok + ng) / 2;
    bool is_ok = [&]{
      int n_cut = 0;
      rep(i, N) n_cut += ((A[i] + mid - 1) / mid) - 1;
      return n_cut <= K;
    }();
    if (is_ok) ok = mid; else ng = mid;
  }
  int ans = ok;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3956
nl = lambda: list(map(int, input().split()))
sl = lambda: input().split()
n = lambda: int(input())
s = lambda: input()

A, B, C, D, E, F = nl()

max_density = -1
max_total = 0
max_sugar = 0
for i in range(F // 100):
    for j in range(F // 100):
        if i == 0 and j == 0:
            continue

        water = 100*A*i + 100*B*j
        if water > F:
            break

        left = F - water
        sugar_limit = min((A*i+B*j)*E, F - water)

        msugar = 0
        for k in range(sugar_limit // C + 1):
            for l in range(sugar_limit // D + 1):
                sugar = C * k + D * l
                if sugar > sugar_limit:
                    break
                if sugar > msugar:
                    msugar = sugar

        density = 100 * msugar / (msugar + water)
        if density > max_density:
            max_density = density
            max_total = msugar + water
            max_sugar = msugar

print(max_total, max_sugar)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

typedef long long ll;
typedef vector<bool> vb;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;

int N, M;
vll x[3];

ll num(ll a, bool f) {
	return (f ? a : -a);
}

ll solve(vb f) {
	vvll dp(N + 1, vll(M + 1, 0));
	rep(i, N) {
		rep(j, M) {
			if (j > i)continue;
			ll next = dp[i][j];
			rep(k, 3) {
				next += num(x[k][i], f[k]);
			}

			if (j == i) {
				dp[i + 1][j + 1] = next;
			}
			else {
				dp[i + 1][j + 1] = max(dp[i][j + 1], next);
			}
		}
	}
	return dp[N][M];
}

int main() {
	cin >> N >> M;
	rep(i, 3) {
		x[i] = vll(N);
	}
	rep(i, N) {
		rep(j, 3) {
			cin >> x[j][i];
		}
	}

	vb f = { true,false };
	ll ma = 0;
	rep(i, 2)rep(j, 2)rep(k, 2) {
		ll s = solve({ f[i], f[j], f[k] });
		ma = max(ma, s);
	}
	cout << ma << endl;

	return 0;
}

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

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> x(N);
    for (int i = 0; i < N; i++) {
        cin >> x[i];
    }
    long long ans = 0;
    for (int i = 0; i < N; i++) {
        ans += min(x[i] * 2, (K - x[i]) * 2);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t k;
    string s;
    cin >> s >> k;
    // 2**INFとなるから、1以外はすべて無視してよい
    char res = '1';
    for(int i=0; i<s.size(); i++){
        if(i>k-1) break;
        if(s.at(i)!='1'){
            res = s.at(i);
            break;
        }
    }
    //kが小さい場合の考慮
    
    cout << res << endl;;
    
}


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

const int INF=1000100010;
int L;
int a[200001];
int dp[200001][5];
int main(){
    cin>>L;
    rep(i,L) cin>>a[i];
    rep(i,L+1)rep(j,5) dp[i][j]=INF;
    rep(i,5) dp[0][i]=0;
    rep(i,L){
        rep(j,5){
            rep(k,j+1){
                dp[i+1][j]=min(dp[i+1][j],dp[i][k]);
            }
            if(j==0||j==4) dp[i+1][j]+=a[i];
            else if(j==2) dp[i+1][j]+=(a[i]+1)%2;
            else if(a[i]==0) dp[i+1][j]+=2;
            else dp[i+1][j]+=a[i]%2;
        }
    }
    int ans=INF;
    rep(i,5) ans=min(ans,dp[L][i]);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9+ 7;
const int INF = 1e9;

int main() {
    int K;
    cin >> K;
    if (K <= 10) {
        cout << K << endl;
        return 0;
    }
    list<int> explore;
    explore.push_front(1);
    explore.push_front(0);
    for (int i = 11; i <= K; i++) {
        int count = 0;
        for (auto itr = explore.begin(); itr != explore.end();) {
            (*itr)++;
            if (next(itr, 1) == explore.end()) {
                if (*itr == 10) {
                    explore.erase(itr);
                    explore.push_front(1);
                    count++;
                }
                break;
            }
            int dif = abs(*itr - *next(itr, 1));
            if (dif <= 1 && *itr != 10) break;
            itr = explore.erase(itr);
            count++;
        }
        for (int j = 0; j < count; j++) explore.push_front(max(*explore.begin() - 1, 0));
    }
    for (auto itr = explore.rbegin(); itr != explore.rend(); itr++) cout << *itr;
    cout << endl;
}


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

namespace ConsoleApp59
{
    class Program
    {
        static void Main(string[] args)
        {
            var l =   Console.ReadLine().Trim();
            var r = new int[l.Length];
            for ( var i = 0; i< l.Length; i++)
            { 
                if( i == 0)
                {
                    if (l[0] == 'P')
                    {
                        r[0] =1;
                    }
                    else
                    {
                        r[0] = 2;
                    }
                }
                if (l[i] == 'P')
                {
                    r[i] = 1;
                }
                else
                {
                    r[i] = 2;
                }
            }
            Console.WriteLine(listToStr(r));
        }

        static string listToStr(int[] list)
        {
            var sb = new StringBuilder();

            for( var i = 0; i< list.Length; i++)
            {
                sb.Append(swi(list[i]));

            }
            return sb.ToString();
        }
        static string swi(int i)
        {
            switch (i)
            {
                case 1:
                    return "P";
                case 2:
                    return "D";
            }
            return "";

        }
     
    }
}


Measured memory_bytes: 28252
#include <iostream>
#include <cstdio>
#include <algorithm>
#define DEBUG 0
using namespace std;

int main()
{
    #if DEBUG
    freopen("test.txt", "r", stdin);
    #endif // DEBUG
    //取数据
    int N;
    scanf("%d",&N);

    int num4=0;
    int num2=0;
    int num1=0;
    for(int i=0; i<N; i++)
    {
        int temp;
        scanf("%d",&temp);
        if(temp%4 == 0){
            num4++;
        }else if(temp%2 ==0){
            num2++;
        }else{
            num1++;
        }
    }
    //计算结果
    if(num2 == 0 && num1 <= num4+1)
        printf("Yes\n");
    else if(num2 > 0 && num1 <= num4)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}

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

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n)  FOR(i, 0, n)
#define ASC(c) sort((c).begin(), (c).end())
#define DESC(c) sort((c).begin(), (c).end(), greater<int>())

#define DUMP(x)  cerr << #x << " = " << (x) << endl;
#define DEBUG(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

typedef long long ll;
typedef unsigned long long ull;
struct edge { int u, v; ll w; };
 
ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int main() {
  int n, t, a; cin >> n >> t >> a;
  float mn = 1000000;
  int ans = -1;
  REP(i, n) { 
    int x; cin >> x;
    float tmp = abs(a - (t - x * 0.006));
    if (mn > tmp) {
      mn = tmp;
      ans = i + 1;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]

cnt = 0
for i in A:
    tmp = 0
    for m, n in zip(B, i):
        tmp += m*n
    if tmp + C > 0:
        cnt += 1

print(cnt)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, d;
    cin >> n >> d;
    int points[n][d];

    rep(i, n) rep(j, d) cin >> points[i][j];

    int cnt = 0;
    rep(i,n) {
        for (int j=i+1; j<n; j++) {
            float sum = 0;
            rep(k, d) {
                sum += pow((float)(points[i][k] - points[j][k]), 2.0);
            }
            sum = sqrt(sum);
            if (sum == (float)(int) sum) {
                cnt ++;
            }
        }
    }
    cout << cnt << endl;
}


Measured memory_bytes: 256
# import pdb
N = int(input())

CSF = [input() for i in range(N-1)]
ans_r = []
# pdb.set_trace()
for i in range(N-1)[::-1]:
    C, S, F = map(int, CSF[i].split(' '))
    cost = S + C
    for j in range(i+1, N-1):
        Cj, Sj, Fj = map(int, CSF[j].split(' '))
        if cost <= Sj:
            cost = ans_r[(N-1) - j - 1]
            break
        else:
            temp = (cost+Fj-1)//Fj * Fj
            cost = temp + Cj
    ans_r.append(cost)
for i in ans_r[::-1]:
    print(i)
print(0)


Measured memory_bytes: 3188
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define max(p,q) ((p)>(q)?(p):(q))
#define min(p,q) ((p)<(q)?(p):(q))
#define chmax(a,b) ((a)=(a)>(b)?(a):(b))
#define chmin(a,b) ((a)=(a)<(b)?(a):(b))
#define abs(p) ((p)>=(0)?(p):(-(p)))
#define MOD 1000000007
ll powll(ll a,ll b){ll r=1;rep(i,b){r*=a;}return r;}
#define swap(a,b) do{ll w=(a);(a)=(b);(b)=w;}while(0)
#define swapd(a,b) do{double w=(a);(a)=(b);(b)=w}while(0)
//      puts(a) printf("%s\n", a) 文字はこっち
//your code here!
int main(void){
    ll A, B, C;
    scanf("%lld %lld %lld", &A, &B, &C);
    if(A+B>=C) printf("%lld\n", B+C);
    else printf("%lld\n", 1+A+B+B);
    return 0;
}


Measured memory_bytes: 128
/* 
   AOJ 1141
   Dirichlet's Theorem on Arithmetic Progressions
   2015.4.29
 */

#include<stdio.h>
#define MAX_NUM 1000000
int prime_num[MAX_NUM + 1];

void generate_prime_num_table()
{
  int i, j;

  for(i = 0; i < MAX_NUM + 1; i++)
    {
      prime_num[i] = 1;
    }
  
  prime_num[0] = 0;
  prime_num[1] = 0;
  for(i = 2; i <= MAX_NUM; i++)
    {
      if(prime_num[i] == 1)
	{
	  for(j = 2; i * j <= MAX_NUM; j++)
	    {
	      prime_num[i * j] = 0;
	    }
	}
    }
  
}

int calc_prime_num(int start_num, int diff, int target_num)
{
  int i, diff_num[MAX_NUM], count = 0;
  for(i = 0; i <= MAX_NUM; i++)
    {
      diff_num[i] = 0;
    }

  for(i = 0; start_num + i * diff <= MAX_NUM; i++)
    {
      diff_num[start_num + i * diff] = 1;
    }

  /* for(i = 0; i < 100; i++) */
  /*   { */
  /*     if(diff_num[i] == 1) */
  /* 	{ */
  /* 	  printf("%3d", i); */
  /* 	} */
  /*   } */
  /* printf("\n"); */


  for(i = 0; i <= MAX_NUM; i++)
    {
      if(prime_num[i] == 1 && diff_num[i] == 1)
	{
	  count++;
	  if(count == target_num)
	    {
	      fflush(stdout);
	      return i;
	    }
	}
    }  
}

int main(void)
{
  int start_num, diff, target_num, prime_total_num;

  generate_prime_num_table();

  while(1)
    {

      scanf("%d %d %d", &start_num, &diff, &target_num);

      if(start_num == 0 && diff == 0 && target_num == 0)
	{
	  break;
	}

      prime_total_num = calc_prime_num(start_num, diff, target_num);
      printf("%d\n", prime_total_num);
    }

  return 0;
}

Measured memory_bytes: 8412
def calc(w, h):
    if w == 1 or h == 1:
        return 1

    result = w * h / 2

    if w * h % 2 != 0:
        result += 1

    return int(result)


w, h = input().split(' ')
w = int(w)
h = int(h)

result = calc(w, h)
print(result)

Measured memory_bytes: 2940
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=1;i<=n;i++){
			if(i%3==0)System.out.printf(" %d",i);
			else{
				int x=i;
				while(x!=0){
					if(x%10==3){
						System.out.printf(" %d",i);
						break;
					}
					x/=10;
				}
			}
		}
		System.out.print("\n");
	}
}



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

using namespace std;
using ll = long long;

int main() {
    int n; ll L; scanf("%d %lld", &n, &L);
    ll a[n + 2];
    for (int i = 1; i <= n; i++) {
        scanf("%lld", &a[i]);
    }

    for (int i = 1; i < n; i++) {
        if (a[i] + a[i + 1] >= L) {
            puts("Possible");
            vector <int> ans;
            for (int j = 1; j < i; j++) printf("%d\n", j);
            for (int j = n; j > i + 1; j--) printf("%d\n", j - 1);
            printf("%d\n", i);
            return 0;
        }
    }

    puts("Impossible");
}

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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

string rotate(string s)
{
    return s.substr(1) + s[0];
}

int main()
{
    string s, t;
    cin >> s >> t;

    int n = s.size();
    rep(i, n)
    {
        if (s == t)
        {
            cout << "Yes" << '\n';
            return 0;
        }
        s = rotate(s);
    }
    cout << "No" << '\n';
    return (0);
}

// int main()
// {
//     string s, t;
//     cin >> s >> t;

//     t += t;
//     cout << ((t.find(s) != -1) ? "Yes" : "No") << endl;
//     return (0);
// }


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
#define deb(x) cout << #x <<  " " << x << endl;
#define all(x) x.begin(), x.end()
typedef std::vector<int> vi;
typedef std::vector<vector<int>> vvi;
typedef std::vector<string> vs;
typedef std::vector<bool> vb;
typedef std::pair<int, int> pii;
typedef long long ll;
const int inf = 1e9 + 5;

template <typename T>
void print(T v){ for(auto i= v.begin(); i!=v.end(); i++)cout<<setw(2)<<*i<<" ";cout<<endl; }
template <typename T>
void print_vv(T v, bool same_line=true){
for(auto i= 0; i<v.size(); i++){cout<<"{";for(auto j = 0; j!=v[i].size(); j++){cout<<setw(3)<<v[i][j]<<",";}cout<<"},";if(same_line) cout<<endl;}cout<<endl;}

int main(){
    int n, k;
    while(cin>>n>>k){
        vi dp(k+1); // possible to win if there are i stones

        vi a(n);
        for(int i=0; i<n; i++)
            cin>>a[i];

        for(int stones = 1; stones<=k; stones++){
            for(int x: a){
                // out of "stones" stones, if i choose x, i can only win if with the remaining st
                // (stones-x) the opponent is loosing !dp[rem]
                if(stones-x>=0 && !dp[stones-x]){ 
                    dp[stones] = 1;
                }
            }
        }

        string out = dp[k] ? "First" : "Second";
        cout<<out<<endl;

    }
    
    return 0;
}

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

using namespace std;



int mod(int a, int b){
  if(a>b)
    return a-b;
  return b-a;
}

long minimum(long a, long b)
{
  if(a<b)
    return a;
  return b;
}

int main(){
  long n,W,V=0;
  cin >> n >> W;
  long w[n],v[n];
  for(int i=0;i<n;i++) {
    cin >> w[i] >> v[i];
    V+=v[i];
  }
  long dp[n+1][V+1];
  for(int i=0;i<=n;i++) {
      for(int j=0;j<=V;j++) {
          if(j>0)
            dp[i][j] = INT_MAX;
            else
            dp[i][j]=0;
      }
  }
  for(int i=1;i<=n;i++) {
      for(int j=0;j<=V;j++){
          dp[i][j] = dp[i-1][j];
          if(j>=v[i-1]){
              //cout << i << " " << j << " " << w[i-1] << " " << v[i-1] << " " << dp[i][j] << " " << w[i-1]+dp[i-1][j-v[i-1]] << " " << minimum(dp[i][j], w[i-1]+dp[i-1][j-v[i-1]]) << endl;
              dp[i][j] = minimum(dp[i][j], w[i-1]+dp[i-1][j-v[i-1]]);
          }
          //cout << dp[i][j] << " ";
      }
      //cout << endl;
  }
  int ans=0;
  for(int j=0;j<=V;j++){
      //cout << dp[n][j] << " ";
      if(dp[n][j]<=W){
          ans=j;
      }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 82500
/*Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define debug(x) cout << #x << " " << x <<endl;
typedef long long ll;
typedef unsigned long long ull;
typedef priority_queue<int, vector<int>, function<bool(int, int)>> pq_func;
/*---------------------------------------------------------------------------------------------------------------------------*/
int gcd(int a, int b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod) {ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
void google(int t) {cout << "Case #" << t << ": ";}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	ll a, b, c;
	cin >> a >> b >> c;
	ll x = min(c, b - 1);
	ll val1 = (a * x) / b;
	cout << val1 << endl;
	return 0;
}

Measured memory_bytes: 3652
//QWsin
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,x,y) for(int i=x;i<=y;++i)
#define out(i,u) for(int i=first[u];i!=-1;i=nxt[i])
#define repvc(i,vc) for(int i=0,Sz=vc.size();i<Sz;++i)
using namespace std;
inline int read()
{
	char ch=getchar();int ret=0,f=1;
	while(ch<'0' || ch>'9') {if(ch=='-')f=-1;ch=getchar();}
	for(;ch>='0' && ch<='9';ch=getchar()) ret=ret*10+ch-'0';
	return ret*f;
}

typedef long long ll;
const int INF=1<<30;
const int MOD=1e9+7;

const int maxn=10000+10;
const int maxv=3000000+10;

int not_prime[maxv],prime[maxv],primeno[maxv],pcnt;
void init_prime(int n){
	rep(i,2,n){
		if(!not_prime[i]) prime[++pcnt]=i,primeno[i]=pcnt;	
		for(int j=1;j<=pcnt&&1ll*i*prime[j]<=n;++j){
			not_prime[i*prime[j]]=1;
			if(i%prime[j]==0) break;		
		}
	}
}

int a[maxn];

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

ll Pow(ll x,ll p){
	x%=MOD;ll ret=1;
	for(;p;p>>=1,x=x*x%MOD) if(p&1) ret=ret*x%MOD;
	return ret;		
}

ll inv(ll x){return Pow(x,MOD-2);}

ll B[maxn];

int cnt[maxv];
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
ll lc[maxn];
int main()
{
//	freopen("std.in","r",stdin);
	int n;cin>>n;
	rep(i,1,n) cin>>a[i];
	init_prime(1000000);
	
	ll G=1;
	
	rep(i,1,n)
	{
		ll t=a[i];
		rep(j,1,pcnt)
		{
			if(1ll*prime[j]*prime[j]>t) break;
			int tmp=0;
			while(t%prime[j]==0){
				++tmp;
				t/=prime[j];	
			}
			cnt[j]=max(cnt[j],tmp);
		}
		if(t!=1) cnt[primeno[t]]=max(cnt[primeno[t]],1);
	}
	
	rep(i,1,pcnt) G=G*Pow(prime[i],cnt[i])%MOD;
	
	ll ans=0;
	rep(i,1,n) ans+=G*inv(a[i])%MOD;
	cout<<ans%MOD<<endl;
	
	return 0;
}


Measured memory_bytes: 14848
#include <string>
#include <vector>
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<cmath>
#include<algorithm>
#include<functional>
#include<list>
#include<deque>
#include<bitset>
#include<set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<sstream>
#include<complex>
#include<iomanip>
#include<numeric>
#include<cassert>
#define X first
#define Y second
#define pb push_back
#define rep(X,Y) for (int (X) = 0;(X) < (Y);++(X))
#define reps(X,S,Y) for (int (X) = S;(X) < (Y);++(X))
#define rrep(X,Y) for (int (X) = (Y)-1;(X) >=0;--(X))
#define repe(X,Y) for ((X) = 0;(X) < (Y);++(X))
#define peat(X,Y) for (;(X) < (Y);++(X))
#define all(X) (X).begin(),(X).end()
#define rall(X) (X).rbegin(),(X).rend()
#define eb emplace_back
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;
ll modpow(ll r,ll n,ll m=MOD){
  ll re=1,d=r%m;
  if(n<0)(n%=MOD-1)+=MOD-1;
  for(;n;n/=2){
    if(n&1)(re*=d)%=m;
    (d*=d)%=m;
  }
  return re;
}
vector<ll> fact,finv,inv;
ll comb(ll n,ll r){
  if(n<r||r<0)return 0;
  return fact[n]*finv[n-r]%MOD*finv[r]%MOD;
}
class Doralion{
  void Modinvs(vector<ll> &re,int n){
    re.resize(n+1); re[1]=1;
    for(int i=2;i<=n;++i)re[i]=re[MOD%i]*(MOD-MOD/i)%MOD;
  }
  void Facts(vector<ll> &re,int n){
    re.resize(n+1); re[0]=1;
    rep(i,n)re[i+1]=re[i]*(i+1)%MOD;
  }
  void Factinvs(vector<ll> &re,const vector<ll> &inv,int n){
    re.resize(n+1); re[0]=1;
    rep(i,n)re[i+1]=re[i]*inv[i+1]%MOD;
  }
public:
  Doralion(int n){
    Modinvs(inv,n);
    Facts(fact,n);
    Factinvs(finv,inv,n);
  }
} doralion(212345);


int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  ll h,w,a,b;
  cin>>h>>w>>a>>b;
  ll re=0;
  rep(i,h-a) (re+=comb(b-1+i,i)*comb(w-b-1+h-i-1,h-i-1)%MOD)%=MOD;
  //rep(i,h-a) cout<<pii(b-1+i,i)<<pii(w-b-1+h-i-1,h-i-1)<<endl;
  cout<<re<<endl;
  return 0;
}


Measured memory_bytes: 5248
#include <iostream>
#include <algorithm>
#include <cstdint>

int main() {
	std::int64_t a, b, c;
	std::cin >> a >> b >> c;

	auto x = c - a - b;

	std::cout << (x > 0 && 4 * a * b < x * x ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 256
N, K = input().split()
H = input().split()
if int(K) >= int(N):
    print(0)
else:
    attack = 0
    H = list(map(int, H))
    H.sort(reverse = True)
    del H[0:int(K)]
    for x in H:
        attack += x
    print(attack)


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

int main(){
    string str;
    
    while(getline(cin,str)){
        int flg = 0;
        
        while(true){
            for(int i = 0 ; i < str.length() ; i++){
                string key1 = str.substr(i,3),key2 = str.substr(i,4);
                if(key1 == "the" || key2 == "that" || key2 == "this") flg = 1;
            }
            
            if(flg) goto end;
            else{
                for(int j = 0 ; j < str.length() ; j++){
                    if('a' <= str[j] && str[j] <= 'z'){
                        str[j] -= 'a' - 'A';
                        str[j] = (char)('A'+(str[j]-'A'+26+1)%26);
                        str[j] += 'a' - 'A';
                    }
                    else continue;
                }
            }
        }
    end:
    cout << str << endl;
    }
        
    return 0;
}

Measured memory_bytes: 1188
def main
    n = gets.to_i
    as = gets.chomp.split(" ").map(&:to_i)
    ans = 1

    while as.size > 1
        as.push 1 if as.size % 2 == 1
        bs = []
        (0..as.size/2-1).each do |i|
            bs.push (as[2*i] * as[2*i+1])
        end
        as = Marshal.load(Marshal.dump(bs))
    end
    if as[0] > 10**18
        puts -1
        return
    else
        puts as[0]
    end
end

main


Measured memory_bytes: 71100
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);
//cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> plpl;
typedef tuple<ll,ll,ll> tl;
ll mod=1000000007;
ll mod2=998244353;
ll inf=1000000000000000000;
double pi=2*acos(0);
#define rep(i,m,n) for(int i=m;i<n;i++)
#define rrep(i,n,m) for(int i=n;i>=m;i--)
ll lmax(ll a,ll b){
    if(a<b)return b;
    else return a;
}
ll lmin(ll a,ll b){
    if(a<b)return a;
    else return b;
}
int main(){
    int n;cin>>n;
    ll x[n],y[n];rep(i,0,n)cin>>x[i]>>y[i];
    int mi=100;
  if(n==1){
    cout<<1<<endl;
    return 0;
  }
    rep(i,0,n){
        rep(j,0,n){
            if(i==j)continue;
            int p=x[i]-x[j];
            int q=y[i]-y[j];
            if(p==0&&q==0)continue;
            int cnt=0;
            rep(k,0,n){
                rep(l,0,n){
                    if(k==l)continue;
                    if(x[k]-x[l]==p&&y[k]-y[l]==q)cnt++;
                    //cout<<x[k]-x[l]<<" "<<y[k]-y[l]<<" "<<cnt<<endl;
                }
            }
            //return 0;
            mi=min(mi,n-cnt);
            //cout<<cnt<<endl;
        }
    }
    cout<<mi<<endl;
}


Measured memory_bytes: 256
# でつoO(YOU PLAY WITH THE CARDS YOU'RE DEALT..)
from typing import Iterable
import sys
def main(N, M, AB):
    uf = UnionFindTree(N)
    for a, b in AB:
        a, b = a - 1, b - 1
        uf.union(a, b)
    d = set()
    for i in range(N):
        r = uf.find(i)
        if r not in d:
            d.add(r)
    print(len(d) - 1)

class UnionFindTree:
    __slots__ = ('parent')

    def __init__(self, n: int) -> None:
        self.parent = [-1] * n

    def find(self, x: int) -> int:
        p = self.parent
        while p[x] >= 0: x, p[x] = p[x], p[p[x]]
        return x

    def union(self, x: int, y: int) -> bool:
        x, y, p = self.find(x), self.find(y), self.parent
        if x == y: return False
        if p[x] > p[y]: x, y = y, x
        p[x], p[y] = p[x] + p[y], x
        return True

    def same(self, x: int, y: int) -> bool:
        return self.find(x) == self.find(y)

    def size(self, x: int) -> int:
        return -self.parent[self.find(x)]

    def same_all(self, indices: Iterable[int]) -> bool:
        f, v = self.find, self.find(indices[0])
        return all(f(i) == v for i in indices)

if __name__ == '__main__':
    input = sys.stdin.readline
    N, M = map(int, input().split())
    AB = [tuple(map(int, input().split())) for _ in range(M)]
    main(N, M, AB)


Measured memory_bytes: 85700
H,W = map(int, input().split())
L = []
while H != 0 or W != 0:
 L.append([H, W])
 H,W = map(int, input().split())

def draw(H,W):
 if W == 1:
  for i in range(H // 2):
   print("#")
   print(".")
  if H % 2 == 1:
   print("#")
  print("")
 elif W % 2 == 1:
  for i in range(H // 2):
   print("#." * (W // 2) +"#")
   print(".#" * (W // 2) + ".")
  if H % 2 == 1:
   print("#." * (W // 2) +"#")
  print("")
 else:
  for i in range(H // 2):
   print("#." * (W // 2))
   print(".#" * (W // 2))
  if H % 2 == 1:
   print("#." * (W // 2))
  print("")

for (H, W) in L:
 draw(H,W)

Measured memory_bytes: 7680
while True:
    (n, x) = [int(i) for i in input().split()]
    if n == x == 0:
        break

    count = 0
    limit = n if n < x else x
    for a in range(1, limit + 1):
        for b in range(a + 1, limit + 1):
            for c in range(b + 1, limit + 1):
                if sum([a,b,c]) == x:
                    count += 1

    print(count)

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

int main(){
    int N, A[100000];
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i];
    }
    sort(A, A+N);

    int ans = 0;
    vector<pair<int, int>> ps;
    if(A[0] >= 0){
        for(int i=1; i<N-1; i++){
            ps.push_back({A[0], A[i]});
            A[0] -= A[i];
        }
        ps.push_back({A[N-1], A[0]});
        A[N-1] -= A[0];
        ans = A[N-1];
    }else if(A[N-1] <= 0){
        for(int i=0; i<N-1; i++){
            ps.push_back({A[N-1], A[i]});
            A[N-1] -= A[i];
        }
        ans = A[N-1];
    }else{
        for(int i=1; i<N-1; i++) if(A[i] >= 0){
            ps.push_back({A[0], A[i]});
            A[0] -= A[i];
        }
        for(int i=0; i<N-1; i++) if(A[i] < 0){
            ps.push_back({A[N-1], A[i]});
            A[N-1] -= A[i];
        }
        ans = A[N-1];
    }
    cout << ans << endl;
    for(auto& p : ps) cout << p.first << " " << p.second << endl;
    return 0;
}


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

#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()

Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n, k;
    cin >> n >> k;
    vector<Int> a(n);
    for(Int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(all(a));
    vector<Int> b;
    Int res = 1;
    for (Int i = 0; i < n; i++) {
        Int add = i + 1 - (lower_bound(all(a), a[i] - k) - a.begin());
        res = res * add % mod;
    }
    dump(res);
    return 0;
}



Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
const int N = 1e5 + 5;
#define int long long int

int32_t main() {
    IOS ;
    int n, k ; cin >> n ;
    if(n&1) k = n/2 ; 
    else k = n/2 - 1 ;

    double arr[n+1], dp[n+1][k+1] ;
    dp[0][0] = 1 ; 
    for(int i=1; i<n+1; i++) cin >> arr[i], dp[i][0] = arr[i]*dp[i-1][0] ; 

    // for(int i=0; i<=n; i++) cout << dp[i][0] << " ";

    for(int i=1; i<n+1; i++) arr[i] = 1 - arr[i] ;

    for(int i=0; i<n+1; i++) {
        for(int j=0; j<k+1; j++) {
            if(j == 0) continue ;
            else if(i == j) dp[i][j] = arr[i] * dp[i-1][j-1] ;
            else if(j > i) dp[i][j] = 0 ;
            else dp[i][j] = (arr[i] * dp[i-1][j-1]) + ((1-arr[i]) * dp[i-1][j]) ;   
        }
    }

    double res = 0 ;
    for(int i=0; i<=k; i++) res += dp[n][i] ;

    cout << std::setprecision(10) << res ;

    return 0 ;
}


Measured memory_bytes: 38936
// Problem : B - Product Max
// Contest : AtCoder - AtCoder Beginner Contest 178
// URL : https://atcoder.jp/contests/abc178/tasks/abc178_b
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  // Common file
#include <ext/pb_ds/tree_policy.hpp>  // Including tree_order_statistics_node_update
#define int long long
#define fastio                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
#define sz(a) (int)((a).size())
#define pb push_back
#define mp make_pair
#define db1(x) cout << #x << "=" << x << endl
#define db2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z)                                                       \
  cout << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z \
       << endl
#define dbp(x) \
  cout << #x << "= {" << (x.first) << ", " << (x.second) << "}" << endl;
#define dbv(v)                         \
  {                                    \
    cout << #v << " : ";               \
    for (auto x : v) cout << x << ' '; \
    cout << endl;                      \
  }
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define rep2(i, a, b) for (int i = a; i >= b; i--)
#define die(x) return cout << x << '\n', 0;

using namespace __gnu_pbds;
using namespace std;

// Declaring ordered_set
typedef tree<int, null_type, less<int>, rb_tree_tag,
             tree_order_statistics_node_update>
    ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

int32_t main() {
  fastio;
  //  freopen("input.txt", "r", stdin);
  //  freopen("output.txt", "w", stdout);
  int testcases;
  testcases = 1;
  // cin >> testcases;

  while (testcases--) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int mx = max(b * d, a * c);
    mx = max(mx, b * c);
    mx = max(mx, a * d);
    cout << mx << '\n';
  }

  return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;
    int sum = 1;
    for(int i=0; i<N; i++) {
        if(sum*2 >= sum+K) {
            sum += K;
        }else {
            sum *= 2;
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k,a,d[101],biaoji[101],count=0;;
  memset(biaoji,0,sizeof(biaoji));
  cin>>n>>k;
  for(int i=1;i<=k;i++)
  {
      cin>>d[i];
      for(int j=1;j<=d[i];j++)
      {
          cin>>a;
          biaoji[a]=1;
      }
  }
  for(int i=1;i<=n;i++)
  {
      if(biaoji[i]==0)
        count++;
  }
  cout<<count<<endl;
}

Measured memory_bytes: 3592
#include <iostream>                   
                                      
int main() {                          
    int x, y = 0;                     
    while(true) {                     
        std::cin >> x >> y;           
        if(x == 0 && y == 0) break;   
                                      
        if(x > y) {                   
            std::cout << y << " " << x << std::endl;
        }else {                       
            std::cout << x << " " << y << std::endl;
        }                             
    }                                 
    return 0;                         
}

Measured memory_bytes: 1160
#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 For(i,a,b) for(auto i=(a);i<=(b);++i)
#define rFor(i,a,b) for(auto i=(b);i>=(a);--i)
#define call(var) cerr<<#var<<"="<<var<<"\n";
#define dup(x,y) (((x)+(y)-1)/(y))
#define all(x) (x).begin(),(x).end()
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
const double pi = acos(-1);
template<class t,class u> inline bool chmax(t&a,u b){if(a<b){a=b;return true;}return false;}
template<class t,class u> inline bool chmin(t&a,u b){if(b<a){a=b;return true;}return false;}
template<class T> istream& operator>>(istream& is, vector<T>& a){rep(i,a.size()) is >> a[i]; return is;}
template<class T> ostream& operator<<(ostream& os, vector<T>& a){rep(i,a.size()) os << a[i] << " "; return os;}
template<class T, class U> istream& operator>>(istream& is, pair<T,U>& p){is >> p.first >> p.second; return is;}
template<class T, class U> ostream& operator<<(ostream& os, const pair<T,U>& p){os << "("<< p.first << "," << p.second << ")"; return os;}
template<class T, class U> ostream& operator<<(ostream& os, const map<T,U>& mp){for(auto& t : mp) os << t.first << " " << t.second << "\n"; return os;}

int main(){
    int n;cin >> n;
    vl a(n);
    cin >> a;

    sort(a.begin(), a.end(), greater<ll>());

    ll ans = 0;

    ans += a[0];
    --n;

    int i = 1;

    --n; // last 

    while(n){
        if(n >= 2){
            ans += (ll)2 * a[i];
            ++i;
            n -= 2;
        }else{
            ans += (ll)n * a[i];
            break;
        }
    }
    cout << ans << endl;
}

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e18;
//const int INF=(1<<30);


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

  string s;
  cin >> s;
  reverse(ALL(s));

  map<int, int> mp;
  mp[0]=1;

  ll ans = 0;
  if(P==2 || P ==5){
    REP(i,s.size()){
      int n = s[i] - '0';
      if(n%P==0)ans += N-i;
    }
  }else{

    int t=0;
    int base = 1;
    REP(i,s.size()){
      int n = s[i] - '0';

      t = (n * base + t) % P;
      base = (base * 10) % P;
      ans += mp[t%P];
      mp[t]++;
    }

  }


  cout << ans << endl;
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int n;cin >> n;
    cout << "ABC" << n << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define DEBUG "::"
#define REPI(itei) for(long long int i = 0,iteii=itei;i < iteii;i++)
#define REPJ(itej) for(long long int j = 0,itejj=itej;j < itejj;j++)
#define REPK(itek) for(long long int k = 0,itekk=itek;k < itekk;k++)
using namespace std;
typedef long long int ll;
int main(){
    int N,K;
    cin >> N >> K;
    vector<ll>val;
    REPI(N){
        ll x;
        cin >> x;
        val.push_back(x);
    }
    sort(val.begin(),val.end());
    ll ans = 99999999999;
    REPI(N-K+1){
        //cout << DEBUG << ans << "\n";
        ans = min(ans,val[i+K-1]-val[i]);
        //cout << DEBUG << ans << "\n";
    }
    cout << ans << "\n";
    return 0;
}

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

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define X real()
#define Y imag()
#define value(x,y,w,h) (x >= 0 && x < w && y >= 0 && y < h)
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl
#define fcout(n) cout<<fixed<<setprecision((n))
#define scout(n) cout<<setw(n)

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto &n :(array))

typedef long long ll ;
typedef deque<int> di ;
typedef deque<ll> dl ;
typedef map<string,int> dict;
typedef complex<double> comd;
typedef pair<int,int> pii;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
constexpr double PI = acos(-1.0) ;
double eps = 1e-10 ;
const int dy[] = {-1,0,1,0};
const int dx[] = {0,-1,0,1};

double CalcDist(comd p1, comd p2){
  return sqrt(pow(p1.X - p2.X,2.0) + pow(p1.Y -p2.Y,2.0));
}

template <typename T>
void out(deque < T > d)
{
  for(size_t i = 0; i < d.size(); i++)
  {
    debug(d[i]);
  }
}

template<typename T>
T ston(string& str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}
int v[10000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int i = 0;
  while(cin>>v[i]) ++i;
  gsort(v,v+10000);
  cout << v[0] << "\n"<<v[1]<<"\n"<<v[2]<<"\n";
  return 0;
}

Measured memory_bytes: 3248
#include<iostream>
#include<numeric>
#include<vector>
#include<iomanip>
#include<algorithm>
#include<map>
#include<utility>
#include<cmath>
#include<tuple>
#include<string>
#include<bitset>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
using namespace std;
typedef long long ll;

int main(){
    int x,y;
    cin>>x>>y;
    if(y%2){
        cout<<"No"<<endl;
        return 0;
    }
    for(int i=0;i<=x;i++){
        if(y==i*2+(x-i)*4){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

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

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = mod * mod;
typedef pair<int, int>P;
typedef pair<int, bool> sP;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef vector<ll> vec;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<ll> vec;


void solve() {
	int n, k; cin >> n >> k;
	vector<int> a(n);
	rep(i, n) {
		cin >> a[i]; a[i]--;
	}
	vector<ll> ra(n + 1);
	rep(i, n) {
		ra[i + 1] += ra[i] + a[i];
	}
	rep(i, n + 1) {
		ra[i] %= k;
	}
	map<int, vector<int>> mp;
	ll ans = 0;
	rep(i, n + 1) {
		int s = ra[i];
		vector<int> &v = mp[s];
		int id = lower_bound(v.begin(), v.end(), i - (k - 1)) - v.begin();
		ans += v.size() - id;
		mp[s].push_back(i);
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(7);
	//init();
	solve();
	return 0;
}



Measured memory_bytes: 24448
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <set>

using namespace std;

#define rep(i,a,n) for(int (i)=a;(i)<(int)(n);(i)++)
#define rrep(i,a,n) for(int (i)=(n)-1;(i)>=a;(i)--)
#define all(x) (x).begin(),(x).end()

typedef long long ll;

int main() {
	int W, H;
	int x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x + r <= W && x - r >= 0 && y + r <= H && y - r >= 0) {
			cout << "Yes" << endl;
	} else {
			cout << "No" << endl;
	}
}

Measured memory_bytes: 3096
#include <iostream>
#include <vector>
#include <bitset>
#include <algorithm>

using namespace std;

const int MAX_PRIME = 50000;

int main(){
	bitset<MAX_PRIME> sieve;
	vector<int> primes;
	sieve[0] = sieve[1] = true;
	for(int i = 2; i < MAX_PRIME; ++i){
		if(sieve[i]){ continue; }
		primes.push_back(i);
		for(int j = i + i; j < MAX_PRIME; j += i){ sieve[j] = true; }
	}
	while(true){
		int m, a, b;
		cin >> m >> a >> b;
		if(m == 0 && a == 0 && b == 0){ break; }
		int c = 0, d = 0;
		for(int i = 0; i < primes.size(); ++i){
			int deno = primes[i];
			int upper = std::min(m / deno, deno);
			vector<int>::iterator it = upper_bound(
				primes.begin(), primes.end(), upper);
			if(it != primes.begin()){
				--it;
				if(a * deno > b * (*it)){ continue; }
				if(c * d < *it * deno){
					c = *it;
					d = deno;
				}
			}
		}
		cout << min(c, d) << " " << max(c, d) << endl;
	}
	return 0;
}

Measured memory_bytes: 1276
import sys


def main():
    lines = [x.strip() for x in sys.stdin.readlines()]
    N = lines[0]
    words = lines[1:]
    w = words[0][-1]
    result = "Yes"
    if len(set(words)) != len(words):
        result = "No"
    else:
        for i in words[1:]:
            if i[0] != w:
                result = "No"
            w = i[-1]
    print(result)


if __name__ == '__main__':
    main()


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

namespace ConsoleApp1
{
    static class BTapDance
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine();
            var sChars = s.ToList();

            var odds = new List<string> { "R", "U", "D" };
            var evens = new List<string> { "L", "U", "D" };

            bool error = false;

            for (int i = 0; i < sChars.Count; i++)
            {
                if (i % 2 == 0)
                {
                    // odd at list.
                    if (!odds.Any(x => x == sChars[i].ToString()))
                    {
                        error = true;
                        break;
                    }
                }
                else
                {
                    // even at list.
                    if (!evens.Any(x => x == sChars[i].ToString()))
                    {
                        error = true;
                        break;
                    }
                }
            }

            Console.WriteLine(error ? "No" : "Yes");
            Console.ReadLine();
        }
    }
}

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

int main(){
	string s, t;
	cin >> s >> t;

	int sz = s.size();
	bool flag = false;
	for(int i = 0; i < sz; i++){
		s.insert(s.begin(), s[sz-1]);
		s.erase(s.end()-1);
		if(s == t) flag = true;
		//cout << s << endl;
	}

	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
using namespace std;
 
int main () {
	int a[26]={0},l;
	string s;
	string ans = "yes";

	cin >> s;
	l = s.length();

	for(int i=0;i<l;i++){
		a[s[i]-'a']++;
	}

	for(int i=0;i<26;i++){
		if(a[i]>1){
			ans = "no";
		}
	}
	cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
char a[105],b[105],c[105];
int aa,bb,cc,nw,pp,ra,rb,rc;
int main()
{
	scanf("%s",a);
	scanf("%s",b);
	scanf("%s",c);
	aa=strlen(a),bb=strlen(b),cc=strlen(c);
	while(1)
	{
		if(nw==0)
		{
			if(ra==aa)
			{
				pp=0;
				break;
			}
			nw=a[ra]-'a';
			ra++;
		}
		else if(nw==1)
		{
			if(rb==bb)
			{
				pp=1;
				break;
			}
			nw=b[rb]-'a';
			rb++;
		}
		else
		{
			if(rc==cc)
			{
				pp=0;
				break;
			}
			nw=c[rc]-'a';
			rc++;
		}
	}
	printf("%c",nw+'A');
}

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

if N == 1:
    print(0)
    quit()
start = N - 1
moves = []
for i in range(N-1, 0, -1):
    if H[i] <= H[i-1]:
        continue
    moves.append(start - i)
    start = i - 1
if H[1] <= H[0]:
    moves.append(start - i + 1)
print(max(moves))


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
typedef pair <string, string> pss;
typedef long long ll;

const int N = 18 + 1;
int n;
ll ans;
string s1, s2, s;
map <pss, int> mp;

pss solve(int msk) {
	string tmp1, tmp2;
	for (int i = 0; i < n; i++)
		if (msk & (1LL << i))
			tmp1 += s[n + i];
		else
			tmp2 += s[n + i];
	
	reverse(tmp1.begin(), tmp1.end());
	reverse(tmp2.begin(), tmp2.end());
	return pss(tmp1, tmp2);
}

void solve2(int msk) {
	string tmp1, tmp2;
	for (int i = 0; i < n; i++)
		if (msk & (1LL << i))
			tmp1 += s[i];
		else
			tmp2 += s[i];
	
	ans += mp[pss(tmp1, tmp2)];
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n >> s;
	for (int i = 0; i < n; i++)
		s1 += s[i];
	for (int i = n; i < n; i++)
		s2 += s[i];
	
	for (int msk = 0; msk < (1LL << n); msk++) {
		pss p = solve(msk);
//		cout << p.first << " " << p.second << endl;
		mp[p]++;
	}
	
	for (int msk = 0; msk < (1LL << n); msk++)
		solve2(msk);
	cout << ans;
}

Measured memory_bytes: 87040