akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
using namespace std;

//------- 大きな数の (a * b) % m -----------
long long modMult(long long a, long long b, long long m) {
    long long res = 0;
    long long exp = a % m;
    while (b) {
        if (b & 1) {
            res += exp;
            if (res > m) res -= m;
        }
        exp <<= 1;
        if (exp > m) exp -= m;
        b >>= 1;
    }
    return res;
}

//-------- べき剰余 (a ^ b) % m --------------------
long long powMod(long long a, long long b, long long m) {
    long long res = 1;
    long long exp = a % m;
    while (b) {
        if (b & 1) res = modMult(res, exp, m);
        exp = modMult(exp, exp, m);
        b >>= 1;
    }
    return res;
}

int main(int argc, const char * argv[]) {
    long long int waru = pow(10,9.0) + 7;
    
    int n;
    cin >> n;
    int a[n];
    for (int i=0; i<n; i++) {
        cin >> a[i];
    }
    map<int,int> mp;
    for (int i=0; i<n; i++) {
        mp[a[i]]++;
    }
    bool flag = true;
    if(n%2 == 0){
        for (int i=0; i<n; i++) {
            if(mp[a[i]] != 2) flag = false;
        }
    }else{
        for (int i=0; i<n; i++) {
            if(a[i]== 0 && mp[a[i]] != 1) flag = false;
            else if(a[i]!= 0 && mp[a[i]] != 2) flag = false;
        }
    }
    long long ans = powMod(2, n/2, waru);
    if(flag) cout << ans % waru << endl;
    else cout << 0;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); ++i)
#define per(i,n) for(int i = (n)-1; i >= 0; --i)
#define rng(i,a,b) for(int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

vector<int> isPrime;
vector<int> primes;
void init(int N=2000000) {
    isPrime.assign(N,true);
    isPrime[0] = isPrime[1] = false;
    for (int p = 2; p < N; ++p) {
        if (isPrime[p] == false) continue;
        primes.push_back(p);
        for (int q = 2*p; q < N; q += p) {
            isPrime[q] = false;
        }
    }
}

int main() {
    ll n, ans = 0; cin >> n;
    init(sqrt(n)+10);
    for (auto p : primes) {
        if (n % p != 0) continue;
        ll cnt = 0, N = n;
        while (N % p == 0) cnt++, N /= p;
        rng(i,1,60) {
            if (n % ll(pow(p,i)) == 0) {
                n /= pow(p,i);
                ans++;
            }
        }
        while (n % p == 0) n /= p;
    }
    if (n != 1) ans++;
    cout << ans << endl;
    return 0;
}


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

using i64 = int64_t;

constexpr int N = 2000;
constexpr int M = 20000;

bool match(char c1, char c2){
    return (c1 == '?' || c2 == '?' || c1 == c2);
}

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

    vector<bool> ab(M), bc(M), ac(M);
    for(int i=0;i<a.size();++i){
        for(int j=0;j<b.size();++j){
            if(!match(a[i], b[j]))ab[i-j+M/2] = true;
        }
    }
    for(int i=0;i<a.size();++i){
        for(int j=0;j<c.size();++j){
            if(!match(a[i], c[j]))ac[i-j+M/2] = true;
        }
    }
    for(int i=0;i<b.size();++i){
        for(int j=0;j<c.size();++j){
            if(!match(b[i], c[j]))bc[i-j+M/2] = true;
        }
    }

    int ans = 3*N;
    for(int i=-2*N;i<=2*N;++i){
        for(int j=-2*N;j<=2*N;++j){
            if(!ab[i+M/2] && !ac[j+M/2] && !bc[j-i+M/2]){
                int left = min({0, i, j});
                int right = max({(int)a.size(), i+(int)b.size(), j+(int)c.size()});
                ans = min(ans, right - left);
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  unsigned int key;
  struct node *next;
  struct node *prev;
};
 
typedef struct node * NodePointer;
 
NodePointer nil;
 
NodePointer listSearch(int key){
  NodePointer x;
  x=nil->next;
  while (x!=nil && x->key!=key){
    x=x->next;
  }
  return x;
}
 
void init(){
  nil = malloc(sizeof(struct node));
  nil->next = nil;
  nil->prev = nil;
}
 
void printList(){
  NodePointer cur = nil->next;
  int isf = 1;
  while(1){
    if ( cur == nil ) break;
    if ( isf == 0)  printf(" ");
    printf("%d", cur->key);
    cur = cur->next;
    isf = 0;
  }
  printf("\n");
}
 
void deleteNode(NodePointer t){
  t->prev->next=t->next;
  t->next->prev=t->prev;
}
 
void deleteFirst(){
  NodePointer t = nil->next;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void deleteLast(){
  NodePointer t=nil->prev;
  if ( t == nil ) return;
  deleteNode(t);
}
 
void delete(int key){
  NodePointer t;
  if((t=(listSearch(key)))!=NULL){
    if ( t == nil ) return;
    deleteNode(t);
  }
}
 
void insert(int key){
  NodePointer x;
  x = malloc(sizeof(struct node));
  x->key = key;
  x->next=nil->next;
  nil->next->prev=x;
  nil->next=x;
  x->prev=nil;
}
 
int main(){
  int key, n, i;
  int size = 0;
  char com[20];
  int np = 0, nd = 0;
  scanf("%d", &n);
  init();
  for ( i = 0; i < n; i++ ){
    scanf("%s%d", com, &key);
    if ( com[0] == 'i' ) {insert(key); np++; size++;}
    else if ( com[0] == 'd' ) {
      if (strlen(com) > 6){
    if ( com[6] == 'F' ) deleteFirst();
    else if ( com[6] == 'L' ) deleteLast();
      } else {
    delete(key); nd++; 
      }
      size--;
    }
  }
 
  printList();
  return 0;
}

Measured memory_bytes: 34976
#include <bits/stdc++.h>
using namespace std;
int main()
{
 int n;
 cin>>n;
 int arr1[n];
 int arr2[n];
 bool b{0};
 for(int i{0};i<n;i++)
    {
        cin>>arr1[i]>>arr2[i];
        if(i>=2)
        {
            if((arr1[i]==arr2[i])&&(arr1[i-1]==arr2[i-1])&&(arr1[i-2]==arr2[i-2]))
            {
                b=1;
            }
        }
    }
    if(b==1)
    {
        cout<<"Yes";
    }
    else{cout<<"No";}
}


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

const ll MOD = 1000000007;
ll N, M, A[1000], B[1000];
bool row[1000001], col[1000001];

ll solve() {
  REP(i, 0, N) {
    if (row[A[i]]) return 0;
    row[A[i]] = true;
  }
  REP(i, 0, M) {
    if (col[B[i]]) return 0;
    col[B[i]] = true;
  }

  ll ans = 1, cr = 0, cc = 0;
  for (ll k = N * M; k >= 1; k--) {
    ll r = row[k], c = col[k];
    if (row[k] && col[k]) {
      cr++;
      cc++;
    } else if (row[k] && !col[k]) {
      (ans *= cc) %= MOD;
      cr++;
    } else if (!row[k] && col[k]) {
      (ans *= cr) %= MOD;
      cc++;
    } else {
      ll t = N * M - k, x = (cr * cc) - t;
      (ans *= x) %= MOD;
    }
  }
  return ans;
}

int main(void) {
  cin >> N >> M;
  REP(i, 0, N) cin >> A[i];
  REP(i, 0, M) cin >> B[i];

  cout << solve() << endl;
}

Measured memory_bytes: 256
# coding:utf-8

import sys


input = sys.stdin.readline
INF = float('inf')
MOD = 10 ** 9 + 7


def inpl(): return list(map(int, input().split()))


n, k = inpl()
H = inpl()

dp = [INF] * n
dp[0] = 0

for i in range(n):
    for j in range(1, k + 1):
        if i + j < n:
            dp[i + j] = min(dp[i + j], abs(H[i + j] - H[i]) + dp[i])

print(dp[n - 1])


Measured memory_bytes: 55260
import itertools

N = input()
K = int(input())
lN = len(N)


if K == 1:
    ans = int(N[0])+9*(lN-1)
    print(ans)

elif K == 2:
    not0 = 1000
    for i in range(1,lN):
        if int(N[i]) != 0:
            not0 = i
            break

    ans = 0
    n = [i for i in range(lN)]

    for v in itertools.combinations(n,2):
        #print(v)
        if v[0] != 0:
            ans += 9*9
        else:
            if not0 == v[1]:
                ans += max(0,int(N[0])-1)*9 + int(N[v[1]])
            elif not0 < v[1]:
                ans += int(N[0])*9
            else:
                ans += max(0,int(N[0])-1)*9
    print(ans)

else:
    not0f = 1000
    not0s = 1000
    for i in range(1,lN):
        if int(N[i]) != 0:
            not0f = i
            break
    for i in range(not0f+1,lN):
        if int(N[i]) != 0:
            not0s = i
            break
    ans = 0
    n = [i for i in range(lN)]
    for v in itertools.combinations(n,3):
        if v[0] != 0:
            ans += 9*9*9
        else:
            if not0f == v[1]:
                if not0s == v[2]:
                    ans += max(0,int(N[0])-1)*9*9
                    ans += max(0,int(N[v[1]])-1)*9
                    ans += int(N[v[2]])
                elif not0s < v[2]:
                    ans += max(0,int(N[0])-1)*9*9
                    ans += int(N[v[1]])*9
                    #ans += int(N[0])*int(N[v[1]])*9
                else:
                    ans += max(0,int(N[0])-1)*9*9
                    ans += max(0,int(N[v[1]])-1)*9
            elif not0f < v[1]:
                ans += int(N[0])*9*9
            else:
                ans += max(0,int(N[0])-1)*9*9

    print(ans)


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

int main()
{
    string s;
    int a=0;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='+'){
            a++;
        }else{
            a--;
        }
    }
    cout<<a<<endl;
}

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

int main(){
  int64_t Lucas;
  int N;
  cin >> N;
  vector<int64_t> two;
  two = {2,1};
  if(N==1){
    cout << 1 << endl;
  }
  if(N!=1){
  for(int i=0;i<N-1;i++){
    Lucas = two.at(0) + two.at(1);
    two.at(0) = two.at(1);
    two.at(1) = Lucas;
  }
  cout << Lucas << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <sstream>

using namespace std;

int main() {
    int a,b;

    cin >> a >> b;

    if(a + b < 24){
        cout << a + b << endl;
    }
    else {
        cout << a + b - 24 << endl; 
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <mylib.h>
using namespace std;
//cin.sync_with_stdio(false);

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define FOR_EQ(i,a,b) for(int i = (a); i <= (b); ++i)
#define FOR_RE(i,a,b) for(int i = (a); i > (b); --i)
#define rep(i,n) FOR(i,0,n)
#define rep_eq(i,n) FOR_EQ(i,0,n)
#define rep_re(i,n) FOR_RE(i,n,0)

#define WHITE 1//（未訪問）
#define GRAY 2//（訪問）未だに訪問していない頂点への辺を持っている。スタックに退避。
#define BLACK 3//（訪問完了）未訪問への頂点への辺を持たない
#define N 100
#define INFTY (1 << 21) //10^21
int M[N][N];//隣接行列
int color[N];

//1個上から時計周り
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
//上右下左
const int dx[4] = {0, 1, 0, -1};
const int dy[4] = {1, 0, -1, 0};
static const int NIL = -1;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> Vector;
typedef vector<Vector>	DVector;
int n;

//配列の表示
void printArray(int array[], int n){
    rep(i, n){
        if(i)   cout << " ";
        cout << array[i];
    }
    cout << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    int ud, lr;
    ud = ty - sy;
    lr = tx - sx;
    
    rep(i, ud){
        cout << "U";
    }
    lr++;
    rep(i, lr){
        cout << "R";
    }
    ud++;
    rep(i, ud){
        cout << "D";
    }
    rep(i, lr){
        cout << "L";
    }
    rep(i, 1){
        cout << "U";
    }
    //
    rep(i, 1){
        cout << "L";
    }
    rep(i, ud){
        cout << "U";
    }
    rep(i, lr){
        cout << "R";
    }
    rep(i, ud){
        cout << "D";
    }
    lr--;
    rep(i, lr){
        cout << "L";
    }
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <cctype>
#include <complex>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second
using ll = long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

int N;
vector<int> G[114514];
int root = -1;

PII dfs(int v, int p){
	int cnt = 0;
	PII ret = {0, 0};
	REP(i, G[v].size()){
		if(G[v][i] == p) continue;
		PII r = dfs(G[v][i], v);
		if(r.sc == 0){
			cnt++;
			ret.fs += r.fs;
		}else{
			ret.sc = 1;
			ret.fs += r.fs;
		}
	}
	if(cnt) ret.fs--;
	if(ret.fs == 0 && ret.sc == 0)
		ret.fs = 1;
	if(G[v].size()-(p!=-1) > 1)
		ret.sc = 1;
	return ret;
}

int main(void){
	cin >> N;
	REP(i, N-1){
		int u, v;
		cin >> u >> v;
		G[u].push_back(v);
		G[v].push_back(u);
	}
	REP(i, N){
		if(G[i].size() > 2){
			root = i;
			break;
		}
	}
	if(root == -1){
		cout << 1 << endl;
		return 0;
	}
	cout << dfs(root, -1).fs << endl;
	return 0;
}


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

#define int long long
#define ll long long
#define f1(i,a,b) for(int i=a;i<b;i++)
#define f2(i,a,b) for(int i=a;i>=b;i--)
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair

const int mod=1000000007;
ll temp;

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,m;
    cin>>n>>m;
    int a[n];
    int sum = 0;
    f1(i,0,n)
    {
        cin>>a[i];
        sum+=a[i];
    }
    long double num = (long double)sum/(4.00*m);
    int ans = 0;
    f1(i,0,n)
    {
        if(a[i]>=num)
        ans++;
    }
    if(ans>=m)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;

    return 0;
}

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

int main() {
  int N, K;
  cin >> N >> K;
  vector<int> h(N);
  for (int i = 0; i < N; i++) cin >> h[i];
  sort(h.begin(), h.end());
  int res = 1000000000;
  for (int i = K - 1; i < N; i++) {
    if (res > h[i] - h[i - K + 1]) res = h[i] - h[i - K + 1];
  }
  cout << res << endl;
}


Measured memory_bytes: 640
#include <algorithm>
#include<iostream>
#include<vector>
#include<deque>
#include<queue>
#include<list>
#include<stack>
#include<map>
#include<set>
#include<string>
#include <sstream>
#include<bitset>

#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<limits.h>

using namespace std;
const int INF = 0x7fffffff;

int gcd(int x,int y){
  int mi,ma;
  ma = max(x,y);
  mi = min(x,y);
  if(ma % mi == 0){
    return mi;
  }
  else{
    return gcd(mi,ma % mi);
  }
}

int main(){
  long ii,jj,kk;
  vector<int> a;
  int n,q;
  int x,y;
  cin >> n >> q;

  a.resize(n);

  for(ii=0;ii<n;ii++){
    a[ii] = 0;
  }

  //cout << "========" << endl;
  //for(ii=0;ii<n;ii++){
  //  cout << a[ii] << endl;
  //}  
  int qq;

  for(ii=0;ii<q;ii++){

    cin >> qq;

    //cout << "q:" << q << " " << qq << endl;

    if(qq == 0){
      cin >> x >> y;

      a[x-1] += y;
      //cout << y << endl;
    }
    
    else{

      cin >> x >> y;

      //cout << "x:" << x <<"y:" << y << endl;
      int sum = 0;

      for(jj=x-1;jj<y;jj++){
        sum+=a[jj];
      }
      
      cout << sum << endl;

    }

    
  }

  //cout << "========" << endl;
  //for(ii=0;ii<n;ii++){
  //  cout << a[ii] << endl;
  //}
  
  return 0;
}



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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define For(i, a, b) for(int i = (a); i < (b); ++i)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
typedef vector<int> vint;
typedef vector<long long> vlint;
typedef vector<string> vstr;
typedef vector<char> vchar;
typedef vector<vector<long long>> vlint2;

lint powint(lint x, lint y){
    int ret = 1;
    for (int i=0; i < y; i++) ret *= x;
    return ret;
};

lint mod = 1000000007;
vector<int> dx = {1, 0, 0, -1, 1, 1, -1, -1};
vector<int> dy = {0, -1, 1, 0, 1, -1, 1, -1};

map<char, long long> counter(string s){
    map<char, long long> count;
    rep(i, s.size()){
        count[s[i]] ++;
    }
    return count;
};

int powmod(int x, int y, int m){
    if (y == 0) return 1;
    return ((powint(powmod(x, y>>1, m), 2) % m) * powint(x, (y & 1))) % m;
};

int main() {
    string s; cin >> s;
    lint n = s.size();
    lint p = 2019;

    map<int, lint> cnt;
    lint ans = 0;
    int a = 0;
    cnt[0] ++;
    For(i, 1, n+1){
        a = (a + (int)(s[n-i] - '0') * powmod(10, i-1, p)) % p;
        cnt[a] ++;
    }
    for (auto i = cnt.begin(); i != cnt.end(); ++i){
        ans += (i -> second) * ((i -> second)-1)/2;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3732
from collections import Counter
import sys

n, m, k = map(int, input().split())
F = [[] for _ in range(n)]
B = [[0] for _ in range(n)]

sys.setrecursionlimit(10**9)

for _ in range(m):
    a, b = map(int, input().split())
    F[a-1].append(b)
    F[b-1].append(a)

rks = [0]*(n)

def dfs(s,r):
    if rks[s] == 0:
        rks[s] = r
    for i in F[s]:
        if rks[i-1] != 0:
            continue
        dfs(i-1,r)

r = 0
for i in range(n):
    if rks[i] == 0:
        r += 1
        dfs(i,r)

for _ in range(k):
    c, d = map(int, input().split())
    if rks[c-1] == rks[d-1]:
        B[c-1][0] += 1
        B[d-1][0] += 1

counter = Counter(rks)
for i in range(n):
    print(counter[rks[i]] - len(F[i]) - (B[i][0]) - 1)




Measured memory_bytes: 412596
n,x,m = map(int,input().split())
a = []
a.append(0)
a.append(x)
isBreak = False
for i in range(1,n):
  #tmp = (a[i]**2)%m
  tmp = (a[i]%m)*(a[i]%m)
  tmp = tmp%m
  if tmp==0:
    break
  if tmp in a:
    isBreak = True
    break
  a.append(tmp)
#print(a)
if isBreak:
  i = 1
  while a[i]!=tmp:
    i+=1
  kurikaeshi = len(a) - i
  goukei = sum(a[i:])
  #print(goukei)
  tmp=(n-(len(a)-1))
  #print(tmp//kurikaeshi)
  a.append(tmp//kurikaeshi * goukei)
  #print(a)
  tmp = tmp%kurikaeshi
  if tmp!=0:
    t = sum(a[i:i+tmp])
    a.append(t)
print(sum(a))

Measured memory_bytes: 68400
#include <stdio.h>
#include <stdlib.h>

int main(void) {
  int n, i , j;
  long long *a, diff, max = 0;

  scanf("%d", &n);
  a = malloc(sizeof(long) * n);

  for (i = 0; i < n; i++) {
    scanf("%lld", &a[i]);
  }

  for (i = 0; i < n; i++) {
    for (j = i + 1; j < n; j++) {
      ((a[j] - a[i]) > 0) ? (diff = (a[j] - a[i])) : (diff = (a[i] - a[j]));
      if (max < diff) {
        max = diff;
      }
    }
  }

  printf("%lld\n", max);

  return 0;
}

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

int n;
vector < int > G[105];
int mc[105];

void bfs()
{
    queue < int > que;

    fill_n(mc, 105, -1);
    que.push(1);
    mc[1] = 0;
    
    while ( !que.empty() ) {
        int u = que.front(); que.pop();
        for ( auto &v : G[u] ) {
            if ( mc[v] == -1 ) {
                mc[v] = mc[u] + 1;
                que.push(v);
            }
        }
    }
}

int main()
{
    cin >> n;
    for ( int i = 0; i < n; i++ ) {
        int u, k;
        cin >> u >> k;
        for ( int j = 0; j < k; j++ ) {
            int v;
            cin >> v;
            G[u].push_back(v);
        }
    }
    
    bfs();

    for ( int i = 1; i <= n; i++ ) {
        cout << i << " " << mc[i] << endl;
    }

    return (0);
}



Measured memory_bytes: 3092
# Coding is about expressing your feeling and there is always a better way to express your feeling _feelme
import sys,math,numpy as np
#sys.stdin,sys.stdout=open('input.txt','r'),open('output.txt','w')
from sys import stdin,stdout;mod=int(1e9 + 7);from statistics import mode
from collections import *;from math import ceil,floor,inf,factorial,gcd,log2,sqrt
ii1=lambda:int(stdin.readline().strip())
is1=lambda:stdin.readline().strip()
iia=lambda:list(map(int,stdin.readline().strip().split()))
isa=lambda:stdin.readline().strip().split()
# print('{:.3f}'.format(1),round(1.123456789,4))
# np.set_printoptions(sign=' ',legacy='1.13') # legacy add space at sign position
# sys.setrecursionlimit(500000)
def lcm(a,b): return (a*b)//gcd(a,b)
def setbits(n):return bin(n).count('1')
def resetbits(n):return bin(n).count('0')
def modinv(n,p):return pow(n,p-2,p)
def ncr(n,r):
    num,den=1,1;r=min(n,n-r)
    for i in range(r):num*=(n-i);den*=(i+1)
    return num//den
def ncr_p(n, r, p):
    num,den=1,1;r=min(r,n-r)
    for i in range(r):num = (num * (n - i)) % p ;den = (den * (i + 1)) % p
    return (num * modinv(den,p)) % p
def isPrime(num) :
    if num<=1:return False
    if num==2 or n==3:return True
    if (num % 2 == 0 or num % 3 == 0) :return False
    m = int(num**0.5)+1
    for i in range(5,m,6):
        if (num % i == 0 or num % (i + 2) == 0) :return False
    return True
def bin_search(arr, low, high, val):
    while low <= high:
        mid = low + (high - low) // 2;
        if arr[mid] == val:return mid
        elif arr[mid] < val:low = mid + 1
        else:high = mid - 1
    return -1
def sumofdigit(num):
    count=0;
    while num : count+=num % 10;num //= 10;
    return count;
def inputmatrix():
    r,c=iia();mat=[0]*r;
    for i in range(r):mat[i]=iia();
    return r,c,mat;
def prefix_sum(n,arr):
    for i in range(1,n):arr[i]+=arr[i-1]
    return arr;
def binomial(n, k):
    if 0 <= k <= n:
        ntok = 1;ktok = 1
        for t in range(1, min(k, n - k) + 1):ntok *= n;ktok *= t;n -= 1
        return ntok // ktok
    else:return 0
def divisors(n):
    res = [];
    for i in range(1,ceil(sqrt(n))+1):
        if n%i == 0:
            if i==n//i:res.append(i)
            else:res.append(i);res.append(n//i)
    return res;

n,d=iia()
count=0
for i in range(n):
    a,b=iia()
    if a**2 + b**2<=d*d:
        count+=1
print(count)




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

int main(){
  int N; cin >> N;
  string str;
  set<string> S;
  for (int i = 0; i < N; i++){
    cin >> str;
    S.insert(str);
  }
  cout << S.size() << endl;
  return 0;
}

Measured memory_bytes: 19220
//56
#include<iostream>
#include<algorithm>

using namespace std;

#define INF (1<<29)

int main(){
  for(int n,m;cin>>n>>m,n|m;){
    int cm[101][101];
    int tm[101][101];
    fill_n(cm[0],101*101,INF);
    fill_n(tm[0],101*101,INF);
    for(int i=1;i<=100;i++){
      cm[i][i]=tm[i][i]=0;
    }
    for(int i=0;i<n;i++){
      int a,b,c,t;
      cin>>a>>b>>c>>t;
      tm[a][b]=tm[b][a]=t;
      cm[a][b]=cm[b][a]=c;
    }
    for(int k=1;k<=100;k++){
      for(int j=1;j<=100;j++){
	for(int i=1;i<=100;i++){
	  tm[i][j]=min(tm[i][j],tm[i][k]+tm[k][j]);
	  cm[i][j]=min(cm[i][j],cm[i][k]+cm[k][j]);
	}
      }
    }
    int k;
    cin>>k;
    while(k--){
      int p,q,r;
      cin>>p>>q>>r;
      cout<<((r)?tm:cm)[p][q]<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
A = input().split()

N = int(A[0])
K = int(A[1])

A = input().split()
l = []

for n in range(N):
    l.append(int(A[n]))

l.sort(reverse=True)
sum=0
for i in range(K):
    sum = sum + l[i]
print(sum)


Measured memory_bytes: 3060
{-
This code was written after reading the editorial.
-}

import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import Data.List

solve :: Int -> Int -> [[Int]] -> Int
solve n m abs = count $ trim $ map head
                   $ groupBy (\[a1,_] [a2,_] -> a1 == a2) $ sort abs

trim :: [[Int]] -> [[Int]]
trim [] = []
trim [x] = [x]
trim ([a1,b1] : sabs)
  | b1 >= b2 = sabs'
  | otherwise = [a1,b1] : sabs'
  where sabs'@([_,b2] : _) = trim sabs

count :: [[Int]] -> Int
count = sum . unfoldr f
  where
    f [] = Nothing
    f ([a,b] : sabs) = Just (1, remove b sabs)
      where remove b [] = []
            remove b all@([a1,b1] : sabs) | b <= a1 = all
                                          | otherwise = remove b sabs

bsReadInts :: B.ByteString -> [Int]
bsReadInts = map (fst . fromJust . B.readInt) . B.words

main :: IO ()
main = do
  conts <- B.getContents
  let [n, m] : abs = map bsReadInts (B.lines conts)
      answer = solve n m abs
  putStrLn (show answer)


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

AB = [[int(_) for _ in input().split()] for i in range(N)]
CD = [[int(_) for _ in input().split()] + [0, ] for i in range(N)]
AB.sort(reverse=True)
CD.sort(reverse=True)
ans = 0
for a, b in AB:
    # for c, d, f in CD:
    min_idx = -1
    min_val = 1e10

    for i in range(N):
        c, d, f = CD[i]
        if f: continue
        if c <= a and d <= b: break
        if c <= a or d <= b: continue
        if min_val > d:
            min_val = d
            min_idx = i
    if min_idx >= 0:
        ans += 1
        CD[min_idx][2] = 1
        #print('pare:', (a, b), CD[min_idx])
print(ans)

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

#define llint long long int

using namespace std;

int main(){
    int N, A;

    cin >> N;

    for(int i = 0; i < N; i ++){
        cin >> A;

        if(A % 2 == 0){
            if(A % 3 != 0 && A % 5 != 0){
                cout << "DENIED" << endl;

                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
  int N = sc.nextInt();
  int A = sc.nextInt();
  int B = sc.nextInt();
  if(N*A <= B){System.out.println(N*A);}
  else{System.out.println(B);}
}
}


Measured memory_bytes: 21972
package main

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

var sc *bufio.Scanner

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt()
	a := make([][][]int, 4)
	for i := 0; i < 4; i++ {
		a[i] = make([][]int, 3)
		for j := 0; j < 3; j++ {
			a[i][j] = make([]int, 10)
		}
	}

	for i := 0; i < n; i++ {
		b, f, r, v := nextInt(), nextInt(), nextInt(), nextInt()
		a[b-1][f-1][r-1] += v
	}

	for i := 0; i < 4; i++ {
		for j := 0; j < 3; j++ {
			for k := 0; k < 10; k++ {
				fmt.Printf(" %d", a[i][j][k])
			}
			fmt.Println("")
		}
		if i == 3 {
			break
		}
		fmt.Print("####################\n")
	}
}



Measured memory_bytes: 1104
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {

    public static void main(String[] args) throws IOException {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        InputReader.OutputWriter out = new InputReader.OutputWriter(outputStream);

        long n = in.nextLong();
        long m = in.nextLong();
        if(n%m == 0) {
            out.println(0);
        }
        else {
            if(n < m) {
                out.println(Math.min(n,m-n));
            }
            else {
                long min = n/m;
                out.println(Math.min(n-min*m,++min*m-n));
            }
        }
        out.flush();
    }
}

class Interval {
    int start;
    int end;

    public int getStart() {
        return start;
    }

    public int getEnd() {
        return end;
    }

    public Interval(int start, int end) {
        this.start = start;
        this.end = end;
    }

    @Override
    public String toString() {
        return
                "start=" + start +
                ", end=" + end +
                '}';
    }
}


class InputReader extends BufferedReader {
    StringTokenizer tokenizer;

    public InputReader(InputStream inputStream) {
        super(new InputStreamReader(inputStream), 32768);
    }

    public InputReader(String filename) {
        super(new InputStreamReader(Thread.currentThread().getContextClassLoader().getResourceAsStream(filename)));
    }

    public String next() {
        while (tokenizer == null || !tokenizer.hasMoreTokens()) {
            try {
                tokenizer = new StringTokenizer(readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return tokenizer.nextToken();
    }

    public Integer nextInt(){
        return Integer.valueOf(next());
    }
    public Long nextLong() {
        return  Long.valueOf(next());
    }
    public Double nextDouble() {
        return Double.valueOf(next());
    }
    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream outputStream) {
            super(outputStream);
        }

        public OutputWriter(Writer writer) {
            super(writer);
        }

        public OutputWriter(String filename) throws FileNotFoundException {
            super(filename);
        }

        public void close() {
            super.close();
        }
    }
}


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

int dp(vector<int>& h, vector<int>& mem, int n) {

    if(n == 0 || n == 1) {
        mem[n] = abs(h[n] - h[0]);
        return mem[n];
    }
    int x = mem[n-1] > -1 ? mem[n-1] : dp(h, mem, n-1);
    int y = mem[n-2] > -1 ? mem[n-2] : dp(h, mem, n-2);
    mem[n] = min(x + abs(h[n]-h[n-1]), y + abs(h[n]-h[n-2]));
    
}

int main() {
    int n;
    cin >> n;
    vector<int> height(n, 0);
    vector<int> mem(n, -1);
    for(int i = 0; i < n; i++) {
        cin >> height[i];
    }
    dp(height, mem, n-1);
    cout << mem[n-1];

    return 0;
} 

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#define ll long long
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define Mod 998244353
#define pi 3.14159265358979323846
#define endl '\n'
#define IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
typedef vector<ll> vll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;

int main()
{
    string s;
    cin>>s;
    if(s[s.size()-1]!='s') cout<<s+'s'<<endl;
    else cout<<s+"es"<<endl;
    return 0;
}


Measured memory_bytes: 3644
using System;

class Program {
  static void Main() {
    var s = Console.ReadLine().Split();
    if (s[0][s[0].Length-1]==s[1][0] && s[1][s[1].Length-1] == s[2][0]) {
      Console.WriteLine("YES");
    } else {
      Console.WriteLine("NO");
    }
  }
}

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

int main(){
    int N, D;
    std::cin >> N >> D;
    std::vector< int > X(N);
    std::vector< int > Y(N);
    for(int i=0; i<N; i++){
        std::cin >> X[i] >> Y[i];
    }
    
    int cnt = 0;
    for(int i=0; i<N; i++){
        double dist = std::sqrt((double)((long long)X[i] * (long long)X[i] + (long long)Y[i] * (long long)Y[i]));
        if(D >= dist){
            cnt++;
        }
    }
    std::cout << cnt << std::endl;
    
    return 0;
}



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

ll N;
string ans = "";

ll powll(ll num, ll count) {
    ll temp = 1;
    for (int i = 0; i < count; i++) temp *= num;
    return temp;
}

int main() {
    scanf("%Ld", &N);
    ll pool = 0;
    ll i = 0;
    ll Ntemp = N;
    if (N == 0) {
        cout << 0 << endl;
        return 0;
    }
    for (ll i = 0; pool != N; i++) {
        if (Ntemp % powll(2, i+1)) {
            ans = "1" + ans;
            pool += powll(-2, i);
            Ntemp -= powll(-2, i);
        }
        else ans = "0" + ans;
    }
    cout << ans << endl;
}

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

int main(){
    int n;
    double p1 = 0, p2 = 0, p3 = 0, p00 = -1;
    cin >> n;
    vector<int> xi;
    vector<int> yi;
    int i = n;
    int temp;
    while (i --> 0) {
        cin >> temp;
        xi.push_back(temp);
    }
    while (n --> 0) {
        cin >> temp;
        yi.push_back(temp);
    }
    for (auto i1 = xi.begin(), i2 = yi.begin(); i1 != xi.end() && i2 != yi.end(); ++i1, ++i2) {
        p1 += abs(*i1 - *i2);
        p2 += pow(*i1 - *i2, 2);
        p3 += pow(abs(*i1 - *i2), 3);
        p00 = max(p00, (double)abs(*i1 - *i2));
    }
    p2 = pow(p2, 1/(double)2);
    p3 = pow(p3, 1/(double)3);

    printf("%.6f\n", p1);
    printf("%.6f\n", p2);
    printf("%.6f\n", p3);
    printf("%.6f\n", p00);
}


Measured memory_bytes: 3432
/*
读题不规范，爆零两行泪。
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include<bits/stdc++.h>
using namespace std;
#define urd uniform_real_distribution
mt19937 rng(19260817);
double sq(double x){return x*x;}
const int N=60;
int n,m;
double x[N+1],y[N+1],c[N+1];
double a[N+1];
double calc(double x0,double y0){
	for(int i=1;i<=n;i++)a[i]=c[i]*sqrt(sq(x[i]-x0)+sq(y[i]-y0));
	sort(a+1,a+n+1);
	return a[m];
}
double sim_ann(double st,double ed,double delta){
	double x0=0,y0=0,res=calc(0,0);
//	int cnt=0;
	for(double tem=st;tem>=ed;tem*=delta){
		double nw_x=x0+(urd<>(0,10000)(rng)-urd<>(0,10000)(rng))*tem;
		double nw_y=y0+(urd<>(0,10000)(rng)-urd<>(0,10000)(rng))*tem;
		double nw=calc(nw_x,nw_y);
		if(nw<res||urd<>(0,1)(rng)<=exp((res-nw)/tem))x0=nw_x,y0=nw_y,res=nw;
//		if((++cnt)%100==0)printf("tem=%.5lf x=%.5lf y=%.5lf res=%.5lf\n",tem,x0,y0,res);
	}
	return res;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<=n;i++)cin>>x[i]>>y[i]>>c[i];
	double ans=sim_ann(1e4,1e-10,.9999);
	rng=mt19937(114514);
	ans=min(ans,sim_ann(1e4,1e-10,.9999));
	printf("%.10lf",ans);
	return 0;
}

Measured memory_bytes: 4388
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      int A, B, C, D;
      cin >> A >> B >> C >> D;
      
      if ((A+B) == (C+D)){
        cout << "Balanced" << endl;
      }
      if ((A+B)<(C+D)){
        cout << "Right" << endl;
      }
      if ((A+B)>(C+D)){
        cout << "Left" << endl;
      }
    }

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
#define INF 1e9 //10^9
#define MOD 1000000007
#define INFL 100000000000000000//10^18 = 2^60


int main(void){
    string a,b,c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        string s;
        cin >> s;
        for(i=0;i<s.length();i++){
                s[i] = 'x';
        }
        cout << s << endl; 
        return 0;
}



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

int main(){
    int N; cin>>N;
    int n = N;
    int S=0;
    while(n > 0){
        int tmp = n % 10;
        S += tmp;
        n /= 10;
    }
    if(N % S == 0) cout<< "Yes" << endl;
    else cout<< "No" << endl;
    // int S;
    // for(int i=0;i<s.size();i++){
    //     S += stoi(s[i]);
    // }
    // int a = stoi(s);

    // cout<<s[1]<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//typedef __int128_t LL;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define F first
#define S second
#define pb push_back
mt19937 rnd;


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
#endif

    int a, b, c, k;
    cin >> a >> b >> c >> k;
    int ans = 0;
    while (a >= b) {
        b *= 2;
        ans++;
    }
    while (b >= c) {
        c *= 2;
        ans++;
    }
    if (ans <= k) cout << "Yes\n";
    else cout << "No\n";

#ifdef LOCAL
    cerr << "\nTime elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
    return 0;
}


Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 9999999999
#define m0(x) memset(x,0,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define p(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
//#define int long long


using namespace std;


int dy[4] = { 0,0,1,-1 };
int dx[4] = { 1,-1,0,0 };
int dxx[8] = { 0,0,1,1,1,-1,-1,-1 };
int dyy[8] = { 1,-1,0,1,-1,0,1,-1 };




ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}

ll myPow(ll x, ll n, ll m) {
	if (n == 0)
		return 1;
	if (n % 2 == 0)
		return myPow(x * x % m, n / 2, m);
	else
		return x * myPow(x, n - 1, m) % m;
}

ll pow2(ll a, ll n) {//aのn乗を計算します。
	ll x = 1;
	while (n > 0) {//全てのbitが捨てられるまで。
		if (n & 1) {//1番右のbitが1のとき。
			x = x * a;
		}
		a = a * a;
		n >>= 1;//bit全体を右に1つシフトして一番右を捨てる。
	}
	return x;
}

long long nCr(int n, int r) {
	if (r > n / 2) r = n - r; // because C(n, r) == C(n, n - r)
	long long ans = 1;
	int i;

	for (i = 1; i <= r; i++) {
		ans *= n - r + i;
		ans /= i;
	}

	return ans;
}


const int MOD = 1000000007;

bool arr[1050000];
int sosuu[100010];
void Eratosthenes() {
	ll N = 1050000;
	int c = 0;
	for (int i = 0; i < N; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < sqrt(N); i++) {
		if (arr[i]) {
			for (int j = 0; i * (j + 2) < N; j++) {
				arr[i *(j + 2)] = 0;
			}
		}
	}

	for (int i = 2; i < N; i++) {
		if (arr[i]) {
			sosuu[c] = i;
			//cout << sosuu[c] << " ";
			c++;
		}
	}
	//cout << endl;
	//cout << c << endl;
}


bool prime(ll n) {
	if (n == 1)return false;
	if (n == 2)return true;
	for (int i = 2; i < (int)sqrt(n) + 1;i++) {
		if (n%i == 0)return false;
	}
	return true;
}
map<ll, int>mp;
int main() {
	ll N, P;
	cin >> N >> P;
	if (N == 1) {
		p(P);
		return 0;
	}
	ll x = P;
	if (P == 1) {
		p(1);
		return 0;
	}
	while (x >= 2) {
		for (ll i = 2; i < (ll)sqrt(P) + 1; i++) {
			if (x%i == 0) {
				mp[i]++;
				x /= i;
				break;
			}
			if (i == (ll)sqrt(P))goto END;
		}
	}
	END:
	ll ans = 1;
	for (auto x : mp) {
		while (x.second / N > 0) {
			ans *= x.first;
			x.second -= N;
		}
	}
	p(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define MOD (1000000007)
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1}; // 移動方向

int N;

void input(){
    cin >> N;
}

int dp[100001];

int rec(int n){
    if(n==0) return 0;
    if(dp[n] != -1) return dp[n];
    int res = n;
    for(int pow6=1;pow6<=n;pow6*=6) res = min(res, rec(n - pow6)+1);
    for(int pow9=1;pow9<=n;pow9*=9) res = min(res, rec(n - pow9)+1);
    return dp[n] = res;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    input();
    for(int i=0;i<100001;i++) dp[i] = -1; //初期化
    cout << rec(N) << endl;
    return 0;
}

Measured memory_bytes: 3712
#include <iostream>
#include <stdio.h>

#include <vector>
#include <cctype>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <string>
#include <map>

using namespace std;


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

    vector<long long> arr(n);
    
    for (int i = 0; i < n; i++) cin >> arr[i];

    int count = 0;

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (arr[i] != arr[j] && arr[k] != arr[j] && arr[i] != arr[k]) {
                    //a+b>c  かつ b+c>a かつ c+a>b
                    if (arr[i] + arr[j] > arr[k] && arr[k] + arr[j] > arr[i] && arr[i] + arr[k] > arr[j]) {
                        count++;
                }
                
                }
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 3592
N = int(input())
A = [int(a) for a in input().split()]
g = 1000
s = 0
for i in range(1, N):
    if A[i] > A[i-1]:
        t = g // A[i-1]
        g -= t * A[i-1]
        s += t
    else:
        g += s * A[i-1]
        s = 0
print(g + s * A[-1])

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

int main() {
  int h, n;
  cin >> h >> n;
  
  bool a = true;
  
  vector<int> vec(n);
  for (int i = 0; i < n; i++){
    cin >> vec.at(i);
  }
  int b = 0;
  
  for (int i = 0; i < n; i++){
    b += vec.at(i);
  }
  if (b < h){
    a = false;
  }
  
  if (a == true){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;
        
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
        
#define print(a) {for(auto xxxxx : (a)) cout << xxxxx << ' '; cout << '\n';}
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

ll next(){ll x; cin >> x; return x;}
const int maxn = 2e5 + 5, intf = 2e9;
const ll inf = 1e18, mod = 998244353;
const ld eps = 1e-9;


void solve(){
  int n; cin >> n;
  vector <int> a(n) , cnt(1e6 + 1 , 0);
  for (auto &x : a){
    cin >> x;
    cnt[x]++;
  }

  int ans = 0;
  for (auto x : a){
    if (x == 1){
      ans += (cnt[1] == 1);
      continue;
    }
    bool flag = (cnt[1] == 0 && cnt[x] == 1);
    for (int i = 2; i*i <= x; i ++){
      if (x % i == 0){
        if (cnt[i] || cnt[x / i]){
          flag = false;
        }
      }
    }
    ans += flag;
  }
  cout << ans << '\n';
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.precision(20);
  
  for (int t = 1; t--;) {
    solve();
  }
        
  return 0;
}
/*

*/


Measured memory_bytes: 7932
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb push_back
#define ppb pop_back
#define ii pair<int,int>
#define ll long long
#define umin(x,y) x=min(x,y)
#define umax(x,y) x=max(x,y)
#define orta ((bas+son)>>1)
#define sz(x) ((int)x.size())
#define all(x) x.begin(),x.end()
#define inf 100000000
#define N 505
#define MOD 998244353
using namespace std;

void no() {printf("-1");exit(0);}

ll solve(vector<int>& a,int l,int r) {

	ll res=0;
	int cur=a[r];

	for(int i=r;i>=l;i--) {

		res+=a[i];

		if(cur) res-=(cur-1),--cur;

	}

	res+=(ll)a[l]*(a[l]-1)/2-(ll)cur*(cur-1)/2;

	return res;

}

int main() {

	int n;

	scanf("%d",&n);

	vector<int> a(n+1);

	for(int i=1;i<=n;i++) {

		scanf("%d",&a[i]);

	}

	if(a[1]) no();

	for(int i=1;i<n;i++) {

		if(a[i+1]>a[i] && a[i+1]-a[i]>1) no();

	}

	ll ans=0;

	for(int i=1;i<=n;i++) {

		int t=i;

		while(i+1<=n && a[i+1]>=a[i]) i++;

		ans+=solve(a,t,i);

	}

	printf("%lld",ans);

}

Measured memory_bytes: 1152
a, b, c, d, e, f = [int(x) for x in input().strip().split()]
a *= 100
b *= 100

water_cands = set()
t = 0
while t <= f:
    water_cands.add(t)
    u = t + b
    while u <= f:
        water_cands.add(u)
        u += b
    t += a

rat, wat, sug = 0.0, a, 0
for w in water_cands:
    if w == 0:
        continue
    suger_limit = min(f - w, w // 100 * e)
    suger_max = 0
    t = 0
    while t <= suger_limit:
        if suger_max < t:
            suger_max = t
        u = t + d
        while u <= suger_limit:
            if suger_max < u:
                suger_max = u
            u += d
        t += c
    if suger_max / (suger_max + w) > rat:
        rat = suger_max / (suger_max + w)
        wat = w
        sug = suger_max

print(wat + sug, sug)


Measured memory_bytes: 3064
#define loop(i, s, e) for(ll i = s;i < e;i++)

#include <iostream>
#include <iomanip>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <algorithm>
#include <map>
#include <cmath>
//#include "vector2d.cpp"

using namespace std;
//using namespace libcgl;
typedef long long signed ll;

long long n,c,v[200000],x[200000],s[2][200000],d[2][200000],ss[2][200000],dd[2][200000];

long long xx(int i) {
    if(i == 0) return 0;
    if(i < 0) return c-x[n+i+1];
    return x[i];
}


long long vv(int i) {
    if(i == 0) return 0;
    if(i < 0) return v[n+i+1];
    return v[i];
}

int main() {
    cin >> n >> c;
    loop(i,1,n+1) { cin >> x[i] >> v[i]; }

    loop(i,1,n+1) {
        s[0][i] = s[0][i-1] + vv(i) - (xx(i) - xx(i-1));
        d[0][i] = d[0][i-1] + vv(-i) - (xx(-i) - xx(-i+1));
        ss[0][i] = max(ss[0][i-1],s[0][i]);
        dd[0][i] = max(dd[0][i-1],d[0][i]);
        s[1][i] = s[1][i-1] + vv(i) - 2 * (xx(i) - xx(i-1));
        d[1][i] = d[1][i-1] + vv(-i) - 2 * (xx(-i) - xx(-i+1));
        ss[1][i] = max(ss[1][i-1],s[1][i]);
        dd[1][i] = max(dd[1][i-1],d[1][i]);
    }

    ll res = 0;
    loop(i,0,n+1) {
        res = max(res,max(ss[1][i] + dd[0][n-i],ss[0][i] + dd[1][n-i]));
    }
    cout << res << endl;
}



Measured memory_bytes: 14336
#define _CRT_SECURE_NO_WARNINGS
#include "bits/stdc++.h"

#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define fr(x) freopen(x,"r",stdin)
#define fw(x) freopen(x,"w",stdout)
#define iout(x) printf("%d\n",x)
#define lout(x) printf("%lld\n",x)
#define REP(x,l,u) for(ll x = l;x<u;x++)
#define RREP(x,l,u) for(ll x = l;x>=u;x--)
#define complete_unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define mst(x,a) memset(x,a,sizeof(x))
#define all(a) a.begin(),a.end()
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define sqr(x) ((x)*(x))
#define lowbit(x) ((x)&(-(x)))
#define lson (ind<<1)
#define rson (ind<<1|1)
#define se second
#define fi first
#define sz(x) ((int)x.size())
#define EX0 exit(0);

typedef  long long ll;
typedef unsigned long long ull;
typedef double db;
typedef long double ld;
using namespace std;
typedef vector<ll> VLL;
typedef vector<int> VI;
const int block_size = 320;
typedef complex<ll> point;
const ll mod = 1e9 + 7;
const ll inf = 1e9 + 7;
const ld eps = 1e-9;
const db PI = atan(1) * 4;

template<typename T, typename S>inline bool upmin(T&a, const S&b) { return a > b ? a = b, 1 : 0; }
template<typename T, typename S>inline bool upmax(T&a, const S&b) { return a < b ? a = b, 1 : 0; }

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a%b); }
ll pow(ll a, ll b) {
	if (b == 0) {
		return 1;
	}
	if (b == 1) {
		return a;
	}
	ll ans = pow(a, b / 2);
	ans *= ans;
	ans *= b % 2 == 1 ? a : 1;
	return ans;
}

namespace SOLVE {
	struct edge {
		ll v1, v2, weight;
	};

	VI id;

	ll parent(ll a) {
		if (id[a] == a) {
			return a;
		}
		id[a] = parent(id[a]);
		return id[a];
	}

	void unite(ll a, ll b) {
		id[parent(a)] = parent(b);
	}

	int query(ll a, ll b) {
		return (parent(a) == parent(b));
	}

	bool comp(edge a, edge b) {
		return a.weight < b.weight;
	}

	void main() {
		ll V, E, a, b, c;
		cin >> V >> E;

		vector<edge> edges;

		REP(i, 0, E) {
			cin >> a >> b >> c;
			edge x;
			x.v1 = a;
			x.v2 = b;
			x.weight = c;
			edges.push_back(x);
		}

		sort(edges.begin(), edges.end(), comp);

		id.resize(V);
		REP(i, 0, V) {
			id[i] = i;
		}

		ll ans = 0;
		for (edge e : edges) {
			if (!query(e.v1, e.v2)) {
				// join them
				unite(e.v1, e.v2);
				// cout << e.v1 << ' ' << e.v2 << ' ' << e.weight << endl;
				ans += e.weight;

			}
		}
		cout << ans << endl;
	}
}


signed main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int t;
	//    in(t);
	t = 1;
	while (t--) {
		SOLVE::main();

	}

	return 0;
}


Measured memory_bytes: 6016
import sys
input = sys.stdin.readline

def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))

def main():
    mod=10**9+7
    N,X,Y=MI()
    X-=1
    Y-=1
    ans=[0]*N
    
    for i in range(N-1):
        for j in range(i+1,N):
            d=min(j-i,abs(X-i)+1+abs(Y-j))
            ans[d-1]+=1
            
    for i in range(N-1):
        print(ans[i])
                
    
    

main()


Measured memory_bytes: 46172
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;

int main()
{  
	long long A,B,C,D;
	cin >> A >> B >>C >>D;
	bool YesFlag=false;

	if((int)ceil((double)A/D)*B>=C){
		YesFlag=true;
	}

	if(YesFlag)	cout<<"Yes" <<endl;
	else cout <<"No"<<endl;
	
	return 0;
}


Measured memory_bytes: 3628