akhauriyash/Code-Regression huggingface dataset:
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 

 
int main()
{
    //ios_base::sync_with_stdio(false);
    //cin.tie(NULL);
    
    long long int n,sum=0;
    cin>>n;
    vector<long long int>a(n+1);
    
    for(int i=1;i<=n;i=i+1) for(int j=i;j<=n;j=j+i) a[j]++;
    
    for(int i=1;i<=n;i=i+1) sum+=i*a[i];
    cout<<sum<<endl;
}


 


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

int main(){
	int n;
	cin >> n;
	vector<int> v(n);
	long long sum = 0;
	for(int i = 0; i < n; i++){
		cin >> v[i];
		sum += v[i];
	}

	long long ans = 1e18;
	long long x = 0;
	long long y;
	for(int i = 0; i < n - 1; i++){
		x += v[i];
		y = sum - x;
		ans = min(ans, abs(x - y));
	}
	cout << ans << endl;


}


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

int main(){
    int n;
    double num, cnt;
    string s;
    cin >> n;
    cnt = 0.0;
    for(int i = 0; i < n; i++){
        cin >> num >> s;
        if(s == "JPY") cnt += num;
        else {
          num *= 380000;
          cnt += num;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    int d = a[2]-a[1];
    int e = a[2]-a[0];
    if(d%2==e%2 && d%2==0){
        cout << d/2+e/2 << endl;
    }
    else if(d%2==e%2 && d%2==1){
        cout << 1+d/2+e/2 << endl;
    }
    else{
        cout << 1+(d+e+1)/2 << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;cin >> n;
vector<int>a(n);
vector<int>b(n);
for(int i = 0;i<n;i++){
    cin >> a[i]>>b[i];
}
sort(a.begin(),a.end());
sort(b.begin(),b.end());
if(n%2==0){
    cout << b[n/2-1]+b[n/2]-a[n/2-1]-a[n/2]+1;
}
else {
    cout << b[n/2]-a[n/2]+1;
}
return 0;
}

Measured memory_bytes: 4840
/**
 * @author torith
 * @date 2018-10-31
 */

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;


vector<int> edges[10];
int goal;

int dfs(int now, vector<int> visited){
    visited.push_back(now);
    if((int) visited.size() == goal) return 1;
    int rtn = 0;

    for (auto & e: edges[now]){
        auto r = find(visited.begin(),visited.end(),e);
        if (r == visited.end()) {
            rtn += dfs(e,visited);
        }
    }

    return rtn;
}

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

    int N,M; cin >> N >> M;
    goal = N;
    for (int i = 0; i < M; ++i) {
        int a,b; cin >> a >> b;
        edges[a-1].push_back(b-1);
        edges[b-1].push_back(a-1);
    }

    vector<int> ini = {};
    cout << dfs(0,ini) << "\n";

    return 0;
}



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

long long int func(long long int a, long long int x){
	if (a==-1) return 0;
  	else return a/x+1;
}

int main() {
  
  long long int a,b,x;
  cin >> a >> b >> x;
  cout << func(b,x)-func(a-1,x) << endl;
  
}

Measured memory_bytes: 256
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

#define REP(i,a,b) for(int i=a; i<=b; i++)

#define MOD 1000000007

void solve(int test_case) {//227
	int n,m;
	cin>>n>>m;
	cout<<((n-m)*100+1900*m)*(1<<m);
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3684
package main

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

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)

	for sc.Scan() {
		s := strings.Split(sc.Text(), " ")
		H, _ := strconv.Atoi(s[0])
		W, _ := strconv.Atoi(s[1])

		if H == 0 && W == 0 {
			return
		}

		for h := 0; h < H; h++ {
			if h == 0 || h == H-1 {
				for w := 0; w < W; w++ {
					fmt.Print("#")
				}
			} else {
				fmt.Print("#")
				for w := 1; w < W-1; w++ {
					fmt.Print(".")
				}
				fmt.Print("#")
			}
			fmt.Println()
		}
		fmt.Println()
	}
}



Measured memory_bytes: 1096
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)

int main()
{
  string s;
  cin >> s;
  ll count = 0;

  set<int> se;

  for (int i = 0; i < 4; i++)
  {
    se.insert(s[i] - '0');
  }

  if (se.size() == 2)
  {
    cout << "Yes" << endl;
  }
  else
  {

    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//https://atcoder.jp/contests/agc017/tasks/agc017_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
ll dp[54][2]={}; //Ai,P=0,1
int main() {
    ll N,P; cin>>N>>P;
    vector<ll> an(N+1);
    FOR(i,1,N+1){
        cin>>an[i];
    }
    dp[0][0]=1;
    FOR(i,1,N+1){
        //選ばない
        dp[i][0]=dp[i-1][0];
        dp[i][1]=dp[i-1][1];
        //選ぶ
        if(an[i]%2==0){
            dp[i][0]+=dp[i-1][0];
            dp[i][1]+=dp[i-1][1];
        }else{ //odd
            dp[i][0]+=dp[i-1][1];
            dp[i][1]+=dp[i-1][0];
        }
    }
    cout<<dp[N][P]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lld long long
#define pb push_back
#define mk make_pair
#define MAX (lld)1e18+7
#define lim (lld)1e9+7
#define MAX2 (lld)2e5+9
#define ff first
#define ss second
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
using namespace std;

const lld mod=lim;

lld power(lld x, lld y, lld p)  
{   lld res = 1;     x = x % p; if (x == 0) return 0;  
  
    while (y > 0)  
    { if (y & 1) res = (res*x) % p;  y = y>>1; x = (x*x) % p;   }  
    return res;  } 


lld extend_gcd(lld a, lld b, lld& x, lld& y) {
    if (b == 0) { x = 1;y = 0;return a;}
    lld x1, y1;
    lld d = extend_gcd(b, a % b, x1, y1);
    x = y1; y = x1 - y1 * (a / b);return d;	}

lld rowNum[]={-1,0,0,1};
lld colNum[]={0,-1,1,0};

int main()
{
	fastio
	lld n,d,cnt=0;
	cin>>n>>d;

	std::vector<lld> x(n);
	std::vector<lld> y(n);

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

	for(lld i=0;i<n;i++)
	{
		if(x[i]*x[i]+y[i]*y[i]<=d*d)
			cnt++;
	}

	cout<<cnt<<endl;
}

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  vector<int> a(n + 1);
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    ans += a[i];
  }
  int m;
  cin >> m;
  for (int i = 1; i <= m; i++) {
    int u, v;
    cin >> u >> v;
    cout << ans - a[u] + v << '\n';
  }
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
    int N, L;
    string s;

    cin >> N >> L;
    vector<string> mtrx(N);

    for(int j = 0;j < N; ++j) {
        cin >> s;
        mtrx[j] = s;
    }

    sort(mtrx.begin(), mtrx.end());

    for(int i = 0;i < N; ++i) {
        cout << mtrx[i];
    }
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n;
	
	while(scanf("%d",&n) != EOF){
		int i,j,k,l;
		int result = 0;
		
		for(i = 0;i <= 9;i++){
			for(j = 0;j <= 9;j++){
				for(k = 0;k <= 9;k++){
					for(l = 0;l <= 9;l++){
						if(i+j+k+l == n)result++;
					}
				}
			}
		}
		printf("%d\n",result);
	}
	return 0;
}

Measured memory_bytes: 596
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,a,b) for(int i(a);i<b;i++)
#define rep(i,n) for(int i(0);i<n;i++)
#define fast  ios_base::sync_with_stdio(0); cin.tie(0);
#define pres(x) cout<<fixed; cout<<setprecision(x);
#define open freopen("input.txt","r",stdin) ; freopen("output.txt","w",stdout);
#define watch(x) cout<<(#x)<<" is "<<x<<"\n";
#define out(x) cout<<x<<"\n";
#define pb push_back
#define all(v) v.begin() v.end()

int ceil(int a , int b){
	if(a%b == 0)return a/b;
	else return a/b + 1;
}

int32_t main(){
	
	fast;
	//open;

	int a, b;
	cin>>a>>b;
	cout<<ceil(b-1 , a-1);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    int n,k,q; cin >> n >> k >> q;
    vi a(n,k-q);
    rep(i,q){
        int x; cin >> x;
        a[x-1]++;
    }
    rep(i,n){
        if(a[i] > 0) yes();
        else no();
    }
    return 0;
}


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



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

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

	cout<<a[0];
	for(int i=1;i<n;i++)cout<< " " << a[i];
	cout<<endl;

	for(int i=1;i<n;i++){
		v=a[i];
		
		for(int j=i-1;j>=0 && a[j]>v;j--){
			a[j+1]=a[j];
			a[j]=v;
		}


		cout<<a[0];
		for(int i=1;i<n;i++)cout<< " " << a[i];
		cout<<endl;
	}

	

	return 0;
}




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

using namespace std;

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

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

  vector<int> B(M);
  for (int i = 0; i < M; ++i) {
    cin >> B.at(i);
  }
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cin >> A.at(i).at(j);
    }
  }

  int counter = 0;
  for (int i = 0; i < N; ++i) {
    int sum = C;
    for (int j = 0; j < M; ++j) {
      sum += A.at(i).at(j) * B.at(j);
    }
    if (sum > 0) {
      counter++;
    }
  }
  cout << counter << endl;
}


Measured memory_bytes: 3656
length = int(input())
arr = input().split()

iniV = int(arr[0])

mi = iniV
mx = iniV
su = 0
for s in arr:
    val = int(s)
    su += val
    if(val < mi):
        mi = val
    if(val > mx):
        mx = val

print(mi, mx, su)



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

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

	cout << fixed << setprecision(10);
	double a, b;
	cin >> a >> b;
	cout << a/b;
	return 0;
}


Measured memory_bytes: 256
import * as fs from 'fs';

const input = fs.readFileSync('/dev/stdin', 'utf8');
const args: string[][] = input.split('\n').map(l => l.split(' '));

const k = parseInt(args[0][0]);
const [a, b] = args[1].map(x => parseInt(x));

let tmp = k;
let msg = 'NG';
while (tmp <= b) {
    if (a <= tmp && tmp <=b) {
        msg = 'OK';
        break
    }
    tmp += k;
}

console.log(msg);

Measured memory_bytes: 29636
#include<iostream>

using namespace std;

int dp[101][10001];

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

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

    cout << dp[N][W] << endl;
}


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

using namespace std;

const int MAX = 100005;
typedef pair<char, int> P;

class UnionFind{
public:
  int par[MAX];
  int rank[MAX];
  int mark[MAX];
  void init(int n){
    for(int i = 1; i <= n; i++){
      par[i] = i;
      rank[i] = mark[i] = 0;
    }
  }
  
  int find(int x){
    if(mark[x] > 0) return x;
    else return par[x] = find(par[x]);
  }
};

int N,M;
UnionFind T;
vector<P> V;

void init(){
  T.init(N);
  T.mark[1] = MAX;
  V.clear();
}

void input(){
  for(int i = 0; i < N-1; i++){
    int in;
    cin >> in;
    T.par[i+2] = in;
  }

  for(int i = 0; i < M; i++){
    char c;
    int in;
    cin >> c >> in;
    if(c == 'M') T.mark[in]++;
    V.push_back(P(c,in));
  }
}

void solve(){
  long long ans = 0;
  for(int i = V.size()-1; i>=0; i--){
    if(V[i].first == 'M') T.mark[V[i].second]--;
    else ans += T.find(V[i].second);
  }
  cout << ans << endl;
}
int main(){
  while(cin >> N >> M && N+M){
    init();
    input();
    solve();
  }
  return 0;
}

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

int main(){
int a,b;
char op;

while(true){
cin >> a >> op >> b;
if(op == '+') {
cout << a+b<<endl;} else if(op == '-') {
cout << a-b<<endl;} else if(op == '*') {
cout << a*b<<endl;} else if(op == '/') {
cout << a/b<<endl;} else {break;}
}
    return 0;
}

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

typedef long long ll;
typedef vector <bool> v_bool;
typedef vector <ll> v_ll;
typedef vector <vector <ll> > vv_ll;
typedef vector < pair <ll,ll> > vp_ll;
typedef pair <ll,ll> p_ll;

bool TEST=false;
ll MOD = 1000000007;

void show(){if (TEST){cout << endl;}}
void show(string x){if (TEST){cout << x;}}
void show(string x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(ll x){if (TEST){cout << x;}}
void show(ll x,bool enter){
  if (TEST){if (enter) cout << "<#> " << x << endl;else cout << x;}
}
void show(p_ll p){
  if (TEST){cout << "{ ";show(p.first);cout << " ";show(p.second);cout << " }";}
}
void show(v_ll v){
  if (TEST){
    cout << "<begin> ";
    for (ll i=0;i<v.size();i++){show(v[i]); cout << " ";}cout <<"<end>"<< endl;
}}
void show(vv_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}
void show(vp_ll v){
  if (TEST){
    cout << "//////////" << endl;
    for (ll i=0;i<v.size();i++){
      show(v[i]); cout << endl;
}}}

ll mod(ll x){
  ll n=MOD;
  ll ret=x%n;
  if (ret<0)ret+=n;
  return ret;
}
void mod_self(ll &x){
  x=mod(x);
}
ll mod_inv(ll x){
  ll n=MOD;
  ll y = x,z = n-2, ret=1;
  y=mod(y);
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  return ret;
}
ll mod_pow(ll x,ll a){
  ll y = x,z = a,ret=1;
  y=mod(y);
  if (z<0)z=-z;
  while (z>0){
    if(z%2==1) ret=mod(ret*y);
    y=mod(y*y);
    z/=2;
  }
  if (a<0) ret=mod_inv(ret);
  return ret;
}
v_ll mod_nck(ll n){
  v_ll nck(n+1,0);
  nck[0]=1;
  for (ll i=1;i<=n;i++){
    nck[i]=mod(nck[i-1]*(n+1-i));
    nck[i]=mod(nck[i]*mod_inv(i));
  }
  return nck;
}
v_ll mod_factorial(ll n){
  v_ll fct(n+1,0);
  fct[0]=1;
  for (ll i=1;i<=n;i++){
    fct[i]=mod(fct[i-1]*i);
  }
  return fct;
}

ll K,X;
int main(){
  cin >> K >> X;
  for (ll i=X-(K-1);i<=X+(K-1);i++){
    if (i>X-(K-1)) cout << " ";
    cout << i;
  }
  cout << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a, b, c, i;
    while (1)
    {
        scanf("%d %d", &a,&b);
        if (a==0 && b==0) break;

        for (i=1; i<=a; i++)
        {

        for(c=1; c<=b; c++)
            {
            printf("#");
        }
        printf("\n");
        }
        printf("\n");
    }
}



Measured memory_bytes: 2064
#### import ####
import sys
sys.setrecursionlimit(10**7)
import math
from collections import defaultdict

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
  read_all = [tuple(map(int, input().split())) for _ in range(N)]
  return map(list,zip(*read_all))

#################

S = str(input())
while S:
  ls = len(S)
  if ls>=7:
    if S[-7:]=='dreamer':
      S = S[:-7]
      continue
    elif S[-6:]=='eraser':
      S = S[:-6]
      continue
    elif S[-5:]=='dream':
      S = S[:-5]
      continue
    elif S[-5:]=='erase':
      S = S[:-5]
      continue
    else:
      print('NO')
      exit()
  if ls>=6:
    if S[-6:]=='eraser':
      S = S[:-6]
      continue
    elif S[-5:]=='dream':
      S = S[:-5]
      continue
    elif S[-5:]=='erase':
      S = S[:-5]
      continue
    else:
      print('NO')
      exit()
  if ls>=5:
    if S[-5:]=='dream':
      S = S[:-5]
      continue
    elif S[-5:]=='erase':
      S = S[:-5]
      continue
    else:
      print('NO')
      exit()
  print('NO')
  exit()

print('YES')

Measured memory_bytes: 135048
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#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 inf (ll)1e9
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<setprecision(7)<<x<<endl
vector<int> vec;

int n,temp,a[100001],minv=inf,flag;
int main(void){
    cin>>n;
    rep(i,n){
        cin>>a[i];
        if(minv>a[i])minv=a[i];
    }
    while(-1){
        flag=1;
        rep(i,n){
            if(a[i]!=minv)a[i]%=minv;
        }
        rep(i,n){
            if(a[i]==0)continue;
            if(minv>a[i])minv=a[i];
        }
        //p("");
        //rep(i,n)p(a[i]);
        rep(i,n)if(a[i]>minv)flag=0;
        if(flag==1)break;
    }
    p(minv);
}


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

using namespace std;

int main() {
    int x, y;
    cin >> x >> y;
    if (x == y)
        cout << "Draw";
    else if ((x > y or x==1) and y != 1 ) {
        cout << "Alice";
    } else if ((y>x or y==1) and x != 1) {
        cout<<"Bob";
        return 0;
    }
}

Measured memory_bytes: 256
// AOJ 1174

#include <iostream>
#include <algorithm>
using namespace std;

int data[10][10], done[10][10];
int h, w, c;
int ret, cnt;

void coloring(int x, int y, int color, int from);
void calc(int x, int y, int color);

void rec(int deep)
{
	if (deep == 5){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				done[i][j] = 0;
			}
		}
		coloring(1, 1, c, data[1][1]);
		cnt = 0;
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				done[i][j] = 0;
			}
		}
		calc(1, 1, c);
		ret = max(ret, cnt);
	}
	else {
		for (int i = 1; i <= 6; i++){
			int tmp[10][10];
			for (int i = 0; i < 10; i++){
				for (int j = 0; j < 10; j++){
					tmp[i][j] = data[i][j];
					done[i][j] = 0;
				}
			}
			coloring(1, 1, i, data[1][1]);
			rec(deep + 1);
			for (int i = 0; i < 10; i++){
				for (int j = 0; j < 10; j++){
					data[i][j] = tmp[i][j];
				}
			}
		}
	}
	
	return;
}

void coloring(int x, int y, int color, int from)
{
	if (data[y][x] == from && done[y][x] == false){
		data[y][x] = color;
		done[y][x] = true;
		coloring(x + 1, y, color, from);
		coloring(x - 1, y, color, from);
		coloring(x, y + 1, color, from);
		coloring(x, y - 1, color, from);
	}
	return;
}

void calc(int x, int y, int color)
{
	if (data[y][x] == color && done[y][x] == false){
		cnt++;
		done[y][x] = true;
		calc(x + 1, y, color);
		calc(x - 1, y, color);
		calc(x, y + 1, color);
		calc(x, y - 1, color);
	}
	return;
}

int main(void)
{
	while (cin >> h >> w >> c, h && w){
		for (int i = 0; i < 10; i++){
			for (int j = 0; j < 10; j++){
				data[i][j] = -1;
			}
		}
		
		for (int i = 1; i <= h; i++){
			for (int j = 1; j <= w; j++){
				cin >> data[i][j];
			}
		}
		ret = 0;
		rec(1);
		
		cout << ret << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1164
#include<stdio.h>

int main()
{
  int n;
  int l[200];
  int i,j;
  int tmp;
  int sum;
  scanf("%d",&n);
  for(i=0;i<2*n;i++)
  {
    scanf("%d",&l[i]);
  }
  for(i=0;i<2*n;i++)
  {
    for(j=i+1;j<2*n;j++)
    {
      if(l[i] < l[j])
      {
        tmp = l[i];
        l[i] = l[j];
        l[j] = tmp;
      }
    }
  }
  for(i=0;i<n;i++)
  {
    sum += l[i*2+1];
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cstdio>
#include <cstring>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>

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

#define FALSE printf("false\n");
#define TRUE printf("true\n");
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
#define rep(i,n) for(int i = 0;i < ((int)(n));++i)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SUM(vec) accumulate(all(vec),0LL)
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define test(a) cout<<"line:"<<__LINE__<<"["<<(#a)<<": "<<(a)<<"]"<<endl

const int INF = 1e9+7;
const ll INFL = 9*1e18;

ll inline digit(ll num){int tmp = 0;while(num){tmp++;num/=10;}return tmp;}
template<typename T>inline T digitSum(T num){T sum = 0;while(num){sum+=num%10;num/=10;}return sum;} // 各桁の和
template<typename T>inline T gcd(T a,T b){if(b == 0)return a;return gcd(b,a%b);}
template<typename T>inline T lcm(T a, T b){T g = gcd(a,b);return a/g*b;}
template<typename T>inline T power(T a,T b){T tmp=1;rep(i,b){tmp*=a;}return tmp;}


bool isOk(ll key,ll value){
  return key >= value;
}

ll binary_search(vector<ll> a,ll key){
  ll ok = a.size()-1;
  ll ng = 0;

  while(abs(ok - ng) > 1){
    ll mid = (ok + ng) / 2;
    if(isOk(key,a[mid]))ok = mid;
    else ng = mid;
  }
  return ok;
}

bool isPrime(ll n) {
	for (int i = 2; n >= i * i; ++i) {
		if(!(n % i))return false;
	}
  return true;
}
vector<ll> primes(ll n){
  vector<ll> v(1,1);
  for (ll i = 2; n >= i * i; ++i) {
		if(!(n % i)){
      v.pb(i);
	  }
  }
  if(v.size()==1)v.pb(n);
  return v;
}

int main() {
  cin.tie(0); ios::sync_with_stdio(0);
  ll n,m;cin>>n>>m;
  vector<ll> a(n);rep(i,n)cin>>a[i];
  ll tmp = a[0]/2;

  int two = 0;
  rep(i,n){
    int b = a[i];
    int temp = 0;
    while(b && !(b%2)){
      b/=2;
      if(!i)two++;
      else  temp++;
    }
    if(i != 0 && two != temp){
      print(0);
      return 0;
    }
  }
  
  rep(i,n)tmp = lcm(tmp,a[i]/2);
  ll ans = (m/tmp)/2+(m/tmp)%2;

  
  print(ans);
  return 0;
} 

Measured memory_bytes: 1024
import java.util.*;
import java.lang.*;

public class Main {
	static int n;
	static int A;
	static int B;
	static int C;
	static int[] l;
	static int mincost;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		n = sc.nextInt();
		A = sc.nextInt();
		B = sc.nextInt();
		C = sc.nextInt();
		l = new int[n];
		for (int i = 0; i < n; i++) {
			l[i] = sc.nextInt();
		}
		mincost = 1000000000;
		dfs(0, 0, 0, 0, 0);
		System.out.println(mincost);
	}
	static void dfs(int cnt, int a, int b, int c, int cost) {
		if (cnt == n) {
			if (a == 0 || b == 0 || c == 0) {
				cost = 1000000000;
			} else {
				cost += Math.abs(A - a) + Math.abs(B - b) + Math.abs(C - c) - 30;
			}
			mincost = Math.min(mincost, cost);
			return;
		}
		dfs(cnt + 1, a, b, c, cost);
		dfs(cnt + 1, a + l[cnt], b, c, cost + 10);
		dfs(cnt + 1, a, b + l[cnt], c, cost + 10);
		dfs(cnt + 1, a, b, c + l[cnt], cost + 10);

	}
}

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

int main(){
    double N,A = 0;
    cin >> N;
    for (int i = 1; i <= N;i++){
        if (i % 2 == 1)
            A++;
    }
    cout << A / N << endl;
}


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

#include <boost/range/adaptors.hpp>
#include <boost/range/combine.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int main() {
    string s;
    cin >> s;

    if (s == "RRR") {
        cout << 3 << endl;
    } else if (s == "RRS" || s == "SRR") {
        cout << 2 << endl;
    } else if (s == "RSS" || s == "SRS" || s == "SSR" || s == "RSR") {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
}

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

#define F first
#define S second

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;

const int N = 100010, M = 110, mod = 1e9 + 7;

int n, m, k;
vector<LL> a, b;

int get(vector<LL> &a, int n, LL st)
{
	int l = 0, r = n + 1;
	while (l < r)
	{
		int mid = l + r >> 1;
		if (a[mid] >= st) r = mid;
		else l = mid + 1;
	}
	return r;
}

int main()
{
	scanf("%d%d%d", &n, &m, &k);
	a.resize(n + 2), b.resize(m + 2);
	for (int i = 1; i <= n; i ++ ) scanf("%lld", &a[i]);
	for (int i = 1; i <= m; i ++ ) scanf("%lld", &b[i]);
	a[0] = b[0] = -1e18, a[n + 1] = b[m + 1] = 1e18;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	
	while (k -- )
	{
		LL x, res = 1e18;
		scanf("%lld", &x);
		int i = get(a, n, x);
		int j = get(b, m, x);
		
		LL ra = a[i] - x;
		LL rb = b[j] - x;
		LL la = x - a[i - 1];
		LL lb = x - b[j - 1];
		
		res = min(res, max(ra, rb));
		res = min(res, max(la, lb));
		res = min(res, la + rb + min(la, rb));
		res = min(res, ra + lb + min(ra, lb));
		printf("%lld\n", res);
	}
	return 0;
}

Measured memory_bytes: 2816
#coding: utf-8
from collections import deque

N = int(input())
F = []
for i in range(N):
    F.append([int(x) for x in input().split()])

P = []
for i in range(N):
    P.append([int(x) for x in input().split()])

ret = None
for bit in range(1, 2**10):
    nWork = [0] * N
    for i in range(10):
        if (bit >> i) & 1:
            for shop in range(N):
                if F[shop][i] == 1:
                    nWork[shop] += 1

    cand = 0
    for i in range(N):
        cand += P[i][nWork[i]]
    if ret == None or cand > ret:
        ret = cand
print(ret)



Measured memory_bytes: 9516
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <bitset>
typedef long long ll;
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
 
const int mod = 1000000007;
//const int mod = 998244353;
 
 
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
 
 
struct combination {
  vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
} c(200005);
 
vector<pair<long long, long long> > prime_factorize(long long N) {
    vector<pair<long long, long long> > res;
    for (long long a = 2; a * a <= N; ++a) {
        if (N % a != 0) continue;
        long long ex = 0; // 指数
 
        // 割れる限り割り続ける
        while (N % a == 0) {
            ++ex;
            N /= a;
        }
 
        // その結果を push
        res.push_back({a, ex});
    }
 
    // 最後に残った数について
    if (N != 1) res.push_back({N, 1});
    return res;
}
vector<long long> enum_divisors(long long N) {
    vector<long long> res;
    for (long long i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            res.push_back(i);
            // 重複しないならば i の相方である N/i も push
            if (N/i != i) res.push_back(N/i);
        }
    }
    // 小さい順に並び替える
    sort(res.begin(), res.end());
    return res;
}
 
int main(int argc, const char * argv[]) {
    
    string S,T;
    cin >> S;
    cin >> T;
    
    ll sum=0;
    for(ll i=0;i<S.size();i++){
        if(S[i]!=T[i]) sum++;
    }
    
    cout << sum << endl;
    
    
    
    
    return 0;
}


Measured memory_bytes: 6996
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, x;
    cin >> a >> b;
    for(x=a/8*100; ; x++){
        if(x*8/100 == a && x/10 == b)
            break;
        if(x*8/100 > a || x/10 > b){
            cout << -1 << '\n';
            return 0;
        }
    }
    cout << x << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <climits>
#include <cmath>

using namespace std;



long long int height[50], count_p[50];



int main(int argc, char *argv[])
{
	int n ,m;
	vector<int> x;
	//input
	cin >> n >> m;
	for (int i = 0; i < m; i++){
		int xi;
		cin >> xi;
		x.push_back(xi);
	}


	//calc
	sort(x.begin(), x.end());

	int min_x = x[0];
	int max_x = x[m - 1];
	int range = (max_x - min_x);
	vector<int> space;
	space.push_back(0);
	for (int i = 1; i < m; i++){
		int space_i = x[i] - x[i - 1];
		space.push_back(space_i);
	}
	
	sort(space.begin(), space.end(), greater<int>());
	int ans = range;
	for (int i = 0; i < min(n - 1, m); i++){
		ans -= space[i];
	}
	if (ans < 0){
		ans = 0;
	}


	//ans
	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 1400
n = int(input())
comments = {}

for i in range(1, n+1):
    ni = int(input())
    comments[i] = [tuple(map(int, input().split())) for _ in range(ni)]

nhonests = [0]

for ibin in [format(i, "b") for i in range(2**n, 2**(n+1))]:
    lie, ni = 0, 1
    ### print(ibin) ###
    
    while (not lie) and ni < n+1:          
        for ci in comments[ni]:
            if int(ibin[ni]) and ci[1] ^ int(ibin[ci[0]]):
                lie += 1
                
        ### print(comments[ni], lie) ###
        ni += 1
        
    if not lie:
        nhonests.append(ibin.count("1") - 1)
        
print(max(nhonests))

Measured memory_bytes: 5912
n,m=map(int,input().split())
l=[[0 for i in range(2)]for j in range(n+1)]
wa,ac=0,0
for i in range(m):
  p,s=input().split()
  p=int(p)
  if s=="WA" and l[p][1]==0:
    l[p][0]+=1
  elif s=="AC" and l[p][1]==0:
    l[p][1]+=1
    ac+=1
    wa+=l[p][0]
print(ac,wa)  

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

int main(){
  int A, B, i, i1 , i2, i3, i4, i5, a;
  a = 0;
  cin >> A >> B;
  
  for(i=A; i<B+1; i++){
    i1 = i / 10000;
    i2 = (i % 10000) / 1000;
    i3 = (i % 1000) / 100;
    i4 = (i % 100) / 10;
    i5 = i % 10;
    if(i1 == i5 && i2 == i4){
      a++;
    }
  }
  cout << a << endl;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  for(int i = 1; i <= N; i++){
    cin >> A.at(i);
  }
  
  bool can = false;
  int count = 0;
  int b = 1;
  for(int i = 0; i < N; i++){
    if(b == 2){
      can = true;
      break;
    }
    count++;
    b = A.at(b);
  }
  if(can == true){
    cout << count << endl;
  }
  else{
    cout << "-1" << endl;
  }
        
}

Measured memory_bytes: 640
#include <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>

using namespace std;
using ll = long long;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((int)(x).size())
#define MSG(a) cout << #a << " " << a << endl;

int main()
{
    int N;
    cin >> N;
    vector<int> v(N);
    REP(i, N)
    {
        cin >> v[i];
    }

    int maxNum = *max_element(ALL(v));
    if (count(ALL(v), maxNum) > 1)
    {
        REP(i, N)
        {
            cout << maxNum << endl;
        }
    }
    else
    {
        REP(i, N)
        {
            int tmp = v[i];
            if (tmp == maxNum)
            {
                v[i] = *min_element(ALL(v));
                cout << *max_element(ALL(v)) << endl;
                v[i] = tmp;
            }
            else
            {
                cout << maxNum << endl;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2432
o=input()
e=input()
l=[]
if len(o)==len(e):
  for x in range(len(o)):
    l.append(o[x])
    l.append(e[x])
else:
  for x in range(len(e)):
    l.append(o[x])
    l.append(e[x])
  l.append(o[len(o)-1])
print(''.join(l))

Measured memory_bytes: 3064
'''
先に基準を変数で設定して、whileで回すと見た目もきれいだし、あとから調整も楽。
ついでだからclass化する？しなくてもいいけど。
while意味ない
'''
s = []

while True:
    t = input()
    if t == "-1 -1 -1":
        break
    else:
        s.append(list(map(int, t.split())))
        
#print(r)

#テスト値。リストにしておかないとインプットがうまくいかなくなるはず。
#s = [[20,20,40],[40,40,-1],[-1,50,60]]

#80,65,50,30
a, b, c, d = 80, 65, 50, 30

g = []

for i in range(len(s)):
    r = s[i][0] + s[i][1]
    
    if s[i][0]==-1 or s[i][1]==-1:
        g.append("F")
        #break
    elif r >= a:
        g.append("A")
    elif r >= b:
        g.append("B")
    elif r >= c:
        g.append("C")
    elif r >= d:
        if s[i][2] >= 50:
            g.append("C")
        else:
            g.append("D")
    else:
        g.append("F")
    
[print(g[i]) for i in range(len(g))]

    


Measured memory_bytes: 5616
#include<stdio.h>
#include<stdlib.h>
#define N 36
 
typedef struct{
  int suji;
  char moji;
}card;
 
main(){
  int n, i, j, minj, hantei = 1;
  card a[N], d[N], b, c;
 
  scanf("%d", &n);
  if( N<n )
    exit(1);

  for(i = 0;i < n;i++){
    scanf(" %c%d", &a[i].moji, &a[i].suji);
  }
  for(i = 0;i < n;i++){
    d[i] = a[i];
  }
  for(i = 0;i < n-1;i++){
     for(j = n-1;j > i;j--){
       if(a[j].suji < a[j-1].suji){
    b = a[j];
    c = a[j-1];
    a[j] = c;
    a[j-1] = b;
       }
     }
   }
  for(i = 0;i < n;i++){
    minj = i;
    for(j = i;j < n;j++){
      if(d[j].suji < d[minj].suji){
    minj = j;
      }
    }
    b = d[i];
    c = d[minj];
    d[i] = c;
    d[minj] = b;
  }
  for(i = 0;i < n-1;i++){
    printf("%c%d ", a[i].moji, a[i].suji);
  }
  printf("%c%d\n", a[n-1].moji, a[n-1].suji);
  printf("Stable\n");
  for(i = 0;i < n-1;i++){
    printf("%c%d ", d[i].moji, d[i].suji);
  }
  printf("%c%d\n", d[n-1].moji, d[n-1].suji);
  for(i = 0;i < n;i++){
    if(a[i].moji != d[i].moji){
      hantei = 0;
      break;
    }
  }
  if(hantei == 1){
    printf("Stable\n");
  }
  else printf("Not stable\n");
  return 0;
}

Measured memory_bytes: 608
s=input()
a=[]
b=[]
for i in range(len(s)):
    if i%2==0:
        a.append('0')
    else:
        a.append('1')
for j in range(len(s)):
    if j%2==1:
        b.append('0')
    else:
        b.append('1')
ans1=0
ans2=0
for k in range(len(a)):
    if a[k]!=s[k]:
        ans1+=1
for z in range(len(b)):
    if b[z]!=s[z]:
        ans2+=1
print(min(ans1,ans2))

Measured memory_bytes: 4852
#include <iostream>

int main()
{
        uint16_t* height;
        height=new uint16_t [10];
        for(uint8_t i=0;i<10;i++)
                std::cin>>height[i];
        for(uint8_t i=0;i<10;i++)
                for(uint8_t j=i;j<10;j++)
                        if(height[i]<height[j])
                        {
                                uint16_t buf=height[i];
                                height[i]=height[j];
                                height[j]=buf;
                        }
        std::cout<<height[0]<<std::endl<<height[1]<<std::endl<<height[2]<<std::endl;
        delete(height);

        return 0;
}

Measured memory_bytes: 3116
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

typedef pair<int, int> pii;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, K;
int A[100010], B[100010];
int rec[35];

signed main() {
    cin >> N >> K;
    rep(i,0,N) cin >> A[i] >> B[i];

    int M = 0;
    rep(i,0,32) if(K >> i & 1) M = i;

    rep(i,0,N) repq(j,0,M) {
        if(!( K >> j & 1 )) continue;
        int S = ((K >> (j + 1)) << (j + 1)) | ( (1 << j) - 1 );
        if((S | A[i]) == S) rec[j] += B[i];
    }
    rep(i,0,N) if((K | A[i]) == K) rec[M+1] += B[i];
    cout << *max_element(rec, rec+35) << endl;
    return 0;
}

Measured memory_bytes: 1792
N = int(input())
A = [list(input().split()) for _ in range(N)]
X = input().strip()
for i in range(N):
    if X==A[i][0]:
        ind = i
        break
T = 0
for i in range(ind+1,N):
    T += int(A[i][1])
print(T)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
constexpr ll mod=1e9+7;

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

  bool table[(int)1e6+30]={};
  for(const auto& f: a) 
  {
    int e=f.first;
    if(f.second!=1) table[e]=true;
    for (int i = e*2; i <= 1e6+20; i+=e)
    {
      table[i]=true;
    }
  }
  int ans=0;
  for(const auto& e: a) 
  {
    if(!table[e.first]) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 13992
#include<bits/stdc++.h>
#define ll long long 
#define ull unsigned long long 
#define ld long double
#define ui unsigned int 
using namespace std;
int main()
{
	int t;
	cin >> t;
	while (t--) {
		int arr[3];
		for (int i = 0; i < 3; i++) {
			cin >> arr[i];
		}
		sort(arr, arr + 3);
		arr[0] *= arr[0];
		arr[1] *= arr[1];
		int s = arr[0] + arr[1];
		if (s != (arr[2] * arr[2])) {
			cout << "NO" << endl;
		}
		else
			cout << "YES" << endl;
	}
}




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

int main()
{
	int a, b;

	cin >> a >> b;

	if (a < b) {
		cout << "a < b" << endl;
	}
	else if (a > b) {
		cout << "a > b" << endl;
	}
	else {
		cout << "a == b" << endl;
	}

	return 0;
}


Measured memory_bytes: 3108
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;
	using BigNum = std::vector<long long>;

	class InputData {
	public:
		void getInput(void);
		void skipInput(void);
		Str getStr(void);
		Num getNum(void);
		BigNum getBigNum(void);
	private:
		Str str;
		Num num;
		BigNum bNum;
	};
	Str AtCoder::InputData::getStr(void) {
		return this->str;
	}
	Num AtCoder::InputData::getNum(void) {
		return this->num;
	}
	BigNum AtCoder::InputData::getBigNum(void) {
		return this->bNum;
	}
	void AtCoder::InputData::skipInput(void) {
		std::string buf = "";
		std::getline(std::cin, buf);
	}
	void AtCoder::InputData::getInput(void) {
		this->str.clear();
		this->num.clear();
		this->bNum.clear();

		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				this->str.push_back(row);
				this->num.push_back(std::atoi(row.c_str()));
				this->bNum.push_back(std::atoll(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		this->str.push_back(row);
		this->num.push_back(std::atoi(row.c_str()));
		this->bNum.push_back(std::atoll(row.c_str()));
	}

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(long long);
		void decrement(void);
		void decrement(long long);
		long long getResult(void);
	private:
		long long result;
	};
	void Ans::showResult(void) {
		printf("%lld\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(long long value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(long long value) {
		this->result -= value;
	}
	long long AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {
  
	AtCoder::InputData* data = new AtCoder::InputData();
	data->getInput();

	AtCoder::Num num = data->getNum();

	const int N = num[0], X = num[1], T = num[2];

	const int buf = N / X;

	if (0 == buf) {
		printf("%d\n", T);
	} else if(0 == N % X){
		printf("%d\n", (buf * T));
	} else {
		printf("%d\n", ((buf * T) + T));
	}
	
	delete(data);

	return 0;
}

Measured memory_bytes: 3192
using System;
using System.Linq;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] inputsForecasts = Console.ReadLine().ToCharArray();
            char[] inputsWeathers = Console.ReadLine().ToCharArray();
            int answer = inputsForecasts.Zip(inputsWeathers, (f, w) => f == w).Aggregate(0, (sum, v) => sum + (v ? 1 : 0));
            Console.WriteLine(answer.ToString());
        }
    }
}


Measured memory_bytes: 13268
import sys
A, B = map(int, input().split())
S = input()
for i in range(len(S)):
    if i == A:
        if S[i] != '-':
            print('No')
            sys.exit()
    else:
        if S[i].isdigit() is False:
            print('No')
            sys.exit()
print('Yes')


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A , B , C , D;
  cin >> A >> B >> C >> D;
  if (A+B > C+D) {
    cout << "Left" << endl;
  }
  else if (A+B < C+D) {
    cout << "Right" << endl;
  }
  else if (A+B == C+D) {
    cout << "Balanced" << left;
  }
}

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

decltype(0) main () {
  int n; cin >> n; int k; cin >> k;
  int sum = 0;
  for (int i=0; i<n; i++) {
    int a; cin >> a;
    if (a>=k) sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import time
import random

def test(li):
    m=0
    for i in range(D):
        m+=s[i][li[i]-1]
        last[li[i]-1]=i+1
        for j in range(26):
            m-=c[j]*(i+1-last[j])
    return m

start=time.time()
D=int(input())
c=list(map(int,input().split()))
s=[list(map(int,input().split())) for i in range(D)]
last=[0]*26
t=[random.randrange(1,27) for i in range(D)]

res=test(t)

while(True):
    if time.time()-start>=1.70:
        break
    for i in range(D):
        if time.time()-start>=1.70:
            break
        q=random.randrange(1,27)
        li=t.copy()
        li[i]=q
        r=test(li)
        if r>res:
            res=r
            t[i]=q
print(*t,sep='\n')

Measured memory_bytes: 80044
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
const int N=3e5+5;
int n,s[N];
long long ans;
void INT()
{
    int i;
    scanf("%d",&n);
    for(i=1;i<=2*n;++i) scanf("%d",&s[i]);
    sort(s+1,s+2*n+1);
}
void CHAR()
{
    int i;
    for(i=1;i<=2*n;++i) ans+=1LL*(i-1)*s[i];
    printf("%.10lf\n",1.0*ans/(2*n-1));
}
int main()
{
    INT();
    CHAR();
    return 0;
}

Measured memory_bytes: 1024
#include"bits/stdc++.h"
using namespace std;

int main(){
  int r, d, x2000, x[11];
  cin >> r >> d >> x2000;
  x[0] = x2000;
  for(int i=1; i<11; i++){
    x[i] = r * x[i-1] - d;
    cout << x[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 256
//package algorthims.LeetCode;

import java.util.*;


public class Main{
    
    public static int points( int num ){
	
	int points = 0;
	
	int mul = num / 500;
	num %= 500;
	points = points + mul*1000;
	    
	if( num > 0){
	    mul = num/5;
	    num %= 5;
	    points = points + mul*5;
	}
	    
	return points;
	
    }
    public static void main(String[] args) {
	
	Scanner sc = new Scanner( System.in );
	System.out.print( points( sc.nextInt() ));
    }
}


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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,start,end) for(int i=(start);i<=(end);i++)
#define all(n) begin(n),end(n)

#define DEBUG

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

Measured memory_bytes: 256