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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
const int INF = 1e5;

bool A[10];
int DP[100000];
int match[] = {-1,2,5,5,4,5,6,3,7,6};

int main(){
    int N, M;
    cin >> N >> M;
    REP(i,M){
        int a;
        cin >> a;
        A[a] = true;
    }

    fill(DP, DP+N, INF);

    for(int d = 1; d <= 9; d++){
        if(!A[d]) continue;
        DP[match[d]] = 1;
    }
    DP[0] = 0;

    for(int i = 0; i < N; i++){
        if(DP[i] == INF)  continue;
        for(int d = 1; d <= 9; d++){
            if(!A[d]) continue;
            DP[i+match[d]] = DP[i] + 1;
        }
    }

    //for(int i = 0; i < N; i++){
    //    printf("%d ", DP[i]);
    //}
    //printf("\n");
    //printf("keta:%d\n", DP[N]);

    int keta = DP[N];
    int m = N;
    for(int k = 0; k < keta; k++){
        for(int d = 9; d >= 1; d--){
            if(!A[d]) continue;
            if(m - match[d] >= 0 && DP[m-match[d]] == keta-k-1){
                printf("%d", d);
                m -= match[d];
                break;
            }
        }
    }
    printf("\n");
    return 0;
}


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

struct Dice {
  top: usize,
  front: usize,
  right: usize
}

impl Dice {
  fn build(top: usize, front: usize) -> Self {
    Self {
      top: top,
      front: front,
      right: Self::right_of(top, front)
    }
  }

  fn right_of(top: usize, front: usize) -> usize {
    let (a, b) = (top > 2, front > 2);

    let t = if a { 5 - top } else { top };
    let f = if b { 5 - front } else { front };

    let right = match (t, f) {
      (0, 1) => 2,
      (1, 2) => 0,
      (2, 0) => 1,
      (1, 0) => 3,
      (2, 1) => 5,
      (0, 2) => 4,
      _ => unreachable!()
    };

    if a ^ b { 5 - right } else { right }
  }

  fn left(&self) -> usize { 5 - self.right }

  fn back(&self) -> usize { 5 - self.front }

  fn bottom(&self) -> usize { 5 - self.top }
}

fn main() {
  let stdin = stdin();
  let mut lines = stdin.lock().lines();

  let line = lines.next().unwrap().unwrap();
  let mut labels_a = line.split_whitespace();

  let line = lines.next().unwrap().unwrap();
  let labels_b = line.split_whitespace().collect::<Vec<_>>();

  let top = labels_a.next().unwrap();
  let front = labels_a.next().unwrap();
  let right = labels_a.next().unwrap();
  let left = labels_a.next().unwrap();
  let back = labels_a.next().unwrap();
  let bottom = labels_a.next().unwrap();

  // top
  let tops = labels_b.iter().enumerate()
    .filter(|&(_, &b)| top == b);

  for (i, _) in tops {
    // front
    let fronts = labels_b.iter().enumerate()
      .filter(|&(j, &b)| front == b && j != i && j != (5 - i));

    for (j, _) in fronts {
      let dice = Dice::build(i, j);

      if right != labels_b[dice.right] { break; }

      if left != labels_b[dice.left()] { break; }

      if back != labels_b[dice.back()] { break; }

      if bottom != labels_b[dice.bottom()] { break; }

      println!("Yes");
      return;
    }
  }

  println!("No");
}



Measured memory_bytes: 5028
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, s, e) for (int i = (int)(s); i <= (int)(e); i++)
#define printYesNo(is_ok) puts(is_ok ? "Yes" : "No");
#define SORT(v) sort(v.begin(), v.end());
#define RSORT(v) sort(v.rbegin(), v.rend());
#define REVERSE(v) reverse(v.begin(), v.end());

template <typename T>
void printlnVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << endl;
  }
}

template <typename T>
void printVector(T v)
{
  rep(i, v.size())
  {
    cout << v[i] << " ";
  }
  cout << endl;
}

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if(A < C && C < B)
    cout << "Yes" << endl;
  else if(B < C && C < A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		try (Scanner sc = new Scanner(System.in);) {
			
			StringBuilder sb = new StringBuilder();
			
			while(true) {
				String x = sc.next();
				
				if(x.equals("0")) break;
				
				int sum = 0;
				
				for(int i = 0; i < x.length(); i++) {
					sum += Integer.parseInt(String.valueOf(x.charAt(i)));
				}
				
				sb.append(sum);
				sb.append("\n");
			}
			
			System.out.print(sb.toString());
		}
	}
}


Measured memory_bytes: 26820
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
	static void Main(string[] args)
    {
    	var input = Console.ReadLine();
        var set = new HashSet<char>();
        foreach(var s in input)
        {
        	set.Add(s); 
        }
      
        foreach(var i in set)
        {
            var c = input.Where(x => x == i).Count();
          	if (c % 2 != 0)
            {
            	Console.WriteLine("No");
                return;
            }        	
        }
        Console.WriteLine("Yes");
    }
}

Measured memory_bytes: 13408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <map>
#include <set>

using namespace std;

long long n, m, x;
long long a[50000];



signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> x;
    if (n <= x && x <= n + m)
    {
        cout << "YES";
    }
    else
    {
        cout << "NO";
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
	using namespace std;
	#define int long long int
	#define pb push_back
	const int mod=1e9+7;
	#define all(x) x.begin(),x.end()
	#define endl '\n'
	#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
	int32_t main(){
		IOS;
		int n;
		cin>>n;
		string s;
		cin>>s;
		if(s.size()<=n)cout<<s<<endl;
		else if(s.size()>n){
			for(int i=0;i<n;i++){
				cout<<s[i];
			}
			cout<<"..."<<endl;
		}
		return 0;
	}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
int32_t main()
{
	set<int> s;
	int x,n;
	cin>>x>>n;
	int a;
	for(int i=0;i<n;i++){cin>>a;s.insert(a);}
	int l,r;
	for(int i=0;i<=100;i++)
	{
		l=x-i;
		r=x+i;
		if(!s.count(l)){cout<<l;return 0;}
		else if(!s.count(r)){cout<<r;return 0;}
	}
}

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

typedef pair<P, int> PP;
const int INF = 1e9;

class union_find {
    private:
        vector<int> par;
        vector<int> ran;
        vector<ll> size;
    public:
        union_find(int n);
        int find(int x);
        void unite(int x, int y);
        bool same(int x, int y);
        ll show_size(int x);
};

union_find::union_find(int n){
    par.resize(n);
    ran.resize(n);
    size.resize(n);
    rep(i,n) par[i] = i;
    rep(i,n) ran[i] = 0;
    rep(i,n) size[i] = 1;
};

int union_find::find(int x) {
    if(par[x] == x) return x;
    else return par[x] = find(par[x]);
};

void union_find::unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    ll t = show_size(x)+show_size(y);
    size[x] = size[y] = t;
    if(ran[x] < ran[y]){
        par[x] = y;
        //size[y] += size[x];
    }
    else{
        par[y] = x;
        //size[x] += size[y];
        if(ran[x] == ran[y]) ran[x]++;
    }
};

ll union_find::show_size(int x) {
    if(par[x] == x) return size[x];
    return show_size(par[x] = find(par[x]));
}

bool union_find::same(int x, int y) {
    return (find(x) == find(y));
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vector<PP> v;
	rep(i,n){
		int x, y;
		cin >> x >> y;
		v.emplace_back(P(x, y), i+1);
	}
	sort(v.begin(), v.end());
	union_find uf(n+1);
	set<P> st;
	st.insert(P(INF, INF));
	for(int i = n-1; i >= 0; --i){
		int x = v[i].first.first;
		int y = v[i].first.second;
		int idx = v[i].second;
		auto itr = st.lower_bound(P(y, -1));
		bool merge = false;
		while(*itr != P(INF, INF)){
			P p = *itr;
			uf.unite(idx, p.second);
			merge = true;
			++itr;
		}
		if(!merge) st.insert(P(y, idx));
	}
	for(int i = 1; i <= n; ++i){
		cout << uf.show_size(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 9496
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll=long long;
using P=pair<int,int>;
int main(){
    int n;ll k;
    cin >> n >> k;
    int a[n];
    rep(i,n) cin >> a[i];
    vector<int> s;
    vector<int> ord(n+1,-1);//-1ならば訪れていない
    int c=1,l=0;
    {
        int v=1;
        while(ord[v]==-1){
            ord[v]=s.size();
            s.push_back(v);
            v=a[v-1];
        }
        c=s.size()-ord[v];
        l=ord[v];
    }
    if(k<l) cout<<s[k]<<endl;
    else{
        k-=l;
        k%=c;
        cout<<s[l+k]<<endl;
    }
    return 0;
}

Measured memory_bytes: 5888
#include <iostream>
#include <vector>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <assert.h>
#include <algorithm>
#include <queue>
#include <bitset>
#include <stack>
#include <chrono>
#include <random>
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define ll long long
#define INF 1000000000000000000
#define MOD 1000000007
#define rnd mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define FIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define uid uniform_int_distribution <int>
using namespace std;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
// Read the question carefully and see all the given sample tests
// Think about the correctness before implementing

int main() {
	string s;
	cin >> s;
	int n = (int) s.size();
	for (int i = 1; i < n; i++) {
		if (s[i] == s[i - 1]) {
			cout << i << " " << i + 1;
			return 0;
		}
		else if(i < n - 1) {
			if (s[i - 1] == s[i + 1]) {
				cout << i << " " << i + 2;
				return 0;
			}
		}
	}
	cout << -1 << " " << -1;
}


Measured memory_bytes: 512
#include <stdio.h>
#define NUM 21

int main(void){
    int N;
    int V[NUM], C[NUM];
    scanf("%d", &N);

    int sum = 0;
    for(int i = 0 ; i < N; i++){
        scanf("%d", &V[i]);
    }
    for(int i = 0 ; i < N; i++){
        scanf("%d", &C[i]);
    }
    for(int i = 0 ; i < N; i++){
        int cost = V[i] - C[i];
        if(cost > 0){
            sum += cost;
        }
    }

    printf("%d\n", sum);
}


Measured memory_bytes: 504
# include "bits/stdc++.h"
using namespace std;
using LL = long long;
using ULL = unsigned long long;
const double PI = acos(-1);
template<class T>constexpr T INF() { return ::std::numeric_limits<T>::max(); }
template<class T>constexpr T HINF() { return INF<T>() / 2; }
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
int d_sum(LL n) { int ret = 0; while (n > 0) { ret += n % 10; n /= 10; }return ret; }
int d_cnt(LL n) { int ret = 0; while (n > 0) { ret++; n /= 10; }return ret; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define REP(i,upupu)         FOR(i,0,upupu)

struct INIT{
    INIT(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(0);
        cout << fixed << setprecision(13);
    }
}INIT;

int a, b;

int main(){
    cin >> a >> b;
    REP(i, max(a, b))cout << min(a, b);
    cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P;
typedef vector<int> Vi;
int const MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { return a = b; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { return a = b; } return false; }



int main(){
  cin.tie(0); ios::sync_with_stdio(false);
    
  string s1,s2; cin>>s1>>s2;
  int ans=0;
  for (int i = 0; i < 3; i++)if(s1[i]==s2[i])ans++;
  cout<<ans<<'\n';
}

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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)

using namespace std;

const int MAX_V = 100010;
const int MAX_E = 1000010;
const string YES = "yes";
const string NO  = "no";

int V,E;
int degree[MAX_V],us[MAX_E],vs[MAX_E],V_sub[MAX_V],E_sub[MAX_V];
int par[MAX_V],ones[MAX_V],two[MAX_V];

int find(int x) { 
  if( x == par[x] ) return x;
  return par[x] = find(par[x]);
}

void unit(int x,int y){
  x = find(x), y = find(y);
  if( x != y ) par[x] = y;
}

void compute(){
  if( E >= V ) { cout << NO << endl; return; }
  rep(i,V) if( degree[i] >= 3 ) { cout << NO << endl; return; }
  rep(i,V) ++V_sub[find(i)];
  rep(i,E) ++E_sub[find(vs[i])];
  rep(i,V) if( V_sub[i] && E_sub[i] != V_sub[i]-1 )  { cout << NO << endl; return; }

  
  rep(i,V) {
    int group_index = find(i);
    if( degree[i] == 1 ) ++ones[group_index];
    else if( degree[i] == 2 ) ++two[group_index];
  }
  rep(i,V) if( ones[i] >= 3 ) { cout << NO << endl; return; }
  cout << YES << endl;
}

int main(){
  int u,v;
  while( scanf("%d %d",&V,&E), V|E ){
    rep(i,V) degree[i] = ones[i] = two[i] = V_sub[i] = E_sub[i] = 0, par[i] = i;
    typedef pair<int,int> ii;
    set<ii> S;
    bool success = true;
    rep(i,E){
      scanf("%d %d",&us[i],&vs[i]);
      --us[i], --vs[i];
      if( us[i] > vs[i] ) swap(us[i],vs[i]);
      ++degree[us[i]], ++degree[vs[i]];
      if( us[i] == vs[i] ) success = false;
      if( S.count(ii(us[i],vs[i])) ) success = false;
      S.insert(ii(us[i],vs[i]));
      unit(us[i],vs[i]);
    }
    if( !success ) { cout << NO << endl; continue; }
    compute();
  }
  return 0;
}

Measured memory_bytes: 19140
#include <iostream>
#define INFTY 1000000001

using namespace std;

int count = 0;

void merge(int *A, int left, int mid, int right){
    int i, j;
    int n1 = mid - left;
    int n2 = right - mid;
    int L[n1+1], R[n2+1];
    for(i = 0; i < n1; i++) L[i] = A[left + i];
    for(i = 0; i < n2; i++) R[i] = A[mid + i];
    L[n1] = INFTY;
    R[n2] = INFTY;
    i = 0;
    j = 0;
    for(int k = left; k < right; k++){
        if(L[i] <= R[j]){
            A[k] = L[i];
            i++;
        }else{
            A[k] = R[j];
            j++;
        }
        count++;
    }
}

void mergeSort(int *A, int left, int right){
    int mid;
    if(left + 1 < right){
        mid = (left + right) / 2;
        mergeSort(A, left, mid);
        mergeSort(A, mid, right);
        merge(A, left, mid, right);
    }
}

int main(){
    int n, i;
    cin >> n;
    int A[n];
    for(i = 0; i < n; i++){
        cin >> A[i];       
    }
    mergeSort(A, 0, n);

    for(i = 0; i < n-1; i++) cout << A[i] << " ";
    cout << A[i] << endl;
    cout << count << endl;

    return 0;
}


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

using namespace std;
const int N=2e5+5;
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int n,m;
    cin>>n>>m;
    if(n==m) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<LL,LL> PL;

const int MOD=1000000007;
int INF=100100100;
int main(){
  LL a;
  string s;
  cin>>a>>s;
  string t=s[0]+s.substr(2);
  int c=stoi(t);
  cout<<a*c/100<<endl;
  return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main(){    
  int x,y;
  cin >> x >> y;
  if(y%2 == 1) cout << "No" << endl;
  else if(y < 2*x || 4*x < y) cout << "No" << endl;
  else cout << "Yes" << endl;
}
 

Measured memory_bytes: 3628
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
h,w,d = map(int,input().split())
ans = 0
x = [0]*(h*w+1)
y = [0]*(h*w+1)
for i in range(h):
    a = list(map(int,input().split()))
    for j in range(w):
        x[a[j]] = j
        y[a[j]] = i
q = int(input())
#飛び飛びの累積和をとる　視点と
cum_sum_d = [0]*(h*w+1)
for i in range(d,h*w+1):
    cum_sum_d[i] =  cum_sum_d[i-d] + abs(x[i]-x[i-d])+abs(y[i]-y[i-d])
for i in range(q):
    l,r = map(int,input().split())
    ans = cum_sum_d[r] - cum_sum_d[l]
    
    """ #TLE解
    for i in range((r-l)//d): 
        ans += abs(x[l+d*i]-x[l+d*(i+1)])+abs(y[l+d*i]-y[l+d*(i+1)])
        """
    print(ans)

Measured memory_bytes: 9548
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
using namespace std;
char s[100010];
int len,f[100010];
int main()
{
	scanf("%s",s+1);
	len=strlen(s+1);
	int top=0;
	for(int i=1;i<=len;i++)
		if(s[i]!='x') s[++top]=s[i];
		else f[top]++;
//	for(int i=0;i<=top;i++)
//		cout<<f[i]<<' ';
//	cout<<endl;		
	bool pd=1;int ans=0;	
	for(int i=1;i<=top/2;i++)
		if(s[i]==s[top-i+1]) ans+=abs(f[i-1]-f[top-i+1]);
		else {pd=0; break;}
	if(top&1) ans+=abs(f[top/2]-f[top/2+1]);
	if(pd) printf("%d",ans);
	else puts("-1");	
	return 0;
}
/*xabxa*/

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int dp[101][100001];
long long int v[101], w[101];

long long int solve(int n, int w1){
      if(n==0 || w1==0)return 0;
      if(dp[n][w1]!=-1)return dp[n][w1];
      dp[n][w1]=solve(n-1, w1);
      if(w[n]<=w1)dp[n][w1]=max(dp[n][w1], v[n]+solve(n-1, w1-w[n]));
      return dp[n][w1];
}

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

      for(int i=0; i<n; i++)
            cin>>w[i+1]>>v[i+1];
      memset(dp, -1, sizeof(dp));

      solve(n, W);
      /*for(int i=0; i<=W; i++)
      for(int j=0; j<=n; j++)
      {
            dp[j][i]=-1;
            if(i==0 || j==0)dp[j][i]=0;
      }

      for(int i=1; i<=n; i++)
      {
            for(int w1=1; w1<=W; w1++){
                  dp[i][w1]=dp[i-1][w1];
                  if(w[i]<=w1)
                  dp[i][w1]=max(dp[i][w1], dp[i-1][w1-w[i]]+v[i]);
            }
      }*/
      cout<<dp[n][W]<<'\n';
}

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


int arr[3][3];
int main()
{

    
    
    int a, b, c, d, e, f, g, h, i;
    cin>>a>>b>>c>>d>>e>>f>>g>>h>>i;
    int n;
    cin>>n;
    vector<bool> bn(101);
    for(int j=0;j<n;j++){
       int t;cin>>t;
       bn[t] = true; 
    }
    bool bingo= (bn[a]&&bn[b]&&bn[c])||(bn[d]&&bn[e]&&bn[f])||
                (bn[g]&&bn[h]&&bn[i])||(bn[a]&&bn[d]&&bn[g])||
                (bn[b]&&bn[e]&&bn[h])||(bn[c]&&bn[f]&&bn[i])||
                (bn[a]&&bn[e]&&bn[i])||(bn[c]&&bn[e]&&bn[g]);
    cout<<(bingo ? "Yes" : "No" ) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ve vector
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())
//using namespace __gnu_pbds;
using namespace std;

// // // functions: find_by_order  & order_of_key
// typedef tree<
// int,
// null_type,
// less<int>,
// rb_tree_tag,
// tree_order_statistics_node_update>
// ordered_set;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<vi> vvi;

const int inf=(int)2e9;
const long long md=1000000007; //1E9+7
int dx[]={1,-1,0,0},dy[]={0,0,1,-1};

ll powmod(ll a,ll p){
	ll ans=1;
	while(p){
		if(p&1) ans*=a;
		p/=2;a*=a; ans%=md;a%=md;
	}
	return ans;
}
ll mdinv(ll a){return powmod(a,md-2); }

const int N=16;
int sc[1<<N];
int DP[1<<N];

signed main(){
	IOS
	int n;cin>>n;
	vector<vector<int>> M(n,vi(n));
	forn(i,n)
	forn(j,n) cin>>M[i][j];
	vi tmp;
	for(int msk=1;msk<1<<n;msk++){
		tmp.clear();
		for(int x=0;x<n;x++)
			if((msk>>x)&1) tmp.pb(x);
		int here=0;
		for(int i=0;i<tmp.size();i++)
			for(int j=i+1;j<tmp.size();j++)
				here+=M[tmp[i]][tmp[j]];
		sc[msk]=here;
	}

	DP[0]=0;
	for(int msk=1;msk<(1<<n);msk++){
		int b=LLONG_MIN;
		for(int sub=msk;sub;sub=(sub-1)&msk)
			b=max(b,sc[sub]+DP[msk^sub]);
		DP[msk]=b;
	}
	cout<<DP[(1<<n)-1];
}


Measured memory_bytes: 1280
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]
flag = False
for i in range(n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        flag = True
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9196
#include<cstdio>
#include<vector>
#include<algorithm>
#include<utility>
#include<numeric>
#include<iostream>
#include<array>
#include<string>
#include<sstream>
#include<stack>
#include<queue>
#include<list>
#include<functional>
#include<set>
#include<complex>
#include<complex>
#define _USE_MATH_DEFINES

#include<math.h>
#include<map>

#define INF 200000000
#define FER 0.0000000001

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;

int dp[10001];
int v[100], w[100];

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

	int N, W;

	cin >> N >> W;

	for (int i = 0; i < N; i++)
	{
		cin >> v[i] >> w[i];
	}

	for (int i = 0; i < N; i++)for (int j = W; j != 0; j--)
	{
		if (j >= w[i])
		{
			dp[j] = max(dp[j], dp[j - w[i]] + v[i]);
		}
	}

	cout << dp[W] << endl;
	
	return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;




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


    ll n, d;
    cin >> n >> d;

    ll ans = 0;

    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;

        if (sqrt(x*x + y*y) <= d) {
            ans++;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 3192
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
#define acc(v) accumulate(v.begin(), v.end(), 0)
#define cinv(n,v) rep(i,n) cin >> v[i]
using namespace std;
const int INF = 1e9;
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vint;
typedef vector<string> vstr;
typedef vector<char> vchar;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
int x_pos[4] = {1,0,-1,0}, y_pos[4] = {0,1,0,-1};
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

char upper(char c){
	return c-0x20;
}

char lower(char c){
	return c+0x20;
}

void unique_vector(vector<int>& v){
	sort(all(v));
	v.erase(unique(all(v)), v.end());
}

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

//ユークリッドの互除法
//最大公約数
ll gcd(ll x, ll y) {
  if (y == 0) return x;
  return gcd(y, x%y);
}

//最小公倍数
ll lcm(ll x, ll y){
	ll g = gcd(x,y);
	return x/g*y;
}

ll myPow(ll x, ll n, ll m){
  if(n == 0)
    return 1;
  if(n % 2 == 0)
    return myPow(x * x % m, n / 2, m);
  else
    return x * myPow(x, n - 1, m) % m;
}

int main() {
	string s,t;
	cin >> s >> t;
	int count = 0;
	for (int i = 0; i < 3; i++)
	{
		if(s[i]==t[i]){
			count++;
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<double,int>;
const ll inf = numeric_limits<ll>::max()/3;

int h,w;
vector< string > grid;
int rmatch[20];
int ccmatch[20];
bool dfs1(int,bool);
bool dfs2(int,bool);

bool dfs1(int n,bool f){
  if(n == w){
    return dfs2(0,(h % 2 == 1));
  }
  if(ccmatch[n] != -1)
    return dfs1(n+1,f);
  for(int i = 0;i < w;++i){
    if(i != n && ccmatch[i] == -1){
      ccmatch[i] = n;
      ccmatch[n] = i;
      bool res = dfs1(n+1,f);
      ccmatch[i] = -1;
      ccmatch[n] = -1;
      if(res)
        return true;
    }
  }
  if(f){
    ccmatch[n] = n;
    bool res = dfs1(n+1,false);
    ccmatch[n] = -1;
    if(res)
      return true;
  }
  return false;
}

bool ok(int r1,int r2){
  for(int i = 0;i < w;++i){
    if(grid[r1][i] != grid[r2][ccmatch[i]] ||
       grid[r1][ccmatch[i]] != grid[r2][i])
      return false;
  }
  return true;   
}

bool pal(int r){
  for(int i = 0;i < w;++i)
    if(grid[r][i] != grid[r][ccmatch[i]])
      return false;
  return true;
}

bool dfs2(int n,bool f){
  if(n == h)
    return true;
  if(rmatch[n] != -1)
    return dfs2(n+1,f);
  for(int i = 0;i < h;++i){
    if(i != n && rmatch[i] == -1 && ok(n,i)){
      rmatch[i] = n;
      rmatch[n] = i;
      bool res = dfs2(n+1,f);
      rmatch[i] = -1;
      rmatch[n] = -1;
      if(res)
        return true;
    }
  }
  if(f && pal(n)){
    rmatch[n] = n;
    bool res = dfs2(n+1,false);
    rmatch[n] = -1;
    if(res)
      return true;
  }
  return false;
}



int main(void){
  cin >> h >> w;
  grid.clear();
  grid.resize(h);
  fill(rmatch,rmatch+20,-1);
  fill(ccmatch,ccmatch+20,-1);
  for(int i = 0;i < h;++i){
    cin >> grid[i];
  }
  if(dfs1(0,(w % 2 == 1)))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>
#include <stack>
#include <numeric>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


#define MAX_N 200005
#define MOD 1000000007
#define mod 1000000007

long long inv[MAX_N],fac[MAX_N],finv[MAX_N];

void make()
{
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2;i<MAX_N;i++){
		inv[i] = MOD - (long long)inv[MOD%i] * (MOD/i) % MOD;
		fac[i] = (long long)fac[i-1] * i % MOD;
		finv[i] = (long long)finv[i-1] * inv[i] % MOD;
	}
}

long long comb(int a,int b)
{
	if(a < b){
		return 0;
	}
	return fac[a] * ((long long)finv[b] * finv[a-b] % MOD) % MOD;
}

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


int main(){
    int b,w;
    cin >> b >> w;
    int n = b+w;
    ll B = -1;
    ll W = -1;
    make();
    ll hal = mod_pow(2,MOD-2);
    rep(i,n){
        ll res = hal;
        if(i>=b){
            if(i==b){
                B = mod_pow(hal,b);
            }else{
                B += (comb(i-1,b-1)*mod_pow(hal,i))%mod;
                B %= mod;
            }
            res += mod-((hal*B)%mod);
            res %= mod;
            
        }
        if(i>=w){
            if(i==w){
                W = mod_pow(mod_pow(2,MOD-2),w);
            }else{
                W += (comb(i-1,w-1)*mod_pow(hal,i))%mod;
                W %= mod;
            }
            res += (hal*W)%mod;
            res %= mod;
        }
        //cerr << B << " " << W << endl;
        
        
        cout << res << endl;
    }

    return 0;
}

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

const int maxn = 2e5 + 5;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {-1, 0, 1, 0};
int h, w, n, r, c;
char s[maxn], t[maxn];

bool check(int d) {
    int x = r, y = c;
    for (int i = 0; i < n; ++i) {
        if (s[i] == d) {
            x += dx[d];
            y += dy[d];
            if (x < 0 || x >= h || y < 0 || y >= w)
                return false;
        }

        if (t[i] == (d + 2) % 4) {
            if (x + dx[(d + 2) % 4] >= 0 &&
                x + dx[(d + 2) % 4] < h  &&
                y + dy[(d + 2) % 4] >= 0 &&
                y + dy[(d + 2) % 4] < w) {
                x += dx[(d + 2) % 4];
                y += dy[(d + 2) % 4];
            }
        }
    }
    return true;
}

int main() {
    scanf("%d%d%d", &h, &w, &n);
    scanf("%d%d", &r, &c);
    --r, --c;
    scanf("%s", s);
    scanf("%s", t);

    for (int i = 0; i < n; ++i)
        s[i] = s[i] == 'L' ? 0 :
               s[i] == 'D' ? 1 :
               s[i] == 'R' ? 2 : 3;

    for (int i = 0; i < n; ++i)
        t[i] = t[i] == 'L' ? 0 :
               t[i] == 'D' ? 1 :
               t[i] == 'R' ? 2 : 3;

    bool ans = true;
    for (int i = 0; i < 4; ++i) 
        ans &= check(i);

    if (ans)
        puts("YES");
    else
        puts("NO");

    return 0;
}


Measured memory_bytes: 640
n = int(input())

dp = []
for i in range(n):
    a, b, c = map(int, input().split())

    if not dp:
        dp.append([a, b, c])
    else:
        dp.append([a + max(dp[-1][1], dp[-1][2]),
                   b + max(dp[-1][0], dp[-1][2]),
                   c + max(dp[-1][0], dp[-1][1])])

print(max(dp[-1]))


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

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

typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//定数
#define INF 1000000000 //10^9:極めて大きい値,∞
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second　//pairの二つ目の要素

int main(){
    int h,a;
    cin>>h>>a;
    int ans=h/a;
    if(h%a!=0) ans++;
     cout<<ans<<endl;
    return 0;
}

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

#define ll long long
#define pb push_back
#define MP make_pair
#define F first
#define S second
#define MAX 1e9
#define MIN -1e9
#define MOD 1000000007

int main(){
	ios::sync_with_stdio(0); 
    cin.tie(0); 
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	ll n;
	cin >> n;
	ll a[n];
	ll xr;
	cin >> xr;
	a[0] = xr;
	for(ll i=1; i<n; i++){
		cin >> a[i];
		xr ^= a[i];
	}
	ll ans;
	for(ll i=0; i<n; i++){
		ans = xr ^ a[i];
		cout << ans << " ";
	}
	cout << "\n";
	return 0;
}

Measured memory_bytes: 5168
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define INIVAL 2147483647

int *a, *ts, c, s, t, v;

void update(int k, int l, int r)
{
  if (r<s || t<=l) return;
  if (s<=l && r<=t) {
    a[k] = v;
    ts[k] = c;
  } else if (l<r-1) {
    update(((k+1)<<1)-1, l, (l+r)>>1);
    update((k+1)<<1, (l+r)>>1, r);
  }
}

int main()
{
  int i, k, n, z, w, latest;
  char *p,buf[64] = {0};
  buf[62] = '\n';
  fgets(buf, 64, stdin);
  for (n=0,p=buf; *p>' '; n=n*10+*(p++)-'0');
  w = n>1 ? pow(2,(int)ceil(log2(n)))-1 : 1;
  ts = (a = (int*)malloc((w+n)*2*sizeof(int))) + w+n;
  for (i=0; i<w+n; i++)  ts[i] = -1;
  a[0] = INIVAL;
  ts[0] = 0;
  c = 0;
  while (fgets(buf, 64, stdin)) {
    for (s=0,p=buf+2; *p>' '; s=s*10+*(p++)-'0');
    if (*buf=='0') { // update(s, t, x)
      for (t=0,p++; *p>' '; t=t*10+*(p++)-'0');
      for (v=0,p++; *p>' '; v=v*10+*(p++)-'0');
      t++;
      update(0, 0, w+1);
      c++;
    } else { // find(x) x->s
      latest = -1;
      for (k=w+s; ; k=(k-1)>>1) {
	if (ts[k]>latest) {
          latest = ts[k];
          z = a[k];
        }
	if (k==0) break;
      }
      if (z<10) {
	putc_unlocked('0'+z, stdout);
	putc_unlocked('\n', stdout);
      } else {
        for (i=62; z>0; buf[--i]='0'+z%10,z/=10);
        fputs(buf+i, stdout);
      }
    }
  }
  return 0;
}



Measured memory_bytes: 3516
#include <cstdio>

typedef long long ll;
const int MAXN=2e5+5;
ll mod=998244353;

ll N,M,K;

ll fast_power(ll a,ll exp){
    if (exp==1) return a%mod;
    if (exp==0) return 1ll;

    auto temp=fast_power(a,exp/2);
    temp=temp*temp%mod;
    if (exp%2) temp=temp*(a%mod)%mod;
    return temp;
}

ll inverse(ll a){ return fast_power(a,mod-2);};

ll inv[MAXN];
ll Cn_1[MAXN];//C n-1 i

int main(){

    scanf("%lld%lld%lld",&N,&M,&K);

    if (M==1&&K==N-1){
        puts("1");
        return 0;
    }

    for(int i=1;i<=N;i++) inv[i]=inverse(i);
    Cn_1[0]=1;
    for(ll i=1;i<=N-1;i++){
        Cn_1[i]=Cn_1[i-1]*((N-i)%mod)%mod;
        Cn_1[i]=Cn_1[i]*(inv[i])%mod;
    }

    ll someval=M*(fast_power(M-1,N))%mod;
    ll invM=inverse(M-1);
    ll ans=0;
    for(ll i=0;i<=K;i++){
        someval=someval*invM % mod;
        ll temp=someval*Cn_1[i]%mod;
        ans=(ans+temp)%mod;
    }

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

    return 0;
}

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

int main() {
  int n, o = 0;
  cin >> n;
  vector<int> a(n), b(n - 1);
  for(int i = 0; i < n - 1; i++)
    cin >> b.at(i);
  a.at(0) = b.at(0);
  a.at(n - 1) = b.at(n - 2);
  for(int i = 1; i < n - 1; i++)
    a.at(i) = min(b.at(i - 1), b.at(i));
  for(int i = 0; i < n; i++)
    o += a.at(i);
  cout << o << endl;
}

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

int main() {
    int h, w;
    cin >> h >> w;
    int n;
    cin >> n;
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        int a;
        cin >> a;
        generate_n(back_inserter(ans), a, [&]() { return i; });
    }
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            cout << (i % 2 == 0 ? ans[i*w+j] : ans[i*w+(w-j-1)]) << " ";
        }
        cout << endl;
    }
}


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


int main()
{
    long long n;
    cin >> n;
    long long arr[n+5];
    for(int i=0; i<n; i++)
    {
        cin >> arr[i];
    }
    sort(arr, arr+n);
    cout << abs(arr[0]-arr[n-1]) << endl;
    return 0;
}







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

const int INF = 10000000;

int base16(char c) {
  if( 'a' <= c ) return c-'a'+10;
  else return c-'0';
}

int main() {

  string s;

  int coltabel[8][3] = { { 0, 0, 0 }, { 0, 0, 255 }, { 0, 255, 0 },
			 { 0, 255, 255 }, { 255, 0, 0 }, { 255, 0, 255 },
			 { 255, 255, 0 }, { 255, 255, 255 } };

  string nametable[8] = { "black", "blue", "lime", "aqua",
			 "red", "fuchsia", "yellow", "white" };

  while(true) {

    cin>>s;
    if( s=="0" ) break;

    int r,g,b;
    r = base16(s[1])*16+base16(s[2]);
    g = base16(s[3])*16+base16(s[4]);
    b = base16(s[5])*16+base16(s[6]);

    int res,tmp=INF,t;

    for(int i=0; i<8; i++) {
      if( ( t = (r-coltabel[i][0])*(r-coltabel[i][0])
	  + (g-coltabel[i][1])*(g-coltabel[i][1])
	  + (b-coltabel[i][2])*(b-coltabel[i][2]) )
	  < tmp ) {
	//cout<<t<<" "<<i<<endl;
	res = i;
	tmp = t;
      }
    }

    cout<<nametable[res]<<endl;
  }
}

Measured memory_bytes: 592
n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ans = 0

A = [0]*(n+1)

for i in range(n):
    A[i+1] = A[i] + a[i]

B = [0]*(m+1)

for i in range(m):
    B[i+1] = B[i] + b[i]

j = m

for i in range(n+1):
    if A[i] > k :
        break
    while B[j] > k-A[i]:
        j -= 1

    ans = max(ans,i+j)


print(ans)


Measured memory_bytes: 47464
input = input().split()

k = int(input[0])
x = int(input[1])

min = x - (k - 1)
max = x + (k - 1)

if min < -100000: min = -1000000

if max > 1000000: max = 1000000

anslist = []
for i in range(min, max + 1, 1):
    print(i, end=" ")


Measured memory_bytes: 3060
p=print
r=range
def a(i,j,k,l=0):p("+<"[l],i,j,k)
def b(i):a(i,i,i+1)
def d(x,i,j):
	for t in r(30):b(p:=j+t-1);a(q:=j+t,n,q);[*map(b,r(j+t,j+29))];a(j+29,x,i+t,1);b(p);a(q,i+t,q)
p(3933)
a(0,1,n:=97)
a(2,n,n,1)
a(0,n,3)
a(1,n,4)
d(3,5,36)
d(4,36,67)
for t in r(59):a(2,2,2);[(a(5+t-s,36+s,98),a(n,98,99,1),a(2,99,2))for s in r(t+1)if t-30<s<30]

Measured memory_bytes: 9312
import sys,math,itertools
input = sys.stdin.readline
Q = int(input())
query = [list(map(int,input().split())) for i in range(Q)]

def is_prime(n):
        if n <= 0:return None
        if n == 1:return False
        sup = math.floor(pow(n,1/2))
        for i in range(2,sup+1):
                if n % i == 0:
                        return False
        return True

prime = [0]*(10**5+1)
for i in range(1,10**5+1):
        if is_prime(i):
                prime[i] = 1

for i in range(10**5,-1,-1):
        if prime[i] and i % 2 == 1 and prime[(i+1)//2]:
                pass
        else:
                prime[i] = 0

acc = list(itertools.accumulate(prime))
for l,r in query:
        print(acc[r]-acc[l-1])

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

int main(){
  int A,B;
  cin>>A>>B;
  int p=A+B;
  int m=A-B;
  int k=A*B;
  if(p<=k&&m<=k){
    cout<<k<<endl;
  }else if(p<=m&&k<=m){
    cout<<m<<endl;
  }else{
    cout<<p<<endl;
  }
}

Measured memory_bytes: 3632
n,m = map(int,input().split())
h = list(map(int,input().split()))
l = []
for i in range(m):
  a,b = map(int,input().split())
  a-=1
  b-=1
  if h[a]<h[b]:
    l.append(a)
  elif h[a] == h[b]:
    l += [a,b]
  else:
    l.append(b)
s = set(l)
print(n-len(s))


Measured memory_bytes: 91196
#include <bits/stdc++.h> 
using namespace std;
using ll = long long;
using ld = long double;
template<typename T> using v2 = vector<vector<T>>;
template<typename T> inline v2<T> fill(int r, int c, const T& t){ return v2<T>(r, vector<T>(c, t)); }
#define F first
#define S second

ll choose(int n, int k){
    if(k > n) return 0;
    if(k*2 > n) k = n-k;
    if(!k) return 1;

    ll ans = n;
    for(int i = 2; i <= k; ++i){
        ans *= n-i+1;
        ans /= i;
    }
    return ans;
}

void solve(){
    int n,a,b;
    cin>>n>>a>>b;
    vector<ll> v(n);
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    sort(v.begin(), v.end(), greater<ll>());

    ll last = v[a-1];

    int start = a-1;
    while(start-1 >= 0 && v[start-1]==last) --start;

    int end = a-1;
    while(end+1 < n && v[end+1]==last) ++end;

    int l = end-start+1;
    if(start==0){
        ll ways = 0;
        for(int i = a; i <= min(l, b); ++i){
            ways += choose(l, i);
        }
        cout << fixed <<setprecision(9)<<(ld)v[0] << '\n' << ways << '\n';
    }
    else{
        int need = a-start;
        ll ways = choose(l, need);
        ll sum = 0;
        for(int i = 0; i < a; ++i) sum+=v[i];
        ld avg = (ld)sum/a;
        cout << fixed <<setprecision(9)<<avg << '\n' << ways << '\n';
    }
}

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

Measured memory_bytes: 3808
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n,k,s;
  cin>>n>>k>>s;
  for(int i=0;i<k;i++)cout<<s<<" ";
  if(s==1e9)for(int i=k;i<n;i++)cout<<1<<" ";
  else for(int i=k;i<n;i++)cout<<s+1<<" ";
  cout<<endl;
  return 0;
}

Measured memory_bytes: 1280
import java.util.Arrays;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    // TODO 自動生成されたメソッド・スタブ
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int a[] = new int[n];
    int b[] = new int[n - 1];
    for (int i = 0; i < n - 1; i++) {
      b[i] = sc.nextInt();
    }
    Arrays.fill(a, Integer.MAX_VALUE);

    for (int i = 0; i < n - 1; i++) {
      a[i] = Math.min(a[i], b[i]);
      a[i + 1] = Math.min(a[i + 1], b[i]);
    }

    int sum = 0;
    for (int i = 0; i < n; i++) {
      sum += a[i];
    }
    System.out.println(sum);
  }
}


Measured memory_bytes: 23636
N, M = map(int, raw_input().split())
P = [map(int, raw_input().split()) for _ in range(N)]
Q = [map(int, raw_input().split()) for _ in range(M)]

for x1, y1 in P:
    dist = 10 ** 9
    ans = -1
    for i, (x2, y2) in enumerate(Q):
        if abs(x1 - x2) + abs(y1 - y2) < dist:
            dist = abs(x1 - x2) + abs(y1 - y2)
            ans = i + 1
    print ans


Measured memory_bytes: 2568
use proconio::input;
use proconio::marker::Chars;

fn main() {
    input! {
        s1: Chars,
        s2: Chars,
        s3: Chars,
    };

    println!(
        "{}{}{}",
        s1[0].to_uppercase(),
        s2[0].to_uppercase(),
        s3[0].to_uppercase()
    );
}


Measured memory_bytes: 2152
#include<bits/stdc++.h>
#define MAXN 200005
using namespace std;

typedef long long LL;
int N;
LL K, S[MAXN];
unordered_map<LL,LL> M;

LL id(LL x) {
  LL p = (S[x] - x) % K;
  if (p < 0) p += K;
  return p;
}

int main () {
  scanf("%d%lld",&N,&K);
  for (int i=1;i<=N;++i) {
    scanf("%lld",&S[i]);
    S[i] = (S[i] + S[i-1]) % K;
  }
  LL ans = 0;
  M[id(0)]++;
  int pre = 0;
  for (LL i=1;i<=N;++i) {
    while (pre < i && i - pre  > K-1) M[id(pre++)]--;
    LL x = id(i);
    ans += M[x];
    M[x]++;
  }
  printf("%lld\n",ans);
}


Measured memory_bytes: 10056
#include <iostream>
using namespace std;
int main(void){
    int a,b;
    int c;
    cin >> a;
    cin >> b;
    if(a>b)
        c=a-b;
    else
        c=b-a;
    if(a==b)
        cout << a << "\n";
    for(int i=c;i>0;i--){
        if(a%i == 0 && b%i==0){
            cout << i << "\n";
            break;
        }
    }
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int a[N][3];
int dp[N][3];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    f(i, n) {
        f(j, 3) cin>>a[i][j];
    }
    f(i, 3) dp[0][i] = a[0][i];
    for(int i = 1; i < n; i++){
        f(j, 3) {
            dp[i][j] = a[i][j] + max(dp[i - 1][add(j, 1, 3)] , dp[i - 1][add(j, 2, 3)]);
        }
    }
    cout<<max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]});
    return 0;
}

Measured memory_bytes: 2560
k, n = map(int, input().split())
a = list(map(int,input().split()))[::-1]
diff = 0

for i in range(len(a)-1):
    if diff < a[i] - a[i+1]:
        diff = a[i] - a[i+1]

if diff < k-a[0] + a[-1]:
    diff = k-a[0] + a[-1]

ans = k-diff

print(ans)


Measured memory_bytes: 26444
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define PI pair<int,int>
#define ff first
#define ss second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL)
#define INF LONG_MAX
#define io freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int32_t main()
{
   // io;
    boost;
    int a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
}



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

int main(void)
{
	int count = 0;
	int limit = 0;

	std::cin >> count >> limit;

	int countInRange = 0;
	double root = std::pow(static_cast<double>(limit), 2.0);
	for (int i = 0; i < count; i++) {
		int x, y;
		std::cin >> x >> y;

		const double distanceRootX = std::pow(static_cast<double>(x), 2.0);
		const double distanceRootY = std::pow(static_cast<double>(y), 2.0);
		if (distanceRootX + distanceRootY <= root) countInRange++;
	}
	std::cout << countInRange;
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<string>
#include<algorithm>
#include <map>  
#include <string.h>
#include <math.h>

using namespace std;

int n, z, w, a[2001] = {};
int t1, t2, t3=0;


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

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

	if (n == 1) {
		cout << abs(a[0] - w) << endl;
		return 0;
	}

	t1 = abs(a[n - 2] - a[n - 1]);
	t2 = abs(a[n - 1] - w);

	cout << max(t1, t2) << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
int main()
{
    _SAD()
    int a,b,c;
    cin>>a>>b>>c;
    if(a+b+c>=22)
    {
        cout<<"bust"<<NL;
        return 0;
    }
    cout<<"win"<<NL;
    return 0;
}



Measured memory_bytes: 256
/*
 * Author : anaksoleh
 * 8 september 2019
 */

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

int N;
int A[105];
int B[105];

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

	cin >> N;

	for(int i = 1 ; i <= (N-1) ; i++){
		cin >> B[i];
	}

	A[N] = B[N-1];
	long long sum = A[N]; 
	for(int i = (N-1) ; i > 1 ; i--){
		A[i] = min(B[i],B[i-1]);
		sum += A[i];
	}
	A[1] = B[1];
	sum += A[1];

	cout << sum << '\n';

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
	int n,i;
	cin>>n;
	vector<int>a(n+1);
	for(i=1;i<=n;i++)
	cin>>a[i];
	int dp[n+1];
    memset(dp,-1,sizeof(dp));
    dp[1]=0;dp[2]=abs(a[2]-a[1]);
    for(i=3;i<=n;i++)
    {
    	dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]));
    }
    cout<<dp[n];
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>

using namespace std;
using ll = long long int;

int main()
{
  ll n, h, w;
  cin >> n >> h >> w;
  vector<pair<ll, ll>> slates(n);
  for(int i = 0; i < n; i++)
  {
    ll a, b;
    cin >> a >> b;
    slates[i] = {a, b};
  }
  int count = 0;
  for(int i = 0; i < n; i++)
  {
    if(slates[i].first >= h && slates[i].second >= w)
    {
      count++;
    }
  }
  cout << count << endl;
	return 0;
}


Measured memory_bytes: 256