akhauriyash/Code-Regression huggingface dataset:
import bisect
a, b, q = map(int, input().split())
s = [0] * a
t = [0] * b
x = [0] * q

for i in range(a):
    s[i] = int(input())
for i in range(b):
    t[i] = int(input())
for i in range(q):
    x[i] = int(input())

s.append(- 10 ** 20)
s.append(10 ** 20)
t.append(- 10 ** 20)
t.append(10 ** 20)

s.sort()
t.sort()

for i in range(q):
    ans = 10 ** 20

    s_idx = bisect.bisect_left(s, x[i])
    sl = s_idx - 1
    sr = s_idx

    t_idx = bisect.bisect_left(t, x[i])
    tl = t_idx - 1
    tr = t_idx

    ans = min(ans, max(abs(s[sl] - x[i]), abs(t[tl] - x[i])))
    ans = min(ans, max(abs(s[sr] - x[i]), abs(t[tr] - x[i])))
    ans = min(ans, min(abs(s[sl] - x[i]) * 2 + abs(x[i] - t[tr]),
                       abs(s[sl] - x[i]) + abs(x[i] - t[tr]) * 2))
    ans = min(ans, min(abs(t[tl] - x[i]) * 2 + abs(x[i] - s[sr]),
                       abs(t[tl] - x[i]) + abs(x[i] - s[sr]) * 2))
    print(ans)

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

int power(int x, int y){
  int n = 1;
  for(int i = 0; i < y; i++)
    n *= x;
  return n;
}
int digit(int x, int y){
  return x%power(10,y+1)/power(10,y);
}

int mod = 1e9+7;

int main() {
  int n;
  cin >> n;
  vector<double> v(n);
  for(int i = 0; i < n; i++)
    cin >> v.at(i);
  sort(v.begin(), v.end());
  double ans = v.at(0);
  for(int i = 0; i < n-1; i++)
    ans = (ans+v.at(i+1))/2;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <ctime>
#include <list>
#include <numeric>
#include <utility>
#include <ctime>
#define INF 100000000
#define LINF 9000000000000000000
#define mod 1000000007
 
#define rep(i,n) for(int i=0;i<int(n);i++)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair
#define MOD(x) (x%(mod))
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;
 
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
bool debug=false;
 
/*---------------------------------------------------*/

int main(){
  int n,a,b;
  cin>>n>>a>>b;
  int ans=0;
  REP(i,1,n+1){
    int sum=0;
    int x=i;
    while(x){
      sum+=(x%10);
      x/=10;
    }
    if(a<=sum&&sum<=b)ans+=i;
  }
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
	vector<long> a(3);
	cin >> a[0] >> a[1] >> a[2];

	cout << *min_element(a.begin(), a.end()) << " " 
		<< *max_element(a.begin(), a.end()) << endl;

	return 0;
}


Measured memory_bytes: 3100
function Main(input) {
  input = input.split("\n");
  var P = parseInt(input[0].split(" ")[0]);
  var Q = parseInt(input[0].split(" ")[1]);
  var R = parseInt(input[0].split(" ")[2]);
  var ans=Math.min(P+Q,Q+R,R+P);

  console.log('%s', ans);
  return ans;
}

function debug(n){
  var input = document.getElementById("input"+n).value;
  var ans=Main(input);
  var result="WA";
  if(ans==document.getElementById("output"+n).value.split("\n")[0]){
    result="AC";
  }
  document.getElementById("result"+n).innerHTML=result;
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 21064
//@formatter:off
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < int(n); ++i)
#define rrep(i,n) for (int i = int(n)-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = int(s); i < int(n); ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vd vector<double>
#define vvd vector<vector<double>>
#define vs vector<string>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
#define vp vector<P>
#define vvp vector<vector<P>>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class S,class T> istream& operator>>(istream &is,pair<S,T> &p) { return is >> p.first >> p.second; }
template<class S,class T> ostream& operator<<(ostream &os,const pair<S,T> &p) { return os<<'{'<<p.first<<","<<p.second<<'}'; }
template<class T> istream& operator>>(istream &is,vector<T> &v) { for(T &t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) { os<<'[';rep(i,v.size())os<<v[i]<<(i==int(v.size()-1)?']':','); return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << '\n'; }
void YES(bool b) { cout << (b ? "YES" : "NO") << '\n'; }
template<class T> bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;
//@formatter:on

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;
    int cnt = 0;
    for(char c : s) if(c == 'R') cnt++;
    int ans = 0;
    rep(i,n) if(s[i] == 'R' and i >= cnt) ans++;
    cout << ans << endl;
}


Measured memory_bytes: 3736
#include <iostream>
#include <cmath>
#include <string>
#include <queue>
#include <string.h>
#include <map>
#include <set>
#include <algorithm>
#include <string.h>
#include <stack>
#include <cstdio>

using namespace std;
typedef long long ll;
const int mod=1000000007;
const int maxn=100007;

double qpow(double x,int y)
{
    double sum=1;
    while(y>0)
    {
        if(y%2==1)
            sum=sum*x;
        x=x*x;
        y=y/2;
    }
    return sum;
}
int vis[10000];
int main()
{
    int ret=1;
    vis[0]=1;
    //vis[1]=1;
    for(;vis[ret-1]<=100000;ret++)
    {
        vis[ret]=vis[ret-1]*2;
    }
    int n,k;
    scanf("%d%d",&n,&k);
    double x=1.0/n;
    int flag=0;
    double ans=0;
    for(int i=n;i>=1;i--)
    {
        while(i*vis[flag]<k)
        {
            flag++;
        }
        ans=ans+qpow(0.5,flag);
    }
    ans=ans*x;
    printf("%.10lf",ans);
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
using namespace std;

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> m(n);
	int sum = 0;
	for (int i = 0; i < n; i++) {
		cin >> m[i];
		sum += m[i];
	}
	int d = x - sum;
	sort(m.begin(), m.end());
	cout << n + (d / m[0]) << endl;
}

Measured memory_bytes: 256
//organize , stay in moment and work -- Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ar array
#define f(i,x,n) for(int i=x;i<n;++i)
#define sz(s) s.size()
#define pb push_back
int mod;
int nc2(int n){
    if(n<2)
        return 0;
    int pp=n-1;if(pp%2==0) pp/=2;
    else n/=2;
    n*=pp;
    return n;
}
int ans,cp;
vector<int> v1,v2;
int bs(int look){
    int l=0,hi=sz(v2)-1,poss=-1;
    if(look < v2[0])
        return hi+1;
    if(look > v2[hi])
        return 0;
    while(l<=hi){
        int mid=l+(hi-l)/2;
        if(v2[mid]>look){
            poss=mid;
            hi=mid-1;
        }else l=mid+1;
    }
    return sz(v2)-poss;
}
bool cpp(int a[],int n){
    int mn=a[0];
    f(i,1,n){
        if(a[i]<mn)
            return false;
        mn=a[i];
    }
    return true;
}
void solve(){
   int n,m; cin>>n>>m;
   string s;  cin>>s;
   int a[sz(s)][26];
   f(i,0,sz(s))
   f(j,0,26)
   a[i][j]=0;
   f(i,0,sz(s)){
    if(i==0)
        ++a[0][s[i]-'a'];
    else{
        ++a[i][s[i]-'a'];
        f(j,0,26)
        a[i][j]+=a[i-1][j];
    }
   }
   int ans[26]={0};
   f(i,0,m){
    int pp; cin>>pp; --pp;
    f(j,0,26)
    ans[j]+=a[pp][j];
   }
   f(j,0,26)
   cout<<ans[j]+a[n-1][j]<<" ";
   cout<<"\n";
}
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mod=1e9+7;
    int t;t=1;
    cin>>t;
    cout<<(t+1)/2;
    return 0;
    while(t--)
    solve();
    return 0;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
a = list(map(str, input().split()))
dis = len(set(a)) - k
if dis > 0:
    dic = {}
    for i in range(n):
        if a[i] in dic:
            dic[a[i]] += 1
        else:
            dic[a[i]] = 1
    dic_v = sorted(dic.values())
    print(sum(dic_v[:dis]))
else:
    print(0)


Measured memory_bytes: 40244
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();

        if (m > n || m == 0) {
            System.out.println("No");
            return;
        }

        List<Integer> items = new ArrayList<>();

        int votes = 0;
        for (int i = 0; i < n; i++) {
            int vote = in.nextInt();
            votes += vote;
            items.add(vote);
        }

        int condition = (int) Math.ceil(votes / (4.0 * m));

        int checkCount = 0;
        Collections.sort(items, (o1, o2) -> o2 - o1);
        for (Integer check: items) {
            if (check >= condition && ++checkCount >= m) {
                System.out.println("Yes");
                return;
            }
        }
        System.out.println("No");

    }

}

Measured memory_bytes: 26836
#include<bits/stdc++.h>
#define faster  ios :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define ull unsigned long long
using namespace std;

int main()
{
    faster

    int k,x;
    cin>>k>>x;

    for(int i=x-(k-1); i<=x+(k-1); i++)
        cout<<i<<" ";
    cout<<endl;




    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
map<char,int>q;
int main()
{
    string s;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        q[s[i]]++;
    }
    for(char i='a';i<='z';i++)
    {
        if(q[i]%2)
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define de(x) cout << #x << "=" << x << endl
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
const int INF = 0x3f3f3f3f;
const int MOD = 1e9+7;
const int maxn = -1;

const double eps = 1e-7;
bool eq(const double &a, double const &b) { return fabs(a - b) < eps; }
bool ls(const double &a, double const &b) { return a + eps < b; }

int main ()
{
    int n;
    scanf("%d",&n);
    int ans = 0;
    rep(i,0,n) {
        int l,r;
        scanf("%d%d",&l,&r);
        ans += r - l + 1;
    }
    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int cost[22][22]={0};
 
int main(){
    int n,m,i,j,k,a,b,c,d;
    char cc;
    cin>>n>>m;
    for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
            cost[i][j] = 1<<28;
    for(i=0;i<m;i++){
        cin>>a>>cc>>b>>cc>>c>>cc>>d;
        cost[a][b]=c;cost[b][a]=d;
    }
    for(k=1;k<=n;k++)
      for(i=1;i<=n;i++)
        for(j=1;j<=n;j++)
        cost[i][j] = min(cost[i][j], cost[i][k] + cost[k][j]);
    cin>>a>>cc>>b>>cc>>c>>cc>>d;
    cout << c-d-cost[a][b]-cost[b][a] << endl;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>

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

using namespace std;
using ll = long long int;
using ull = unsigned long long;

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

int main() {
	ll n, a, b;
	cin >> n >> a >> b;
	ll ans = n / (a + b);
	if (n % (a + b) != 0) {
		if (n % (a + b) < a) {
			cout << (a * ans) + (n % (a + b)) << endl;
		} else {
			cout << (a * (ans + 1)) << endl;
		}
	} else {
		cout << a * ans << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		
		if (judge(s, 0)) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
	
	public static boolean judge(String s, int i) {
		if (i == s.length()) {
			return true;
		}
		
		boolean f = false;
		
		if (s.length() >= i + 7 && s.substring(i, i + 7).equals("dreamer")) {
			f |= judge(s, i + 7);
		} 
		if(s.length() >= i + 5 &&  s.substring(i, i + 5).equals("dream")) {
			f |= judge(s, i + 5);
		} 
		if(s.length() >= i + 6 &&  s.substring(i, i + 6).equals("eraser")) {
			f |= judge(s, i + 6);
		} 
		if(s.length() >= i + 5 &&  s.substring(i, i + 5).equals("erase")) {
			f |= judge(s, i + 5);
		} 
		
		return f;
	}
}

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

int main() {
    int N;
    cin >> N;
    int d[N] = {};
    for (int i = 0;i < N;i++){
        cin >> d[i];
    }
    long long ans = 0;
    for (int i = 0;i < N - 1;i++){
        for (int j = i + 1;j < N;j++){
            ans += d[i] * d[j];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
# Here your code !
a,b = gets.chomp.split(" ").map{|u| u.to_i}
memo = Array.new(a)
memo2 = Array.new(a)
memo2 = memo2.map{|u| u = 1}
memo[0] = 1
count = 0
b.times do
    c,d = gets.chomp.split(" ").map{|u| u.to_i}
    memo2[c-1] -= 1
    memo2[d-1] += 1
    memo[d-1]=1 if(memo[c-1] == 1)
    memo[c-1]=0 if(memo2[c-1] == 0)
end
puts memo.count(1)

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
int n,k,A[100005],dp[100005];
int miro(int node){
	int cev=1000000000;
	if(node==n) return 0;
	if(dp[node]!=-1) return dp[node];
	for(int i=1;i<=k;i++){
		int go=node+i;
		if(go>n)continue;
		cev=min(miro(go)+abs(A[node]-A[go]),cev);
	}
	return dp[node]=cev;
}
int main(){
	memset(dp,-1,sizeof(dp));
	scanf("%d %d",&n,&k);
	for(int i=1;i<=n;i++){
		scanf("%d",&A[i]);
	}
	int ty=miro(1);
	printf("%d",ty);
	
	return 0;
}


Measured memory_bytes: 5760
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let s: Vec<char> = itr.next().unwrap().chars().collect();
    if (s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3]) {
        println!("Yes")
    } else {
        println!("No")
    }
}


Measured memory_bytes: 2112
import math
 
N = 1000001
 
spf = [*range(N)]
i = 2
while i * i < N:
  if spf[i] == i:
    for j in range(i * i, N, i):
      if spf[j] == j:
        spf[j] = i
  i += 1
  
r = 'pairwise'
 
input()
d = None
u = set()
for x in map(int, input().split()):
  d = math.gcd(d or x, x);
  s = set()
  while x > 1:
    p = spf[x]
    if p in u:
      r = 'setwise'
    s.add(p)
    x //= p
  u |= s
print('not' if d > 1 else r, 'coprime')


Measured memory_bytes: 179236
#include<stdio.h>
int main(){
  int A[10][10];
  int i,j;
  int H,W,h,w;
  
  scanf("%d %d",&H,&W);
  scanf("%d %d",&h,&w);
  
  int ans;
  ans=H*W-(h*W+w*H-h*w);
  printf("%d",ans);
  return 0;
}

Measured memory_bytes: 128
def extended_gcd(a, b)
  last_remainder, remainder = a.abs, b.abs
  x, last_x, y, last_y = 0, 1, 1, 0
  while remainder != 0
    last_remainder, (quotient, remainder) = remainder, last_remainder.divmod(remainder)
    x, last_x = last_x - quotient*x, x
    y, last_y = last_y - quotient*y, y
  end

  return last_remainder, last_x * (a < 0 ? -1 : 1)
end

def invmod(e, et)
  g, x = extended_gcd(e, et)
  if g != 1
    raise 'The maths are broken!'
  end
  x % et
end

MOD = 10**9 + 7
h,w,a,b = gets.chomp.split().map(&:to_i)

hw = h+w
kaijo = Array.new(hw)
kaijo[0] = 1
1.upto(hw).each do |i|
  kaijo[i] = (kaijo[i-1] * i) % MOD
end

ans = 0
(h-a).times do |i|
  path1 = ((kaijo[b-1 + i] * invmod(kaijo[b-1], MOD) % MOD) * invmod(kaijo[i], MOD)) % MOD
  path2 = ((kaijo[h-i-1 + w-b-1] * invmod(kaijo[h-i-1], MOD) % MOD) * invmod(kaijo[w-b-1], MOD)) % MOD
  #path1 = kaijo[b + i] / kaijo[b] / kaijo
  #path2 = kaijo[h-i + w-b] / kaijo[h-i] / kaijo[w-b]
  path = (path1 * path2) % MOD
  ans = (ans + path) % MOD
  #p [path1, path2, '', path, ans]
end

puts ans


Measured memory_bytes: 3324
// 簡易競プロテンプレ
#include <bits/stdc++.h>
#define ll long long
using namespace std;

int main(void){
 ll a, b;
 cin >> a >> b;
 if (a>0) {cout << "Positive" << endl; return 0;}
 if (b>=0) {cout << "Zero" << endl; return 0;}
 if ((b-a)%2) cout << "Positive" << endl; else cout << "Negative" << endl;
  
 return 0;
}

Measured memory_bytes: 256
N = int(input())
B = [int(x) for x in input().split()]
sumA = 0
for i in range(N):
    if i == 0:
        sumA += B[0]
    elif i == N-1:
        sumA += B[N-2]
    else:
        sumA += min([B[i-1],B[i]])
print(sumA)

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef tuple<int, int> duo;

#define TT template<typename T>
#define TTF template<typename T, typename F>
#define ET(T) typename T::value_type
TT inline T sq(T x){return x*x;}
TT inline T In(){T x;cin>>x;return x;}
TT inline void Out(T&x){cout<<x;}
TT inline void sort(T&v){sort(begin(v),end(v));}
TT inline void revs(T&v){reverse(begin(v),end(v));}
TT inline void uniq(T&v){sort(v);v.erase(unique(begin(v),end(v)),end(v));}
TT inline int ubnd(T&v,ET(T)&x){return upper_bound(begin(v),end(v),x)-begin(v);}
TT inline int lbnd(T&v,ET(T)&x){return lower_bound(begin(v),end(v),x)-begin(v);}
TTF inline void inpt(T&v,int n,F f){for(v.reserve(n);n--;v.emplace_back(f()));}
TTF inline void show(T&v,F f,string d=" ",string e="\n"){int i=0;for(auto&x:v)i++&&(cout<<d),f(x);cout<<e;}
#undef TT
#undef TTF
#undef ET

inline void fast_io(){ios::sync_with_stdio(0);cin.tie(0);}
inline int in(){int x;scanf("%d",&x);return x;}
inline ll pow_mod(ll a,ll k,ll m){ll r=1;for(;k>0;a=a*a%m,k>>=1)if(k&1)r=r*a%m;return r;}
inline ll mod_inv(ll a,ll p){return pow_mod(a,p-2,p);}

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

bool is_palindrome(int n)
{
  string s = to_string(n);
  string rs = s;
  revs(s);
  return s == rs;
}

int main()
{
  int n = in();
  for (int i = 0; i < n; i++){
    if (is_palindrome(n - i)){
      printf("%d\n", n - i);
      break;
    }
    if (is_palindrome(n + i)){
      printf("%d\n", n + i);
      break;
    }
  }
  return (0);
}

// priority_queue queue deque front stringstream max_element min_element insert count make_tuple

Measured memory_bytes: 1220
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stack>
#include <cmath>
#include <string>
#define  endl "\n"
using namespace std;

void FastInput() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void OutputFile()
{
    freopen("output.txt","w",stdout);
}



int main()
{

    FastInput();
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    while(a>0 && c>0)
    {
        c-=b;
        if(c<=0)
            break;
        a-=d;
        if(a<=0)
            break;
    }
    if(a>c)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 3648
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n,m;
  cin >> n >> m;
  if(abs(n-m)>=2){
    cout << 0 << endl;
    return 0;
  }
  
  ll ans = 1;
  if(n==m){
  rep2(i,1,min(n,m)+1){
    ans *= i;
    ans %=mod;
  }
  ans*=ans;
  ans%=mod;
  ans*=2;
  ans%=mod;
  cout << ans << endl;
  }
  else{
    rep2(i,1,min(n,m)+1){
    ans *= i;
    ans %=mod;
    }
    ll an = ans*max(n,m);
    an%=mod;
      
    ans*=an;
    ans%=mod;
    cout << ans << endl;
  }
      
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a, b, c;
    cin >>a >>b >>c;
    
    vector<int> yakusu;
    
    for (int i = 1; i <= c; i++) {
        
        if (c % i == 0) {
            yakusu.push_back(i);
        }
    }
    
    int count = 0;
    
    for (int i = 0; i < yakusu.size(); i++) {
        
        if (a <= yakusu[i] && yakusu[i] <= b) {
            count ++;
        }
    }
    
    cout << count << endl;
}


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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    vector<ll> cnt(61, 0);
    rep(i,n){
        ll a;
        cin >> a;
        rep(j,61){
            if(a>>j & 1) cnt[j]++;
        }
    }
    ll ans = 0;
    for(int i = 60; i >= 0; --i){
        ll tmp = 1LL;
        rep(j,i) tmp *= 2;
        if(k >= tmp){
            if(n - cnt[i] >= cnt[i]){
                k -= tmp;
                ans += (n - cnt[i]) * tmp;
                continue;
            }
        }
        ans += cnt[i] * tmp;
    }
    cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define vll vector<ll>
#define pll pair<ll,ll>
#define vpll vector<pll>
#define vvll vector<vll>
#define all(v) v.begin(),v.end()
#define itr(r,v) for(auto r=v.begin();r!=v.end();r++)
#define FOR(i,n) for(ll i=0;i<n;i++)
#define ffo(i,a,b) for(ll i=a;i<=b;i++)
#define rfr(i,a,b) for(ll i=a;i>=b;i--)
#define space cout<<"\n\n";
#define endl "\n"
#define pqmx priority_queue<ll>
#define pqmn priority_queue<ll,vll,greater<ll>>
#define fps(x,y) fixed<<setprecision(y)<<x
#define merg(a,b,c) set_union(a.begin(),a.end(),b.begin(),b.end(),inserter(c,c.begin()))
#define set_ar(arr,v) memset(arr,v,sizeof(arr))
#define ctime auto sttart = high_resolution_clock::now()
#define etime auto sttop = high_resolution_clock::now()
#define go_t ll testcases; cin>>testcases; for(ll caseno= 1 ;caseno <= testcases; caseno++)
#define ptime auto z1z = duration_cast<microseconds>(sttop-sttart); cout<<"\nTime taken : "<<z1z.count()<<" microseconds\n"
#define dbg1(x)             cout <<#x<<": "<<x<<'\n';
#define dbg2(x, y)          cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<'\n';
#define dbg3(x, y, z)       cout <<#x<<": "<<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<'\n';
#define dbg4(a, b, c, d)    cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<'\n';
#define dbg5(a, b, c, d, e) cout <<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<<": "<<e<<'\n';

using namespace std;
using namespace std::chrono;

const ll MOD = 1e9 + 7;
const ll N = 1e5 + 5;
const ll maxN = 1e5 + 5;
const ll MAX_SIZE = 2e6 + 6;
const ll INF = 0x3f3f3f3f3f3f3f3fll;
const double PI = 3.14159265359;

ll powerM(ll x, ll y, ll M = MOD) { // default argument
	ll v = 1; x = x % M; while (y > 0) {if (y & 1)v = (v * x) % M; y = y >> 1; x = (x * x) % M;} return v;
}

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

vll adj[maxN];
ll dp[maxN];
ll vis[maxN];

void dfs(ll v) {
	vis[v] = 1;
	for (auto& u : adj[v]) {
		if (!vis[u]) {
			dfs(u);
		}
		dp[v] = max(dp[v], dp[u] + 1);
	}
}

int main()
{
#ifndef ONLINE_JUDGE
	freopen("input1.txt", "r", stdin);
	freopen("output2.txt", "w", stdout);
#endif
	FIO
    // USING DFS ANS NOT TOPO SORT
	ll n, m; cin >> n >> m;
	FOR(i, m) {
		ll x, y; cin >> x >> y; --x, --y;
		adj[x].pb(y);
	}
	for (ll i = 0; i < n; i++) {
		if (vis[i]) continue;
		dfs(i);
	}
	ll ans = 0;
	for (ll i = 0; i <= n; i++) ans = max(ans, dp[i]);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 21132
#include <bits/stdc++.h>
using namespace std;
int main() {

    string s;
    stack <int> st;
    while (cin >> s) {
        if (s[0] == '+') {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            st.push(a + b);
        }
        else if (s[0] == '-') {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            st.push(b - a);
        }
        else if (s[0] == '*') {
            int a = st.top(); st.pop();
            int b = st.top(); st.pop();
            st.push(a * b);
        }
        else {
            int n = stoi(s);
            st.push(n);
        }
    }
    cout << st.top() << endl;

    return 0;
}



Measured memory_bytes: 3160
#include <stdio.h>

int main(){
	int a, b, c;
	
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	if(a < b && b < c){
		printf("Yes\n");
	}else{
		printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 580
d = 10**9 + 7

x,y = map(int, input().split())

def numerator(n, k, p):
    l = 1;
    for j in range(k+1,n+1):
        l = (l*j)%p;
    return l

def denominator(n, k, p):
    l = 1;
    for j in range(2,n-k+1):
        l = (l*j)%p;
    return l


def power(a, k, p):
    if (k == 0):
        return 1
    r = power((a*a)%p,k>>0x01,p);
    if ((k&0x01) == 0x01): #odd number
        r = (r*a)%p;
    return r


def n_choose_K(n, k, p):
    num = numerator(n,k,p)
    den = denominator(n,k,p)
    return (num*power(den,p-2,p))%p
    

n = -(x-2*y)/3.0
m = -(-2*x+y)/3.0

if n-int(n) != 0 or m-int(m) != 0:
    print(0)
elif n<0 or m<0:
    print(0)
else:
    n = int(n)
    m = int(m)
    ans = n_choose_K(n+m,n,d)
    print(int(ans))
    


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  vector<pair<int, int>> ga(n);
  vector<pair<int, int>> ch(m);
  rep(i, n){
    int a, b;
    cin >> a >> b;
    ga.at(i) = {a, b};
  }
  rep(i, m){
    int c, d;
    cin >> c >> d;
    ch.at(i) = {c, d};
  }

  rep(i, n){
    int mnd = 1001001001, ans = -1;
    rep(j, m){
      int d = abs(ga.at(i).first - ch.at(j).first) + abs(ga.at(i).second - ch.at(j).second);
      if(d < mnd){
        mnd = d;
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  if (S.size() % 2 == 1) {
    cout << "No" << endl;
    return 0;
  }
  for (int i = 0; i < S.size(); i++) {
    if (i % 2 == 0) {
      if (S.at(i) != 'h') {
        cout << "No" << endl;
        return 0;
      }
    } else {
      if (S.at(i) != 'i') {
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<cctype>
#include<cstdio>
#include<vector>
#include<cstring>
const int N=300007,P=998244353,i2=P-P/2;
int m,root,len,fa[N],dia[N],f[N][3][3],g[3][3];std::vector<int>e[N];
void inc(int&a,int b){a+=b-P,a+=a>>31&P;}
int mul(int a,int b){return 1ll*a*b%P;}
int read(){int x=0,c=getchar();while(isspace(c))c=getchar();while(isdigit(c))(x*=10)+=c&15,c=getchar();return x;}
void dfs(int u,int dep)
{
    if(dep>len) len=dep,root=u;
    for(int v:e[u]) if(v^fa[u]) fa[v]=u,dfs(v,dep+1);
}
void dp(int u,int fa,int d)
{
    (d==m/2? f[u][1][1]:f[u][0][0])=1;
    for(int v:e[u])
    {
	if(v==fa) continue;
	dp(v,u,d+1),memset(g,0,36);
	for(int x=0;x<3;++x) for(int y=0;y<3;++y) for(int p=0;p<3;++p) for(int q=0;q<3;++q) for(int k=0,r,t;k<3;++k) r=std::min(2,x+p*(k==1)),t=std::min(2,y+q*(k==2)),inc(g[r][t],mul(f[u][x][y],f[v][p][q]));
	memcpy(f[u],g,36);
    }
}
int main()
{
    int n=read(),p,q;
    for(int i=1,u,v;i<n;++i) u=read(),v=read(),e[u].push_back(v),e[v].push_back(u);
    dfs(1,1),memset(fa+1,0,n<<2),len=0,dfs(root,1);
    for(int i=root;i;i=fa[i]) dia[++m]=i;
    if(m&1) p=dia[m/2+1],dp(p,0,0),printf("%d",mul(i2,f[p][1][1]));
    else p=dia[m/2],q=dia[m/2+1],dp(p,q,1),dp(q,p,1),printf("%d",mul((1ll*f[p][1][0]+f[p][1][1]+f[p][1][2])%P,(1ll*f[q][1][0]+f[q][1][1]+f[q][1][2])%P));
}


Measured memory_bytes: 30720
#include <iostream>
#include <algorithm>
using namespace std;
static const int MAX = 100;

void trace(int *A, int N) {
    for ( int i = 0; i < N; ++i ) {
        if ( i > 0 ) {
            cout << ' ';
        }
        cout << A[i];
    }
    cout << endl;
}

void swap(int *a, int *b) {
    int temp;
    temp = *a;
    *a = *b;
    *b = temp;
}

int BubbleSort(int *A, int N) {
    int flag = 0;
    int sw = 0;
    int cnt = 0;
    do {
        flag = 0;
        for (int i = N - 1; i > cnt; --i) {
            if (A[i] < A[i - 1]) {
                swap(A + i, A + i - 1);
                sw++;
                flag = 1;
            }
        }
        cnt++;
    }while ( flag == 1 );
    return sw;
}

int SelectionSort(int *A, int N) {
    int mini;
    int cnt = 0;
    for ( int i = 0; i < N; ++i ) {
        mini = i;
        for ( int j = i; j < N; ++j ) {
            if ( A[mini] > A[j] ) {
                mini = j;
            }
        }
        if ( A[mini] < A[i]) {
            swap(A + mini, A + i);
            cnt++;
        }
    }
    return cnt;
}

int main() {
    int A[MAX],N;
    int ans;

    cin >> N;
    for ( int i = 0; i < N; ++i ) cin >> A[i];

    ans = SelectionSort(A,N);

    trace(A,N);
    cout << ans << endl;


    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcountll

#define INF 1e16
#define mod 1000000007

vector<P> es;

void makegraph(int l,int r){ // [l,r)
  if(l>=r)return ;
  if(l+1==r){
    return ;
  }
  int m=(l+1+r)/2;
  repl(i,l+1,m)es.push_back(P(l,i));
  makegraph(l+1,m); makegraph(m,r);
}

string query(int x){
  cout<<x+1<<endl;
  fflush(stdout);
  string res;
  cin>>res;
  return res;
}

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

  int N,K;
  cin>>N>>K;
  makegraph(0,N);
  cout<<es.size()<<endl;
  rep(i,es.size())cout<<es[i].fi+1<<" "<<es[i].se+1<<endl;

  rep(_,K){
    int l=0,r=N;
    while(1){
      string q=query(l);
      int m=(l+1+r)/2;
      if(q=="Yes"){
        break;
      }else if(q=="Near"){
        l++; r=m;
      }else{
        l=m;
      }
    }
  }

  return 0;
}



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

int main() {
    long long N, A, B, C, D, E;   cin >> N >> A >> B >> C >> D >> E;
    long long ans = N/min({A, B, C, D, E}) + 4;

    if(N % min({A, B, C, D, E})) ans = N / min({A, B, C, D, E}) + 5;

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

Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

f [a, b, n] = f' 0 (mod a b) n
  where
    f' t _ 0 = t
    f' t x n = f' (t+q) r (n-1)
      where
        (q, r) = divMod (10 * x) b

main = map (f . map read . words) . lines <$> getContents >>= mapM_ print

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

using namespace std;
using ll =long long;
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
static const ll INF = 1LL << 60;
#define leftunique(a) {(a).erase(unique((a).begin(),(a).end()),(a).end());}
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int y = 0, x = 0;
	sort(s.begin(),s.end());
	leftunique(s);
	rep(i,s.size()) {
		if(s[i] == 'N' || s[i] == 'S') {
			if(y < 0) continue;
			if(y == 1){
				y = -1;
			} else {
				y = 1;
			}
		}
		if(s[i] == 'W' || s[i] == 'E') {
			if(x < 0) continue;
			if(x == 1){
				x = -1;
			} else {
				x = 1;
			}
		}
	}
	if(x <= 0 && y <= 0) {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main (){
    int n,m,k;
    cin >> n >> m >> k;
    bool flg = false;
    for(int i = 0;i<=n;i++){
        for(int j=0;j<=m;j++){
            int t = i*m+j*n-i*j*2;
            if(k==t)
                flg = true;
        }
    }
    if(flg)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, init, n) for(int i = (int)(init); i < (int)(n); i++)
#define inf __INT_MAX__

int main() {
    int N, M, P;
    cin>>N>>M>>P;
    vector<vector<pair<int, int>>> V(N);
    vector<long> D(N, -inf);
    vector<bool> update(N, false);
    REP(i, 0, M){
        int A, B, C;
        cin >> A >> B >> C;
        V[A-1].push_back({B-1, C-P});
    }
    D[0] = 0;
    REP(i, 0, N){
        REP(j, 0, N){
            for(pair<int, int> k: V[j]){
                long newCoin = D[j] + k.second;

                if (D[j] != -inf && newCoin > D[k.first]){
                    D[k.first] = newCoin;
                }
            }
        }
    }
    REP(i, 0, N){
        REP(j, 0, N){
            for(pair<int, int> k: V[j]){
                long newCoin = D[j] + k.second;

                if (D[k.first] != -inf && newCoin > D[k.first]){
                    D[k.first] = inf;
                }
            }
        }
    }
    long ans = (D[N-1] > 0 ? D[N-1] :0 );
    cout << ((ans == inf) ? -1 : ans) << endl;
}

Measured memory_bytes: 384
import java.io.*;
 
class Main {
    public static void main(String args[]) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String buf;
 
        try {
            while ((buf = br.readLine())!=null) {
                int n = Integer.parseInt(buf);
                int S = 1;
                for (int i=1;i<=n;i++) {
                    S += i;
                }
                System.out.println(S);
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}

Measured memory_bytes: 17752
#include <iostream>
using namespace std;
typedef long long ll;
#define rep(i,s,n)for(ll i = s;i<n;i++)
#define repe(i,s,n)for(ll i = s;i<=n;i++)

int main() {
	ll a, b, c; cin >> a >> b >> c;

	ll max = a;
	if (max < b) max = b;
	if (max < c) max = c;

	ll diff = max - a + max - b + max - c;

	if (diff % 2 == 0) {
		cout << diff / 2 << endl;
	}
	else {
		cout << diff / 2 + 2 << endl;
	}
	return 0;
}

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


int main(){
	long long int x;
	cin >> x;
	int f=0;
	long long int m=100;
	int y=0;
	while(f==0){
		m = floor(m*1.01);
		
		if(m>=x){
			f =1;
		}else{
		y++;
		}
	}
	cout << y+1;
}

Measured memory_bytes: 3740
#include<stdio.h>
#define MAX 10000
#define NIL -1

struct Node{int p,l,r;};
struct Node T[MAX];
int n;

void preParse(int u){
	if(u==NIL)return;
	printf(" %d",u);
	preParse(T[u].l);
	preParse(T[u].r);
}
void inParse(int u){
	if(u==NIL)return;
	inParse(T[u].l);
	printf(" %d",u);
	inParse(T[u].r);
}
void postParse(int u){
	if(u==NIL)return;
	postParse(T[u].l);
	postParse(T[u].r);
	printf(" %d",u);
}
int main(){
	int i,v,l,r,root;
	scanf("%d",&n);
	for(i=0;i<n;i++){
		T[i].p=NIL;
	}
	
	for(i=0;i<n;i++){
		scanf("%d%d%d",&v,&l,&r);
		T[v].l=l;
		T[v].r=r;
		if(l!=NIL)T[l].p=v;
		if(r!=NIL)T[r].p=v;
	}
	for(i=0;i<n;i++)if(T[i].p==NIL)root=i;
	
	printf("Preorder\n");
	preParse(root);
	printf("\n");
	printf("Inorder\n");
	inParse(root);
	printf("\n");
	printf("Postorder\n");
	postParse(root);
	printf("\n");
	return 0;
}


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

int main() {
  int N;cin>>N;
  vector<string>W (200,"");
  string ans="Yes";
  string w1,w2;cin>>w1;
  W[0]=w1;
  for(int i=1; i<N; i++){
    cin>>w2;
    for(int j=0; j<i;j++){
      if(W[j]==w2)ans="No";
    }
    W[i]=w2;
    if(w2[0]!=w1[w1.size()-1])ans="No";
    w1=w2;
  }
  cout<<ans<<endl;
}


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

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();
        var l = new LinkedList<bool>(s.Select(x => x == '1'));
        var node = l.First;
        while (node?.Next != null)
        {
            var nPrev = node;
            var nNext = node.Next;
            if (nPrev.Value != nNext.Value)
            {
                node = nPrev.Previous ?? nNext.Next;
                l.Remove(nPrev);
                l.Remove(nNext);
            }
            else
            {
                node = nNext;
            }
        }
        Console.WriteLine(s.Length - l.Count);
    }
}

Measured memory_bytes: 19804
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int n,a[1000];
    while(1){
        cin >> n;
        if(n == 0)break;
        for(int i = 0;i < n;i++) cin >> a[i];
        int sd = 0;
        for(int i = 0;i < n;i++)sd += a[i];
        double avg = 1.0*sd/n;
        double dist = 0.0;
        for(int i = 0;i < n;i++){
            dist += (avg-a[i])*(avg-a[i]);
        }
        cout << fixed << setprecision(8) << sqrt(dist/n) << endl;
    }
}
    


Measured memory_bytes: 3240
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <limits.h>
#include <string>
#include <string.h>
#include <sstream>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <stack>
#include <queue>

using namespace std;

typedef long long ll;

int main(){
  int a, b, c;
  cin >> a >> b >> c;

  int array[3] = { a, b, c };
  sort(array, array+3);

  printf("%d %d %d\n", array[0], array[1], array[2]);
  
  return 0;
}

Measured memory_bytes: 1160
fun main(args: Array<String>) {
    val (N, M) = listOfInt()
    val A = listOfInt().sortedDescending()
    val U = arrayListOf(0, 2, 5, 5, 4, 5, 6, 3, 7, 6)
    val V = A.map { U[it] }
    val S = Array<String?>(10001) { null }; S[0] = ""
    for (n in 1 .. N) {
        for (m in 0 until M) {
            val t = n - V[m]
            if (t >= 0 && S[t] != null) {
                if (S[n] == null) S[n] = ""
                if (S[n]!!.length <= S[t]!!.length) {
                    S[n] = S[t] + A[m].toString()
                }
            }
        }
    }
    val ans = S[N]!!.split("").sortedDescending()
    println(ans.joinToString(""))
}
fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map(String::toInt)

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

using namespace std;
typedef long long ll;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n,m;
    cin>>n>>m;
    vector<pair<ll,ll> > drink(n);
    for(int i=0;i<n;i++)
    {
        cin>>drink[i].first>>drink[i].second;
    }
    sort(drink.begin(),drink.end());
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        if(drink[i].second>=m)
        {
            sum+=(m*drink[i].first);
            break;
        }
        else
        {
            sum+=(drink[i].second*drink[i].first);
            m-=drink[i].second;
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

Int n, ans = 1e18;
vector<Int> x, y;
using P = pair<Int, Int>;
map<P, Int> mp;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin >> n;
	x.resize(n); y.resize(n);
	for(Int i=0; i<n; ++i) cin >> x[i] >> y[i];
	for(Int i=0; i<n; ++i) mp[P(x[i], y[i])] = i;
	for(Int i=0; i<n-1; ++i)
		for(Int j=i+1; j<n; ++j){
			Int p = x[j] - x[i], q = y[j] - y[i];
			vector<bool> f(n, false);
			Int tmp = 1;
			f[0] = true;
			for(Int k=0; k<n; ++k){
				if(!f[k]){
					++tmp;
					f[k] = true;
				}
				Int tx = x[k], ty = y[k];
				while(mp.count(P(tx+p, ty+q))){
					f[mp[P(tx+p, ty+q)]] = true;
					tx += p;
					ty += q;
				}
				tx = x[k], ty = y[k];
				while(mp.count(P(tx-p, ty-q))){
					f[mp[P(tx-p, ty-q)]] = true;
					tx -= p;
					ty -= q;
				}
			}
			ans = min(ans, tmp);
		}
	cout << (n == 1 ? 1 : ans) << "\n";
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.util.ArrayList;

public class Main{

	public static void main(String[] args) {

		//
		ArrayList<Integer> big_list = new ArrayList<Integer>();
		ArrayList<Integer> small_list = new ArrayList<Integer>();
		
		int big = 0;
		int small = 0;

		// テキスト入力
		Scanner sc = new Scanner(System.in);
		
		while(true){
			// 入力文字を取得
			int first = sc.nextInt();
			int second = sc.nextInt();
			
			//
			if(first==0 && second==0){
				break;
			}

			// 小さい順に並べる
			if (first >= second) {
				//
				big = first;
				small = second;
			} else {
				big = second;
				small = first;
			}
			
			//リストに入れる
			big_list.add(big);
			small_list.add(small);
		}

		//ループ
		for(int i = 0;i < big_list.size();i++)
		// 出力
				System.out.println(small_list.get(i)+ " " + big_list.get(i));
	}
}

Measured memory_bytes: 27768
n = int(input())
l = []
for i in range(n):
    a = input()
    l.append(a)
print("AC" , "x" , l.count("AC"))
print("WA" , "x" , l.count("WA"))
print("TLE" , "x" , l.count("TLE"))
print("RE" , "x" , l.count("RE"))


Measured memory_bytes: 78768
public class Main {
	public static void main(String args[]) {
		java.util.Scanner sc = new java.util.Scanner(System.in);
		int N = sc.nextInt();
		int[] H = new int[N];
		for (int i=0; i < N; i++) {
			H[i] = sc.nextInt();
		}

		int result = 0;

		boolean b = false;
		for (int i=0; i < N; i++) {
			b = false;
			for (int j=0; j < i; j++) {
				if (H[i] < H[j]) {
					b = true;
				}
			}
			if (!b) {
				result++;
			}
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 22996
<?php


fscanf(STDIN, "%d%d%d", $n, $A, $T);

for($i=1;$i<$n;$i++){
    fscanf(STDIN, "%d%d", $t1, $t2);
    $map[$t1][$t2]=1;
    $map[$t2][$t1]=1;
}
$dmap[$T] = 0;
getDepth($T, 1);

$half = intdiv($dmap[$A] - 1, 2);
if($half != intdiv($dmap[$A], 2)){
    $add = 1;
}else{
    $add = 0;
}
$halfD = $dmap[$A] - $half;
    $start = $A;

while($dmap[$start] != $halfD){
    foreach($map[$start] as $key => $value){
        if($dmap[$key] < $dmap[$start]){
            $start = $key;
            break;
        }
    }
}

$ans = search($start);
echo $ans -1;


function search($T){
    global $map, $dmap;
    $now = $dmap[$T];
    $return = $now;
    foreach($map[$T] as $key=> $value){
        if($dmap[$key] > $now){
            $return = max($return, search($key));
        }
    }
    return $return;
}


function getDepth($T, $depth){
    global $map, $dmap;
    foreach($map[$T] as $key => $value){
        if(!isset($dmap[$key])){
            $dmap[$key] = $depth;
            getDepth($key, $depth+1);
        }elseif($map[$key] < $depth){
            $dmap[$key] = $depth;
            getDepth($key, $depth+1);
        }
    }
}



Measured memory_bytes: 92664
#include<iostream>
#include<vector>
#include<string>
#include<bitset>
using namespace std;
int main(){
	int N, M; cin >> N >> M;
	vector<vector<int>>light(M);
	for (int i = 0; i < M; ++i){
		int k; cin >> k;
		for (int j = 0; j < k; ++j){
			int a; cin >> a;
			light[i].push_back(a);
		}
	}
	vector<int>P(M);
	for (int i = 0; i < M; ++i){
		cin >> P[i];
	}
	int ans = 0;
	for (int bit = 0; bit < (1 << N); ++bit){
		int on = 0;
		for (int i = 0; i < M; ++i){
			int cnt = 0;
			for (auto p : light[i]){
				if (bit&(1 << p - 1))++cnt;
			}
			if (cnt % 2 == P[i])++on;
		}
		if (on == M)++ans;
	}
	cout << ans << "\n";

	 return 0;
}

Measured memory_bytes: 256
// ABC166C.cpp

#include <iostream>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
using ll = long long;
using P = pair<int, int>;
int main()
{
    int n, m;
    cin >> n >> m;
    vector<bool>tower(n,true); // 良い展望台か
    vector<ll>h(n); // 高さ
    rep(i, n) cin >> h[i];
    int a, b;
    rep(i, m) {
        cin >> a >> b;
        --a;
        --b;
        if (h[a] <= h[b]) tower[a] = false;
        if (h[b] <= h[a]) tower[b] = false;
    }
    int ans = 0;
    rep(i, n) {
        if (tower[i] == true) ans++;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3576
import java.util.*;

class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        char[] ch=sc.next().toCharArray();
        sc.close();
        int n=ch.length;
        String ans;
        if(ch[0]==ch[n-1]){
            ans=n%2==0?"First":"Second";
        } else{
            ans=n%2==0?"Second":"First";
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 27856
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;

#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T &val) {
	std::fill((T*)array, (T*)(array + N), val);
}

ll N, Q;
string s;
vector<pair<char, char>> vec;

int func(ll pos) {
	rep(i, Q) {
		if (vec[i].first == s[pos]) {
			if (vec[i].second == 'L') pos--;
			if (vec[i].second == 'R') pos++;
		}
		if (pos == N) return 1;
		if (pos == -1) return -1;
	}
	return 0;
}

void solve() {
	cin >> N >> Q >> s;
	vec.resize(Q);
	rep(i, Q) cin >> vec[i].first >> vec[i].second;

	//binary search
	//最終的にL=Rはtrueの左端で止まる
	//←false→LR←true→
	ll L = 0, R = N;
	//全てtrueのときは普通に0が返る
	//全てfalseのとき，sizeが返る
	while (L != R) {
		ll F = (L + R) / 2;
		bool judge;

		//判定式
		if (func(F) == -1) {
			judge = false;
		}
		else {
			judge = true;
		}

		if (judge) { R = F; }
		else { L = F + 1; }

	}

	ll ans = R;

	L = 0, R = N;
	while (L != R) {
		ll F = (L + R) / 2;
		bool judge;

		//判定式
		if (func(F) == 1) {
			judge = true;
		}
		else {
			judge = false;
		}

		if (judge) { R = F; }
		else { L = F + 1; }

	}

	ans = R-ans;

	cout << ans;

}

int main() {
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 900