akhauriyash/Code-Regression huggingface dataset:
# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_8_B
# Binary Search Tree II
# Result:
import sys

class BinarySearchTree(object):
    def __init__(self):
        super(BinarySearchTree, self).__init__()
        self.root = None
        self.count = 0

    def insert(self, val):
        node = Node(val)
        y = None
        x = self.root
        while x != None:
            y = x
            if node.id_ < x.id_:
                x = x.left
            else:
                x = x.right
        node.parent = y

        if y == None:
            self.root = node
        elif node.id_ < y.id_:
            y.left = node
        else:
            y.right = node

    def find(self, val):
        x = self.root
        while x != None:
            if val == x.id_:
                break
            elif val < x.id_:
                x = x.left
            else: # val > x.id_
                x = x.right
        if x != None:
            return True
        else:
            return False

    def __str__(self):
        return 'Call to_inorder_walk() or to_preorder_walk()'

    def to_inorder_walk(self):
        return self._to_inorder_walk(self.root)

    def to_preorder_walk(self):
        return self._to_preorder_walk(self.root)

    def _to_inorder_walk(self, node):
        if node == None: return ''
        str_ = self._to_inorder_walk(node.left)
        str_ += ' %d' % (node.id_)
        str_ += self._to_inorder_walk(node.right)
        return str_

    def _to_preorder_walk(self, node):
        if node == None: return ''
        str_ = ' %d' % (node.id_)
        str_ += self._to_preorder_walk(node.left)
        str_ += self._to_preorder_walk(node.right)
        return str_

class Node(object):
    def __init__(self, id_):
        super(Node, self).__init__()
        self.id_ = id_
        self.parent = None
        self.left = None
        self.right = None

    def __str__(self):
        str_ = '%d' % (self.id_)
        return str_


bst = BinarySearchTree()

_nops = int(sys.stdin.readline())
for _ in range(0, _nops):
    op = sys.stdin.readline().rstrip().split(' ')
    if op[0] == 'insert':
        bst.insert(int(op[1]))
    elif op[0] == 'print':
        print bst.to_inorder_walk()
        print bst.to_preorder_walk()
    elif op[0] == 'find':
        if bst.find(int(op[1])):
            print 'yes'
        else:
            print 'no'
    else:
        pass

Measured memory_bytes: 177692
import sys
import itertools
# import numpy as np
import time
import math
from heapq import heappop, heappush
from collections import defaultdict
from collections import Counter
from collections import deque
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())
N = int(input())
A = [0] + [int(input()) for _ in range(N)]

cur = 1
ans = 0
pushed = [False] * (N + 1)
pushed[1] = True
ok = True
while True:
    pushed[cur] = True
    ans += 1
    cur = A[cur]
    if cur == 2:
        break
    if pushed[cur]:
        ok = False
        break

if ok:
    print(ans)
else:
    print(-1)

        



Measured memory_bytes: 14168
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
using namespace std;
signed main(){
  int a,b;
  cin>>a>>b;
  if((a*b)%2==0)
    cout<<"Even";
  else
    cout<<"Odd";
    
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
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() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif


void solve(){
  double n,m,d;
  cin>>n>>m>>d;
  double x;
  if(d)x=2.0*(n-d)*(m-1.0);
  else x=(n-d)*(m-1.0);
  x/=n*n;
  cout<<x<<endl;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdint>
#include <iostream>
#include <vector>

using namespace std;

namespace {
constexpr size_t MX = 3001;
int64_t dp[4][MX][MX];
int64_t values[MX][MX];
}

int main() {  
  int64_t R, C, K;
  cin >> R >> C >> K;

  for (int64_t k = 0; k < K; ++k) {
    int64_t r, c, v;
    cin >> r >> c >> v;
    values[r-1][c-1] = v;
  }
  
  for (size_t r = 0; r < R; ++r) {
    for (size_t c = 0; c < C; ++c) {
      for (size_t k = 0; k < 4; ++k) {
        dp[k][r][c] = -1;
      }
    }
  }
  dp[0][0][0] = 0;
  for (int64_t r = 0; r < R; ++r) {
    for (int64_t c = 0; c < C; ++c) {
      int64_t value = values[r][c];
      int64_t next = 0;
      for (int64_t k = 3; k > 0; --k) {
        if (value != 0 && dp[k-1][r][c] >= 0) {
          dp[k][r][c] = max(dp[k][r][c], dp[k-1][r][c] + value);
        }
        if (c != C-1) dp[k][r][c+1] = dp[k][r][c];
        next = max(next, dp[k][r][c]);
      }
      if (c != C-1) dp[0][r][c+1] = max(dp[0][r][c+1], dp[0][r][c]);
      dp[0][r+1][c] = max(dp[0][r][c] + value, next);
    }
  }
  cout << dp[0][R][C-1] << endl;

  return 0;
}


Measured memory_bytes: 354956
import sys
sys.setrecursionlimit(10**6)
if sys.platform in (['ios','darwin','win32']):
	sys.stdin=open('Untitled.txt')
input = sys.stdin.readline
def INT(): return int(input())
def MAP(): return [int(s) for s in input().split()]

S = input().rstrip()
K = INT()

cnt = -1
for i in range(len(S)):
	if S[i] == str(1):
		cnt += 1
	else:
		break
if cnt == -1 or K-1 > cnt:
	print(S[cnt+1])
else:
	print(1)

Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int D,N;	cin>>D>>N;
	int ans;
	ans=(int)pow(100,D);
	if(N==100) N++;
	ans*=N;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3796
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( 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>>;
template<class T, class F=less<T>> void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

struct UnionFind
{
    int n, num;
    vector<int> sz, par;
    UnionFind() {}
    UnionFind(int n_) : n(n_), num(n_), sz(n_, 1), par(n_, 0) { iota(par.begin(), par.end(), 0); }
    int find(int x)
    {
        return (x == par[x] ? x : par[x] = find(par[x]));
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
    void unite(int x, int y)
    {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (sz[x] < sz[y])
            swap(x, y);
        sz[x] += sz[y];
        par[y] = x;
        num--;
    }
    int size(int x)
    {
        return sz[find(x)];
    }
    int count() const
    {
        return num;
    }
};


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

    int n, m, k;
    cin >> n >> m >> k;
    UnionFind uf(n);

    vector<int> fr[n];
    vector<int> bl[n];

    REP(i, m) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        uf.unite(a, b);
        fr[a].PB(b);
        fr[b].PB(a);
    }

    REP(i, k) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        bl[a].PB(b);
        bl[b].PB(a);
    }

    REP(i, n) {
        int sz = uf.size(i);
        for(int j:bl[i]) {
            if(uf.same(i, j)) sz--;
        }
        cout << sz - (int)fr[i].size() - 1 << " \n"[i==n-1];
    }

    return 0;
}

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

int main() {
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int al[103]={0};
	int bob[103]={0};
	for(int i=a;i<b;i++){
		al[i]=1;
	}
	for(int i=c;i<d;i++){
		bob[i]=1;
	}
	int cnt=0;
	for(int i=0;i<=100;i++){
		if(al[i]==1&&bob[i]==1){
			cnt++;
		}
	}
	cout<<cnt;
	return 0;
}

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

public class Program{
    public static void Main(){
        int N=int.Parse(Console.ReadLine());
        List<int> A=new List<int>();
        for(int i=0;i<N;i++){
            A.Add(int.Parse(Console.ReadLine()));
        }
        int max=A.Max();
        List<int> B=A.OrderByDescending(x=>x).ToList();
        for(int i=0;i<N;i++){
            if(A[i]!=max){
                Console.WriteLine(max);
            }else{
                Console.WriteLine(B[1]);
            }
        }
    }
}


Measured memory_bytes: 24152
#include <iostream>
#include<string>
#include<math.h>
#include<vector>
#include<algorithm>
#include<array>
#include<functional>
#include<iomanip>
#include<ios>
using namespace std;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
const long long int mod=1e9+7;
typedef long long ll;
ll gcd(ll a, ll b) {
  if(a < b) return gcd(b, a);
  ll r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
double reabs(double in){
    if(in<0){
        return (-1)*in;
    }else{
        return in;
    }
}

int main(){
    long long N,M;
    cin>>N>>M;

    long long K;

    if(N==M){
        K=0;
    }else{
        if((N+M)%2==0){
            K=abs(N+M)/2;
        }else{
            K=-1;
        }
    }
    if(K>=0){
        cout<<K<<endl;
    }else{
        cout<<"IMPOSSIBLE"<<endl;
    }

   
    return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { for (auto &vi: vec) os << vi << " "; return os; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<typename T >inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T> inline void add(T &a, int b) { a += b; if (a >= mod) a -= mod; }


void solve();

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

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  int m;
  cin >> m;
  vector<int> a(n);
  cin >> a;
  sort(all(a), greater<int>());
  if (a[m - 1] * 4 * m < accumulate(all(a), 0)) cout << "No" << endl;
  else cout << "Yes" << endl;
}


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

int main() {
    int n;cin>>n;
    map<int,int> m;
    int a;
    for (int i=0;i<n;i++) {
        cin>>a;
        m[a]=1-m[a];
    }
    int sm=0;
    for (auto p:m)
        sm+=p.second;
    cout<<sm<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }








const ll maxn=2e5+2;
vll b;
ll n;ll k;

bool ch(ll x){
    ll cnt=0;
for(ll i=0;i<n;i++){
        ll y=b[i];
        ll h=y/x;      
        if(y%x==0)h--;
        
        cnt+=h;
        // cout<<"\n";
    }
    return (cnt<=k);
}



int main()
{ fastio;
//freopen("test_input (1).xt", "r", stdin); 
//freopen("output.txt", "w", stdout);
cin>>n>>k;
for(ll i=0;i<n;i++){
    ll x;cin>>x;
    b.pb(x);
}

ll l=1,r=1e11;

// cout<<ch(4);
// cout<<ch(262703497);
while(l<r){
    ll mid=l+(r-l)/2ll;

    if(ch(mid)){
        r=mid;
    }
    else{
        l=mid+1ll;
    }
}
cout<<l;






return 0;
}




  










Measured memory_bytes: 5276
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
#define W(x) cout<<x<<endl;
#define Debug(x) cout<<"#DEBUG "<<x<<endl;
#define INF (1<<29)
using namespace std;
int min(int x,int y){if(y<x)return y;else return x;}
int max(int x,int y){return x+y-min(x,y);}
int fact(int x){int i=1;rep(j,x){i*=(j+1);} return i;}
int n,m;
vector<int> G[100000];
int fl,x[2][100001],q[100001];
void dfs(int fl,int now)
{
    if(q[now]==-1)
    {
        q[now]=fl;
        rep(i,G[now].size())
        {
            dfs(fl,G[now][i]);
        }
        return;
    }
    else return;
}
int main()
{
    cin>>n>>m;
    int p[n];
    rep(i,n)
    {
        cin>>p[i];
        q[i]=-1;
    }
    int flag1,flag2;
    rep(i,m)
    {
        cin>>flag1>>flag2;
        G[flag1-1].push_back(flag2-1);
        G[flag2-1].push_back(flag1-1);
    }
    fl=0;
    rep(i,n)
    {
        if(q[i]==-1)
        {
            fl++;
            dfs(fl,i);
        }
    }
    int ans=0;
    rep(i,n)
    {
        if(q[i]==q[p[i]-1])
        {
            ans++;
        }
        else{}
    }
    W(ans)
    return 0;
}

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

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    int x[3] = {A,B,C};
    sort(x,x+3);
    long count = 0;
    int q;
    for(int p = x[0]+2;p<=x[1]; p+=2){
        count++;
        q = p;
    }
    if(A==B && B==C) count = 0;
    else if(q==x[1]){
        count = count + x[2] - x[1];
    } else {
        count = count + x[2] + 1 - x[1] + 1;

    }
    cout << count <<"\n";
    return 0;
}

Measured memory_bytes: 256
import java.awt.Point;
import java.util.ArrayDeque;
import java.util.Scanner;
import java.util.*;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Set;
import java.util.HashSet;
import java.util.Collection;


 
public class Main{
	
        static final Scanner sc=new Scanner(System.in);
        
        
        
        
        
        
        public static void main(String[]args){
                int N=sc.nextInt();
                int X=sc.nextInt();
                int[]x=new int[N];
                for(int i=0;i<N;i++){
                        x[i]=sc.nextInt();
                }
                int[]kyori=new int[N];
                for(int i=0;i<N;i++){
                        kyori[i]=Math.abs(X-x[i]);
                }
                if(N>1){
                int n=gcd(kyori[0],kyori[1]);
                for(int i=2;i<N;i++){
                        n=gcd(n,kyori[i]);

                }
                System.out.println(n);
        }else{
                System.out.println(Math.abs(X-x[0]));
        }




                


                
        }
        private static int gcd(int m, int n) {
                if(m < n) return gcd(n, m);
                if(n == 0) return m;
                return gcd(n, m % n);
            }
        
        
        

		
	
}


Measured memory_bytes: 51456
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 263000;
const int MAXX = 100000;

int n, v[N], w[N], q, a, b, i, best, act, j, m, res[512][MAXX + 4];
vector<ii> v1, v2;

int get(int i, int lim, int maxx) {
	v1.clear();
	v1.pb(ii(0, 0));
	int j;
	for (j=i;j>=lim;j/=2) {
		v2.clear();
		for (auto& ww : v1) if (w[j] + ww.second <= maxx) v2.pb(ii(ww.first + v[j], ww.second + w[j]));
		for (auto& ww : v2) v1.pb(ww);
	}
	return j;
}

int main() {
scanf("%d", &n);
for (i=1;i<=n;i++) scanf("%d %d", &v[i], &w[i]);
m = min((1<<9) - 1, n);
for (i=1;i<=m;i++) {
	get(i, 1, MAXX);
	//printf("%d\n", v1.size());
	for (auto& ww : v1) if (res[i][ww.second] < ww.first) res[i][ww.second] = ww.first;
	best = 0;
	for (j=0;j<=MAXX;j++) if (res[i][j] < best) res[i][j] = best; else best = res[i][j];
}
scanf("%d", &q);
while (q--) {
	scanf("%d %d", &a, &b);
	if (a <= m) {
		printf("%d\n", res[a][b]);
		continue;
	}
	act = get(a, m + 1, b);
	//printf("%d\n", act);
	best = 0;
	for (auto& ww : v1) best = max(best, ww.first + res[act][b - ww.second]);
	printf("%d\n", best);
}
return 0;
}

Measured memory_bytes: 204924
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for(int i=0; i<(int)(a); i++)
typedef long long ll;

int main()
{
  int n; cin >> n;
  vector<int> a(n, 0);
  rep(i, n) cin>>a[i];

  rep(i, n) {
    int v = a[i];
    int j = i-1;
    while (j>=0 && a[j]>v) {
      a[j+1] = a[j];
      j--;
    }
    a[j+1] = v;
    rep(k, n) {
      if (k==0) cout << a[k];
      else cout << " " << a[k];
    }
    cout << endl;
  }

  return 0;
}



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

int main(){
    int n;
    int A[1000];
    int y,j;
    int count = 0;
    cin >> n;
    
    for(int i = 0; i < n; i++){
        cin >> A[i];
        //cout << A[i];
    }
    for(int i = 0; i < n ; i++){
        j = n- 1;
        
        while(j >= i + 1 ){
            
            if(A[j] < A[j - 1]){
                y = A[j];
                A[j] = A[j - 1];
                A[j - 1] = y;
                count += 1;
                
            }
            //A[j + 1] = A[j];
            j = j - 1;
            continue;
        }
        //A[i] = A[j + 1];
        //A[j + 1] = y;
        
        
    }
    
    for(int i = 0; i < n; i++){
        //cin >> A[i];
        if(i != 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
    cout << count << endl;
    
    
    return 0;
}



Measured memory_bytes: 3100
import std.stdio;
import std.array;
import std.conv;
import std.algorithm;
int w,h;
string[] input;

struct pos{
  int x;int y;int distance;
}

int bfs(int[][] hrz, int[][] vrt,int w,int h){
  bool[110][110] checked = false;
  pos[] queue;
  queue~=pos(0,0,1);
  checked[0][0]=true;
  while(queue.length!=0){
    if(queue[0].x==w-1&&queue[0].y==h-1){return queue[0].distance;}
    if(queue[0].x>0&&vrt[queue[0].y][queue[0].x-1]==0&&!checked[queue[0].x-1][queue[0].y]){
      queue~=pos(queue[0].x-1,queue[0].y,queue[0].distance+1);
      checked[queue[0].x-1][queue[0].y]=true;
    }
    if(queue[0].x<w-1&&vrt[queue[0].y][queue[0].x]==0&&!checked[queue[0].x+1][queue[0].y]){
      queue~=pos(queue[0].x+1,queue[0].y,queue[0].distance+1);
      checked[queue[0].x+1][queue[0].y]=true;
    }
    if(queue[0].y>0&&hrz[queue[0].y-1][queue[0].x]==0&&!checked[queue[0].x][queue[0].y-1]){
      queue~=pos(queue[0].x,queue[0].y-1,queue[0].distance+1);
      checked[queue[0].x][queue[0].y-1]=true;
    }
    if(queue[0].y<h-1&&hrz[queue[0].y][queue[0].x]==0&&!checked[queue[0].x][queue[0].y+1]){
      queue~=pos(queue[0].x,queue[0].y+1,queue[0].distance+1);
      checked[queue[0].x][queue[0].y+1]=true;
    }
    queue=queue[1..$];
  }
  return 0;
}

void main(){
  while(input=readln.split,w=input[0].to!int,h=input[1].to!int,(w|h)!=0){
    int[][] hrz;
    int[][] vrt;
    for(int i=0;i<h;i++){
      if(i!=0)
	hrz~=readln.split.map!(to!int).array;
      vrt~=readln.split.map!(to!int).array;
    }
    writeln(bfs(hrz,vrt,w,h));
  }
}

Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int A,B;cin >> A >> B;
    int ans = 0;
    int tmp = 1;
    while(tmp < B){
        tmp += A-1;
        ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
#define endl "\n"
//#pragma GCC optimize(2)
using namespace std;
const int N=1e6+1;
const int M=1e9+7;
const double eps=1e-6;
typedef complex<double>C;
const double PI(acos(-1.0));
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){return x?BIT[x]+sum(x-(x&-x)):0;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a, LL b,LL M) { return b ? b & 1 ? a*pw(a, b - 1,M) % M : pw(a*a%M, b>>1,M) : 1; }
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
int main(){Accel
	int n;
	LL a,k;
	cin>>n;
	int t=0;
	REP(i,n){
		cin>>a>>k;
		while(1){
			if(a<k)break;
			else if(a%k==0){
				t^=a/k;
				break;
			}
			else{
				LL div=a/k+1,mod=a%k;
				if(mod%div)
					a-=div*(mod/div+1);
				else a-=div*(mod/div);
			}
		}
	}
	if(t)cout<<"Takahashi"<<endl;
	else cout<<"Aoki"<<endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
using ll = long long;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define IN(v) int v;cin>>v;
#define OUT(v) cout<<v<<"\n"
const int MOD = 1e9+7;

int A[22][22];
ll dp[22][1 << 21];
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  IN(N);

  REP(i, N) REP(j, N) cin >> A[i][j];
  dp[0][0] = 1;
  REP(i, N) REP(msk, 1 << N) {
    if (i != __builtin_popcount(msk))
      continue;
    REP(j, N) {
      if (!(msk & (1 << j)))
        if (A[i][j]) {
          dp[i+1][msk | (1 << j)] += dp[i][msk];
          dp[i+1][msk | (1 << j)] %= MOD;
        }
    }
  }
  OUT(dp[N][(1 << N) - 1]);

  return 0;
}


Measured memory_bytes: 309504
n, k = map(int, input().split())
al = list(map(int, input().split()))
al_abs = []
al_p = []
al_m = []
zero_cnt = 0
MOD = 10**9+7

for a in al:
    if a == 0:
        zero_cnt+=1
    elif a > 0: 
        al_abs.append((abs(a),1))
        al_p.append(a)
    else: 
        al_abs.append((abs(a),-1))
al_abs.sort(reverse=True)


if n == k:
    ans = 1
    for a in al:
        ans *= a
        ans %= MOD
    print(ans)
    exit()


if len(al_abs) < k:
    print(0)
    exit()



if not al_p:
    if k%2 == 1 and zero_cnt > 0:
        print(0)
    else:
        if k%2 == 1:
            al_abs.sort()
        ans = 1
        for a,s in al_abs[:k]:
            ans *= (a*(-1))
            ans %= MOD
        print(ans)
    exit()


val = 1
m_cnt = 0
last_m = 0
last_p = 0
for i in range(k):
    v,sig = al_abs[i]
    val *= v
    val %= MOD
    if sig == -1:
        m_cnt += 1
        last_m = v
    else:
        last_p = v

if m_cnt %2 == 0:
    print(val)
    exit()


# minus -> plus 

## search next p
next_p = 0
for i in range(k,len(al_abs)):
    v,sig = al_abs[i]
    if sig == 1:
        next_p = v
        break

## search next m
next_m = 0
for i in range(k,len(al_abs)):
    v,sig = al_abs[i]
    if sig == -1:
        next_m = v
        break

if next_p == 0 and next_m == 0:
    print(0)
    exit()

# last_m -> next_p
if next_p*last_p >= next_m*last_m or last_p == 0:
# if next_p > 0 and next_m == 0:
    ans = 1
    skip_flag = False
    for i in range(k):
        v,sig = al_abs[i]
        if not skip_flag and v == last_m and sig == -1:
            ans *= next_p
            skip_flag = True
        else:
            ans *= v
        # print(ans)
        ans %= MOD
    print(ans)
    exit()


# last_p -> next_m
# if next_p == 0 and next_m > 0:
elif next_p*last_p <= next_m*last_m:
    ans = 1
    skip_flag = False
    for i in range(k):
        v,sig = al_abs[i]
        if not skip_flag and v == last_p and sig == 1:
            ans *= next_m
            skip_flag = True
        else:
            ans *= v
        ans %= MOD
    print(ans)
    exit()

Measured memory_bytes: 125212
from itertools import combinations, product

N = int(input())
F = [list(map(int, input().split())) for _ in range(N)]
P = [list(map(int, input().split())) for _ in range(N)]

idx_list = [i for i in range(0,10)]
ans = -1 * float('inf')
for i in range(1,11):
  for combination in combinations(idx_list,i):
    jos = [0 for _ in range(10)]
    for idx in combination:jos[idx] = 1
    
    prof_sum = 0
    for j in range(N):
      num_open = sum([a*b for a,b in zip(jos,F[j][:])])
      prof_sum += P[j][num_open]
    if ans < prof_sum: ans = prof_sum
print(ans)

Measured memory_bytes: 42860
#include <cstdio>

int main(int argc, char const *argv[]) {
  int min=1000;
  int max=0;
  int tmp;
  int N;
  scanf("%d", &N);
  for (size_t i = 0; i < N; i++) {
    if(i==N-1){
      scanf("%d\n", &tmp);
    }
    else{
      scanf("%d ",&tmp);
    }
    if(tmp<min){
      min=tmp;
    }
    if(tmp>max){
      max=tmp;
    }
  }
  printf("%d\n", max-min);
  return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
        A.at(i)--;
    }
    int cnt = 0, temp = 0; 
    for(;;){
        if(temp == 1){
            cout << cnt << endl;
            break;
        }
        if(cnt >= N){
            cout << -1 << endl;
            break;
        }
        cnt++;
        temp = A.at(temp);
    }
    return 0;
}

Measured memory_bytes: 3720
#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <cstdlib>
#include <utility>
#include <cctype>
#include <algorithm>
#include <bitset>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cmath>
#define LL long long
#define LB long double
#define x first
#define y second
#define Pair pair<int,int>
#define pb push_back
#define pf push_front
#define mp make_pair
#define LOWBIT(x) x & (-x)
using namespace std;

const int MOD=1e9+7;
const LL LINF=2e16;
const int INF=2e9;
const int magic=348;
const double eps=1e-10;
const double pi=3.14159265;

inline int getint()
{
    char ch;int res;bool f;
    while (!isdigit(ch=getchar()) && ch!='-') {}
    if (ch=='-') f=false,res=0; else f=true,res=ch-'0';
    while (isdigit(ch=getchar())) res=res*10+ch-'0';
    return f?res:-res;
}

int n,k;
string s[2048];
int cntCh[27];
string ans;
bitset<1000048> can[2048];
Pair dp[2][1000048];

int main ()
{
	int i,j,cnt,ncnt,cur,minCh,minSt;
	n=getint();k=getint();
	for (i=1;i<=n;i++)
	{
		cin>>s[i];
		for (j=0;j<int(s[i].size());j++)
			cntCh[s[i][j]-'a'+1]++;
	}
	int fcnt=0;
	for (i=1;i<=26;i++)
		if (cntCh[i]) fcnt++;
	if (fcnt==1)
	{
		for (i=1;i<=26;i++)
			if (cntCh[i])
			{
				ans=string(k,'a'+i-1);
				cout<<ans<<endl;
				return 0;
			}
	}
	can[n+1][0]=1;
	for (i=n;i>=1;i--)
		can[i]=can[i+1]|(can[i+1]<<(int(s[i].size())));
	for (i=1;i<=n;i++)
		if (can[i+1][k-int(s[i].size())]) dp[0][++cnt]=mp(i,0);
	cur=0;
	for (i=1;i<=k;i++)
	{
		cnt=min(cnt,10000);ncnt=0;
		minCh=26;
		for (j=1;j<=cnt;j++)
			minCh=min(minCh,s[dp[cur][j].x][dp[cur][j].y]-'a'+1);
		ans+=string(1,'a'+minCh-1);
		minSt=INF;
		for (j=1;j<=cnt;j++)
			if (s[dp[cur][j].x][dp[cur][j].y]-'a'+1==minCh)
			{
				if (dp[cur][j].y==int(s[dp[cur][j].x].size())-1)
					minSt=min(minSt,dp[cur][j].x+1);
				else
					dp[cur^1][++ncnt]=mp(dp[cur][j].x,dp[cur][j].y+1);
			}
		for (j=minSt;j<=n;j++)
			if (k-i-int(s[j].size())>=0 && can[j+1][k-i-int(s[j].size())])
				dp[cur^1][++ncnt]=mp(j,0);
		cnt=ncnt;cur^=1;
	}
	cout<<ans<<endl;
	return 0;
}	

Measured memory_bytes: 246272
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    int j=s.size()-1;
    int cnt=0;
    for(int i=0;i<s.size()/2;i++) {

        if(s[i]!=s[j])cnt++;
        j--;
    }
    cout<<cnt<<endl;

}


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

int main(){
    int h,w;
    cin >> h >> w;
    vector<vector<char>> v= vector<vector<char>>(h, vector<char>(w, '.'));
    vector<vector<bool>> b= vector<vector<bool>>(h, vector<bool>(w, true));
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            cin >> v[i][j];
        }
    }
    vector<bool> checkerw(w);
    int c;
    for(int i = 0; i < h; i++){
        for(int k = 0; k < w; k++){
            checkerw[k] = false;
        }
        c = 0;
        for(int j = 0; j < w; j++){
            if(v[i][j] == '.') checkerw[j] = true;
        }
        for(int l = 0; l < w; l++){
            if(checkerw[l]) c++;
        }
        if(c == w){
            for(int m = 0; m < w; m++){
                b[i][m] = false;
            }
        }
    }
    vector<bool> checkerh(h);
    for(int i = 0; i < w; i++){
        for(int k = 0; k < h; k++){
            checkerw[k] = false;
        }
        c = 0;
        for(int j = 0; j < h; j++){
            if(v[j][i] == '.') checkerw[j] = true;
        }
        for(int l = 0; l < h; l++){
            if(checkerw[l]) c++;
        }
        if(c == h){
            for(int m = 0; m < h; m++){
                b[m][i] = false;
            }
        }
    }
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(b[i][j]) cout << v[i][j];
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Math;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            A();
        }

        static void A()
        {
            var N = ReadInt();
            var T = ReadLines(N);
            
            if (N == 1)
            {
                Println(T[0]);
                return;
            }

            var lcm = Lcm(T[0], T[1]);
            for (int i = 2; i < N; i++)
            {
                lcm = Lcm(lcm, T[i]);
            }
            Println(lcm);
        }

        static List<long> ReadLines(long n)
        {
            var l = new List<long>();
            for (long i = 0; i < n; i++)
            {
                l.Add(ReadLong());
            }
            return l;
        }

        static IEnumerable<int> Range(int start, int stop)
        {
            if (start < 0 || stop < 0 || start > stop || (start <= 0 && stop <= 0))
                return new List<int>();

            return Enumerable.Range(start, stop - start);
        }

        static bool IsDigit(string str)
        {
            var i = 0;
            return int.TryParse(str, out i);
        }

        static int SumDigits(long num)
        {
            return num.ToString().Select(x => x.ToString()).Sum(int.Parse);
        }

        static int[] ToIntArray(string str)
        {
            return str.Select(x => x.ToString()).Select(int.Parse).ToArray();
        }

        static long Gcd(long a, long b) => b == 0 ? a : Gcd(b, a % b);
        static long Lcm(long a, long b) => a / Gcd(a, b) * b;

        static bool IsPrime(int x)
        {
            if (x <= 1 || (x != 2 && x % 2 == 0)) return false;
            if (x == 2) return true;

            for (int i = 3; i < x; i += 2)
                if (x % i == 0) return false;

            return true;
        }

        static string Read() => Console.ReadLine();
        static int ReadInt() => int.Parse(Read());
        static long ReadLong() => long.Parse(Read());

        static List<string> ReadSplit() => Read().Split().ToList();
        static List<int> ReadSplitInt() => Read().Split().Select(int.Parse).ToList();
        static List<long> ReadSplitLong() => Read().Split().Select(long.Parse).ToList();

        static void Print(object value) => Console.Write(value.ToString());
        static void Println(object value) => Console.WriteLine(value.ToString());

        static string Join<T>(IEnumerable<T> list) => string.Join("", list);
    }

    public static class MyExtensions
    {
        public static string Slice(this string str, int start = 0, int stop = 0)
        {
            if (start > str.Length || stop > str.Length || start < 0 || stop < 0)
                return "";

            if (stop == 0) stop = str.Length;
            return str.Substring(start, stop - start);
        }
    }
}


Measured memory_bytes: 13268
import bisect,copy,heapq,itertools,string
from collections import *
from math import *
import sys
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

n = INT()
s = [sorted(input()) for i in range(n)]
s.sort()

cnt = 1
ans = 0
for i in range(1, n):
        if s[i] == s[i-1]:
                cnt += 1                
        else:
                ans += cnt*(cnt-1)//2
                cnt = 1
ans += cnt*(cnt-1)//2
print(ans)

Measured memory_bytes: 31788
#define _USE_MATH_DEFINES
#include<iostream>
#include<fstream>
#include<vector>
#include<string>
#include<algorithm>
#include<climits>
#include<numeric>
#include<cmath>
#include<cstring>
#include<deque>
#include<map>
#include<iomanip>

#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define VSORT(v) sort(v.begin(), v.end());
#define VE vector<int>
#define VEP vector<pair<int,int>>
#define llong long long
#define pb(a) push_back(a)
using namespace std;
const vector<VE> DIR{ {-1,0},{1,0},{0,-1},{0,1} };
const llong MOD = 1000000007;
long long GCD(long long a, long long b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname);
int range_check(int val, int min, int max) {
	if (val < min) {
		return -1;
	}
	if (val > max) {
		return -1;
	}
	return val;
}
template<class T,class T1>
bool array_find(const T& array, const T1& dst) {
	auto result = find(array.first(), array.end(), dst);
	if (result == array.end()) {
		return false;
	}
	else {
		return true;
	}
}
int main() {
	int a;
	cin >> a;
	string str0, str1;
	cin >> str0;
	cin >> str1;
	string ans = str0 + str0;
	REP(i, a) {
		ans[2 * i] = str0[i];
		ans[2 * i + 1] = str1[i];
	}
	cout << ans << endl;
	return 0;
}
template<class T>
int dp2csv(const vector<vector<T>> & dp, const string fname) {
	ofstream ofs(fname);
	if (ofs.fail()) { cerr << "cannot open file. :" + fname << endl; return -1; }
	for (auto dp_row : dp) {
		for (auto dp_cell : dp_row) {
			ofs << dp_cell << ",";
		}
		ofs << endl;
	}
	ofs.close();
	return 0;
}


Measured memory_bytes: 256
n,k,s=list(map(int,input().split()))

a=[]
for i in range(n):
  if i < k:
  	a.append(s)
  else:
    if s > 50:
      a.append(s-1)
    else:
      a.append(s+1)
    
t=[str(l) for l in a]
t=" ".join(t)
print(t)

Measured memory_bytes: 15128
alphabet = ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z"]

def main():
  N = int(input())
  S = input()
  
  newS = ""
  for letter in S:
    num = order(letter, alphabet)
    new_order = (num + N) % 26
    newS += alphabet[new_order]
  print (newS)
    
def order(letter, alphabet):
  for i in range(len(alphabet)):
    if letter == alphabet[i]:
      return i

if __name__ == "__main__":
  main()

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

int main()
{
    double x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    
    printf("%.07lf\n", sqrt(pow(x2-x1, 2)+pow(y2-y1, 2)));
}



Measured memory_bytes: 3292
#include <iostream>
#include <algorithm>
#include <queue>
#include <tuple>
#include <stack>
#include <climits>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#define INF INT_MAX>>1 //要climits#includ

typedef long long ll;

using namespace std;

int main(void){
	int n; cin >> n;
	pair<string, pair<int, int> > p[101];
	for(int i=0; i<n; i++){
		cin >> p[i].first >> p[i].second.first;
		p[i].second.first *= -1;
		p[i].second.second = i+1;
	}
	sort(p, p+n);
	for(int i=0; i<n; i++){
		cout << p[i].second.second << endl;
	}
}

/*
int main(void){
	int a, p; cin >> a >> p;
	cout << (a*3+p)/2 << endl;


	return 0;
}
*/

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/rope>

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

template<class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
/***********************************************/
/* Dear online judge:
 * I've read the problem, and tried to solve it.
 * Even if you don't accept my solution, you should respect my effort.
 * I hope my code compiles and gets accepted.
 *  ___  __     _______    _______      
 * |\  \|\  \  |\  ___ \  |\  ___ \     
 * \ \  \/  /|_\ \   __/| \ \   __/|    
 *  \ \   ___  \\ \  \_|/__\ \  \_|/__  
 *   \ \  \\ \  \\ \  \_|\ \\ \  \_|\ \ 
 *    \ \__\\ \__\\ \_______\\ \_______\
 *     \|__| \|__| \|_______| \|_______|
 */
const long long mod = 1000000007;


int main(int argc, char** argv) {
#ifdef ONLINE_JUDGE
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
#endif
	
	long long N,M;
	cin>>N>>M;
	long long res = 1;
	for(long long i = 1;i * i <= M;i++) {
		if(M%i) continue;
		if(M/i >= N) res = max(res,i);
		if(i >= N) res = max(res,M/i);
	}
	cout<<res<<'\n';

	return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,sse3,sse4,popcnt,abm,mmx")

#include <bits/stdc++.h>   
#include <stdio.h>    
 
using namespace std;
     
#define F first
#define S second
#define lb lower_bound               
#define ub upper_bound
#define pb push_back
#define pf push_front    
#define ppb pop_back
#define mp make_pair
#define bpp __builtin_popcountll                                                                                        
#define sqr(x) ((x) * (x)) 
#define al 0x3F3F3F3F
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define in insert
#define ppf pop_front
#define endl '\n'
//#define int long long
 
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;
const ll inf = (ll)3e18 + 1;

const double pi = acos (-1.0);
const double eps = 1e-7;
const int dx[] = {0, 0, 1, 0, -1};
const int dy[] = {0, 1, 0, -1, 0};

int n, x, y, z, ten[42], S, ans, dp[42][(1 << 17)];

inline int mult (int a, int b) {
   return 1ll * a * b % mod;
}

inline int add (int a, int b) {
   a += b;
   if (a >= mod) a -= mod;
   if (a < 0) a += mod;
   return a;
}                                      

inline void boost () {                    
   ios_base :: sync_with_stdio (NULL);
   cin.tie (NULL), cout.tie (NULL);          
}                                                     

inline void Solve () {
   cin >> n >> x >> y >> z;
   ten[0] = 1;
   int sum = x + y + z;
   int u = (1 << (sum - 1)) | (1 << (sum - z - 1)) | (1 << (x - 1));
   for (int i = 1; i <= n; i ++) ten[i] = mult (ten[i - 1], 10);
   dp[1][0] = 1;
   for (int i = 1; i <= n; i ++) {
      for (int mask = 0; mask < (1 << sum); mask ++) {
         for (int k = 1; k <= 10; k ++) {
            int new_mask = (mask << k) | (1 << (k - 1));
            new_mask &= ((1 << sum) - 1);
            if ((new_mask & u) == u) continue;
            dp[i + 1][new_mask] = add (dp[i + 1][new_mask], dp[i][mask]);
         }                                                 
      }         
   }
   for (int i = 0; i < (1 << sum); i ++) ans = add (ans, dp[n + 1][i]);
   cout << add (ten[n], -ans);

}                                     

main () {                                       
// freopen (".in", "r", stdin);    
// freopen (".out", "w", stdout);              
   boost ();
   int tt = 1;
// cin >> tt;   
   while (tt --) {
      Solve ();
   }                                               
   return 0;      
}


Measured memory_bytes: 20736
import collections

N, M = map(int, input().split())
ab = [list(map(int, input().split())) for i in range(M)]

a = [v[0] for v in ab]
b = [v[1] for v in ab]
a.extend(b)
c = collections.Counter(a)

for i in range(1, N + 1):
    print(c[i])


Measured memory_bytes: 3316
N, M = map(int, input().split())
a = [2*10**5+1] + sorted(map(int, input().split()), reverse=True)


def solve(x):
   count = 0
   j = N
   for i in range(1, N+1):
      while a[i] + a[j] < x:
         j -= 1
      count += j
   
   return count

left, right = 0, 2*10**5+1
while left < right - 1:
   mid = (left + right) // 2
   if solve(mid) >= M:
      left = mid
   else:
      right = mid

acc = a[:]
acc[0] = 0
for i in range(N):
   acc[i+1] += acc[i]

ans = 0
j = N
for i in range(1, N+1):
   while a[i] + a[j] < left+1:
      j -= 1
   ans += a[i]*j + acc[j]
   M -= j

if M:
   ans += left * M

print(ans)

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

int main(){
	char c;
	string b;
	cin >> c;
	cin >> b;


	switch(c) {
	case 'S':
		cout << "Cloudy";
		break;
	case 'C':
		cout << "Rainy";
		break;
	case 'R':
		cout << "Sunny";
		break;
	}
	cout << endl;
	cin >> c;
	return 0;
}

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

int main(){
    int N,ans = 0;
    cin >> N;
    vector<int> a(N);
    map<int,int> mp;
    for(int i = 0;i < N;i ++){
        cin >> a[i];
        mp[a[i]] ++;
    }
    for(auto i:mp){
        int num = i.first;
        int cnt = i.second;
        if(cnt < num) ans += cnt;
        else  ans += cnt - num;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 5120