akhauriyash/Code-Regression huggingface dataset:
import math


N, K = map(int, input().split(" "))
R, S, P = map(int, input().split(" "))
T = input()



# print(N, K, R, S, P)


# Lets wrirte a  Greedy SOlution

mapped_dict = {
    0 : "r",
    1 : "s",
    2 : "p"
}
reverse_mapped_dict = {
    "r" : 0,
    "s" : 1,
    "p" : 2
}

def determine_R_P_S(val):
    if val == "r":
        # print("p")
        return "p"
    elif val == "p":
        # print("s")
        return "s"
    else:
        # print("r")
        return "r"
    
def add_profit(machine_val, you_played, succeed, R, P, S):
    if machine_val == "r":
        if succeed == 1:
            return P
        else:
            return 0

    if machine_val == "p":
        if succeed == 1:
            return S
        else:
            return 0

    if machine_val == "s":
        if succeed == 1:
            return R
        else:
            return 0
    


def total_profit(T, R, P, S, K, N):
    profit = 0
    S_played = ""
    for i in range(0, K):
        I_played = determine_R_P_S(T[i])
        S_played += I_played
        # print("SHOULD PLAY")
        # print(S_played)   
        # print(i)
        # print(I_played)
        # print()
        profit += add_profit(T[i], I_played, 1, R, P, S)

    for i in range(K, N):
        I_played = determine_R_P_S(T[i])
        I_played_previous = S_played[i - K]
        # # print("SHOULD PLAY")
        # print(i )
        # print(I_played, I_played_previous)
        # print()
        if I_played != I_played_previous:
            S_played += I_played
            profit += add_profit(T[i], I_played, 1, R,  P, S)
        else:   
            if i + K < N:
                To_play_future = determine_R_P_S(T[i + K])
                if To_play_future != I_played_previous:
                    S_played += mapped_dict[3 - reverse_mapped_dict[To_play_future] - reverse_mapped_dict[I_played_previous]]
                else:
                    S_played += T[i]
                    
            else:
                S_played += T[i]
                

    # print(S_played)
    return profit



print(total_profit(T, R, P, S, K, N))





Measured memory_bytes: 3444
a=input()
op=['+','-']
 
for i in op:
    for j in op:
        for k in op:
            if eval(a[0]+i+a[1]+j+a[2]+k+a[3])==7:
                print(a[0]+i+a[1]+j+a[2]+k+a[3]+"=7")
                exit()

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define LL long long
#define PII pair<int,int>
#define PIL pair<int,LL>
#define PLI pair<LL,int>
#define PIII pair<int,PII>
#define PLL pair<LL,LL>
#define PLII pair<LL,PII>
#define VI vector<int>
#define VVI vector<VI>
#define VL vector<LL>
#define VVL vector<VL>
#define VPII vector<PII>
#define FF first
#define SS second
#define MP make_pair
#define PB push_back
#define all(x) x.begin(),x.end()
#define watch(x) cout<<(#x)<<" = "<<(x)<<'\n'
#define mset(a,v) memset(a,v,sizeof(a))
#define setp(x) cout<<fixed<<setprecision(x)
#define EPS 0.00000000001
#define PI acos(-1)
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
using namespace std;

const int MOD = 1e9 + 7;
const LL MX = 1e9;
const LL INF = 1e9;

int main()
{
    //ofstream out("output.txt");
    //ifstream in("input.txt");
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int k;
    cin>>k;

    int ans = 0;
    if(k % 2 == 0 || k % 5 == 0) ans = -1;
    else
    {
        int m = 7 % k, mul = 1;
        ans = 1;
        while(m)
        {
            ++ans;
            mul = (mul * 10) % k;
            m = (m + ((7 * mul) % k)) % k;
        }
    }

    cout<<ans<<'\n';

    /*
    int t,n;
    cin>>t;
    while(t--)
    {
        cin>>n;
        int a[n];
        loop(i,0,n)
        {
            cin>>a[i];
        }
    }
    */

    /*
    int n;
    cin>>n;
    int a[n];
    loop(i,0,n)
    {
        cin>>a[i];
    }
    */

    /*
    cout<<ans<<'\n';

    if(f) cout<<"YES\n";
    else cout<<"NO\n";

    if(f) cout<<"Yes\n";
    else cout<<"No\n";
    */

    return 0;
}


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

int main() {
    int N;
    int ac =0;
    int wa = 0;
    int tle = 0;
    int re = 0;
    string kotae;
    cin >> N;
    for (int i = 0; i < N; ++i) {
        cin >> kotae;
        if(kotae == "AC"){
            ac++;
        }
        else if(kotae == "WA"){
            wa++;
        }else if(kotae == "TLE"){
            tle++;
        }else if(kotae == "RE"){
            re++;
        }
        
    }

    cout << "AC x " << ac << endl;
    cout << "WA x " << wa << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x " << re << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define int long long
#define endl '\n'
using namespace std;

typedef long long ll;
#define READ(a) int a; cin >> a;
#define READARR(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define READMAT(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;

signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	READ(a);
	READ(b);
	if (a - 2*b >= 0) cout << a - 2*b;
	else cout << 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

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

int main()
{
    int a, b, c;
    int n;
    int r;
    while (scanf("%d %d %d", &a, &b, &c))
    {
        if (a == 0 and b == 0 and c == 0)
            return 0;
        scanf("%d", &n);
        int r1;
        r1 = a * a + b * b;
        r1 = min(r1, b * b + c * c);
        r1 = min(r1, c * c + a * a);
        for (int i = 0; i < n; i++)
        {
            scanf("%d", &r);
            printf("%s\n", 4 * r * r > r1 ? "OK" : "NA");
        }
    }
    return 0;
}


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

int left(int index){
    return 2*index;
}

int right(int index){
    return 2*index+1;
}

int H;

void maxHeapify(int A[],int i){//iは節点番号
    int l=left(i);
    int r=right(i);
    int largest;
    
    largest= (l<=H && A[l]>A[i]) ? l:i;

    if(r<=H && A[r] > A[largest]) largest=r;

    if (largest!=i){
        swap(A[i],A[largest]);
        maxHeapify(A,largest);
    }
}

void buildMaxHeap(int A[]){
    for(int i=H/2;i>=1;i--)
        maxHeapify(A,i);
}

void print(int A[],int H){
    for(int i=1;i<=H;i++) printf(" %d",A[i]);
    printf("\n");
}

int main(){
    scanf("%d",&H);
    int A[500001]={0};

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

    buildMaxHeap(A);
    print(A,H);

    return 0;
}


Measured memory_bytes: 5164
import itertools,sys
def S(): return sys.stdin.readline().rstrip()
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
H,W = LI()
s = [S() for _ in range(H)]
ans = 1
for i,j in itertools.product(range(H),range(W)):
    if s[i][j]=='.':
        continue
    try:
        if s[i-1][j]=='#' or s[i+1][j]=='#' or s[i][j-1]=='#' or s[i][j+1]=='#':
            continue
    except:
        continue
    else:
        ans = 0
        break
print({1:'Yes',0:'No'}[ans])


Measured memory_bytes: 3064
#include<iostream>
#define TARO 0
#define JIRO 1
using namespace std;

int main(){
	int i, str[25], marbles, flag, cou;
	
	while(1){
		cin >>i;
		if(i == 0) break;
		for(int j = 0; j < i; j++){
			cin >>str[j];
		}
		
		marbles = 32;
		cou = 0;
		flag = TARO;
		
		while(marbles){
			if(flag == TARO){
				marbles = marbles - ((marbles - 1) % 5);
				flag = JIRO;
				if(marbles < 0) marbles = 0;
			} else{
				marbles -= str[cou];
				cou++;
				if(cou >= i) cou = 0;
				flag = TARO;
				if(marbles < 0) marbles = 0;
			}
			cout <<marbles <<endl;
		}
	}
	return 0;
}

Measured memory_bytes: 0
h,n=map(int,input().split())
a=[0]
b=[0]
for i in range(n):
    A,B=map(int,input().split())
    a.append(A)
    b.append(B)
dp=[[10**9 for j in range(h+max(a)+1)] for i in range(n+1)]
for i in range(n+1):
    dp[i][0]=0
for i in range(n):
    for j in range(h+max(a)+1):
        if j>=a[i+1]:
            dp[i+1][j]=min(dp[i][j],dp[i+1][j-a[i+1]]+b[i+1])
        else:
            dp[i+1][j]=dp[i][j]
ans=10**9
for j in range(h,h+max(a)+1):
    if ans>dp[n][j]:
        ans=dp[n][j]
print(ans)


Measured memory_bytes: 133768
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pi;
typedef pair<double,double> pd;
typedef pair<double,ll> pdl;
#define F first
#define S second
#define MK make_pair
const ll E=1e18+7;
const ll MOD=1000000007;

ll mod_pow(ll a,ll x){
    ll ans=1;
    for(int i=0;i<63;i++){
        if(x>>i&1){ans*=a; ans%=MOD;}
        a*=a;
        a%=MOD;
    }
    return ans;
}

ll R(ll a){
    return mod_pow(a,MOD-2);
}

ll factorial(ll n){
    ll ret=1;
    for(int i=2;i<=n;i++){
        ret*=i%MOD;
        ret%=MOD;
    }
    return ret;
}

ll c(ll n,ll k){
    return factorial(n)*R(factorial(n-k))%MOD*R(factorial(k))%MOD;
}

ll gcd(ll a,ll b){
    if(a%b==0){return b;}
    return gcd(b,a%b);
}

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

bool prime(ll p){
    for(int i=2;i*i<=p;i++){
        if(p%i==0){return false;}
    }
    return true;
}

vector<ll> mk_prime(ll mx){
    vector<ll> p={2};
    for(int i=3;i<=mx;i++){
        bool j=true;
        for(int t=0;p[t]*p[t]<=i;t++){
            if(i%p[t]==0){j=false; break;}
        }
        if(j){p.push_back(i);}
    }
    return p;
}


int main(){
    ll n,k;
    cin>>n>>k;
    ll ans=0;
    for(ll i=1;i<=k;i++){
        if((k-i)%2){ans-=c(k,i)*mod_pow(i,n)%MOD;}
        else{ans+=c(k,i)*mod_pow(i,n)%MOD;}
        ans%=MOD;
    }
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    
    return 0;
}



Measured memory_bytes: 3120
/*** author: yuji9511 ***/
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using lpair = pair<ll, ll>;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(ll i=(m);i<(n);i++)
#define rrep(i,m,n) for(ll i=(m);i>=(n);i--)
#define printa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
void print() {}
template <class H,class... T>
void print(H&& h, T&&... t){cout<<h<<" \n"[sizeof...(t)==0];print(forward<T>(t)...);}

void solve(){
    ll X,Y;
    cin >> X >> Y;
    rep(a,0,101){
        rep(b,0,101){
            ll x = a + b;
            ll y = 2 * a + 4 * b;
            if(X == x && Y == y){
                print("Yes");
                return;
            }
        }
    }
    print("No");
    

}

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

Measured memory_bytes: 3636
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scan(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n,a,b;
void input(){
    cin>>n>>a>>b;
}
void src(){
    int c1=0,c2=0,c3=0;
    rep(i,n){
        int p;
        cin>>p;
        if(p<=a){
            c1++;
        }else if(p<=b){
            c2++;
        }else{
            c3++;
        }
    }
    cout<<min({c1,c2,c3});
}   
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

int F(ll x) {
  int res = 0;
  while (x > 0) {
    res++;
    x %= __builtin_popcount(x);
  }
  return res;
}

int main() {
  // 最初の１回は割ってから総和にする、逆から、ビット反転したものが０の場合に注意
  // popcは２通り持っておく+1がupと-1がdown
  int N;
  cin >> N;
  string X;
  cin >> X;
  ll upTotal = 0;
  ll downTotal = 0;
  int popc = count(X.begin(), X.end(), '1');
  if (popc == 0) {
    rep(i, N) {
      cout << 1 << '\n';
      return 0;
    }
  } else if (popc == 1) {
    ll upCoef = 1;
    for (int i = N-1; i >= 0; i--) {
      //1の位から計算
      if (X[i] == '1') {
        ll upAdd = upCoef % (popc+1);
        upTotal += upAdd;
      }
      upCoef *= 2;
      upCoef %= (popc+1);
    }
    vector<int> ans(N);
    upCoef = 1;
    for (int i = N-1; i >= 0; i--) {
      if (X[i] == '0') {
        int temp = F((upTotal + upCoef) % (popc + 1));
        ans[i] = temp + 1;
      } else {
        ans[i] = 0;
      }
      upCoef *= 2; upCoef %= (popc+1);
    }
    rep(i, N) {
      cout << ans[i] << '\n';
    }
    return 0;
  }
  //cout << popc << '\n';
  ll upCoef = 1;
  ll downCoef = 1;
  for (int i = N-1; i >= 0; i--) {
    //1の位から計算
    if (X[i] == '1') {
      ll upAdd = upCoef % (popc+1);
      upTotal += upAdd;
      ll downAdd = downCoef % (popc-1);
      downTotal += downAdd;
    }
    upCoef *= 2;
    upCoef %= (popc+1);
    downCoef *= 2;
    downCoef %= (popc-1);
    // cout << upTotal << '\n';
  }
  vector<int> ans(N);
  upCoef = 1;
  downCoef = 1;
  for (int i = N-1; i >= 0; i--) {
    if (X[i] == '0') {
      int temp = F((upTotal + upCoef) % (popc + 1));
      ans[i] = temp + 1;
    } else {
      if (popc == 1) {
        ans[i] = 0;
      } else {
        int temp = F((downTotal - downCoef) % (popc - 1));
        ans[i] = temp + 1;
      }
    }
    upCoef *= 2; upCoef %= (popc+1);
    downCoef *= 2; downCoef %= (popc-1);
  }
  rep(i, N) {
    cout << ans[i] << '\n';
  }
  return 0;
}



Measured memory_bytes: 4300
#include <stdio.h>
int main(int argc, char const *argv[]) {
  int a,b,c;
  scanf("%d%d%d\n",&a,&b,&c);

  if(a<b && b<c){
    printf("Yes\n");
  }else{
    printf("No\n");
  }
  return 0;
}

Measured memory_bytes: 584
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
#define _GLIBCXX_DEBUG
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<chrono>//実行時間計測
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm,accumulate
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//順序保持しないmap
#include<unordered_set>//順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, int> pii;
typedef pair<ll, ld> pld;
typedef pair<pii, int> ppiii;
typedef pair<pii, ll> ppiill;
typedef pair<pll, ll> ppllll;
typedef pair<pli, int> pplii;
typedef map<int, int> mii;
typedef deque<ll> dll;
typedef queue<ll> qll;
typedef priority_queue<ll> pqll;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqrll;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<pll>> vvpll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define cin(x) cin >> x

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    //入力
    ll N = 0, L =0;
    cin(N);cin(L);

    //vll X(N);
    //REP(i,N) cin(X.at(i));
    vector<string> S(N);
    REP(i,N) cin >> S[i];

    sort(ALL(S));

    //出力
    REP(i,N) cout << S.at(i);
  return 0;
}

Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
   int a,b;
   cin >> a >> b;
   if(b%a == 0){
      cout << a+b;
   }else{
      cout << b-a;
   }
   return 0;
}

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

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

  int H, W, D; cin >> H >> W >> D;
  int HW = H * W;
  vector<int> p(HW);
  for (int i = 0; i < HW; i++) {
    int A; cin >> A; A--;
    p[A] = i;
  }

  auto dist = [&](int p1, int p2) {
    return abs(p1 / W - p2 / W) + abs(p1 % W - p2 % W);
  };

  vector<int> cs(HW);
  for (int x = 0; x < D; x++) {
    int y = x;
    for (int y = x; y + D < HW; y += D) {
      cs[y + D] = cs[y] + dist(p[y], p[y + D]);
    }
  }

  int Q; cin >> Q;
  for (int i = 0; i < Q; i++) {
    int L, R; cin >> L >> R; L--; R--;
    cout << cs[R] - cs[L] << "\n";
  }
}

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

struct X{
	int p;
	int v;
	int b;
};

bool comv(const X& copylx, const X& copyrx) {
	return copylx.v < copyrx.v;
}

bool comp(const X& copylx, const X& copyrx) {
	return copylx.p < copyrx.p;
}

int main() {
	int n;
	cin >> n;
	vector<X> x(n);
	for (int i = 0; i < n; ++i) {
		cin >> x[i].v;
		x[i].p = i;
	}
	sort(x.begin(), x.end(), comv);
	for (int i = 0; i < n; ++i) {
		if (i + 1 <= n / 2) {
			x[i].b = x[(n / 2)].v;
		}
		else {
			x[i].b = x[(n / 2) - 1].v;
		}
	}
	sort(x.begin(), x.end(), comp);
	for (auto itr = x.begin(); itr != x.end(); ++itr) {
		cout << itr->b << endl;
	}
}

Measured memory_bytes: 4480
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""
 
def main():
  n = int(input())
  P = [int(input()) for i in range(n)]
  
  P = sorted(P,reverse=True)
  ans = P[0] //2
  for i in range(1,len(P)):
    ans += P[i]
  print(ans)
  
if __name__ == '__main__':
  main()

Measured memory_bytes: 3188
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

v = 0

for i in range(N):
    v += B[A[i] - 1]
    if i > 0 and A[i - 1] + 1 == A[i]:
        v += C[A[i - 1] - 1]

print(v)




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

using namespace std;

int main(void){
	int N;
	cin >> N;
	char S[N];
	cin >> S;
	int i;
	if(N % 2 == 1){
		cout<<"No"<<endl;
		return 0;
	}
	int j = N / 2;
	for(i=0;i<j;i++){
		if(S[i] != S[i+j]){
			cout <<"No"<<endl;
			return 0;
		}
	}
	cout <<"Yes"<<endl;
	
	return 0;

}






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

using namespace std;

#define int 		long long
#define endl		"\n"
#define mod			1000000007
#define inf			1e12
#define IOS			ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)

int32_t main() {

	IOS;

	int h, w;
	cin >> h >> w;

	vector<vector<char>> grid(h, vector<char>(w));
	vector<vector<int>> dp(h, vector<int>(w));

	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> grid[i][j];
		}
	}

	dp[h - 1][w - 1] = 1;

	for (int i = h - 1; i >= 0; i--) {
		for (int j = w - 1; j >= 0; j--) {
			if (i == h - 1 && j == w - 1)
				continue;

			if (grid[i][j] == '#') {
				dp[i][j] = 0;
				continue;
			}

			if (i == h - 1)
				dp[i][j] = dp[i][j + 1] % mod;
			else if (j == w - 1)
				dp[i][j] = dp[i + 1][j] % mod;
			else
				dp[i][j] = (dp[i + 1][j] + dp[i][j + 1]) % mod;
		}
	}

	cout << dp[0][0] << endl;

	return 0;
}

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

int main() {
    int a,ans = 0;
    for(int i = 0;i < 3;i++){
        cin >> a;
        ans += a;
    } 
    if (ans >= 22) cout << "bust" << endl;
    else cout << "win" << endl;
}

Measured memory_bytes: 256
#include <iostream>
typedef long long int lli;
using namespace std;
int main(void)
{
	lli N; cin >> N;
	lli ans = 0;
	lli teki = 1;
	while (N > 0) {
		ans += teki;
		teki *= 2;
		N /= 2;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
mod=998244353
def mod_pow(x,n):
    res=1
    while n>0:
        if n&1:
            res=res*x%mod
        x=x*x%mod
        n>>=1
    return res
def inverse_element(t):
    return mod_pow(t,mod-2)

n,m,k=map(int,input().split())
if m==1:
    if k==n-1:
        print(m)
    else:
        print(0)
    exit(0)
ans=0
p1=m*mod_pow(m-1,n-1)%mod
p2=1
for i in range(0,k+1):
    ans+=p1*p2%mod
    ans%=mod
    p1*=inverse_element(m-1)
    p2*=(n-i-1)
    p2*=inverse_element(i+1)
    p1%=mod
    p2%=mod
print(ans%mod)

Measured memory_bytes: 68144
#include<iostream>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int matrix[n][m], vector[m];
    for(int i = 0; i < n; i++)
        for(int j = 0; j < m; j++)
            cin >> matrix[i][j];
    for(int i = 0; i < m; i++) cin >> vector[i];

    for(int i = 0; i < n; i++){
        int item = 0;
        for(int j = 0; j < m; j++) item += matrix[i][j] * vector[j];
        cout << item << endl;
    }
    return 0;
}


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

static int m;

void p(int s,int n,int a[],int j) {
	int i;
	int hokanj=0;
	if(s<0)return;
	if(s==0 && n==0){m++;return;}
	for(i=j+1;i<=9;i++){
		if(a[i]==0){a[i]=1;s-=i;hokanj=j;j=i;p(s,--n,a,j);}
		a[i]=0;s+=i;++n;j=hokanj;
	}
	return;
	
}
int partition(int s,int n, int a[]) {
	p(s,n,a,-1);
	return m;
}

int main(void){
	int s=1,n=1;
	while(scanf("%d %d",&n,&s)>0 && (n!=0 || s!=0)){
		m=0;
		int a[]={0,0,0,0,0,0,0,0,0,0};
		partition(s, n, a);
		printf("%d\n",m);
	}
	return 0;
}


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

typedef int INT_;

#define int long long

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

	map<int,int> mp;

	int sum=0;
	mp[0]=1;
	int ans=0;
	for(int i=0;i<n;i++){
		int x; cin>>x;
		sum += x;
		if(mp[sum]) ans += mp[sum];
		mp[sum]++;
	}

	cout<<ans;
}

Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define long long long int
using namespace std;

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    int r = 0;
    while (n > 0) {
        n /= k;
        r++;
    }
    cout << r;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//#define int long long

int main() {
  int a,b,c;
  cin >>a>>b>>c;
  
  cout << 9*max({a,b,c})+a+b+c;
}



Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int a;
    int b;
    
    cin >> a >> b;
    
    if(a < b) cout << "a < b" << endl;
    
    if(a > b) cout << "a > b" << endl;
    
    if(a == b) cout << "a == b" << endl;
    
}


Measured memory_bytes: 3104
#include <vector>
#include <iostream>
#include <algorithm>
using namespace std;
const int inf = 1<<30;

int main() {
  int n, m; cin >> n >> m;
  vector<pair<int, int>> key;
  for(int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    int s = 0;
    for(int j = 0; j < b; j++) {
      int c; cin >> c; --c;
      s |= (1 << c);
    }
    key.emplace_back(s, a);
  }

  vector<int> dp(1<<n, inf);
  dp[0] = 0;
  for(int s = 0; s < 1<<n; s++) {
    for(int i = 0; i < m; i++) {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      dp[t] = min(dp[t], cost);
    }
  }
  cout << (dp.back() == inf ? -1 : dp.back()) << endl;
  return 0;
}


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

int main() {
  int x,y,fx=0;
  cin>>x;
  y=x;
  while(true){
    fx+=y%10;
    y/=10;
    if(y==0)
      break;  
  }
  if(x%fx==0)
  cout<<"Yes"<<endl;
  else
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
import math
while True:
    
    n = int(input())
    if n == 0:
        break
    else:
        pass
    
    s = list(map(int, input().split()))
    
    m = sum(s) / len(s)
    
    result = 0
    for i in range(n):
        result += pow(s[i] - m, 2)
        
    result = result / n
    
    print(pow(result, 0.5))



Measured memory_bytes: 5724
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

# Written by NoKnowledgeGG @YlePhan

import math
#mod = 10**9+7



def main():
  x,y,z = map(int,input().split())
  
  x -= z
  print(x//(y+z))
if __name__ == '__main__':
  main()

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

public class Main{

	static class FastReader{
		BufferedReader br;
		StringTokenizer st;
		public FastReader(){
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		public String next(){
			try{
				while(st==null||!st.hasMoreElements()){
					st = new StringTokenizer(br.readLine());
				}
			}catch(Exception e){
				e.printStackTrace();
			}
			return st.nextToken();
	
		}
		public int nextInt(){
			return Integer.parseInt(next());
		}
		public long nextLong(){
			return Long.parseLong(next());
		}
		public double nextDouble(){
			return Double.parseDouble(next());
		}
		public String nextLine(){
			String s = "";
			try{
				s = br.readLine();
			}catch(Exception e){
				e.printStackTrace();
			}	
			return s;		
		}
	} 
	static long mod = (int)1e9+7;
	public static long fact(int n){
		long pr =1;
		for(int i = 1; i <= n; i++){
			pr=(pr*i)%mod;
		}
		return pr;
	}
	public static void main(String[] args){
		FastReader in = new FastReader();
		PrintWriter out = new PrintWriter(System.out);
		int n = in.nextInt();
		out.println(fact(n));	
		out.flush();
		out.close();  
	}

}





Measured memory_bytes: 20948
#include <iostream>
#include <algorithm>
#include <cmath>
using namespace std;
int main()
{
	int n; // countはやめてみる
	cin >> n;
	int a[n];

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

	sort(a, a+n);

	for (int i = n % 2; i < n - 1; i += 2) // これさえあれば
	{
		if (a[i] - a[i + 1] != 0) // 合わなかったときだけ判定すればいい
		{
			cout << 0 << endl;
			exit(0);
		}
	}
	// 求めたい数は2の(n/2)乗
	// n = 2n' の時のn/2と n = 2n'+1 の時の(n-1/2)は同義なので省略
	long long result = 1;
	for (int i = 0; i < n/2; ++i)
	{
		result *= 2;
		result %= 1000000007;
	}
	cout << result << endl;
	return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<int> a;
	int c = 0;
	for ( int i = 0; i < n; i++ ) {
		a.push_back(i);
		cin >> a[i];
	}
	for ( int i = 0; i < n - 1; i++ ) {
		int b = i + 1;
		for ( int t = i + 2; t < n; t++ ) {
			if ( a[b] > a[t] ) b = t;
		}
		if ( a[i] > a[b] ) {
			swap(a[i],a[b]);
			c++;
		}
	}
	for ( int i = 0; i < n; i++ ) {
		cout << a[i];
		if ( i < n - 1 ) {
			cout << " ";
		}else {
			cout << endl;
		}
	}
	cout << c << endl;
	return 0;
}

Measured memory_bytes: 1220
{-# OPTIONS_GHC -O #-}

import Data.List
import Control.Monad

main=do
    n<-readLn
    [d,x]<-map read.words<$>getLine::IO[Int]
    as<-replicateM n readLn::IO[Int]
    print $ (+) x $ sum $ map (\a -> length [1,(a+1)..d]) as

Measured memory_bytes: 1020
#include <cstdio>
#include <cassert>
#include <string>
#include <vector>
#include <utility>
#include <algorithm>

bool nya(std::vector<int> const& w, size_t k) {
  std::vector<int> haiku{5, 7, 5, 7, 7};
  int j = 0;
  for (size_t i = k; i < w.size(); ++i) {
    if (haiku[j] < w[i]) return false;
    haiku[j] -= w[i];
    if (haiku[j] == 0) {
      if (++j == 5) return true;
    }
  }
  return false;
}

int testcase_ends() {
  size_t n;
  scanf("%zu", &n);
  if (n == 0) return 1;

  std::vector<int> w(n);
  for (auto& wi: w) {
    char buf[16];
    scanf("%s", buf);
    wi = std::string(buf).length();
  }

  for (size_t i = 0; i < n; ++i)
    if (nya(w, i)) return !printf("%zu\n", i+1);

  assert(false);
}

int main() {
  while (!testcase_ends()) {}
}



Measured memory_bytes: 2844
#include <stdio.h>

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



Measured memory_bytes: 2696
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();

        if (a < b) {
            System.out.println("a < b");
        } else if (a > b) {
            System.out.println("a > b");
        } else {
            System.out.println("a == b");
        }
    }
}



Measured memory_bytes: 26320
import java.io.*;
class Main{
	public static void main(String[]args)throws IOException{
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		String str=br.readLine();
		int n=Integer.parseInt(str);
		
		String[] a=br.readLine().split(" ");
		int min=Integer.parseInt(a[0]),max=Integer.parseInt(a[0]),ai=0;
		long sum=0;
		for(int i=0;i<n;i++){
			ai=Integer.parseInt(a[i]);
			sum+=ai;
			if(min>ai){
				min=ai;
			}
			if(max<ai){
				max=ai;
			}
		}
		System.out.println(min+" "+max+" "+sum);
	}
}

Measured memory_bytes: 28376
#include<iostream>
using namespace std;
int b[25],a[25][25];
int main(void)
{
    int n,m,c,sum=0,cnt=0;
    cin >> n >>m >> c;
    for(int i=1;i<=m;i++)
        cin >> b[i];
    for(int i=1;i<=n;i++)
        for(int j=1;j<=m;j++)
            cin >> a[i][j];
    for(int i=1;i<=n;i++)
    {
        sum=0;
        for(int j=1;j<=m;j++)
        {
            sum+=a[i][j]*b[j];
        }
        sum+=c;
        if(sum>0)
            cnt++;
    }
    cout << cnt;
}

Measured memory_bytes: 256
def find(x):
  if P[x] < 0:
    return x
  else:
    return find(P[x])

N, M, *X = map(int,open(0).read().split())
P = [-1] * (N + 1)
S = N * (N - 1) // 2
r = [S]

while X:
  b, a = find(X.pop()), find(X.pop())
  if a != b:
    S -= P[a] * P[b]
    if P[a] > P[b]:
      a, b = b, a
    P[a] += P[b]
    P[b] = a
  r.append(S)

r.pop()
print(*reversed(r), sep='\n')

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N,K;
  cin >> N >> K;
  ll x[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  if (N == 1) {
    cout << abs(x[0]) << endl;
    return 0;
  }
  ll ans = 99999999999;
  for (int i = 0; i < N - K + 1; i++) {
    // x[i] - x[i + K - 1] の火を全部つける
    if (x[i] <= 0 && x[i + K - 1] >= 0) {
      ll res = (min(abs(x[i]),abs(x[i + K - 1])) * 2LL) + max(abs(x[i]),abs(x[i + K - 1]));
      ans = min(ans,res);
    } else if (x[i] <= 0 && x[i + K - 1] <= 0) {
      ll res = abs(x[i]);
      ans = min(ans,res);
    } else {
      ll res = x[i + K - 1];
      ans = min(ans,res);
    }
  }
  cout << ans << endl;
  return 0;
}

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

int main(){
	string a;
  	cin >> a;
  	if(a == "SAT") cout << "1" << endl;
  	if(a == "SUN") cout << "7" << endl;
  	if(a == "THU") cout << "3" << endl;
  	if(a == "TUE") cout << "5" << endl;
  	if(a == "MON") cout << "6" << endl;
  	if(a == "WED") cout << "4" << endl;
  	if(a == "FRI") cout << "2" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main()
{
    int N,W[100],i,T,sum=0,S1[100],ans[100],min=2147483647;
    scanf("%d",&N);
    for(i=0;i<N;i++)
    {
        scanf("%d",&W[i]);
        //printf(" %d",W[i]);
        sum+=W[i];
        S1[i]=0;
    }
    //////////////////////////
    //printf("%d\n",sum);
    //////////////////////////
    for(T=0;T<N-1;T++)
    {
        for(i=0;i<=T;i++)
        {
            S1[T]=S1[T]+W[i];
        }
        /////////////////////////////
        //printf("%d\n",S1[T]);
        /////////////////////////////
        ans[T]=sum-2*S1[T];
        if(ans[T]<0)ans[T]=-ans[T];

        if(ans[T]<min)min=ans[T];
    }
    printf("%d",min);

    return 0;
}

Measured memory_bytes: 128
/*
    NO 
        TIME 
            TO 
                DIE
                    --007
                            */
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
//#include <boost/functional/hash.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
typedef long long int lli;
lli mod=998244353;
#define OS //single input use oeis
lli INF=1e17;
lli eps=1e-8;
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define sqr(x) (x) * (x)
#define bip(n) __builtin_popcountll(n)//no of ones bit in binary!!
#define bictz(n) __builtin_ctzll(n)//no of trailing zeroes in binary!!
#define biclz(n) __builtin_clzll(n)//no of leading zeroes in binary!!
#define bffs(n) __builtin_ffsll(n)//index of first one bit!!
typedef pair<lli,lli> ll;
#define mem1(a,x) fill(&a[0], &a[0] + sizeof(a) / sizeof(a[0]), x)
#define mem2(a,x) fill(&a[0][0], &a[0][0] +sizeof(a)/sizeof(a[0][0]),x)
#define mem3(a,x) fill(&a[0][0][0], &a[0][0][0] +sizeof(a)/sizeof(a[0][0][0]),x)
#define fi1 ifstream fin("input.txt")
#define of1 ofstream fout("output.txt")
int fmx(int x, int y) { return (((y-x)>>(31))&(x^y))^y; }
int fmi(int x, int y) { return (((y-x)>>(31))&(x^y))^x; }
typedef tree<lli,null_type,less<lli>,rb_tree_tag,tree_order_statistics_node_update> ost;
lli n,z,k,x,m,d,y,q,b,c;
const double pi=3.14159265358979323846;
// double dp[100005];
 
// bool cmp
lli dp[200005];
lli back[200005];
lli ans[200005];
int main()
{

 IO;
 OS;
 cin>>n;
 lli val=n/500ll;
 n=n-val*500;
 val=val*1000ll;
 
 val+=(n/5)*5;
 cout<<val;
 
 
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
num = 0
count = 1
mode = 0
while num < n - 1:
    if a[num] == a[num + 1]:
        num += 1
    elif a[num] > a[num + 1]:
        num += 1
        if mode == -1:
            pass
        elif mode == 0:
            mode = -1
        else:
            count += 1
            mode = 0
    else:
        num += 1
        if mode == 1:
            pass
        elif mode == 0:
            mode = 1
        else:
            count += 1
            mode = 0
print(count)

Measured memory_bytes: 20016
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define INF 1000000007
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}

int n, w, a[110], b[110], dp[114][114514], ta = INF;

signed main() {
	cin >> n >> w;
	rep(i, n)cin >> a[i] >> b[i];
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < 114514; j++) {
			dp[i][j] = INF;
		}
	}
	dp[0][b[0]] = a[0];
	dp[0][0] = 0;
	for (int i = 1; i < n; i++) {
		for (int j = 0; j <= 100000; j++) {
			dp[i][j] = min(dp[i][j], dp[i - 1][j]);
			dp[i][j + b[i]] = min(dp[i][j + b[i]], dp[i - 1][j] + a[i]);
		}
	}
	for (int i = 100000; i >= 0; i--) {
		if (dp[n - 1][i] <= w) {
			cout << i << endl;
			ggr
		}
	}
	ggr
}

Measured memory_bytes: 45312
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int main(){
    int n;
    int a;
    cin>>n;
    cin>>a;
    cout<<(n*n)-a<<endl;
}



Measured memory_bytes: 256
a = [list(map(int, input().split())) for _ in range(5)]
mod = 9
ans = 0
c = 0

for i in range(5):
    modi = (a[i][0]%10)
    if modi != 0:
        mod = min(mod, modi)
    else:
        c += 1
    ref = (0 - -a[i][0]//10)*10
    ans += ref
if c != 5:
    mod = 10 - mod
    ans = ans - mod
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <map>
using namespace std;
int main() {
    int n;
    cin >> n;
    int iMax=0;
    vector<string> s(n);
    map<string, int> dict{};
    map<string, int>::iterator itr;

    for (int i = 0; i < n; i++) {
        cin >> s[i];
        dict[s[i]]++;
        if (iMax < dict[s[i]]) iMax = dict[s[i]];
    }

    for (itr = dict.begin(); itr != dict.end(); itr++) {
        if (iMax == itr->second) {
            cout << itr->first << endl;
        }
    }

    return 0;
}

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



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

    int h,w,a,b;
    cin>>h>>w>>b>>a;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(i<h-a && j<b){
                cout << 1;
            }
            else if(i>=h-a && j>=b) cout << 1;
            else cout << 0;
        }
        cout << endl;
    }

}

Measured memory_bytes: 1280
import numpy as np

a,b = list(map(int,input().split()))
S = input()
sub= "AC"
l = np.zeros(len(S)+1)
for i in range(len(S)):
  l[i+1] = l[i] + (1 if S[i:i+2]=="AC" else 0)

for i in range(b):
    r,t = list(map(int,input().split()))
    n = l[t-1]-l[r-1]
    print(int(n))


Measured memory_bytes: 15816
#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>;
#define INF 1000000010

int main(){
    ll n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    ll ans=0;
    int r=0; // 右側
    int wa=0;
    rep(l,n){ // 左側
        while(r<n && (wa & a[r])==0){
            wa|=a[r];
            r++;
            ans+=r-l;
        }
        if(l==r) r++;
        else wa^=a[l];
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(){
    int n, m, a[MAX];
    cin >> n >> m;
    int total = 0;
    rep(i,n){
        cin >> a[i];
        total += a[i];
    }
    sort(a, a+n);
    reverse(a, a+n);
    if(a[m-1] >= total / (4.0*m)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

char s[110];
typedef long long ll;
int k;

int main() {
	scanf("%s%d", s+1, &k);
	int n = strlen(s + 1);
	ll ans = 0;
    if (s[1] == s[n]) {
		int l = 1;
		while (s[1] == s[l]) l ++;
		l --;
		if (l == n) {
			ans = 1ll * k * n / 2;
		}
		else {
			int r = n;
			while (s[n] == s[r]) r --;
			r ++;
			ans = ((n - r + 1 + l) / 2) * 1ll * (k - 1);
			ans += l / 2;
			ans += (n - r + 1) / 2;
			for (int i = l + 1; i < r; ) {
				int j = i;
				while (j < r && s[i] == s[j]) j ++;
				ans += 1ll * k * ((j - i) / 2);
				i = j;
			}
		}
    }
    else {
		for (int i = 1; i <= n; ) {
			int j = i;
			while (j <= n && s[i] == s[j]) j ++;
			ans += 1ll * k * ((j - i) / 2);
			i = j;
		}
    }
    cout<<ans<<endl;
}


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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

const ll MOD = (ll)(1e9 + 7);


int dp[302][302][302];
int L[302], R[302], x[302];
vector<int> qs[302];

bool satisfy(int L, int x, int r, int g, int b) {
  // R == k == max(r, g, b)
  // [L, R]の間にちょうどx種類の色が出現する
  return (L <= r)+(L <= g)+(L <= b) == x;
}

int main2() {
  CLR(dp, 0);
  REP(i, 302) qs[i].clear();

  int N = nextInt();
  int M = nextInt();
  REP(i, M) {
    L[i] = nextInt();
    R[i] = nextInt();
    x[i] = nextInt();
    qs[R[i]].push_back(i);
  }

  dp[0][0][0] = 1;
  for (int r = 0; r <= N; r++) {
    for (int g = 0; g <= N; g++) {
      for (int b = 0; b <= N; b++) {
        if (dp[r][g][b] == 0) continue;
        int k = max(r, max(g, b));
        bool ng = false;
        for (int q : qs[k]) if (!satisfy(L[q], x[q], r, g, b)) ng = true;
        if (ng) {
          dp[r][g][b] = 0;
          continue;
        }
        (dp[k+1][g][b] += dp[r][g][b]) %= MOD;
        (dp[r][k+1][b] += dp[r][g][b]) %= MOD;
        (dp[r][g][k+1] += dp[r][g][b]) %= MOD;
      }
    }
  }
  ll ans = 0;
  for (int r = 0; r <= N; r++) {
    for (int g = 0; g <= N; g++) {
      for (int b = 0; b <= N; b++) {
        if (r == N || g == N || b == N) {
          ans += dp[r][g][b];
          ans %= MOD;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

int main() {
  for (;!cin.eof();cin>>ws)
    main2();
  return 0;
}


Measured memory_bytes: 107904
import sys
from collections import deque


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    a = list(map(int, input().split()))
    A = [0] +a
    a_max = max(A)
    dp = [[0] * (K + 1) for _ in range(N + 1)] # dp[i][j] i:既に配った数 j :番目の子供     10^7なので辛い
    mod = 10**9+7
    accum=[0] *(K+2)
    dp[0][0]=1
    for i in range(1,N): # i さん 1からN１−１さんまで
        lim = A[i] # iさんの上限
        count =0
        for t in range(K+1):
            count +=dp[i-1][t]
            accum[t+1] = count

        for j in range(K+1): # 総数
            dp[i][j] =accum[j+1] -accum[max(j-lim,0)]
            dp[i][j] %=mod


    ans =0
    for i in range(0,A[-1]+1):
        ans +=dp[N-1][K-i]
        ans %=mod

    print(ans)









if __name__ == "__main__":
    main()


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

l = []
city = []
for i in range(n):
  s,p = input().split()
  city.append(s)
  l.append([s,int(p),i+1])

l.sort(key=lambda i: i[1], reverse=True)

for i in sorted(set(city)):
  for j in l:
    if j[0] == i:
      print(j[2])

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

int main(void) {
  int n, k;
  string s;
  cin >> n >> k >> s;

  vector<int> comp;

  bool start1 = (s[0] == '1' ? true : false);

  int cnt = 1;
  s += '5';
  rep (i, n) {
    if (s[i] == s[i + 1]) cnt++;
    else {
      comp.push_back(cnt);
      cnt = 1;
    }
  }
  //rep (i, comp.size()) cout << comp[i] << endl;

  vector<int> sum(comp.size() + 1, 0);
  rep (i, comp.size()) sum[i + 1] = comp[i];

  rep (i, comp.size()) sum[i + 1] += sum[i];

  

  
  if (comp.size() == 1) {
    cout << comp[0] << endl;
    return 0;
  }
  else if (comp.size() == 2) {
    cout << comp[0] + comp[1] << endl;
    return 0;
  }
  

  int ans = 0;

  int t = (start1 ? 1 : 0) ;

  for (int left = 0; left < sum.size(); left++) {
    if (left % 2 != t) {
      int right = left + k * 2 + 1;
      if (right >= sum.size()) right = sum.size() - 1;
      ans = max(ans, sum[right] - sum[left]);
    }
    else {
      int right = left + k * 2;
      if (right >= sum.size()) right = sum.size() - 1;
      ans = max(ans, sum[right] - sum[left]);
    }
  }

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

Measured memory_bytes: 1272
import sys
import math
stdin = sys.stdin
mod = 10**9 + 7

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
sa = lambda h: [list(map(int, stdin.readline().split())) for i in range(h)]

r = ni()

print(r**2)

Measured memory_bytes: 3064
#include<cstdio>
#include<sstream>
#include<cstdlib>
#include<cctype>
#include<cmath>
#include<algorithm>
#include<set>
#include<queue>
#include<stack>
#include<list>
#include<iostream>
#include<fstream>
#include<numeric>
#include<string>
#include<vector>
#include<cstring>
#include<map>
#include<iterator>
#include<bitset>
typedef long long ll;
double pi=3.1415926535897931159979635;
using namespace std;

string con_num(ll n) {
    ll b; 
    string a;
    while(n) {
        n--;
        a+=n%26+'a';
        n/=26;
    }
    return a;
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n,d;
    cin>>n;
    string a,b;
    a=con_num(n);
    d=a.size();
    
    for(int i=0,j=d-1; i<d/2; i++,j--) {
        b[0]=a[i];
        a[i]=a[j];
        a[j]=b[0];
    }
    cout<<a<<"\n";

    return 0;

}

Measured memory_bytes: 3664
S = input()
ans = 0
tmp_ans = 0
for i in range(len(S)):
    if S[i]=='A' or S[i]=='C' or S[i]=='G' or S[i]=='T' :
        tmp_ans += 1
        ans = max(tmp_ans, ans)
    else:
        tmp_ans = 0

print(ans)

Measured memory_bytes: 2940
using System;

public class Hello{
    public static void Main(){
        // Here your code !
        // your code goes here
        bool isCon = true;
        
        while(isCon){
            string line = System.Console.ReadLine();
            string[] ab = line.Split(' ');
            int a = Convert.ToInt32(ab[0]);
            string op = Convert.ToString(ab[1]);
            int b = Convert.ToInt32(ab[2]);
            if(op.Equals("?")){
                isCon = false;
            }else if(op.Equals("+")){
                Console.WriteLine(a+b);
            }else if(op.Equals("-")){
                Console.WriteLine(a-b);
            }else if(op.Equals("*")){
                Console.WriteLine(a*b);
            }else if(op.Equals("/")){
                Console.WriteLine(a/b);
            }
        }
    }
}

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

const int mod = 1e9 + 7;
void add_self (int & a, int b) {
	a += b;
	if (a >= mod) a -= mod;
}

int main() {
	int H, W;
	scanf ("%d%d", &H, &W);
	vector < string > grid (H);
	for (int i = 0; i < H; i++) {
		cin >> grid[i];
	}
	vector < vector < int > > dp (H, vector < int > (W));
	dp[0][0] = 1;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '#') {
				dp[i][j] = 0; continue;
			}
			if (i != 0) {
				add_self (dp[i][j], dp[i - 1][j]);
			}
			if (j != 0) {
				add_self (dp[i][j], dp[i][j - 1]);
			}
		}
		//cout << endl;
	}
	printf ("%d\n", dp[H - 1][W - 1]);
	return 0;
}


Measured memory_bytes: 5248
L,R = map(int,input().split())
# R-LはLからRまでの個数を表す
#解の最小は０であり、LからRまでに2019の倍数が存在すればよい
# R-L > 2018ならRからLに2019の倍数が出てくることになる
if R - L >= 2018:
    print(0)
else:
    ans = 2019
    #iとj=i+1でi*jmod2019の最小値を全探索
    for i in range(L,R):
        for j in range(i+1,R+1):
            ans = min(ans,i*j % 2019)
    print(ans)

Measured memory_bytes: 2940