akhauriyash/Code-Regression huggingface dataset:
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        input_inner!{$s, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($exp_input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                let start = std::time::Instant::now();
                let input = solve($exp_input);
                let end = start.elapsed();
                assert_eq!(input, $output, "{}.{:03}", end.as_secs(), end.subsec_millis());
                assert!(end.as_secs() <= 2, "expected_sec: {}sec, actual_sec: {}sec", 2, end.as_secs());
                assert!(end.as_secs() <= 1, "expected_sec: {}sec, actual_sec: {}sec", 1, end.as_secs());
                assert!(end.subsec_millis() <= 10, "expected_ms: {}ms, actual_ms: {}ms", 10, end.subsec_millis());
                assert!(end.subsec_millis() <= 2, "expected_ms: {}ms, actual_ms: {}ms", 2, end.subsec_millis());
            )*
        }
    };
}

test! {
r#"FC"# => r#"Yes"#,
}

fn solve(src: &str) -> String {
    let mut src_iter = src.split_whitespace();
    input! {
        source = src_iter,
        s: chars,
    }
    let mut c_f = false;
    let mut f_f = false;


    for i in 0..s.len() {
        if c_f == false && s[i] == 'C' {
            c_f = true;
        }

        if c_f == true && f_f == false && s[i] == 'F' {
            f_f = true;
        }

        if c_f && f_f {
            break;
        }
    }

    if c_f && f_f {
        "Yes"
    } else {
        "No"
    }.to_string()
}

Measured memory_bytes: 4352
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int y = sc.nextInt();
		int z = sc.nextInt();
		
		if( x < y && y < z){
			System.out.println("Yes");
		}else{
			System.out.println("No");
			
		}
	sc.close();
	}

}

Measured memory_bytes: 26200
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <utility>
using namespace std;
#define INF 100000000
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define rep(i, n) for(int (i)=1; (i)<=(n); (i)++)
typedef pair<int, int> P;
typedef long long ll;
int main(){
    int N;
    cin >> N;

    vector<int> JOSHIs(N);
    JOSHIs[0] = 0;
    for(int i=1; i<N; i++){
        cin >> JOSHIs[i];
    }

    vector<int> BUKAs(N);

    //initialization
    REP(i, N) BUKAs[i] = 0;

    for(int i=0; i<N; i++){
        if(JOSHIs[i]-1 > -1) BUKAs[JOSHIs[i]-1]++;
    }

    for(int i=0; i<N; i++){
        cout << BUKAs[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 4852
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;++i)

int main(){
  ll n,k;
  cin >>n >>k;
  ll a[n],ans=200000000000000,res;

  rep(i,n) cin >> a[i];
  sort(a,a+n);
  rep(i,n-k+1){
    res=a[i+k-1]-a[i];
    ans=min(ans,res);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
fun main(args: Array<String>) {

    val (a, b, c, d) = readLine()!!.split(" ").map { it.toLong() }

    val crb = b / c
    val drb = b / d
    val cdrb = b / ((c * d) / eucred(d, c))
    val bans = b - crb - drb + cdrb

    val cra = (a - 1) / c
    val dra = (a - 1) / d
    val cdra = (a - 1) / ((c * d) / eucred(d, c))
    val aans = a - 1 - cra - dra + cdra

    println(bans - aans)
}

fun eucred(n: Long, m: Long): Long {
    if (n % m == 0L) return m
    return eucred(m, n % m)
}

Measured memory_bytes: 35984
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;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

using namespace std;

/*
   cin.tie(0);
   ios::sync_with_stdio(false);
   */

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int n,a[100005];
  int maxi=-INF+1;
  cin>>n;
  rep(i,n){
    cin>>a[i];
    maxi=max(maxi,a[i]);
  }
  double ave=(double)maxi/2;
  int sec=-INF+1,diff=INF+1;
  rep(i,n){
    if(abs(ave-a[i])<=diff){
      diff=abs(maxi/2-a[i]);
      sec=a[i];
    }
  }
  cout<<maxi<<" "<<sec<<endl;
  return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String str = sc.nextLine();
    sc.close();
    
    for(int i = 0; i < str.length(); i++){
      if(str.charAt(i) == '7'){
        System.out.print("Yes");
        return;
      }
    }
    System.out.print("No");
  }
}

Measured memory_bytes: 35712
#include<cstdio>
const int N=2E5+10;
int n;
int hd[N],nxt[N<<1],to[N<<1],cnt;
int id[N],tot,top[N];
int fa[N],siz[N],ans[N],g[N],fo[N],rd[N];
inline void init(int x,int y){
	cnt++;
	nxt[cnt]=hd[x];
	hd[x]=cnt;
	to[cnt]=y;
}
inline void predfs(int x,int pre){
	fa[x]=pre;
	for(int i=hd[x];i;i=nxt[i]){
		int u=to[i];
		if(u!=pre){
			predfs(u,x);
		}
	}
}
inline void find(int x,int pre,int num);
inline void dfs(int x,int pre,int num,int val){
	siz[top[x]=num]++;
	for(int i=hd[x];i;i=nxt[i]){
		int u=to[i];
		if(u!=pre){
			if(u>val) find(u,x,++tot);
			else dfs(u,x,num,val);
		}
	}
}
inline void find(int x,int pre,int num){
	id[x]=num;
	for(int i=hd[x];i;i=nxt[i]){
		int u=to[i];
		if(u!=pre){
			if(u>x) find(u,x,++tot);
			else dfs(u,x,u,x);
		}
	}
}
inline int wk(int x,int pre,int val){
	if(x>val) return 0;
	int res=1;
	for(int i=hd[x];i;i=nxt[i]){
		int u=to[i];
		if(u!=pre) res+=wk(u,x,val);
	}
	return res;
}
inline void sol(int x,int pre){
	if(id[x]) ans[x]=rd[x]+ans[pre];
	else if(top[x]!=x) ans[x]=ans[top[x]];
	else ans[x]=siz[x]+rd[fa[x]]-g[x]+ans[fa[fa[x]]];
	for(int i=hd[x];i;i=nxt[i]){
		int u=to[i];
		if(u!=pre){
			sol(u,x);
		}
	}
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		init(x,y);
		init(y,x);
	}
	predfs(1,1);
	find(1,1,tot=1);
	for(int i=2;i<=n;i++){
		if(id[i]){
			if(id[fa[i]]) fo[i]=fa[i];
			else fo[i]=fa[top[fa[i]]];
		}
//		printf("%d %d\n",id[i],fo[i]);
	}
	for(int i=2;i<=n;i++){
		if(top[i]==i){
			g[i]=wk(i,fa[i],fo[fa[i]]);
		}
	}
	for(int i=2;i<=n;i++){
		if(id[i]){
			rd[i]=1;
			for(int j=hd[i];j;j=nxt[j]){
				int u=to[j];
				if(u!=fa[i]&&!id[u]){
					rd[i]+=g[u];
				}
			}
		}
//		printf("%d %d\n",id[i],rd[i]);
	}
	sol(1,1);
	for(int i=2;i<=n;i++) printf("%d ",ans[i]);
	return 0;
}

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

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

  long long acc[n+1];
  acc[0] = 0;
  for (int i=0; i<n; i++) {
    acc[i+1] = acc[i] + a[i];
  }

  map<long long, long long> m;
  for (int i=0; i<n+1; i++) {
    ++m[acc[i]];
  }
  long long ans = 0;
  for (auto mi: m) {
    long long x = mi.second;
   ans += x * (x - 1) / 2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 15104
def main():
    N, M = map(int, input().split())
    A = set()
    for _ in range(M):
        a = int(input())
        A.add(a)
    mod = 10**9 + 7
    dp = [0] * (N+1)
    dp[0] = 1
    if 1 not in A:
        dp[1] = 1
    for i in range(2, N+1):
        if i not in A:
            dp[i] = dp[i-1] + dp[i-2]
            dp[i] %= mod
    return dp[-1]
print(main())


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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A + B;
  R = C + D;

  if (L > R) {
    cout << "Left" << endl;
  }
  else if (L == R) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    cout << max(c- (a-b), 0) << endl;
    

}

Measured memory_bytes: 256
n,q = map(int,input().split())
s = input()
L = [0]*q
R = [0]*q
for i in range(q):
    L[i],R[i] = map(int,input().split())

dp = [0]*n
for i in range(1,n):
    dp[i]+=dp[i-1]
    if s[i-1:i+1]=='AC':
        dp[i]+=1
for i in range(q):
    print(dp[R[i]-1]-dp[L[i]-1])

Measured memory_bytes: 15772
#!/usr/bin/env python3
import sys


def solve(A: int, B: int, C: int, X: int):
    ans = 0
    for yen500 in range(0, A + 1):
        for yen100 in range(0, B + 1):
            for yen50 in range(0, C + 1):
                if yen500 * 500 + yen100 * 100 + yen50 * 50 == X:
                    ans += 1

    print(ans)
    return


# Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    C = int(next(tokens))  # type: int
    X = int(next(tokens))  # type: int
    solve(A, B, C, X)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);





int main(){
  ll N=100000000;
  vector<ll>v(10000000,0);
vector<bool> is_prime(N + 1, true);
ll ii=0;
for (ll p = 2; p <= N; p++) {
    if (!is_prime[p]) continue;
    // p の倍数を全て消す。
    for (ll k = p * 2; k <= N; k += p) is_prime[k] = false;
    v[ii]=p;
    ii++;
}
ll n;
cin>>n;
ll ans=0;
for(ll i=0;i<n;i++){
  ll z;
  cin>>z;
  if(is_prime[z])ans++;
}
  cout<<ans<<endl;
}



Measured memory_bytes: 92952
#include <stdio.h>

int main(void) {
  int a, b, c;
  int divisors = 0;
  scanf(" %d %d %d", &a, &b, &c);
  for (a; a <= b; a++) {
    if (c % a == 0)
      divisors++;
  }
  printf("%d\n", divisors);
}



Measured memory_bytes: 1788
#include <cstdio>
#include <algorithm>
using namespace std;
struct unionfind {
    int par[100], rank[100];
    unionfind(int n) {
        for (int i=0; i<n; i++) {
            par[i]=i;
            rank[i]=0;
        }
    }
    int find(int x) {
        if (par[x]==x) {
            return x;
        } else {
            return par[x]=find(par[x]);
        }
    }
    void unite(int x, int y) {
        x=find(x);
        y=find(y);
        if (x==y) return;
        if (rank[x]<rank[y]) {
            par[x]=y;
        } else {
            par[y]=x;
            if (rank[x]==rank[y]) rank[x]++;
        }
    }
    bool same(int x, int y) {
        return find(x)==find(y);
    }
};
struct edge {
    int u, v, cost;
    edge(){}
    edge(int u, int v, int cost) : u(u), v(v), cost(cost) {}
};
bool comp(const edge& e1, const edge& e2) {
    return e1.cost<e2.cost;
}
int main() {
    int n, m;
    while (scanf("%d%d",&n,&m)) {
        if (!n&&!m) break;
        unionfind uf(n);
        edge bridge[m];
        for (int i=0; i<m; i++) {
            int a, b, cost; scanf("%d%d%d",&a,&b,&cost);
            bridge[i]=edge(a,b,cost);
        }
        sort(bridge,bridge+m,comp);
        int res=0;
        for (int i=0; i<m; i++) {
            edge e=bridge[i];
            if (!uf.same(e.u,e.v)) {
                uf.unite(e.u,e.v);
                res+=e.cost;
            }
        }
        printf("%d\n",res);
    }
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define REP(i, n) FOR(i, 0, n)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define RREP(i, n) RFOR(i, n, 0)
#define MFOR(i, m) for(auto i=(m).begin();i!=(m).end();i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())

typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

const double eps = 1e-10;
const int MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1 << 30;

template<typename T>
void printv(vector<T> const& s) {
  REP(i, SZ(s)) {
    cout << s[i] << " ";
  }
  cout << endl;
}

int main () {
  cin.tie(0);
  cout << setprecision(10);

  int n; cin >> n;
  vi a(n);
  REP(i, n) {
    cin >> a[i];
  }

  map<int, int> m;
  REP(i, n) m[a[i]]++;
  REP(i, n-1) m[10 * a[i] + a[i+1]]++;
  REP(i, n-2) m[100*a[i] + 10*a[i+1] + a[i+2]]++;
  REP(i, 1001) {
    if(m[i] == 0) {
      cout << i << endl;
      break;
    }
  }
}



Measured memory_bytes: 3132
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

//二項係数（nCk mod.p;1<=k<=n<=1e7,pは素数）
template <class T> struct Combination {
    const int MOD = 1000000007;
    vector<T> fac, finv, inv;
    Combination(const int MAX) : fac(MAX), finv(MAX), inv(MAX) {
        fac[0] = fac[1] = 1;
        finv[0] = finv[1] = 1;
        inv[1] = 1;
        for(int i = 2; i < MAX; i++) {
            fac[i] = fac[i - 1] * i % MOD;
            inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
            finv[i] = finv[i - 1] * inv[i] % MOD;
        }
    }
    T comb(int n, int k) {
        if(n < k)
            return 0;
        if(n < 0 || k < 0)
            return 0;
        return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
    }
};

long long mod(long long val, int m) {
    long long res = val % m;
    if(res < 0)
        res += m;
    return res;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    Combination<ll> C(200000);
    sort(All(A));
    ll res = 0;
    if(K == 1) {
        cout << 0 << endl;
        return 0;
    }
    for(int i = N - 1; i >= K - 1; i--) {
        res = mod(res + mod((A[i] * C.comb(i, K - 1)) % MOD, MOD), MOD);
    }
    for(int i = 0; K <= N - i; i++) {
        res = mod(res - mod((A[i] * C.comb(N - i - 1, K - 1)) % MOD, MOD), MOD);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 5760
//#include <bits/stdc++.h>
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <queue>
#include <deque>
#include <set>
#include <stack>
#include <time.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
 
const ll nmax = 1e9 + 7;
const ll Mod = 998244353;
const double PI = 2 * asin(1);

int N, Count[100005];
int main(){
  scanf("%d", &N);
  for (int i = 0; i < N; i++){
    int A; scanf("%d", &A);
    Count[A]++;
  }
  
  int cnt = 0;
  for (int i = 0; i < 100005; i++){
    if (Count[i]) cnt += Count[i] - 1;
  }
  if (cnt % 2 != 0) cnt++;
  cout << N - cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdtr1c++.h>

#define MAX 1010
#define MOD 1000000007
#define clr(ar) memset(ar, 0, sizeof(ar))
#define read() freopen("lol.txt", "r", stdin)
#define dbg(x) cout << #x << " = " << x << endl
#define ran(a, b) ((((rand() << 15) ^ rand()) % ((b) - (a) + 1)) + (a))

using namespace std;

int n, a, b, c, d, inv[MAX], fact[MAX], dp[MAX][MAX], binomial[MAX][MAX];

int expo(int a, int b){
    int res = 1;

    while (b){
        if (b & 1) res = (long long)res * a % MOD;
        a = (long long)a * a % MOD;
        b >>= 1;
    }
    return res;
}

int group(int n, int s, int c){
    int i;
    long long res = 1;

    for (i = 1; i <= c; i++){
        res = (res * binomial[n][s]) % MOD;
        n -= s;
    }
    return res * inv[c] % MOD;
}

int F(int i, int p){
    if (i > b) return (p == 0);
    if (dp[i][p] != -1) return dp[i][p];

    long long x, res = F(i + 1, p);
    for (int j = c; j <= d && (j * i) <= p; j++){
        x = (long long)F(i + 1, p - i * j) * group(p, i, j);
        res = (res + x) % MOD;
    }

    return (dp[i][p] = (res % MOD));
}

void generate(){
    int i, j;

    for (i = 0; i < MAX; i++){
        for (j = 0; j <= i; j++){
            if (i == j || j == 0) binomial[i][j] = 1;
            else binomial[i][j] = (binomial[i - 1][j] + binomial[i - 1][j - 1]) % MOD;
        }
    }
    for (fact[0] = 1, i = 1; i < MAX; i++) fact[i] = (long long)fact[i - 1] * i % MOD;
    for (i = 0; i < MAX; i++) inv[i] = expo(fact[i], MOD - 2);
}

int main(){
    generate();
    int i, j, k, l, res;

    while (scanf("%d %d %d %d %d", &n, &a, &b, &c, &d) != EOF){
        memset(dp, -1, sizeof(dp));
        printf("%d\n", F(a, n));
    }
    return 0;
}


Measured memory_bytes: 8320
use proconio::fastout;
use proconio::input;

const MOD: u64 = 1000000007;

#[fastout]
fn main() {
    input! {
        n: usize,
        an: [u64; n],
    }
    let mut ans = 0;
    let mut sum: u64 = an.iter().sum();
    for i in 0..n {
        sum -= an[i];
        ans += ((sum % MOD) * an[i]) % MOD;
        ans %= MOD;
    }
    println!("{}", ans);
}


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

int main(){
  string s;
  cin >> s;
  
  map<char,int> ma;
  
  for(int i = 0;i < s.size();i++){
   		ma[s[i]]++; 
  }
    
  if(ma.size() != 2){
   	cout << "No" << endl;
    return 0;
  }
 auto p = ma.begin();
 auto q = ma.begin(); q++;
  if(p->second == 2 && q->second == 2){
    cout << "Yes" << endl;
  }
  
  else{
   cout << "No" << endl; 
  }
    
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int K;
    cin >> K;
    int ans;
    ans = 0;
    for(int i=1; i<=K-1; i++){
        for( int j=i+1; j<=K; j++){
            if(i%2==0 && j%2==1){
                ans++;
                //cout << i << j << endl;
            }else if(i%2==1 && j%2==0){
                ans++;
                //cout << i << j << endl;
            }
        }
    }   
    cout << ans << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
string s;
long long ans;
void solve(int idx , long long x)
{
    if(idx==s.size())
    {
        ans += x;
        return ;
    }
    long long y = s[idx]-'0';
    for(int i = idx+1 ; i<=s.size() ; ++i)
    {
        solve(i , y+x);
        if(i < s.size()) y = (y*10) + s[i]-'0';
    }
}
int main()
{
    cin>>s;
    solve(0,0);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <csignal>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>

using ll = long long;
using namespace std;

int main() {
    string s = "";
    cin >> s;
    vector<int> a(4, -1);
    for (char c : s) {
        if (c == 'N') {
            a.at(0) = 1;
        }
        else if (c == 'S') {
            a.at(1) = 1;
        }
        else if (c == 'W') {
            a.at(2) = 1;
        }
        else {
            a.at(3) = 1;
        }
    }
    if (a.at(0)*a.at(1) < 0 || a.at(2)*a.at(3) < 0) {
        cout << "No" << endl;
    }
    else {
        cout << "Yes" << endl;
    }
    return 0;
}


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

const int N = 502;

int grid[N][N], dp[N][N];

int main () {
	int n, m, q; cin >> n >> m >> q;
	for (int i = 0; i < m; i++) {
		int u, v; cin >> u >> v;
		grid[u][v]++;
	}
	for (int i = n; i >= 1; i--) {
		for (int j = 1; j <= n; j++) {
			dp[i][j] = grid[i][j] + dp[i][j-1] + dp[i+1][j] - dp[i+1][j-1];
		}
	}

	// for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) cout << dp[i][j] << (j == n ? '\n' : ' ');

	for (int i = 0; i < q; i++) {
		int u, v; cin >> u >> v;
		cout << dp[u][v] << endl;
	}

	return 0;
}


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

#define fa(x,v) for(auto x:v)
#define f(i,a,b) for(ll i=(ll)a;i<=(ll)b;i++)
#define rf(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define spc " "
#define endl '\n'
#define ll long long
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define len(s) (ll)int(s.length())
#define sz(v) (ll)int(v.size())
#define MOD 1000000007

void Fast_IO() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.in","r",stdin);
    freopen("output.out","w",stdout);
    freopen("debug.out","w",stderr);
    #endif
} 

// Code Here

int main()
{
    //Fast_IO();
    ll s, w; cin >> s >> w;
    if(w >= s) cout << "unsafe";
    else cout << "safe";
    return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <array>
#include <vector>

using namespace std;

enum dir_t {NORTH, EAST, WEST, SOUTH, CLKW, CCLKW};
enum face_t {TOP, BOTTOM, FRONT, BACK, LEFT, RIGHT};

class Dice {
public:
    Dice() {
        val[TOP]    = 0;
        val[BOTTOM] = 0;
        val[FRONT]  = 0;
        val[BACK]   = 0;
        val[LEFT]   = 0;
        val[RIGHT]  = 0;
    }

    Dice(int32_t top, int32_t bottom, int32_t front, int32_t back, int32_t left, int32_t right) {
        val[TOP]    = top;
        val[BOTTOM] = bottom;
        val[FRONT]  = front;
        val[BACK]   = back;
        val[LEFT]   = left;
        val[RIGHT]  = right;
    }

    int32_t operator[](face_t f) {
        return val[f];
    }

    bool operator== (const Dice &d2) {
        return (*this).val == d2.val;
    }

    void roll(dir_t dir) {
        switch (dir) {
            case NORTH: inner_roll(TOP, FRONT, BOTTOM, BACK); break;
            case EAST:  inner_roll(TOP, LEFT, BOTTOM, RIGHT); break;
            case WEST:  inner_roll(TOP, RIGHT, BOTTOM, LEFT); break;
            case SOUTH: inner_roll(TOP, BACK, BOTTOM, FRONT); break;
            case CLKW:  inner_roll(FRONT, RIGHT, BACK, LEFT); break;
            case CCLKW: inner_roll(FRONT, LEFT, BACK, RIGHT); break;
        }
    }

    bool identical_with(Dice d) {
        for (int32_t i = 0; i < 6; i++) {
            for (int32_t j = 0; j < 4; j++) {
                if (d == *this) {
                    return true;
                }
                d.roll(CLKW);
            }

            if (i % 2 == 0) {
                d.roll(NORTH);
            } else {
                d.roll(WEST);
            }
        }

        return false;
    }

private:
    array<int32_t, 6> val;

    void inner_roll(face_t f1, face_t f2, face_t f3, face_t f4) {
        int32_t temp;
        temp = val[f1];
        val[f1] = val[f2];
        val[f2] = val[f3];
        val[f3] = val[f4];
        val[f4] = temp;

        return;
    }
};

int main() {
    int32_t n, top, bottom, front, back, left, right;

    cin >> n;

    vector<Dice> dices(n);

    for (int32_t i = 0; i < n; i++) {
        cin >> top >> front >> right >> left >> back >> bottom;
        Dice d(top, bottom, front, back, left, right);

        for (int32_t j = 0; j < i; j++) {
            if (d.identical_with(dices[j])) {
                cout << "No" << endl;
                return 0;
            }
        }

        dices[i] = d;
    }

    cout << "Yes" << endl;

    return 0;
}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
#define debug(x) cerr << #x << ": " << x << endl
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  2018/02/27  Problem: 064_arc_b / Link: https://abc048.contest.atcoder.jp/tasks/arc064_b?lang=en  ----- */
/* ------問題------

長さ 3 以上の文字列 s があります。 s の中に同一の文字が隣り合う箇所はありません。
高橋君と青木君がゲームで勝負します。 二人は交互に次の操作を行います。 高橋君が先手です。
s から両端以外の文字をひとつ取り除く。 ただし、その文字を取り除くことで、s の中に同一の文字が隣り合う箇所ができる場合、その文字を取り除くことはできない。
先に操作を行えなくなった人が負けです。 二人が最適に行動したとき、どちらが勝つかを判定してください。

-----問題ここまで----- */
/* -----解説等-----

終了条件は端が一緒で文字列が奇数のとき
端が異なって文字列が偶数のとき
手によらず決定ではないけど最適なら勝てる

----解説ここまで---- */

LL N;

LL ans = 0LL;

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

	string s;
	cin >> s;
	cout << ((s.front() == s.back())^(SZ(s)%2)?"First":"Second") << "\n";

	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;

int main(){
    int n, m, d;
    cin >> n >> m >> d;

    int pairs = n-d;
    
    double ans = (double)(pairs) * 2 * (m-1) / n / n;
    if(d == 0)  ans /= 2.0;
    cout << fixed << setprecision(10) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
n, m = gets.split.map(&:to_i)
g = Array.new(n) { [] }
m.times do
  u, v = gets.split.map(&:to_i)
  g[u - 1] << v - 1
end

s, t = gets.split.map { |x| x.to_i - 1 }

path = Array.new(n) { Array.new(3, -3) }
path[s][0] = 0
q = [[s, 1]]
until q.empty?
  v, r = q.shift
  g[v].each do |child|
    if path[child][r] == -3
      path[child][r] = path[v][(r - 1) % 3] + 1
      q << [child, (r + 1) % 3]
    end
  end
end

# pp path
p path[t][0] / 3


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

using namespace std;

const int MOD = 1e9 + 7;

int n,i,j,t[100005],a[100005],num[100005];

bool check(){
	int mx = -1;
	for(i = 0; i < n; i++){
		mx = max(mx, num[i]);
		if(mx != t[i])
		return 1;
	}
	mx = -1;
	for(i = n - 1; i >= 0; i--){
		mx = max(mx, num[i]);
		if(mx != a[i])
		return 1;
	}
	return 0;
}

int main(){
	scanf("%d", &n);
	for(i = 0; i < n; i++)
	scanf("%d", &t[i]);
	for(i = 0; i < n; i++)
	scanf("%d", &a[i]);
	
	int last = -1;
	for(i = 0; i < n; i++){
		if(t[i] != last)
		num[i] = t[i];
		last = t[i];
	}
	last = -1;
	for(i = n - 1; i >= 0; i--){
		if(a[i] != last)
		num[i] = a[i];
		last = a[i];
	}
	
	if(check())
	return 0 * printf("0\n");
	
	long long res = 1;
	
	for(i = 0; i < n; i++){
		if(num[i] != 0) continue;
		res = (res * min(t[i], a[i])) % MOD;
	}
	
	printf("%lld\n", res);
}



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

# define REP(i,n) for (int i=0;i<(n);++i)
# define rep(i,a,b) for(int i=a;i<(b);++i)
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
# define printIf(j,s1,s2) cout << (j ? s1 : s2) << endl;
# define YES(j) cout << (j ? "YES" : "NO") << endl;
# define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
# define yes(j) std::cout << (j ? "yes" : "no") << endl;
# define all(v) v.begin(),v.end()
# define showVector(v) REP(i,v.size()){p(v[i]);p(" ")} pl("")
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;}
typedef long long int ll;
typedef pair<ll,ll> P_ii;
typedef pair<double,double> P_dd;

const int MOD = 1000000007;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;

void addM(long long &a, long long b) {
    a += b;
    if (a >= MOD) a -= MOD;
}

void mulM(long long &a, long long b) {
    a = ((a%MOD)*(b%MOD))%MOD ;
}

int main(){
    int H, W, K;
    cin >> H >> W >> K;

    int C[30][30];
    REP(i, H) REP(j, W) scanf("%1d", &C[i][j]);

    ll ans = 0;
    REP(x, H) REP(y, W){

        int c[30][30];
        REP(i, H) REP(j, W) c[i][j] = C[i][j];
        c[x][y] = 0;

        ll pw = 0, result = 0;
        while(true){
            ll num = 0;
            REP(i, H){
                REP(j, W) {
                    int st = j;
                    while(st < W && c[i][j] == c[i][st]) st++;
                    if(st - j >= K){
                        for(int l = j; l < st; l++){
                            num += c[i][l];
                            c[i][l] = 0;
                        }
                    }
                    j = st - 1;
                }
            }
            if(pw > 0 && num == 0) break;
            result += pw * num;
            pw = pw > 0 ? pw * 2 : 1;

            REP(j, W){
                int pos = H - 1;
                for(int i = H - 1; i >= 0; i--){
                    if(c[i][j] > 0){
                        c[pos][j] = c[i][j];
                        if(pos != i) c[i][j] = 0;
                        pos--;
                    }
                }
            }
        }
        ans = max(ans, result);
    }
    cout << ans << endl;
    return 0;
}

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

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

  for(size_t i = 0; i < s.length(); i++){
    if(s[i] != 'a'){
      int c = 26 - (s[i] - 'a');
      if(c <= k){
        k -= c;
        s[i] = 'a';
      }
    }
  }
  s[s.length() - 1] = 'a' + ((s[s.length() - 1] - 'a') + k) % 26;

  cout << s << endl;
  
  return 0;
}



Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

ll gcd(ll x,ll y) {return y ? gcd(y,x%y) : x;}
ll lcm(ll x, ll y) {return x/gcd(x,y)*y;}



int main(){
    int n,x;
    cin>>n>>x;
    vector<int> v(n);
    rep(i,n){
        int a;
        cin>>a;
        v[i]=abs(a-x);
    }

    if(n==1){
        cout<<v[0]<<endl;
        return 0;
    }

    int ans=gcd(v[0],v[1]);
    for(int i=2;i<n;i++) ans=gcd(ans,v[i]);

    cout<<ans<<endl;
}



Measured memory_bytes: 3736
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>
#include <iterator>
#include <deque>
#include <string>
#include <queue>
#include <omp.h>
#include <fstream>   // ifstream, ofstream
typedef int64_t ll;
using namespace std;
const ll INF=1e10;
const double EPS=1e-8;

int main(){
	ll n;
	cin>>n;
	vector<ll> p;
	for(ll i1=0;i1<n;i1++){
		ll temp;
		cin>>temp;
		p.push_back(temp);
	}
	ll ans=0;
	for(ll i1=0;i1<n-2;i1++){
		if(p[i1]>p[i1+1]&&p[i1+1]>p[i1+2]){
			ans++;
		}
		if(p[i1]<p[i1+1]&&p[i1+1]<p[i1+2]){
			ans++;
		}

	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#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>;

int main() {
  string s, t, u;
  int a, b;
  cin >> s >> t >> a >> b >> u;
  if(s==u) a--;
  else b--;
  cout << a << " " << b << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  long n; cin>>n; long x;
  for(long k=1;k*k<=n;k++){
    
  if(n%k==0) { x=k; }
  }
  cout<< x+(n/x)-2 <<endl;
}

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

double dp[3000][3000];
// dp[index][heads] = probability
double p[3000];

int main(){
	int n;
	cin>>n;
	for(int i = 0; i<n; i++){
		cin>>p[i];
	}
	
	dp[0][0] = (1-p[0]);
	dp[0][1] = p[0];
	
	for(int i = 1; i < n ;i++){
		for(int j = 0; j < 3000; j++){
			//tails
			dp[i][j] += (1-p[i]) * dp[i-1][j];
			//heads
			if(j > 0)
				dp[i][j] += p[i] * dp[i-1][j-1];
		}
	}
	
	double ans = 0;
	
	for(int i = n/2 + 1; i < 3000; i++){
		ans += dp[n-1][i];
	}
	
	cout<<setprecision(9);
	cout<<fixed;
	
	cout<<ans;
	
}


Measured memory_bytes: 74044
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int (i)=(m);(i)<(n);++(i))
#define rrep(i,m,n) for(int (i)=(n)-1;(i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr ll INF = (ll)1e9;
constexpr ll mod = (ll)1e9 + 7;
constexpr double PI = 3.1415926535897932;
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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int s; cin >> s;
	ll dp[2050];
	memset(dp, 0, sizeof dp);
	dp[0] = 1;
	rep(i, 0, s + 1) {
		rep(j, 3, s + 1) {
			if (i + j <= s && dp[i] > 0) {
				dp[i + j] += dp[i];
				dp[i + j] %= mod;
			}
		}
	}
	cout << dp[s] << "\n";

	return 0;
}

Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
#define pi acos(-1);
ll strtoint(string str);
int main(){
	fast;
	ll n,odd=0,even=0; cin>>n;
	for(auto i=1;i<=n;++i){
		if(i%2)++odd;
		else
			++even;
	}
	if(even==odd)cout<<fixed<<setprecision(9)<<(double)odd/(odd+even)<<'\n';
	else{
		cout<<fixed<<setprecision(9)<<(double)odd/(odd+even)<<'\n';
	}
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main() 
{ 
	// freopen("input.txt","r",stdin);
 //   freopen("output.txt","w",stdout);
  int n,k;
  cin>>n>>k;
  int arr[n];
  for(int i=0;i<n;i++){
    cin>>arr[i];
  }
  sort(arr,arr+n);
  int count=0;
  for(int i=0;i<k;i++){
    count += arr[i];
  }
  cout<<count<<"\n";
	return 0; 
} 
 

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

int main() {
    int N; cin >> N;
    int m = N+1;
    int ans = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (a < m) {
            ans++;
            m = a;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long n = sc.nextLong();
        long x = sc.nextLong();
        long eatp = 0;
        long eati = n;
        boolean th = false;
        for (long i = n; i > 0; i--) {
            if ((eati - i) + Math.pow(2, i + 2) - 3 <= x) {
                eatp += Math.pow(2, i + 1) - 1;
                x -= (eati - i) + Math.pow(2, i + 2) - 3;
                eati = i;
                th = true;
                if (x == 0 || eati == n) {
                    break;
                } else {
                    x--;
                    eatp++;
                }
            }
        }
        if (eati == n && th) {
        }else {
            x -= eati - 1;
            if (x == 2) {
                eatp++;
            } else if (x == 3) {
                eatp += 2;
            } else if (x >= 4) {
                eatp += 3;
            }
        }
        System.out.println(eatp);
    }
}

Measured memory_bytes: 23124
import Control.Applicative
main = do
  _ <- (read::String->Integer) <$> getLine
  s<-getContents
  let v = cut2 . map (read::String->Integer) . lines $ s
  mapM_ (putStrLn . aux) v
  where
    cut2::[Integer] -> [[Integer]]
    cut2 [] = []
    cut2 xs = (take 2 xs):(cut2(drop 2 xs))

aux::[Integer]->String
aux [l,m] =  if (length . show $ s) > 80 then
               "overflow"
             else
               show s
  where s = l + m

Measured memory_bytes: 4316
#include<stdio.h>
int main(void){
  int n,k;
  double ans=0,p[200000],q[200000];
  scanf("%d %d",&n,&k);
  for(int i=0;i<n;i++){
    scanf("%lf",&p[i]);
    p[i]=(p[i]+1)/2;
   
  }
  for(int i=0;i<k;i++){
    q[0]+=p[i];
    ans=q[0];
  }
  for(int i=1;i<n-k+1;i++){
    q[i]=q[i-1]-p[i-1]+p[i+k-1];
    if(ans<q[i]){
      ans=q[i];
    }
  }
  printf("%lf",ans);
  return 0;
}

Measured memory_bytes: 4836
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[220];
int main()
{
	int n,k;
	string s,s2;
	double lo;
	cin>>s;
	cin>>lo;
	n=s.size();
	k=n;
	for (int i=1;i<=n;i++)
	{
		a[i]=s[i-1]-'0';
	}
	long long jsq=1;
	while (a[jsq]==1)
	{
		if (lo==1)
		{
			cout<<a[jsq];
			return 0;
		}
		lo=lo-1;
		jsq++;
	}
	cout<<a[jsq];
	return 0;
}

Measured memory_bytes: 256
a,b,k=map(int,input().split())
ans=[]
for i in range(a,k+a):
  if a<=i<=b:
    ans.append(i)
    
for i in range(b-k+1,b+1):
  if a<=i<=b:
    ans.append(i)
ans=list(set(ans))
ans.sort()
for i in ans:
  print(i)



Measured memory_bytes: 9076
#include <cstdio>
#include <cmath>

using namespace std;

int main()
{
        double x, h;
        double s;

        while (1){
                scanf("%lf", &x);
                scanf("%lf", &h);

                if (x == 0.0 && h == 0.0){
                        break;
                }

                s = (x * x) + (x * sqrt((x / 2.0) * (x / 2.0) + h * h)) * 2.0;

                printf("%lf\n", s);
        }

        return (0);
}

Measured memory_bytes: 1072
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
//public:
  Comb(){
    fac = new ll[1000000];
    finv = new ll[1000000];
    inv = new ll[1000000];
    fac[0] = 1;
    for(int i=1;i<1000000;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000000;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000000;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n,k;
  cin >> n >> k;
  ll ans = 0;
  for(ll i=k;i<n+2;i++){
    ans += i*(2*n-i+1)/2 - i*(i-1)/2 + 1;
    ans %= MOD;
  }
  ans += 2*MOD;
  ans %= MOD;
  cout << ans << endl;
  return 0;
}


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

using namespace std;
using ll = long long;

#define REP(i,m,n) for(ll (i)=(m),i##_len=(n);(i)<(i##_len);++(i))
#define FORR(i,v) for(auto (i):v)
#define ALL(x) (x).begin(), (x).end()
#define _PR(x) cout << (x) << endl
#define _PS(x) cout << (x) << " "
#define SZ(x) ((int)(x).size())
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define pb push_back

int main()
{
    string s, t;
    cin >> s >> t;
    ll S = s.length(), T = t.length();

    vector<vector<ll>> dp(S+1, vector<ll>(T+1));

    REP(i,0,S) {
        REP(j,0,T) {
            if (s[i] == t[j]) dp[i+1][j+1] = MAX(dp[i+1][j+1],dp[i][j]+1);
            dp[i+1][j+1] = MAX(dp[i+1][j+1],dp[i+1][j]);
            dp[i+1][j+1] = MAX(dp[i+1][j+1],dp[i][j+1]);
        }
    }

    ll i = S, j = T;
    string res = "";
    while(i > 0 && j > 0) {
        if (dp[i][j] == dp[i-1][j]) --i;
        else if (dp[i][j] == dp[i][j-1]) --j;
        else {
            res = s[i-1] + res;
            --i;
            --j;
        }
    }

    _PR(res);

    return 0;
}

/*



*/

Measured memory_bytes: 70784
#include<cstdio>
#include<algorithm>
using namespace std;
int a[21],n,ans;
int main(){
	scanf("%d",&n);
	ans=n;
	for(register int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(register int i=1;i<=n;i++){
		for(register int j=1;j<i;j++){
			if(a[j]>a[i]){
				ans--;
				break;
			}
		}
	}
	printf("%d",ans);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> pii;
#define F first
#define S second
const int C = 1e6 + 87, N = 4e5;
int tp, tt, vis[N];
vector<pii> e[C];
vector<int> g[N],tg[N];
void dfs(int u)
{
    g[u].push_back(tp);
    g[tp].push_back(u);
    vis[u] = tt;
    for (int v : tg[u])
        if (vis[v] != tt) {
            dfs(v);
        }
}
int main()
{
    ios::sync_with_stdio(0);
    int n,m;
    cin >> n >> m;
    tp = n;
    for (int i = 0; i < m; ++i) {
        int a,b,c;
        cin >> a >> b >> c;
        e[c].emplace_back(a,b);
    }
    for (int c = 0; c < C; ++c) {
        for (auto x : e[c])  {
            tg[x.F].clear();
            tg[x.S].clear();
        }
        for (auto x : e[c])  {
            tg[x.F].push_back(x.S);
            tg[x.S].push_back(x.F);
        }
        ++tt;
        for (auto x : e[c])  {
            if (vis[x.F] != tt) {
                ++tp;
                dfs(x.F);
            }
        }
    }
    ++tt;
    vector<int> q[2];
    q[0] = {1};
    vis[1] = tt;
    int d = 0;
    for (int i = 0; q[i].size() && vis[n] != tt; ++d, i^=1) {
        q[i^1].clear();
        for (int u : q[i])
            for (int v : g[u])
                if (vis[v] != tt) {
                    vis[v] = tt;
                    q[i^1].push_back(v);
                }
    } 
    if (vis[n] != tt) {
        cout << "-1\n";
        return 0;
    }
    cout << d/2 << endl;
}


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

#define endl ("\n")
#define all(x) (x).begin(),(x).end()

template<typename Type>
Type gcd(const Type a,const Type b){return(b==0)?a:gcd(b,a%b);}
template<typename Type>
Type lcm(const Type a,const Type b){return(a/gcd(a,b))*b;}

template<typename Type>
void sort(vector<Type>& v){
	sort(all(v));
}

int main(){
	int N,M;
	cin >> N >> M;
	cout << (N*(N-1)/2 + M*(M-1)/2) << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long n,a[100005],b[100005],c[100005],f=0;
long long fa[100005];
long long s=1;

int main(){
  cin>>n;
  for(int i=0;i<n;i++)cin>>a[i];
  for(int i=0;i<n;i++)cin>>b[i];
  for(int i=0;i<n;i++)
    c[i]=min(a[i],b[i]);
  long long maxc=0;
  for(int i=0;i<n-1;i++){
    maxc=max(maxc,c[i]);
    if(a[i]!=maxc)f=1;
  }
  maxc=0;
  for(int i=n-1;i>=0;i--){
    maxc=max(maxc,c[i]);
    if(b[i]!=maxc)f=1;
  }
  if(n==1&&a[0]!=b[0])f=1;
  if(f){
    cout<<0<<endl;
  }else{
    for(int i=1;i<n-1;i++)
      if(a[i]==a[i-1])fa[i]=1;
    for(int i=n-2;i>0;i--)
      if(b[i]==b[i+1]&&fa[i]){
	s=(s*min(a[i],b[i]))%1000000007;
      }
    cout<<s<<endl;
  }
  return 0;
}


Measured memory_bytes: 3328
def main ():
  N = int(input())
  A = list(map(int,input(). split ()))
  if 0 in A:
    print(0)
    return
  
  prod = 1
  for a in A:
    prod *= a
    if prod > 1000000000000000000:
      print(-1)
      return
  print(prod)
  
main ()

Measured memory_bytes: 21624
S = input()
let_1 = ""
let_2 = ""
count_1 = 0
count_2 = 0
for s in S:
    if s == let_1:
        count_1 += 1
    elif s == let_2:
        count_2 += 1
    elif let_1 == "":
        let_1 = s
        count_1 += 1
    elif let_2 == "":
        let_2 = s
        count_2 += 1
    else:
        print("No")
        exit()

if count_1 == 2 and count_2 == 2:
    print("Yes")
else:
    print("No")



Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=1;i<=n;i++)
#define drep(i,n) for(int i=n;i>=0;i--)
#define MAX 100000
#define ll long long
#define dmp make_pair
#define dpb push_back
#define P pair<int,int>
#define fi first
#define se second
using namespace std;
//__gcd(a,b), __builtin_popcount(a);
const int INF = 2147483647;
#define B 100
 
int bucket[MAX/B][B];
int data[MAX/B];
void update(int a, int b, int x){
    int f1 = 1, f2 = 1;
    while(a <= b && a%B != 0){
        if(f1 && data[a/B] != -1){
            for(int i = 0;i < B;i++)bucket[a/B][i] = data[a/B];
            f1 = 0;data[a/B] = -1;
        }
        bucket[a/B][a%B] = x;
        a++;
    }
    while(a <= b && b%B != B-1){
        if(f2 && data[b/B] != -1){
            for(int i = 0;i < B;i++)bucket[b/B][i] = data[b/B];
            f2 = 0;data[b/B] = -1;
        }
        bucket[b/B][b%B] = x;
        b--;
    }
    while(a < b){
        data[a/B] = x;
        a += B;
    }
}
 
int find(int x){
    if(data[x/B] != -1){
        for(int i = 0;i < B;i++)bucket[x/B][i] = data[x/B];
        data[x/B] = -1;
    }
    return bucket[x/B][x%B];
}
 
int main(){
    int n, q, c, s, t, x, ans;
    scanf("%d%d", &n, &q);
    fill(data, data+MAX/B, -1);
    fill((int*)bucket, (int*)(bucket+MAX/B), INF);
    while(q--){
        scanf("%d", &c);
        if(!c){
            scanf("%d%d%d", &s, &t, &x);
            update(s, t, x);
        }else{
            scanf("%d", &x);
            ans = find(x);
            printf("%d\n", ans);
        }
    }
    //rep(i,n)printf("%d ", bucket[0][i]);
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define For(i,a,b) for(int i=a;i<b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define pi acos(-1)
#define eps 0.00000001
#define pb push_back
#define off 250555

long long n,lis[100005],l,ans;

int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios::sync_with_stdio(0);
    cin>>n>>l;
    For(i,0,n) cin>>lis[i];
    ans=-1;
    For(i,0,n-1) if(lis[i]+lis[i+1]>=l)
    {
        ans=i;
        break;
    }
    if(ans==-1) cout<<"Impossible";
    else
    {
        cout<<"Possible"<<endl;
        For(i,0,ans) cout<<i+1<<endl;
        for(int i=n-1;i>ans;i--) cout<<i<<endl;
    }
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll MOD = 1000000007;

int main(){
    ll n, m, d;
    cin >> n >> m >> d;

    if(d == 0){
        printf("%.12f\n", double(m - 1) / n);
    }else{
        printf("%.12f\n", double(m - 1) * (2 * (n - d)) / (n * n));
    }

    return 0;
}

Measured memory_bytes: 256