akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main {
 	public static void main(String[] args){
    	
    	Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String b = sc.next();
		
		if(a.equals("H")){   
		    if(b.equals("H")){
		        System.out.println('H');
		    }
		    else{
		        System.out.println('D');
		    }
		}
		else{
		    if(b.equals("H")){
		        System.out.println('D');
		    }
		    else{
		        System.out.println('H');
		    }
		}
	}
 
}

Measured memory_bytes: 20688
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;
vector<ll> v(10000000);
ll b;
bool C(ll num){
    ll sum=0;
    rep(i,v.size()){
        if(v[i]>num){
            sum+=v[i]/num;
            if(!(v[i]%num)) sum--;
        }
    }
    return(b<sum);
}
bool hantei(ll num){
    if(num==0) return true;
    ll sum=0;
    rep(i,v.size()){
        if(v[i]>num){
            sum+=v[i]/num;
            if(!(v[i]%num)) sum--;
        }
    }
    if(sum<=b) return true;
    else return false;
}

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

    ll a,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    cin>>n>>b;
    priority_queue<long double> q;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    v.resize(n);
    rep(i,n)  {
        cin>>v[i];
    }
    if(b==0){
        maxi=v[n-1];
        rep(i,n-1){
            maxi=max(maxi,v[i]);
        }
        cout<<maxi<<endl;
        return 0;
    }
    ll ub=10e9+1;
    ll lb=0;
    for(ll i=0;i<100;i++){
        ll mid=(lb+ub)/2;
        if(mid==0) continue;
        if(C(mid)) lb=mid;
        else ub=mid;
    }
    if(hantei(ub)) cout<<ub<<endl;
    else cout<<lb<<endl;
    //cout<<"ub "<<ub<<" lb "<<lb<<endl;

    return 0;
}


Measured memory_bytes: 81200
#include <bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())

using namespace std;
typedef long long  ll;
const int N = 1e5 + 3;
int memo[N];
vector<int> a;

int solve(int rem){

    int &ret = memo[rem];
    if(~ret)
        return ret;

    ret = 0;
    for(int x : a)
        if(rem >= x)ret |= (!solve(rem - x));
    return ret;
}

int main(){
    int n , k;
    cin >> n >> k;
    a.resize(n);
    for(int &x : a)
        cin >> x;

    memset(memo , -1 , sizeof memo);
    cout << (solve(k) ? "First" : "Second") << "\n";
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

// ABC051 B - Sum of Three Integers
// 2020.06.13

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int K, S; cin >> K >> S;
  int ans = 0;
  REP(i, K+1){
    REP(j, K+1){
      if(S-i-j >= 0 && S-i-j <= K){
        ans++;
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
S = input()
S = S[::-1]
#print(S)

while True:
    if len(S) >= 7 and S[:7] =='remaerd':
        S = S[7:]
    elif len(S) >= 6 and S[:6] =='resare':
        S = S[6:]
    elif len(S) >= 5 and S[:5] =='maerd':
        S = S[5:]
    elif len(S) >= 5 and S[:5] =='esare':
        S = S[5:]
    else:
        print("NO")
        exit()
    if len(S) == 0:
        print("YES")
        exit()


Measured memory_bytes: 3188
import java.util.ArrayDeque;
import java.util.Deque;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int[][] g    = new int[n+1][n+1];
        int[] find   = new int[n+1];
        int[] finish = new int[n+1];
        
        for (int i = 0; i < n; i++) {
            int u = sc.nextInt();
            int k = sc.nextInt();
            for (int j = 0; j < k; j++) {
                int v = sc.nextInt();
                g[u][v] = 1;
            }
        }
        
        Deque<Integer> deq = new ArrayDeque<Integer>();
        int time = 0;
        for (int k = 1; k <= n; k++ ) {
            if (find[k] != 0) continue;
            
            deq.push(k);
            while(!deq.isEmpty()) {
                int top = deq.peek();
                if (find[top] == 0) find[top] = ++time;
                
                int j;
                for (j = 1; j <= n; j++) {
                    if (g[top][j] == 1 && find[j] == 0) {
                        deq.push(j);
                        find[j] = ++time;
                        break;
                    }
                }
                if (j == n + 1) {
                    deq.pop();
                    finish[top] = ++time;
                }
            }
        }
        
        for (int i = 1; i <= n; i++) {
            System.out.println(i + " " + find[i] + " " + finish[i]);
        }
    }
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;

struct Segtree{
    ll n;
    vector<ll> elm;
    Segtree(ll n) : n(n), elm(2 * n, 0){

    }

    void add(ll x, ll y, ll val){
        x += n;
        y += n - 1;
        while(x <= y){
            if(x & 1){
                elm[x++] += val;
                elm[x] %= MOD;
            }
            if(!(y & 1)){
                elm[y--] += val;
                elm[y] %= MOD;
            }
            x >>= 1;
            y >>= 1;
        }
    }

    ll get(ll x){
        ll val = 0;
        x += n;
        while(x){
            val += elm[x];
            val %= MOD;
            x /= 2;
        }
        return val;
    }
};

signed main()
{
    ll n, l;
    cin >> n >> l;
    vector<ll> a(n);
    for(auto& x : a)
        cin >> x;
    Segtree dp(l + 1);
    dp.add(0, 1, 1);
    for(ll i = 0; i < n; ++i){
        Segtree next(l + 1);
        for(ll j = 0; j <= l; ++j){
            next.add(j, min(j + a[i] + 1, l + 1), dp.get(j));
        }
        dp = move(next);
    }
    cout << dp.get(l) << endl;
}


Measured memory_bytes: 5456
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>

#define endl '\n'
#define fi first
#define se second
#define pb push_back
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
const int MOD = 1e9 + 7;
const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-8;
ll a[100005];
ll vis[100005];
int main() {
    int n, m; cin >> n >> m;
    memset(a, 0, sizeof(a));
    memset(vis, 0, sizeof(vis));
    for(int i = 0; i < m; ++i){
        int x; cin >> x;
        vis[x] = 1;
    }
    a[0] = 1;
    if(vis[1] == 0) a[1] = 1;
    else a[1] = 0;
    for(int i = 2; i <= n; ++i){
        if(vis[i] == 1){
            a[i] = 0;
            continue;
        }
        a[i] = (a[i - 1] + a[i - 2]) % MOD;
    }
    cout << a[n] << endl;
	return 0;
}

Measured memory_bytes: 1792
/* ITP1_8_C */
import java.io.*;

class Main
{
  static final int ALPHABET = 26;

  public static void main(String[] args)
  {
    int[] count = new int[ALPHABET];
    try{
      BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
      StringBuilder sb = new StringBuilder();
      String str = "";

      while((str = br.readLine()) != null){
        str = str.toLowerCase();

        for(char c : str.toCharArray()){
          if(Character.isLetter(c))
            count[c - 'a']++;
        }
      }

      for(int i = 0; i < count.length; i++){
        sb.append((char)('a' + i));
        sb.append(" : ").append(count[i]).append("\n");
      }
      System.out.print(sb);

    }catch(Exception e){
      System.out.println(e);
    }
  }
}

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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(aa, (v).size()) { cout << v[aa]; if (aa != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
ll min(ll a, int b) { return min(a, ll(b)); }
ll min(int a, ll b) { return min(ll(a), b); }
///(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)(´・ω・`)///

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k;
	cin >> n >> k;
	vi v(n);
	REP(i, n)cin >> v[i];
	sort(ALL(v),greater<int>());
	int ans = 0;
	REP(i, k)ans += v[i];
	cout << ans << endl;
}


Measured memory_bytes: 256
#include <vector>
#include <cstdio>
int main(){
	int N,L;
	for(;scanf("%d%d",&N,&L),L;){
		std::vector<std::pair<int,int> >v(N);
		for(int i=0;i<N;i++){
			char c;
			scanf(" %c%d",&c,&v[i].second);
			v[i].first=c=='L'?-1:1;
		}
		int rl,rr,f=1,t=0;
		for(;f;t++){
			rl=rr=f=0;
			for(int i=0;i<N;i++)if(v[i].second!=0&&v[i].second!=L){
				v[i].second+=v[i].first;
				if(v[i].second==0)rl=i+1;
				if(v[i].second==L)rr=i+1;
			}
			for(int i=0;i<N;i++)if(v[i].second!=0&&v[i].second!=L){
				f=1;
				for(int j=i+1;j<N;j++)if(v[i].second==v[j].second){
					v[i].first*=-1;
					v[j].first*=-1;
				}
			}
		}
		printf("%d %d\n",t,rl?rl:rr);
	}
}

Measured memory_bytes: 1032
N,M = tuple(map(int,input().split()))
from collections import defaultdict
graph = defaultdict(list)
for i in range(M):
  a,b = tuple(map(int,input().split()))
  graph[a].append(b)
  graph[b].append(a)
  
# pathを運んで，その中で
queue = [(1,set())]
res = 0
while queue:
  now,prevs = queue.pop()
  
  if len(prevs) == N-1:
      res += 1
      continue
  for next_node in graph[now]:
    #print("{}: {}->{} {}".format(prevs,now,next_node,"o" if next_node not in prevs else "x"))
    if next_node not in prevs:
      queue.append((next_node, prevs|{now}))
print(res)

Measured memory_bytes: 39664
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;
const int mod=1000000007;

int main(){
	int n,c=0;
	map<int,int> mp;
	cin>>n;
	FOR(i,0,n){
		int b;
		cin>>b;
		if(mp[b]==0){
			mp[b]++;
			c++;
		}else{
			mp[b]--;
			c--;
		}
	}
	
	cout<<c<<endl;
    return 0;
}


Measured memory_bytes: 4864
import java.util.Scanner;
class Main{
    int N;
    int x,y,b,p;
    int cnt;
    int i,k;
    int go,wari;
    
    public void solve(){
        Scanner sc = new Scanner(System.in);
        
        N=sc.nextInt();
        for(cnt=0; cnt<N; cnt++){
            x=sc.nextInt();
            y=sc.nextInt();
            b=sc.nextInt();
            p=sc.nextInt();
            
            go=x*b+y*p;
            
            if(b>=5 && p>=2){
                go=(x*b+y*p)*8/10;
                
            }else{
                if(b<5){
                    b=5;
                }
                if(p<2){
                    p=2;
                }
                wari=(x*b+y*p)*8/10;
                
                if(go>wari){
                    go=wari;
                }
            }
            System.out.println(go);
        }
    }
    public static void main(String[]args){
        Main obj = new Main();
        obj.solve();
    }
}
                 

Measured memory_bytes: 23356
#include<iostream>
#include<algorithm>
using namespace std;
long long int sum;
int main(){
  int K;
  cin>>K;
  for(int i=1; i<=K; i++){
    for(int j=1; j<=K; j++){
      for(int l=1; l<=K; l++){
        sum+=__gcd(i,__gcd(j,l));
      }
    }
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using P = pair<ll, ll>;

int main()
{
    int n;
    cin >> n;
    vector<int> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    int sum = 0;
    rep(i, n) sum += s[i];
    if(sum % 10 != 0) {
        cout << sum << endl;
        return 0;
    }
    rep(i, n) {
        if(s[i] % 10 != 0) {
            sum -= s[i];
            cout << sum << endl;
            return 0;
        }
    }
    cout << 0 << endl;
    return 0;
}


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

using namespace std;

typedef long long ll;

const ll MOD = 1e9+7;


signed main()
{
    ll h, w;
    cin >> h >> w;
    vector<string> s(h);
    for(auto& x : s)
        cin >> x;

    vector<ll> dx = {0, 1, 0, -1};
    vector<ll> dy = {1, 0, -1, 0};

    vector<vector<ll>> flag(h, vector<ll>(w, 0));
    function<pair<ll,ll>(ll, ll)> f = [&](ll x, ll y){
        pair<ll,ll> p(0, 0);
        ++(s[x][y] == '.' ? p.first : p.second);
        for(ll i = 0; i < 4; ++i){
            if(x + dx[i] < 0 || x + dx[i] >= h || y + dy[i] < 0 || y + dy[i] >= w || flag[x + dx[i]][y + dy[i]])
                continue;
            if(s[x][y] == s[x + dx[i]][y + dy[i]])
                continue;
            flag[x + dx[i]][y + dy[i]] = 1;
            auto ret = f(x + dx[i], y + dy[i]);
            p.first += ret.first;
            p.second += ret.second;
        }
        return p;
    };
    ll ans = 0;
    for(ll i = 0; i < h; ++i){
        for(ll j = 0; j < w; ++j){
            if(flag[i][j])
                continue;
            flag[i][j] = 1;
            auto t = f(i, j);
            ans += t.first * t.second;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19200
import sys
sys.setrecursionlimit(100000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15

def main():  
    N,K = map(int,input().split())
    A = list(map(int,input().split()))
    A = [a - 1 for a in A]
    visited = {0}
    loop = [0]
    now = 0
    while A[now] not in visited:
        now = A[now]
        visited.add(now)
        loop.append(now)
    
    for i,s in enumerate(loop):
        if s == A[now]:
            X = loop[:i]
            loop = loop[i:]
            break
    if K < len(X):
        print(X[K] + 1)
    else:
        K -= len(X)
        K %= len(loop)
        print(loop[K] + 1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 139844
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
int main(){
  int n;
  P a[100001];
  cin>>n;
  for(int i=0;i<n;i++)
    cin>>a[i].first,a[i].second=-i;
  sort(a,a+n,greater<P>());
  a[n].first=0;
  
  ll ans[100000]={},p=a[0].first,q=a[0].second;
  for(int i=1;i<=n;i++)
    ans[-q]+=i*(p-a[i].first),p=a[i].first,q=max(q,a[i].second);
  for(int i=0;i<n;i++)cout<<ans[i]<<endl;
  return 0;
}

Measured memory_bytes: 3456
N = int(input())
T, A = map(int, input().split())
H = list(map(int, input().split()))
n = 0
place = 0
diff = 10**6
for h in H:
  n += 1
  t = T - h * 0.006
  if abs(A - t) < diff:
    diff = abs(A - t)
    place = n
print(place)

Measured memory_bytes: 62696
#include <iostream>
#include <algorithm>

using namespace std;
void bubblesort(int a[],int n){
    int f=1;
    int count=0;
    while(f){
        f=0;
        for(int j=n-1;j>0;j--){
            if(a[j]<a[j-1]){
                int v=a[j];
                a[j]=a[j-1];
                a[j-1]=v;
                f=1;
                count +=1;
            }
        }
    }
        for (int i=0;i<n-1;i++){
        cout<<a[i]<<" ";
    }
    cout <<a[n-1] <<endl;
    cout << count <<endl;
    
}




int main() {
    int n,a[103];
    cin >>n;
    for (int i=0; i<n;i++){
        cin >>a[i];
    }
    bubblesort(a,n);


    return 0;
}



Measured memory_bytes: 3100
# 入力
data = list(map(int, input().split()))

# 大きい方を判別
max_i = 0
min_i = 1
if data[0] < data[1]:
    max_i = 1
    min_i = 0

a = data[min_i]

# 大きい数を小さい数で悪る
b = data[max_i] % a

while b != 0:
    c = b
    b = a % b
    a = c

print(a)



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

int main() {
    int h,w;
    cin>>h>>w;
    vector<vector<char>> c(h,vector<char>(w));
    for (int i=0;i<h;i++){
        for (int j=0;j<w;j++){
            cin>>c.at(i).at(j);
        }
    }

    for (int i=0;i<2*h;i++){
        for (int j=0;j<w;j++){
            cout<<c.at(i/2).at(j);
        }
        cout<<endl;
    }
}


Measured memory_bytes: 256
if __name__ == "__main__":
    N = int(input())
    A = list(map(int, input().split()))
    R = [0]
    MOD = 10**9 + 7
    ans = 0
    for i in range(N):
        R.append(A[i]+R[-1])
    for i in range(N-1):
        ans += A[i] * (R[-1] - R[i+1])
        ans %= MOD
    print(ans)


Measured memory_bytes: 31612
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;
int main(void){
    // Here your code !
  int r,c,n,i,j;
  int table[101][101];

  cin>>r>>c;
  for( i=0;i<r;i++){
      for( j=0;j<c;j++){
      cin>>table[i][j];
      }}
      
      for( i=0;i<r;i++){
          n=0;
      for( j=0;j<c;j++){
      n=n+table[i][j];
      }
          table[i][c]=n;
      }
      
      for( i=0;i<c;i++){
          n=0;
      for( j=0;j<r;j++){
      n=n+table[j][i];
      }
          table[r][i]=n;
      }
      
      for( i=0;i<r;i++){
     table[r][c]=table[r][c]+table[i][c];
      }
 for( i=0;i<=r;i++){
      for( j=0;j<=c;j++){
      cout<<table[i][j];
      if(j!=c) {cout<<" ";}
      }
         cout<<endl;
      }
}

Measured memory_bytes: 1196
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<vector>
#include<map>
#include<queue>


using namespace std;

using vi=vector<int>;
using vvi=vector<vi>;


int main(void)
{
	int a, b, c;

	while(scanf("%d%d%d", &a, &b, &c)==3)
	{
		printf("%s\n", (a<=c && c<=b)?"Yes":"No");
	}

	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<sstream>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define loop(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revloop(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define stloop(it,v) for(it=v.begin();it!=v.end();++it)
#define ii pair<ll,ll>
#define MP make_pair
#define pb push_back
#define f first
#define s second
#define ll long long int
#define vi vector<int>
#define rs resize
int main()
{  std::ios::sync_with_stdio(false);
   cin.tie(0);
   cout.tie(0);
   int n,i,j;
   cin>>n;
   string a;
   map<char,int> mp,mpf;
   loop(i,0,n)
   {
    cin>>a;
    loop(j,0,a.length())
     mp[a[j]]++;
    if(i==0)
    {
      for(auto &it:mp)
        mpf[it.f]=it.s;
    }
    else
    { for(auto &it:mpf)
       it.s=min(it.s,mp[it.f]);
    }
    mp.clear();
   }
   bool flag=false;
   for(auto &it:mpf)
   {
     if(it.s!=0)
     {
       flag=true;
       loop(j,0,it.s)
        cout<<it.f;
     }
   }
   if(!flag)
    cout<<endl;
   return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i=0;i<n;i++) {
			double xa = sc.nextDouble();
			double ya = sc.nextDouble();
			double ra = sc.nextDouble();
			double xb = sc.nextDouble();
			double yb = sc.nextDouble();
			double rb = sc.nextDouble();
			double dx = xa-xb;
			double dy = ya-yb;
			double distsq = dx * dx + dy * dy;
			double dist = Math.sqrt(distsq);
			if ((ra + rb) * (ra + rb) < distsq) {
				System.out.println(0);
				continue;
			}
			if (Math.abs(ra-rb) > dist) {
				if (ra < rb) {
					System.out.println(-2);
					continue;
				}else{
					System.out.println(2);
					continue;
				}
			}
			System.out.println(1);
		}
	}

}

Measured memory_bytes: 20580
#include<iostream>
#include<vector>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>

int main(){

    size_t n, m;
    std::cin >> n >> m;

    std::vector<std::pair<size_t, char>> v(m);
    for(size_t i = 0; i < m; i++){
        size_t s;
        char c;
        std::cin >> s >> c;
        v.at(i) = {s - 1, c};
    }

    for(size_t i = n == 1 ? 0 : std::pow(10, n - 1); i < std::pow(10, n); i++){
        auto tmp = std::to_string(i);

        bool flag = true;
        for(const auto& e : v){
            if(tmp.at(e.first) != e.second){
                flag = false;
            }
        }

        if(flag){
            std::cout << i << std::endl;
            return 0;
        }
    }

    std::cout << -1 << std::endl;

    return 0;
}


Measured memory_bytes: 256
n = int(input())
ab = str(input())

ans = set([0])
lenab = len(ab)

for h in range(lenab):
    abc = ab[h:]
    lenabc = len(abc)
    i = 1; j = 0
    A = [0]*lenabc
    A[0] = lenabc
    while i < lenabc:
        while i+j < lenabc and abc[j] == abc[i+j] and j < i:
            j += 1
        if j == 0:
            i += 1
        else:
            A[i] = j
            ans.add(j)
            k = 1
            while lenabc - i > k < j - A[k] and j < i - k :
                A[i + k] = A[k]
                k += 1
            i += k;
            j -= k

print(max(ans))

Measured memory_bytes: 49756
#include<stdio.h>

int partition(int*,int,int);
int main(){

  int a[1000000],a_num,i,key,x;


  scanf("%d",&a_num);
  for(i = 0; i < a_num; i++){
    scanf("%d",&a[i]);
  }

  
  key = a[a_num-1];
  x =parttition(a,0,a_num-1);

  for(i = 0; i < x; i++){
    printf("%d ",a[i]);
  }
  printf("[%d]",key);
  for(i = x+1; i < a_num; i++){
    printf(" %d",a[i]);
  }
  printf("\n");
  return 0;
}


int parttition(int *a, int p, int last)
{
  int key,i,j,swap;

  key = a[last];
  i = p-1;


  for(j = p; j < last; j++){
    if(a[j] <= key){
      i = i+1;
      swap = a[i];
      a[i] = a[j];
      a[j] = swap;
    }
  }
      swap = a[i+1];
      a[i+1] = a[last];
      a[last] = swap;

      return i+1;
}

Measured memory_bytes: 2824
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cctype>
#include <map>
#include <set>

const int INT_INF = 1e9;
const long long LONG_INF = 1e18;
const long long MOD = 1e9 + 7;
const double PI = 3.14159265358979323846;

using namespace std;

int main()
{
    string s;
    cin >> s;
    long long int l = 0, r = s.length() - 1;
    long long int ans = 0;
    while (l < r)
    {
        if (s[l] == 'W')
        {
            l++;
        }
        else if (s[r] == 'B')
        {
            r--;
        }
        else
        {
            ans += r - l;
            l++;
            r--;
        }
    }

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

Measured memory_bytes: 3708
#include <bits/stdc++.h>
	    
	    
	    using namespace std;
	
	    #define ll long long
	    #define do double
	    #define ff first
	    #define ss second
	    #define FOR(a,n) for(i=0;i<n;i++){    cin>>a[i];}
	    #define pb push_back
	    #define mp make_pair
	    #define inf LONG_LONG_MAX
	    #define mod  1000000007
	    #define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	    

	ll d,x,y;
	void extendedEuclid(ll A, ll B) 
	{
	    if(B == 0) {
	        d = A;
	        x = 1;
	        y = 0;
	    }
	    else {
	        extendedEuclid(B, A%B);
	        int temp = x;
	        x = y;
	        y = temp - (A/B)*y;
	    }
	}

	ll power(ll x,ll y, ll p) 
	{ 
	    ll res = 1; 
	    x = x % p;
	    while (y > 0) 
	    {  // If y is odd, multiply x with result 
	        if (y & 1) 
	            res = (res*x) % p;
	            
	        y = y>>1; 
	        x = (x*x) % p;   
	    } 
	    return res; 
	} 



map<ll,ll> par,val;
void ini()
{
	for(ll i=0;i<500010;i++)
		{
			par[i]=i;
		}
}

ll root(ll x)
{
	while(par[x]!=x)
	{
		par[x]=par[par[x]];
		x=par[x];
	}
	return x;
}

void uni(ll x,ll y)
{
	x=root(x);
	y=root(y);
		par[y]=par[x];
}

int gcdExtended(int a, int b, int *x, int *y) 
{ 

    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
    int x1, y1;
    int gcd = gcdExtended(b%a, a, &x1, &y1); 
    *x = y1 - (b/a) * x1; 
    *y = x1;
    return gcd; 
}  
int modInverse(int b, int m) 
{ 
    int x, y; 
    int g = gcdExtended(b, m, &x, &y); 
    if (g != 1) 
        return -1; 
    return (x%m + m) % m; 
}
ll isPrime(ll n)
{
    if(n==0||n==1)
        return n;
    if(n%2==0)
        return (ll)2;
    if(n%3==0)
        return (ll)3;
    else
    {
        for(ll i=5;i*i<=n;i+=6)
        {
            if(n%i==0)
                return i;
            if(n%(i+2)==0)
                return (i+2);
        }
        return n;
    }
}
const ll N=10000010;
vector<bool> prime(N);
vector<ll> spf(N);
void sieve()
{
	fill(prime.begin(),prime.end(),true);
	prime[1]=false;
	prime[0]=false;
	ll i,j;
	for(i=2;i*i<=N;i++)
	{
		if(prime[i]==true)
		{	spf[i]=i;
			for(j=i*i;j<N;j+=i)
			{
				prime[j]=false;
				if(spf[j]==0)
					spf[j]=i;
			}
		}
	}
}
int main()
{
	FAST;
	ll n,i,j,k,m;
	string s;
	cin>>n;
	ll a[n];
	FOR(a,n);
	if(n%2==1)
		return cout<<0,0;
	sort(a,a+n);
	ll x=a[n/2]-a[n/2-1];
	cout<<x;

	
}

Measured memory_bytes: 80512
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>

char field[52][52] = {};

int main(void) {

	int h, w;
	std::cin >> h >> w;

	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++)
			std::cin >> field[i][j];

	const int dir[5] = { 0,-1,0,1,0 };

	for (int i = 1; i <= h; i++)
		for (int j = 1; j <= w; j++) {
			if (field[i][j] == '.')
				continue;
			bool f = false;
			for (int k = 0; k < 4; k++)
				if (field[i][j] == '#' && field[i + dir[k]][j + dir[k + 1]] == '#') {
					f = true;
				}
			if (!f) {
				//std::cerr << i << " " << j << std::endl;
				std::cout << "No" << std::endl;
				return 0;
			}
		}

	std::cout << "Yes" << std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

const int mod = 1000000007;

struct mint {
    long long x;
    mint(long long x=0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(long long t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
bool operator==(const mint& a, const mint& b) { return a.x == b.x;}

struct combination {
    vector<mint> fact, ifact;
    combination(int n) : fact(n+1), ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
    mint p(int n, int k) { return fact[n] * ifact[n-k];}
} c(1e6);

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

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

    auto sum = [](int x) { return 1LL * x * (x + 1) / 2;};
    mint ans = 0;
    rep(i, n) rep(j, m) {
        ans += mint(m) * (mint(sum(i)) + mint(sum(n-i-1)));
        ans += mint(n) * (mint(sum(j)) + mint(sum(m-j-1)));
    }
    ans /= 2;
    ans *= c(n*m-2, k-2);
    cout << ans << endl;
}


Measured memory_bytes: 18636
import scala.io.Source.stdin
import scala.collection.mutable.{ SortedSet => Set }

case class Node(
  id: Int,
  children: List[Int],
  start: Int = 1,
  end: Int = 1
)

object Main {
  var time: Int = 0
  var checked = Set[Int]()

  def main(argv: Array[String]) = {
    val head :: tail = stdin.getLines.toList
    val count = head.toInt
    val nodes = new Array[Node](count)

    tail foreach { line =>
      val id :: length :: children = line.split(" ").map(_.toInt).toList
      nodes(id-1) = Node(id, children)
    }

    nodes.foreach { node =>
      if(!checked.contains(node.id)) {
        checked += node.id
        time = time + 1
        nodes(node.id -1) = nodes(node.id -1).copy(start = time)
        recursive(nodes(node.id -1), nodes)
        time = time + 1
        nodes(node.id -1) = nodes(node.id -1).copy(end = time)
      }
    }

    nodes foreach { node =>
      println(s"${node.id} ${node.start} ${node.end}")
    }
  }

  def recursive(node: Node, nodes: Array[Node]): Unit = {
    node.children foreach { id =>
      if (!checked.contains(id)) {
        time = time + 1
        nodes(id-1) = nodes(id-1).copy(start = time)
        checked += id
        recursive(nodes(id-1), nodes)
        time = time + 1
        nodes(id-1) = nodes(id-1).copy(end = time)
      }
    }
  }
}



Measured memory_bytes: 44636
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define lw(vc,num) lower_bound(vc.begin(), vc.end(), num) - vc.begin();
#define hg(vc,num) upper_bound(vc.begin(), vc.end(), num) - vc.begin();
#define bn(v,x) binary_search (v.begin(), v.end(), x)
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
bool isprime(int n)
{
    if(n == 1) return false;
    if(n == 2 || n == 3) return true;
    if(n%2 == 0 || n%3 == 0) return false;
    for(int i=5; i*i<=n; i+=6){
        if((n%i == 0)||(n%(i+2) == 0)) return false;
    }
    return true;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
int main()
{
    fio;
    int x,y;
    cin>>x>>y;
    if(x==y)
        cout<<"Yes\n";
    else
        cout<<"No\n";
    return 0;
}



Measured memory_bytes: 3636
n,q=map(int,input().split( ))
A=[[] for i in range(n)]
for i in range(q):
    command=input().split( )
    com=int(command[0])
    if len(command)>2:
        t=int(command[1])
        x=int(command[2])
    else:
        t=int(command[1])
    if com==0:
        A[t].append(x)
    elif com==1:
        print(*A[t])
    elif com==2:
        A[t].clear()



Measured memory_bytes: 29764
// वाह मोदी जी वाह!

#include<iostream>
#include<algorithm>
#include<bitset>

#include<cmath>
#include<cstring>
#include<climits>

#include<deque>
#include<vector>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>

#include<fstream>
#include<chrono>
using namespace std;

typedef long long LL;
typedef pair<LL,LL> p64;
typedef vector<LL> v64;

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define rep(i,s,e) for(long long i=s;i<=e;i++)
#define brep(i,s,e) for(long long i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x))
#define DANGER std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

int main()
{
    // DANGER;
    ofstream out("output.txt");

    auto start = chrono::high_resolution_clock::now();
    
    LL n;
    cin>>n;
    cout<< n*n*n <<endl;
    
    auto stop = chrono::high_resolution_clock::now();
    // auto duration = chrono::duration_cast<chrono::milliseconds>(stop - start); 
    // cout << "Time taken by function: " << duration.count() << " milliseconds" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace std;
using namespace __gnu_pbds;

#define TRACE

#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define lsc(x)      scanf("%lld",&x)
#define sc(x)       scanf("%d",&x)
#define lpr(x)      printf("%lld ",(long long)x)
#define pr(x)       printf("%d ",x)
#define n_l         printf("\n")
#define VI          vector<int>
#define VII         vector<long long int>
#define m_p         make_pair
#define pb          push_back
#define fi           first
#define se           second
#define mset(x,y)   memset(x,y,sizeof(x))
#define sz(v)       (int)v.size()
#define all(v)      v.begin(), v.end()
#define fr(i, a, n) for(int i=a;i<=n;i++)
#define FIO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
mt19937 rng32(chrono::steady_clock::now().time_since_epoch().count());
const int N=(int)1e6+5;
const int mod = 1000000007;
typedef long long ll;
// order_of_key (val): returns the no. of values strictly less than val
// find_by_order (k): returns the kth largest element iterator.(0-based)
// vector<int>::iterator itr=lower_bound(v.begin(),v.end(),x);
// s.substr(pos[0-indexed], len(default=till end))
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll fmod(ll x){if (x<mod) return x;return x%mod;}
ll mul(ll a, ll b, ll c){
	ll ret=0;while(b){if (b%2) ret=(ret+a)%c;a=(a*2)%c;b>>=1;}
    return ret;
}
int modpow(ll a, ll b){
    ll ret=1;while(b){if (b%2) ret=(ret*a)%mod;a=(a*a)%mod;b>>=1;}
    return (int)ret;
}
inline int inv(int x){ return modpow(x, mod-2);}
int isprime[N];
void calc_prime(){
	isprime[1]=1;for(ll i=2;i<N;i++) if (!isprime[i]) for(ll j=i*i;j<N;j+=i) isprime[j]=1;
}
int main(){
    int a, p;
    sc(a);sc(p);
    a = a*3 + p;
    pr(a/2);n_l;
    return 0;
}



Measured memory_bytes: 3828
n, m, xx, yy = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)
y = gets.split.map(&:to_i)
x_max = [x.max, xx].max
y_min = [y.min, yy].min
puts (x_max >= y_min) ? "War" : "No War"


Measured memory_bytes: 1788
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    static StringTokenizer st;
    static int MOD = 1000000007;
    public static void main(String[] args) throws IOException{
        int H = readInt(), W = readInt();
        int[][]dp = new int[H+1][W+1];
        char[][]grid = new char[H+1][W+1];
        for(int i = 1;i<=H;i++){
            String s = read();
            for(int j = 1;j<=W;j++){
                grid[i][j] = s.charAt(j-1);
            }
        }
        dp[1][1] = 1;
        for(int i = 1;i<=H;i++){
            for(int j = 1;j<=W;j++){
                if(i+1<=H&&grid[i+1][j]=='.')dp[i+1][j] = (dp[i][j]+dp[i+1][j])%MOD;
                if(j+1<=W&&grid[i][j+1]=='.')dp[i][j+1] = (dp[i][j]+dp[i][j+1])%MOD;
            }
        }
        System.out.println(dp[H][W]);
    }
    static String read() throws IOException{
        while(st==null||!st.hasMoreTokens())
            st = new StringTokenizer(br.readLine().trim());
        return st.nextToken();
    }
    static int readInt() throws IOException{
        return Integer.parseInt(read());
    }
    static long readLong() throws IOException{
        return Long.parseLong(read());
    }
    static double readDouble() throws IOException{
        return Double.parseDouble(read());
    }
}

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

char a[400005];
char b[743333];
int n;
int k=1;

inline int qr()
{
    int s=0,f=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){s=(s<<3)+(s<<1)+(ch^48);ch=getchar();}
    return s*f;
}

int main()
{
    cin>>a;
    cin>>n;
    int len=strlen(a);
    for(int i=0;i<len;i++)
    	b[i+200002]=a[i];
    int sh=200002,zh=200001+len; 
    while(n--)
    {
    	int p;
    	cin>>p;
    	if(p==1)
    		k==1?k=0:k=1;
    	else
    	{
    		int x;
    		char e;
    		cin>>x;
    		cin>>e;
    		if((x==1&&k==1)||(x==2&&k==0))
    		{
    			sh--;
    			b[sh]=e;
			}
    		else
    		{
    			zh++;
    			b[zh]=e;
			}
		}
	}
	if(k==1)
	{
		for(int i=sh;i<=zh;i++)
			cout<<b[i];
	}
	else
	{
		for(int i=zh;i>=sh;i--)
			cout<<b[i];
	}
    return 0;
}

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

using namespace std;

int main(void) {
    string S;
    cin >> S;
    int N = S.size();

    if(count(S.begin(), S.end(), '0') == N || count(S.begin(), S.end(), '0') == 0) {
        cout << N << endl;
    } else {
        int low = 1;
        int high = N;
        while(high > low+1) {
            int mid = (low + high) / 2;
            bool ok = false;
            if(count(S.begin()+(N-mid), S.end()-(N-mid), '0') == 2*mid-N || count(S.begin()+(N-mid), S.end()-(N-mid), '0') == 0) {
                low = mid;
            } else {
                high = mid;
            }
        }
        cout << low << endl;
    }
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
int main() {
  int a, b;
  cin >> a >> b;
  if(a>=(b+1))cout << a+a-1<< endl;
  else if(a==b)cout << a+a<< endl;
  else if(b>=(a+1))cout << b+b-1<< endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=int(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
#define rAll(x) (x).rbegin(),(x).rend()
using namespace std;
using ll = long long;

int main(){
    int N,M,K;cin>>N>>M>>K;
    for(int s=0;s<=N;++s) for(int t=0;t<=M;++t){
        if(t*s+(M-t)*(N-s)==K){
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
}

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

#define pi acos(-1.0)
#define eps 1e-9
#define ll long long
#define ull unsigned long long
#define sf scanf
#define pf printf
#define nl printf("\n")
#define ps(s) printf("%s",s.c_str())
#define inf (ll)1e15
#define mod 1000000007
#define mem(x,val) memset(x,val,sizeof x)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend() 
#define sz(x) (int)(x).size()
#define test_case int ___t;scanf("%d", &___t);for(int cs=1;cs<=___t;cs++)

using namespace __gnu_pbds;
using namespace std;

inline string str_inp(int n){char ch[n+5];sf(" %s",ch);return string(ch);}
inline string line_inp(int n)
{char ch[n+5];fgets(ch,n+5,stdin);string s=string(ch);s.pop_back();return s;}

//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;


const int S=50;
ll n,a,b;
ll ncr[S+5][S+5];
ll ara[S+5];

void NcR()
{
    for(ll i=0;i<=S;i++)
    {
        for(ll j=0;j<=i;j++)
        {
            if(j==0 || j==i)ncr[i][j]=1;
            else ncr[i][j]=ncr[i-1][j-1]+ncr[i-1][j];
        }
    }
}

int main()
{
    //#ifndef ONLINE_JUDGE
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //#endif
    NcR();
    while(~sf("%lld %lld %lld",&n,&a,&b))
    {
        map<ll,ll>mp;    
        for(ll i=1;i<=n;i++)sf("%lld",&ara[i]),mp[ara[i]]++;
        
        sort(ara+1,ara+n+1);
        reverse(ara+1,ara+n+1);

        ll ways=0;
        double avg;
        for(ll i=a;i<=b;i++)
        {           
            if(i==a)
            {
                double sum=0;
                for(ll j=1;j<=a;j++)sum+=ara[j];
                avg=sum/a;

                ll need=1;
                for(ll j=a-1;j>=1;j--)if(ara[j]==ara[a])need++;

                ways+=ncr[mp[ara[a]]][need];
            }
            else if(mp[ara[1]]>=i)ways+=ncr[mp[ara[1]]][i];
        }
        pf("%.10f\n%lld\n",avg,ways);
    }
    return 0;
}
 






































Measured memory_bytes: 3836
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<string>
#include<cmath>
#include<queue>
#include<bitset>
#define INF 0x3f3f3f3f
#define eps 1e-8
#define re register
#define LL long long
#define MOD 998244353
#define MAXN 100005
using namespace std;
LL n,m,Q,cnt,k,fa[MAXN],a[MAXN],b[MAXN],c[MAXN];
LL rd(){
	LL x=0,tp=1;char c;
	c=getchar();
	while(c<'0' || c>'9'){if(c=='-')tp=-1;c=getchar();}
	while(c>='0' && c<='9'){
		x=x*10+c-'0';
		c=getchar();
	}
	return x*tp;
}
int find(int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
int main(){
	// freopen("sb.in","r",stdin);
	// freopen("sb.out","w",stdout);
	cnt=n=rd(),m=rd(),Q=rd();
	for(int i=1;i<=Q;i++){
		a[i]=rd()+1,b[i]=rd()+1,c[i]=rd();
	}
	for(int i=1;i<=n;i++)fa[i]=i;
	if(m==n-1){
		for(int i=1;i<=Q;i++)
			if(c[i]){
				printf("No\n");
				return 0;
			}
		printf("Yes\n");
		return 0;
	}
	for(int i=1;i<=Q;i++){
		if(!c[i]){
			int fx=find(a[i]),fy=find(b[i]);
			if(fx==fy)continue;
			fa[fy]=fx;
			cnt--;
			k++;
		}
	}
	for(int i=1;i<=Q;i++){
		if(c[i]){
			int fx=find(a[i]),fy=find(b[i]);
			if(fx==fy){
				printf("No\n");
				return 0;
			}
		}
	}
	if(cnt==2){
		for(int i=1;i<=Q;i++){
			if(c[i]){
				printf("No\n");
				return 0;
			}
		}
		printf("Yes\n");
		return 0;
	}
	if(m<cnt+k || m>k+cnt*(cnt-1)/2){
		printf("No\n");
		return 0;
	}
	printf("Yes\n");
	return 0;
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int> vec(n);

	for (auto& e : vec) {
		cin >> e;
	}

	int ans = 0;
	int prev = 0;
	for (int i = 0; i < n; i++) {
		ans += max(0, vec.at(i) - prev);
		prev = vec.at(i);
	}

	cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>

int main() {
    int N, D, X;
    std::cin >> N >> D >> X;

    int count = 0;
    for (int i = 0; i < N; i++) {
        int A;
        std::cin >> A;

        for (int j = 1; j <= D; j += A) {
            count++;
        }
    }

    std::cout << count + X << std::endl;

    return 0;
}

Measured memory_bytes: 3600
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (int)(n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1.0);

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; }

ll mod_pow(long long x, long long n) {
    long long ret = 1;
    while (n > 0) {
        if (n & 1) ret = ret * x % MOD;  // n の最下位bitが 1 ならば x^(2^i) をかける
        x = x * x % MOD;
        n >>= 1;  // n を1bit 左にずらす
    }
    return ret;
}

int main()
{
  ll N; cin>>N;
  vector<ll> C(N); rep(i,N) cin>>C[i];
  sort(C.rbegin(),C.rend());
  
  ll ans=0;
  rep(i,N){
    ans+=C[i]*mod_pow(4,N-1)%MOD*(i+2)%MOD;
    ans%=MOD;
  }
  
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 4828
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>

#define debug(x) cout << #x << " = " << x << endl
#define fori(i, ini, lim) for(int i = int(ini); i < int(lim); i++)
#define ford(i, ini, lim) for(int i = int(ini); i >= int(lim); i--)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;

const int MAX = 3000 + 5;
const int MOD = 998244353;
int memo[MAX][MAX], a[MAX];
int n, s;

inline int add(int x, int b) {
    return (x + b) % MOD;
}

inline int mult(int x, int b) {
    return (1LL * x * b) % MOD;
}

int roll(int idx, int sum) {
    if (sum < 0) {
        return 0;
    }
    if (idx == (n + 1)) {
        return sum == 0;
    }
    int &ans = memo[idx][sum];
    if (~ans) {
        return ans;
    }
    ans = add(mult(2, roll(idx + 1, sum)), roll(idx + 1, sum - a[idx]));
    return ans;
}

void solve() {
    cin >> n >> s;
    fori (i, 1, n + 1) cin >> a[i];
    memset(memo, -1, sizeof memo);
    cout << roll(1, s) << endl;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    solve();
    return 0;
}



Measured memory_bytes: 39064
#!/usr/bin/env python3

import sys


def LI():
    return list(map(int, sys.stdin.buffer.readline().split()))


def I():
    return int(sys.stdin.buffer.readline())


def LS():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()


def S():
    return sys.stdin.buffer.readline().rstrip().decode('utf-8')


def IR(n):
    return [I() for i in range(n)]


def LIR(n):
    return [LI() for i in range(n)]


def SR(n):
    return [S() for i in range(n)]


def LSR(n):
    return [LS() for i in range(n)]


def SRL(n):
    return [list(S()) for i in range(n)]


def MSRL(n):
    return [[int(j) for j in list(S())] for i in range(n)]

# ----------------------------------------------------------------


def main():
    k, n = LI()
    a = LI()

    dists = []

    for i in range(len(a) - 1):
        dists.append(a[i + 1] - a[i])

    dists.append(a[0] + k - a[-1])

    ans = sum(dists) - max(dists)

    print(ans)


main()


Measured memory_bytes: 20440