akhauriyash/Code-Regression huggingface dataset:
/******************************************
* AUTHOR : Ashish Joshi* 
* INSTITUTION : NIT Hamirpur *
******************************************/
#include <bits/stdc++.h>
using namespace std;

#define N 100005
#define MOD 1000000007
#define PI 3.141592653589793

#define dd double
#define loop(i, n) for(int i = 0; i < n; i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,b) for(int i=1;i<=b;i++)
#define pb push_back
#define mp make_pair
#define clr(x) x.clear()
#define sz(x) ((int)(x).size())
#define fi first
#define se second
#define set(b,i) (b|(1<<i))
#define unset(b,i) (b&!(1<<i))
#define cbit(b,i) bool(b&(1<<i))

typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<ll> > vvll;

int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
int n;
cin>>n;
string s[n];
map<string,int> m;
int mx=0;
for(int i=0;i<n;i++){
	cin>>s[i];
	m[s[i]]++;
}
for(auto x:m){
	mx=max(mx,x.se);
}
for(auto x:m)
	if(x.se==mx)
		cout<<x.fi<<endl;
	
	return 0;
}


Measured memory_bytes: 25472
#include<stdio.h>

int main(){
  while(1){
    int i, t[5], used[] = {0, 0, 0};
    for(i = 0;i < 5;i++){
      scanf("%d", t + i);
      used[t[i] % 3]++;
    }
    if(t[0] == 0)return 0;
    if(used[0] && used[1] && used[2]){
      for(i = 0;i < 5;i++)
	puts("3");
    }
    else if(used[0] == 0){
      if(used[1] == 0 || used[2] == 0){
	for(i = 0;i < 5;i++)
	  puts("3");
      }
      else{
	for(i = 0;i < 5;i++){
	  if(t[i] == 1)
	    puts("1");
	  else
	    puts("2");
	}
      }
    }
    else if(used[1] == 0){
      if(used[2] == 0){
	for(i = 0;i < 5;i++)
	  puts("3");
      }
      else{
	for(i = 0;i < 5;i++){
	  if(t[i] == 2)
	    puts("1");
	  else
	    puts("2");
	}
      }
    }
    else{
      for(i = 0;i < 5;i++){
	if(t[i] == 3)
	  puts("1");
	else
	  puts("2");
      }
    }
  }
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
using namespace std;
char c;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    while(cin>>c)
        if(c=='9')
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll n,a,b,x[N],dp[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cin>>n>>a>>b;
    for(ll i=1;i<=n;i++)cin>>x[i];
    for(ll i=2;i<=n;i++)dp[i]=dp[i-1] + min(a*(x[i]-x[i-1]) , b);
    cout<<dp[n];
}


Measured memory_bytes: 1792
def to_bin(number):

    return bin(number)[2:].zfill(45)


def xor(num1, num2):

    num1_str = to_bin(num1)
    num2_str = to_bin(num2)

    result_list = [0] * 45

    for digit in range(0, 45):
        result_list[digit] += int(num1_str[digit])
        result_list[digit] += int(num2_str[digit])

    result_str = ''

    for digit in result_list:

        if digit % 2 == 0:
            result_str += '0'
        else:
            result_str += '1'
    return int(result_str, 2)


def f(a, b):
    if a > 0:
        a -= 1

    return xor(g(a), g(b))


def g(num):

    others = 0

    if num % 2 == 0:
        if (num // 2) % 2 != 0:
            others = 1

        return xor(num, others)
    else:
        if ((num - 1) // 2) % 2 != 0:
            others = 1

        return xor(xor(num, others), num - 1)


A, B = map(int, input().split())

result = f(A, B)

print(result)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define newl "\n"
using namespace std;
using lli = long long int;
using vvint = vector <vector <int>>;
const int mod = 1e9 + 7;

const int N = 2e5 + 1;

void solve(){
	string s,t;
	cin >> s >> t;
	int n = s.length();
	for(int i = 0;i < n;++i){
		if(s[i] != t[i]){
			cout << "No" << newl;
			return;
		}
	}
	cout << "Yes" << newl;
	return;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout << fixed << setprecision(10);
	#ifdef EXECUTE_LOCALLY
		   freopen("in.txt","r",stdin);
	#endif
	int t = 1;
	//cin >> t;
	while(t--) solve();
	#ifdef EXECUTE_LOCALLY
    	cout << setprecision(3) << "program time: " << (double)clock() / CLOCKS_PER_SEC << newl;
	#endif
	return 0;
}


Measured memory_bytes: 3592
#
# abc147 c
#
import sys
from io import StringIO
import unittest
from collections import deque


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """3
1
2 1
1
1 1
1
2 0"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """3
2
2 1
3 0
2
3 1
1 0
2
1 1
2 0"""
        output = """0"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """2
1
2 0
1
1 0"""
        output = """1"""
        self.assertIO(input, output)


def resolve_bit():
    N = int(input())
    C = []
    for i in range(N):
        a = int(input())
        C.append([list(map(int, input().split())) for j in range(a)])

    ans = 0
    for bit in range(1 << N):
        f = True
        for i in range(N):
            if bit & (1 << i):
                for c in C[i]:
                    if bit & (1 << c[0]-1) != (1 << c[0]-1)*c[1]:
                        f = False
                        break
        if f == True:
            ans = max(ans, bin(bit).count("1"))
    print(ans)


def resolve():
    global N, C
    N = int(input())
    C = []
    for i in range(N):
        a = int(input())
        C.append([list(map(int, input().split())) for j in range(a)])

    V = deque()
    print(dfs(0, V))


def dfs(n, V):
    if n == N:
        count = 0
        for v in V:
            if count == -1:
                break
            for c in C[v-1]:
                if (c[0] in V and c[1] == 0) or (c[0] not in V and c[1] == 1):
                    count = -1
                    break
            else:
                count += 1
        if count == -1:
            return 0
        else:
            return count

    ans = 0
    V.append(n+1)
    ans = max(ans, dfs(n+1, V))
    V.pop()
    ans = max(ans, dfs(n+1, V))

    return ans


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16168
object Main extends App{
  import java.io.{BufferedOutputStream, BufferedReader, InputStreamReader, PrintWriter}
  val in=new BufferedReader(new InputStreamReader(System.in))
  val out = new PrintWriter(new BufferedOutputStream(System.out))
  val Array(n,m) = in.readLine().split(" ").map(_.toInt)
  val ac = scala.collection.mutable.HashMap[Int,Int]()
  var pe = scala.collection.mutable.HashMap[Int,Int]()
  for{i <- (0 until(m))}{
    val Array(p,s)=in.readLine().split(" ")
    val j = p.toInt
    if(ac.contains(j)){}
    else{
      if(s=="AC") {
        ac(j) = if(pe.contains(j)) pe(j) else 0
      }
      else pe(j) = if(pe.contains(j)) pe(j) + 1 else 1
    }
  }
  var ans = 0
  ac.toSeq.map(r => ans += r._2)
  out.println(s"${ac.toSeq.size} ${ans}")
  out.flush()
}

Measured memory_bytes: 57668
#include<bits/stdc++.h>
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) \
  for (ll i = static_cast<int>(a); i < static_cast<int>(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, ) (__VA_ARGS__)  // NOLINT
#define chmax(x, a)  do { x = max(x, a); } while(0)
#define chmin(x, a)  do { x = min(x, a); } while(0)

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll,ll> PLL;


void solve() {
  ll H, W;
  cin >> H >> W;
  vector<ll> a(H), b(H);
  map<ll,ll> m;
  multiset<ll> s;
  rep(x, W) {
    m[x] = x;
    s.insert(0);
  }
  rep(i, H) {
    cin >> a[i] >> b[i];
    a[i]--;
    b[i]--;
  }
  rep(i, H) {
    auto it = m.lower_bound(a[i]);
    // 削除対象のx一覧
    vector<ll> dels; 
    while (it != m.end() && it->first <= b[i]+1) {
      dels.push_back(it->first);
      it++;
    }
    // 削除
    ll mx = -1;
    for (auto x : dels) {
      chmax(mx, m[x]);
      s.erase(s.find(x-m[x]));
      m.erase(m.find(x));
      //cout << "delete x=" << x << endl;
    }
    // 追加
    if (mx != -1 && b[i] + 1 < W) {
      m[b[i]+1] = mx;
      s.insert(b[i]+1 - mx);
      //cout << "add x=" << b[i]+1 << endl;
    }
    // 答え
    ll ans = -1;
    if (s.size() > 0)
      ans = i + 1 + *s.begin();
    cout << ans << endl;
  }
}

int main() {
  //ll T;
  //cin >> T;
  //rep(_,T)
    solve();
  return 0;
}


Measured memory_bytes: 28344
import java.util.*;
import java.io.*;

public class Main{
  public static void main(String args[]) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
    String[] list = str.split(" ", 0);
    int c = Integer.parseInt(list[0]) * Integer.parseInt(list[1]);
    if(c%2==0){
      System.out.print("Even");
    }else{
      System.out.print("Odd");
    }
  }
}

Measured memory_bytes: 21204
a, b, c, d, e = map(int, input().split())
f = c * max(d, e) * 2
g = c * min(d, e) * 2 + (abs(d - e) * a if d > e else abs(d - e) * b)
h = a * d + b * e
print(min(f, g, h))


Measured memory_bytes: 2940
n,k=map(int,input().split())
a=list(map(int,input().split()))
towns=[-1]*n
towns[0]=0
current=1
for i in range(1,n+2):
  current=a[current-1]
  if i==k+1:
    loop=k+2
    thing=0
    place=1
    break
  elif towns[current-1]==-1:
    towns[current-1]=i
  else:
    loop=i-towns[current-1]
    thing=towns[current-1]
    place=current
    break
k-=thing
b=k%loop
current=place
for i in range(b):
  current=a[current-1]
  if towns[current-1]==-1:
    towns[current-1]=i
print(current)
  

Measured memory_bytes: 32380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,m,k,x,y,mp[128],px[5],py[5],dx[4]={-1,1,0,0},dy[4]={0,0,-1,1};
char s[200005],t[200005];
void fail(){puts("NO");exit(0);}
bool valid(int x,int y){
    return (x>=1 && x<=n) && (y>=1 && y<=m);
}
int main()
{
    scanf("%d%d%d%d%d%s%s",&n,&m,&k,&x,&y,s+1,t+1);
    mp['U']=0; mp['D']=1; mp['L']=2; mp['R']=3;
    rep(i,0,3) px[i] = x, py[i] = y;
    rep(i,1,k) rep(j,0,3){
        int jj = j ^ 1;
        if(mp[s[i]] == j){
            px[j] += dx[j];
            py[j] += dy[j];
            if(!valid(px[j],py[j])) fail();
        }
        if(mp[t[i]] == jj){
            if(valid(px[j] + dx[jj], py[j] + dy[jj])) {
                px[j] += dx[jj];
                py[j] += dy[jj];
            }
        }
    }
    puts("YES");
    return 0;
}

Measured memory_bytes: 640
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES

#include "bits/stdc++.h"
#define REP(i,a,b) for(int i=a;i<b;++i)
#define rep(i,n) REP(i,0,n)
#define ll long long
#define ull unsigned ll
typedef long double ld;
#define ALL(a) begin(a),end(a)
#define ifnot(a) if(not a)
#define dump(x)  cerr << #x << " = " << (x) << endl
using namespace std;

// #define int ll
#ifdef _MSC_VER
const bool test = true;
#else 
const bool test = false;
#endif

int dx[] = { 0,1,0,-1 };
int dy[] = { 1,0,-1,0 };
#define INF (1 << 28)
ull mod = (int)1e9 + 7;
//.....................
#define MAX (int)1e6 + 5

int T;
int N[1005];
int D[1005];

signed main() {
	cout << setprecision(20) << fixed;
	cin >> T;
	rep(i, T) {
		cin >> N[i] >> D[i];
		int sum = 0;
		rep(j, N[i]-1) {
			D[i] ^= 127;
			sum += 127;
		}
		sum += D[i];
		cout << sum << endl;
	}
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    string s; cin>>s; sort(all(s)); yn(s=="abc");
}

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

#define times(n, i)      uptil(0, n, i)
#define rtimes(n, i)     downto((n) - 1, 0, i)
#define upto(f, t, i)    for(auto i##0_to = (t), i = decltype(t)(f); i <= i##0_to; i++)
#define uptil(f, t, i)   for(auto i##0_to = (t), i = decltype(t)(f); i <  i##0_to; i++)
#define downto(f, t, i)  for(auto i##0_to = decltype(f)(t), i = (f); i >= i##0_to; i--)
#define downtil(f, t, i) for(auto i##0_to = decltype(f)(t), i = (f); i >  i##0_to; i--)
using LD = long double;
#define double LD
#define long long long
#define LL long
#define int long
template<class T> using vec = vector<T>;
using VB = vec<bool>;   using WB = vec<VB>;
using VC = vec<char>;   using WC = vec<VC>;
using VI = vec<int>;    using WI = vec<VI>;
using VD = vec<double>; using WD = vec<VD>;
using VS = vec<string>; using WS = vec<VS>;
using PI = pair<int, int>;  using VPI = vec<PI>; using WPI = vec<VPI>;
using MI = map<int, int>;   using VMI = vec<MI>;

#if defined(EBUG) && !defined(ONLINE_JUDGE)
    #define debug true
    #define _GLIBCXX_DEBUG
    #define _LIBCPP_DEBUG 2
    #define _LIBCPP_DEBUG2 2
    #define ln << endl
    #define dd(x) cerr << #x << " = " << (x) << ", "
    #define ddd(x) cerr << #x << " = " << (x) ln
#else
    #define debug false
    #define ln << '\n'
    #define dd(x) cerr
    #define ddd(x) cerr
#endif
#define tb << '\t'
#define sp << ' '
#define db dd
#define dbg ddd

template<class T>          inline istream& operator>>(istream& s, vec<T>& v) { for(auto&& p : v) s >> p; return s; }
template<class T, class S> inline ostream& operator<<(ostream&, const pair<T, S>&);
template<class T>          inline ostream& operator<<(ostream&, const vec<T>&);
template<class T, class S> inline ostream& operator<<(ostream&, const map<T, S>&);
#define DEFINE_ITER_OUTPUT(s, x, sep) { int i = 0; for(const auto& x##0_elem : x) { if(i++) s << sep; s << x##0_elem; } return s; }
template<class T, class S> inline ostream& operator<<(ostream& s, const pair<T, S>& p) { return s << "(" << p.first << "," << p.second << ")"; }
template<class T>          inline ostream& operator<<(ostream& s, const vec<T>& v) DEFINE_ITER_OUTPUT(s, v, ' ')
template<class T, class S> inline ostream& operator<<(ostream& s, const map<T, S>& m) DEFINE_ITER_OUTPUT(s, m, ' ')
template<class T>          inline ostream& operator<<(ostream& s, const vec<vec<T>>& w) DEFINE_ITER_OUTPUT(s, w, '\n')
template<class T, class S> inline ostream& operator<<(ostream& s, const vec<map<T, S>>& vm) DEFINE_ITER_OUTPUT(s, vm, '\n')


void solve();

signed main() {
    if(!debug) {
        cin.tie(0);
        ios::sync_with_stdio(0);
    }
    cout << fixed << setprecision(20);
    cerr << fixed << setprecision(20);

    solve();

    return 0;
}

void solve() {
// N N(A)
/* <foxy.memo-area> */
int N;cin>>N;VI A(N);times(N,Ri_0){cin>>A[Ri_0];}
/* </foxy.memo-area> */

    int ans = 0;
    uptil(1, N, i) {
        if(A[i-1] == A[i]) {
            A[i] = -1;
            ++ans;
        }
    }
    cout << ans ln;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
#include <utility>
#include <unordered_map>
#include <numeric>
using namespace std;
#define fol(i,n) for (int i=0;i<n;i++)

int main(){
    int n,m;
    cin >>n>>m;
    int a[n],b[n],c[m],d[m];
    vector <pair<int,int>>z(50);
    fol(i,n) cin >>a[i]>>b[i];
    fol(i,m) cin >>c[i]>>d[i];
    fol(i,n){
            fol(j,m){
            int x = fabs(a[i]-c[j]);
            int y = fabs(b[i]-d[j]);
             z[j]=make_pair(x+y,j);
        }
        sort(z.begin(),z.begin()+m);
        cout << z[0].second+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
# coding: utf-8
# Your code here!
s = input()
front = int(s[0:2])
back = int(s[2:])

if 12 < front or front == 0:
    if 1 <= back and back <= 12:
        print('YYMM')
    else:
        print('NA')
elif 1 <= front and front <= 12:
    if 1 <= back and back <= 12:
        print('AMBIGUOUS')
    elif 12 < back or back == 0:
        print('MMYY')
    else:
        print('NA')
else:
    print('NA')
    

Measured memory_bytes: 3060
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        grid: [[usize; 3]; 3],
        n: usize,
        bv: [usize; n]
    };

    let mut marks = vec![vec![false; 3]; 3];
    for b in bv {
        for i in 0..3 {
            for j in 0..3 {
                if grid[i][j] == b {
                    marks[i][j] = true;
                }
            }
        }
    }
    let mut count = 0;
    // 横
    for i in 0..3 {
        if (0..3).all(|j| marks[i][j]) {
            count += 1;
        }
    }
    // 縦
    for j in 0..3 {
        if (0..3).all(|i| marks[i][j]) {
            count += 1;
        }
    }
    // 斜め
    if (0..3).all(|ij| marks[ij][ij]) {
        count += 1;
    }
    if marks[0][2] && marks[1][1] && marks[2][0] {
        count += 1;
    }
    let res = if count > 0 { "Yes" } else { "No" };
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 2284
#include<bits/stdc++.h>
#define ll long long

using namespace std;

int main(){
	ll n, i, j, mini, z;
	
	cin>>n;
	
	vector < ll > a(n+1);
	
	for(i=0; i<n; i++){
		cin>>a[i];
	} 
	
	z=0;
	for(i=0; i<n; i++){
		mini=i;
		for(j=i; j<n; j++){
			if(a[j]<a[mini]){
				mini=j;
			}
		}
		swap(a[i],a[mini]);
		if(i!=mini) z++;
	}
	
	for(i=0; i<n-1; i++){
		cout<<a[i]<<" ";
	}
	cout<<a[n-1]<<"\n";
	cout<<z<<"\n";
	
	return 0;
}


Measured memory_bytes: 3100
def calcs(x,y,ax,ay,bx,by) ((ax-x)*(by-y)-(bx-x)*(ay-y))/2.0 end
def inpf() a=gets.chomp.split(" ").map(&:to_f)end
def inps() a=gets.chomp.split(" ")end  
def copy(a) Marshal.load(Marshal.dump(a)) end
def kaizyo(n)(n < 2)? 1 : (2..n).inject(:*) end
def scount(a) b=na(a.max+1);a.each{|n|b[n]+=1};return b end
def na(n=0,d=0) Array.new(n,d)end
def na2(n=0,m=0,d=0) Array.new(n){Array.new(m,d)}end
def na3(n=0,m=0,l=0,d=0) Array.new(n){Array.new(m){Array.new(l,d)}}end
def bit(n) n.to_s(2).split("").map(&:to_i) end
def inp() a=gets.chomp.split(" ").map(&:to_i)end
@n,k = inp
@lis = na2(@n+1,0)
@rev = na2(@n+1,0)
k.times do
  a,b,c = inp
  @rev[b].push(a)
  @lis[a].push([b,c])
end
@h = {}
@ans = -1e20
@memo = na(@n+1,-1e20)
@able = na(@n+1,false)
def sable(x)
  return if(@able[x])
  @able[x] = true
  @rev[x].each do |i|
    sable(i)
  end
end
sable(@n)
def zent(x,s,d)
  return unless(@able[x])
  if(d > 1500)
    puts  "inf"
    exit
  end
  if(x == @n)
    @ans = [@ans,s].max
  end
  return if(@memo[x] >= s)
  @memo[x] = s
  @lis[x].each do |aa|
    zent(aa[0],s+aa[1],d+1)
  end
end
zent(1,0,0)
p @ans
=begin
=end

Measured memory_bytes: 6652
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define req(i,n) for(int i = 1;i <=n;i++)
#define pai 3.14159265358979323846
const int INF = 1001001001;
typedef long long ll;
int A[3][3], N;
bool punched[3][3];
bool ok[3][3];
using Graph = vector<vector<int>>;
vector<vector<int>> field;
vector<bool> seen;

const int MOD = 1000000007;
typedef pair<int,int> P;

//最大公約数
int gcd(int a,int b){
	if (a%b == 0){
		return b;
	}
	else{
		return gcd(b,a%b);
	}

}

//最小公倍数
int lcm(int a,int b){
	return a /gcd(a,b) * b;
}

//素数判定
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}



  








      

 
int main(){
   ll n;
   cin >> n;
   string s[n+1];
   map<string,int> cnt;
   rep (i,n){
     cin >> s[i];
     cnt[s[i]]++;
   }
   cout << "AC x " << cnt["AC"] << endl;
   cout << "WA x " << cnt["WA"] << endl;
   cout << "TLE x " << cnt["TLE"] << endl;
   cout << "RE x " << cnt["RE"] << endl;

}


Measured memory_bytes: 6756
#pragma GCC optimize(2)
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
#define rint register int
#define rep(i,l,r) for(rint i=l;i<=r;i++)
#define per(i,l,r) for(rint i=l;i>=r;i--)
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back 
#define fir first
#define sec second
template<typename T1,typename T2>void ckmin(T1 &a,T2 b){if(a>b)a=b;}
template<typename T1,typename T2>void ckmax(T1 &a,T2 b){if(a<b)a=b;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
int read(){
  int x=0,f=0;
  char ch=getchar();
  while(!isdigit(ch))f|=ch=='-',ch=getchar();
  while(isdigit(ch))x=10*x+ch-'0',ch=getchar();
  return f?-x:x;
}
const int N=300005;
int n,m,w;
int row[N],col[N],X[N],Y[N];
int main(){
	scanf("%d%d%d",&n,&m,&w);
	for(int i=1;i<=w;i++){
		X[i]=read(),Y[i]=read();
		row[X[i]]++,col[Y[i]]++;
	}
	int maxr=0,maxc=0,mr=0,mc=0;
	for(int i=1;i<=n;i++){
		if(row[i]>maxr)maxr=row[i],mr=1;
		else if(row[i]==maxr)mr++;
	}
	for(int i=1;i<=m;i++){
		if(col[i]>maxc)maxc=col[i],mc=1;
		else if(col[i]==maxc)mc++;
	}
	int ret=0;
	for(int i=1;i<=w;i++){
		if(row[X[i]]==maxr&&col[Y[i]]==maxc)ret++;
	}	
	if(ret==1ll*mr*mc)printf("%d\n",maxr+maxc-1);
	else printf("%d\n",maxr+maxc);
	return 0;
}

Measured memory_bytes: 8480
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;

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

  int ans = 0;
  if(L >= 0){
    for(int i = 0; i < N; i++){
      ans += L + i;
    }
    ans -= L;
  }
  else{
    if(-L < N){
      for(int i = 0; i < N; i++){
        ans += L + i;
      }
    }
    else{
      for(int i = 0; i < N; i++){
        ans += L + i;
      }
      ans -= L + N - 1;
    }
  }

  cout << ans << endl;
  return 0;

}


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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(const string & S){
    const int P = 2019;
    vector<vector<int>> remainders(S.size()+1, vector<int>(10));
    rep(i,1,10) remainders[1][i] = i % P;
    rep(i,2,S.size()+1) {
        rep(j,0,10) {
            remainders[i][j] = (remainders[i-1][j] * 10) % P;
        }
    }

    vector<int> dp(S.size()+1);
    rep(i,1,S.size()+1) {
        dp[i] = (dp[i-1] + remainders[i][S[i-1] - '0']) % P;
    }

    vector<int> remaindersSum(S.size()+1);
    rrep(i,0,S.size()) {
        remaindersSum[i] = (remaindersSum[i+1] + remainders[S.size() - i][S[i] - '0']) % P;
    }
    vector<int> cnt(P);
    cnt[0]++;
    rep(i,0,S.size()) cnt[remaindersSum[i]]++;
    ll answer = 0;
    rep(i,0,P) {
        if (cnt[i] <= 1) continue;
        answer += ((ll)cnt[i] * (cnt[i]-1) / 2);
    }
    cout << answer << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 19236
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll a,b,c,x,y,z;
int32_t main(){
CODE_START;
cin>>a;
cin>>b;
cin>>c;
cin>>x;
cin>>y;
if(x>y){
    z=y*min(a+b,c*2)+(x-y)*min(a,c*2);
}else {
     z=x*min(a+b,c*2)+abs(x-y)*min(b,c*2);
}
cout<<min(z,max(x,y)*c*2);
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
        
        while (scan.hasNext()){
      int n=scan.nextInt();
      if(n==0)break;
      int []judge =new int[n];
      for(int i=0;i<n;i++)judge[i]=scan.nextInt();
      Arrays.sort(judge);
      int sum=0;
      for(int i=1;i<judge.length-1;i++)
    	  sum+=judge[i];
      System.out.println(sum/(n-2));
    			  
      }
        }
      

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A,B ;
  cin >> A >> B ;
   //cout << setprecision(15) << (double)1/3 << endl;
  //cout << (double)1/3 << endl;
  if (A>2*B) {
   // cout << fixed << setprecision(12);
    cout << A - 2 * B << endl;
  }
  else {
  cout << 0 << endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int X;
	scan(X);
	int sum=0;
	rep1(i,INF){
		sum+=i;
		if(sum>=X){
			prin(i);
			break;
		}
	}
	return 0;
}


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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            string txt = Console.ReadLine();

            string a = "apple", p = "peach";
            char[] ch = txt.ToCharArray();

            int len = txt.Length - 5;
            for (int i = 0; i <= len; i++)
            {
                if (txt[i] == 'a' && txt.Substring(i, 5) == a)
                {
                    for (int j = 0; j < 5; i++, j++)
                    {
                        ch[i] = p[j];
                    }
                }
                else if (txt[i] == 'p' && txt.Substring(i, 5) == p)
                {
                    for (int j = 0; j < 5; i++, j++)
                    {
                        ch[i] = a[j];
                    }
                }
            }
            Console.WriteLine(new string(ch));
        }
    }
}

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

#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

using namespace std;
using ll = long long;

const ll MOD = 1000000007LL; // = 10^9 + 7
const double PI = 3.14159265358979;

void solve()
{
	int h, w;
	cin >> h >> w;
	vector<string> s(h);
	for(int i = 0; i < h; ++i)
	{
		cin >> s[i];
	}

	vector< vector<int> > runlength_h(h, vector<int>(1, 1));
	for(int y = 0; y < h; ++y)
	{
		for(int x = 1; x < w; ++x)
		{
			if (s[y][x-1] == s[y][x]) runlength_h[y].back() += 1;
			else runlength_h[y].emplace_back(1);
		}
	}

	vector< vector<int> > runlength_w(w, vector<int>(1, 1));
	for(int x = 0; x < w; ++x)
	{
		for(int y = 1; y < h; ++y)
		{
			if (s[y][x] == s[y-1][x]) runlength_w[x].back() += 1;
			else runlength_w[x].emplace_back(1);
		}
	}

	/*
	for(int y = 0; y < h; ++y)
	{
		for(const auto& r : runlength_h[y])
		{
			cout << r << " ";
		}
		cout << endl;
	}
	//*/

	int ans = 0;
	vector< vector<int> > score(h, vector<int>(w, 0));
	for(int y = 0; y < h; ++y)
	{
		int index = 0;
		for(const int& r : runlength_h[y])
		{
			for(int i = index; i < index + r; ++i) score[y][i] += r;
			index += r;
		}
	}

	for(int x = 0; x < w; ++x)
	{
		int index = 0;
		for(const int& r : runlength_w[x])
		{
			for(int i = index; i < index + r; ++i) score[i][x] += r;
			index += r;
		}
	}

	for(int y = 0; y < h; ++y)
	{
		for(int x = 0; x < w; ++x)
		{
			if (s[y][x] == '.') 
			{
				score[y][x]--;
				ans = max(ans, score[y][x]);
			}
		}
	}
	cout << ans;
}

int main()
{
	fastio;
	solve();

	return 0;
}

Measured memory_bytes: 39312
s=list(input())
N=int(input())

apple=lambda c:ord(c)-ord("a")+1

l=[]
for i in range(len(s)):
    s[i]=apple(s[i])
    dif=27-s[i]
    if s[i]==1:
        pass
    elif dif<=N:
        N-=dif
        s[i]=1

s[-1]-=1
s[-1]=(s[-1]+N)%26
s[-1]+=1

kiss = lambda c: chr(c+96)
for i in range(len(s)):
    s[i]=kiss(s[i])

print("".join(s))

Measured memory_bytes: 4152
#include <bits/stdc++.h>
using namespace std;
void alert(vector<int64_t> vec){
  int64_t N = vec.size();
  for(int i=0; i<N-1; i++) cout << vec.at(i) << " ";
  cout << vec.at(N-1) << endl;
}

int main(){
  int64_t N, M;
  cin >> N >> M;
  vector<int64_t> H(N);
  for(int64_t i=0; i<N; i++){
    cin >> H.at(i);
  }
  vector<pair<int64_t, int64_t>> p; 
  for(int64_t i=0; i<M; i++){
    int a, b;
    cin >> a >> b;
    a--; b--;
    p.push_back(make_pair(a,b));
  }
  sort(p.begin(), p.end());
  int64_t ans = N;
  /*for(int64_t i=0; i<M-1; i++){
    if(p.at(i).first==p.at(i+1).first){
      if(p.at(i).second==p.at(i+1).second){
        if(H.at(p.at(i).first)!=H.at(p.at(i).second)){
          ans++;
        }
      }
    }
  }*/
  vector<int64_t> res(N);
  for(int64_t i=0; i<M; i++){
    int a=p.at(i).first;
    int b=p.at(i).second;
    if(H.at(a)<H.at(b)){
      if(res.at(a)==0){
        ans--;
        res.at(a)++;
      }
    }
    else if(H.at(a)>H.at(b)){
      if(res.at(b)==0){
        ans--;
        res.at(b)++;
      }
    }
    else{
      if(res.at(b)==0){
        ans--;
        res.at(b)++;
      }
      if(res.at(a)==0){
        ans--;
        res.at(a)++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6404
/*
    Created by vasu090 on 19 Apr, 2020
*/
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;

#define rep(i, a, b) for(auto (i)=a;i<b;i++)
#define list(i, N) for(auto (i)=0;i<N;i++)

typedef long long ll;
typedef vector <ll> vi;
typedef pair <ll, ll> pi;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define int ll
#define INF 1e18+5
#define mod 1000000007

template<class T>
T max(T a, T b, T c) {
    return max(a, max(b, c));
}

int32_t main() {

    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int n; cin >> n;
    vi a(n+1); rep(i,2,n+1) cin >> a[i];

    vi cnt(n+1); rep(i,1,n+1) cnt[i]=0;

    rep(i,2,n+1){
        int cur = a[i];
        cnt[cur]+=1;
    }

    rep(i,1,n+1) cout << cnt[i] << '\n';

    return 0;
}

Measured memory_bytes: 5992
// https://atcoder.jp/contests/abcXXX/tasks/abcXXX_x

#include <iostream>
#include <vector>
#include <tuple>
#include <queue>

using namespace std;
using ll = long long;
using ull = unsigned long long;
using pll = pair<ll, ll>;

void debug_out() {};
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << to_string(H);
    debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 1
#endif

struct C1 {
    ll N_{};
    ll M_{};
    vector<ll> v_{};
    priority_queue<ll> a_{};
    explicit C1(ll M, vector<ll> v) : N_(v.size()), M_(M), v_(move(v)){
        for(auto e : v_) {
            a_.push(e);
        }
    }
    ll resolve() {
        while(!a_.empty() && M_ > 0) {
            auto top = a_.top();
            a_.pop();
            auto second = a_.top();
            while(M_ > 0 && top >= second) {
                top /= 2;
                M_--;
            }
            a_.push(top);
        }
        ll cost = 0;
        while(!a_.empty()) {
            cost += a_.top();
            a_.pop();
        }
        return cost;
    }
};

int main() {
    ll N, M;
    cin >> N >> M;
    vector<ll> v{};
    for (int i=0; i < N; ++i) {
        ll x;
        cin >> x;
        v.emplace_back(x);
    }
    C1 c{M, move(v)};
    cout << c.resolve() << endl;
    debug(c.resolve());
    return 0;
}


Measured memory_bytes: 2548
#include <stdio.h>
#include <math.h>
#include <iostream>
#include <string>
using namespace std;

int main(void)
{
    int N, n;
    cin >> N;
    int P[10][10];
    for(int i = 1; i <= 7; i++){
        if(N < pow(10, i)){
            n = i;
            break;
        }
    }
    //cout << n << endl; 
    if(n != 1){
    int a, b;
    a = N/pow(10, n-1);
    b = N%10;
    int A, B, C;
    A = 0;
    B = 0;
    for(int k = 0; k <= n-3; k++){
        A += pow(10, k);
    }
    for(int k = 0; k <= n-2; k++){
        B += pow(10, k);
    }
    C = A + (N-a*pow(10, n-1)-b)/10;
    //cout << a << b << endl;
    for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            if(i > a){
                P[i][j] = A;
            }else if(i < a){
                P[i][j] = B;
            }else if(j > b){
                P[i][j] = C;
            }else{
                P[i][j] = C+1;
            }
        }
    }
    for(int i = 1; i <= 9; i++){
        P[i][i]++;
    }
    int ans = 0;
     for(int i = 1; i <= 9; i++){
        for(int j = 1; j <= 9; j++){
            ans += P[i][j]*P[j][i];
        }
     }
     cout << ans << endl;
    }else{
        cout << N << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
   int n;
  cin>>n;
  map<int,int>m;
  int i,j;
  for(i=0;i<n;i++)
  {
     int b;
    cin>>b;
    m.insert(make_pair(b,i+1));
             }
      for(auto i=m.begin();i!=m.end();i++)
             {
                 cout<<i->second<<" ";
             }
             }

Measured memory_bytes: 5504
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define SIZE 200005
#define INF 1000000005LL
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;
int main(){
    ll n;
    cin >> n;
    cout<<n*(n-1)/2<<endl;
  return 0;
}

Measured memory_bytes: 3564
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1<<30;

int main(){
  int n;cin>>n;
  map<pair<int, int>, int> mp;
  vector<pair<int, int>> vec(n);
  for(int i=0;i<n;i++){
    int x, y;cin>>x>>y;
    vec[i]=make_pair(x, y);
  }
  for(int i=0;i<n;i++){
  	for(int j=0;j<n;j++){
      if(i==j)continue;
      mp[make_pair(vec[j].first-vec[i].first, vec[j].second-vec[i].second)]++;
    }
  }
  int m=0;
  for(auto itr=mp.begin();itr!=mp.end();itr++){
  	m=max(m, itr->second);
  }
  cout<<n-m<<endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <cmath>
#include <string>
#include <algorithm>
#include <numeric>
#include <climits>
#define ll long long
#define LIM 1000
using namespace std;
int main() {
  string s;
  cin >> s;
  int cnt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] == '1') {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
import java.math.BigDecimal;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		// 整数の入力
		int a = sc.nextInt();
       	BigDecimal b = new BigDecimal("0");
        BigDecimal c = new BigDecimal("0");

    	for (int i = 0; i < a; i++) {
          	if (i == 0) {
                b = sc.nextBigDecimal();
            } else {
                c = sc.nextBigDecimal();
              	if (b.compareTo(new BigDecimal("1000000000000000000")) <= 0) {
                  b = b.multiply(c);
                }
              	if (b.compareTo(new BigDecimal("0")) == 0
                   || c.compareTo(new BigDecimal("0")) == 0) {
                  System.out.println(0);
                  return;
                }
            }
        }

      	if (b.compareTo(new BigDecimal("1000000000000000000")) > 0) {
          System.out.println(-1);
        } else {
          System.out.println(b);
        }
	}
}

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

int main(){
	vector<vector<int>> a(3, vector<int>(3));
	vector<vector<bool>> c(3, vector<bool>(3, false));
	rep(i, 3){
		rep(j, 3){
			cin >> a.at(i).at(j);
		}
	}
	
	
	int n, in;
	cin >> n;
	rep(i, n){
		cin >> in;
		rep(j, 3){
			rep(k, 3){
				if(a.at(j).at(k) == in) c.at(j).at(k) = true;
			}
		}
	}
	
	
	rep(i, 3){
		bool temp = false;
		rep(j, 3){
			if(c.at(i).at(j) == false) temp = true;
		}
		if(temp == false){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	rep(i, 3){
		bool temp = false;
		rep(j, 3){
			if(c.at(j).at(i) == false) temp = true;
		}
		if(temp == false){
			cout << "Yes" << endl;
			return 0;
		}
	}
	
	bool temp1 = false;
	rep(i, 3){
		if(c.at(i).at(i) == false) temp1 = true;
	}
	if(temp1 == false){
		cout << "Yes" << endl;
		return 0;
	}
	
	temp1 = false;
	rep(i, 3){
		if(c.at(i).at(2-i) == false) temp1 = true;
	}
	if(temp1 == false){
		cout << "Yes" << endl;
		return 0;
	}
	
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
/*{{{*/
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>
#include <unordered_map>
#include <unordered_set>
#include <cassert>
using namespace std;
typedef pair<int, int> PP;
typedef long long LL;
#define pb push_back
#define fr first
#define sc second
#define bitcnt __builtin_popcount
#define all(x) x.begin(), x.end()
inline LL ri() {LL x; scanf("%lld", &x); return x;}
#define rep2(i, n, ...) for (int i = 0; i < (n); i ++) 
#define rep3(i, a, b, ...) for (int i = (a); i < (b); i ++)
#define GET_MACRO(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep3, rep2)(__VA_ARGS__)
#define drep2(i, n, ...) for (int i = (n) - 1; i >= 0; i --)
#define drep3(i, a, b) for (int i = (a) - 1; i >= (b); i --)
#define drep(...) GET_MACRO(__VA_ARGS__, drep3, drep2)(__VA_ARGS__)
template<typename T>inline bool smax(T&a, T b){if(a<b){a=b;return true;}return false;} 
template<typename T>inline bool smin(T&a, T b){if(a>b){a=b;return true;}return false;} 
/*}}}*/


int p[1000], n;

//mod int
struct mint{
  const static long long mod = 1e9 + 7;
  int x;
  mint():x(0){}       
  mint(long long x):x(((x%mod)+mod)%mod){};
  mint operator+=(const mint&a){if((x+=a.x)>=mod) x-=mod; return *this;}
  mint operator-=(const mint&a){if((x+=mod-a.x)>=mod) x-=mod; return *this;}
  mint operator*=(const mint&a){x=((LL)x*a.x)%mod; return *this;}
  mint operator*(const mint&a){return mint(*this)*=a;}
  mint operator-(const mint&a){return mint(*this)-=a;}
  mint operator+(const mint&a){return mint(*this)+=a;}
  template<typename T>mint operator*(const T&a){return mint(*this)*=a;}
  template<typename T>mint operator-(const T&a){return mint(*this)-=a;}
  template<typename T>mint operator+(const T&a){return mint(*this)+=a;}
  template<typename T>friend mint operator*(T x,const mint&m){return mint(x)*=m;}
  template<typename T>friend mint operator-(T x,const mint&m){return mint(x)-=m;}
  template<typename T>friend mint operator+(T x,const mint&m){return mint(x)+=m;}
  bool operator==(const mint& a)const{ return x == a.x;}
  operator long long () const {return x;}
};
mint pw(mint a, long long b){mint res(1);while(b){if(b&1)res*=a;a*=a;b>>=1;}return res;}
mint inv(mint a){return pw(a, mint::mod - 2);}
//mod int

int main() {
  cin >> n;
  rep(i, n) cin >> p[i];
  //LL res = pw(3, n);
  LL res = 1, sub = 1;
  rep(i, n) {
    int a = 0, b = 0;
    int x = p[i];
    rep(j, -1, 2) {
      if (x + j >= 0) {
        a ++;
        if ((x + j) % 2 == 1) 
          b ++;
      }
    }
    //cout << a << ' ' << b << endl;
    res *= a;
    sub *= b;
  }
  cout << res - sub << endl;

  return 0;
}


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

using namespace std;

void solve() {
    int n;
    int cnt4, cnt2, cnt1;
    cnt1 = cnt2 = cnt4 = 0;
    cin >> n;
    for (int i=0; i<n; ++i) {
        int ai;
        cin >> ai;
        if (ai&1) {
            ++cnt1;
        } else if (ai % 4 == 0) {
            ++cnt4;
        } else  {
            ++cnt2;
        }
    }
    //cout << cnt1 << " " << cnt2 << " " << cnt4 << endl;
    if (cnt4 + 1 < cnt1) {
        cout << "No";
        return;
    } else {
        if (cnt2 == 0) {
            cout << "Yes";
            return;
        } else if (cnt4 < cnt1) {
            cout << "No";
        } else {
            cout << "Yes";
        }

    }

}

int main() {

	solve();
    return 0;
}


Measured memory_bytes: 3096
p[1<<17],h[1<<17],i,I,n;main(k){for(scanf("%*d%d",&k);~scanf("%d",h+n);)p[n]=n++*1e4;for(;I<k+i?:(I=++i,i<n);)p[++I]=fmin(p[I],p[i]+abs(h[I]-h[i]));printf("%d",p[n-1]);}

Measured memory_bytes: 896
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val monsterL = readLine()!!.split(" ").map { it.toLong() }.toMutableList()
    val heroL = readLine()!!.split(" ").map { it.toLong() }
    var kill = 0L
    for (i in 0 until n) {
        when {
            monsterL[n - i] < heroL[n - i - 1] ->{
                kill += Math.min(monsterL[n - i] + monsterL[n - i - 1], heroL[n - i - 1])
                monsterL[n - i - 1] =  Math.max(monsterL[n - i] + monsterL[n - i - 1] - heroL[n - i - 1], 0)
            }
            else -> kill += heroL[n - i - 1]
        }
    }
    
    println(kill)
}

Measured memory_bytes: 85104
use std::io;


fn main() {
    let n = read_one::<usize>();
    let h = read_one::<usize>();
    let w = read_one::<usize>();

    println!("{}", (n - h + 1) * (n - w + 1));
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
std::str::FromStr,
T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main() {

    int a,b,c,A;
    cin >> a >> b >> c;

    A = a + b + c;

    if(A >= 22)
    {
        cout << "bust" << endl;
    } else if(A <= 21){

        cout << "win" <<endl;
    }



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string S;
  cin >> S;
  string ans = "No";
  int N = S.size();
  int sum = 0;
  for (int i = 0; i < N; i++) {
    if (S.at(i) == S.at(N - i - 1)) {
      sum++;
    }
  }
  // sum == N;
  for (int j = 0; j < N / 2; j++) {
    if (S.at(j) == S.at(N / 2 - j - 1) && S.at(N / 2 + j + 1) == S.at(N - j - 1)) {
      sum++;
    }
  }
  // sum == N + N / 2; 
  if (sum == N + N / 2) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}  

Measured memory_bytes: 256
n, m = gets.split(" ").map(&:to_i)
ary = []
n.times do
  ary << gets.split(" ").map(&:to_i)
end

ary = ary.sort
i = 0
sum = 0

while m > 0
    if m - ary[i][1] >= 0
        sum += ary[i][0] * ary[i][1]
        m -= ary[i][1]
    else
        sum += m * ary[i][0]
        m = 0
    end
    i += 1
end

puts sum

Measured memory_bytes: 13176
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define int long long
#define float long double
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define endl '\n'
#define pii pair<int, int>
#define min3(a,b,c) min(a, min(b, c))
#define max3(a,b,c) max(a, max(b, c))
#define all(x) x.begin(), x.end()
#define fill(a,b) memset(a, b, sizeof(a))
#define sz(x) (int)x.size()
#define sp(x) setprecision(x)
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define bs binary_search

signed main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);

    int n; cin>>n;
    n=(1000-(n%1000))%1000;
    cout<<n<<endl;

}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<static_cast<int>(n);++i)
#define per(i, n) for(int i=static_cast<int>(n)-1;i>=0;--i)
#define eee(a) (cerr<<"[@"<<__LINE__<<"] "<<(#a)<<": "<<(a)<<'\n');
#define ppp(a) (cout<<(a)<<'\n'); 
#define cop(a) for(auto x:(a)){cerr<<(x)<<'\n';}
using ll = long long;
constexpr int dx[4]={1,0,-1,0};
constexpr int dy[4]={0,1,0,-1};
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
inline ll inverse(ll n,ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}
template<class T>inline bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename T1,typename T2>ostream& operator<<(ostream& s,const pair<T1, T2>& p){return s <<"("<<p.first<<", "<<p.second<<")";}
template<typename T> ostream& operator<<(ostream& s,const vector<T>& v){s<<'[';for(size_t i=0;i<v.size();++i){s<<v[i];if(i<v.size()-1)s<<", ";}s<<']';return s;}
template<typename T> istream& operator>>(istream& s,vector<T>& v){for(T& x:v)s>>x;return s;}

int main(){
    cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(15);
    
    string s;
    cin >> s;

    string t = "";
    for(int i = 0; i < 5; ++i){
        t += "hi";
        if(s == t) {
            Yes();
            return 0;
        }
    }
    No(); 
    
    return 0;
}


Measured memory_bytes: 256