akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

template<class T> ostream& operator<<(ostream &os, vector<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T> ostream& operator<<(ostream &os, set<T> V){
	os << "[ ";
	for(auto v  : V) os << v << " ";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, map<T , R> V){
	os << "[ ";
	for(auto v  : V) os << "(" << v.first << ":" << v.second << ")";
	return os << " ]";
}
template<class T , class R > ostream& operator<<(ostream &os, pair<T , R> V){
	return os << "(" << V.first << "," << V.second << ")";
}

#define cerr cout
#define TRACE
#ifdef TRACE
    #define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cerr << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ',');
        cerr.write(names, comma - names) << " : " << arg1<<" | ";
        __f(comma+1, args...);
    }
    clock_t clk=clock();
    #define checktime() cout<<"\nTime Elapsed : "<<float(clock()-clk)/CLOCKS_PER_SEC<<endl
#else
    #define trace(...);
    #define checktime();
#endif
/*---------------------------Defines----------------------*/
typedef long long int ll;
typedef long double ld;
#define pll pair<ll,ll>
#define pb push_back
#define F first
#define S second
#define I insert
#define vll vector<ll>
#define vbl vector<bool>
#define vvll vector<vll>
#define vld vector<ld>
#define vb vector<bool>
#define vc vector<char>
#define vpll vector<pll>
#define all(x) (x).begin(), (x).end()
/*-----------------------Modular Arithmetic---------------*/
inline int add(int x,int y,int mod){
    x+=y;
    if (x>=mod) return x-mod;
    return x;
}
inline int sub(int x,int y,int mod){
    x-=y;
    if (x<0) return x+mod;
    return x;
}
inline int mul(int x,int y,int mod){
    return (x*1ll*y)%mod;
}
inline int power(int x,int y,int mod){
    int ans=1;
    while(y){
        if (y&1) ans=mul(ans,x,mod);
        x=mul(x,x,mod);
        y>>=1;
    }
    return ans;
}
inline int inv(int x,int mod){
    return power(x,mod-2,mod);
}
/*-----------------------------Code begins----------------------------------*/



void solve(){
    ll n,w;cin>>n>>w;
    ll a[n][2];
    for(ll i=0;i<n;i++) cin>>a[i][0]>>a[i][1];
    ll sum=0;
    for(ll i=0;i<n;i++) sum+=a[i][1];
    vll dp(sum+1,1e18);
    dp[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=sum;j>=a[i][1];j--) dp[j]=min(dp[j], dp[j-a[i][1]]+a[i][0]);
    }
    for(ll i=sum;i>=0;i--){
        if(dp[i]<=w){
            cout<<i<<"\n";
            return;
        }
    }
}

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<fixed<<setprecision(25);

    ll t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, a, b, d;
  in(n);
  vector<ll> c(n);
  rep(i, n)
    in(c[i]);
  rep(i, n){
    if(c[i] % 4 == 0)
      c[i] = 2;
    else if(c[i] % 2 == 0)
      c[i] = 1;
    else
      c[i] = 0;
  }
  a = b = 0;
  rep(i, n){
    if(c[i] == 0)
      a++;
    if(c[i] == 2)
      b++;
  }
  if(a > b){
    if(a == b + 1 && n - a - b == 0)
      out("Yes");
    else
      out("No");
  }
  else
    out("Yes");
  memi;
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
a,b,c,d = list(input())

for op1 in ["+","-"]:
    for op2 in ["+","-"]:
        for op3 in ["+","-"]:
            s = a+op1+b+op2+c+op3+d
            r = eval(s)
            if r==7:
                print(s+"=7")
                exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define int int64_t
#define pb push_back
#define pii pair<int, int>
#define F first
#define S second
#define vecsort(x) sort(x.begin(), x.end())
#define vecrsort(x) sort(x.rbegin(), x.rend())
#define massort(x, n) sort(x, x + n)
#define FOR(i, n) for(int i = 0; i < n; i ++)
using namespace std;
int max(int32_t a, int b){
   return max((int)a, b);
}

const int N = 1e5 + 200;

vector<int> g[N];
int degree[N];
int dist[N];
bool visited[N];

void dfs(int v){
   visited[v] = true;
   for(int x: g[v]){
      dist[x] = max(dist[x], dist[v] + 1);
       degree[x] --;
      if(degree[x] == 0)
         dfs(x);
   }
}

int32_t main(){
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   int n, m;
   cin >> n >> m;
   for(int i = 0; i < m; i ++){
      int u, v;
      cin >> u >> v;
      u --; v --;
      g[u].pb(v);
      degree[v] ++;
   }
   int ans = 0;
   for(int i = 0; i < n; i ++){
      if(!visited[i] && degree[i] == 0){
         dfs(i);
      }
   }
   for(int i = 0; i < n; i ++)
      ans = max(ans, dist[i]);
   cout << ans;

}


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

int main(){
    int A,B;
    cin >> A >> B;
    int i;
    int a=0;
    for(i=1;i<4;i++){
        if((A*B*i)%2==1){
            a++;
        }
    }

    if(a==0){
        cout << "No" << endl;
    }
    else{
        cout << "Yes" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A = [-1]*N
for _ in range(M):
  s,c=map(int,input().split())
  s = s-1
  if A[s] != -1 and A[s] != c:
    print(-1)
    exit()
  A[s] = c

if N == 1:
  if A[0]==-1:
    print(0)
  else:
    print(A[0])
  exit()

if A[0] == 0:
  print(-1)
  exit()
if A[0] == -1: A[0] = 1
for i,a in enumerate(A):
  if a == -1:
    print(0,end='')
  else:
    print(a,end='')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <iomanip>
#include<algorithm>
#define ll long long
using namespace std;

int main() {
  ll N, K, temp = 1, init = 0, end = 0;
  bool tr = 0;
  cin >> N >> K;
  vector<ll> A(N), B(1, 1), C(N, 0);
  C.at(0) = 1;
  for(ll i = 0; i < N; i++) cin >> A.at(i);
  while(1) {
    end++;
    if(end == K) {
      cout << A.at(temp - 1) << endl;
      break;
    }
    temp = A.at(temp - 1);
    if(C.at(temp - 1) == 0) {
      C.at(temp - 1)++;
      B.push_back(temp);
    }
    else {
      while(1) {
        if(B.at(init) == temp) {
          cout << B.at((K - init) % (end - init) + init) << endl;
          tr = 1;
          break;
        }
        init++;
      }
    }
    if(tr) break;
  }
}


Measured memory_bytes: 8492
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int a=stdIn.nextInt(),b=stdIn.nextInt(),c=stdIn.nextInt(),d=stdIn.nextInt();
		if(a>b) {
			if(c>d) System.out.print(b+d);
			else System.out.print(b+c);
		}
		else {
			if(c>d) System.out.print(a+d);
			else System.out.print(a+c);
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define VI vector<int> 
#define SI set<int>
#define QI queue<int> 
#define PII pair<int, int>
#define MP make_pair
#define PB push_back
#define REP(i,a,b) for(int i = a; i < b; ++i)
#define F for(int i = 0; i < n; ++i)
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define M 1000000007
using namespace std;

int main()
 {  
    FIO
    ll a;
    float b;

    cin>>a>>b;
    ll ib = b*100 + 0.5;
    a *= ib;
    cout<<a/100;
    
    return 0;
}

Measured memory_bytes: 3688
object Main {

  def main(args: Array[String]): Unit = {
    import scala.collection.mutable.ArrayBuffer
    val sc = new java.util.Scanner(System.in)

    // 方向性
    // Bellman-Fordアルゴリズムによって, 全ての頂点vについて, 到達可能な異なる頂点への単一始点最短路を解く.
    // Bellman-FordアルゴリズムはO(VE)なので, 全ての頂点について調べると全点対最短路を解くことになりO(V^2E)である.
    // この時点で全点最短路が求まっているので, 任意のu of Vについて,
    // v of {V - u (d(u,v) != ∞) } からu に到達するために先行点を手繰って通る辺は最短路であるから, この時の最短路を数えていく.
    // 同様の辺を通ることがあるから, ユニークな数を数える.

    val N, M = sc.nextInt()

    val MINF = Int.MinValue / 10
    val INF = Int.MaxValue / 10

    // 全て親が存在しないものとする.
    // parent(u)(v) (u != v) は u について v への推定最短路を達成する v の先行点.
    // u についての v の推定最短路を達成する全ての辺はv の先行点を辿ることで列挙できる.
    val parent = Array.fill(N+1, N+1)(MINF)
    // 全ての距離を∞に初期化する. distance(u)(v) (u != v) はuからvへの推定最短路.
    // アルゴリズムが収束した時, distance(u)(v) = δ(u, v) となり, 最短路の値となる.
    // この時, u についての最短路ではparent(v) を起点としてuまで
    val distance = Array.fill(N+1, N+1)(INF)
    (1 to N) foreach { i => // 全ての自分自身への距離を0とする.
      distance(i)(i) = 0
    }
    // weight(u, v) は u から vへの重さ
    val weight = Array.fill(N+1, N+1)(INF)

    val E = new ArrayBuffer[(Int, Int)]()
    (0 until M) foreach { _ =>
      val a, b, c = sc.nextInt()
      weight(a)(b) = c
      weight(b)(a) = c
      E.append((a, b), (b, a))
    }

    // 全ての頂点について, ベルマンフォードの緩和のステップを行う.
    // ここで, 負閉路がないことが前提なので, 負閉路の判定のステップは必要がない.
    (1 to N) foreach { i =>
      (1 until N) foreach { _ =>
        E foreach { case (u, v) =>
          if (distance(i)(v) > distance(i)(u) + weight(u)(v)) {
            distance(i)(v) = distance(i)(u) + weight(u)(v)
            parent(i)(v) = u
          }
        }
      }
    }

    // 全ての頂点について, 異なる頂点への最短路を逆方向に辿って最短路をカウントしていく.
    val b = Set.newBuilder[(Int, Int)]
    (1 to N) foreach { u =>
      (1 to N) foreach { v =>
        var _v = v
        while (parent(u)(_v) != MINF) {
          b += (if (parent(u)(_v) < _v) (parent(u)(_v), _v) else (_v, parent(u)(_v)))
          _v = parent(u)(_v)
        }
      }
    }

    // ユニークな最短路に使った辺の数を全体の辺の数から引くと, 使わなかった辺の数になる.
    println(M - b.result().size)
  }
}

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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	int a, b, c;
	cin >> a >> b >> c;

	if(c >= a && c <= b){
		puts("Yes");
	}else{
		puts("No");
	}
	
	return 0;
}


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;

int main() {
  int n, d;
  cin >> n >> d;
  vector<vector<int>> data(n, vector<int>(2));
  rep(i,n) rep(j,2) cin >> data.at(i).at(j);
  int cnt = 0;
  rep(i,n) {
    ll x = data.at(i).at(0);
    ll y = data.at(i).at(1);
    ll tmp = x*x + y*y;
    double ans = pow(tmp, 0.5);
    
    //cout << ans << endl;
    
    
    if (ans <= d) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 14420
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = int_fast64_t;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }
struct DisjointSet {
  std::map<int, int> parent, rank, num;

  void makeSet(int x) {
    parent[x] = x;
    rank[x] = 0;
    num[x] = 1;
  }

  bool same(int x, int y) {
    return findSet(x) == findSet(y);
  }

  void unite(int x, int y) {
    link(findSet(x), findSet(y));
  }

  void link(int x, int y) {
    if(rank[x] < rank[y]) {
      parent[x] = y;
      num[y] += num[x];
    } else {
      parent[y] = x;
      num[x] += num[y];
      if(rank[x] == rank[y]) rank[x]++;
    }
  }

  int numberOf(int x) {
    return num[findSet(x)];
  }

  int findSet(int x) {
    if(x == parent[x]) return x;
    else return parent[x] = findSet(parent[x]);
  }
};

void answer() {
  int n, m, k;
  cin >> n >> m >> k;
  DisjointSet ds;
  rep(i, n) ds.makeSet(i);
  vector<vector<int> > F(n), B(n);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    F[a].emplace_back(b);
    F[b].emplace_back(a);
    if(!ds.same(a, b)) ds.unite(a, b);
  }
  rep(i, k) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    B[a].emplace_back(b);
    B[b].emplace_back(a);
  }
  rep(i, n) {
    if(i) cout << " ";
    int ans = ds.numberOf(i) - 1 - F[i].size();
    for(const int b : B[i]) if(ds.same(i, b)) ans--;
    cout << ans;
  }
  cout << "\n";
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 28276
use std::io;

fn main() {
    let n = read_values::<usize>()[0];
    let mut cur = (0, 0);
    let mut time = 0;
    for _ in 0..n {
        let (t, x, y) = {
            let v = read_values::<i64>();
            (v[0], v[1], v[2])
        };

        let duration = t - time;
        let (cx, cy) = cur;
        let length = (cx - x).abs() + (cy - y).abs();
        if length > duration {
            println!("No");
            return;
        }
        if (duration - length) % 2 != 0 {
            println!("No");
            return;
        }
        time = t;
        cur = (x, y)
    }
    println!("Yes");
}

fn read_line() -> String {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.read_line(&mut buf).unwrap();
    buf
}

fn read_values<T>() -> Vec<T> where T: std::str::FromStr, T::Err: std::fmt::Debug {
    read_line()
        .split(' ')
        .map(|a| a.trim().parse().unwrap())
        .collect()
}

Measured memory_bytes: 4352
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<tr1/unordered_map>
using namespace std;
using namespace std::tr1;
int n,m,l,s[26];
unordered_map<long long,int> g;
long long ans=0,k;
char c;
int mx(int x,int y)
{
	return x>y?x:y;
}
int mn(int x,int y)
{
	return x<y?x:y;
}
int main()
{
	scanf("%d",&n);
	c=getchar();
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<26;j++) s[j]=0;
		while(c<'a' || c>'z') c=getchar();
		while(c>='a' && c<='z')
		{
			s[c-'a']++;
			c=getchar();
		}
		k=0;
		for(int j=0;j<26;j++) k=(k*11+s[j])%576460752303423487;
		ans+=g[k];
		g[k]++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 5540
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)


N, Q = map(int, input().split())
 
class Node():
    def __init__(self):
        self.connected = []
        self.count = 0
 
 
 
def add_count(v, p):
    for c in G[v].connected:
        if c == p:
            continue
        G[c].count += G[v].count
        add_count(c, v)

def add_count2():
    s = [(0, -1)]
    while s:
        v, p = s.pop()
        for c in G[v].connected:
            if c == p:
                continue
            G[c].count += G[v].count
            s.append((c, v))

G = [Node() for _ in range(N)]
for _ in range(N-1):
    a, b = map(int, input().split())
    G[a-1].connected.append(b-1)
    G[b-1].connected.append(a-1)

for _ in range(Q):
    p, x = map(int, input().split())
    G[p-1].count += x

# add_count(0, -1)
add_count2()
counts = [node.count for node in G]
print(*counts)



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

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    string s; cin >> s;
    if (s[0] == '7' || s[1] == '7' || s[2] == '7') cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3640
from itertools import *
g=lambda a,x,b:a+b if x=='+'else a-b if x=='-'else a*b
def f(s):
 for a,b,c,d in permutations(s):
  for x,y,z in product('+-*',repeat=3):
   if g(g(a,x,b),y,g(c,z,d))==10:return f"(({a} {x} {b}) {y} ({c} {z} {d}))"
   if g(g(a,x,g(b,y,c)),z,d)==10:return f"(({a} {x} ({b} {y} {c})) {z} {d})"
 return 0
for e in iter(input,'0 0 0 0'):print(f(list(map(int,e.split()))))


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

public class Main {

    static int n,a[];
    static Boolean[][]memo;
    static boolean dp(int turn,int rem){
        if (rem<=0)return false;
        if (memo[turn][rem]!=null)return memo[turn][rem];
        boolean ans=false;
        for (int i =0;i<n;i++){
            if (rem>=a[i]){
                ans=ans|(!dp(1-turn,rem-a[i]));
            }
        }
        return memo[turn][rem]=ans;
    }
    public static void main(String[] args) throws IOException, InterruptedException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        n = sc.nextInt();
        int k =sc.nextInt();
        a= new int[n];
        for (int i =0;i<n;i++)a[i]=sc.nextInt();
        memo= new Boolean[2][k+1];
        boolean[][]dp= new boolean[2][k+1];
        for (int i =0;i<=k;i++){
            for (int j=0;j<n;j++){
                if (i+a[j]<=k){
                    dp[0][i+a[j]]|=(!dp[1][i]);
                    dp[1][i+a[j]]|=(!dp[0][i]);
                }
            }
        }
        for (int i =0;i<k;i++){
            dp(0,i);
            dp(1,i);
        }
        if (dp(0,k)){
            pw.println("First");
        }
        else pw.println("Second");
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

        public int nextInt() throws IOException {
            return Integer.parseInt(next());
        }

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            String x = next();
            StringBuilder sb = new StringBuilder("0");
            double res = 0, f = 1;
            boolean dec = false, neg = false;
            int start = 0;
            if (x.charAt(0) == '-') {
                neg = true;
                start++;
            }
            for (int i = start; i < x.length(); i++)
                if (x.charAt(i) == '.') {
                    res = Long.parseLong(sb.toString());
                    sb = new StringBuilder("0");
                    dec = true;
                } else {
                    sb.append(x.charAt(i));
                    if (dec)
                        f *= 10;
                }
            res += Long.parseLong(sb.toString()) / f;
            return res * (neg ? -1 : 1);
        }

        public boolean ready() throws IOException {
            return br.ready();
        }
    }

}

Measured memory_bytes: 22972
#include <bits/stdc++.h>
#pragma GCC target("avx")
using namespace std;

#define INIT std::cin.tie(0);std::ios::sync_with_stdio(false);
#define ALL(c) (c).begin(), (c).end()
#define CALL(c) (c).cbegin(), (c).cend()
#define RALL(c) (c).rbegin(), (c).rend()
#define CRALL(c) (c).crbegin(), (c).crend()
#define REP(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define FOR(i, s, n) for (int i = s; i < static_cast<int>(n); i++)
#define ASC(t) [](t& x, t& y){ return x < y; }
#define DESC(t) [](t& x, t& y){ return x > y; }
#define PSORT(s,p,e) partial_sort((s), next((s), (p)), (e))
#define VIEW(v,t) for_each((v).begin(), (v).end(), [](t& a) { cout << a << " "; }); cout << endl;

#define IN(a, x, b) (a<=x && x<b)
template<class T> inline T CHMAX(T& x, const T y){return x=(x<y)?y:x;}
template<class T> inline T CHMIN(T& x, const T y){return x=(x>y)?y:x;}
#define OUT(dist) std::cout<<(dist);
#define WS std::cout<<" ";
#define NL std::cout<<"\n"

using PII = pair<int, int>;
using PLL = pair<long long, long long>;
using LL = long long;
using ULL = unsigned long long;
template<class T> using V = vector<T>;
template<class T> using V2 = vector<vector<T>>;
template<class T, int W=255> using A = array<T, W>;
template<class T, int W=255, int H=255> using A2 = array<array<T, W>, W>;

int N;
std::stack<std::string> ab, a, b, e;
std::string ans;

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

    REP(i,N) {
        std::string s; cin >> s;
        if(s[0] == 'B' && s[s.size()-1] == 'A') ab.push(s);
        else if(s[s.size()-1] == 'A') a.push(s);
        else if(s[0] == 'B') b.push(s);
        else e.push(s);
    }

    while(true) {
        int t1;
        string s1;
        if(!ab.empty()) { s1 = ab.top(), ab.pop(); t1 = 3; }
        else
        if(!a.empty()) { s1 = a.top(), a.pop(); t1 = 2; }
        else
        if(!b.empty()) { s1 = b.top(); b.pop(); t1 = 1; }
        else
        if(!e.empty()) { s1 = e.top(); e.pop(); t1 = 0; }

        if(ab.empty() && a.empty() && b.empty() && e.empty()) {
            ans = s1; break;
        }

        int t2 = 0;
        string s2;
        if(!ab.empty()) { s2 = ab.top(), ab.pop(); t2 = 3; }
        else
        if(!b.empty()) { s2 = b.top(); b.pop(); t2 = 1; }
        else
        if(!a.empty()) { s2 = a.top(), a.pop(); t2 = 2; }
        else
        if(!e.empty()) { s2 = e.top(); e.pop(); t2 = 0; }

        string s;
        if(t1 == t2) s = s1 + s2;
        else
        if(t1 == 3 && t2 == 2) s = s2 + s1;
        else
        if(t1 == 3 && t2 == 1) s = s1 + s2;
        else
        if(t1 == 2 && t2 == 1) s = s1 + s2;
        else s = s1 + s2;

        if(s[0] == 'B' && s[s.size()-1] == 'A') ab.push(s);
        else if(s[s.size()-1] == 'A') a.push(s);
        else if(s[0] == 'B') b.push(s);
        else e.push(s);
    }

    LL cnt = 0;
    REP(i,ans.size()-1) {
        if(ans[i] == 'A' && ans[i+1] == 'B') cnt++;
    }

    cout << cnt << "\n";
}

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

  #define vi vector<int>
  #define all(v) v.begin(),v.end()
  #define ll long long int
  #define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  #define D1(x) {cerr<<" [" <<#x<<": "<<x<<"]";cout << endl;}
  #define D2(x) {cerr<<" [" <<#x<<": ";for(auto it:x)cerr<<it<< " ";cerr<<"] ";cout << endl;}

  const ll MOD=1e9+7;

  void solve(){
     int h,w,k;
     int ans=0;
     cin >> h >> w >> k;
     char grid[h+1][w+1];
     for(int i=1;i<=h;i++){
       for(int j=1;j<=w;j++){
         cin >> grid[i][j];
       }
     }
     for(int i=0;i<=(1<<(h))-1;i++){
       for(int j=0;j<=(1<<(w))-1;j++){
          set<int> row;
          set<int> col;
          for(int r=0;r<h;r++){
            if(i&(1<<r))row.insert(r+1);
          }
          for(int c=0;c<w;c++){
             if(j&(1<<c))col.insert(c+1);
          }
          int cnt=0;
          for(int x=1;x<=h;x++){
             if(row.find(x)!=row.end())continue;
            for(int y=1;y<=w;y++){
               if(col.find(y)!=col.end())continue;
               if(grid[x][y]=='#')cnt++;
            }
          }
          if(cnt==k)ans++;
       }
     }
     cout << ans;
  }


  int main(){
    IOS
       solve();
       cerr <<endl <<"[ Time : " << (float)clock() / CLOCKS_PER_SEC << " secs ]" << endl;
  }
// integer overflow
// remember to clear visited array
// take input as vector<string> while using grid
// don't assign after modifying


Measured memory_bytes: 3840
#include <iostream> 
using namespace std;
#include <cstdio>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
int main()
{
	
	int n;
	cin >>n;
	vector<int>v;
	int num;
	
	for(int i = 0;i<n;i++)
	{
		cin>>num;
		v.push_back(num);
	}
	bool tf =true;
	int fr =v[0];
	
	for(int i = 1;i<v.size();i++)
	{
		if(v[i]>fr)
		{
			fr = v[i];
		}
		else if(v[i]==fr-1||v[i]==fr)
		{
			continue;
		}
		else
		{
			tf = false;
			break;
		}
	}
	
	if(tf)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 892
#include "bits/stdc++.h"
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair <ll, ll > pll;

bool comp(const pll &a, const pll &b) {
	return a.first < b.first;
}
std::vector<int> enum_div(int n)//nの約数を列挙
{
	std::vector<int> ret;
	for (int i = 1; i*i <= n; ++i)
	{
		if (n%i == 0)
		{
			ret.push_back(i);
			if (i != 1 && i*i != n)
			{
				ret.push_back(n / i);
			}
		}
	}
	return ret;
}


template<int N>
int factorial() {
	return factorial<N - 1>() * N;
}

template<>  /// 特殊化：factorial<N=”1”>だったら，値を返す
int factorial<1>() {
	return 1;
}
int main()
{
	priority_queue<int> q;
	string s = {};
	string s1 = {};
	ll h = 0, w = 0, k = 0, a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, ans = 0;
	ll x[300005] = {};
	ll y[300005] = {};
	ll y2[302][302] = {};
	cin >> a;
	cin >> b;
	cin >> c;
	for (int i = 0; i < b; i++)
	{
		cout << c<<" ";
	}
	for (int i = 0; i < a-b; i++)
	{
		cout << (c+1)%1000000000 << " ";
	}

	//cout << ans << endl;



	//return 0;

	/*cout << c << endl;
	cout << b << endl;*/
	//cout << fixed << setprecision(10) <<tmp << endl;
	//cout<<factorial<10><<endl;
	return 0;
}
//2つの組の数をソートしたりするやつ
//vector<pair<ll, ll> > hoges(a);
//for (int i = 1; i <= a; i++)
//{
//	cin >> h;
//	hoges[i - 1] = make_pair(h, i);
//}
//sort(hoges.begin(), hoges.end(), comp);
//for (int i = 0; i < a; i++)
//{
//	cout << hoges[i].second << endl;
//}


Measured memory_bytes: 1280
import java.util.*;
import java.math.*;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		long ans = 1;
		long prev = 1;
		boolean flag = true;
		boolean zero = false;
		long[] mult = new long[n];
		long check = 1000000000000000000L;
		for(int i = 0; i < n; i++) {
			mult[i] = in.nextLong();
			if(mult[i] == 0L) zero = true;
		}
		if(zero == true) {
			System.out.println("0");
		}else {
			for(int i = 0; i < n; i++) {
				long cur = mult[i];
				if((check / cur) < ans) flag = false;
				ans *= cur;
			}
			if(flag == true) {
				System.out.println(ans);
			}else {
				System.out.println("-1");
			}
		}
	}
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define fs first
#define fst first
#define sc second
#define snd second
#define sz(X) (int)(X).size()
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define fornr(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define forab(i, a, b) for(int i = int(a); i < int(b); i++)
#define all(X) X.begin(), X.end()

typedef long long ll;
typedef vector<pair<ll, ll>> vpll;
typedef pair<int, int> pii;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef double dbl;
typedef long double ld;
typedef vector<int> vi;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, m;
    cin >> n >> m;
    if (n == m)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> VI;
 
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
const int mod=1e9+7;

int main(){
    string s,t;
    cin>>s>>t;
    int ssz=s.size();
    int tsz=t.size();
    int next[ssz][26];
    vector<int> a[26];
    rep(i,ssz){
        a[(int)s[i]-'a'].push_back(i);
    }
    rep(i,ssz){
        rep(j,26){
            auto it=upper_bound(all(a[j]),i);
            if(it==a[j].end()){
                it=lower_bound(all(a[j]),0);
                if(it==a[j].end()){
                    next[i][j]=-1;
                }
                else next[i][j]=(ssz-(i-(*it)));
            }
            else next[i][j]=-(i-(*it));
        }
    }
    ll ans=0;
    int f=t[0]-'a';
    int now;
    rep(i,ssz){
        if(t[0]==s[i]){
            now=i;ans+=(i+1);
            break;
        }
        if(i==ssz-1){
            cout<<-1<<endl;
            exit(0);
        }
    }
    rep(i,tsz-1){
        if(next[now][(int)t[i+1]-'a']==-1){
            cout<<-1<<endl;
            exit(0);
        }
        ans+=next[now][(int)t[i+1]-'a'];
        now=(now+next[now][(int)t[i+1]-'a'])%ssz;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 11324
#include<bits/stdc++.h>
#define endl "\n"
#define int long  long 

using namespace std ; 

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL) ;

	int n , m, k ; 
	cin >> n >> m >> k ; 
	set<pair<int,int>> a ; 
	map<int,int> row , col ;
	int r = 0 , c = 0 , id1 =0 , id2 = 0  ;  
	for(int i = 0 ;i < k ; ++i)
	{
		int u , v ;
		cin >> u >> v ; 
		a.insert({u ,v}) ; 
		row[u]++ ; 
		col[v]++ ;
		if(row[u] > r)
		{
			r =row[u] ; 
            id1 = u ; 

		}
		if(col[v] > c)
		{
			c =col[v] ; 
            id2 = v ; 

		}

	}
	if(r== 0 && c ==0)
		cout << 0  ; 
	else
	{
		int ans = 0 ;
		for(int i =1 ; i <= m ; ++i)
		{
			int e = 0 ;
			if(a.find(make_pair(id1 , i)) != a.end())
				e = -1 ;
			ans = max(r + col[i] + e , ans) ; 			
		}
		 
	
	 
		for(int i =1 ; i <= n ; ++i)
		{
			int e = 0 ; 
			if(a.find(make_pair(i , id2)) != a.end())
				e = -1 ;
			ans = max(c + row[i] + e , ans) ; 
		}
		cout << ans ;
	}
		 
		
}       





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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

int main() {
  int N, M, A;
  cin >> N >> M;
  if (N >= M) {
    cout << 0 << endl;
    return 0;
  }
  // ここからはN < M
  
  VI X(M),L(M-1);
  REP(i,M) {
    cin >> X.at(i);
  }
  SORT(X);
  //A = X.at(M-1) = X.at(0);
  REP(i,M-1){
    L.at(i) = X.at(i+1) - X.at(i);
  }
  SORT(L);
  REP(i,N-1) {
    L.at(M-2-i) = 0;
  }
  A=0;
  REP(i,M-1) {
  //  A -= L.at(i);
    A += L.at(i);
  }
  cout << A << endl;
  return 0;
}


Measured memory_bytes: 1024
import sys
M,N,K = map(int,input().split())
if N > M:
    tmp = M
    M = N
    N = tmp
for i in range(N+1):
    for j in range(M+1):
        if M*i + N*j - 2*i*j == K:
            print('Yes')
            sys.exit()
 
print('No')

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

int main() {
	int a, b;
	int cnt = 0;
	cin >> a >> b;
	for (int i = a;i <= b;i++) {
		auto s = to_string(i);
		if (s[0] == s[4] && s[1] == s[3]) {
			cnt++;
		}
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO                     \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0);
typedef long long ll;
/**
 * Uncomment the #define below if problem contains multiple test cases
 */
// #define MULTIPLE_TESTS 1

void solve() {
  int n, m;
  cin >> n >> m;
  int sum = 0, x;
  for (int i = 0; i < m; ++i) {
    cin >> x;
    sum += x;
  }
  if (sum > n) {
    cout << -1 << endl;
  } else {
    cout << n - sum << endl;
  }
}

int main() {
  FAST_IO;
  int t = 1;
#ifdef MULTIPLE_TESTS
  cin >> t;
#endif

  while (t--) {
    solve();
  }

  return 0;
}

Measured memory_bytes: 3592
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val s = Array(n){ readLine()!! }
    val map = mutableMapOf<Char, Int>()
    var c = 'a'
    while(c <= 'z'){
        map.put(c, s.map { it.filter { it == c }.count() }.min() ?: 0)
        c++
    }

    var ans = ""
    c = 'a'
    while(c <= 'z'){
        repeat(map[c]!!){
            ans += c
        }
        c++
    }
    println(ans)
}

Measured memory_bytes: 33912
#include "stdio.h"
#include"string.h"
int main()
{
    char s[10];
    scanf("%s",&s);
    int len;
    len=strlen(s);

    int c[10];


    for (int i = 0; i < 10; ++i)
    {
        if (s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
        {
            c[i]=1;
            //printf("c[%d] is %d\n",i,c[i]);
        }else{
            c[i]=0;
            //printf("c[%d] is %d\n",i,c[i]);
        }
    }

    int max=0;
    int count=0;

    for (int i = 0; i < 10; ++i)
    {
        if(c[i]==0){
            count=0;
        }
        if(c[i]==1)
        {
            count++;
            if (count>=max)
            {
                max=count;
            }
        }
        //printf("count is %d\n",count);
    }

    printf("%d\n",max );
    return 0;
}

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

const int INF = 2e9;

int main(){
    int x;
    cin >> x;
    for(ll i = -200;i <= 200;i++){
        for(ll j = -200;j <= 200;j++){
            ll a = i*i*i*i*i;
            ll b = j*j*j*j*j;
            if(a - b == x){
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
}

Measured memory_bytes: 3624
//g++ -std=c++14 test.cpp -o test.out

#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;

LL N;

string ans = "";

void solve(){
	if(N==0){
		ans = "0";
		return;
	}
	while(N!=0){
		ans = (char)(abs(N)%2+'0') + ans;
		N = N/(-2) + (abs(N)%2==1 && N<0);
	}
}
 
int main(){
    cin >> N;
 
    solve();

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

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

int main() {
    string p;
    string s;

    cin >> p;
    cin >> s;

    p += p;

    string::size_type judge = p.find(s);

    if(judge != string::npos)
	cout << "Yes" << endl;
    else
	cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 1192
n = int(input())
t = []
x = []
y = []
ans = "Yes"
tmpx = 0
tmpy = 0
tmpt = 0
for i in range(n):
    v1,v2,v3 = map(int,input().split())
    t.append(v1)
    x.append(v2)
    y.append(v3)
for i in range(n):
    if abs(tmpx-x[i]) + abs(tmpy-y[i]) <= t[i] - tmpt and (abs(tmpx-x[i]) + abs(tmpy-y[i])) % 2 == (t[i] - tmpt) % 2:
        tmpx = x[i]
        tmpy = y[i]
        tmpt = t[i]
        continue
    else:
        ans = "No"
        break
print(ans)

Measured memory_bytes: 11840
n=int(input())
t = list(map(int, input().split()))
m = int(input())
px = []
for _ in range(m):
        px.append(list(map(int, input().split())))
sm = sum(t)
for num in range(m):
        print(sm - t[px[num][0]-1] + px[num][1])

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
  int N = 0;
  std::cin >> N;
  if (1 == N%2)
    std::cout << "No" << std::endl;
  else
  {
    std::string s;
    std::cin >> s;
    if (s.substr(0, N/2) == s.substr(N/2, N))
	    std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var S = ReadLine();
            IO_ShortCut.WriteLineYes_or_No(S[2] == S[3] && S[4] == S[5]);
        }
    }

    public class IO_ShortCut
    {
        #region Input
        public static string ReadString => ReadLine();
        public static int ReadInt => int.Parse(ReadLine());
        public static long ReadLong => long.Parse(ReadLine());
        public static double ReadDouble => double.Parse(ReadLine());

        public static List<string> ReadSplitString => ReadLine().Split().ToList();
        public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
        public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
        public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

        #endregion
    }

    /// <summary>
    /// 正の数の四則演算のみ対応
    /// </summary>
    public class Mod
    {
        // 割る数の定義
        private readonly static long M = 1000000007;

        // 足し算
        public static long Add(long a, long b) => (a * b) % M;
        // 引き算
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        // 掛け算
        public static long Multi(long a, long b) => (a * b) % M;
    }

}

Measured memory_bytes: 13140
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string> 
#include <vector> 
using namespace std;
 
int main(){
int a[3],i = 1,keta;
cin >> a[0];
int n[a[0]],m[a[0]];
while (a[0] >= i){
    cin >> n[i] >> m[i];
    i++;
}
i = 1;
cin >> a[1];
int o[a[1]],p[a[1]];
while (a[1] >= i){
    cin >> o[i] >> p[i];
    i++;
}
i = 1;
int ii,c,aa,iii,aaa;
aa = a[0] + a[1];
a[3] = a[1];
aaa = aa;
int ans[aa][2],hh[aa],mm[aa],chk,count;
count = 1;
while(aa >= i){
    ii = 1;
    chk = 1;
    if(a[0] >= i){
        while(i - 1 >= ii){
            if(n[i] == hh[ii] and m[i] == mm[ii]){
                chk = 0;
                //cout << n[i] << hh[ii] << m[i] << mm[ii];
            }
            ii++;
        }
        if(chk == 1){ 
            hh[count] = n[i];
            mm[count] = m[i];
            count++;
        }
    }else{
        while(i - 1 >= ii){
            if(o[i - a[0]] == hh[ii] and p[i - a[0]] == mm[ii]){
                chk = 0;
                //cout << o[i] << hh[ii] << p[i] << mm[ii];
            }
            ii++;
        }
        if(chk == 1){ 
            hh[count] = o[i - a[0]];
            mm[count] = p[i - a[0]];
            count++;
        }       
 
    }
    //cout << hh[i] << " " << hh[ii] << " " << mm[i] << " " << mm[ii] << " " << chk << endl;
    i++;
}
aa = count - 1;
 
 
i = 1;
while(aa >= i){
    ii = 1;
    c = 1;
        while(aa >= ii){
                if(hh[i] > hh[ii] or hh[i] == hh[ii] and mm[i] > mm[ii] and i != ii){
                    c++;
                }
        ii++;
        }
    ans[c][0] = hh[i];
    ans[c][1] = mm[i];
    //cout << c  << endl;
 i++;
}
i = 1;
while(aa >= i){
    if(aa == i){
        if(ans[i][1] < 10){
            cout << ans[i][0] << ":" << "0" << ans[i][1] << endl;;
        }else{
            cout << ans[i][0] << ":" << ans[i][1] << endl;;
        }
 
    }else{
        if(ans[i][1] < 10){
            cout << ans[i][0] << ":" << "0" << ans[i][1] << " ";
        }else{
            cout << ans[i][0] << ":" << ans[i][1] << " ";
        }
    }
    i++;
}

}

Measured memory_bytes: 1168
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, A, B; cin >> N >> A >> B;
	vector<vector<int>>nCr(N + 1, vector<int>(N + 1, 0));
	nCr[0][0] = 1;
	rep(i, 1, N + 1)rep(j, 0, i + 1) {
		if (j == 0 || j == i)nCr[i][j] = 1;
		else nCr[i][j] = nCr[i - 1][j] + nCr[i - 1][j - 1];
	}
	map<int, int>mp;
	vector<int> v(N); rep(i, 0, N) { cin >> v[i]; mp[v[i]]++; }
	sort(all(v), greater<int>());

	if (v[0] == v[A - 1]) {
		cout << fixed << setprecision(6) << v[0] << endl;
		int ans(0);
		rep(i, A, B + 1)ans += nCr[mp[v[0]]][i];
		cout << ans << endl;
	}
	else {
		cout << fixed << setprecision(6) << accumulate(v.begin(), v.begin() + A, 0.0) / A << endl;
		int x(0);
		rep(i, 0, A)x += (v[A - 1] == v[i]);
		cout << nCr[mp[v[A - 1]]][x] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
/*
#include<algorithm>
#include<array>
#include<cassert>
#include<cmath>
#include<cstdlib>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<typeinfo>
#include<utility>
#include<vector>
*/
#define int long long int
#define double long double
using namespace std;
#define MOD 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i, n) for (int(i) = 0, i##_len = (n); (i) < i##_len; (i)++)
#define reps(i, x) for (int(i) = 1; (i) <= (int)(x); (i)++)
#define rrep(i, x) for (int(i) = ((int)(x)-1); (i) >= 0; (i)--)
#define rreps(i, x) for (int(i) = ((int)(x)); (i) > 0; (i)--)
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1) << (n))
#define all(x) (x).begin(), (x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl
#define nint int
using namespace std;

int dy[] = {0, 0, 1, -1, 0};
int dx[] = {1, -1, 0, 0, 0};
typedef pair<int, int> pii;
typedef pair<double, double> dop;
template <class T>
bool chmax(T& a, const T& b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b)
{
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
struct aaa {
    aaa()
    {
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout << fixed << setprecision(20);
    };
} aaaaaaa;


signed main()
{
    int n, x;
    cin >> n >> x;
    std::vector<int> l(n);
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }
    int sum = 1;
    int len = 0;
    for (int i = 0; i < n; i++) {
        if (len + l[i] <= x) {
            sum++;
            len += l[i];
        } else {
            break;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
import copy

h,w,K = map(int, input().split())

c = []
for j in range(h):
    tmpc = input()
    tmpc = [1 if i=='#' else 0 for i in tmpc]
    c.append(tmpc)

#print(c)
cnt = 0
for i in range(2**h):
    for j in range(2**w):
        buc = copy.deepcopy(c)
        sumc = 0
        for k in range(h):
            if i >> k & 1 == 1:
                c[k] = [0] * w    
        for l in range(j):
            if j >> l & 1 == 1:
                for m in range(h):
                    c[m][l] = 0
        for l in range(h):
            sumc += sum(c[l])
        c = copy.deepcopy(buc)
        if sumc == K:
            cnt += 1
print(cnt)


Measured memory_bytes: 78916
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#define ll long long
using namespace std;

int main(){
    ll n;
    cin >> n;
    ll a[n], check[n];
    ll ans = 0;
    ll count = n/2;
    if(n%2==0) count--;
    for(ll i = 0; i < n; i++){
        cin >> a[i];
        check[i] = a[i]-i-1;
    }
    sort(check, check+n);
    for(ll i = 0; i < n; i++)
        ans+= abs(check[i]-check[count]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{
	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	ll n;
	ll x[100005] = {};
	ll y[100005] = {};
	ll z[100005] = {};
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> y[i];
	}
	for (int i = 0; i < n; i++)
	{
		cin >> z[i];
	}
	sort(x, x + n, std::greater<ll>());
	sort(y, y + n, std::greater<ll>());
	sort(z, z + n, std::greater<ll>());
	b = 0;
	c = 0;
	d = 0;
	for (int i = 0; i < n; i++)
	{
		while (x[b]>=y[i]&&b<n)
		{
			b++;
		}
		while (y[i]<z[d]&&d<n)
		{
			d++;
		}
		c += (n-b)*d;
		//cout << n-b << endl;
		//cout << d << endl;
		//cout <<  endl;

	}



	cout << c << endl;
	//cout << ans << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//char型の文字数字は、-'0'で数値に変換できる
//accumulate(x, x + a, 0);//int型までの配列の合計
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;
//cout << char(z - 'a');
//log10(i) + 1 //10進数の桁数を取得

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}

//最小公倍数
//ll x = a * b;
//ll tmp;
///* 自然数 a > b を確認・入替 */
//if (a<b) {
//	tmp = a;
//	a = b;
//	b = tmp;
//}
///* ユークリッドの互除法 */
//ll r = a % b;
//while (r != 0) {
//	a = b;
//	b = r;
//	r = a % b;
//}
//a = x / b;//答え

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

typedef long long ll;


int main(){
  ll n;
  cin>>n;
  ll ans = (n/11) * 2;
  n %= 11;

  if(n==0){
    
    cout<<ans<<endl;
    
  }else if(n<=6){
    
    cout<<ans+1<<endl;
    
  }else if(n<=11){
    
    cout<<ans+2<<endl;
    
  }

  
  return 0;
}


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

typedef pair<long long, long long> P;
int INF = - 2'000'000'000;

int main(){
    int n;
    cin >> n;
    vector<double> ans(n + 1, 0);
    ans[0] = 1;
    double x;
    for (int i = 0; i < n; i++){
        cin >> x;
        vector<double> tmp(n + 1, 0);
        tmp[0] += ans[0] * (1 - x);
        for (int j = 1; j <= n; j++){
            tmp[j] += ans[j - 1] * x;
            tmp[j] += ans[j] * (1 - x);
        }
        ans = tmp;
    }

    double solve = 0;
    for (int i = (n + 1) / 2; i <= n; i++) solve += ans[i];
    cout << setprecision(15) << solve << endl;
}

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


		using namespace std;

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


			if (d == 25) {
				cout << "Christmas";
			}
			if (d == 24) {
				cout << "Christmas Eve";
			}
				if (d == 23) {
					cout << "Christmas Eve Eve";
				}
				if (d == 22) {
					cout << "Christmas Eve Eve Eve";
				}
			}

		

Measured memory_bytes: 256
// ABC_140_C

#include <bits/stdc++.h>
using namespace std;
using ll = long long;

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

	vector<int> v(n-1);
	for(int i = 0; i < n-1; ++i) cin >> v[i];

	vector<int> v_1(n);
	v_1[0] = v[0];
	v_1[n-1] = v[n-2];

	int sum = 0;
	for(int i = 1; i < n-1; ++i) {
		v_1[i] = min(v[i-1], v[i]);
		sum += v_1[i];
	}

	int ans = sum + v_1[0] + v_1[n-1];
	cout << ans << "\n";

	return 0;
}

Measured memory_bytes: 256