akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

#define x(p) real(p)
#define y(p) imag(p)

const double eps=1e-10;
const double inf=1e12;
const double PI=acos(-1);
typedef complex<double> P;

namespace std{
  bool operator<(const P& a,const P& b){
    return x(a)==x(b)?y(a)<y(b):x(a)<x(b);
  }
}
double cross(const P& a,const P& b){
  return y(conj(a)*b);
}
double dot(const P& a,const P& b){
  return x(conj(a)*b);
}
struct L : public vector<P> { // line and segment
  L(const P& a,const P &b){
    push_back(a);
    push_back(b);
  }
};

struct C{
  P p;
  double r;
  C(const P& p,double r):p(p),r(r){}
};
int ccw(P a,P b,P c) {
  b=b-a;c=c-a;
  if(cross(b,c)>0) return +1;       // counter clockwise
  if(cross(b,c)<0) return -1;       // clockwise
  if(dot(b,c)<0)   return +2;       // c--a--b on line
  if(norm(b)<norm(c)) return -2;       // a--b--c on line
  return 0;
}
P projection(const L& l,const P& p){
  P b=l[1]-l[0],c=p-l[0];
  return l[0]+b*x(c/b);
}
bool intersectSP(const L& s,const P& p){
  return abs(s[0]-p)+abs(s[1]-p)-abs(s[1]-s[0])<eps;
}
bool intersectSS(const L& s,const L& t){
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1])<=0&&ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1])<=0;
}
double distanceSP(const L& s,const P& p) {
  const P r=projection(s,p);
  return intersectSP(s,r)?abs(r-p):min(abs(s[0]-p),abs(s[1]-p));
}

double d[333];

int main(){
	cin.sync_with_stdio(false);
  while(1){
    int n;
    vector<C> cs;
    vector<P> ps;
    cin>>n;
    if(n==0)break;
    rep(i,n){
      double x,y,r;
      cin>>x>>y>>r;
      cs.pb(C(P(x,y),r));
    }
    ps.push_back(cs[0].p);
    rep(i,n-1){
      double x1=x(cs[i+1].p)-x(cs[i].p),y1=y(cs[i+1].p)-y(cs[i].p);
      double r1=cs[i].r,r2=cs[i+1].r;
      double a=(x1*x1+y1*y1+r1*r1-r2*r2)/2.0;
      double xx1=((a*x1+y1*sqrt((x1*x1+y1*y1)*r1*r1-a*a))/(x1*x1+y1*y1))+x(cs[i].p);
      double xx2=((a*x1-y1*sqrt((x1*x1+y1*y1)*r1*r1-a*a))/(x1*x1+y1*y1))+x(cs[i].p);
      double yy1=((a*y1-x1*sqrt((x1*x1+y1*y1)*r1*r1-a*a))/(x1*x1+y1*y1))+y(cs[i].p);
      double yy2=((a*y1+x1*sqrt((x1*x1+y1*y1)*r1*r1-a*a))/(x1*x1+y1*y1))+y(cs[i].p);
      ps.push_back(P(xx1,yy1));
      ps.push_back(P(xx2,yy2));
    }
    ps.push_back(cs[n-1].p);
    rep(i,333)d[i]=inf;
    d[0]=0;
    int m=ps.size();
    rep(i,m)repl(j,i+i%2+1,m){
      // i->j
      bool ok=true;
      repl(k,(i%2==0?i-1:i),(j%2==0?j:j+1)){
        if(!intersectSS(L(ps[k],ps[k+1]),L(ps[i],ps[j])))ok=false;
        k++;
      }
      if(ok){
        minch(d[j],d[i]+abs(ps[i]-ps[j]));
      }
    }
    printf("%.10f\n", d[m-1]);
  }
	return 0;
}

Measured memory_bytes: 3392
#!/usr/bin/env python3
import sys


def solve(N: int):
    res = 0
    x = 1
    while x * x <= N:
        mp1, r = divmod(N, x)
        m = mp1 - 1
        if x >= m:
            break
        x += 1
        if r > 0:
            continue
        res += m
    print(res)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
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
    solve(N)

if __name__ == '__main__':
    main()


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

int main() {
  int n;
  cin >> n;
  vector<int64_t> v(3 * n);
  for (int i = 0; i < 3 * n; i++) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  reverse(v.begin(), v.end());
  int64_t s = 0;
  for (int i = 1; i < 2 * n; i += 2) {
    s += v.at(i);
  }
  cout << s << endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define SORTR(x) sort(ALLR(x));
#define SORT(x) sort(ALL(x));
#define SUM(x) accumulate(ALL(x), 0);
#define EACH(i,x) for(typeof((x).begin()) i=(x).begin(); i!=(x).end(); ++i)
typedef vector<ll> VI;
typedef vector<VI> VVI;
typedef vector<char> VC;
typedef vector<VC> VVC;
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; }
template <class BidirectionalIterator>
bool next_partial_permutation(BidirectionalIterator first, BidirectionalIterator middle,BidirectionalIterator last){reverse(middle, last); return next_permutation(first , last);}


void Main()
{
	ll N,L;
	ll result=0;
	ll index=0;
	string S;
	cin>>N>>L;
	VI vec(N);
	REP(i, N) vec[i]=L+i;
	ll sum=SUM(vec);
	ll val;
	ll diff=10000000;
	REP(i,N){
		val=abs(vec[i]);
		bool change=chmin(diff,val);
		if(change){
			index=i;
		}
	}
	result=accumulate(ALL(vec),0)-vec[index];
	cout << result << "\n";
	return;
}

int main()
{
	std::cin.tie(0);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    char a, b;
    scanf("%c %c", &a, &b);
    if (a == 'H') {
        printf("%c\n", b);
    } else { // a == 'D'
        if (b == 'D') {
            printf("%c\n", 'H');
        } else {
            printf("%c\n", 'D');
        }
    }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    string s;
    cin>>s;
    ll n = s.length();
    ll k = 0;
    string prev = "";
    string temp = "";
    for(ll i=0;i<n;i++)
    {
        temp += s[i];
        if(temp != prev)
        {
            prev = temp;
            temp = "";
            k++;
        }
    }
    cout<<k;
	return 0;
}


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

int main()
{
    char s[11],ans[11];

    scanf("%s",s);

    int len = strlen(s),i,j,left = 0;

    for (i = 0; i < len; i++)
    {
        if(s[i] == '0')
        {
            ans[left] = '0';
            left++;
        }
        else if(s[i] == '1')
        {
            ans[left] = '1';
            left++;
        }
        else
        {
            left--;
            if(left < 0)left = 0;
        }
    }
    
    for (i = 0; i < left; i++)
    {
        printf("%c", ans[i]);
    }
    
}

Measured memory_bytes: 128
// #include {{{
#include <iostream>
#include <cassert>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <ctime>
#include <queue>
#include <set>
#include <map>
#include <stack>
#include <string>
#include <bitset>
#include <vector>
#include <complex>
#include <algorithm>
using namespace std;
// }}}
// #define {{{
typedef long long ll;
typedef double db;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define per(i,a,b) for(int i=(b)-1;i>=(a);--i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
// }}}

const int N = (1<<15) , P = 998244353 , G = 3 , B = 2;
int w[2][N],rev[N],fac[N]={1},ifac[N];
ll Pow(ll x,ll t){ll r=1;for(;t;t>>=1,x=x*x%P)if(t&1)r=r*x%P;return r;}
void ini(){
    ll t = Pow(G,(P-1)/N);
    w[0][0] = w[1][0] = 1;
    rep(i,1,N) w[0][i] = t*w[0][i-1]%P;
    rep(i,1,N) w[1][i] = w[0][N-i];
    rep(i,0,N) for(int j=1;j<N;j*=B) (rev[i]<<=1)|=(i/j)%B;
    rep(i,1,N) fac[i]=ll(fac[i-1])*i%P;
    ifac[N-1]=Pow(fac[N-1],P-2);
    per(i,1,N) ifac[i-1]=ll(ifac[i])*i%P;
}
void ntt(int *a,int n,int o){
    int tt = N/n;
    rep(i,0,n){
        int j = rev[i]/tt;
        if(i<j) swap(a[i],a[j]);
    }
    for(int i=1;i<n;i<<=1)
        for(int j=0,t=N/(i+i);j<n;j+=i+i)
            for(int k=j,l=0;k<j+i;++k,l+=t){
                int b = (ll)a[k+i]*w[o][l]%P;
                a[k+i] = a[k]-b; if(a[k+i]<0) a[k+i]+=P;
                a[k] = a[k]+b; if(a[k]>=P) a[k]-=P;
            }
    if(o == 1){
        ll inv = Pow(n,P-2);
        rep(i,0,n) a[i] = a[i]*inv%P;
    }
}
int a[N] , b[N] , c[N];
void mul(int *a,int *b,int len,int lim){
    memcpy(c,b,sizeof(*b)*len);
    ntt(a,len,0);
    ntt(c,len,0);
    rep(i,0,len) a[i]=ll(a[i])*c[i]%P;
    ntt(a,len,1);
    rep(i,lim+1,len) a[i]=0;
}

int main(){
    ini();
    string s , t;
    cin >> s >> t;
    int e = 0 , m = 0;
    rep(i,0,sz(s)) {
        e += s[i] == '1' && t[i] == '0';
        m += s[i] == '1' && t[i] == '1';
    }
    int len = 1;
    while(len <= m + m) len <<= 1;
    a[0] = 1;
    rep(i,0,m+1) b[i]=ifac[i+1];
    for(int t=e;t;t>>=1,mul(b,b,len,m)) if(t&1) mul(a,b,len,m);
    int ans=0;
    rep(i,0,m+1) (ans+=a[i])%=P;
    ans=ll(ans)*fac[e]%P*fac[m]%P*fac[e+m]%P;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

ll N, a[100010];

signed main(){
    cin >> N;
    REP(i, N) cin >> a[i];
    bool win = false;
    REP(i, N) win |= (a[i] % 2 == 1);
    PRINT((win ? "first" : "second"));
    return 0; 
}

Measured memory_bytes: 4380
#include<stdio.h>

#include<string.h>

int main(){

	char s[11]="";

	char t[12]="";

	scanf("%s",s);
	scanf("%s",t);


	if(strncmp(s,t,strlen(s))==0){
		int S,T;
		S=strlen(s);
		T=strlen(t);
		if(S+1==T){
			printf("Yes");
		}else{
			printf("No");
		}



		
	}else{
		printf("No");
	}



	return 0;
		
}	


Measured memory_bytes: 1748
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)


int main(){
	int a,b,c;
	cin >> a >> b >> c;
	cout << a*b/2 << endl;
	
	
	return 0; 
}



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

#define sz(x) (int)(x).size()
#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;

constexpr ll lim = 11;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll x, y, z, k;
    cin >> x >> y >> z >> k;
    vector<ll> a(x), b(y), c(z);
    for (ll i = 0; i < x; i++) cin >> a[i];
    for (ll i = 0; i < y; i++) cin >> b[i];
    for (ll i = 0; i < z; i++) cin >> c[i];
    vector<ll> d;
    for (ll i = 0; i < x; i++) {
        for (ll j = 0; j < y; j++) {
            d.push_back(a[i] + b[j]);
        }
    }
    vector<ll> e(z);
    sort(all(d), greater<ll>());
    for (ll i = 0; i < k; i++) {
        ll res = 0;
        ll k = -1;
        for (ll j = 0; j < z; j++) {
            if (e[j] < sz(d) && c[j] + d[e[j]] > res) {
                res = c[j] + d[e[j]];
                k = j;
            }
        }
        cout << res << endl;
        e[k]++;
    }
}


Measured memory_bytes: 10608
package main

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

//Util
func nextStr() string {
	sc.Scan()
	return sc.Text()
}

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

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

func minInt(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}

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

func absFloat64(a float64) float64 {
	if a >= 0 {
		return a
	} else {
		return -a
	}
}

func maxFloat64(a, b float64) float64 {
	if a > b {
		return a
	} else {
		return b
	}
}

func minFloat64(a, b float64) float64 {
	if a > b {
		return b
	} else {
		return a
	}
}

func str2Int(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func powInt(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	if x == 2 {
		return true
	}
	if x%2 == 0 {
		return false
	}

	b := true
	rootx := int(math.Sqrt(float64(x)))
	i := 3
	for i <= rootx {
		if x%i == 0 {
			b = false
			break
		}
		i += 2
	}
	return b
}

func PrimeFactors(n int) (pfs []int) {
	// Get the number of 2s that divide n
	for n%2 == 0 {
		pfs = append(pfs, 2)
		n = n / 2
	}

	// n must be odd at this point. so we can skip one element
	// (note i = i + 2)
	for i := 3; i*i <= n; i = i + 2 {
		// while i divides n, append i and divide n
		for n%i == 0 {
			pfs = append(pfs, i)
			n = n / i
		}
	}

	// This condition is to handle the case when n is a prime number
	// greater than 2
	if n > 2 {
		pfs = append(pfs, n)
	}

	return
}

func sumInts(x []int) int {

	total := 0
	for _, v := range x {
		total += v
	}

	return total
}

//Main
const (
	initialBufSize = 10000
	maxBufSize     = 1000000
	mod            = 1e9 + 7
)

var (
	sc *bufio.Scanner = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		return sc
	}()
)

var N, M int

func main() {
	sc.Split(bufio.ScanWords)

	N, M = nextInt(), nextInt()

	if N == 1 && M == 1 {
		fmt.Println(1)
		return
	} else if N == 1 {
		fmt.Println(M - 2)
		return
	} else if M == 1 {
		fmt.Println(N - 2)
		return
	}

	fmt.Println((M - 2) * (N - 2))
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)
const int mod=1000000007;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,k;cin >> n >> k;
	string s;cin >> s;
	int cnt=0;
	vector<int> a;
	vector<int> c;
	rep(i,n){
		if(s.at(i)=='0') cnt++;
		else{
			if(cnt) a.pb(cnt);
			cnt=0;
		}
	}
	if(cnt) a.pb(cnt);
	cnt=0;
	rep(i,n){
		if(s.at(i)=='1') cnt++;
		else{
			if(cnt) c.pb(cnt);
			cnt=0;
		}
	}
	if(cnt) c.pb(cnt);
	vector<int> b(a.size()+1);
	vector<int> d(c.size()+1);
	rep(i,a.size()) b.at(i+1)+=a.at(i)+b.at(i);
	rep(i,c.size()) d.at(i+1)+=c.at(i)+d.at(i);
	if(a.size()<=k){
		cout << n << endl;
	}
	else{
		if(a.size()==c.size()){
			if(s.at(0)=='0'){
				int ans=0;
				for(int i=k;i<b.size();++i){
					if(i==k) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k));
					else if(i==b.size()-1) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k-1));
					else ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k-1));
				}
				cout << ans << endl;
			}
			else{
				int ans=0;
				for(int i=k;i<b.size();++i){
					if(i==k) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i+1)-d.at(i-k));
					else if(i==b.size()-1) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k));
					else ans=max(ans,b.at(i)-b.at(i-k)+d.at(i+1)-d.at(i-k));
				}
				cout << ans << endl;
			}
		}
		else if(a.size()>c.size()){
			int ans=0;
			for(int i=k;i<b.size();++i){
				if(i==k) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k));
				else if(i==b.size()-1) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i-1)-d.at(i-k-1));
				else ans=max(ans,b.at(i)-b.at(i-k)+d.at(i)-d.at(i-k-1));
			}
			cout << ans << endl;
		}
		else{
			int ans=0;
			for(int i=k;i<b.size();++i){
				if(i==k) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i+1)-d.at(i-k));
				else if(i==b.size()-1) ans=max(ans,b.at(i)-b.at(i-k)+d.at(i+1)-d.at(i-k));
				else ans=max(ans,b.at(i)-b.at(i-k)+d.at(i+1)-d.at(i-k));
			}
			cout << ans << endl;
		}
	}
}


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

int dig_sum(int a)
{
    int sum=0;
    while(a)
    {
        sum=sum+a%10;
        a=a/10;
    }
    return sum;
}
int cheak_zero(int a)
{
    int count=0;
    while(a)
    {
        int b=a%10;
        a=a/10;
        if(b!=0)
            break;
        else
            count++;
    }
    return count;
}
void sort(int numbers[], int count)
{
    for(int i = 0; i < count - 1; i++)
    {
        int currentMin = numbers[i];
        int currentMinIndex = i;

        for(int j = i + 1; j < count; j++)
        {
            if(currentMin > numbers[j])
            {
                currentMin = numbers[j];
                currentMinIndex = j;
            }
        }

        if(currentMinIndex != i)
        {
            numbers[currentMinIndex] = numbers[i];
            numbers[i] = currentMin;

        }
    }
}


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


int main()
{
    int n;
    cin>>n;
    if(n<1200)
        cout<<"ABC"<<endl;
    else if(n<2800)
        cout<<"ARC"<<endl;
    else
        cout<<"AGC"<<endl;
    return 0;
}


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

int main(){
	int H, W, i, j, pair = 0, one = 0;
	scanf("%d%d", &H, &W);
	char **A = (char **)malloc(sizeof(char *) * H);
	for(i = 0; i < H; i++){
		A[i] = (char *)malloc(sizeof(char) * (W + 1));
		scanf("%s", A[i]);
	}
	int *alf_num = (int *)malloc(sizeof(int) * 26);
	for(i = 0; i < 26; i++){
		alf_num[i] = 0;
	}
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			alf_num[(int)A[i][j] - (int)'a']++;
		}
	}
	if(H % 2 == 0 && W % 2 == 0){
		for(i = 0; i < 26; i++){
			if(alf_num[i] % 4 != 0){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}
	else if(H % 2 == 0 && W % 2 == 1){
		for(i = 0; i < 26; i++){
			if(alf_num[i] % 4 != 0){
				if(alf_num[i] % 4 != 2){
					printf("No\n");
					return 0;
				}
				else{
					pair++;
				}
			}
		}
		if(pair <= H / 2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		return 0;
	}
	else if(H % 2 == 1 && W % 2 == 0){
		for(i = 0; i < 26; i++){
			if(alf_num[i] % 4 != 0){
				if(alf_num[i] % 4 != 2){
					printf("No\n");
					return 0;
				}
				else{
					pair++;
				}
			}
		}
		if(pair <= W / 2){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		return 0;
	}
	else{
		for(i = 0; i < 26; i++){
			if(alf_num[i] % 4 != 0){
				if(alf_num[i] % 4 == 1){
					one++;
				}
				else if(alf_num[i] % 4 == 3){
					printf("No\n");
					return 0;
				}
				else{
					pair++;
				}
			}
		}
		if(pair <= H / 2 + W / 2 && one == 1){
			printf("Yes\n");
		}
		else{
			printf("No\n");
		}
		return 0;
	}
}

Measured memory_bytes: 128
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
const char *ds = "ULDR";
int h, w, sz, goal;
char in[10][11], ans[40];

void rec(int y, int x, int dir){
	if(sz == goal){
		cout << ans << endl;
		exit(0);
	}
	rep(d, 4) if((d ^ 2) != dir){
		int ny = y, nx = x;
		while(0 <= ny && ny < h && 0 <= nx && nx < w && in[ny][nx] == '.')
		ny += dy[d], nx += dx[d];
		
		if(0 <= ny && ny < h && 0 <= nx && nx < w){
			ans[sz++] = ds[d];
			in[ny][nx] = '.';
			rec(ny, nx, d);
			in[ny][nx] = 'o';
			sz--;
		}
	}
}

int main(){
	cin >> h >> w;
	int y, x, dir;
	rep(i, h){
		cin >> in[i];
		rep(j, w){
			rep(k, 4) if(in[i][j] == ds[k]){
				y = i, x = j, dir = k;
				in[y][x] = '.';
			}
			if(in[i][j] == 'o') goal++;
		}
	}
	rec(y, x, dir);
	return 0;
}

Measured memory_bytes: 1168
#include <bits/stdc++.h>
using namespace std;
const int maxn=1000005;
typedef long long ll;
typedef double dbl;
typedef long double ld;
const ld EPS=1e-9;
const ld PI=3.141592653589793;
const ll MOD = 1e9+7;
const int SQRT = 300;
const int LG=21;
const int FOURIER = (1<<LG);
////////////////
ll dp[51][51][2501];
int x[100];
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int n;
    int a;
    cin>>n>>a;
    for(int i=1; i<=n; ++i)
        cin>>x[i];
    dp[0][0][0]=1;
    for(int i=1; i<=n; ++i){
        for(int el=0; el<=n; ++el)
            for(int sum=0; sum<=2501; ++sum){
                dp[i][el][sum]=dp[i-1][el][sum];
                if (sum>=x[i] && el)
                    dp[i][el][sum]+=dp[i-1][el-1][sum-x[i]];
            }
    }
    ll ans=0;
    for(int col=1; col<=n; ++col){
        int need=a*col;
        ans+=dp[n][col][need];
    }
    cout<<ans;
}



Measured memory_bytes: 50048
#include<stdio.h>
int main(void){
    
    int summer_vacation;
    int homeworks;
    int weihgt[10010];
    int homework_Times = 0;
    int Remain_vacation;

    scanf("%d%d",&summer_vacation,&homeworks);
    for(int i = 0; i < homeworks; i++){
        scanf("%d",&weihgt[i]);
        homework_Times += weihgt[i];
    }

    Remain_vacation=summer_vacation-homework_Times;
    if(Remain_vacation>=0){
        printf("%d\n",Remain_vacation);
    }else
    {
        printf("%d\n",-1);
    }
    
    return 0;
}

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

signed main(void)
{
	int n;
	cin >> n;
	long long ans;
	int a[n];
	ans = 0;
	rep(i, n) 
	{
		cin >> a[i];
		if (a[i] == 0) continue;
		if (i != 0)
			a[i] += a[i - 1];
		ans += a[i] / 2;
		a[i] %= 2;
	}
	cout << ans << endl;
	return 0;
}


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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll n;
    cin >> n;
    
    cout << ((n-1)/2) << endl;
}


Measured memory_bytes: 256
def solve():
    n = int(input())
    s = input()
    cnt = [0] * 3
    for i in range(n):
        cnt[ord(s[i]) % 3] += 1
    ans = 1
    for i in range(3):
        ans *= cnt[i]
    for i in range(n):
        for j in range(i + 1, n):
            k = j + j - i
            if k < n:
                if s[i] == s[j] or s[i] == s[k] or s[j] == s[k]:
                    continue
                ans -= 1
    return ans


print(solve())


Measured memory_bytes: 9212
#include <stdio.h>

int main(void)
{
  int N,i,j,sum=0,ans=0;
  
  for(;;){
    scanf("%d", &N);
    if(N==0) break;
    if(N==1){
      printf("0\n");
      continue;
    }
    
    if(N%2==1) ans=1;
    for(i=1;i<N/2;i++){
      for(j=i;;j++){
	sum+=j;
	if(sum>N) break;
	if(sum==N) ans++;
      }
      sum=0;
    }
    printf("%d\n", ans);
    ans=0;
  }

  return 0;
}


Measured memory_bytes: 612
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;	cin >> n;
  set<int>	s;
  for(int i=0;i<n;i++){
    int in;	cin >> in;
    s.insert(in);
  }
  if(s.size()==n)	cout << "YES";
  else	cout << "NO";
}

Measured memory_bytes: 12976
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   unik(v)       v.erase(unique(all(v)),v.end())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=2e5+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------

void solve()
{
    ll n;
    cin>>n;
    ll a[n];
    umll mp;
    ll sum=0;
    for(ll i=0;i<n;i++){
        cin>>a[i];
        mp[a[i]]++;
        sum+=a[i];
    }
    ll q;
    cin>>q;
    while(q--){
        ll b,c;
        cin>>b>>c;
        ll cnt=mp[b];
        sum-=(cnt*b);
        sum+=(cnt*c);
        mp[b]-=cnt;
        mp[c]+=cnt;
        cout << sum <<"\n";
    }
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
template<class T> using vv=vector<vector<T>>;
template<class T> ostream& operator<<(ostream &os, const vector<T> &t) {
os<<"{"; rep(i,t.size()) {os<<t[i]<<",";} os<<"}"<<endl; return os;}
template<class S, class T> ostream& operator<<(ostream &os, const pair<S,T> &t) { return os<<"("<<t.first<<","<<t.second<<")";}
template<class T> inline bool MX(T &l,const T &r){return l<r?l=r,1:0;}
template<class T> inline bool MN(T &l,const T &r){return l>r?l=r,1:0;}
const ll MOD=1e9+7;

int main(){
  ios_base::sync_with_stdio(false);
  cout<<fixed<<setprecision(0);
  int h,w,n;
  cin>>h>>w>>n;
  set<pii> ps;
  rep(i,n){
    int x,y;
    cin>>y>>x; --y; --x;
    ps.emplace(x,y);
  }
  vector<int> re(10);
  for(pii p:ps){
    reps(dx,-2,1) reps(dy,-2,1){
      int x=p.X+dx,y=p.Y+dy;
      if(x<0 || y<0 || x+3>w || y+3>h) continue;
      int cnt=0;
      rep(i,3)rep(j,3) if(ps.count(pii(x+j,y+i))) ++cnt;
      ++re[cnt];
    }
  }
  ll al=(w-2ll)*(h-2);
  //cout<<al<<re;
  reps(i,1,10) al-=re[i]/i;
  cout<<al<<endl;
  reps(i,1,10) cout<<re[i]/i<<endl;
  return 0;
}


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

int main(){
  int N,tmp;
  vector<int> b;
  vector<int> ans;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> tmp;
    b.push_back(tmp);  
  }
  
  for(int i =0; i < N; i++){
    for(int j = b.size()-1; j >= 0; j--){
      // cout << b[j] <<" " << j <<endl;
      if(b[j] == j + 1){
        b.erase(b.begin() + j);
        ans.push_back(j+1);
        break;
      }
      if(j == 0){
        cout << -1 << endl;
        return 0;
      }
    }
  }
  
  for(int i = N-1; i >= 0; i--){
    cout << ans[i] << endl;
  }
  
  return 0;
}

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

using namespace std;

int n, cur, mi, a[500000];
long long sum;
pair<int,int> in[500000];
string s;

int main()
{
	cin >> s;
	n = s.length()+1;
	in[0] = {0,0};
	for(int i = 0; i<n-1; i++)
    {
        if(s[i]=='<') cur++;
        else cur--;
        mi = min(mi,cur);
        in[i+1] = {cur,i+1};
    }
    sort(in,in+n);
    for(int i = 0; i<n; i++)
    {
        int j = in[i].second;
        if((j==0)&&(s[0]=='<'))
            a[0] = 0;
        else if((j==0)&&(s[0]=='>'))
            a[0] = a[1]+1;
        else if((j==n-1)&&(s[n-2]=='<'))
            a[n-1] = a[n-2]+1;
        else if((j==n-1)&&(s[n-2]=='>'))
            a[n-1] = 0;
        else if((s[j-1]=='<')&&(s[j]=='<'))
            a[j] = a[j-1]+1;
        else if((s[j-1]=='<')&&(s[j]=='>'))
            a[j] = max(a[j-1],a[j+1])+1;
        else if((s[j-1]=='>')&&(s[j]=='<'))
            a[j] = 0;
        else if((s[j-1]=='>')&&(s[j]=='>'))
            a[j] = a[j+1]+1;
    }
    for(int i = 0; i<n; i++)
    {
        sum+=(long long)(a[i]);
    }
    cout << sum << endl;
}



Measured memory_bytes: 6788
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        int[] c = new int[n+1];
        for(int i = 1; i <= n; i++) {
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }
        int[][] dp = new int[n+1][3];
        for(int i = 1; i <= n; i++) {
            dp[i][0] = Math.max(dp[i - 1][1] + a[i], dp[i - 1][2] + a[i]);
            dp[i][1] = Math.max(dp[i - 1][0] + b[i], dp[i - 1][2] + b[i]);
            dp[i][2] = Math.max(dp[i - 1][0] + c[i], dp[i - 1][1] + c[i]);
        }
        System.out.println(Math.max(dp[n][0], Math.max(dp[n][1], dp[n][2])));
    }
}


Measured memory_bytes: 94012
n,k=map(int,input().split())
if k>((n-2)*(n-1))//2:
  print(-1)
else:
  ans=[]
  for b in range(1,n):
    ans.append((1,b+1))
  s=[]
  for i in range(1,n-1):
    for j in range(i+1,n):
      s.append((i+1,j+1))
  for i in range(((n-2)*(n-1))//2-k):
    ans.append((s[i][0],s[i][1]))
  print(len(ans))
  for i in range(len(ans)):
    print(*ans[i])

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}


int main(){
  long long H,W;
  cin >> H >> W;
  if(H % 3 == 0 || W % 3 == 0){
    cout << 0 << endl;
    return 0;
  }
  long long score = H*W;
  //縦に3分割
  if(H > 2) score = min((H/3 + 1)*(W) - (H/3) * W,score);

  //横に3分割
  if(W > 2) score = min((W/3+1)*H - W/3 * H,score);

  //縦に2分割 -> 横に2分割
  FOR(h,1,H){
    if(W%2 == 1) score = min( max(h*W,(H-h)*(W/2 + 1))
                            - min(h*W,(H-h)*(W/2)) , score);
    if(W%2 == 0) score = min( max(h*W,(H-h)*(W/2))
                            - min(h*W,(H-h)*(W/2)) , score);
  }

  FOR(w,1,W){
    if(H%2 == 1) score = min( max(w*H,(W-w)*(H/2 + 1))
                            - min(w*H,(W-w)*(H/2)) , score);
    if(H%2 == 0) score = min( max(w*H,(W-w)*(H/2))
                            - min(w*H,(W-w)*(H/2)) , score);
  }

  cout << score << endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        boolean canDo(int t1, int t2, int x1, int y1, int x2, int y2) {
            int dist = Math.abs(x1 - x2) + Math.abs(y1 - y2);
            int t = Math.abs(t2 - t1);
            if (dist > t) return false;
            if (dist == t) return true;
            return (t - dist) % 2 == 0;
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int[] x = new int[n + 1];
            int[] y = new int[n + 1];
            int[] t = new int[n + 1];
            x[0] = y[0] = t[0] = 0;
            for (int i = 1; i <= n; i++) {
                t[i] = in.nextInt();
                x[i] = in.nextInt();
                y[i] = in.nextInt();
            }

            for (int i = 0; i < n; i++) {
                if (!canDo(t[i], t[i + 1], x[i], y[i], x[i + 1], y[i + 1])) {
                    out.println("No");
                    return;
                }
            }
            out.println("Yes");
        }

    }
}



Measured memory_bytes: 91248
#include <bits/stdc++.h>
#define whatis(x) cout << #x << " is " << x << endl;
#define MOD 1000000007
#define endl "\n"
#define ll long long
#define ii pair<int, int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MAX 100001
using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int i, t = 1;
    //cin>>t;
    while (t--)
    {
        int n;
        cin >> n;
        int *arr = new int[n];
        int *dp = new int[n];
        for (int i = 0; i < n; i++)
        {
            cin >> arr[i];
        }
        fill(dp, dp + n, 0);
        dp[n - 1] = 0;
        dp[n - 2] = abs(arr[n - 2] - arr[n - 1]);
        for (i = n - 3; i >= 0; i--)
        {
            dp[i] = min(abs(arr[i] - arr[i + 1]) + dp[i + 1], abs(arr[i] - arr[i + 2]) + dp[i + 2]);
        }
        cout << dp[0] << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
import           Control.Applicative
import           Control.Monad
import           Data.List
import           Data.Maybe          (fromJust)

newtype Dice =
    Dice [Int]
    deriving (Eq, Show)

dice :: Dice
dice = Dice [0,1,2,3,4,5]

roll :: Char -> Dice -> Dice
roll 'E' (Dice ds) = Dice [ds !! (i-1) | i <- [4,2,1,6,5,3]]
roll 'N' (Dice ds) = Dice [ds !! (i-1) | i <- [2,6,3,4,1,5]]
roll 'S' (Dice ds) = Dice [ds !! (i-1) | i <- [5,1,3,4,6,2]]
roll 'W' (Dice ds) = Dice [ds !! (i-1) | i <- [3,2,6,1,5,4]]

rollH :: Dice -> [Dice]
rollH d = take 4 (iterate f d)
  where
    f (Dice ds) = Dice [ds !! (i-1) | i <- [1,4,2,5,3,6]]

rollTop :: Int -> Dice -> Dice
rollTop 0 ds = ds
rollTop 1 ds = roll 'N' ds
rollTop 2 ds = roll 'W' ds
rollTop 3 ds = roll 'E' ds
rollTop 4 ds = roll 'S' ds
rollTop 5 ds = roll 'S' $ roll 'S' ds

main :: IO ()
main = do
    d1 <- fmap read . words <$> getLine :: IO [Int]
    d2 <- fmap read . words <$> getLine :: IO [Int]
    let ass = concatMap rollH $ fmap (flip rollTop dice) [0..5]
    let bss = fmap (\(Dice ds) -> fmap (d2 !!) ds) ass
    if null $ filter (== d1) bss
       then putStrLn "No"
       else putStrLn "Yes"



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

int main(){
  int n;
  cin >> n;
  vector<ll> v(n);
  for(int i=0;i<n;i++){
    cin >> v[i];
  }
  if (n == 1){
    cout << v[0] << endl;
    return 0;
  }
  int i = n-1;
  while(i >= 0){
    cout << v[i] << " ";
    i-=2;
  }
  if (i == -2){
    i = 1;
  }else{
    i = 0;
  }
  for(int j=i;j<n-2;j+=2){
    cout << v[j] << " ";
  }
  cout << v[n-2] << endl;
  return 0;
}

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

// #include <boost/algorithm/string/join.hpp>
// using boost::algorithm::join;
//
// #include "boost/multi_array.hpp"
// boost::multi_array<int, 3> dp;
// dp.resize(boost::extents[10][9][8]);
//
// #include <boost/multiprecision/cpp_dec_float.hpp>  // quite slowly
// #include <boost/multiprecision/cpp_int.hpp>
// namespace mp = boost::multiprecision; // mp::log10
// using bigint = boost::multiprecision::cpp_int;
// using rational = mp::cpp_rational;  // double d = static_cast<double>(r);

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

//constexpr ll MOD = 1e9+7;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/4;
constexpr int INF=inf<int>;
constexpr ll LINF=inf<ll>;

#define Sort(x) sort(begin(x),end(x))
#define Reverse(x) reverse(begin(x),end(x))
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ull<<(n))
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...) _ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n) for(int i=n-1;i>=0;--i)
#define REPA(i,v) REP(i,(v).size())

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
#define endl "\n"
  }
} before_main_function;

// ========== end of template ==========

int main(int argc, char** argv) {
  int N,M,K;
  cin >> N >> M >> K;

  REP(i, N+1) {
    REP(j, M+1) {
      int odd = i*(M-j) + (N-i)*j;
      if (odd == K) {
//cerr << "yes " << i << ", " << j << endl;
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

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

/* vim: set expandtab shiftwidth=2 softtabstop=2 : */


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

#define rep(x, y) for (int i = (x); i < (y); i++)

typedef long long ll;

using namespace std;

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

    if (x == 3 || x == 5 || x == 7)
        cout << "YES";
    else
        cout << "NO";
    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string.h>
#include<cmath>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
int N, K;
int main() {
	scanf("%d%d", &N, &K);
	vector<int> h(N);
	vector<int> dp(N, 1000000000);
	rep(i, 0, N)scanf("%d", &h[i]);
	dp[0] = 0;
	rep(i, 0, N - 1) {
		rep(d, 1, min(N - i, K + 1)) {
			dp[i + d] = min(dp[i + d], dp[i] + abs(h[i] - h[i + d]));
		}
	}
	printf("%d", dp[N - 1]);
	return 0;
}

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

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

  int ans = 1, max = h[0];
  for (int i = 1; i < n; i ++) {
    if (max <= h[i]) {
      ans ++;
      max = h[i];
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 384
#include<cstdio>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<cstring>
#include<functional>

using namespace std;

int main()
{
	long long k;
	int n;

	scanf("%lld %d", &k, &n);

	long long sol = 0;
	long long lmax = 0;
	long long first;

	scanf("%lld", &first);

	long long prev;
	prev = first;
	long long input;

	for (int i = 0; i < n - 1; i++)
	{
		scanf("%lld", &input);

		sol += input - prev;

		if (input - prev > lmax)
		{
			lmax = input - prev;
		}

		prev = input;
	}

	sol += first + k - input;

	if (first + k - input > lmax)
	{
		lmax = first + k - input;
	}

	sol -= lmax;

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

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 2000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

// N^P mod M（ただしM == -1の時はmodを取らない）
template<typename T>
T RS(T N, T P, T M){
    if(P == 0) {
        return 1;
    }
    if(P < 0) {
        return 0;
    }
    if(P % 2 == 0){
        ll t = RS(N, P/2, M);
        if(M == -1) return t * t;
        return t * t % M;
    }
    if(M == -1) {
        return N * RS(N,P - 1,M);
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int Rdiff = 0; //WにするべきところをR
    int Wdiff = 0; //RにするべきところをW
    for(int i = 0;i < N;i++) {
        if(S.at(i) == 'R') {
            Rdiff++;
        }
    }
    int ret = min(Rdiff,Wdiff) + (Rdiff - min(Rdiff,Wdiff)) + (Wdiff - min(Rdiff,Wdiff));
    for(int i = 0;i < N;i++) {
        if(S.at(i) == 'R') {
            Rdiff--;
        }
        else {
            Wdiff++;
        }
        chmin(ret, min(Rdiff, Wdiff) + (Rdiff - min(Rdiff, Wdiff)) + (Wdiff - min(Rdiff, Wdiff)));
    }
    cout << ret << endl;
}

Measured memory_bytes: 3752
// {{{
// vim:filetype=cpp foldmethod=marker foldmarker={{{,}}}
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <complex>
#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 <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define MP  make_pair
#define PB  push_back
using namespace std;
typedef long long ll;

int vx[]={1,0,-1,0},vy[]={0,1,0,-1};
// }}}

vector<int> par,rank;
vector<pair<int,pair<int,int> > > edge;
int find(int n){
    if(par[n]==n) return n;
    else return par[n]=find(par[n]);
}
void unite(int a,int b){
    int pa=find(a),pb=find(b);
    if(pa==pb) return;
    if(rank[pa]>rank[pb]) swap(pa,pb);
    par[pa]=pb;
    if(rank[pa]==rank[pb]) rank[pb]++;
}
int main(){
    int n,m;
    for(;;){
        scanf("%d\n",&n);
        if(n==0) break;
        scanf("%d\n",&m);
        int a,b,d;
        edge=vector<pair<int,pair<int,int> > >(m);
        for(int i=0;i<m;i++){
            scanf("%d,%d,%d\n",&a,&b,&d);
            d=d/100-1;
            edge[i]=MP(d,MP(a,b));
        }
        par=vector<int>(n);
        rank=vector<int>(n);
        for(int i=0;i<n;i++){
            par[i]=i;
            rank[i]=0;
        }
        sort(ALL(edge));
        int ret=0;
        for(int i=0;i<edge.size();i++){
            int a=edge[i].second.first,b=edge[i].second.second,d=edge[i].first;
            if(find(a)!=find(b)){
                ret+=d;
                unite(a,b);
            }
        }
        printf("%d\n",ret);
    }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}
 
 
 
 
 
 
 














int main()
{
    int n,m;
    cin>>n>>m;
    priority_queue<int> q;
    int a[n];
    for(int i=0;i<n;i++){
         cin>>a[i];
         q.push(a[i]);
    }
    for(int i=0;i<m;i++){
         int t=abs(q.top());
         //cout<<t<<"\n";
         q.pop();
         q.push(t/2);
    }
    ll res=0;
    while(!q.empty()){
         res+=abs(q.top());q.pop();
    }
    cout<<res;
}

























Measured memory_bytes: 1148
#include <iostream>
#include <fstream>
#include <string>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <limits.h>
#define int long long
using namespace std;
using P = pair<int, int>;
using ll = long long;
using prique = priority_queue<int>;
const int MOD = 1000000007;
const int INF = LLONG_MAX/3;

signed main(){
    int n;
    cin>>n;
    cout<<(n)*(n-1)/2<<endl;
    return 0;
}



Measured memory_bytes: 256
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


q,h,s,d = list(map(int, input().split()))
n = int(input())
vals = [q*4, h*2, s, d/2]
v = min(vals)
if v==q*4:
    ans = n*4*q
elif v==h*2:
    ans = n*2*h
elif v==s:
    ans = n*s
else:
    ans = (n//2)*d
    vv = min(vals[:-1])
    if n%2!=0:
        ans += vv
print(ans)

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

int main(){
  int h,w;
  int x[8]={0,1,0,-1,1,1,-1,-1};
  int y[8]={1,0,-1,0,1,-1,-1,1};
  string s[100];
  cin>>h>>w;
  for(int i=0;i<h;i++) cin>>s[i];

  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      int cnt=0;
      if(s[i][j]=='#') continue;
      for(int k=0;k<8;k++){
        int a=i+x[k];
        int b=j+y[k];
        if(a<0 || h<=a || b<0 || w<=b) continue;
        if(s[a][b]=='#') cnt++;
      }
      s[i][j]=char(cnt+'0');
    }
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cout<<s[i][j];
    }
    cout<<endl;
  }
}


Measured memory_bytes: 256