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

#include <utility>

using namespace std;

typedef long long ll;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

template<class T>
class SegmentTree {
    int n;
    vector<T> data;
    T def;
    function<T(T, T)> operation;
    function<T(T, T)> update;

    T _query(int a, int b, int k, int l, int r) {
        // 交差しない
        if (r <= a || b <= l) return def;
        // 区間 [a, b) に l, r が含まれる
        if (a <= l && r <= b) return data[k];
        // 左の子
        T c1 = _query(a, b, 2 * k + 1, l, (l + r) / 2);
        // 右の子
        T c2 = _query(a, b, 2 * k + 2, (l + r) / 2, r);
        return operation(c1, c2);
    }

public:
    /**
     * @param _n size
     * @param _def initial value
     * @param _operation operation for query
     * @param _update operation for update
     */
    SegmentTree(size_t _n, T _def, function<T(T, T)> _operation, function<T(T, T)> _update)
            : def(_def), operation(move(_operation)), update(move(_update)) {
        n = 1;
        while (n < _n) {
            n *= 2;
        }
        data = vector<T>(2 * n - 1, def);
    }

    /**
     * iの値をxに更新
     * @param i index ( 0-indexed )
     * @param x  value
     */
    void change(int i, T x) {
        i += n - 1;
        data[i] = update(data[i], x);
        while (i > 0) {
            i = (i - 1) / 2;
            data[i] = operation(data[i * 2 + 1], data[i * 2 + 2]);
        }
    }

    /**
     * [a, b)の区間でクエリを実行
     */
    T query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    /**
     * 添字でアクセス
     * @param i index ( 0-indexed )
     */
    T operator[](int i) {
        return data[i + n - 1];
    }
};

void Main() {
    int N, Q;
    cin >> N >> Q;
    SegmentTree<ll> segmentTree(N, (1ll << 31) - 1, [](ll a, ll b) { return min(a, b); }, [](ll a, ll b) { return b; });

    rep(q, Q) {
        int com, x, y;
        cin >> com >> x >> y;
        if (com == 1) {
            ll res = segmentTree.query(x, y + 1);
            cout << res << '\n';
        } else {
            segmentTree.change(x, y);
        }
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}



Measured memory_bytes: 4972
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<utility>
#include<numeric>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<functional>
#include<iterator>
#include<cmath>
#include<cctype>

using namespace std;

typedef long long ll;
typedef pair<int,int> P;

const int INF = 1e9;
const ll LINF = 1e18;

struct edge{int to,cost;};


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

	int n,m;
	cin >> n >> m;
	
	vector<int> es[n];
	int a,b;
	for(int i=0;i<m;i++){
		cin >> a >> b;
		a--;b--;
		es[a].push_back(b);
	}

	int d[n];
	d[0]=0;
	for(int i=1;i<n;i++) d[i] = INF;
	
	priority_queue<P,vector<P>,greater<P>> que;
	que.push(P(0,0));
	while(!que.empty()){
		P tmp = que.top(); que.pop();
		int cost=tmp.first,t=tmp.second;
		if(d[t] < cost) continue;
		for(int i=0;i<es[t].size();i++){
			int e=es[t][i];
			if(d[e] > cost+1){
				d[e] = cost+1;
				if(d[e] < 2) que.push(P(d[e],e));
			}
		}
	}
	cout << (d[n-1]<=2?"":"IM") << "POSSIBLE\n";

	return 0;
}

Measured memory_bytes: 10360
# https://abc113.contest.atcoder.jp/tasks/abc113_c
def pad(n):
    return '{:0>6}'.format(n)


N, M = map(int, input().split())
work = [None for _ in range(M)]
orig = [None for _ in range(M)]  # retains original order
for i in range(M):
    Pi, Yi = map(int, input().split())
    data = [Pi, Yi, 1, i]
    work[i] = data
    orig[i] = data

work.sort(key=lambda x: x[1])  # sort by year
work.sort(key=lambda x: x[0])  # sort by prefectures

for i in range(1, M):
    if work[i][0] == work[i - 1][0]:
        work[i][2] = work[i - 1][2] + 1

ans = []
for di in orig:
    ans.append(pad(di[0]) + pad(di[2]))
print('\n'.join(ans))


Measured memory_bytes: 39152
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if(b == 100){
      System.out.println(101 * (int)Math.pow(100, a));
    }else{
      System.out.println(b * (int)Math.pow(100, a));
    }
  }
}

Measured memory_bytes: 21844
#include<stdio.h>

int main(void) {
	int i, n, j, a[1000], k = 0, v;
	
	scanf("%d", &n);
	for (i = 0; i < n; ++i)
	{
		scanf("%d", &a[i]);
	}
	
		for (j = 0; j < n; ++j)
	{
		printf("%d", a[j]);
		if (j != n-1) printf(" ");
	}
	printf("\n");
	
	for (i = 1; i < n; ++i)
	{
		v = a[i];
		j = i - 1;
		
		while (j >= 0 && a[j] > v)
		{
			a[j+1] = a[j];
			j--;
		}
		
		a[j+1] = v;
		
		for (j = 0; j < n; ++j)
		{
			printf("%d", a[j]);
			if (j != n-1) printf(" ");
		}
		printf("\n");
	}
	
	return 0;
}

Measured memory_bytes: 2720
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

class UnionFind {
public:
    vector<int> par;
    int num;

    UnionFind(int n) : par(n, -1), num(n) {};

    int root(int x) {
        if (par[x] < 0) return x;
        return par[x] = root(par[x]);
    }

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

    bool unite(int x, int y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (size(x) < size(y)) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        num--;
        return true;
    }

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

int main() {
    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    rep(i, 0, m) {
        int x, y;
        cin >> x >> y;
        if (!uf.same(x, y)) uf.unite(x, y);
    }
    int q;
    cin >> q;
    vector<string> ans(q);
    rep(i, 0, q) {
        int x, y;
        cin >> x >> y;
        if (uf.same(x, y)) ans[i] = "yes";
        else ans[i] = "no";
    }

    rep(i, 0, q) cout << ans[i] << endl;
    return 0;
}



Measured memory_bytes: 3920
import math
a, b, h, m = map(int, input().split())

theta = abs((h*30 + 0.5*m) -6 * m)

theta = min(theta, 360-theta)

ans = math.sqrt(a**2 + b**2 - 2*a*b*math.cos(math.radians(theta)))

print(ans)

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

//Made with <3 by MinumCoklatPanas
typedef long long ll;
const ll INF = 1e9;
const ll INFF = 1e18;
const ll MAXN = 510;
const ll MOD = 1e9 + 7;
const double PI = acos(-1.0);
const double INFD = 1E9;
const double EPS = 1e-9;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n,m;
    cin >> n >> m;
    priority_queue< ll > pq;
    for (ll i = 1 ; i <= n ; i++)
    {
        ll ta;
        cin >> ta;
        pq.push(ta);
    }
    for (ll i = 1 ; i <= m ; i++)
    {
        ll cur = pq.top();
        pq.pop();
        pq.push(cur / 2);
    }
    ll ans = 0;
    for (ll i = 1 ; i <= n ; i++)
    {
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int r, g, d; cin >> r >> g >> d;
  int a = r * 100 + g * 10 + d;
  if(a % 4 == 0) cout << "YES" << endl;
  else cout << "NO" << endl;
}  


Measured memory_bytes: 3632
#include "bits/stdc++.h"

using namespace std;

#define pb              push_back
#define endl            "\n"
#define sz(x)          (int) (x.size())
#define all(v)          v.begin(), v.end()
#define isOdd(n)       (n&1)
#define pow(n, m)      (ll)powl(n, m)
#define clr(x, val)     memset(x, val, sizeof(x))

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;


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

    string s; cin >> s;
    int c = 0, n = 3, mx = 0;
    for(int i = 0; i <= n; i++){
        if(i == n || s[i] == 'S'){
            mx = max(mx, c);
            c = 0;
            if(i == n) break;
        }else c++;
    }
    cout << mx;
    return 0;
}


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

long long int gcd(long long int a,long long int b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    long long int i,j,k,l,m=0,n;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=n;j++)
        {
            for(k=1;k<=n;k++)
            {
                m+=gcd(i,gcd(j,k));
            }

        }
    }
    printf("%lld\n",m);
}


Measured memory_bytes: 3780
def gcd(x,y):
    if x<y:
        x,y=y,x
    if y==0:
        return x
    if y==1:
        return 1
    else:
        return gcd(y,x%y)
n=int(input())
t=int(input())
lcm=t
a=t
for i in range(n-1):
    t=int(input())
    a=gcd(lcm,t)
    lcm=lcm*t//a
print(lcm)

Measured memory_bytes: 3064
#include <cmath>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <cstdlib>
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <set>
using namespace std;

typedef vector<double> vec;
typedef vector<vec> mat;

bool nz(double d){
#define ABS(x) ((x) < 0.0 ? -(x) : (x))
  return ABS(d) > 1e-2;
}

vec solve(mat m, vec v){
  const int n = m.size();

  REP(i,n){
    REP(j,n) if(nz(m[i][j])){
      for(int k = 0; k < n; k++) if(i != k){
        if(nz(m[k][j])){
          const double rate = m[k][j] / m[i][j];
          for(int l = 0; l < n; l++){
            m[k][l] -= m[i][l] * rate;
          }
          v[k] -= v[i] * rate;
        }
      }

      break;
    }
  }

  REP(i,n) REP(j,n){
    if(nz(m[i][j]) && i != j){
      m[i].swap(m[j]);
      swap(v[i], v[j]);
    }
  }

  // REP(i,n){ REP(j,n) printf("%.2f ", m[i][j]); printf(": %.2f\n", v[i]); } puts("");

  REP(i,n)
    v[i] /= m[i][i];

  return v;
}

bool vecEq(const vec &lhs, const vec &rhs){
  REP(i, lhs.size()) if(nz(lhs[i] - rhs[i])){
    return false;
  }
  return true;
}

int main(){
  while(const int n = getInt()){
    vec v(n + 3); REP(i,n + 3) scanf("%lf", &v[i]);

    vector<vec> ans(n + 3);

    REP(i,n + 3){
      vector<vec> tmp;
      REP(j, n + 3) if(i != j){
        vec vv;
        mat mm;

        REP(k, n + 3){
          if(k != i && k != j){
            vec tmp;
            vv.push_back(v[k]);
            REP(l, n + 1){
              tmp.push_back(k + l == 0 ? 1.0 : pow(k, l));
            }
            mm.push_back(tmp);
          }
        }

        tmp.push_back(solve(mm, vv));
      }

      bool ok = true;
      REP(k,n + 2) if(!vecEq(tmp[0], tmp[k])){
        ok = false;
      }

      // REP(j,n + 2){ REP(k, tmp[j].size()) printf("%.10f ", tmp[j][k]); puts(""); } puts("");

      if(ok){
        printf("%d\n", i);
        break;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long unsigned int ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

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

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// https://atcoder.jp/contests/abc076/tasks/abc076_c

int main() {
    string S; cin >> S;
    string T; cin >> T;

    if (S.length() < T.length()) {
        cout << "UNRESTORABLE" << "\n";
        return 0;
    }

    string ans = "~";
    REP(i, S.length() - T.length() + 1) {
        string sub = S.substr(i, T.length());

        bool can = true;
        REP(j, T.length()) {
            if (sub[j] != T[j] && sub[j] != '?') can = false;
        }

        if (can) {
            string P = S;
            REP(j, T.length()) {
                P[i+j] = T[j];
            }
            REP(j, P.length()) {
                if (P[j] == '?') P[j] = 'a';
            }
            ans = min(ans, P);
        }
    }

    if (ans == "~") {
        cout << "UNRESTORABLE" << "\n";
    } else {
        cout << ans << "\n";
    }

    return 0;
}


Measured memory_bytes: 256
/*maximum subarray sum 
 * kadane algo space optimize dp
*/




#include <bits/stdc++.h>
using namespace std;
#define int long long


signed main()
{
	int N,W;
	cin>>N>>W;
	int val[N];
	int wei[N];
	for(int i = 0;i<N;i++)cin>>wei[i]>>val[i];
	int dp[N+1][W+1];
	for(int i = 0;i<N+1;i++)
	{
		for(int j = 0;j<W+1;j++)
		{
		dp[i][j]=0;
		}
	}
	
	for(int i = 0;i<=N;i++)
	{
		for(int w = 0;w<=W;w++)
		{	
			if(i==0 || w==0)
			dp[i][w] = 0;
			
			else if(w - wei[i-1] >= 0)
			dp[i][w] = max(dp[i-1][w - wei[i-1]] + val[i-1],dp[i-1][w]);
			
			else
			dp[i][w] = dp[i-1][w];
		}
	}
	cout<<dp[N][W]<<endl;
}


Measured memory_bytes: 82432
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,K,pt[3];
	char T[100001];
	scan(N>>K);
	rep(i,3) scan(pt[i]);
	scan(T);
	ll ans=0;
	rep(i,K){
		int dp[3]={},olddp[3]={};
		int sum=0;
		for(int j=0;i+j*K<N;j++){
			int te;
			if(T[i+j*K]=='r') te=2;
			else if(T[i+j*K]=='s') te=0;
			else te=1;
			rep(k,3){
				rep(l,3){
					if(k==l) continue;
					if(te==l) dp[l]=max(dp[l],olddp[k]+pt[l]);
					else dp[l]=max(dp[l],olddp[k]);
					sum=max(sum,dp[l]);
				}
			}
			rep(k,3) olddp[k]=dp[k];
		}
		ans+=sum;
	}
	prin(ans);
	return 0;
}


Measured memory_bytes: 384
package main

import "fmt"

func main() {
	var h, w int
	fmt.Scan(&h, &w)
	a := make([][]byte, h+2)
	for i := range a {
		a[i] = make([]byte, w+2)
		for j := 0; j < len(a[i]); j++ {
			a[i][j] = byte('#')
		}
	}
	for i := 1; i <= h; i++ {
		var s string
		fmt.Scan(&s)
		for j := 1; j <= w; j++ {
			a[i][j] = s[j-1]
		}
	}
	for i := range a {
		fmt.Println(string(a[i]))
	}
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define endl '\n'
const ll mod = 1000000007;
const double PI = 3.141592653589793238463;
using namespace std;
ll a[(int)1e5+9];
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    ll x,k;
    cin>>x>>k;
    set<ll>s;
    ll y,b;
    for (int i=0;i<x;i++){
        cin>>y>>b;
        a[y]+=b;
        s.insert(y);
    }
    ll sum=0;
    for (auto i=s.begin();i!=s.end();i++){
        if (sum+a[*i]>=k)
        {
            cout<<*i<<endl;
            break;
        }
        sum+=a[*i];
    }
    return 0;
}


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

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

    int n, m;
    cin >> n >> m;

    cout << (1900*m + 100 * (n-m)) * pow(2, m) << endl;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
    int n, m, x, y;
    scanf("%d %d %d %d", &n, &m, &x, &y);
    int xx, yy;
    int maxx = -2000000000, miny = 2000000000;
    int i;
    for (i = 0; i < n; i++)
    {
        scanf("%d", &xx);
        if (xx > maxx)
            maxx = xx;
    }
    for (i = 0; i < m; i++)
    {
        scanf("%d", &yy);
        if (yy < miny)
            miny = yy;
    }
    if (y < miny)
        miny = y;
    if (x > maxx)
        maxx = x;
    if (maxx < miny)
        printf("No War\n");
    else
        printf("War\n");
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<iomanip>
using namespace std;
int main(){
	string s;
	int N;
	cin >> s;
	N=s.size();
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(s[i]==s[j]){
				cout << "no" <<endl;
				return 0;
			}
		}
	}
	cout << "yes" << endl;
	return 0;
}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(b == 1){
        cout << 0 << endl;
        return 0;
    }

    int i = 0;
    while(1){
        if(a + (a-1) * i >= b) break;
        i++;
    }
    cout << i + 1 << endl;
    return 0;
}

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

int main(){
    int A, B, C, D, E; cin >> A >> B >> C >> D >> E;

    int sum = ((A + 9) / 10 * 10) + ((B + 9) / 10 * 10) + ((C + 9) / 10 * 10) + ((D + 9) / 10 * 10) + ((E + 9) / 10 * 10);
    sum -= max({(A + 9) / 10 * 10 - A, (B + 9) / 10 * 10 - B, (C + 9) / 10 * 10 - C, (D + 9) / 10 * 10 - D, (E + 9) / 10 * 10 - E});

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 10000000099
// aよりもbが大きいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する
// (更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;  // aをbで更新
    return true;
  }
  return false;
}

ll countlunlun(string x){ // x以下のルンルン数の個数
  vector<vector<vector<vector<ll>>>> dp(20, vector<vector<vector<ll>>>(2, vector<vector<ll>>(10, vector<ll>(2, 0))));
  rep(i, sz(x)){
    if(i == 0){
      rep(d, (x.at(i)-'0')+1){
        if(d == 0){
          dp.at(i+1).at(1).at(d).at(0) = 1;
        }
        else if(d < x.at(i)-'0'){
          dp.at(i+1).at(1).at(d).at(1) = 1;
        }
        else{
          dp.at(i+1).at(0).at(d).at(1) = 1;
        }
      }
    }
    else{
      rep(j, 2){
        rep(d, (j ? 9 : x.at(i)-'0')+1){
          if(d == 0){
            dp.at(i+1).at(j || ( d < x.at(i)-'0' )).at(d).at(0) += dp.at(i).at(j).at(0).at(0);
            dp.at(i+1).at(j || ( d < x.at(i)-'0' )).at(d).at(1) += dp.at(i).at(j).at(1).at(1) + dp.at(i).at(j).at(0).at(1);
          }
          else if(d == 9){
            dp.at(i+1).at(j || ( d < x.at(i)-'0' )).at(d).at(1) += dp.at(i).at(j).at(0).at(0) + dp.at(i).at(j).at(8).at(1) + dp.at(i).at(j).at(9).at(1);
          }
          else{
            dp.at(i+1).at(j || ( d < x.at(i)-'0' )).at(d).at(1) += dp.at(i).at(j).at(0).at(0) + dp.at(i).at(j).at(d+1).at(1) + dp.at(i).at(j).at(d-1).at(1) + dp.at(i).at(j).at(d).at(1);
          }
        }
      }
    }
  }
  ll sum = 0;
  rep(d, 10){
    sum += dp.at(sz(x)).at(1).at(d).at(1) + dp.at(sz(x)).at(0).at(d).at(1);
  }
  return sum;
}

int main(){
  ll K;
  cin >> K;
  ll l = 0;
  ll r = INF;
//  cout << countlunlun(to_string(21)) << endl;
//  cout << countlunlun(to_string(102)) << endl;
  while(r-l > 1){
//    cout << (l+r)/2 << " " << countlunlun(to_string((l+r)/2))<<  "ko" << endl;
    if(countlunlun(to_string((l+r)/2)) < K){
      l = (l+r)/2;
    }
    else{
      r = (l+r)/2;
    }
//    cout << l << " " << r << endl;
  }
  cout << r << endl;
}

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

using namespace std;
#define inputInt(a) int a; cin >> a; 
#define inputInt2(a,b) int a; int b; cin >> a >> b; 
#define inputInt3(a,b,c) int a; int b; int c; cin >> a >> b >> c;
#define inputLong(a) long a;cin >> a; 
#define inputIntArray(a,N) int a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputLongArray(a,N) long a[N];for(int i=0;i<N;i++){cin >> a[i];}
#define inputIntArray2(a,b,N) int a[N]; int b[N]; for(int i=0;i<N;i++){cin >> a[i] >> b[i];}
#define output(answer) cout << answer << endl;
#define fN(i,N)    for(int i=0; i<N; i++)
#define fSE(i,s,e) for(int i=s; i<=e; i++)
#define ll long long
#define pb push_back
#define mp make_pair
#define fi first
#define se second
const ll MOD2 = 998244353;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

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

  //main
  int N, x; cin >> N >> x;
  vector<int> a(N);
  for(int i=0; i<N; i++){ cin >> a[i]; }
  
  // output
  if(accumulate(a.begin(), a.end(), 0LL) < x){ cout << N-1 << endl; return 0; }
  
  sort(a.begin(), a.end());
  int tmp = 0, count = 0;
  for(int i=0; i<N; i++){
    tmp += a[i];
    if(tmp <= x){ count ++; }
    else{ break; }
  }
  
  cout << count << endl;
  
  return 0;
}


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

#define ll long long

const int N = 1e6+4;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	ll int k;
	
	cin >> k;
	
	if( (k % 2) == 0 || (k % 5) == 0)
	{
		cout << "-1\n";
		return 0;
	}
	
	ll int cur = 7 % k;
	ll int ans = 1;
	
	while( cur != 0)
	{
		cur = cur * 10 + 7;
//		cout << "total is " << cur << "\n";  
		cur %= k;
//		cout << "after module is " << cur << "\n";
		ans++;		
		
	}		
	
	cout << ans << "\n";
		

	
	return 0;
}


Measured memory_bytes: 3620
import java.util.*;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    long N = sc.nextLong();
    long K = sc.nextLong();
    long T = 0;

    T = N%K;
    long ans = Math.min(T , K - T);

    System.out.println(ans);

}
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  if (s == "AAA" || s == "BBB") cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
H,W,D = map(int,input().split())
lis = [0] * (H*W+1)
for i in range(H):
    A = list(map(int,input().split()))
    for j in range(W):
        lis[A[j]] = (i,j)
# print(lis)
com = [0] * (H*W+1)
for i in range(D+1,H*W+1):
    com[i] = com[i-D] + abs(lis[i-D][0]-lis[i][0]) + abs(lis[i-D][1]-lis[i][1])
    #print(i,abs(lis[i-D][0]-lis[i][0]),abs(lis[i-D][1]-lis[i][0]))
    #print(i,lis[i-D][0],lis[i-D][1],lis[i][0],lis[i][1])
# print(lis)
# print(com)
Q = int(input())
for i in range(Q):
    L,R = map(int,input().split())
    print(com[R]-com[L])


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

#define si(v) int(v.size())
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define rep2(i, n, m) for (ll i = n; i <= (m); ++i)
#define rep3(i, n, m) for (ll i = n; i >= (m); --i)

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

using ll = long long;
using ld = long double;
using namespace std;

signed main()
{
  cout << fixed << setprecision(20);
  ios::sync_with_stdio(false);
  cin.tie(0);
  
  string s; cin >> s;

  int ans = 700;
  rep(i, 3) if (s[i] == 'o') ans += 100;
  
  cout << ans << endl;
  
  return (0);
}

Measured memory_bytes: 3628
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#define MN 101000

typedef long long ll;

struct xxx{
	ll d;
	int id;
}a[MN];

int siz[MN];
std::map<ll, int> mp;
int x[MN], y[MN];

bool cmp(xxx a, xxx b) {return a.d < b.d;}

int main()
{
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%lld", &a[i].d), a[i].id = i;
	std::sort(a + 1, a + n + 1, cmp);
	for(int i = 1; i <= n; i++) mp[a[i].d] = i, siz[i] = 1;
	ll sum = 0;
	for(int i = n; i >= 2; i--)
	{
		sum += siz[i];
		a[i].d -= n - 2 * siz[i]; 
		if(!mp[a[i].d] || mp[a[i].d] >= i) return 0 * puts("-1");
		siz[mp[a[i].d]] += siz[i];
		x[n - i + 1] = a[i].id; y[n - i + 1] = a[mp[a[i].d]].id; 
	}
	if(sum != a[1].d) return 0 * puts("-1");
	for(int i = 1; i < n; i++) printf("%d %d\n", x[i], y[i]);
}

Measured memory_bytes: 11392
N=int(input())
v = [int(i) for i in input().split()] 
v.sort()
value=(v[0]+v[1])/2
j=0
hoge=[]
if N==2:
    print(value)
else:
    for i in range(2,N):
        value=(value+v[i])/2
    print(value)

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

int main(){
  int n, m;
  cin >> n >> m;
  vector<int> city(n, 0);
  
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    city.at(a - 1) += 1;
    city.at(b - 1) += 1;
  }
  for (int i = 0; i < n; i++) 
    cout << city.at(i) << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

// 方向ベクトル
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main() {
    int h, w;
    cin >> h >> w;

    vector<string> board(h);
    rep(i, h) {
        cin >> board[i];
    }

    vector<vector<int>> matrix(h, vector<int>(w, -1));  // 数字を書き込むマス。-1で初期化
    queue<pair<int, int>> next;  // 次に探索するマス目を入れるqueue

    rep(i, h) {
        rep(j, w) {
            if(board[i][j] == '#') {
                next.push(make_pair(i, j));  // queueに黒マスを入れる
                matrix[i][j] = 0;  // 黒マスを0にする
            }
        }
    }

    while(!next.empty()) {  // nextが空になるまで探索

        int x = next.front().first;
        int y = next.front().second;
        
        // 4方向調べる
        rep(i, 4) {

            int nx = x + dx[i];
            int ny = y + dy[i];

            // 盤外または探索済みのところはダメ
            if(nx < 0 || h <= nx || ny < 0 || w <= ny || matrix[nx][ny] >= 0) {   
                continue;
            }
            
            matrix[nx][ny] = matrix[x][y] + 1;  // 隣接マスに1足す
            next.push(make_pair(nx, ny));  // 隣接マスをnextに入れる
        }

        next.pop();  // nextからいま探索したマスを削除
    }

    int ans = 0;
    rep(i, h) {
        rep(j, w) {
            ans = max(ans, matrix[i][j]);
        }
    }

    cout << ans << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef double ld;
#define int ll
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<vvc> vvvc;
typedef pair<int, int> pii;
typedef pair<pii, pii> piii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector< vi > vvi;
typedef vector< vvi > vvvi;
typedef vector<short> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef vector<vvld> vvvld;
typedef vector<string> vst;
typedef vector<vst> vvst;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define sqr(x) ((x) * (x))
#define fori(i, n) for(int i = 0; i < int(n); ++i)
#define SZ(a) ((int)((a).size()))
#define triple(T) tuple<T, T, T>
#define quad(T) tuple<T, T, T, T>
#define watch(x) cerr << (#x) << " = " << (x) << endl;

#ifdef RUS_HOME
#define cerr cout
#else
#define cerr if (false) cerr
#endif

const double PI = 2 * acos(0.0);
#define rand shittttty_shit
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

const string DIGITS = "0123456789";
const string ALPH = "abcdefghijklmnopqrstuvwxyz";


template <class T0, class T1>
inline ostream & operator << (ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template <class T0, class T1>
inline istream & operator >> (istream &in, pair<T0, T1> &a) {
    return in >> a.first >> a.second;
}

template <class T0, class T1, class T2>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << "}";
}

template <class T0, class T1, class T2, class T3>
inline ostream & operator << (ostream &out, tuple<T0, T1, T2, T3> &a) {
    return out << "{" << get<0>(a) << ", " << get<1>(a) << ", " << get<2>(a) << ", " <<  get<3>(a) << "}";
}

template<class T>
inline ostream & operator << (ostream &out, vector<T> &a) {
    out << "[";
    fori (i, a.size())
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();



signed main() {
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
#ifdef RUS_HOME
    freopen("input", "r", stdin);
    clock_t start = clock();
#endif
    cout << setprecision(12) << fixed;
    smain();
#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float( clock () - start ) /  CLOCKS_PER_SEC << endl;
#endif
    return 0;
}



void smain() {

    int n, w;
    cin >> n >> w;

    vi dp(w + 1);

    dp[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        int a, b;
        cin >> a >> b;
        for (int j = w; j - a >= 0; j--)
        {
            inmax(dp[j], dp[j - a] + b);
        }
    }

    int mx = 0;
    for (int i = 0; i <= w; i++)
        inmax(mx, dp[i]);


    cout << mx;

}


Measured memory_bytes: 1024
<?php
$A=array('S'=>array(),'H'=>array(),'C'=>array(),'D'=>array());
fscanf(STDIN,"%d",$x);
for($i=0;$i<$x;$i++){
    fscanf(STDIN,"%c %d",$c,$d);
    $A[$c][$d]=1;
}
while($C=  current($A)) {
    //print_r($value);
    for($i=1;$i<=13;$i++){
        if(!array_key_exists($i, $C)){
            echo key($A)." ".$i."\n";
        }
    }
    next($A);
}

Measured memory_bytes: 6600
#include <bits/stdc++.h>
using namespace std;
#define ll  long long int
#define mod 1000000007
#define modd 998244353
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
int main()
{
    fast; 
    ll n,k;
    cin>>n>>k;
    ll a[n];
    for(ll i=0; i<n; i++)
    cin>>a[i];
    ll x =1;
    for(ll i=0; i< k-1;i++)
    x=x*a[i];
    ll f =0;
    ll prev = x;
    for(ll i= k; i<n; i++)
    {
        // if(i == k-1)
        // {
        //     x = x *a[i];
        //     prev = x;
        //     cout<<x<<" "; 
        //     x =  x/a[i-k+1];
        // }
        // else
        // {
            x = x*a[i];
            if(a[i-k] >= a[i])
            {
                cout<<"No"<<"\n";
            }
            else 
            {
                cout<<"Yes"<<"\n";
            }
            prev = x;
            // cout<<a[i-k]<<" "<<a[i]<<"\n"; 
            x = x  /a[i-k+1];
        // }
       
    }
}

Measured memory_bytes: 5176
class InputLine
  def self.to_s
    gets.chomp
  end

  def self.to_i
    InputLine.to_s.to_i
  end
  
  def self.to_f
    InputLine.to_s.to_f
  end

  def self.to_sa
    InputLine.to_s.split(' ')
  end

  def self.to_ia
    InputLine.to_sa.map(&:to_i)
  end
  
  def self.to_fa
    InputLine.to_sa.map(&:to_f)
  end
end

def main(argv)
  n = InputLine.to_i
  a = InputLine.to_ia

  b = a.uniq
  
  if a.size == b.size then
    puts 'YES'
  else
    puts 'NO'
  end
end

if self.to_s == 'main' then
  main(ARGV)
end

Measured memory_bytes: 32388
import java.io.*;
public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader S =new BufferedReader(new InputStreamReader(System.in));
		String str=S.readLine();
		int time=Integer.parseInt(str);
		int h=time/(3600);
		int m=(time%3600)/60;
		int s=time%(3600/60);
		System.out.println(h+":"+m+":"+s);
		
		
	
		
	}
}

Measured memory_bytes: 17044
#include"bits/stdc++.h"
using namespace std;

int main() {
	int N; cin >> N;
	vector<tuple<string, int, int>> gb;
	for (int i = 0; i < N; i++)
	{
		string a;
		int b;
		cin >> a >> b;
		gb.push_back(make_tuple(a, -1*b, i));
	}
	sort(gb.begin(), gb.end());
	for (int i = 0; i < N; i++)
	{
		int a;
		tie(ignore, ignore, a) = gb.at(i);
		cout << a+1 << endl;
	}
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 1007;

const char S[] = ".<>^v";

int n, m, A, B;
int g[MAXN][MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	cin >> n >> m >> A >> B;
}

void work ()
{
	// main work

	if ( n & 1 ) {
		for ( int t = 1; t + 1 <= m && A; t += 2 ) {
			g[n][t] = 1, g[n][t + 1] = 2;
			--A;
		}
	}
	if ( m & 1 ) {
		for ( int t = 1; t + 1 <= n && B; t += 2 ) {
			g[t][m] = 3, g[t + 1][m] = 4;
			--B;
		}
	}

	for ( int i = 1; i + 1 <= n && ( A || B ); i += 2 ) {
		for ( int j = 1; j + 1 <= m && ( A || B ); j += 2 ) {
			if ( i + 2 == n && j + 2 == m && A == 1 && B == 1 ) {
				g[i][j] = 1, g[i][j + 1] = 2;
				g[i][j + 2] = 3, g[i + 1][j + 2] = 4;
				g[i + 2][j + 1] = 1, g[i + 2][j + 2] = 2;
				g[i + 1][j] = 3, g[i + 2][j] = 4;
				--A, --B;
			} else if ( A >= 2 || ( A && B < 2 ) ) {
				g[i][j] = 1, g[i][j + 1] = 2;
				--A;
				if ( A ) {
					g[i + 1][j] = 1, g[i + 1][j + 1] = 2;
					--A;
				}
			} else {
				g[i][j] = 3, g[i + 1][j] = 4;
				--B;
				if ( B ) {
					g[i][j + 1] = 3, g[i + 1][j + 1] = 4;
					--B;
				}
			}
		}
	}

	if ( A || B ) printf ( "NO\n" );
	else {
		printf ( "YES\n" );
		lpi ( i, 1, n ) {
			lpi ( j, 1, m ) putchar ( S[g[i][j]] );
			putchar ( '\n' );
		}
	}
}

Measured memory_bytes: 5120
N, K = map(int, input().split())
A = list(map(int, input().split()))

count = {}
for i in A:
    if i not in count:
        count[i] = 0
    count[i] += 1

cs = sorted(count.items(), key=lambda x: x[1])
ans = 0
for i in range(len(cs) - K):
    ans += cs[i][1]
print(ans)

Measured memory_bytes: 38964
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
#define MAX_C 1000000001

int check(char c) {
  if ((c-'A')*(c-'C')*(c-'G')*(c-'T') == 0) return 1;
  return 0;
}

int main() {
  string s;
  cin >> s;
  vector<int> atcg(s.size());
  
  for (int i = 0; i < s.size(); i++) {
    atcg[i] = check(s[i]);
  }

  int ret = 0;
  int tmp = 0;
  for (int i = 0; i < s.size(); i++) {
    if (atcg[i] == 1) {
      tmp++;
      ret = max(ret, tmp);
    }
    else tmp = 0;
  }
  cout << ret << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int k;
  string s;
  cin >> k;
  cin >> s;
  
  int slength = (int)(s.length());
  if( slength <= k){
    cout << s << endl;
  }else{
    s = s.substr(0,k);
    cout << s << "..." << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
package main

import "fmt"

func main() {
	var n int
	var count int
	fmt.Scan(&n)
	nums := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&nums[i])
	}
	f := true
	for f {
		for i, v := range nums {
			if v%2 == 1 {
				f = false
			}
			nums[i] = nums[i] / 2
		}
		if f {
			count++
		}
	}

	fmt.Println(count)

}


Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _DEBUG
#define DMP(x) cerr << #x << ": " << x << "\n"
#else
#define DMP(x) ((void)0)
#endif

const int MOD = 1000000007, INF = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

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

	int N;
	cin >> N;

	vector<int> even(N / 2), odd(N / 2);
	for (int i = 0; i < N / 2; i++) cin >> even[i] >> odd[i];
	sort(even.begin(), even.end());
	sort(odd.begin(), odd.end());

	int tmp_e = 1, tmp_o = 1, max_e = 0, max_o = 0, prev_e = 0, prev_o = 0, memo_e = -1, memo_o = -1;
	for (int i = 1; i < N / 2; i++) {
		
		if (even[i] == even[i - 1]) tmp_e++;
		else {
			if (max_e <= tmp_e) {
				memo_e = even[i - 1];
				prev_e = max_e;
				max_e = tmp_e;
			}
			else if (prev_e <= tmp_e) prev_e = tmp_e;
			tmp_e = 1;
		}		
		if (odd[i] == odd[i - 1]) tmp_o++;
		else {
			if (max_o <= tmp_o) {
				memo_o = odd[i - 1];
				prev_o = max_o;
				max_o = tmp_o;
			}
			else if (prev_o <= tmp_o) prev_o = tmp_o;
			tmp_o = 1;
		}		
	}

	if (max_e <= tmp_e) {
		memo_e = even[N / 2 - 1];
		prev_e = max_e;
		max_e = tmp_e;
	}
	else if (prev_e <= tmp_e) prev_e = tmp_e;
	if (max_o <= tmp_o) {
		memo_o = odd[N / 2 - 1];
		prev_o = max_o;
		max_o = tmp_o;
	}
	else if (prev_o <= tmp_o) prev_o = tmp_o;

	if (memo_o != memo_e) {
		cout << N - max_e - max_o << "\n";
	}
	else {
		if(max_e + prev_o > max_o + prev_e) cout << N - max_e - prev_o << "\n";
		else cout << N - max_o - prev_e << "\n";
	}

	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

int main(){
  int M,ans;
  bool bmap[6][6];
  cin >> M;
  while(M-- > 0){
    rep(i,5){
      rep(j,5)cin >> bmap[i][j];
    }
    ans = 0;
    rep(i,5){// sp x
      rep(j,5){// sp y
	REP(k,i,5){// gp x
	  REP(l,j,5){// gp y

	    bool fin = false;
	    int m,n;
	    //verify
	    for(m=i;m<=k;m++){
	      for(n=j;n<=l;n++){
		if(!bmap[n][m]){
		  fin = true;
		  break;
		}
	      }  
	    }
	    if(!fin)ans = max(ans,(k-i+1)*(l-j+1));

	  }
	}
      }
    }
    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for(int i = a; i < b; i++)
string s;
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> s;
    ll sum = 0;
    for(int i = 0; i < s.length(); i++) {
        // cout << s[i] - '0' << endl;
        sum += s[i] - '0';
        sum %= 9;
    }
    if(sum % 9 == 0) {
        puts("Yes");
    } else {
        puts("No");
    }
    return 0;
}


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

int main(){
  int a,b,c=0;
  cin >> a >> b;
  if(a>b){
    c+=a;
    a-=1;
  }else{
    c+=b;
    b-=1;
  }
  if(a>b){
    c+=a;
  }else{
    c+=b;
  }
  cout << c;
}


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

using namespace std;

const int N = 123, MAXN = 10000;

int n;

int a[N], can[MAXN + 123], ans;

int main () {
    cin >> n;
    for (int i = 1;i <= n;i ++) {
        cin >> a[i];
    }can[0] = 1;
    for (int i = 1;i <= n;i ++) {
        for (int j = MAXN - 1;j >= 0;j --) {
            if (can[j]) {
                can[j + a[i]] = 1;
            }
        }
    }
    for (int i = MAXN;i >= 1;i --) {
        if (can[i] && i % 10) {
            cout << i;
            exit (0);
        }
    }cout << 0;
}


Measured memory_bytes: 256
unittest
{
	assert( [ "20 4", "3 7 8 4" ].solve == "777773" );
	assert( [ "101 9", "9 8 7 6 5 4 3 2 1" ].solve == "71111111111111111111111111111111111111111111111111" );
	assert( [ "15 3", "5 4 6" ].solve == "654" );
}



import std.algorithm;
import std.bigint;
import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = 0L;
	auto m = 0L;
	input.front.formattedRead!"%s %s"( n, m );
	input.popFront;
	auto as = input.front.split.to!( long[] );
	
	const MS = [ 0L, 2L, 5L, 5L, 4L, 5L, 6L, 3L, 7L, 6L ];
	
	// dp[ 使用したマッチの本数 ] = 作れる最大の整数
	auto dp = new BigInt[ 1 + n ];
	foreach( a; as )
	{
		auto j = MS[ a ];
		if( j < dp.length ) dp[ j ] = max( dp[ j ], BigInt( a ) );
	}
	foreach( i; 0L .. dp.length.signed )
	{
		foreach( a; as )
		{
			auto j = MS[ a ];
			if( 0 < dp[ i ] && i + j < dp.length ) dp[ i + j ] = max( dp[ i + j ], dp[ i ] * 10 + a );
		}
	}
	return format( "%s", dp[ $ - 1 ] );
}


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

const int INF = 2e9;

int main(){
    int n;
    cin >> n;
    set<int> s;
    int count = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(a >= 3200) count++;
        else{
            s.insert(a/400);
        }
    }
    if(s.size() == 0){
        cout << 1;
    }
    else{
        cout << s.size();
    }
    cout << " " << s.size() + count << endl;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

#define ll long long
#define db double
#define el "\n"
#define ld long double
#define rep(i,n) for(int i=0;i<n;i++)
#define rev(i,n) for(int i=n;i>=0;i--)
#define rep_a(i,a,n) for(int i=a;i<n;i++)
#define tr(ds, it) for(auto it=ds.begin(); it!=ds.end(); it++)
#define rtr(ds, it) for(auto it=ds.rbegin(); it!=ds.rend(); it--)
#define all(ds) ds.begin(), ds.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
typedef priority_queue <int> pq;
typedef vector< long long > vi;
typedef pair<long long, long long> ii;
#define o_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define graph vector<vi>

const ll mod = 1000000007;
ll po(ll x, ll n ){ 
    ll ans=1;
     while(n>0){
         if(n&1) ans=(ans*x)%mod;
         x=(x*x)%mod;
         n/=2;
     }
     return ans;
}



int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
 
    int T=1;
    //cin >> T;
    while(T--){
        ll n;
        cin>>n;
        map<ll,ll>m;
        ll a[n];
        rep(i,n){
            cin>>a[i];
            if(m.find(a[i])==m.end()) m.insert(mp(a[i],1ll));
            else m[a[i]]++;
        }   
        ll s=0,k;
        tr(m,h){
            k=h->ss;
            s+=(k*k-k)/2;
        }
        rep(i,n){
            k=m[a[i]];
            cout<<s-k+1<<el;
        }
    }

    return 0;
}

Measured memory_bytes: 11136
#include <stdio.h>

int main(){
  int A,B,C,D;
  scanf("%d",&D);
  A=D/100;
  B=(D/10)%10;
  C=D%10;
  
  
  if(A==7 || B==7 || C==7){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 1640
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

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

    int k, t; cin >> k >> t;
    int a[t];
    rep(i, t){
        cin >> a[i];
    }

    priority_queue<P> que;
    rep(i, t){
        que.push({a[i], i});
    }

    int ans = 0;
    int iprev = -1;
    while(!que.empty()){
        P firstmax = que.top();
        que.pop();

        if(que.empty()){
            if(iprev == firstmax.second){
                ans++;
            }
            firstmax.first--;
            iprev = firstmax.second;
            if(firstmax.first != 0){
                que.push(firstmax);
            }
            continue;
        }

        if(iprev != firstmax.second){
            firstmax.first--;
            iprev = firstmax.second;
            if(firstmax.first != 0){
                que.push(firstmax);
            }
            continue;
        }

        P secondmax = que.top();
        que.pop();

        secondmax.first--;
        iprev = secondmax.second;
        que.push(firstmax);
        if(secondmax.first != 0){
            que.push(secondmax);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define min(a,b)(a<b?a:b)
int main()
{
	int a,b,k,cnt=0;
	scanf("%d %d %d",&a,&b,&k);
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0&&b%i==0)cnt++;
		if(cnt==k){
			printf("%d\n",i);
			break;
		}
	}
	return 0;
}

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

#define MAX_N 100000

// string s = "125";
string input;
// vector<int> s = {1, 2, 5};
vector<char> s;
vector<string> result;

void dfs(int i, string tmp) {
    // 停止条件
    if (i == s.size() - 1) {
        result.push_back(tmp);
        return;
    }

    // 右側に+使う
    dfs(i + 1, tmp + "+" + (s[i+1]));

    // 右側に+使わない
    dfs(i + 1, tmp + (s[i+1]));
}

int main() {
    // TODO: インプット作成
    cin >> input;

    for (int i = 0; i < input.length(); i++) {
        // cout << typeid(input[i]).name() << endl;
        s.push_back(input[i]);
    }

    // 文字列作成
    string init = { s[0] };
    dfs(0, init);
    
    // 式を計算する
    long int ans = 0;

    for (int i = 0; i < result.size(); i++) {
        // cout << result[i] << endl;

        string sahen = "";
        for (int j = 0; j < result[i].length(); j++) {
        //     cout << result[i][j] << endl;
            if (result[i][j] == '+') {
                ans += stol(sahen);
                sahen = "";
            } else {
                sahen += result[i][j];
            }
        }
        // cout << sahen << endl;
        if (sahen != "") {
            ans += stol(sahen);
        }
    }
    cout << ans << endl;
}

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

using namespace std;

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans=n;
    int east[n]={};
    for(int i=0;i<n;i++){
        if(i==0 && s[i]=='E'){
            east[0]=1;
        }else if(s[i]=='E'){
            east[i]=east[i-1]+1;
        }else{
            east[i]=east[i-1];
        }
    }
    for(int i=0;i<n;i++){
        int cnt=0;
        if(i==0){
            cnt=east[n-1];
        }else if(i==n-1){
            cnt=n-1-east[n-2];
        }else{
            cnt=(east[n-1]-east[i])+(i-east[i-1]);
        }
        if(ans>cnt){
            ans=cnt;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 1796