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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  string s;
  cin >> s;
  int ans = 0;
  rep(i, s.size()) ans += s[i] == '1';
  cout << ans << endl;
}


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

int main() {
  int X ; cin >> X;
  int count = 0;
  bool flag = true;
  while(flag){
    for(int i = 2; i < X ;i++){
      if(X % i == 0){ 
        count = 1;
    }
    }
    if (count == 0){
      flag = false;
    }
    else if (count == 1){
      flag = true;
      X++;
      count = 0;
    }
    
  }
cout << X  << endl;
  }

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

using namespace std;
const int LIMIT = 1e5;

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    vector<int> count(LIMIT + 1);
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        sum += a;
        count[a]++;
    }

    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        long long b, c;
        cin >> b >> c;
        sum += count[b] * c, sum -= count[b] * b;
        count[c] += count[b], count[b] = 0;

        cout << sum << endl;
    }
    return 0;
}

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

ll gcd(ll a, ll b){return b!=0 ? gcd(b, a%b) : a;}
ll lcm(ll a, ll b){return a / gcd(a, b) * b;}

int main(){
	int n, q;
  cin >> n >> q;
  vector<vector<int>> g(n, vector<int>());
  rep(i, n-1){
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  vector<ll> point(n, 0);
  rep(i, q){
    int p, x;
    cin >> p >> x;
    p--;
    point[p] += x;
  }

  vector<bool> check(n, false);
  stack<int> st;
  st.push(0);
  while(!st.empty()){
    int now = st.top();
    st.pop();
    check[now] = true;
    for(auto itr : g[now]){
      if(check[itr]) continue;
      point[itr] += point[now];
      st.push(itr);
    }
  }

  rep(i, n){
    cout << point[i] << " ";
  }
  cout << endl;
	return 0;
}



Measured memory_bytes: 16372
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
 
int main() {
    int n;
    cin >> n;
    VI a(n), b(n), c(n);
    REP(i,n) scanf("%d", &a[i]);
    REP(i,n) scanf("%d", &b[i]);
    REP(i,n) scanf("%d", &c[i]);
    sort(ALL(a));
    sort(ALL(b));
    sort(ALL(c));
 
    VL x(n);
    int j = 0;
    REP(i,n){
        while (j < n && c[j] <= b[i]) j++;
        x[i] = n - j;
    }
    FORR(i,n-2,0) x[i] += x[i+1];
 
    ll ans = 0;
    j = 0;
    REP(i,n){
        while (j < n && b[j] <= a[i]) j++;
        if (j < n) ans += x[j];
    }
    cout << ans << endl;
 
 
    return 0;
}

Measured memory_bytes: 2176
import java.util.Scanner;
import java.util.Arrays;

public class Main {

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

    void solve() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        int ans = 1;
        lavel:
        for (int i = 2; i < X; i++) {
            for (int j = 2;; j++) {
                if ((int) Math.pow(i, j) >X) {
                    continue lavel;
                } else if (ans < (int) Math.pow(i, j)) {
                    ans = (int) Math.pow(i, j);
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 21844
#include <algorithm>
#include <iostream>
#include <limits>
#include <vector>

using namespace std;

void dfs(vector<int>& vs, int depth, int rest, int ans, int* best)
{
    if (ans >= *best)
    {
        return;
    }

    if (depth == vs.size() - 1)
    {
        *best = min(*best, ans + rest);
    }
    else
    {
        const int unit = vs[depth];
        int s = rest / unit;
        int e = max(0, s - (*best - ans));
        for (int i = s; i >= e; i--)
        {
            dfs(vs, depth + 1, rest - unit * i, ans + i, best);
        }
    }
}

int main()
{
    int n;
    cin >> n;
    vector<int> vs;
    vs.push_back(1);

    for (int i = 6; i <= n; i *= 6)
    {
        vs.push_back(i);
    }
    for (int i = 9; i <= n; i *= 9)
    {
        vs.push_back(i);
    }
    sort(vs.begin(), vs.end(), greater<>());
    int ans = numeric_limits<int>::max();
    dfs(vs, 0, n, 0, &ans);

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>
#include <cmath>
#include <cassert>
#include <bitset>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define EL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

// ceil of a/b
inline int ceil(int a, int b) { return (a+b-1)/b; }


int grundy(int n, int k) {
	while(n>=k) {
		if(n%k) n-=ceil(n%k,n/k+1)*(n/k+1);
		else return n/k;
	}
	return 0;
};

signed main() {
	int n;
	std::cin >> n;
	int xorsum = 0;
	rep(i,n) {
		int a,k;
		std::cin >> a >> k;
		xorsum^=grundy(a,k);
	}
	if(xorsum) print("Takahashi");
	else print("Aoki");

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
int main(){
  ll n,k;
  cin>>n>>k;
  vector<ll> a(n);
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  sort(a.rbegin(),a.rend());
  ll ans=0;
  for(int i=0;i<n;i++){
    if(i>=k){
      ans+=a[i];
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4752
import java.util.Scanner;

class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int M = sc.nextInt();
        int D = sc.nextInt();
        int ans=0;
        for(int i=1;i<=M;i++){
            for(int j=10;j<=D;j++){
                String s = String.valueOf(j);
                int a = Integer.parseInt(s.substring(0, 1));
                                int b = Integer.parseInt(s.substring(1, 2));
                if(a>=2 && b>=2 && a*b==i){
                    ans++;
                }
            }
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 24404
import std;

immutable int dirs = 4;
immutable int [dirs] dRow = [-1,  0, +1,  0];
immutable int [dirs] dCol = [ 0, -1,  0, +1];

void main ()
{
	int n;
	while (readf !(" %s") (n) > 0)
	{
		readln;
		auto board = new int [] [] (n + 2, n + 2);
		foreach (row; 1..n + 1)
		{
			foreach (col; 1..n + 1)
			{
				board[row][col] = min (row - 1, n - row,
				    col - 1, n - col);
			}
		}
		auto mark = new bool [] [] (n + 2, n + 2);

		void recur (int row, int col)
		{
			auto cost = board[row][col] + !mark[row][col];
			foreach (dir; 0..dirs)
			{
				auto nRow = row + dRow[dir];
				auto nCol = col + dCol[dir];
				if (board[nRow][nCol] > cost)
				{
					board[nRow][nCol] = cost;
					recur (nRow, nCol);
				}
			}
		}

		int res = 0;
		foreach (cur; readln.splitter.map !(to !(int)))
		{
			cur -= 1;
			auto row = cur % n + 1;
			auto col = cur / n + 1;
			res += board[row][col];
			mark[row][col] = true;
			recur (row, col);
		}
		writeln (res);
	}
}


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

typedef pair<int,int> Pi;
int main(){
int A, B, C, D ,E ,F;
string S,Sa,Sb,Sc;
long long int V[10000000] = {};
bool ans = false;
cin >> A >> B >> C;
cout << min(B , C) << endl;
if(C + B >= A)cout << C + B - A << endl;
else cout << 0 << endl;


return 0; 
}


Measured memory_bytes: 256
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <algorithm>
#define ii pair<int, int>
#define iii pair<ii, int>
#define pq priority_queue

using namespace std;

struct UnionFind {
    vector<int> parent;
    vector<int> size;

    UnionFind(int n) : parent(n) {
        //init
        for (int i = 0; i < n; i++) {
            parent[i] = i;
        }
        size.resize(n, 1);
    }

    int root(int x) {
        //finds parent furthest down, cache results
        if (parent[x] == x) {
            return x;
        }
        return parent[x] = root(parent[x]); //this is for caching
    }

    bool same(int a, int b) {
        return root(a) == root(b);
    }

    void unite(int a, int b) {
        int ra = root(a);
        int rb = root(b);
        if (ra == rb) {
            return;
        }
        parent[rb] = ra;
        size[ra] += size[rb];
    }

    int union_size(int x) {
        return size[root(x)];
    }
};

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

    int n, m, k;
    cin >> n >> m >> k;
    UnionFind union_tree(n);
    vector<int> invalids(n, 0);

    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        union_tree.unite(a - 1, b - 1);
        invalids[a - 1]++;
        invalids[b - 1]++;
    }

    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        if (union_tree.same(a - 1, b - 1)) {
            //also invalid
            invalids[a - 1]++;
            invalids[b - 1]++;
        }
    }

    for (int i = 0; i < n; i++) {
        cout << union_tree.union_size(i) - invalids[i] - 1 << ' ';
    }
}

Measured memory_bytes: 5560
import java.util.Scanner;

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

    int[] rec = new int[2];
    int[] cir = new int[3];

    rec[0] = sin.nextInt();
    rec[1] = sin.nextInt();

    cir[0] = sin.nextInt();
    cir[1] = sin.nextInt();
    cir[2] = sin.nextInt();

    if ( (rec[0] - cir[2]) >= cir[0] && cir[0] >= cir[2]
      && (rec[1] - cir[2]) >= cir[1] && cir[1] >= cir[2]){
        System.out.println("Yes");
    } else {
        System.out.println("No");
    }

    sin.close();
  }
}


Measured memory_bytes: 26284
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef pair<int, int> P;
struct edge{
    int u, v, cost;
};

struct Vertex{
    int x, y, num;
};

int n;
int par[1000006];
int rnk[1000006];

void union_find_init(int x){
    for(int i=0; i<n; i++){
        par[i] = i;
        rnk[i] = 0;
    }
}
int find(int x){
    if(par[x] == x){
        return x;
    }else{
        return par[x] = find(par[x]);
    }
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y){
        return;
    }
    if(rnk[x] < rnk[y]){
        par[x] = y;
    }else{
        par[y] = x;
        if(rnk[x] == rnk[y]){
            rnk[x]++;
        }
    }
}
bool same(int x, int y){
    return find(x) == find(y);
}

bool comp_x(const Vertex& e1, const Vertex& e2){
    return e1.x < e2.x;
}
bool comp_y(const Vertex& e1, const Vertex& e2){
    return e1.y < e2.y;
}
bool comp_cost(const edge& e1, const edge& e2){
    return e1.cost < e2.cost;
}

int main(void){
    cin >> n;
    vector<Vertex> vec;
    edge es[1000006];
    int E = 2*(n-1);
    for(int i=0; i<n; i++){
        int x, y;
        cin >> x >> y;
        Vertex xy;
        xy.x = x;
        xy.y = y;
        xy.num = i;
        vec.push_back(xy);
    }
    sort(vec.begin(), vec.end(), comp_x);
    
    for(int i=0;i<n-1;i++){
        edge e1;
        e1.u = vec[i].num;
        e1.v = vec[i+1].num;
        e1.cost = abs(vec[i+1].x-vec[i].x);
        es[i] = e1;
    }
    sort(vec.begin(), vec.end(), comp_y);
    
    for(int i=0;i<n-1;i++){
        edge e2;
        e2.u = vec[i].num;
        e2.v = vec[i+1].num;
        e2.cost = abs(vec[i+1].y-vec[i].y);
        es[n-1+i] = e2;
    }
    
    sort(es,es+E,comp_cost);
    
    union_find_init(n);
    
    int res = 0;
    for(int i=0; i<E; i++){
        edge e = es[i];
        if(!same(e.u, e.v)){
            unite(e.u, e.v);
            res += e.cost;
        }
    }
    cout << res << endl;

    return 0;
}

Measured memory_bytes: 10484
#include <stdio.h>

int main(void) {

  int n;
  char s[51];
  int i;
  int cnt = 0;

  scanf("%d", &n);
  scanf("%s", s);

  for(i = 0; i < n - 2; i++) {
    if(s[i] == 'A') {
      if(s[i+1] == 'B') {
	if(s[i+2] == 'C') {
	  cnt++;
	}
      }
    }
  }

  printf("%d\n", cnt);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define EPS (1e-7)
#define INF (1 << 30)
#define LLINF (1LL << 60)
#define PI (acos(-1))
#define MOD (1000000007)
#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, int> cnt;
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        cnt[a]++;
    }
    int ans = cnt.size();
    if (ans % 2)
    {
        cout << ans << endl;
    }
    else
    {
        cout << ans - 1 << endl;
    }
}

Measured memory_bytes: 4992
#include <stdio.h>
int main(void) {
	int flag = 1, i, j, minj, n, swap, changes = 0, a[100];
	scanf("%d", &n);
	for (i = 0; i < n; i++)
		scanf("%d", &a[i]);
	for (i = 0; i < n; i++) {
		minj = i;
		for (j = i; j < n; j++) {
			if (a[j] < a[minj])
				minj = j;
		}
		if (a[i] != a[minj]) {
			swap = a[i];
			a[i] = a[minj];
			a[minj] = swap;
			changes++;
		}
	}
	for (j = 0; j < n - 1; j++)
		printf("%d ", a[j]);
	printf("%d\n", a[n - 1]);
	printf("%d\n", changes);
	return 0;
}

Measured memory_bytes: 600
'''A=高橋のHP
B=高橋の攻撃力
C=青木のHP
D=青木の攻撃力 '''

# A,B,C,Dを受け取る
A,B,C,D = map(int,input().split())

#while文でHP計算
while C > 0 and A > 0:
  #高橋の攻撃
  C = C - B
  #勝利判定
  if C <= 0:
    print('Yes')
    break
  #青木の攻撃
  A = A - D
  if A <= 0:
    print('No')
    break

Measured memory_bytes: 9116
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

alias E = Tuple!(int, int);

void main()
{
    auto s = readln.chomp;
    if (s[0] == '0' || s[$-2] == '0' || s[$-1] == '1') {
        writeln(-1);
        return;
    }
    auto n = s.length.to!int;
    foreach (i; 0..n/2) {
        if (s[i] != s[n-i-2]) {
            writeln(-1);
            return;
        }
    } 
    E[] t;
    t.length = n-1;
    int e = 2, last, ti, t_size, last_e;
    void add_node(int i) {
        auto o = e;
        foreach (_; 0..i-last-1) {
            t[ti++] = E(e, ++e);
        }
        if (last_e) t[ti++] = E(e, last_e);
        last_e = o;
        auto ee = e;
        foreach (_; 0..last-t_size) {
            t[ti++] = E(ee, ++e);
        }
        t_size = i;
        ++e;
    }
    foreach (int i; 0..n/2) {
        if (s[i] == '0' && s[i-1] == '1') {
            add_node(i);
        } else {
            if (i == 0 || s[i-1] == '0') last = i;
        }
    }
    if (s[n/2-1] == '1') add_node(n/2);
    t[ti++] = E(1, last_e);
    while (e <= n) {
        t[ti++] = E(1, e++);
    }

    foreach (x; t) {
        writefln("%d %d", x[0], x[1]);
    }
}

Measured memory_bytes: 4120
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n;
    cin >> n;
    rep(i, n) {
        int a;
        cin >> a;
        if (a%2 == 0) {
            if (a%3 != 0 && a%5 != 0) {
                cout << "DENIED" << endl;
                return 0;
            }
        }
    }
    cout << "APPROVED" << endl;
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
//#define MOD 1000000007
#define INF 1000000000

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x% mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) {
		(x *= a.x) %= mod;
		return *this;
	}
	mint operator+(const mint a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint a) const {
		mint res(*this);
		return res *= a;
	}
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const {
		return pow(mod - 2);
	}
	mint& operator/=(const mint a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint a) const {
		mint res(*this);
		return res /= a;
	}
};

// nCr
// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
// usage:
//   combination comb(n+5);
//   ans = comb(n,r);
struct combination {
	vector<mint> fact, ifact;
	combination(int n) :fact(n + 1), ifact(n + 1) {
		assert(n < mod);
		fact[0] = 1;
		for (int i = 1; i <= n; ++i) fact[i] = fact[i - 1] * i;
		ifact[n] = fact[n].inv();
		for (int i = n; i >= 1; --i) ifact[i - 1] = ifact[i] * i;
	}
	mint operator()(int n, int k) {
		if (k < 0 || k > n) return 0;
		return fact[n] * ifact[k] * ifact[n - k];
	}
};


void solve_abc_e() {
	ll n, m, k;
	cin >> n >> m >> k;

	vector<mint> sum(n + 5, 1);
	mint mv = m;
	sum[0] = m;
	rep(i, n) {
		sum[i + 1] *= sum[i] * (mv - 1);
	}

	mint ans = 0;
	mint num;
	mint nv = n;
	combination comb(n + 5);
	ll val = m;
	rep(i, k + 1){
		num = sum[n - 1 - i] * comb(n - 1, i);
		ans += num;
	}

	cout << ans.x << "\n";
}

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

	solve_abc_e();

	return 0;
}

Measured memory_bytes: 7952
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;

int main() {
	cin.tie(0)->sync_with_stdio(false);

	int n; cin >> n;
	vector<ll> a(n);
	REP(i, n) cin >> a[i];

	vector<ll> s(n + 1, 0);
	REP(i, n) {
		s[i + 1] += s[i] + a[i];
		s[i + 1] %= MOD;
	}

	ll res = 0;
	REP(i, n - 1) {
		ll tmp = s[n] - s[i + 1];
		if (tmp < 0)
			tmp += MOD;
		res += a[i] * tmp;
		res %= MOD;
	}
	cout << res << '\n';
	return 0;
}

Measured memory_bytes: 6360
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush,heapify
import sys,bisect,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
mod2 = 998244353
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpln(n): return list(int(sys.stdin.readline()) for i in range(n))

n = inp()
xy = [[] for i in range(n)]
for i in range(n):
    for j in range(inp()):
        a,b = inpl()
        a -= 1
        xy[i].append([a,b])

def check(h):
    t = [0] * n
    for i,j in enumerate(h):
        t[i] = j
    for i,j in enumerate(h):
        if j:
            for k in xy[i]:
                if t[k[0]] != k[1]:
                    return False
    return True

def dfs(h):
    if len(h) == n:
        if check(h):
            return sum(h)
        else:
            return 0
    return max(dfs(h + [True]), dfs(h + [False]))
print(dfs([]))

Measured memory_bytes: 72788
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;


int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;

    if (N == 1) {
        cout << "Hello World" << endl;
    } else {
        int a, b;
        cin >> a >> b;

        cout << a + b << endl;
    }

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
using ld = long double;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);i++)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;i--)
#define lb lower_bound
#define ub upper_bound
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
const ll mod = 1000000007;
const ll INF = 1000000099;
const ll LINF = (ll)(1e18 +99);
vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> void chmin(T& t, const U& u){if(t>u)t=u;}
template<typename T,typename U> void chmax(T& t, const U& u){if(t<u)t=u;}
template<typename T>T gcd(T a,T b){return b?gcd(b,a%b):a;}
template<typename T>T mpow(T a, T n) {
   T res = 1;
   for(;n;n>>=1) {
      if (n & 1) res = res * a;
      a = a * a;
   }
   return res;
}

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

template<typename T>
vector<T> finddivisor(T x){//整数xの約数が入ったvectorを返すよ(xを含む)  
    vector<T> divisor;
    for(T i=1; (i*i)<=x ;i++)
    {
        if(x%i==0){
            divisor.push_back(i);
            if(i*i!=x){
                divisor.push_back(x/i);
            }//約数はペアを持つことを利用

        }
    }
    sort(divisor.begin(),divisor.end());
    //divisor.push_back(x);
    return divisor;
}

signed main(){
    ll n,ans=LINF;cin>>n;
    vector<ll> divs=finddivisor(n);
    for(int i=0;i<=siz(divs)-1-i;i++){
        ans=min(ans,divs[i]+divs[siz(divs)-1-i]-2);
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 384
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
lint mo=1000000007;
vector<int> ta,yo;
int n,m;
lint cal(){
	lint ret=1,x=0,y=0;
	int it=0,i2=0,now=n*m+1;
	/*while(it<n || i2<m){
		if(it<n && i2<m && ta[it]=yo[i2]){
			x++;y++;
		}
		else if(it<n && (i2>=m || ta[it]>yo))
	}*/
	for(int i=n*m;i>0;i--){
		int t=0;
		if(it<n && ta[it]==i){
			t++;it++;
		}
		if(i2<m && yo[i2]==i){
			t+=2;i2++;
		}
		//cout<<i<<' '<<t<<endl;
		if(t==0){
			ret*=(x*y-(n*m-i));
		}
		if(t==1){
			ret*=y;x++;
		}
		if(t==2){
			ret*=x;y++;
		}
		if(t==3){
			x++;y++;
		}
		ret%=mo;
	}
	return ret;
}
int main()
{
	int a,b;
	cin>>n>>m;
	rep(i,n){
		cin>>a;ta.pb(a);
	}
	rep(i,m){
		cin>>a;yo.pb(a);
	}
	sort(All(ta));reverse(All(ta));
	sort(All(yo));reverse(All(yo));
	cout<<cal()<<endl;
}


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

public class Main {

    private static Scanner in = new Scanner(System.in);
    private static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        solve();
        out.flush();
    }

    private static void solve() {
        while (in.hasNextInt()) {
            int a = in.nextInt();
            int b = in.nextInt();

            out.println(Integer.toString(a+b).length());
        }
    }

}



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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> A = vector<int>(N + 2);
	for(i = 1; i <= N; i++){
		scanf("%d", &A[i]);
	}
	vector<int> B = vector<int>(N + 2);
	B[0] = 0;
	for(i = 1; i <= N; i++){
		B[i] = __gcd(B[i - 1], A[i]);
	}
	vector<int> C = vector<int>(N + 2);
	C[N + 1] = 0;
	for(i = N; i >= 0; i--){
		C[i] = __gcd(C[i + 1], A[i]);
	}
	int ans = 0;
	for(i = 1; i <= N; i++){
		ans = max(ans, __gcd(B[i - 1], C[i + 1]));
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N=105;
int a[N];
int main() {
	//freopen("in.txt","r",stdin);
	int n,ans=1e9;
	scanf("%d",&n);
	for(int i=0,x;i<n;i++) {
		scanf("%d",&a[i]);
	}
	for(int i=1;i<=100;i++) {
		int s=0;
		for(int j=0;j<n;j++) {
			s+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,s);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 256
function main(input) {
  var args = input.split(' ');
  var n = parseInt(args[0], 10);
  var r = parseInt(args[1], 10);
  var hiddenRating;
  if ( n >= 10) {
    hiddenRating = r;
  } else {
    var argument = 100*(10 - n);
    hiddenRating = r + argument;
  }
  return hiddenRating;
}
console.log(main(require('fs').readFileSync('/dev/stdin', 'utf8')));

Measured memory_bytes: 7372
import sys

cin = sys.stdin
# cin = open("in.txt", "r")

def line2N():
    return map(int, cin.readline().split())

N, = line2N()
A = list(line2N())
C = [0] * N
C[0] = A[0]
for i in range(1,N):
    C[i] = C[i-1] + A[i]
from collections import Counter
cnt = Counter()
ttl = 0
cnt[0] += 1
cnt[A[0]] += 1
if A[0]==0:
    ttl += 1
for i in range(1,N):
    if C[i] in cnt:
        ttl += cnt[C[i]]
    cnt[C[i]] += 1

# print(cnt)
print(ttl)


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

int main() {
  int n,a,temp;
  int ans = 30;
  cin >> n;
  for (int i=0; i<n; i++) {
    cin >> a;
    temp = 0;
    while (a%2==0) {
      temp += 1;
      a /= 2;
    }
    if(temp<ans) {
      ans = temp;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    int A[3];
    cin >> N >> A[0] >> A[1] >> A[2];
    int l[10];
    rep(i, N) cin >> l[i];
    int ans = INF;
    rep(i, pow(4, N) + 0.5) {
        int bit = i;
        int cnt[4] = {};
        int height[4] = {};
        rep(k, N) {
            cnt[bit % 4]++;
            height[bit % 4] += l[k];
            bit /= 4;
        }
        int m = 100;
        rep(j, 3) m = min(m, cnt[j]);
        if (m == 0) continue;
        int tmp = 0;
        rep(j, 3) tmp += abs(A[j] - height[j]) + (cnt[j] - 1) * 10;
        ans = min(ans, tmp);
    }
    cout << ans << endl;

    return 0;
}


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

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

    while(num != 0){
        int temp = num%10;
        if(temp == 7){
            cout<<"Yes"<<endl;
            return 0;
        }
        num /= 10;
    }
    cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i = (a);i < (b);++i)
#define FORR(i, b, a) for (int i = (b) - 1;i >= 0;--i)
#define REP(i, n) for(int i = 0;i < (n);++i)
#define REPR(i, n) for(int i = (n) - 1;i >= 0;--i)
#define ITER(itr, v) for(auto itr = v.begin();itr != v.end();++itr)
#define SORT(v) sort(v.begin(), v.end())
#define REV(v) reverse(v.begin(), v.end())
#define SIZE(v) int(v.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

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

	int N, X, Y;
	cin >> N >> X >> Y;
	vector<int> res(N);
	FOR(i, 1, N) {
		FOR(j, i, N + 1) {
			int d = min(j - i, abs(i - X) + 1 + abs(j - Y));
			res[d]++;
		}
	}
	
	FOR(k, 1, N) cout << res[k] << endl;

	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        int r = S.indexOf("A");
        int l = S.lastIndexOf("Z");
        int ans = l-r+1;
        System.out.println(ans);
    }
}

Measured memory_bytes: 14640
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;
    rep(i, n) {
        if ( s[i] == s[k-1] ) cout << s[i];
        else                  cout << '*';
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int A, B, K;
    cin >> A >> B >> K;
    for(int i = A * B; i >= 1; i--) {
        if(A % i == 0 && B % i == 0) K--;
        if(K == 0) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}


Measured memory_bytes: 3624
import java.util.*;

public class Main {
	static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {
		int N=sc.nextInt();
		int re[] = new int[10050];
		Arrays.fill(re,0);
		for(int x=1;x<105;x++) {
			for(int y=1;y<105;y++) {
				for(int z=1;z<105;z++) {
					int v=x*x+y*y+z*z+x*y+y*z+z*x;
					if(v<10050) {
						re[v]++;
					}
				}
			}
		}
		for(int i=1;i<=N;i++)
			System.out.println(re[i]);
	}
}

Measured memory_bytes: 38876
h, w = map(int, input().split())
l = [0]*h
for i in range(h):
  l[i] = str(input())
  
dp = [[0]*w for _ in range(h)]
dp[0][0] = 1
for i in range(h):
  for j in range(w):
    if i+1 < h and l[i+1][j] == '.':
      dp[i+1][j] += dp[i][j]
    if j+1 < w and l[i][j+1] == '.':
      dp[i][j+1] += dp[i][j]
      
print(dp[-1][-1]%(10**9+7))

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

using ll = long long;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
#define debug(x) cerr << #x << " : " << x << endl

class Solver {
  public:
    vector<vector<ll>> memo;
    ll nCk(int n, int k){
        if(memo[n][k] >= 0) return memo[n][k];
        if(k == 0 or k == n) return 1;
        else return memo[n][k] = nCk(n-1, k-1) + nCk(n-1, k);
    }

    Solver() {
        memo.resize(100, vector<ll>(100, -1));
    }
    
    bool solve() {
        int N, A, B; cin >> N >> A >> B;
        vector<ll> V(N);
        rep(i, N) cin >> V[i];
        sort(all(V), greater<ll>());

        ll sum = 0;
        rep(i, A) sum += V[i];

        ll selectable_size = 0;
        rep(i, N) selectable_size += V[i] == V[A - 1];
        ll select_cnt = 0;
        rep(i, A) select_cnt += V[i] == V[A - 1];
        
        cout << fixed << setprecision(10) << (double)sum / A << endl;

        ll ans = 0;
        ans += nCk(selectable_size, select_cnt);

        if(V[0] == V[A - 1]) {
            repeat(i, 1, min<int>(B - A, selectable_size - select_cnt) + 1) {
                ans += nCk(selectable_size, i + select_cnt);
            }
        }
        cout << ans << endl;
        
        return 0;
    }
};

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


Measured memory_bytes: 384
n,m,k=map(int,input().split())
a=list(map(int,input().split()))
b=list(map(int,input().split()))

aa=[a[0]]
for i in range(n-1):
    aa.append(aa[i]+a[i+1])
aa.insert(0,0)
bb=[b[0]]
for i in range(m-1):
    bb.append(bb[i]+b[i+1])
    
import bisect
l=[]
for i in range(n+1):
    p=k-aa[i]
    if p>=0:
        l.append(i+bisect.bisect_right(bb,p))
    else:
        break
print(max(l))



Measured memory_bytes: 48668
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();

		int l = s.length();

		int cnt = 0;
		for(int i = 0; i < l/2-0.5; i++) {
			if(s.charAt(i) != s.charAt(l-i-1)) {
				cnt++;
			}
		}

		System.out.println(cnt);


	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define el '\n'
typedef long long ll;
const int mod = 1e9+7;
ll dp[100005];
int n, m;
int main() {
  int n, m;
  cin >> n >> m;
  vector<bool> vis(n+1);
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    vis[x] = 1;
  }
  dp[0] = 1;
  for (int i = 1; i <= n; i++) {
    if (vis[i]) continue;
    dp[i] += dp[i-1]+dp[i-2];
    if (dp[i] >= mod) dp[i] -= mod;
  }
  cout << dp[n] << el;;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
long long n,k,vis[5005],p[5005],c[5005],sum[5005],ans=-1e18;

int main()
{
    cin>>n>>k;
    for(int i=1;i<=n;i++)
		cin>>p[i];
    for(int i=1;i<=n;i++)
		cin>>c[i];
    for(int i=1;i<=n;i++)
	{
        long long s=c[i];
        vector<long long> t; 
		t.push_back(s);
        for(int j=p[i];j!=i;j=p[j])
        {
			s+=c[j];
			t.push_back(s);
		}
		int l=t.size();
        for(int j=0;j<l;j++)
		{
            long long rest=k-j-1;
            if(rest<0)
				break;
			
            ans=max(ans,t[j]+(rest/l)*max(s,0LL));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3832
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


int main(){
	string s;
	int res=0;
	
	while(cin>>s){
		string t;
		rep(i,s.size()){
			t[i]=s[s.size()-1-i];
		}
		bool f=true;
		rep(i,s.size()){
			if(s[i]!=t[i]){
				f=false;
				break;
			}
		}
		if(f) res++;
	}
	cout<<res<<endl;
	return 0;
}
		
		

Measured memory_bytes: 1184
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Abc
{
    public class QuestionA
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

			string a = Console.ReadLine();
			string b = Console.ReadLine();
			string c = Console.ReadLine();

			string a1 = a[0].ToString();
			string b1 = b[1].ToString();
			string c1 = c[2].ToString();


			string result = a1 + b1 + c1;

            Console.WriteLine(result);

            Console.Out.Flush();
        }
    }
}


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

using namespace std;

#define int long long
#define N 100005
#define MOD 1000000007


int32_t main()
{
    int n, m;
    cin>>n>>m;

    int ans = 0;
    if( n > m )
        swap(n, m);
    if(n > 2 && m > 2) 
    {
        ans = (n-2)*(m-2);
    }
    else if(n==1)
    {
        if(m==1)
            ans = 1;
        else
            ans = m-2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n';

typedef long long ll;

using namespace std;

const string YES = "";
const string NO  = "";

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

    int a[3];

    cin >> a[0] >> a[1] >> a[2];

    sort(a, a + 3);

    cout << abs(a[1] - a[0]) + abs(a[2] - a[1]) << endl;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
	int a,b,c,d[100],e,f,g,h;
	scanf("%d",&a);
	for (b=0;b<a;b++)
	{
		scanf("%d",&c);
		d[b]=c;
	}
	for (e=0;;e++)
	{
		f=0;
		for (b=0;b<a;b++)
		{
			if (e<=d[b])
			{
				f++;
			}
		}
		if (e>f)
		{
			break ;
		}
	}
	printf("%d\n",e-1);
	return 0;
}

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

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

typedef pair<int, int> result;
constexpr int MAX_M = 1000000;
constexpr int SIZE = 1100;

int n, m;
bool is_prime[MAX_M + 1];
int x[MAX_M + 1];
int y[MAX_M + 1];
int field[SIZE][SIZE];
result memo[SIZE][SIZE];

void sieve() {
	fill_n((bool *)is_prime, sizeof(is_prime) / sizeof(bool), true);
	is_prime[0] = is_prime[1] = false;

	for(int i = 1; i <= MAX_M; ++i) {
		if(is_prime[i]) {
			for(int j = i + i; j <= MAX_M; j += i) {
				is_prime[j] = false;
			}
		}
	}
}

void make_field() {
	fill_n((int *)field, sizeof(field) / sizeof(int), INT_MAX);

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

	int cx = SIZE / 2;
	int cy = SIZE / 2;
	int dir = 0;

	for(int i = 1; i <= MAX_M; ++i) {
		field[cy][cx] = i;
		x[i] = cx;
		y[i] = cy;

		const int left = (dir + 1) & 0x3;
		if(field[cy + dy[left]][cx + dx[left]] == INT_MAX) {
			dir = left;
		}

		cx += dx[dir];
		cy += dy[dir];
	}
}

void init() {
	sieve();
	make_field();
}

result dfs(int cx, int cy) {
	const int &value = field[cy][cx];
	if(value > m) return result(-1, -1);

	auto &res = memo[cy][cx];
	if(res.first != -1) return res;

	res.first = 0;
	res.second = (is_prime[value] ? value : 0);

	for(int dx = -1; dx <= 1; ++dx) {
		chmax(res, dfs(cx + dx, cy + 1));
	}

	if(is_prime[value]) ++res.first;
	return res;
}

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

	init();

	while(cin >> m >> n && m) {
		fill_n((result *)memo, sizeof(memo) / sizeof(result), result(-1, -1));
		const auto ans = dfs(x[n], y[n]);
		cout << ans.first << ' ' << ans.second << endl;
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 24220
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <iostream>
#include <string>

#include <algorithm>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <vector>

#define PB push_back
#define MP make_pair

#define FOR(i, b, e) for(int i=(b);i<(e);i++)
#define REP(i, n) FOR(i,0,n)

#define ALL(v) (v).begin(),(v).end()

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;

typedef pair<int, int> PII;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VPII;

const int MOD = 1000000007;
const int INF = 1e9;

const double EPS = 1e-9;
const double PI = acos(-1.0);

LL gcd(LL a, LL b) { return b ? gcd(b, a % b) : a; }
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }

int W, H, x, y;

int main() {
    cin >> W >> H >> x >> y;
    double s = W / 2.0 * H;
    int t = (W == 2 * x && H == 2 * y);
    printf("%lf %d", s, t);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	int n;
	cin>>n;
	ll a[n];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	ll ans=0,extra=0;
	for(int i=0;i<n-1;i++)
	{
		if(a[i]<=a[i+1])
		continue;
		else
		{
			extra=abs(a[i]-a[i+1]);
			ans+=extra;
			a[i+1]+=extra;
		}
	}
	cout<<ans;
}

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

int main(){
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL);  
    map<ll,ll> m;
   	for(ll i=1; i<=100; i++){
   		for(ll j=1; j<=100; j++){
   			for(ll k=1; k<=100; k++){
   				ll a = (i*i)+(j*j)+(k*k)+(i*j)+(j*k)+(i*k);
   				m[a]++;
   			}
   		}
   	}
   	
   	ll n;
   	cin>>n;
   	for(ll i=1; i<=n; i++){
   		cout<<m[i]<<"\n";
   	}
    return 0;
}

Measured memory_bytes: 6108
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  vi a(n), p(n, -INF), q(n, -INF);
  rep(i, n) cin >> a[i];
  int s = 0;
  rep(i, n) {
    int x = i, c = 0;
    for (; p[x] < 0; c++) {
      p[x] = c;
      q[x] = i;
      x    = (x + a[x]) % n;
    }
    if (q[x] == i) s += c - p[x];
  }
  cout << s << endl;
}

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

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        AServalVsMonster solver = new AServalVsMonster();
        solver.solve(1, in, out);
        out.close();
    }

    static class AServalVsMonster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            double h = in.nextInt();
            double a = in.nextInt();
            out.println((int) Math.ceil(h / a));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 21460
#include <algorithm>
#include <functional>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <string>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <bitset>
#include <climits>

typedef long long ll;
#define all(c) (c).begin(), (c).end()
#define rep(i,n) for(long long i=0;i<(n);i++)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)
#define fr first
#define sc second

using namespace std;

ll N,M,Q;
ll ans[1003];
void plot() {
    rep(i,M) {
        ll count=0;
        ll val=0;
        rep(j,N) {
            if(((ans[i])>>j)&1LL) {
                count++;
                val=j;
            }
        }
        if(count==1) {
            if(val<10) printf("%d",val);
            else printf("%c",'A'+val-10);
        }
        else cout<<"?";
    }
    cout<<endl;
}

void update(ll& mask, string S, string B) {
    ll bit=0LL;
    rep(i,N) if(S[i]=='1') bit|=(1LL<<i);
    mask^=bit;
    // printf("%s : %X\n", S.c_str(),bit);
    rep(i,M) {
        if(B[i] == '1') {
            ans[i] &= mask;
        }
        else {
            ans[i] &= ~mask;
        }
    }
}


void solve() {
    
    rep(i,1003) ans[i]=(1LL<<N)-1LL;
    ll mask=0LL;
    string S,B;
    rep(i,Q) {
        cin>>S>>B;
        update(mask, S,B);

        // rep(i,M) cout<<ans[i]<<",";
        // cout<<endl;
    }
    plot();
}

int main() {
    while(cin>>N>>M>>Q) {
        if(N+M+Q==0) break;
        solve();
    }

    return 0;
}

Measured memory_bytes: 1248
#include<stdio.h>

int main()
{
	int i,N;
	unsigned int A[100];
	unsigned int max, min,ans;

	scanf("%d", &N);
	for (i = 0; i < N; i++)
		scanf("%u", &A[i]);

	max = A[0];
	min = A[0];
	for (i = 1; i < N; i++)
	{
		if (max < A[i])
			max = A[i];
		if (min>A[i])
			min = A[i];
	}
	ans = max - min;
	printf("%u\n", ans);

	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void)
{
  int K;
  int N;
  int A[200000];
  int i;
  int min = 10000000;
  int dist = 0;

  scanf("%d %d", &K, &N);
  for ( i = 0; i < N; i++ ) {
    scanf("%d", &A[i]);
  }

  // i番目からスタートする
  for ( i = 0; i < N; i++ ) {
    dist = 2*(A[i] - A[0]) + (A[N-1] - A[i]);
    if ( dist < min ) {
        min = dist;
    }
    if ( i > 0 ) {
      dist = (K - A[i]) + A[i - 1];
      if ( dist < min ) {
        min = dist;
      }
    }
  }
  for ( i = N - 1; i >= 0; i-- ) {
    dist = 2 * (A[N-1] - A[i]) + ( A[i] - A[0] );
    if ( dist < min ) {
      min = dist;
    }
    if ( i < (N - 1) ) {
      dist = A[i] + ( K - A[i+1] );
      if ( dist < min ) {
        min = dist;
      }
    }
  }

  printf("%d\n", min);

  return 0;

}


Measured memory_bytes: 896