akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename A, size_t N, typename T> void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> void vdebug(vector<T> v){ cout << "vdebug" << endl; for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ cout << "adebug" << endl; reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
template<typename T1, typename T2> void mdebug(map<T1, T2> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebug(multimap<T1, T2> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mdebugr(map<T1, T2, greater<T1>> mp){ cout << "mdebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
template<typename T1, typename T2> void mldebugr(multimap<T1, T2, greater<T1>> mp){ cout << "mldebug" << endl; for(auto const& m : mp){ cout << m.first sp m.second << endl; }}
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    int n;
    vector<int> elements;
    elements.push_back(2);
    reps(i, 3, 55555){
        if(i%2 == 0) continue;
        bool flg = true;
        reps(j, 2, sqrt(i)){
            if(i%j == 0){
                flg = false;
                break;
            }
        }
        if(flg) elements.push_back(i);
    }

    vector<int> res;
    for(auto const& e : elements){
        if(e%5==1){
            res.push_back(e);
        }
    }

    cin >> n;
    rep(i, n){
        cout << res[i] << " ";
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 384
M = 10**9 + 7
a = [1] + [0] * 12
p = 1
for c in reversed(input()):
    r = [x % 13 for x in range(0, p * 10, p)] if c == '?' else (p * int(c) % 13,)
    a = [sum(a[(i - j, i - j + 13)[i < j]] for j in r) % M for i in range(13)]
    p = p * 10 % 13
print(a[5])


Measured memory_bytes: 49644
import java.math.*;
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int X = sc.nextInt();
    int Y = sc.nextInt();
    int A = sc.nextInt();
    int B = sc.nextInt();
    int C = sc.nextInt();
    int[] p = new int[A];
    int[] q = new int[B];
    int[] r = new int[C];
    for (int i = 0; i < A; i++) p[i] = sc.nextInt();
    for (int i = 0; i < B; i++) q[i] = sc.nextInt();
    for (int i = 0; i < C; i++) r[i] = sc.nextInt();
    sc.close();

    Arrays.sort(p);
    Arrays.sort(q);

    int[] xyc = new int[X + Y + C];
    for (int i = 0; i < X; i++) xyc[i] = p[A - i - 1];
    for (int i = 0; i < Y; i++) xyc[X + i] = q[B - i - 1];
    for (int i = 0; i < C; i++) xyc[X + Y + i] = r[i];
    Arrays.sort(xyc);

    long ans = 0;
    for (int i = 0; i < X + Y; i++)
      ans += xyc[X + Y + C - 1 - i];

    System.out.println(ans);
  }
}


Measured memory_bytes: 97132
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/





int N;
using pii = pair<int, int>;
pii HP[5010];
ll dp[5010][5010];
//---------------------------------------------------------------------------------------------------
void _main() {
    cin >> N;
    rep(i, 0, N) {
        int a, b; cin >> a >> b;
        HP[i] = { a, b };
    }
    sort(HP, HP + N, [&](pii a, pii b) { return a.first + a.second < b.first + b.second; });

    rep(i, 0, N + 1) rep(j, 0, N + 1) dp[i][j] = infl;
    dp[0][0] = 0;
    rep(i, 0, N) rep(j, 0, N) if(dp[i][j] < infl) {
        int H = HP[i].first;
        int P = HP[i].second;

        // 取らない
        chmin(dp[i + 1][j], dp[i][j]);
        
        // 取れたら取る
        if (dp[i][j] <= H) chmin(dp[i + 1][j + 1], dp[i][j] + P);
    }

    int ans = 0;
    rep(j, 0, N + 1) if (dp[N][j] < infl) chmax(ans, j);
    cout << ans << endl;
}

Measured memory_bytes: 196096
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  int total =0;
  vector<int>vec(n);
  for(int i=0;i<n;i++){
    cin>>vec.at(i);
    total+=vec.at(i);
  }
  sort(vec.begin(),vec.end());
  cout<<total-vec.at(n-1)/2<<endl;
}
  


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

int main(){
	int i, j, k, l;
	int n, Y, M, D, x, count = 0;
	
	cin>>n;
	
	for(l = 0; l < n; l++){
		cin>>Y>>M>>D;
		
		count = 0;
		
		
		for(i = Y; i < 1000; i++){
			if(i == Y) j = M;
			else j = 1;
			for(; j <= 10;j++){
				if(j%2 == 1) x = 20;
				else x = 19;
				if(i%3 == 0)x = 20;
				if(Y == i && M == j) k = D;
				else k = 1;
				for(; k <= x; k++){
					count++;
				}
			}
		}
		
		cout<<count<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int rest = x - a;
        System.out.println(rest % b);
    }
}

Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, m, n) for (int i = m; i < n; ++i)
#define FORR(i, m, n) for (int i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
struct UnionFind {
    vector<int> par,siz; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) , siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
        for(int i = 0; i < N; i++) siz[i] = 1;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[ry] = rx; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
        siz[rx]+=siz[ry];
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
    int size(int x){
        return siz[root(x)];
    }
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,m;cin >> n >> m;
    UnionFind uf(n);
    REP(i,m){
        int a,b;cin >> a >> b;
        a--,b--;
        uf.unite(a,b);
    }
    int ans=0;
    REP(i,n){
        chmax(ans,uf.size(i));
    }
    cout << ans << endl;
}

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

#define rep2(x,fr,to) for(int x=(fr);x<(to);x++)
#define rep(x,to) for(int x=0;x<(to);x++)
#define repr(x,fr,to) for(int x=(fr);x>=(to);x--)
#define all(c) c.begin(),c.end()
#define sz(v) (int)v.size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
typedef vector<ll> VL; const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; } template <typename T,typename ...T2> void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T, class T2> void amax(T& a,T2 b){ if(a < b) a = b;}


int main()
{
	cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	cin >>n >>q;
	using T3 = tuple<ll, int, ll>;
	vector<T3> dt;
	rep(i, n){
		int s, t, x;
		cin >>s >>t >>x;
		dt.emplace_back(s-x, 1, x);
		dt.emplace_back(t-x, 5, x);
	}
	rep(i, q){
		int d; cin >>d;
		dt.emplace_back(d,  9, i);
	}
	sort(all(dt));
	VL ans(q);
	multiset<ll> mst;
	for(auto& z: dt){
		ll a, b, c;
		tie(a, b, c) = z;
		//dbg(a,b,c);
		if(b==1) mst.insert(c);
		else if(b==5) mst.erase(mst.lower_bound(c));
		else ans[c] = sz(mst)? *mst.begin(): -1;
	}
	for(auto z: ans) cout<< z <<"\n";
	
	return 0;
}


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

int deff(int x, int y) {

  if (x-y >= 0) {
    return x-y;
  }
  else {
    return 0;
  }

}

int main() {
    int H, N;
    cin >> H >> N;
    vector<vector<int>> mgc(N, vector<int>(2));
    for (int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        mgc.at(i).at(0) = a;
        mgc.at(i).at(1) = b;
    }
    
    vector<int> dp(H+1, 0);
    
    for (int i=0; i<H; i++){
        int MIN = INT_MAX;
        for (int j=0; j<N; j++){
            MIN = min(MIN, dp.at(deff(i+1, mgc.at(j).at(0))) + mgc.at(j).at(1));
        }
        dp.at(i+1) = MIN;
    }
    
    cout << dp.at(H) << endl;
}


Measured memory_bytes: 384
#define _USE_MATH_DEFINES
#include <math.h>
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <stdio.h>
#include <vector>
#include <map>
#include <queue>

using namespace std;
typedef long long ll;

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

int main() {

    ll N,M;
    cin >> N >> M;
    string A[N];
    rep(i,N) cin >> A[i];
    string B[M];
    rep(i,M) cin >> B[i];
    string out = "No";
    rep(i,N-M+1){
        rep(j,N-M+1){
            ll cnt = 0;
            rep(k,M){
                rep(l,M){
                    if(A[i+k][j+l]==B[k][l]) cnt++;
                    else break;
                }
            }
            if(cnt==M*M){
                out = "Yes";
                break;
            }
        }
    }
    cout << out << endl;
    return 0;
}


Measured memory_bytes: 3564
#![allow(unused_imports)]
#![allow(unused_macros)]
// use proconio::input;
use std::cmp::{Ordering::*, Reverse};
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, VecDeque};
use std::io::{self, BufWriter, Write};
use std::str::{self, SplitAsciiWhitespace};

// I have no idea what I'm doing

macro_rules! answer {
    ($out:ident, $ans:expr) => {
        writeln!($out, "{}", $ans)
    };
}

fn main() -> Result<(), io::Error> {
    let (stdin, stdout) = (io::stdin(), io::stdout());
    let mut scan = UnsafeScanner::new(stdin.lock());
    let mut out = BufWriter::new(stdout.lock());

    let k: i32 = scan.token();
    let mut m = 0;
    let mut ans = None;
    for i in 1..=k {
        m *= 10;
        m += 7;
        m %= k;

        if m == 0 {
            ans = Some(i);
            break;
        }
    }

    answer!(out, ans.unwrap_or(-1))
}

///////////////////////////////////////////////////////////////////////////////////////////////////

/// Mostly copied from https://github.com/EbTech/rust-algorithms/blob/master/src/scanner.rs
/// Same API as Scanner but nearly twice as fast, using horribly unsafe dark arts
/// **REQUIRES** Rust 1.34 or higher
pub struct UnsafeScanner<R> {
    reader: R,
    buf_str: Vec<u8>,
    buf_iter: SplitAsciiWhitespace<'static>,
}

impl<R: io::BufRead> UnsafeScanner<R> {
    pub fn new(reader: R) -> Self {
        Self {
            reader,
            buf_str: vec![],
            buf_iter: "".split_ascii_whitespace(),
        }
    }

    /// This function should be marked unsafe, but noone has time for that in a
    /// programming contest. Use at your own risk!
    pub fn token<T: str::FromStr>(&mut self) -> T {
        loop {
            if let Some(token) = self.buf_iter.next() {
                return token.parse().ok().expect("Failed parse [Scanner]");
            }
            self.buf_str.clear();
            self.reader
                .read_until(b'\n', &mut self.buf_str)
                .expect("Failed read");
            self.buf_iter = unsafe {
                let slice = str::from_utf8_unchecked(&self.buf_str);
                std::mem::transmute(slice.split_ascii_whitespace())
            }
        }
    }

    pub fn pair<T: str::FromStr>(&mut self) -> (T, T) {
        (self.token(), self.token())
    }
}

// aka #![feature(bool_to_option)]
trait BoolThen {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T>;
}

impl BoolThen for bool {
    fn then_<T>(self, f: impl FnOnce() -> T) -> Option<T> {
        if self {
            Some(f())
        } else {
            None
        }
    }
}

trait BoolToYes {
    fn yes(self) -> &'static str;
}

impl BoolToYes for bool {
    fn yes(self) -> &'static str {
        match self {
            true => "Yes",
            false => "No",
        }
    }
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    ll n, m;
    cin >> n >> m;
    vvll e(n);
    ll a, b;
    REP(i, m) {
        cin >> a >> b;
        a--, b--;
        e[a].push_back(b);
        e[b].push_back(a);
    }
    ll s = 0;
    vll res(n);
    queue<ll> que;
    res[s] = 1;
    que.push(s);

    while (!que.empty()) {
        ll cur = que.front();
        que.pop();
        for (auto to : e[cur]) {
            if (res[to]) continue;
            res[to] = cur + 1;
            que.push(to);
        }
    }
    cout << "Yes" << endl;
    REP(i, n - 1) {
        cout << res[i + 1] << endl;
    }
    return 0;
}

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

int main(){
  int n,m;
  cin >> n >> m;
  vector<int> v(n);
  int sum=0;
  for(int i=0;i<n;i++){
    cin >> v[i];
    sum+=v[i];
  }
  sort(v.begin(),v.end());
  bool flag = true;
  for(int i=n-m;i<n;i++){
    if(4*m*v[i] < sum){
      flag = false;
    }
  }
  if(flag){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = [int(x) for x in input().split()]

from collections import Counter

cnt = Counter(a)

value = sorted(cnt.values(),reverse=True)

flg = 0
if len(value)<=k:
    print(0)
else:
    for i in range(k):
        flg += value[i]

    print(n-flg)


Measured memory_bytes: 98768
terms = '1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51'.split(', ')
print(terms[int(input()) - 1])

Measured memory_bytes: 38740
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

long long GCD(long long m, long long n){
	if(n == 0) return m;
	else return GCD(n, m % n);
}

signed main(){
	int n;
	cin >> n;
	ll a[n];
	rep(i,n){
		cin >> a[i];
	}
	ll sum[n + 2] = {}, rsum[n + 2] = {};
	sum[1] = a[0];
	for(int i = 1; i < n; i++){
		sum[i + 1] = GCD(sum[i], a[i]);
	}
	rsum[n] = a[n - 1];
	for(int i = n - 1; i > 0; i--){
		rsum[i] = GCD(rsum[i + 1], a[i - 1]);
	}
	ll ans = 0;
	for(int i = 1; i <= n; i++){
		if(sum[i - 1] == 0) ans = max(ans, rsum[i + 1]);
		if(rsum[i + 1] == 0) ans = max(ans, sum[i - 1]);
		ans = max(ans, GCD(sum[i - 1], rsum[i + 1]));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
#include <iostream>

using namespace std;

int main(){
	int D, N, X;
	cin >> D >> N;
	X = 1;
	for (int i = 0; i < D; i++){
		X = X * 100;
	}
	if (N == 100){
		N++;
	}
	X = X * N;
	cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>

typedef long long ll;

int main(){
  ll N, K;
  std::cin >> N >> K;
  ll resa = 0;
  for(ll i = K ; i <= N + 1 ; i++){
    ll min = (i - 1) * i / 2;
    ll max = (N + 1) * N / 2 - (N - i) * (N - i + 1) / 2;
    resa += max - min + 1;
  }
  std::cout << resa % 1000000007<< std::endl;  
  return 0;
}

Measured memory_bytes: 3616
#include "bits/stdc++.h"
#include <set>

using namespace std;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep1(i, n) for (int i = 1; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
#define all(i) (i).begin(), (i).end()
#define rall(i) (i).begin(), (i).end(), greater<int>()
#define int long long
#define elif else if
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define fst first
#define sec second
#define mod 1000000007
#define INF 10e10
template <typename T>

void print(T x)
{
	std::cout << x << " ";
}
template <typename T>

void println(T x)
{
	std::cout << x << "\n";
}

signed main(void) {
	int h, n;
	cin >> h >> n;
	int sum = 0;
	rep(i, n) {
		int a;
		cin >> a;
		sum += a;
	}
	if (h > sum)print("No");
	else print("Yes");
	
}


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

//オーバーフロー
//コーナーケース

typedef long long ll;

int main() {
    int n,m;
    cin >> n >> m;
    stack<int> ans;
    string s;
    cin >> s;
    int pos = s.size() - 1;
    while (1) {
        if (pos - m < 0) {
            ans.push(pos);
            break;
        }
        int pp = pos - m;
        while (s[pp] == '1') {
            pp++;
        }
        if (pp == pos) {
            cout << -1 << endl;
            return 0;
        }
        ans.push(pos - pp);
        pos = pp;
        if (pos == 0) break;
    }
    while (!ans.empty()) {
        cout << ans.top();
        ans.pop();
        if (ans.empty()) {
            cout << endl;
            return 0;
        } else {
            cout << " ";
        }
    }
    return 0;
}


Measured memory_bytes: 876
while True:
    #繰り返し回数を入力し0であった場合はbreakする
    num = int(input())
    if num == 0:
        break
    else:
        for _ in range(num):
            a,b,c = map(int,input().split())
            
            #100 点の科目があるまたは数学と英語の平均点が 90 点以上または3 科目の平均点が 80 点以上の場合"A"を出力する
            if a == 100 or b == 100 or c == 100 or (a + b) / 2 >= 90 or (a + b + c) / 3 >= 80:print("A")
            
            #3 科目の平均点が 70 点以上または3 科目の平均点が 50 点以上で数学か英語が 80 点以上の場合"B"を出力する
            elif (a + b + c) / 3 >= 70 or (a + b + c) / 3 >= 50 and a >= 80 or (a + b + c) / 3 >= 50 and b >= 80:print("B")
            
            #上記のどれにも当てはまらない場合、"C"を出力する
            else:print("C")


Measured memory_bytes: 5616
#include "bits/stdc++.h"
using namespace std;
int main(){
    string s;
    cin >> s;
    int i,n,a,z;
    n=s.size();
    for(i=0;i<n;i++){
        if(s.at(i)=='A'){
            a = i;
            break;
        }
    }
    for(i=n-1;i>=0;i--){
        if(s.at(i)=='Z'){
            z = i;
            break;
        }
    }
    cout << z-a+1 << endl;
    return 0;
}

Measured memory_bytes: 640
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int h = Integer.parseInt(sc.next());
        int w = Integer.parseInt(sc.next());
        int K = Integer.parseInt(sc.next());

        String[] hw = new String[h];
        for(int i=0; i<h; i++){
            hw[i] = sc.next();
        }

        sc.close();

        int[] line = new int[h];
        int[] column = new int[w];
        int total = 0;
        for(int i=0; i<h; i++){
            for(int j=0; j<w; j++){
                if(hw[i].charAt(j) == '#'){
                    total++;
                    line[i]++;
                    column[j]++;
                }
            }
        }
        // for(int i=0; i<h; i++){
        //     System.out.println(line[i]);
        // }
        // System.out.print("\n");
        // for(int i=0; i<w; i++){
        //     System.out.println(column[i]);
        // }
        // System.out.print("\n");

        int count = 0;
        for(int i=0; i<(1<<h); i++){
            List<Integer> lineList = new ArrayList<>();
            int temp = total;
            for(int j=0; j<h; j++){
                if((i & (1<<j)) > 0){
                    lineList.add(j);
                    temp -= line[j];
                }
            }
            for(int j=0; j<(1<<w); j++){
                int temp2 = temp;
                List<Integer> columnList = new ArrayList<>();
                for(int k=0; k<w; k++){
                    if((j & (1<<k)) > 0){
                        columnList.add(k);
                        temp2 -= column[k];
                    }
                }
                for(int k=0; k<lineList.size(); k++){
                    for(int l=0; l<columnList.size(); l++){
                        if(hw[lineList.get(k)].charAt(columnList.get(l)) == '#'){
                            temp2++;
                        }
                    }
                }
                if(temp2 == K){
                    //System.out.println("\n" + lineList.toString() + "\n" + columnList.toString() + "\n");
                    count++;
                }
            }
        }
        System.out.println(count);
    }
}

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

const lint MOD = 1e9 + 7;
int N, A, B, C, D;
lint dp[1005][1005], fact[1005], fact_inv[1005];

lint mod_pow(lint x, lint y){
    lint res = 1;
    while(y){
        if(y & 1) res = res * x % MOD;
        x = x * x % MOD; y >>= 1;
    }
    return res;
}

lint comb(int n, int r){
    if(n < r) return 0;
    return fact[n] * fact_inv[n-r] % MOD * fact_inv[r] % MOD;
}

int main(){
    cin >> N >> A >> B >> C >> D;

    fact[0] = 1;
    for(int i=1;i<=N;i++) fact[i] = fact[i-1] * i % MOD;

    fact_inv[N] = mod_pow(fact[N], MOD-2);
    for(int i=N-1;0<=i;i--) fact_inv[i] = (i+1) * fact_inv[i+1] % MOD;

    for(int i=0;i<=N;i++) dp[i][0] = 1;
    for(int i=1;i<=N;i++){
        for(int j=1;j<=N;j++){
            dp[i][j] = dp[i-1][j];
            if(i < A || B < i) continue;

            lint c = comb(j, i);
            for(int k=1;i*k<=j;k++){
                if(C <= k && k <= D) {
                    dp[i][j] += c * dp[i-1][j-k*i] % MOD * fact_inv[k] % MOD;
                    dp[i][j] %= MOD;
                }
                c = c * comb(j-k*i, i) % MOD;
            }
        }
    }

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

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  double tmp;
  double ans;
  
  cin >> N;
  for (int i=0; i<N; i++){
    cin >> tmp;
    ans += 1 /tmp;
  }
  cout << 1 / ans << endl;
}


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

void solve()
{
    int a, b; cin >> a >> b;
    cout << (a > 12 ? b : a > 5 ? b / 2 : 0) << '\n';
}

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

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

int main()
{
	int n;
	cin>>n;
	int h[3][n];
	int dp[3][n];
	int i;
	for(i=0;i<n;i++)
	{
		cin>>h[0][i]>>h[1][i]>>h[2][i];
	}
	dp[0][0]=h[0][0];
	dp[1][0]=h[1][0];
	dp[2][0]=h[2][0];
	for(i=1;i<n;i++)
	{
		dp[0][i]=max(max(dp[0][i-1],dp[1][i-1]+h[0][i]),dp[2][i-1]+h[0][i]);
		dp[1][i]=max(max(dp[1][i-1],dp[0][i-1]+h[1][i]),dp[2][i-1]+h[1][i]);
		dp[2][i]=max(max(dp[2][i-1],dp[1][i-1]+h[2][i]),dp[0][i-1]+h[2][i]);
	}
	cout<<max(max(dp[2][n-1],dp[1][n-1]),dp[0][n-1]);
}

Measured memory_bytes: 2560
def resolve():
  n = int(input())
  p = list(map(int, input().split()))
  m = 1000000000
  ans = 0
  for i in range(n):
    if p[i] <= m:
      ans += 1
    m = min(m, p[i])

  print(ans)
  return

if __name__ == "__main__":
  resolve()


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

ll A[100005], B[100005];
pair<ll, pair<ll, ll> > x[100005];

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

    ll N;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> A[i] >> B[i];
        x[i] = make_pair(A[i]+B[i], make_pair(A[i], B[i]));
    }
    sort(x, x+N);
    reverse(x, x+N);

    ll ta = 0;
    ll ao = 0;
    for(int i=0; i<N; i++){
        if(i%2 == 0) ta += x[i].second.first;
        else ao += x[i].second.second;
    }
    //cout << ta << " " << ao << endl;
    cout << ta-ao << endl;
}


Measured memory_bytes: 4224
/***
        ***Fresher***
    Md Mahfujur Rahman Khan
    Dept. of CSE
    CSE-28 Batch
    JU-48 Batch
    Jahangirnagar University

***/
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<queue>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<iomanip>
#include<functional>
#include<set>
#include<map>
#include<climits>
#include<numeric>
#include<utility>
using namespace std;
#define V_ vector
#define Q_ queue
#define S_ set
#define ST_ stack
#define M_ map
#define DQ_ deque
/***PAIR***/
#define pii pair<ll,ll>
#define pci pair<char,ll>
#define psi pair<string, ll>
#define pis pair<ll,string>
#define pic pair<ll, char>
/***MAP***/
#define mii map<ll,ll>
#define msi map<string, ll>
#define mis map<ll, string>
#define mib map<ll,bool>
#define msb map<string,bool>
#define mci map<char, ll>
/***VECTOR***/
#define vi vector<ll>
#define vs vector<string>
/***ITERASTORS***/
#define ivi vector<ll> :: iterator
#define ivs vector<string> :: iterator
#define imii map<ll,ll> :: iterator
#define imsi map<string,ll> :: iterator
#define imis map<ll, string> :: iterator
#define imib map<ll, bool> :: iterator
#define imsb map<string, bool> :: iterator
#define imci map<char, ll> :: iterator
/*** FAST ***/
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/***FUNCTIONS AND MACROS***/
#define F first
#define S second
#define M_P(x, y) make_pair(x, y)
#define PB(x) push_back(x)
#define PP(x) push(x)
#define RSZ(n) resize(n)
#define POB pop_back()
#define P_ pop()
#define CL_ clear()
#define LEN_ length()
#define SZ_ size()
#define CNT(x) count(x)
#define FF first.first
#define FS first.second
#define SF second.first
#define SS second.second
#define B_ begin()
#define E_ end()
#define F_ front()
#define t_ top()
#define IN_ insert
#define ER_  erase
#define GT(x) getline(cin , x)
#define NL_   "\n"
#define SP_ " "
#define R_0 return 0
#define R_ return

#define ul unsigned long long int
#define ll long long int
/***
//prime fact
#define most_prime_loop 1001
#define most_prime_number 2000010
#define prime_MAX_arr 2000010/2
ll PRIME[2000010];
void seive()
{
    PRIME[0] = 0;
    for(auto &x: PRIME )
        x = 1;
    for(ll i= 3; i <= most_prime_loop; i+=2)
    {
        for(ll j = i*i; j <= most_prime_number; j+=2*i)
            PRIME[j/2] = 0;
    }
}
***/

#define fr(i, n) for( ll i = 0; i < n; i++)
#define fe(x, n) for( ll i = x; i <= n; i++)
#define fa(x,a)    for(auto &x : a)

#define pi acos(-1)

#define SR(x) sqrt(x)
#define IC   (ll)

const ll  inf = 2000000;
ll i=0, T=0, N=0, tc =0, t= 0;
ll n=0, k=0;
string s;
bool palin(ll a, ll b)
{
    a--;
    b--;
    while(a<=b)
    {
        if(s[a++]!=s[b--]) return 0;
    }
    return 1;
}
int main()
{
      cin >> s;
      if(s.compare("AAA")==0 || s.compare("BBB")==0) cout <<"No";
        else cout <<"Yes";
      R_0;
}



Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>
using namespace std;
int main(){
	double x,q;
	
	while(cin>>q){
		if(q==-1)break;
		
		x=q/2;
		
		while(fabs( x*x*x-q ) >= 0.00001f * q){
			x = x - (x*x*x-q)/(3*x*x);
		}
		
		cout << setprecision(10) << x << endl;
	}
}

Measured memory_bytes: 1276
import collections
n=int(input())
p=input()
ll=[int(n) for n in p.split()]
x=collections.Counter(ll)
y=list(set(ll))
y.sort()
n=len(y)
c=0
for i in range(n-2):
    for l in range(i+1,n-1):
        for j in range(l+1,n):
            if y[i]+y[l]>y[j]:
                c+=x[y[i]]*x[y[l]]*x[y[j]]
print(c)

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

#ifdef NON_SUBMIT
#define TEST(n) (n)
#define tout cerr
#else
#define TEST(n) ((void)0)
#define tout cin
#endif

using namespace std;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	TEST(freopen("input.txt","r",stdin));
	TEST(freopen("output.txt","w",stdout));
	TEST(freopen("debug.txt","w",stderr));
	long long X;
	__int128 c=100;
	cin>>X;
	for(int i=1;;i++) {
		c=c*101/100;
		if(c>=X) {
			cout<<i<<'\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3648
def run(x, y):
    '''
    '''
    for i in range(x + 1): # turtle
        if y == 2 * i + 4 * (x - i):
            print('Yes')
            return
    print('No')



if __name__ == '__main__':
    x, y = list(map(int, input().split()))
    run(x, y)

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

using namespace std;

#define MOD 1000000007
#define N 100005
#define M 30
#define ll long long 
#define ld long double
#define pb push_back
#define ff first
#define ss second

vector <int> g[N];
ll dp[N][2];

void dfs(int node, int par){
	dp[node][0] = 1;
	dp[node][1] = 1;
	for(auto it : g[node]){
		if(it != par){
			dfs(it, node);
			dp[node][0] = (dp[node][0] * (dp[it][0] + dp[it][1]) % MOD) % MOD;
			dp[node][1] = (dp[node][1] * dp[it][0]) % MOD;
		}
	}
}

int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n; cin>>n;
	int m, x, y, i;
	m = n-1;
	while(m--){
		cin>>x>>y;
		g[x].pb(y);
		g[y].pb(x);
	}
	dfs(1, -1);
	ll ans = (dp[1][0] + dp[1][1]) % MOD;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 14208
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

ll fact(ll x) {
	if (x == 1){
		return 1;
	}
	else{
		return (x* fact(x- 1)) % mod;
	}
}



int main(){
	ll n,m;
	cin >> n >> m;
	ll ans = 0;
	
	if(abs(n - m) > 1){
		ans = 0;
	}
	else if(abs(n - m) == 0){
		ans = (fact(n) * fact(m) * 2) % mod;
	}
	else{
		ans = (fact(n) * fact(m)) % mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
function Main (input) {
  input = input.split("\n");
  var N = parseInt(input[0], 10);
  input.shift();
  input.pop();
  var ans = 0;
  input = input.map(inp => inp.split(" ").map(Number));
  for (var i of input) {
    ans += i[1] - i[0] + 1;
  }
  console.log(ans);
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7844
#define rep(i, n) for (int i = 0; i < (n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MOD = 1000000007;
// MAX int 2,147,483,647
// MAX O(n) 10^18

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    // 図形から
    int dx = x2 - x1;
    int dy = y2 - y1;
    int x3 = x2 - dy;
    int y3 = y2 + dx;
    int x4 = x3 - dx;
    int y4 = y3 - dy;

    cout << x3 << " " << y3 << " "  << x4 << " "  << y4 << endl;

    return 0;
}


Measured memory_bytes: 3604
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]
C = [[0 for i in range(l)] for j in range(n)]
for i in range(n):
    for j in range(l):
        for k in range(m):
            C[i][j] += A[i][k]*B[k][j]
for i in range(n):
    print(" ".join(map(str, C[i])))



Measured memory_bytes: 6892
#include <cstdio>
using namespace std;
int main(){
    int N,A[200];
    int ans=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&A[i]);
        if(A[i]%2==0){
            A[i] /= 2;
            if(i==N-1){
                ans++;
                i = -1;
            }
        }
        else{
            break;
        } 
    }
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000

int count;

void merge(int A[], int left, int mid, int right){
  int i, j , k, n1, n2;
  int L[MAX/2+2], R[MAX/2+2];
 
  n1 = mid - left;
  n2 = right - mid;

  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(k=left; k<right; k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    } else{ 
      A[k] = R[j];
      j = j + 1;
    }
  }

}

void mergeSort(int A[], int left,int  right){
  int mid=0;

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

int main(){
  int i, n;
  int A[MAX];

  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  mergeSort(A, 0, n);
  
  for(i=0; i<n; i++){
    printf("%d", A[i]);
    if(i==n-1) break;
    printf(" ");
  }
  printf("\n");
  printf("%d\n", count);
  
  return 0;
}

Measured memory_bytes: 4508
/**
 * code generated by Junayed Kader
 * Student of Computer Science
 * @author
 */

#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

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


typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef double dl;

#define endl '\n'
#define PB push_back
#define F first
#define S second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define sz(x) (int)x.size()
#define test int tc; cin>>tc; while(tc--)
#define forn(i,n) for(i=0;i<n;i++)
#define rforn(i,n) for(i=n-1;i>=0;i--)

const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

#define mem(a,b) memset(a, b, sizeof(a) )
#define sqr(a) ((a) * (a))
#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define fraction() cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);
#define file() freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu ()
{
    cerr << endl;
}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest)
{
    cerr << arg << ' ';
    faltu(rest...);
}

ll gcd ( ll a, ll b )
{
    return __gcd ( a, b );
}
ll lcm ( ll a, ll b )
{
    return a * ( b / gcd ( a, b ) );
}
ll max(ll a,ll b)
{
    return a>b?a:b;
}
ll min(ll a,ll b)
{
    return a<b?a:b;
}
const int mx = 1e5+123;
int dp[mx], n, stone[mx];
int solve (int i )
{
    if(i==n) return 0;
    if(dp[i]!=-1) return dp[i];

    int  ret2 = inf, ret1;
    ret1 = abs(stone[i]-stone[i+1])+solve(i+1);
    if(i+2<=n) ret2 =  abs(stone[i]-stone[i+2])+solve(i+2);
    dp[i] =min(ret1, ret2);
    return dp[i];

}
void _case()
{


   cin>>n;
   for(int i = 1; i<=n;i++)
   {
       cin>>stone[i];
   }
   mem(dp, -1);
   cout<<solve(1)<<endl;


}
int main()
{
    optimize();
     _case();

    return 0;
}


Measured memory_bytes: 12140
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n;
    cin >> n;
    int b[n+1];
    REP(i,n-1) cin >> b[i+1];
    b[0]=b[1];b[n]=b[n-1];
    int ans=0;
    REP(i,n)ans+=min(b[i],b[i+1]);
    cout << ans;
    return 0;
}

Measured memory_bytes: 3636
use std::io::{stdin, Read};
use std::str::FromStr;

// https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

#[allow(dead_code)]
fn main() {
    let n = read::<usize>();
    let mut a = vec![0; n + 2];
    for i in 0..n {
        a[i + 1] = read::<i64>()
    }
    let mut s = 0;
    for i in 0..n + 1 {
        s += (a[i + 1] - a[i]).abs()
    }
    for i in 0..n {
        println!(
            "{}",
            s + (a[i + 2] - a[i]).abs() - (a[i + 2] - a[i + 1]).abs() - (a[i + 1] - a[i]).abs()
        )
    }
}


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

int main(){
	long times;
	scanf(" %ld", &times);
	for(long t=0; t<times; ++t){
		int x, y, w, h;
		int n;
		scanf(" %d %d %d %d", &x, &y, &w, &h);
		scanf(" %d", &n);
		
		int ans=0;
		for(int i=0; i<n; ++i){
			int cx, cy;
			scanf(" %d %d", &cx, &cy);	
			
			if(x<=cx && cx<=x+w && y<=cy && cy<=y+h) ans++;
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 1188
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define mod 1000000007
using ll=long long;
const int INF=1000000000;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0},dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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(b<a){a=b;return true;}return false;}

struct IOSetup{
    IOSetup(){
        cin.tie(0);
        ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(12);
    }
} iosetup;
 
template<typename T1,typename T2>
ostream &operator<<(ostream &os,const pair<T1,T2>&p){
    os<<p.first<<" "<<p.second;
    return os;
}
 
template<typename T>
ostream &operator<<(ostream &os,const vector<T>&v){
    for(int i=0;i<(int)v.size();i++) os<<v[i]<<(i+1==(int)v.size()?"":" ");
    return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is,pair<T1,T2>&p){
    is>>p.first>>p.second;
    return is;
}

template<typename T>
istream &operator>>(istream &is,vector<T>&v){
    for(T &x:v)is>>x;
    return is;
}

struct UnionFind{
    vector<int> par,siz;
    int con;
    UnionFind(int n){
        par.resize(n);
        iota(begin(par),end(par),0);
        siz.assign(n,1);
    }
    int root(int x){
        return (par[x]==x?x:(par[x]=root(par[x])));
    }
    bool sameroot(int x,int y){
        return root(x)==root(y);
    }
    bool unite(int x,int y){
        x=root(x);y=root(y);
        if(x==y) return false;
        if(siz[x]<siz[y])swap(x,y);
        siz[x]+=siz[y];
        par[y]=x;
        con--;
        return true;
    }
    int size(int x){
        return siz[root(x)];
    }
};

signed main(){
    int n,m;cin>>n>>m;
    UnionFind uf(n);
    rep(i,m){
        int u,v;cin>>u>>v;u--,v--;
        uf.unite(u,v);
    }

    int ans=1;
    rep(i,n){
        chmax(ans,uf.size(i));
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 4744
n = int(input())
as_ = list(int(i) for i in input().split())


def output_history(history):
    print(len(history))
    for h in history:
        print('{0} {1}'.format(h[0], h[1]))


def distribute(list_, hstr, x, y):
    list_[y] += list_[x]
    hstr.append((x + 1, y + 1))  # Fortran式
    return list_, hstr


history = []

# 正負どちらかに寄せる
# MaxMin大きく外れている方に寄せる
if abs(max(as_)) > abs(min(as_)):
    # 正に寄せる
    # 正のMaxを負の要素に繰り返し分配
    x = as_.index(max(as_))
    while not all([a >= 0 for a in as_]):
        for y, a in enumerate(as_):
            if a < 0:
                as_, history = distribute(as_, history, x, y)

    # 前から順に走査し反転箇所で前の要素を後ろの要素に足し合わせる
    for x in range(len(as_) - 1):
        # 反転箇所で
        if as_[x + 1] - as_[x] < 0:
            as_, history = distribute(as_, history, x, x + 1)

else:
    # 負に寄せる
    # 負のMaxを正の要素に繰り返し分配
    x = as_.index(min(as_))
    while not all([a <= 0 for a in as_]):
        for y, a in enumerate(as_):
            if a > 0:
                as_, history = distribute(as_, history, x, y)

    # 後ろから順に走査し反転箇所で後ろの要素を前の要素に足し合わせる
    for x in reversed(range(len(as_) - 1)):
        # 反転箇所で
        if as_[x + 1] - as_[x] < 0:
            as_, history = distribute(as_, history, x + 1, x)

output_history(history)


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

typedef long long ll;

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

    int N, D;

    cin >> N >> D;

    vector<vector<int> > X(N, vector<int>(D));

    for(int i = 0; i < N; i++) {
        for(int j = 0; j < D; j++) {
            cin >> X[i][j];
        }
    }

    int count = 0;

    for(int i = 0; i < N - 1; i++) {
        for(int j = i + 1; j < N; j++) {
            int c = 0;
            for(int k = 0; k < D; k++) {
                c += pow(abs(X[i][k] - X[j][k]), 2);
            }
            int x = static_cast<int> (sqrt(c));
            if(x * x == c) {
                //cout << x << endl;
                count++;
            }
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 256
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math") 
///#pragma GCC target("avx2")
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <cmath>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <iomanip>
#include <cassert>
#include <functional>
#include <ctime>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <climits>
#include <numeric>

using namespace std;
#define open_streams ifstream fin("olympiad.in");ofstream fout("olympiad.out")
#define close_streams fin.close();fout.close()
#define speed cout.tie(0);cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long
#define ull unsigned long long
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define UNIQ(a) a.resize(unique(all(a)) - a.begin())
#define eps 1e-6
//const double PI = M_PI;
const int INF = INT_MAX;
const ll limit = 1LL * 4e18;
const int MOD = 1e9 + 711;
const int MOD2 = 1e9 + 933;
//---------------------------------------------------------------------------
const int mod = 1e9 + 7;
const int maxn = 1e6 + 100;






signed main() {
	speed;
	int ans = -1,a,b;
	cin >> a >> b;
	for (int i = 1; i < maxn; ++i) {
		if (8 * i / 100 == a && i / 10 == b) {
			ans = i;
			break;
		}
	}
	cout << ans;
	return 0;
}

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

using ll = long long;
const int INF = 1e9+100;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	
	string s;
	cin>>s;
	if (s.back() == 's'){
		cout<<s+"es\n";
	}else{
		cout<<s+"s\n";
	}
	return 0;
}

Measured memory_bytes: 3604
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
//#include<bits/stdc++.h>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int mod = 1e9 + 7;
const int IMAX = 2000010;
constexpr ll modpow(ll A, ll B) {
	ll kotae = 1;
	while (B > 0) {
		if (B & 1) kotae = kotae * A % mod;
		A = A * A % mod;
		B >>= 1;
	}
	return kotae;
}
class unko {
public:
	int inv[IMAX + 1];
	unko() : inv() {
		inv[0] = 1;
		inv[1] = 1;
		rep1(i, IMAX - 1) inv[i + 1] = ll(inv[i]) * i % mod;
		ll tmp = modpow(ll(inv[IMAX]) * IMAX % mod, mod - 2);
		for (int i = IMAX; i > 0; i--) {
			inv[i] = inv[i] * tmp % mod;
			tmp = tmp * i % mod;
		}
	}
} f;

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


	int K;
	cin >> K;

	string S;
	cin >> S;

	int M = S.size();

	const ll are = 423076927;
	ll tmp = modpow(26, K);
	ll kotae = 0;
	rep(i, K + 1) {
		tmp = tmp * f.inv[i] % mod;
		kotae += tmp;
		tmp = tmp * (M + i) % mod;
		tmp = tmp * are % mod;
	}

	co(kotae % mod);

	Would you please return 0;
}

Measured memory_bytes: 12088
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int H;
    int W;
    cin >> H >> W;
    vector<vector<char>> s(H + 2, vector<char>(W + 2, '.'));
    REP(i, H) {
        REP(j, W) { cin >> s[i][j]; }
    }
    //孤立しているマスを探す
    REP(i, H - 1) {
        REP(j, W - 1) {
            if(s[i][j] == '.') {
                continue;
            }
            int cnt = 0;
            if(s[i + 0][j + 1] == '#') {
                cnt++;
            }
            if(s[i + 1][j + 0] == '#') {
                cnt++;
            }
            if(j != 0 and s[i + 0][j - 1] == '#') {
                cnt++;
            }
            if(i != 0 and s[i - 1][j] == '#') {
                cnt++;
            }
            if(cnt == 0) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, k = map(int, input().split())

    res = 0
    for i in range(1, n + 1):
        cnt = 0
        while i < k:
            i *= 2
            cnt += 1
        p = (1 / n) * pow(1 / 2, cnt)
        res += p
    print(res)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 39152