akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <algorithm>
#include <vector>
#include <utility>

using i8 = std::int8_t;
using u8 = std::uint8_t;
using i16 = std::int16_t;
using u16 = std::uint16_t;
using i32 = std::int32_t;
using u32 = std::uint32_t;
using i64 = std::int64_t;
using u64 = std::uint64_t;
using i128 = __int128_t;
using u128 = __uint128_t;
using usize = std::size_t;

char s[200001];

auto main() -> i32 {
	i32 n;
	scanf("%d%s", &n, s);

	i32 r = n - 1;

	i32 ans = 0;
	for (i32 i = 0; i < n; ++i) {
		if (i > r) {
			break;
		}
		if (s[i] == 'W') {
			while (r > i && s[r] == 'W') {
				--r;
			}
			if (i == r) {
				break;
			}
			ans += 1;
			--r;
		}
	}
	printf("%d\n", ans);
	return 0;
}


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

int main()
{
    int n,m;
    cin>>n>>m;
    int a[n],b[n],c[m],d[m],ans[n],k[n];
    for(int i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    for(int i=0;i<m;i++) cin>>c[i]>>d[i];
    
    for(int i=0;i<n;i++) {
        ans[i]=abs(a[i]-c[0])+abs(b[i]-d[0]);
        k[i]=1;
    }
    for(int i=0;i<n;i++){
        for(int j=1;j<m;j++){
            if(abs(a[i]-c[j])+abs(b[i]-d[j]) < ans[i]){
                ans[i]=abs(a[i]-c[j])+abs(b[i]-d[j]);
                k[i]=j+1;
            }
        }
    }
    for(int i=0;i<n;i++) cout<<k[i]<<endl;
    
 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;
typedef long long ll;

const int MOD = 1e9+7;
const int INF = 1e9;
ll N,K,Z;
vector<ll> A,F,T;
bool solve(ll x){
    ll sumb = 0;
    rep(i,N){
        ll B = min(A[i],x/F[i]);
        sumb += B;
    }
    cerr<<x<<" "<<sumb<<endl;
    return sumb>=Z;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    cin>>N>>K;
    A.resize(N);
    F.resize(N);
    ll suma = 0;
    rep(i,N){
        cin>>A[i];
        suma += A[i];
    }
    rep(i,N){
        cin>>F[i];
    }
    Z = suma - K;
    if(Z<=0){
        cout<<0<<endl;
        return 0;
    }
    sort(all(A),greater<ll>());
    sort(all(F));
    /*
    rep(i,N)T.push_back(A[i]*F[i]);
    print(A);print(F);print(T);
    */
    ll ok = 1e13;
    ll ng = -1;

    while(abs(ok-ng)>1){
        ll mid = (ok+ng)/2;
        if(solve(mid)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    cout<<ok<<endl;
}

Measured memory_bytes: 3456
import math
x = input()
x = int(x)
if x in [2,3,5,7]:
    print(x)
elif x == 4:
    print(5)
elif x==6:
    print(7)
elif x==8:
    print(11)
else:
    while 1:
        flag = 0
        if x%2==0:
            x= x+1
            continue
        y = 3
        while y<math.sqrt(x):
            if x%y==0:
                break
            y=y+2
            if y>math.sqrt(x):
                flag=1
                break
        if flag == 1:
            print(x)
            break
        x = x+2


Measured memory_bytes: 3188
N=int(input())
*h,=map(int,input().split())

dp = [0]*N

for i in range(1,N):
  if i == 1:
    dp[i] = dp[0]+abs(h[i]-h[0])
  else:
    dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
    
print(dp[-1])

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

int main(){

  int n;
  cin >> n;
  
  if( n == 1 ){
    
    cout << "Hello World" << endl;
    
  }
  
  else if( n == 2 ){
    int a,b;
    cin >> a >> b;
    
    cout << a+b << endl;
    
  }
  
}

Measured memory_bytes: 256
N = int(input())
temp = input().split()
A = []
for i in range(N):
  A.append(int(temp[i]))
temp = input().split()
B = []
for i in range(N):
  B.append(int(temp[i]))
temp = input().split()
C = []
for i in range(N-1):
  C.append(int(temp[i]))

total = 0
for i in range(N):
  total += B[A[i]-1]
  if(i>=1 and A[i]-A[i-1]==1):
    total += C[A[i-1]-1]
print(total)

Measured memory_bytes: 3064
using System;
using static System.Console;

namespace Main
{
    class Program
    {
        static void Main(string[] args)
        {
            int K = int.Parse(ReadLine());
            int sum = 0;
            for(int i = 0; i < K; i ++)
            {
                for(int j = 0; j < K; j ++)
                {
                    for(int k = 0; k < K; k ++)
                    {
                        sum +=Gcd(i + 1, Gcd(j + 1, k + 1));
                    }
                }
            }
            WriteLine(sum);
        }

        static int Gcd(int a, int b)
        {
            var v = new int[] { a, b };
            while (v[1] != 0) { v = new[] { v[1], v[0] % v[1] }; }
            return v[0];
        }
    }
}


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

int main()
{
  int n;
  cin>>n;
  vector<int> a(n);
  map<int,int> check;
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i);
    if(check.count(a.at(i)))
    {
      cout<<"NO"<<endl;
      return 0;
    }
    else
    {
      check[a.at(i)]=1;
    }
  }
  cout<<"YES"<<endl;
}

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

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

  ll n, t;
  cin >> n >> t;

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

  ll ans = n * t;
  ll dup = 0;
  for (int i = 1; i < n; i++) {
    ll prev = vt.at(i - 1);
    ll curr = vt.at(i);

    if (curr - prev < t) {
      dup += t - (curr - prev);
    }
  }

  cout << ans - dup << endl;

  return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
#include<tuple>
#include<cassert>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(vector<int> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%d%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}
void array_show(vector<LL> &vec_s,int vec_n=-1,char middle=' '){
	if(vec_n==-1)vec_n=vec_s.size();
	for(int i=0;i<vec_n;i++)printf("%lld%c",vec_s[i],(i!=vec_n-1?middle:'\n'));
}

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	cin>>n>>a>>b;
	b=b/n*n;
	if(a<=b)cout<<"OK"<<endl;
	else cout<<"NG"<<endl;
}


Measured memory_bytes: 3592
import sys
readline=sys.stdin.readline
def main():
  N,M=map(int,readline().split())
  mlst = [0] * M
  for i in range(1,M+1):
    _, *tmp = map(int,readline().split())
    for j in tmp:
      mlst[i-1] |= 1<<(j-1)

  def popcnt(n):
      # 求1的个数
      c = (n & 0x5555555555555555) + ((n >> 1) & 0x5555555555555555)
      c = (c & 0x3333333333333333) + ((c >> 2) & 0x3333333333333333)
      c = (c & 0x0f0f0f0f0f0f0f0f) + ((c >> 4) & 0x0f0f0f0f0f0f0f0f)
      c = (c & 0x00ff00ff00ff00ff) + ((c >> 8) & 0x00ff00ff00ff00ff)
      c = (c & 0x0000ffff0000ffff) + ((c >> 16) & 0x0000ffff0000ffff)
      return c


  mod = list(map(int, readline().split()))
  ab = list(zip(mlst, mod))
  res = 0
  for i in range(1<<N):
    for a,b in ab:
      tmp = a & i
      if popcnt(tmp) & 1 != b:
        break
    else:
      res += 1
  print(res)
if __name__ == '__main__':
  main()

Measured memory_bytes: 3064
#[allow(dead_code)]
fn is_whitespace(c: &char) -> bool {
    c.is_whitespace()
}

#[allow(dead_code)]
fn is_eol(c: &char) -> bool {
    ['\r', '\n'].contains(c)
}

#[allow(unused_macros)]
macro_rules! input {
    ($var:ident, $($r:tt)*) => {
        input_inner!{$var, $($r)*}
    };

    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        #[allow(unused_mut, unused_variables, bare_trait_objects)]
        let mut next = move |f: &Fn(&char)->bool| -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|f(&c))
                .take_while(|c|!f(&c))
                .collect()
        };
        input_inner!{next, $($r)*};
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; eol ]) => {
        $next(&is_eol).split(' ').map(|x| x.parse::<$t>().unwrap()).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, parser) => {
        $next
    };

    ($next:expr, $t:ty) => {
        $next(&is_whitespace).parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BinaryHeap, HashMap, HashSet};

#[allow(dead_code)]
struct Edge {
    from: usize,
    to: usize,
}

#[allow(dead_code)]
type Graph = Vec<Vec<usize>>;
#[allow(dead_code)]
const M: usize = 1_000_000_007;

fn main() {
    input! {
        n: usize,
        x: [i32; n]
    }
    let mut sx = x.to_vec();
    sx.sort();

    let midi = n / 2;
    let mid = sx[midi];
    let prev = sx[midi - 1];

    for i in 0..n {
        println!("{}", if x[i] < mid { mid } else { prev });
    }
}

Measured memory_bytes: 8444
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[4] = {-1, 0, 1, 0};
ll dy[4] = {0, 1, 0, -1};

int main(void){
    ll n;
    cin >> n;
    string s;
    cin >> s;
    ll w[n], b[n];
    w[0] = 0; b[0] = 0;
    if(s[0]=='.') w[0]++;
    else b[0]++;
    for(ll i = 1; i < n; i++){
        if(s[i]=='.'){
            w[i] = w[i-1]+1;
            b[i] = b[i-1];
        }
        else if(s[i]=='#'){
            b[i] = b[i-1]+1;
            w[i] = w[i-1];
        }
    }
    ll mw = w[n-1], mb = b[n-1];
    ll MIN = min(mw, mb);
    ll ans = 1e+11;
    for(ll i = 0; i < n; i++){
        ll check = min(mw-w[i]+b[i], mw);
        ans = min(ans, check);
        ans = min(ans, MIN);
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
int ma(int a,int b){
  if(a<b) return a;
  else return b;


}
int main()
{
    int n,k,x,d,i;
   while(scanf("%d%d",&n,&k)!=EOF){
   d=0;
        for(i=0;i<n;i++){
            scanf("%d",&x);
            d=d+ 2*ma(x,k-x);

        }


   printf("%d\n",d);
   }


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void) {
  int n,x,k;
  cin >> n >> x;
  int m[n];
  for(int i=0;i<n;++i) {
    cin >> m[i];
    x = x - m[i];
  }
  sort(m,m+n);
  k = x / m[0];
  cout << n + k << endl;
  
}




Measured memory_bytes: 256
import sys
n = int(input())
b_ls = [int(i) for i in sys.stdin.readline().split()]
cnt = 0
res = []
while len(b_ls) > 0:
    flg = True
    for i in range(n - cnt - 1, -1, -1):
        if b_ls[i] == i + 1:
            cnt += 1
            res.append(i+1)
            b_ls.pop(i)
            flg = False
            break
    if flg:
        res = -1
        break
if res == -1:
    print(res)
else:
    for b in res[::-1]:
        print(b)

Measured memory_bytes: 38512
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

class Main {
    public static void main(String args[]) {
        ArrayList<Integer> heights = new ArrayList<Integer>();

        Scanner sc = new Scanner(System.in);
        while (sc.hasNextInt()) {
            heights.add(sc.nextInt());
        }

        Collections.sort(heights, Collections.reverseOrder());

        for (int i = 0; i < 3; i++) {
            System.out.println(heights.get(i));
        }
    }
}

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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int a[n+1];
        map<int,int> mb,mc;
        for(int i=1;i<=n;i++)
        {
            cin>>a[i];
            mb[a[i]+i]++;
            mc[i-a[i]]++;
        }
        int ans = 0;
        for(auto p:mb)
        {
            if(mc.count(p.ff))ans+=mc[p.ff]*p.ss;
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 28336
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
const double EPS = 1e-10;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

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

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<LL,LL>
#define I vector<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())
#define ENDL cout<<endl

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    int from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
LL gcd(LL a, LL b) {
    if(b == 0) return a;
    return gcd(b, a % b);
}
LL lcm(LL a, LL b) {
    return a / gcd(a, b) * b ;
}
int main(){
    CIN(N);CIN(M);
    SCIN(S);SCIN(T);
    LL ans = lcm(N,M);
    map<LL,char> mm;
    for(int a = 0;a < N;a++){
        mm[a*(ans/N)]=S.at(a);
    }
    bool flag = true;
    for(int a = 0;a < M;a++){
        if(mm[a*(ans/M)] != T.at(a) && mm[a*(ans/M)] != 0){
         //   COUT(ins.at(a*(ans/M)));
         //   COUT(T.at(a));
         //   ENDL;
            flag = false;
        }
    }
    if(flag){
       COUT(ans);
    }else{
        COUT(-1);
    }

}


Measured memory_bytes: 10880
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
 
public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        br.readLine();
        String[] in = br.readLine().split(" ");
        ArrayList<Integer> list = new ArrayList<Integer>();
        boolean[] color = {true, true, true, true, true, true, true, true};
        for(int i = 0; i < in.length; i++) {
            list.add(Integer.parseInt(in[i]));
        }
        int count = 0;
        int min = 0;
        int max = 0;
        for(int j = 0; j < list.size(); j++) {
            if(list.get(j) < 400 && color[0]){
                color[0] = false;
                count++;
            } else if(list.get(j) >= 400 && list.get(j) < 800 && color[1]) {
                color[1] = false;
                count++;
            } else if(list.get(j) >= 800 && list.get(j) < 1200 && color[2]) {
                color[2] = false;
                count++;
            } else if(list.get(j) >= 1200 && list.get(j) < 1600 && color[3]) {
                color[3] = false;
                count++;
            } else if(list.get(j) >= 1600 && list.get(j) < 2000 && color[4]) {
                color[4] = false;
                count++;
            } else if(list.get(j) >= 2000 && list.get(j) < 2400 && color[5]) {
                color[5] = false;
                count++;
            } else if(list.get(j) >= 2400 && list.get(j) < 2800 && color[6]) {
                color[6] = false;
                count++;
            } else if(list.get(j) >= 2800 && list.get(j) < 3200 && color[7]) {
                color[7] = false;
                count++;
            } else if(list.get(j) >= 3200) {
                max++;
            }
        }
        max = max + count;
        min = count;
        if(min == 0) {
            min++;
        }
        System.out.println(min + " " + max);
    }
}

Measured memory_bytes: 21204
import java.util.*;

public class Main{
  Scanner sc = new Scanner(System.in);
  StringBuilder sb = new StringBuilder();

  int H;
  int[] A;

  public static void main(String[] args){
    Main main = new Main();
    main.in();
    main.out();
  }
  public void in(){
    H = sc.nextInt();
    A = new int[H + 1];
    for(int i = 1;i < A.length;i++){
      A[i] = sc.nextInt();
    }
  }
  public void out(){
    int id;
    for(int i = 1;i < A.length;i++){
      sb.append("node ").append(Integer.toString(i));
      sb.append(": key = ").append(Integer.toString(A[i])).append(", ");

      id = i / 2;
      if(!(id < 1)){
        sb.append("parent key = ").append( Integer.toString(A[id]) ).append(", ");
       
      }
      id = 2 * i;
      if(!(id > H)){
        sb.append("left key = ").append( Integer.toString(A[id])).append(", ");
      }
      id = 2 * i + 1;
      if(!(id > H)){
        sb.append("right key = ").append( Integer.toString(A[id])).append(", ");
      }
      sb.append("\n");
    }
System.out.print(sb.toString());
  }

}


Measured memory_bytes: 26520
n = int(input())
d = [list(map(int, input().split())) for _ in range(n)]
cnt = 0

for i in range(n):
    if d[i][0] == d[i][1]:
        cnt += 1
    else:
        cnt = 0
    if cnt == 3:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 9180
def main():
    n, d = map(int, input().split())
    ans = 0
    for _ in range(n):
        x, y = map(int, input().split())
        if x ** 2 + y ** 2 <= d ** 2:
            ans += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9116
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

int N;
int X;
vector<int> x;

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    cin >> N >> X;
    rep(i, N) {
        int a;
        cin >> a;
        x.push_back(a);
    }
    x.push_back(X);
    sort(x.begin(), x.end());

    int d = x[1] - x[0];
    if (x.size() < 2)
        cout << d << endl;
    else {
        for (int i = 1; i < x.size() - 1; i++)
            d = gcd(d, x[i+1] - x[i]);
        cout << d << endl;
    }
}

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

#define fi first
#define se second
#define be begin
#define en end
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define ALL(a) (a).be() , (a).en()
#define REP(i,n) for(int (i)=0;(i)<(n);(i)++)        //repeat n times
#define REP2(i,s,n) for(int (i)=(s);(i)<(n);(i)++)   //repeat from s to n 
#define REPD(i,n) for(int (i)=(n);(i)>=0;(i)--)      //repeat from n to 0
#define REPD2(i,s,e) for(int (i)=(s);(i)>=(e);(i)--) //repeat from s to e
#define RANGE(i,v) for(auto &(i):v)                  //repeat range
#define ASIZE(a) (sizeof(a) / sizeof(a[0]))          //array size

using LL = long long;

template<typename T> using V = vector< T >;
using Vi = V<int>;
using Vll = V<LL>;
using Vs = V<string>;

template<typename T>
T SUM(V<T> v, T init_val=0){return accumulate(ALL(v),T(init_val));}

int main(){
    int n,k;
    cin>>n>>k;
    Vi h(n);
    REP(i,n) cin>>h[i];

    sort(ALL(h));

    if(n<=k){
        cout<<0<<endl;
    }else{
        LL total = 0;
        REP(i,n-k){
            total += h[i];
        }
        cout<<total<<endl;
    }

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define long long long int
#define A(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
void _read();
const int mod = 1e9 + 7;
long dp[3001][3001];

void add( long &a, long b ) {
      a += b;
      while ( a > mod ) a -= mod;
      while ( a < 0 ) a += mod;
}

int main () { _read(); 

      int n; string s;
      cin >> n >> s;
      dp[1][1] = 1;
      for( int i = 2; i <= n; i++) {
            for( int j = 1; j < i; j++) {
                  add(dp[i-1][j],dp[i-1][j-1]);
            }
            for( int j = 1; j <= i; j++) {
                  int L,R;
                  if(s[i-2] == '<') {
                        L = 1, R = j-1;
                  }
                  else {
                        L = j; R = i-1;
                  }
                  add(dp[i][j],dp[i-1][R]-dp[i-1][L-1]);
            }
      }
      long ans = 0;
      for( int i = 1; i <= n; ++i) {
            add(ans,dp[n][i]);
      }
      cout << ans << '\n';
      return 0;
};

void _read() {
      ios_base :: sync_with_stdio(false);
      cin.tie(NULL);
      #ifdef LOCAL
      freopen("input.txt","r",stdin);
      #endif
}


Measured memory_bytes: 49772
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
    int H;
    while(cin >> H, H) {
        vector<vector<int>> v(H, vector<int>(5)); // [h][w]
        for(int i=0; i<v.size(); ++i) {
            for(int j=0; j<5; ++j) {
                cin >> v[i][j];
            }
        }
        reverse(v.begin(), v.end());

        int ret = 0;
        bool updated = true;
        while(updated) {
            for(int h=0; h<v.size(); ++h) {
                int prev = v[h][0], cnt = 1;
                int left = -1, right = 4;
                for(int w=1; w<5; ++w) {
                    if(prev == v[h][w]) {
                        ++cnt;
                    } else if(prev != v[h][w] && cnt >= 3) {
                        right = w-1;
                        break;
                    } else {
                        cnt = 1;
                    }
                    prev = v[h][w];
                }
                if(cnt >= 3) {
                    ret += prev * cnt;
                    left = right - cnt + 1;
                    for(int w=left; w<=right; ++w) {
                        v[h][w] = 0;
                    }
                }
            }
            updated = false;
            if(H != 1) {
                for(int h=0; h<v.size(); ++h) {
                    for(int w=0; w<5; ++w) {
                        if(v[h][w] == 0) {
                            int h2 = h+1;
                            while(h2 < H && v[h2][w] == 0) {
                                h2++;
                            }
                            if(h2 == H) continue;

                            int tmp_h = h;
                            while(h2 < H) {
                                v[tmp_h][w] = v[h2][w];
                                v[h2][w] = 0;
                                tmp_h++;
                                h2++;
                            }
                            updated = true;
                        }
                    }
                }
            }
        }
        cout << ret << endl;
    }
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll l, r, d;
    cin >> l >> r >> d;
    ll cnt = 0;
    for(ll i=l;i<=r;i++){
        if(i%d==0){
            cnt++;
        }
    }
    cout << cnt <<endl;

    
    return 0;
}



Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,ans=0,i;
    unordered_map<ll,ll> mp;
    cin>>n;
    ll z=n-1;
    for(i=1;i*i<=z;i++)
    {
        if(z%i==0)
        {
            ll a=z/i;
            mp[a]=1;
            mp[i]=1;
            if(a!=i)
                ans+=2;
            else
                ans+=1;
        }
    }
    ans--;
    for(i=2;i<=1000000;i++)
    {
        if(n%i!=0)
            continue;
        if(mp[i]==0)
        {
            ll j=1,f=0,s=i;
            while(j)
            {
                ll a=n/s;
                a-=1;
                if(a%i==0)
                {
                    f=1;
                    break;
                }
                s=s*i;
                if(n%s!=0)
                    break;
            }
            if(f==1)
            {
                mp[i]=1;
                ans+=1;
            }
        }
    }
    if(mp[n]==0)
        ans+=1;
    cout<<ans;
}


Measured memory_bytes: 384
#!/usr/bin/env python3
import sys
#sys.setrecursionlimit(150000)

#def my_index_multi(l, x):
#    return [i for i, _x in enumerate(l) if _x == x]

YES = "Yes"  # type: str
NO = "No"  # type: str


def solve(N: int, M: int, A: "List[int]"):
    A=sorted(A,reverse=True)
    sa=sum(A)
    if N==1:
        print(YES)
    else:
        print(YES if sa/(4*M)<=A[M-1] else NO)

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    A = [int(next(tokens)) for _ in range(N)]  # type: "List[int]"
    solve(N, M, A)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include "atcoder/dsu.hpp"
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)

using namespace std;
using namespace atcoder;
using ll = long long;

int main() {
	int n, q;
	cin >> n >> q;
	dsu d(n);
	rep(i, q) {
		bool t;
		int a, b;
		cin >> t >> a >> b;
		if (t) {
			bool s;
			s = d.same(a, b);
			cout << (s ? 1 : 0) << endl;
		}
		else {
			d.merge(a, b);
		}
	}
	return 0;
}


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

using namespace std;

#define int          long long
#define fast()        ios_base :: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(v)       v.begin() , v.end()
#define ff           first
#define ss           second
#define out(x)       cerr << #x << " is : " << x << endl
#define endl         "\n"

void up()
{
    int a , b;
    cin >> a >> b;
    for(int i = 0 ; i <= a ; i++)
    {
        int j = a - i;
        int legs = 2 * i + 4 * j;
        if(legs == b)
        {
            cout << "Yes" << endl;
            return;
        }
    }
    cout << "No" << endl;
    return;
}


int32_t main()
{
    fast();
    up();
    return 0;
}



Measured memory_bytes: 3652
import java.io.PrintWriter

val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val aa = listOfInt()

    var minCost = Int.MAX_VALUE
    for (num in -100..100) {
        var cost = 0
        aa.forEach {
            cost += (num - it) * (num - it)
        }
        if (cost < minCost) minCost = cost
    }

    println(minCost)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37868
H, W = map(int, input().split())
import numpy as np
Grid = np.array([[0 if x == '.' else -1 for x in input()] for _ in range(H)],dtype='int64')

def solveMase(Grid, start, goal):
    seen = {start}
    V = [start]
    while len(V) != 0:
        v = V.pop(0)
        if v == goal:
            return Grid[goal]

        y,x = v
        nV = []
        if x > 0: nV.append((y,x-1))
        if y > 0: nV.append((y-1,x))
        if x < W-1: nV.append((y,x+1))
        if y < H-1: nV.append((y+1,x))

        for nv in nV:
            if Grid[nv] == -1 or nv in seen:
                continue
            Grid[nv] = Grid[v] + 1
            V.append(nv)
            seen.add(nv)
    return 0

white = len(Grid[Grid == 0])-1
nes_white = solveMase(Grid, (0,0), (H-1,W-1))
if nes_white > 0:
    ans = white - nes_white
else:
    ans = -1
print(ans)

Measured memory_bytes: 29380
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

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

	if (n==m) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	

	return 0;
}


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

typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007;

int main(){
    
    int N,X;cin>>N>>X;
    vector<int> S(N+1,0);
    for(int i=0;i<N;i++){
        int a;cin>>a;
        S[i+1]=S[i]+a;
    }
    int cnt=0;
    for(int i=0;i<=N;i++){
        if(S[i]<=X) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <math.h>
#include <limits.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define MOD 1000000007
#define SIZE 100005
#define FOR(i,a,n) for(i=(a);i<(n);i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
char str[200001];
int a[200001];
int dp[200001];
int mem[1<<26];
int main(void)
{
	int len,S,i,j;
	scanf("%s",str);
	len=strlen(str);
	FOR(i,0,len){
		a[i+1]=a[i]^(1<<(str[i]-'a'));
		dp[i+1]=INF;
	}
	FOR(i,1,1<<26) mem[i]=INF;
	FOR(i,1,len+1){
		dp[i]=mem[a[i]]+1;
		FOR(j,0,26){
			dp[i]=MIN(dp[i],mem[a[i]^(1<<j)]+1);
		}
		mem[a[i]]=MIN(dp[i],mem[a[i]]);
	}
	printf("%d\n",dp[len]);
	return 0;
}
    

Measured memory_bytes: 264192
fn main() {
    loop {
        let (n, m) = base();
        if (0, 0) == (n, m) {
            break;
        }

        let mut alphabet = std::collections::HashMap::new();
        for i in 0..n {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();

            for (j, c) in s.trim().chars().enumerate() {
                alphabet.insert(c, (i as i32, j as i32));
            }
        }

        let mut word = String::new();
        std::io::stdin().read_line(&mut word).unwrap();

        let mut ans = 0;
        let mut pre = (0, 0);
        for c in word.trim().chars() {
            ans += (alphabet.get(&c).unwrap().0 - pre.0).abs();
            ans += (alphabet.get(&c).unwrap().1 - pre.1).abs();

            pre = *alphabet.get(&c).unwrap();
            ans += 1;
        }

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

fn base() -> (usize, usize) {
    let v = input();

    (v[0] as usize, v[1] as usize)
}

fn input() -> Vec<i32> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let v: Vec<i32> = s.trim().split_whitespace().map(|x| x.parse().unwrap()).collect::<_>();

    v
}



Measured memory_bytes: 5044
#include<iostream>
#include<vector>
using namespace std;
const int N = 20;

int rec(int n, int k, int s)
{
  if(s < 0) return 0;  // no answer
  if(k == 0) return s == 0 ? 1 : 0; // 0 by 0?
  if(n > k) {
    // using n, or not using n
    return rec(n-1, k-1, s-n) + rec(n-1, k, s);
  } else if(n == k) {
    if( s == n * (n+1) / 2 ) return 1;
  }
  return 0;
}
int main(int argc, char *argv[])
{
  for(;;) {
    int n, k, s;
    cin >> n >> k >> s;
    if(n == 0 && k == 0 && s == 0) break;
    int cnt = 0;
    if(k <= n) {
      cnt = rec(n, k, s);
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <bits/stdc++.h>
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define rrep(i,n) RFOR(i,n,0)
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
 
	int n, k;
	cin >> n >> k;
 
	ll h[n];
	rep(i, n) cin >> h[i];
 
	ll INF = 1e13;
	ll c[n];
	rep(i, n) c[i] = INF;
	c[0] = 0;
 
	for(int i = 1; i < n; i++){
		for(int j = max(i-k, 0); j < i; j++){
			c[i] = min(c[i], c[j] + abs(h[j] - h[i]));
		}
	}
 
	cout << c[n-1] << endl;
}

Measured memory_bytes: 5220
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#include <numeric>
#define IINF 1000000000
#define INF 9223372036854775807
#define MOD 1000000007
#define mod 1000000007
#define INT_MAX_ 2147483647
#define EPS (1e-10)
#define REP(i, a, n) fo-r (ll i = a; i < (ll)(n); i++)
#define REPE(i, a, n) for (ll i = a; i <= (ll)(n); i++)
//#define rep(i,n)for (ll i = 0; i < (ll)(n); i++)
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define Endl endl
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
#define me memset
#define bit(n,k) ((n>>k)&1)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair<int,int>Pin;
typedef pair<ll,ll>Pll;
template<class T> using V=vector<T>;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T> >;
long long GCD(long long a, long long b) {return b?GCD(b,a%b):a;}
long long LCM(long long a, long long b) {return a/GCD(a,b)*b;}
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};
int ddx[8]={-1,0,1,0,1,1,-1,-1};
int ddy[8]={0,-1,0,1,1,-1,1,-1};
ll cmp1(pair<ll,ll> a,pair<ll,ll> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se>b.se;
}
//----------------------------------------------------------------------

//----------------------------------------------------------------------
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------  
    //ll begin_t=clock();
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    //------------------------------
    ll n;cin>>n;
    ll AC=0,WA=0,TLE=0,RE=0;
    for(ll i=0;i<n;i++){
        string s;cin>>s;
        if(s=="AC")AC++;
        else if(s=="WA")WA++;
        else if(s=="TLE")TLE++;
        else RE++;
    }
    cout<<"AC x "<<AC<<endl;
    cout<<"WA x "<<WA<<endl;
    cout<<"TLE x "<<TLE<<endl;
    cout<<"RE x "<<RE<<endl;
    //------------------------------
    //fclose(stdin);
    //fclose(stdout);
    //ll end_t=clock();cout<<"time="<<end_t-begin_t<<"ms"<<endl;
    //------------------------------- 
    return 0;
}
//----------------------------------------------------------------------






































Measured memory_bytes: 3644
#include<iostream>
#include<fstream>
#include<vector>
using namespace std;

int main(){
  //ifstream in("input.txt");
  //cin.rdbuf(in.rdbuf());

  int N;
  cin>>N;

  vector<long> A(N+1);
  for(int i=0;i<N+1;i++) cin>>A.at(i);

  vector<long> B(N+1);
  for(int i=0;i<N;i++) cin>>B.at(i);
  B.at(N)=0;

  long ans=0;

  for(int i=0;i<N;i++){
    if(B.at(i)>A.at(i)){
      ans += A.at(i);
      long k=B.at(i)-A.at(i);
      if(k>A.at(i+1)){
        ans += A.at(i+1);
        A.at(i+1)=0;
      }else{
        A.at(i+1) -=k;
        ans += k;
      }

    }else{
      ans += B.at(i);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 1792
n = gets.strip.to_i
l = gets.strip.split.map(&:to_i)
ans = 0
l.combination(3) do |ee|
  e = ee.sort
  next if e[0] == e[1] || e[1] == e[2]
  ans += 1 if e[0]+e[1]>e[2]
end
p ans


Measured memory_bytes: 14400
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <queue>

#define mod 1000000007
#define MAX_N 200000

using namespace std;

int A[MAX_N + 1];

int main()
{
    int L, R, d, multiples;

    scanf("%d%d%d", &L, &R, &d);
    multiples = R / d - (L - 1) / d;
    printf("%d", multiples);

    return 0;
}


Measured memory_bytes: 1708
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	set<string> S;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		S.insert(s);
	}

	cout << S.size() << endl;

}


Measured memory_bytes: 19144
# -*- coding: utf-8 -*-
"""
Created on Sun Jun 21 21:34:50 2020

@author: NEC-PCuser
"""
import collections

N = int(input())

A = list(map(int, input().split()))
c = collections.Counter(A)

list_sum = sum(A)

Q = int(input())
sum_list = []
for i in range(Q):
    B, C = map(int, input().split())
    count_b = c[B]
    list_sum -= count_b * B
    list_sum += count_b * C
    c[B] = 0
    c[C] += count_b
    sum_list.append(list_sum)

for i in sum_list:
    print(i)

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

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

    ll X;
    cin >> X;

    ll l = 1;
    ll r = 100000000;
    while (l <= r) {
        ll mid = l + (r - l) / 2;
        ll value = mid * (mid + 1) / 2;
        if (value == X) {
            cout << mid << endl;
            return 0;
        } else if (value < X) {
            if ((value + mid + 1) >= X) {
                cout << (mid + 1) << endl;
                return 0;
            } else {
                l = mid + 1;
            }
        } else if (value > X) {
            r = mid - 1;
        }
    }

    return 0;
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 10000000;
const long long inf = 11451419198109130;
typedef pair<int, int> P;
typedef pair<P, int> PP;
typedef pair<int, PP> PPP;
struct edge { int to; int to2; int cost; };

signed main() {
	int k, a, b; cin >> k >> a >> b;
	if (a >= b)cout << k + 1 << endl;
	else {
		int f = a, cnt = k;;
		if (a - 1 >= k)cout << k +1<< endl;
		else {

			cnt -= a - 1;
			f += (b - a)*(cnt / 2);
			if (cnt & 1)f++;
			cout <<max( f,k+1) << endl;
		}
	}
	}

Measured memory_bytes: 256
run (function * (write, gets) {
	var a = +(yield);
	var b = +(yield);
	var c = +(yield);
	if (b < a) {
		var d = a;
		a = b;
		b = d;
	}
	if (c < b) {
		var d = b;
		b = c;
		c = d;

		if (b < a) {
			var d = a;
			a = b;
			b = d;
		}
	}

	var e = b - a;
	console.log((c - b) + ((e & 1) ? (e + 1) / 2 + 1 : e / 2));
});

/**
 * @param {(write: (line: string, end?: string) => void, gets: () => IterableIterator<string|null>) => IterableIterator<any>} main 
 */
function run (main) {
	var istream = process.stdin;
	var ostream = process.stdout;

	/**
	 * @type {[string|null]}
	 */
	var words = [];
	/**
	 * @type {[string]}
	 */
	var lines = [];
	var rest = "";
	var ended = false;
	var INPUT_MODE_LINE = 0;
	var INPUT_MODE_WORD = 1;
	var input_mode = INPUT_MODE_WORD;

	/**
	 * @param {string} line 
	 * @param {string} [end] 
	 */
	function write (line, end) {
		ostream.write(line + (undefined === end ? os.EOL : end));
	}
	function *gets () {
		if (0 < lines.length) {
			return lines.shift();
		} else {
			input_mode = INPUT_MODE_LINE;
			/**
			 * @type {string}
			 */
			var line = yield;
			input_mode = INPUT_MODE_WORD;
			return line;
		}
	}

	var main_itr = main(write, gets);

	/**
	 * @param {string|null} chunk 
	 */
	function get_chunk (chunk) {
		istream.pause();
		if (null === chunk) {
			lines.push(null);
		} else {
			rest += chunk;
			var line_exp = /.*(\r?\n|\r)/g;
			var line_match, lastIndex = 0;
			while (null !== (line_match = line_exp.exec(rest))) {
				lastIndex = line_exp.lastIndex;
				lines.push(line_match[0]);
			}
			rest = rest.substring(lastIndex);
		}
		loop();
	}

	function loop () {
		while (0 < lines.length) {
			switch (input_mode) {
				case INPUT_MODE_LINE:
				{
					words.push(lines.shift());
				}
				break;
				case INPUT_MODE_WORD:
				{
					if (null === lines[0]) {
						words.push(lines.shift());
					} else {
						var word_exp = /[^\s]+/g;
						var line_match;
						if (null !== (line_match = word_exp.exec(lines[0]))) {
							words.push(line_match[0]);
							lines[0] = lines[0].substring(word_exp.lastIndex);
						} else {
							lines.shift();
						}
					}
				}
				break;
			}

			while (0 < words.length) {
				var result = main_itr.next(words.shift());
				if (undefined !== result.value) {
					if ('string' === typeof result.value) {
						write(result.value, "");
					} else {
						write(`${result.value}`, "");
					}
				}
				if (result.done) return;
			}
		}

		ended ? setTimeout(get_chunk, 0, null) : istream.resume();
	}
	istream.on('data', get_chunk);
	istream.on('end', function () {
		ended = true;
		get_chunk(null);
	});

	istream.setEncoding('utf8');
	get_chunk(null);
};

var os = require('os');


Measured memory_bytes: 21320
A, B, C, D, E, F= (int(i) for i in input().split())

dens=0
for a in range(30+1):
  for b in range(30+1):
    waterA=100*a*A
    waterAB=waterA+100*b*B
    if  waterA<= F and 0 < waterAB <= F:
      for c in range(100+1):
        for d in range(100+1):
          if waterAB+c*C+d*D <= F:
            if c*C+d*D <= (a*A+b*B)*E:
              if dens < (c*C+d*D)/(waterAB+c*C+d*D):
                dens=(c*C+d*D)/(waterAB+c*C+d*D)
                max1=waterAB+c*C+d*D
                max2=c*C+d*D
            else:
              max3=waterAB
              max4=0
if dens>0:
  print(max1,max2)
else:
  print(max3,max4)

Measured memory_bytes: 41200
package main
import . "fmt"
import . "strconv"
func main() {
  var n,f int
  var s string
  Scan(&n)
  s = Itoa(n)
  f = 0
  for i:=0;i<len(s);i++ {
    m,_ := Atoi(s[i:i+1])
    f += m
  }
  if n%f == 0 {
    Println("Yes")
  } else {
    Println("No")
  }
}

Measured memory_bytes: 512
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll A,B,C,K,ans=0;
  cin>>A>>B>>C>>K;
  
  ans=A-B;
  if(K%2==1) ans*=(-1);
  
  co(ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

using namespace std;

int main()
{
    int n,a,b,c,x;
    while(cin >> n >> a >> b >> c >> x)
    {
        if(n == 0 && a == 0 && b == 0 && c == 0 && x == 0) break;

        vector<int> y(n);
        rep(i,n) cin >> y[i];

        int ans = 0;
        bool flag = true;
        rep(i,n) {
            while(y[i] != x) {
                x = a*x + b;
                x %= c;
                ans++;

                if(ans > 10000) {
                    flag = false;
                    break;
                }
            }

            if(i != n-1) {
                x = a*x + b;
                x %= c;
                ans++;
            }
        }

        if(flag) cout << ans << endl;
        else cout << -1 << endl;
    }

    return 0;
}

Measured memory_bytes: 1192
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<list>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>

using namespace std;

#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define INF 11111111111111111
#define MOD 1000000007
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef pair<ll, ll> pll;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, temp = 0;
string s;
bool flag;

//-------------------------------------------------------------------------------

#define MAX 10000

int main(void) {
  ll odd = 0;
  ll even = 0;

  cin >> n >> m;

  FOR(i, 0, n) {
	cin >> temp;
	temp % 2 == 1 ? odd++ : even++;
  }

  ans = 1LL << (odd + even - 1);

  if (m == 1 && odd == 0) {
	ans = 0;
  }
  else if (m == 0 && odd == 0) {
	ans *= 2;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256