akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>

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

typedef int long long ll;
using namespace std;
typedef pair<int, int> P;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const ll MOD = 1e9 + 7;
static const int MAX = 100;
static const int INF = (1 << 23);



int main() {
    ll n;
    cin>>n;
    vector<ll> k[n+1];
    rep(i,n-1){

        ll a,b;
        cin>>a>>b;
        k[a].push_back(b);
        k[b].push_back(a);

    }

    vector<ll> v(n);
    rep(i,n){cin>>v[i];}
    sort(v.begin(),v.end());//cost 0 n-1
    ll sum=0;

    for(int i=0;i<n-1;i++)sum+=v[i];
    queue<ll> q;
    vector<ll> ans(n);

    int nodes[n+1];
    rep(i,n+1)nodes[i]=0;
    for(ll i=1;i<=n;i++){
        if(k[i].size()==1){q.push(i);}
        nodes[i]=k[i].size();
    }
    int j=0;
    bool al[n+1];rep(i,n+1)al[i]=false;

    while(!q.empty()){


        int h=q.front();
        //cout<<h<<endl;
        q.pop();
        if(al[h]==false) {
            ans[h-1] = v[j];
            j++;
            al[h]=true;
            nodes[h]=0;

            rep(i,k[h].size()){
                int g=k[h][i];
                nodes[g]--;
                if(nodes[g]==1){
                    q.push(g);

//                if(al[k[h][i]]==false){
//                q.push(k[h][i]);
                }
            }
        }

    }
    cout<<sum<<endl;
    rep(i,n)cout<<ans[i]<<" ";




    return 0;
}


Measured memory_bytes: 1280
import sys, math
from collections import defaultdict, deque, Counter
from bisect import bisect_left, bisect_right
from itertools import combinations, permutations, product
from heapq import heappush, heappop
from functools import lru_cache
input = sys.stdin.readline
rs = lambda: input().strip()
ri = lambda: int(input())
rl = lambda: list(map(int, input().split()))
mat = lambda x, y, v: [[v]*y for _ in range(x)]
ten = lambda x, y, z, v: [mat(y, z, v) for _ in range(x)]
mod = 1000000007
sys.setrecursionlimit(1000000)

N, K = rl()
A = rl()

def is_ok(x):
	s = 0
	for a in A:
		s += math.ceil(a / x)-1
	return s <= K

l, r = 0, 10**9
while r-l > 1:
	m = (r+l)//2
	if is_ok(m):
		r = m
	else:
		l = m
print(r)


Measured memory_bytes: 103232
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
string s;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>s;
    int cnt=1;
    for(int i=0;i<s.size();i++){
        if(cnt&1){
            if(s[i]=='L'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        else{
            if(s[i]=='R'){
                cout<<"No"<<endl;
                return 0;
            }
        }
        cnt++;
    }
    cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
class Heap
  attr_reader :size
  def initialize(up: false)
    @up = up
    @heap = []
    @size = 0
  end
  def sum
    x = 0
    @size.times do |i|
      x += @heap[i]
    end
    x
  end
  def push(n)
    n = -n if @up
    i = @size
    while i > 0
      pid = (i - 1) / 2
      break if n >= @heap[pid]
      @heap[i] = @heap[pid]
      i = pid
    end
    @heap[i] = n
    @size += 1
  end
  def pop
    return nil if @size == 0
    top = @heap[0]
    @size -= 1
    n = @heap[@size]
    i = 0
    while i * 2 + 1 < @size
      cid1 = i * 2 + 1
      cid2 = cid1 + 1
      if cid2 < @size && @heap[cid2] < @heap[cid1]
        cid1 = cid2
      end
      break if @heap[cid1] >= n
      @heap[i] = @heap[cid1]
      i = cid1
    end
    @heap[i] = n
    if @up
      -top
    else
      top
    end
  end
end

gets
a = gets.split.map(&:to_i)
h = Heap.new(up: true)
a.each do |x|
  h.push(x)
end
while h.size > 1
  u = h.pop
  v = h.pop
  h.push(u - 1) if u - 1 > 0
  h.push(v - 1) if v - 1 > 0
end
if h.size == 0
  puts "0"
else
  puts h.pop - 1
end

Measured memory_bytes: 1788
#include <iostream>

int main(int argc, char** argv)
{
	int a, b, c;
	std::cin >> a >> b >> c;

	int count = 0;
	for (int i = a; i <= b; ++i)
	{
		if (c % i == 0)
		{
			++count;
		}
	}

	std::cout << count << std::endl;

	return 0;
}


Measured memory_bytes: 3096
#include <cstdio>
#include <iostream>
#include <cstring>
#define maxn 2000005
using namespace std;
int Far[maxn],dis[maxn];
void inti(int n){
    for(int i=0;i<=n;i++){
        Far[i]=i;
        dis[i]=0;
    }
}
int find_F(int x){
    if(Far[x]==x) return x;
    int tmp=Far[x];
    Far[x]=find_F(Far[x]);
    dis[x]+=dis[tmp];
    return Far[x];
}
int find_D(int x){
    if(Far[x]==x) return 0;
    else return find_D(Far[x])+dis[x];
}
int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    inti(n);
    for(int i=0;i<m;i++){
        int a,b,c;
        scanf("%d%d%d",&a,&b,&c);
        int Fa=find_F(a);
        int Fb=find_F(b);
        if(Fa==Fb){
            if(dis[b]-dis[a]!=c){
                puts("No");
                return 0;
            }
        }
        else{
            Far[Fb]=Fa;
            dis[Fb]=find_D(a)-find_D(b)+c;
        }
    }
    puts("Yes");
}


Measured memory_bytes: 4864
n = int(raw_input())
nums = map(int, raw_input().split())

swaps = 0
i = 0

while i < n:
    if nums[i] == i + 1:
        swaps += 1
        if i + 1 == n:
            nums[i], nums[i-1] = nums[i-1], nums[i]
        else:
            nums[i], nums[i+1] = nums[i+1], nums[i]

        i += 1
            
    i += 1
    
print swaps


Measured memory_bytes: 42604
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef double lf;
typedef pair<ll,ll> ii;
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define RST(i,n) memset(i,n,sizeof i)
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define X first
#define Y second
#define mkp make_pair
#define pb push_back
#define eb emplace_back
#define pob pop_back
#ifdef cold66
#define debug(...) do{\
    fprintf(stderr,"%s - %d (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
    _do(__VA_ARGS__);\
}while(0)
template<typename T>void _do(T &&_x){cerr<<_x<<endl;}
template<typename T,typename ...S> void _do(T &&_x,S &&..._t){cerr<<_x<<", ";_do(_t...);}
template<typename _a,typename _b> ostream& operator << (ostream &_s,const pair<_a,_b> &_p){return _s<<"("<<_p.X<<","<<_p.Y<<")";}
template<typename It> ostream& _OUTC(ostream &_s,It _ita,It _itb)
{
    _s<<"{";
    for(It _it=_ita;_it!=_itb;_it++)
    {
        _s<<(_it==_ita?"":",")<<*_it;
    }
    _s<<"}";
    return _s;
}
template<typename _a> ostream &operator << (ostream &_s,vector<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a> ostream &operator << (ostream &_s,set<_a> &_c){return _OUTC(_s,ALL(_c));}
template<typename _a,typename _b> ostream &operator << (ostream &_s,map<_a,_b> &_c){return _OUTC(_s,ALL(_c));}
template<typename _t> void pary(_t _a,_t _b){_OUTC(cerr,_a,_b);cerr<<endl;}
#define IOS()
#else
#define debug(...)
#define pary(...)
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#endif // cold66
//}
template<class T> inline bool chkmax(T &a, const T &b) { return b > a ? a = b, true : false; }
template<class T> inline bool chkmin(T &a, const T &b) { return b < a ? a = b, true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;

const ll MAXn=1e5+5,MAXlg=__lg(MAXn)+2;
const ll MOD=1000000007;
const ll INF=0x3f3f3f3f;

int main(){
  IOS();
  string s;
  cin>>s;
  int k;
  cin>>k;
  vector<string> dt;
  REP(i,SZ(s)){
    for(int j=1;j<=5;j++){
      if( i+j-1>=SZ(s) ) break;
      dt.eb(s.substr(i,j));
    }
  }
  debug(dt);
  sort(ALL(dt));
  dt.resize(unique(ALL(dt))-dt.begin());
  cout<<dt[k-1]<<endl;
}


Measured memory_bytes: 1660
#include <iostream>
#include <sstream>
#include <cmath>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <set>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <queue>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ul;
typedef pair<int,int> P;
#define X first
#define Y second

void go() {
	int n,y;
	cin >> n >> y;
	y /= 1000;
	int c = y-n;
	int u,v,w;
	u = v = w = -1;
	for(int i = 0; i*9<=c; i++) {
		if((c-i*9)%4==0 && i+(c-i*9)/4<=n) {
			u = i;
			v = (c-9*u)/4;
			w = n - u - v;
			break;
		}
	}
	cout << u << " " << v << " " << w << endl;
}

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	// int t; cin >> t; for(;t--;)
	go();
	return 0;
}



Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever while (true)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
using namespace std;
// clang-format on

using Weight = int;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(const int &s = 0, const int &d = 0, const Weight &w = 0) : src(s), dst(d), weight(w) {}
};

using Edges = std::vector<Edge>;
using Array = std::vector<Weight>;
using Matrix = std::vector<Array>;

class Graph {
  std::vector<Edges> g;

public:
  Graph(const int &size = 0) : g(size) {}

  void addArc(const int &src, const int &dst, const Weight &w = 1) { g[src].emplace_back(src, dst, w); }

  void addEdge(const int &node1, const int &node2, const Weight &w = 1) {
    addArc(node1, node2, w);
    addArc(node2, node1, w);
  }

  const Edges &operator[](const int &i) const { return g[i]; }

  Graph toRootedTree(int r);
  std::pair<std::vector<Weight>, std::vector<int>> dijkstra(const int &src, const int &inf);
  Matrix warshallFloyd(const int &inf);
  std::pair<Weight, Edges> prim(const int &r);
  template<typename UnionFind> std::pair<Weight, Edges> kruskal();
  Weight solveTSP(const int &inf);
};

std::pair<std::vector<Weight>, std::vector<int>> Graph::dijkstra(const int &src, const int &inf = std::numeric_limits<Weight>::max() / 8) {
  using state = std::pair<Weight, int>;
  std::priority_queue<state, std::vector<state>, std::greater<state>> q;
  std::vector<Weight> dist(g.size(), inf);
  std::vector<int> via(g.size());
  dist[src] = 0;
  q.emplace(0, src);
  while (q.size()) {
    Weight d;
    int v;
    std::tie(d, v) = q.top();
    q.pop();
    if (dist[v] < d) continue;
    for (auto &e : g[v]) {
      if (cmin(dist[e.dst], dist[v] + e.weight)) {
        via[e.dst] = v;
        q.emplace(dist[e.dst], e.dst);
      }
    }
  }
  return {dist, via};
}

main {
  int n;
  cin >> n;
  Graph g(n);
  rep(_, n) {
    int u, k;
    cin >> u >> k;
    while (k--) {
      int v, c;
      cin >> v >> c;
      g.addArc(u, v, c);
    }
  }
  vi d = g.dijkstra(0).first;
  rep(i, n) cout << i << ' ' << d[i] << endl;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
#define int long long
int32_t main() {
   int t=1;
  // cin>>t;
   while(t--)
   {
    int n,k,i,p,q,ans=0;
    cin>>n;
    if(n>=30)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
   }
}


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

int main() {
  string s, t;
  cin >> s >> t;
  bool b = 0;
  if(s.size() > t.size()) cout << "GREATER" << endl;
  else if(s.size() < t.size()) cout << "LESS" << endl;
  else{
    rep(i, s.size()){
      b = 1;
      if(s[i] > t[i]){
        cout << "GREATER" << endl;
        b = 0;
        break;
      }
      else if(s[i] < t[i]){
        cout << "LESS" << endl;
        b = 0;
        break;
      }
    }
    if(b) cout << "EQUAL" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define SUM(a)  accumulate((a).begin(),(a).end(),0)
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
typedef long long ll;
const int INTINF = 1<<29;
const ll LLINF = 1LL<<61;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
const int DX[8]={ 0, 1, 0,-1, 1, 1,-1,-1};
const int DY[8]={ 1, 0,-1, 0, 1,-1, 1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  bool ok = false;
  REP(i,2){
      if (S[i]=='9')ok =true;
  }
  if (ok)cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

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

	int n, N[50];
	N[0] = N[1] = 1;
	cin >> n;

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

	cout << N[n]<<endl;
	return 0;
}


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

using namespace std;

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

typedef long long ll;
typedef vector<int> VI;

#define MAX_V 1010

vector<int> G[MAX_V];
int match[MAX_V];
bool used[MAX_V];

void add_edge(int u, int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v] = true;
  rep(i,G[v].size()){
    int u = G[v][i], w = match[u];
    if(w < 0 || (!used[w] && dfs(w)) ){
      match[v] = u;
      match[u] = v;
      return true;
    }
  }
  return false;
}

int m,n;
int bipartie_matching(){
  int V = n+m;
  int res = 0;
  memset(match, -1, sizeof(match));

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

long long gcd( long long m, long long n ){
    if ( n == 0) return m;
    return gcd(n,m%n);
}//最大公約数

int main(){
  while(true){

    cin >> m >> n;
    if(m == 0 && n == 0) break;
    VI b(m),r(n);
    rep(i,m) cin >> b[i];
    rep(i,n) cin >> r[i];

    rep(i,m)rep(j,n){
      if( gcd(b[i],r[j]) > 1 ){
        add_edge(i,j+m);
      }
    }

    int ans = bipartie_matching();
    cout << ans << "\n";
    rep(i,MAX_V) G[i].clear();
    memset(used,false,sizeof(used));
  }
}



Measured memory_bytes: 4972
#include <iostream>

using namespace std;

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

    int sum=1,keep=0; //保存
    for(int i=1;i<N;i++){
        
        if(sum<N) {
            keep=sum;
            sum=i*i;
        }
        if(sum>N) {
            cout<<keep<<endl;
            return 0;
        }
    }

    cout<<sum<<endl;

    return 0;
}

Measured memory_bytes: 256
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
#define pb push_back
#define F first
#define S second
#define ins insert
#define mp make_pair
#define fo(i, n1, n, x) for(int i = n1; i <= n; i += x)
#define foo(i, n, n1, x) for(int i = n; i >= n1; i -= x)
#define bit __builtin_popcount
#define md (l + ((r - l) / 2))
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define ub upper_bound
#define lb lower_bound
#define ios ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define file(s) if (fopen(s".in", "r")) freopen(s".in", "r", stdin), freopen(s".out", "w", stdout)

using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;


using ll = long long;

//#define int ll

using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vi = vector<int>;



const int N = 2e5 + 11, mod = 1e9 + 7, mod2 = 998244353;
const int MAX = 1e5 + 11;
const int INF1 = 2e9 + 11;
const ll INF2 = 6e18 + 11;
const double INF3 = 1e8 + 11;
const int base = 500;
const int P = 31;
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};
const double EPS = 1e-4;
const double PI = acos(-1.0);


//template<typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>;
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; }


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


main() {
  file("threesum");
  ios;
  int a, b;
  cin >> a >> b;
  cout << a * b;
  return 0;
}
/**

*/


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll x;
    cin>>x;
    ll ans=2*(x/11);
    if(x%11>6) ans+=2;
    else if(x%11>0) ans+=1;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const long long LINF = 1000000000000000018ll;
const int INF = 1000000009;
const int mod = 1000000007;

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

  string s; cin >> s;
  int n = s.length();
  for (int i = 0; i < n; i++) {
    int a = i + 1;
    int b = i + 2;
    if (a < n && s[i] == s[a]) {
      cout << i+1 << " " << a+1 << endl;
      return 0;
    }
    if (b < n && s[i] == s[b]) {
      cout << i+1 << " " << b+1 << endl;
      return 0;
    }
  }
  cout << -1 << " " << -1 << endl;
  return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
ll MOD = 1e9+7;

#define vec     vector<int>
#define vecll   vector<ll>
#define vec2    vector<vector<int>>
#define vec2ll  vector<vector<ll>>
#define vpair   vector<pair<int, int>>
#define vpairll vector<pair<ll, ll>>
#define vecst   vector<string>
#define vecb    vector<bool>

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define f_sum(var)       accumulate(all(var), 0)
#define f_sumll(var)     accumulate(all(var), 0LL)
#define chmin(v1, v2)    v1 = min(v1, v2)
#define chmax(v1, v2)    v1 = max(v1, v2)
#define mpair(v1, v2)    make_pair(v1, v2)
#define pb(var)          push_back(var)
#define prt(var)         cout << var << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << var << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << var;
#define prt2(v1, v2)     cout << v1 << " " << v2 << "\n"
#define prt3(v1, v2, v3) cout << v1 << " " << v2 << " " << v3 << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
void prtok(bool ok){prt((ok ? "Yes" : "No"));}
//----------------------------------------------------------------
class Graph{

public:
  vector<vector<int>> graphs;
  vector<bool> check; // For DFS
  vector<ll> dist;   // For BFS
  queue<int> q; // For BFS

  Graph(int n){
    graphs.resize(n);
    init(n);
  }
  ~Graph(){}

  void addedge(int u, int v){
    u--; v--;
    graphs[u].push_back(v);
    graphs[v].push_back(u);
  }

  void addedge_cin(int m){
    rep(i,m){
      int a, b;
      cin >> a >> b;
      addedge(a, b);
    }
  }

  void init(int n){
    check.resize(n, false);
    dist.resize(n, -1);
  }

  void dfs(int v)
  {
    check[v] = true;

    for(auto next_v : graphs[v]){
      if(check[next_v]) continue;
      dfs(next_v);
    }
  }

  void bfs(int v)//----------------------
  {
    dist[v] = 0;
    q.push(v);

    while(!q.empty()){
      int cur_v = q.front();
      q.pop();

      for(int next_v : graphs[cur_v]){
        if(dist[next_v] != -1){
          continue;
        }

        dist[next_v] = dist[cur_v] + 1;
        q.push(next_v);
      }
    }
  }//-----------------------

};

int main(void) {
  int n, m;
  cin >> n >> m;
  arrll(h,n);

  Graph g(n);
  g.addedge_cin(m);

  int ans=0;
  rep(i,n){
    bool ok=true;
    rep(j,g.graphs[i].size()){
      if(h[g.graphs[i][j]]>=h[i]) ok=false;
    }
    if(ok) ans++;
  }

  prt(ans);
}


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

using namespace std;

#define REP(i, N) for (int (i) = 0; (i) < (N); ++(i))
#define READALL(c) for (auto &e : c) { cin >> e; }
#define PRINTALL(c) for (const auto &e : c) { cout << e << "\t"; } cout << "\n";

template <typename T>
using V = vector<T>;

typedef long double ld;

int R, C;

V<string> G;
map<char, int> cnts;

char search(int cnt, set<int> isdiv, set<int> ndiv) {
	char choice = '#';
	for (const auto &kv : cnts) {
		if (kv.second >= cnt) {
			for (int n : ndiv) if (kv.second % n == 0) {
				continue;
			}
			for (int n : isdiv) if (kv.second % n != 0) {
				continue;
			}
			choice = kv.first;
			break;
		}
	}
	if (choice)
	return choice;
}

bool solve() {
	cnts.clear();
	REP(i, R) {
		for (char c : G[i]) {
			cnts[c]++;
		}
	}

	map<int, int> need;


	REP(len, R/2+1) {
		int top = len, bot = R-1-len;

		if (top == bot) {
			REP(clen, C/2+1) {
				int l = clen, r = C-1-clen;
				if (l == r) {
					need[1]++;
				} else if (l < r) {
					need[2]++;
				}
			}
		} else if (top < bot) {
			REP(clen, C/2+1) {
				int l = clen, r = C-1-clen;
				if (l == r) {
					need[2]++;
				} else if (l < r) {
					need[4]++;
				}
			}
		}

	}

	V<int> vals = {4, 2, 1};
	for (int v : vals) if (need[v]) {
		while (need[v]) {
			bool fnd = 0;
			for (auto &kv : cnts) if (kv.second >= v) {
				kv.second -= v;
				--need[v];
				fnd = 1;
				break;
			}
			if (!fnd) {
				return 0;
			}
		}
	}
	return 1;
}

V<string> ans;
V<string> aa;
bool found;

bool isgood() {
	REP(i, R) {
		string rev = ans[i];
		reverse(begin(rev), end(rev));
		if (rev != ans[i])
			return 0;
	}
	REP(i, C) {
		string s;
		REP(j, R) {
			s.push_back(ans[j][i]);
		}
		string rev = s;
		reverse(begin(rev), end(rev));
		if (rev != s)
			return 0;
	}
	return 1;
}
void fill(int r, int c) {
	if (r == R) {
		// for (auto s : ans) {
		// 	cout << s << endl;
		// }
		// cout << endl;
		if (isgood()) {
			aa = ans;
			found = 1;
		}
		return;
	}
	if (c == C) {
		fill(r+1, 0);
		return;
	}
	REP(ci, 26) if (cnts[ci+'a']) {
		cnts[ci+'a']--;
		ans[r][c] = ci+'a';
		fill(r, c+1);
		ans[r][c] = '#';
		cnts[ci+'a']++;
	}
}


bool brute() {
	cnts.clear();
	REP(i, R) {
		for (char c : G[i]) {
			cnts[c]++;
		}
	}

	ans = V<string>(R, string(C, '#'));
	found = 0;
	fill(0, 0);
	return found;
}


void test() {
	string alpha = "abc";
	default_random_engine re;
	REP(tc, 100000) {
		R = re()%3 + 1;
		C = re()%3 + 1;
		G.assign(R, string(C, '#'));
		REP(i, R) {
			REP(j, C) {
				G[i][j] = alpha[re()%alpha.size()];
			}
		}
		for (string s : G) {
			cout << s << endl;
		}
		cout << endl;
		cout << solve() << endl;
		assert(brute() == solve());
	}
}


int main() {
	// test();
	// return 0;
	ios::sync_with_stdio(0);
	cin.tie(0);

	cin >> R >> C;

	G.resize(R);
	READALL(G);

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

	// for (auto s : aa) {
	// 	cout << s << endl;
	// }

	
}

Measured memory_bytes: 256
def f(y,x,c0):
  M.append([y,x])
  while M:
    y,x=M.pop()
    if A[y][x]==c0:
      A[y][x]=' '
      for i,j in [[0,-1],[-1,0],[0,1],[1,0]]: M.append([y+i,x+j])
  return 1

M=[]
while 1:
  H,W=map(int,raw_input().split())
  if H==W==0: break
  A=[list(' '*(W+2)) for _ in range(H+2)]
  for i in range(H): A[i+1][1:W+1]=list(raw_input())
  c=0
  for i in range(1,H+1):
    for j in range(1,W+1):
      c0=A[i][j]
      if c0!=' ': c+=f(i,j,c0)
  print c

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

typedef long long ll;
const ll INF = 1e9, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define REPR(i,a,b) for(ll i=b;i>=a;i--)
#define repr(i,n) REPR(i,0,n)
#define all(v) (v).begin(), (v).end()
#define pb push_back
#define fi first
#define se second
#define m_p make_pair

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

    ll n,num1=0,num2=0,num3=0,num4=0,tapi,tapu,tape,tapo,ans=0;
    cin >> n;
    vector<ll> v(n);
    rep(i,n) cin >> v[i];
    map<ll,ll> mp1,mp2,mp3,mp4;
    for(ll i=0;i<n;i+=2){
        mp1[v[i]]++;
        if(num1 < mp1[v[i]]){
            num1 = mp1[v[i]];
            tapi = v[i];
        }
    }
    for(ll i=0;i<n;i+=2){
        mp3[v[i]]++;
        if(v[i] != tapi && num3 < mp3[v[i]]){
            num3 = mp3[v[i]];
            tape = v[i];
        }
    }
    for(ll i=1;i<n;i+=2){
        mp2[v[i]]++;
        if(num2 < mp2[v[i]]){
            num2 = mp2[v[i]];
            tapu = v[i];
        }
    }
    for(ll i=1;i<n;i+=2){
        mp4[v[i]]++;
        if(v[i] != tapu && num4 < mp4[v[i]]){
            num4 = mp4[v[i]];
            tapo = v[i];
        }
    }
    if(tapi != tapu){
        ans = n - num1 - num2;
    }else{
        if(num1 > num2){
            ans = n - num1 - num4;
        }else if(num1 < num2){
            ans = n - num2 - num3;
        }else{
            if(num3 > num4){
                ans = n - num2 - num3;
            }else{
                ans = n - num1 - num4;
            }
        }
    }
    cout << ans << "\n";
    return 0;  
}

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

using namespace std;

#define FOR(i,s,e) for((i)=(s);(i)<(int)(e);(i)++)
#define REP(i,e) FOR(i,0,e)

#define all(o) (o).begin(), (o).end()
#define psb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))

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

const double EPS = 1e-10;

const int INF = 1000*1000*1000;
const int N = 100;
const int W = 10000;
int n, m;
int dp[N+1][W+1];
int v[N+1], w[N+1];

int main() {
  int i, j;
  memset(dp, 0, sizeof(dp));
  scanf("%d%d ", &n, &m);
  for (i=1; i<=n; i++) scanf("%d%d ", v+i, w+i);
  for (i=1; i<=n; i++)
    for (j=0; j<=m; j++)
      if (j-w[i]<0)
        dp[i][j] = dp[i-1][j];
      else
        dp[i][j] = max(dp[i-1][j], dp[i][j-w[i]]+v[i]);

  printf("%d\n", dp[n][m]);

  return 0;
}

Measured memory_bytes: 5148
n,m = map(int,input().split())
a=[]
b=[]
vector=[[False for i in range(n)] for j in range(n)]

visited = [False]*n
for i in range(m):
  x,y=map(int,input().split())
  a.append(x-1)
  b.append(y-1)
  vector[x-1][y-1]=vector[y-1][x-1]=True
  


def dfs(v):
  visited[v]=True
  for i in range(n):
    if not vector[v][i]:continue
    if visited[i]:continue
    dfs(i)
      
def main():
  ans=0
  for i in range(m):
    vector[a[i]][b[i]]=vector[b[i]][a[i]]=False
  
    for j in range(n):visited[j]=False
   
    dfs(0)
    
    bridge=False
    for j in range(1,n):
      if visited[j]==False:
        bridge=True
    if bridge:
      ans+=1
    vector[a[i]][b[i]]=vector[b[i]][a[i]]=True
    
  print(ans)

if __name__=='__main__':
  main()
                              
                              
    
    

  
      
  
  

Measured memory_bytes: 3064
import Foundation

private func readString() -> String {
    readLine()!
}

private func readStringArray() -> [String] {
    readString().components(separatedBy: " ")
}

private func readInt() -> Int {
    Int(readString())!
}

private func readIntArray() -> [Int] {
    readStringArray().map { Int($0)! }
}

private func readStringTupple() -> (String, String) {
    let array = readStringArray()
    return (array[0], array[1])
}

private func readStringTupple() -> (String, String, String) {
    let array = readStringArray()
    return (array[0], array[1], array[2])
}

private func readIntTupple() -> (Int, Int) {
    let array = readIntArray()
    return (array[0], array[1])
}

private func readIntTupple() -> (Int, Int, Int) {
    let array = readIntArray()
    return (array[0], array[1], array[2])
}

private func pow(_ x: Int, _ y: Int) -> Int {
    Int(pow(Double(x), Double(y)))
}

/*＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿
 〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
 ￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣*/

let n = readInt()
let a = [-1] + readIntArray()
var x = [Int](repeating: 0, count: n + 1)
var y = [Int](repeating: 0, count: n + 1)
for i in 1 ..< n + 1 {
    if a[i] + i < n + 1 {
        x[a[i] + i] += 1
    }
    if i - a[i] >= 1 {
        y[i - a[i]] += 1
    }
}
print((1 ..< n + 1).map { x[$0] * y[$0] }.reduce(0) { $0 + $1 })

/*＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿＿
〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓〓
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣*/


Measured memory_bytes: 21256
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
int main(){
  int i=0;
  int j,k,a,s=0;
  int count=0;
  int n[10000];
  scanf("%d",&a);
  if(a<1 || a>10000){
    exit(1);
  }
  for(i=0;i<a;i++){
    scanf("%d",&n[i]);
    if(n[i]<2 || n[i]>100000000){
      exit(1);
    }
    s=0;
    if(n[i]==2){
      count++;
    }
    if(n[i]%2==0){
      continue;
    }
    for(j=3;j<=sqrt(n[i]);j+=2){
      k=n[i]%j;
      if(k==0){
	s++;
      }
    }
      if(s==0){
	count++;
      }
    }
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2124
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const long double EPS=1e-9;
const long double PI=acos(-1.0);
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
long double ABS(long double a){return max(a,-a);}

int main(){
	long long a,b;
	scanf("%lld%lld",&a,&b);
	long long ret=1;
	long long tmp=b;
	for(int i=2;(long long)i*i<=b;i++){
		if(tmp%i==0){
			int cnt=0;
			while(tmp%i==0){
				tmp/=i;cnt++;
			}
			cnt/=a;
			for(int j=0;j<cnt;j++)ret*=i;
		}
	}
	if(tmp>1){
		if(a==1)ret*=tmp;
	}
	printf("%lld\n",ret);
}


Measured memory_bytes: 128
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


n = II()
F = [LI() for _ in range(n)]
P = [LI() for _ in range(n)]

ans = -INF
for bit in range(1, 1024):
    profit = 0
    for shop in range(n):
        cnt = 0
        for shift in range(10):
            if not bit >> shift & 1:
                continue

            if F[shop][shift]:
                cnt += 1

        profit += P[shop][cnt]

    ans = max(ans, profit)

print(ans)


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

long long dp[110][100010] = {0};//N-1番目までで入れた容量の価値を最大にするもの
long long weight[110], value[110];

int main(){
    int N, W;
    cin >> N >> W;
    for(int i=0; i<N; ++i){
        cin >> weight[i] >> value[i];
    }

    for (int i = 0; i < N; ++i)
    {
        for(int sum_W = 0; sum_W <= W; ++sum_W){
            //i番目の商品を選ぶ
            if(sum_W - weight[i]>=0){
                if(dp[i+1][sum_W] < dp[i][sum_W - weight[i]]+value[i]){
                    dp[i+1][sum_W] = dp[i][sum_W - weight[i]]+value[i];
                }
            }

            if(dp[i+1][sum_W] < dp[i][sum_W]){
                    dp[i+1][sum_W] = dp[i][sum_W];
                }
        }
    }
    cout << dp[N][W] <<endl;

    return 0;
}

Measured memory_bytes: 79360
from itertools import permutations
N = int(input())
ls = []
for i in range(N):
    ls.append([int(j) for j in input().split()])
arr = list(range(N))
ans = 0
num = 0
for x in permutations(arr, N):
    num += 1
    for y, z in zip(x, x[1:]):
        ans += ((ls[y][0] - ls[z][0])**2 + (ls[y][1] - ls[z][1])**2)**(1/2)
print(ans/num)

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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> a(n), b(n), c(n);
  rep(i, n) cin >> a[i];
  rep(i, n) cin >> b[i];
  rep(i, n) cin >> c[i];
  int ans = 0;
  rep(i, n) {
    ans += b[i];
    if (a[i] + 1 == a[i + 1]) {
      ans += c[a[i] - 1];
    }
  }
  out(ans);
}


Measured memory_bytes: 256
#include <cstdio>
#include <cmath>
#include <cstdint>
#include <cinttypes>
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

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

    int v[n] = {0};
    for(int& val : v){
        cin >> val;
    }

    int c[n] = {0};
    for(int& cost : c){
        cin >> cost;
    }

    int total = 0;
    for(int i = 0 ; i < n ; i++){
        int profit = v[i] - c[i];
        if(profit > 0){
            total += profit;
        }
    }

    cout << total << endl;
    return 0;
}


Measured memory_bytes: 256
from collections import defaultdict
N,M=map(int,input().split())
A=list(map(int,input().split()))
BC=defaultdict(int)
s=set()
for i in A:
    BC[i]+=1
    s.add(i)
for i in range(M):
    B,C=map(int,input().split())
    BC[C]+=B
    s.add(C)
s=list(s)
s.sort(reverse=True)
res=0
ans=0
for i in s:
    k=min(N-res,BC[i])
    res+=k
    ans+=k*i
    if res==N:
        break
print(ans)


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

void prians(bool answer) {
  if(answer)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}
int n;

int main() {
  cin >> n;
  prians(n % 10 == 9 || n / 10 == 9);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;
using namespace std;

#define rep(i, n) for (int(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (int i = (a); i < (b); i++)
#define rrrep(i, a, b) for (int i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl

ll n, cnt, ans, a[ohara], b, c, d, tmp, tmpp, m, h, w, x, y, sum, pos, k, t;
ld doua;
int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
bool fl;
struct edge
{
    int to, cost;
};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin >> k >> t;
    rep(i, t) cin >> a[i];
    while (1)
    {
        sort(a, a + t);
        reverse(a, a + t);
        if (a[1] == 0)
        {
            ans = a[0];
            break;
        }
        a[0] -= a[1];
        a[1] = 0;
    }
    ans = max(0LL, ans - 1);
    Cout(ans);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
          #include <chrono>
        
          using namespace std;
          using namespace std::chrono; 
       
          typedef long long int ll;
       
          #define MOD (ll)(1e9+7)
          #define endl "\n"
          #define pb push_back
          #define TEST_CASES  ll t;cin>>t;while(t--)
          #define forn(i,a,n) for (int i = a; i < n; ++i)
          #define f first
          #define s second
          #define all(x) x.begin(), x.end()


          
          ll powD(ll x,ll y){
            ll res = 1;
            while(y > 0){
              if(y & 1)
                res = (res*x);
              x = (x*x);
              y = y>>1;
            }
            return res;
          }

          int main()
          {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            int a;
            cin>>a;
            int ans = a + a*a + a*a*a;
            cout<<ans<<endl;             
          }

          
        


Measured memory_bytes: 3580
#include <cstdio>
#include <algorithm>

#define Rep(i, n) for (int i = 1; i <= n; i ++)
#define Rep0(i, n) for (int i = 0; i <= n; i ++)
#define RepG(i, x) for (int i = head[x]; i; i = edge[i].next)
#define v edge[i].to

using namespace std;

const int N = 500010;

int dis[N], d[N], f[N];

int main()
{
	int n, q, D;
	scanf("%d%d", &n, &D);
	dis[0] = D;
	Rep(i, n){
		scanf("%d", &d[i]);
		dis[i] = min(dis[i - 1], abs(dis[i - 1] - d[i]));
	}
	f[n + 1] = 0;
	for (int i = n; i; i --) {
		if (d[i] < (f[i + 1] + 1) * 2) f[i] = f[i + 1] + d[i];
		else f[i] = f[i + 1];
	}
	scanf("%d", &q);
	Rep(i, q) {
		int x;
		scanf("%d", &x);
		if (dis[x - 1] > f[x + 1]) printf("YES\n");
		else printf("NO\n");
	}
	
	return 0;
}


Measured memory_bytes: 7680
N, A, B = map(int, input().split())
X= list(map(int, input().split()))

dp = [float("inf") for _ in range(N)]
dp[0] = 0

for i in range(N-1):
    dp[i+1] = min(dp[i]+(X[i+1]-X[i])*A, dp[i]+B)
print(dp[-1])

Measured memory_bytes: 20140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second

int main()
{
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    for(int i=1;i<=n;i++)
    {
        int cnt=0;
        int tmp=i;
        while(tmp>0)
        {
            cnt+=(tmp%10);
            tmp/=10;
        }
        if(cnt<=b&&a<=cnt)
            ans+=i;
    }
    cout<<ans<<'\n';
}


Measured memory_bytes: 256
ans' :: Int -> (Double,Double) -> (Double,Double)
ans' 0 (x,y) = (x,y)
ans' n (x,y) =
  let r = sqrt(x*x+y*y)
      dx= y / r
      dy= x / r

      x'= x - dx
      y'= y + dy
  in
    ans' (n-1) (x',y') 

ans :: [Int] -> [Double]
ans [] = []
ans (-1:_) = []
ans (n:ns) =
  let (x,y) = ans' (n-1) (1,0)
  in
    (x:y:ans ns)
  
main = do
  c <- getContents
  let i = takeWhile (/= -1) $ map read $ lines c :: [Int]
      o = ans i
  mapM_ print o

Measured memory_bytes: 4464
#include <iostream>
#include <string>
#include <ios>
using namespace std;

struct LinkedList
{
	struct Node
	{
		Node(int k): v(k), prev(0), next(0){}
		int v;
		Node* prev;
		Node* next;
	};

	LinkedList(): front(0), last(0){}
	~LinkedList(){
		Node* p = 0;
		Node* n = front;
		while(n){
			p = n;
			n = n->next;
			delete p;
		}
	}
	void insert(int k){
		Node* n = new Node(k);
		if(!front){
			front = last = n;
		} else {
			front->prev = n;
			n->next = front;
			front = n;
		}
	}
	void remove(int k){
		Node* n = front;
		while(n){
			if(n->v == k)
				break;			
			n = n->next;
		}
		if(n){
			if(!n->prev && n->next){
				n->next->prev = 0;
				front = n->next;
			} else if (!n->prev && !n->next) {
				front = last = 0;
			} else if (n->prev && !n->next) {
				n->prev->next = 0;
				last = n->prev;
			} else {
				n->prev->next = n->next;
				n->next->prev = n->prev;
			}
			delete n;
		}
	}
	void removeFirst(){
		if(!front) return;
		else if( front == last ){
			Node* n = front;
			front = last = 0;
			delete n;
		} else {
			Node* n = front;
			front->next->prev = 0;
			front = front->next;
			delete n;
		}
	}
	void removeLast(){
		if(!last) return;
		else if( front == last){
			Node* n = last;
			front = last = 0;
			delete n;
		} else {
			Node* n = last;
			last->prev->next = 0;
			last = last->prev;
			delete n;
		}
	}

	Node* front;
	Node* last;
};

int main(){
	ios::sync_with_stdio(false);

	int m, i, k;
	cin >> m;
	string s;
	LinkedList myList;
	for(i = 0; i < m; ++i){
		cin >> s;
		if( s == "insert" ){
			cin >> k;
			myList.insert(k);
		}else if( s == "delete" ){
			cin >> k;
			myList.remove(k);
		}else if (s == "deleteFirst"){
			myList.removeFirst();
		}else if (s == "deleteLast"){
			myList.removeLast();
		}
	}

	LinkedList::Node* n = myList.front;
	while(n){
		cout << n->v;
		if( n != myList.last )
			cout << " ";
		n = n->next;
	}
	cout << "\n";

	return 0;
}

Measured memory_bytes: 32472
#include<iostream>
using namespace std;
int main(){
	int H;
	int W;
	for (;;){
		cin >> H >> W;
		if (H == 0 && W == 0){
			return 0;
		}else{
			for (int b = 0; b < H; b++){
				for (int c = 0; c < W; c++){
					if (c == 0){
						cout << "#";
					}
					else if (c == W-1){
						cout << "#";
					}
					else if (b == 0){
						cout << "#";
					}
					else if (b == H-1){
						cout << "#";
					}else{
						cout << ".";
					}
				}cout << endl;
			}cout << endl;
		}

	}
}

Measured memory_bytes: 3088
#include<stdio.h>

int main(){
	int n,x;
	int a,b,c,d;
	while(1){
		scanf("%d %d",&n,&x);
		if(!n && !x)
			break;
		d=0;
		for(a=1;a<=n;a++)
			for(b=a+1;b<=n;b++)
				for(c=b+1;c<=n;c++)
					if(a+b+c==x)
						d++;
		printf("%d\n",d);
	}
	return 0;
}

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

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

  vector<pair<int,int>> r(n);
  vector<pair<int,int>> b(n);

  for (int i = 0; i < n; i++)
  {
    int x,y;
    cin >> x >> y;
    r[i]=make_pair(y,x);
  }
  for (int i = 0; i < n; i++)
  {
    int x,y;
    cin >> x >> y;
    b[i]=make_pair(x,y);
  }

  sort(b.begin(),b.end());
  sort(r.begin(),r.end(),greater<pair<int,int>>());

  int ans=0;
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < r.size(); j++)
    {
      if(b[i].first>r[j].second && b[i].second>r[j].first){
        r.erase(r.begin()+j);
        ans++;
        break;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
words = lambda t : list(map(t, input().split()))
n = int(input())
xys = []
for i in range(n):
    x,y = words(int)
    xys.append((x,y))

import math
def distance(x1,y1,x2,y2):
    return math.sqrt((x2-x1)**2+(y2-y1)**2)

fn = math.factorial(n)
nc2 = math.factorial(n) // (math.factorial(2) * math.factorial(n-2))

ans = 0
for i in range(n-1):
    for j in range(i,n):
        d = distance(xys[i][0], xys[i][1], xys[j][0], xys[j][1])
        ans += d * (fn // nc2)

print(ans*(n-1)/fn)


Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<functional>
using namespace std;

int main(){

  int n;
  cin>>n;
  int a[100];
  int count=1;
  for(int i=0;i<n;i++){
    cin>>a[i];
  }

  sort(a,a+n);
  for(int i=0;i<n-1;i++){
    if(a[i]<a[i+1])count++;
  }
  cout<<count<<endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define reg register
typedef long long ll;
using namespace std;
int n;
map<int,int>mp;
int main(){
	scanf("%d",&n);
	while(n--){
		static int x;scanf("%d",&x);
		if(mp[x])return 0*puts("NO");
		mp[x]=1;
	}
	puts("YES");
	return 0;
}

Measured memory_bytes: 9600
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
#define yorn(f) cout<<((f)?"Yes":"No")<<endl
#define YORN(f) cout<<((f)?"YES":"NO")<<endl
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int main()
{
    int n;
    cin >> n;
    cout << n * (n + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
constexpr int INF = 2e9;

int main() {
  int x;
  cin >> x;
  cout << (x ^ 1) << endl;
  return 0; 
}


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

using namespace std;

#define ll long long
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int maxN = 1e5+5;
const int mod = 1e9+7;
vector<int> g[maxN];
int dp[maxN];

int dfs(int u){
    if(dp[u]!=-1)
        return dp[u];
    int temp = 0;
    for(auto x:g[u]){
        temp = max(temp,dfs(x)+1);
    }
    return dp[u] = temp;
}



void solve(){
    int n,m,u,v;
    cin>>n>>m;
    memset(dp,-1,sizeof dp);
    for(int i=0;i<m;i++){
        cin>>u>>v,u--,v--;
        g[u].push_back(v);
    }
    int ans = 0;
    for(int i=0;i<n;i++){
        ans = max(ans,dfs(i));
    }
    cout<<ans<<endl;
}

int main()
{
    FASTIO
    int t = 1;
    //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}





Measured memory_bytes: 11444
#include <iostream>
#define llint long long

using namespace std;

int n;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	for(int i = 1; i <= 9; i++){
		for(int j = 1; j <= 9; j++){
			if(i*j == n){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+7
#define MOD 1000000007
using namespace std;



int main(){
    int ans=0;
    
    int N;
    cin >> N;
    
    for(int i=0; i<262144; i++){
        int temp=0;
        int j=i;
        int t=1;
        
        int three=0;
        int five=0;
        int seven=0;
        
        while(j>0){
            if(j%4==1){
                temp+=t*3;
                three++;
            }else if(j%4==2){
                temp+=t*5;
                five++;
            }else if(j%4==3){
                temp+=t*7;
                seven++;
            }else if(j%4==0){
                temp=N+1;
                break;
            }
            j/=4;
            t*=10;
        }
        
        if(temp<=N && three*five*seven>0){
            ans++;
       //     cout<<temp<<endl;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stack>
using namespace std;
stack<int> s;
int main(){
	int n;
	int i;
	while(1){
	s.push(0);
	int c;
	scanf("%d",&n);
	if(n==0)return 0;
	scanf("%d",&c);
	for(i=1;i<n;i++){
		int nc;
		scanf("%d",&nc);
		if(i%2==0&&c!=nc){
			s.push(i);
		}
		else if(c!=nc){
			if(s.top()!=0)s.pop();
		}
		c=nc;
	}
	int p=n;
	int ans=0;
	while(!s.empty()){
		if(c==0)ans+=p-s.top();
		p=s.top();
		s.pop();
		c=(c+1)%2;
	}
	printf("%d\n",ans);
	}
}

Measured memory_bytes: 1036