akhauriyash/Code-Regression huggingface dataset:
#include <queue>
#include <cstdio>
#include <iostream>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <stack>
#include <time.h>
#include <functional>

//#include "All.h"

using namespace std;
typedef long long int ll;

#define EPS (1e-9)
#define INF (1e9)
#define PI (acos(-1))
#define REP(i,n) for(int i=0;i<n;i++)

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

ll beki(ll a, ll b) {
    ll tmp = 1;
    REP(i, b) tmp *= a;
    return tmp;
}

ll N, M, Q;
ll a[110], b[110], c[110], d[110];
ll A[110] = {};

ll ans = 0;

int main() {
    cin >> N >> M >> Q;
    REP(i, Q) cin >> a[i] >> b[i] >> c[i] >> d[i];
    for (A[0] = 0; A[0] < M; A[0]++) {
        for (A[1] = A[0]; A[1] < M; A[1]++) {
            for (A[2] = A[1]; A[2] < M; A[2]++) {
                for (A[3] = A[2]; A[3] < M; A[3]++) {
                    for (A[4] = A[3]; A[4] < M; A[4]++) {
                        for (A[5] = A[4]; A[5] < M; A[5]++) {
                            for (A[6] = A[5]; A[6] < M; A[6]++) {
                                for (A[7] = A[6]; A[7] < M; A[7]++) {
                                    for (A[8] = A[7]; A[8] < M; A[8]++) {
                                        for (A[9] = A[8]; A[9] < M; A[9]++) {
                                            //処理
                                            //ここでAの数列確定
                                            ll tmp = 0;
                                            REP(i, Q) {
                                                //そのAに対してQ回確かめる
                                                if (A[b[i] - 1] - A[a[i] - 1] == c[i])
                                                    tmp += d[i];
                                            }
                                            ans = max(ans, tmp);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }
    cout << ans << endl;
}

/*
10 10 2
1 10 9 1
2 10 9 2
*/


Measured memory_bytes: 3592
//#pragma GCC optimize("Ofast")

#pragma GCC optimize("O3")
//#pragma GCC target("avx,avx2,fma")
#include<iostream>
#include<algorithm>
#include<string>
#include<cmath>
#include<cstdlib>
#include<set>
#include<vector>
#include<sstream>
#include<queue>
#include <iomanip>
#include<unordered_set>
#include <stack>
#include <unordered_map>
#include <map>
constexpr auto INF = 9223372036854775807;
typedef long long int ll;
typedef unsigned long long int ull;
typedef unsigned long int ul;
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i+=1)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i-=1)
#define endl '\n'
#define N 1000000007// prime modulo value 
#define C 1000000001
#define M 998244353
#define all(x) x.begin(),x.end()
using namespace std;
// From Geeksforgeeks
inline ll gcd(ll a, ll b)
{
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
// Power function took from geeksforgeeks
ll power(ll x, ll y)
{
	ll res = 1;

	x = x;
	if (x == 0) return 0;
	while (y > 0)
	{
		if (y & 1)
			res = (res * x);
		y = y >> 1;
		x = (x * x);
	}
	return res;
}
double dist(ll x1, ll y1, ll x2, ll y2)
{
	double ans = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
	return ans;
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n;
	cin >> n;
	ll digits = log10(n) + 1;
	ll ans = 0;
	if (digits % 2 == 0)
	{
		digits -= 1;
		for(ll i=1;i<=digits;i+=2)
		{
			ans += 9 * (power(10, i - 1));
		}
		cout << ans;
	}
	else
	{
		digits -= 2;
		for (ll i = 1; i <= digits; i += 2)
		{
			ans += 9 * (power(10, i - 1));
		}
		ans += n-power(10, digits + 1)+1;
		cout << ans;
	}
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int Dig = 1;
			int a = sc.nextInt();
			int b = sc.nextInt();
			int kei = a+b;
			while(kei/10 != 0){
				Dig ++;
				kei /= 10;
			}
			System.out.println(Dig);
		}
	}
}

Measured memory_bytes: 26640
import math
A, B, C, D, E, F = map(int, input().split())
limit_r = 100 * E / (100 + E)
max_r, max_w, max_s = -1 * float('inf'), 0, 0
for a in range(math.floor(F/100/A)+1):
  for b in range(math.floor(F/100/B)+1):
    w = 100 * A * a + 100 * B * b
    if w == 0:
      continue
    if w > F:
      break
    for c in range(math.floor((F-w)/C)+1):
      for d in range(math.floor((F-w)/D)+1):
        s = C * c + D * d
        r = 100 * s / (w + s)
        if w + s > F or r > limit_r:
          break
        if r > max_r:
          max_r, max_w, max_s = r, w, s
print("{0} {1}".format(max_w+max_s, max_s))


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

int main() {
	int n; scanf("%d", &n);
	rep(i, n) {
		double x1, y1, r1, x2, y2, r2;
		scanf("%lf%lf%lf%lf%lf%lf", &x1, &y1, &r1, &x2, &y2, &r2);
		double d = sqrt((x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2));
		if (d > r1 + r2)puts("0");
		else if (d < r1 - r2)puts("2");
		else if (d < r2 - r1)puts("-2");
		else puts("1");
	}
}

Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define eps 1e-12
using namespace std;

const double PI = acos(-1.0);

int main() {
	
	double a, b, x;
	scanf("%lf%lf%lf", &a, &b, &x);

	double vol = 1.0 * a * a * b;
	double low = 0, high = 90;
	while((high - low) > eps) {
		double t = (high + low) / 2;
		if(a * tan(t * PI / 180.0) < b) {
			double s = 0.5 * a * a * a * tan(t * PI / 180.0);
			if(x > vol - s) high = t;		//溢出
			else low = t; 	//未溢出
		} else {
			double s = 0.5 * a * b * b / tan(t * PI / 180.0);
			if(x > s) high = t;		//溢出
			else low = t; 	//未溢出
		}

	}
	printf("%.10f\n", low);

	return 0;
}

Measured memory_bytes: 256
//file_name:ABC51_C.cpp
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

    // int scan
    /*
    int x;
    scanf("%d",&x);
    int y;
    scanf("%d",&y);
    int z;
    scanf("%d",&z);

    // matrix scan
    /*
    ll a[n] = {};
    rep(i,n){
        scanf("%lld",&a[i]);
    }
    */

    // string scan
    /*
    string s;
    cin >> s;
    */


int main() {
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    rep(i,c-a){
        cout << 'R';
    }
    rep(i,d-b){
        cout << 'U';
    }
    rep(i,c-a){
        cout << 'L';
    }
    rep(i,d-b){
        cout << 'D';
    }
    cout << 'D';
    rep(i,c-a+1){
        cout << 'R';
    }
    rep(i,d-b+1){
        cout << 'U';
    }
    cout << 'L';
    cout << 'U';
    rep(i,c-a+1){
        cout << 'L';
    }
    rep(i,d-b+1){
        cout << 'D';
    }
    cout << 'R';
    cout << endl;
    


    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int a[100005];
int main()
{
    int n;
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
        int ans=a[1];
    for(int i=1;i<=n;i++)
        ans=min(ans,__gcd(ans,a[i]));
    cout<<ans;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
long long mod = 1000000007;
long long modpow(long long m,long long n){
    long long res = 1;
    if(n > 0){
        res = modpow(m,n / 2);
        if(n % 2 == 0){
            res = (res * res) % mod;
        }
        else{
            res = (((res * res) % mod) * m) % mod;
        }
    }
    return res;
}
ll fac[200001];
ll convi(ll a,ll b){//aCbをmodで割ったあまりを求める
  ll res = fac[a];
  res *= modpow(fac[b],mod - 2),res %= mod;
  res *= modpow(fac[a - b],mod - 2),res %= mod;
  return res;
}
int main(){
  fac[0] = 1;
  for(int i = 1;i <= 200000;i++){
    fac[i] = fac[i - 1] * i;
    fac[i] %= mod;
  }
  
  ll h,w,a,b;
  cin >> h >> w >> a >> b;
  //cout << convi(h + w - 2,h - 1) << endl;
  ll res = 0;
  res = convi(h + w - 2,h - 1);
  for(int i = 0;i < b;i++){
    //cout << res << endl;
    ll now = 0;
    now = convi(h - a - 1 + i,i);//スタートから立入禁止区域入り口まで
    now *= convi(w - i - 1 + a - 1,a - 1),now %= mod;
    res -= now;
    res += mod,res %= mod;
  }
  cout << res << endl;
}

Measured memory_bytes: 5208
#include<iostream>
using namespace std;
int n, k, i, r;
long long sol;
int ff[200005];
int main(){
    cin>> n >> k;
    for(i = 1; i <= n; i++){
        ff[i % k]++;
    }
    for(i = 1; i <= n; i++){
        r = (k - i % k) % k;
        if( (r + r) % k == 0){
            sol += ff[r] * 1LL * ff[r];
        }
    }
    cout<< sol;
}


Measured memory_bytes: 640
s = input()
p = len(s) // 2
g = len(s) - p
cnt = 0
for i in range(len(s)):
    if s[i] == "g":
        if p != 0:
            p -= 1
            cnt += 1
        else:
            g -= 1
    else:
        if p != 0:
            p -= 1
        else:
            g -= 1
            cnt -= 1
print(cnt)


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

struct UnionFind {
  vector<int> par;
  UnionFind(int n) : par(n) {
    for (int i = 0; i < n; i++) par[i] = i;
  }
  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }
  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);
    if (rx == ry) return;
    par[rx] = ry;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  int n, m;
  cin >> n >> m;
  vector<int> p(n);
  for (int i = 0; i < n; i++) cin >> p[i];
  
  UnionFind tree(n);
  
  for (int i = 0; i < m; i++) {
    int x, y;
    cin >> x >> y;
    tree.unite(x-1, y-1);
  }
  
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (tree.same(i, p[i]-1)) cnt++;
  }
  
  cout << cnt << endl;
}

Measured memory_bytes: 1024
n,m=map(x->parse(Int,x),split(readline()))
s=map(x->parse(Int,x),split(readline()))
t=map(x->parse(Int,x),split(readline()))
sum=ones(Int,m+1)
mod=10^9+7
for ss=s
	sum[2:m+1]+=cumsum([ss==tt?sum[j]%mod:0 for (j,tt) in zip(1:m,t)])
end
println(sum[m+1]%mod)

Measured memory_bytes: 154760
#include<stdio.h>
int main(){
double a,b,c,d,e,f,x,y;
while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f)!=EOF){
 y=(c*d-f*a)/(b*d-e*a);
 x=(c-b*y)/a;
 printf("%.3f %.3f\n",x,y);
 }
return 0;}

Measured memory_bytes: 1080
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
#define int long long
const int inf = 999999999999999999;
typedef long long ll;
typedef long double ld;
struct A {
	int v, w;
};
A a[100];
int dp[10001];
signed main() {
	int n, w, ans = 0;
	cin >> n >> w;
	for (int i = 0; i < n; i++)
		cin >> a[i].v >> a[i].w;
	fill(dp, dp + 10001, -1);
	dp[0] = 0;
	for (int i = 0; i < n; i++)
		for (int j = 0; j <= 10000; j++)
			if (dp[j] != -1&&j+a[i].w<=10000)
				dp[j + a[i].w] = max(dp[j + a[i].w], dp[j] + a[i].v);
	for (int i = 0; i <= w; i++)
		ans = max(ans, dp[i]);
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <functional>
#include <deque>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int MOD = 1000000007;

int main(){
    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5])cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <queue>
using namespace std;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const int MAX = 10000;
static const ll INFTY = 1e12;

// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

// 入力
// 入力
int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
queue<pair<int, int>> que;

// 探索
int bfs(int h, int w) {

    //pair<int, int> now;
    //// 初期条件 (頂点 0 を初期ノードとする)
    //dist[sy][sx] = 0;
    //now.first = sy; 
    //now.second = sx; 
    //que.push(now); 
    int _max = 0;

    // 八方向を探索
    while(!que.empty()){
        pair<int, int> v = que.front();
        que.pop();

        for (int i = 0; i < 4; ++i) {
            int nh = v.first + dy[i], nw = v.second + dx[i];

            // 場外アウトしたり、0 だったりはスルー
            if (nh < 0 || nh >= H || nw < 0 || nw >= W) continue;
            if (field[nh][nw] == '#') continue;
            if (dist[nh][nw] != -1) continue;

            dist[nh][nw] = dist[v.first][v.second] + 1;
            _max = max(_max, dist[nh][nw]);
            field[nh][nw] = '#';
            pair<int, int> nv;
            nv.first = nh; nv.second = nw;
            que.push(nv);
        }
    }    
    return _max;
}

int main() {
    // 入力受け取り

    int count = 0;

    cin >> H >> W;
    field.assign(H, vector<char>(W));
    dist.assign(H, vector<int>(W, -1));
    for (int h = 0; h < H; ++h) {
      for (int w = 0; w < W; ++w) {
        cin >> field[h][w];
        if( field[h][w] == '#' ) {
          sy = h; sx = w;
          pair<int, int> now;
          // 初期条件 (頂点 0 を初期ノードとする)
          dist[sy][sx] = 0;
          now.first = sy; 
          now.second = sx; 
          que.push(now); 
        }
      }
    }
   // sy = 0; sx = 0; gy = H-1; gx = W-1;
    
    int ans = bfs(sy, sx);
    cout << ans << endl;

    //REP(i, H){
    //    REP(j, W){
    //        cout << field[i][j] << " ";
    //    } cout << endl;
    //}
//
    //REP(i, H){
    //    REP(j, W){
    //        cout << dist[i][j] << " ";
    //    } cout << endl;
    //}

}
/*
                   _ooOoo_
                  o8888888o
                  88" . "88
                  (| -_- |)
                  O\  =  /O
               ____/`---'\____
             .'  \\|     |//  `.
            /  \\|||  :  |||//  \
           /  _||||| -:- |||||-  \
           |   | \\\  -  /// |   |
           | \_|  ''\---/''  |   |
           \  .-\__  `-`  ___/-. /
         ___`. .'  /--.--\  `. . __
      ."" '<  `.___\_<|>_/___.'  >'"".
     | | :  `- \`.;`\ _ /`;.`/ - ` : | |
     \  \ `-.   \_ __\ /__ _/   .-` /  /
======`-.____`-.___\_____/___.-`____.-'======
                   `=---='
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
         pass System Test!
*/

Measured memory_bytes: 13328
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
using LL = long long;
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define LCIN(n) LL(n);cin >> (n)
#define SCIN(n) string(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

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

#define P pair<LL,LL>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
#define rmsame(a) sort(ALL(a)),a.erase(unique(ALL(a)), a.end())

typedef string::const_iterator State;
class PalseError {};
class Edge{
public:
    LL from,to,value;
    Edge(LL a,LL b,LL c){
        from = a;
        to = b;
        value = c;
    }
    Edge(LL a,LL b){
        from = a;
        to = b;
    }
};
int s[10000];
int f[10000];
int main(){
    CIN(H);CIN(W);
    vector<string> vec;
    for(int a = 0;a < H;a++){
        SCIN(s);
        vec.push_back(s);
    }
    REP(a,H){
        bool result = true;
        REP(b,W){
            if(vec.at(a).at(b) == '#'){
                result = false;
            }
        }
        if(result)s[a]=1;
    }
    REP(a,W){
        bool result = true;
        REP(b,H){
            if(vec.at(b).at(a) == '#'){
                result = false;
            }
        }
        if(result)f[a]=1;
    }

    for(int a = 0;a < W;a++){
        //cout<<f[a]<<endl;
    }
    for(int a = 0;a < H;a++){
        for(int b = 0;b < W;b++){
            if(s[a] ==0 && f[b] == 0){
                cout<<vec.at(a).at(b);
            }
        }
        cout<<endl;
    }
}



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

using namespace std;

int main(){
  int a,b,c,x,counter=0;
  cin >> a >> b >> c >> x;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
     for(int k=0;k<=c;k++){
       if(500*i+100*j+50*k==x)counter++;
     }
    }
  }
  cout << counter << endl;
}

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

int main()
{
    int counter = 0;
    char S[200000], T[200000];
    scanf("%s", S);
    scanf("%s", T);
    for(int i = 0; i < 200000; i++){
        if(strncmp(&S[i],&T[i],1) != 0) counter++;
        if(S[i] == '\0') break; 
    }
    printf("%d\n", counter);
    return 0;
}


Measured memory_bytes: 2020
n, k = map(int, input().split())
s = input()
u = []
d = []
if s[0]=='0':
    d.append(0)
cnt = 1
for i in range(n-1):
    if s[i+1]=='1' and s[i]=='0':
        u.append(cnt)
        cnt = 1
    elif s[i+1]=='0' and s[i]=='1':
        d.append(cnt)
        cnt = 1
    else:
        cnt += 1
if s[-1]=='0':
    u.append(cnt)
    d.append(0)
else:
    d.append(cnt)
if len(u)<=k:
    print(n)
    exit()
tmp = sum(d[:k+1]) + sum(u[:k])
ans = tmp
for i in range(len(u)-k):
    tmp += u[i+k]+d[i+k+1]-u[i]-d[i]
    ans = max(ans, tmp)
print(ans)    

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

int main(){
    int N;
    cin >> N;
    //int a[N];
    int a,b,ans_min, ans_max;

    int color[9]={};

    for(int i=0; i<N; i++){
        cin >> a;
        b = (int) a/400;
        if(b>=8) b=8;
        color[b]+=1;
    }
/*
    for(int i=0; i<9; i++){
        cout << color[i] << " ";
    }
    cout << endl;
*/
    ans_min=0;
    for(int i=0; i<8; i++){
        if(color[i]>0){
            ans_min++;
        }
    }

    if(ans_min==0){
        ans_min++;
        color[8]--;
    }
    ans_max = ans_min + color[8];
    //if(ans_max > 8) ans_max=8;

    cout << ans_min << " " << ans_max << endl;

    return 0;
}

Measured memory_bytes: 256
//Author:- S_Aditya

#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const ll mod=1e9+7;         
const int N=3e3+4;

int dp[N][N];

int main()                  
{
    string s,t;
    
    cin>>s>>t;
    
    int n,m;
    
    n=s.size(); m=t.size();
    
    rep(i,1,n+1)
    {
        rep(j,1,m+1)
        {
            if(s[i-1]==t[j-1])
            dp[i][j]=1+dp[i-1][j-1];
            else
            dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
        }
    }
    
    int i=n,j=m;
    
    string ans;
    
    while(i>0 and j>0)
    {
        if(s[i-1]==t[j-1])
        {
            ans.pb(s[i-1]);
            
            i--; j--;
        }
        else
        {
            if(dp[i-1][j]==dp[i][j])
            i--;
            else
            j--;
        }
    }
    
    reverse(ans.begin(),ans.end());
    
    cout<<ans;
    
} 

Measured memory_bytes: 35456
// In the name of God
#include <bits/stdc++.h>

using namespace std;
#define Size(x) ((int)(x).size())
#define pb push_back
typedef long long ll;
typedef long double ld;
typedef pair<int,int>pii;
const int INF = 1e9 + 10;
const int MN = 1e5 + 10;

int arr[MN];

short func(int a,int b){
	if(a == b) return 0;
	else if(a < b) return 1;
	else return -1;
}

int main()
{
	ios_base :: sync_with_stdio(false) ,cin.tie(0) , cout.tie(0);
	short f = 0;
	int n;cin>>n;
	int ans = 0;
	for(int i=0;i<n;++i) cin >> arr[i];
	for(int i=1;i<n;++i){
		short f1 = func(arr[i-1] , arr[i]);
		if(f != 0 && f1 != 0 && f != f1) ++ans , f = 0;
		else{
			if(f1 != 0) f = f1;
		}
	}
	cout << ans+1 << '\n';
	return 0;
}


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

int main() {
  int n,x;
  cin >> n >> x;
  vector<int> m(n);
  int min=x;
  int sum=0;
  for (int i=0;i<n;i++) {
	cin >> m.at(i);
	if (m.at(i)<=min) min=m.at(i);
	sum +=m.at(i);
  }
  cout << n + (x-sum)/min <<endl;
}


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

//#pragma GCC optimize ("Ofast")
//#pragma GCC target ("avx,avx2")

#define rep(i, n)    for(int i = 0; i < (n); ++i)
#define repA(i, a, n)  for(int i = a; i <= (n); ++i)
#define repD(i, a, n)  for(int i = a; i >= (n); --i)
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define dbg(x) cerr<<#x<<" : "<<x<<endl

typedef long long int ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vii;
const ll INF = 1e18+1;
const ll MOD = 1000000007L;
clock_t time_p=clock();
void timer(){time_p=clock()-time_p;cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";}

template <typename Arg1> ostream& operator << (ostream& out, const vector<Arg1> &a) {out<<"[ ";for(const auto &x:a)out<<x<<" ";return out<<"]";}

vi dist, depth;
vector<vi>adj;
vi p;

ll dfs1(ll cur, ll prev, ll dis){
    dist[cur] = dis;
    p[cur] = prev;
    ll ret = dis;
    for(auto x: adj[cur]){
        if(x != p[cur]){
            ret = max(ret, dfs1(x,cur,dis+1));
        }
    }
    depth[cur] = ret;
    return ret;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,u,v;
    cin>>n>>u>>v;
    u--;v--;
    adj.assign(n,{});
    dist.assign(n,0);
    depth.assign(n,0);
    p.assign(n,0);
    rep(i,n-1){
        ll a,b;
        cin>>a>>b;
        a--;b--;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    dfs1(v,-1,0);

    //dbg(dist);
    //dbg(depth);

    ll up = (dist[u]-1)/2;
    ll ans = depth[u]-1;
    ll cur = u;

    ll ctr=0;
    while(ctr++ < up){
        cur = p[cur];
        //dbg(cur);
        ans = max(ans, depth[cur]-1);
    }

    cout<<ans<<endl;







    timer();
    return 0;
}


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

#define endl '\n'
#define ll long long
#define ld long double
#define fi first
#define se second
#define MP make_pair
#define pii pair<int, int>
#define pll pair<long long, long long>
#define mod (ll) (1e9 + 7)
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) v.begin(), v.end()
#define dvec(v) for(auto i: v) cout << i << " "; cout << '\n';
#define gcd(a,b) __gcd(a, b)
#define lcm(a,b) ((a)*((b)/gcd(a,b)))
#define darr(a,n) for(int i=0; i<n;i++) cout << a[i] << " "; cout << '\n';
#define what_is(x) cerr << #x << " : " << x << '\n';


int main() {
    fast;
    int n; cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    int dp[n+1];
    dp[1] = 0;
    dp[2] = abs(h[0] - h[1]);

    for (int i = 3; i <= n; i++) {
        dp[i] = min(dp[i-1] + abs(h[i-2]-h[i-1]), dp[i-2] + abs(h[i-3]-h[i-1]));
    }
    cout << dp[n] << endl;
    
    return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=998244353;
const int N=200005;
ll val[N<<2],inc[N<<2],pre[N],rp[N];
void push_up(int u,int len) {
	val[u]=(val[u<<1]+val[u<<1|1]*rp[len])%mod;
//	if (u==1) printf("{%d: %lld %lld %lld %d}\n",u,val[u],val[u<<1],val[u<<1|1],len);
}
void push_down(int u,int len1,int len2) {
	if (inc[u]) {
		val[u<<1]=inc[u]*pre[len1-1]%mod;
		val[u<<1|1]=inc[u]*pre[len2-1]%mod;
		inc[u<<1]=inc[u];
		inc[u<<1|1]=inc[u];
		inc[u]=0;
	}
}
void update(int u,int l,int r,int x,int y,ll v) {
	if (x<=l && r<=y) {
		inc[u]=v;
		val[u]=pre[r-l]*v%mod;
		return;
	}
	int mid=l+r>>1;
	push_down(u,mid-l+1,r-mid);
	if (x<=mid) update(u<<1,l,mid,x,y,v);
	if (y>mid) update(u<<1|1,mid+1,r,x,y,v);
	push_up(u,mid-l+1);
}
int main() {
	int n,q;
	scanf("%d %d",&n,&q);
	pre[0]=1;
	rp[0]=1;
	ll now=10;
	for (int i=1; i<=n+1; i++) {
		rp[i]=rp[i-1]*10%mod;
		pre[i]=(pre[i-1]+now)%mod;
		now=now*10%mod;
	}
	update(1,1,n,1,n,1);
	for (int i=1; i<=q; i++) {
		int l,r,d;
		scanf("%d %d %d",&l,&r,&d);
		update(1,1,n,n-r+1,n-l+1,d);
		printf("%lld\n",val[1]);
		//if (i==1) break;
	}
	return 0;
}

Measured memory_bytes: 15064
while (n = gets(chomp:true).to_i) != 0
  scores = []
  scores = gets.split.map(&:to_f)

  # 平均値(scoresの合計/n)
  average = scores.inject(&:+) / n

  # 偏差(scores - 平均値)**2
  deviation = scores.map do |score|
    (score - average)**2
  end

  # 分散(偏差 / n)
  dispersion = deviation.inject(&:+) / n

  # 標準偏差(分散の平方根)
  square_root = dispersion**(1/2.0)

  puts square_root
end



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

string query(int n) {
	cout << n << '\n';
	fflush(stdout);
	string s; cin >> s;
	if (s == "Vacant") exit(0);
	return s;
}

int main() {
	int n; cin >> n;
	int l = 0;
	int r = n - 1;
	string L = query(l);
	string R = query(r);

	while (l < r) {
		int m = (l + r) / 2;
		R = query(m);
		if (m % 2) {
			if (L == R) r = m;
			else l = m;
		} else {
			if (L == R) l = m;
			else r = m;
		}
		if (r - l == 1)
			query(r);
	}
	return 0;
}

Measured memory_bytes: 3856
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_map>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>
#include<bitset>

using namespace std;

#define ll long long int

ll const MOD = 1000000007;
ll const INF = (long long int)1 << 61;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s,t;
    cin >> s;
    cin >> t;

    vector<vector<ll>> dp(s.size() + 1,vector<ll>(t.size() + 1,0));

    for(int i = 0; i < s.size(); i++){
        for(int j = 0; j < t.size(); j++){
            dp[i+1][j] = max(dp[i+1][j],dp[i][j]);
            dp[i][j+1] = max(dp[i][j+1],dp[i][j]);
            if(s[i] == t[j]){
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j] + 1);
            }else{
                dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]);
            }
        }
    }

    ll ans = 0;
    ll x = 0;
    ll y = 0;
    for(int i = 0; i <= s.size(); i++){
        if(ans < dp[i][t.size()]){
            ans = dp[i][t.size()];
            x = i;
            y = t.size();
        }
    }
    for(int i = 0; i <= t.size(); i++){
        if(ans < dp[s.size()][i]){
            ans = dp[s.size()][i];
            x = s.size();
            y = i;
        }
    }

    stack<char> st;

    while(x != 0 && y != 0){
        if(dp[x][y] == dp[x-1][y-1] + 1 && s[x-1] == t[y-1]){
            st.push(s[x-1]);
            x--;
            y--;
        }else{
            if(dp[x][y] == dp[x-1][y]){
                x--;
            }else if(dp[x][y] == dp[x][y-1]){
                y--;
            }else{
                x--;
                y--;
            }
        }
    }

    string str = "";
    while(!st.empty()){
        str += st.top();
        st.pop();
    }

    cout << str << endl;
    
    return 0;
}

Measured memory_bytes: 70784
import math
#----エラトステネスの篩--------
def get_primenumber(number):
    prime_list = []
    #2からnumberまでの数字をsearch_listに入れる
    search_list = list(range(2,number+1))
    while True:
      #search_listの先頭の値が√nの値を超えたら処理終了
      if search_list[0] > math.sqrt(number):
        #prime_listにsearch_listを結合
        prime_list.extend(search_list)
        break
      else:
        #search_listの先頭をprime_listに入れる
        head_num = search_list[0]
        prime_list.append(head_num)
        #search_listの先頭をpopする
        search_list.pop(0)
        #head_numの倍数を取り除く
        search_list = [num for num in search_list if num % head_num != 0]
    return prime_list

X = int(input())
PL=get_primenumber(100003)

Y = [p for p in PL if X<=p]
print(Y[0])


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

typedef pair<int,int> P;

int n,k,ans = 10000;
vector<P> edges(2010);
vector<int> adj[2010];
vector<int> dist;

void bfs(vector<int>& q,vector<int>& dist) {
    while (!q.empty()) {
        int p = q.back();
        q.pop_back();
        if (dist[p] == k/2) continue;
        for (int i = 0;i < adj[p].size();++i) {
            if (dist[adj[p][i]] > dist[p]+1) {
                dist[adj[p][i]] = dist[p]+1;
                q.push_back(adj[p][i]);
            }
        }
    }
    int cnt = 0;
    for (int i = 0;i < n;++i) if (dist[i] == 10000) cnt++;
    ans = min(ans,cnt);
}

int main() {
    cin >> n >> k;
    for (int i = 0;i < n-1;++i) {
        int a,b;
        cin >> a >> b;
        a--;b--;
        edges[i] = P(a,b);
        adj[a].push_back(b);
        adj[b].push_back(a);
    }

    if (k%2 == 0) {
        for (int i = 0;i < n;++i) {
            vector<int> q,dist(n,10000);
            dist[i] = 0;
            q.push_back(i);
            bfs(q,dist);
        }
    } else {
        for (int i = 0;i < n-1;++i) {
            vector<int> q,dist(n,10000);
            dist[edges[i].first] = 0;
            dist[edges[i].second] = 0;
            q.push_back(edges[i].first);
            q.push_back(edges[i].second);
            bfs(q,dist);
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
    int H,W;
    while (1){
        cin >> H >> W ;
        if (H == 0 && W == 0){
            break;
        }
        for (int i = 0; i < H; i++){
            if (i % 2 == 0){
                for (int j = 0; j < W; j++){
                    if (j % 2 == 0){
                        cout << "#" ;
                    } else {
                        cout << "." ;
                    }
                }
                cout << endl;
            } else {
                for (int j = 0; j < W; j++){
                    if (j % 2 == 0){
                        cout << "." ;
                    } else {
                        cout << "#" ;
                    }
                }
                cout << endl;
            }
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<iostream>
#include<cstdio>
#define N 101
using namespace std;

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

	long long A[N][N], B[N][N], C[N][N];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m; j++) {
			cin >> A[i][j];
		}
	}

	for (int i = 0; i < m; i++) {
		for (int j = 0; j < l; j++) {
			cin >> B[i][j];
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			C[i][j] = 0;
		}
	}


	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
			for (int k = 0; k < m; k++) {
				C[i][j] += A[i][k] * B[k][j];
			}
		}
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < l; j++) {
		    if(j) cout << " " ;
			cout << C[i][j];
		}
		cout << endl;
	}

}


Measured memory_bytes: 3324
#include <iostream>

#define MAXLINE 100

int main(void) {
    int n, k, N, K;
    int i, A, d;
    int owner[MAXLINE] = {0};
    int counter = 0;
    
    std::cin >> N >> K;
    
    for(k = 0; k < K; k++) {
        std::cin >> d;
        for(i = 0; i < d; i++) {
            std::cin >> A;
            owner[A-1] = 1;
        }
    }
    
    for(n = 0; n < N; n++) {
        if(owner[n]==0) {
            counter++;
        }
    }
    
    std::cout << counter << std::endl;
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int N;
  cin >> N;
  vector<string> S(N);
  int C1 = 0;
  int C2 = 0;
  int C3 = 0;
  int C4 = 0;
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
    if (S.at(i) == "AC") {
      C1++;
    }
    if (S.at(i) == "WA") {
      C2++;
    }
    if (S.at(i) == "TLE") {
      C3++;
    }
    if (S.at(i) == "RE") {
      C4++;
    }
  }
  cout << "AC x " << C1 << endl;
  cout << "WA x " << C2 << endl;
  cout << "TLE x " << C3 << endl;
  cout << "RE x " << C4 << endl;
  
}


Measured memory_bytes: 6376
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
typedef pair<P,P> P2;
const ll INF=100000000000000001;

int main() {


	int n,m;
	int r[51]={};
	cin>>n>>m;
	int a,b;
	for(int i=0;i<m;++i){
		cin>>a>>b;
		r[a]++;
		r[b]++;
	}
	for(int i=1;i<n+1;++i)cout<<r[i]<<endl;
//	if(a<=c&&b>=c){
//		cout<<"Yes"<<endl;
//	}else{
//		cout<<"No"<<endl;
//	}
	//
//	cin>>n;
//	int total=1;
//	for(int i=0;i<n;i++)total=(total*2)%1000000007;
//	for(int i=1;i<n+1;i++){
//		cin>>p[i];
//		R[p[i]].push_back(i);
//	}
//	queue<int> que;
//	que.push(0);
//	while(!que.empty()){
//		int p=que.front();que.pop();
//		int sum=0;
//		for(auto it:R[p]){
//			sum+=R[it].size();
//		}
//		int k=n-sum;
//	}
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <stack>
#include <cstdlib>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef double DB;

int A, B, C, D, E, F;
bool vis[3005], ok[3005];

int main()
{
	memset(vis, 0, sizeof(vis));
	scanf("%d%d%d%d%d%d", &A, &B, &C, &D, &E, &F); 
	vis[0] = 1;
	for(int i = 1; i <= (F / 100); i++) {
		if(i - A >= 0 && vis[i - A]) vis[i] = 1;
		if(i - B >= 0 && vis[i - B]) vis[i] = 1;
	}
	DB p = 0.00; int ans1 = A * 100, ans2 = 0;
	for(int i = 1; i <= (F / 100); i++) {
		if(vis[i]) {
			memset(ok, 0, sizeof(vis));
			int P = min(F - i * 100, E * i);
			ok[0] = 1;
			for(int j = 1; j <= P; j++) {
				if(j - C >= 0 && ok[j - C]) ok[j] = 1;
				if(j - D >= 0 && ok[j - D]) ok[j] = 1;
			}
			int U = 0;
			for(int j = P; j >= 0; j--)
				if(ok[j]) {U = j; break;}
			if((DB)U / (DB)(U + i * 100) > p) 
				p = (DB)U / (DB)(U + i * 100), ans1 = U + i * 100, ans2 = U;
		}
	}
	printf("%d %d\n", ans1, ans2);
}

Measured memory_bytes: 256
#abc15047d
n=int(raw_input())
a=map(int,raw_input().split())
mod=10**9+7
res=0
for i in range(60):
 cnt=sum([1 for x in a if (x>>i & 1)])
 res+=cnt*(n-cnt)*(1<<i)
 res=res%mod
print res


Measured memory_bytes: 134988
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
)

var sc *bufio.Scanner

const BufferSize = 1024

func nextString() string {
	if !sc.Scan() {
		panic(nil)
	}
	return sc.Text()
}

// 1 - 3 patterns
// 0 0,1
// 1 0
// 1*3

// 11 - 9 patterns
// 00 00,01,10,11
// 01 00,10
// 10 00,01
// 11 00
// 3*3
// 1*3*3
// [2,4] [1,5]

// 10 - 5 patterns
// 00 00,01,10
// 01 00
// 10 00
// 3 + 2
// 3(1)-5(10)
// [2,2] [1,3]

// 100 - 11 patterns
// 000 000,001,010,011,100
// 001 000,010
// 010 000,001
// 011 000
// 100 000
// 5(10)-11(100)
// [2,2,2] [1,3,9]

// 110 - 19 patterns
// 000 000,001,010,011,100,101,110
// 001 000,010,100
// 010 000,001,100
// 011 000
// 100 000,001,010
// 101 000
// 110 000
// 1*3*3
// 9 + 5 + 5
// 1*3*3 + 2*(1*3+2*1)
// 9 + 5 + 5
// 1*3*3 + 1*1*3 + 1*2*1 + 1*1*3 + 1*2*1
// 9(11)-19(110)
// [2,4,4] [1,5,15]

// 111 - 27 patterns
// [2,4,8] [1,5,19]

func answer(reader io.Reader, writer io.Writer) {
	sc = bufio.NewScanner(reader)
	buf := make([]byte, BufferSize)
	sc.Buffer(buf, 1e+7)
	sc.Split(bufio.ScanWords)
	s := nextString()
	mod := 1000*1000*1000 + 7

	dp1 := make([]int, len(s))
	dp2 := make([]int, len(s))

	for i := 0; i < len(s); i++ {
		if i == 0 {
			dp1[0] = 2
			dp2[0] = 1
			continue
		}

		dp1[i] = dp1[i-1]
		dp2[i] = dp2[i-1] * 3

		if string(s[i]) == "1" {
			dp1[i] += dp1[i-1]
			dp2[i] += dp1[i-1]
		}
		dp1[i] %= mod
		dp2[i] %= mod
	}
	_, _ = fmt.Fprintf(writer, "%d", (dp1[(len(s)-1)]+dp2[len(s)-1])%mod)
}

func main() {
	answer(os.Stdin, os.Stdout)
}


Measured memory_bytes: 2560
import std.algorithm, std.array, std.conv, std.range, std.stdio, std.string;
import std.utf;

enum inf = 1 << 24;
void main()
{
    auto buf = readln.chomp.split.to!(int[]);
    immutable height = buf[0], width = buf[1];
    auto map = Map(Grid(buf[0], buf[1]));
    foreach (i; 0..height)
        map.addRow(readln.chomp);
    auto distances = new int[][](map.length, map.length);
    foreach (i, ref row; distances)
        foreach (j, ref elem; row)
            if (i != j) elem = inf;
    foreach (i0; 0..map.height)
        foreach (j0; 0..map.width)
            foreach (d; [[-1, 0], [1, 0], [0, 1], [0, -1]])
            {
                immutable
                        i1 = i0 + d[0],
                        j1 = j0 + d[1];
                debug stderr.writefln("%d, %d - %d, %d", i0, j0, i1, j1);
                if (i1 < 0 || map.height <= i1) continue;
                if (j1 < 0 || map.width <= j1) continue;
                if (map.map[i0][j0] || map.map[i1][j1]) continue;
                debug stderr.writefln("connected");
                distances[map.coordinateToIndex(i0, j0)][map.coordinateToIndex(i1, j1)] = 1;
            }
    debug stderr.writefln("%(%(% 3d%)\n%)", distances);
    foreach (k; 0..distances.length)
        foreach (i; 0..distances.length)
            foreach (j; 0..distances.length)
                distances[i][j] = min(distances[i][j],
                        distances[i][k] + distances[j][k]);
    debug stderr.writefln("%(%(% 3d%)\n%)", distances);
    distances.joiner.array.sort!((a, b) => a > b).uniq.find!(a => a != inf).front.writeln;
}

struct Grid
{
    immutable size_t height, width;
    auto coordinates() const
    {
        return height.iota.cartesianProduct(width.iota);
    }
    auto coordinateToIndex(size_t i, size_t j) const
    {
        return i * width + j;
    }
    auto length() const
    {
        return height * width;
    }
}
unittest
{
    auto g = Grid(4, 5);
    assert (g.coordinates.map!(c => g.coordinateToIndex(c[0], c[1])).
            equal(g.length.iota));
    stderr.writeln("unittest passed!");
}
enum MapElement
{
    road, wall
}
struct Map
{
    Grid grid;
    MapElement[][] map;
    this (Grid grid)
    {
        this.grid = grid;
    }
    void addRow(string t)
    {
        with (MapElement)
            map ~= t.byChar.map!(c => ['.': road, '#': wall][c]).array;
        assert (map[$-1].length == width);
    }
    alias grid this;
}


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

using ll = long long;

// [pos][i - 3][i - 2][i - 1][already ok][strictly less]
ll dp[20][10][10][10][2][2];

ll solve(ll n) {
	dp[0][0][0][0][0][0] = 1;
	const auto s = to_string(n);
	const int m = s.size();
	for (int i = 0; i < m; ++i) {
		for (int i3 = 0; i3 <= 9; ++i3) for (int i2 = 0; i2 <= 9; ++i2) for (int i1 = 0; i1 <= 9; ++i1) {
			for (int aok = 0; aok <= 1; aok++) {
				for (int le = 0; le <= 1; ++le) {
					const int lim = le ? 9 : s[i] - '0';
					for (int add = 0; add <= lim; ++add) {
						int nok = aok || (i3 == 5 && i2 == 1 && add == 3);
						int nle = le || s[i] - '0' > add;
						dp[i + 1][i2][i1][add][nok][nle] += dp[i][i3][i2][i1][aok][le];
					}
				}
			}
		}
	}

	ll ans = 0;
	for (int i = 0; i <= 9; ++i) {
		for (int j = 0; j <= 9; ++j) {
			for (int k = 0; k <= 9; ++k) {
				ans += dp[m][i][j][k][1][0] + dp[m][i][j][k][1][1];
			}
		}
	}
	return ans;
}

int main() {
	ll N;
	cin >> N;
	cout << solve(N) << endl;
}



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

S = sum(A)

M = [0 for _ in range(N)]

M0 = S

for i in range(1, N, 2):
    M0 -= 2*A[i]

M[0] = M0

for i in range(1, N):
    M[i] = 2*A[i-1] - M[i-1]


print(*M)


Measured memory_bytes: 95440
package main

import (
	"fmt"
  	"sort"
)

func main() {
	var n,m,x,y int
  	fmt.Scan(&n,&m,&x,&y)
	
  xcities := make([]int,n+1)
  xcities[0] = x;
  ycities := make([]int,m+1)
  ycities[0] = y;
  
  for i := 1; i < len(xcities); i++ {
    fmt.Scan(&xcities[i])
  }
  for i := 1; i < len(ycities); i++ {
    fmt.Scan(&ycities[i])
  }
  sort.Ints(xcities)
  sort.Ints(ycities)
  if xcities[n] < ycities[0] {
    fmt.Println("No War")
  } else {
    fmt.Println("War")
  }
}

Measured memory_bytes: 512
fn main() {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).ok();
    let s = line.trim();
    let mut ans = 0;
    for c in s.chars() {
        if c == '1' {
            ans = ans + 1;
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 4352
#!/usr/bin/env python3

import numpy as np


def solv(n, a_, b_):
    idxs = np.argsort(b_, axis=0)
    t = 0
    for i in idxs:
        t += a_[i]
        if t > b_[i]:
            return 'No'
    return 'Yes'


if __name__ == '__main__':

    n = int(input())
    a_ = np.empty(n, dtype=np.int32)
    b_ = np.empty(n, dtype=np.int32)

    for i in range(n):
        a, b = map(int, input().split())
        a_[i] = a
        b_[i] = b

    ans = solv(n, a_, b_)

    print(ans)

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

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

int main() {
   int a[] = {-1, 0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
   int x, y;
   cin >> x >> y;
   puts(a[x]==a[y]?"Yes":"No");

   return 0;
}

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

int main(){
    int n, a[100];
    cin >> n;
    for(int i=0;i<n;i++) cin >> a[i];
    // selecion sort
    int m_ind, swap_num = 0;
    for(int i=0;i<n;i++){
        m_ind = i;
        for(int j=i+1;j<n;j++){
            if(a[j] < a[m_ind]) m_ind = j;
        }
        swap(a[i], a[m_ind]);
        if(i!=m_ind) swap_num++;
    }
    // disp result
    for(int i=0;i<n;i++){
        if(i) cout << ' ';
        cout << a[i];
    }
    cout << endl;
    cout << swap_num << endl;
    return 0;
}



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

#define int long long
#define endl '\n'

signed main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    char c; cin >> c;
    cout << (c >= 'a' && c <= 'z' ? 'a': 'A');    
}


Measured memory_bytes: 3608
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<queue>
#include<math.h>
#include<complex>

using namespace std;


//ユークリッドの互除法　a,bは最大公約数を求めたい２つの数
long long int gcd(long long int a, long long int b) {
             long long int tmp;
             long long int r = 1;
             if (b > a) {
                           tmp = a;
                           a = b;
                           b = tmp;
             }
             r = a % b;
             while (r != 0) {
 
 
                           a = b;
                           b = r;
                           r = a % b;
 
             }
             return b;
}

const long long int mod=1000000007;
int main(){
	long long int n=0;
	string str,str2="CODEFESTIVAL2016";
	cin>>str;
	for(int i=0;i<16;i++){
		if(str[i]!=str2[i]){n++;}
	}
	cout<<n<<endl;
}


Measured memory_bytes: 256
import sys
f = sys.stdin


import operator
while True:
    a = sum(map(int, f.readline().split()))
    if a == 0:
        break
    abcde = [a] + [sum(map(int, f.readline().split())) for i in range(4)]
    print(*max(zip('ABCDE', abcde), key=operator.itemgetter(1)))

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

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

  int ans = 0;
  for(int i=0; i < n-2; i++) {
    if (s[i] == 'A' && s[i+1] == 'B' && s[i+2] == 'C') ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#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 sp(n) cout << fixed << setprecision(n)
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 ll;
using namespace std;
int main(void){
    int n;cin>>n;
    string s,t;cin>>s>>t;
    int res=s.size()+t.size();
    rep(i,s.size()){
        bool ok=true;
        if(s.size()-i>t.size())continue;
        for(int j=0;j<s.size()-i;j++){
            if(s[i+j]!=t[j]){
                ok=false;
                break;
            }
        }
        if(ok){
            int buf=t.size()+i;
            chmin(res,buf);
        }
    }
    cout<<res<<endl;
}

Measured memory_bytes: 3552
#pragma gcc optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n; cin >> n;
    vector<int> ans(10001);
    for (int i = 1; i < 200; ++i)
    for (int j = 1; j < 200; ++j)
    for (int k = 1; k < 200; ++k) {
        int t = i * i + j * j + k * k + i * j + j * k + k * i;
        if (t <= 10000) ++ans[t];
    }
    for (int i = 1; i <= n; ++i) cout << ans[i] << '\n';
}

Measured memory_bytes: 3640
N = int(input())
S, T = [], []
for i in range(N):
    S.append(input())
M = int(input())
for i in range(M):
    T.append(input())

    cnt = 0
for s in set(S):
    cnt = max(cnt, S.count(s)-T.count(s))
print(cnt)

Measured memory_bytes: 3064