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

using namespace std;
using ll = long long;

int main()
{
    int n, m, s, t;
    cin >> n >> m;
    vector<vector<int>> Hen(n);
    vector<vector<int>> dist(n, vector<int>(3, -3));

    for(int i = 0; i < m; i++){
        int a, b; cin >> a >> b; a--; b--;
        Hen[a].push_back(b);
    }cin >> s >> t; s--; t--;

    queue<pair<int,int>> que;
    vector<vector<bool>> seen(n,vector<bool>(3));
    que.push({s, 0}); //sでmod3で0;

    while(que.size())
    {
        auto cur = que.front();
        que.pop();
        for(auto i : Hen[cur.first]){
            if(seen[i][(cur.second + 1) % 3])continue;
            dist[i][(cur.second + 1) % 3] = cur.second + 1;
            seen[i][(cur.second + 1) % 3] = true;
            que.push({i, cur.second + 1});
        }
    }
    cout << dist[t][0] / 3<< endl;

}

Measured memory_bytes: 18176
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <fstream>
#include <set>
#include <stack>
#include <queue>
#include <list>
using namespace std;
typedef long long int64;
typedef vector<int> vec;
typedef vector<int64> vec64;
#define db(x) cout << "> " << #x << ": " << x << "\n";
#define ss cout << " ";
#define ct(x) cout << x;
#define nn cout << "\n";
#define cts(x) cout << x << " ";
#define ctn(x) cout << x << "\n";
// // // // // // // // // // // // // // // // // // //
int64 q, n;

void solve(){

    return;
}
const int MAXN = 1e5 + 100;
vector <int64> L(MAXN);

int main(){
    int64 n,k;
    cin >> n >> k;
    vec64 arr(MAXN);
    for (int i = 1; i <= n; i++){
        cin >> arr[i];
    }
    for (int i = 1; i <= k; i++){
        int64 a,b;
        cin >> a >> b;
        L[a] = max(L[a], arr[b]);
        L[b] = max(L[b], arr[a]);
        // cts(a); ctn(b);
    }
    int64 rs = 0;
    // nn;
    for (int i = 1; i <= n; i++){
        // cout << arr[i] << " " << L[i] << "\n";
        if (arr[i] > L[i]){
            rs++;
        }
    }
    ctn(rs);
    return 0;
}


Measured memory_bytes: 4840
#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <time.h>
#include <stdarg.h>
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>
#include <map>

#define ll long long

using namespace std;

void
solve() {
  ll n;
  cin>>n;

  vector<ll> h(n, 0);
  for (ll i=0; i<n; i++)
    cin>>h[i];

  vector<ll> value(n, 0);
  value[0] = 0;
  for (ll i=1; i<n; i++) {
    if (i == 1)
      value[i] = abs(h[1]-h[0]);
    else
      value[i] = min(value[i-1] + abs(h[i]-h[i-1]), value[i-2] + abs(h[i] - h[i-2]));
  }
  cout<<value[n-1]<<endl;
}

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

  ll t = 1;
  //cin>>t;

  while (t > 0) {
    t--;
    solve();
  }

  return 0;
}



Measured memory_bytes: 4764
N=int(input())
List = list(map(int, input().split()))
Row = int(input())
QList = []
for i in range (Row):
  QList.append(list(map(int, input().split())))
dictA ={}
res = 0
for i in range (N):
  dictA.setdefault(List[i],0) 
  dictA[List[i]] += 1
  res += List[i]
num = 0
for i in range(Row):
  if QList[i][0] not in dictA:
    pass
  else:
    num = dictA[QList[i][0]] 
    res = res - dictA[QList[i][0]] * QList[i][0]
    dictA[QList[i][0]] = 0
    dictA.setdefault(QList[i][1],0) 
    dictA[QList[i][1]] += num
    res += QList[i][1] * num
  print(res)

Measured memory_bytes: 35820
import java.util.Arrays;
import java.util.Scanner;

public class Main{
	private static Scanner scan;
	public static void main(String[] args) {
		scan = new Scanner(System.in);
		int a[] = new int[5];
		for(int i = 0; i < 5;i++)a[i] = Integer.parseInt(scan.next());
		Arrays.sort(a);
		System.out.print(a[4]);
		for(int i = 3;i >= 0;i--){
			System.out.print(" " + a[i]);
		}
		System.out.println();
		System.exit(0);
	}

}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;
const ll LINF = 1001001001001001;
const int MOD = 1000000007;

template <typename T>
void print(const T &v);

int main()
{
    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x[i] >> y[i];
    }

    map<string, ll> mp;
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < n; j++)
        {
            if (i == j)
            {
                continue;
            }
            ll dx = x[i] - x[j];
            ll dy = y[i] - y[j];
            string key = to_string(dx) + ':' + to_string(dy);
            mp[key]++;
        }
    }
    ll maxi = 0;
    for (auto m : mp)
    {
        maxi = max(maxi, m.second);
    }
    cout << n - maxi << endl;
    return 0;
}

// Use For Debug
template <typename T>
void print(T const &v)
{
    for (int i = 0; i < v.size(); i++)
    {
        if (i)
            cout << ' ';
        cout << v[i];
    }
    cout << endl;
}

Measured memory_bytes: 3940
/*
এইসব বৃত্ত থাকুক। থাকুক আমার কড়া পাহারা। তারপরও অসাবধানে ঢুকে পড়ুক কিছু মানুষ। 
তারপর চলে যাইতে চাইলে চলে যাক। বলব, ভালো থাকবেন। আবার দেখা হবে।
*/

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

#define EPS (1e-9)
#define ll long long int
#define ull unsigned long long
#define pi (acos(-1.0))
#define endl "\n"
#define all(v) v.begin(),v.end()
#define printa(a,L,R) for(int i=L;i<R;i++) cout<<a[i]<<(i==R-1?'\n':' ')
#define precise(n) cout << fixed << setprecision(n)
#define show(a) cout << (#a) << " is " << (a) << endl;
#define pcase cout<<"Case "<<++cs<<": "
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);
const int mod=1e9+5;
const int mx=1e5+10;
const int inf=1<<28;
ll binpow(ll base, ll exp){ll res = 1;while(1){ if(exp&1) res*=base;exp>>=1;if(!exp)break;base*=base;}return res;}

int main(int argc, char const *argv[])
{
	FAST
	int n,k;
	cin >> n;
	int arr[n+10],dp[n+10];
    memset(dp,mod,sizeof(dp));
    int aa=0,bb=0,cc=0;
    for (int i = 0; i < n; ++i )
    {
    		int a,b,c;
            cin >> a >> b >> c;
            a=a+max(bb,cc);
            b=b+max(aa,cc);
            c=c+max(aa,bb);
            aa=a,bb=b,cc=c;
            //cout << aa << " " << bb << " " << cc << endl;
    }
   
    
    cout << max(aa,max(bb,cc)) << endl;

	
	

	return 0;
}

Measured memory_bytes: 640
def q(a,h):
 d[a]=str(h)
 for b in t[a]:q(b,h+1)
t,p,d={},{},{}
for _ in[0]*int(input()):
 e=input().split()
 t[e[0]]=e[2:]
 for i in e[2:]:p[i]=e[0]
r=(set(t)-set(p)).pop()
p[r]='-1'
q(r,0)
for i in sorted(map(int,t)):i=str(i);print(f"node {i}: parent = {p[i]}, depth = {d[i]}, {'root'if'-1'==p[i]else'internal node'if t[i]else'leaf'}, [{', '.join(t[i])}]")


Measured memory_bytes: 52936
"""
author : halo2halo
date : 12, Jan, 2020
"""

import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

N, A, B = map(int, read().split())

print(min(N * A, B))


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

#define ll long long int
#define ull unsigned long long int
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define mo 998244353
string str;
//map<int, int>::iterator itr; 
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;cin>>n;
    ll d;cin>>d;
    int c=0;
    for(int i=0;i<n;i++){
        ll a,b;cin>>a>>b;
        if(a*a+b*b<=d*d){
            c++;
        }
    }
        cout<<c;
    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>

int main()
{
  int n,m;
  int p=1e9+7;
  long long ans_n=1,ans_m=1,ans=1;
  int i;
  
  scanf("%d%d",&n,&m);
  
  if(n>m+1||m>n+1)
  {
    printf("0\n");
    return 0;
  }
  
  for(i=1;i<=n;i++)
  {
    ans_n=(ans_n*i)%p;
  }
 
  for(i=1;i<=m;i++)
  {
    ans_m=(ans_m*i)%p;
  }
  
  if(n==m)
  {
    ans=(ans_n*ans_m*2)%p;
  }
  else
  {
    ans=(ans_n*ans_m)%p;
  }
  
  printf("%lld\n",ans);
  
  return 0;
}
  

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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N; cin >> N;
    string S; cin >> S;
    vector<int> W_num(N,0), E_num(N,0);
    REP(i,N-1){
        if(S[i] == 'W') W_num[i+1] = W_num[i] + 1;
        else W_num[i+1] = W_num[i];
    }

    for(int i=N-1; i>0; i--){
        if(S[i] == 'E') E_num[i-1] = E_num[i] + 1;
        else E_num[i-1] = E_num[i];
    }

    int ans = INF;
    REP(i,N){
        ans = min(ans, W_num[i]+E_num[i]);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6088
fun str() = readLine()!!
fun int() = str().toInt()
fun long() = str().toLong()

fun read(d:String = " ") = str().split(d)
fun <T> list(d:String = " ",f:String.()->T) = read(d).map {f(it)}
fun list() = list {toInt()}

fun <T> MutableList<T>.removeLast() = this.removeAt(this.lastIndex)

const val mod = 1000000007L

fun modpow(n:Long,p:Long = mod-2L):Long = when {
	p==0L->1L
	p%2==1L->n*modpow(n,p-1)%mod
	else-> {
		val d = modpow(n,p/2)
		d*d%mod
	}
}

fun main() {
	abc000X()
}

fun abc000X() {
	when(int()) {
		in 400..599->8
		in 600..799->7
		in 800..999->6
		in 1000..1199->5
		in 1200..1399->4
		in 1400..1599->3
		in 1600..1799->2
		in 1800..1999->1
		else->0
	}.let(::println)
}


Measured memory_bytes: 34484
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
#define ll long long
#define umap unordered_map
using graph = vector<vector<int>>;
using graph2 = vector<vector<pair<int, int>>>;
#define oorret true //std::out_of_rangeが返された時
#define oor(x) [&](){try{x;} catch(const std::out_of_range& oor){return oorret;} return x;}()
double pi = 3.141592653589793238;
ll mod(ll x, ll y){if(x>=0||x%y==0) return x%y;return y+x%y;} //mod including minus
ll dv0(ll x, ll y){if(x>=0||x%y==0)return x/y;return x/y-1;} //rnd down
ll dv1(ll x, ll y){if(x%y==0) return dv0(x,y);return dv0(x,y)+1;} //rnd up
int D;
void calculate(vector<int> c, vector<vector<int>> s, int contest,int day, vector<int> &t, ll &score){
    ll p=0;
    int a[26];
    rep(i, 26){
        a[i]=0;
    }
    rep(i, D){
        rep(j, 26){
            p-=c[j]*(i+1-a[j]);
        }
        if(i!=day){
            p+=s[i].at(t[i])+c[t[i]]*(i+1-a[t[i]]);
            a[t[i]]=i+1;
        }else{
            p+=s[day].at(contest)+c[contest]*(day+1-a[contest]);
            a[contest]=i+1;
        }
        
    }
    if(score<p){
        score=p;
        t[day]=contest;
    }
}

int main(){
cin>>D;
vector<int> c(26);
rep(i, 26){
    cin>>c[i];
}
vector<vector<int>> s(D);
int r;
rep(i, D){
    rep(j, 26){
        cin>>r;
        s[i].push_back(r);
    }
}
int M[26];
rep(i, 26){
    M[i]=0;
}
vector<vector<int>> m(D);
rep(i, D){
    rep(j, 26){
        m[i].push_back(0);
    }
}
vector<int> a(26);

rep(i, 26){
    a[i]=0;
}
rep(i, D){
}
vector<int> t(D);
ll score=0;
rep(i, D){
    rep(j, 26){
        M[j]=0;
    }
    rep(j, 26){
        score-=c[j]*(i+1-a[j]);
        rep(k, j+1){
            if(s[i].at(j)+c[j]*(i+1-a[j])>M[k]){
                rep(l, j-k){
                    M[j-l]=M[j-l-1];
                    m[i].at(j-l)=m[i].at(j-l-1);
                }
                M[k]=s[i].at(j)+c[j]*(i+1-a[j]);
                m[i].at(k)=j;
            }
        }
    }
    score+=M[0];
    a[m[i].at(0)]=i+1;
    t[i]=m[i].at(0);
}
rep(j, 20){
    rep(i, 7){
        rep(k, D){
            calculate(c, s, m[k].at(i+1),k, t, score);
        }
    }
    rep(k, D){
        calculate(c, s, m[k].at(0),k, t, score);
    }
}
rep(i, D){
    cout<<t[i]+1<<endl;
}
}


Measured memory_bytes: 3780
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define pii pair<int,int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define vii vector<pii>
#define IO ios_base::sync_with_stdio(0);cin.tie(0); cout.tie(0);
#define all(x) x.begin(),x.end()
#define rep(i,m,n) for(ll i=m ; i<n ; i++)
#define forr(i,m,n) for(ll i=m ; i<=n ; i++)
#define endl '\n'
#define pb push_back
#define re return
const int N =1e5+5;
using namespace std;
int main()
{
    //IO;
    ll h; cin>>h;
    ll i=0,ans=0;
    while(h!=0){
        ans+=powl(2,i++);
        h/=2;
    }


    cout<<ans;






}


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

int main(int argc, char *argv[]){
        long n = 0;
        scanf("%ld", &n);
        long a = 0;
        int i;
        for(i = 0; i <= n;i++){
                a += i;
        }
        printf("%ld\n", a);
        return 0;
}

Measured memory_bytes: 1720
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)((x).size())
#define mp make_pair

using namespace std;

typedef unsigned long long ull;
typedef pair<int,int> ii;

template<class U,class T>ostream& operator<<(ostream& out, pair<U,T> & P){
    return out << "[" << P.first << ", " << P.second << "]";
}
template<class T>ostream& operator<<(ostream& out, vector<T> & V){
    if(!V.empty())out << "[";
    for(int i = 0; i < sz(V); i++)out << V[i] << (i+1==sz(V)?"]":", ");
    return out;
}

long long dp[10001][1001];
long long A[10001];
long long B[10001];

long long H, N;

long long rec(int h, int m){
    if (h <= 0)return 0ll;
    if (dp[h][m] != -1)return dp[h][m];
    if (m+1 < N) return dp[h][m] = min(rec(h-A[m], m) + B[m], rec(h,m+1));
    else return dp[h][m] = rec(h-A[m], m) + B[m];
    return dp[h][m];
}

int main(){
    ios_base::sync_with_stdio(false);
    cin >> H >> N;
    for(int i = 0; i < N; i++){
        cin >> A[i] >> B[i];
    }
    memset(dp,-1,sizeof dp);
    cout << rec(H,0) << endl;
}

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

typedef long long ll;

int main(){
    ll i, N, m;
    ll ans = 0;

    cin>>N;

    for (i=1;i*i<N;++i){
        if (N%i == 0){
            ll b = N/i;
            if (i>1){
                if (N/(i-1) == N%(i-1)) ans += (i-1);
            }
            if (N/(b-1) == N%(b-1)) ans += (b-1);
        }
    }
    if (N/i == 0){
        ll b = N/i;
        if (N/(i-1) == N%(i-1)) ans+= (i-1);
        if (N/(b-1) == N%(b-1)) ans+= (b-1);
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
/*
    oj d https://atcoder.jp/contests/abc167/tasks/abc167_a
    g++ A.cpp
    oj t
    oj s https://atcoder.jp/contests/abc167/tasks/abc167_a A.cpp
*/
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string S, T;
    cin >> S >> T;

    int l = T.size();
    string U = T.substr(0, l-1);
    if(S == U){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 3604
#!/usr/bin/env python3
import sys

def dfs(seen, v, M, N, Q, a, b, c, d, mx):
    seen[v] = True
    if len(list(v)) == N:
        p = 0
        for i in range(Q):
            if v[b[i]-1] - v[a[i]-1] == c[i]:
                p += d[i]
        if mx < p:
            mx = p
        return mx
    for x in [list(v) + [i] for i in range(v[-1],M+1)]:
        x = tuple(x)
        if not x in seen.keys():
            seen[x] = False
        if seen[x] == True:
            continue
        mx = max(mx, dfs(seen, x, M, N, Q, a, b, c, d, mx))
    return mx

def solve(N: int, M: int, Q: int, a: "List[int]", b: "List[int]", c: "List[int]", d: "List[int]"):
    seen = {}
    mx = 0
    c = dfs(seen, (1,), M, N, Q, a, b, c, d, mx)
    print(c)
    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
    Q = int(next(tokens))  # type: int
    a = [int()] * (Q)  # type: "List[int]"
    b = [int()] * (Q)  # type: "List[int]"
    c = [int()] * (Q)  # type: "List[int]"
    d = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        a[i] = int(next(tokens))
        b[i] = int(next(tokens))
        c[i] = int(next(tokens))
        d[i] = int(next(tokens))
    solve(N, M, Q, a, b, c, d)

if __name__ == '__main__':
    main()

Measured memory_bytes: 122360
#include <cstdio>
#include <algorithm>
using namespace std;

int n,m,t[20000];

int main(){
	while(scanf("%d%d",&n,&m),(n|m) != 0){
		for(int i = 0; i < n+m; i++){
			scanf("%d",&t[i]);
		}
		sort(t,t+n+m);
		int mx = t[0];
		for(int i = 1; i < n+m; i++){
			if(mx < t[i] -t[i-1]){
				mx = t[i] - t[i-1];
			}
		}
		printf("%d\n",mx);
	}
	return 0;
}

Measured memory_bytes: 2648
import sys, math, collections, heapq, itertools
F = sys.stdin
def single_input(): return F.readline().strip("\n")
def line_input(): return F.readline().strip("\n").split()
def gcd(a, b):
    a, b = max(a, b), min(a, b)
    while a % b > 0: a, b = b, a % b
    return b
  
def solve():
    N, K = map(int, line_input())
    sum = 0
    for i in range(1, N+1):
        count = 0
        num = i
        while num < K:
            count += 1
            num *= 2
        sum += (1 / N) * (0.5) ** count
    print(sum)

    return 0
  
if __name__ == "__main__":
    solve()

Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  if(a+b+c+d==21 && a*b*c*d==252){cout << "YES" << endl;}
  else{cout << "NO" << endl;}
}

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

using namespace std;

#define rep(i,a,b) for(int i = a; i<int(b);++i)
#define all(v) v.begin(),v.end()
#define sz(v) v.size()
#define trav(a,c) for(auto a: c)

typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pii;

int main(){
	cin.sync_with_stdio(false);
	ll n,a,b;
	cin>>n>>a>>b;
    if((a+b)%2==0) cout<<"Alice"<<endl;
    else cout<<"Borys"<<endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(false);
#define FO cout.tie(NULL);
#define FI cin.tie(NULL);
#define IN cin>>
#define OUT cout<<
#define loop(i,a,n) for(int i=a; i<n; i++)
#define rloop(i,a,n) for(int i=a; i>=n; i--)
#define endl "\n";
#define pb push_back
#define mp make_pair
#define set_bits(a) __builtin_popcount(a)
#define ll long long int
#define ld long double
#define vll vector<long long int>
#define pll pair<long long int, long long int>
#define mod 1000000007
#define M 998244353
ll gcd(ll a, ll b)
{
    return (b?gcd(b,a%b):a);
}
ll P(ll B, ll power, ll modulo)
{
    ll ans=1LL;
    while(power>0LL)
    {
        if(power%2LL==1LL)
        {
            ans=(ans*B)%modulo;
        }
        B=(B*B)%modulo;
        power/=2LL;
    }
    return ans;
}
bool isPrime(ll n)
{
    if(n<=1LL)
    {
        return false;
    }
    if(n<=3LL)
    {
        return true;
    }
    if(n%2==0LL || n%3==0LL)
    {
        return false;
    }
    for(ll i=5LL; (i*i)<=n; i+=6LL)
    {
        if(n%i==0LL || n%(i+2LL)==0LL)
        {
            return false;
        }
    }
    return true;
}
using namespace std;
bool sortbysec(const pair<int,int> &a, const pair<int,int> &b)
{
    return (a.second<b.second);
}
bool sortbysecll(const pll &a, const pll &b)
{
    return (a.second<b.second);
}
ll modinv(ll x, ll y, ll modulo)
{
    return ((x%modulo)*(P(y,modulo-2LL,modulo)%modulo))%modulo;
}
int main()
{
    FAST
    FO
    FI
    int a[32]= {1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51};
    int k;
    IN k;
    k--;
    OUT a[k];
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define rep2(i,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define uni(e) e.erase(unique(e.begin(),e.end()),e.end())
#define double long double
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; }
int INF=1e10;
int MOD=1e9+7;
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
}
int kurai(int a,int b){
  int m=pow(10,b),n=pow(10,b-1);
  return (a%m)/n;
}
int ketawa(int a){
  int k=0;
  rep(i,keta(a)){
  k+=kurai(a,i+1);
  }
  return k;
}
int gcd(int a,int b){
  if(a%b==0)
    return b;
  return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
int mid(int a,int b,int c){
  vector<int> k(3);
  k[0]=a;k[1]=b;k[2]=c;
  sort(all(k));
  return k[1];
}
bool sosuu(int a){
  bool b=1;
  if(a<=1)
    return 0;
  else{
  rep1(i,sqrt(a)-1){
  if(a%(i+1)==0)
  b=0;
  }
  return b;
  }
}
int modpow(int a,int b,int m=MOD){
	if(!b)return 1;	if(b&1)return modpow(a,b-1,m)*a%m;
	int memo = modpow(a,b>>1,m);
	return memo*memo%m;
}
int fact_mod(int n) {
    int f=1; 
for(int i=2;i<n+1;i++) f=f*(i%MOD)% MOD;
    return f;
}
int mod_pow(int x,int n) {
    int res=1;
    while(n>0){
        if(n&1) res=(res*x)%MOD; 
        x=(x*x)%MOD;        
n>>=1; 
    }
    return res;
}
int c_mod(int n, int r) {
    if(r>n-r) r=n-r;
    if(r==0) return 1;
    int a=1;
    rep(i,r) 
a=a*((n-i)%MOD)%MOD;
    int b=mod_pow(fact_mod(r), MOD-2);
    return (a%MOD)*(b%MOD)%MOD;
}
signed main(){
  int a;
  cin>>a;
  vector<int> b(a),c(1000010,0);
  rep(i,a)
    cin>>b[i];
  rep(i,a){
  c[b[i]]+=1;
  }
  if(c[1]==0){
  int d=0;
  rep(i,a){
  int e=1;
  rep(j,sqrt(b[i])+0.1){
    if(j==0){
    if(c[b[i]]>1){
    e=0;
      break;
    }
      
    }
    else{
      if(b[i]!=2&&b[i]!=3){
  if(b[i]%(j+1)==0){
  if((c[j+1])||(c[b[i]/(j+1)])){
  e=0;
    break;
    }
  }
        }
      }
  }
    d+=e;
  }
  out(d);
    }
  else if(c[1]==1)
    out(1);
  else
    out(0);
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

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

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int N, K; cin >> N >> K;
    vector<int> A(N);
    REP(i, N) {
        cin >> A[i];
    }
    SORT(A);
    int ans = 0;
    REP(i, K) {
        ans += A[i];
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3656
#include "bits/stdc++.h"
using namespace std;
void solve(){
    string s;
    cin >> s;
    bool a = true;
    bool c = false;
    bool small = true;
    if(s.at(0) != 'A')
    a = false;    
    for(int i = 1; i < s.size(); i++){
        if(s.at(i) >= 'A' && s.at(i) <= 'Z'){    //大文字の時
            if(small){//小文字以外がないとき
                small = false;  //大文字があったのでsmall→false
                if(s.at(i) == 'C' && c == false && i != s.size() - 1 && i != 1){//1回目のC
                c = true;
                small = true;
                }
            }
        }
    }
    if(a && c && small)
    cout << "AC" << endl;
    else 
    cout << "WA" << endl;
}
int main(){
    solve();
    return 0;
}

Measured memory_bytes: 256
from sys import stdin, setrecursionlimit
input = stdin.buffer.readline

N = int(input())
A = list(map(int, input().split()))

max_A = max(A)
if max_A == 1:
    print("pairwise coprime")
    exit()

class Prime:
    def __init__(self, n):
        self.prime_factor = [i for i in range(n + 1)]
        self.prime = []
        for i in range(2, n + 1):
            if self.prime_factor[i] == i:
                for j in range(2, n // i + 1):
                    self.prime_factor[i * j] = i
                self.prime.append(i)
        #print(self.prime_factor)
        #print(self.prime)
    def factorize(self, m):
        ret = []
        while m != 1:
            if not ret:
                ret = [[self.prime_factor[m], 1]]
            elif self.prime_factor[m] == ret[-1][0]:
                ret[-1][1] += 1
            else:
                ret.append([self.prime_factor[m], 1])
            m //= self.prime_factor[m]
        return ret
    def divisors(self, m):
        ret = []
        for i in range(1, int(m ** 0.5) + 1):
            if m % i == 0:
                ret.append(i)
                if i != m // i:
                    ret.append(m // i)
        #self.divisors.sort()
        return ret
pm = Prime(max_A)

def is_pairwise_coprime(arr):
    cnt = [0] * (max_A + 1)
    for a in arr:
        for b, c in pm.factorize(a):
            cnt[b] += 1
    if max(cnt[2:]) <= 1:
        return 1
    else:
        return 0

def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

def is_setwise_coprime(A):
    gcd_a = 0
    for a in A:
        gcd_a = gcd(gcd_a, a)
    if gcd_a == 1:
        return 1
    else:
        return 0

if is_pairwise_coprime(A):
    print("pairwise coprime")
elif is_setwise_coprime(A):
    print("setwise coprime")
else:
    print("not coprime")

Measured memory_bytes: 214920
#include <bits/stdc++.h>
using namespace std;
template <typename A, typename B>
string to_string(pair<A, B> p);
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
string to_string(const string& s) {
  return '"' + s + '"';
}
string to_string(const char* s) {
  return to_string((string) s);
}
string to_string(bool b) {
  return (b ? "true" : "false");
}
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define dbg(...) cout << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif
const long long mod = 1e9+7; // CHECK
long long power(long long a, long long b, long long m = mod) {
    if(b < 0) {
        return power(power(a, -b), mod-2);
    }
    long long x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}
#define ll long long
const int INT_INF = 1e9+9;
const ll LL_INF = 2e18;
const int N = 3e5+9; // check N, mod

signed main() {  
    ios_base::sync_with_stdio(false); 
    cin.tie(0); cout.tie(0);
    
    int n; cin >> n;
    vector<int> a(n);
    map<int, int> freq;
    int ans = 0;
    multiset<int> ss;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        ss.insert(a[i]);
    }
    while (ss.size() > 1) {
        int t = *--ss.end();
        ss.erase(--ss.end());
        int u = (1<<(1+__lg(t))) - t;
        if (ss.count(u)) {
            ss.erase(ss.find(u));
            ans++;
        }
    }
    cout << ans << endl;
    



    

    

    return 0;
}



Measured memory_bytes: 13500
n = int(input())
p = list(map(int, input().split()))

answer = 0

for i in range(n-2):
    if p[i] < p[i+1] and p[i+1] < p[i+2]:
        answer = answer + 1
    elif p[i] > p[i+1] and p[i+1] > p[i+2]:
        answer = answer + 1
print(answer)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using ull = unsigned long long;
using vl = vector<ll>;
using vi = vector<int>;
using vchar = vector<char>;
using vstr = vector<string>;
using pll =  pair<ll,ll>;

const ll mod = 1000000007;
const ll inf = 1000000000000000;

#define pi acos(-1)
#define pb push_back
#define test int TEST;cin>>TEST;while(TEST--)
#define vsort(xx) sort(xx.begin(),xx.end())
#define vrevsort(xx) sort(xx.rbegin(),xx.rend())


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    int n,i;cin>>n;
    int m;cin>>m;
    int a[n];
    long double sum=0;
    for(i=0;i<n;i++){
        cin>>a[i];sum+=a[i];
    }
    sum=sum/(4*m);
    int val=0;
    for(i=0;i<n;i++){
        if(!(a[i]<sum)) val++;
    }
    (val<m)?cout<<"No":cout<<"Yes";
    
   
    return 0;
}




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

class Star {
public:
    int x;
    int y;
    Star(int _x, int _y): x(_x), y(_y) {};
    bool operator> (const Star& p) const { return x > p.x; }
    bool operator== (const Star& p) const { return x == p.x; }
    inline bool operator<(const Star& p) const { return !(*this > p || *this == p); }
    inline bool operator>=(const Star& p) const { return *this > p || *this == p; }
    inline bool operator<=(const Star& p) const { return !(*this > p); }
    inline bool operator!=(const Star& p) const { return !(*this == p); }
};
int main() {
    string line;
    int m, n;
    vector<Star> constellation;
    vector<Star> stars;
    while (cin >> m && m) {
        int i, j, k;
        int x, y;
        constellation.clear();
        stars.clear();
        for (i = 0; i < m; ++i) {
            cin >> x >> y;
            Star star(x, y);
            constellation.push_back(star);
        }
        cin >> n;
        for (i = 0; i < n; ++i) {
            cin >> x >> y;
            Star star(x, y);
            stars.push_back(star);
        }
        sort(constellation.begin(), constellation.end());
        sort(stars.begin(), stars.end());
        bool notFound = true;
        for (i = 0; i < stars.size() && notFound; ++i) {
            // stars[i]????????§???1??????????????¨??????
            int dx = stars[i].x - constellation[0].x;
            int dy = stars[i].y - constellation[0].y;
            k = 1;
            for (j = i; j < stars.size(); ++j) {
                if (stars[j].x == constellation[k].x + dx) {
                    // ?????§???k??????????????¨stars[j]?????????
                    if (stars[j].y == constellation[k].y + dy) {
                        k++;
                        if (k == constellation.size()) {
                            // ?????´??????
                            cout << dx << " " << dy << endl;
                            notFound = false;
                            break;
                        }
                    }
                } else if (stars[j].x > constellation[k].x + dx) {
                    // 1????????????????????????????????????
                    break;
                }
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

namespace AtCoder.A
{
    public class Program
    {
        public static void Main() { var r = GetResult(); Debug.WriteLine(r); Console.Write(r); }

        private static object GetResult()
        {
            var x = ReadLong();
            if(x == 1) { return 0; }
            return 1;
        }

        #region Console.Read

        public static string ReadText() { return Console.ReadLine(); }
        public static List<string> ReadTexts() { return Console.ReadLine().Split(' ').ToList(); }
        public static long ReadLong() { return long.Parse(Console.ReadLine()); }
        public static (long, long) Read2Longs() { var ls = ReadLongs(); return (ls[0], ls[1]); }
        public static (long, long, long) Read3Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2]); }
        public static (long, long, long, long) Read4Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3]); }
        public static (long, long, long, long, long) Read5Longs() { var ls = ReadLongs(); return (ls[0], ls[1], ls[2], ls[3], ls[4]); }
        public static List<long> ReadLongs() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList(); }

        #endregion
    }
}


Measured memory_bytes: 27480
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
using Pair = pair<int64_t, int64_t>;

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

  int32_t N, M, C;
  cin >> N >> M >> C;
  int32_t count = 0;
  vector<int32_t> B(M);
  for (int32_t j = 0; j < M; ++j) {
    cin >> B[j];
  }
  for (int32_t i = 0; i < N; ++i) {
    int32_t sum = C;
    for (int32_t j = 0; j < M; ++j) {
      int32_t a;
      cin >> a;
      sum += a * B[j];
    }
    if (sum > 0) {
      ++count;
    }
  }
  cout << count << endl;
  return 0;
}


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

namespace G
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        static bool[] used;
        static List<int> nodes;
        static List<int>[] graph;

        public static void Solve()
        {
            var NM = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (N, M) = (NM[0], NM[1]);

            graph = new List<int>[N].Select(x => new List<int>()).ToArray();
            for (var i = 0; i < M; i++)
            {
                var ab = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
                var a = ab[0] - 1;
                var b = ab[1] - 1;
                graph[a].Add(b);
            }

            used = new bool[N];
            nodes = new List<int>();

            for (var i = 0; i < N; i++)
            {
                Dfs(i);
            }

            var answer = 0;
            var dp = new int[N];
            foreach (var u in nodes)
            {
                foreach (var v in graph[u])
                {
                    dp[u] = Math.Max(dp[u], dp[v] + 1);
                }
                answer = Math.Max(answer, dp[u]);
            }

            Console.WriteLine(answer);
        }

        private static void Dfs(int u)
        {
            if (used[u]) return;
            used[u] = true;
            foreach (var v in graph[u])
            {
                Dfs(v);
            }
            nodes.Add(u);
        }
    }
}


Measured memory_bytes: 57516
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  map<string, ll> M;
  REP(i, N) {
    string s;
    cin >> s;
    sort(ALL(s));
    if (M.find(s) == M.end())
      M[s] = 1;
    else
      M[s]++;
  }
  ll ans = 0;
  AUTO(m, M) {
    if (m.second == 1)
      continue;
    else {
      ans += (m.second * (m.second - 1)) / 2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

long long n;

int f(long long x, int m) {
    if (x > n) return 0;
    return f(x * 10 + 3, m | 1 << 0) + f(x * 10 + 5, m | 1 << 1) + f(x * 10 + 7, m | 1 << 2) + (m == 7);
}

int main() {
    cin >> n;
    cout << f(0, 0) << endl;
}

Measured memory_bytes: 256
import math

A, B, H, M = map(int, input().split())

hangle = 2*math.pi/360*(H*30+M/2)
mangle = 2*math.pi/360*M*6

hx = A*math.cos(hangle)
hy = A*math.sin(hangle)
mx = B*math.cos(mangle)
my = B*math.sin(mangle)

dx = hx-mx
dy = hy-my
d2 = dx*dx+dy*dy
d = d2**0.5
print(d)


Measured memory_bytes: 9576
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<deque>
#include<queue>

using std::cout;
using std::cin;
using std::setw;
using std::setfill;
using std::string;
using std::pair;
using std::vector;
using std::queue;
using std::deque;
using std::priority_queue;
using std::next_permutation;
//using std::iota;
using std::sort;
using std::greater;
using std::max;
using std::min;

using lli = long long int;
using ulli = unsigned long long int;

#define INF 999999999;

//#define EVEL 1

#ifndef EVEL
#define dbug(X) std::cout << #X << ":" <<X<<" " ;
#define dbugf(s) std::cout << s << " ";
#define dbugln std::cout<<"\n";
#else
#define dbug(X) {}
#define dbugf(s) {}
#define dbugln {}
#endif

lli A, B, C;

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

	cin >> A >> B >> C;
	if(A == B)cout << C;
	else if(B == C) cout << A;
	else cout << B;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
const Int MAX = 305;
const Int MAX2 = MAX*2;
signed ex[MAX2][MAX2];
signed dp[MAX2+2][MAX2+2];
signed main(){
  Int h,w;
  cin>>h>>w;
  vector<string> s(h);
  for(Int i=0;i<h;i++) cin>>s[i];

  using P = pair<Int, Int>;
  vector<P> vp;
  memset(ex,0,sizeof(ex));
  for(Int i=0;i<h;i++){
    for(Int j=0;j<w;j++){
      if(s[i][j]!='#') continue;
      vp.emplace_back(1+i+j,1+i-j+w);
      ex[1+i+j][1+i-j+w]=1;      
    }
  }
  
  auto ch=
    [&](Int i,Int j)->Int{
      if(i<0||i>=MAX2) return 0;
      if(j<0||j>=MAX2) return 0;
      return ex[i][j];
    };
  
  memset(dp,0,sizeof(dp));
  Int ans=0;
  
  const Int LIM = h+w;
  for(Int k=1;k<=LIM;k++){
    for(Int i=0;i<MAX2;i++)
      for(Int j=0;j<MAX2;j++)
        dp[i][j+1]=dp[i][j]+(ex[i][j]&&ch(i,j-k));

    for(P p:vp){
      Int i,j;
      tie(i,j)=p;
      if(i-k>=0)  ans+=dp[i-k][min(MAX2-1,j+k+1)]-dp[i-k][j];
      if(i+k<MAX2) ans+=dp[i+k][min(MAX2-1,j+k+1)]-dp[i+k][j];
    }

    for(Int j=0;j<MAX2;j++)
      for(Int i=0;i<MAX2;i++)
        dp[j][i+1]=dp[j][i]+(ex[i][j]&&ch(i-k,j));
    
    for(P p:vp){
      Int i,j;
      tie(i,j)=p;
      if(j-k>=0)  ans+=dp[j-k][min(MAX2-1,i+k+1)]-dp[j-k][i];
      if(j+k<MAX2) ans+=dp[j+k][min(MAX2-1,i+k+1)]-dp[j+k][i];   
    }            
  }

  //cout<<ans<<endl;
  for(P p:vp){
    Int i,j;
    tie(i,j)=p;
    for(Int k=1;k<=LIM;k++){
      if(ch(i+k,j)&&ch(i,j+k)) ans--;
      if(ch(i+k,j)&&ch(i,j-k)) ans--;
      if(ch(i-k,j)&&ch(i,j+k)) ans--;
      if(ch(i-k,j)&&ch(i,j-k)) ans--;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4980
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;
typedef long long ll;

ll C[55][55];

void initC()
{
  C[0][0] = 1;
  for( int i=1; i<=50; i++ ){
    C[i][0] = 1;
    C[i][i] = 1;
    for( int j=1; j<i; j++ ){
      C[i][j] = C[i-1][j-1] + C[i-1][j];
    }
  }
}

int main()
{
  ios::sync_with_stdio(false);
  int A, B, N;
  cin >> N >> A >> B;
  map<ll,int> m;
  for( int i=0; i<N; i++ ){
    ll v;
    cin >> v;
    m[v]++;
  }
  initC();
  int first = 1;
  int c = 0;
  ll ret = 0;
  ll sum = 0;
  double retv;
  for( map<ll,int>::reverse_iterator it=m.rbegin(); it!=m.rend(); ++it ){
    if( first ){
      if( it->second >= A ){
        for( int i=A; i<=min( it->second, B ); i++ ){
          ret += C[ it->second ][ i ];
        }
        retv = it->first;
        break;
      }
      c = it->second;
      sum = it->first * it->second;
      first = 0;
      continue;
    }
    if( c + it->second >= A ){
      ret = C[ it->second ][ A - c ];
      sum += it->first * ( A - c );
      retv = ((double)sum) / A;
      break;
    }
    c += it->second;
    sum += it->first * it->second;
  }
  printf( "%.12f\n", retv );
  printf( "%lld\n", ret );
}

Measured memory_bytes: 256
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cstring>

#define fi first
#define se second
#define mp(x, y) std::make_pair(x, y)

typedef long long ll;
const int maxn = 55;
const int maxm = 105;
const ll INF = 0x3f3f3f3f3f3f3f3f;

int n, m;
int first[maxn], tot;
ll maxs, s;
ll c[maxn], t[maxn];
ll dp[maxn][maxm * 50];
bool inque[maxn][maxm * 50];
std::queue<std::pair<int, ll> > q;
struct Edge {
	int to, next;
	ll sil, tim;
} e[maxm * 2];

void Add(int x, int y, ll a, ll b)
{
	e[++tot] = { y, first[x], a, b };
	first[x] = tot;
}

int main() {
	memset(dp, 0x3f, sizeof dp);
	
	scanf("%d%d%lld", &n, &m, &s);
	for(int i = 1; i <= m; ++i) {
		int x, y;
		ll a, b;
		
		scanf("%d%d%lld%lld", &x, &y, &a, &b);
		Add(x, y, a, b), Add(y, x, a, b);
	}
	
	maxs = 50 * m, s = std::min(s, maxs);
	for(int i = 1; i <= n; ++i)
		scanf("%lld%lld", &c[i], &t[i]);
	
	dp[1][s] = 0, q.push(mp(1, s)), inque[1][s] = 1;
	while(!q.empty()) {
		std::pair<int, ll> u = q.front();
		inque[u.fi][u.se] = 0, q.pop();
		
		int to = std::min(u.se + c[u.fi], maxs);
		if(dp[u.fi][to] > dp[u.fi][u.se] + t[u.fi]) {
			dp[u.fi][to] = dp[u.fi][u.se] + t[u.fi];
			if(!inque[u.fi][to])
				q.push(mp(u.fi, to)), inque[u.fi][to] = 1;
		}
		
		for(int i = first[u.fi]; i; i = e[i].next) {
			int v = e[i].to;
			if(u.se >= e[i].sil && dp[v][u.se - e[i].sil] > dp[u.fi][u.se] + e[i].tim) {
				dp[v][u.se - e[i].sil] = dp[u.fi][u.se] + e[i].tim;
				if(!inque[v][u.se - e[i].sil])
					q.push(mp(v, u.se - e[i].sil)), inque[v][u.se - e[i].sil] = 1;
			}
		}
	}
	
	for(int i = 2; i <= n; ++i) {
		ll ans = INF;
		for(int j = 0; j <= maxs; ++j)
			ans = std::min(ans, dp[i][j]);
		printf("%lld\n", ans);
	}
}

Measured memory_bytes: 6504
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <string>


int main(void){
    int a,b,c,max,d;
scanf("%d %d %d",&a,&b,&c);
  max = a;
  if( max < b ) {
    max = b;
    d=a+c;
  }
  else if( max < c ) {
    max = c;
    d=a+b;
  }
  else{d=b+c;}

  printf("%d",max*10 + d );
}

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

#define rep(a,b) for(int a = 0;a < b;a++)
#define REP(i, x, n) for(int i = x; i < n; i++)
#define P(a) cout << a << endl
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define ssort(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define vP(v) for(int i = 0;i < v.size();i++){cout << v[i];if(i != v.size()-1)cout << endl;}
#define vcin(v,n) rep(i,n){int a;cin >> a;v.pb(a);}

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int dx[] = { 1, -1 , 0 , 0 };
int dy[] = { 0,  0,  1, -1 };
ll MOD = 1000000007;

void solve(){
	int r,g;
	cin >> r >> g;
	P(g*2 - r);
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

int main (void) {
    int n, k;
    cin >> n >> k;

    double ans = 0;
    double ans_;
    int score;
    for ( int init = 1; init <= n; init++ ) {
        ans_ = 1.0 / n;
        score = init;
        while ( score < k ) {
            score *= 2;
            ans_ /= 2;
        }
        ans += ans_;
    }

    printf("%.10lf\n", ans);
    return 0;
}


Measured memory_bytes: 3720
// Header {{{
#include <bits/stdc++.h>

using namespace std;
template<typename T>
using reversed_priority_queue = std::priority_queue<T, std::vector<T>, std::greater<T> >;
typedef unsigned long long int ull;
typedef long long int ll;
#define rep(i,a,b) for (ll i=(a); i<(b); i++)
typedef pair<ll,ll> PLL;
// }}}

ll gcd(ll x, ll y) {
    if (x>y)
        return gcd(y,x);
    else if (x<=0)
        return y;
    else
        return gcd(y%x,x);
}

signed main() {
    ll n,x;
    cin>>n>>x;
    vector<ll> v(n);
    rep(i,0,n) cin>>v[i];
    ll ans=abs(v[0]-x);
    rep(i,0,n-1){
        ans = gcd(ans, abs(v[i]-v[i+1]));
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 1024