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

using namespace std;

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int ans = 0;
	for (int i = 0; i <= a; i++) {
		for (int j = 0; j <= b; j++) {
			for (int k = 0; k <= c; k++) {
				if ((i * 500 + 100 * j + k * 50) == x) {
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
A=gets.split.map(&:to_i)
if A.any?{|a|a&1==1}; p 0;exit;end
a=A.map{|a|(A.inject(:+)-a)/2}
bs=[0,1,2].map{|i|b=(A[i]-a[i]).abs.to_s(2)}.uniq.reject{|b|b=="0"}
#p A,a,bs
p bs==[]?-1:bs.map{|b|b.match(/0*$/)[0].size}.min+1


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

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

	vector<int> juwelry_values;
	for (int index = 0; index < juwelry_count; index++) {
		int juwelry_value;
		cin >> juwelry_value;
		juwelry_values.push_back(juwelry_value);
	}

	vector<int> juwelry_costs;
	for (int index = 0; index < juwelry_count; index++) {
		int juwelry_cost;
		cin >> juwelry_cost;
		juwelry_costs.push_back(juwelry_cost);
	}

	vector<int> juwelry_ranks;
	for (int index = 0; index < juwelry_count; index++) {
		int juwelry_rank;
		
		juwelry_rank = juwelry_values[index] - juwelry_costs[index];
		juwelry_ranks.push_back(juwelry_rank);
	}

	int max_calucuration = 0;
	for (int index = 0; index < juwelry_ranks.size(); index++) {
		if (juwelry_ranks[index] > 0) {
			max_calucuration += juwelry_ranks[index];
		}
	}

	cout << max_calucuration;
}

Measured memory_bytes: 256
n = gets.to_i
s = gets.chomp.split("")
intcode = s.map!(&:ord)
addbect = Array.new(s.length, n)

outcode = [intcode, addbect].transpose.map{|a| a.inject(:+)}
outcode.map!{|i| (i-65)%26 +65}
outcode.map!(&:chr)
print(outcode.join(), "\n")

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

int main() {
	int n, p[50];
	int cnt = 0;
	bool f = true;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
	}
	for (int i = 0; i < n; i++) {
		if (p[i] != i + 1) {
			int tmp = p[i];
			p[i] = i + 1;
			p[tmp - 1] = tmp;
			cnt++;
			if (cnt > 1) f = false;
		}
	}
	if (f)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var s = Console.ReadLine().Trim().Select(x => (int)x - '0').ToArray();

        var rest = 1;
        var color = s[0];
        var k = 0;
        for (int i = 1; i < s.Length; i++)
        {
            if (color + s[i] == 1)
            {
                rest--;
                k++;
                if (rest == 0)
                {
                    color = -1;
                }
                continue;
            }

            color = s[i];
            rest++;
        }
        Console.WriteLine(k * 2);
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
#define pii pair<int,int>

const int maxn = 1e6+7;
int t,n,m;
int h,w;
set<pii> nodes; //{ending, starting}
multiset<int> ans;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin >> h >> w;
	for (int i=0; i<w; i++){
		nodes.insert({i,i});
		ans.insert(0);
	}
	int x,y;
	for (int i=0; i<h; i++){
		cin >> x >> y;
		--x, --y;
		auto itst = nodes.lower_bound({x,-maxn});
		auto ited = nodes.upper_bound({y+1, -maxn});
		int mx =-1;
		
		while (itst != ited){
			mx = itst->second;
			
			ans.erase(ans.find(itst-> first - mx));
			nodes.erase(itst++); //em.. can't separate mp.erase and it++
		}
		
		if (mx > -1 && y < w-1){
			nodes.insert({y+1, mx});
			ans.insert(y+1-mx);
		}
		
		if (ans.size()) cout << *ans.begin() + i + 1 << endl;
		else cout << -1 << endl;
	}
	return 0;
}


Measured memory_bytes: 22372
macro_rules! get {
    (Vec<$t:ty>) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
            get!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
            get!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (N, M) = get!(usize, usize);
    let (a, b): (Vec<i64>, Vec<i64>) = get!(i64, i64; N).into_iter().unzip();
    let (c, d): (Vec<i64>, Vec<i64>) = get!(i64, i64; M).into_iter().unzip();

    for (x, y) in a.iter().zip(b.iter()) {
        let ans = (0..M).min_by_key(|&i| (x - c[i]).abs() + (y - d[i]).abs()).unwrap() + 1;
        println!("{}", ans);
    }
}

Measured memory_bytes: 4352
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <cfloat>
#include <stack>
#include <queue>
#include <vector>
#include <string>
#include <iostream>
#include <set>
#include <map>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;
 
struct Node{
    int location;
    int p,left,right;
};
 
struct Point{
    Point(){
        id = x = y = 0;
    }
 
    Point(int arg_id,int arg_x,int arg_y){
        id = arg_id;
        x = arg_x;
        y = arg_y;
    }
    bool operator < (const Point & arg)const{
        return id < arg.id;
    }
    void print(){
        printf("%d\n",id);
    }
    int id,x,y;
};
 
static const int MAX = 1000000;
static const int NIL = -1;
 
int N;
Point P[MAX];
Node T[MAX];
int number;
 
bool lessX(const Point &p1, const Point &p2) {return p1.x < p2.x; }
bool lessY(const Point &p1, const Point &p2) {return p1.y < p2.y; }
 
int makeKDTree(int left,int right, int depth){
 
    if(!(left < right))return NIL;
 
    int mid = (left+right)/2;
 
    int node_id = number++;
 
    if(depth%2 == 0){
        sort(P+left,P+right,lessX);
    }else{
        sort(P+left,P+right,lessY);
    }
 
    T[node_id].location = mid;
    T[node_id].left = makeKDTree(left,mid,depth+1);
    T[node_id].right = makeKDTree(mid+1,right,depth+1);
 
    return node_id;
}
 
void find(int node_id,int sx,int tx,int sy,int ty, int depth, vector<Point> &ans){
 
    int x = P[T[node_id].location].x;
    int y = P[T[node_id].location].y;
 
    if(sx <= x && x <= tx && sy <= y && y <= ty){
        ans.push_back(P[T[node_id].location]);
    }
 
    if(depth%2 == 0){
        if(T[node_id].left != NIL){
            if(sx <= x)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if( x <= tx)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }else{
        if(T[node_id].left != NIL){
            if(sy <= y)find(T[node_id].left,sx,tx,sy,ty,depth+1,ans);
        }
        if(T[node_id].right != NIL){
            if(y <= ty)find(T[node_id].right,sx,tx,sy,ty,depth+1,ans);
        }
    }
}
 
 
int main(){
 
    int x,y;
    scanf("%d",&N);
    for(int i = 0; i < N; i++){
        scanf("%d %d",&x,&y);
        P[i] = Point(i,x,y);
        T[i].left = T[i].right = T[i].p = NIL;
    }
 
    number = 0;
 
    int root = makeKDTree(0,N,0);
 
    int q;
    scanf("%d",&q);
    int sx,tx,sy,ty;
    vector<Point> ans;
    for(int i = 0; i < q; i++){
        scanf("%d %d %d %d",&sx,&tx,&sy,&ty);
        ans.clear();
        find(root,sx,tx,sy,ty,0,ans);
        sort(ans.begin(),ans.end());
        for(int j = 0; j < ans.size(); j++){
            ans[j].print();
        }
        printf("\n");
    }
    return 0;
}


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

int main() {
    int n, k;
    cin>>n>>k;
    
    string s;
    cin>>s;
    
    if(s[k-1]>=97 && s[k-1]<=122) {
        cout<<s;
    } else {
        s[k-1] += 32;
        cout<<s;
    }

}

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

int main() {
  int N;
  int64_t deff = 2000000000000000, sum = 0, temp = 0;
  cin >> N;
  vector<int> A(N);

  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
    sum += A.at(i);
  }
  
  for (int i = 0; i < N-1; i++) {
    temp += A.at(i);
    deff = min(deff, abs(sum - temp * 2));
  }
  cout << deff << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#define REP(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;
typedef long long ll;
const int INF = 1e9;

int main() {
  int N;
  char a;
  cin >> N;
  for(int i=0; i<N; i++) {
    cin >> a;
    if (a == 'Y') {
      cout << "Four" << endl;
      return 0;
    }
  }
  cout << "Three" << endl;
  return 0;
}


Measured memory_bytes: 256
/*
    Author:zeke
    
    pass System Test!
    GET AC!!
*/
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <string>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
#include <iomanip>
#include <utility>
#include <stack>
#include <bitset>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
const int MAX = 1e7;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit()
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n,k;
    cin>>n>>k;
    COMinit();
    if(k-1>=n){
        cout<<COM(2*n-1,n)<<endl;
        return 0;
    }
    ll sum=0;
    rep(i,k+1){
        sum+=COM(n,n-i)*COM(n-1,n-i-1);
       // cout<<COM(n,n-i)*COM(n-1,n-i-1)<<endl;
        sum%=MOD;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 234624
#include<bits/stdc++.h>
#define r(i,a,b) for(register int i=a;i<=b;i++)
#define ll long long
#define ull unsigned long long
using namespace std;
const ll mod=1e9+7;
ll qpow(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b&1) 
			res=res*a%mod;
		a = a * a % mod;
		b >>= 1;
	}
	return res;
} 
ll n;
int main()
{
	cin>>n;
	ll ans=((qpow((ll)10,n)-2*qpow((ll)9,n)+qpow((ll)8,n))%mod+mod)%mod;
	cout<<ans<<endl;
	return 0;	
} 

Measured memory_bytes: 3608
package main

import "fmt"

func main() {

	var h, w int

	for {
		fmt.Scan(&h, &w)
		if h==0 && w==0 {
			break
		}
		for row:=0; row<h; row++ {
			fmt.Print("#")
		
			for col:=1; col<w-1; col++ {
				if row==0 || row==h-1 {
					fmt.Print("#")
				} else {
					fmt.Print(".")
				}
			}
			fmt.Print("#\n")
		}
		fmt.Print("\n")
	}
}


Measured memory_bytes: 1128
#include<bits/stdc++.h>
using namespace std;
int main(){
int  N;
  cin>>N;
  vector<int64_t>a(N);
  for(int i=0;i<N;i++)
    cin>>a.at(i);
  int64_t dp[N][N];
  for(int i=0;i<N;i++)
    dp[i][i]=a.at(i);
  for(int i=0;i<N-1;i++)
    dp[i][i+1]=max(a.at(i),a.at(i+1))-min(a.at(i),a.at(i+1));
  for(int l=2;l<=N-1;l++){
    for(int i=0;i<N-l;i++){
    int j=i+l;
    dp[i][j]=
 max(a[i]+min(dp[i+2][j]-a[i+1],dp[i+1][j-1]-a[j]),a[j]+min(dp[i+1][j-1]-a[i],dp[i][j-2]-a[j-1]));
    
    
    }
  
  }cout<<dp[0][N-1]<<endl;
   return 0;
}

Measured memory_bytes: 70528
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	l, r, d := scanInt(), scanInt(), scanInt()
	ans := 0
	for i := l; i < r+1; i++ {
		if i%d == 0 {
			ans++
		}
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 1776
#include <iostream>

using namespace std;

int main(){
    int N;
    cin >> N;
    int ans = 0;
    for(int i = 0; i < N; ++i){
        int a;
        cin >> a;
        if(a%2 == 1 && (i+1)%2 == 1){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
def solve(n, d):
    if n >= 24:
        return 0

    cnt = {i: 0 for i in range(12 + 1)}
    cnt[0] = 1
    for dd in d:
        cnt[dd] += 1

    # 同じ時刻の都市が存在する場合、
    # 時刻の差の最小値は、0になる
    # 鳩ノ巣
    if cnt[0] > 1:
        return 0
    elif cnt[12] > 1:
        return 0
    else:
        for i in range(1, 12):
            if cnt[i] > 2:
                return 0

    bit_cnt = 0
    for i in range(1, 12):
        if cnt[i] == 1:
            bit_cnt += 1

    res = -1
    for mask in range(1 << bit_cnt):
        t = [False] * 24
        t[0] = True

        cur = 0
        for i in range(1, 12):
            if cnt[i] == 1:
                if (mask >> cur) & 1 == 1:
                    t[i] = True
                else:
                    t[24 - i] = True
                cur += 1
            elif cnt[i] == 2:
                t[i] = True
                t[24 - i] = True

        if cnt[12] == 1:
            t[12] = True

        # print(*map(lambda x: 1 if x else '-', t))

        dist = 24
        frm = 0
        for i in range(1, 48 + 1):
            if t[i % 24]:
                dist = min(dist, (i - frm) % 24)
                frm = i

        res = max(res, dist)

    return res


if __name__ == '__main__':
    n = int(input())
    d = tuple(map(int, input().split()))

    res = solve(n, d)
    print(res)


Measured memory_bytes: 3064
fun main(args: Array<String>) {
    val N = readLine()!!
    val K = readLine()!!.toInt()
    val L = N.length
    val dp0 = Array(L + 1) { IntArray(K + 1) }
    val dp1 = Array(L + 1) { IntArray(K + 1) }
    dp0[0][0] = 0
    dp0[0][1] = 0
    dp1[0][0] = 1
    dp1[0][1] = 0
    (1..L).forEach { l ->
        val n = N[l - 1] - '0'
        val a = (0 until n).count()
        dp0[l][0] = if (N.take(l).all { it=='0' }) 0 else 1
        dp1[l][0] = if (N.take(l).all { it=='0' }) 1 else 0
        (1..K).forEach { k ->
            dp0[l][k] = dp0[l-1][k] + dp0[l-1][k-1] * 9 + if (n != 0) dp1[l-1][k-1] * (a-1) + dp1[l-1][k] else 0
            dp1[l][k] = if (n == 0) dp1[l-1][k] else dp1[l-1][k-1]
        }
    }
    print(dp0[L][K] + dp1[L][K])
}

Measured memory_bytes: 33844
#include <iostream>
#include <cstdio>
#include <tuple>
#include <set>
#include <queue>
using namespace std;
struct hms_t {
    int h, m, s;
};
bool operator < (hms_t const & a, hms_t const & b) {
    return make_tuple(a.h, a.m, a.s) < make_tuple(b.h, b.m, b.s);
}
struct event_t {
    hms_t time;
    int train;
    bool is_adding;
};
bool operator < (event_t const & a, event_t const & b) {
    return not (make_pair(a.time, a.is_adding) < make_pair(b.time, b.is_adding)); // reversed
}
int main() {
    while (true) {
        int n; cin >> n;
        if (not n) break;
        priority_queue<event_t> q;
        for (int i = 0; i < n; ++i) {
            hms_t a, b;
            scanf("%d:%d:%d", &a.h, &a.m, &a.s);
            scanf("%d:%d:%d", &b.h, &b.m, &b.s);
            q.push({ a, i,  true });
            q.push({ b, i, false });
        }
        int result = 0;
        set<int> trains;
        while (not q.empty()) {
            event_t e = q.top(); q.pop();
            if (trains.count(e.train)) {
                trains.erase(e.train);
            } else {
                trains.insert(e.train);
                result = max(result, (int)trains.size());
            }
        }
        cout << result << endl;
    }
    return 0;
}

Measured memory_bytes: 2168
using System.Collections.Generic;
using System.Linq;
using System;
using static System.Console;

class Program
{
  static void Main() => new Program().solve();

  void solve()
  {
    var seq = ReadLine().Split(' ').Select(int.Parse).ToArray();
    var max = seq.Max();
    var seq2 = seq.Select(i => max - i);
    var cnt = seq2.Select(i => i / 2).Sum();
    switch(seq2.Select(i => i % 2).Sum())
      {
        case 1: cnt += 2;
          break;
        case 2: cnt += 1;
          break;
        default:
          break;
      }
    var ans = cnt;
    WriteLine(ans);
  }
}

Measured memory_bytes: 13396
n = int(input())
l = list(map(int,input().split()))
dic1={}
dic2={}
for i in range(n):
  if i%2==0:
    if l[i] in dic1:
      dic1[l[i]] += 1
    else:
      dic1[l[i]]=1
  else:
    if l[i] in dic2:
      dic2[l[i]] += 1
    else:
      dic2[l[i]]=1
dic1a = sorted(dic1.items(),key = lambda x:x[1])
dic2a = sorted(dic2.items(),key = lambda x:x[1]) 
 
if dic1a[-1][0] == dic2a[-1][0]:
    if len(dic1a) == len(dic2a) == 1:
        print(n//2)
    else:
        if dic1a[-2][1] >= dic2a[-2][1]:
            print(sum(dic2.values())-dic2a[-1][1]+sum(dic1.values())-dic1a[-2][1])
        else:
            print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-2][1])
else:
    print(sum(dic1.values())-dic1a[-1][1]+sum(dic2.values())-dic2a[-1][1])


Measured memory_bytes: 22368
#include <iostream>
#include <vector>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

void update_map(int row, int col, vector<vector<int>>& vv, vector<vector<int>>& m, int val) {
    int n = m.size();
    if (row < 0 || col < 0 || row >= n || col >= n) return;
    if (m[row][col] <= val) return;
    m[row][col] = val;
    update_map(row + 1, col, vv, m, m[row][col] + vv[row][col]);
    update_map(row - 1, col, vv, m, m[row][col] + vv[row][col]);
    update_map(row, col - 1, vv, m, m[row][col] + vv[row][col]);
    update_map(row, col + 1, vv, m, m[row][col] + vv[row][col]);
}

int main() {
    int n;
    cin >> n;
    vector<int> v;
    for (int i = 0; i < n * n; i++) {
        int t;
        cin >> t;
        v.push_back(t);
    }
    vector<vector<int>> vv(n, vector<int>(n, 1));
    vector<vector<int>> m(n, vector<int>(n, n * n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            m[i][j] = min(min(i, j), min(n - 1 - i, n - 1 - j));
        }
    }
    int res = 0;
    for (int i = 0; i < n * n; i++) {
        int row = (v[i] - 1) / n, col = (v[i] - 1) % n;
        res += m[row][col];
        if (row != 0) m[row][col] = min(m[row][col], m[row - 1][col] + vv[row - 1][col]);
        if (row != n - 1) m[row][col] = min(m[row][col], m[row + 1][col] + vv[row + 1][col]);
        if (col != 0) m[row][col] = min(m[row][col], m[row][col - 1] + vv[row][col - 1]);
        if (col != n - 1) m[row][col] = min(m[row][col], m[row][col + 1] + vv[row][col + 1]);
        vv[row][col] = 0;
        update_map(row - 1, col, vv, m, m[row][col]);
        update_map(row + 1, col, vv, m, m[row][col]);
        update_map(row, col - 1, vv, m, m[row][col]);
        update_map(row, col + 1, vv, m, m[row][col]);
    }
    cout << res << endl;
}


Measured memory_bytes: 25080
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    string str;
    cin >> str;
    int n[256] = {};
    for(char c: str){
        n[c]++;
    }
    if( ( (n['N'] == 0 && n['S'] == 0) || (n['N'] > 0 && n['S'] > 0) )
      &&( (n['E'] == 0 && n['W'] == 0) || (n['E'] > 0 && n['W'] > 0) )
      ){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}


Measured memory_bytes: 256
#include<iostream>

#include<algorithm>

#include<cstdio>

#include<cstring>

#include<cmath>

#include<map>

#include<queue>

#include<set>

#include<stack>

#include<string>

#include<sstream>

#include<vector>

#define inf 2147483647

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

#define  rr read()

#define ll long long

#define repb(i,a,b) for(int i=a;i<=b;i++)

#define CloseIo   ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)

using namespace std;

int read()

{

    char ch = getchar();

	int x = 0, f = 1;

    while(ch < '0' || ch > '9') {if(ch == '-') f = -1; ch = getchar();}

    while('0' <= ch && ch <= '9') {x = x * 10 + ch - '0'; ch = getchar();}

    return x * f;

}

int n,m;

int lowbit(int t)

{

	return (-t)&t;

}

int tree[1000005]={0};

void add(int x,int k)

{

	while(x<=n)

	{

		tree[x]+=k;

		x+=lowbit(x);

	}

}

int sum(int x)

{

	int ans=0;

	while(x!=0)

	{

		ans+=tree[x];

		x-=lowbit(x);

	}

	return ans;

}

int main()

{

	

n=rr;

m=rr;

int last=0;


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

	int x,y;



		x=rr;

		y=rr;

	

		add(x,1);

		add(y+1,-1);

	

	

}
ll ans=0;
 for(int i=1;i<=n;i++)
 {    
    if(sum(i)==m)
    ans++;
 	 //printf("%d\n",sum(i));
 }
 cout<<ans<<"\n";
}



Measured memory_bytes: 640
<?php

$map = [];
$list = [];
for ($i=0; $i < 3; $i++) { 
	$input = explode(' ', trim(fgets(STDIN)));
	foreach ($input as $k => $v) {
		$map[(int)$v]  = [$i, $k];
		$list[$i][$k] = false;
	}
}
$n = (int)trim(fgets(STDIN));


for ($i=0; $i < $n; $i++) { 
	$b = (int)trim(fgets(STDIN));
	if (isset($map[$b])) {
		$list[$map[$b][0]][$map[$b][1]] = true;
	}
}
// var_dump($list);
if (is_bingo($list)) {
	echo "Yes";
}else{
	echo "No";
}


function is_bingo($list){
	$ret = false;
	if ($list[0][0] === true) {
		if ($list[0][1] === true && $list[0][2] === true) {
			$ret = true;
		}
		if ($list[1][1] === true && $list[2][2] === true) {
			$ret = true;
		}
		if ($list[1][0] === true && $list[2][0] === true) {
			$ret = true;
		}
	}
	if ($list[1][1] === true) {
		if ($list[0][1] === true && $list[2][1] === true) {
			$ret = true;
		}
		if ($list[1][0] === true && $list[1][2] === true) {
			$ret = true;
		}
		if ($list[0][2] === true && $list[2][0] === true) {
			$ret = true;
		}
	}
	if ($list[2][2] === true) {
		if ($list[0][2] === true && $list[1][2] === true) {
			$ret = true;
		}
		if ($list[2][0] === true && $list[2][1] === true) {
			$ret = true;
		}
	}
	return $ret;
}

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

int main() {
  int n;cin>>n;
  string s[3];rep(i,3)cin>>s[i];
  
  char an[3];
  ll ans=0;
  rep(i,n) {
    rep(j,3)an[j]=s[j][i];
    sort(an, an+3);
    if (an[0]!=an[1] && an[1]!=an[2]) ans+=2;
    else if (an[0]!=an[1] || an[1]!=an[2]) ans++;
  }
  cout<<ans<<endl;
  
}


Measured memory_bytes: 3604
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        B solver = new B();
        solver.solve(1, in, out);
        out.close();
    }

    static class B {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            int K = in.nextInt();
            int S = in.nextInt();
            for (int i = 0; i < K; i++) {
                out.print(S + " ");
            }
            if (S == 1_000_000_000) {
                for (int i = K; i < N; i++) {
                    out.print((S - 1) + " ");
                }
            } else {
                for (int i = K; i < N; i++) {
                    out.print((S + 1) + " ");
                }
            }
        }

    }

    static class InputReader {
        private BufferedReader reader;
        private StringTokenizer stt;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
        }

        public String nextLine() {
            try {
                return reader.readLine();
            } catch (IOException e) {
                return null;
            }
        }

        public String next() {
            while (stt == null || !stt.hasMoreTokens()) {
                stt = new StringTokenizer(nextLine());
            }
            return stt.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

int main(){
  int n;
  cin >> n;
  
  vector<int> mochi(n);
  for (int i = 0; i < n; i++)
    cin >> mochi.at(i);
  
  sort(mochi.begin(), mochi.end());
  
  int count = 0;
  for (int i = 0; i < n-1; i++){
    if (mochi.at(i) == mochi.at(i+1))
      count++;
  }
  
  cout << n - count << endl;
}

  

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int n;
double a[3333];
//i個目までに表がj個あったときの確率」
double dp[3939][3939];
signed main(){
	double ans=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	dp[0][0]=1;
	for(int i=1;i<n+1;i++){
		for(int j=0;j<n+1;j++){
			if(j==0)dp[i][j]=dp[i-1][j]*(1-a[i-1]);
			else dp[i][j]=dp[i-1][j-1]*a[i-1]+dp[i-1][j]*(1-a[i-1]);
		}
	}
	for(int i=n-n/2;i<=n;i++)ans+=dp[n][i];
	cout<<setprecision(15)<<ans<<endl;
}


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

using namespace std;

int n, m, k, ans = 0, cnt;

vector<string> board;

void solve() {
	cin >> n >> m >> k;
	board.resize(n);
	for (int i = 0; i < n; ++i) {
		cin >> board[i];
	} 
	for (int i = 0; i < (1 << n); ++i) {
		for (int j = 0; j < (1 << m); ++j) {
			cnt = 0;
			for (int k = 0; k < n; ++k) {
				for (int l = 0; l < m; ++l) {
					if ((((i >> k) & 1) && ((j >> l) & 1)) && board[k][l] == '#') {
						cnt++;
					}
				}
			}
			if (cnt == k) {
				ans++;
			}
		}
	}
	cout << ans << endl;
}

int main() {
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);    
    //freopen("input.txt", "r", stdin);
	solve();
    return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N, MA, MB;
	cin >>N >>MA >>MB;
	vector<vector<int>> A(N+1, vector<int> (3, 0));
	Rep1(i, N)
		Rep0(j, 3)
			cin >>A.at(i).at(j);
	vector<vector<vector<int>>> DP(N+1, vector<vector<int>> (N*10+1, vector<int> (N*10+1, -1)));
	DP.at(0).at(0).at(0)=0;
	int Cost=INF;
	Rep1(i, N) {// Each item
		int a=A.at(i).at(0);
		int b=A.at(i).at(1);
		int c=A.at(i).at(2);
		Rep0(a0, (i-1)*10+1) // Each a of previous item
			Rep0(b0, (i-1)*10+1) { // Each b of previous item
				int c0=DP.at(i-1).at(a0).at(b0);
				if (0>c0)
					continue;
				if (0>DP.at(i).at(a0).at(b0))
					DP.at(i).at(a0).at(b0)=c0;
				else
					DP.at(i).at(a0).at(b0)=min(DP.at(i).at(a0).at(b0), c0);
				DP.at(i).at(a0+a).at(b0+b)=c0+c;
				if ((a0+a)*MB==(b0+b)*MA)
					Cost=min(Cost, c0+c);
			}
	}
	if (INF==Cost)
		cout <<-1 <<endl;
	else
		cout <<Cost <<endl;
	return 0;
}



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

int main() {
    string a,b,c;
    cin >> a >> b >> c;
    char turn = 'a';
    for(;;){
        if(turn == 'a'){
            if(a.size() == 0) {
                cout << 'A' << endl;
                return 0;
            }
            else {
                turn = a.at(0);
                a = a.substr(1);
            }
        }
        if(turn == 'b'){
            if(b.size() == 0) {
                cout << 'B' << endl;
                return 0;
            }
            else{
                turn = b.at(0);
                b = b.substr(1);
            }
        }
        if(turn == 'c'){
            if(c.size() == 0) {
                cout << 'C' << endl;
                return 0;
            }
            else{
                turn = c.at(0);
                c = c.substr(1);
            }
        }
        }
    }

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

#define int long long int
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int N = 2e5 + 5;
const int inf = 1e16 + 2;


int dp[N][5][5][5] , n , A , B , C , check = 0;
char ans[N][5][5][5];
string s[N];
int rec(int idx , int a , int b , int c) {
    if(a < 0 or b < 0 or c < 0) return 0;
    if(idx == n) {
        check = 1;
        return 1;
    }
    if(dp[idx][a][b][c] != -1) return dp[idx][a][b][c];
    
    int res = 0;
    if(s[idx] == "AB") {
        if(rec(idx + 1 , a + 1 , b - 1 , c)) ans[idx][a][b][c] = 'A' , res = 1;
        else if(rec(idx + 1 , a - 1 , b + 1 , c)) ans[idx][a][b][c] = 'B' , res = 1;
    }
    else if(s[idx] == "AC") {
        if(rec(idx + 1 , a + 1 , b  , c - 1)) ans[idx][a][b][c] = 'A' , res = 1;
        else if(rec(idx + 1 , a - 1 , b  , c + 1)) ans[idx][a][b][c] = 'C' , res = 1;
    }
    else {
        if(rec(idx + 1 , a , b - 1 , c + 1)) ans[idx][a][b][c] = 'C' , res = 1;
        else if(rec(idx + 1 , a , b + 1 , c - 1)) ans[idx][a][b][c] = 'B' , res = 1;
    }
    dp[idx][a][b][c] = res;
    return res;
}
void solve(int z) {
    memset(dp , -1 , sizeof dp);
    cin >> n >> A >> B >> C;
    for(int i = 0 ; i < n ; i ++) cin >> s[i];
    
    A = min(2LL , A);
    B = min(2LL , B);
    C = min(2LL , C);
    rec(0 , A , B , C);
    
    if(check == 0) cout << "No";
    else {
        cout << "Yes" << '\n';
        int i = 0;
        while(n -- ) {
            cout << ans[i][A][B][C] << '\n';
            if(ans[i][A][B][C] == 'A') {
                A ++;
                if(s[i] == "AB") B --;
                else C --;
            }
            if(ans[i][A][B][C] == 'B') {
                B ++;
                if(s[i] == "AB") A --;
                else C --;
            }
            if(ans[i][A][B][C] == 'C') {
                C ++;
                if(s[i] == "AC") A --;
                else B --;
            }
            i ++;
        }
    }
}

/*
 */

int32_t main()
{
    fastio
    int testcase = 1;
    //cin >> testcase;
    int x = 1;
    while(testcase --) {
        solve(x ++);
    }
    
    return 0;
}
 



Measured memory_bytes: 225216
n = input().split()[0]
n = int(n)

a_list = list(map(int, input().split()))

def ok_continue(a_list):
    contain_odd = [x for x in a_list if x % 2 == 1]
    if contain_odd:
        return False
    return True

n_sousa = 0

while ok_continue(a_list):
    a_list = [a / 2 for a in a_list]
    n_sousa += 1

print(n_sousa)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {


  string s;
  cin >>s;
int count_0=0;
  int count_1=0;
  for(int i=0;i<s.size();i++){
  if(s[i]=='0')count_0++;
    if(s[i]=='1')count_1++;
  }
  cout<< min(count_0,count_1) * 2<<endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
// const lint MOD = 998244353;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}


//k!
ll facctorialMethod(ll k){
    ll sum = 1;
    for (ll i = 1; i <= k; ++i)
    {
        sum = sum%MOD*i%MOD;
    }
    return sum%MOD;
}

const int MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main() {
    int N,W;cin>>N>>W;
    vector<int> w(N), v(N);
    rep(i,N)cin>>w[i]>>v[i];
    ll dp[110][100010];
    Fill(dp,LINF);
    dp[0][0] = 0;
    int ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j< 100010; j++){
            dp[i+1][j] = dp[i][j];
            if(j < v[i])continue;
            dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
            if(dp[i+1][j]<=W){
                ans = max(ans,j);
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 86144
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

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

N=one_int()

num=int(N/100) 

amari = N%100

def dfs(now, count, max_count):
    if count==max_count:
        if now+(100*max_count) == N:
            return 1
        else:
            return 0
    else:
        ret=[]
        for i in range(6):
            if (max_count-count-1)*5 + i<N:
                dfs(now+i, count+1, max_count ) 
        return ret

if num*5 < amari:
    print(0)
else:
    print(1)
    



Measured memory_bytes: 38384
N, M = map(int, input().split())
As = list(map(int, input().split()))
s = 0
Ss = [0]
for A in As:
  s += A
  Ss.append(s%M)
r = 0
Cs = {}
for s in Ss:
  if not(s in Cs):
    Cs[s] = 0
  r += Cs[s]
  Cs[s] += 1
print(r)


Measured memory_bytes: 16296
using System;

namespace AOJ_Intro_Watch
{
	class MainClass
	{
		public static void Main (string[] args)
		{
			int h, m, s;
			s = int.Parse (Console.ReadLine ());
			m = s / 60;
			s = s % 60;
			h = m / 60;
			m = m % 60;
			Console.WriteLine ("{0}:{1}:{2}",h,m,s);
		}
	}
}

Measured memory_bytes: 5620
/**
 *    author:  FromDihPout
 *    created: 2020-08-01
**/

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


const int N = 1e5 + 10;
int n, f1, f2;
vector<vector<int>> adj;
bool seen[N];

int first(int u, int dist) {
    seen[u] = true;
    if (u == n - 1) {
        if (dist <= 2) f1 = u;
        return dist;
    }
    for (int v : adj[u]) {
        if (seen[v]) continue;
        int d = first(v, dist + 1);
        if (d > 0) {
            if (dist == d / 2 + 1) f1 = u;
            else if (dist == d - (d + 1) / 2) f2 = u;
            return d;
        }
    }
    return -1;
}

int dfs(int u) {
    seen[u] = true;
    int cnt = 1;
    for (int v : adj[u]) {
        if (seen[v]) continue;
        cnt += dfs(v);
    }
    return cnt;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin >> n;
    adj.resize(n);
    for (int i = 0; i < n-1; i++) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    
    memset(seen, false, n);
    first(0, 0);
    
    int cnt1 = 0;
    memset(seen, false, n);
    seen[f1] = true;
    cnt1 += dfs(0) - 1;
    
    int cnt2 = 0;
    memset(seen, false, n);
    seen[f2] = true;
    cnt2 += dfs(n-1) - 1;
  
    if (cnt1 > cnt2) {
        cout << "Fennec" << '\n';
    }
    else {
        cout << "Snuke" << '\n';
    }
    return 0;
}


Measured memory_bytes: 15048
//DEEPANSHU RAWAT
/*************************************************************************************************************************/


#include<bits/stdc++.h>
#define ull unsigned long long
#define lld long long int
#define infi 1e9
#define ninfi LLONG_MIN
#define ff first
#define ss second
#define pb push_back    
#define mp make_pair
#define ee endl
#define mod 1000000007 
#define isPowerOfTwo(S) (!(S & (S - 1)))
#define nearestPowerOfTwo(S) ((int)pow(2.0, (int)((log((double)S) / log(2.0)) + 0.5)))
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define pq priority_queue<int,vector<int>,greater<int>>

using namespace std ;
/*************************************************************************************************************************/

vector<lld>dp(100001,1e9);
lld minCost(vector<lld>& v,lld n,lld k){
	
	dp[0]=0;
	for(lld i=0;i<n;i++){
		for(lld j=i+1;j<=i+k && j<n;j++){
			dp[j]=min(dp[j],dp[i]+abs(v[j]-v[i]));
		}
	}
	return dp[n-1];
}
/**************************************************************************************************************************/
int main()
{
       
  ios_base::sync_with_stdio(false);   
  cin.tie(NULL);
  
  
  lld n,k;
  cin>>n>>k;
  vector<lld>v(n);
  for(lld i=0;i<n;i++){
  	cin>>v[i];
  }

  cout<<minCost(v,n,k);
}

    
   

/**************************************************************************************************************************/                                                                                                                                                                                                                                                                                                                

Measured memory_bytes: 4708
#include<iostream>
using namespace std;
int main(){
	string a;
	int num;
	cin>>num;
	cin>>a;
	if(a.length()>num){
		for(int i=0;i<num;i++){
			cout<<a[i];
		}
		cout<<"...";
	} 
	else{
		cout<<a;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) begin(x),end(x)
#define F(i,n) for (int i = 0; i < n; ++i)
#define F1(i,n) for (int i = 1; i <= n; ++i)
#define dbg(x) cerr << #x << " = " << x << endl
#define dbgg(x) cerr << #x << " = " << x << ' '
#define T(x) x[pool]
#define mineq(x,y) { if ((x) > (y)) (x) = (y); }
#define maxeq(x,y) { if ((x) < (y)) (x) = (y); }
#define MEOW cout << "meowwwww" << '\n'; system("pause");
#define int long long
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c)
{
	s << "[ "; for (auto it : c) s << it << " "; s << "\b]\n";
	return s;
}

template<typename T>
ostream& operator <<(ostream &s, const pair<int, T> &c)
{
	s << "[ "; cout << c.fi << " , " << c.se << " ] ";
	return s;
}

const int maxn = 123456;
int n, t[maxn], x[maxn], y[maxn];

void input()
{
	ios::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	F1 (i, n) cin >> t[i] >> x[i] >> y[i];
}

void solve()
{
	int flag = 1;
	F (i, n)
	{
		int dt = t[i + 1] - t[i];
		int d = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
		if (dt < d || (dt - d) % 2 != 0) flag = 0; 
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";
}

main()
{
	input();
	solve();
}


Measured memory_bytes: 2560
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long k = sc.nextLong();
        List<Long> ai = new ArrayList<Long>(n) {{
            for (int i = 0; i < n; i++) {
                add(sc.nextLong());
            }
        }};
        //
        int strlen = Long.toBinaryString(k).length();
        for( long a : ai ) {
            int tmp = Long.toBinaryString(a).length();
            if( tmp > strlen ) strlen = tmp;
        }
        //
        int nh = n/2 + n%2;
        long ans = 0L;
        boolean isSmall = false;
        int j = strlen-1;
        long unit = Math.round(Math.pow(2, j));
        for (int i = 0; i < strlen; i++) {
            int one = 0;
            for (long a : ai) {
                one += (a >> j) & 1L;
            }

            boolean flag = ( (k>>j )&1L )==1L;
            if( one >= nh ) {
                ans += unit * one;
                if( flag ) isSmall = true;
            } else {
                if( !flag & !isSmall ) {
                    ans += unit * (long)one;
                } else {
                    ans += unit * (long)(n-one);
                }
            }
            j--;
            unit /= 2L;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 65256
N = int(input())
num = list(map(int, input().split()))
count = 0

for i in num:
    if i%4==0:
        N -= 2
    elif i%2==0:
        count += 1
if count>1:
    N = N - count + 1

if N > 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define show(x) cout << #x << " = " << (x) << endl
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
int main(){
	int N;
	string s,t,r;
	cin>>N>>s>>t>>r;
	int ans = 0;
	rep(i,N){
		set<char> st;
		st.insert(s[i]);
		st.insert(t[i]);
		st.insert(r[i]);
		int K = st.size();
		ans += K-1;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int read()
{
	int i=0,f=1;char c=getchar();
	while(c>'9'||c<'0') {if(c=='-') f=-1;c=getchar();}
	while(c>='0'&&c<='9') {i=i*10+c-'0';c=getchar();}
	return i*f;
} 
int main()
{
	int n;
	n=read();
	if(n==1)	
	{
		cout<<"Hello World"<<endl;	
	}
	if(n==2)
	{
		int a,b;
		a=read(),b=read();
		int c;
		c=a+b;
		printf("%d\n",c);
	}
	return 0;
}

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

int main()
{	
	int n;

	while (cin >> n) {
		if (n % 39 == 0)
			n = 39;
		else
			n = n % 39;

		cout << "3C" << setw(2) << setfill('0') << n << endl;
	}

	return 0;
}



Measured memory_bytes: 3004
package main 

import "fmt"

var a, b, c, k int

func main () {
	ans := "No"
	fmt.Scan(&a, &b, &c, &k)
	for i:=0; i<k; i++{
		if a>=b {
			b *= 2 
		}else if b>=c{
			c *= 2
		}
		if a<b && b<c {
			ans = "Yes"
			break
		}
	}
	fmt.Println(ans)
}

Measured memory_bytes: 1772
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<int> g[100001];
vector<int> tp;
vector<bool> vis(100001);

void dfs(int n)
{
    vis[n]=true;
    for(int nd:g[n])
        if(!vis[nd])
            dfs(nd);
    tp.push_back(n);
}
int main()
{
    ll n,m;
    cin>>n>>m;
    for(ll i=1;i<=m;i++)
    {

        int u,v;
        cin>>u>>v;
        g[u].push_back(v);
    }
    for(int i=1;i<=n;i++)
        if(!vis[i])
            dfs(i);
    reverse(tp.begin(),tp.end());
    ll dp[n+1]={0};
    for(ll u:tp)
        for(ll v:g[u])
            dp[v]=max(dp[v],1+dp[u]);
    ll ans=0;
    for(ll i=1;i<=n;i++)
        ans=max(ans,dp[i]);
    cout<<ans;
    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

template <class T>
void chmin(T &a, const T &b) {
  if (a > b) a = b;
}
template <class T>
void chmax(T &a, const T &b) {
  if (a < b) a = b;
}

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int a, b, c;
  cin >> a >> b >> c;
  int x, y;
  cin >> x >> y;
  int d = min(a + b, 2 * c);
  int o = min(x, y);
  int ans = d * o;
  x -= o;
  y -= o;
  ans += x * min(a, 2 * c);
  ans += y * min(b, 2 * c);
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  //   int t;
  //   cin >> t;
  //   while (t--) solve();
  return 0;
}


Measured memory_bytes: 256