akhauriyash/Code-Regression huggingface dataset:
import std.algorithm, std.conv, std.range, std.stdio, std.string;
import std.container; // SList, DList, BinaryHeap

void main()
{
  auto rd1 = readln.split.to!(size_t[]), n = rd1[0], k = rd1[1], l = rd1[2];

  auto readUf(size_t m)
  {
    auto uf = UnionFind(n);
    foreach (_1; 0..m) {
      auto rd2 = readln.splitter;
      auto u = rd2.front.to!size_t-1; rd2.popFront;
      auto v = rd2.front.to!size_t-1;
      uf.unite(u, v);
    }
    return uf;
  }

  auto uf1 = readUf(k), uf2 = readUf(l);

  struct P { size_t i, p1, p2; }

  auto p = new P[](n);
  foreach (i; 0..n) p[i] = P(i, uf1[i], uf2[i]);
  p.multiSort!("a.p1 < b.p1", "a.p2 < b.p2");

  auto ans = new size_t[](n), prevP = p[0], prevI = size_t(0);
  foreach (i; 1..n) {
    if (p[i].p1 == prevP.p1 && p[i].p2 == prevP.p2) continue;
    foreach (j; prevI..i)
      ans[p[j].i] = i - prevI;

    prevP = p[i];
    prevI = i;
  }
  foreach (j; prevI..n)
    ans[p[j].i] = n - prevI;

  foreach (i; 0..n) {
    write(ans[i]);
    if (i < n-1) write(" ");
  }
  writeln;
}

struct UnionFind
{
  import std.algorithm, std.range;

  size_t[] p; // parent
  const size_t s; // sentinel
  const size_t n;
  size_t countForests; // number of forests
  size_t[] countNodes; // number of nodes in forests

  this(size_t n)
  {
    this.n = n;
    s = n;
    p = new size_t[](n);
    p[] = s;
    countForests = n;
    countNodes = new size_t[](n);
    countNodes[] = 1;
  }

  size_t opIndex(size_t i)
  {
    if (p[i] == s) {
      return i;
    } else {
      p[i] = this[p[i]];
      return p[i];
    }
  }

  bool unite(size_t i, size_t j)
  {
    auto pi = this[i], pj = this[j];
    if (pi != pj) {
      p[pj] = pi;
      --countForests;
      countNodes[pi] += countNodes[pj];
      return true;
    } else {
      return false;
    }
  }

  auto countNodesOf(size_t i) { return countNodes[this[i]]; }
  bool isSame(size_t i, size_t j) { return this[i] == this[j]; }

  auto groups()
  {
    auto g = new size_t[][](n);
    foreach (i; 0..n) g[this[i]] ~= i;
    return g.filter!(l => !l.empty);
  }
}


Measured memory_bytes: 17660
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        sc.close();

        // 主処理
        boolean judge = 30 <= n;
        String result = judge ? "Yes" : "No";

        // 出力
        System.out.println(result);
    }
}


Measured memory_bytes: 35716
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    ll n = nxt(), x = nxt(), y = nxt();

    basic_string <ll> ans(n, 0);

    for(ll k=1; k<n; k++)
    {
        for(ll i=k+1; i<=n; i++)
        {
            ll d = min(i-k, abs(i-y) + 1 + abs(k-x));
            ans[d]++;
        }
    }

    for(ll i=1; i<n; i++)
    {
        cout << ans[i] << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

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

using namespace std;

int const size = 1e5+5;

int arr[size];
int dp[size];

int getans(int k, int n){
	if(k<0) return 0;
	if(dp[k] != -1) return dp[k];
	bool flag = true;
	for(int x=0;x<n;x++){
		if(k - arr[x] >=0 && !getans(k-arr[x], n)){
			dp[k] = 1;
			flag = false;
		};
	}
	if(flag) dp[k] = 0;
	return dp[k];
}

int main(){
	int n, k;
	for(int x=0;x<size;x++) dp[x] = -1;
	dp[0] = 0;
	scanf("%d %d",&n, &k);
	for(int x=0;x<n;x++) scanf("%d",&arr[x]);
	if(getans(k, n) == 1) cout<<"First";
	else cout<<"Second";
	// cout<<"\n";
	// cout<<k<<endl;
	// for(int x=0;x<=k;x++) cout<<dp[x]<<" "; 	
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T>
vector<T> table(int n, T v) { return vector<T>(n, v); }

template <class... Args>
auto table(int n, Args... args) {
    auto val = table(args...);
    return vector<decltype(val)>(n, move(val));
}
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 200005;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    PRINT(a[n-1]-a[0]);
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] m = new int[N];
        for(int i = 0; i < N; i++){
            m[i] = sc.nextInt();
        }

        int remain = X;
        int min = 1100;
        for(int i = 0; i < N; i++){
            remain -= m[i]; 
            min = Math.min(min, m[i]);
        }

        int ans = 0;
        if(remain == 0) ans = m.length;
        else ans = (remain - (remain % min)) / min + m.length;
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N;
  cin >> N;
  int cnt = 0;
  for (int i = 0; i < N; ++i) {
    int p;
    cin >> p;
    if (p != i + 1) cnt++;
  }
  if (cnt <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k>a)
  {
    if(k>(a+b))
    {
      cout<<a-k+a+b<<endl;
    }
    else
      cout<<a<<endl;
  }
  else
    cout<<k<<endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <math.h>
#include <sstream>
#include <numeric>
#include <string>

using namespace std;

int main()
{
  int R, G, B, N;
  cin >> R >> G >> B >> N;
  int cnt = 0;
  for (int r = 0; r <= 3000; ++r) {
    for (int g = 0; g <= 3000; ++g) {
      int x = N - (r * R + g * G);
      if (x % B != 0) continue;
      int b = x / B;
      if (0 <= b) ++cnt;
    }
  }
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
 int a;
 int b;
 int c; 
int f=0;
int fa;
int fb;
int fc;
 int i;
 scanf("%d %d %d",&a,&b,&c);
 while(1)
 {
    if(a==i)
    {
        if(f==0)
        {
            fa=a;
            f=1;
        }
        else if(f==1)
        {
            fb=a;
            f=2;
        }
        else if(f==2)
        {
            fc=a;
            f=3;
        }
    }
    if(b==i)
    {
        if(f==0)
        {
            fa=b;
            f=1;
        }
        else if(f==1)
        {
            fb=b;
            f=2;
        }
        else if(f==2)
        {
            fc=b;
            f=3;
        }
    }
    if(c==i)
    {
        if(f==0)
        {
            fa=c;
            f=1;
        }
        else if(f==1)
        {
            fb=c;
            f=2;
        }
        else if(f==2)
        {
            fc=c;
            f=3;
        }
    }
    i=i+1;
    if(f==3)
    {
          break;
    }
 }
 printf("%d %d %d\n",fa,fb,fc);

return 0;
 
}

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

int main() {
  //ベクトル配列の入力
  vector<int> a(9);
  for (int i = 0; i < 9; i++) cin >> a[i];

  int n;
  cin >> n;

  //ベクトル配列の入力
  vector<int> b(n);
  for (int i = 0; i < n; i++) cin >> b[i];

  //bool配列（判定用）
  vector<bool> hantei(9);
  for (int i = 0; i < 9; i++) hantei[i] = false;

  for (int i = 0; i < n; i++) {
    for (int j = 0; j < 9; j++) {
      if (a[j] == b[i]) hantei[j] = true;
    }
  }

  if (hantei[0]==true && hantei[1]==true && hantei[2]==true) cout << "Yes" << endl;
  else if (hantei[3]==true && hantei[4]==true && hantei[5]==true) cout << "Yes" << endl;
  else if (hantei[6]==true && hantei[7]==true && hantei[8]==true) cout << "Yes" << endl;
  else if (hantei[0]==true && hantei[3]==true && hantei[6]==true) cout << "Yes" << endl;
  else if (hantei[1]==true && hantei[4]==true && hantei[7]==true) cout << "Yes" << endl;
  else if (hantei[2]==true && hantei[5]==true && hantei[8]==true) cout << "Yes" << endl;
  else if (hantei[0]==true && hantei[4]==true && hantei[8]==true) cout << "Yes" << endl;
  else if (hantei[2]==true && hantei[4]==true && hantei[6]==true) cout << "Yes" << endl;
  else cout << "No" <<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.StringTokenizer;

public class Main {

    public static void main(String[] args) {
        
        FastScanner sc = new FastScanner(System.in);
        
        StringBuilder sb = new StringBuilder(sc.next());
        StringBuilder sb2 = new StringBuilder();
        int q = Integer.parseInt(sc.next());
        boolean reverse = false;
        for(int i = 0; i < q; i++){
            if(Integer.parseInt(sc.next()) == 1){
                reverse = !reverse;
            }else{
                int f = Integer.parseInt(sc.next());
                if((!reverse && f == 1) || (reverse && f == 2)){
                    sb2.append(sc.next());
                }else{
                    sb.append(sc.next());
                }
            }
        }
        if(reverse){
            System.out.print(sb.reverse());
            System.out.println(sb2);
        }else{
            System.out.print(sb2.reverse());
            System.out.println(sb);
        }
    }
    
    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        
        public FastScanner(InputStream in) {
            br = new BufferedReader(new InputStreamReader(in));
        }
        String next(){
            while(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch(IOException  e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
    }
}

Measured memory_bytes: 46732
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int>> vvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
const int INF = 1001001001;
const ll LINF = 1e18;
const string endstr = "\n";

template <typename T>
T gcd(T a, T b) {
    if(a < b) gcd(b, a);
    T r;
    while((r=a%b)) {
        a = b; b = r;
    }
    return b;
}
bool p_comp_fs(const P p1, const P p2){ return p1.first < p2.first;};
bool p_comp_fg(const P p1, const P p2){ return p1.first > p2.first;};
bool p_comp_ss(const P p1, const P p2){ return p1.second < p2.second;};
bool p_comp_sg(const P p1, const P p2){ return p1.second > p2.second;};
    
int main(){
    ll N, a, ret = 0; cin >> N;
    vl as(N + 1, 0);
    for (int i = 0; i < N; i++) {
        cin >> a;
        if(a > N) ret++;
        else as[a]++;
    }
    for (int i = 0; i < as.size(); i++) {
        if(as[i] < i){
            ret += as[i];
        }
        else if(as[i] > i){
            ret += as[i] - i;
        }
    }
    cout << ret << endstr;
    return 0;
}


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

int main() {
	long a, b;
	cin >> a >> b;  for (int n = 0; n < 10000; ++n) {
        int za = n * 8 / 100;
        int zb = n * 10 / 100;
        if (a == za && b == zb) {
            cout << n << endl;
            return 0;
        }
    }
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  int a,b;
  cin >> a >> b;
  if(a>=13){
    cout << b << endl;
  }else if(a>=6){
    cout << b/2 << endl;
  }else{
    cout << 0 << endl;
  }
}



Measured memory_bytes: 256
import java.util.*

fun main(arr:Array<String>) {
    val n = readLine()!!.toInt()
    val numbers = readLine()!!.split(" ").map { it.toInt() }.sorted()
    val queue = PriorityQueue<Double>()
    queue.addAll(numbers.map { it.toDouble() })
    while (queue.count() > 2) {
        val current = (queue.poll() + queue.poll())/2
        queue.add(current)
    }
    val ans = (queue.poll() + queue.poll()) / 2
    println(ans)
}


Measured memory_bytes: 37792
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <iterator>
#include <iomanip>
using namespace std;

vector<vector<long long> > g;
vector<long long> tin, tout, t, b;
long long tmr = 0;

void dfs(long long v, long long p){
    tin[v] = ++tmr;
    for(int i = 0; i < g[v].size(); ++i){
        if(g[v][i] != p) dfs(g[v][i], v);
    }
    tout[v] = tmr;
}

void push(int v, int tl, int tr) {
    if (b[v] != -1)
        t[v] = (tr - tl + 1) * b[v];
    if (tl != tr && b[v] != -1) {
        b[v << 1] = b[v];
        b[v << 1 | 1] = b[v];
    }
    b[v] = -1;
}
 
void upd(long long l, long long r, long long val, long long v, long long tl, long long tr) {
    push(v, tl, tr);
    if (l > tr || tl > r) return ;
    if (l <= tl && tr <= r) {
        b[v] = val;
        push(v, tl, tr);
        return;
    }
    long long tm = (tl + tr) >> 1;
    upd(l, r, val, v << 1, tl, tm);
    upd(l, r, val, v << 1 | 1, tm + 1, tr);
    t[v] = t[v << 1] + t[v << 1 | 1];
}
 
long long get(long long l, long long r, long long v, long long tl, long long tr) {
    push(v, tl, tr);
    if (l > tr || tl > r) return 0;
    if (l <= tl && tr <= r) return t[v];
    long long tm = (tl + tr) >> 1;
    return get(l, r, v << 1, tl, tm) +
            get(l, r, v << 1 | 1, tm + 1, tr);
}

long long cnt(long long k){
    return k * (k + 1) / 2;
}

bool comp(const long long &frst, const long long &scnd){
    return tin[frst] > tin[scnd];
}

int main(){
    long long n, el;
    cin >> n;
    g.resize(n + 1);
    tin.resize(n + 1);
    tout.resize(n + 1);
    t.resize(4 * n);
    b.resize(4 * n);
    vector<vector<long long> > a(n + 1);
    for(int i = 1; i <= n; ++i){
        cin >> el;
        a[el].push_back(i);
    }
    long long fr, to;
    for(int i = 0; i < n - 1; ++i){
        cin >> fr >> to;
        g[fr].push_back(to);
        g[to].push_back(fr);
    }
    dfs(1, -1);

    upd(1, n, 1, 1, 1, n);
    
    for(int i = 1; i <= n; ++i){
        sort(a[i].begin(), a[i].end(), comp);
        long long ans = cnt(n);
        for(int x:a[i]){
            for(int to:g[x]){
                if(tin[to] < tin[x]) continue;
                ans -= cnt(get(tin[to], tout[to], 1, 1, n));
            }
            upd(tin[x], tout[x], 0, 1, 1, n);
        }
        ans -= cnt(get(1, n, 1, 1, n));
        cout << ans << "\n";
        upd(1, n, 1, 1, 1, n);
    }
}


Measured memory_bytes: 47920
#!/usr/bin/env python3
import sys
input = sys.stdin.readline

h, w, K = map(int, input().split())
field = []
for _ in range(h):
    line = input().rstrip()
    field.append(line)

ans = 0
for i in range(2**h):
    for j in range(2**w):
        cnt = 0
        for k in range(h):
            if i & (1 << k):
                continue
            for l in range(w):
                if j & (1 << l):
                    continue
                if field[k][l] == "#":
                    cnt += 1
        if cnt == K:
            ans += 1
print(ans)

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
int main(){
 
long long N, M, cnt = 0;
  cin >> N >> M;
  
  if((N == 1) && (M == 1)) cnt = 1;
  else if((N == 1) || (M == 1)) cnt = max(N, M) - 2;
  else if((N == 2) || (M == 2)) cnt = 0;
  else cnt = (N - 2) * (M - 2);
 
  cout << cnt << endl;
  
return 0;
  
}

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

public class Main {
	FastScanner in;
	PrintWriter out;

	void solve() {
		int n = in.nextInt();
		int sum = 0;
		for (int x = 1;; x++) {
			sum += x;
			if (sum >= n) {
				for (int i = x; i >= 1; i--) {
					if (n >= i) {
						out.println(i);
						n -= i;
					}
				}
				return;
			}
		}
	}

	void run() {
		try {
			in = new FastScanner(new File("object.in"));
			out = new PrintWriter(new File("object.out"));

			solve();

			out.close();
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		}
	}

	void runIO() {

		in = new FastScanner(System.in);
		out = new PrintWriter(System.out);

		solve();

		out.close();
	}

	class FastScanner {
		BufferedReader br;
		StringTokenizer st;

		public FastScanner(File f) {
			try {
				br = new BufferedReader(new FileReader(f));
			} catch (FileNotFoundException e) {
				e.printStackTrace();
			}
		}

		public FastScanner(InputStream f) {
			br = new BufferedReader(new InputStreamReader(f));
		}

		String next() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return null;
				st = new StringTokenizer(s);
			}
			return st.nextToken();
		}

		boolean hasMoreTokens() {
			while (st == null || !st.hasMoreTokens()) {
				String s = null;
				try {
					s = br.readLine();
				} catch (IOException e) {
					e.printStackTrace();
				}
				if (s == null)
					return false;
				st = new StringTokenizer(s);
			}
			return true;
		}

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

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

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

	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
				new Main().runIO();
			}
		}, "1", 1 << 26).start();
	}
}

Measured memory_bytes: 9092
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long x = sc.nextLong();
		long k = sc.nextLong();
		long d = sc.nextLong();
		long ax = Math.abs(x);
		if(ax/d > k) {
			System.out.println(ax-k*d);
		}
		else {
			k -= ax/d;
			ax = ax - d*(ax/d);
			if(k%2==0) {
				System.out.println(ax);
			}
			else {
				System.out.println(Math.abs(ax-d));
			}
		}
	}
}

Measured memory_bytes: 35604
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main {
    static class Fast {
        BufferedReader br;
        StringTokenizer st;

        public Fast() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

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

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

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

    public static void main(String args[]) throws Exception {
        Fast in = new Fast();
        int n=in.nextInt();
        int b=in.nextInt();
        if((b*n)%2==0){
            System.out.println("Even");
        }else{
            System.out.println("Odd");
        }
    }
}






Measured memory_bytes: 21204
import heapq

n,m=map(int, input().split())
a=list(map(int,input().split()))
a = list(map(lambda x: x*(-1), a)) 

heapq.heapify(a)

for i in range(m):
    x=heapq.heappop(a)
    heapq.heappush(a,-(-x//2))

a = list(map(lambda x: x*(-1), a)) 
print(sum(a))



Measured memory_bytes: 79596
from itertools import combinations

D, G = map(int, input().split())
PC = []
for i in range(D):
    p, c = map(int, input().split())
    total = ((i + 1) * 100) * p + c
    PC.append([p, c, total])

A = []
B = {i for i in range(D)}
for i in range(D+1):
    A += list(combinations(B, i))

# print(A)

ans = []
for ai in A:
    p = 0  # ポイント
    c = 0  # 問題数
    for aii in ai:
        p += PC[aii][2]
        c += PC[aii][0]
    if p < G:
        x = B.difference(ai)
        max_x = max(x)
        cnt = 0
        while p < G and cnt < PC[max_x][0]:
            p += (max_x + 1) * 100
            cnt += 1
            c += 1
        if p >= G:
            # ans.append([p, c])
            ans.append(c)
    else:
        # ans.append([p, c])
        ans.append(c)

print(min(ans))

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

int main() {
  int N;
  cin >> N;
  int L, max = 0, sum = 0;
  for (int i = 0; i < N; i++) {
    cin >> L;
    if (max < L) {
      max = L;
    }
    sum += L;
  }
  if (sum > 2 * max) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
    
#define all(a) a.begin(), a.end()
#define forn(l, r) for(int i = l; i < (r); ++i)
#define F first
#define S second
#define $ ios::sync_with_stdio(0);
///#define int long long int
    
using namespace std;
using namespace __gnu_pbds;
using ll = long long int;
using ii = pair<int, int>;
using li = pair<ll, int>;
using vi = vector<int>;
using graph = vector<vi>;
using ordered_set = tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>;
    
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    
const ll mod =  1000000007;
const int INF = 0x3f3f3f3f;
const int MAXN = 312345;
//const double pi = 3.14159265359;
const double eps = 0.00000001;
    
int g[11];
int pi;
int n, m;
    
int dp[11][4000];
bool seen[11][4000];
 
int sol (int idx, int bm) {
    bool& vis = seen[idx][bm];
    int& pd = dp[idx][bm];
    if (vis) return pd;
    if (idx == n) {
        return pi == bm;
    }
    pd += sol (idx + 1, bm);
    pd += sol (idx + 1, bm ^ g[idx]);
    vis = 1;
    return pd;
}
    
int32_t main() {
    $
    
    cin >>  n >> m;
    
    int qtd, x;
    forn (0, m) {
        cin >> qtd;
        while (qtd--) {
            cin >> x;
            --x;
            g[x] |= (1 << i); 
        }
    }
    
    forn (0, m) {
       cin >> x;
       pi |= (x << i);
    }
    
    cout << sol(0, 0) << endl;
}

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

class UnionFind {
public:
    std::vector<int> data;

    UnionFind( int n ) {
        data.resize( n, -1 );
    }

    int find( int x ) {
        if ( data[x] < 0 ) {
            return x;
        } else {
            int r = find( data[x] );
            data[x] = r;
            return r;
        }
    }

    void unite( int x, int y ) {
        int r = find( x );
        int s = find( y );
        if ( r != s ) {
            data[r] += data[s];
            data[s] = r;
        }
    }
};

int solve() {
    int N, M;
    cin >> N >> M;
    vector<int> P(N);
    for ( int i = 0; i < N; i++ ) {
        cin >> P[i];
        P[i]--;
    }
    int x, y;
    UnionFind uf(N);
    for ( int i = 0; i < M; i++ ) {
        cin >> x >> y;
        x--, y--;
        uf.unite(x, y);
    }

    ll ans = 0;
    for ( int i = 0; i < N; i++ ) {
        if ( uf.find(i) == uf.find(P[i]) ) ans++;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

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

void print(int i, int j, int k, int l) {
  printf("[%d -> %d] : [%d -> %d] + [%d -> %d] == %d\n", i, j, i, k, k, j, l);
}

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

  long long ans = 0;
  vector<vector<int>> d(n, vector<int>(n));
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      cin >> d[i][j];
      ans += d[i][j];
    }
  }

  ans /= 2;

  bool f = false;
  for (int k = 0; k < n; ++k) {
    for (int i = 0; i < n; ++i) {

      if (i == k || d[i][k] == 0) continue;

      for (int j = 0; j < n; ++j) {

        if (j == k || d[k][j] == 0) continue;
        
        if (d[i][j] > d[i][k] + d[k][j]) {
          f = true;
          d[i][j] = d[i][k] + d[k][j];
        }
        if (d[i][j] && d[i][j] == d[i][k] + d[k][j]) {
          ans -= d[i][j];
          // print(i, j, k, d[i][j]);
          d[i][j] = d[j][i] = 0;
        }
      }
    }
  }

  if (f) {
    puts("-1");
    return 0;
  } else {
    cout << ans << endl;
  }
}


Measured memory_bytes: 640
#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
using namespace std;

long long dis[301][301];

int main()
{
    int n,m,l;scanf("%d%d%d",&n,&m,&l);

    for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
    {
        if (i==j) dis[i][j]=0;
        else dis[i][j]=-1;
    }

    for (int i=0;i<m;++i)
    {
        int a,b,c;scanf("%d%d%d",&a,&b,&c);
        dis[a][b]=dis[b][a]=c;
    }

    for (int k=1;k<=n;++k)
    for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
    {
        if (dis[i][k]<0 || dis[k][j]<0) continue;
        if (dis[i][j]<0 || dis[i][j]>dis[i][k]+dis[k][j])
            dis[i][j]=dis[i][k]+dis[k][j];
    }
    for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
    {
        if (dis[i][j]>0 && dis[i][j]<=l) dis[i][j]=1;
        else dis[i][j]=-1;
    }

    for (int k=1;k<=n;++k)
    for (int i=1;i<=n;++i)
    for (int j=1;j<=n;++j)
    {
        if (dis[i][k]<0 || dis[k][j]<0) continue;
        if (dis[i][j]<0 || dis[i][j]>dis[i][k]+dis[k][j])
            dis[i][j]=dis[i][k]+dis[k][j];
    }
    int q;scanf("%d",&q);
    while (q--)
    {
        int i,j;scanf("%d%d",&i,&j);
        if (dis[i][j]>0)
        printf("%d\n",dis[i][j]-1);
        else printf("%d\n",dis[i][j]);

    }


}







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

long long func(long long a, long long x)
{
    if(a==-1){
        return 0;
    }
    else
        return a / x+1;
}

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

    long long ans = func(b,x) - func(a-1,x);
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
from operator import itemgetter
sys.setrecursionlimit(10000000)
INF = 10**30

def main():
    n = int(input().strip())
    a = list(map(int, input().strip().split()))
    q = int(input().strip())
    m = list(map(int, input().strip().split()))
    l = []
    for i in range(2**n):
        w = 0
        for j in range(n):
            if 1 & (i >> j) == 1:
                w += a[j]
        l.append(w)
    l = set(l)
    for i in range(q):
        if m[i] in l:
            print('yes')
        else:
            print('no')
if __name__ == '__main__':
    main()



Measured memory_bytes: 43092
import java.util.*;
public class Main {
	Scanner sc = new Scanner(System.in);
	int N;
	int[] A;
	int count=0;
	int flag;
	int key;
	
	public void input(){
		N=sc.nextInt();
		A = new int[N];
		for(int i=0; i<N; i++){
			A[i]=sc.nextInt();
		}
	}
	
	public void bubblesort(){
		flag=1;
		while(flag==1){
			flag=0;
			for(int j=N-1; j>=1; j--){
				if(A[j] < A[j-1]){
					key = A[j];
					A[j] = A[j-1];
					A[j-1] = key;
					flag=1;
					count++;
				}
			}
		}
	}
	
	public void output(){
		System.out.print(A[0]);
		for(int i=1; i<N; i++){
			System.out.print(" "+A[i]);
		}
		System.out.println("\n"+count);
	}
	
	public static void main(String[] args){
		Main obj = new Main();
		obj.input();
		obj.bubblesort();
		obj.output();
	}
}


Measured memory_bytes: 26304
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
typedef long long ll;
//#include <stack>
//#include <queue>
#define MOD 1000000007

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 
 

int main(){

    int N,M;
    cin >> N >> M;

    bool kaidan[100000];
    rep(ni,N+100) kaidan[ni]=true;
    int tmp;
    int dp[100000]={};
    rep(mi,M) { cin >> tmp; kaidan[tmp] = false;   }

    dp[0]=1;
    rep(ni,N){
        //cout << ":" << kaidan[ni+1] << endl;
        if(kaidan[ni+1])  {dp[ni+1]+=dp[ni]; dp[ni+1]%=MOD;}
        if(kaidan[ni+2])  {dp[ni+2]+=dp[ni]; dp[ni+2]%=MOD;}
    }
    //rep(ni,N+1) cout << dp[ni] << endl;
    cout << dp[N] << endl;
}

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

int ans[16][16];
void init(){
  for(int i = 0; i < 16; i++){
    for(int j = 0; j < 16; j++){
      ans[i][j] = -1;
    }
  }
}

bool isfull(int n){
  for(int i = 0; i < n; i++){
    for(int j = 0; j < n; j++){
      if(ans[i][j] == -1){
	return true;
      }
    }
  }
  return false;
}

int main(){
  int n;
  int count = 1;
  int x,y;
  while(true){
    cin >> n;
    if(!n){
      break;
    }
    init();
    count = 1;
    x = n / 2;
    y = n / 2 + 1;
    ans[y][x] = count;
  
    count ++;
    y++;
    x++;
    while(isfull(n)){
      if(x == n){
	x = 0;
      }
      if(y == n){
	y = 0;
      }
      
      if(ans[y][x] == -1){
	ans[y][x] = count;
	count ++;
	y++;
	x++;
      }
      else{
	while(ans[y][x] != -1){
	  y++;
	  x--;
	  if(y == n){
	    y = 0;
	  }
	  if(x < 0){
	    x = n -1;
	  }
	}
	ans[y][x] = count;
	count ++;
	y++;
	x++;
      }
    }
    
    for(int i = 0;i < n;i++){
      for(int j=0;j<n;j++){
	printf("%4d",ans[i][j]);
      }
      printf("\n");
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N;
    vector<ll> a(100010);
    cin >> N;
    for (int i=0;i<N;i++) cin >> a[i];

    map<ll,pair<int,int>,greater<ll>> M;
    for (int i=0;i<N;i++) {
        if (M.find(a[i]) == M.end()) {
            M[a[i]].first = i+1;
            (M[a[i]].second)++;
        } else {
            if (M[a[i]].first > i+1) M[a[i]].first = i+1;
            (M[a[i]].second)++;
        }
    }
    
    ll c = 0LL;
    ll x, xp = 0LL, y, z, yp = 100001, zp;
    vector<ll> b(100010,0LL);
    for (auto itr: M) {
#ifdef DEBUG
        cout << itr.first << ": <" << itr.second.first << "," << itr.second.second << ">" << endl; 
#endif
        x = itr.first, y = min(yp,(ll)itr.second.first), z = itr.second.second;
        if (xp) if (xp-x > 1) {
            b[yp] += (xp-x-1)*c;
        }
        c += z;
        b[y] += c;
        xp = x, yp = y, zp = z;
    }
    if (xp) {
        b[yp] += (xp-1)*c;
    }

    for (int i=1;i<=N;i++) {
        cout << b[i] << endl;
    }

    return 0;
}


Measured memory_bytes: 8832
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n, A[100010];

int main() {
    scanf("%lld", &n);
    for(int i = 1; i <= n; i++) scanf("%lld", &A[i]);
    for(int i = 1; i <= n; i++) if(A[i] % 2 == 1) {
        puts("first");
        return 0;
    }
    puts("second");
    return 0;
}

Measured memory_bytes: 896
#include <iostream>
using std::cout;
using std::cin;
using std::endl;

void grade()
{
	int m, f, r;
	while(true)
	{
		cin >> m >> f >> r;
		if (m == -1 && f == -1 && r == -1) break;
		if (m == -1 || f == -1) cout << 'F';
		else if (m + f >= 80) cout << 'A';
		else if (m + f >= 65) cout << 'B';
		else if (m + f >= 50) cout << 'C';
		else if (m + f >= 30)
			if (r >= 50) cout << 'C';
			else cout << 'D';
		else cout <<'F';
		cout << endl;
	}
}

int main()
{
	grade();
	return 0;
}

Measured memory_bytes: 1152
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        Integer d[] = new Integer[N];
        int s = 1;

        for(int i = 0;i < N;i++){
            d[i] = scanner.nextInt();
        }

        Arrays.sort(d, Comparator.reverseOrder());
        for(int i = 0;i < N - 1;i++){
            if(d[i] > d[i + 1])
            s++;
        }

        System.out.println(s);
        }
}

Measured memory_bytes: 21972
/**
 *    DP
 *    27.04.2020 14:06
**/

#include <bits/stdc++.h>

using namespace std;

const int nx = 305;
long double ev[nx][nx][nx]; // ev[cnt[1]][cnt[2]][cnt[3]]
int cnt[4];

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, x;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> x;
    cnt[x]++;
  }
  /*
    EV(i, j, k) = expected number of trials to reach state (i, j, k)
    want to find EV(0, 0, 0): when all of 1, 2, 3 sushi plates are 0
    
    EV(0, 0, 0) = EV(success) + EV(1, 0, 0)
    EV(success) = expected number of trials to reach that 1 sushi plate
                  1/p, where p = probability of success
                  p = number of filled sushi plates / n
    EV(1, 0, 0) = expected number of trials to reach 1, 0, 0 from
                  initial E(cnt[1], cnt[2], cnt[3])
    total plates = i + j + k
    EV(i, j, k) = n / total plates +
                  i / total plates * E(i + 1, j, k) +
                  j / total plates * E(i - 1, j + 1, k) +
                  k / total playes * E(i, j - 1, k + 1)
    loop bottom up
  */

  for (int k = 0; k < nx; k++) {
    for (int j = 0; j < nx; j++) {
      for (int i = 0; i < nx; i++) {
        if (i + j + k == 0 || i + j + k > n) continue;
        double total_plates = i + j + k;
        double ev_success = double(n) / total_plates;
        double p_i = double(i) / total_plates;
        double p_j = double(j) / total_plates;
        double p_k = double(k) / total_plates;
        if (i) ev[i][j][k] += p_i * ev[i - 1][j][k];
        if (j) ev[i][j][k] += p_j * ev[i + 1][j - 1][k];
        if (k) ev[i][j][k] += p_k * ev[i][j + 1][k - 1];
        ev[i][j][k] += ev_success;
      }
    }
  }
  cout << fixed << setprecision(16) << ev[cnt[1]][cnt[2]][cnt[3]] << "\n";
  return 0;
}


Measured memory_bytes: 436480
odd = ['R','U','D']
even = ['L','U','D']

s = input()
frag = True

for i, c in enumerate(s):
  if i%2 ==0:
    if c not in odd:
      frag = False
      break
  else:
    if c not in even:
      frag = False
      break

if frag:
  print('Yes')
else:
  print('No')
      
  

Measured memory_bytes: 9056
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
//        Scanner scanner = new Scanner(System.in);
//
//        long X = scanner.nextLong();
//        long Y = scanner.nextLong();
//
//        int cnt = 0;
//        // A[i+1]はもっとも小さいA[i]の倍数にする=2をかけていく
//        for (double i = Y; (int) i >= X ; i = i / 2) {
//            cnt++;
//        }
//
//        System.out.println(cnt);

        main2();
    }

    public static void main2() {
        Scanner scanner = new Scanner(System.in);

        long X = scanner.nextLong();
        long Y = scanner.nextLong();

        int cnt = 0;
        for (long i = X; i <= Y; i *= 2) {
            cnt++;
        }

        System.out.println(cnt);
    }
}


Measured memory_bytes: 35644
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed;
	cout << setprecision(10);
	double a, b, c, PI = 3.1415926535;
	cin >> a >> b >> c;
	cout << a * b * sin(c * PI / 180) / 2 << endl;
	cout << sqrt(a * a + b * b - 2 * a * b * cos(c * PI / 180)) + a + b << endl;
	cout << b * sin(c * PI / 180) << endl;
	return 0;
}


Measured memory_bytes: 3400
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int Anum, Bnum, result;
    cin >> Anum >> Bnum;
    result = 0;
    int out=1;
    while (out < Bnum)
    {
        out--;
        out += Anum;
        result++;
    }
    cout << result << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void) {
  string s;
  cin >> s;
  int ans=0;
  int l=s.length();
  for (int i=0; i<l-2; i++) {
    if (s[i] == s[i+1] && s[i+1] == s[i+2])
    {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int V, E;
struct edge {
	int to;
	LL cost;
};

vector<edge>graph[123456];

int r;
LL dist[123456];

using P = pair<LL, int>;

int main(void)
{
	cin >> V >> E >> r;
	for (int i = 0; i < E; ++i) {
		int s, t, d;
		cin >> s >> t >> d;
		graph[s].push_back({ t,d });
	}
	priority_queue<P, vector<P>, greater<P>>que;
	fill(dist, dist + 123456, 1234567890123456LL);
	dist[r] = 0;
	que.push({ 0LL,r });
	while (!que.empty()) {
		auto q = que.top();
		que.pop();
		LL dis = q.first;
		int ver = q.second;
		if (dist[ver] < dis)continue;
		for (edge& e : graph[ver]) {
			if (dist[e.to] > dist[ver] + e.cost) {
				dist[e.to] = dist[ver] + e.cost;
				que.push({ dist[e.to], e.to });
			}
		}
	}
	for (int i = 0; i < V; ++i) {
		if (dist[i] >= 1234567890123456LL) {
			cout << "INF" << endl;
		}
		else {
			cout << dist[i] << endl;
		}
	}
	return 0;
}



Measured memory_bytes: 20200
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

// std::cout << std::setprecision(20) << 1.1 << endl;

constexpr int64_t kInf = INT64_MAX / 2L;

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

  int64_t H, N;
  cin >> H >> N;
  // const int64_t L = static_cast<int64_t>(T.length());
  vector<int64_t> total_mp(H + 1, kInf);
  total_mp[0] = 0;
  for (int64_t i = 0; i < N; ++i) {
    int64_t damage, mp;
    cin >> damage >> mp;
    for (int64_t d = 0; d < H; ++d) {
      const int64_t next_daname = min(H, d + damage);
      total_mp[next_daname] = min(total_mp[next_daname], total_mp[d] + mp);
    }
  }
  cout << total_mp[H] << endl;
  return 0;
}


Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

int H,W;
char S[303][303];

const ll INF=1e15;

void chmin(ll &a,ll b){
    if(a>b) a=b;
    return;
}

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

  ll ans=0;
  for(int i=0;i<W-1;i++){
      ll dp[303][303]={};
      ll match[303][303]={};
      for(int j=0;j<=H;j++) for(int k=0;k<=H;k++) dp[j][k]=INF;

      dp[0][0]=0;
      for(int j=0;j<=H;j++){
          for(int k=0;k<=H;k++){
              if(j+1<=H&&k+1<=H){
                  match[j+1][k+1]=match[j][k];
                  int cost=0;
                  if(S[i][j]==S[i+1][k]){
                      cost++;
                      match[j+1][k+1]++;
                  }
                  chmin(dp[j+1][k+1],dp[j][k]+cost+match[j][k]+min(match[j][k+1],match[j+1][k]));
              }
              if(j+1<=H){
                  chmin(dp[j+1][k],dp[j][k]+match[j+1][k]);
              }
              if(k+1<=H){
                  chmin(dp[j][k+1],dp[j][k]+match[j][k+1]);
              }

              if(j==0) dp[j][k+1]=0;
              if(k==0) dp[j+1][k]=0;
          }
      }
      ans+=dp[H][H];
  }

  cout<<ans<<endl;

  return 0;
}


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

def yaku(n):
  ans = []
  x = int(N ** (1/2))
  for i in range(1, x + 1):
    if n % i == 0:
      if i != n // i:
        if i not in ans:
          ans.append(i)
        if n // i not in ans:  
          ans.append(n // i)
  return len(ans)

ans = 0
for i in range(1, N + 1, 2):
  if yaku(i) == 8:
    ans += 1
    
    
print(ans)
  
  

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

using ll = long long; 

int main() {
  int H, A;
  cin >> H >> A;

  int ans;
  ans = H / A;
  if (H%A != 0) {
    ++ans;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
	int N;
    ll K;
	cin >> N >> K;
	vector<ll> a(N), d;
	ll sum=0;
	for(int i=0; i<N; ++i){
	    cin >> a[i];
	    sum += a[i];
	}
	for(ll i=1; i*i<=sum; ++i){
	    if(sum%i==0){
	        d.push_back(i);
	        if(i*i<sum) d.push_back(sum/i);
	    }
	}
	sort(d.begin(), d.end(), greater<ll>());
	for(int i=0; i<d.size(); ++i){
	    vector<ll> res;
	    for(int j=0; j<N; ++j){
	        if(a[j]%d[i]>0) res.push_back(a[j]%d[i]);
	    }
	    if(res.size()<1){
	        cout << d[i] << endl;
	        return 0;
	    }
	    sort(res.begin(), res.end());
	    vector<ll> b_sum(res.size()), e_sum(res.size());
	    b_sum[0]=res[0];
	    for(int j=1; j<res.size(); ++j) b_sum[j]=b_sum[j-1]+res[j];
	    e_sum.back()=d[i]-res.back();
	    for(int j=res.size()-2; j>=0; --j) e_sum[j]=e_sum[j+1]+d[i]-res[j];
	    ll mn=1e10;
	    for(int j=0; j+1<res.size(); ++j) mn=min(mn, max(b_sum[j], e_sum[j+1]));
	    if(mn<=K){
	        cout << d[i] << endl;
	        return 0;
	    }
	}
	return 0;
}


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

int main(){
    int N;
    cin >> N;
    LL ans = 0, sum = 0;
    for(int i = 0;i < N;i++){
        int ai;
        cin >> ai;
        sum += ai;
        if(ai == 0 || i == N-1){
            ans += sum/2;
            sum = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#define INF 1e9
#define eps 1e-6
typedef long long ll;
using namespace std;

int a, b, c;

int main(){

	cin >> a >> b >> c;
	if(a + b + c >= 22) puts("bust");
	else puts("win");

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

int main() {
  int a[5];
  int k;
  while(inputs(a,5), cin>> k) {
    cout <<  ((a[4] - a[0] <= k) ? "Yay!" : ":(") << endl;
  }
}


Measured memory_bytes: 256