akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int inf = INT_MAX;
const ll INF = LLONG_MAX;
const ll MOD = 1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b, const ll mod=MOD) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b, const ll mod=MOD) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b, const ll mod=MOD) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b, const ll mod=MOD) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
vi cnt;
vector<vi> G;
vi res;

void dfs(int v, int num){
    if(res[v] != -1) return;

    res[v] = num + cnt[v];
    for(auto& nv : G[v]){
        dfs(nv, res[v]);
    }
}

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

    int n, Q; cin >> n >> Q;
    G = vector<vi>(n);
    rep(_, n-1){
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }

    cnt = vi(n);
    rep(_, Q){
        int v, x; cin >> v >> x;
        v--;
        cnt[v] += x;
    }

    res = vi(n, -1);
    dfs(0, 0);

    rep(i, n){
        cout << (i ? " ":"") << res[i];
    }
    cout << endl;

    return 0;
}


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

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
typedef long long ll;

int main(){
  vector<char> s(4);
  rep(i,4) cin >> s.at(i);

  if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)&&s.at(2)==s.at(3)) cout << "No";
  else if(s.at(0)==s.at(1)&&s.at(2)==s.at(3)) cout << "Yes";
  else if(s.at(0)==s.at(2)&&s.at(1)==s.at(3)) cout << "Yes";
  else if(s.at(0)==s.at(3)&&s.at(1)==s.at(2)) cout << "Yes";
  else cout << "No";
  
}

Measured memory_bytes: 3556
#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 pair<int,int> PII;
typedef long long int ll;
typedef pair< ll,ll> PLL;
typedef unsigned long long int ULL;
typedef pair<ULL,int> PUI;
#define S second
#define F first
typedef tree<
PLL,
null_type,
less<PLL>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;


PLL operator+(PLL a,PLL b){ return {a.first + b.first, a.second + b.second}; }
PLL operator-(PLL a,PLL b){ return {a.first - b.first, a.second - b.second}; }
PLL operator*(PLL a,PLL b){ return {a.first * b.first, a.second * b.second}; }
PLL operator/(PLL a,PLL b){ return {a.first / b.first, a.second / b.second}; }
PLL operator%(PLL a,PLL b){ return {( b.first + a.first) % b.first, (b.second + a.second) % b.second}; }
PLL operator%(PLL a,ll b){ return {a.first % b, a.second % b} ;}
PLL operator+(PLL a,ll b){ return {a.first + b, a.second + b} ;}
PLL operator-(PLL a,ll b){ return {a.first - b, a.second - b} ;}
PLL operator*(PLL a,ll b){ return {a.first * b, a.second * b} ;}

ostream& operator<<(ostream &out,PLL a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}

ostream& operator<<(ostream &out,PUI a)
{
    out << "( " << a.first << ", " << a.second << " )" ;
    return out;
}
/*
	Order Statistics Tree ( OST )

	find_by_order()
		takes an integer k and returns an iterator to the k'th largest element counting from zero
	order_of_key()
		takes an element, here an integer and returns the number of elements strictly smaller than input
*/


int const MOD = 1e9 + 7;

int const N = 1e5 + 10;
bool mark[N] ;

void sieve()
{
    for(int i = 2; i < N; i++){
        if(!mark[i]){
            for(int j = 2 * i ; j < N; j += i) 
                mark[j] = 1;
        }
    }
}
vector < int > v[100];

ll dd(int i,int j)
{
    ll ret = 0;
    for(int x = 0; x < v[i].size(); x++){
        ret += (v[i][x] - v[j][x]) * (v[i][x] - v[j][x]);
    }
    return ret;
}

int main()
{
    ios::sync_with_stdio(0); cin.tie(0);
    
    int n,d;
    cin >> n >> d;

    for(int i = 0; i < n; i++){
        for(int x = 0; x < d; x++){
            int y;
            cin >> y;
            v[i].push_back(y);
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int dist = dd(i,j);
            int root = (sqrt(dist*1.0) + 1e-9);
            if(root * root == dist){
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;

}

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

typedef long long int ll;
typedef pair<ll, ll> p_ll;
typedef vector<pair<ll, ll>> vec_p; //vector<pair<ll, ll>> pairs(n) ,pairs.at(i) = make_pair(i*i, i)

#define REP(i, x) for (ll i = 0; i < (ll)(x); i++)
#define REPS(i, x) for (ll i = 1; i <= (ll)(x); i++)
#define RREP(i, x) for (ll i = ((ll)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (ll i = ((ll)(x)); i > 0; i--)
#define all(x) (x).begin(), (x).end()

const ll MOD = pow(10, 9) + 7;
const ll LLINF = pow(2, 61) - 1;
const int INF = pow(2, 30) - 1;

ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

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

    ll H,W;
    cin >> H >>W;
    char s[H][W];

    REP(i,H){
        REP(j,W){
            cin >> s[i][j];
        }
    }

    ll su, sd, sl, sr;
    bool flag = true;

    REP(i, H)
    {
        REP(j, W)
        {
            if(s[i][j]=='.'){
                continue;
            }
            else{
                ll area = 0;
                ll dot_area = 0;
                su = i - 1;
                sd = i + 1;
                sl = j - 1;
                sr = j + 1;

                if (su >= 0 && su < H)
                {
                    area++;
                    if(s[su][j]=='.'){
                        dot_area++;
                    }
                }
                if (sd >= 0 && sd < H)
                {
                    area++;
                    if (s[sd][j] == '.')
                    {
                        dot_area++;
                    }
                }
                if (sl >= 0 && sl < W)
                {
                    area++;
                    if (s[i][sl] == '.')
                    {
                        dot_area++;
                    }
                }
                if (sr >= 0 && sr < W)
                {
                    area++;
                    if (s[i][sr] == '.')
                    {
                        dot_area++;
                    }
                }
                if(area==dot_area){
                    flag = false;
                }
            }
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int n, a[200000];
    cin >> n;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    long long res = 0;
    int acc = 0;
    for (int s = 0, e = 0; e < n;) {
        while ((acc & a[e]) == 0) {
            acc += a[e];
            ++e;
            res += (e - s);
            if (e == n) break;
        }
        while ((acc & a[e]) != 0) {
            acc -= a[s];
            ++s;
            if (s == e) break;
        }
    }
    cout << res << endl;
    return 0;
}

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

typedef vector <int> VI;

int main( void )
{
    int n, m;
    while ( cin >> n >> m && n && m )
    {
        int mins = -1, ct, ch;
        VI T(n), H(m);
        for ( int i = 0; i < n; i++ ) cin >> T[i];
        for ( int i = 0; i < m; i++ ) cin >> H[i];

        int ts = accumulate( T.begin(), T.end(), 0 ), hs = accumulate( H.begin(), H.end(), 0 );
        for ( int i = 0; i < n; i++ ) for ( int j = 0; j < m; j++ )
        {
            if ( ts - T[i] + H[j] == hs - H[j] + T[i] )
            {
                if ( mins == -1 || mins > T[i] + H[j] )
                {
                    mins = T[i] + H[j];
                    ct = T[i];
                    ch = H[j];
                }
            }
        }

        if ( mins == -1 )
        {
            cout << -1 << endl;
        }
        else
        {
            cout << ct << " " << ch << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 0
def solve():
  ans = 0
  N = int(input())
  A = [int(input()) for _ in range(N)]
  rem = 0
  for i in range(N):
    ans += (A[i]+rem)//2
    if A[i]>0:
      rem = (A[i]+rem)%2
    else:
      rem = 0
  return ans
print(solve())

Measured memory_bytes: 13044
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**8)


class Node:
    def __init__(self, index):
        self.index = index
        self.ref = []
        self.visited = False

    def append(self, node):
        self.ref.append(node)
        node.ref.append(self)

    def visit(self):
        self.visited = True
        for r in self.ref:
            if not r.visited:
                r.visit()


def solve(N: int, M: int, X: "List[int]", Y: "List[int]", Z: "List[int]"):
    nodes = [Node(i) for i in range(N)]
    X = [x-1 for x in X]
    Y = [y-1 for y in Y]
    for i in range(M):
        nodes[X[i]].append(nodes[Y[i]])
    sum = 0
    for i in range(N):
        if not nodes[i].visited:
            sum += 1
            nodes[i].visit()
    print(sum)
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    M = int(next(tokens))  # type: int
    X = [int()] * (M)  # type: "List[int]"
    Y = [int()] * (M)  # type: "List[int]"
    Z = [int()] * (M)  # type: "List[int]"
    for i in range(M):
        X[i] = int(next(tokens))
        Y[i] = int(next(tokens))
        Z[i] = int(next(tokens))
    solve(N, M, X, Y, Z)


if __name__ == '__main__':
    main()


Measured memory_bytes: 133904
#include <iostream>

#include <iostream>
using namespace std;

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

Measured memory_bytes: 256
n, k = map(int, input().split())
a_list = [int(input()) for _ in range(n)]

dp = [1] * n

for i in range(n):
    for j in range(max(0, i - 100), i):
        if abs(a_list[i] - a_list[j]) <= k:
            dp[i] = max(dp[i], dp[j] + 1)

ans = max(dp)
print(ans)

Measured memory_bytes: 94840
#include <bits/stdc++.h>
using namespace std;
int main(){
  long int S;
  cin >> S;
  vector<int> s(12,0);
  for(int i = 0;i < 10;i++){
    s.at(i) = S % 10;
    S /= 10;
    if(S == 0) break;
  }
  reverse(s.begin(), s.end());
  int answer = 1000;
  for(int i = 0;i < 10;i++){
    int num = 100*s.at(i) + 10*s.at(i+1) + s.at(i+2);
    if(answer > abs(753 - num)) answer = abs(753 - num);
  }
  cout << answer << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
namespace Collections
{
	class program
	{
    //static long MAX_LONG = 5000000000000000;
		static void Main(string[] args)
		{

			// 入力
			long N = long.Parse(Console.ReadLine());
      //int[] input = Console.ReadLine().Split().Select(p => int.Parse(p)).ToArray();

			long ret = N*(N-1)/2;

			Console.WriteLine(ret + "");
    }
	}
}


Measured memory_bytes: 11092
#include<stdio.h>

int main(void){
	char s[16];
	int i;
	scanf("%s",s);
	for(i=0;i<=3;i++) printf("%c",s[i]);
	printf(" ");
	for(i=4;i<=11;i++) printf("%c",s[i]);
	printf("\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, ll> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 100010;
const int MAXM = 100010;
const int MAXK = 510;
const int MAXQ = 200010;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
  int a, b, c;
  cin >> a >> b >> c;
  if (c >= a && c <= b) cout << "Yes";
  else cout << "No";
    return 0;
}

Measured memory_bytes: 256
from bisect import bisect_right
n = int(input())
d = {}
amax = 0
for a in map(int, input().split()):
  if a in d:
    d[a] += 1
  else:
    d[a] = 1
amax = max(d.keys())
t = 1
valids = []
while t < 2 * amax:
  t *= 2
  valids.append(t)
result = 0
while True:
  prev = result
  keys = list(d.keys())
  keys.sort(reverse = True)
  for x in keys:
    if x not in d:
      continue
    t = valids[bisect_right(valids, x)] - x
    while True:
      if t not in d:
        break
      if x == t and d[x] == 1:
        break
      result += 1
      if d[x] == 1:
        del d[x]
      else:
        d[x] -= 1
      if d[t] == 1:
        del d[t]
      else:
        d[t] -= 1
      if x not in d:
        break
  if prev == result:
    break
print(result)

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

const int N = 200 * 1000 + 20;
int n, k, c, dp[N], dp2[N], cnt[N], idx[N];
string s;

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k >> c >> s;
	dp[n - 1] = s[n - 1] == 'o';
	for (int i = n - 2; ~i; i--) {
		if (s[i] == 'o')
			dp[i] = 1 + (i + c + 1< n? dp[i + c + 1]: 0);
		dp[i] = max(dp[i], dp[i + 1]);
	}
	dp2[0] = s[0] == 'o';
	for (int i = 1; i < n; i++) {
		if (s[i] == 'o')
			dp2[i] = 1 + (i - c - 1 >= 0? dp2[i - c - 1]: 0);
		dp2[i] = max(dp2[i], dp2[i - 1]);
	}
	if (dp[0] > k)
		return cout << endl, 0; 
	for (int i = 0; i < n; i++) {
		if (s[i] == 'o' && dp[i] + dp2[i] == k + 1) {
			cnt[dp[i]]++;
			idx[dp[i]] = i;
		}
	}
	for (int i = k; i; i--)
		if (cnt[i] == 1)
			cout << idx[i] + 1 << "\n";
	return 0;
}


Measured memory_bytes: 5012
#include <iostream>
#include <iomanip>
#include <cstring>
#include <algorithm> 
#include <math.h>
#include <queue>
#include <functional>
#include <map>
#include <vector>
#include <string>
using namespace std;

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

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

const ll MOD = 1000000007;
const ll INF = 10000000;




int main(void){
    string s;
    cin >> s;
    int sz = s.size();

    ll a[100005], c[100005], q[100005],pow[100005];
    pow[0] = 1;

    for (int i = 0; i < sz; i++){
        if (s[i] == 'A') a[i]++;
        else if (s[i] == 'C') c[i]++;
        else if (s[i] == '?') q[i]++;

        if (i == 0) continue;

        a[i] += a[i - 1];
        c[i] += c[i - 1];
        q[i] += q[i - 1];

        pow[i] = (pow[i - 1] * 3) % MOD;

    }

    ll ans = 0;
    for (int i = 1; i < sz; i++){
        ll qcount = q[sz-1];
        if (s[i] == '?') qcount--;

        if (s[i] == 'B' || s[i] == '?'){
            (ans += a[i - 1] * (c[sz - 1] - c[i])*pow[qcount]) %= MOD;

            if (qcount >= 1){
                (ans += a[i - 1] * (q[sz - 1] - q[i])*pow[qcount - 1]) %= MOD;
                (ans += q[i - 1] * (c[sz - 1] - c[i])*pow[qcount - 1]) %= MOD;
            }

            if (qcount >= 2) (ans += q[i - 1] * (q[sz - 1] - q[i])*pow[qcount - 2]) %= MOD;

        }
        
    }

    cout << ans << endl;
    

}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = (0); i < (n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define DEBUG(val) cout << #val << " : " << val << endl
#define MOD 1000000007

// goalを指定してそこまでの最小移動数を求める版
int map_search_for_goal(int now_h, int now_w, int max_h, int max_w, int goal_h,
                        int goal_w, vector<string> &data) {
  // initial value
  int fx[] = {0, 1};
  int fy[] = {1, 0};
  int forward_count = 2;
  char forwardable = '.';
  int dist[max_h][max_w];
  REP(i, max_h) {
    REP(j, max_w) { dist[i][j] = INT_MAX; }
  }
  queue<tuple<int, int, int>> q;

  int now_z = (data[0][0] == '#') ? 1 : 0;
  // start
  q.push(make_tuple(now_h, now_w, now_z));
  int move_dist = INT_MAX;
  while (!q.empty()) {
    tuple<int, int, int> p = q.front();
    q.pop();
    REP(i, forward_count) {
      int next_h = get<0>(p) + fx[i];
      int next_w = get<1>(p) + fy[i];
      if (next_h >= 0 && next_h < max_h && next_w >= 0 && next_w < max_w) {
        int now_z =
            (data[get<0>(p)][get<1>(p)] == '.' && data[next_h][next_w] == '#')
                ? 1
                : 0;
        int next_z = get<2>(p) + now_z;

        if (next_h == goal_h && next_w == goal_w) {
          move_dist = min(move_dist, next_z);
        } else {
          if (next_z < dist[next_h][next_w]) {
            dist[next_h][next_w] = next_z;
            q.push(make_tuple(next_h, next_w, next_z));
          }
        }
      }
    }
  }
  return move_dist;
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> data(h);
  REP(i, h) {
    string s;
    cin >> s;
    data[i] = s;
  }
  int ans = map_search_for_goal(0, 0, h, w, h - 1, w - 1, data);
  cout << ans << endl;
}

Measured memory_bytes: 384
/*
 *   
 *   Date: 07 September 2019
 *   Time: 01:03:00
*/
import java.io.*; 
import java.util.*;


   
 class Main
{   

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n=sc.nextInt();
        long arr[]=new long[n];
        for(int i=0;i<n;i++){
        	arr[i]=sc.nextLong();
        }
        long max=arr[0];
        long diff=0;
        for(int i=1;i<n;i++){
        	if(arr[i]>=max){
        		        		max=arr[i];

        		continue;
        	}else{
        		diff+=max-arr[i];
        		arr[i]=max;;
        	}
        }
       
        System.out.println(diff);
     
        
       

       
    } 
} 
 
 
 


Measured memory_bytes: 62408
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

const int maxn = 1 << 20;
int a[maxn];

int main() {
    #ifdef LOCAL
    assert(freopen("c.in", "r", stdin));
    #else
    #endif
    int n;
    cin >> n;
    int base = 1 << n;
    forn (i, 1 << n) {
        cin >> a[i + base];
    }
    for (int i = base - 1; i > 0; --i) {
        int u = a[i * 2];
        int v = a[i * 2 + 1];
        if (u == v)
            a[i] = u;
        else
            a[i] = abs(u - v);
    }
    cout << a[1] << '\n';
}


Measured memory_bytes: 2432
#include<iostream>
#include<math.h>
#include<iomanip>
using namespace std;

int main(){

int n;

while(1){

double inputsum=0;
double average=0;
double sum=0;

cin>>n;
if(n==0)break;
double s[n];
double hensa[n];
double haverage=0;

for(int i=0;i<n;i++){
    hensa[i]=0.0;
    s[i]=0.0;
}
for(int i=0;i<n;i++){
cin>>s[i];
inputsum=inputsum+s[i];

}

average=inputsum/n;

for(int i=0;i<n;i++){
hensa[i]=s[i]-average;
}

for(int i=0;i<n;i++){
haverage=haverage+pow(hensa[i],2);
}

haverage=haverage/n;

sum=sqrt(haverage);

cout<<fixed<<sum<<" "<<endl;

}

}


Measured memory_bytes: 3292
from subprocess import*
call(('pypy3','-c',"""

n=int(input())
a=[int(i) for i in input().split()]
a.sort()

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

l=make_divisors(a[0])
l2=make_divisors(a[1])
le=len(l)
le2=len(l2)         
an=[0]*le
an2=[0]*le2
for i in range(n):
    for j in range(le):
        if a[i]%l[j]==0:
            an[j]+=1
    for j in range(le2):
        if a[i]%l2[j]==0:
            an2[j]+=1
ans=1
ans2=1
for i in range(le):
    if an[i]>=n-1:
        ans=max(ans,l[i])
for i in range(le2):
    if an2[i]>=n-1:
        ans2=max(ans2,l2[i])

print(max(ans,ans2))


"""))

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

int main() {
  int64_t S;
  cin >> S;
  cout << 0 << endl;
  cout << 0 << endl;
  if(S == 1000000000000000000) {
    cout << 0 << endl;
    cout << 1000000000 << endl;
    cout << 1000000000 << endl;
    cout << 0 << endl;
  }
  else {
    cout << 1 << endl;
    int64_t N = 1 + (int64_t) sqrt(S);
    int64_t M = 1000000000;
    if(N * N - S <= M) {
      cout << N << endl;
      cout << N << endl;
      cout << N * N - S << endl;
    }
    else {
      cout << N << endl;
      cout << N - 1 << endl;
      cout << N * (N - 1) - S << endl;
    }
  } 
}

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

struct edge{
    int to,cost;
};

vector<edge> G[100010];
int res[100010];

void dfs(int v, int p,int c) {
    res[v] = c;
    for(auto e : G[v]) {
        if(e.to == p) continue;
        if(e.cost & 1) dfs(e.to, v, 1-c);
        else dfs(e.to, v, c);
    }
}


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

int N;
cin >> N;
rep(i,N-1){
    int u,v,w;
    cin >> u >> v >> w;
    u--;v--;
    G[u].push_back({v,w});
    G[v].push_back({u,w});
}

rep(i,N) res[i] = 0;
dfs(0, -1, 1);
rep(i,N) cout << res[i] << endl;

return 0;
}

Measured memory_bytes: 9216
import java.util.Scanner;

public class Main {

	static int MAX = 100001;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, a[], count[] = new int[MAX];
		n = sc.nextInt();
		a = new int[n];
		int max2 = 0;
		for (int i = 0; i < n; ++i) {
			a[i] = sc.nextInt();
			count[a[i]]++;
			max2 = Math.max(max2,  a[i]);
		}
		sc.close();

		int max = 0, x = 0;
		for (int i = 0; i <= max2; ++i) {
			x = count[i];
			if (i + 1 <= max2)
				x += count[i + 1];
			if (i - 1 >= 0)
				x += count[i - 1];
			max = Math.max(max, x);
		}

		System.out.println(max);
	}

}


Measured memory_bytes: 62436
#include <iostream>
#include <ios>
#include <iomanip>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <utility>
using namespace std;

#define MOD 1000000007
#define INF 1e9+7
#define rep(i, n) for(int i=0; i<n; ++i)
#define rrep(i, m, n) for(int i=m; i<n; ++i)
typedef long long ll;

#define MAX_N 100000
#define MAX_M 100000
#define MAX_V 100
#define MAX_E 100
#define MAX_Q 100000

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

int ddx[] = {-1, 0, 1, 0, -1, 1, -1, 1};
int ddy[] = {0, -1, 0, 1, 1, 1, -1, -1};

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

int n;
string s, color = "null";
int cnt;

int main() {

  cin >> n >> s;


  rep(i, n) {
    if(color=="null") {
      color = s[i];
      ++cnt;
    }else if(color[0]!=s[i]) {
      color = "null";
      --i;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>


using namespace std;
const double pi=acos(-1.0);

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;

int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}

/**.................................................................................................................................*/
int main(){
	boost;
	int n,a,b;
	cin>>n>>a>>b;
	
	cout<<min(a*n,b)<<endl;
 	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     siii(a,b,c)       scanf("%d%d%d",&a,&b,&c)
#define     si(a)             scanf("%d",&a)
#define     sii(a,b)          scanf("%d%d",&a,&b)
#define     sl(a)             scanf("%lld",&a);
#define     sll(a,b)          scanf("%lld%lld",&a,&b);
#define     slll(a,b,c)       scanf("%lld%lld%lld",&a,&b,&c);
#define     sd(a)             scanf("%lf",&a);
#define     sdd(a,b)          scanf("%lf%lf",&a,&b);
#define     pb(a)             push_back(a)
#define     deb(a)            printf("### %d ###\n",a)
#define     mp                make_pair
#define     pf                printf
#define     fl(a, b, c)       for(int a= b ;a<c;a++)
#define     mx                100000 //10^5
#define     fread             freopen("input.txt","r",stdin)
#define     CLR(a,b)          memset(a,b,sizeof(a))
#define     ll                long long
#define     D(x)              cout<<#x" = "<<x<<endl;
#define     sz                10000
#define     bl                printf("\n")
#define     spc               printf(" ")


int main()
{
    int n;
    si(n);
    vector<int>h(n);
    fl(i,0,n) si(h[i]);
    int ans  = 0;
    //for(int i = 0 ; i< n ; i++) D(i);
    fl(i,0,n)
    {
        bool ck = true;
        fl(j,0,i)
        {
            if(h[j]>h[i])
            {
                ck = false;
                break;
            }
        }
        if(ck)
        {
            ++ans;
        }
    }
    cout<<ans<<endl;



    return 0;
}


Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		String s = sc.next();
		
		// 計算
		String result = "";
		if(s.equals("Sunny")) result = "Cloudy";
		if(s.equals("Cloudy")) result = "Rainy";
		if(s.equals("Rainy")) result = "Sunny";

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


Measured memory_bytes: 22100
import java.util.Scanner;

public class Main {

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

		int N = in.nextInt();

		double sum = 0;
		for (int i = 0; i < N; i++) {
			double x = in.nextDouble();
			String u = in.next();
			if (u.equals("JPY")) {
				sum += x;
			} else {
				sum += (x * 380000.0);
			}
		}
		System.out.println(sum);
	}
}


Measured memory_bytes: 26580
#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstring>
#define rep(i, N) for (int i = 0; i < (int)N; i++)
using namespace std;
typedef long long ll;
const ll LLINF = 9223372036854775807;
const int MOD = 1000000007;

int main() {
  int N, i; cin >> N >> i;
  int result = N-i+1;
  cout << result << endl;
  return 0;
}

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

using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
typedef long long ll;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;

const int MOD = 1000000007;
const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;

int main()
{
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N)
    {
        cin >> A[i];
    }
    sort(A.rbegin(), A.rend());
    vector<ll> B(2 * N + 5);
    B[0] = A[0];
    for (int i = 1; i <= 2 * N; i++) {
        B[i] = A[(i + 1) / 2];
    }
    ll ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += B[i];
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 8000
function main(s) {
	s = s.split("\n")[0].split(" ");
	console.log(((s[0][s[0].length-1] === s[1][0]) && (s[1][s[1].length-1] === s[2][0])) ? "YES" : "NO");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 8520
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < (n);i++)
ll INF = 1000000010; 
const ll MOD = 1000000007;


int main(){
    int n, m; cin >> n >> m;
    vector<pair<int,int>> key;

    rep(i,m){
        int a, b; cin >> a >> b;
        int s = 0;
        rep(j,b){
            int c; cin >> c;
            c--;
            s |= (1<<c);
        }
        key.emplace_back(s,a);
    }

    vector<ll> dp(1<<n,INF);
    dp[0] = 0;

    rep(i, (1<<n)){
        rep(j, m){
            int t = i | key[j].first;
            ll cost = dp[i] + key[j].second;
            dp[t] = min(dp[t],cost);
        }
    }
    ll ans = dp.back();
    if(ans == INF) ans = -1;
    cout << ans << endl;
}

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

Measured memory_bytes: 3608
# -*- coding: utf-8 -*-


def main():
    from heapq import heappush, heappop

    n, m = map(int, input().split())
    a = list(map(int, input().split()))
    b = list()

    for ai in a:
        heappush(b, -ai)

    for i in range(m):
        bi = -heappop(b)
        bi //= 2
        heappush(b, -bi)

    print(-sum(b))


if __name__ == '__main__':
    main()


Measured memory_bytes: 14380
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.next();
        
        S = S.replaceAll("eraser", "-");
        S = S.replaceAll("erase", "-");
        S = S.replaceAll("dreamer", "-");
        S = S.replaceAll("dream", "-");
        S = S.replaceAll("-", "");
        if(S.length() == 0) {
        	System.out.println("YES");
        }
        else {
        	System.out.println("NO");
        }
    }
}

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

int main(){
  int n,k;cin>>n>>k;
  vector<int> arr(n);
  for(int i=0;i<n;++i)cin>>arr[i];
  
  // dp for first win
  vector<bool> dp(k+1,false);
  
  for(int i=1;i<=k;++i){
    for(auto j:arr){
      if(i-j>=0 && dp[i-j]==false){
        dp[i] = true;
        break;
      }
    }
  }
  
  cout<<endl;
  if(dp[k]){
    cout<<"First"<<endl;
  }else{
    cout<<"Second"<<endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
using ll=long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
inline constexpr ll gcd(ll a,ll b){if(!a||!b)return 0;while(b){ll c=b;b=a%b;a=c;}return a;}
inline constexpr ll lcm(ll a,ll b){if(!a||!b)return 0;return a*b/gcd(a,b);}

int main() {
  int a,b;
  cin>>a>>b;
  cout<<a*a-b<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << endl
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
int dx8[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy8[8] = {0, 1, 0, -1, 1, 1, -1, -1};
int dx4[4] = {1, 0, -1, 0};
int dy4[4] = {0, 1, 0, -1};
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;}
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

struct edge {
    int to;
    int id;
};


void dfs(vector<vector<edge>> &G,int v,int p, int parentC,vi &ans,int maxColor){
    int k = 1;
    for (int i = 0; i < G[v].size(); i++)
    {
        edge nv = G[v][i];
        if(p == nv.to) continue;//逆流禁止
        //modMaxColorで管理
        //k++としていくことで兄弟間の色も別々にmodMaxColorないで表現できる、しかも親の色に何かを足しているので親の色と同じにはならない
        int nextC = (parentC+k++) % maxColor;//modでその数以外を表現できるのがかしこい、例えば3以外が欲しかったらk+1mod3とか,今だと親の色以外
        ans[nv.id] = nextC;//ここで辺の色とidを順番を結び付けている
        dfs(G,nv.to,v,nextC,ans,maxColor);
    }
    
    
}

int main(void) {
    int N;
    cin >> N;
    vector<vector<edge>> G(N);
    vi ans(N-1,-1);
    
    rep(i,N-1){
        int x,y;
        cin >> x >> y;
        x--,y--;
        G[x].push_back(edge{y,i});
        G[y].push_back(edge{x,i});
    }
    
    //一番辺が多い奴の辺の数が色の数なので
    int maxColor=-1;
    rep(i,N){
        maxColor=max<int>(maxColor,G[i].size());//普通のmaxじゃintとvector<edge>を比較できないみたいなので
    }
    dfs(G,0,-1,-1,ans,maxColor);

    cout << maxColor << endl;
    rep(i,N-1){
        cout << ans[i]+1<<endl;//0-indexのため
    }
}

Measured memory_bytes: 8320
n,m,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
x.append(X)
y.append(Y)
x.sort(reverse = True)
y.sort()
if x[0]<y[0]:
    print('No War')
else:
    print('War')

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int d = sc.nextInt();
		
		System.out.println((int)Math.max(a * b,  c * d));

	}

}


Measured memory_bytes: 23764
<?php

$all_sec = trim(fgets(STDIN));

$hour = floor($all_sec / (60 * 60));
$all_sec %=  (60 * 60);

$minite = floor($all_sec / 60);
$all_sec %=  60;

$second = $all_sec;

echo $hour . ":" . $minite . ":" . $second . PHP_EOL;




?>


Measured memory_bytes: 9180
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = unsigned long long;
using vi = vector<int>;

unordered_map<ll, bool> M;
bool l[5][5];
ll s[10];
int h, w, n;

inline bool getv(ll x, ll y)
{
    ll v = (x << 32) | y;
    return M.find(v) != M.end();
}

inline void setv(ll x, ll y)
{
    ll v = ((ll)x << 32) | y;
    M[v] = true;
}

inline bool good(int x, int y)
{
    return x >= 0 && y >= 0 && x < h && y < w;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> h >> w >> n;
    s[0] = (ll) (h - 2) * (w - 2);
    for (int k = 0; k < n; ++k)
    {
        int a, b;
        cin >> a >> b;
        a--; b--;
        setv(a, b);
        memset(l, 0, sizeof l);
        for (int i = a - 2; i <= a + 2; ++i)
            for (int j = b - 2; j <= b + 2; ++j)
                if (good(i, j))
                    l[i - (a - 2)][j - (b - 2)] = getv(i, j);

        for (int i = 0; i < 3; ++i)
        {
            for (int j = 0; j < 3; ++j)
            {
                if (!good(a - 2 + i, b - 2 + j) ||
                    !good(a + i, b + j))
                    continue;

                int cnt = 0;
                for (int p = i; p < i + 3; ++p)
                    for (int q = j; q < j + 3; ++q)
                        cnt += (bool)l[p][q];

                s[cnt - 1]--;
                s[cnt]++;
            }
        }
    }
    for (int k = 0; k < 10; ++k)
        cout << s[k] << '\n';
}


Measured memory_bytes: 4388
S=list(input())
K=int(input())

S_=[]
for s in range(len(S)):
    s_temp=S[s]
    S_.append(s_temp)
    for e in range(s+1,len(S)):
        if e-s>K+10:
          break
        s_temp+=S[e]
        S_.append(s_temp)
        
S_=list(set(S_))
S_.sort()
# print(S_)
print(S_[K-1])

Measured memory_bytes: 83472
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


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

  int n,w;
  cin>>n>>w;
  vi dp(w+1,0);
  int ans=0;
  while(n--){
    int a,b;
    cin>>a>>b;
    rrep(i,w-b){
      dp[i+b]=max(dp[i+b],dp[i]+a);
      ans=max(ans,dp[i+b]);
    }
  }

  cout<<ans<<endl;

}


Measured memory_bytes: 3264
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<string,int>;
using T = tuple<string,int,int>;

int main(){
  int n; cin >> n;
  map<string, int> mp;
  for(int i = 0; i < n; i++){
    string s; cin >> s;
    mp[s]++;
  }
  int ans = mp.size();
  cout << ans << endl;
  return 0;
}


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

#define int long long
using namespace std;
#define rep(i, n) for(int i=0;i<(n);++i)
typedef pair<int, int> pii;
const int INF = 1l << 60;
#define u_b upper_bound
#define l_b lower_bound


signed main() {
    int a;
    string s;
    cin >> a >> s;
    if (a >= 3200)cout << s << endl;
    else cout << "red" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int cal(int x){
	int j=1;
	while (x-j>=0){
		x-=j;
		j++;
	}
	return j-1;
}
int main(){
	long long n;
	cin >> n;
	int m=int(sqrt(n));
	int a[m+1];
	for (int i=1; i<=m; i++) a[i]=0;
	while (n%2==0){
		n/=2;
		a[2]++;
	}
	int t=3, ans=0;
	while (n!=1&&t<=m){
		while (n%t==0){
			n/=t;
			a[t]++;
		}
		t+=2;
	}
	for (int i=1; i<=m; i++)
		if (a[i]!=0) ans+=cal(a[i]);
	if (n==1) cout << ans << endl;
	else cout << ans+1 << endl;
	return 0;
}

Measured memory_bytes: 7552
h, w, k = [int(i) for i in input().split()]
a = [input() for j in range(h)]

ans = 0
for mi in range(1 << h):
    for mj in range(1 << w):
        bi = [i for i in range(h) if ((mi >> i) & 1) == 0]
        bj = [j for j in range(w) if ((mj >> j) & 1) == 0]
        cnt = 0
        for i in range(h):
            if i in bi:
                continue
            for j in range(w):
                if j in bj:
                    continue
                if a[i][j] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)


Measured memory_bytes: 9036
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <ctime>
#define INF 999999999
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=(n);i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
/*---------------------------------------------------*/

int m,n;

void solve(){
  int p=0;
  vector<bool> x(7368792,0);
  for(int i=m;i<=7368792;i++){
    if(!x[i]){
      p++;
      if(p==n+1){cout<<i<<endl;return;}
      for(int j=i+i;j<=7368792;j+=i)x[j]=true;
    }
  }
}

int main(){
  while(scanf("%d%d",&m,&n)){
    if(m==0&&n==0)break;
    if(m>=n){cout<<n+m<<endl;continue;}
    solve();
  }
  return 0;
}

Measured memory_bytes: 4032
n, m = gets.chomp.split(' ').map(&:to_i)
a = gets.chomp.split(' ').map(&:to_i)
count = 0
b = a.sum.to_f / (4 * m)

a.each{|i|
  if(i >= b)
    count += 1
  end
}

if(count < m)
  puts "No"
else
  puts "Yes"
end

Measured memory_bytes: 14284
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define REP(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N){
    if(N == 1){
        cout << 1 << endl;
        return;
    }
    ll sum = 0, i, m=0;
    for( i=1; ; i++){
        sum += i;
        if(sum >= N){
            m = i;
            break;
        }
    }
    for(ll j = 1; j<= m; j++){
        if(j != (m*(m+1)/2 - N))
            cout << j << endl;
    }
    return;
}

int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


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

#define int long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL << 60)

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

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

// 素因数分解
vector<pair<int, int> > prime_factorize(int n) {
    vector<pair<int, int> > res;
    for (int p = 2; p * p <= n; ++p) {
        if (n % p != 0) continue;
        int num = 0;
        while (n % p == 0) {
            ++num;
            n /= p;
        }
        res.push_back(make_pair(p, num));
    }
    if (n != 1) res.push_back(make_pair(n, 1));
    return res;
}

signed main() {
    int A, B;
    cin >> A >> B;
    int g = gcd(A, B);

    vector<P> r = prime_factorize(g);

    cout << r.size() + 1 << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define inf 1000000000
int h, w, a[15][15], x, ans, f[15][15];
int main () {
	cin>>h>>w;
	for (int i=0; i<10; i++) for (int j=0; j<10; j++) cin>>f[i][j];
	for (int k=0; k<10; k++) {
		for (int i=0; i<10; i++) {
			for (int j=0; j<10; j++) {
				f[i][j]=min(f[i][j], f[i][k]+f[k][j]);
			}
		}
	}
	for (int i=1; i<=h; i++) for (int j=1; j<=w; j++) {
		cin>>x;
		if (x!=-1)ans+=f[x][1];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
import sys
import math
N, K = map(int, sys.stdin.readline().rstrip().split())
A = list(map(int, sys.stdin.readline().rstrip().split()))
F = list(map(int, sys.stdin.readline().rstrip().split()))
A.sort()
A = A[::-1]
F.sort()

def test(x):
    res = 0
    for i in range(N):
        t = A[i] * F[i]
        if t > x:
            res += math.ceil((t - x) / F[i])
    
    return res <= K

ng = -1
ok = 10**18

while ng + 1 < ok:
    mid = (ng + ok) // 2
    if test(mid):
        ok = mid
    else:
        ng = mid
print(ok)

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

int main()
{
    string s;
    cin >> s;
    int n = s.size();
    string s1;
    string s2;
    int ans = 0;
    for(int i = 1; n - 2 * i >= 0; i++){
        s1 = s.substr(0, n / 2 - i);
        s2 = s.substr(n / 2 - i, n / 2 - i);
        if(s1 == s2){
            ans = n - 2 * i;
            break;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
n, m = gets.to_s.split.map{|t|t.to_i}
h    = [0] + gets.to_s.split.map{|t|t.to_i}

ans = [true] * (n+1)
ans[0] = false

m.times do
  
  a, b = gets.to_s.split.map{|t|t.to_i}
  
  if h[a] < h[b]
    ans[a] = false
  elsif h[a] > h[b]
    ans[b] = false
  else
    ans[a] = ans[b] = false
  end
end

puts ans.count(true)

Measured memory_bytes: 23184
#include<stdio.h>

int main (void)
{
	int t;
	int h,m,s;
	scanf( "%d",&t);
	
	h = t/3600;
	t = t%3600;
	m = t/60;
	s = t%60;
	
	printf( "%d:%d:%d\n",h,m,s );
	
	return 0;
}


Measured memory_bytes: 2104