akhauriyash/Code-Regression huggingface dataset:
#line 2 "/Users/kaage/Desktop/ProgrammingWorkspace/library/other/template.hpp"
#define _CRT_SECURE_NO_WARNINGS
#pragma target("avx2")
#pragma optimize("O3")
#pragma optimize("unroll-loops")
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define all(V) V.begin(),V.end()
typedef long long lint;
typedef unsigned long long ulint;
typedef std::pair<int, int> P;
typedef std::pair<lint, lint> LP;
constexpr int INF = INT_MAX/2;
constexpr lint LINF = LLONG_MAX/2;
constexpr double eps = DBL_EPSILON;
constexpr double PI=3.141592653589793238462643383279;
template<class T>
class prique :public std::priority_queue<T, std::vector<T>, std::greater<T>> {};
template <class T, class U>
inline bool chmax(T& lhs, const U& rhs) {
	if (lhs < rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
template <class T, class U>
inline bool chmin(T& lhs, const U& rhs) {
	if (lhs > rhs) {
		lhs = rhs;
		return 1;
	}
	return 0;
}
inline lint gcd(lint a, lint b) {
	while (b) {
		lint c = a;
		a = b; b = c % b;
	}
	return a;
}
inline lint lcm(lint a, lint b) {
	return a / gcd(a, b) * b;
}
bool isprime(lint n) {
	if (n == 1)return false;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0)return false;
	}
	return true;
}
template<typename T>
T mypow(T a, lint b) {
	T res(1);
	while(b){
		if(b&1)res*=a;
		a*=a;
		b>>=1;
	}
	return res;
}
lint modpow(lint a, lint b, lint m) {
	lint res(1);
	while(b){
		if(b&1){
			res*=a;res/=m;
		}
		a*=a;a/=m;
		b>>=1;
	}
	return res;
}
template<typename T>
void printArray(std::vector<T>& vec) {
	rep(i, vec.size()){
		std::cout << vec[i];
		std::cout<<(i==(int)vec.size()-1?"\n":" ");
	}
}
template<typename T>
void printArray(T l, T r) {
	T rprev = std::prev(r);
	for (T i = l; i != rprev; i++) {
		std::cout << *i << " ";
	}
	std::cout << *rprev << std::endl;
}
#line 2 "main.cpp"
int n,c[200010],d[10][45][20],e[200010],f[200010];
std::string a[200010];
int main(){
	std::cin>>n;
	rep(i,n){
		std::cin>>a[i];
		lint b=0;
		bool g=false;
		rep(j,a[i].size()){
			if(a[i][j]=='.')g=true;
			else{
				if(g)c[i]++;
				b*=10;
				b+=a[i][j]-'0';
			}
		}
		while(b%2==0){
			e[i]++;
			b/=2;
		}
		while(b%5==0){
			f[i]++;
			b/=5;
		}
		d[c[i]][e[i]][f[i]]++;
	}
	rep(i,10){
		for(int j=43;j>=0;j--){
			for(int k=19;k>=0;k--)d[i][j][k]+=d[i][j+1][k];
		}
		for(int j=44;j>=0;j--){
			for(int k=18;k>=0;k--)d[i][j][k]+=d[i][j][k+1];
		}
	}
	lint ans=0;
	rep(i,n){
		if(c[i]*2-e[i]<=e[i]&&c[i]*2-f[i]<=f[i])ans--;
		rep(j,10){
			ans+=d[j][std::max(0,c[i]+j-e[i])][std::max(0,c[i]+j-f[i])];
		}
	}
	std::cout<<ans/2<<std::endl;
	return 0;
}

Measured memory_bytes: 12224
n = gets.to_i
allmk = ["S","H","C","D"]
arr = Array.new(52)
n.times{
  card = STDIN.gets.split(" ")
  mk = allmk.index(card[0])
    ## 入力したカードがどのマークか探し、何番目のマークかを出力
  num = card[1].to_i-1
  arr[mk*13+num] = 1
  ## 52の配列のうち、カードが入力された配列番号に1を入力
}

0.upto(3){|i|
  0.upto(12){|j|
    if arr[i*13+j] != 1 ## 1が配列番号に入力されていない場合
      j += 1
      print "#{allmk[i]} #{j}"
      print "\n"
    end
  }
}


Measured memory_bytes: 6872
using System;
class P
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int M = int.Parse(input[1]);
    int C = int.Parse(input[2]);
    
    input = Console.ReadLine().Split(' ');
    int[] bArray = new int[M];
    for (int i = 0; i < M; i++) {
      bArray[i] = int.Parse(input[i]);
    }
    
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int aSum = C;
      input = Console.ReadLine().Split(' ');
      for (int j = 0; j < M; j++) {
        aSum += (int.Parse(input[j]) * bArray[j]);
      }
      if (0 < aSum) {
        sum++;
      }
    }
    Console.WriteLine(sum);
  }
}

Measured memory_bytes: 13140
import sys
from heapq import heappop, heappush
readline = sys.stdin.readline


H, W = map(int, readline().split())
grid = '#' * (W + 2) + ''.join('#' + readline().strip() +
                               '#' for _ in range(H)) + '#' * (W + 2)
INF = 400


def shortest(grid, start, cost=0):
    dist = [INF] * (H + 2) * (W + 2)
    move = (-1, 1, W + 2, -W - 2)
    st = [start]
    dist[start] = 0
    while(st):
        sx = heappop(st)
        c = dist[sx]
        for a in move:
            x = sx + a
            if grid[x] == '#':
                continue
            dx = dist[sx] + 1
            if dist[x] <= dx:
                continue
            dist[x] = dx
            heappush(st, x)
    return max(x for x in dist if x < INF)


m = 0
for i in range(W + 3, (H + 1) * (W + 2) - 1):
    if grid[i] == '#':
        continue
    tm = shortest(grid, i)
    if m < tm:
        m = tm
print(m)


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <cassert>
#include <memory>
#include <stack>
#include <set>
#include <map>
#include <cctype>
#include <climits>
#include <list>

#define INF 1000000000
#define MOD 1000000007
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

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

  int N; cin>>N;
  vector<int> arr(N);
  int sum = 0;
  for(int i=0; i<N; i++) {
    int a; cin>>a;
    arr[i] = a;
    sum += a;
  }

  sort(arr.begin(), arr.end());
  for(int i=0; i<N; i++) {
    if(sum % 10 != 0) {
      break;
    }
    if(arr[i] % 10 == 0) {
      continue;
    }
    sum -= arr[i];
  }

  if(sum % 10 == 0) {
    cout << 0 << endl;
  } else {
    cout << sum << endl;
  }
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
const int inf = 1e9;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}

	int ans = inf;
	for(int m=-100; m<=100; m++){
		int sub = 0;
		for(int i=0; i<n; i++){
			sub += (a[i]-m)*(a[i]-m);
		}
		ans = min(ans, sub);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {
	public static void main(String []args) {
		Scanner sc = new Scanner(System.in);
		
		int n = Integer.parseInt(sc.next());
		
		
		Map <Integer,Integer> hmb = new HashMap<Integer,Integer>();
		Map <Integer,Integer> hmc = new HashMap<Integer,Integer>();
		
		for(int i = 1 ; i <= n ;i++) {
			int a = Integer.parseInt(sc.next());
			int b = i + a;
			int c = i - a;
			if(hmb.containsKey(b)) {
				hmb.put(b, hmb.get(b) +1);
			}
			else {
				hmb.put(b,1);
			}
			if(hmc.containsKey(c)) {
				hmc.put(c, hmc.get(c) +1);
			}
			else {
				hmc.put(c,1);
			}
		}
		
		long ans = 0;
		
		for(int i = 0 ; i <= n ;i++) {
			if(hmb.containsKey(i)&&hmc.containsKey(i)) {
			 long temp = (long)hmb.get(i)* hmc.get(i);
				ans += temp;
			}
		}
		System.out.println(ans);
	
	}

}


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

// macro
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()

// code starts
int main()
{
  int n,col;cin>>n>>col;
  vector<vector<int>> d(col,vector<int>(col));
  vector<vector<int>> c(n,vector<int>(n));
  vector<vector<int>> dot(3,vector<int>(col,0));
  int i,j,k,l;
  rep(i,col)rep(j,col)cin>>d[i][j];
  rep(i,n)rep(j,n)cin>>c[i][j];
  rep(i,n)rep(j,n)dot[(i+j)%3][c[i][j]-1]++;
  int ans=1000000000;
  for(i=0;i<col;i++)
  {
    for(j=0;j<col;j++)
    {
      if(j==i)continue;
      for(k=0;k<col;k++)
      {
        if(k==i||k==j)continue;
        int kans=0;
        for(l=0;l<col;l++)kans+=d[l][i]*dot[0][l];
        for(l=0;l<col;l++)kans+=d[l][j]*dot[1][l];
        for(l=0;l<col;l++)kans+=d[l][k]*dot[2][l];
        ans=min(ans,kans);
      }
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1280
info=gets.chomp.split(" ").map(&:to_i)
def cal_count(k,_point)
	_count=0
	while k>_point
		_point=_point*2
		_count+=1
	end 
	return _count
end
result=0.0
info[0].times do|i|
	result+=(0.5**(cal_count(info[1],i+1))).to_f
end
print result*(1.0/info[0])


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

int N,A,B;
int cnt1=0,cnt2=0,cnt3=0;

int main(){
    cin>>N>>A>>B;
    for(int i=0; i<N; i++){
        int t;
        cin>>t;
        if(t<=A)cnt1++;
        else if(t<=B)cnt2++;
        else cnt3++;
    }
    cout<<min(cnt1,min(cnt2,cnt3))<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef vector<pair<ll,ll>> vp;
#define rep(i,n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin() , v.end()
#define inputv(v,n) rep(i,n){\
    ll x;\
    cin>>x;\
    v.push_back(x);\
    }
const ll INF=99999999999999;
const ll MOD=1000000007;
 
int main() {
  ll n,d;
  cin >> n >> d;
  double a[n][d];
  rep(i,n){
    rep(j,d){
      cin >> a[i][j];
    }
  }
  int count=0;
  double sum = 0;
    rep(i,n){
      for(int j=i+1;j<n;j++){
        rep(k,d){
        sum += (a[i][k] - a[j][k])*(a[i][k] - a[j][k]);
     }
     if(floor(sqrt(sum))==sqrt(sum)){
       count++;
     }
     sum = 0;
    }
  }
  cout << count;

  
 return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = a*b;
    int road = a+b-1;
    System.out.println(c-road);
  }
}


Measured memory_bytes: 22996
#include <bits/stdc++.h>
#include<iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define MOD 1000000007
using namespace std;


int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int n,m1,m2,i;
    cin >> n;
    int a[n],sum=0,s1=0,s2=0;
    for(i=0;i<n;i++) {
    	cin >> a[i];
    	sum +=  a[i];
    }
    m1=sum/n;
    m2 = m1;
    if(sum%n) m2++;
    for(i=0;i<n;i++) {
    	s1+=(a[i]-m1)*(a[i]-m1);
    	s2+=(a[i]-m2)*(a[i]-m2);
    }
    cout << min(s1,s2) << "\n";
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define pi 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define lcm(a,b) (a*b)/__gcd(a,b)
#define inf -1
int main()
{
    FIO;

    ///freopen("in.txt","r",stdin);
    ///freopen("output.txt","w",stdout);
    int n,m,i,j;
    cin>>n>>m;
    vvi grap(n+1);
    int a,b;
    for(i=0; i<m; i++)
    {
        cin>>a>>b;
        grap[a].pb(b);
        grap[b].pb(a);
    }
    queue<int>q;
    q.push(1);
    vi length(n+1,-1);
    length[1]=0;
    while(!q.empty())
    {
        int u = q.front();
        q.pop();
        for(auto it:grap[u])
        {
            if(length[it]==-1)
            {
                length[it]=u;
                q.push(it);
            }
        }
    }
    bool  ok=0;
    for(i=2; i<=n; i++)
    if(length[i]==-1){ok=1;break;}
    if(ok)
        cout<<"No"<<endl;
    else
    {
        cout<<"Yes"<<endl;
        for(i=2; i<=n; i++)
            cout<<length[i]<<endl;
    }


}


Measured memory_bytes: 10300
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

#define ll long long

void swap (int *x, int *y) {
  int temp;

  temp = *x;
  *x = *y;
  *y = temp;

  return;
}


int gcd(int a, int b){
  int c;

  while (b > 0){
    c = a % b;
    a = b;
    b = c;
  }

  return a;
}

int upll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;
}

int downll(const void*a, const void*b){
  return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;
}

void sortup(ll*a,int n){
  qsort(a,n,sizeof(ll),upll);
}

void sortdown(ll*a,int n){
  qsort(a,n,sizeof(ll),downll);
}

long int modpow(long int a,long int n,long int mod){
  long int ans=1;
  while(n>0){
    if(n & 1){
      ans=ans*a%mod;
    }
    a=a*a%mod;
    n/=2;
  }
  return ans;
}

long int modinv(long int a,long int mod){
  return modpow(a,mod-2,mod);
}

int max(int a,int b){
  if(a<b){
    return b;
  }
  else{
    return a;
  }
}

int min(int a,int b){
  if(a<b){
    return a;
  }
  else{
    return b;
  }
}

void chmax(int *a,int b){
  if(*a < b){
    *a = b;
  }

  return;
}

void chmin(int *a,int b){
  if(*a > b){
    *a =b;
  }

  return;
}


/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/

int main(void){
  int n;
  scanf("%d",&n);

  int A[n+1];
  for(int i=0;i<n+1;i++){
    A[i]=0;
  }

  int ans=0;
  
  for(int i=0;i<n;i++){
    int a;
    scanf("%d",&a);

    if(a>n){
      ans++;
    }
    else{
      A[a]++;
    }
  }

  for(int i=1;i<=n;i++){
    if(A[i]>=i){
      ans+=A[i]-i;
    }
    else{
      ans+=A[i];
    }
  }

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

  return 0;
}

Measured memory_bytes: 2108
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
def input(): return sys.stdin.readline().rstrip()

def main():
    X=int(input())
    ans=X//500*1000+(X-X//500*500)//5*5
    print(ans)
    

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#![allow(unused_imports)]

#[macro_use]
mod _input {
    use std::fmt;
    use std::io::{self, Read};
    use std::str::{self, FromStr};

    macro_rules! input {
        ($($name:ident : $t:tt),*,) => {
            input!($($name: $t),*)
        };
        ($($name:ident : $t:tt),*) => {
            let mut _scanned = ::_input::Scanned::new(::std::io::stdin(), 1024);
            $(
                let $name = unsafe { _read_value!(_scanned, $t) };
            )*
        };
    }

    macro_rules! _read_value {
        ($scanned:expr, ($($t:tt),*)) => {
            ($(_read_value!($scanned, $t)),*)
        };
        ($scanned:expr, [$t:tt; $n:expr]) => {
            (0..$n).map(|_| _read_value!($scanned, $t)).collect::<Vec<_>>()
        };
        ($scanned:expr, _bytes) => {
            _read_value!($scanned, String).into_bytes()
        };
        ($scanned:expr, _1based) => {
            _read_value!($scanned, usize) - 1
        };
        ($scanned:expr, $t:ty) => {
            $scanned.next::<$t>()
        };
    }

    pub struct Scanned {
        buf: Vec<u8>,
        pos: usize,
    }

    impl Scanned {
        pub fn new<R: Read>(mut input: R, estimated: usize) -> Self {
            let mut buf_ = Vec::with_capacity(estimated);
            let _ = io::copy(&mut input, &mut buf_).unwrap();
            debug_assert!(str::from_utf8(&buf_).is_ok());
            debug_assert!(buf_.iter().all(|&c| u32::from(c) <= 0x7F));
            Scanned { buf: buf_, pos: 0 }
        }

        #[inline]
        pub unsafe fn next<T: FromStr>(&mut self) -> T
        where
            T::Err: fmt::Debug,
        {
            let mut start = None;
            loop {
                match (self.buf[self.pos], start.is_some()) {
                    (b' ', true) | (b'\n', true) => break,
                    (_, true) | (b' ', false) | (b'\n', false) => self.pos += 1,
                    (_, false) => start = Some(self.pos),
                }
            }
            let target = &self.buf[start.unwrap()..self.pos];
            str::from_utf8_unchecked(target).parse().unwrap()
        }
    }
}

use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
use std::io::{self, BufWriter, Read, Stderr, StderrLock, Stdout, StdoutLock, Write};
use std::num::{ParseFloatError, ParseIntError};
use std::ops::{
    Add, AddAssign, BitAnd, BitAndAssign, BitOr, BitOrAssign, BitXor, BitXorAssign, Div, DivAssign,
    Mul, MulAssign, Neg, Not, Rem, RemAssign, Sub, SubAssign,
};
use std::str::{self, FromStr};
use std::{char, cmp, f32, f64, fmt, i16, i32, i64, i8, mem, thread, u16, u32, u64, u8};

fn main() {
    input! {
        h: u32,
        w: u32,
        n: u32,
        m: u32,
    }
    let r = h * w + n * m - h * m - w * n;
    println!("{}", r);
}


Measured memory_bytes: 4352
#include <iostream>
#include <queue>
#include <map>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;

int W,H,N;
bool fld[6100][6100];
int X1[1000],X2[1000],Y1[1000],Y2[1000];
const int dx[4]={0,0,1,-1},dy[4]={1,-1,0,0};

int compress(int *x1,int *x2,int w){
	vector<int> xs;
	for(int i=0;i<N;i++){
		for(int j=-1;j<=0;j++){
			int tx1=x1[i]+j,tx2=x2[i]+j;
			if(0<=tx1 && tx1<w)xs.push_back(tx1);
		}
		x2[i]--;
		for(int j=0;j<=1;j++){
			int tx2=x2[i]+j;
			if(0<=tx2 && tx2<w)xs.push_back(tx2);
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	for(int i=0;i<N;i++){
		x1[i]=find(xs.begin(),xs.end(),x1[i])-xs.begin();
		x2[i]=find(xs.begin(),xs.end(),x2[i])-xs.begin();
	}
	return xs.size();
}

void solve(){
	W=compress(X1,X2,W);
	H=compress(Y1,Y2,H);
	memset(fld,0,sizeof(fld));
	for(int i=0;i<N;i++){
		for(int y=Y1[i];y<=Y2[i];y++){
			for(int x=X1[i];x<=X2[i];x++){
				fld[y][x]=true;
			}
		}
	}
	/*for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			printf("%d ",fld[y][x]);
		}
		printf("\n");
	}*/
	long long int ans=0;
	for(int y=0;y<H;y++){
		for(int x=0;x<W;x++){
			if(fld[y][x])continue;
			ans++;

			queue<pair<int, int> > que;
			que.push(make_pair(x, y));
			while(!que.empty()){
				int sx=que.front().first,sy=que.front().second;
				que.pop();
				for(int i=0;i<4;i++){
					int tx=sx+dx[i],ty=sy+dy[i];
					if(tx<0 || W<=tx || ty<0 || H<=ty)continue;
					if(fld[ty][tx])continue;
					que.push(make_pair(tx, ty));
					fld[ty][tx]=true;
				}
			}
		}
	}
	printf("%d\n",ans);

}

int main(void){
	while(1){
		scanf("%d%d",&W,&H);
		if(W==0 && H==0)break;
		scanf("%d",&N);
		for(int i=0;i<N;i++){
			scanf("%d%d%d%d",&X1[i],&Y1[i],&X2[i],&Y2[i]);
		}
		solve();
	}
    return 0;
}

Measured memory_bytes: 36000
#include <cstdio>
#include <math.h>

int main()
{
    while (1)
    {
        int s[1001];
        double n, m;
        double a;
        int sum = 0;
        double sum1 = 0;
        scanf("%lf", &n);
        if (n == 0)
        {
            break;
        }
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &s[i]);
            sum += s[i];
        }
        m = sum / n;
        for (int i = 0; i < n; i++)
        {
            sum1 += (s[i] - m) * (s[i] - m);
        }
        a = sqrt(sum1 / n);
        printf("%.8f\n", a);
    }
}


Measured memory_bytes: 2748
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    ll n,ans = 0;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        ans += a[i];
    }
    if(ans %2 == 0){
        cout << "YES" << endl;
    }else {
        cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
///   ***   ---   |||         In the name of ALLAH        |||   ---   ***   ///



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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}

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

const int mx = 1e7+123;
ll cnt[mx];

int main()
{
    optimize();

    int lim = 1e7;
    for ( int i = 1; i <= lim; i++ ) {
        for ( int j = i; j <= lim; j+= i ) {
            cnt[j]++;
        }
    }

    int n;
    cin >> n;
    ll ans = 0;
    for ( int i = 1; i <= n; i++ ) {
        ans += ( 1LL * cnt[i] * i );
    }

    cout << ans << endl;


    return 0;
}


















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

int main(){
	int n, x;
	cin >> n >> x;
	int counter = n;
	int min = 100000;
	for(int i = 0; i < n; i++){
		int temp;
		cin >> temp;
		x-= temp;
		if(temp < min)
			min = temp;
	}
	counter += x/min;
	cout << counter << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vp = vector<P>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using vvb = vector<vb>;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll  INFL = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int N, M;
vvi G;
vb used;
vi tsorted;
vi depth;

void dfs(int n)
{
    if(used[n]) return;
    used[n] = true;
    REP(i, G[n].size()) dfs(G[n][i]);
    tsorted.push_back(n);
}

void tsort()
{
    REP(i, N) dfs(i);
    reverse(ALL(tsorted));
}

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    cin >> N >> M;
    G.resize(N);
    used.resize(N, false);
    depth.resize(N, 0);
    REP(i, M)
    {
        int x, y; cin >> x >> y;
        x--; y--;
        G[x].push_back(y);
    }
    tsort();
    //REP(i, N) cout << tsorted[i] << endl;
    REP(i, N)
    {
        REP(j, G[tsorted[i]].size()) chmax(depth[G[tsorted[i]][j]], depth[tsorted[i]]+1);
    }
    cout << *max_element(ALL(depth)) << endl;
}

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

int main() {
  ll a,b,k;
  cin>>k>>a>>b;
  ll   ans;
  if(a+3>b){
    ans=1+k;
  }
  else {
  ll mtk=a;
    if(k>=a+1){
  ll nkr;
     mtk=b;
    nkr=k-(a+1);
    ll c=nkr/2;
    mtk=b+(b-a)*c;//1¥
    if(nkr%2==0){}
      else mtk++;
   ans=mtk;
    }
    else{
      ans=1+k;
    }
  }
  
    
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/// hi_im_manh :D
#include <bits/stdc++.h>
#define reset(a,n) memset(a,0,(n+1)*sizeof(int))
#define endl "\n"
#define llmin LLONG_MIN
#define llmax LLONG_MAX
#define intmax INT_MAX
#define intmin INT_MIN
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define duckman "TASK"

#define input freopen(duckman".inp", "r", stdin);
#define output freopen(duckman".out", "w", stdout);

#define nmax 22000
using namespace std;


int main()
{
    fast;
//    input;
//    output;

    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[2]) {
        cout << "No";
    }
    else {
        cout << "Yes";
    }
    return 0;
}
/*

*/


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int first=0;
int last=0;
int a[2000100];
int main(void){
  int n;
  scanf("%d",&n);
  char x[10];
  int d,i;

  for(;n>0;n--){
    scanf("%s",x);
    if(strcmp(x,"insert")==0){
      scanf("%d",&d);
      a[first]=d;
      first++;
    }

    else if(strcmp(x,"delete")==0){
      scanf("%d",&d);
      for(i=first;i>=last;i--){
        if(a[i]==d){
          a[i]=-1;
          if(i==first-1)first--;
          if(i==last)last++;
          break;
        }
      }
    }

    else if(strcmp(x,"deleteLast")==0){
      last++;
    }

    else if(strcmp(x,"deleteFirst")==0){
      a[first-1]=-1;
      first--;
    }
  }

  int c=0;
  for(i=first-1;i>last;i--){
    if(a[i]!=-1){
      if(c==0){printf("%d",a[i]);}
      else {printf(" %d",a[i]);}
      c++;
    }
  }

  if(a[i]!=-1){
    if(c==0)printf("%d\n",a[i]);
    else printf(" %d\n",a[i]);
  }
  else printf("\n");

  return 0;
}



Measured memory_bytes: 5640
import Control.Applicative

main = do
  s <- getLine
  putStrLn $ case s of
    s
      | isMatchMonth first &&
        isMatchYear first &&
        isMatchMonth second &&
        isMatchYear second -> "AMBIGUOUS"
      | isMatchMonth first &&
        isMatchYear second -> "MMYY"
      | isMatchYear first &&
        isMatchMonth second -> "YYMM"
      | otherwise -> "NA"
      where
        first = read $ take 2 s
        second = read $ drop 2 s

isMatchMonth::Int -> Bool
isMatchMonth x
  | x <= 0 = False
  | x <= 12 = True
  | otherwise = False

isMatchYear::Int -> Bool
isMatchYear x
  | x < 0 = False
  | x <= 99 = True
  | otherwise = False
  

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

int main() {
  int N;
  cin >> N;
  int t=N,fn=0;
  while(t>0) {
    fn+=t%10;
    t/=10;
  }
  if(N%fn==0) cout << "Yes" << endl;
  else cout << "No"  << endl;
}

Measured memory_bytes: 256
package main

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

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func lowerBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] >= x
	})
	return idx
}

func upperBound(a []int, x int) int {
	idx := sort.Search(len(a), func(i int) bool {
		return a[i] > x
	})
	return idx
}

func main() {
	sc.Split(bufio.ScanWords)
	N := getInt()
	p := make([]int, N)
	for i := 0; i < N; i++ {
		p[i] = getInt()
	}

	const inf = 1001001001
	dp := make([]int, N+1)
	for i := 0; i <= N; i++ {
		dp[i] = 0
	}
	for i := 0; i < N; i++ {
		dp[p[i]] += dp[p[i]-1] + 1
	}

	m := 0
	for i := 0; i <= N; i++ {
		m = max(m, dp[i])
	}

	// out(p)
	// out(dp)
	// out(N, m)
	out(N - m)
}


Measured memory_bytes: 5248
N, A,B = map(int,input().split())
S = input()
abroadR= 1
overAllR=0
for i in range(N):
  if S[i] == 'c':
    print('No')
  elif S[i] == 'a':
    if overAllR < A+B:
      print('Yes')
      overAllR+=1
    else:
      print('No')
  elif S[i] == 'b':
    if overAllR < A+B and abroadR<= B:
      print('Yes')
      overAllR+=1
      abroadR+=1
    else:
      print('No')
      

Measured memory_bytes: 9204
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define str string
#define pb push_back
#define vc vector
#define ci cin
#define co cout
// remove fropen in online judge
int main()
{ 
   

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll x,n;cin>>x>>n;
    bool vis[100000]={false};
    ll a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
        vis[a[i]]=true;
    }
    ll ma=x;
    ll val=x;
    for(int i=1;i<=1000;i++)
    { 
        for(int j=0;j<n;j++)
        {
            if(a[j]-i>=0&&vis[a[j]+i]==false)
            {
            	
            	if(abs(x-(a[j]+i))<ma)
            	{
            		ma=abs(x-(a[j]+i));
            		val=a[j]+i;
            	}
                else if(abs(x-(a[j]+i))==ma&&val>a[j]+i)
                {
                	val=a[j]+i;
                }
                else if(abs(x-(a[j]-i)<ma)&&vis[a[j]-i]==false)
                {
                	ma=abs(x-(a[j]-i));
                	val=a[j]-i;
                }
                else if(abs(x-(a[j]-i)==ma)&&vis[a[j]-i]==false)
                {
                	val=a[j]-i;
                }
             
            }
            
        }
        

    }
    if(n)
    cout<<val;
    else
    cout<<x;
    
}


Measured memory_bytes: 3728
#include <iostream>
#include <string>
#include <valarray>

int main() {
    while (true) {
        std::string cards;
        std::cin >> cards;
        if (cards == "-") break;

        int m;
        std::cin >> m;
        std::valarray<int> shuffles(m);
        for (int i = 0; i < m; i++) {
            std::cin >> shuffles[i];
        }

        int shift = shuffles.sum() % cards.size();
        std::cout << (cards + cards).substr(shift, cards.size()) << std::endl;
    }
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

using namespace std;
typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    set<int> accepted;
    map<int, int> wa;
    for (int i = 0; i < M; i++) {
        int p;
        string verdict;
        cin >> p >> verdict;
        if (accepted.count(p)) {
            continue;
        }

        if (verdict == "AC") {
            accepted.insert(p);
        }
        else {
            wa[p] += 1;
        }
    }
    int totalwa = 0;
    for (auto& kv : wa) {
        int k, v;
        tie(k, v) = kv;
        if (accepted.count(k)) totalwa += v;
    }
    printf("%lu %d\n", accepted.size(), totalwa);
}


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

int main() {
  int N;
  string S;
  cin >> N >> S;
  for(int i = 0; i < S.size(); i++){
      cout << (char)((S.at(i)-'A'+ N)%26+'A');
  }
  cout << endl;

}

Measured memory_bytes: 256
/* -----KAUN_MEET--------*/

#include <bits/stdc++.h>
using namespace std;
#define int long long int
int mod = 1000000007;
#define P get<0>
#define D get<1>
#define T get<2>
#define C get<3>
#define PB push_back
#define MP make_pair
#define BS binary_search
#define LB lower_bound
#define UB upper_bound
#define F first
#define S second
#define gcd __gcd
#define fastio               \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0);

void __print(int x)
{
    cerr << x;
}
void __print(unsigned x) { cerr << x; }
void __print(unsigned long x) { cerr << x; }
void __print(unsigned long long x) { cerr << x; }
void __print(float x) { cerr << x; }
void __print(double x) { cerr << x; }
void __print(long double x) { cerr << x; }
void __print(char x) { cerr << '\'' << x << '\''; }
void __print(const char *x) { cerr << '\"' << x << '\"'; }
void __print(const string &x) { cerr << '\"' << x << '\"'; }
void __print(bool x) { cerr << (x ? "true" : "false"); }

template <typename Th, typename V>
void __print(const pair<Th, V> &x)
{
    cerr << '{';
    __print(x.first);
    cerr << ',';
    __print(x.second);
    cerr << '}';
}
template <typename Th>
void __print(const Th &x)
{
    int f = 0;
    cerr << '{';
    for (auto &i : x)
        cerr << (f++ ? "," : ""), __print(i);
    cerr << "}";
}
void _print() { cerr << "]\n"; }
template <typename Th, typename... V>
void _print(Th t, V... v)
{
    __print(t);
    if (sizeof...(v))
        cerr << ", ";
    _print(v...);
}
#ifndef ONLINE_JUDGE
#define debug(x...)               \
    cerr << "[" << #x << "] = ["; \
    _print(x)
#else
#define debug(x...)
#endif
void binary_rock()
{
    int n, k;
    cin >> n >> k;
    int i, j, l;
    vector<int> a(n);
    for (i = 0; i < n; i++)
        cin >> a[i];

    int cost[n];
    cost[0] = 0;
    cost[1] = (abs(a[1] - a[0]));
    for (i = 2; i < n; i++)
    {
        cost[i]=INT_MAX;
        // int xx=cost[i-1]+(abs(a[i]-a[i-1]));
        // int yy=cost[i-2]+((abs(a[i]-a[i-2])));
        // cost[i]=min(xx,yy);
        int times = 0;
        for (j = i - 1; j >= 0 && times < k; j--)
        {
            cost[i]=min(cost[i],cost[j]+((abs(a[i]-a[j]))));

            times++;
        }
    }
    cout << cost[n - 1] << endl;
}

signed main()
{
    fastio
        clock_t t1 = clock();

    int t = 1;
    // cin >> t;
    while (t--)
    {
        binary_rock();
    }

    clock_t t2 = clock();
    // cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;
    // cout << CLOCKS_PER_SEC << endl;
    return 0;
}

Measured memory_bytes: 1792
//In the name of God:)
#include <bits/stdc++.h>
#define pb push_back
#define F first
#define S second
#define pii pair<int,int>
#define ll long long
using namespace std;
const int MAXN = 1e5+10;
ll dp[MAXN];
void solve(){

}

int32_t main(){
  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  ll n , w , tmp1 , tmp2;
  ll a[MAXN][2];
  cin>>n>>w;
  for(int i = 0 ; i < n ; i++){
    cin>>a[i][0]>>a[i][1];
  }
  ll ans = 0;
  for(int i = 0 ; i < n ;i++){
    for(int j = w ;  j >= a[i][0] ; j--){
      dp[j] = max(dp[j] , dp[j - a[i][0]] + a[i][1] );
      ans = max(ans , dp[j]);
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main() {
  string S, T;
  cin >> S;
  cin >> T;
  
  int ans = 0;
  
  for (int i = 0; i < S.size(); i++) {
    if (S.at(i) != T.at(i)) {
      ans++;
    }
  }
  cout << ans;
}

Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (int i = (int)(a); i < (int)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define ll long long
#define lld long double
#ifdef DEBUG
#define line() cout << "[" << __LINE__ << "] ";
#define dump(i) cout << #i ": " << i << " ";
#define dumpl(i) cout << #i ": " << i << endl;
#else
#define line(i)
#define dump(i)
#define dumpl(i)
#endif
using namespace std;
int main(int argc, char const *argv[])
{
    int h, w;
    cin >> h >> w;
    int x, y;
    cin >> x >> y;
    cout << h * w - (w * x + h * y - x * y) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    Int ans=0;
    for(int i=0; i<1000; i++){
        int tmp[3];
        tmp[0]=i/100;
		tmp[1]=(i/10)%10;
		tmp[2]=i%10;
		int count=0;
		for (int j =0; j<s.length(); j++)
		{
 
			if ((s[j]-'0')==tmp[count])
			{
				
              count++;
			}
			if(count==3)
			{
				ans++;
              break;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3676
#include <bits/stdc++.h>
    using namespace std;
    #define mp make_pair
    #define pb push_back
    #define lb lower_bound
    #define up upper_bound
    #define vll vector<ll>
    #define G vector<vll >
    #define F first
    #define S second
    #define pll pair<ll,ll>
    #define FOR1(i,a) for(i=0;i<=a;i++)
    #define FOR2(i,a,b) for(i=a;i<=b;i++)
    #define endl '\n'
    #define clr(a) memset(a,0,sizeof(a))
    #define all(x) x.begin(),x.end()
    #define rll read_ll();
    #ifndef ONLINE_JUDGE
    #define gc getchar
    #define pc putchar
    #else
    #define gc getchar_unlocked
    #define pc putchar_unlocked
    #endif
    typedef long long ll;
    ll read_ll(){char c=gc();while((c<'0'||c>'9')&&c!='-')c=gc();ll ret=0;int neg=0;if(c=='-')neg=1,c=gc();while(c>='0'&&c<='9'){ret=10*ret+c-48;c=gc();}return neg?-ret:ret;}
     
    int main()
    {
    	ll n,t,i;
    	n=rll t=rll
    	vll a(n+1);
    	FOR1(i,n-1)
    	{
    		cin>>a[i];
    	}
    	a[i]=1000000000000;
    	// ll endtime=a[0]+t;
    	ll runtime=0,endtime=0;
    	// bool flag;
    	FOR2(i,0,n-1)
    	{
    		runtime+=min(t,a[i+1]-a[i]);
    	}
    	// cout<<runtime<<" ";
    	// cout<<endtime;
    	cout<<runtime;
    	
    	return 0;
    }

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

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,n;
  cin >> a >> b >> n;
  ll ans;
  if(b <= n){
    ans = a*(b-1)/b;
  }else{
    ans = a*(n)/b;
  }

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



Measured memory_bytes: 3512
import itertools, math

N = int(input())
shops = []
for i in range(N):
    shops.append(list(map(int, input().split())))

routes = itertools.permutations(shops, N)
l = list(routes)

total = 0
for route in l:
    tmp = 0
    for i in range(1,len(route)):
        kyori = (route[i][0]-route[i-1][0])**2 + (route[i][1]-route[i-1][1])**2
        tmp += math.sqrt(kyori)
    total += tmp
ans = total/len(l)
print(ans)



Measured memory_bytes: 7972
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
ll bg=pow(10,9)+7;
#define ff(i,n) for(i=0;i<n;i++)
#define gg1(n1) cin>>n1;
#define gg(n1,n2) cin>>n1>>n2;
#define gg3(n1,n2,n3) cin>>n1>>n2>>n3;
#define hh(n) cout<<n<<endl;
#define t top
#define p push
#define pb push_back
#define mp make_pair
void print(ll f)
{
     if(f==1)  cout<<"First";
     else      cout<<"Second";
     
}
int main()
{
  ll i,j,n,k;
  cin>>n>>k;
  ll arr[n],dp[k+1];
  dp[0]=2;
  for(i=0;i<n;i++)  cin>>arr[i];
  for(i=1;i<=k;i++)
   {
        ll flag=0;
        for(j=0;j<n;j++)
          if(i-arr[j]>=0&&dp[i-arr[j]]==2)  
             flag=1;
        if(flag==1)        
           dp[i]=1;
        else
           dp[i]=2;
   }
   print(dp[k]);
  return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <bitset>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#define X first
#define Y second
using namespace std;

int main(){
	int kind[] = {1000, 500, 100};
	int n, m;
	while(cin >> n >> m && (n!=0||m!=0)){
		int count[] = {0, 0, 0};
		int oturi=m-n;
		for(int i = 0; i < 3; i++){
			while(oturi>=kind[i]){
				count[i]++;
				oturi -= kind[i];
			}
		}
		cout << count[2] << " " << count[1] << " " << count[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int N,M;
 cin >> N >> M;
  
 if ((N >= 1 && N <= 9) && (M >= 1 && M <= 9)){
 	cout << M*N;
 }
  else {
    cout << -1;
  }
  
  
}

Measured memory_bytes: 256
MOD = 10**9+7

n, k = [int(_) for _ in input().split()]

a = [int(_) for _ in input().split()]

m = list(filter(lambda x: x < 0, a))
p = list(filter(lambda x: x > 0, a))

m.sort()
p.sort(reverse=True)


if len(p)+len(m) < k:
    print(0)
    exit()
if len(p)+len(m) == k:
    ans = 1
    for p_ in p:
        ans = (ans*p_) % MOD
    for q_ in m:
        ans = (ans*q_) % MOD
    print(ans)
    exit()

if len(p) == 0 and k % 2 == 1:
    ans = 1
    for i in range(k):
        ans = (ans*m[-i-1]) % MOD
    if 0 in a:
        ans *= 0
    print(ans)
    exit()

i, j = 0, 0
if k % 2 == 1:
    d = p.pop(-1)
m.append(0)
m.append(0)
p.append(0)
p.append(0)
# print(p, m)
ans = 1
for c in range(k//2):
    # print(i, j)
    if m[i]*m[i+1] >= p[j]*p[j+1]:
        ans = (ans*m[i]*m[i+1]) % MOD
        i += 2
    else:
        ans = (ans*p[j]*p[j+1]) % MOD
        j += 2

if k % 2 == 1:
    ans = (ans*max(p[j], d)) % MOD


if ans > MOD:
    ans -= MOD
print(ans)


Measured memory_bytes: 33088
import java.awt.Point;
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main{
	
	static final Scanner s=new Scanner(System.in);
	
	public static void main(String[] __){
		int n=s.nextInt(),m=s.nextInt();
		Point[] students=new Point[n];
		CheckPoint[] cps=new CheckPoint[m];
		for(int i=0;i<n;i++)
			students[i]=new Point(s.nextInt(),s.nextInt());
		for(int i=0;i<m;i++)
			cps[i]=new CheckPoint(i+1,s.nextInt(),s.nextInt());
		for(Point st:students)
			System.out.println(Arrays.stream(cps).min(
					Comparator.comparingInt(o->Math.abs(o.x-st.x)+Math.abs(o.y-st.y))).get().id);
	}
}
class CheckPoint extends Point{
	int id;
	CheckPoint(int id,int x,int y){
		super(x,y);
		this.id=id;
	}
}

Measured memory_bytes: 26708
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 500;
int a[N];
int n, k, x;

bool cmp(int a, int b) {
    return a > b;
}
int main()
{
    cin>>n>>k;
    for(int i=0;i<n;i++) {
        scanf("%d",&x);
        a[x] ++;
    }

    sort(a, a + N - 400, cmp);
    int cnt = 0;


    for(int i=0;i<=N-500;i++) {
        if(i >= k) {
            cnt += a[i];
        }
    }
    cout<<cnt<<endl;
    return 0;
}


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

int main() {
  long long num;  
  cin >> num;
  long long kekka = 1e12;
  
  for(long long i = 1; i * i <= num; i++){
    if(num % i == 0){
      kekka = min(kekka,i + num/i - 2);
    }
  }
  
  cout << kekka;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
using namespace std;
typedef long long ll;

int main()
{
  int N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;

  int cnt[2100] = {0};

  rep(i, N) {
    for(int j = i+1; j<N; j++) {
      int d = j - i;
      int dd = d;
      if ( X - d <= i && i <= X + d && Y - d <= j && j <= Y + d ){
        dd = min(d, abs(X-i) + 1 + abs(Y-j));
      }
      cnt[dd]++;
    }
  }
  FOR(i, 1, N-1) {
    cout << cnt[i] << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
 int lcm(int a,int b){
   int d=a,e=b,f;
   if(a<b)
    swap(a,b); 
   int c,m=1;
   while(m){
    c=a%b;
   if(c==0){
      f=b;
      m--;
    }
     else{
       a=b;
      b=c;
  }
   }
  return d*e/f;
    }
signed main(){
  int a,b,c,d,e;
  cin>>a>>b>>c>>d;
  e=lcm(c,d);
 cout<< b-a+1-(b/c-(a-1)/c+b/d-(a-1)/d-b/e+(a-1)/e);
  
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <algorithm>
#include <set>
#include <cmath>
#include <iomanip>
#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 INF 999999999
#define ll long long
#define VSORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
using namespace std;

#ifdef INPUT
#include <sstream>
stringstream input(R"(
14
1 2 2 3 3 3 4 4 4 4 1 2 3 4
)");
#define cin input
#endif

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

	vector<int> a(n+1);
	FOR(i,0,n)
		cin >> a[i];
	
	int count=0;
	REP(i,n)
	{
		int num = 0;
		FOR(j,i+1,n+1)
		{
			if(a[i]==a[j])
				num++;
			else
			{
				i=j-1;
				break;
			}
		}
		count += (num+1)/2;
	}

	cout << count << endl;
}

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

#define rep(i, x, n) for (int i = x; i < n; i++)
typedef long long ll;

const int INF = 1e9 + 7;

using namespace std;

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

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

	ll res = 0;
	if (n == 1) {
		cout << m << endl;
		return 0;
	}

	for (ll i = 1; i * i <= m; i++) {
		if (m % i == 0) {
			if (i * n <= m)
				res = max(res, i);

			ll div = m / i;
			if (div != i) {
				if (div * n <= m)
					res = max(res, div);
			}
		}
	}

	cout << res << endl;
	return 0;
}


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

int n,m,x,y,pre;
int fen[N];
vector<int> v[N];

void up(int node,int val) {
	node++;
	while(node-1<=m) {
		fen[node]+=val;
		node+=node&-node;
	}
}

int get(int node) {
	int ret=0;
	node++;
	while(node>=1) {
		ret+=fen[node];
		node-=node&-node;
	}
	return ret;
}

int main() {
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) {
		scanf("%d %d",&x,&y);
		v[y-x+1].push_back(x);
	}
	for(int i=1;i<=m;i++) {
		int ans=0;
		for(int j=0;j<=m;j+=i) {
			ans+=get(j);
		}
		printf("%d\n",n-pre+ans);
		for(int j=0;j<v[i].size();j++) {
			up(v[i][j],1);
			up(v[i][j]+i,-1);
		}
		pre+=v[i].size();
	}
}



Measured memory_bytes: 11520
import java.util.*;
public class Main{
 public static void main(String[] args){
   Scanner sc = new Scanner(System.in);
   int s1 = sc.nextInt();
   int s2 = sc.nextInt();
   int s3 = sc.nextInt();
 
   if(Math.abs(s1-s2)>Math.abs(s1-s3))System.out.println("B");
   else System.out.println("A");
 }
}

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

int main() {
    long long k;
    cin >> k;
    queue<long long> q;
    for(long long i = 1; i < 10; ++i) q.push(i);
    for(int i = 0; i < k-1; ++i) {
        long long x = q.front();
        q.pop();
        if(x % 10 != 0) q.push(10*x+(x%10)-1);
        q.push(10*x+(x%10));
        if(x % 10 != 9) q.push(10*x+(x%10)+1);
    }
    cout << q.front() << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using lint = int64_t;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(v)    begin(v), end(v)
#define in        []{lint n; cin>>n; return n;}()

int main() { cin.tie(0); ios::sync_with_stdio(false);
    int V = in, E = in;
    vector<vector<int>> to(V*3);

    rep( i, E ) {
        int u = in-1, v = in-1;
        to[u*3+0].push_back(v*3+1);
        to[u*3+1].push_back(v*3+2);
        to[u*3+2].push_back(v*3+0);
    }

    int S = in-1, G = in-1;
    vector<bool> visited(to.size(), false);
    queue<pair<int,int>> q;
    q.push( make_pair(0,S*3) );
    while( !q.empty() ) {
        int d = q.front().first;
        int v = q.front().second;
        q.pop();
        if( visited[v] ) continue;
        visited[v] = true;
        if( v == G*3 ) { cout << d/3 << "\n"; return 0; }
        for( auto t : to[v] ) q.push( make_pair(d+1, t) );
    }
    cout << "-1\n";
}


Measured memory_bytes: 16640
#include <iostream>
#include <cstdlib>
#include <vector>
#include <string>
#include <utility>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>


using namespace std;
using ll = long long;
using ull = unsigned long long;

unordered_map<char, vector<int>> pos;

int main()
{
    string s, t;
    cin >> s >> t;
    const ull N = s.size();
    
    for(ull i = 0; i < N; ++i){
        pos[s[i]].push_back(i + 1);
    }
    
    ull ans = 0;
    int last = 0;
    
    for(auto c : t){
        auto& p = pos[c];
        if(p.empty()){
            cout << -1 << endl;
            return 0;
        }
        auto it = upper_bound(p.begin(), p.end(), last);
        if(it == p.end()){
            ans += N;
            last = *p.begin();
        }
        else{
            last = *it;
        }
    }
    
    cout << ans + last << endl;
}


Measured memory_bytes: 1216