akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < (int)n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 1e9 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const ll MOD = 1e9 + 7;
const int M = 5e3 + 3;
const int N = 1e3 + 3;

int p[N], x[N];
vector <int> g[N];
int d[N][2];
int r[2][N][M];

void dfs(int v) {
    //cout << v << endl;
    for (auto t: g[v])
        dfs(t);
    if (g[v].size() == 0) {
        fr(i, 2)
            d[v][i] = INF;
        d[v][0] = 0;
        d[v][1] = 0;
        return;
    }

    fr(col, 2)
        fr(i, g[v].size() + 1)
            fill(r[col][i], r[col][i] + M, INF);
    r[0][0][0] = r[1][0][0] = 0;
    fr(col, 2)
        fr(i, g[v].size()) {
            int u = g[v][i];
            fr(j, M)
                if (r[col][i][j] != INF) {
                    if (j + x[u] < M)
                        r[col][i + 1][j + x[u]] = min(r[col][i + 1][j + x[u]],
                            r[col][i][j] + d[u][col]);
                    if (j + d[u][!col] < M)
                        r[col][i + 1][j + d[u][!col]] = min(r[col][i + 1][j + d[u][!col]],
                            r[col][i][j] + x[u]);
                }
        }

    d[v][0] = INF;
    d[v][1] = INF;
    fr(i, x[v] + 1) {
        d[v][0] = min(d[v][0], r[0][(int)g[v].size()][i]);
        d[v][1] = min(d[v][1], r[1][(int)g[v].size()][i]);
    }
    return;
}

int main() {
    //freopen("a.in", "r", stdin);
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    fr(i, n - 1) {
        cin >> p[i + 1];
        g[p[i + 1] - 1].pb(i + 1);
    }
    fr(i, n)
        cin >> x[i];
    dfs(0);
    if (d[0][0] != INF || d[0][1] != INF)
        cout << "POSSIBLE";
    else
        cout << "IMPOSSIBLE";
}


Measured memory_bytes: 39424
// Tazoe

#include <iostream>
using namespace std;

int main()
{
while(true){
	double t500, t1000;
	cin >> t500;
if(cin.eof())  break;
	cin >> t1000;

	if(t500<35.5&&t1000<71.0){
		cout << "AAA" << '\n';
	}
	else if(t500<37.5&&t1000<77.0){
		cout << "AA" << '\n';
	}
	else if(t500<40.0&&t1000<83.0){
		cout << "A" << '\n';
	}
	else if(t500<43.0&&t1000<89.0){
		cout << "B" << '\n';
	}
	else if(t500<50.0&&t1000<105.0){
		cout << "C" << '\n';
	}
	else if(t500<55.0&&t1000<116.0){
		cout << "D" << '\n';
	}
	else if(t500<70.0&&t1000<148.0){
		cout << "E" << '\n';
	}
	else{
		cout << "NA" << '\n';
	}
}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	int M;
	if (N > 0)
		M = A[0].size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < M; j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}

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

struct edge {
	int from, to, d, c;
	edge(int _from = 0, int _to = 0, int _d = 0, int _c = 0) {
		from = _from;
		to = _to;
		d = _d;
		c = _c;
	}
	bool operator<(const edge &rhs) const {
		return (d == rhs.d) ? (c < rhs.c) : (d < rhs.d);
	}
};
struct aabb {
	int x1, y1, x2, y2;
	aabb(int x1, int y1, int x2, int y2) : x1(x1), y1(y1), x2(x2), y2(y2) {}
};

typedef vector< edge > edges;
typedef vector< edges > graph;
struct flow {
	int to, cap, rev, cost;
	flow(int to = 0, int cap = 0, int rev = 0, int cost = 0) : to(to), cap(cap), rev(rev), cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4] = {0, -1, 0, 1};
const int dj[4] = {-1, 0, 1, 0};
const int ci[5] = {0, 0, -1, 0, 1};
const int cj[5] = {0, -1, 0, 1, 0};
const ll LINF = LLONG_MAX / 2;
const int INF = INT_MAX / 2;
const double PI = acos(-1);

int pow2(int n) { return 1 << n; }
template < typename T, typename U >
bool chmin(T &x, const U &y) {
	if (x > y) {
		x = y;
		return true;
	}
	return false;
}
template < typename T, typename U >
bool chmax(T &x, const U &y) {
	if (x < y) {
		x = y;
		return true;
	}
	return false;
}

struct initializer {
	initializer() {
		cout << fixed << setprecision(11);
	}
};
initializer _____;

int N, M, K, T, Q;
bool check(vector< int > &A, int m) {
	vector< int > dp(K, 0);
	dp[0] = 1;
	rep(i, N) {
		if (i == m)
			continue;
		int a = A[i];
		for (int i = K - 1; i >= 0; i--) {
			if (i - a >= 0 && dp[i - a] == 1)
				dp[i] = 1;
		}
	}
	for (int i = 0; i < A[m]; i++) {
		if (dp[K - 1 - i] == 1)
			return false;
	}
	return true;
}
signed main() {
	cin >> N >> K;
	vector< int > A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end());
	int l = -1, r = N;
	while (r - l > 1) {
		int m = (l + r) / 2;
		if (check(A, m)) {
			l = m;
		} else {
			r = m;
		}
	}
	cout << l + 1 << endl;
	return 0;
}

Measured memory_bytes: 384
n = int(input())
G = {i:[] for i in range(1, n+1)}
for _ in range(n):
    ukv = list(map(int, input().split()))
    u = ukv[0]
    k = ukv[1]
    for i in range(2, 2+k):
        G[u].append(ukv[i])
        
d = [-1 for _ in range(n+1)]
f = [-1 for _ in range(n+1)]
counter = 0

def dfs(n):
    global counter
    counter += 1
    d[n] = counter
    
    for n_i in G[n]:
        if d[n_i]==-1:
            dfs(n_i)
            
    counter += 1
    f[n] = counter

for i in range(1, n+1):
    if d[i]==-1:
        dfs(i)

for id_i, (d_i, f_i) in enumerate(zip(d[1:], f[1:]), 1):
    print(id_i, d_i, f_i)


Measured memory_bytes: 5716
n = int(input())
x = [list(map(int,input().split())) for _ in range(n)]
a = 0
b = 0
c = 0
for i in range(n):
  pa = a
  pb = b
  pc = c
  X = x[i]
  a = max(pb,pc)+X[0]
  b = max(pc,pa)+X[1]
  c = max(pa,pb)+X[2]
  
print(max([a,b,c]))
  


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

int main(){
    int A, B;
    cin >> A >> B;
    
    string s,t;
    
    int cnt=0;
    for(int i=A; i<=B; i++){
        s = to_string(i);
        t = s;
        reverse(s.begin(),s.end());
        if(t==s)
            cnt++;
    }
    
    cout << cnt << endl;
}


Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    let N = read!(usize);
    let X = read![[i64]];

    let mut m = std::i64::MAX;

    for P in 1..101 {
        let mut s = 0;

        for i in 0..N {
            let d = X[i] - P;
            s += d * d;
        }

        m = min(m, s);
    }

    println!("{}", m)
}


Measured memory_bytes: 4352
#include <cstdio>
#include <cstdlib>

class Stack {
private:
    int stack[200];
public:
    void printStack() {
        for (int i=0; i<size(); i++) printf("stack0: %d\n", stack[i]);
    }
    void push(int a) {
        for (int i=0; i<=size(); i++) {
            int t = stack[i]; stack[i]=a; a=t;
        }
    }
    int size() { return sizeof(stack) / sizeof(stack[0]); }
    int pull() {
        int first = stack[0];
        for (int i=0; i<size(); i++) {
            stack[i] = stack[i+1];
        }
        return first;
    }

    void calculate(char c) {
        int b = pull();
        int a = pull();

        //printf("%d %c %d\n", a, c, b);
        char p;
        switch (c) {
            case '+':
                //printf("%d\n", a+b);
                push(a+b);
                break;
            case '-':
                //printf("%d\n", a-b);
                push(a-b);
                break;
            case '*':
                //printf("%d\n", a*b);
                push(a*b);
                break;
            default:
                push(c);
        }
    }
};

int main()
{
    Stack stack;
    for (int i=0; i<200; i++) stack.push(0);
    char s[200];
    while (scanf("%s", s) != EOF) {
        if ( s[0] == '+'
           || s[0] == '-'
           || s[0] == '*' ) {
            stack.calculate(s[0]);
        } else {
            stack.push(atoi(s));
        }
    }
    int z = stack.pull();
    printf("%d\n", z);

    return 0;
}

Measured memory_bytes: 976
#include<iostream>
#include<iomanip>
#include<sstream>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<map>
#include<vector>
#include<queue>
#include<set>
#include<numeric>

using namespace std ;

#define pb(n) push_back(n)
#define fi first
#define se second
#define np string::npos
#define all(r) (r).begin(),(r).end()
#define gsort(st,en) sort((st),(en),greater<int>())
#define vmax(ary) *max_element(all(ary))
#define vmin(ary) *min_element(all(ary))
#define debug(x) cout<<#x<<": "<<x<<endl

#define rep(i,n) for(int i = 0; i < (int)(n);++i)
#define repc(i,a,b) for(int i = (a);i < (int)(b);++i)
#define repi(it,array) for(auto it = array.begin(),end = array.end(); it != end;++it)
#define repa(n,array) for(auto n :(array))

typedef long long ll ;
typedef vector<int> vi ;
typedef vector<ll> vl ;
typedef map<string,int> dict;

constexpr int imax = ((1<<30)-1)*2+1 ;
constexpr int inf = 100000000;
double eps = 1e-10 ;

template <typename T>
void out(vector < T > v)
{
  for(size_t i = 0; i < v.size(); i++)
  {
    debug(v[i]);
  }
}

template<typename T>
string ntos( T i ) {
  ostringstream s ;
  s << i ;
  return s.str() ;
}

template<typename T>
T ston(string str, T n){
  istringstream sin(str) ;
  T num ;
  sin >> num ;
  return num ;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int ans = 0,n;
  string s;
  while(cin >> s){
    n = 0;
    rep(i,s.size()/2+1){
      if(s[i] == s[s.size()-1-i]){
        ++n ;
      }
      else{
        break;
      }
    }
    if(n == s.size()/2+1){
      ++ans;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2992
//MISHON69
//DATE:6/24/2020
#include<bits/stdc++.h>
using namespace std;
#define FOR(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long

int main(){
  string s1;
  string s2;
  cin>>s1;
  cin>>s2;
  int move=0;
  for(int i=0;i<s1.size();i++){
     if(s1[i]!=s2[i])
     move++;
  } 
  cout<<move<<endl;
}

Measured memory_bytes: 3816
#include<stdio.h>
int main(void)
{
   int r, a, b;
   scanf("%d %d", &a, &b);
   if (a < b)
   {
       r = a;
       a = b;
       b = r;
   }
   while(b > 0)
   {
      r = a % b;
      a = b;
      b = r;
   }
   printf("%d\n",a);
   return 0;
}


Measured memory_bytes: 2136
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
#include <cassert>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(1e9+7)
#define INF (int)(1e9)
#define LINF (long long int)(1e18)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

ll D = 365;
ll C[26] = {};
ll S[365][26] = {};

ll score(const vector<ll> &ans){
  ll ret = 0;
  ll last[26] = {};
  rep(i,D){
    ret += S[i][ans[i]];
    last[ans[i]] = i+1;
    rep(j,26){
      ret -= C[j] * (i+1 - last[j]);
    }
    cout<<ret<<endl;
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  cin>>D;
  rep(i,26){
    cin>>C[i];
  }
  rep(i,D){
    rep(j,26){
      cin>>S[i][j];
    }
  }

  vector<ll> ans(D);
  rep(i,D){
    cin>>ans[i];
    ans[i]--;
  }
  score(ans);
  return 0;
}

Measured memory_bytes: 3652
from math import sqrt
import sys
sdin = sys.stdin.readline

q = int(sdin())
ab = []
for i in range(q):
    a,b = map(int, sdin().split())
    if a > b:
        a,b = b,a
    ab.append(tuple([a,b]))

for a, b in ab:
    if  b-a < 2:
        print(2*a - 2)
        
    else:
        if not (sqrt(a*b) - int(sqrt(a*b))):
            c = int(sqrt(a*b) - 1)
        else:
            c  = int(sqrt(a*b))
        
        if c*(c+1) >= a*b:
            print(2*c - 2)
        else:
            print(2*c - 1)
            
            

Measured memory_bytes: 3064
dd = Array.new('z'.ord+2){0}
$stdin.readline.chomp.each_char.to_a.sort.map(&:ord).each{|k|
  dd[k] += 1
}
res = 0
150.times{
  c = 0
  r = 0
  while c < dd.size
    if dd[c]==0
      res += if r>=3 then 3 else r end
      r = 0
    else
      dd[c] -= 1
      r += 1
    end
    c+=1
  end
}

puts res

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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;
typedef vector<ld> vld;
typedef vector<pll> vpl;
typedef vector<vll> vvll;

#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define yes cout<<"Yes"<<endl
#define YES cout<<"YES"<<endl
#define no cout<<"No"<<endl
#define NO cout<<"NO"<<endl
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

ll solve(ll x, ll y, ll z){
  ll maxs=0;
  ll mins=LLINF;
  maxs=max(maxs,x);
  maxs=max(maxs,y);
  maxs=max(maxs,z);

  mins=min(mins,x);
  mins=min(mins,y);
  mins=min(mins,z);

  return maxs-mins;
}

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

  ll H,W;
  cin>>H>>W;

  ll ans=LLINF;
  for(ll hx=1; hx<=H; hx++){
    ll x=hx*W;

    ll h=H-hx;
    ll y=(W-W/2)*h;
    ll z=W/2*h;
    ans=min(ans,solve(x,y,z));

    y=(h-h/2)*W;
    z=h/2*W;
    ans=min(ans,solve(x,y,z));
  }

  for(ll wx=1; wx<=W; wx++){
    ll x=wx*H;

    ll w=W-wx;
    ll y=(H-H/2)*w;
    ll z=H/2*w;
    ans=min(ans,solve(x,y,z));

    y=(w-w/2)*H;
    z=w/2*H;
    ans=min(ans,solve(x,y,z));
  }

  cout<<ans<<endl;
}



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

using namespace std;

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

  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (i + 1 >= n) continue;
    string t = "";
    t += s[i], t += s[i + 1];
    if (t == "OX" || t == "XO") {
      ans++;
      i++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3340
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin >> n;
    char s[n];
    vector<char> output;
    cin >> s;
    output.push_back(s[0]);
    for (int i = 1; i < n; i++)
    {
        if (s[i] != s[i - 1])
        {
            output.push_back(s[i]);
        }
    }
    cout << output.size();
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define mp(x, y) make_pair(x, y)
#define pb(x) emplace_back(x)
#define IOS ios::sync_with_stdio(false), cin.tie(0), cout.tie(0)

typedef long long ll;
typedef vector<int> V;
typedef pair<int, int> pii;

const int N = 1e5;
int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    while (n--) {
        string s;
        cin >> s;
        m[s]++;
    }
    vector<pair<int, string>> v;
    int ansn = -1;
    for (auto i : m)
        v.push_back({ i.ss, i.ff }), ansn = max(ansn, i.ss);
    sort(v.begin(), v.end());
    for (auto i : v) {
        if (i.ff == ansn)
            cout << i.ss << "\n";
    }
}

Measured memory_bytes: 29680
import sys
readline = sys.stdin.readline

K,N = map(int,readline().split())
A = list(map(int,readline().split()))

ans = A[-1] - A[0] # K - ((K - A[-1]) + A[0])

for i in range(1,len(A)):
  if K - (A[i] - A[i - 1]) < ans:
    ans = K - (A[i] - A[i - 1])

print(ans)

Measured memory_bytes: 31448
#include <bits/stdc++.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++)

int main() {
  long n;
  cin >>n;
  long ans=0;
  for(long i=1;i*i<n;i++){
    if(n%i==0){
      long a=n/i;
      if(n%(a-1)!=0){
        ans+=a-1;
      }
    }
  }
  
  
  cout<<ans<<endl;  
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
typedef vector <int> vi;
int f0070(vi A,int n,int s){
	if (s<0)return 0;
	int b1=0,b2=0,c=0,j=1,i,a=A.size();
	vi::iterator it1=A.begin(),it2=it1+a;
	if(n==1)return(find(it1,it2,s)==it2)?0:1;
	sort(it1,it2);
	it1+=n-1;
	it2-=n;
	for (i=0;i<n;i++){
		b1+=j*(*it1--);
		b2+=j*(*it2++);
		j++;
	}
	vi A3(a-1);
	if (b1<=s&&s<=b2)
		for (i=0;i<a;i++){
			A3.clear();
			for (j=0;j<a;j++)
				if (j!=i)A3.push_back(A[j]);
			c+=f0070(A3,n-1,s-A[i]*n);
		}
	return c;
}
int main(){
	int n,s,i;
	vi A(10);
	for(i=0;i<10;i++)A[i]=i;
	while(1){
		cin>>n>>s;
		if (cin.eof())break;
		cout<<f0070(A,n,s)<<endl;
	}
}

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

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict

s = list(input())
t = list(input())
c = 0
for i in range(len(s)):
    if s[i] != t[i]:
        c+=1

print(c)


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

    using namespace std;
    #define ll long long
    #define rep(i,a,n) for(int i=a;i<n;i++)
    #define pb push_back
    #define in insert
    
    #define SORT(x) sort(x.begin(),x.end())
    #define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
    #define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
    #define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
    #define All(x) (x).begin(),(x).end()
    #define rAll(x) (x).rbegin(),(x).rend()
    #define db long double
    #define sc scanf
    #define pf printf
    const double pi=3.1415926535897;
    ll gcd(ll x,ll y){
    	if(x==0)return y;
    	else return gcd(y%x,x);
    }
    ll lcm(ll x,ll y){
    	return (x*y)/gcd(x,y);
    }
    bool valid(ll k){
    	ll a[10005]={0};
    	for(ll x=5;x<=100;x++){
    		for(ll i=5;i<=100;i++){
    			a[i*x]=1;
    		}
    	}
    	
    	if(a[k])return true;
    	else return false;
    	
    }
   
    int main() {
    	ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);
    	int n;
    	cin>>n;
    	
    	if(n%10==3){cout<<"bon";return 0;}
    	if(n%10==0||n%10==1||n%10==6||n%10==8)cout<<"pon";
    	else{
    		cout<<"hon";
    	}
    	

    	return 0;
}


Measured memory_bytes: 3612
/*
考虑对树的深度奇偶分类，然后再在奇数层放球。
定义一个点的颜色(0/1) = 深度奇偶性 xor 球的有无；
容易得到初始状态是全 0，每次操作等价于球往相邻空位移动。

比较容易构造出最优的策略，每条边都贴下界。 
也就是说设有球点权 = 1，空位点权 = -1，
则 u 的子树和 sum 等价于 u->fa 移动球的次数(若 sum<0 则代表 fa->u )。 

考虑如果有奇环

偶环 
*/
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

const int N=100005;

int n,m,S,T,dep[N],fa[N],ord,dfn[N],f[N];
vector<int>G[N];
long long ans;

void link(int a,int b)
{
	G[a].push_back(b);
	G[b].push_back(a);
}

void dfs(int u,int par)
{
	fa[u]=par;
	dfn[u]=++ord;
	for(auto &v:G[u])
		if(v^par)
		{
			if(!dfn[v])
			{
				dep[v]=dep[u]+1;
				dfs(v,u);
			}
			else if(dfn[v]<dfn[u])
			{
				S=u;
				T=v;
			}
		}
}

void dfs1(int u)
{
	f[u]=dep[u]&1?1:-1;
	for(auto &v:G[u])
		if(fa[v]==u)
			dfs1(v),f[u]+=f[v];
}

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1,a,b; i<=m; i++)
	{
		scanf("%d%d",&a,&b);
		link(a,b);
	}
	dep[1]=1;
	dfs(1,0);
	dfs1(1);
	if(n>m)
	{
		if(f[1])
			return puts("-1"),0;
	}
	else
	{
		if(dep[S]%2==dep[T]%2)
		{
			if(f[1]%2)
				return puts("-1"),0;
			ans+=abs(f[1]/2);
			for(int x=S; x!=T; x=fa[x])
				f[x]-=f[1]/2;
			for(int x=T; x; x=fa[x])
				f[x]-=f[1];
		}
		else
		{
			if(f[1])
				return puts("-1"),0;
			vector<int> v;
			for(int x=S; x!=T; x=fa[x])v.push_back(f[x]);
			v.push_back(0);
			nth_element(v.begin(),v.begin()+v.size()/2,v.end());
			int F=v[v.size()/2];
			ans+=abs(F);
			for(int x=S; x!=T; x=fa[x])f[x]-=F;
		}
	}
	for(int i=1; i<=n; i++)
		ans+=f[i]<0?-f[i]:f[i];
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 12540
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (b)-1; i >= (a); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class S, class T>bool chmax(S &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class S, class T>bool chmin(S &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vvll dp;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, m;
    cin >> n >> m;
    vll a(m), b(m);
    vll cost(n, INF);
    vvll c(m);
    rep(i, m){
        cin >> a[i] >> b[i];
        rep(j, b[i]){
            ll _;
            cin >> _;
            _--;
            c[i].emplace_back(_);
            chmin(cost[c[i][j]], a[i]);
        }
    }
    ll ans = accumulate(ALL(cost), 0ll);
    // 右が0
    vll cbit(m, 0);
    rep(i, m){
        rep(j, SZ(c[i])){
            cbit[i] += (1 << c[i][j]);
        }
    }
    if(ans >= INF){
        cout << -1 << endl;
    }else{
        dp.resize(m, vll((1<<n), INF));
        // 左から
        dp[0][0] = 0;
        dp[0][cbit[0]] = a[0];
        repr(i, 1, m){
            rep(j, (1<<n)){
                // 買う、買わない
                chmin(dp[i][j|cbit[i]], dp[i-1][j]+a[i]);
                chmin(dp[i][j], dp[i-1][j]);
            }
        }
        cout << dp[m-1][(1<<n)-1] << endl;
    }
    return 0;
}

Measured memory_bytes: 32512
#include <bits/stdc++.h>
using namespace std;
deque<int> Era(int n) {
    deque<int> arr(n+1,1);
    //deque<int> prime;
    arr[0]=0;
    arr[1]=0;
    for (int i=2;i*i<n;i++) {
        if (arr[i]==1) {
            for (int j=i*i;j<n;j+=i) {
                arr[j]=0;
            }
        }
    }
    return arr;
    /*
    for (int k=2;k<=n;k++) {
        if (arr[k]==1) {
            prime.emplace_back(k);
        }
    }
    return prime;
    */
}
int main(void){
    int a,d,n;
    std::deque<int> deq;
    deq=Era(1000000);
    while (cin>>a>>d>>n) {
        if (a==0&&d==0&&n==0) {
            break;
        } else {
            int count=0;
            int flag=0;
            if (deq[a]==1) {
                count++;
            }
            if (count==n) {
                flag=1;
                cout<<a<<endl;
            }
            int tmp=a;
            if (flag==0) {
                while (1) {
                    tmp+=d;
                    if (tmp%2==1||tmp==2) {
                        if (deq[tmp]==1) {
                            count++;
                        }
                        if (count==n) {
                            cout<<tmp<<endl;
                            break;
                        }
                    }
                }
            }
        }
    }
}


Measured memory_bytes: 6564
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  if((1 <= N)&&(N < 10)){
  cout << N << endl;
  }
  else if((10 <= N)&&(N < 100)){
  cout << 9 << endl;
  }
  else if((100 <= N)&&(N< 1000)){
  cout << N - 90 << endl;
  }
  else if((1000 <= N)&&(N < 10000)){
   cout << 909 << endl;
  }
  else if((10000 <= N)&&(N < 100000)){
   cout << N - 9090 << endl;
  }
  else if((100000 <= N)&&(N < 1000000)){
   cout << 90909 << endl;
  }
}

Measured memory_bytes: 256
# solution
import io
import math
import heapq
import bisect

n,m = (int(x) for x in input().split())

a = [int(i)*(-1) for i in input().split()]
heapq.heapify(a)
for _ in range(m):

    b  = -(heapq.heappop(a))//2
    heapq.heappush(a,-b)
print(-sum(a))

Measured memory_bytes: 14536
def checkBW(i,j):
    try:
        up = S[i-1][j]
    except:
        up = '.'
    try:
        right = S[i][j+1]
    except:
        right = '.'
    try:
        down = S[i+1][j]
    except:
        down = '.'
    try:
        left = S[i][j-1]
    except:
        left = '.'
    #print(up,right, down, left)
    if(up == '.' and right == '.' and down == '.' and left == '.'):
        return True
    else:
        return False

H, W = map(int, input().split())
S = []
for i in range(H):
    temp_input = input()
    S.append(temp_input)

# 黒を探索
for i in range(H):
    for j in range(W):
        if(S[i][j] == '#'):
            #print(i,j)
            if(checkBW(i,j)):
                print('No')
                exit()
print('Yes')


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

int main(){
  int N;cin>>N;
  int X=N/4+1;
  bool can=false;
  for(int i=0;i<=X;i++){
    int j=0;
    while(true){
      if(4*i+7*j==N){
        can=true;
        break;
      }
      if(4*i+7*j>N) break;
      j++;
    }
    if(can) break;
  }
  cout<<(can?"Yes":"No")<<endl;
}

Measured memory_bytes: 3580
N=int(input())
S=input()
nagasa=len(S)
D=[]
goukei=0
for i in range(nagasa-1):
    if S[i+1]=="E":
        goukei+=1
    else:
        goukei+=0
#print(goukei)
     
D.append(goukei)
for i in range(nagasa-1):
    if S[i]=="W":
        goukei+=1
    else:
        goukei+=0
    if S[i+1]== "W":
        goukei+=0
    else:
        goukei-=1
    
    D.append(goukei)
#print(D)
print(min(D))    

Measured memory_bytes: 21400
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<map>
#include<queue>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
using namespace std;


int main(){

  double pi = 3.141592653589;
  double r;
  cin >> r;

  printf("%.8lf %.8lf\n", pi*r*r,2*r*pi);

  return 0;
}








// EOF

Measured memory_bytes: 3200
import sys

def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

N = I()
W = LI()


min_v = 1000000
for t in range(1,N+1):

    a = sum(W[:t])
    b = sum(W[t:])
    min_v = min(min_v,abs(a-b)) 
print(min_v)


Measured memory_bytes: 9100
def insertitionSort(A,N):
    for i in range(N):
        v = A[i]
        j = i -1
        
        while j>=0 and A[j] > v:
            A[j+1] = A[j]
            j = j -1
        A[j+1] = v
        map_result = map(str, A)
        print(' '.join(map_result))                  ### 出力形式を変換

##from IPython.core.debugger import Pdb; Pdb().set_trace()        
N = int(input())
A = list(map(int, input().split()))   ###　　1行の複数の入力を整数型で

insertitionSort(A,N)





Measured memory_bytes: 5600
object Main {
  def main(args: Array[String]): Unit = {
    Iterator.continually(io.StdIn.readLine())
      .map { line =>
        val arr = line.split(" ").map(_.toInt)
        (arr(0), arr(1))
      }
      .takeWhile {
        case (0, 0) => false
        case _ => true
      }
      .foreach { case (h, w) =>
        val size = w - 2
        val sb = StringBuilder.newBuilder
        append(sb)("#" * size)
        for (_ <- 0 until h - 2) {
          append(sb)("." * size)
        }
        append(sb)("#" * size)
        sb.append('\n')
        print(sb.toString())
      }
  }

  def append(sb: StringBuilder)(row: => String): Unit = {
    sb.append('#')
      .append(row)
      .append('#')
      .append('\n')
  }
}

Measured memory_bytes: 45196
#![allow(non_snake_case)]

use std::cmp::min;
use std::io::{stdin, Read};
use std::str::FromStr;
fn read_option<T: FromStr>() -> Option<T> {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok()
}
fn read<T: FromStr>() -> T {
    let opt = read_option();
    opt.expect("failed to parse token")
}

fn main() {
    let T: usize = read();
    for _ in 0..T {
        let (N, A, B, C, D): (i64, i64, i64, i64, i64) = (read(), read(), read(), read(), read());
        let ans = solve(N, A, B, C, D);
        println!("{}", ans);
    }
}

#[allow(dead_code)]
fn solve(N: i64, A: i64, B: i64, C: i64, D: i64) -> i64 {
    use std::collections::{HashMap, VecDeque};
    let mut dp = HashMap::new();
    let mut new = VecDeque::new();
    dp.insert(N, 0);
    new.push_front((N, 0));
    let mut min_cost: i64 = N.saturating_mul(D);
    while let Some((v, now_cost)) = new.pop_back() {
        if v == 0 {
            min_cost = min(min_cost, now_cost);
            continue;
        }
        if now_cost >= min_cost {
            continue;
        }
        for &(d, cost) in &[(2, A), (3, B), (5, C)] {
            let nexts = match v % d {
                0 => vec![(v / d, 0)],
                rem => vec![
                    ((v - rem) / d, rem * D),
                    ((v + (d - rem)) / d, (d - rem) * D),
                ],
            };
            for (next, add_cost) in nexts {
                // 後者は全部1を引いた場合と比較している。全部1が少ないコストの場合はadd_costなしで最初からv - nextに直線で行けば良い
                let new_cost = min(
                    now_cost + cost + add_cost,
                    now_cost.saturating_add((v - next).saturating_mul(D)),
                );

                match dp.get(&next) {
                    None => {
                        dp.insert(next, new_cost);
                        new.push_front((next, new_cost))
                    }
                    Some(&cost2) => {
                        // 新しい道のほうが安い場合はコスト更新するためにキューに突っ込む
                        if cost2 > new_cost {
                            dp.insert(next, new_cost);
                            new.push_front((next, new_cost))
                        }
                    }
                }
            }
        }
    }
    min_cost
}


Measured memory_bytes: 19052
def main():
    A, B, K = list(map(int, input().split()))
    for i in range(K):
        if i % 2 == 0:
            if A % 2 != 0:
                A = A - 1
            A = A / 2
            B = B + A
        else:
            if B % 2 != 0:
                B = B - 1
            B = B / 2
            A = A + B
    print(int(A), int(B))
if __name__ == '__main__':
    main()


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

bool pal(string s) {
  string t = s;
  reverse(t.begin(), t.end());
  return s == t;
}

int main() {
  string S;
  cin >> S;
  int N = S.size();
  cout << ((pal(S) && pal(S.substr(0, N / 2)) && pal(S.substr(N / 2 + 1))) ? "Yes" : "No") << "\n";
}

Measured memory_bytes: 256
INF = float("inf")
# MOD = 10 ** 9 + 7
# import sys
# input = sys.stdin.readline
# sys.setrecursionlimit(10 ** 6)
import numpy as np


def main():
    n, m, x = map(int, input().split())
    books = [np.array(list(map(int, input().split()))) for _ in range(n)]
    ans = INF
    for bit in range(1 << n):
        bag = [0] * n
        for i in range(n):
            if bit >> i & 1:
                bag[i] = 1
        tmp = np.array([0] * m)
        cost = 0
        for i, v in enumerate(bag):
            if v:
                cost += books[i][0]
                tmp += books[i][1:]
        if all([i >= x for i in tmp]):
            ans = min(ans, cost)
    if ans == INF:
        print(-1)
    else:
        print(ans)

if __name__ == '__main__':
    main()

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

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

    int ans;
    for (int i = 1; i < S.size(); i++)
    {
        int length = (S.size() - i);
        if (length % 2 != 0)
        {
            continue;
        }
        if (S.substr(0, length / 2) == S.substr(length / 2, length / 2))
        {
            ans = length;
            break;
        }
    }

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

Measured memory_bytes: 3592
#include <stdio.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath>
//#include <unordered_map>
//#include <unordered_set>
//#include <boost/container/static_vector.hpp>
//#include <boost/unordered_set.hpp>
//#include <boost/unordered_map.hpp>
//#include <unistd.h>

//#include <cv.h>
//#include <highgui.h>
#include <stdlib.h>
#include <string>
#include <cstring>

const int MAX_V = 400;
int V;
std::vector<int> G[MAX_V]; // グラフの隣接リスト表現
int match[MAX_V];          // マッチングのペア
bool used[MAX_V];          // DFSですでに調べたかのフラグ

// fromからtoへ向かう辺をグラフに追加する
void add_edge(const int u, const int v) {
    G[u].push_back(v);
    G[v].push_back(u);
}

// 増加パスをDFSで探す。
bool dfs(const int v) {
    //std::cout << "dfs" << std::endl;
    used[v] = true;
    for (int i = 0; i < G[v].size(); i++) {
        int u = G[v][i];
        int w = match[u];
        if (w < 0 || !used[w] && dfs(w)) { // uのmatch wが存在しない、またはwに対して別のマッチングを構築可能
            match[v] = u;
            match[u] = v;
            return true;
        }
    }
    return false;
}

int bipartite_matching() {
    int res = 0;
    std::memset(match, -1, sizeof(match));
    for (int v = 0; v < V; v++) {
        if (match[v] < 0) {
            std::memset(used, false, sizeof(used));
            if (dfs(v)) {
                res++;
            }
        }
    }
    return res;
}

const int MAX_N = 110;
int N, a[MAX_N], b[MAX_N], c[MAX_N], d[MAX_N];

int main(int argc, char **argv) {
    std::cin >> N;
    for (int i = 1; i <= N; i++) {
        std::cin >> a[i] >> b[i];
    }
    for (int i = 1; i <= N; i++) {
        std::cin >> c[i] >> d[i];
    }
    V = N * 2 + 2;

    for (int i = 1; i <= N; i++) {
        for (int j = 1; j <= N; j++) {
            if (a[i] < c[j] && b[i] < d[j]) {
                add_edge(i, N + j);
            }
        }
    }
    int ret = bipartite_matching();

    std::cout << ret << std::endl;

    return 0;

}


Measured memory_bytes: 256
/***
*   author:   ashikur rahman
*   created:  29.08.2020 20:04:01
***/

#include<bits/stdc++.h>

using namespace std;

const int N = 1e6 + 2;
bool vis[N + 5];
vector<int> primes;
int sz;
void seive(){
  for (int i = 4; i < N; i += 2) {
    vis[i] = true;
  }       
  for (int i = 3; i * i < N; i += 2){
    if (vis[i] == false){
      for (int j = i * i; j < N; j += (i << 1)) {
        vis[j] = true;
      }
    }
  }
  primes.push_back(2);
  for (int i = 3; i < N; i += 2){
    if (vis[i] == false){
      primes.push_back(i);
    }
  }
  sz = primes.size();
}
int cnt[N + 5];
int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  seive();
  int n;
  cin >> n;
  vector<int>ar(n);
  for (int i = 0; i < n; i++){
    cin >> ar[i];
  }
  int gg = 0;
  for (int i = 0; i < n; i++){
    gg = __gcd(gg, ar[i]);
  }
  if (gg > 1) {
    cout << "not coprime\n";
    return 0;
  }
  for (int v : ar){
    int x = v;
    for (int i = 0; i < sz && primes[i] * primes[i] <= x; i++){
      if (x % primes[i] == 0){
        while (x % primes[i] == 0){
          x /= primes[i];
        }
        cnt[primes[i]]++;
      }
    }
    if (x > 1){
      cnt[x]++;
    }
  }
  for (int i = 0; i < N; i++){
    if (cnt[i] > 1){
      cout << "setwise coprime\n";
      return 0;
    }
  }
  cout << "pairwise coprime\n";
  return 0;
}

Measured memory_bytes: 12160
#include<iostream>
using namespace std;
int a[1000], b[1000], x[1000], y[1000], n, m;
int main() {
	while (true) {
		cin >> m; if (m == 0)break;
		for (int i = 0; i < m; i++)cin >> a[i] >> b[i];
		cin >> n;
		for (int i = 0; i < n; i++)cin >> x[i] >> y[i];
		for (int i = 0; i < n; i++) {
			int Gx = x[i] - a[0], Gy = y[i] - b[0];
			bool flag = true;
			for (int j = 0; j < m; j++) {
				int Hx = Gx + a[j], Hy = Gy + b[j];
				bool OK = false;
				for (int k = 0; k < n; k++) {
					if (x[k] == Hx && y[k] == Hy)OK = true;
				}
				if (OK == false)flag = false;
			}
			if (flag == true) { cout << Gx << ' ' << Gy << endl; }
		}
	}
	return 0;
}

Measured memory_bytes: 3088
n = int(input())
x = [int(i) for i in input().split()]
d = []
for i in range(min(x), max(x)+1):
  a = 0
  for j in x:
    a += (j - i)**2
#    print("({}-{})**2={}".format(j,i,(j - i)**2))
  d.append(a)
print(min(d))


Measured memory_bytes: 2940
#include<stdio.h>

void trace(int A[], int N) {
    int i;
    for (i = 0; i < N; i++) {
        if (i > 0) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n");
}


int bubbleSort(int A[], int n) {
    int tmp, flag = 1, count = 0;
    while (flag) {
        flag = 0;
        for (int j = n - 1; j > 0; j--) {
            if (A[j] < A[j-1]) {
                tmp = A[j]; A[j] = A[j-1]; A[j-1] = tmp;
                flag = 1;
                count++;
            }
        }
    }

    return count;
}

int main(void) {
  int A[100], i, n;
  scanf("%d", &n);
  for (i = 0; i < n; i++) {
      scanf("%d", &A[i]);
  }
  int count = bubbleSort(A, n);
  trace(A, n);
  printf("%d\n", count);

  return 0;
}


Measured memory_bytes: 2144
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <vector>
#include <numeric>
using namespace std;
int main() {
	int N, a[200] = {},ans = 0,sum=0;
	cin >> N;
	for (int i = 0; i < N; ++i) {
		sum = 0;
		cin >> a[i];
		while (a[i] % 2 == 0) {
			a[i] /= 2;
			sum++;
		}
		ans = (i == 0 ? sum : min(sum, ans));
	}
	cout << ans;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
using namespace std;
int main()
{
    int A,B;
    while(scanf("%d %d",&A,&B)!=EOF)
    {
        int a=A-B;
        int b=A+B;
        int c=A*B;
        int temp=a;
        if(temp<b)temp=b;
        if(temp<c)temp=c;
        printf("%d\n",temp);
    }
    return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
C - City Savers
https://atcoder.jp/contests/abc135/tasks/abc135_c

"""
import sys


def solve(N, monsters, heros):
    carries = [0] * (N + 1)
    ans = 0
    for i in range(N+1):
        m = monsters[i]
        x = min(carries[i], m)
        ans += x
        m -= x
        h = heros[i]
        y = min(h, m)
        ans += y
        if y < h:
            carries[i+1] = h - y
    return ans


def main(args):
    N = int(input())
    monsters = [int(a) for a in input().split()]
    heros = [int(b) for b in input().split()] + [0]
    ans = solve(N, monsters, heros)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);
 
    ll n,k;
    cin>>n>>k;
    ll h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    ll ans = 0;
    for(int i=0;i<n;i++){
        if(h[i]>=k) ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

//long mod = 10^^9 + 7;
long mod = 998_244_353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }
void modd(T)(ref T x, T y) { x.modm(y.modpow(mod - 2)); }

void main()
{
	auto K = RD;
	auto N = RD;
	auto A = RDA;

	auto B = new long[](N);
	B[0] = A[0]+K - A[$-1];
	foreach (i; 1..N)
	{
		B[i] = A[i] - A[i-1];
	}
	auto pos = B.MIN_POS!"a > b"();
	auto ans = K - B[pos];

	writeln(ans);
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 11732
#include <stdlib.h>
#include <stdio.h>

int main(){
	int a, b;
	int x, y;	

	while(1){
		scanf("%d %d", &a, &b);
		if((a == 0) && (b == 0)){
			break;
		}
		else{
			for(y=0;y<a; y++){
				for(x=0;x<b;x++){
					if((x==0)||(x==b-1)||(y==0)||(y==a-1))
						printf("#");
					else
						printf(".");
				}
				printf("\n");
			}
			printf("\n");
		}

	}
	
	return 0;

}


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

int main() {
	char s[3];
	for (int i = 0; i < 3; i++) {
		cin >> s[i];
	}
	int a = 0, b = 0, c = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == 'a') {
			a++;
		}
		if (s[i] == 'b') {
			b++;
		}
		if (s[i] == 'c') {
			c++;
		}
	}
	if (a == 1 && b == 1 && c == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace ziyuutyou
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var a = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var L = Enumerable.Repeat(0, n).ToList();
            for (var i = 0; i < n; i++)
            {
                if (i == 0)
                {
                    L[0] = 0;
                }
                else
                {
                    L[i] = gcd(a[i - 1], L[i - 1]);
                }
            }
            var R = Enumerable.Repeat(0, n).ToList();
            for (var i = n - 1; i >= 0; i--)
            {
                if (i == n - 1)
                {
                    R[n - 1] = 0;
                }
                else
                {
                    R[i] = gcd(a[i + 1], R[i + 1]);
                }
            }
            var max = 0;
            for (var i = 0; i < n; i++)
            {
                max = Math.Max(max, gcd(L[i], R[i]));
            }
            Console.WriteLine(max);
        }
        static int gcd(int a, int b)
        {
            if (b > a)
            {
                return gcd(b, a);
            }
            else
            {
                while (b != 0)
                {
                    var remainder = a % b;
                    a = b;
                    b = remainder;
                }
                return a;
            }
        }
    }
}

Measured memory_bytes: 29276
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll x;
	cin>>x;
	for(ll a=-200;a<=200;a++){
		for(ll b=-200;b<=200;b++){
			if(a*a*a*a*a-b*b*b*b*b==x){
				cout<<a<<' '<<b;
				return 0;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 3608
N=int(input())
As=list(map(int,input().split()))

d1={}
for i,e in enumerate(As):
    d=i-e
    if d > 0:
        if d in d1.keys():
            d1[d]+=1
        else:
            d1[d]=1
cnt=0
for i,e in enumerate(As):
    if (i+e) in d1.keys():
        cnt += d1[i+e]
print(cnt)

Measured memory_bytes: 32368