akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>

using namespace std;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

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

    int arr[n];
    int count = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> arr[i];
    }
    
    for (int i = 0; i < n; i++)
    {
        if (arr[i] != i+1)
        {
            if (count >= 1)
            {
                cout << "NO" << endl;
                return 0;
            }
            int num = arr[i];
            arr[num - 1] = num;
            count++;
        }
    }
    
    cout << "YES" << endl;

    return 0;
}

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

int main() {
  string A,B,C; cin >> A >> B >> C;
  if (A[A.size()-1] == B[0] && B[B.size()-1] == C[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
}  

Measured memory_bytes: 3588
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>
using namespace std;
#define ll long long

int main() {
  int a,b;cin>>a>>b;
  int ans;
  ans=max(a+b,a-b);
  ans=max(ans,a*b);
  cout<<ans;
}

Measured memory_bytes: 256
package main
 
import (
    "bufio"
    "fmt"
    "os"
    "strconv"
)

func main(){
    
    N := nextInt()
    K := nextInt()
    h := make([]bool, 10)
	for i := 0; i < K; i++ {
		di := nextInt()
		h[di] = true
	}
 
	for {
		flag := true
		t := N
 
		for t > 0 && flag {
			if h[t%10] {
				flag = false
			}
			t /= 10
		}
 
		if flag {
			fmt.Println(N)
			break
		}
		N++
	}
 
 }
 
/* templates */
 
func Max(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r < a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Min(a []int) int {
    r := a[0]
    for i := 0; i < len(a); i++ {
        if r > a[i] {
            r = a[i]
        }
    }
    return r
}
 
func Sum(a []int) (r int) {
    for i := range a {
        r += a[i]
    }
    return r
}
 
func Abs(a float64) float64 {
    if a < 0 {
        return -a
    }
    return a
}
 
type Pair struct {
    a, b int
}
 
type Pairs []Pair
 
func (p Pairs) Len() int {
    return len(p)
}
 
func (p Pairs) Swap(i, j int) {
    p[i], p[j] = p[j], p[i]
}
 
func (p Pairs) Less(i, j int) bool {
    return p[i].b < p[j].b
}
 
var nextReader func() string
 
func init() {
    nextReader = NewScanner()
}
 
func NewScanner() func() string {
    r := bufio.NewScanner(os.Stdin)
    r.Buffer(make([]byte, 1024), int(1e+11))
    r.Split(bufio.ScanWords)
    return func() string {
        r.Scan()
        return r.Text()
    }
}

func nextString() string {
    return nextReader()
}
 
func nextInt64() int64 {
    v, _ := strconv.ParseInt(nextReader(), 10, 64)
    return v
}
 
func nextInt() int {
    v, _ := strconv.Atoi(nextReader())
    return v
}
 
func nextInts(n int) []int {
    r := make([]int, n)
    for i := 0; i < n; i++ {
        r[i] = nextInt()
    }
    return r
}

func nextStrings(n int) []string {
    r := make([]string, n)
    for i := 0; i < n; i++ {
        r[i] = nextString()
    }
    return r
}

func nextFloat64() float64 {
    f, _ := strconv.ParseFloat(nextReader(), 64)
    return f
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define  rep(i,n) for(ll i = 0; i < (n); ++i)
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }

int main()
{
    const ll M=200017;
    bool P[M+10]={0};
    P[0]=P[1]=1;
    for(int i=2;i*i<M+7;i++) if(!P[i]) for(int j=i+i;j<M+7;j+=i) P[j]=1;
    ll x,i;
    cin>>x;
    for(i=x;P[i]==1;i++);
    cout<<i<<endl;
    return 0;
}


Measured memory_bytes: 384
from collections import Counter

N=int(input())
S=input()

C=Counter(S)
r=C['R']
g=C['G']
b=C['B']

ans=r*g*b
# print(r,g,b)

for i in range(N-2):
    for j in range(i+1,N-1):
        if S[i]==S[j]:
            continue
        
        k=2*j-i
        if k>=N:
            continue
        if S[j]!=S[k] and S[k]!=S[i] :
            ans-=1

print(ans)

Measured memory_bytes: 9372
import sys
from bisect import bisect_left, bisect_right


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


def main():
    N = int(input())
    L = list(map(int, input().split()))

    L.sort()
    count = 0

    for j in range(1, N - 1):
        for i in range(j):
            if L[i] == L[j]:
                break

            count += bisect_left(L[j + 1:], L[i] + L[j]) - bisect_right(L[j + 1:], L[j])

    print(count)


if __name__ == "__main__":
    main()


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
 
int main()
{	
  cout.precision(7);
  	int n;
  	cin >> n;
  	double ans = (int)((n + 1.0) / 2);
  	ans = ans / n;
  	cout << fixed << ans;
	return 0;
}

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

a = []

for i in range(n):
    a.append(int(input()))

now = a[0]
count = 1

while now != 2 and count < n:
    count += 1
    now = a[now - 1]

if now == 2:
    print(count)
    exit(0)

else:
    print("-1")
    exit(0)



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

int main(){
    int A,B;
    cin >>A>>B;
    int amari=abs(A-B);

    string ans="Yay!";
    if(amari!=0){
      if(16-A-B<amari*2)ans=":(";
    }
    cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FIO ios_base::sync_with_stdio(false); //cin.tie(NULL); cout.tie(NULL)
#define mp make_pair
#define pb push_back
#define fs first
#define sc second

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

int n, sz = 0, A[10], ans = 0;

void TRY(int x){
	if (x >= 2 && x <= sz){
		int num = 0;
		int a=0,b=0,c=0;
		for (int i=0; i<x; ++i){
			if (A[i] == 3) a = 1;
			if (A[i] == 5) b = 1;
			if (A[i] == 7) c = 1;
			num = num*10 + A[i];
		}
		if (a && b && c && num <= n){
			++ans;
//			cout << num << endl;
		}
	}
	if (x == sz){
		return;
	}
	for (int i=3; i<=7; i+=2){
		A[x] = i;
		TRY(x+1);
	}
}

void solve(){
	cin >> n;
	int temp = n;
	while (temp){
		++sz;
		temp/=10;
	}
	TRY(0);
	cout << ans;
}	

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

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

using namespace std;

const int N = 50000;

int r, c, q, a[N], b[N], o[N], d[2];
bool used[2][N];

main(){
  while(cin >> r >> c >> q && (r|c|q)){
    for(int i=q-1;i>=0;i--) cin >> a[i] >> b[i] >> o[i];
    fill(used[0], used[2], false);
    d[0] = d[1] = 0;
    int ans = 0;
    for(int i=0;i<q;i++){
      if(!used[a[i]][b[i]]){
        used[a[i]][b[i]] = true;
        ans += ((a[i] ? r : c) - d[1-a[i]]) * o[i];
        d[a[i]]++;
      }
      //printf("%d %d %d = %d\n", a[i], b[i], o[i], ans);
      //printf("d[%d] = %d\n", a[i], d[a[i]]);
    }
    cout << ans << endl;
  }
}

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

pll S[100005];

int main()
{
    ll N, K;
    cin >> N >> K;
    REP(i, N)
    {
        cin >> S[i].first >> S[i].second;
    }

    ll max = 0;
    REP(i, 31)
    {
        ll m = 0;
        REP(j, N)
        {
            ll a = S[j].first;
            bool e = true;
            REP(k, 30)
            {
                if (((K >> i) & 1) == 1)
                {
                    if (k < i)
                        continue;
                    if (k == i && ((a >> i) & 1) == 1)
                    {
                        e = false;
                        break;
                    }
                    else if (((a >> k) & 1) > ((K >> k) & 1))
                    {
                        e = false;
                        break;
                    }
                }
                else
                {
                    if (((a >> k) & 1) > ((K >> k) & 1))
                    {
                        e = false;
                        break;
                    }
                }
            }
            if (e)
                m += S[j].second;
        }
        max = std::max(max, m);
    }
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1792
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cpp,赤波線出るけどコンパイルできる

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,d,n,maxi=0,f=0,mini=INF,sum=0;
    ll w=0,h,x,y,k;
    //string str[3];
    string str;
    ll e=0;
	cin>>n>>str;
    rep(i,n) {
        if(str[i]=='E') e++;
        else w++;
    }
    sum=n;
    ll le=0;
    ll lw=0;
    rep(i,n){
        if(str[i]=='E'){
            le++;
            e--;
            sum=min(sum,lw+e);
        }else{
            sum=min(sum,lw+e);
            lw++;
            w--;
        }
        //cout<<sum<<endl;
    }
    cout<<sum<<endl;


    return 0;
}



Measured memory_bytes: 3816
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 10000 + 10;
const int INF = 0x3f3f3f3f;
 
int q, h, s, d, n;
 
void Work()
{
	scanf("%d%d%d%d%d", &q, &h, &s, &d, &n);
	h = min(h, 2 * q);
	s = min(s, 2 * h);
	d = min(d, 2 * s);
	long long ans = (long long) (n / 2) * (long long) d + (long long) (n % 2) * (long long) s;
	printf("%lld\n", ans);
}
 
int main()
{
	Work();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)
 
#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=(int)(a)-1;i>=(int)(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)
 
#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
 
// #define DEBUG
 
#ifdef DEBUG
    #define dump(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dump(...)
#endif
 
template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}
 
using namespace std;
using ll=long long;
using vi=vector<int>;
using vll=vector<ll>;
 
const double EPS = 1e-10;
const double PI = acos(-1.0);
const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
 
 
ll extgcd(ll a,ll b,ll& x,ll& y){x=1,y=0;ll g=a;if(b!=0) g=extgcd(b,a%b,y,x),y-=a/b*x;return g;}
ll ADD(const ll &a, const ll &b,const ll &mod) { return (a+b)%mod;}
ll SUB(const ll &a, const ll &b,const ll &mod) { return (a-b+mod)%mod;}
ll MUL(const ll &a, const ll &b,const ll &mod) { return (1LL*a*b)%mod;}
ll DIV(const ll &a, const ll &b,const ll &mod) {ll x,y; extgcd(b,mod,x,y);return MUL(a,(x+mod)%mod,mod);}
 
random_device rd;
mt19937 mt(rd());
uniform_int_distribution<int> dice(1,6);
uniform_real_distribution<double> score(0.0,10.0);

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

    int n; cin >> n;
    string s1, s2; cin >> s1 >> s2;

    vi tbl;
    rep(i, n){
        if(s1[i] == s2[i]){
            tbl.emplace_back(1);
        }
        else {
            tbl.emplace_back(2);
            i++;
        }
    }

    ll res = (tbl[0] == 1 ? 3:6);
    rep(i, 1, (int)tbl.size()){
        int cur = tbl[i];
        int pre = tbl[i - 1];

        if(cur == 1){
            if(pre == 1){
                res = MUL(res, 2, mod);
            }
        }
        else {
            if(pre == 2){
                res = MUL(res, 3, mod);
            }
            else {
                res = MUL(res, 2, mod);
            }
        }
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int i, j, sum, min, x;
    int[] a;
    int[][] l;

    a = new int[8]; l = new int[8][8]; min = 0; x = 0;
    l[0][0] = 1; l[0][1] = 2; l[0][2] = 1; l[0][3] = 2;
    l[0][4] = 1; l[0][5] = 4; l[0][6] = 1; l[0][7] = 4;
    for(i = 0;i < 8;i++)l[1][i] = l[0][(i + 2) % 8];
    for(i = 0;i < 8;i++)l[2][i] = l[0][(i + 6) % 8];
    for(i = 0;i < 8;i++)l[3][i] = l[0][(i + 4) % 8];
    for(j = 4;j < 8;j++)for(i = 0;i < 8;i++)l[j][i] = l[j - 4][(i + 1) % 8];

    for(;sc.hasNext();){
      for(i = 0;i < 8;i++){
        a[i] = sc.nextInt(); min += a[i];
      }
      for(i = 0;i < 8;i++){
        sum = 0;
        for(j = 0;j < 8;j++)if(a[j] > l[i][j])sum += (a[j] - l[i][j]);
        if(min > sum){ min = sum; x = i; }
      }
      for(i = 0;i < 7;i++)out.print(l[x][i] + " ");
      out.println(l[x][i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 30224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef pair<int, int> ii;
typedef pair<int, bool> ib;

#define FOR(a, b, c) for(int a = b; a < c; ++a)
#define RFOR(a, b, c) for(int a = b; a >= c; --a)
#define mp(a, b) make_pair(a, b)
#define all(v) v.begin(), v.end()

#define ii pair<int, int>
#define vi vector<int>
#define vii vector<ii>
#define vvi vector<vi>
#define vb vector<bool>
#define fst first
#define snd second
#define MAXN 310
#define MAXM 44100
#define LOGMAXN 20
#define INF 1000000007
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define MOD 1000000007LL


int main()
{
	ios_base::sync_with_stdio(false); cin.tie(0);
	string s;
	map<string, string> mm;
	mm["Sunny"] = "Cloudy";
	mm["Cloudy"] = "Rainy";
	mm["Rainy"] = "Sunny";
	while(cin >> s)
	{
		printf("%s\n", mm[s].c_str());
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int h,w;
char a[120][120];
int cnt[50];
int main(){
    cin >> h >> w;
    for(int i=1;i<=h;i++) cin >> a[i];
    for(int i=1;i<=h;i++)
        for(int j=0;j<w;j++)
            cnt[a[i][j]-'a']++;
    int num = 0,num2 = 0;
    for(int i=0;i<26;i++){
        if((cnt[i]%4)){
           if(!(cnt[i]%2)) num++;
           else {
            num += (cnt[i]%4)/2;
            num2++;
           }
        }
    }
    if(!(h%2) && !(w%2)){
        if(num==0 && num2==0) printf("Yes\n");
        else printf("No\n");
    }
    if((h+w)%2){
        if(h%2){
            if(num2==0 && num<=(w/2)) printf("Yes\n");
            else printf("No\n");
        }
        else {
            if(num2==0 && num<=(h/2)) printf("Yes\n");
            else printf("No\n");
        }
    }
    if(h%2 && w%2){
        if(num2==1 && num<=(((h-1)/2)+((w-1)/2))) printf("Yes\n");
        else printf("No\n");
    }
    return 0;
}


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

int main() {
  double l;
  cin >> l;
  l /= 3;
  cout << fixed << setprecision(10) << l*l*l << endl;
  return 0;
}

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

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

int N;
string S;

void solve() {
    cin >> N >> S;
    long long count = 0;
    vector<int> R(N + 1), G(N + 1), B(N + 1);
    R.at(0) = 0;
    G.at(0) = 0;
    B.at(0) = 0;

    rep(i, N) {
        if (S.at(i) == 'R') {
            R.at(i + 1) = R.at(i) + 1;
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i);
        }
        else if (S.at(i) == 'G') {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i) + 1;
            B.at(i + 1) = B.at(i);
        }
        else {
            R.at(i + 1) = R.at(i);
            G.at(i + 1) = G.at(i);
            B.at(i + 1) = B.at(i) + 1;
        }
    }

    rep(i, N) {
        for (int j = i + 1; j < N; j++) {
            if (S.at(i) != S.at(j)) {
                if ((S.at(i) == 'R' && S.at(j) == 'G') || (S.at(i) == 'G' && S.at(j) == 'R')) {
                    count += (B.at(N) - B.at(j));
                }
                else if ((S.at(i) == 'R' && S.at(j) == 'B') || (S.at(i) == 'B' && S.at(j) == 'R')) {
                    count += (G.at(N) - G.at(j));
                }
                else {
                    count += (R.at(N) - R.at(j));
                }
                if (2 * j - i < N) {
                    if (S.at(2 * j - i) != S.at(i) && S.at(2 * j - i) != S.at(j)) {
                        count--;
                    }
                }
            }
        }
    }

    cout << count << endl;
    return;
}

int main() {
    solve();
}


Measured memory_bytes: 3648
#include <iostream>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <ctime>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <cassert>

using namespace std;

#define pb push_back
#define pp pop_back
#define f first
#define s second
#define mp make_pair
#define sz(a) int((a).size())
#ifdef _WIN32
#  define I64 "%I64d"
#else
#  define I64 "%lld"
#endif
#define fname "."

typedef long long ll;
typedef unsigned long long ull;
typedef pair < int, int > pi;

const int MAX_N = (int)1e5 + 123;
const int inf = (int)1e9 + 123;

using namespace std;

char t[MAX_N];

bool check(int len, string a, string b) {
    if (len < sz(a) || len < sz(b))
    	return 0;
	for (int i = 0; i < sz(a); i++)
		t[i] = a[i];
	for (int i = len - 1, j = sz(b) - 1; i >= len - sz(b); i--, j--)
		t[i] = b[j];
	for (int i = 0; i < sz(a); i++)
		if (t[i] != a[i])
			return 0;
	return 1;
}

int main() {
	#ifdef Nick
	freopen(".in","r",stdin);
	freopen(".out","w",stdout);
	#endif
	int n;
	string a, b;
	cin >> n >> a >> b;
	for (int ans = n; ; ans++)
		if (check(ans, a, b)) {
			cout << ans;
			return 0;
		}
	return 0;
}


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

int main(){
	string S;
	cin >> S;
	int N = S.size();
	int rem_cup = 15 - N;
	for(int i = 0; i < N; i++){
		if(S.at(i) == 'o') rem_cup++;
	}
	if(rem_cup >= 8) cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
import sys
from operator import itemgetter


def parse_input(input_lines):
    return tuple(map(lambda sl: tuple(map(int, sl)),
                     map(lambda s: s.strip().split(),
                         input_lines)))


def main(inps):
    (N, M), *shops = inps
    shops = sorted(shops, key=itemgetter(0))
    result = 0
    for cost, count in shops:
        if M > count:
            result += cost * count
            M -= count
        else:
            result += cost * M
            return result


if __name__ == '__main__':
    inps = parse_input(sys.stdin.readlines())
    print(main(inps))


Measured memory_bytes: 24632
#include<bits/stdc++.h>
using namespace std;
using LL = long long;
// InSane Code	...	

int main(int argc , char** argv){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	int n;
	cin >> n;
	string s;
	cin >> s;
	vector<int> L(n,0) , R(n,0);
	for(int i = 0 ; i < n ; ++i){
		if(i == 0){
			L[i] = (s[i] == 'W' ? 1 : 0);
			R[n-1-i] = (s[n-1-i] == 'E' ? 1 : 0);
		}
		else{
			L[i] = (s[i] == 'W' ? 1 : 0) + L[i-1];
			R[n-1-i] = (s[n-1-i] == 'E' ? 1 : 0) + R[n-i];
		}
	}
	int GMin = INT_MAX;
	for(int i = 0 ; i < n ; ++i){
		if(i == 0){
			GMin = min(GMin , R[1]);
		}
		else if(i == n-1){
			GMin = min(GMin , L[n-2]);
		}
		else{
			GMin = min(GMin , L[i-1] + R[i+1]);
		}
	}
	cout << GMin << endl;
	return 0;
}

Measured memory_bytes: 2964
# Problem B - Shiritori

# input
N = int(input())

# initialization
last = input()
word_list = []
word_list.append(last)
is_ok = True

# search
for i in range(N-1):
    tmp = input()
    if tmp in word_list or not last[-1]==tmp[0]:
        is_ok = False
        break
    else:
        last = tmp
        word_list.append(tmp)

# output
if is_ok:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define sz(x) (int)x.size()
#define eb emplace_back
using LL = long long;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
int main()
{
    int N;
    string S;
    cin >> N >> S;
    int x{}, MAX{};
    REP( i, sz( S ) )
    {
        if( S[i] == 'I' )
        {
            x++;
        }
        if( MAX < x )
        {
            MAX = x;
        }
        if( S[i] == 'D' )
        {
            x--;
        }
        if( MAX < x )
        {
            MAX = x;
        }
    }
    cout << MAX << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
using namespace std;

const ll N = 3e5+100;
const ll MOD = 1e9+7;
const ll INF = 1e16;

void solve(){
	ll a,b,c;
	cin >> a >> b >> c;

	ll x = c-a-b;if(x<0){cout<<"No\n";return;}x*=x;
	if((a*b*4) < (x)) cout<<"Yes\n";
	else cout << "No\n";
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	ll t=1;
	while(t--){
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 768
#include<stdio.h>

int main(){
    double ans=0.0;
    int N, A;
    scanf("%d", &N);
  
    for (int a = 0; a < N;a++){
        scanf("%d", &A);
        ans += (1.0 / (A*1.0));
    }
    printf("%f", 1.0 / ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
using namespace std;
struct pocker{
    char Suit;
    char Value;
};
void print(pocker C[],int N)
{
    for(int i=0;i<N;i++)
    {
        if(i)
            cout<<" ";
        cout<<C[i].Suit<<C[i].Value;
    }
    cout<<endl;
}
void BubbleSort(pocker C[],int N)
{
    int i,j;
    pocker p;
    for(i=0;i<N-1;i++)
    {
        for(j=N-1;j>=i+1;j--)
        {
            if(C[j].Value<C[j-1].Value)
            {
                p=C[j];
                C[j]=C[j-1];
                C[j-1]=p;
            }
        }
    }
    print(C,N);
}
void SelectionSort(pocker C[],int N)
{
    int i,j,minj;
    pocker p;
    for(i=0;i<N-1;i++)
    {
        minj=i;
        for(j=i;j<N;j++)
        {
            if(C[j].Value<C[minj].Value)
            {
                minj=j;
            }
        }
        p=C[minj];
        C[minj]=C[i];
        C[i]=p;
    }
    print(C,N);
}
bool isEqual(pocker p1, pocker p2)
{
    if(p1.Value==p2.Value&&p1.Suit==p2.Suit)
        return true;
    else
    {
        return false;
    }
}
bool isStable(pocker in[],pocker out[],int N)
{
    int i,j,a,b;
    for(i=0;i<N;i++)
    {
        for(j=i+1;j<N;j++)
        {
            for(a=0;a<N;a++)
            {
                for(b=a+1;b<N;b++)
                {
                    if(in[i].Value==in[j].Value&&isEqual(in[i],out[b])&&isEqual(in[j],out[a]))
                        return false;
                }
            }
        }
    }
    return true;
}
int main()
{
    pocker p[36],tmp[36],tmp1[36];
    int N;
    cin>>N;
    for(int i=0;i<N;i++)
    {
        cin>>p[i].Suit>>p[i].Value;
        tmp[i].Suit=p[i].Suit;
        tmp[i].Value=p[i].Value;
        tmp1[i].Suit=p[i].Suit;
        tmp1[i].Value=p[i].Value;

    }

    BubbleSort(p,N);
    if(isStable(tmp1,p,N))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;
    SelectionSort(tmp,N);
    if(isStable(tmp1,tmp,N))
        cout<<"Stable"<<endl;
    else
        cout<<"Not stable"<<endl;

    return 0;
}



Measured memory_bytes: 3112
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <stdio.h>
using namespace std;
#define int long long
int MOD = 1000000007;
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vector<int> A(100005, 0);
	int res = 0;
	
	for (int i = 2; i < A.size(); i++) {
		for (int j = 2 * i; j < A.size(); j += i) {
			A[j]++;
		}
	}
	vector<int> X(A.size(), 0);
	for (int i = 1; i < X.size(); i++) {
		X[i] = X[i - 1];
		if (A[i] >= 3) {
			X[i]++;
		}
	}
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}
	for (int i = 0; i < N; i++) {
		cout << X[A[i]] << endl;
	}
}


Measured memory_bytes: 4408
import sys
readline = sys.stdin.readline
N, M = map(int, input().split())
ab = [tuple(map(lambda x: int(x) - 1, readline().split())) for _ in range(M)]
class UnionFind:
    def __init__(self, size):
        self.rank = [-1 for _ in range(size)]
        self.number = [1 for _ in range(size)]
    def find(self, x):
        while self.rank[x] >= 0:
            x = self.rank[x]
        return x
    def union(self, s1, s2):
        if s1 == s2:
            return
        if self.rank[s1] == self.rank[s2]:
            self.rank[s1] -= 1
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        elif self.rank[s1] < self.rank[s2]:
            self.rank[s2] = s1
            self.number[s1] += self.number[s2]
        else:
            self.rank[s1] = s2
            self.number[s2] += self.number[s1]
uf = UnionFind(N)
p = N * (N - 1) // 2
ans = [p]
for x, y in reversed(ab[1:]):
    px = uf.find(x)
    py = uf.find(y)
    if px != py:
        p -= uf.number[px] * uf.number[py]
        uf.union(px, py)
    ans.append(p)
print(*ans[::-1], sep="\n")


Measured memory_bytes: 25400
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
const int inf = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<int> v(n);
    rep(i, n) v[i] = inf;
    rep(i, n) {
        int a; cin >> a;
        v[lower_bound(v.begin(), v.end(), a) - v.begin()] = a;
    }
    int cnt = 0;
    rep(i, n) if (v[i] != 1e9 + 7) cnt++; else break;
    cout << cnt << endl;
}



Measured memory_bytes: 3068
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let n: i32 = input();
    let k: i32 = input();
    let x: i32 = input();
    let y: i32 = input();
    println!("{}", x * std::cmp::min(n, k) + y * std::cmp::max(0, n - k));
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define fr(i,n,m) for(ll i=n;i<m;i++)
int main()
{
    ll n,rcount=0, ans;
    scanf("%lli",&n);
    char c[200005];
    scanf("%s",c);
    fr(i,0,n)
    {
        if (c[i] == 'R') rcount++;
    }
    ll left=0;
    fr(i,0,rcount)
    {
        if (c[i] == 'W') {
            left++;
        }
    }
    ll right=0;
    fr (i,0,n-rcount)
    {
        if (c[n - i - 1] == 'R') {
            right++;
        }
    }
    if (left > right) {
        ans = left;
    } else {
        ans = right;
    }
    printf("%lli\n",ans);
    return 0;
}

Measured memory_bytes: 1900
k=io.read("n")
q={1,2,3,4,5,6,7,8,9}
for i=1,k-1 do
    for j=-1,1 do
        a=(q[i]%10)+j
        if 0<=a and a<=9 then
            q[#q+1]=q[i]*10+a
        end
    end
end
print(q[k])

Measured memory_bytes: 6656
import java.util.*;
 
class Main {
  public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
    
    String x = sc.next(); //next(文字列), nextDouble, nextLine(1行)とか
    if (x.equals("ABC")){
    System.out.println("ARC");
    }else{
      System.out.println("ABC");
    }
  }
}

Measured memory_bytes: 35704
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) {
    
    new Main().run();
  }

  public void run() {

    try(BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(br.readLine());
      int[][] graph = new int[n][n];
      String[] vInfo;
      int degree;

      for(int i=0,v=0; i<n; i++) {
        vInfo = br.readLine().split(" ");
        degree = Integer.parseInt(vInfo[1]);
        for(int j=0,k=2; j<degree; j++) {
          v = Integer.parseInt(vInfo[k++]);
          graph[i][v-1] = 1;
        }
      }

      StringBuilder buf = new StringBuilder(n*n);
      for (int[] vertex : graph) {
        for (int v : vertex) {
          buf.append(v).append(" ");
        }
        buf.setLength(buf.length()-1);
        buf.append("\n");
      }

      System.out.print(buf);
    }
    catch (IOException e) {
      System.err.println(e);
    }
  }
}


Measured memory_bytes: 25332
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int isp(int a){
    int b[10];
    int sum=0;
    int t=a;
    int k=0;
    while(a>0){
        k=a%10;
        sum=sum*10+k;
        a=a/10;
    }
    if(sum==t){
        return 1;
    }
    return 0;
}
int main() {
    int a,b;
    int ans=0;
    cin>>a>>b;
    for(int i=a;i<=b;i++){
        if(isp(i)){
            ans++;
        }
    }
    cout<<ans;
}


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

int main() {
  int n;
  cin >> n;
  vector<int> p(n), q(n);
  for (int i = 0; i < n; i++) {
    cin >> p[i];
  }
  for (int i = 0; i < n; i++) {
    cin >> q[i];
  }
  vector<int> tmp(n);
  for (int i = 0; i < n; i++) {
    tmp[i] = i + 1;
  }
  int a, b;
  int count = 1;
  do {
    if (tmp == p) {
      a = count;
    }
    if (tmp == q) {
      b = count;
    }
    count++;
  } while (next_permutation(tmp.begin(), tmp.end()));
  cout << abs(a - b) << endl;
}


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

int main(){
  int a,b,k;
  cin>>a>>b>>k;
  int c=0;
  int ans;
  for(int i=100;i>0;i--){
    if(a%i==0 && b%i==0){
      c++;
    }
    if(c==k){
      ans=i;
      break;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
F=lambda:tuple(int(X)for X in input().split());H,W,N=F();S={F()for _ in[0]*N};T=set();Z=[0]*10;*R,=range(9)
for Y,X in S:
	for A in R:
		P=A,B=X-A%3,Y-A//3
		if(0<A<W-1)*(0<B<H-1)*(P not in T):T.add(P);Z[sum((B+C//3,A+C%3)in S for C in R)]+=1
Z[0]+=(H-2)*(W-2)-sum(Z);print(*Z,sep='\n')

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

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

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

  int ans = 200000;
  for (int k = 0; k < M; k++) {
    int x, y, c;
    cin >> x >> y >> c;
    int num = a.at(x-1)+b.at(y-1)-c;
    ans = min(ans, num);
  }

  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  ans = min(ans, a.at(0)+b.at(0));

  cout << ans << endl;

}

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

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

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

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

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

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

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

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

use std::collections::BTreeSet;

fn main() {
    input! {
        n: usize,
        ws: [chars; n]
    };

    let ans = ws.iter().collect::<BTreeSet<&Vec<char>>>().len() == n
                && (0..n-1).all(|x| ws[x][ws[x].len()-1] == ws[x+1][0]);

    println!("{}", if ans { "Yes" } else { "No" });
}


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

int main(){
    
    
    while(true){
        
        
        int a,b;
        cin>>a>>b;
        if(a==0&&b==0)break;
        
        for(int i=0;i<a;i++){
            
            for(int j=0;j<b;j++){
                
                if(i%2==0){
                    if(j%2==0)cout<<'#';
                        else cout<<'.';
                    
                }else{
                    if(j%2==0)cout<<'.';
                    else cout<<'#';
                }
                    
                    
                    
                    }
            cout<<endl;
        }
        
        cout<<endl;
        
    }
    
}


Measured memory_bytes: 3100
package main
 
import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)
 
var sc = bufio.NewScanner(os.Stdin)
var ReadString func() string
 
func init() {
	ReadString = newReadString()
}
 
/*------ scan ------*/
 
func newReadString() func() string {
	sc.Buffer(make([]byte, 1024), 2048)
	sc.Split(bufio.ScanWords)
	return func() string {
		if !sc.Scan() {
			panic("scanできなかった")
		}
		return sc.Text()
	}
}
 
func ReadLine() string {
	if !sc.Scan() {
		panic("line をscanできなかった")
	}
	return sc.Text()
}
 
func ReadInt64() int64 {
	i, err := strconv.ParseInt(ReadString(), 0, 64)
	if err != nil {
		fmt.Println("parseInt失敗")
		panic(err.Error())
	}
	return int64(i)
}
 
func ReadInt() int {
	i := ReadInt64()
	return int(i)
}
 
func ReadIntSlice(n int) []int {
	arr := make([]int, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt()
	}
	return arr
}
 
func ReadInt64Slice(n int) []int64 {
	arr := make([]int64, n)
	for i := 0; i < n; i++ {
		arr[i] = ReadInt64()
	}
	return arr
}
 
/*------ number util ------*/
 
func GetIntAbs(n int) int {
	if n < 0 {
		return -n
	}
	return n
}
 
func Atoi(a string) int {
	i, err := strconv.Atoi(a)
	if err != nil {
		panic(err.Error())
	}
	return i
}
 
func FindMin(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	min := arr[0]
	for _, v := range arr {
		if v < min {
			min = v
		}
	}
	return min
}
 
func FindMax(arr []int) int {
	if len(arr) == 0 {
		return 0
	}
	max := arr[0]
	for _, v := range arr {
		if v > max {
			max = v
		}
	}
	return max
}
 
 
func main() {
	L := ReadInt64()
	R := ReadInt64()
  var max, min int64
	max = L
      min = R
		if R > max {
			max = R
          min = L
		}
		var minRs int64
      minRs = 10000000
  var j, i int64
		for j = max; j >= min + 1; j-- {
			for i = j - 1; i >= min; i-- {
              if i % 2019 == 0 {
                fmt.Println(0)
                return
              }
             	var mod int64
              mod = (i * j) % 2019
				if mod < minRs {
					minRs = mod
				}
			}
		}
		fmt.Println(minRs)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

int main() {
  string s;
  cin >> s;
  if ((s[0] == s[1] && s[1] == s[2]) || (s[1] == s[2] && s[2] == s[3])){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3624
#include<stdio.h>

int main(void)
{

	char s[20], t[20];
	scanf("%s", &s);
	scanf("%s", &t);


	for (int i = 0;s[i] != '\0';i++) {
		if (s[i] != t[i]) {
			printf("No");
			return 0;
		}
	}
	
	printf("Yes");

	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define in ({int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';n?-x:x;})
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
int rnd(int l,int r){return l+rng()%(r-l+1);}
#define fasty ios_base::sync_with_stdio(0),cin.tie(0)
#define fori(x,a,b) for (int x=a;x<=b;++x)
#define ford(x,a,b) for (int x=a;x>=b;x--)
#define forv(a,b) for(auto&a:b)
#define fi first
#define se second
#define pb push_back
#define ii pair<int,int>
#define mt make_tuple
#define mp make_pair
#define all(a) a.begin(),a.end()
#define reset(f, x) memset(f, x, sizeof(f))
#define getbit(x,i) ((x>>(i-1))&1)
#define batbit(x,i) (x|(1ll<<(i-1)))
#define tatbit(x,i) (x&~(1<<(i-1)))
#define gg exit(0);

const int maxn = 1e5 + 10;
int n,x,y,mod;
int f[maxn],g[maxn];
vector<int> ke[maxn];


void dfs(int u,int pr)
{
   forv(v,ke[u])
   {
       if (v==pr) continue;
       dfs(v,u);
       f[u] = (f[u]*(f[v]+1))%mod;
   }
}

void dfs1(int u,int pr)
{
    vector<int> a,l,r;

    int cnt = 0;
    forv(v,ke[u]) if (v!=pr) ++cnt;
    a.resize(cnt+5,0);
    l.resize(cnt+5,0);
    r.resize(cnt+5,0);

    int m = 0;
    forv(v,ke[u]) if (v!=pr) a[++m] = v;

    l[0] = 1;
    r[m+1] = 1;
    fori(i,1,m) l[i] = l[i-1]*(f[a[i]]+1)%mod;
    ford(i,m,1) r[i] = r[i+1]*(f[a[i]]+1)%mod;

    fori(i,1,m)
    {
        int v = a[i];
        g[v] = ((g[u]*l[i-1]%mod)*r[i+1]%mod+1);
        dfs1(v,u);
    }
}
main()
{
    fasty;
    cin>>n>>mod;
    fori(i,1,n-1)
    {
        cin>>x>>y;
        ke[x].pb(y);
        ke[y].pb(x);
    }
    fori(i,1,n) f[i] = g[i] = 1;
    dfs(1,0);
    dfs1(1,0);

    fori(i,1,n)
    {
        cout<<f[i]*g[i]%mod<<"\n";
    }
}


Measured memory_bytes: 35528
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iostream>
#include<cstring>
using namespace std;
template<class _T>inline void read(_T &_a)
{
    bool f=0; char _c=getchar(); _a=0;
    while(_c<'0'||_c>'9'){ if(_c=='-') f=1; _c=getchar(); }
    while(_c>='0'&&_c<='9'){ _a=(_a<<3)+(_a<<1)-'0'+_c; _c=getchar(); }
    if(f) _a=-_a;
}

const int MAXN=1002;
int n;
char str[MAXN],str2[MAXN];

int main()
{
    scanf("%s\n%s",str+1,str2+1);
    n=strlen(str+1);
    for (int i=1;i<=n;++i)
        if(str[i]!=str2[i])
        {
            printf("No");
            return 0;
        }
    printf("Yes");
    return 0;
}

Measured memory_bytes: 3824
def main():
    N, L = map(int, input().split())
    s = [input() for _ in range(N)]
    s.sort()
    ans = ''.join(s)
    print(ans)


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


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

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

typedef long long ll;

using namespace std;

const int INF   = 1e9;
const double PI = 3.14159265358979323846;

int main(){
  ll N;
  cin >> N;  
  if(N%2==1){
    cout << 0 << endl;
    return 0;
  }
  ll ans=0, cf=10;
  while(N>=cf){
    ans+=N/cf;
    cf*=5;
  }  
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) throws IOException {
		Main mainObj = new Main();
		mainObj.solve();
	}

	public void solve() throws IOException {
		FastScanner fs = new FastScanner();
		int n = fs.nextInt();
		int k = fs.nextInt();
		
		int[] price = fs.nextIntArr(n);
		Arrays.sort(price);
		
		int ans = 0;
		for(int i = 0; i < k; i++) {
			ans+=price[i];
		}
		
		System.out.println(ans);
;	}

	

	public class FastScanner {

		BufferedReader reader;
		private StringTokenizer st;

		public FastScanner() {
			st = null;
			reader = new BufferedReader(new InputStreamReader(System.in));
		}

		public String next() throws IOException {
			if (st == null || !st.hasMoreElements()) {
				st = new StringTokenizer(reader.readLine());
			}
			return st.nextToken();
		}

		public String nextLine() throws IOException {
			st = null;
			String readLine = null;
			readLine = reader.readLine();
			return readLine;
		}

		public int nextInt() throws NumberFormatException, IOException {
			return Integer.parseInt(next());
		}

		public long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		public int[] nextIntArr(int n) throws NumberFormatException, IOException {
			int[] retArr = new int[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextInt();
			}
			return retArr;
		}

		public long[] nextLongArr(int n) throws NumberFormatException, IOException {
			long[] retArr = new long[n];
			for (int i = 0; i < n; i++) {
				retArr[i] = nextLong();
			}
			return retArr;
		}

		public void close() throws IOException {
			reader.close();
		}
	}

}


Measured memory_bytes: 33024
import java.util.*;
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>0 && B >0){
      System.out.println(Math.max(A+B,A*B));
    }else if(A<0 && B<0 || A<0 && B==0){
      System.out.println(A*B);
    }else{
      System.out.println(Math.max(A+B,A-B));
    }
  }
}


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

int main() {
    long long n, a, b;
    cin >> n >> a >> b;


    long long p = a + b;
    long long w = n / p;
    long long m = n % p;
    long long x = a < m ? a : m;

    cout << (w * a + x) << endl;
    return 0;
}


Measured memory_bytes: 256
<?php

list($h, $w) = explode(' ', trim(fgets(STDIN)));

$s = [];
for ($i = 0; $i < $h; ++$i) {
    $s[] = str_split(trim(fgets(STDIN)));
}

$bfs = new BFS($h, $w, $s);
echo $bfs->getLongestDistnace();

/**
 * BFS（幅優先探索）での解法
 */
class BFS
{
    private $height;
    private $width;
    private $maze;
    private $longest_distance = 0;

    public function __construct($height, $width, $maze)
    {
        $this->height = $height;
        $this->width = $width;

        // queとの兼ね合いを考えて、1次元配列に格納
        for ($i = 0; $i < $this->height; ++$i) {
            for ($j = 0; $j < $this->width; ++$j) {
                $this->maze[$this->convertXY2Index($j, $i)] = $maze[$i][$j];
            }
        }
    }

    /**
     * 各点に対して最も遠い点までの距離を求める
     */
    public function getLongestDistnace()
    {
        foreach ($this->maze as $index => $road_or_stop) {
            if ($road_or_stop === '#') {
                continue;
            }
            $distance = $this->getLongestDistnaceWithStartPoint($index);
            if ($distance > $this->longest_distance) {
                $this->longest_distance = $distance;
            }
        }

        return $this->longest_distance;
    }

    /**
     * 指定された点から最も遠い点までの距離をBFS（幅優先探索）で求める
     */
    protected function getLongestDistnaceWithStartPoint($start_point_index)
    {
        $que = [$start_point_index];
        $distance = [$start_point_index => 0];
        $passed = [];

        while (($current_point = array_shift($que)) !== null) {
            $passed[$current_point] = $distance[$current_point];
            foreach ($this->getNextPoints($current_point) as $next_point) {
                if ($this->maze[$next_point] === '#') {
                    continue;
                }
                if (array_key_exists($next_point, $passed)) {
                    continue;
                }
                if (in_array($next_point, $que)) {
                    continue;
                }

                $que[] = $next_point;
                $distance[$next_point] = $distance[$current_point] + 1;
            }
        }

        return max($distance);
    }

    protected function getNextPoints($current_point)
    {
        $x = $current_point % $this->width;
        $y = ($current_point - $x) / $this->width;

        $next_points = [];
        if ($y > 0) {
            $next_points[] = $this->convertXY2Index($x, $y - 1);
        }
        if ($y < $this->height - 1) {
            $next_points[] = $this->convertXY2Index($x, $y + 1);
        }
        if ($x > 0) {
            $next_points[] = $this->convertXY2Index($x - 1, $y);
        }
        if ($x < $this->width - 1) {
            $next_points[] = $this->convertXY2Index($x + 1, $y);
        }

        return $next_points;
    }

    protected function convertXY2Index($x, $y)
    {
        return $this->width * $y + $x;
    }
}


Measured memory_bytes: 4604
N = gets.to_i
A = gets.split.map &:to_i

cusum = [sum = 0] + A.map{|a| sum += a}
xcusum = [xsum = 0] + A.map{|a| xsum ^= a}
chk= ->l, r{cusum[r] - cusum[l] == xcusum[r] ^ xcusum[l]}
l = 0
ans = 0
(1..N).each{|r|
  while !chk[l, r] && l < r
    l += 1
  end
  ans += r - l
}
p ans


Measured memory_bytes: 21644
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE BinaryLiterals #-}
{-# LANGUAGE MultiWayIf #-}
{-# LANGUAGE NumDecimals #-}
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE TupleSections #-}

import Control.Applicative
import Control.Arrow
import Control.Monad
import Control.Monad.ST

import Data.Char
import Data.List
import Data.Maybe

import qualified Data.ByteString.Char8 as B

import Data.Array.ST.Safe
import Data.STRef

import Debug.Trace
import Text.Printf

readInt = readLn :: IO Int
readInteger = readLn :: IO Integer
readInts = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine
readIntegers = map ( fst . fromJust . B.readInteger ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

modifyArray a i f = writeArray a i =<< f <$> readArray a i

main = do
	[ n, k ] <- readInts
	hs <- reverse . sort <$> readIntegers
	print $ sum $ drop k hs

Measured memory_bytes: 32124
#include <iostream>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <unordered_map>

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

using namespace std;

int main()
{
  string s;
  cin >> s;
  int n = s.length();

  int count0 = 0;
  int count1 = 0;
  REP(i, n)
  {
    if (s[i] == '0')
    {
      count0++;
    }
    else
    {
      count1++;
    }
  }
  cout << n - abs(count0 - count1) << endl;
}


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

/*各食べ物iに対して回答人数をカウント*/

int main(){
    int n, m;
    cin >> n >> m;
    int A[m] = {};
    for(int i=0;i<n;i++){
        int k; cin >> k;
        for(int j=0;j<k;j++){
            int a; cin >> a; a--;
            A[a]++;
        }
    }
    int ans = 0;
    for(int i=0;i<m;i++){
        if(A[i] == n){
            ans++;
        }
    }
    cout << ans << endl;
}

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

void solv() {
    int N;
    ll a = 1, b = 1;
    cin >> N;
    rep(i, N) {
        ll buf, buf2;
        cin >> buf >> buf2;
        ll n = max((a + (buf - 1) )/ buf, (b + (buf2 - 1) )/ buf2);
        a = buf * n;
        b = buf2 * n;
    }
    cout << a + b << endl;
}

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

Measured memory_bytes: 256