akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <tuple>
#include <vector>
#include <bitset>
#include <stack>
#include <iomanip>
#include <set>
#include <queue>
typedef long long ll;
typedef unsigned long long ull;
#define mk make_pair
#define mkt make_tuple

using namespace std;
const int N = 20;
bool walls[N][N];
int h, w;

bool isValid(pair<int, int> pos) {
    return pos.first >= 0 && pos.first < h
        && pos.second >= 0 && pos.second < w
        && !walls[pos.first][pos.second];
}


int bfs(pair<int, int> start) {
    int d[N][N]; memset(d, -1, sizeof(d));
    queue<pair<int, int>> q;
    int ans = 0;
    q.push(start);
    d[start.first][start.second] = 0;

    while (!q.empty()) {
        auto t = q.front();
        q.pop();

        for(int i = t.first - 1; i<=t.first +1; i++)
            for (int j = t.second - 1; j <= t.second + 1; j++) {
                auto p = mk(i, j);
                if (isValid(p) && d[i][j] == -1 && (i == t.first || j == t.second)) {
                    d[i][j] = d[t.first][t.second] + 1;
                    ans = max(ans, d[i][j]);
                    q.push(p);
                }
            }
    }

    return ans;
}

int main()
{
    cin >> h >> w;
    string s;
    int ans = 0;

    for (int i = 0; i < h; i++) {
        cin >> s;
        for (int j = 0; j < w; j++)
            walls[i][j] = s[j] == '#';
    }

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
            if(!walls[i][j])
                ans = max(ans, bfs(mk(i, j)));

    cout << ans;
}



Measured memory_bytes: 256
fn main() {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    use std::iter::FromIterator;
    let mut iter = input.split_whitespace();
    let n : usize = iter.next().unwrap().parse().unwrap();
    let mut v : Vec<usize> = Vec::from_iter(iter.map(|s| s.parse().unwrap()));
    v.sort();
    for i in 0..n-1 {
        if v[i] == v[i+1] {
            println!("NO");
            return;
        }
    }
    println!("YES");
}


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

int main() {
    ll N;
    cin >> N;

    vector<vector<ll>> num(10, vector<ll>(10, 0));
    for (ll i = 1; i <= N; i++) {
        string str_i = to_string(i);
        num[str_i.front() - '0'][str_i.back() - '0']++;
    }

    ll ans = 0;
    for (ll i = 0; i < 10; i++) {
        for (ll j = 0; j < 10; j++) {
            ans += num[i][j] * num[j][i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
program AIsing2020C
    implicit none
    integer(8)::N,i,j,k,A(10000),m
    read*,N
    A=0

    do i=1,100
        do j=1,100
            do k=1,100
                m=i**2+j**2+k**2+i*j+j*k+k*i
                if(m<=10000)A(m)=A(m)+1
            end do
        end do
    end do

    do i=1,N
        print'(i0)',A(i)
    end do
end program AIsing2020C

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

int main() {
  int N;
  cin >> N;
  vector<int> cnt(100010);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    cnt.at(a)++;
  }
  int ans = cnt.at(0) + cnt.at(1);
  for (int i = 1; i <= 100000; i++) {
    ans = max(ans, cnt.at(i-1) + cnt.at(i) + cnt.at(i+1));
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<set>
#include<vector>
#include<functional>
#include <random>
#include<iostream>
#include<iomanip>
using namespace std;

int m(int a, int b) {
	if (a < b) { return a; }
	else { return b; }
}


int main() {
	int H, W;
	char s[101][101];
	char t[102][102];
	int ans[101][101];

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

	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (i == 0) {
				if (j == 0) {
					if (s[0][0] == '.') {
						ans[0][0] = 0;
					}
					else {
						ans[0][0] = 1;
					}
				}
				else {
					if (s[0][j] == '.') {
						ans[0][j] = ans[0][j - 1];
					}
					else {
						if (s[0][j - 1] == '.') {
							ans[0][j] = ans[0][j - 1] + 1;
						}
						else {
							ans[0][j] = ans[0][j - 1];
						}
					}
				}
			}
			else if (j == 0) {
				if (s[i][0] == '.') {
					ans[i][0] = ans[i - 1][0];
				}
				else {
					if (s[i - 1][0] == '.') {
						ans[i][0] = ans[i - 1][0] + 1;
					}
					else {
						ans[i][0] = ans[i - 1][0];

					}
				}
			}
			else {
				if (s[i][j] == '.') {
					ans[i][j] = m(ans[i - 1][j], ans[i][j-1]);
				}else{
					int a = 0;
					int b = 0;
					if (s[i-1][j] == '.') { a = 1; }
					if (s[i][j-1] == '.') { b = 1; }
					ans[i][j] = m(ans[i - 1][j] + a, ans[i][j - 1] + b);
				}
			}
		}
	}

	cout << ans[H-1][W-1];
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;


int main()
{
    uint64_t N;
    cin >> N;

    uint64_t p = 1;
    for (uint64_t i = 1; i <= N; ++i)
    {
        p = p * i % (1'000'000'000 + 7);
    }

    cout << p << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define sz size()
#define all(a)  a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define mod 1000000007
#define _for(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); ++it)

using namespace std;

int a[200005];
int N;
pair<int, int> dp1[200005][35];
pair<int, int> dp2[200005][35];

void pre(){
  for(int n = 0; n < N; ++n){
    dp1[n][0] = mp(a[n], n);
    dp2[n][0] = mp(a[n], n);
  }
  for(int j = 1; j <= 30; ++j){
    for(int i = 0; i <= (N - (1 << j)); ++i){
      if(dp1[i][j - 1].ff < dp1[i + (1 << (j - 1))][j - 1].ff){
        dp1[i][j] = dp1[i][j - 1];
      }
      else{
        dp1[i][j] = dp1[i + (1 << (j - 1))][j - 1];
      }

      if(dp2[i][j - 1].ff > dp2[i + (1 << (j - 1))][j - 1].ff){
        dp2[i][j] = dp2[i][j - 1];
      }
      else{
        dp2[i][j] = dp2[i + (1 << (j - 1))][j - 1];
      }
    }
  }
}

pair<int, int> queryMin(int l, int r){
  pair<int, int> res;
  res.ff = 1e9 + 7;
  res.ss = -1;
  int pl = l;
  int pr = r;
  for(int j = 30; j >= 0; --j){
    if(l + (1 << j) - 1 <= r){
      if(res.ff > dp1[l][j].ff){
        res = dp1[l][j];
      }
      l += (1 << j);
    }
  }
  assert(res.ss >= pl && res.ss <= pr);
  return res;
}

long long res = 0;

void solve(int l, int r){
   if(l > r) return;
   pair<int, int> idx = queryMin(l, r);
   long long right = (idx.ss - l + 1) * 1ll * (r - idx.ss + 1);
   res += idx.ff * right;
   solve(l, idx.ss - 1);
   solve(idx.ss + 1, r);
}

int main(){
   cin >> N;
   for(int n = 0; n < N; ++n){
      scanf("%d", &a[n]);
   }
   pre();
   solve(0, N - 1);
   cout << res << endl;
   return 0;
}

Measured memory_bytes: 116736
#include <cstdio>
#include <math.h>

using namespace std;

int main(){
  int tmp, n;
  scanf("%d", &n);
  int min =  1000001;
  int max = -1000001;
  long long int sum = 0;
  for(int i=0; i<n; i++) {
    scanf("%d", &tmp);
    if(min > tmp) {
      min = tmp;
    }
    if(max < tmp) {
      max = tmp;
    }
    sum += tmp;
  }
  printf("%d %d %lld\n", min, max, sum);
}



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

using VI = vector<int>;
using VVI = vector<VI>;

void dfs(int v, VI &used, VVI &adj, VI &vs) {
  used[v] = true;
  for (int i = 0; i < adj[v].size(); i++) {
    if (!used[adj[v][i]]) dfs(adj[v][i], used, adj, vs);
  }
  vs.push_back(v);
}

void rdfs(int v, int k, VI &used, VVI &adjv, VI &cmp) {
  used[v] = true;
  cmp[v] = k;
  for (int i = 0; i < adjv[v].size(); i++) {
    if (!used[adjv[v][i]]) rdfs(adjv[v][i], k, used, adjv, cmp);
  }
}

void solve(int n) {
  vector<double> ps;
  VVI adj(n), adjv(n);
  for (int i = 0; i < n; i++) {
    double p;
    cin >> p;
    ps.push_back(p);
    int m;
    cin >> m;
    for (int j = 0; j < m; j++) {
      int k;
      cin >> k;
      k--;
      adj[i].push_back(k);
      adjv[k].push_back(i);
    }
  }
  VI used(n, 0);
  VI cmp(n, -1);
  VI vs;

  for (int i = 0; i < n; i++) {
    if (!used[i]) dfs(i, used, adj, vs);
  }
  used = VI(n, 0);
  int k = 0;
  for (int i = vs.size() - 1; i >= 0; i--) {
    if (!used[vs[i]]) rdfs(vs[i], k++, used, adjv, cmp);
  }

  double ans = 1;
  VVI g(k, VI(k, 0));
  for (int i = 0; i < n; i++) {
    for (int j: adj[i]) {
      // i -> j
      if (cmp[i] != cmp[j]) {
        g[cmp[i]][cmp[j]] = 1;
      }
    }
  }
  for (int i = 0; i < k; i++) {
    int deg = 0;
    for (int j = 0; j < k; j++) {
      if (g[j][i]) deg++;
    }
    if (deg == 0) {
      double pp = 1.0;
      for (int l = 0; l < n; l++) {
        if (cmp[l] == i) {
          pp *= ps[l];
        }
      }
      ans *= (1.0 - pp);
    }
  }
  printf("%.8f\n", ans);
}

int main() {
  int n;
  while (1) {
    cin >> n;
    if (n == 0) return 0;
    solve(n);
  }
}



Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x) ((x) * (x))
#define bit(n) (1LL<<(n))
#define pcnt(x) __builtin_popcountll(x)
#define PB push_back
#define MP make_pair
#define endl "\n"
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main() {
  int n; cin >> n;
  map<ll,ll> mp;
  ++mp[0];
  ll now = 0;
  FOR(i,0,n-1){
    ll a; cin >> a;
    now += a;
    ++mp[now];
  }
  ll ans = 0;
  for(auto x: mp){
    ans += x.second * (x.second-1) / 2;
  }
  cout << ans << "\n";
    

}


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

int main(){
    using namespace std;
    unsigned long N, K;
    cin >> N >> K;
    vector<unsigned long> A(N);
    for(auto&& i : A)cin >> i;
    unsigned long R{0}, L{*max_element(begin(A), end(A))};
    while(R + 1 < L){
        unsigned long M{(R + L) / 2};
        unsigned long t{0};
        for(const auto& i : A)t += (i - 1) / M;
        (t <= K ? L : R) = M;
    }
    cout << L << endl;
    return 0;
}

Measured memory_bytes: 4712
#include <bits/stdc++.h>
      
#define FOR(i,a,b) for(ll i = (a); i < (ll)(b); i++)
#define REP(i,n) FOR(i,0,n)
#define YYS(x,arr) for(auto& x:arr)
#define PW(x) (1LL<<(x))
#define SZ(x) ((ll)(x).size())

#define pb emplace_back
#define fi first
#define se second

using namespace std;

using ld = long double;
using ll = long long int;

const ll INF = (ll)1e9 + 10;
const ll INFLL = (ll)1e18 + 10;
const ll MOD = 1e9+7;
     
template<class T> T &chmin( T &a , const T &b ){ return a = min(a,b); }
template<class T> T &chmax( T &a , const T &b ){ return a = max(a,b); }
template<class T> void UNIQUE(vector<T> &a){ a.erase(unique(a.begin(), a.end()), a.end()); }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

ll in(){long long int x; assert(scanf("%lld", &x) == 1); return x;}
ld fin(){double x; assert(scanf("%lf", &x) == 1); return x;}
char yuyushiki[1000010]; string stin(){assert(scanf("%s", yuyushiki) == 1); return yuyushiki;}

// head

struct Mod{
  unsigned n;
  Mod() : n(0){}
  Mod( ll x ){
    if( x < 0 ) n = x%MOD+MOD;
    else n = x%MOD;
  }
};
Mod operator + ( Mod a  , Mod b ){ return Mod( a.n + b.n ); }
Mod operator +=( Mod &a , Mod b ){ return a = a + b; }
Mod operator - ( Mod a ){ return Mod( MOD - a.n ); }
Mod operator - ( Mod a  , Mod b ){ return Mod( a.n + MOD - b.n ); }
Mod operator -=( Mod &a , Mod b ){ return a = a - b; }
Mod operator * ( Mod a  , Mod b ){ return Mod( (ll)a.n * b.n ); }
Mod operator *=( Mod &a , Mod b ){ return a = a * b; }
Mod modpow( Mod x , ll k ){
  Mod res = 1;
  while( k ){
    if( k & 1 ) res *= x;
    k /= 2;
    x *= x;
  }
  return res;
}
ll extgcd( ll a , ll b , ll &x , ll &y ){
  ll d = a;
  if( b != 0 ){
    d = extgcd( b , a % b , y , x );
    y -= a / b * x;
  } else {
    x = 1, y = 0;
  }
  return d;
}
Mod inv( Mod a ){ ll x, y; assert( extgcd( a.n , MOD , x , y ) == 1 ); return Mod( x ); }
Mod operator / ( Mod a  , Mod b ){ return Mod( (ll)a.n * inv(b).n ); }
Mod operator /=( Mod &a , Mod b ){ return a = a / b; }

vector<int> G[100010];
Mod dp[100010][2];

void dfs(int x, int p){
  Mod s = 1;
  Mod a = 1;
  YYS(w, G[x]){
    if(w == p){
      continue;
    }
    dfs(w, x);
    s *= dp[w][0] + dp[w][1];
    a *= dp[w][0];
  }
  dp[x][1] = a;
  dp[x][0] = s;
}

int main(){

  int n = in();
  REP(i, n-1){
    int a = in() - 1;
    int b = in() - 1;
    G[a].pb(b);
    G[b].pb(a);
  }

  dfs(0, -1);
  
  Mod ans = dp[0][0] + dp[0][1];

  cout << ans.n << endl;

  return 0;
}


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

firstDigit = N % 10

result = ''

if firstDigit in {2, 4, 5, 7, 9}:
  result = 'hon'
elif firstDigit in {0, 1, 6, 8}:
  result = 'pon'
elif firstDigit in {3}:
  result = 'bon'

print(result)

Measured memory_bytes: 9176
"""
問題文は言い換えると、青いボールの連続する区間の数がi個になるような並べ方はいくつあるか。というもの

上記のような並べ方はさらに4種類に分けられる。
(1). 両端が青色になるような並べ方
(2). 両端が赤色になるような並べ方
(3). 左端が赤色、右端が青色になるような並べ方
(4). 左端が青色、右端が赤色になるような並べ方

(1)の場合：A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i-1個のグループに割り振る赤ボールの数)
Aは(k-1)個の隙間から(i-1)個の隙間を選ぶ場合の数なので、(k-1)C(i-1)で計算できる。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i-1)をどう分けるか、の場合の数なので、(N-K-(i-1)+(i-2))C(i-2)で計算できる。

(2)の場合：A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i+1個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-(i+1)をどう分けるか、の場合の数なので、(N-K-(i+1)+i)C(i)で計算できる。

(3)の場合：A(K個並んでいるの青ボールの隙間にi-1個の赤ボールグループをぶっこむ箇所の場合の数) × B(i個のグループに割り振る赤ボールの数)
Aは(1)と同様なので省略。Bは各グループに最低1個は赤色のボールを割り当てるとして残りN-K-iをどう分けるか、の場合の数なので、(N-K-i+(i-1))C(i-1)で計算できる。

(4)は(3)と同様なので省略

なお、赤のボールの数が分割するグループの数以上存在していないと行けないことに注意。
"""
def choose(n,k):
    import math
    return math.factorial(n)//(math.factorial(n-k)*math.factorial(k))
mod = 10**9 +7
N,K = map(int,input().split())
for i in range(1,K+1):
    ans = 0
    A = choose(K-1,i-1)
    
    #(1)の場合の数を求める
    if N-K >= i-1:
        if i-2>=0:
            B = choose(N-K-(i-1)+(i-2),i-2)
            ans += A*B
            ans %= mod
        elif N==K:
            ans += 1
    
    if N-K >= i+1:
        B = choose(N-K-(i+1)+i,i)
        ans += A*B
        ans %= mod

    if N-K >= i:
        B = choose(N-K-i+(i-1),i-1)
        ans += A*B*2
        ans %= mod
    print(ans)

    


Measured memory_bytes: 79856
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
typedef vector<int> vint;
typedef pair<int, int> pint;
#define rep(i, n) REP(i, 0, n)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
template <class T, class C> void chmax(T &a, C b) { a > b ?: a = b; }
template <class T, class C> void chmin(T &a, C b) { a < b ?: a = b; }

int main() {

  int a, b, c, d;
  cin >> a >> b >> c >> d;
  while (true) {
    c -= b;
    if (c <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    a -= d;
    if (a <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }

  return 0;
}


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

int main() {
    string S, T;
    cin >> S >> T;
    if (S.size() + 1 != T.size()) {
        cout << "No" << endl;
    } else {
        bool flag = true;
        for (int i = 0; i < S.size(); i++) {
            if (S[i] != T[i]) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

typedef pair<int, int> ii;
typedef pair<ll, ll> pll;

int main( int argc, char *argv[] ) {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	ll a, b, c, k, s;
	cin >> a >> b >> c >> k;
	
	s = min(a,k);
	k -= a + b;
	if (k > 0)
		s -= k;

	cout << s << "\n";


	return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>
#include <algorithm>
#include <vector>

#define int long long
struct arrow
{
	int target;
	int score;
};

int32_t main()
{
	int32_t N, M;
	int scores[1001];
	std::vector<arrow> arrows[2001];
	scanf("%d%d", &N, &M);
	int i;
	for (i = 0; i <= N; i++)
	{
		scores[i] = -100000000000000LL;
	}
	for (i = 0; i < M; i++)
	{
		int32_t a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		arrows[a].push_back(arrow{ b, c });
	}
	scores[1] = 0;
	std::vector<int> lastchange;
	lastchange.push_back(1);
	int j;
	int newn = 0;
	for (j = 0; j < 2003; j++)
	{
		std::vector<int> ch;
		for (auto c : lastchange)
		{
			int currentscore = scores[c];
			for (auto arr : arrows[c])
			{
				if (scores[arr.target] < currentscore + arr.score)
				{
					if (arr.target == N)
					{
						newn = j;
					}
					scores[arr.target] = currentscore + arr.score;
					bool neww = true;
					for (auto t : ch)
					{
						if (t == arr.target)
						{
							neww = false;
						}
					}
					if (neww)
					{
						ch.push_back(arr.target);
					}
				}
			}
		}
		lastchange = ch;
	}
	if (newn > 1000)
	{
		printf("inf\n");
	}
	else
	{
		printf("%lld\n", scores[N]);
	}
	return 0;
}


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

vector<long long int> dp(100005,-1);
long long int n,ara[100005];
int f(long long int i){

    if(i==n) return 0;

    if(i==n-1) return abs(ara[i+1]-ara[i]);

    if(dp[i]!=-1) return dp[i];

    dp[i] = min(f(i+1)+ abs(ara[i+1]-ara[i]), f(i+2)+abs(ara[i+2]-ara[i]));
    return dp[i];


}




int main()
{
    long long int i;
    cin>>n;
    for(i=1;i<=n;i++){
        scanf("%lld",&ara[i]);
    }

    cout<<f(1)<<endl;

    return 0;
}


Measured memory_bytes: 4096
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<sstream>
#include<bits/stdc++.h>
using namespace std;
int n,m,k,c[1001],r[1001],ans,tot;
char a[1001][1001];
void dsf(int x)
{
	if(x==m+1)
	{
		int sum=0;
		for(int i=1;i<=n;i++)
		{
			for(int j=1;j<=m;j++)
			{
				if((c[i]||r[j])&&a[i][j]=='#')sum++;	
			}	
		}
		if(tot-sum==k)
			ans++;
		return;
	}
	dsf(x+1);
	r[x]=1;
	dsf(x+1);
	r[x]=0;
}
void dfs(int x)
{
	if(x==n+1)
	{
		dsf(1);
		return;
	}
	dfs(x+1);
	c[x]=1;
	dfs(x+1);
	c[x]=0;
	
}
int main()
{
	cin>>n>>m>>k;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			cin>>a[i][j];
			if(a[i][j]=='#')tot++;
		}
		getchar();
	}
	dfs(1);
	cout<<ans;
}

Measured memory_bytes: 3632
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
int ma[30],now[30];
int main()
{
	rep(i,30) ma[i]=58;
	int n;string s,out="";
	cin>>n;
	rep(i,n){
		cin>>s;
		memset(now,0,sizeof(now));
		rep(j,s.size()) now[(s[j]-'a')]++;
		rep(j,26) ma[j]=min(now[j],ma[j]);
	}
	rep(i,26) rep(j,ma[i]) out+=('a'+i);
	cout<<out<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
int main(){
  int n;
  cin>>n;
  int lowest=300000;
  int count=0;
  for(int i=0; i<n; i++){
    int pi;
    cin>>pi;
    if(pi<=lowest){
      count++;
      lowest=pi;
    }
  }
  cout<<count<<endl;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;

int main(void){
  int a,b;
  cin >> a >> b;
  if(a%3 == 0 || b%3 == 0 || (a+b)%3 == 0){
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }

  return 0;
}

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

int main(){
    string str1,str2;

    cin >> str1;
    cin >> str2;

    for(int i=0;i<str1.length();i++){
        if(str1==str2){
            cout << "Yes" << endl;
            return 0;
        }
        string tmp=str2.substr(str2.length()-1,1)+str2.substr(0,str2.length()-1);
        str2=tmp;
    }
    if(str1==str2){
        cout << "Yes" << endl;
        return 0;
    }
    else{
        cout << "No" << endl;
        return 0;
    }


    return 0;
}

Measured memory_bytes: 256
lines = []
while line = gets
    lines << line.chomp.split(' ').map(&:to_i)
end

N = lines[0][0]
X = lines[0][1]

ans = 1
now = 0
for i in 1..N do
  now += lines[1][i-1]
  if now <= X then
    ans += 1
  end
end
  
puts ans

Measured memory_bytes: 14340
class Paper

  def initialize
    @paper = Array.new(10).map! { Array.new(10, 0) }
  end

  def drop_ink ink
    if ink.size == 1 then
      drop_point(ink.x, ink.y)
      drop_point(ink.x - 1, ink.y)
      drop_point(ink.x + 1, ink.y)
      drop_point(ink.x, ink.y - 1)
      drop_point(ink.x, ink.y + 1)
    elsif ink.size == 2 then
      (ink.x - 1).upto(ink.x + 1) do |x|
        (ink.y - 1).upto(ink.y + 1) do |y|
          drop_point(x, y)
        end
      end
    else
      (ink.x - 1).upto(ink.x + 1) do |x|
        (ink.y - 1).upto(ink.y + 1) do |y|
          drop_point(x, y)
        end
      end
      drop_point(ink.x - 2, ink.y)
      drop_point(ink.x + 2, ink.y)
      drop_point(ink.x, ink.y - 2)
      drop_point(ink.x, ink.y + 2)
    end
  end

  def count_no_color
    result = 0
    @paper.each do |arr|
      arr.each do |point|
        result += 1 if point == 0
      end
    end
    return result
  end

  def most_dark
    max = 0
    @paper.each do |arr|
      arr.each do |point|
        max = point if max < point
      end
    end
    return max
  end

  private

  def check_point x,y
    if ( 0 <= x && x <= 9 ) && ( 0 <= y && y <= 9 ) then
      return true
    else
      return false
    end
  end

  def drop_point x,y
    @paper[x][y] += 1 if check_point(x, y)
  end

end

class Ink
  def initialize(x, y, size)
    @x, @y, @size = x, y, size
  end
  attr :x, :y, :size
end

paper = Paper.new
while true
  line = gets
  break if line == nil
  x, y, size = line.split(',').map{|i| i.to_i}
  ink = Ink.new(x, y, size)
  paper.drop_ink(ink)
end

puts paper.count_no_color
puts paper.most_dark

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

using namespace std;
using ll = long long;

const int N = 100005;

int n;

int a[N];

pair<int, int> ta[N];

vector<pair<int, int>> g[N];

vector<int> ans;
int vis[N];

int dfs(int u) {
	vis[u] = 1;
	int ret = a[u];
	for(auto e : g[u]) if(!vis[e.first]) {
		int tmp = dfs(e.first);
		if(tmp) {
			ans.push_back(e.second);
			ret ^= 1;
		}
	}
	return ret;
}

int main() {

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

	for(int i = 0; i < n; i++) {
		scanf("%d %d", &ta[i].first, &ta[i].second);
	}
	sort(ta, ta + n);
	for(int i = 0; i < n; i++) {
		a[i] = ta[i].second;
	}
	for(int i = n; i > 0; i--) {
		a[i] ^= a[i - 1];
	}

	for(int i = 0; i < m; i++) {
		int l, r;
		scanf("%d %d", &l, &r);
		int idl = int(lower_bound(ta, ta+n, make_pair(l, 0))-ta);
		int idr = int(upper_bound(ta, ta+n, make_pair(r, 1))-ta);
		if(idl >= idr) continue;
		g[idl].emplace_back(idr, i);
		g[idr].emplace_back(idl, i);
	}

	for(int i = 0; i <= n; i++) if(!vis[i]) {
		if(dfs(i)) return printf("-1\n"), 0;
	}

	sort(ans.begin(), ans.end());

	printf("%d\n", (int)ans.size());
	for(int i = 0; i < (int)ans.size(); i++) {
		printf("%d%c", ans[i]+1, " \n"[i + 1 == (int)ans.size()]);
	}
}



Measured memory_bytes: 14460
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    int a, b;
    char op;
 
    while(1){
        cin >> a >> op >> b;
 
        if(op == '+'){
            cout << a + b << endl;
        }else if(op == '-'){
            cout << a - b << endl;
        }else if(op == '*'){
            cout << a * b << endl;
        }else if(op == '/'){
            cout << a / b << endl;
        }else{
            break;
        }
    }
 
    return(0);
}

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

using ll = long long;

#define pb push_back
#define mkp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)
#define FOR(it,c) for ( __typeof((c).begin()) it=(c).begin(); it!=(c).end(); it++ )

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

ll a, b, n;
    
ll ok(ll x) {
	return (a*x)/b - a * (x/b);
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b >> n;
    ll lo = 1, hi = n;
    while(lo != hi) {
    	ll mid = (lo+hi+1)/2;
    	if(ok(lo) <= ok(mid))
    		lo = mid;
    	else
    		hi = mid-1;	
    }
    cout << ok(lo) << "\n";
    return 0;
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s,t;
  cin >> s >> t;
  if (s.size() > t.size()) {
    cout << "GREATER" << endl;
    return 0;
  } else if (t.size() > s.size()) {
    cout << "LESS" << endl;
    return 0;
  }
  for (int i=0; i<s.size(); i++) {
    if (s.at(i) > t.at(i)) {
      cout << "GREATER" << endl;
      return 0;
    } else if (t.at(i) > s.at(i)) {
      cout << "LESS" << endl;
      return 0;
    }
  }
  cout << "EQUAL" << endl;
}

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

int main() {
	int k;
	cin >> k;
	string st="";
	rep(i,k) 
		st += "ACL";
	cout << st << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
 
using namespace std;
using namespace __gnu_pbds;
 
#define debug(s) cout << #s << " = " << s << endl
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define maxn 100010
#define INF 1e15
#define ff first
#define ss second
#define endl '\n'
typedef long long ll;
 
//typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

int arr[21][21];
int n, m, c;
int b[21];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m >> c;
  for (int i = 1; i <= m; ++i) cin >> b[i];
  for (int i = 1; i <= n; ++i) {
    for (int j = 1; j <= m; ++j) {
      cin >> arr[i][j];
    }
  }
  int ans = 0;
  for (int i = 1; i <= n; ++i) {
    int sum = c;
    for (int j = 1; j <= m; ++j) sum += (b[j] * arr[i][j]);
    if (sum > 0) ans++;
  } 
  cout << ans << endl;
}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

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;
}


struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

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

    int size(int x) {
        return sz[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};


int main(){
  int i,j;
  int n,m,k;
  cin>>n>>m>>k;
  VI v(n,0);
  UnionFind uf(n);
  for(i=0;i<m;i++){
    int a,b;
    cin>>a>>b;
    a--; b--;
    v[a]++;
    v[b]++;
    uf.unite(a,b);
  }
  for(i=0;i<n;i++){
    v[i]=uf.size(i)-v[i]-1;
  }
  for(i=0;i<k;i++){
    int c,d;
    cin>>c>>d;
    c--; d--;
    if(uf.same(c,d)) {
      v[c]--;
      v[d]--;
    }
  }
  for(i=0;i<n;i++){
    cout<<v[i]<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 2816
#include <bits/stdc++.h>
using namespace std;
int main(){
  double A[5];
  cin >> A[0] >> A[1] >> A[2] >> A[3] >> A[4];
  int min=10;
  for(int i=0;i<5;i++){
    if (int(A[i])%10!=0 && min>int(A[i])%10){
      min=int(A[i])%10;
    }
  }
  min=10-min;
  cout << ceil(A[0]/10.0)*10 + ceil(A[1]/10.0)*10 +ceil(A[2]/10.0)*10+ceil(A[3]/10.0)*10+ceil(A[4]/10.0)*10-min;
}


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

int main(){

    long long n, C; cin >> n >> C;
    vector<long long> x(n + 2, 0);
    vector<long long> v(n + 2, 0);
    for(int i = 1; i <= n; i++){
        cin >> x[i] >> v[i];
    }

    x[n + 1] = C;

    vector<long long> a(n + 2);
    vector<long long> b(n + 2);

    for(int i = 1; i <= n; i++){
        a[i] = -(x[i] - x[i - 1]) + v[i];
    }

    for(int i = n; i >= 1; i--){
        b[i] = -(x[i + 1] - x[i]) + v[i];
    }

    /*for(int i = 1; i <= n; i++){
        cout << a[i] << " " << b[i] << endl;
    }*/

    for(int i = 2; i <= n; i++) a[i] += a[i - 1];
    for(int i = n - 1; i >= 0; i--) b[i] += b[i + 1];

    long long ans = 0;
    for(int i = 1; i <= n; i++){
        ans = max(ans, max(a[i], b[i]));
        //cout << a[i] << " " << b[i] << endl;
    }

    vector<long long> c(n + 2);
    for(int i = 1; i <= n; i++){
        c[i] = -2*(x[i] - x[i - 1]) + v[i];
    }

    for(int i = 2; i <= n; i++) c[i] += c[i - 1];

    long long q = c[1];
    for(int i = 2; i <= n; i++){

        if(c[i] <= q) c[i] = q;
        else q = c[i];
    }

    /*for(int i = 1; i <= n; i++) cout << c[i] << " ";
    cout << endl;*/

    long long dis = 0;
    long long vv = 0;
    for(int k = n; k >= 2; k--){
        dis += x[k + 1] - x[k];
        vv += v[k];
        ans = max(ans, c[k - 1] + vv - dis);
    }

    dis = 0;
    vv = 0;

    vector<long long> d(n + 2);
    for(int i = n; i >= 1; i--){
        d[i] = -2*(x[i + 1] - x[i]) + v[i];
    }

    for(int i  = n - 1; i >= 1; i--) d[i] += d[i + 1];

    q = d[n];
    for(int i = n - 1; i >= 1; i--){

        if(d[i] <= q) d[i] = q;
        else q = d[i];
    }

    /*for(int i = 1; i <= n; i++) cout << d[i] << " ";
    cout << endl;*/

    for(int k = 1; k < n; k++){
        dis += x[k] - x[k - 1];
        vv += v[k];
        ans = max(ans, d[k + 1] + vv - dis);
    }

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

Measured memory_bytes: 6272
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{
	int parent,left,right;
};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
	if(u==NIL) return;
	D[u] = d;
	setDepth(T[u].left,d+1);
	setDepth(T[u].right,d+1);
}

int setHeight(int u){
	int h1=0,h2=0;
	if(T[u].left!=NIL)
		h1=setHeight(T[u].left)+1;
	if(T[u].right!=NIL)
		h2=setHeight(T[u].right)+1;
	return H[u]=(h1>h2?h1:h2); 
}

int getSibling(int u){
	if(T[u].parent == NIL) return NIL;
	if(T[T[u].parent].left!=u&&T[T[u].parent].left!=NIL)
		return T[T[u].parent].left;
	if(T[T[u].parent].right!=u&&T[T[u].parent].right!=NIL)
		return T[T[u].parent].right;
	return NIL;		
}

void print(int u){
	printf("node %d: ",u);
	printf("parent = %d, ",T[u].parent);
	printf("sibling = %d, ",getSibling(u));
	int deg = 0;
	if(T[u].left !=NIL) deg++;
	if(T[u].right !=NIL) deg++;	
	printf("degree = %d, ",deg);
	printf("depth = %d, ",D[u]);
	printf("height = %d, ",H[u]);
	
	if(T[u].parent == NIL){
		printf("root\n");
	}else if(T[u].left==NIL && T[u].right==NIL){
		printf("leaf\n");
	}else{
		printf("internal node\n");
	}
}

int main() {
	
	int v,l,r,root = 0;
	scanf("%d",&n);
	for(int i=0;i<n;i++) T[i].parent = NIL;
	
	for(int i=0;i<n;i++){
		scanf("%d %d %d",&v,&l,&r);
		T[v].left=l;
		T[v].right=r;
		if(l != NIL) T[l].parent = v;
		if(r!=NIL) T[r].parent = v;
	}
	
	for(int i=0;i<n;i++) 
		if(T[i].parent == NIL) 
			root = i;
	
	setDepth(root,0);
	setHeight(root);
	
	for(int i=0;i<n;i++) print(i);
	
	return 0;
}

Measured memory_bytes: 2740
N = int(input())
H = list(map(int, input().split()))
for i in range(1, N):
  if H[N-i-1] - H[N-i] > 1: 
    print("No")
    break
  elif H[N-i-1] - H[N-i] == 1:
    H[N-i-1] -= 1
else:
  print("Yes")

Measured memory_bytes: 63984
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

constexpr LL kInf = 1e18;
vector<vector<LL>> d;

void warshal_floyd() {
  int V = d.size();
  for (int k = 0; k < V; ++k) {
    for (int i = 0; i < V; ++i) {
      for (int j = 0; j < V; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main() {
  int H, W; cin >> H >> W;
  d.resize(10, vector<LL>(10));
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> d[i][j];
    }
  }
  warshal_floyd();
#if 0
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cout << d[i][j] << " ";
    }
    cout << endl;
  }
#endif

  LL cost = 0;
  for (int r = 0; r < H; ++r) {
    for (int c = 0; c < W; ++c) {
      int a; cin >> a;
      if (a >= 0) {
        cost += d[a][1];
      }
    }
  }
  cout << cost << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;


int main() {
	int n;
	cin >> n;
	int a[105];
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		sum += a[i];
	}
	int t[2];
	t[0] = sum / n;
	t[1] = sum / n + 1;
	int ans = 1000000000;
	for (int i = 0; i < 2; i++) {
		int s = 0;
		for (int j = 0; j < n; j++) {
			s += (t[i] - a[j]) * (t[i] - a[j]);
		}
		if (s < ans)ans = s;
	}
	cout << ans;
}

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

using namespace std;

double get_x(double r1, double r2)
{
    return sqrt(pow(r1 + r2, 2) - pow(r1 - r2, 2));
}

int main()
{
    int N;
    cin >> N;
    vector<double> R(N), x(N);
    for (int i = 0; i < N; i++) {
        cin >> R[i];      
    }
    double res = 0;
    for (int i = 0; i < N; i++) {
        double nx = R[i];
        for (int j = 0; j < i; j++) {
            nx = max(nx, x[j] + get_x(R[i], R[j]));
        }
        x[i] = nx;
        res = max(res, x[i] + R[i]);
    }
    printf("%.10f\n", res);
    return 0;
}

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int64_t n,tmp,i;
  int64_t c=0;
  scanf("%ld",&n);
  if(n%2==1){
    printf("0");
    return 0;
  }
  n=n/2;
  for(i=5;i<=n;i=i*5){
    c=c+n/i;
  }
  printf("%ld",c);
  return 0;
}

Measured memory_bytes: 256
import fractions
num = int(input())
numarray = [int(i) for i in input().split()]

result_f = numarray[:] + [0]
result_t = [0] + numarray[:]
for i in range(num):
    result_f[num-i-1] = fractions.gcd(result_f[num-i], numarray[num-i-1])
    result_t[i+1] = fractions.gcd(result_t[i], result_t[i+1])

gcd_result = []
for i in range(num):
    gcd_result.append(fractions.gcd(result_t[i], result_f[i+1]))

print(max(gcd_result))

Measured memory_bytes: 16144
#include <bits/stdc++.h>
#define REP(i, a, b) for (int i = a; i <= b; ++i)
#define PER(i, a, b) for (int i = a; i >= b; --i)
#define RVC(i, S) for (int i = 0; i < S.size(); ++i)
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;

typedef pair<int, int> pii;
typedef long long LL;
typedef vector<int> VI;

inline int read(){
	int x = 0, ch = getchar(), f = 1;
	while (!isdigit(ch)){if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
	return x * f;
}

const int N = 100005;
int n, m, q, col[N], dp[N][15], inq[N];
VI E[N];
queue<int> qu;

int main(){
	n = read(), m = read();
	REP(i, 1, m){
		int a = read(), b = read();
		E[a].pb(b);
		E[b].pb(a);
	}
	q = read();
	REP(i, 1, q){
		int v = read(), d = read();
		col[i] = read();
		dp[v][d] = i;
	}
	REP(i, 1, n){
		PER(j, 10, 1)
			dp[i][j - 1] = max(dp[i][j - 1], dp[i][j]);
		qu.push(i); inq[i] = 1;
	}
	while (!qu.empty()){
		int h = qu.front();
		qu.pop(); inq[h] = 0;
		RVC(i, E[h]){
			int x = E[h][i];
			int upd = 0;
			PER(j, 10, 1){

				if (max(dp[h][j], dp[x][j]) > dp[x][j - 1]){
					dp[x][j - 1] = max(dp[h][j], dp[x][j]);
					upd = 1;
				}
			}
			if (upd && !inq[x]) qu.push(x), inq[x] = 1;
		}
	}
	REP(i, 1, n) printf("%d\n", col[dp[i][0]]);
	return 0;
}

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

#define pb push_back
#define lli long long int

vector <int> v ;
int main ()
{   
    ios_base::sync_with_stdio(false) ;
    cin.tie(NULL) ;

    int n , aux ;
    cin >> n ;

    for (int i = 0 ; i < n ; i++)
    {
        cin >> aux ;
        v.pb(aux) ;
    }  

    lli ans = LLONG_MAX ;

    for (int i = 1 ; i <= 100000 ; i++)
    {
        lli at = 0 ;

        for (int j = 0 ; j < n ; j++)
        {
            at += pow((v[j] - i) , 2) ;
        }
        
        if (at < ans)
        {
            ans = at ;
        }
    } 

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

Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);

    int n = cin.nextInt();
    double sum = 0;

    for (int i = 0; i < n; i++) {
      double value = cin.nextDouble();
      String type = cin.nextLine();
//      System.out.println(value);
//      System.out.println(type);
//      System.out.println(value*380000.0);
      if (type.contains("JPY") ) {
        sum += value;
      } else if (type.contains("BTC")){
        sum += value * 380000.0;
      }
    }
    System.out.println(sum);

  }

}


Measured memory_bytes: 24660
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a%b)

def lcm(a, b):
    return a * b // gcd(a, b)
 
from functools import reduce

n = int(input())
t = [int(input()) for _ in range(n)]
print(reduce(lcm, t))

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<numeric>
#include<cmath>
#include<queue>
#include<stack>
#include<list>
#include<unordered_map>
#include<unordered_set>
#include<cctype>

using namespace std;
typedef long long int ll;typedef pair<int, int> P;
const long long mod = 1e9 + 7;
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(a) (a).begin(),(a).end()



int main(void) {
	int n; cin >> n;
	vector<ll> v(n);
	rep(i, n)cin >> v[i];
	cout << *max_element(all(v)) - *min_element(all(v)) << endl;
	return 0;
}

Measured memory_bytes: 256
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

signed main(){
/*
  cin >> N;
  vector<int> a(N);
  for (int i = 0; i < N; i++)
    cin >> a[i];
*/
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  for (int i = 0; i < N; i++)
    cin >> A[i];

  for (int i = K; i < N; i++) {
    if (A[i - K] < A[i])
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 4040
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n, x;
	cin >> n >> x;
	int min = 1001001;
	rep(i, n){
		int m;
		cin >> m;
		x -= m;
		if(min > m) min = m;
	}
	int ans = n + x / min;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
import itertools
import math
import string
import collections
from collections import Counter
from collections import deque
from operator import itemgetter
import sys
sys.setrecursionlimit(2*10**5)
INF = 2**60


def readints():
    return list(map(int, input().split()))


def nCr(n, r):
    return math.factorial(n)//(math.factorial(n-r)*math.factorial(r))


def has_duplicates2(seq):
    seen = []
    for item in seq:
        if not(item in seen):
            seen.append(item)
    return len(seq) != len(seen)


def divisor(n):
    divisor = []
    for i in range(1, n+1):
        if n % i == 0:
            divisor.append(i)
    return divisor


# coordinates
dx = [-1, -1, -1, 0, 0, 1, 1, 1]
dy = [-1, 0, 1, -1, 1, -1, 0, 1]
n = int(input())
a = [None]*n
for i in range(n):
    a[i] = [None]*2
for i in range(n):
    a[i] = input().split()
# print(a)
for i in range(n):
    a[i][1] = int(a[i][1])
for i in range(n):
    a[i].append(i+1)
#print('a', a)
b = sorted(a, key=itemgetter(1), reverse=True)
#print('b', b)
c = sorted(b, key=itemgetter(0))
#print('c', c)
for i in range(n):
    print(c[i][2])


Measured memory_bytes: 38896
//#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>

using namespace std;

const int nmax = 1e9 + 7;
const long long INF = 1e18;
const double PI = 2 * asin(1);
typedef long long ll;

int main(){

  int H, W; cin >> H >> W;

  int A[H][W], B[H][W];
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> A[i][j];
    }
  }
  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      cin >> B[i][j];
    }
  }

  vector <int> ans[H][W];

  for (int i = 0; i < H; i++){
    for (int j = 0; j < W; j++){
      vector <bool> checked(10000);
      int now = abs(A[i][j] - B[i][j]);

      if (i == 0 && j == 0){
        checked[now] = true;
      }else if(i == 0){
        for (int k = 0; k < ans[i][j - 1].size(); k++){
          int num = ans[i][j - 1][k];
          if (abs(num - now) < 10000) checked[abs(num - now)] = true;
          if (abs(num + now) < 10000) checked[abs(num + now)] = true;
        }
      }else if (j == 0){
        for (int k = 0; k < ans[i - 1][j].size(); k++){
          int num = ans[i - 1][j][k];
          if (abs(num - now) < 10000) checked[abs(num - now)] = true;
          if (abs(num + now) < 10000) checked[abs(num + now)] = true;
        }
      }else{
        for (int k = 0; k < ans[i - 1][j].size(); k++){
          int num = ans[i - 1][j][k];
          if (abs(num - now) < 10000) checked[abs(num - now)] = true;
          if (abs(num + now) < 10000) checked[abs(num + now)] = true;
        }
        for (int k = 0; k < ans[i][j - 1].size(); k++){
          int num = ans[i][j - 1][k];
          if (abs(num - now) < 10000) checked[abs(num - now)] = true;
          if (abs(num + now) < 10000) checked[abs(num + now)] = true;
        }
      }

      for (int k = 0; k < 10000; k++){
        if (checked[k] == true){
          ans[i][j].push_back(k);
        }
      }
    }
  }
  

  
  cout << ans[H - 1][W - 1][0] << endl;
  
  return 0;
}


Measured memory_bytes: 97536
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <stdio.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second
#define mp make_pair
 
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M, K = 1e9;
vector <int> Graph[1005], Regraph[1005];
vector <int> ans;

int Solve(int U, int V){
  int Dist[N + 1] = {};
  fill(Dist, Dist + N + 1, -1);
  Dist[V] = 1;
  queue <int> que; que.push(V);
  while (!que.empty() && Dist[U] == -1){
    int Q = que.front(); que.pop();
    for (int i = 0; i < Graph[Q].size(); i++){
      int next = Graph[Q][i];
      if (Dist[next] != -1) continue;
      Dist[next] = Dist[Q] + 1;
      que.push(next);
    }
  }
  while(!que.empty()) que.pop();

  if (Dist[U] == -1) return 0;
  if (K < Dist[U]) return 0;

  K = Dist[U]; ans = {};
  que.push(U);
  while (!que.empty()){
    int Q = que.front(); que.pop();
    ans.push_back(Q);
    for (int i = 0; i < Regraph[Q].size(); i++){
      int before = Regraph[Q][i];
      if (Dist[before] + 1 != Dist[Q]) continue;
      que.push(before);
    }
  }

  return 0;
}


int main(){
  scanf("%d%d", &N, &M);
  for (int i = 0; i < M; i++){
    int A, B; scanf("%d%d", &A, &B);
    Graph[A].push_back(B);
    Regraph[B].push_back(A);
  }

  for (int i = 1; i <= N; i++){
    for (int j = 0; j < Graph[i].size(); j++){
      Solve(i, Graph[i][j]);
    }
  }

  if (K == 1e9) cout << -1 << endl;
  else{
    printf("%d\n", ans.size());
    for (int i = 0; i < ans.size(); i++) printf("%d\n", ans[i]);
  }

  return 0;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main (void) {
    int N;
    bool four = false;

    cin >> N;
    for (int i = 0; i < N; i++) {
        char s;
        cin >> s;
        if (s == 'Y') four = true;
    }

    if (four) cout << "Four" << endl;
    else cout << "Three" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
using namespace std;

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

int main()
{
    int A, B;
    cin >> A >> B;
    if (A == B)
    {
        cout << 2*max(A, B) << endl;
    }
    else
    {
        cout << 2*max(A, B) -1 << endl;
    }
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int gcd(int a,int b){
	while (a!=0&&b!=0){if (a>b){a%=b;}else{b%=a;}}
	return a|b;
}

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int i,n,a[100000],ans;
	cin>>n;
	for (i=0;i<n;i++){
		cin>>a[i];
	}
	ans=gcd(a[0],a[1]);
	for (i=2;i<n;i++){
		ans=gcd(ans,a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 640