akhauriyash/Code-Regression huggingface dataset:
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

#[allow(unused_macros)]
macro_rules! vecs {
    ($init:expr; $($dim:expr);*) => {
        vecs!($($dim);* => $init)
    };
    ($head:expr; $($tail:expr);* => $init:expr) => {
        vec![vecs!($($tail);* => $init); $head]
    };
    ($head:expr => $init:expr) => {
        vec![$init; $head]
    };
}

#[allow(unused_macros)]
macro_rules! chmax {
    ($x:expr, $y:expr) => {
        if $x < $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}


#[allow(unused_macros)]
macro_rules! chmin {
    ($x:expr, $y:expr) => {
        if $x > $y {
            $x = $y;
            true
        } else {
            false
        }
    };
}

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let n = scan.read::<usize>();
    let t = scan.read::<usize>();
    let mut a = vec![];
    let mut b = vec![];
    for _ in 0..n {
        a.push(scan.read::<usize>());
        b.push(scan.read::<usize>());
    }

    let mut dp1 = vecs![0usize;n+1;t+1];
    let mut dp2 = vecs![0usize;n+1;t+1];
    for i in 0..n {
        for j in 0..t+1 {
            chmax!(dp1[i+1][j], dp1[i][j]);
            if j + a[i] < dp1[0].len() {
                chmax!(dp1[i + 1][j + a[i]], dp1[i][j] + b[i]);
            }
        }
    }

    for i in (0..n).rev() {
        for j in 0..t+1 {
            chmax!(dp2[i][j], dp2[i+1][j]);
            if j + a[i] < dp2[0].len() {
                chmax!(dp2[i][j + a[i]], dp2[i+1][j] + b[i]);
            }
        }
    }

    let mut ret = 0usize;
    for i in 0..n {
        for j in 0..t {
            chmax!(ret, dp1[i][j] + dp2[i+1][t-1-j] + b[i]);
        }
    }
    println!("{}", ret);
}

// region template
#[allow(dead_code)]
fn iu(i: i64) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> i64 { i as i64 }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

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

long long gcd(long long c, long long d){
    if(c%d==0){
        return d;
    }else{
        return gcd(d, c%d);
    }
}

long long lcm(long long c, long long d){
    return c*d/gcd(c, d);
}

int main(void){
    long long a,b,c,d;
    cin>>a>>b>>c>>d;
    long long asum, bsum, cm, dm, cdm;
    cm=(a-1)/c;
    dm=(a-1)/d;
    cdm=(a-1)/lcm(c,d);
    asum=(a-1)-cm-dm+cdm;
    
    cm=b/c;
    dm=b/d;
    cdm=b/lcm(c,d);
    bsum=b-cm-dm+cdm;
    
    cout<<bsum-asum<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
// #define allr(x) (x).rbegin(),(x).rend()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
template<class T> T in(){T x;cin>>x;return x;}

int main(){
	ll N; cin>>N;
	vl A(N),B(N),C(N);
	ll sumA=0, sumB=0, minus=0;
	int ans = 0;
	rp(i,0,N){
		A[i] = in<ll>();
		sumA+=A[i];
		C[i] = A[i];
	}
	rp(i,0,N){
		cin>>B[i];
		sumB+=B[i];
		C[i] -= B[i];
		if(C[i]<0){
			ans++;
			minus += C[i];
		}
	}

	// for(auto x:C){cout<<x<<" ";}puts("");///

	// ote(sumA);
	// ote(sumB);
	// ote(minus);

	if(sumA < sumB){
		puts("-1");
		return 0;
	}

	sort(all(C));

	// for(auto x:C){cout<<x<<" ";}puts("");///

	for(int i=C.size()-1; minus<0 && i>=0 && C[i]>0; --i){
		ans++;
		minus += C[i];
	}

	ote(ans);
}


Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int a,b,c;
    int ans =0;
    cin >> a >> b >> c;
    int mx = max(a,b);
    int mn = min(a,b);
    int mn2 = min(mx,c);
    int gapi,gapj=0;
    mx = max(mx,c);
    if((mn+mn2)%2!=0){
        if(mx%2==0){
            if(mn%2==0){
                mx++;
                mn++;
                ans++;
            }else{
                mx++;
                mn2++;
                ans++;
            }
        }else{
            if(mn%2!=0){
                mx++;
                mn++;
                ans++;
            }else{
                mx++;
                mn2++;
                ans++;
            }
        }
    }
    gapi = mx-mn2;
    ans +=gapi;
    mn +=gapi;
    if((mx-mn)%2==0){
      gapj=mx - mn;
    }else{
      gapj=mx-mn+1;
    }
      ans+=gapj/2;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int n;
    cin>>n;
    vector<ll> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    int ans=0;
    for(int i=0;i<n;i++)ans+=a[i]-1;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
sdush = input()
t = input()

ans = []
for i in range(len(sdush)-len(t)+1):
  for index,c in enumerate(t):
    if c != sdush[i+index] and sdush[i+index] != '?':
      break
    if index+1 == len(t):
      ans.append(sdush[:i]+t+sdush[i+1+index:])

result = "z"*50
for an in ans:
  if result > an:
    result = an
if result == "z"*50:
  print("UNRESTORABLE")
else:
  print(result.replace("?","a"))


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

int main(){
  int H,W;
  cin >> H >> W;
  vector<vector<char>> table(H,vector<char>(W));
    for(int i=0;i < H;i++){
      for(int j=0;j < W;j++){
        cin >> table.at(i).at(j);
      }
    }
  
  vector<bool> row(H,false);
  vector<bool> col(W,false);
  for(int i=0;i < H;i++){
      for(int j=0;j < W;j++){
        if(table.at(i).at(j)=='#'){
          row.at(i)=true;
          col.at(j)=true;
        }
      }
  }
  for(int i=0;i<H;i++){
    if(row.at(i)){
      for(int j=0;j<W;j++){
        if(col.at(j)){
          cout << table.at(i).at(j);
        }
      }
    }
    cout << endl;
  }
}
  


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

int main() {
	int a,b,i=0;
	long long int c,d;
	cin>>a;
	cin>>b;
	cin>>c;
	for(i=0;i<10;i++)
	{d=a*c-b;
	c=d;
	cout<<d<<endl;}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
    char x[1001];
    int sum;
    
    while (scanf("%s", x) && x[0]!='0'){
        sum=0;
        for (char *p=x; *p != '\0'; p++){
            sum += *p - '0';
        }
        printf("%d\n", sum);
    }

    return 0;
}

Measured memory_bytes: 964
s=input()
t=input()

n=len(s)

slis=[]

for i in range(n):
  if s[i] not in slis:
    slis.append(s[i])

tlis=[]

for i in range(n):
  if t[i] not in tlis:
    tlis.append(t[i])

snum=[]

for i in range(n):
  for j in range(len(slis)):
    if s[i]==slis[j]:
      snum.append(j)
      break

tnum=[]
for i in range(n):
  for j in range(len(tlis)):
    if t[i]==tlis[j]:
      tnum.append(j)


c=0
for i in range(n):
  if snum[i]!=tnum[i]:
    c+=1

if c==0:
  print("Yes")
else:
  print("No")


Measured memory_bytes: 90308
using System;

namespace ASPC2019_A
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var H = int.Parse(Console.ReadLine());
            var W = int.Parse(Console.ReadLine());

            Console.WriteLine((N - H + 1) * (N - W + 1));
        }
    }
}


Measured memory_bytes: 11220
#include<bits/stdc++.h>
using namespace std;
string a,b="CODEFESTIVAL2016";
int c=16;
int main(){
    cin>>a;
    for(int i=0;i<16;i++)
    c-=(a[i]==b[i])?1:0;
    cout<<c<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fios ios_base::sync_with_stdio(false); cin.tie(0);
#define sf(x) scanf("%d",&x)
#define sfl(x) scanf("%lld",&x)
#define pf(x) printf("%d\n",x)
#define pfl(x) printf("%lld\n",x)
#define ll long long
#define nl "\n"
using namespace std;


int main()
{
    int ans=0,r,l,len;

    string s;

    cin>>s;
    len=s.length();

    //if(len%2==0)
    //{
        r=0;

         while(r<len/2)
         {
             if(s[r]!=s[len-r-1])
                ans++;

             r++;
         }
    //}
    cout<<ans<<nl;

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()

ll mpow(ll a, ll b){
	if(b==0) return 1;
	else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
	else return mpow(a,b-1) * a % MOD;
}
ll gcd(ll a, ll b){
	if(b==0) return a;
	else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
	if(kaijo_memo.size() > n) return kaijo_memo[n];
	if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
	while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
	return kaijo_memo[n];
}
ll nCr(ll n, ll r){
	if(n < r || r < 0) return 0;
	ll ret = 1;
	ret *= kaijo(n); ret %= MOD;
	ret *= mpow(kaijo(r), MOD-2); ret %= MOD;
	ret *= mpow(kaijo(n-r), MOD-2); ret %= MOD;
	return ret;
}

int main(void){
	int n;
	int a;
	cin>>n;
	vector<int> A, count;
	rep(i,n+1){
		count.push_back(0);
	}
	rep(i,n+1){
		cin>>a;
		A.push_back(a);
		count[a]++;
	}
	int chohuku;
	reps(i,n){
		if(count[i] == 2){
			chohuku = i;
			break;
		}
	}

	vector<int> idx;
	rep(i,n+1){
		if(chohuku == A[i]){
			idx.push_back(i);
		}
	}

	int kouho1 = idx[0], kouho2 = n - idx[1];

	reps(k, n+1){
		ll ans = 0;
		ans += nCr(n+1, k);
		ans -= nCr(kouho1 + kouho2, k-1);
		ans = (ans+MOD)%MOD;
		cout<<ans<<endl;
	}
	return 0;
}


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

int main(){
  int A,B;
  cin >> A >> B;
  if(A+B==3){
    cout << '3' << endl;
  }
  else if(A+B==4){
    cout << '2' << endl;
  }
  else{
    cout << '1' << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> iint;
typedef pair<ll,ll> llll;
#define ALL(x) (x).begin(),(x).end()
const ll zero = 0;
const ll one = 1;
const ll INF = 9223372036854775807; //10^18
const int inINF = 2147483647; //10^9
const ll MOD = 1000000007; //10^9+7
const ll MOD2 = 998244353;
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

bool f(ll K, vector<ll> &h, ll N, ll A, ll B){
    vector<ll> tmp(N);
    for (ll i = 0; i < N; i++) {
        tmp[i] = h[i] - K*B;
    }
    ll C = A - B;
    ll cnt = 0;
    for (ll i = 0; i < N; i++) {
        if(tmp[i] <= 0) continue;
        cnt += (tmp[i] - 1) / C + 1;
    }

    if(cnt <= K){
        return true;
    }
    else{
        return false;
    }
}

int main(){
    ll N, A, B;
    cin >> N >> A >> B;
    vector<ll> h(N);
    for (ll i = 0; i < N; i++) {
        cin >> h[i];
    }

    ll ng = 0;
    ll ok = 1000000005;
    ll mid;
    while( ng + 1 < ok ){
        mid = (ng + ok) / 2;
        if(f(mid, h, N, A, B)){
            ok = mid;
        }
        else{
            ng = mid;
        }
    }
    printf("%lld\n", ok);


}

Measured memory_bytes: 5044
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    string S;
    cin >>S;
    S[3]='8';
    cout <<S<<endl;



}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long
using pi=pair<int,int>;
#define mp make_pair
const int mod = 1e9+7;

signed main(){
  int n;
  cin>>n;
  vector<int> a(3*n);
  for(auto& i:a)cin>>i;
  int res=0;
  sort(a.begin(),a.end(),greater<>());
  for(int i=0;i<n;++i)res+=a[2*i+1];
  cout<<res;
}


Measured memory_bytes: 2560
import sys
sys.setrecursionlimit(2147483647)
INF=float("inf")
MOD=10**9+7
input=lambda:sys.stdin.readline().rstrip()

def bisection(l,r,f,left=True,discrete=True):
    eps=1 if discrete else 10**-12
    if((not left)^f(r)): return r if left else r+1
    elif(left^f(l)): return l-1 if left else l
    while(r-l>eps):
        h=(l+r)//2 if discrete else (l+r)/2
        if((not left)^f(h)): l=h
        else: r=h
    return (l+r)/2 if not discrete else l if left else r

def resolve():
    n,k=map(int,input().split())
    A=list(map(int,input().split()))
    A.sort()
    F=list(map(int,input().split()))
    F.sort(reverse=1)

    def check(m):
        cost=0
        for a,f in zip(A,F):
            if(a*f<=m): continue
            cost+=(a*f-m-1)//f+1
        return cost<=k

    print(bisection(0,10**12,check,left=False))
resolve()

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

#define ll long long
#define all(x) (x).begin(), (x).end()
const long long INF = 1LL << 60;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)  //(i, 10) i=0～i=9まで
#define repr(i, n) for (int i = n; i >= 0; i--)   // (i, 10) i=10～i=0まで
#define FOR(i, m, n) for (int i = m; i < n; i++)  // (i, 3, 10) i=3～i=9まで

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

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

    // 入力
    double T, X;
    cin >> T >> X;

    // 処理
    // 出力
    cout << T / X << 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();
    String t = sc.next();
    int n = s.length();
    int m = t.length();
    int[][] dp = new int[n+1][m+1];
    for(int i=0;i<n;i++){
      for(int j=0;j<m;j++){
        if(s.charAt(i)==t.charAt(j))dp[i+1][j+1]=dp[i][j]+1;
        else dp[i+1][j+1]=Math.max(dp[i+1][j],dp[i][j+1]);
      }
    }
    int x = n-1;
    int y = m-1;
    StringBuilder sb = new StringBuilder();
    while(x>=0&&y>=0){
      if(s.charAt(x)==t.charAt(y)){
        sb.append(s.substring(x,x+1));
        x--;
        y--;
      }
      else if(dp[x+1][y+1]==dp[x+1][y])y--;
      else if(dp[x+1][y+1]==dp[x][y+1])x--;
    }
    sb.reverse();
    System.out.println(sb.toString());
  }
}

Measured memory_bytes: 85796
n, m = map(int, input().split())
if m == 1 or n >= m:
  print(0)
else:
  x = list(map(int, input().split()))
  x.sort()
  d = [0]*(m-1)
  for i in range(m-1):
    d[i] = x[i+1] - x[i]
  d.sort(reverse = True)
  sum = sum(d)
  for i in range(n-1):
    sum -= d[i]
  print(sum)

Measured memory_bytes: 13960
import sys

a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

target = [a,b,c,d,e]

gap = [abs(a-e),abs(b-e),abs(c-e),abs(d-e)]

for i in range(len(gap)):
	if gap[i] > k:
		print(':(')
		sys.exit()
print('Yay!')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using it=std::int64_t;

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

    it count=0;
    for(it i=0;i<2;i++){
        if(a>=b){
            count+=a;
            a--;
        }
        else{
            count+=b;
            b--;
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
//Robs Code

/***********HEADER***************/
#include <iostream>
#include <bitset>
#include <deque>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <string>
#include <algorithm>
#include <list>
#include <vector>
#include <unordered_set>
#include <unordered_map>
#include <stack>
#include <set>
#include <queue>
#include <map>
#include <iomanip>

/***********MACROS***************/
#define int long long int
#define all(x) x.begin(),x.end()
#define allr(x) x.rbegin(),x.rend()
#define endl "\n"
#define pb push_back
#define _1 first
#define _2 second
#define pii pair<int,int>

using namespace std;

const int N = 1e5 + 1;
int n,m,i,j,k,l,x,y,z,cnt[3],sum[3];

/***********MAIN**************/
signed main(){
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
	cin >> n;
	if(n >= 30){
		cout << "Yes";
	}else{
		cout << "No";
	}
}
//.........

Measured memory_bytes: 3684
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

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

    if (D == 0) {
        if (N == 100)
            cout << 101 << endl;
        else 
            cout << N << endl;
    }
    else if (D == 1) {
        if (N == 100)
            cout << 10100 << endl;
        else {
            long long int N_1 = N*100;
            cout << N_1<< endl;
        }
    }
    else if (D == 2) {
        if (N == 100)
            cout << 1010000 << endl;
        else {
            long long int N_2 = N*10000;
            cout << N_2 << endl;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void pr(A a){cout << a << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for(int j=0;j<N;++j) {}

int main(void) {
  int n,l;cin>>n>>l;
  int L[n+10];
  REP(i,n) {
    L[i] = l+i;
  }
  int tmp = L[0];
  int sum = L[0];
  for(int j=1;j<n;++j) {
    if(abs(L[j])<abs(tmp)) tmp=L[j];
    sum += L[j];
  }
  pr(sum-tmp);
  return 0;
}


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

// Inserted snippets: io, root
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
template<typename H> bool chmin(H& v1, const H v2) { if (v1 > v2) { v1 = v2; return true; } return false; }
template<typename H> bool chmax(H& v1, const H v2) { if (v1 < v2) { v1 = v2; return true; } return false; }
template<typename H> void read(H& head) { cin >> head; }
template<typename H, typename ...T> void read(H& head, T& ...tail) { cin >> head; read(tail...); }
template<typename H> void write(H head) { cout << head << '\n'; }
template<typename H, typename ...T> void write(H head, T ...tail) { cout << head << " "; write(tail...); }
template<typename ...T> void die(T ...tok) { write(tok...); exit(0); }
// End snippets

int main() {
	cin.tie(0)->sync_with_stdio(0);
	cin.exceptions(cin.failbit);

	string s; read(s);
	if (sz(s) == 26) {
		if (s == "zyxwvutsrqponmlkjihgfedcba")
			write(-1);
		else {
			string t;
			while (s[sz(s) - 2] > s[sz(s) - 1]) {
				s.pop_back();
			}
			s.pop_back();
			char d = s.back(); s.pop_back();
			//write(s, d);
			set<char> sc(all(s));
			for (char c = d + 1; c <= 'z'; c++)
				if (sc.find(c) == sc.end()) {
					s += c;
					write(s);
					return 0;
				}
		}
	} else {
		set<char> sc(all(s));
		for (char c = 'a'; c <= 'z'; c++)
			if (sc.find(c) == sc.end()) {
				s += c;
				write(s);
				return 0;
			}
	}
}


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

#define fr(i,n) for(int i = 0; i<n; i++)
#define sz(v) (int)(v.size())
#define prin(a) cout << #a << " = " << a << endl
#define all(v) (v).begin(),(v).end()
typedef long long ll;

int main(){
	ll n, k;
	cin >> n >> k;
	
	multiset<pair<ll,ll>> s;
	fr(i,n){
		ll a, b;
		scanf("%lld%lld", &a, &b);
		s.emplace(a,b);
	}
	
	ll soma = 0;
	k--;
	for(auto &p : s){
		ll val, freq;
		tie(val,freq) = p;
		soma+=freq;
		if(k<soma){
			printf("%lld\n", val);
			return 0;
		}
	}
	puts("erro");
}

Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int main() {
  string s;
  cin >> s;
  if(s[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }
  s[0] = 'a';
  int c = 0;
  for(int i = 2; i < s.size()-1; i++) {
    if(s[i] == 'C') {
      c++;
      s[i] = 'c';
    }
  }
  if(c != 1) {
    cout << "WA" << endl;
    return 0;
  }
  REP(i, s.size()) {
    if(s[i] < 'a' || 'z' < s[i]) {
      cout << "WA" << endl;
      return 0;
    }
  }
  cout << "AC" << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[200000];
  int b[200000];
  int max_first = 0;
  int max_second = 0;
  int tmp = 0;
  int k;
  for(int i=0; i<n; i++){
    cin >> a[i];
    b[i] = a[i];
    if(max_first < a[i]){
    	max_first = a[i];
      	tmp = i;
    }
  }
  sort(b, b+n);
  reverse(b, b+n);
  max_second = b[1];
  for(int i=0; i<n; i++){
    if(i == tmp){
      cout << max_second << '\n';
    }
    else{
      cout << max_first << '\n';
    }
  }
  
 return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using Graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

vector<ll> dijkstra(int s,WeightedGraph  & G){
  using P = pair<ll, int>;
  int n=G.size();
  vector<ll> ds(n,INF);
  vector<int> bs(n,-1);
  priority_queue<P, vector<P>, greater<P> > pq;
  ds[s]=0;
  pq.emplace(ds[s],s);
  while(!pq.empty()){
    P p=pq.top();pq.pop();
    int v=p.second;
    if(ds[v]<p.first) continue;
    for(auto& e:G[v]){
      int u=e.first;
      ll c=e.second;
      if(ds[u]>ds[v]+c){
        ds[u]=ds[v]+c;
        bs[u]=v;
        pq.emplace(ds[u],u);
      }
    }
  }
  return ds;
}


int main(){
  int n,m,s,t;
  cin >> n >> m >> s >> t;
  --s;--t;
  
  WeightedGraph G(n), G2(n);
  for(int i = 0; i < m; ++i){
    ll u,v,a,b;
    cin >> u >> v >> a >> b;
    --u;--v;
    G[u].push_back({v,a});
    G[v].push_back({u,a});
    G2[u].push_back({v,b});
    G2[v].push_back({u,b});
  }
  auto d = dijkstra(s,G);
  auto d2 = dijkstra(t,G2);
  vector<ll> ans(n+1,INF);
  for(int i = n-1; i >= 0; --i){
    ans[i]= min(ans[i+1], d[i]+ d2[i]);
  }
  ll tmp = 1e15;
  for(int i = 0; i < n; ++i){
    cout << tmp-ans[i] << endl;
  }
}


Measured memory_bytes: 19320
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int x,y;
    cin>>x>>y;
    if ((x+y)<24)
        cout<<x+y;
    else if (x+y==24)
        cout<<0;
    else if (x+y>24)
        cout<<(x+y)-24;

return 0;
}




Measured memory_bytes: 3596
a, b, c, x = map(int, [input() for i in range(4)])
ans = 0
for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if i * 500 + j * 100 + k * 50 == x:
                ans += 1
print(ans)

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using P = pair<int,int>;



int main() {
	
	
	int n; cin >> n;
	int num = 7;
	
	rep(i,n+1){
		num %= n;
		if(num == 0){
			cout << i+1 << endl;
			return 0;
		}
		num = num * 10 + 7;
	}
	cout << "-1\n"; return 0;
	return 0;
}


Measured memory_bytes: 3572
require 'pp'

class String
  def to_a
    self.bytes.to_a.map(&:chr)
  end
end

# http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0118

def depth_search(map, h, w)
  directions = [[1, 0], [-1, 0], [0, 1], [0, -1]]
  stack = []
  visit = []
  stack.push([h, w])
  until stack.empty? do
    h, w = stack.pop
    visit[h] = [] if visit[h].nil?
    visit[h][w] = true
    target = map[h][w]
    map[h][w] = nil
    directions.each do |(i, j)|
      target_next = map[h + i][w + j]
      if target_next != nil and target == target_next then
        stack.push([h + i, w + j])
      end
    end
  end
end

def read_each_data(&proc)
  h, w = $stdin.gets.chomp.split(" ").map(&:to_i)
  return if h == 0 and w == 0
  map = []
  map << Array.new(w + 2, nil)
  h.times do
    map << [nil] + $stdin.gets.chomp.to_a + [nil]
  end
  map << Array.new(w + 2, nil)
  proc.call(map, h, w)
  read_each_data(&proc)
end

read_each_data do |map, height, width|
  counter = 0
  1.upto(height) do |h|
    1.upto(width) do |w|
      if (map[h][w].nil?) then next
      else
        depth_search(map, h, w)
        counter += 1
      end
    end
  end
  puts counter
end

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

using namespace std;

#define F 		first
#define S 		second
#define ll 		long long
#define ld 		long double
#define pii		pair<ll, ll>
#define vi		vector<ll>
#define si 		set<ll>
#define mii 	map<int, int>
#define umii 	unordered_map<ll, ll>
#define pb		push_back
#define mk		make_pair
#define all(a)	a.begin(), a.end()
#define ask(x) 	cerr << #x << " = " << x << "\n";
#define INF 	1000000007
#define hell 	998244353

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

	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif

	ll n;
	cin >> n;

	vi a(n), b(n);
	for (ll i = 0; i < n; ++i)
		cin >> a[i] >> b[i];

	sort(all(a));
	sort(all(b));

	if (n & 1) {
		cout << b[n / 2] - a[n / 2] + 1;
	}
	else {
		cout << b[n / 2] + b[n / 2 - 1] - a[n / 2] - a[n / 2 - 1] + 1;
	}

	return 0;
}

Measured memory_bytes: 6332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i =1 ;i<n;i++)
typedef long long ll;
ll lcm(ll x,ll y);

int main (){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<(b-a+1-b/c-b/d+b/lcm(c,d)+(a-1)/c+(a-1)/d-(a-1)/lcm(c,d))<<"\n";
	return 0;
}

ll lcm(ll x,ll y){
	return x*y/__gcd(x,y);
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cassert>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <iostream>
#include <numeric>

/* debug macros */
#ifdef WAFDAYO
#define DBG_LINE() {std::cerr<<"\e[2m[L"<<__LINE__<<"]\e[m ";}
#define DBG_PRINT(s,t,u) {std::cerr<<(s)<<" \e[2m=\e[m \e[1m"<<(t)<<"\e[m"<<(u);}
#define SELECT_7TH(x1,x2,x3,x4,x5,x6,x7,...) x7
#define dbg1(x1) DBG_PRINT(#x1,x1,std::endl)
#define dbg2(x1,x2) DBG_PRINT(#x1,x1,", ")dbg1(x2)
#define dbg3(x1,x2,x3) DBG_PRINT(#x1,x1,", ")dbg2(x2,x3)
#define dbg4(x1,x2,x3,x4) DBG_PRINT(#x1,x1,", ")dbg3(x2,x3,x4)
#define dbg5(x1,x2,x3,x4,x5) DBG_PRINT(#x1,x1,", ")dbg4(x2,x3,x4,x5)
#define dbg6(x1,x2,x3,x4,x5,x6) DBG_PRINT(#x1,x1,", ")dbg5(x2,x3,x4,x5,x6)
#define dbg(...) DBG_LINE()\
SELECT_7TH(__VA_ARGS__,dbg6,dbg5,dbg4,dbg3,dbg2,dbg1)(__VA_ARGS__)
#else
#define dbg(...) {}
#endif

/* utility functions */
struct read_item{read_item(){};
template<class T>operator T(){T t;std::cin>>t;return t;}};
char splf(int i,int n){return(i+1<n)?' ':'\n';};
template<bool up>
struct _RI{int i;_RI(int a):i(a){}
int operator*(){return i;}void operator++(){i+=(up?1:-1);}
bool operator!=(const _RI& r){return up?i<r.i:i>=r.i;}};
template<bool up>
struct _RX{_RI<up> x,y;_RI<up> begin(){return x;}_RI<up> end(){return y;}
_RX(int a,int b):x(up?a:(a-1)),y(b){}_RX(int a):_RX(up?0:a,up?a:0){}};
typedef _RX<true> range;
typedef _RX<false> revrange;

/* types and constants */
typedef int64_t i64;
typedef uint64_t u64;
// const i64 inf = (i64)1.05e18;
// const int inf = (int)1.05e9;

using namespace std;

int compute(int v, int from, vector<vector<int>>& g) {

	int sum = 0;
	int zero = 0;

	for(auto w : g[v]) {

		if(w == from) {
			continue;
		}

		int s = compute(w, v, g);
		if(s == 0) {
			zero += 1;
		}
		sum += s;
	}

	return sum + max(0, zero - 1);
}

int main() {

	const int N = read_item();
	vector<vector<int>> g(N);
	for(auto i : range(N - 1)) {
		int a = read_item();
		int b = read_item();
		g[a].push_back(b);
		g[b].push_back(a);
	}

	int root = -1;
	for(auto v : range(N)) {
		if(g[v].size() > 2) {
			root = v;
			break;
		}
	}

	if(root == -1) {
		printf("1\n");
		return 0;
	}

	int ans = compute(root, -1, g);

	printf("%d\n", ans);

	return 0;
}

/* wafdayo~~~ */


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

int main() 
{
    int K, X;
    cin >> K >> X;
    int min_v, max_v;

    min_v = X - (K - 1);
    max_v = X + (K - 1);
    if (min_v < -1000000) min_v = -1000000;
    if (max_v > 1000000) max_v = 1000000;

    for (int i = min_v; i <= max_v; i++) 
    {
        if (i != min_v) cout << " ";
        cout << i;
    }
    cout << endl;
}

Measured memory_bytes: 256
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int memo[2010][2010];

int solve(int x, int y) {
    int &val = memo[x][y];
    if(~val) return val;

    bool flag = false;
    for(int i=1; 2*i<=x; i++) {
        int nx = x - 2*i, ny = y + i;
        flag |= (!solve(nx, ny));
    }

    for(int i=1; 2*i<=y; i++) {
        int ny = y - 2*i, nx = x + i;
        flag |= (!solve(nx, ny));
    }
    return val = flag;
}
 
signed main() {
    /*
    for(int X=0; X<=20; X++) {
        for(int Y=0; Y<=20; Y++) {
            memset(memo, -1, sizeof(memo));
            int ans = solve(X, Y);

            printf("%lld ", ans);
        }
        cout << endl;
    }
    */

    int X, Y; scanf("%lld%lld", &X, &Y);
    cout << (abs(X - Y) <= 1 ? "Brown" : "Alice") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <bitset>
#include <memory>
#include <cmath>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <cfloat>
constexpr long long int mod = 1000000007LL;

long long int power(const long long int base, const int exp) {
	switch (exp) {
	case 0: return 1LL;
	case 1: return base % mod;
	default: return power(base * base % mod, exp / 2)* power(base, exp % 2) % mod;
	}
}

int main() {
	int n; std::cin >> n;
	std::vector<int> numbers(n + 1); for (auto& a : numbers) std::cin >> a;
	long long int doubled = -n * (n + 1LL) / 2;
	for (const auto a : numbers) doubled += a;
	std::vector<int> doubling_index;
	for (auto i = 0; i < numbers.size(); ++i) if (numbers[i] == doubled) doubling_index.push_back(i);
	std::vector<long long int> factorial(n + 2, 1LL), inverse(n + 2, 1LL), inv_factorial(n + 2, 1LL);
	for (auto i = 2; i < factorial.size(); ++i) {
		factorial[i] = (i * factorial[i - 1]) % mod;
		inverse[i] = (mod - mod / i) * inverse[mod % i] % mod;
		inv_factorial[i] = inverse[i] * inv_factorial[i - 1] % mod;
	}
	auto outer = doubling_index[0] + n - doubling_index[1];
	for (auto i = 1; i <= n; ++i) {
		auto all = factorial[n + 1] * inv_factorial[i] % mod * inv_factorial[n - i + 1] % mod;
		if (outer + 1 >= i) {
			auto doub = factorial[outer] * inv_factorial[i - 1] % mod * inv_factorial[outer - i + 1] % mod;
			all -= doub;
			all = (all % mod + mod) % mod;
		}
		std::cout << all << '\n';
	}
	std::cout << 1 << '\n';
}

Measured memory_bytes: 3968
#include<iostream>

using namespace std;
int main(){
  int A,B,K;
  cin >> A >> B >> K ;
  
  int i,l=0,kouyakusuu[A];
  for( i=A; i>0;i--){
      if(A%i==0 && B%i==0)
        kouyakusuu[l++]=i;
        if(K==l)
        break;
     
  }
  
    cout << i <<endl;
  
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define mo 998244353
#define N 500010
using namespace std;
ll jie[N],nj[N],m,n,ans;
ll po(ll x,ll y){ll z=1;while (y){if(y%2)z=x*z%mo;x=x*x%mo;y/=2;}return z;}
ll C(ll x,ll y){return (jie[x]*nj[y]%mo)*nj[x-y]%mo;}
int main(){
	cin>>n>>m;if (n>m) swap(m,n);
	jie[0]=1;for (int i=1;i<=m;i++)jie[i]=jie[i-1]*i%mo;
	nj[m]=po(jie[m],mo-2);for (int i=m-1;i>=0;i--)nj[i]=nj[i+1]*(i+1)%mo;
	for (int i=0;i<=n;i++){
		ans=(ans+((((C(m,i)*C(n,i)%mo)*po(m+1,n-i)%mo)*po(n+1,m-i)%mo)*po(mo-1,i)%mo)*jie[i])%mo;
	}
	cout<<ans<<endl;
	return 0;
}

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

int main()
{
    //入力処理
    string S;
    cin >> S;
    vector<string> inputs = { //inputsという配列に4つの要素がある
        "dream",
        "dreamer",
        "erase",
        "eraser"
    };
    reverse(S.begin(), S.end());//文字列sを反転している
    for (int i = 0; i < inputs.size(); i++)//配列内すべての要素を反転している
        reverse(inputs[i].begin(), inputs[i].end());
    //入力　反転処理終了

    int pos = 0;
    while (true)//trueの間ループし続ける
    {
        bool update = false;
        for (int i = 0; i < inputs.size(); i++)//inputsのサイズ(4)回ループする
        {
            if (S.substr(pos, inputs[i].size()) == inputs[i])//もしsの0から
            {
                update = true;
                pos += inputs[i].size();
                break;
            }
        }
        if (!update)
            break;
    }

    if (pos == S.size())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
}


Measured memory_bytes: 3652
module.exports=function(e){var n={};function t(r){if(n[r])return n[r].exports;var o=n[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,t),o.l=!0,o.exports}return t.m=e,t.c=n,t.d=function(e,n,r){t.o(e,n)||Object.defineProperty(e,n,{enumerable:!0,get:r})},t.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},t.t=function(e,n){if(1&n&&(e=t(e)),8&n)return e;if(4&n&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(t.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&n&&"string"!=typeof e)for(var o in e)t.d(r,o,function(n){return e[n]}.bind(null,o));return r},t.n=function(e){var n=e&&e.__esModule?function(){return e.default}:function(){return e};return t.d(n,"a",n),n},t.o=function(e,n){return Object.prototype.hasOwnProperty.call(e,n)},t.p="",t(t.s=0)}([function(e,n,t){t(1)(t(2).readFileSync("/dev/stdin","UTF-8").split("\n"))},function(e,n){e.exports=function(e){var n=e[0];"Sunny"==n?console.log("Cloudy"):"Cloudy"==n?console.log("Rainy"):console.log("Sunny")}},function(e,n){e.exports=require("fs")}]);

Measured memory_bytes: 22964
# frozen_string_literal: true

dic = {}

gets.strip.to_i.times do
  s = gets.strip
  dic[s] ||= 0
  dic[s] += 1
end

dic       = dic.sort { |a, b| b[1] <=> a[1] }
max_count = dic[0][1]
puts dic.select { |e| e[1] == max_count }.to_h.keys.sort


Measured memory_bytes: 58088
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int n; cin >> n;
  int t, a; cin >> t >> a;
  vector<int> h(n);
  double d = 1e9;
  int p = 0;
  for(int i=0; i<n; i++){
    cin >> h[i];
    double tt = t - (h[i] * 0.006);
    double dd = abs(a*1.0-tt);
    if(d > dd){
      p = i;
      d = dd;
    }
  }
  cout << p + 1 << endl;
  return 0;
}


///


Measured memory_bytes: 256
N, M = map(int, input().split())
a = sorted(list(map(int, input().split())), reverse=True)
b = 0

for i in range(M):
    if sum(a)%(M*4)== 0:
        if a[i] >= int(sum(a)/(M*4)):
            b += 1 
    if sum(a)%(M*4)!= 0:
        if a[i] > int(sum(a)//(M*4)):
            b += 1 
if b == M:
    print('Yes')
elif b < M:
    print('No')

Measured memory_bytes: 9200
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;
  
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

for(i=0;i<=VMAX;i++){
  C[i] = 0;
}
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    C[A[i+1]] = C[A[i+1]]+1;
  }
  for(i=1;i<=VMAX;i++){
    C[i]=C[i]+C[i-1];
  }
  for(j=1;j<=n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
}
for(i=1;i<=n;i++){
  if(i>1){
    printf(" ");
  }
   printf("%d",B[i]);
 }
 printf("\n");
  return 0;
}




Measured memory_bytes: 9592
#include<stdio.h>
#include<string.h>

int main(void){
    int i,j,k=0;
    char s[202];

    gets(s);

        for(j=strlen(s)-2;j>=0;j=j-2){
            if(strlen(s)%2!=0)continue;
            if(strncmp(s,s+j/2,j/2)==0){printf("%d",j);;return 0;}
        }

}


Measured memory_bytes: 1644
from itertools import permutations
n=int(input())
x=[0]*n
y=[0]*n
for i in range(n):
  x[i],y[i]=map(int,input().split())
a=0
for p in permutations([i for i in range(n)]):
  for j in range(1,n):
    a+=((x[p[j]]-x[p[j-1]])**2+(y[p[j]]-y[p[j-1]])**2)**0.5
for i in range(1,n+1):
  a/=i
print(a)

Measured memory_bytes: 3064
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;


int main()
{ios_base::sync_with_stdio(false);
string s;
cin>>s;
int n=s.length();
if(s[n-1]=='s')s+="es";
else s+="s";
ol(s);
return 0;
}



Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
ll i, temp,t, n,j, a[200600];
int main()
{
    //I am Monim, a tiny creature of Allah
    cin >> t;
    if(t>=30)
        cout << "Yes" <<  endl;
    else
        cout << "No" <<  endl;
    return 0;
}



Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define DBG(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define EN cout<<"\n"
#define fi first
#define se second
#define PI (acos(-1))
#define fastread ios::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 200005
template<class T> ostream& operator<<(ostream &s,pair<T,ll> a)
{
    s<<a.fi<<' '<<a.se;
    return s;
}
int main()
{
    fastread;
    ll T=1;
//    cin>>T;
    for(ll qq=1;qq<=T; qq++)
    {
        vi v(7);
        for(auto &x:v)cin>>x;
        ll ans=v[1];
        if(v[0]%2&&v[3]%2&&v[4]>0||v[0]%2&&v[4]%2&&v[3]>0||v[4]%2&&v[3]%2&&v[0]>0)
        {
            ans+=3;
            v[0]--,v[3]--,v[4]--;
        }
        ans+=v[0]/2*2;
        ans+=v[3]/2*2;
        ans+=v[4]/2*2;
        cout<<ans<<endl;
    }
}



Measured memory_bytes: 256
N=int(input())
S=input()
c={}
for i in range(N):
    if S[i] in c:
        c[S[i]]+=1
    else:
        c[S[i]]=1
f=1
for i in c:
    f=f*(c[i]+1)
print((f-1)%(10**9+7))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int ms = 1e5 + 9;
vector<int> v1, v2;
int n,m,q;
int inf = 0x3f3f3f3f3f3f3f3f;

int left(int val, vector<int> &veto){

	auto it = lower_bound(veto.begin(),veto.end(),val);
	if(*it == val)
		return val;
	if(it == veto.begin())
		return inf;
	it--;
	return *it;
}
int right(int val, vector<int>& veto){
	auto it = lower_bound(veto.begin(),veto.end(),val);
	if(*it == val)
		return val;
	if(it == veto.end())
		return inf;
	return *it;

}
int closer(int val, vector<int>&veto){

	auto it = lower_bound(veto.begin(),veto.end(), val);
	int dist = inf;
	if(*it == val)
		dist = 0;
	if(it != veto.end()){
		dist = min(dist, (int)labs(*it-val));
	}
	if(it != veto.begin()){
		it--;
		dist = min(dist, (int)labs(val-*it));
	}
	return dist;

}

main(){
	cin >> n >> m >> q;
	v1.resize(n);
	v2.resize(m);
	for(int i= 0;i<n;i++) cin >> v1[i];
	for(int i= 0;i<m;i++) cin >> v2[i];
	sort(v1.begin(),v1.end());
	sort(v2.begin(),v2.end());
	int val, maxi;
	for(int i =0;i<q;i++){
		maxi =inf;
		cin >> val;
		int l1 = left(val,v1);
		int r1 = right(val,v1);
	//	cout<<l1<<" "<<val<<" "<<closer(l1,v2)<<endl;
		int s1 = labs(l1-val) + closer(l1,v2);
		int s2 = labs(r1-val) + closer(r1,v2);
	
		maxi = min(maxi, min(s1,s2));
	
		l1 = left(val,v2);
		r1 = right(val,v2);
	//	cout<<l1<<" "<<val<<" "<<closer(l1,v1)<<endl;
		s1 = labs(l1-val) + closer(l1,v1);
		s2 = labs(r1-val) + closer(r1,v1);
		maxi = min(maxi, min(s1,s2));
		
		
		cout<<maxi<<endl;	
			
	}/*val =2000;
		int l1 = left(val,v2);
		int r1 = right(val,v2);
		cout<<l1<<" "<<val<<" "<<closer(l1,v1)<<endl;*/
	
}

Measured memory_bytes: 2944
#include <stdio.h>
 
int main() {
 
    int N, AC=0, WA=0, TLE=0, RE=0;
    char str[105];
 
    scanf("%d", &N);
    while(N--) {
        scanf("%s", str);
        if(str[0] == 'A') {
            AC++;
        } else if(str[0] == 'W') {
            WA++;
        } else if(str[0] == 'T') {
            TLE++;
        } else if(str[0] == 'R') {
            RE++;
        }
    }
 
    printf("AC x %d\n", AC);
    printf("WA x %d\n", WA);
    printf("TLE x %d\n", TLE);
    printf("RE x %d\n", RE);
 
    return 0;
}

Measured memory_bytes: 1736
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <iomanip>
#include <queue>
using namespace std;
#define MAX_M 200000
#define MAX_N 200000

template<class T> inline bool chmax(T& a, T b) { if(a < b) {a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if(a > b) {a = b; return true; } return false; }
const long long INF = 1LL << 60;

// Input
int H1, M1, H2, M2, K;

int main() {
  cin >> H1 >> M1 >> H2 >> M2 >> K;
  
  int start = H1 * 60 + M1;
  int end = H2 * 60 + M2;
  int should_start = end - K;

  int ans = 0;
  if (should_start >= start) {
    ans = should_start - start;
  }

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


Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,a,b;
	int h[100010];
	set<int > v[100010];
	cin >> n >> m;
	for(int i = 1; i <= n; i++){
		cin >> h[i];
	}
	for(int i = 0; i < m; i++){
		cin >> a >> b;
		v[a].insert(b);
		v[b].insert(a);
	}
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		if(v[i].empty()){
			cnt++;
		}else{
			int flag = 1;
			for(auto x:v[i]){
				if(h[x] >= h[i]){
					flag = 0;
					break;
				}
			}
			if(flag)
				cnt++;
		}
	}
	cout << cnt << endl;
}


Measured memory_bytes: 17964
#include <bits/stdc++.h>
using namespace std;
#define int long long

const int MAX = 1000000;
const int MOD = 1000000007;

signed main() {
 int n,m,ans=0;
 cin>>n>>m;
 int x[n],y[n],z[n];
 for(int i=0;i<n;i++)cin>>x[i]>>y[i]>>z[i];
 int dp[n][m+1];
 fill(dp[0],dp[0]+m+1,0);
 for(int i=0;i<n;i++)dp[i][0]=0;
 dp[0][1]=x[0]+y[0]+z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]+x[i]+y[i]+z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]+x[i]+y[i]+z[i];
 }
 ans=dp[n-1][m];


 dp[0][1]=-x[0]+y[0]+z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]-x[i]+y[i]+z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]-x[i]+y[i]+z[i];
 }
 ans=max(ans,dp[n-1][m]);

 dp[0][1]=x[0]-y[0]+z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]+x[i]-y[i]+z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]+x[i]-y[i]+z[i];
 }
ans=max(ans,dp[n-1][m]);


 dp[0][1]=x[0]+y[0]-z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]+x[i]+y[i]-z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]+x[i]+y[i]-z[i];
 }
ans=max(ans,dp[n-1][m]);
  dp[0][1]=-x[0]-y[0]+z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]-x[i]-y[i]+z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]-x[i]-y[i]+z[i];
 }
ans=max(ans,dp[n-1][m]);


 dp[0][1]=x[0]-y[0]-z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]+x[i]-y[i]-z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]+x[i]-y[i]-z[i];
 }
ans=max(ans,dp[n-1][m]);

 dp[0][1]=-x[0]+y[0]-z[0];
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]-x[i]+y[i]-z[i],dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]-x[i]+y[i]-z[i];
 }
ans=max(ans,dp[n-1][m]);


 dp[0][1]=-1*(x[0]+y[0]+z[0]);
 for(int i=1;i<n;i++){
     for(int j=0;j<min(m,i);j++)dp[i][j+1]=max(dp[i-1][j]-(x[i]+y[i]+z[i]),dp[i-1][j+1]);
    if(i+1<=m) dp[i][i+1]=dp[i-1][i]-(x[i]+y[i]+z[i]);
 }
ans=max(ans,dp[n-1][m]);
cout<<ans;
return 0;
}


Measured memory_bytes: 7936