akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
using namespace std;
 
int main()
{
  long int a,b;
  cin>>a>>b;
 for(int i = 1; i <= b; i++){
    if((a * i) % b == 0){
      cout << a * i << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 256
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
  
    if op == '?':
        break
  
    if op == '+':
        print(a + b)
  
    if op == '-':
        print(a - b)
  
    if op == '*':
        print(a *b)
  
    if op == '/':
        print(a // b)

Measured memory_bytes: 7652
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

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

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

template <typename T>
void debugV(const vector<T> v) {
#ifdef _DEBUG
  rep(i, v.size()) {
    cout << i << ":" << v[i] << " ";
  }
  cout << endl;
#else
  (void)v;
#endif
}

signed main() {
  ll N, X;
  cin >> N >> X;
  vll L(N);
  rep(i, N) {
    cin >> L[i];
  }

  ll ans = 1;
  ll now = 0;
  rep(i, N) {
    now += L[i];
    ans++;
    if (now > X) {
      COUT(ans - 1);
      return 0;
    }
  }
  COUT(N + 1);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main (){
    int a[3],count=0;
  for (int i=0;i<3;i++){
        cin >>a[i];
    if (a[i]==5)
      count++;
    if (a[i]==7)
      count+=2;
  }
  if (count==4)
    cout <<"YES\n";
  else
    cout <<"NO\n";
}

Measured memory_bytes: 256
#include <iostream>
#define MOD 1000000007
using namespace std;

int main() {
  long long min_ = 10000000000000;
  long long max_ = 0;
  long long min__ = 10000000000000;
  long long max__ = 0;
  long long N; cin >> N;
  for (int i = 0; i < N; i++){
    long long x, y;
    cin >> x >> y;
    min_ = min(min_, x + y);
    max_ = max(max_, x + y);
    min__ = min(min__, y - x + 10000000000);
    max__ = max(max__, y - x + 10000000000);
  }
  cout << max(max_ - min_, max__ - min__) << endl;
}

Measured memory_bytes: 3632
import java.util.*;
import static java.lang.System.*;

public class Main {

	Scanner sc = new Scanner(in);
	
	String reverse(String s) {
		String ans = "";
		int len = s.length();
		for (int i = 0; i < len; i++)
			ans += s.charAt(len-i-1);
		return ans;
	}
	
	String J(String s) {
		return s.substring(s.length()-1)+s.substring(0, s.length()-1);
	}
	
	String C(String s) {
		return s.substring(1)+s.substring(0, 1);
	}
	
	String A(String s) {	
		return reverse(s);
	}
	
	String P(String s) {
		char[] ans = s.toCharArray();
		for (int i = 0; i < ans.length; i++) {
			if (Character.isDigit(ans[i])) {
				switch(ans[i]) {
				case '0': ans[i] = '9'; break;
				case '1': ans[i] = '0'; break;
				case '2': ans[i] = '1'; break;
				case '3': ans[i] = '2'; break;
				case '4': ans[i] = '3'; break;
				case '5': ans[i] = '4'; break;
				case '6': ans[i] = '5'; break;
				case '7': ans[i] = '6'; break;
				case '8': ans[i] = '7'; break;
				case '9': ans[i] = '8'; break;
				}
			}
		}
		return String.valueOf(ans);
	}
	
	String M(String s) {
		char[] ans = s.toCharArray();
		for (int i = 0; i < ans.length; i++) {
			if (Character.isDigit(ans[i])) {
				switch(ans[i]) {
				case '0': ans[i] = '1'; break;
				case '1': ans[i] = '2'; break;
				case '2': ans[i] = '3'; break;
				case '3': ans[i] = '4'; break;
				case '4': ans[i] = '5'; break;
				case '5': ans[i] = '6'; break;
				case '6': ans[i] = '7'; break;
				case '7': ans[i] = '8'; break;
				case '8': ans[i] = '9'; break;
				case '9': ans[i] = '0'; break;
				}
			}
		}
		return String.valueOf(ans);
	}
	
	String E(String s) {
		int n = s.length();
		if (n % 2 == 0) {
			return s.substring(n/2)+s.substring(0,n/2); 
		} else {
			return s.substring(n/2+1)+s.substring(n/2, n/2+1)+s.substring(0,n/2);
		}
	}
	
	void run() {
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String order = sc.next();
			String message = sc.next();
			for (int j = order.length()-1; j >= 0; j--) {
				switch(order.charAt(j)) {
				case 'J': message = J(message); break;
				case 'C': message = C(message); break;
				case 'E': message = E(message); break;
				case 'A': message = A(message); break;
				case 'P': message = P(message); break;
				case 'M': message = M(message); break;
				}
			}
			out.println(message);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}

}

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

int main() {
	int	N;
	cin >> N;
	vector<int> vec;
	rep(i, N)
	{
		int	a;
		cin >> a;
		vec.push_back(a);
	}
	int M;
	cin >> M;
	rep(i, M)
	{
		int	b, m, e;
		cin >> b >> m >> e;
		rotate(next(vec.begin(), b), next(vec.begin(), m), next(vec.begin(), e));
	}
	rep(i, N)
	{
		if (i)
			cout << ' ';
		cout << vec.at(i);
	}
	cout << endl;
}



Measured memory_bytes: 3152
import java.util.*;
public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int num = sc.nextInt();
    int min = num;
    for (int i = 1; i <= num / 2; i++) {
      String num1 = String.valueOf(i);
      int num1Length = num1.length();
      char[] num1Char = num1.toCharArray();
      String num2 = String.valueOf(num - i);
      int num2Length = num2.length();
      char[] num2Char = num2.toCharArray();
      int count = 0;
      for (int j = 0; j < num1Length; j++) {
        count += Character.getNumericValue(num1Char[j]);
      }
      for (int k = 0; k < num2Length; k++) {
        count += Character.getNumericValue(num2Char[k]);
      }
      if (count < min) {
        min = count;
      }
      
    }
    System.out.println(min);
  }
}

Measured memory_bytes: 28956
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;
const int MOD = 1000000007;

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;
    int ans = s.size() + t.size();
    int tot = 0;
    for(int i = n - 1; i >= 0; i--) {
        bool check = true;
        for(int j = i; j < n; j++) {
            if(s[j] != t[j - i]) check = false;
        }
        if(check) tot = n - i;
    }
    cout << ans - tot << endl;

    return 0;
}

Measured memory_bytes: 256
'use strict';
const inputs = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n');

const N = parseInt(inputs[0]);
const a = inputs[1].split(' ');

let cnt = 0;
for (let len = a.length, i = 1; i <= len; i++) {
	let j = parseInt(a[i - 1]);
	if (j < i) continue;
	
	if (parseInt(a[j - 1]) === i) cnt++;
}
console.log(cnt);

Measured memory_bytes: 13432
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<vector>
using namespace std;
typedef long long ll;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    string s, ans;
    cin >> s;
    int len = s.size();
    REP(i, len){
        if (s[i] == '0') ans += '0';
        else if(s[i] == '1') ans += '1';
        else if (ans.size() > 0) ans.erase(ans.size() - 1);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func recv() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	w, h, n := recv(), recv(), recv()

	arr := make([][]int, n)
	for i := 0; i < n; i++ {
		arr[i] = []int{recv(), recv(), recv()}
	}

	xy := make([][]int, w)
	for i := 0; i < w; i++ {
		xy[i] = make([]int, h)
	}

	var x, y, a int
	for _, v := range arr {
		x = v[0]
		y = v[1]
		a = v[2]

		switch a {
		case 1:
			for i := 0; i < x; i++ {
				for j := 0; j < h; j++ {
					xy[i][j]++
				}
			}
		case 2:
			for i := x; i < w; i++ {
				for j := 0; j < h; j++ {
					xy[i][j]++
				}
			}
		case 3:
			for i := 0; i < w; i++ {
				for j := 0; j < y; j++ {
					xy[i][j]++
				}
			}
		case 4:
			for i := 0; i < w; i++ {
				for j := y; j < h; j++ {
					xy[i][j]++
				}
			}
		}
	}

	var ans int
	for i := 0; i < w; i++ {
		for j := 0; j < h; j++ {
			if xy[i][j] == 0 {
				ans++
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 768
# 合計食数の取得
N = int(input())

# 合計金額及びキャッシュバック金額を取得
Cashsum = 800 * N 
Cashback = (N // 15) * 200

# 合計金額からキャッシュバック額を引いたものを出力
print(Cashsum - Cashback)

Measured memory_bytes: 9096
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

int main(){
    string s;
    cin >> s;
    int ans = 0;
    if(s=="RRR") ans = 3;
    else if(s=="SSS") ans = 0;
    else if(s=="RRS"||s=="SRR") ans = 2;
    else ans = 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int n,m;
vector<string> G[100];

bool check(string &s,string &t){
  for(int i=0;i+t.size()<=s.size();i++){
    if(s.substr(i,t.size())==t)return true;
  }
  return false;
}

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    G[i].resize(3);
    for(int j=0;j<3;j++)cin>>G[i][j];
  }
  cin>>m;
  for(int i=0;i<m;i++){
    if(i)cout<<endl;
    vector<string> a(4);    
    for(int j=0;j<4;j++)cin>>a[j];
    for(int k=0;k<n;k++){
      if(a[0]!="*"&&!check(G[k][0],a[0]))continue;
      if(a[1]!="*"&&!check(G[k][1],a[1]))continue;
      if(a[2]!="*"&&G[k][2]<a[2])continue;
      if(a[3]!="*"&&G[k][2]>a[3])continue;
      cout<<G[k][0]<<endl;
    }
  }
  return 0;
}

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

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

  int n_colors = 8;
  vector<int> v(n_colors + 1);
  rep(i, N) {
    int a;
    cin >> a;
    if (a < 3200)
      v[a / 400]++;
    else
      v[n_colors + 1]++;
  }

  int n_min = 0;
  rep(i, n_colors) if (v[i] > 0) n_min++;

  int n_max = n_min + v[n_colors + 1];

  if (n_min == 0)
    n_min++;

  cout << n_min << " " << n_max << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
using namespace std;
///////////////////////////////////////////
const long long int INF = 100000000000;
const long long int Mod = 1000000007;
using ll = long long int; //long long int は64bit
using vi = vector<int>; using Vi = vector<long long int>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define mt make_tuple
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(long long int i=0;i<N;i++)
#define np nullptr
template<class T>bool chmax(T &former, const T &b) { if (former<=b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define fill(x,num) memset(x,num,sizeof(x));
typedef vector<vector<ll> > matrix;
typedef pair<ll,ll> Pair;
bool p_compare(const Pair& firstP, const Pair& secondP){ 
    return firstP.second < secondP.second; 
}//sort(all(v),p_compare)で昇順ソート
//////////////////////////^^ *Emile ^^^//////////////////////////////////////////////////////
//Snipet -> Caps Lock

ll n;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    cin>>n;
    double x;
    string s;
    ll t1=0;
    double t2 = 0.0;
    rep(i,n){
        cin>>x>>s;
        if(s=="JPY"){
            t1 += x;
        }else{
            t2 += x;
        }
    }
    cout<<t1+t2*380000.0<<endl;
    return 0;
}

Measured memory_bytes: 256
S = list(input())
flag = True
if(len(S)%2 == 0):
    flag = True
else:
    flag = False
for i in range(len(S)):
    if(i%2 == 0):
        if(S[i] != "h"):
            flag = False
            break
    else:
        if(S[i] != "i"):
            flag = False
            break
if(flag == True):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <stdio.h>
#include <math.h>

#define DICE_SIZE 6

class Dice
{
private:
	int eyes[DICE_SIZE];
public:
	Dice(int e1, int e2, int e3, int e4, int e5, int e6)
	{
		eyes[0] = e1;
		eyes[1] = e2;
		eyes[2] = e3;
		eyes[3] = e4;
		eyes[4] = e5;
		eyes[5] = e6;
	}

	int GetEye(int i)
	{
		return eyes[i];
	}

	void Roll(char c)
	{
		switch (c)
		{
		case 'E':
		case 'e':
			ToEest();
			break;

		case 'N':
		case 'n':
			ToNorth();
			break;

		case 'S':
		case 's':
			ToSouth();
			break;

		case 'W':
		case 'w':
			ToWest();
			break;

		default:
			break;
		}
	}

	void ToEest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[3];
		eyes[1] = temp[1];
		eyes[2] = temp[0];
		eyes[3] = temp[5];
		eyes[4] = temp[4];
		eyes[5] = temp[2];
	}

	void ToNorth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[1];
		eyes[1] = temp[5];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[0];
		eyes[5] = temp[4];
	}

	void ToSouth()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[4];
		eyes[1] = temp[0];
		eyes[2] = temp[2];
		eyes[3] = temp[3];
		eyes[4] = temp[5];
		eyes[5] = temp[1];
	}
	
	void ToWest()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[2];
		eyes[1] = temp[1];
		eyes[2] = temp[5];
		eyes[3] = temp[0];
		eyes[4] = temp[4];
		eyes[5] = temp[3];
	}

	void TurnClockWise()
	{
		int temp[DICE_SIZE];
		for (int i = 0; i < DICE_SIZE; i++) temp[i] = eyes[i];
		eyes[0] = temp[0];
		eyes[1] = temp[2];
		eyes[2] = temp[4];
		eyes[3] = temp[1];
		eyes[4] = temp[3];
		eyes[5] = temp[5];
	}
};

int main()
{
	int e1, e2, e3, e4, e5, e6;
	scanf("%d %d %d %d %d %d", &e1, &e2, &e3, &e4, &e5, &e6);
	Dice dice(e1, e2, e3, e4, e5, e6);

	int n;
	scanf("%d", &n);

	for (int i = 0; i < n; i++)
	{
		int a, b;
		scanf("%d %d", &a, &b);

		// 上面を合わせる
		for (int i = 0; i < 4; i++)
		{
			if(dice.GetEye(0)==a) break;
			dice.Roll('N');
		}
		if (dice.GetEye(0)!= a)
		{
			for (int i = 0; i < 4; i++)
			{
				if (dice.GetEye(0) == a) break;
				dice.Roll('E');
			}
		}

		// 前面を合わせる
		for (int i = 0; i < 4; i++)
		{
			if (dice.GetEye(1) == b) break;
			dice.TurnClockWise();
		}

		std::cout << dice.GetEye(2) << std::endl;
	}

}


Measured memory_bytes: 3132
#include<stdio.h>
#include<algorithm>
#include<functional>
#include<cmath>
#include<numeric>
#include<queue>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
ll mod = 1000000007;
using namespace std;
priority_queue<ll int>A;
int main(void)
{
	int N, M;
	ll X, sum = 0, S;
	scanf("%d%d", &N, &M);
	rep(i, N) {
		scanf("%lld", &X);
		A.push(X);
	}
	rep(i, M) {
		S=A.top();
		A.pop();
		A.push(S / 2);
	}
	rep(i, N) {
		sum += A.top();
		A.pop();
	}
	printf("%lld", sum);
	return 0;

}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int n,x=0;cin>>n;
	for(int i=1;i<=n;i++){
		x=(x*10+7)%n;
		if(!x){
			cout<<i<<endl;
			return 0;
		}
	}
	puts("-1");
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

int main() {
    int N,K;

    cin >> N >> K;

    double p=.0;

    for(int i=N;i>0;i--){
        int ic=i;
        int cnt=0;
        while(ic<K){
            ic*=2;
            cnt++;
        }
        p+=1.0/N*pow(.5,(double)cnt);
    }

    cout << setprecision(12) << p;
}


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

int cnt[1<<20] = {};

// bucket method
int main(){
    int n, k, x0;
    cin >> n >> k >> x0;
    if(x0 == 0){
        cout << 0 << endl;
        return 0;
    }
    unsigned long long int x = x0;
    for (int i = 0; i < n; i++) {
        ll tmp = (long long int)x;
        cnt[(1<<19)+(tmp>>44)]++;
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
    }
    int key = 0;
    for(key = 0; key < 1<<20; key++){
        if(k-cnt[key] <= 0) break;
        k -= cnt[key];
    }
    x = x0;
    vector<ll> v;
    for (int i = 0; i < n; i++) {
        ll tmp = (long long int)x;
        if((1<<19)+(tmp>>44) == key)    v.push_back(tmp);
        x ^= x << 13;
        x ^= x >> 7;
        x ^= x << 17;
    }
    sort(v.begin(), v.end());
    cout << v[k-1] << endl;
    return 0;
}


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

void writeRectangle(int w, int h)
{
    const char frame = '#';
    const char dot = '.';

    char c = ' ';
    for (int i=0; i<w; ++i)
    {
        for (int j=0; j<h; ++j)
        {
            if ((i == 0 || i == w-1) || (j == 0 || j == h-1)) c = frame;
            else    c = dot;
            cout << c;
        }
        cout << endl;
    }
}

int main()
{
    int w=0, h=0;
    
    while(true)
    {
        cin >> w >> h;
        if (w == 0 && h == 0)   break;

        writeRectangle(w, h);
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(void){
  int a[100000], n, i, count=0;
  scanf("%d", &n);
  for(i=0; i<n; ++i){
    scanf("%d", &a[i]);
  }
  i=0;
  while(i!=1){
    count +=1;
    i = a[i]-1;
    if (count > n) break;
  }
  if (i!=1) printf("%d\n", -1);
  else printf("%d\n", count);
  return 0;
}


Measured memory_bytes: 640
def main():
    N = int(input())
    S = input()

    s = S
    while True:
        s = s.replace('()', '')
        if s.count('()') == 0:
            break

    if len(s) == 0:
        print(S)
        return

    left = ''
    right = ''
    if s[0] == ')':
        left = '(' * s.count(')')
    if s[-1] == '(':
        right = ')' * s.count('(')

    print('{}{}{}'.format(left, S, right))

main()


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

using namespace std;

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



int main(){

  int n,a;
  cin >> n >> a;
  if(n%500<=a)cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 768
//95a.cpp
#include<iostream>
using namespace std;

int main(){
    char s[3];
    cin >> s;
    int cnt = 0;
    if(s[0] == 'o'){
        cnt ++;
    }
    if(s[1] == 'o'){
        cnt ++;
    }
    if(s[2] == 'o'){
        cnt ++;
    }
    cout << 700 + cnt * 100 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>

int main() {
    int N;
    scanf(" %d", &N);

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

    int cnt = 0;
    bool flg = true;
    while(flg) {
        // printf("origin x: ");
        for (int i = 0; i < N; i++) {
            // printf("%d ", A[i]);
            if (A[i]%2 != 0) {
                flg = false;
                break;
            } else {
                A[i] /= 2;
            }
        }
        // printf("\nnew x: ");
        // for (int i = 0; i < N; i++) {
        //     printf("%d ", A[i]);
        // }
        // printf("\n");
        cnt++;
    }
    printf("%d\n", --cnt);
}

Measured memory_bytes: 128
#include <stdio.h>

int main(){
	int a[4];
	int b[4];
	int hit,blow;
	int i,j;
	char c[8];
	
	while(scanf("%d %d %d %d",&a[0],&a[1],&a[2],&a[3])!=EOF){
		hit=0;
		blow=0;
		
		
		scanf("%d %d %d %d",&b[0],&b[1],&b[2],&b[3]);
		
		for(i=0;i<4;i++){
			for(j=0;j<4;j++){
				if(a[i]==b[j]){
					blow++;
				}
			}
			if(a[i]==b[i]){
				hit++;
			}
		}
		blow-=hit;
		printf("%d %d\n",hit,blow);
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>

int main(){
    int H, W, i, j, k;
    
    for(k=0; ; k++){
    scanf("%d%d", &H, &W);
    if (H==0 && W==0) break;
        for(i=0; i<H; i++){
            for(j=0; j<W; j++){
                printf("#");
            }
        printf("\n");
        }
    printf("\n");
    }
    return 0;
}

Measured memory_bytes: 572
n, k = list(map(int, input().split()))
a = [i - 1 for i in list(map(int, input().split()))]
logk = k.bit_length()
doubling = [[-1 for _ in range(n)] for _ in range(logk)]
for i in range(n):
    doubling[0][i] = a[i]
for i in range(1, logk):
    for j in range(n):
        doubling[i][j] = doubling[i - 1][doubling[i - 1][j]]
index = 0
k_bin = list(map(int, [list(bin(k))[-i]
                       for i in range(1, logk + 1)]))
for i in range(logk):
    if k_bin[i]:
        index = doubling[i][index]
print(index + 1)


Measured memory_bytes: 217480
nmx = input().split()
n = int(nmx[0])
m = int(nmx[1])
x = int(nmx[2])
a = input().split()
for i in range(m):
    a[i] = int(a[i])
    
cl = 0
cr = 0

for i in range(n):
    if i in a:
        if i < x:
            cl += 1
        else:
            cr += 1

print(min(cl,cr))

Measured memory_bytes: 3064
#include <iostream>

 using namespace std;

 int main(void){
 int K;
 cin >> K;

 int a[] = {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};
 cout << a[K-1] << endl;
   
 return 0;
 }


Measured memory_bytes: 256
import sys
s = input()
n = len(s)
ans = 7
for bit in range(2**(n - 1)):
    f = s[0]
    for i in range(n - 1):
        if bit & (1 << i):#i番目の数が1なら以下の処理を行う
            f += "+"
            f += s[i + 1]
        else:#i番目の数が0なら以下の処理を行う
            f += "-"
            f += s[i + 1]
    if eval(f)==7:
        print(f+"=7")
        sys.exit()

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

using namespace std;

const int maxn=105;

char s[maxn];
int n,ans;

int main(){
	cin>>(s+1);
	n=strlen(s+1);
	for(int i=1;i<=(n/2);i++){
		if(s[i]!=s[n-i+1]) ans++;
	}
	cout<<ans<<endl;
	return 0;
}

















Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <algorithm>
#include <cmath>
#include <string>
using namespace std;
typedef long long lli;
typedef vector<lli> vll;
typedef vector<bool> vbl;
typedef vector<vector<lli> > mat;
typedef vector<vector<bool> > matb;
typedef vector<string> vst;
typedef pair<lli,lli> pll;
typedef pair<double,double> pdd;

lli n;
vll a;
lli ans,ans_;

int main(){
    cin >> n;
    a = vll(n);
    for(lli i = 0;i < n;i++) cin >> a[i];
    lli sum = 0;
    for(lli i = 0,d = 1;i < n;i++,d *= -1){
        sum += a[i];
        if(sum*d <= 0){
            ans_ += abs(d-sum);
            sum = d;
        }
    }
    ans = ans_;
    ans_ = 0;sum = 0;
    for(lli i = 0,d = -1;i < n;i++,d *= -1){
        sum += a[i];
        if(sum*d <= 0){
            ans_ += abs(d-sum);
            sum = d;
        }
    }
    cout << min(ans_,ans) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<=b;++i)
#define per(i,a,b) for(int i=a;i>=b;--i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define rvc(i,S) for(int i=0;i<(int)S.size();++i)
#define fore(i,x) for(int i = head[x] ; i ; i = e[i].next)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define PII pair<int,int>
#define debug(...) fprintf(stderr, __VA_ARGS__)
using namespace std;
int n,k;
int main()
{cin>>n>>k;
 cout<<n-k+1<<endl;
	
	
	
}

Measured memory_bytes: 256
from math import gcd
from functools import reduce
from sys import exit

# O(A+N)解
MAX_A = 1000000
lowerst_prime = [0] * (MAX_A + 1) # 最小の素因数をいれる(2以上をみていけばいい)
primes = [] # MAX_A以下の素数の集合
count = [0] * (MAX_A + 1) # 約数として出てくる回数を数える
for i in range(2, MAX_A + 1): # 線形時間で処理してくれる
    if lowerst_prime[i] == 0:
        lowerst_prime[i] = i
        primes.append(i)
    for p in primes:
        if i * p > MAX_A:
            break
        lowerst_prime[i * p] = p # p がi * p のもっとも小さな素因数となるときのみ更新されるので、線形時間アルゴリズムとなる
# 入力
N = int(input())
A = [*map(int, input().split())]
if reduce(gcd, A) != 1:
    print("not coprime")
    exit(0)
for i in range(N):
    while A[i] > 1:
        divide = lowerst_prime[A[i]]
        if count[divide]:
            # A[x] % i == A[y] % i == 0 となるx != yが存在するので、i | gcd(x, y)となる
            print("setwise coprime")
            exit(0)
        count[divide] += 1
        while A[i] % divide == 0: # 割れるだけ割る
            A[i] //= divide
print("pairwise coprime")

Measured memory_bytes: 206524
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
// #include <numeric>
#include <complex>
#include <tuple>

#define FAST ios_base::sync_with_stdio(false); cin.tie(0)
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define repr(i, a, b) for(int i=int(a); i>=int(b); i--)
#define reps(i,n) for(int i=1;i<=int(n);++i)
#define RREP(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define RREPS(i,x) for(int i=((int)(x));i>0;i--)
#define iceil(x,y) (x+y-1)/y
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define all(x) (x).begin(),(x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )

int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<int, PII> PP;

int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};

ll n, ans=0;

template<typename T>
map<T, ll> factoring(T x) {
	map<T, ll> res;
	for(ll i=2;i*i<=x;i++){
    	while(x%i==0){
			x/=i;
			res[i]++;
		}
	}
	if(x!=1) res[x]++;
	return res;
}

int main()
{
	FAST;

	cin >> n;
	vector<ll> cnt(111,0);
	reps(i,n){
		for (auto p:factoring(i)) {
			cnt[p.first]+=p.second;
		}
	}

	// if (cnt[2]>=74) ans++;
	for (int i=2;i<111;++i)
		if (cnt[i]>=74) ans++;

	for(int i=2;i<111;++i) {
		for(int j=2;j<111;++j)
			if (i!=j&&cnt[i]>=2&&cnt[j]>=24) ans++;
	}

	for(int i=2; i<111;++i){
		for(int j=0;j<111;++j)
			if(i!=j&&cnt[i]>=4&&cnt[j]>=14) ans++;
	}

	for (int i=2; i<111;++i)
		for (int j=2; j<111; ++j)
			for (int k=2; k<j; ++k)
				if(i!=j&&i!=k&&cnt[i]>=2&&cnt[j]>=4&&cnt[k]>=4) ans++;

	cout << ans << "\n";

	return 0;
}

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

long long n;
vector<int> v, tmp;

void solve();

int main() {
  cin >> n;
  solve();
  return 0;
}

void solve() {
  int num = 0, cntr = 0, cntb = 0, allcnt = 0;
  string s;
  v.assign(n * 2, 0);
  string bf;
  int nowl = 0, nowr = n;
  cout << '?';
  ++allcnt;
  for(int j = 0; j < n; ++j) cout << " " << j % (2 * n) + 1;
  cout << endl;
  cin >> s;
  bool a = s == "Red";

  while(nowr - nowl > 1) {
    int i = (nowl + nowr) / 2;
    cout << '?';
    ++allcnt;
    for(int j = 0; j < n; ++j)
      cout << " " << (i + j) % (2 * n) + 1;
    cout << endl;
    cin >> s;
    if((s == "Red") == a)
      nowl = i;
    else
      nowr = i;
  }
  num = nowl + 1;
  for(int i = 0; i < 2 * n; ++i)
    if(i < num || i >= num + n) {
      cout << '?';
      ++allcnt;
      for(int j = 0; j < n - 1; ++j)
        cout << " " << (num + j) % (2 * n) + 1;
      cout << " " << i + 1 << endl;
      cin >> s;
      v[i] = 1 + (s == "Red");
    }
  for(int i = 0; i < 2 * n; ++i)
    if(v[i] == 2 && cntr < n / 2) {
      tmp.push_back(i + 1);
      ++cntr;
    }
    else if(v[i] == 1 && cntb < n / 2) {
      tmp.push_back(i + 1);
      ++cntb;
    }
  assert(tmp.size() == n - 1);
  for(int i = 0; i < 2 * n; ++i)
    if(i >= num && i < num + n) {
      cout << '?';
      ++allcnt;
      for(int j = 0; j < n - 1; ++j) cout << " " << tmp[j];
      cout << " " << i + 1 << endl;
      cin >> s;
      v[i] = 1 + (s == "Red");
    }
  string ans;
  for(int i = 0; i < 2 * n; ++i)
    if(v[i] == 2)
      ans += 'R';
    else
      ans += 'B';
  assert(allcnt <= 210);
  cout << "! " << ans << endl;
}

Measured memory_bytes: 724
#include<iostream>
#include<string.h>
#include <stdio.h>
#include<vector>
#include<string>
#include <sstream>      // std::ostringstream

//文字列化演算子
#define STR(str) #str

using namespace std;
vector<string> split_s(const string &str, char sep);
vector<int> split_i(const string &str, char sep);
int hash(string s);
bool find(string *,int, string);
void insert(string *,int, string);

const int HASHDIV = 1046527;
int main()
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  string line = "";
  getline(cin, line);
  int ordersize =stoi(line);
  string *hashed_data  = new string[HASHDIV];
  for (int i = 0; i < HASHDIV;i++)
  {
    hashed_data[i] = "";
  }
  string order ;
  string target ;
  for (int i = 0; i < ordersize ; i++)
  {
    cin >> order;
    cin >> target;

    if (order=="insert")
    {
      insert(hashed_data,ordersize,target);
    }
    else if (order=="find")
    {
      if(find(hashed_data, ordersize,string(target)))
      {
        printf("yes\n");
      }
      else
      {
        printf("no\n");
      }
    }
  }
  delete[](hashed_data);
}
vector<string> split_s(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_i(const string &str, char sep)
{
  vector<int> veci;
  vector<string> vecs = split_s(str, sep);
  for(string s:vecs)
  {
    veci.push_back(stoi(s));
  }
  return veci;
}

int geneToKey(string s)
{
  int key = 0;
  //ATGCを4進数とみて10進数に変換する
  for(char c : s)
  {
    key *= 4;
    if (c == 'A')
    {
      key += 0;
    }
    else if (c=='T')
    {
      key += 1;
    }
    else if (c=='G')
    {
      key += 2;
    }
    else if (c=='C')
    {
      key += 3;
    }
  }
  return key;
}
int h1(int key)
{
  return key % HASHDIV;
}
int h2(int key)
{
  return 1 + key % (HASHDIV-1);
}
int hashnize(int unhashedkey,int i)
{
  return (h1(unhashedkey) + i * h2(unhashedkey)) % HASHDIV;
}
void insert(string * list,int listsize, string target)
{
  int key = geneToKey(target);
  for (int i = 0;i<listsize;i++)
  {
    int hashedkey = hashnize(key,i);
    //cout << hashedkey << endl;
    if (list[hashedkey]=="")
    {
      //cout << endl;
      list[hashedkey] = target;
      return;
    }
  }
  //insert不能
  printf("挿入に失敗しました : 空きスペースがありません！");
  exit(-1);
}
bool find(string *list,int listsize , string target)
{
  int key = geneToKey(target);
  for (int i = 0;i<listsize;i++)
  {
    int hashedkey = hashnize(key,i);
    if (list[hashedkey]==target)
    {
      return true;
    }
    if (list[hashedkey]=="")
    {
      return false;
    }
  }
  return false;
}


Measured memory_bytes: 38392
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

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

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

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        p: [usize; n],
        q: [usize; n]
    }
    let pi = rank(&p) as i64;
    let qi = rank(&q) as i64;
    println!("{}", (pi - qi).abs());
}

fn rank(p: &Vec<usize>) -> usize {
    let n = p.len();
    let mut rest: Vec<usize> = (1..n + 1).collect();
    let mut f = (1..n + 1).fold(1, |ac, x| {ac * x});
    let mut ret = 0;
    for x in p {
        f /= rest.len();
        let idx = rest.binary_search(x).unwrap();
        ret += f * idx;
        rest.remove(idx);
    }
    ret
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <fstream>
#include <iostream>
#include <iterator>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;
typedef pair<int,int> PI;
typedef vector<PI> VPI;
typedef unsigned long long ull;
typedef long long ll;

#define FOR(i, n) for(int i=0;i<(n);++i)
#define REP(i,s,n) for(int i=s;i<=n;++i)
#define SZ(x) ((int)(x).size())
#define LOOP(i,x) FOR(i,SZ(x))
#define IT(it,x) for(typeof((x).begin()) it = (x).begin();it!=(x).end();++it)
#define ALL(x) (x).begin(), (x).end()
#define ST first
#define ND second
#define MP make_pair
#define PB push_back
#define gc getchar

const int INF = 1e9 + 5;
const int MAXN = 1e5 + 5;
vector<int> edges[MAXN];
int in_degree[MAXN];
bool v[MAXN];
int dist[MAXN];

void dfs(int s) {
	assert(!v[s]);
	v[s] = true;
	for (int e: edges[s]) {
		dist[e] = max(dist[e], dist[s] + 1);
		--in_degree[e];
		if (in_degree[e] == 0) dfs(e);
	}
}

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

	int n, m;
	cin >> n >> m;

	for (int i = 0; i < m; i++) {
		int x, y;
		cin >> x >> y;
		edges[x - 1].push_back(y - 1);
		in_degree[y - 1]++;
	}

	for ( int i = 0; i < n; i++) if (!v[i] && in_degree[i] == 0) dfs(i);

	int ans = 0;
	for ( int i = 0; i < n; i++) ans = max(ans, dist[i]);
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 9728
#include <iostream>
#include <algorithm>

using namespace std;
typedef long long ll;

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

int main(void)
{
    int a,b;
    cin >> a >> b;
    if(a*b%2==1){
        cout << "Odd" << endl;
    } else {
        cout << "Even" << endl;
    }
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include <stdio.h>
using namespace std;
#define TREE_N (1<<17)

int ans,c,n,tree[ TREE_N * 2 -1]={};

void update(int i){
  i+=TREE_N-1;
  ans+=tree[i];
  while(i>0){
    i=(i-1)/2;
    ans+=tree[i];
  }
}

void rec(int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    rec(a,b,k*2+1,l,m);
    rec(a,b,k*2+2,m,r);
  }else if(a<=l&&r<=b){
    tree[k]+=c;
  }
}

int Rec(int a,int b,int k=0,int l=0,int r=TREE_N){
  if((l<a&&a<r)||(l<b&&b<r)){
    int m=(l+r)/2;
    int left = Rec(a,b,k*2+1,l,m);
    int right = Rec(a,b,k*2+2,m,r);
    return min(left,right);
    
  }else if(a<=l&&r<=b){
    return tree[k];
  }else{
    return 2147483647;
  }
}

int main(){
  int q,com,a,b;
  cin>>n>>q;
  for(int i=0;i<q;i++){
    cin>>com;
    if(com){
      cin>>a;
      ans=0;
      update(a);
      printf("%d\n",ans);
    }
    else {
      cin>>a>>b>>c;
      rec(a,b+1);
    }
  }
  return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i = 0; i < N; i++){
    cin >> A[i];
  }
  int count = 0, even = 0;
   for(int i = 0; i < N; i++){     
     if(A[i] % 2 == 0){
       if(A[i] % 3 == 0 || A[i] % 5 == 0){
         count++;
       }
       even++;
     }     
   } 
  if(count == even){
        cout << "APPROVED" << "\n";
     }else{
       cout << "DENIED" << "\n";
     }
  return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
string s1,s2,s3;
int main()
{
    cin>>s1>>s2>>s3;
    char p1=s1[0]-32;
    char p2=s2[0]-32;
    char p3=s3[0]-32;
    cout<<p1<<p2<<p3<<endl;


return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#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(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  ll mn = 1e9, mx = -1e9;
  ll sum = 0;
  REP(i, n) {
    ll a;
    cin >> a;
    mn = min(mn, a);
    mx = max(mx, a);
    sum += a;
  }
  cout << mn << " " << mx << " " << sum << endl;
  return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

int main(){
  int N,M;
  cin>>N>>M;
  vector<int> A(N);
  for(int i(0);i<N;i++) cin>>A[i];
  int cnt(0);
  int sum(0);
  for(int i(0);i<N;i++){
    sum += A[i];
  }
  for(int i(0);i<N;i++){
    if (A[i]*4*M >= sum) cnt++;
  }
  if(cnt >= M){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
long long inf=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  string s[3];
  REP(i,3){
    cin>>s[i];
  }
  int next=0;
  char next_char;
  while(s[next].size()){
    next_char=s[next][0];
    s[next].erase(s[next].begin(),s[next].begin()+1);
    if(next_char=='a'){
      next=0;
    }else if(next_char=='b'){
      next=1;
    }else{
      next=2;
    }
  }
  
  if(next==0){
    cout<<"A"<<endl;
  }else if(next==1){
    cout<<"B"<<endl;
  }else{
    cout<<"C"<<endl;
  }
  
  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define inf 1e18
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define ff first
#define ss second
#define vll vector<ll>
#define pii pair<ll,ll>
#define sz(v) (v).size()
#define srt(v) sort(v.begin(),v.end())
#define ull unsigned long long
#define tell(a) cout<<a<<" "
#define el cout<<endl
#define rev(v) reverse(v.begin(),v.end())
#define rep(i,a,n) for(int i=a;i<n;i++)
#define M 1000000007
ll power(ll x, ll y, ll p){ll res = 1;x = x % p;while (y > 0){   if (y & 1)res = (res*x) % p;y = y>>1;
x = (x*x) % p;}return res;}
vector<pii>v;
ll dp[2001][2001],n;
ll fu(int i,int j)
{
	if(i==n)return 0;
	if(dp[i][j]!=-1)return dp[i][j];
	dp[i][j]=v[i].ff*abs(v[i].ss-j)+fu(i+1,j+1);
	dp[i][j]=max(dp[i][j],v[i].ff*abs(v[i].ss-(n-i+j-1))+fu(i+1,j));
	return dp[i][j];
}
int main()
{
	IOS;
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	memset(dp,-1,sizeof(dp));
	cin>>n;
	rep(i,0,n)
	{
		int c;
		cin>>c;
		v.pb(make_pair(c,i));
	}
	sort(v.rbegin(),v.rend());
	ll ans=fu(0,0);
	cout<<ans;
}

Measured memory_bytes: 35144
"use strict";
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  var ans = 0, x = 1;
  for(var i = 0; i < n; i++){
    if(a[i] === x)x++;
    else ans++;
  }
  return ans === n? -1:ans;
}

Measured memory_bytes: 24272
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string s; IN(s);
    if(s == "SUN") OUT(7);
    if(s == "MON") OUT(6);
    if(s == "TUE") OUT(5);
    if(s == "WED") OUT(4);
    if(s == "THU") OUT(3);
    if(s == "FRI") OUT(2);
    if(s == "SAT") OUT(1);

    return 0;
}

Measured memory_bytes: 256
n,m = map(int, raw_input().split())
aa = [0] * n
bb = [0] * m
for i in range(n):
    aa[i] = list(raw_input())
for i in range(m):
    bb[i] = list(raw_input())

flag = True
for i in range(n-m):
    for j in range(n-m):
        flag = True
        for ik in range(m):
            for jk in range(m):
                if aa[i+ik][j+jk] != bb[ik][jk]:
                    flag = False
                    
        if flag == True: break
    if flag == True: break

if flag == True:
    print 'Yes'
else:
    print 'No'


Measured memory_bytes: 2692
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
typedef long long ll;
using namespace std;
int main()
{
     string s;
     cin>>s;
     if(s=="RRR")
        cout<<3<<endl;
     else if(s=="RRS")
        cout<<2<<endl;
     else if(s=="SRR")
        cout<<2<<endl;
     else if(s=="SSS")
        cout<<0<<endl;
     else
        cout<<1<<endl;


return 0;
}


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

int main() {
	int n; cin >> n;
	string s; cin >> s;
	int max_x =0;
	int x =0;
	for (int i = 0; i<n;i++) {
		string ss = s.substr(i,1);
		if (ss == "I") {
			++x;
		} else {
			--x;
		}
		max_x = max(x, max_x);
	}
	cout << max_x << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1'000'000'007;
const ld PI = acos(-1);  
const ld EPS = 0.0000000001;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define REP(i, n) for(ll i=0; i<(ll)(n); i++)
#define REPD(i, n) for(ll i=n-1; 0<=i; i--)
#define FOR(i, a, b) for(ll i=a; i<(ll)(b); i++)
#define FORD(i, a, b) for(ll i=a; (ll)(b)<=i; i--)
#define ALL(x) x.begin(), x.end()
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int main(){
    ll x;   cin >> x;
    ll lc = lcm(x, 360);
    cout << lc / x << endl;
}


Measured memory_bytes: 3576
import java.util.Scanner;
public class Main{
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		while(scan.hasNext()){
			int count=0;
			int n=scan.nextInt();
			for(int i=0;i<=9;i++){
				for(int j=0;j<=9;j++){
					for(int k=0;k<=9;k++){
						for(int l=0;l<=9;l++){
							if((i+j+k+l)==n){
								count++;
							}
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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

int main(){
    int n;
    cin >> n;
    vector <int> l(n);
    int wa=0,ma=0;
    rep(i,n){
        cin >> l[i];
        ma=max(ma,l[i]);
        wa+=l[i];
    }

    if(2*ma<wa){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    

    return 0;
}

Measured memory_bytes: 3624