akhauriyash/Code-Regression huggingface dataset:
use std::cmp::max;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let a: u64 = read();
    let b: u64 = read();
    let k: u64 = read();

    let mut count = 0;
    for i in (1..max(a, b) + 1).rev() {
        if a % i == 0 && b % i == 0 {
            count += 1;
        }
        if count == k {
            println!("{}", i);
            return;
        }
    }
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|b| b.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}


Measured memory_bytes: 4352
N,K = map(int,input().split())
A=[]
ans = 0
for i in range(K):
    d = int(input())
    lsA = list(map(int,input().split()))
    for j in range(d):
        A.append(lsA[j])
for i in range(1,N+1):
    if i not in A:
        ans += 1
print(ans)


Measured memory_bytes: 68612
#include <cstdio>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <queue>
#include <functional>

using namespace std;
static const int INF = 1e8;
typedef pair<int, int> P;


void solve()
{
	string s;
	cin >> s;
	int start = 0;
	int end = s.size() - 1;
	while (s[start] != 'A')
	{
		++start;
	}
	while (s[end] != 'Z')
	{
		--end;
	}
	cout << end - start + 1 << endl;
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define sort(A) sort(A.begin(),A.end())
#define reverse(A) reverse(A.begin(),A.end())
#define vecmin(A) *min_element(A.begin(),A.end())
#define vecmax(A) *max_element(A.begin(),A.end())
typedef long long ll;

int main(){
  int n;
  cin >> n;
  vector<int> L(n);
  rep(i,n) cin >> L[i];
  sort(L);
  int ans = 0;
  rep(i,n-1){
    for(int j=i+1;j<n;j++){
      int ng = n;
      int ok = j;
      while(abs(ng-ok)>1){
        int mid = (ok+ng)/2;
        if(L[mid] >= L[i]+L[j]) ng = mid;
        else ok = mid;
      }
      ans += ok - j;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using ii=pair<ll,ll>;
using vi=vector<ll>;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define INF (ll)1e18
#define all(x) (x).begin(),(x).end()
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll n;cin>>n;
    ll a[n-1];
    for(int i=0;i<n-1;i++){
        cin>>a[i];
    }
    ll b[n];mset(b);
    b[0]=a[0];b[n-1]=a[n-2];
    for(int i=n-2;i>0;i--){
        b[i]=min(a[i],a[i-1]);
    }
    ll sum=0;
    for(int i=0;i<n;i++)sum+=b[i];
    cout<<sum<<"\n";
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int N,K;
int c[2<<17];
main()
{
  cin>>N>>K;
  for(int i=0;i<N;i++)
  {
    int A;cin>>A;
    c[A-1]++;
  }
  sort(c,c+N);
  reverse(c,c+N);
  for(int i=0;i<K;i++)N-=c[i];
  cout<<N<<endl;
}

Measured memory_bytes: 1024
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

struct edge
{
    int s,t;
    bool ju;
};

struct graph{
    vector<edge> ed;
    vector<vector<P>> da;
    vector<bool> node;
    vector<bool> co;

    graph(int n, int m){
        ed = vector<edge>(m);
        da = vector<vector<P>> (n,vector<P>(0));
        node = vector<bool>(n);
        co = vector<bool> (n);
    }
};


void dfs(graph &gh, int now, int fo, int k){
    gh.node[now] = true;
    rip(i, gh.da[now].size(), 0){
        P nowl = gh.da[now][i];
        if(gh.node[nowl.first]){
            continue;
        }
        if(gh.co[now]){
            gh.ed[nowl.second].ju = !gh.ed[nowl.second].ju;
            gh.co[nowl.first] = !gh.co[nowl.first];
            gh.co[now] = !gh.co[now];
        }
        dfs(gh, nowl.first, now, nowl.second);
    }
    if (gh.co[now]){
        gh.co[now] = !gh.co[now];
        gh.co[fo] = !gh.co[fo];
        gh.ed[k].ju = !gh.ed[k].ju;
    }
    return;
}


int main(){
    int n, m; cin >> n >> m;
    graph gh(n, m);
    rip(i,m,0){
        cin >> gh.ed[i].s >> gh.ed[i].t;
        gh.ed[i].s--;gh.ed[i].t--;
        gh.co[gh.ed[i].s] = !gh.co[gh.ed[i].s];
        gh.da[gh.ed[i].s].push_back(mpa(gh.ed[i].t, i));
        gh.da[gh.ed[i].t].push_back(mpa(gh.ed[i].s, i));
    }
    if(m % 2){
        cout << -1 << endl;
    }
    else{
        dfs(gh, 0, -1, -1);
        rip(i,m,0){
            if(gh.ed[i].ju){
                swap(gh.ed[i].s, gh.ed[i].t);
            }
            printf("%d %d\n", gh.ed[i].s + 1, gh.ed[i].t + 1);
        }
    }
    return 0;
}

Measured memory_bytes: 15872
///----------------------///
///---Code Written by----///
///-----Al-Shahreyaj-----///
///----------------------///

///PRAGMA
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC optimize("unroll-loops")

#include<bits/stdc++.h>

///PBDS
//#include<ext/pb_ds/assoc_container.hpp>
//#include<ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;

//PBDS_SET
//Index of Value - .order_of_key()
//Value at Index - .find_by_order()
//typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_set; 
//typedef tree<int, null_type, lessorequal<int>, rb_tree_tag,tree_order_statistics_node_update> pbds_multiset; 

#define mem(a, x) memset(a, x, sizeof(a))
#define MP make_air
#define inf 1e8
#define INF 1e18
#define CP(x) printf("Case %d: ", x);
#define unq(v) v.erase(unique(all(v)),v.end())
#define one(x) __builtin_popcount(x)
#define onel(x) __builtin_popcountll(x)
#define ll long long
#define ld long double
#define LMX LLONG_MAX
#define fixpre(x) cout << fixed << setprecision(x)
#define endl "\n"
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int,int>
#define pil pair<int,ll>
#define pll pair<ll,ll>
#define matrix vector<vector<ll> >
#define F first
#define S second
#define pb push_back
#define pq priority_queue
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define INT ini()
#define LONG inl()
#define M 1000000007
#define N 100005



int main()
{
	int n;
	cin >> n;
	__int128 ans = 1;
	while(n--)
	{
		ll x;
		cin >> x;
		if(x == 0) ans = 0;
		if(ans == -1 || ans == 0) continue;
		__int128 y = (__int128)x;
		ans *= y;
		if(ans > (__int128)1e18)
		{
			ans = -1;
		}
	}
	cout << (ll)ans << endl;
	return 0;
}





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

#define rep(i,n) for(i = 0;i < n;++i)
#define all(v) v.begin(), v.end()
using ll = long long;

int main()
{
    ll i,j,k;
    while(true){
        ll n,m;
        cin >> n >> m;
        if(n == 0 && m == 0) return 0;
        vector<ll> c(m);
        vector<ll> x(n);
        for(i = 0;i < m;++i){
            cin >> c.at(i);
        }
        for(i = 0;i < n;++i){
            cin >> x.at(i);
        }
        vector<vector<ll>> dp(n+1,vector<ll>(256,1e9));
        dp.at(0).at(128) = 0;
        for(i = 1;i <= n;++i){
            rep(j,256){
                rep(k,m){
                    ll tmp = j + c.at(k);
                    if(j + c.at(k) < 0) tmp = 0;
                    else if(j + c.at(k) > 255) tmp = 255;
                    dp.at(i).at(tmp) = min(dp.at(i).at(tmp), dp.at(i-1).at(j) + (tmp - x.at(i-1))*(tmp - x.at(i-1)));
                }
            }
        }
        ll ans = 1e9;
        for(i = 0;i < 256;++i){
            ans = min(ans, dp.at(n).at(i));
        }
        cout << ans << endl;
    }
    
    return 0;
}


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

int main(){

int A, B;
  cin >> A >> B;
  
  if((A + B <= 16) && (A < 9) && (B < 9)) cout << "Yay!" << endl;
  else cout << ":(" << endl;
  
  return 0;
  
}

Measured memory_bytes: 256
import numpy as np

a, b, x = map(int, input().split(' '))
theta = 0
if x <= a ** 2 * b / 2:
    theta = np.arctan((a * b ** 2) / (2 * x))
else:
    theta = np.arctan(2 * (a ** 2 * b - x) / (a ** 3))
print(np.rad2deg(theta))

Measured memory_bytes: 12484
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <string>
#include <sstream>
#include <numeric>
#include <ios> // std::left, std::right

typedef long long int ll;
typedef unsigned long long int ull;

using namespace std;

int main()
{
  int n, m;
  cin >> n >> m;
  vector<int> x(n + 1), y(m + 1);

  cin >> x[0] >> y[0];

  for (int i = 0; i < n; i++)
  {
    cin >> x[i + 1];
  }
  for (int i = 0; i < m; i++)
  {
    cin >> y[i + 1];
  }

  if (*max_element(x.begin(), x.end()) < *min_element(y.begin(), y.end()))
  {
    cout << "No War" << endl;
  }
  else
  {
    cout << "War" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var s = next();
  var sLen = s.length;
  var K = myconv(next(),1);
  var set = new Set();
  for(var i = 0; i < K; i++){
    for(var j = 0; j < sLen - i; j++){
      set.add(s.slice(j, j + i + 1));
    }
  }
  var strings = Array.from(set);
  strings.sort();
  myout(strings[K - 1]);
}

Measured memory_bytes: 11428
#include<iostream>
#include<vector>
using namespace std;
int n, q;
vector<int> A;
vector<bool> isE(2001);
  
int main()
{
    cin>>n;
    int num;
    for( int i=0; i<n; i++ ) {
        cin>>num;
        A.push_back( num );
        for( int j=2000-num; 0<j; j-- ) {
            if( isE.at( j ) ) {
                isE.at( j+num ) = true;
            }
        }
        isE.at( num ) = true;
    }
    cin>>q;
    for( int i=0; i<q; i++ ) {
        cin>>num;
        if( isE.at( num ) ) {
            cout<<"yes"<<'\n';          
        } else {
            cout<<"no"<<'\n';
        }
    }
    return 0;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;

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;
}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

int main() {
  int N, K;
  cin >> N >> K;

  vector<int> A(N);
  rep(i, N) cin >> A[i];

  ll sum = 0;
  rep(i, N) { sum += A[i]; }
  vector<ll> div = divisor(sum);
  sort(all(div), greater<int>());

  rep(i, div.size()) {
    ll cand = div[i];
    vector<ll> diff(N);
    rep(j, N) { diff[j] = A[j] % cand; }
    sort(all(diff));

    ll operation_num;

    repp(j, 0, N - 1) {
      ll l = 0, r = 0;
      repp(li, 0, j) { l += diff[li]; }
      repp(ri, j + 1, N - 1) { r += (cand - diff[ri]); }

      if (l == r) {
        operation_num = l;
        break;
      }
    }

    if (operation_num <= K) {
      cout << cand << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops") 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define fr(i,a,b) for(int i = a ; i <= b ; ++i)
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()
#define pb push_back
#define fst first
#define snd second
using namespace __gnu_pbds;
using ordered_set =
 tree<int, null_type,less<int>,
 rb_tree_tag,tree_order_statistics_node_update>;
//find_by_order(k):returns iterator to kth element starting from 0
//order_of_key(k):returns count of elements strictly smaller than k
typedef long long ll;typedef pair<int, int> pii;
typedef vector<int> vi;typedef long double ld;
template<class T>
using min_heap = priority_queue<T,vector<T>,greater<T>>; 
template<typename T> T gcd(T a, T b){return(b?__gcd(a,b):a);}
template<typename T> T lcm(T a, T b){return(a*(b/gcd(a,b)));}
template<typename T> 
void remdup(vector<T>& v) {
	sort(all(v)); v.erase(unique(all(v)), v.end());
}
template<typename T> void re(vector<T> &v) {trav(i,v) cin >> i;}
void unsyncIO() { ios_base::sync_with_stdio(0); cin.tie(0); }
#ifdef np
#include "C:\Users\navodit\Desktop\mycodes\pr.h"
#else
#define trace(...)
#endif

#define MOD 1000000007  


ld powr(double a, int b){
	ld rt = 1. ; 
	while(b){
		if(b&1) rt*=a;
		a*=a;
		b>>=1;
	}
	return rt;
}


void solve(){
	int n , k ;
	cin >> n >> k; 
	vi pwrs;
	for(int i =1 ; i<=n ;i++ ){
		int tmp  = i ;
		int cnt = 0 ; 
		while(tmp<k){
			tmp<<=1;
			cnt++;
		}
		pwrs.pb(cnt);
	}
	ld ans = 0.;
	trav(i,pwrs){
		ans+=(powr(0.5,i));
	}
	
	ans*=(ld)(1/(ld)n);
	cout << fixed << setprecision(12) << ans << endl;
}

signed main() {
	unsyncIO();
	int tt =1 ;
	// cin >> tt;
	rep(i,0,tt) solve();












#ifdef np
	cout <<endl<<endl<< "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}


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

int main(){
	int n,m;
	cin >> n >> m;
	int na,nb;
	bool a[n+1],b[n+1],flag = false;

	for(int i=1;i<n;i++){
		a[i] = false;
		b[i] = false;
	}

	for(int i=0;i<m;i++){
		cin >> na >> nb;
		if(na == 1) a[nb] = true;
		else if (nb == n) b[na] = true;
	}

	for(int i=1;i<n;i++){
		if(a[i] && b[i]){
			flag = true;
			break;
		}
	}

	if(flag == true) cout << "POSSIBLE";
	else cout << "IMPOSSIBLE";

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int a,b;
int ans;
bool ok(int n)
{
	if (n%10==n/10000 && n/10%10==n/1000%10)
		return true;
	else
		return false;
}
int main()
{
	cin>>a>>b;
	for (int i=a;i<=b;i++)
	{
		if (ok(i))
			ans++;
	}
	cout<<ans;
	//system("pause");
    return 0;
}

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

using namespace std;

int n,ans;
int a[4];

int main(){
	while(cin >> n){
		ans = 0;
		for(a[0]=0;a[0]<10;a[0]++){
			for(a[1]=0;a[1]<10;a[1]++){
				for(a[2]=0;a[2]<10;a[2]++){
					for(a[3]=0;a[3]<10;a[3]++){
						if(a[0]+a[1]+a[2]+a[3] == n){
							ans += 1;
							break;
						}
					}
				}
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long int lli;
const int MAX = 1e6+1;
const lli mod = 1e9+7;

int main(){
	vector<bool> prime(MAX, true);
	prime[0] = prime[1] = false;
	for(int i=2; i*i<MAX; i++){
		if(prime[i]){
			for(int j=i*2; j<MAX; j+=i){
				prime[j] = false;
			}
		}
	}
	
	int n;
	cin >> n;
	vector<int> q(n+1, 0);
	for(int i=1; i<=n; i++){
		cin >> q[i];
	}
	
	vector<vector<lli> > dp(n+1, vector<lli>(2, 0));
	dp[0][0] = 1;
	for(int i=0; i<n; i++){
		if(!prime[q[i+1]]) continue;
		for(int j=0; j<2; j++){
			if(dp[i][j] != 0){
				if(q[i-j] < q[i+1]){
					dp[i+1][0] = (dp[i+1][0] +dp[i][j])%mod;
						if(i+2 <= n){
						dp[i+2][1] = (dp[i+2][1] +dp[i][j])%mod;
					}
				}
			}
		}
	}
	cout << (dp[n][0] +dp[n][1])%mod << endl;
	return 0;
}


Measured memory_bytes: 8952
#include <iostream>
#include <math.h>
#include <algorithm>
using namespace std;

int a = 0, b = 0, ans = -1;

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

	for (int i = 1; i <= 10000; i++) {
		if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
			ans = i;
			break;
		}
	}

	cout << ans;

	return 0;
}


Measured memory_bytes: 256
from collections import deque
d = deque()
n = int(input())
for i in range(n):
    s = input()
    if s == "deleteFirst":
        d.popleft()
    elif s == "deleteLast":
        d.pop()
    elif s[:6] == "insert":
        d.appendleft(int(s[7:]))
    else:
        delkey = int(s[7:])
        if delkey in d:
            d.remove(delkey)

print(" ".join(map(str,d)))


Measured memory_bytes: 45940
import sys


# \n
def input():
    return sys.stdin.readline().rstrip()


def main():
    N = int(input())
    S = list(input())



    ans =0
    for k in range(N+1,0,-1):
        i=0
        count =0
        while i<N-k:
            if S[i]==S[i+k]:
                count+=1
                ans =max(ans,min(count,k))
            else:
                count=0
            if ans==k:
                break

            i+=1

    print(ans)









if __name__ == "__main__":
    main()


Measured memory_bytes: 73600
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int[][] a = new int[3][3];
		int[][] c = new int[3][3];

		for (int i=0; i<3; i++ ) {
		for (int j=0; j<3; j++ ) {
			a[i][j] = sc.nextInt();
		}
		}

		int n = sc.nextInt();
		for (int k=0; k<n; k++ ) {
			int b = sc.nextInt();
			for (int i=0; i<3; i++ ) {
			for (int j=0; j<3; j++ ) {
				if ( a[i][j] == b ) {
					c[i][j] = 1;
				}
			}
			}
		}


		if ( ( c[0][0] == 1 && c[0][1] == 1 && c[0][2] == 1 )
		  || ( c[1][0] == 1 && c[1][1] == 1 && c[1][2] == 1 )
		  || ( c[2][0] == 1 && c[2][1] == 1 && c[2][2] == 1 )
		  || ( c[0][0] == 1 && c[1][0] == 1 && c[2][0] == 1 )
		  || ( c[0][1] == 1 && c[1][1] == 1 && c[2][1] == 1 )
		  || ( c[0][2] == 1 && c[1][2] == 1 && c[2][2] == 1 )
		  || ( c[0][0] == 1 && c[1][1] == 1 && c[2][2] == 1 )
		  || ( c[0][2] == 1 && c[1][1] == 1 && c[2][0] == 1 ) ) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#ifdef tabr
#include "library/debug.cpp"
#else
#define debug(...)
#endif

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int get_rand(int a, int b) {  // [a, b]
    return uniform_int_distribution<int>(a, b)(rng);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int d, n = 26;
    cin >> d;
    vector<int> c(n);
    vector<vector<int>> s(d, vector<int>(n));
    for (int i = 0; i < n; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < n; j++) {
            cin >> s[i][j];
        }
    }
    /*
    vector<int> t(d, -1);
    vector<int> last(n, -1);
    int res = 0;
    for (int i = 0; i < d; i++) {
        int z = -2e9;
        for (int k = 0; k < n; k++) {
            int y = 0;
            for (int j = 0; j < n; j++) {
                if (j == k) {
                    y += s[i][j];
                } else {
                    y -= (i - last[j]) * c[j];
                }
            }
            if (y > z) {
                z = y;
                t[i] = k;
            }
        }
        res += z;
        last[t[i]] = i;
        // cout << res << '\n';
        cout << t[i] + 1 << '\n';
    }
    */
    vector<int> t(d);
    int m;
    for (int i = 0; i < d; i++) {
        cin >> t[i];
        t[i]--;
    }
    cin >> m;
    while (m--) {
        int dd, qq;
        cin >> dd >> qq;
        dd--, qq--;
        t[dd] = qq;
        int res = 0;
        vector<int> last(n, -1);
        for (int i = 0; i < d; i++) {
            res += s[i][t[i]];
            int x = i - last[t[i]] - 1;
            res -= c[t[i]] * x * (x + 1) / 2;
            last[t[i]] = i;
        }
        for (int i = 0; i < n; i++) {
            int x = d - last[i] - 1;
            res -= c[i] * x * (x + 1) / 2;
        }
        cout << res << '\n';
    }
    return 0;
}

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

int main(){
    int A,B,C,D;
    scanf("%d %d %d %d",&A,&B,&C,&D);
    if(A+B>C+D){
        puts("Left");
    }else if(A+B==C+D){
        puts("Balanced");
    }else{
    puts("Right");
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    int n = s.length();
    int ans = 0;
    for(int i=0;i<(n+1)/2;++i) {
        if(s[i] != s[n-1-i]) ++ans;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
//#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#pragma GCC optimize("Ofast")
#pragma target("sse", "sse1")

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

int n;
string s, t;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("meetings.in", "r", stdin);
	//freopen("meetings.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> s >> t;
	for (int i = 0; i < s.length(); i++)
		cout << s[i] << t[i];




	return 0;
}

Measured memory_bytes: 256
N = int(input())
s = list(input())

l, r = [[0]*2 for _ in range(N+1)], [[0]*2 for _ in range(N+1)]
for i,j in enumerate(s, start=1):
    if j=="#":
        l[i][1] = l[i-1][1]
        l[i][0] = l[i-1][0] + 1
    else:
        l[i][0] = l[i-1][0]
        l[i][1] = l[i-1][1] + 1

for i,j in enumerate(s[::-1], start=1):
    if j=="#":
        r[N-i][1] = r[N-i+1][1]
        r[N-i][0] = r[N-i+1][0] + 1
    else:
        r[N-i][0] = r[N-i+1][0]
        r[N-i][1] = r[N-i+1][1] + 1

# black white
# .....#####
# 1111100000

ans = N
for i in range(N+1):
    ans = min(ans, l[i][0]+r[i][1])

print(ans)

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

using namespace std;

int main()
{
    std::string S;
    cin >> S;
    bool hit = true;
    for (int i = 0; i < S.size(); ++i)
    {
        char s = S.at(i);
        if (i % 2 == 0)
        {
            hit = (s == 'R') || (s == 'U') || (s == 'D');
        }
        else
        {
            hit = (s == 'L') || (s == 'U') || (s == 'D');
        }
        if (!hit) break;
    }
    cout << (hit ? "Yes" : "No") << endl;
    return 0;
}


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

int main() {
    int a,b;
    cin>>a>>b;
    if (a<=b) cout<<a<<endl;
    else cout<<a-1<<endl;
}


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

using namespace std;
using ll = long long;
using vl = vector<ll>;
using pll = pair<ll, ll>;

#define rep(i, n) for (ll i = 0, xxx_rep_end = (n); i < xxx_rep_end; ++i)
#define all(x) (x).begin(), (x).end()

template <class T1, class T2>
inline bool chmax(T1 &a, const T2 &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T1, class T2>
inline bool chmin(T1 &a, const T2 &b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

constexpr ll INF = 0x3f3f3f3f3f3f3f3fLL;
constexpr ll mod = 1000000007;

int main() {
    int S, W;
    cin >> S >> W;
    if (S <= W) {
        cout << "unsafe" << endl;
    } else {
        cout << "safe" << endl;
    }
}

Measured memory_bytes: 3588
from functools import reduce
N = int(input())
g = 10 ** 9 + 7


def mul(a, b):
  return (a * b) % g

d = []
DP = [None for _ in range(N+1)]
DP[0] = [0 for _ in range(N+1)]
ans = DP[0].copy()
for i in range(2, N+1):
  for j in (x for x in d if x * x <= N):
    if i % j == 0:
      DP[i] = DP[j].copy()
      for k in range(1, N+1):
          DP[i][k] += DP[i//j][k]
      break
  else:
    d.append(i)
    DP[i] = DP[0].copy()
    DP[i][i] = 1
  for k in range(1, N+1):
      ans[k] += DP[i][k]

print(reduce(mul, [x + 1 for x in ans[1:N+1]]))


Measured memory_bytes: 11364
def fizz_buzz(n):
    i = 1

    while i - 1 < n:
        if i % 3 == 0 or i % 5 == 0:
            yield 0
        else:
            yield i
        i += 1


if __name__ == '__main__':
    n = int(input())

    res = 0
    i = 0

    for num in fizz_buzz(n):
        res += num

    print(res)


Measured memory_bytes: 9172
def main():
    n = int(input())
    d_list = list(map(int, input().split()))

    ans = 0
    for i in range(n):
        for j in range(i+1, n, 1):
            ans += d_list[i] * d_list[j]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 39024
import math
n, a, b = map(int, input().strip().split())

modular = 1000000007

mod_value = pow(2, n, modular)
all_combination_modular = mod_value - 1 if mod_value != 0 else modular - 1

# print(all_combination_modular)

p = 1
q = 1
for i in range(a):
    p = p * (n - i) % modular
    q = q * (i + 1) % modular

mod_a = p * pow(q, modular - 2, modular) % modular

p = 1
q = 1
for i in range(b):
    p = p * (n - i) % modular
    q = q * (i + 1) % modular

mod_b = p * pow(q, modular - 2, modular) % modular

result = all_combination_modular - mod_a - mod_b

while True:
    if result < 0:
        result += modular
    else:
        break
print(result)


Measured memory_bytes: 3064
var obj = init();
Main();
function nextInt(){return myconv(next(),1);}
function nextStrArray(){return myconv(next(),2);}//半角スペース分割
function nextIntArray(){return myconv(next(),4);}//半角スペース + 数値化
function nextCharArray(){return myconv(next(),6);}//1文字分割
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myin(){return require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");}
function init(){
  var inputFile = myin();
  var returnObj = {
    "list" : inputFile, "index" : 0, "max" : inputFile.length,
    "hasNext" : function(){return (this.index < this.max);},
    "next" : function(){if(!this.hasNext()){return "";}else{var returnInput = this.list[this.index];this.index++;return returnInput;}}
  };
  return returnObj;
}
function myout(t){console.log(t);}//標準出力
function myerr(t){console.error(t);}//標準エラー出力
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す　1:数値へ変換
//2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字で分割  7:1文字で分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main(){
  var N = nextInt();
  var list = nextIntArray();
  for(var i = 0; i < N; i++){
    if(list[i] > (i + 1)){
      //x番目にxを超える値があってはならない
      myout(-1);
      return;
    }
  }
  var output = [];
  var count = 0;
  while(list.length > 0){
    var index = 0;
    for(var i = 0; i < list.length; i++){
      if(list[i] == i + 1){
        index = i;
      }
    }
    output.unshift(list[index]);
    list.splice(index,1);
  }
  
  myout(myconv(output,9));
}

Measured memory_bytes: 7500
package main

import "fmt"

func main() {
	var n, x, sum int
	for {
		fmt.Scan(&n, &x)
		if n == 0 && x == 0 {
			break
		}
		sum = 0
		for i := 1; i <= n; i++ {
			for j := i + 1; j <= n; j++ {
				for k := j + 1; k <= n; k++ {
					if i + j + k == x {
						sum += 1
					}
				}
			}
		}
		fmt.Println(sum)
	}
}


Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 1e5+10;
const int M = 1e6+10;
/*=================================================================================*/

int n;

int main() {
   cin>>n;
   n %= 10;
   if(n==2 || n==4 || n==5 || n==7 || n==9) puts("hon");
   else if(n==3) puts("bon");
   else puts("pon");
   return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k,x,i;
    cin>>k>>x;
    for(i=x-(k-1);i<=x+(k-1);i++)
    {
        if(i==(x+(k-1)))
            cout<<i<<endl;
        else
            printf("%d ",i);
    }
    return 0;
}


Measured memory_bytes: 256
#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;
const int mod = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }

struct Bitree {
	typedef int btT;
	vector<btT> bv;
	Bitree(int n) : bv(n + 3) {}
	btT sum(int i) {
		btT res=0; for(i++; i>0; i -= i & -i) res += bv[i]; return res;
	}
	btT sum(int a, int b) {return sum(b) - (a? sum(a-1): 0);}
	void add(int i, btT x){for(i++; i<(int)bv.size(); i += i & -i) bv[i] += x; }
	void updt(int i, btT x){ add(i, x - sum(i,i));} //replace, update
};

int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n, q;
	string s;
	cin >> n >>s >>q;
	
	while(q--){
		int k ; cin >>k;
		ll sma =0, smb =0, smab =0, abc =0;
		rep(r, n){
			if(s[r] == 'C') abc += smab;
			if(s[r] == 'D') sma++;
			if(s[r] == 'M') smb++, smab +=sma;
			int l = r - k +1;
			if(l >= 0){
				if(s[l] == 'D'){
					sma--; smab -=smb;
				}
				if(s[l] == 'M') smb--;
			}
		}
		cout << abc <<"\n";
	}
	
	
	return 0;
}


Measured memory_bytes: 1412
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<deque>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#include<string>
#define rep(i,n,m) for(int i=(n);i<(int)(m);i++)
#define reps(i,n,m) for(int i=(n);i<=(int)(m);i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define SZ(x) ((int)(x).size())
#define pb push_back
#define fs first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define LB(a,x) lb(all(a), x) - a.begin()
#define UB(a,x) ub(all(a), x) - a.begin()
#define printfdouble(x) printf("%.12f\n",(x))
#define chartoint(c) (int)((c) - '0')
#define chartoll(c) (long long)((c) - '0')
#define MOD 1000000007
#define itn int
#define enld endl
#define ednl endl
#define icn cin
#define Endl endl
#define stirng string
using namespace std;
typedef long long ll;
const double pi = 3.141592653589793;
using Graph = vector<vector<int>>;
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;}
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 a, ll b){
    if(b == 0) return a;
    else return GCD(b, a%b);
}

ll gcd_bec(vector<ll> const &A){
    int size = SZ(A);
    ll ret = A[0];
    rep(i,1,size){
        ret = GCD(ret, A[i]);

    }
}

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    ll N; cin >> N;
    ll A[1001001];
    int cnt[1001001];

    Fill(cnt, 0);
    rep(i,0,N){
        cin >> A[i];
        cnt[A[i]]++;
    }

    ll gcd = A[0];
    rep(i,1,N) gcd = GCD(gcd, A[i]);

    if(gcd > 1){
        cout << "not coprime" << endl;
        return 0;
    }

    for(int i=2;i<=1000000;i++){
        int count = 0;
        for(int j=i;j<=1000000;j+=i){
            count += cnt[j];
        }
        if(count > 1){
            cout << "setwise coprime" << enld;
            return 0;
        }
    }

    cout << "pairwise coprime" << endl;
    return 0;
}


Measured memory_bytes: 15360
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int str1,str2,i,flag=1;
	char a[110],b[110];
	gets(a);
	gets(b);
	str1=strlen(a);
	str2=strlen(b);
	sort(a,a+str1);
	sort(b,b+str2);
	if(str1<str2)
	{
		for(i=0;i<str1;i++)
		{
			if(a[i]<b[str2-i-1])
			{
				cout<<"Yes"<<endl;
				flag=0;
				break;
			}
			else if(a[i]>b[str2-i-1])
			{
				cout<<"No"<<endl;
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
			cout<<"Yes"<<endl;
		}
	}
	else
	{
		for(i=0;i<str2;i++)
		{
			if(a[i]<b[str2-i-1])
			{
				cout<<"Yes"<<endl;
				flag=0;
				break;
			}
			else if(a[i]>b[str2-i-1])
			{
				cout<<"No"<<endl;
				flag=0;
				break;
			}
		}
		if(flag==1)
		{
			cout<<"No"<<endl;
		}	
	}
}

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

public class AtCoderC
{
    static void Main()
    {
        decimal a;
        decimal b;
        decimal c;
        {
            var line = Console.ReadLine();
            var words = line.Split(' ');
            a = decimal.Parse(words[0]);
            b = decimal.Parse(words[1]);
            c = decimal.Parse(words[2]);
        }

        bool answer;
        decimal d = c - a - b;
        if (d < 0)
        {
            answer = false;
        }
        else
        {
            decimal e = d * d - (4 * a * b);
            answer = e > 0;
        }

        Console.WriteLine(answer ? "Yes" : "No");
    }
}

Measured memory_bytes: 13140
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
    int N, K;
    cin >> N >> K;

    int r = K + N - 1;
    int l = K - N + 1;

    for (int i = l; i <= r; i++) cout << i << " ";
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define mod 1000000007
using namespace std;
vector<string>v;
void permute(string a, int l, int r)  
{  
    // Base case  
    if (l == r)  
         v.push_back(a);
    else
    {  
        // Permutations made  
        for (int i = l; i <= r; i++)  
        {  
  
            // Swapping done  
            swap(a[l], a[i]);  
  
            // Recursion called  
            permute(a, l+1, r);  
  
            //backtrack  
            swap(a[l], a[i]);  
        }  
    }  
}  

int main(){

ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s,t;
    ll a,b,k;
    cin>>a>>b>>k;
    if(k>=a)
    {
    	
    	k=k-a;
    	a=0;
    	if(k>=b)
    	{
    		b=0;
    	
		}
		else
		{
			b=b-k;
		}
    	
	}
	else
	a=a-k;
	cout<<a<<" "<<b;
    
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a,b,d,r;
    double f;
    scanf("%d %d",&a,&b);
    d=a/b;
    r=a%b;
    f=(double)a/b;
    printf("%d %d %f\n",d,r,f);
    return 0;
}


Measured memory_bytes: 2756
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class ARemainingBalls {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        string s, t, u;
        cin >> s >> t;
        int a, b;
        cin >> a >> b;
        cin >> u;
        if (s == u) a--;
        if (t == u) b--;
        cout << a << " " << b << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    ARemainingBalls solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 256
n = int(input())
s = input()
dum1,dum2 = divmod(n,2)
flag = "ok"
if dum2 != 0:
  print("No")
else:
  for i in range(dum1):
    if s[i] != s[i+dum1]:
      flag = "ng"
      break
  if flag == "ng":
    print("No")
  else:
    print("Yes")



Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\Users\Joeon\Desktop\IN.txt", "r", stdin);
//		freopen("C:\Users\Joeon\Desktop\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, a, b;
	cin>>n>>a>>b;
	hrp(i, a, b) if (!(i%n)) { cout<<"OK"<<endl; return 0;}
	cout<<"NG"<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


Measured memory_bytes: 3652
#include <iostream>
#include <algorithm>
#include <string>
#include <cstdio>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define endl "\n"
typedef long long ll;
#define traceV(v) for(auto x:v)cout<<x<<" ";cout<<endl
#define traceM(mp) for(auto x:mp)cout<<x.first<<" "<<x.second<<endl
#define MOD 1000000007

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

  int N,M; cin>>N>>M;

  vector<int> A(N);
  int sum = 0;
  rep(i,N) {
    cin>>A[i];
    sum+=A[i];
  }
  sort(ALL(A));
  reverse(ALL(A));

  rep(i,M) {
    if(A[i]*(4*M)<sum){cout << "No"<<endl; return 0;}
  }
  cout << "Yes" <<endl;

  return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  cout << min(A, B) << " " << max(0, A + B - N) << endl;
  return 0;
}

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

int main() {
	char a, b, c;
  	cin >> a >> b >> c;
  bool hasa = false;
  bool hasb = false;
  if (a == 'A' || b == 'A' || c == 'A') hasa = true;
  if (a == 'B' || b == 'B' || c == 'B') hasb = true;
  
  if (hasa && hasb) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

int main() {
	int N, K, ans = 0;
	cin >> N >> K;

	vector<int> V(N);
	for (int i = 0; i < N; i++) cin >> V.at(i);

	sort(V.begin(),V.end());
	for (int i = 0; i < K; i++) ans += V.at(N - 1 - i);

	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		// double q;
		while (true) {
			double q = in.nextDouble();
			if (q == -1)
				break;
			double x = q / 2;
			while (Math.abs(x * x * x - q) > 0.00001 * q)
				x = Math.abs(x - ((x * x * x - q) / (3 * x * x)));
			System.out.printf("%.6f\n", x);
		}
		// while ((q = in.nextInt()) >= 1) {
		// double xn = q / 2.0;
		// double checkVal = xn * xn * xn - q;
		// while (Math.abs(checkVal) >= 0.00001 * q) {
		// checkVal = xn * xn * xn - q;
		// xn = xn - (checkVal) / (xn * xn * 3.0);
		// }
		// System.out.printf("%f", xn);
		// System.out.println();
		//
		// }
	}
}

Measured memory_bytes: 20220
import math
          
def koch(n, h, i, j, k):
 if n == 0:
  return
           
 sx = (h*2+j)/3
 sy = (i*2+k)/3
 tx = (h+j*2)/3
 ty = (i+k*2)/3
 ux = (tx-sx)*math.cos(math.pi/3) - (ty-sy)*math.sin(math.pi/3) + sx
 uy = (tx-sx)*math.sin(math.pi/3) + (ty-sy)*math.cos(math.pi/3) + sy
          
 koch(n-1, h, i, sx, sy)
 print sx, sy
 koch(n-1, sx, sy, ux, uy)
 print ux, uy
 koch(n-1, ux, uy, tx, ty)
 print tx, ty
 koch(n-1, tx, ty, j, k)
   
n = input()
          
px = float(0)
py = float(0)
qx = float(100)
qy = float(0)
          
print px, py
koch(n, px, py, qx, qy)
print qx, qy

Measured memory_bytes: 6660
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>
#include <list>
#include <random>

// macros
#define ll long long int
#define pb emplace_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for(int i=((int)(n)-1);i>=0;i--)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

// solve
template <class T>bool chmax(T &a, const T &b){if(a < b){a = b; return 1;} return 0;}
template <class T>bool chmin(T &a, const T &b){if(a > b){a = b; return 1;} return 0;}

template<typename T>
T gcd(T a, T b) {
  if(a > b)return gcd(b, a);
  if(a == 0)return b;
  return gcd(b % a, a);
}

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  vector<ll> a(n);
  rep(i, n)cin >> a[i];
  ll res = a[0];
  FOR(i, 1, n)res = gcd(res, a[i]);
  cout << res << endl;
	return 0;
}


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

mat = 0
res = 1000

ls = len(s)
lt = len(t)
#print(ls, lt)

di = ls - lt

for i in range(di + 1):
    tag = s[i:i + lt]
    #print(tag)
    #print(t)
    for j in range(lt):
        if t[j] != tag[j]:
            mat += 1
    if mat <= res:
        res = mat
    #print(res)
    mat = 0

print(res)


Measured memory_bytes: 9032
#include <iostream>
using namespace std;
int main(){
    int A[30][100]={},B[30][100]={},C[30][100]={},D[30][100]={};
    int n,a,b,c,d;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a>>b>>c>>d;
        if(a==1){
            A[b][c]=d+A[b][c];
        }
        else if(a==2){
            B[b][c]=d+B[b][c];
        }
        else if(a==3){
            C[b][c]=d+C[b][c];
        }
        else{
            D[b][c]=d+D[b][c];
        }
    }
    for(int i=1;i<=3;i++){
        for(int j=1;j<=10;j++){
            cout<<" "<<A[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=10;j++){
            cout<<" "<<B[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=10;j++){
            cout<<" "<<C[i][j];
        }
        cout<<endl;
    }
    cout<<"####################"<<endl;
    for(int i=1;i<=3;i++){
        for(int j=1;j<=10;j++){
            cout<<" "<<D[i][j];
        }
        cout<<endl;
    }
    return 0;
    
}


Measured memory_bytes: 3144
package main

import (
	"fmt"
	"io"
	"os"
)

func main() {
	fmt.Println(resolve(parseProblem(os.Stdin)))
}

func parseProblem(r io.Reader) (s string) {
	fmt.Fscanf(r, "%s", &s)
	return s
}

func resolve(s string) string {
	st := newByteSet(s)
	if st.size() > 1 {
		return "Yes"
	}
	return "No"
}

func newByteSet(input string) byteSet {
	s := newSet()
	for i := 0; i < len(input); i++ {
		s.add(input[i])
	}
	return s
}

type byteSet map[byte]none

func newSet() byteSet {
	return make(map[byte]none)
}

func (s byteSet) add(item byte) {
	s[item] = mark
}

func (s byteSet) doesContain(item byte) bool {
	_, ok := s[item]
	return ok
}

func (s byteSet) size() int {
	return len(s)
}

var mark none

type none struct{}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()



int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(18);
  
  string s;
  ll a, b, c, d;
  cin >> a>>b>>c>>d;
  
  //vector<ll> a(n);  rep(i, 0, n) cin >> a[i];
  
  //cout << n << "\n";
  
  cout << (bool)(d==1) << "\n";

}

Measured memory_bytes: 256