akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <vector>
const int MAXN = 205;
const int NOPE = -1;
int A[MAXN][MAXN];
int C[MAXN];
char S[MAXN];
int N;

bool dfs(int cur) {
    for (int nxt = 1; nxt <= N; ++nxt) {
        if ((cur == nxt) || (A[cur][nxt] == MAXN)) {
            continue;
        }
        if (C[nxt] == C[cur]) {
            return false;
        }
        if (C[nxt] == NOPE) {
            C[nxt] = C[cur] ^ 1;
            if (!dfs(nxt)) {
                return false;
            }
        }
    }
    return true;
}

void floyd_warshall() {
    for (int k = 1; k <= N; ++k) {
        for (int i = 1; i <= N; ++i) {
            for (int j = 1; j <= N; ++j) {
                A[i][j] = std::min(A[i][k] + A[k][j], A[i][j]);
            }
        }
    }
}

int solve(int src) {
    C[src] = 0;
    if (!dfs(src)) {
        return NOPE;
    }
    floyd_warshall();
    int ret = 0;
    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= N; ++j) {
            ret = std::max(A[i][j], ret);
        }
    }
    return ret + 1;
}

void init() {
    for (int i = 1; i <= N; ++i) {
        C[i] = NOPE;
    }
}

int main() {
    scanf("%d", &N);
    init();
    for (int i = 1; i <= N; ++i) {
        scanf("%s", S+1);
        for (int j = 1; j <= N; ++j) {
            if (i == j) {
                A[i][j] = 0;
            } else if (S[j] - '0') {
                A[i][j] = 1;
            } else {
                A[i][j] = MAXN;
            }
        }
    }
    printf("%d\n", solve(1));
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, begin, end) for (ll i = (begin); i < (end); i++)
#define REP(i, n) FOR(i, 0, n)
#define IFOR(i, begin, end) for (ll i = (begin)-1; i >= (end); i--)
#define IREP(i, n) IFOR(i, n, 0)
#define SORT(a) sort(a.begin(), a.end())
#define ISORT(a) sort(a.begin(), a.end(), greater<ll>())
#define REVERSE(a) reverse(a.begin(), a.end())
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v)                                                              \
  cout << #v << "=(" << v[0];                                                  \
  FOR(i_debug, 1, v.size()) { cout << "," << v[i_debug]; }                     \
  cout << ")" << endl;
#define mdebug(m)                                                              \
  cout << #m << "=" << endl;                                                   \
  REP(i_debug, m.size()) {                                                     \
    REP(j_debug, m[i_debug].size()) { cout << m[i_debug][j_debug] << ","; }    \
    cout << endl;                                                              \
  }
#define Lower_bound(v, x)                                                      \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x)                                                      \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)

#define ll long long
#define ld long double
// #define f first
// #define s second
#define mp make_pair
#define pb push_back
#define INF 1000000000000000000

using vec = vector<ll>;
using mat = vector<vec>;
using Pii = pair<ll, ll>;
using PiP = pair<ll, Pii>;
using PPi = pair<Pii, ll>;
using bvec = vector<bool>;
using Pvec = vector<Pii>;
// constexpr ll MOD = 998244353;

template <typename T> void readv(vector<T> &a) { REP(i, a.size()) cin >> a[i]; }
void readv_m1(vector<int> &a) {
  REP(i, a.size()) {
    cin >> a[i];
    a[i]--;
  }
}
// constexpr ll MOD=1000000007ll;
constexpr ll MOD = 998244353;
constexpr ll MAX = 510000;

ll fact[MAX], fact_inv[MAX];

// 繰り返し二乗法
ll power(ll a, ll b) {
  ll res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % MOD;
    a = a * a % MOD;
    b >>= 1;
  }
  return res;
}

ll comb(ll n, ll r) {
  return (fact[n] * fact_inv[r]) % MOD * fact_inv[n - r] % MOD;
}

int main() {
  ll N, M, K;
  cin >> N >> M >> K;
  ll ans = 0;

  ll n = max(N, M);
  // cin>>n;
  fact[0] = 1;
  // 階乗の計算
  // debug(fact[0]);
  REP(i, n) fact[i + 1] = fact[i] * (i + 1) % MOD;
  fact_inv[n] = power(fact[n], MOD - 2);
  // 逆元の計算
  IFOR(i, n, 0) fact_inv[i] = fact_inv[i + 1] * (i + 1) % MOD;
  // debug(fact_inv[n - 1]);
  REP(i, K + 1) {
    // debug(M * power(M - 1, N - i - 1) * comb(N - 1, i));
    ans += (M * power(M - 1, N - i - 1)) % MOD * comb(N - 1, i) % MOD;
    ans %= MOD;
    // debug(power(M - 1, N - i - 1));
    // debug(comb(N - 1, i));
    // debug(ans);
    // debug(Mm * (Mm - 1).power(N - K - 1));
    // debug((Nm - 1).nCr(Km));
  }

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

Measured memory_bytes: 6748
#include<vector>
#include<iostream>
#include<string>
#include<algorithm>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
#include<stack>
#include<string.h>
#include<list>
#define MOD 1000000007LL
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
int main() {
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    double mn=0;
    int mw=0;
    int ms=0;
    for(int i=0;i*a*100<=f;i++){
        for(int j=0;i*a*100+j*b*100<=f;j++){
            for(int k=0;(k*c+i*a*100+j*b*100<=f)&&(k*c<=i*a*e+j*b*e);k++){
                for(int l=0;(l*d+k*c+i*a*100+j*b*100<=f)&&(k*c+l*d<=i*a*e+j*b*e);l++){
                    int w=i*a*100+j*b*100;
                    int s=l*d+k*c;
                    double n;
                    if(w+s!=0){n=(double)(100*s)/(double)(w+s);}else{n=0;}
                    if(w*e>=100*s){
                        if(n>mn){
                            mn=n;
                            mw=w;
                            ms=s;
                        }
                    }
                }
            }
        }
    }
    if(mw==0){
        mw=a*100;
    }
    cout<<mw+ms<<" "<<ms<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

struct MyTrie {
    MyTrie* next[26];
    int leaf;
    MyTrie() {
        leaf = 0;
        for (int i = 0; i < 26; i++) {
            next[i] = nullptr;
        }
    }
    ~MyTrie() {
        for (int i = 0; i < 26; i++) {
            if (next[i]) {
                delete next[i];
            }
        }
    }
};

void insert_word(struct MyTrie* root, const string& s, int pos) {
    if (pos == s.size()) {
        root->leaf += 1;
        return;
    }
    char c = s[pos];
    if (root->next[c - 'a'] == nullptr) {
        root->next[c - 'a'] = new MyTrie();
    }
    insert_word(root->next[c - 'a'], s, pos + 1);
}

struct MyTrie* find_word(struct MyTrie* root, const string& s, int pos) {
    if (s.size() == pos) {
        return root;
    }
    char c = s[pos];
    if (root->next[c - 'a'] == nullptr) {
        return nullptr;
    }
    return find_word(root->next[c - 'a'], s, pos + 1);
}

int main() {
    int n;
    cin >> n;
    vector<string> vs;
    string s;
    struct MyTrie* root = new MyTrie();
    for (int i = 0; i < n; i++) {
        cin >> s;
        reverse(s.begin(), s.end());
        vs.push_back(s);

        insert_word(root, s, 0);
    }
    long long int res = 0;
    for (int i = 0; i < n; i++) {
        vector<int> v(26, 0);
        for (auto ss : vs[i]) {
            v[ss - 'a']++;
        }
        
        struct MyTrie* base = root;
        for (int k = 0; k < 26; k++) {
            if (base->next[k] != nullptr && v[k] > 0) {
                res += base->next[k]->leaf;
            }
        }
        for (int j = 0; j < vs[i].size(); j++) {
            v[vs[i][j] - 'a']--;
            base = base->next[vs[i][j] - 'a'];
            if (base == nullptr) break;
            for (int k = 0; k < 26; k++) {
                if (base->next[k] != nullptr && v[k] > 0) {
                    res += base->next[k]->leaf;
                }
            }
        }
    }
    cout << res - n << endl;
}




Measured memory_bytes: 223040
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i < n; i ++)
#define _min(x, y) x = min(x, y)
#define _max(x, y) x = max(x, y)
using namespace std;


int main() {
  long N, L;
  long aji = 0, tabeta = 500; 
  cin >> N >> L;

  rep(i, N) {
    aji += L;
    if (abs(tabeta) >= abs(L)) tabeta = L;
    L += 1;
  }
  cout << aji - tabeta << endl;
  return 0;
}


Measured memory_bytes: 256
/*|-----------|
  | templatka |
  |  Tomasz   |
  |   Zyla    |
  |-----------|*/

#include <bits/stdc++.h>

#define mp make_pair
#define pb push_back
#define f first
#define s second

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tiii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef set<int> si;
typedef set<ll> sll;
typedef list<int> li;
typedef list<ll> lll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef map<string,int> msi;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
typedef unordered_map<string,int> umsi;
typedef queue<int> qi;
typedef queue<ll> qll;
typedef priority_queue<int> pqi;
typedef priority_queue<ll> pqll;

int main() {
	ios::sync_with_stdio(false); cin.tie(0);
	int n; cin >>n;
	cout << n/2 + n%2;
	
	
	return 0;
}









Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
#define rep(i, begin, n) for (int i = begin; i < n; i++)
#define repe(i, begin, n) for (int i = begin; i <= n; i++)
#define repr(i, begin, n) for (int i = begin; i > begin - n; i--)
#define repre(i, begin, end) for (int i = begin; i >= end; i--)

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

const int inf = 1000000007;
const int MOD = 1000000007;
const long long INF = 1000000000000000007;

// -------------------------------------------------------
int N;
string S;
int Easts[301010];

int main() {
  cin >> N >> S;
  rep(i, 0, N) {
    if (S[i] == 'E') {
      Easts[i + 1] = Easts[i] + 1;
    } else {
      Easts[i + 1] = Easts[i];
    }
  }

  int ans = inf;
  repe(i, 1, N) {
    int cost = 0;
    cost += (i - 1) - Easts[i - 1];
    cost += Easts[N] - Easts[i];
    chmin(ans, cost);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  int N;
  cin >> N;
  if (N <= 2)
  {
    cout << 1 << endl;
    return 0;
  }
  vector<ll> a(N), b;
  for (int i = 0; i < N; i++)
    cin >> a[i];
  for (int i = 0; i < N - 1; i++)
  {
    ll dif = a[i + 1] - a[i];
    if (dif == 0)
      continue;
    b.push_back(dif);
  }
  int ans = 1;
  for (int i = 0; i < b.size() - 1; i++)
  {
    if (b[i] * b[i + 1] < 0)
    {
      ans++;
      i++;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2168
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQG = priority_queue<T, vector<T>, greater<T> >;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, W;
    cin >> n >> W;
    vi v(n), w(n);
    rep(i, n) {
        cin >> v[i] >> w[i];
    }

    vi dp(10001, W+1);
    dp[0] = 0;
    rep(i, n) {
        for(int j = 10000-v[i]; j >= 0; --j) {
            dp[j+v[i]] = min(dp[j+v[i]], dp[j] + w[i]);
        }
    }

    int ans = 0;
    rep(i, 10001) if(dp[i] <= W) ans = i;
    cout << ans << endl;
}


Measured memory_bytes: 3228
#include<iostream>
#include <stdio.h>
#include <string>
#include <string.h>
#include <algorithm>
#include <functional>
#include <vector>
#include <math.h>

using namespace std;
int main()
{
	long long N, X;
	long long x[100010];
	cin >> N >> x[0];

	N = N + 1;

	for (long long i = 1; i < N; i++) {
		cin >> x[i];
	}

	sort(x, x + N);

	for (long long i = 1; i < N; i++) {
		x[i] = x[i] - x[0];
	}
	x[0] = 0;

	long long D = x[1] - x[0];
	long long temp = D;
	for (long long i = 1; i < N; i++) {
		long long a = x[i];
		long long b = D;
		while (1) {
			temp = a % b;
			if (temp == 0) {
				D = b;
				break;
			}
			else {
				a = b;
				b = temp;
			}
		}
	}

	cout << D;

	return 0;
}


Measured memory_bytes: 1024
#include <iostream>

using namespace std;

int main(){
	
	cin.tie(0); ios_base::sync_with_stdio(0);
	long long n,x;
	cin>>n;
	int res = 0;
	for(long long i = 2;i*i<=n;i++)if(n%i==0){
		x = n;
		while(x%i==0)x/=i;
		if(x%i==1)res++;
		if(n/i!=i){
			long long d = n/i;
			x = n;
			while(x%d==0)x/=d;
			if(x%d==1)res++;
		}
	}
	else if((n-1)%i==0){
		res++;
		if((n-1)/i!=i)res++;
	}
	res+=1;
	if(n>2)res++;
	cout<<res<<endl;
	
	return 0;
}

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

using namespace std;

#define ll long long
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<pii> vpii;
typedef vector<vpii> vvpii;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef set<int> si;
typedef set<vi> svi;
typedef set<ll> sll;
typedef set<vll> svll;
typedef set<pii> spii;
typedef set<vpii> svpii;
typedef set<pll> spll;
typedef set<vpll> svpll;
typedef vector<si> vsi;
typedef vector<sll> vsll;
typedef vector<spii> vspii;
typedef vector<spll> vspll;
#define ft first
#define sc second
#define pb push_back
#define ins insert
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define all(v) v.begin(),v.end()
#define Sort(v) sort(all(v))
#define sortarr(a,n) sort(a,a+n)
#define tt ll tc; cin >> tc; while(tc--)
#define rep(var,start,end,interval) for(ll var=start;(interval>0 and var<end) or (interval<0 and var>end);var+=interval)
#define each(x,v) for(auto x : v)
#define takearr0(a,n) rep(z,0,n,1) cin >> a[z];
#define takearr1(a,n) rep(z,1,n+1,1) cin >> a[z];

const ll max_n = 2e5 + 5;

ll n;

int main()
{
	io;
	cin >> n;
	vll a(n);
	takearr0(a,n);
	ll ans = 0;
	rep(i,1,n,1)
	{
		if(a[i] < a[i-1])
		{
			ans += a[i-1] - a[i];
			a[i] = a[i-1];
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4776
/* 
 * File:   main.c
 * Author: s1252007
 *
 * Created on June 19, 2018, 10:55 AM
 */

#include <stdio.h>
#include <stdlib.h>

/*
 * 
 */

int bubbleSort(
    int a[],
    int n
);

int main(int argc, char** argv) {
    int size, counter;
    int *A;
    
    scanf("%d", &size);
    A = (int *)malloc(sizeof(int) * size);
    for (int ix = 0; ix < size; ++ix) scanf("%d", &A[ix]);
    counter = bubbleSort(A, size);
    for (int ix = 0; ix < size; ++ix)
    {
        if (ix > 0) printf(" ");
        printf("%d", A[ix]);
    }
    printf("\n");
    printf("%d\n", counter);
    return (EXIT_SUCCESS);
}

int bubbleSort( int a[], int n )
{
    int counter = 0;
    for( int i = 1; i < n; ++i )
	{
            for( int j = n-1; j >= i; --j )
            {
                if( a[j] < a[j-1] )
                {
                    int copy;
                    copy = a[j];
                    a[j] = a[j-1];
                    a[j-1] = copy;
                    counter++;
                }
            }
	}
    return counter;
}




Measured memory_bytes: 2140
import sys
import math
from collections import defaultdict

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N,num):
    if N<=0:
        for _ in range(num): return []
    elif num==1:
        return [I() for _ in range(N)]
    else:
        read_all = [tuple(II()) for _ in range(N)]
        return map(list,zip(*read_all))

#################

#強連結成分分解
#label：グループ数
#group[i]：i個目のノードが所属するグループ
def scc(N, G, RG):
    used = [False]*N
    group = [None]*N
    order = []
    def dfs(S):
        used[S[0]] = True
        while S:
            v1 = S.pop()
            for v1_to in G[v1]:
                if not used[v1_to]:
                    used[v1_to] = True
                    S.append(v1_to)
            order.append(v1)
    for i in range(N):
        if not used[i]:
            dfs([i])
    def rdfs(S,col):
        used[S[0]] = True
        while S:
            v1 = S.pop()
            for v1_to in RG[v1]:
                if not used[v1_to]:
                    used[v1_to] = True
                    S.append(v1_to)
            group[v1] = col
    used = [False]*N
    label = 0
    for s in order:
        if not used[s]:
            rdfs([s], label)
            label += 1
    return label, group

N,M = II()
X,Y,Z = Line(M,3)

graph = [[] for _ in range(N)]
for i in range(M):
    graph[X[i]-1].append(Y[i]-1)
    graph[Y[i]-1].append(X[i]-1)

label,group = scc(N,graph,graph)
print(label)

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

#define ff first
#define ss second
#define pb push_back

using namespace std;
using ll = long long;
using ii = pair<int, int>;

const int N = 100005;

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	printf("%d\n", 6 - a - b);
	return 0;
}


Measured memory_bytes: 256
k = int(input())

seq = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(seq[k - 1])

Measured memory_bytes: 38256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

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

  int ans = 0;
  for(int i=0;i<3;i++){
    if(s[i] == '1') ans++;
  }

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


Measured memory_bytes: 256
program triple_dots
  implicit none
  integer :: k, n
  character(100) :: s
  read(*,*) k
  read(*,*) s
  n = len_trim(s)
  if (n > k) then
    write(*,'(a)') s(1:k)//'...'
  else
    write(*,'(a)') s(1:n)
  end if
end program triple_dots

Measured memory_bytes: 2924
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define F_ first
#define S_ second

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

const int INF=1<<30;
const long long int INF_=1<<60;

int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int N;
    while(cin >> N&&N){
		int Y,ans;
		double max_=0;
		cin >> Y;
		REP(i,0,N){
			double B,R,T;
			cin >> B >> R >> T;
			double tmp=1;
			if(T==1) tmp=1.+Y*R/100;
			else{
				REP(j,0,Y) tmp*=1.+R/100;
			}
			//cout << tmp << endl;
			if(tmp>max_){
				max_=tmp;
				ans=B;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1236
N,M = map(int,input().split())
wa_list= [0]*(N+2)
ac_list=[-1]*(N+2)
for i in range(M):
  p,a = map(str,input().split())
  p = int(p)
  if a =='WA':
    wa_list[p]+=1
  if a =='AC' and ac_list[p] == -1:
    ac_list[p]+=(wa_list[p]+1)
count = 0;count2 = 0
for i in ac_list:
  if i>=0:
    count+=1
    count2+=i
print(count,count2)
    


Measured memory_bytes: 10448
ninzu=input()
dama_sum=0

for a in range(int(ninzu)):
    dama=input()
    dama_spl=dama.split(" ")
    if dama_spl[1]=="JPY":
        r=1
    else:
        r=380000
    dama_sum += float(dama_spl[0])*r
print(dama_sum)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1e9+7;
const LL LINF=1LL<<62;

int n, k, mx, mi, a[200005];
map<int, int> ma;
int main() {
	int i;
	scanf("%d", &n);
	for(i=1; i<=n; i++) {
		scanf("%d", a+i);
		k = ma[a[i]] = ma[a[i]-1] + 1;
		if(k>mx) mx = k, mi = a[i];
	}
	printf("%d\n",n-mx);
	return 0;
}

Measured memory_bytes: 10368
#include <bits/stdc++.h>
using namespace std;
int N,L[10];
int main(){
    cin>>N;
    for(int i=0 ; i<N ; i++)cin>>L[i];
    sort(L,L+N);
    int sum=0;
    for(int i=0 ; i<N-1 ; i++)sum+=L[i];
    if(sum>L[N-1])cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstring>

using namespace std;

struct Circle {
    int x, y, r, c;
    Circle() {}
    Circle(int x, int y, int r, int c)
        : x(x), y(y), r(r), c(c) {}
};

int n;
vector<char> dp;
vector<int> up;
vector<Circle> c(24);

inline bool isOverlap(const Circle &a, const Circle &b)
{
    return (a.r + b.r) * (a.r + b.r) > (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y);
}

int Rec(int s)
{
    if (~dp[s])
        return dp[s];

    int res = 0;
    // 取り除く2つの円の選択
    for (int i = 0; i < n; ++i) {
        // c[i]がないか取り除けない
        if (!(s >> i & 1) || s & up[i])
            continue;

        for (int j = i + 1; j < n; ++j) {
            // c[i]とc[j]の色が異なる  c[j]がないか取り除けない
            if (c[i].c != c[j].c || !(s >> j & 1) || s & up[j])
                continue;

            res = max(res, Rec(s & ~(1 << i) & ~(1 << j)) + 2);
        }
    }

    return dp[s] = res;
}

int main()
{
    while (cin >> n, n) {
        dp.assign(1 << n, -1);
        up.assign(n, 0);

        // 円の入力
        for (int i = 0; i < n; ++i)
            cin >> c[i].x >> c[i].y >> c[i].r >> c[i].c;

        // 円の重なり，上下関係
        for (int i = 0; i < n; ++i)
            for (int j = i + 1; j < n; ++j)
                if (isOverlap(c[i], c[j]))
                    up[j] |= (1 << i);

        cout << Rec((1 << n) - 1) << endl;
    }

    return 0;
}

Measured memory_bytes: 17420
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;

int main()
{
	int N;
	int maxi = -100000;
	int count = 0;
	int ans = 0;
	vector<unsigned long long int> H;
	cin >> N;
	for (int i = 0; i < N; i++) {
		unsigned long long int t;
		cin >> t;
		H.push_back(t);
	}
	for (int i = 0; i < N - 1; i++) {
		if (H[i] < H[i + 1]) {
			count = 0;
		}
		else
			count++;
		ans = max(ans, count);
	}

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

Measured memory_bytes: 3844
// https://atcoder.jp/contests/abc118/tasks/abc118_b

#include <bits/stdc++.h>
#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 INF 1e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

int main()
{
  /* Magic word */
  // cin.tie(0);
  // ios::sync_with_stdio(false);
  /* ---------- */

  int n, m;
  cin >> n >> m;

  vector<int> mm;
  REP(i, m)
  {
    mm.push_back(0);
  }
  REP(i, n)
  {
    int k;
    cin >> k;
    REP(j, k)
    {
      int a;
      cin >> a;
      mm[a - 1]++;
    }
  }

  cout << count(ALL(mm), n) << '\n';

  return 0;
}


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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#else
#define TEST(n) ((void)0)
#endif

using namespace std;

int D[2][2001], V[2001], N, Z, W;

int solve(int t, int a)
{
	int A = (a ? V[a] : t ? W : Z);
	if (D[t][a] != -1) return D[t][a];
	D[t][a] = abs(V[N] - A);
	if (t) {
		for (int i = a + 1; i < N; i++) {
			D[t][a] = max(D[t][a], solve(!t, i));
		}
	}
	else {
		for (int i = a + 1; i < N; i++) {
			D[t][a] = min(D[t][a], solve(!t, i));
		}
	}
	return D[t][a];
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt", "r", stdin));
	TEST(freopen("output.txt", "w", stdout));
	TEST(freopen("debug.txt", "w", stderr));
	cin >> N >> Z >> W;
	for (int i = 1; i <= N; i++) cin >> V[i];
	memset(D, -1, sizeof(D));
	cout << solve(1, 0) << '\n';
	return 0;
}

Measured memory_bytes: 384
S = gets.chomp

ok = true
S.chars.each_with_index do |c, i|
  if c == 'U' || c == 'D'
    next
  end

  if c == 'R' && i.odd?
    ok = false
  end

  if c == 'L' && i.even?
    ok = false
  end
end

if ok
  puts 'Yes'
else
  puts 'No'
end


Measured memory_bytes: 1916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;

int main(){

  int x, a, b;
  cin >> x >> a >> b;

  if (abs(x - a) > abs(x - b)){
    cout << "B" << endl;
  }
  else {
    cout << "A" << endl;
  }

  return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    REP(i, n)
    {
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    ll ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            int left = upper_bound(l.begin(), l.end(), abs(l[i] - l[j])) - l.begin();
            int right = lower_bound(l.begin(), l.end(), l[i] + l[j]) - l.begin();
            int id = lower_bound(l.begin(), l.end(), l[i] + l[j]) - upper_bound(l.begin(), l.end(), abs(l[i] - l[j]));
            left = max(left, j + 1);
            ans += max(right - left, 0);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>
#include <numeric>
#include <iostream>
#include <random>
#include <map>
#include <unordered_map>
#include <queue>
#include <regex>
#include <functional>
#include <complex>
#include <list>
#include <cassert>
/*多倍長整数/cpp_intで宣言
#include <boost/multiprecision/cpp_int.hpp>
using namespace boost::multiprecision;
*/

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define rep2(i, n) for(int i = 2; i < (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printin(a) printf(a ? "possible\n" : "imposible\n")
#define printdb(a) printf("%.50lf\n", a)//少数出力
#define printdbd(a) printf("%.16lf\n", a)//少数出力(桁少なめ)
#define prints(s) printf("%s\n", s.c_str())//string出力
#define all(x) (x).begin(), (x).end()
#define allsum(a, b, c) ((a + b) * c / 2)//等差数列の和、初項,末項,項数
#define pb push_back
#define priq priority_queue
#define rpriq priq<int, vector<int>, greater<int>>
#define deg_to_rad(deg) (((deg)/360.0)*2.0*PI)
#define rad_to_deg(rad) (((rad)/2.0/PI)*360.0)
#define Please return
#define AC 0
#define addf(T) [](T a, T b){return (a + b);}
#define minf(T) [](T a, T b){return min(a, b);}
#define maxf(T) [](T a, T b){return max(a, b);}


using ll = long long;

constexpr int INF = 1073741823;
constexpr int MINF = -1073741823;
constexpr ll LINF = ll(4661686018427387903);
constexpr ll MOD = 1000000007;
const long double PI = acos(-1.0L);

using namespace std;

void scans(string& str) {
	char c;
	str = "";
	scanf("%c", &c);
	if (c == '\n')scanf("%c", &c);//最初の改行対策
	while (c != '\n' && c != -1) {
		str += c;
		scanf("%c", &c);
	}
}

void scanc(char& str) {
	char c;
	scanf("%c", &c);
	if (c == -1)return;
	while (c == '\n') {
		scanf("%c", &c);
	}
	str = c;
}

double acot(double x) {
	return PI / 2 - atan(x);
}

ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

ll lcm(ll number1, ll number2) {//lcmを求める
	return number1 / gcd(number1, number2) * number2;
}

ll LSB(ll n) { return (n & (-n)); }

/*-----------------------------------------ここからコード-----------------------------------------*/



int main() {

	int n;
	scanf("%d", &n);
	int cnt = 0, ans = 0;
	rep1(i, n) {
		cnt = 0;
		rep1(j, i) {
			if (i % j == 0)++cnt;
		}
		ans += (cnt == 8);
		++i;
	}
	printf("%d\n", ans);

	Please AC;
}


Measured memory_bytes: 760
#include <stdio.h>
#include <math.h>

int main(void) {
  int A, B, K, r;
  scanf("%d %d %d", &A, &B, &K);

  for (int i = A; i <= B; i++) {
    if (i >= A + K) {
      i = (i > (r = B - K + 1)) ? i : r;
    }
    printf("%d\n", i);
  }

  return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }

typedef long long ll;



int main() {
    int A,B;
    cin >> A >> B;
    int ans = 0;
    if (1 <= A && A <= 9 && 1 <= B && B <= 9) ans = A*B;
    else ans = -1;
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
N, M = (int(i) for i in input().split())  
X = [int(i) for i in input().split()] 
lg_bw_x = [] 
s= 0
if N >= M:
    print(0)
else:
    X.sort()
    for i in range(M-1):
        lg_bw_x.append(X[i+1] - X[i])
    lg_bw_x.sort()
    for j in range(M-N):
        s = s+lg_bw_x[j]
    print(s)

Measured memory_bytes: 13840
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <cctype>
#include <ctime>
#include <set>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <utility>
#include <string>
#include <map>
#define ll long long

using namespace std;

const int M = 1000000007;

int a, b, c;

int main() {

	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	
	cin >> a >> b;
	
	c = max(a+b, a-b);
	cout << max(c, a*b);
	
return 0;
}




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

int main() {
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;
  if (e - a > k)
  {
    cout << ":(" << endl;
  }
  else
  {
    cout << "Yay!" << endl;
  }
}

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

int main() {
  int n;
  float m,sum;
  int x = 0;
  cin >> n >> m;
  vector<int> a(n);
  for(int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sum = std::accumulate(a.begin(),a.end(),0);
  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());
  
  for(int i = 0; i < m; i++) {
    if(a.at(i) / sum < 1 / (m * 4)) {
      x = 1;
      break;
    }
  }
  
  if(x == 1) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define mod 1000000007
#define ll long long
using namespace std;
int a[22][22];
void input(){
	#ifndef ONLINE JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}
int dp[22][(1<<22)];
int ways(int i,int n,int val){
	if(i==n+1){
		return 1;
	}
	if(dp[i][val]!=-1){
		return dp[i][val];
	}
	int w=0;
	for(int j=1;j<=n;j++){
		if(((1<<(j-1))&val)==0 and a[i][j]==1){
			w=(w+ways(i+1,n, val|(1<<(j-1))))%mod;
		}
	}
	return dp[i][val]=w;
}
int main(){
	//input();
	int n; cin>>n;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=n;j++){
			cin>>a[i][j];
		}
	}
	memset(dp,-1,sizeof(dp));
	cout<<ways(1,n,0);	
}

Measured memory_bytes: 364100
import  java.util.*;
class Main{
    int N;
    int K;
    int P;
    Main(){
	Scanner sc=new Scanner(System.in);
	N=sc.nextInt();
	for(int i=0; i<N; i++){
	    K=sc.nextInt();
	    P=sc.nextInt();
	    
	    if(K%P==0){
		System.out.println(P);
	    }else{
		System.out.println(K%P);
	    }
	}
    }

    public static void main(String[] args){
	new Main();
    }
}

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

int vector_finder(std::vector<int> vec, int number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<vector<char>> data(H, vector<char>(W));
 
  for (int w_i = 0; w_i < H; w_i++) {
	for (int h_i = 0; h_i < W; h_i++) {
    		cin >> data.at(w_i).at(h_i);
	}
  }

 vector<vector<char>> yoko_data(W, vector<char>(H));
  
  //yoko data input
  for (int w_i = 0; w_i < H; w_i++) {
	for (int h_i = 0; h_i < W; h_i++) {
        yoko_data.at(h_i).at(w_i) =  data.at(w_i).at(h_i);
	}
	//cout<<endl;
  }
  
  //yoko print
  /*
  for (int w_i = 0; w_i < W; w_i++) {
	for (int h_i = 0; h_i < H; h_i++) {
    		cout <<  yoko_data.at(w_i).at(h_i);
	}
	cout<<endl;
  }*/
  
//yoko wo kesu
  
  vector<int> v; 
  int count_h=0;
  int count_w=0;
  int point_h=0;
  
  for (int w_i = 0; w_i < H; w_i++) {
  	count_w=0;
	for (int h_i = 0; h_i < W; h_i++) {
    		if(data.at(w_i).at(h_i)=='.'){
    			count_w+=1;
    		}
    		point_h=w_i;
	
	if(count_w==W){
		v.push_back(point_h);
		point_h=0;
	}
	}
  }
  
  vector<int> v2; 
  int count_h2=0;
  int count_w2=0;
  int point_h2=0;
  
  for (int w_i = 0; w_i < W; w_i++) {
  	count_w2=0;
	for (int h_i = 0; h_i < H; h_i++) {
    		if(yoko_data.at(w_i).at(h_i)=='.'){
    			count_w2+=1;
    		}
    		point_h2=w_i;
	
	if(count_w2==H){
		v2.push_back(point_h2);
		point_h2=0;
	}
	}
  }
;
  for (int w_i = 0; w_i < H; w_i++) {
  //yoko
  	if(vector_finder(v,w_i)==1){
  		continue;
  	}
	for (int h_i = 0; h_i < W; h_i++) {
    	if(vector_finder(v2,h_i)==1){
  		continue;
  	    }
       cout <<  data.at(w_i).at(h_i);
	}
	cout<<endl;
  }


}


Measured memory_bytes: 256
package main

import (
  "fmt"
)

func main() {
  var n int 
  fmt.Scan(&n)
  a := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&a[i]); a[i]--
  }
  now := 0
  for i := 0; i < n; i++ {
    if now == 1 {
      fmt.Println(i)
      return
    }
    now = a[now]
  }
  fmt.Println(-1)
}

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

int main() {
  int a,b,c,x;
  cin >> a>>b>>c>>x;
  int count=0;
  
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      for(int k=0;k<=c;k++){
        if(i*500+j*100+k*50==x){
          count+=1;
        }
      }
    }
  }
  
  cout<<count<<endl;
    
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <limits>
#include <sstream>
#include <fstream>
#include <climits>
#include <map>
#include <numeric>
#include <functional>
#include <utility>

using namespace std;

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

int main(void) {
  int a, b;
  cin >> a >> b;
  stringstream ss;
  ss << a << b;
  int x = stoi(ss.str());
  int sq = (int)sqrt(x);
  bool ans = false;
  for (int i = x - 1; i <= x + 1; i++) {
    if (x % sq == 0) {
      ans = true;
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double EPS = 1e-8, INF = 1e12, PI = acos(-1.0);
typedef complex<double> P;
namespace std{
	bool operator<(const P& a, const P& b){
		return real(a) != real(b) ? real(a) < real(b) : imag(a) < imag(b);
	}
}
inline double cross(const P& a, const P& b){ return imag(conj(a)*b); }
inline double dot(const P& a, const P& b){ return real(conj(a)*b); }
struct L : public vector<P>{
	L(const P &a, const P &b) {
		push_back(a); push_back(b);
	}
};
typedef vector<P> G;

inline int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if(cross(b, c) > EPS)   return +1;		// counter clockwise
	if(cross(b, c) < -EPS)   return -1;		// clockwise
	if(dot(b, c) < -EPS)     return +2;		// c--a--b on line
	if(norm(b) + EPS < norm(c)) return -2;		// a--b--c on line
	return 0;
}
P projection(const L &l, const P &p) {
  double t = dot(p-l[0], l[0]-l[1]) / norm(l[0]-l[1]);
  return l[0] + t*(l[0]-l[1]);
}
P reflection(const L &l, const P &p) {
  return p + 2.0 * (projection(l, p) - p);
}
P crosspoint(const L &l, const L &m) {
  double A = cross(l[1] - l[0], m[1] - m[0]);
  double B = cross(l[1] - l[0], l[1] - m[0]);
  if (abs(A) < EPS && abs(B) < EPS) return m[0]; // same line
  if (abs(A) < EPS) assert(false); // !!!PRECONDITION NOT SATISFIED!!!
  return m[0] + B / A * (m[1] - m[0]);
}
bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) == -1 &&
         ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) == -1;
}

int n;
P s, t;
vector<L> ms;
vi use;
double ans;

void rec(int c){
	bool ok = 1;
	P tt = t, cur = s;
	vector<L> tms = ms;
	rep(i, c){
		rep(j, n) rep(k, 2) tms[j][k] = reflection(tms[use[i]], tms[j][k]);
		tt = reflection(tms[use[i]], tt);
	}
	tms = ms;
	L l(cur, tt);
	
	rep(i, c){
		if(!intersectSS(l, tms[use[i]])){
			ok = 0;
			break;
		}
		P cp = crosspoint(l, tms[use[i]]);
		
		rep(j, n) if(j != use[i] && intersectSS(l, tms[j])){
			P p = crosspoint(l, tms[j]);
			if(abs(p - cur) + EPS < abs(cp - cur)) ok = 0;
		}
		if(!ok) break;
		
		l[0] = crosspoint(l, tms[use[i]]);
		rep(j, n) rep(k, 2) tms[j][k] = reflection(tms[use[i]], tms[j][k]);
	}
	rep(i, n) if(intersectSS(l, tms[i])) ok = 0;
	if(ok) ans = min(ans, abs(s - tt));
	
	if(c >= 5) return;
	rep(i, n) if(c == 0 || use.back() != i){
		use.pb(i);
		rec(c + 1);
		use.pop_back();
	}
}

int main(){
	while(cin >> n, n){
		ms.clear();
		rep(i, n){
			int a, b, c, d;
			cin >> a >> b >> c >> d;
			ms.pb(L(P(a, b), P(c, d)));
		}
		cin >> s.real() >> s.imag() >> t.real() >> t.imag();
		ans = INF;
		use.clear();
		rec(0);
		printf("%.9f\n", ans);
	}
	return 0;
}

Measured memory_bytes: 1296
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e9;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
int main(){
	int n;
	cin>>n;
	while(n--){
/*		unsigned a;
		scanf("%x",&a);
		int x=(a&0x7fffffffu)>>7;
		if(a>>31)cout<<"-";
		cout<<x<<".";
*/	
		string s="";
		rep(i,8){
			string q="";
			char c;cin>>c;
			int t;
			if(isalpha(c))t=c-'a'+10;
			else t=c-'0';
			rep(j,4){
				q=(char)(t%2+'0')+q;
				t/=2;
			}
			s+=q;
		}
		int out=0;
		int t=1;
		for(int i=24;i>0;i--){
			out+=t*(s[i]-'0');
			t*=2;
		}
		if(s[0]=='1')cout<<"-";
		cout<<out<<".";
		unsigned a=0,d=1;
		for(int i=31;i>=0;i--){
			a+=d*(s[i]-'0');
			d*=2;
		}
		int y=(a&0x7fu)*78125;
		d=7;
		while(d>1&&y%10==0){
			y/=10;--d;
		}
		printf("%0*d\n",d,y);
/*		int t,out;
		string s="";
		while(a){
			s=(char)(a%2+'0')+s;
			a/=2;
		}
		while(s.size()!=32)s="0"+s;
*/
/*
		t=100000000; 
		out=0;
		for(int i=25;i<32;i++){
			t/=2;
			out+=t*(s[i]-'0');
		}
		if(out==0)cout<<0<<endl;
		else{
			while(out%10==0)out/=10;
			cout<<out<<endl;
		}
*/
	}
}

Measured memory_bytes: 1252
#include <cstdint>
#include <cstdio>
#include <cassert>
#include <cctype>
#include <algorithm>
#include <string>
#include <vector>

int parse_int(typename std::string::iterator& it) {
  int res = *it-'0';
  while (isdigit(*++it))
    res = res*10 + *it-'0';
  return res;
}

int parse(typename std::string::iterator& it) {
  assert(*it == '[');
  ++it;

  int res;
  if (isdigit(*it)) {
    res = parse_int(it) / 2 + 1;
  } else {
    std::vector<int> c;
    while (*it == '[') {
      c.push_back(parse(it));
    }
    std::sort(c.begin(), c.end());
    res = 0;
    for (size_t i = 0; i <= c.size()/2; ++i) res += c[i];
  }

  assert(*it == ']');
  ++it;
  return res;
}

void solve_testcase() {
  char buf[16384];
  scanf("%s", buf);
  std::string s = buf;
  auto it = s.begin();
  printf("%d\n", parse(it));
}

int main() {
  int t;
  scanf("%d", &t);

  while (t--) solve_testcase();
}



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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int Q;
ll A,B;

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>Q;
	while(Q--) {
		cin>>A>>B;
		if(A>B) swap(A,B);
		ll ret=2*(A-1);
		
		int num=0;
		for(i=29;i>=0;i--) {
			num+=1<<i;
			if(A+num>B) {
				num-=1<<i;
				continue;
			}
			int ng=0;
			for(x=num/2-2;x<=num/2+2;x++) {
				if(x<=0 || x>num) continue;
				if((A+x)*(A+num-x)>=A*B) ng=1;
			}
			if(ng) num-=1<<i;
		}
		ret+=num;
		
		cout<<ret<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin >> n;
    vector <int> v(n);
    for(int i=0;i<n;++i) cin >> v[i];
    sort(v.begin(),v.end(),greater<int>());
    vector <double> ans(n);
    ans[n-1]=v[n-1]/pow(2,n-1);
    for(int i=0;i<n-1;++i) {
        ans[i]=v[i]/pow(2,i+1);
    }
    double sum=0;
    for(int i=0;i<n;++i) sum+=ans[i];
    cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
INF = 10 ** 20
n = int(input())
tlst = list(map(int, input().split()))
vlst = list(map(int, input().split()))
dp = [[-INF] * 201 for _ in range(n + 1)]
dp[0][0] = 0
for i in range(n):
    t, v = tlst[i], vlst[i]
    for v_fr in range(v + 1):
        pre_score = dp[i][v_fr]
        for v_to in range(v + 1):
            diff = abs(v_to - v_fr)
            if diff > t:continue
            max_speed = min((v_to + v_fr + t) / 2, v)
            dp[i + 1][v_to] = max(dp[i + 1][v_to], pre_score + max_speed * t - (max_speed - v_to) ** 2 / 2 - (max_speed - v_fr) ** 2 / 2)
print(dp[n][0])

Measured memory_bytes: 3316
n = int(input())
a = [int(x) for x in input().split()]
a.sort(reverse=True)
add, sub = [a[0]], [a[-1]]
for i in range(1, n-1):
    if a[i] >= 0:
        add.append(a[i])
    else:
        sub.append(a[i])
res = []
it = len(add)-1
while it > 0:
    res.append([sub[-1],add[it]])
    sub[-1] -= add[it]
    it -= 1
it = len(sub)-1
while it >= 0:
    res.append([add[0],sub[it]])
    add[0] -= sub[it]
    it -= 1
print(add[0])
print("\n".join([" ".join(map(str,x)) for x in res]))




Measured memory_bytes: 32352
#include <bits/stdc++.h>
using namespace std;
int N ;
int F [100][14];
int P [100][15];
int main (){
  scanf ("%d",&N);
  for(int i=0; i < N ; i++){
    for (int j=0; j<10; j++) scanf("%d" ,&F[i][j]);
}
  
  for(int i=0; i<N; i++) for(int j=0; j<11; j++) scanf("%d",&P[i][j]);
  int res = -(1<<30);
  for (int b=1; b<(1<<10); b++){
    int cc=0;
    for(int i=0; i<N; i++){
      int c=0;
      for (int j=0; j<10; j++) if ((b>>j &1)&& F[i][j]) c++;
      cc+= P[i][c];
    }
    if (res<cc) res=cc ;
  }
  printf ("%d\n",res);
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"sort"
	"strconv"
)

func main() {
	L := readi()
	R := readi()

	ans := INF
	for i := L; i < L+2019; i++ {
		if i >= R {
			break
		}
		for ii := R; ii >= R-2019; ii-- {
			if ii <= L {
				break
			}
			if i == ii {
				continue
			}
			ans = min(ans, ((i * ii) % 2019))
		}
	}

	fmt.Println(ans)
}

/*-------------------utilities-------------------*/

func abs(x int) int {
	if x < 0 {
		return -x
	}
	return x
}

func min(x, y int) int {
	if x < y {
		return x
	}
	return y
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

func chmin(x *int, y int) bool {
	if *x > y {
		*x = y
		return true
	}
	return false
}

func chmax(x *int, y int) bool {
	if *x < y {
		*x = y
		return true
	}
	return false
}

func gcd(a, b int) int {
	if b == 0 {
		return a
	}
	return gcd(b, a%b)
}

func lcm(a, b int) int {
	return (a * b) / gcd(a, b)
}

func permutations(arr []int) [][]int {
	var helper func([]int, int)
	res := [][]int{}

	helper = func(arr []int, n int) {
		if n == 1 {
			tmp := make([]int, len(arr))
			copy(tmp, arr)
			res = append(res, tmp)
		} else {
			for i := 0; i < n; i++ {
				helper(arr, n-1)
				if n%2 == 1 {
					tmp := arr[i]
					arr[i] = arr[n-1]
					arr[n-1] = tmp
				} else {
					tmp := arr[0]
					arr[0] = arr[n-1]
					arr[n-1] = tmp
				}
			}
		}
	}
	helper(arr, len(arr))
	return res
}

func isPrime(n int) bool {
	if n == 1 {
		return false
	}
	for i := 2; i*i <= n; i++ {
		if n%i == 0 {
			return false
		}
	}
	return true
}

func divisor(n int) (res []int) {
	for i := 1; i*i <= n; i++ {
		if n%i == 0 {
			res = append(res, i)
			if i*i != n {
				res = append(res, n/i)
			}
		}
	}
	sort.Ints(res)
	return
}

/*-------------------init-------------------*/

const (
	INF = 1000000000000000000
	MOD = 1e9 + 7
)

var (
	readString func() string
)

func init() {
	readString = newReadString(os.Stdin)
}

/*-------------------inputs-------------------*/

func readi() int {
	return int(readi64())
}

func readi64() int64 {
	i, err := strconv.ParseInt(readString(), 0, 64)
	if err != nil {
		panic(err.Error())
	}
	return i
}

func readf() float64 {
	f, err := strconv.ParseFloat(readString(), 64)
	if err != nil {
		panic(err.Error())
	}
	return f
}

func newReadString(ior io.Reader) func() string {
	r := bufio.NewScanner(ior)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)

	return func() string {
		if !r.Scan() {
			panic("Scan failed")
		}
		return r.Text()
	}
}


Measured memory_bytes: 640
#include <stdio.h>
#include <iostream>
#include <algorithm>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)

int abs(int X, int Y) {
    return X > Y ? X - Y : Y - X;
}

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

    int A[N];
    REP(0, i, N) {
        cin >> A[i];
    }

    sort(A, A + N);

    printf("%d\n", abs(A[0], A[N - 1]));

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define inf 1e9+5
int k;
int frog(int *a,int i, int n, int *dp){
    if(i>=n-1){
        return 0;
    }
    if(dp[i]!=inf) return dp[i];

    for(int j=i+1;j<=i+k;j++){
        if(j<n){
            int smallAns = frog(a,j,n,dp) + abs(a[i]-a[j]);
            dp[i] = min(dp[i], smallAns); 
        }
    }
    return dp[i];
}

int main() {
    ll n;cin>>n>>k;
    int a[n]={0};
    for(int i=0;i<n;i++) cin>>a[i];
    int dp[n];
    for(int i=0;i<n;i++) dp[i] = inf;
    cout<<frog(a,0,n,dp)<<endl;
    //for(int i=0;i<n;i++) cout<<dp[i]<<" ";
}



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

int main (){
  int a, b;
  cin >> a >> b ;
  
    if(a%2 == 1 && b%2 == 1){
    cout << "Odd" << endl;
    }
	if(a%2 == 0 || b%2 == 0){
      cout << "Even" << endl;
    }
}

Measured memory_bytes: 256