akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;
public class Main {
	static int N;
	static int b=0;
	public static String dfs(int a) {
		if(a%10==7) {
			b=1;
			return "Yes";
		}
		else if(a<10&&b==0) {
			return "No";
		}
		else {
			String ans="No";
			for(int i=0;i<3;i++) {
				ans=dfs((a-a%10)/10);
			}
			return ans;
		}
	}
	
	public static void main(String args[]) {
	Scanner sc=new Scanner(System.in);
	N=sc.nextInt();
	System.out.println(dfs(N));
	}
}


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

mod util {
    use std::io::stdin;
    use std::str::FromStr;
    use std::fmt::Debug;

    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }

    #[allow(dead_code)]
    pub fn get<T: FromStr>() -> T
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().parse().unwrap()
    }

    #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
        where <T as FromStr>::Err: Debug
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
}

fn main() {
    let n = util::get::<usize>();
    let a: Vec<i64> = util::gets();

    let mut front: BinaryHeap<i64> = a[0..n].iter().map(|&x| -x).collect();
    let mut back: BinaryHeap<i64> = a[2 * n..].iter().cloned().collect();

    let sum_front = a[n..2 * n]
        .iter()
        .fold(vec![-front.iter().sum::<i64>()], |mut v, &x| {
            let sum = *v.last().unwrap();
            front.push(-x);
            v.push(sum + x + front.pop().unwrap());
            v
        });

    let sum_back = a[n..2 * n]
        .iter()
        .rev()
        .fold(vec![back.iter().sum::<i64>()], |mut v, &x| {
            let sum = *v.last().unwrap();
            back.push(x);
            v.push(sum + x - back.pop().unwrap());
            v
        });

    let a = sum_front
        .into_iter()
        .zip(sum_back.into_iter().rev())
        .map(|(f, b)| f - b)
        .max()
        .unwrap();

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


Measured memory_bytes: 16240
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {return a < b && (a = b, true);}
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {return a > b && (a = b, true);}
template<typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) { return is >> p.first >> p.second;}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) { return os << p.first << ' ' << p.second;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, q;
    cin >> n >> q;

    vi a(n);
    int n_ = sqrt(n);
    vi b((n+n_-1)/n_);
    auto add = [&](int i, int x) {
        a[i] += x;
        int h = i/n_;
        b[h] += x;
    };
    auto sum = [&](int i, int j) {
        if(i/n_ == j/n_) {
            int res = 0;
            for(int k = i; k < j; k++) {
                res += a[k];
            }
            return res;
        }
        int res = 0;
        for(int &k = i; k%n_; k++) {
            res += a[k];
        }
        for(int &k = j; k%n_; k--) {
            res += a[k-1];
        }
        for(int &k = i; k != j; k += n_) {
            res += b[k/n_];
        }
        return res;
    };

    while(q--) {
        int t, x, y;
        cin >> t >> x >> y;
        if(t) {
            cout << sum(x-1, y) << '\n';
        } else {
            add(x-1, y);
        }
        /*rep(i, n) {
            cout << a[i] << (i == n-1?'\n':' ');
        }
        rep(i, b.size()) {
            cout << b[i] << (i == b.size()-1?'\n':' ');
        }
        cout << endl;*/
    }
}


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

int N, M, L, A, B, C, Q, s, t, ans;

int main() {
  scanf("%d%d%d", &N, &M, &L);
  vector<vector<int> > D(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) {
    D[i][i] = 0;
  }

  for (int i = 0; i < M; i++) {
    scanf("%d%d%d", &A, &B, &C);
    D[A - 1][B - 1] = D[B - 1][A - 1] = C;
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        D[i][j] = min(D[i][j], D[i][k] + D[k][j]);
      }
    }
  }

  vector<vector<int> > D2(N, vector<int>(N, INF));
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (D[i][j] <= L) D2[i][j] = 1;
    }
  }

  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        D2[i][j] = min(D2[i][j], D2[i][k] + D2[k][j]);
      }
    }
  }

  scanf("%d", &Q);

  for (int q = 0; q < Q; q++) {
    scanf("%d%d", &s, &t);
    ans = D2[s - 1][t - 1];
    if (ans == INF) {
      printf("%d\n", -1);
    } else {
      printf("%d\n", ans - 1);
    }
  }

  return 0;
}


Measured memory_bytes: 1280
N = input()
N = int(N)

a = list(map(int, input().split()))
a.reverse()

i = 0
while i < N:
    b = max(a)
    c = a.index(b)
    d = a[c+1:]

    i += 1
    if d == []:
        break
    a = d

print(i)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <cmath>
#include <bitset>
#include <iomanip>
#include <stack>
#include <list>
#include <map>
#include <unordered_map>
#include <chrono>
#include <numeric>
using namespace std;
using ll = long long;
const ll INF = (ll)1e18+1;
const ll DIV = 1000000007;
//#define TEST
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
#ifdef TEST
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();
#endif
    long a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
#ifdef TEST
    end = chrono::system_clock::now();
    cerr << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count() / 1000.0) << "[ms]" << endl;
#endif
    return 0;
}

Measured memory_bytes: 3604
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val n: Int = sc.nextInt()
  val s: Int = sc.nextInt()
  val mod = 998244353
  val dp = Array.ofDim[Long](n + 1, s + 1)
  dp(0)(0) = 1
  for (i <- 0 until n) {
    val a = sc.nextInt()
    for (j <- 0 until s + 1) {
      dp(i)(j) %= mod
      dp(i + 1)(j) += dp(i)(j) * 2
      if (j + a <= s) dp(i + 1)(j + a) += dp(i)(j)
    }
  }
  println(dp(n)(s) % mod)
}


Measured memory_bytes: 136164
#Nの最大値が100なのでbit-DPでは間に合わない

N = int(input())

s = []
total = 0
for _ in range(N):
    a = int(input())
    s += [a]
    total += a

s.sort()
if total % 10 != 0:
    print (total)
    exit()
else:
    for i in range(N):
        if s[i]%10 != 0:
            print (total - s[i])
            exit()
print (0)


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

int main() {
    string s; int Q;
    cin >> s >> Q;
    bool r = false;
    string pref = "", suff = "";
    while(Q--) {
        int T;
        cin >> T;
        if(T == 1)
            r = !r;
        else {
            int F; char C;
            cin >> F >> C;
            if((F == 1 && !r) || (F == 2 && r))
                pref += C;
            else 
                suff += C;
        }
    }
    reverse(pref.begin(), pref.end());
    string res = pref + s + suff;
    if(r) reverse(res.begin(), res.end()); 
    cout << res << "\n";
}

Measured memory_bytes: 1348
from copy import deepcopy
N,M=map(int,input().split())
L=list(map(int,input().split()))
H={i+1:L[i] for i in range(N)}
d=deepcopy(H)#現在の良い展望台
ans=N
for i in range(M):
  a,b=map(int,input().split())
  if a in d and b in d:#二人とも王
    ans-=1
    if H[a]<H[b]:
      _=d.pop(a)
    elif H[a]>H[b]:
      _=d.pop(b)
    else:
      ans-=1
      _=d.pop(a)
      _=d.pop(b)

  elif a in d:#どちらか一方が王
    if H[a]>H[b]:
      continue
    else:
      ans-=1
      _=d.pop(a)
      
  elif b in d:#どちらか一方が王
    if H[b]>H[a]:
      continue
    else:
      ans-=1
      _=d.pop(b)  

print(ans)

Measured memory_bytes: 31968
#include<iostream>
#include<iomanip>
#include<stdio.h>

using namespace std;

int main()
{
    int n,x,sum;
    while(1){
        sum = 0;
        cin >> n >> x;
        if(n == 0 && x ==0) break;
        for(int i = 1;i <= n;i++){
            for(int j = i+1;j <= n;j++){
                for(int k = j+1;k <= n;k++){
                    if( i+j+k == x) sum += 1;
                }
            }
        }
        cout << sum << endl;
    }

    return 0;
}


Measured memory_bytes: 3120
import sys

sys.setrecursionlimit(10 ** 9)


# map(int, sys.stdin.read().split())


def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    B = list(map(int,input().split()))
    B.append(10**6)
    A =[]
    A.append(B[0])
    for i in range(N-1):
        a =min(B[i],B[i+1])
        A.append(a)
    print(sum(A))




if __name__ == "__main__":
    main()


Measured memory_bytes: 62028
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define rrep(i,n) for(int i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define pr(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
#define yes "Yes"
#define no "No"
using namespace std;
using ll = long long;
using Edge = pair<int,long long>;
using Graph = vector<vector<Edge>>;
typedef pair<int,int> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    rep(i,N) cin >> h[i];
    
    int DP[N+10];
    DP[0] = 0, DP[1] = abs(h[0]-h[1]);
    for(int i=0; i < N-2; i++) DP[i+2] = min(DP[i]+abs(h[i+2]-h[i]),DP[i+1]+abs(h[i+2]-h[i+1]));
    pr(DP[N-1]);
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pl = pair<ll, ll>;
const ll INF = ll(1e18);
const ll mod = ll(1e9 + 7);
const double pi = acos(-1);
#define rep0(i,n) for(ll (i) = 0; (i) < (n); ++(i))
#define rrep0(i,n) for(ll (i) = (n) - 1; (i) >= 0; --(i))
#define rep1(i,n) for(ll (i) = 1; (i) <= (n); ++(i))
#define rrep1(i,n) for(ll (i) = (n); (i) >= 1; --(i))
#define nfor(i,a,b) for(ll (i) = (a); (i) < (b); ++(i))
#define rnfor(i,a,b) for(ll (i) = (b) - 1; (i) >= (a); --(i))
#define pf(x) cout << (x) << endl
#define all(x) (x).begin(),(x).end()
#define yes pf("Yes")
#define no pf("No")
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; }
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

ll gcd(ll a,ll b){
    if(a < b)swap(a, b);
    if(b == 0) return a;
    return gcd(b,a%b);
}

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

ll factorial(ll n){
    ll ans = 1;
    rep1(i, n){
        ans *= i;
        ans %= mod;
    }
    return ans;
}

ll power(ll a, ll b){
    ll ans = 1;
    a %= mod;
    while(b) {
        if(b & 1LL) ans = ans * a % mod;
        a = a * a % mod;
        b >>= 1;
    }
    return ans % mod;
}

//modの値の確認をすること
int main(){
    ll n;
    cin >> n;
    map<string,ll> c;
    rep0(i, n){
        string s;
        cin >> s;
        ++c[s];
    }
    cout << "AC x " << c["AC"] << endl;
    cout << "WA x " << c["WA"] << endl;
    cout << "TLE x " << c["TLE"] << endl;
    cout << "RE x " << c["RE"] << endl;
    return 0;
}


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

using namespace std;


void solve() {
    string s,t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    if (n < m) {
        cout << "UNRESTORABLE"; return;
    }
    set<string> res;
    for (int i = 0; i+m <= n; i++) {
        auto r = s;
        bool yes = true;
        for (int j = 0; j < m; j++) {
            if (r[i+j] == '?') {
                r[i+j] = t[j];
            }else if(r[i+j] != t[j]) {
                yes = false;
                break;
            }
        }
        if (yes) {
            for (int j = 0; j < n; j++) {
                if (r[j]=='?') r[j] = 'a';
            }
            res.insert(r);
        }
    }
    if (res.empty()) {
        cout << "UNRESTORABLE"; return;
    }
    cout << *res.begin();
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    solve();
    cout << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
int a[200000+10]={},b,n,m;

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

  int j=0;
  for(int i=0;i<m;i++){
    cin >> b;
    while(1){
      if(a[j]==b) break;
      if(j>n){
        cout << "0" << endl;
        return 0;
      }
      else if(a[j]<b) j++;

      else{
        cout << "0" << endl;
        return 0;
      }
    }
  }

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



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

uint64_t gcd(const uint64_t a, const uint64_t b) {
    if(a == 0) {
        return b;
    }

    return gcd(b % a, a);
}

uint64_t calc_lcm(const uint64_t a, const uint64_t b) {
    const auto d = gcd(a, b);
    return a / d * b;
}

int main() {
    uint64_t n, m;
    std::cin >> n >> m;

    auto bs = std::vector<uint64_t>();
    bs.reserve(n);
    for(uint64_t i = 0; i < n; ++i) {
        uint64_t a;
        std::cin >> a;
        bs.push_back(a / 2);
    }

    uint64_t lcm = bs[0];
    bool fail = false;

    for(uint64_t i = 1; i < n; ++i) {
        lcm = calc_lcm(lcm, bs[i]);
        if(lcm > m) {
            fail = true;
            break;
        }
    }

    if(!fail) {
        for(const auto b: bs) {
            if(lcm / b % 2 == 0) {
                fail = true;
                break;
            }
        }
    }

    if(fail) {
        std::cout << 0;
    } else {
        std::cout << (m / lcm + 1) / 2;
    }

    return 0;
}


Measured memory_bytes: 1024
N = int(input())
answer = ""
for i in range(N):
    t, x, y = map(int,input().split())
    if i == 0:
        if t == (abs(x) + abs(y)):
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break
    
    else:
        if (t - pre_t) >= (abs(x - pre_x) + abs(y - pre_y)) and (t - pre_t) % 2 == (abs(x - pre_x) + abs(y - pre_y)) % 2:
            answer = "Yes"
            pre_x = x
            pre_y = y
            pre_t = t
        else:
            answer = "No"
            break

print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
#include<string>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<int, int>P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//max=({});
//条件式が真ならwhileの中身を回し続ける
//printf("%d\n", ans);

//pairの入力
//vector<pair<ll, ll>>work(n);
//rep(i, n) {
//	ll a, b;
//	cin >> a >> b;
//	work[i] = make_pair(a, b);
//for(auto p:mp)(mapの探索)
//printf("%.10f\n",なんちゃら)

int g[15][15];
const int INF = 1001001001;
const int dx[4] = { -1,0,1,0 };
const int dy[4] = { 0,-1,0,1 };

//最大公約数
ll gcd(ll x, ll y) {
	return y ? gcd(y, x % y) : x;
}

ll lcm(ll x, ll y) {
	if (x == 0 || y == 0)return 0;
	return (x / gcd(x, y) * y);
}

//素因数分解
vector<pair<ll, int>>factorize(ll n) {
	vector<pair<ll, int>>res;
	for (ll i = 2;i * i <= n;++i) {
		if (n % i)continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1)res.emplace_back(n, 1);
	return res;
}

vector<ll>relation[20], money(20, 1);

int main() {
	int n, m;
	cin >> n >> m;
	vector<int>a(m);
	rep(i, m) {
		cin >> a[i];
		n -= a[i];
		if (n < 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << n << endl;
	return 0;
}

Measured memory_bytes: 3672
#include <iostream>
#include <vector>
#include <cstdio>
#include <cstring>
#include <math.h>
#include <time.h>
#include <algorithm>
#include <set>
#define ll long long
using namespace std;




vector<int> numbers[33][2];


int MaskOut(int x,int b) {
    if (b < 0)
        return 0;
    return (x&((1<<(b+1))-1));
}

int MaskOutComplement(int x,int b) {
    
    x = MaskOut(x,b);
    return (1<<(b+1))-1-x;
}



int GetCountsLowerEq(int x,int bid, bool w) {
    
    
    if (numbers[bid][w].empty())
        return 0;
    
    if (numbers[bid][w][0]>x)
        return 0;
    
    if (numbers[bid][w].back()<=x)
        return numbers[bid][w].size();
    
    
    int low=0;
    int high=numbers[bid][w].size();
    
    while(low < high) {
        int mid = (low + high + 1)/2;
        if (numbers[bid][w][mid] <= x)
            low=mid;
        else
            high = mid-1;
    }
    
    
    // 0 to low
    
    return low+1;

    
    
    
    
}


int GetCountsGreater(int y,int bid, bool w) {
    return numbers[bid][w].size() - GetCountsLowerEq(y,bid,w);
}

bool HasBit(int x,int b) {
    return ((x>>b)&1);
}

int B[222222];
int C[222222];


char buf[8000000];
int readint() {
    int m;
    static char *bp=buf;
    if(*bp<'0' || *bp>'9')
        *bp++;
    
    for(m=*bp++-48; *bp>=48; bp++) m = m*10+*bp-48;
    bp++;
    return m;
}


int BruteForce(int N) {
    int ans=0;
    for(int i=1;i<=N;i++)
        for(int j=1;j<=N;j++)
            ans ^= (B[i]+C[j]);
    return ans;
}

int main() {
    fread(buf, 1, 7999999, stdin);

    int N=readint();
    for(int i=1;i<=N;i++) {
        B[i]=readint();
        //B[i]=rand()%268435456;
    }
    for(int i=1;i<=N;i++) {
        C[i]=readint();
        //C[i]=rand()%268435456;
    }
    
    
    
    
    
    for(int i=1;i<=N;i++) {
        for(int b=0;b<=30;b++) {
            if (HasBit(C[i],b)) {
                numbers[b][1].push_back(MaskOut(C[i],b-1));
            } else {
                numbers[b][0].push_back(MaskOut(C[i],b-1));
            }
        }
    }
    
    
    
    
    for(int b=0;b<33;b++)
        for(int c=0;c<2;c++)
            sort(numbers[b][c].begin(),numbers[b][c].end());
    
    
    
    
    
    
    vector<int> counts(33,0);
    
    for(int i=1;i<=N;i++) {
        for(int bid=0;bid<=28;bid++) {
            
            
            int blow = MaskOutComplement(B[i],bid-1);

            
            if (HasBit(B[i],bid)) {
                counts[bid] += GetCountsLowerEq(blow,bid,0) + GetCountsGreater(blow,bid,1);
            } else {
                counts[bid] += GetCountsLowerEq(blow,bid,1) + GetCountsGreater(blow,bid,0);
            }
        }
    }
    

    
    ll ans=0;
    for(int i=0;i<33;i++) {
        if (counts[i]%2)
            ans |= (1ll<<i);
    }
    
    cout << ans << endl;
    
    //cout << BruteForce(N) << endl;

    
    
    
    
    
    
    
}

Measured memory_bytes: 37828
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int a, b; //隣り合う辺の長さ
    int c; //対角線の長さ
    int rectangular = 0, rhombus = 0; //長方形と菱形の個数
      
    while(scanf("%d,%d,%d", &a, &b, &c) != EOF){
        if(a * a + b * b == c * c) rectangular++;
        else if(a == b) rhombus++;
    }
    cout << rectangular << endl;
    cout << rhombus << endl;
}


Measured memory_bytes: 3136
import java.util.Scanner;

public class Main {
    static Scanner in;
    
    int n;
    int[] a;
    int ans = 0;

    void solve() {
        n = in.nextInt();
        a = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
        }
        dfs(0, 1);
        System.out.println(ans);
    }
    
    void dfs(int i, int sum) {
        if(i == n) {
            if(sum % 2 == 0) {
                ans++;
            }
            return;
        }
        for(int x = -1; x <= 1; x++) {
            dfs(i + 1, sum * (a[i] + x));
        }
    }

    public static void main(String[] args) {
        in = new Scanner(System.in);
        new Main().solve();
    }
}


Measured memory_bytes: 21844
fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let mut n: usize = sc.read();
    let mut ans = 0;
    for i in 2.. {
        if i * i > n {
            if n != 1 {
                ans += 1;
            }
            break;
        }
        if n % i == 0 {
            let mut count = 0;
            while n % i == 0 {
                n /= i;
                count += 1;
            }

            let mut sum = 0;
            let mut z = 0;
            for i in 1.. {
                if sum + i > count {
                    break;
                }
                sum += i;
                z += 1;
            }
            ans += z;
        }
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 2144
import sys
import copy


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    wn, wm = list(map(int, input().rstrip('\n').split()))

    inf = 10 ** 13
    wl = [[inf] * wn for _ in range(wn)]
    for i in range(wn):
        wl[i][i] = 0

    for i in range(wm):
        wa, wb, wc = list(map(int, input().rstrip('\n').split()))
        wl[wa - 1][wb - 1] = wc
        wl[wb - 1][wa - 1] = wc

    cwl = copy.deepcopy(wl)

    for i in range(wn):
        for j in range(wn):
            for k in range(wn):
                wl[j][k] = min(wl[j][k], wl[j][i] + wl[i][k])

    cnt = 0
    for i in range(wn):
        for j in range(wn):
            if cwl[i][j] != wl[i][j] and cwl[i][j] != 10 ** 13:
                cnt += 1
    print(cnt // 2)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 43736
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException{
		HalfAndHalf solver = new HalfAndHalf();
		solver.readInput();
		solver.solve();
		solver.writeOutput();
	}

	static class HalfAndHalf {

		private int a;
		private int b;
		private int c;
		private int x;
		private int y;

		private Scanner scanner;
		private int output;

		public HalfAndHalf() {
			scanner = new Scanner(System.in);
			output=0;
		}

		public void readInput() {
			a = Integer.parseInt(scanner.next());
			b = Integer.parseInt(scanner.next());
			c = Integer.parseInt(scanner.next());
			x = Integer.parseInt(scanner.next());
			y = Integer.parseInt(scanner.next());
		}

		public void solve() {
			if((a+b) >= c*2) {
				// abを買うほうが安い
				output += (c*2) * Math.min(x, y);
				if(x<y) {
					if(b<c*2) {
						output += b*(y-x);
					} else {
						output += (c*2)*(y-x);
					}
				} else if(y<x) {
					if(a<c*2) {
						output += a*(x-y);
					} else {
						output += c*2*(x-y);
					}
				}
			} else {
				output += a*x + y*b;
			}
		}




		public void writeOutput() {
			System.out.println(output);
		}

	}

}


Measured memory_bytes: 22996
N=int(input())
S1=input()
S2=input()
dominos=[]
index=0
while index<N:
    if S1[index]==S2[index]:
        dominos.append(0)
        index+=1
    else:
        dominos.append(1)
        index+=2
if dominos[0]==0:start=3
else:start=6
for k,c in enumerate(dominos):
    if k==0:continue
    elif dominos[k-1]==0:
        start*=2
    elif c:start*=3
    start%=10**9+7
print(start)

Measured memory_bytes: 3064
n=int(input())
s=list(input())
ans=0
for i in range(1,n-1):
  sum=0
  s1=set(s[:i])
  s2=set(s[i:])
  for j in s1:
    for k in s2:
      if j==k:
        sum+=1
        break
  if sum>ans:
    ans=sum
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
const int N=3e3+5,mo=998244353;
int n,x,f[N][N*2],C[N][N],i,j,ans=1;
inline void add(int&x,const int&y){x+=y;x>=mo?x-=mo:0;}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&x);
	for(i=**C=1;i<=n;++i)for(j=*C[i]=1;j<=n;++j)C[i][j]=(C[i-1][j-1]+C[i-1][j])%mo;
	for(i=0,f[0][0]=1;i<n;++i)for(j=0;j<=i*2;++j)add(f[i+1][j+2],f[i][j]),add(f[i+1][j+1],f[i][j]);
	for(i=1;i<=n;++i){
		int s=0;
		for(j=0;j<x;++j)add(s,f[i][j]);
			for(j=x+1;j<=i*2;j+=2)if(j>=i){
				int p=i-(j-x+1),q=x-1-(j-x+1);
				if(j>=x*2){if(j==i*2)add(s,x&1);}
					else if(p>=0 && q>=0)add(s,f[p][q]);
			}
		ans=(ans+1ll*C[n][i]*s)%mo;
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 105984
#include <algorithm>
#include <iostream>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int n;
	cin >> n;
	unordered_map<string, int> a;
	for (int i = 0; i < n; ++i) {
		string b;
		int c;
		cin >> b >> c;
		a[b] += c;
	}
	vector<pair<string, int>> b;
	for (unordered_map<string, int>::iterator i = a.begin(); i != a.end(); ++i) b.emplace_back(i->first, i->second);
	sort(b.begin(), b.end(), [](pair<string, int>& a, pair<string, int>& b) {
		if (a.first.size() == b.first.size()) return a < b;
		return a.first.size() < b.first.size();
	});
	for (pair<string, int>& i : b) cout << i.first << ' ' << i.second << endl;
}


Measured memory_bytes: 3100
#include<iostream>
#include<algorithm>
using namespace std;
int n;
int a[201];
int main(){
	ios::sync_with_stdio(false);
	cin >> n;
	for(int i=1; i<=2*n ;i++) cin >> a[i];
	sort(a+1,a+2*n+1);
	int ans=0;
	for(int i=1; i<=2*n ;i+=2) ans+=a[i];
	cout << ans << endl;
}

Measured memory_bytes: 256
/* AOJ 0522 JOI and IOI */

#include <iostream>
#include <string>

using namespace std;

int
main() {
    for (;;) {
        string s;
        int len;
        int n_joi = 0;
        int n_ioi = 0;
        int i;

        getline(cin, s);
        if (cin.eof()) break;

        len = s.size();

        for (i = 0; i < len - 2; i++) {
            if (s[i] == 'J' && s[i + 1] == 'O' && s[i + 2] == 'I') {
                n_joi++;
                i++;
            } else if (s[i] == 'I' && s[i + 1] == 'O' && s[i + 2] == 'I') {
                n_ioi++;
                i++;
            }
        }

        cout << n_joi << '\n' << n_ioi << endl;
    }

    return 0;
}

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

int main() {
    int N, ans = 1e6;
    string S;
    cin >> N >> S;
    vector<pair<int, int>> l(N + 1);
    for(int i = 0; i < N; ++i) {
        l[i + 1] = l[i];
        if(S[i] == 'E')
            l[i + 1].first++;
        else
            l[i + 1].second++;
    }
    for(int i = 0; i < N; ++i) {
        int re = l[N].first - l[i + 1].first;
        ans = min(ans, l[i].second + re);
    }
    cout << ans << endl;
    return 0;
}


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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)(n); i++)
#define INF 10000000000
#define MOD 1000000007
using ll = long long;
using Graph = vector<vector<int>>;

int main(){
    vector<int> A(5);
    rep(i,5)cin>>A.at(i);
    rep(i,5)if(A.at(i)==0)cout<<i+1<<endl;
}


Measured memory_bytes: 3628
a, b, m = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
XYC = [list(map(int, input().split())) for _ in range(m)]

ans = min(A) + min(B)
for x, y, c in XYC:
  x -= 1
  y -= 1
  cand = A[x] + B[y] - c
  ans = min(ans, cand)
print(ans)


Measured memory_bytes: 38560
#include <bits/stdc++.h>
typedef long long ll;
#define mod ((ll) 1e9+7)
using namespace std;

ll n, m;
vector<ll> x, y;
int main(){
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        ll z;
        cin >> z;
        x.push_back(z);
    }

    for(int i = 0; i < m; i++){
        ll z;
        cin >> z;
        y.push_back(z);
    }
    ll ans = 0;

    ll x1=0,y1=0;

    for(ll i = 1; i<=n; i++){
        x1 += (((i-1) * x[i-1])%mod - ((n-i) * x[i-1])%mod);
        x1%=mod;
    }
     for(ll i = 1; i<=m; i++){
        y1 += (((i-1) * y[i-1])%mod - ((m-i) * y[i-1])%mod);
        y1%=mod;
    }

    cout << ((x1*y1)%mod + mod)%mod;

    return 0;

}


Measured memory_bytes: 2548
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <string.h>
#include <ctype.h>
#include <algorithm>

using namespace std;

long x;

long f(long n) {
  if(n >= 0)
    return n/x + 1;
  else return 0;
}

int main() {
  long a,b, ans;
  cin >> a >> b >> x;

  ans = f(b) - f(a-1);

  cout << ans << endl;
}

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

int main(){
	int v,n,a[100] = {},i,j;
	cin >> n;
	for(i = 0;i < n;i++){
		cin >> a[i];
	}
		for(int k = 0;k < n;k++){
		if(k != n-1){
			cout << a[k] << " ";
		}
		else cout << a[k] << endl;
		}

	for(i = 1;i < n;i++){
		v = a[i];
		j = i - 1;
		while(j >= 0 && a[j] > v){
			a[j+1] = a[j];
			j--;
		}
		a[j+1] = v;

		for(int k = 0;k < n;k++){
		if(k != n-1){
			cout << a[k] << " ";
		}
		else cout << a[k] << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
#include<string.h>

int main(void){
  int i,j,n;
  char event[10];
  int base[3];
  int out;
  int score;

  scanf("%d",&n);

  for(i=0;i<n;i++){
    score = 0;
    out = 0;
    for(j=0;j<3;j++)base[j] = 0;
    while(1){
      scanf("%s",event);
      if(!strcmp(event,"HIT")){
	if(base[2]){
	  base[2] = 0;
	  score++;
	}
	if(base[1]){
	  base[1] = 0;
	  base[2] = 1;
	}
	if(base[0]){
	  base[0] = 0;
	  base[1] = 1;
	}
	base[0] = 1;
      }else if(!strcmp(event,"HOMERUN")){
	for(j=0;j<3;j++){
	  if(base[j]){
	    base[j] = 0;
	    score++;
	  }
	}
	score++;
      }else{
	out++;
      }
      if(out == 3)break;
    }
    printf("%d\n",score);
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<int, P> P1;
typedef pair<P, P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i, x) for (long long i = 0; i < x; i++)
#define repn(i, x) for (long long i = 1; i <= x; i++)
#define SORT(x) sort(x.begin(), x.end())
#define ERASE(x) x.erase(unique(x.begin(), x.end()), x.end())
#define POSL(x, v) (lower_bound(x.begin(), x.end(), v) - x.begin())
#define POSU(x, v) (upper_bound(x.begin(), x.end(), v) - x.begin())
vector<pair<string, P> > vec;
// vector<vector<int>> data(3, vector<int>(4));

void solve(long long R) { printf("%.16f\n", 2 * R * 3.1415926535); }

int main() {
    long long R;
    scanf("%lld", &R);
    solve(R);
    return 0;
}


Measured memory_bytes: 3812
str1 = str(input())
l1 = str1.split(' ')
n = int(l1[0])
m = int(l1[1])
str2 = str(input())
l2 = str2.split(' ')
l = [int(x) for x in l2]
total = sum(l)
testNum = total/(4*m)
x = []
for i in l:
	if i>=testNum:
		x.append(i)

if len(x)>=m:
	print('Yes')
else:
	print('No')

Measured memory_bytes: 3064
import java.util.Scanner;

class Main{
	public static void main(String[] ag) {
		Scanner sc=new Scanner(System.in);
		int H=sc.nextInt();
		int W=sc.nextInt();

		String s="";
		for(int i=0; i<H; i++) {
			s=sc.next();
			System.out.println(s);
			System.out.println(s);
		}
	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define ll long long
using namespace std;
//typedef vector<unsigned int>vec;
//typedef vector<ll>vec;
//typedef vector<vec> mat;
typedef pair<int, int> P;
typedef pair<ll,ll> LP;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const int INF = 1000000000;
const ll LINF = 1000000000000000000;//1e18
const ll  MOD = 1000000007;
const double PI = acos(-1.0);
const double EPS = 1e-10;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void add(T &a, T b){a = ((a+b) % MOD + MOD) % MOD;};


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, M;
    cin >> A >> B >> M;
    vector<int> a(A), b(B);
    vector<int> x(M), y(M), c(M);
    int mi_a = INF, mi_b = INF;
    REP(i,A){
        cin >> a[i];
        chmin(mi_a, a[i]);
    }
    REP(i,B){
        cin >> b[i];
        chmin(mi_b, b[i]);
    }
    REP(i,M){
        cin >> x[i] >> y[i] >> c[i];
        --x[i], --y[i];
    }
    int ans = mi_a + mi_b;
    REP(i,M){
        int tmp = a[x[i]] + b[y[i]] - c[i];
        chmin(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 2176
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus < 201703L
#        pragma GCC target("avx")
#    else
#        pragma GCC target("avx2")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;
typedef long double Ld;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, a, b, ans;
    cin >> n >> a >> b;

    if ((a & 1LL) == (b & 1LL)) {
        ans = (b - a) / 2;
    } else {
        ans = min(a - 1, n - b) + 1 + (b - a - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  string s;
  cin>>n>>s;
  bool r=0;
  if(n%2==0){
    r=1;
    for(int i=0;i<n/2;i++)
      if(s.at(i)!=s.at(i+n/2))
        r=0;
  }
  cout<<(r?"Yes":"No")<<endl;
}


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

  int main() {
  int N , A;
  cin >> N >> A;
  int L = A;
  int R = A + N - 1;
  int eat;
  if(R <= 0){
    eat = R;
  }
  else if(L >= 0){
    eat = L;
  }
  else {
    eat = 0;
  }
  int answer = (R + L) * (R - L + 1) / 2 - eat;
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		long A,B,K,n;
		do {
			A = stdIn.nextLong();
			B = stdIn.nextLong();
			K = stdIn.nextLong();
		}while(A<0||A>Math.pow(10, 12)||B<0||B>Math.pow(10, 12)||K<0||K>Math.pow(10, 12));
		if(A>K) {
			A -=K;
		}else {
			if((B-(K-A))<0){
				B = 0;
			}else {
				B -=(K-A);
			}
			A = 0;
		}
		System.out.println(A+" "+B);
		}
}


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

#define rep(i, j, n) for(int i=j;i<n;++i)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9
const int mod = 1e9 + 7;

typedef long long i64;
typedef pair<int, int> pi;

template <class T> using vt = vector<T>;
template <class T> using vvt = vector<vector<T>>;

i64 gcd(i64 n, i64 m) {return (m == 0? n : gcd(m, n % m));}
i64 lcm(i64 n, i64 m) {return (n / gcd(n, m) * m);}
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};

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

  int n;
  cin >> n;
  vt<int> t(n);
  int num = 0;
  rep(i, 0, n) {
    cin >> t[i];
    num = max(num, t[i]);
  }

  vt<int> ret;
  rep(i, 1, num + 1) {
    if(num % i == 0) ret.push_back(i);
  }

  int ans = 0;
  rep(i, 0, n) {
    ans += *lower_bound(all(ret), t[i]) - t[i];
  }
  cout << ans << endl;
}



Measured memory_bytes: 3304
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

  
using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<pii>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define re(n) for (int i = 0; i < n; ++i)
#define rep(i,a,b) for (int i = a; i < b; ++i)
#define eb emplace_back

//OutPut
#define ps(x) cout << x << endl;
#define ps_end(x) {ps(x); return;}


const int md = 1e9 + 7; //998244353 ;
const int dir[4][2] = {{-1,0}, {1, 0}, {0, -1}, {0, 1}};
template<class T> bool ckmin(T& a, const T& b) { 
  return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { 
  return a < b ? a = b, 1 : 0; }
ll pw(auto x, auto y) {  ll s = 1; while(y) { if (y & 1) s = s * x % md; x= 1LL * x * x % md; y /= 2; } return s;}

const int maxn = 1e6 + 10;

int n, m, nq, nk;
string str;

void task() {
  cin >> str;
  vector<char> a = {'s'};
  for (auto ch : a)
    if (str[str.size() - 1]== ch) {
      cout << str + "es" << endl;
      return;
    }
  cout << str + "s" << endl;
  
  //Read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  int T = 1;
 // cin >> T;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
  * int overflow, array bounds
  * special cases (n=1?)
  * do smth instead of nothing and stay organized
  * write down
*/


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






fn main() {
    let (n, k) = {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let mut sp = s.split_whitespace().map(|x| x.parse::<u64>().unwrap());
        (sp.next().unwrap(), sp.next().unwrap())
    };

    println!("{}", std::cmp::min(n % k, k - (n % k)));
}


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

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

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

	constexpr int dx[] = {-1, 0, 1, 0};
	constexpr int dy[] = {0, 1, 0, -1};

	int dir[128];
	dir['L'] = 0;
	dir['D'] = 1;
	dir['R'] = 2;
	dir['U'] = 3;
	
	for(int HP_init, HP_max; cin >> HP_init >> HP_max && HP_init;) {
		int h, w;
		cin >> h >> w;

		vector<string> field(h);
		for(auto &e : field) cin >> e;

		int t;
		cin >> t;

		int damage[128] = {};
		for(int i = 0; i < t; ++i) {
			char c;
			int d;
			cin >> c >> d;
			damage[c] = d;
		}

		int s;
		cin >> s;

		vector<int> moves;
		vector<pair<int, int>> pos{{0, 0}};

		moves.reserve(1000);
		pos.reserve(1001);

		for(int i = 0; i < s; ++i) {
			char c;
			int n;
			cin >> c >> n;

			const int d = dir[c];

			for(int j = 0; j < n; ++j) {
				const int x = pos.back().first + dx[d];
				const int y = pos.back().second + dy[d];
				moves.emplace_back(d);
				pos.emplace_back(x, y);
			}
		}

		int p;
		cin >> p;

		vector<int> potions(p);
		for(auto &e : potions) cin >> e;

		const int number_of_steps = moves.size();
		vector<vector<int>> dp(number_of_steps + 1, vector<int>(1 << p, 0));
		dp[0][0] = HP_init;

		for(int i = 0; i < number_of_steps; ++i) {
			const int d = moves[i];
			const int x = pos[i].first;
			const int y = pos[i].second;

			const int dec = damage[field[y + dy[d]][x + dx[d]]];

			for(int used = 0; used < (1 << p); ++used) {
				if(dp[i][used] == 0) continue;

				chmin(dp[i][used], HP_max);
				for(int j = 0; j < p; ++j) {
					if(!(used & (1 << j))) {
						chmax(dp[i][used | (1 << j)], dp[i][used] + potions[j]);
					}
				}

				chmax(dp[i + 1][used], dp[i][used] - dec);
			}
		}

		cout << (dp[number_of_steps][(1 << p) - 1] > 0 ? "YES" : "NO") << endl;
	}
}

Measured memory_bytes: 17188
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = (ll)(n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORD(i, a, b) for (ll i = (a); i >= (b); i--)
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007    //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

// debug
#define DEBUG(x) cout << #x << ": " << x << endl
#define DEBUG2(x, y) cout << #x << ": " << x << " " << #y << ": " << y << endl
#define DEBUG_VEC(v)   \
  cout << #v << ":";   \
  REP(i, v.size())     \
  cout << " " << v[i]; \
  cout << endl
#define DEBUG_ARR(v, n) \
  cout << #v << ":";    \
  REP(i, n)             \
  cout << " " << v[i];  \
  cout << endl

signed main()
{
  ll N;
  map< string, ll > strmap;
  ll max_count = 0;

  cin >> N;
  REP(i, N)
  {
    string str;
    cin >> str;

    ll next_count = (strmap[str] ? strmap[str] : 0) + 1;
    max_count = max(max_count, next_count);
    strmap[str] = next_count;
  }

  queue< string > sorted_strs;
  for (auto m : strmap)
  {
    if (m.second == max_count)
    {
      sorted_strs.push(m.first);
    }
  }

  while (!sorted_strs.empty())
  {
    auto str = sorted_strs.front();
    sorted_strs.pop();

    cout << str << endl;
  }
}

Measured memory_bytes: 26880
/**
 * @author torith
 * @date 2018-10-24
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,Y;
    cin >> N >> Y;

    int tmp = Y / 1000 - N;
    bool ans = false;
    for (int i = 0; 9 * i <= tmp; ++i) {
        int hm = (tmp - 9 * i);
        if(hm % 4 == 0 && (N - hm/4 - i) >= 0){
            cout << i << " " << hm/4 << " " << (N - hm/4 - i) << "\n";
            return 0;
        }
    }
    cout << "-1 -1 -1" << "\n";

    return 0;
}



Measured memory_bytes: 256
ans = 0
s = {}
N = int(input())
for i in range(N):
	tmp = []
	string = input()
	for st in string:
		tmp.append(st)
	tmp.sort()
	stmp = ''.join(tmp)
	if stmp in s and s[stmp] > 0:
		ans += s[stmp]
		s[stmp] = s[stmp]+1
	else:
		s[stmp] = 1
print(ans)

Measured memory_bytes: 17892
#define _USE_MATH_DEFINES    
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <complex>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <tuple>
#include <bitset>
#include <limits>
#include <algorithm>
#include <array>
#include <random>
#include <complex>
#include <regex>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define quickIO()   {cin.tie(0);    cout.sync_with_stdio(false);}
#define rep(i,n)    for(ll i=0; i<(ll)n; i++)
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define fcout cout << fixed << setprecision(10) 
const ll inf = 1e18;
const ll mod = 1e9 +7;
     
ld sqrtld(ld x){
    ld left = 0, right = x;
    rep(i, 100){
        ld mid = (left + right)/2;
        if (mid*mid <= x)   left =mid;
        else    right = mid;
    }
    return left;
}

ll gcd(ll a, ll b){
    if(b>a){
        ll c =b; b=a;   a=c;
    }
    ll d = a%b;
    if(d==0){
        return b;
    }else if(d==1){
        return 1;
    }else{
        gcd(b,d);
    }
}


ll cul(ll n){
    return (n-1)*n/2;
}


int main (){
    ll n, a, b;
    cin >> n >> a >> b;
    string s;
    if( (b-a)%2==0 ){
        s = "Alice";
    }else{
        s = "Borys";
    }

    cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
using System;

namespace atcoder_ABC048B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
			string[] array = Console.ReadLine().Split(' ');
			ulong startNumber = ulong.Parse(array[0]);
			ulong endNumber = ulong.Parse(array[1]);
			ulong x = ulong.Parse(array[2]);

			ulong untilEnd = endNumber / x;
			ulong untilStart = startNumber / x;

			ulong resultCount = untilEnd - untilStart;
			if (startNumber % x == 0)
			{
				resultCount++;
			}

			Console.WriteLine(resultCount);
        }
    }
}


Measured memory_bytes: 13140