akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
using ll = long long int;

int main() {
  ll a, b;
  cin >> a >> b;
  
  ll sum = -1;
  for (ll i = 0; i < 1e9; i++) {
    if (abs(a-i) == abs(b-i)) {
      sum = i;
      break;
    }
  }

  if (sum == -1){cout << "IMPOSSIBLE" << endl;}
  else {cout << sum << endl; }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
int main(){
    int n;
    int w_r=0,e_r=0,w_l=0,e_l=0;
    string s;
    int ans= 1000000;
    int change;
    cin >> n >> s;
    rep(i,n){
        if(s[i] == 'W')w_r++;
        if(s[i] == 'E')e_r++;
    }
    rep(i,n){
        change = 0;
        if(s[i] == 'W')w_r--;
        else e_r--;
        //cout << w_r << " " << e_r << endl;
        change += w_l;
        change += e_r;
        ans = min(ans,change);
        if(s[i] == 'W') w_l++;
        else e_l++;
    }
    cout << ans << endl;
    
}

Measured memory_bytes: 900
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

immutable mod = 10^^9 + 7;
immutable inf = 10^^9 + 7;

void main() {
    int n;
    int[] a;
    scan(n);
    a = readln.split.to!(int[]);

    auto cnt = new int[](200000);

    foreach (ai ; a) {
        cnt[ai]++;
    }

    int ans;

    foreach (i ; 0 .. 100000) {
        int b = cnt[i] + cnt[i + 1] + cnt[i + 2];
        ans = max(ans, b);
    }

    writeln(ans);
}



void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}



void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
} 

Measured memory_bytes: 4144
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define pi acos(-1.0)
const ll INF = 1LL<<61;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
ll jou(ll N, ll P){if(P==0) return 1;
  if(P%2==0){ll t = jou(N, P/2);return t*t % mod;
  }return (N * jou(N, P-1)) % mod;}  //jou(n,mod-2)で逆元
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる




int main() {
  string s;
  cin>>s;
  int n=s.size();
  
  int ans=1000000;
  rep(i,n){
    char x=s[i];
    int kai=0;
    int cnt=0;
    rep(j,n){
      if(s[j]!=x) cnt++;
      else{
        kai=max(kai,cnt);
        cnt=0;
      }
    }
    kai=max(kai,cnt);
    ans=min(ans,kai);
  }

  cout << ans << endl;

}


Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(ll i = 0; i < (n); ++i)
# define reps(i, n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(ll i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(ll i=((int)(n)); i>0; --i)
# define ll long long
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define P pair<int, int>
# define mp make_pair
using namespace std;
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; }
ll lmax(ll a, ll b){if(a>= b) return a;return b;}
ll lmin(ll a, ll b){if(a>= b) return b;return a;}

int main() {
  int n; cin >> n;
  vector<ll> v(n);
  rep(i, n) cin >> v[i];

  int ans = 0, cnt = 0;
  rep(i, n-1){
    if(v[i]>=v[i+1]) cnt++;
    else {
      chmax(ans, cnt);
      cnt = 0;
    }
  }
  chmax(ans, cnt);
  cout << ans << endl;
}


Measured memory_bytes: 3944
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

signed main() {
  ll H, W;
  cin >> H >> W;
  string S[H][W];
  ll mapMap[H][W];
  // ll mapMap2[H][W];

  vector<P> starts;
  rep(i, H) {
    string s;
    cin >> s;
    rep(j, W) {
      char c = s[j];
      if (c == '.') {
        starts.pb({i, j});
      }
      S[i][j] = c;
      mapMap[i][j] = 0;
      // mapMap2[i][j] = 0;
    }
  }

  ll max = 0;
  for (P start : starts) {
    queue<pair<P, ll>> q;
    q.push({start, 0});
    ll tMax = 0;

    rep(i, H) {
      rep(j, W) {
        mapMap[i][j] = 0;
      }
    }
    while (!q.empty()) {
      pair<P, ll> qq = q.front();
      P p = qq.first;
      ll before = qq.second;
      q.pop();

      if (p.first < 0 || H <= p.first) {
        continue;
      }

      if (p.second < 0 || W <= p.second) {
        continue;
      }

      if (mapMap[p.first][p.second] == 1) {
        continue;
      }

      if (S[p.first][p.second] == "#") {
        continue;
      } else {
        mapMap[p.first][p.second] = 1;
        if (tMax < before + 1) {
          tMax = before + 1;
        }
        q.push({{p.first + 1, p.second}, before + 1});
        q.push({{p.first - 1, p.second}, before + 1});
        q.push({{p.first, p.second + 1}, before + 1});
        q.push({{p.first, p.second - 1}, before + 1});
      }
    }
    if (max < tMax) {
      max = tMax;
    }
  }
  COUT(max - 1);

  return 0;
}

Measured memory_bytes: 256
s = input()
d={'a':0,'b':0,'c':0,}
for i in s:
    d[i] += 1
a=d['a']
b=d['b']
c=d['c']
if abs(a-b) > 1:
    print('NO')
    exit()
if abs(a-c) > 1:
    print('NO')
    exit()
if abs(c-b) > 1:
    print('NO')
    exit()
print('YES')

Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
ll n;
//ld ;
//string s,t,u;
// char c;

int main() {
  cin >> n;
  ll ans = (n%2==0)?n/2:n/2+1;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
h,w = map(int,input().split())
ans = float("Inf")
if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()
for i in range(1,h):
    a = (h-i)*(w//2)
    b = (h-i)*-(-w//2)
    ans = min(ans,abs(max(i*w,a,b)-min(i*w,a,b)))
for i in range(1,w):
    a = (w-i)*(h//2)
    b = (w-i)*-(-h//2)
    ans = min(ans,abs(max(i*h,a,b)-min(i*h,a,b)))
print(min(ans,h,w))

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

#define fastIO      ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define asc(s)      sort(s.begin(), s.end())
#define des(s)      sort(s.rbegin(), s.rend())
#define pb(x)       push_back(x)
#define mp(x, y)    make_pair(x, y)
#define all(v)      v.begin(), v.end()
#define rev(v)      reverse(v.begin(), v.end())
#define lower(s)    transform(s.begin(), s.end(), s.begin(), ::tolower);
#define upper(s)    transform(s.begin(), s.end(), s.begin(), ::toupper);
#define MOD         1000000007
#define PI          3.14159265358979

typedef long long ll;

template <typename TH>
void _dbg(const char *sdbg, TH h) { cerr << sdbg << "=" << h << "\n"; }
template <typename TH, typename... TA>
void _dbg(const char *sdbg, TH h, TA... t)
{
    while (*sdbg != ',')
    {
        cerr << *sdbg++;
    }
    cerr << "=" << h << ",";
    _dbg(sdbg + 1, t...);
}

#ifndef ONLINE_JUDGE
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug
#endif

template <class T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

template <class T>
T lcm(T a, T b) { return a * b / gcd(a, b); }

vector<string> split(string s)
{
    istringstream buf(s);
    istream_iterator<string> beg(buf), end;
    vector<string> list(beg, end);
    return list;
}

bool isvowel(char c)
{
    string s = "aeiouAEIOU";
    if (find(s.begin(), s.end(), c) != s.end())     return true;
    return false;
}

vector <ll> sieve(ll n)
{
    vector<bool> prime(n + 1, true);
    prime[0] = prime[1] = 0;

    for (int i = 2; i * i <= n; i++)
    {
        if (prime[i])
            for (int j = i * i; j <= n; j += i)
            {
                prime[j] = 0;
            }
    }

    vector <ll> p;

    for(int i=2; i<=prime.size();i++)
        if(prime[i])
            p.pb(i);
    
    return p;        
}

bool isprime(int n)
{
    for(int i=2;i*i<=n;i++)
    {
        if(n%i==0)
            return false;
    }

    return true && (n!=1);
}

int ncr(ll n, ll r) 
{ 
    ll C[r+1]; 
    memset(C, 0, sizeof(C)); 

    C[0] = 1; 

    for (ll i = 1; i <= n; i++) 
    { 
        for (ll j = min(i, r); j > 0; j--) 
            // nCj = (n-1)Cj + (n-1)C(j-1); 
            C[j] = (C[j] + C[j-1])%MOD; 
    } 

    return C[r]; 
}

bool special(string s)
{
    for(int i=0;i<s.size();i++)
    {
        if(s[i] == ' ')
            continue;
        
        if(s[i] == '#')
            return true;
        
        else
            return false;
    }
    return false;
}

vector <ll> ans;

bool cmp(string &a, string &b)
{
    return (a.size() < b.size() )|| (a.size() == b.size() && a < b);
}

void solve()
{
    ll n;
    cin >> n;

    vector <ll> v;

    for(ll i=1;i<=9;i++)
        v.pb(i);

    int j = 0;

    while(v.size() < n)
    {
        ll cur = v[j++];

        ll start = cur%10;

        for(ll i=max(0ll,start-1); i<=min(9ll, start+1);i++)
        {
            v.pb(cur*10 + i);
        }
    }

    

    asc(v);
    cout << v[n-1];

}

int main()
{
    fastIO
    


    int t = 1;
    // cin >> t;

    for(int i=1;i<=t;i++)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 1400
// B - Minesweeper
#include <bits/stdc++.h>
using namespace std;

int H,W;
string S[50];
string ans[50];

int check(int i,int j);
int calcnum(int i,int j);
int solve();


int main() {

  cin >> H >> W;
  for(int i =0; i< H; i++){
    cin >> S[i];
  }

  solve();

  for(int i =0; i< H; i++){
    cout << ans[i] << endl;
  }
}

int solve(){
  for(int i = 0; i<H; i++){
    for(int j =0; j <W; j++){
      if(S[i].at(j) == '#'){
        ans[i] += '#';
      }else{
        ans[i] += to_string(calcnum(i,j));
      }
    }
  }
  return 0;
}

int calcnum(int i,int j){
  return check(i-1, j-1) +check(i-1, j) +check(i-1, j+1) +check(i, j-1) +check(i, j) +check(i, j+1) +check(i+1, j-1) +check(i+1, j) +check(i+1, j+1);

}




int check(int i,int j){

  if(0<=i && i<H && 0<=j && j<W){
    char s = S[i].at(j);
    if(s == '#'){
      return 1;
    }
  }

  return 0;

}


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

void solve()
{

    for(int i = 0; i<5; i++)
    {
        int c;
        cin >> c;
        if(c == 0)
            cout << i+1 << endl;
    }
}


int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll t;
    solve();
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main(void){
  int N,K;

  cin >> N >> K;

  vector<int> h(N);
  for(int i = 0;i < K;i++){
    int d,tmp;
    cin >> d;
    for(int j=0;j < d;j++){
      int index;
      cin >> index;
      h[index-1] = 1;
    }
  }

  int total = 0;
  for(int i=0;i < N;i++){
    if(h[i] == 0)total++;
  }

  cout << total;

  return 0;
}

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

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

  int N, a, min_num = 200001, ans = 0;
  cin >> N;

  for (int i = 0; i < N; i++)
  {
    cin >> a;
    if (min_num >= a)
    {
      min_num = a;
      ans++;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

int main() {
  int n, m;
  cin >> n >> m;
  vector<set<int>> a(n);
  for (int i = 0; i < m; ++i) {
    int b, c;
    cin >> b >> c;
    a[b - 1].insert(c - 1);
    a[c - 1].insert(b - 1);
  }
  deque<int> d;
  vector<bool> seen;
  int summ=0;
  seen.assign(n, false);
  int v;
  int count=0;
  for(int j=0;j<n;++j){
    v=j;
    if(seen[v])continue;
    count=0;
    seen[v] = true;
    while (1) {
      ++count;
      for (auto i:a[v]) {
        if(!seen[i])d.push_back(i);
        seen[i]=true;
      }
      if (!d.empty()) {
        v = d.front();
        d.pop_front();
//        cout<<v<<" "<<count<<endl;
      }else {
        break;
      }
    }
    summ=max(summ,count);
  }
  cout<<summ<<endl;
}

Measured memory_bytes: 31624
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.*;
import java.awt.Point;

public class Main {
    // static int INF = (1 << 30) - 1;
    // static long L_INF = (1L << 62) - 1;
    // static long MOD = (long) 1e9 + 7;

    static class Solver {
        int N, Q;
        ArrayList<Integer>[] g;
        int[] x;
        int[] ans;
        boolean[] visited;

        void dfs(int v, int before) {
            if (visited[v]) {
                return;
            }
            visited[v] = true;
            ans[v] += x[v];
            if (before != -1) {
                ans[v] += ans[before];
            }
            for (int i = 0; i < g[v].size(); i++) {
                dfs(g[v].get(i), v);
            }
        }

        // write your code
        void solve(InputReader in, PrintWriter out) {
            N = in.nextInt();
            Q = in.nextInt();
            g = new ArrayList[N];
            for (int i = 0; i < N; i++) {
                ArrayList<Integer> al = new ArrayList<>();
                g[i] = al;
            }
            for (int i = 0; i < N - 1; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;
                g[a].add(b);
                g[b].add(a);
            }
            x = new int[N];
            for (int i = 0; i < Q; i++) {
                int pi = in.nextInt() - 1;
                int xi = in.nextInt();
                x[pi] += xi;
            }
            ans = new int[N];
            visited = new boolean[N];
            dfs(0, -1);
            for (int i = 0; i < N; i++) {
                if (i != 0) {
                    out.print(" ");
                }
                out.print(ans[i]);
            }
            out.println();
        }

        void debug(Object... os) {
            System.err.println(Arrays.deepToString(os));
        }
    }

    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Solver solver = new Solver();
        solver.solve(in, out);
        out.close();
    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer tokenizer;

        InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

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

        long nextLong() {
            return Long.parseLong(next());
        }
    }
}


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

using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, a, b) for (int64_t i = (a); i < (b); ++i)
const int MOD = 1e9 + 7;
typedef long long ll;
const long long INF = 1LL << 60;
using Graph = vector<vector<int>>;

int main() {
  int k, x;
  cin >> k >> x;
  if (x <= k * 500)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 764
if !ENV['RUBY_THREAD_VM_STACK_SIZE']
	#require 'rbconfig';RUBY=File.join(RbConfig::CONFIG['bindir'],RbConfig::CONFIG['ruby_install_name'])
	require 'rubygems';RUBY=Gem.ruby
	exec({'RUBY_THREAD_VM_STACK_SIZE'=>'100000000'},RUBY,$0)
end

def dfs(r, ac, now, c)
  ac[now] = c
  r[now].each{|t|
    if ac[t] == 0 then
      dfs(r, ac, t, c+1)
    end
  }
end
 
N = gets.to_i
 
r = N.times.map{[]}
(N-1).times{
  a,b = gets.split.map(&:to_i)
  r[a-1] << b-1
  r[b-1] << a-1
}
 
fc = Array.new(N, 0)
sc = Array.new(N, 0)
 
dfs(r, fc, 0, 1)
dfs(r, sc, N-1, 1)
 
f = 0
N.times{|i|
  f += 1 if fc[i] <= sc[i]
}
 
puts (f>N-f)?"Fennec":"Snuke"
 

Measured memory_bytes: 220860
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
#include <string>
using namespace std;
int main(void){
    int n ;
    string a ;
    cin >> n >> a ;

    size_t b = a.length() ;

    for(int i = 0 ; i < b ; i++ ){
        if(a[i] + n > 'Z' ){
           a[i] = 'A' + (a[i] + n -1- 'Z') ;
        }else{
           a[i] = a[i] + n ;
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 256
import bisect, collections, copy, heapq, itertools, math, numpy, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

mod = 10 ** 9 + 7
N, K = MI()
def num(self):
    return (-2 * pow(self, 3) + 3 * N * pow(self, 2) + (3 * N + 8) * self) // 6
ans = num(N + 1) - num(K - 1)
print(ans % mod)

Measured memory_bytes: 27092
import sys
input = sys.stdin.readline


def main():
    n = int(input())
    list1 = [v*1 for v in range(1, 10)]
    list2 = [v*2 for v in range(1, 10)]
    list3 = [v*3 for v in range(1, 10)]
    list4 = [v*4 for v in range(1, 10)]
    list5 = [v*5 for v in range(1, 10)]
    list6 = [v*6 for v in range(1, 10)]
    list7 = [v*7 for v in range(1, 10)]
    list8 = [v*8 for v in range(1, 10)]
    list9 = [v*9 for v in range(1, 10)]
    if n in list1 or n in list2 or n in list3 or n in list4 or n in list5 or n in list6 or n in list7 or n in list8 or n in list9:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>

using namespace std;

#define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);

typedef long long ll;
typedef long double ld;



int main() {
	fastInp;

	ll n, d;
	cin >> n >> d;
	vector<ll> vec(n);
	vector<ll> dists(n + 1), mn(n + 1);
	ll curMn = 1;
	dists[0] = d;
	mn[n] = 1;
	for (int i = 0; i < n; i++) cin >> vec[i];

	for (int i = 0; i < n; i++) {
		dists[i + 1] = min(dists[i], abs(dists[i] - vec[i]));
	}

	for (int i = n - 1; i >= 0; i--) {
		if (curMn <= vec[i] / 2) {

		}
		else {
			curMn += vec[i];
		}
		mn[i] = curMn;
	}
	ll q;
	cin >> q;

	while (q--) {
		ll nm;
		cin >> nm;
		nm--;
		if (mn[nm + 1] <= dists[nm]) {
			cout << "YES\n";
		}
		else {
			cout << "NO\n";
		}
	}

	return 0;
}

Measured memory_bytes: 15060
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=1e5,M=1e7+1;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}

int n;
int match[N],pre[N],q[N],vis[N],cnt;
int x[N];vector<int>e[N];

inline bool bfs(int k) {
	queue<int>q;
	++cnt;q.push(k);
	while (!q.empty()) {
		k=q.front();q.pop();
		for (int t:e[k]) if (vis[t]!=cnt) {
				if (match[t]) {
					vis[t]=cnt;
					pre[match[t]]=k;
					q.push(match[t]);
				} else {
					int p;
					while (k) {
						p=match[k];
						match[k]=t,match[t]=k;
						t=p,k=pre[k];
					}
					return true;
				}
			}
	}
	return false;
}

int pri[M];
bool in[M];
inline void init(int n) {
	int i,j,len=0;
	for (i=2;i<=n;i++) {
		if (!pri[i]) pri[++len]=i,in[i]=i!=2;
		for (j=1;j<=len&&i*pri[j]<=n;j++) {
			pri[i*pri[j]]=1;
			if (!(i%pri[j])) break;
		}
	}
}
int main()
{
	n=gi();int i,j,odd=0,s=0,m=0;
	for (i=1;i<=n;i++) x[++m]=gi(),x[m+1]=x[m]+1,m++;
	sort(x+1,x+1+m);
	for (i=1,n=0;i<=m;i++) if (x[i]==x[i+1]) i++; else x[++n]=x[i];
	
	init(x[n]-x[1]);

	for (i=1;i<=n;i++)
		if (x[i]&1) {
			odd++;
			for (j=1;j<=n;j++)
				if (in[abs(x[j]-x[i])])
					e[i].push_back(j);
		}
	for (i=1;i<=n;i++) if (x[i]&1) s+=bfs(i);

	cout<<n-s+((s-odd)&1);
	return 0;
}


Measured memory_bytes: 51584
x,y = map(int,input().split())

for i in range(x+1):
    for j in range(x-i+1):
            if (i*10000 + j*5000 + (x-i-j)*1000) == y:
                print(i,j,x-i-j)
                exit()
print("-1 -1 -1")


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>

using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;

const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int MOD = 1e9 + 7; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {
	
	
	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	int N;
	ll A, B;
	cin >> N >> A >> B;
	vll X(N);
	for (int i = 0; i < N; i++) {
		cin >> X[i];
	}

	ll base = B / A;//移動距離がこれより大きければテレポート

	ll ans = 0;
	ll now = X[0];
	for (int i = 1; i < N; i++) {

		ll dis = X[i] - now;
		if (dis > base) {
			ans += B;
		}
		else {
			ans += dis * A;
		}
		now = X[i];


	}

	cout << ans << endl;



}




Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    int ans = 10000;
    REP(i,s.size()-2){
        string sub = s.substr(i,3);
        int x = atoi(sub.c_str());
        int v = abs(753 - x);
        ans = min(ans, v);
    }
    PUTS(ans);
}

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

const int INF = 1e9;

int main() {
    string s;
    cin>>s;
    int a = (s[0] -'0') * 10 + (s[1] - '0');
    int b = (s[2] -'0') * 10 + (s[3] - '0');
    if (a > 0 && a <= 12) {
        if (b > 0 && b <= 12) {
            cout<<"AMBIGUOUS"<<endl;
        } else {
            cout<<"MMYY"<<endl;
        }
    } else if (b > 0 && b <= 12) {
        cout<<"YYMM"<<endl;
    }  else {
        cout<<"NA"<<endl;
    }

}

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

using namespace std;

const int MAX_V = 15;
const int INF = 1<<28;

int G[MAX_V][MAX_V];

int V, E;
int memo[MAX_V][MAX_V][1 << MAX_V];
void init() {
    memset(memo, -1, sizeof(memo));
}
int dfs(int s, int v, int used) {
    if (used == (1 << V) - 1) return G[v][s];
    if (memo[s][v][used] >= 0) return memo[s][v][used];
    int ret = INF;
    for (int u = 0; u < V; u++) {
        if (v == u || G[v][u] == INF || (used & (1 << u))) continue;
        ret = min(ret, dfs(s, u, used | (1 << u)) + G[v][u]);
    }
    return memo[s][v][used] = ret;
}
int TSP() {
    int ret = INF;
    init();
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) {
            if (i == j) continue;
            ret = min(ret, dfs(i, j, (1 << i) | (1 << j)) + G[i][j]);
        }
    }
    return ret;
}

int main() {
    cin >> V >> E;
    for (int i = 0; i < V; i++) {
        for (int j = 0; j < V; j++) G[i][j] = INF;
        G[i][i] = 0;
    }
    for (int i = 0; i < E; i++) {
        int s, t, d;
        cin >> s >> t >> d;
        G[s][t] = d;
    }
    int Ans = TSP();
    cout << (Ans == INF ? -1 : Ans) << endl;
    return 0;
}

Measured memory_bytes: 29972
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
using namespace std;
typedef pair<int,int> P;
double dat[100][100];
int dp[6][1010];//動的計画法
int prime[10000001];
char str[1010][1010];
vector<pair<int,int> > pc[100001];
int ABS(int a){return max(a,-a);}
int main(){
	int w,h,n;
	int x,y,a;
	cin>>w>>h>>n;
	int x1=0,x2=w,y1=0,y2=h;
	for(int i=0;i<n;i++){
		cin>>x>>y>>a;
		if(a==1){
			if(x1<x) x1=x;
		}else if(a==2){
			if(x2>x) x2=x;
		}else if(a==3){
			if(y1<y) y1=y;
		}else{
			if(y2>y) y2=y;
		}
	}
	if((x2-x1)<=0||(y2-y1)<=0) cout<<0<<endl;
	else cout<<(x2-x1)*(y2-y1)<<endl;
	return 0;
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
//double pi=3.1415926535898;
//double pi=acos(-1.0);
#define scarr(a,s,e) for(int i=s;i<=int(e);i++) scanf("%d ",&a[i]);
#define prarr(a,s,e) for(int i=s;i<=int(e);i++) printf("%d ",a[i]);
#define speed      ios::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
#define rng(i,a,b) for(int i=a;i>=int(b);i--)
#define rep(i,a,b) for(int i=a;i<=int(b);++i)
#define lop(i,n)   for(int i=0;i<int(n);i++)
#define ms(x,a)    memset(x,a,sizeof(x))
#define all(x)     (x).begin(),(x).end()
#define sz(x)      int(x.size())
#define pb         push_back
#define mkp        make_pair
#define sc(x)      scanf("%d",&x)
#define scl(x)     scanf("%lld",&x)
#define pr(x)      printf("%d ",x)
#define prl(x)     printf("%lld ",x)
#define prln(x)    printf("%d\n",x)
#define prlln(x)   printf("%lld\n",x)
#define r0         return 0;
#define CC         continue;
#define scd(x)     scanf("%lf",&x)
#define prd(x)     printf("%.10f\n",x);
#define bb(x)      cerr<< x <<endl;
#define ii         pair<int,int>
#define vi         vector<int>
#define fr         first
#define se         second
//#define max(a,b) a<b?b:a
//#define min(a,b) a<b?a:b
const ll M   = 1e7+9 ;
const ll inf = 1e19  ;
const int si = 1e5+9 ;
//////////////////////    Hi    ^_^  hack me if you can :P

int k,n,t;
int main()
{
    string s;
    cin >>s >>k;
    n=sz(s);
    lop(i,n)
    {
        if(s[i]=='a')
            continue;
        t='z'-s[i]+1;
        if (t<=k)
        {
            s[i]='a';
            k-=t;
        }
    }
    if(k)
    {
        k%=26;
        t=s[n-1]-'a'+k;
        t%=26;
        s[n-1]='a'+t;
    }
    cout<<s;
    r0;
}

/*

ll pwmod(ll a, ll n, ll mod) {
    ll ret = 1;
    while (n) {
        if (n & 1) ret = ret * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return ret;
}

*/
/*
freopen("output.txt","w",stdout);
freopen("input.txt","r",stdin);
for (int i=0;i<n;i++)            Hi    ^_^  hack me if you can :P
int mx[]= {0,0,1,1,1,-1,-1,-1};
int my[]= {1,-1,0,1,-1,0,1,-1};
bool inside (int i,int j) {return (i>=0 && i<n && j>=0 && j<m);}
*/


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

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner(System.in);
		PrintWriter pw = new PrintWriter(System.out);
		int[] line = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
		int n = sc.nextInt();
		pw.print(line[n-1]);
		pw.close();

	}

	static class FastScanner {
		private BufferedReader reader = null;
	    private StringTokenizer tokenizer = null;
	    public FastScanner(InputStream in) {
	        reader = new BufferedReader(new InputStreamReader(in));
	        tokenizer = null;
	    }

	    public String next() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                tokenizer = new StringTokenizer(reader.readLine());
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }
	        return tokenizer.nextToken();
	    }

	    public String nextLine() {
	        if (tokenizer == null || !tokenizer.hasMoreTokens()) {
	            try {
	                return reader.readLine();
	            } catch (IOException e) {
	                throw new RuntimeException(e);
	            }
	        }

	        return tokenizer.nextToken("\n");
	    }

	    public long nextLong() {
	        return Long.parseLong(next());
	    }

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

	    public double nextDouble() {
	         return Double.parseDouble(next());
	     }

	    public int[] nextIntArray(int n) {
	        int[] a = new int[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextInt();
	        return a;
	    }

	    public long[] nextLongArray(int n) {
	        long[] a = new long[n];
	        for (int i = 0; i < n; i++)
	            a[i] = nextLong();
	        return a;
	    }
	}
}

Measured memory_bytes: 21204
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define srep(i,s,t) for(int i=(int)(s);i<(int)(t);++i)
#define each(a,b) for(auto& (a): (b))
#define all(v) (v).begin(),(v).end()
#define len(v) (int)(v).size()
#define zip(v) sort(all(v)),v.erase(unique(all(v)),v.end())
#define cmx(x,y) x=max(x,y)
#define cmn(x,y) x=min(x,y)
#define fi first
#define se second
#define pb push_back
#define show(x) cout<<#x<<" = "<<(x)<<endl
#define sar(a,n) cout<<#a<<":";rep(pachico,n)cout<<" "<<a[pachico];cout<<endl

using namespace std;

template<typename S,typename T>auto&operator<<(ostream&o,pair<S,T>p){return o<<"{"<<p.fi<<","<<p.se<<"}";}
template<typename T>auto&operator<<(ostream&o,set<T>s){for(auto&e:s)o<<e<<" ";return o;}
template<typename S,typename T,typename U>
auto&operator<<(ostream&o,priority_queue<S,T,U>q){while(!q.empty())o<<q.top()<<" ",q.pop();return o;}
template<typename K,typename T>auto&operator<<(ostream&o,map<K,T>m){for(auto&e:m)o<<e<<" ";return o;}
template<typename T>auto&operator<<(ostream&o,vector<T>v){for(auto&e:v)o<<e<<" ";return o;}
void ashow(){cout<<endl;}template<typename T,typename...A>void ashow(T t,A...a){cout<<t<<" ";ashow(a...);}

typedef pair<int,int> P;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<P> vp;
typedef vector<double> vd;
typedef vector<string> vs;

const int MAX_N = 100005;

set<P> st;
vector<int> G[MAX_N];

bool dfs(int u, int p, int t)
{
    if(t == u) return true;
    each(v, G[u]){
        if(st.find(P(min(u, v), max(u, v))) == st.end() && v != p){
            st.insert(P(min(u, v), max(u, v)));
            if(dfs(v, u, t)) return true;
        }
    }
    return false;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        G[a-1].pb(b-1), G[b-1].pb(a-1);
    }
    vi hoge, vec;
    rep(i,n){
        if(len(G[i]) % 2){
            cout << "No\n";
            return 0;
        }else if(len(G[i]) >= 6){
            hoge.pb(i);
        }else if(len(G[i]) == 4){
            vec.pb(i);
        }
    }
    if(len(hoge) >= 1){
        cout << "Yes\n";
        return 0;
    }
    if(len(vec) <= 1){
        cout << "No\n";
        return 0;
    }else if(len(vec) >= 3){
        cout << "Yes\n";
        return 0;
    }
    if(!dfs(vec[0],-1,vec[1])){
        cout << "Yes\n";
        return 0;
    }
    if(!dfs(vec[0],-1,vec[1])){
        cout << "Yes\n";
        return 0;
    }
    if(!dfs(vec[0],-1,vec[1])){
        cout << "Yes\n";
        return 0;
    }
    if(!dfs(vec[0],-1,vec[1])){
        cout << "Yes\n";
        return 0;
    }else{
        cout << "No\n";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 13952
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	vector<int> A;
	int N;

	cin >> N;

	for(int i = 2; i <= 100005; i++){
		bool ok = true;
		for(auto a = A.begin(); a != A.end(); a++){
			if(i % (*a) == 0) {
				ok = false;
				break;
			}
		}
		if(ok) {
			A.pb(i);
			if(i >= N ) break;
		}
	}

	cout << A[A.size() - 1] << endl;

	Never To return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

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

  int gx, gy;

  switch (x) {
  case 4:
  case 6:
  case 9:
  case 11:
    gx = 1;
    break;
  case 2:
    gx = 2;
    break;
   default:
     gx = 0;
    break;
  }

  switch (y) {
  case 4:
  case 6:
  case 9:
  case 11:
    gy = 1;
    break;
  case 2:
    gy = 2;
    break;
  default:
    gy = 0;
    break;
  }

  if (gx == gy) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
N=int(input())
A=list(map(int, input().split()))
B=list(map(int, input().split()))
C=list(map(int, input().split()))

ans=0

ans += sum(B)

for i in range(N-1):
    if A[i] + 1 == A[i+1]:
        ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 3064
/* ex 5_4
   Sagzar1993 */

#include <stdio.h>
#define SIZE 30

int main(void){
    int max = 0, count = 0; //ACGT文字列の長さとその最大値
    char str[SIZE], *ptr;
    scanf("%s", str); //文字列の入力
    ptr = str; //ポインタに配列の先頭アドレスを渡す
    
    //\0が来るまでループ
    while(*ptr){
        if(*ptr == 'A'|| *ptr == 'C' || *ptr == 'G' || *ptr == 'T'){
            count++; //A,C,G,TならACGT部分列となるのでその長さを＋１
            //その時点での部分列の長さと最大値を比較
            if(count > max){
                max = count; //最大値を超えていれば最大値を更新
            }
        }else{
            count = 0; //A,C,G,Tでなければ部分列の長さを初期化
        }
        ptr++; //次の文字へ
    }

    printf("%d\n", max); //出力
    return 0;
}

Measured memory_bytes: 1700
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    int n;
    cin >> n;
    vector<int> cnts(n + 1);
    int cnt = 0;
    for (int i = 1; i <= 100; i++)
    {
        for (int j = 1; j <= 100; j++)
        {
            for (int k = 1; k <= 100; k++)
            {
                int num = i * i + j * j + k * k + i * j + j * k + k * i;
                if (num <= n)
                {
                    ++cnts[num - 1];
                }
            }
        }
    }
    for (int i = 0; i < n; i++)
    {
        cout << cnts[i] << endl;
    }
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using pii = pair<int, int>;

#define INF 1e9
#define MOD 1000000007
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define each(x, v) for (auto& x: (v))
#define all(x) (x).begin(), (x).end()
#define print(x) cout << (x) << endl

void solve();
void in(){} template<class T, class... U> void in(T &t, U &...u){ cin >> t; in(u...); }
int main() { cin.tie(0); ios::sync_with_stdio(0); solve(); }

void solve() {
  int N;
  in(N);
  vector<pii> A(N);
  rep(i, 0, N) {
    in(A[i].first);
    A[i].second = i;
  }
  sort(all(A));
  rep(i, 0, N) {
    if (i != 0) {
      cout << ' ';
    }
    cout << A[i].second + 1;
  }
}


Measured memory_bytes: 1664
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<ll>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける

ll n;

int main(){
  ll ans=0;
  cin >> n;
  for(int i=1;i<50000;i++){
    if (((i*8/100)+i)==n){
      cout<<i<<endl;
      return 0;
    }
  }
  cout<<":("<<endl;
  
  return 0;
}

Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	vector<vector<int>>dp(N + 1, vector<int>(100001,MOD));
	dp[0][0] = 0;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		for (int j = 0; j <= 100000 - b; j++) {
			dp[i + 1][j + b] = min({ dp[i][j] + a, dp[i + 1][j + b],dp[i][j + b] });
		}
		for (int j = 0; j <= 100000; j++) {
			dp[i + 1][j] = min(dp[i + 1][j], dp[i][j]);
		}
	}
	for (int i = 100000; i >= 0; i--) {
		if (dp[N][i] <= M) {
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 40192
#include<iostream>
using namespace std;
int H,W,cnt;
string str;
int t[100][100];
bool vd[100][100];
void rec(int y,int x,int id){
  if(vd[y][x]==true)return;
  vd[y][x]=true;
  if(y>0&&t[y-1][x]==id)rec(y-1,x,id);
  if(x>0&&t[y][x-1]==id)rec(y,x-1,id);
  if(y+1<H&&t[y+1][x]==id)rec(y+1,x,id);
  if(x+1<W&&t[y][x+1]==id)rec(y,x+1,id);
}
int main(){
  while(cin>>H>>W){
    if(H==0&&W==0)break;
    for(int i=0;i<H;i++){
      cin>>str;
      for(int j=0;j<W;j++){
	vd[i][j]=false;
	if(str[j]=='#')t[i][j]=1;
	if(str[j]=='@')t[i][j]=2;
	if(str[j]=='*')t[i][j]=3;
      }
    }
    cnt=0;
    for(int i=0;i<H;i++){
      for(int j=0;j<W;j++){
	if(vd[i][j]==false){
	  cnt++;
	  rec(i,j,t[i][j]);
	}
      }
    }
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 2024
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;
using i64 = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int h, w;
  cin >> h >> w;
  int cnt[26] = {};
  rep(i, h) {
    string a;
    cin >> a;
    for (auto& ai : a) {
      cnt[ai - 'a']++;
    }
  }
  if (!(h & 1) && !(w & 1)) {
    rep(i, 26) {
      if (cnt[i] % 4 == 0) {
        continue;
      } else {
        cout << "No" << endl;
        return 0;
      }
    }
  } else if ((h & 1) && (w & 1)) {
    int cnt_odd = 0;
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] & 1) {
        cnt_odd++;
        cnt[i]--;
      }
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (cnt_odd != 1 || !(cnt_mod_2 <= (h / 2) + (w / 2))) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  } else {
    int cnt_mod_2 = 0;
    rep(i, 26) {
      if (cnt[i] % 4 == 2) {
        cnt_mod_2++;
        cnt[i] -= 2;
      }
    }
    if (!(cnt_mod_2 <= ((w & 1) ? h / 2 : w / 2))) {
      cout << "No" << endl;
      return 0;
    }
    rep(i, 26) {
      if (cnt[i] % 4 != 0) {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
#include <map>
#include <list>

using LL = long long;

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

const int inf = 0x7fffffff;
const LL linf = 0x7fffffffffffffff;

int read()
{
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*f; 
}

int main()
{
    int a=read(),b=read();
    if(a<10 && b<10)
        cout<<a*b<<endl;
    else
    {
        puts("-1");
    }
    

    return 0;
}


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

#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define DEBUG if(0)
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}
    
int main(){
    int N,P,a=0,b=0;
    cin>>N>>P;
    REP(i,N){
        int x;cin>>x;
        if(x%2)a++;
        else b++;
    }
    LL res=1ll<<b;
    if(a==0){
        if(P==1)cout<<0<<endl;
        else cout<<res<<endl;
    }
    else{
        cout<<(res<<(a-1))<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

X,K,D = LI()

if abs(X) >= D*K:
    print(abs(X)-D*K)
else:
    count = abs(X)//D
    if count%2 == K%2:
        print(abs(X)-D*(abs(X)//D))
    else:
        print(D-(abs(X)-D*(abs(X)//D)))

Measured memory_bytes: 65372
import heapq
heappop=heapq.heappop
heappush=heapq.heappush
n=int(input())
V=list(map(int,input().split()))
V.sort()
for _ in range(n-1):
    a=heappop(V)
    b=heappop(V)
    heappush(V,(a+b)/2)
print(V[0])

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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define MOD (int)1e9+7;

using ll = long long;
using namespace std;

int main() {
    ll N, M;
    cin >> N >> M;
    ll ans = 0;

    if(N == 1 || M == 1) {
        if(N == 1 && M == 1)
            ans = 1;
        else
            ans = max(M, N) - 2;
    } else if(N == 2 || M == 2) {
        ans = 0;
    } else {
        ans = (M - 2)*(N - 2);
    }
    
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
int N,M;
int H[1<<17];
vector<int>G[1<<17];
main()
{
	cin>>N>>M;
	for(int i=0;i<N;i++)cin>>H[i];
	for(int i=0;i<M;i++)
	{
		int a,b;cin>>a>>b;
		a--,b--;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int ans=0;
	for(int i=0;i<N;i++)
	{
		bool f=true;
		for(int v:G[i])if(H[v]>=H[i])f=false;
		ans+=f;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 9852
MOD = 998244353


def solve(n, s, a_list):
    dp = [[0] * 3001 for _ in range(n + 1)]
    dp[0][0] = 1
    for i in range(n):
        a = a_list[i]
        for v in range(3001):
            dp[i + 1][v] = (dp[i][v] * 2) % MOD
        for v in range(3001):
            if v + a > 3000:
                break
            dp[i + 1][v + a] = (dp[i + 1][v + a] + dp[i][v]) % MOD
    # print(dp[n])
    return dp[n][s]


def main():
    n, s = map(int, input().split())
    a_list = list(map(int, input().split()))
    res = solve(n, s, a_list)
    print(res)


def test():
    assert solve(3, 4, [2, 2, 4]) == 6
    assert solve(5, 8, [9, 9, 9, 9, 9]) == 0
    assert solve(10, 10, [3, 1, 4, 1, 5, 9, 2, 6, 5, 3]) == 3296


if __name__ == "__main__":
    test()
    main()


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

int main()
{
    string str;
    string od;

    int n, a, b;

    cin >> str >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> od;
        if (od == "reverse")
        {
            cin >> a >> b;
            string sstr = str.substr(a, b - a + 1);
            reverse(sstr.begin(), sstr.end());
            str.replace(a, b - a + 1, sstr);
        }
        else if (od == "replace")
        {
            string p;
            cin >> a >> b >> p;
            str.replace(a, b - a + 1, p);
        }
        else
        {
            cin >> a >> b;
            cout << str.substr(a, b - a + 1) << endl;
        }
    }
}



Measured memory_bytes: 3220
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int len = s.length();
    for(int i = 0;i<len;i++){
      System.out.print("x");
    }
    System.out.println("");
  }
}


Measured memory_bytes: 23764