akhauriyash/Code-Regression huggingface dataset:
# -*- coding: utf-8 -*-
# スペース区切りの整数の入力
N, M = map(int, input().split())
# 文字列の入力
H_list = list(map(int, input().split()))
#print(H_list)
#開業されたN個要素を受け付ける
road_list = []
for i in range(M):
    road_list.append(list(map(int, input().split())))
    #road_list.append(input())
#print(road_list)
flg_list=[]
for i in range(N):
    flg_list.append(1)

#print(flg_list)

ans = 0
'''
for i in range(N):
    #print(i+1)
    flg = 1
    for road in road_list:
        if i+1 in road:
            if i+1 == road[0] and H_list[road[0]-1] <= H_list[road[1]-1]:
                flg=0
            elif i+1 == road[1] and H_list[road[1]-1] <= H_list[road[0]-1]:
                flg=0
    if flg==1:
        #print("flg")
        ans=ans+1
'''
for road in road_list:
    if H_list[road[0]-1] < H_list[road[1]-1]:
        flg_list[road[0]-1]=0
    elif H_list[road[1]-1] < H_list[road[0]-1]:
        flg_list[road[1]-1]=0
    else:
        flg_list[road[0]-1]=0
        flg_list[road[1]-1]=0
for i in range(N):
    if flg_list[i]==1:
        ans=ans+1


print(ans)


Measured memory_bytes: 32060
#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 <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;
//typedef pair<int,int> Pint;
typedef pair<ll, ll> P;
//typedef pair<int, pair<int, int>> P;
//typedef tuple<int,int,int> T;
typedef vector<ll> vec;
typedef vector<vec> mat;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define revrep(i, n) for(ll i = n-1; i >= 0; i--)
ll INFL = 1LL << 60;//10^18 = 2^60
int INF = 1 << 30;//10^9
ll MOD  = 1000000007;
vector<int> dy = {0,0,1,-1};
vector<int> dx = {1,-1,0,0};
//vector<int> dy = {1, 1, 1, 0, -1, -1, -1, 0};
//vector<int> dx = {1, 0, -1, -1, -1, 0, 1, 1};

ll max(ll a, ll b){return (a > b) ? a : b;}
ll min(ll a, ll b){return (a < b) ? a : b;}
ll pow(ll x, ll k){
  ll res = 1;
  while(k > 0){
    if(k % 2) res *= x;
    x *= x;
    k /= 2;
  }
  return res;
}

ll pow_mod(ll x, ll k){
  x %= MOD; x += MOD; x %= MOD;
  ll res = 1;
  while(k > 0){
    if(k % 2){
      res *= x; res %= MOD;
    }
    x *= x; x %= MOD;
    k /= 2;
  }
  return res;
}
ll inverse(ll x){return pow_mod(x, MOD - 2);};

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


int main(){
  ll A, B; cin >> A >> B; A--;
  //B XOR A

  if(A % 2){
    ll cnt = (A+1) / 2;
    if(cnt % 2) cnt = 1;
    else cnt = 0;
    A = cnt;
  }else{
    ll cnt = (A+1) / 2;
    if(cnt % 2) cnt = 1;
    else cnt = 0;
    A ^= cnt;
  }

  if(B % 2){
    ll cnt = (B+1) / 2;
    if(cnt % 2) cnt = 1;
    else cnt = 0;
    B = cnt;
  }else{
    ll cnt = (B+1) / 2;
    if(cnt % 2) cnt = 1;
    else cnt = 0;
    B ^= cnt;
  }






  cout << (A ^ B) << endl;
}


Measured memory_bytes: 256
#人のです。
N,M = map(int,input().split())
A = [[0 for j in range(N)] for i in range(N)]
for i in range(M):
    a,b = map(int,input().split())
    A[a-1][b-1]=1
    A[b-1][a-1]=1
#行き方が１通りしかない点から伸びた線を消し、新たに１通りになった点から線を消し、、、というループ（線の存在を１で表現）
flag = True
ans = 0
while(flag):
    flag = False
    for i in range(N):
        if A[i].count(1) == 1:
            flag = True
            ans += 1
            j = A[i].index(1)
            A[i][j] = 0
            A[j][i] = 0
print(ans)

Measured memory_bytes: 3064
a,b,h,m = map(int,input().split())
pi = 3.14159265358979323846
s = pi*m/30
t = pi*h/6 + pi*m/360
import math
diff = s - t
cos = math.cos(s-t)
#print(cos)
print((a**2+b**2-2*a*b*cos)**.5)

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

using namespace std;

int n, m;
long long x, ans;

priority_queue<long long> t;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> m;
	for (int i = 0; i < n; ++i){
		cin >> x;
		t.push(x);
	}
	for (int i = 0; i < m; ++i){
		int tmp = t.top() >> 1;
		t.pop();
		t.push(tmp);
	}
	for (int i = 0; i < n; ++i){
		ans += t.top();
		t.pop();
	}
	cout << ans << endl;
}

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

int n;
int c1, m1, s1, m2, s2, m3, s3, m4, s4;
pair<int, int> ttt[1000000];

signed main()
{
	while (true)
	{
		cin >> n;
		if (n == 0) break;
		rep(i,n)
		{
			cin >> c1 >> m1 >> s1 >> m2 >> s2 >> m3 >> s3 >> m4 >> s4;
			int sec = m1 * 60 + s1 + m2 * 60 + s2 + m3 * 60 + s3 + m4 * 60 + s4;
			ttt[i] = pair<int, int>(sec, c1);
		}
		sort(ttt, ttt + n);
		cout << ttt[0].second << endl;
		cout << ttt[1].second << endl;
		cout << ttt[n - 2].second << endl;
	}
}

Measured memory_bytes: 8976
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int i= 1;
		do{
			int x=i;
			if(x%3==0){
				System.out.print(" "+i);
			}else{
			while(true){
				if(x%10==3){
					System.out.print(" "+i);
					break;
				}
				x/=10;
				if(x!=0) continue;
				else break;
			}
			}
		}while(++i<=n);
			System.out.println();
	}
}

Measured memory_bytes: 28656
#include <stdio.h>
#include <stdlib.h>

int main(void)
{
  int A, B, C, D;

  scanf("%d %d %d %d", &A, &B, &C, &D);

  while (1)
  {
    C -= B;
    if (C <= 0)
    {
      printf("Yes");
      break;
    }

    A -= D;
    if (A <= 0)
    {
      printf("No");
      break;
    }
  }

  return 0;
}

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

string burger_gen ( int n ) {
    if ( n == 0 ) return "P";
    return "B"+burger_gen(n-1)+"P"+burger_gen(n-1)+"B";
}

int main(){
    int n;
    ll x;
    cin >> n >> x;
    vector<ll> p_num(n+1);
    vector<ll> total_num(n+1);
    p_num[0] = 1;
    total_num[0] = 1;
    for ( int i = 1; i <= n; ++i ) {
        p_num[i] = p_num[i-1] * 2 + 1;
        total_num[i] = total_num[i-1] * 2 + 3;
    }
    ll ans = 0;
    for ( int i = n; i >= 0; --i ) {
        if ( x == 0 ) break;
        if ( x == total_num[i] ) {
            ans += p_num[i];
            break;
        }
//        if ( x == 1 ) {
//            break;
//        }
        if ( x <= 1LL + total_num[i-1] ) {
            --x;
        }
        else {
            ans += 1LL + p_num[i-1];
            x -= 1LL + total_num[i-1] + 1LL;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) throws FileNotFoundException {

//    Scanner cin = new Scanner(new FileReader("input.txt"));
    Scanner cin = new Scanner(System.in);
    String n = cin.next();
    int countA=0;
    int countB=0;
    for (int i=0;i<3;i++) {
      if (n.charAt(i)=='A'){
        countA++;
      }
      if (n.charAt(i)=='B')
        countB++;
    } 
    if (countA!=0&&countB!=0)
      System.out.println("Yes");
    else 
      System.out.println("No");
  }

}


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

int main() {
	while (1) {
		string a; int b, c;
		cin >> a >> b >> c;
		if (cin.fail())break;
		cout << a << " " << b + c <<" "<< b * 200 + c * 300 << endl;
	}
}

Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
vector<int> to[1000];
int distnum[1000], door[1000];
void init(){
    rep(i, 1000) to[i].clear();
    memset(distnum, 0, sizeof(distnum));
    memset(door, 0, sizeof(door));
}
int main(){
    int T; scanf("%d", &T);
    int _t;
    rep(casenum, T){
        init();
        scanf("%d", &_t);
        int count = 0, dist = 0;
        distnum[++dist] = ++count;
        door[dist] = _t;
        while(scanf("%d", &_t) && _t){
            while(dist > 0 && door[dist] == 0)
              --dist;
            --door[dist];
            if(_t > 0){
                distnum[++dist] = ++count;
                door[dist] = _t - 1;
                to[count].push_back(distnum[dist - 1]);
                to[distnum[dist - 1]].push_back(count);
            }else{
                to[distnum[dist + _t]].push_back(distnum[dist]);
                to[distnum[dist]].push_back(distnum[dist + _t]);
                door[dist + _t]--;
            }
        }

        REP(i, 1, count + 1){
            printf("%d", i);
            sort(to[i].begin(), to[i].end());
            rep(j, to[i].size())
              printf(" %d", to[i][j]);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

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


Measured memory_bytes: 256
#include <stdio.h>

int compare(const void *a, const void *b) {
	return *(int *)a - *(int *)b;
}

int next(void) {
	int i;
	char ch;
	int ret;

	ch = getchar();
	ungetc(ch, stdin);

	if (ch == '[') {
		int ary[10000], cnt;

		cnt = 0;
		while(getchar() == '[')
			ary[cnt++] = next();

		qsort(ary, cnt, sizeof(int), &compare);

		ret = 0;
		for (i = 0; i < cnt + 1 >> 1; i++)
			ret += ary[i];
	} else {
		scanf("%d]", &ret);
		ret = ret + 1 >> 1;
	}

	return ret;
}

int main(void) {
	int n;

	scanf("%d ", &n);

	while (n--) {
		getchar();
		printf("%d\n", next());
		getchar();
	}

	return 0;
}

Measured memory_bytes: 712
#include<bits/stdc++.h>
using namespace std;
int main(){
   int N, S, a;
   int c = 4, d = 7;
   cin >> N;
   bool b = false;
   if(N % c == 0 || N%d == 0) b = true;
   else{
    a = N / c;
    for(int i=0;i<a;i++){
        S = (a - i) * c;
        while(S < N){
            S += d;
            if(S == N){
                b = true;
                break;
            }
        }
    }
   }
   if(b == true) cout << "Yes\n";
   else cout << "No\n";
   return 0;
}


Measured memory_bytes: 256
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

static const long long mod = 1000000007;

struct UnionFind {
  vector<ll> par, sizes;
  ll cnt;
  UnionFind(ll N) : par(N), sizes(N, 1), cnt(N) {
    for (ll i = 0; i < N; i++) par[i] = i;
  }

  ll find(ll x) { return par[x] == x ? x : par[x] = find(par[x]); }

  bool same(ll x, ll y) { return find(x) == find(y); }

  ll size(ll x) { return sizes[find(x)]; }

  void unite(ll x, ll y) {
    x = find(x);
    y = find(y);
    if (x == y) return;
    if (sizes[x] < sizes[y]) swap(x, y);
    par[y] = x;
    sizes[x] += sizes[y];
    cnt--;
  }

  ll count() const { return cnt; }
};

int main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n, m;
  cin >> n >> m;

  UnionFind uf(n + m);
  rep(i, n) {
    ll k;
    cin >> k;
    rep(j, k) {
      ll l;
      cin >> l;
      l--;
      uf.unite(i, n + l);
    }
  }
  bool ok = true;
  rep(i, n) if (!uf.same(0, i)) {
    ok = false;
    break;
  }
  string ans = ok ? "YES" : "NO";
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3456
import std.stdio, std.string, std.conv, std.algorithm, std.numeric, std.array, std.range;

void main() {
  long n;
  readf("%d\n", &n);
  auto s = readln.strip;

  if (s.count('R') > s.count('B')) {
    writeln("Yes");
  } else {
    writeln("No");
  }
}


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

int main() {
    int a, b;
    string s;
    cin >> a >> b >> s;
    for(int i = 0; i < a+b+1; ++i) {
        if(i < a) {
            if(s[i] == '-') {
                cout << "No" << '\n';
                return 0;
            }
        } else if(i == a) {
            if(s[i] != '-') {
                cout << "No" << '\n';
                return 0;
            }
        } else {
            if(s[i] == '-') {
                cout << "No" << '\n';
                return 0;
            }
        }

    }
    cout << "Yes" << '\n';

    return 0;
}


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

int main() {
  int a, b; //入力する数値の初期化
  
  cin >> a >> b;
  
  if (a * b % 2 == 0){
  	cout << "Even" << endl;
  }else{
  	cout << "Odd" << endl;
  }
}


Measured memory_bytes: 3548
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;

int main(){
    int A,B,K;
    cin >> K >> A >> B;
    if(B%K == 0 | A%K == 0 | B/K - A/K > 0) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}

Measured memory_bytes: 3624
s = str(input())
t = str(input())

num2alpha = lambda c: chr(c+96)
#print(num2alpha(3)) #==> c
alpha2num = lambda c: ord(c) - ord('a') + 1
#alpha2num('y') #==> 25 

S = [0] * 26
T = [0] * 26
for i in range(len(s)):
  S[alpha2num(s[i]) - 1] += 1
for i in range(len(t)):
  T[alpha2num(t[i]) - 1] += 1
#print(S, T)  
  
ss = 0
while S[ss] == 0:
  ss += 1
tt = 25
while T[tt] == 0:
  tt -= 1
  
if tt < ss:
  print("No")
elif tt > ss:
  print("Yes")
else:
  if (T[tt] == sum(T)) and (S[ss] == sum(S)):
    if sum(T) > sum(S):
      print("Yes")
    else:
      print("No")
  else:
    print("No")
  
  
  

  
  

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

int main(){
    int d; cin >> d;
    if(d==25) cout << "Christmas" << endl;
    else if(d==24) cout << "Christmas Eve" << endl;
    else if(d==23) cout << "Christmas Eve Eve" << endl;
    else cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 3632
package main

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

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

	if !sc.Scan() {
		panic(errors.New("cannot read stdin"))
	}
	s := strings.Split(sc.Text(), " ")
	var a, b float64
	var c int
	var err error
	if a, err = strconv.ParseFloat(s[0], 64); err != nil {
		panic(err)
	}
	if b, err = strconv.ParseFloat(s[1], 64); err != nil {
		panic(err)
	}
	if c, err = strconv.Atoi(s[2]); err != nil {
		panic(err)
	}

	numMaxListen := int(math.Floor(b / a))
	numListen := c

	if c > numMaxListen {
		numListen = numMaxListen
	}

	fmt.Println(numListen)
}

Measured memory_bytes: 640
length = int(input())
text = input()

r_count = text.count("R")
g_count = text.count("G")
b_count = text.count("B")

answer = r_count * g_count * b_count

for i in range(length-2):
    for j in range(i+1, length-1):
        k = i + (j-i)*2
        if k < length and text[i]!=text[j] and text[i]!=text[k] and text[j]!=text[k]:
            answer -= 1
        
print(answer)

Measured memory_bytes: 9136
#include <iostream>
#include <vector>
#include<list>
#include <algorithm>
#include <string>
#include <math.h>
#include<map>
#include <utility>
#include <cstring>
#include <iomanip>
#include<queue>
using namespace std;
#define REP(i,k,n) for(int i=k;i<n;i++)
 
#define INF 1000000000
typedef long long  ll;
#define SIZE_OF_ARRAY(array) (sizeof(array)/sizeof(array[0]))
#define MOD 1000000007

template<typename T>
int vector_finder(std::vector<T> vec, T number) {
  auto itr = std::find(vec.begin(), vec.end(), number);
  size_t index = std::distance( vec.begin(), itr );
  if (index != vec.size()) { // 発見できたとき
    return 1;
  }
  else { // 発見できなかったとき
    return 0;
  }
}

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

template<typename T>
T lcm(T a,T b){
	T g = gcd(a, b);
	return a /g* b ;
}

void clear( std::queue<pair<int,int> > &q )
{
   std::queue<pair<int,int> > empty;
   std::swap( q, empty );
}
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
template<typename T>
int  GetDigit(T num){
    int digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}

template<typename T>
std::vector<T> enum_div(T n)//nの約数を列挙
{
	std::vector<T> ret;
	for(T i=1 ; i*i<=n ; ++i)
	{
		if(n%i == 0)
		{
			ret.push_back(i);
			if(i!=1 && i*i!=n)
			{
				ret.push_back(n/i);
			}
		}
	}
	return ret;
}


class DisjointSet{
    public:
        vector<int> rank, p;

        DisjointSet(){
        }

        DisjointSet(int size){
            rank.resize(size, 0);
            p.resize(size, 0);
            for (int i = 0; i < size;i++){
                makeSet(i);
            }
        }
        void makeSet(int x){
            p[x] = x;
            rank[x] = 0;
        }

        bool same(int x,int y){
            return findSet(x) == findSet(y);
        }
        void unite(int x,int y){
            link(findSet(x), findSet(y));
        }
        void link(int x,int y){
            if(rank[x]>rank[y]){
                p[y] = x;
            }else{
                p[x] = y;
                if(rank[x]==rank[y]){
                    rank[y]++;
                }
            }
        }
        int findSet(int x){
            if(x!=p[x]){
                p[x] = findSet(p[x]);
            }
            return p[x];
        }
};


int main()
{
    int N;
    cin >> N;
    ll a[N];
    REP(i,0,N){
        cin >> a[i];
    }
    ll dp[N + 1][N + 1];
    REP(i, 0, N + 1)
    REP(j, 0, N + 1) dp[i][j] = 0;

    for(int len = 1; len <= N; len++){
		for(int l = 0; l < N - len + 1; l++){
			int r = l + len;
			if((N - len) % 2 == 0){
				dp[l][r] = max(dp[l+1][r] + a[l], dp[l][r-1] + a[r-1]);
			}else{
				dp[l][r] = min(dp[l+1][r] - a[l], dp[l][r-1] - a[r-1]);
			}
		}
	}
 
	cout << dp[0][N] << endl;
}

Measured memory_bytes: 70656
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int Q = sc.nextInt();
    int[] num = new int[Q];
    int[] count = new int[N];
    int t = 0;//入れ替え用
    //for(int j=0; j < N; j++){
    //    count[j] = K;
    //}
    for(int i=0; i < Q; i++){
        num[i] = sc.nextInt();
        count[num[i]-1]++;
    }
    for(int j=0; j < N; j++){
        if((count[j]+K-Q) > 0){
        System.out.println("Yes");
        }else{
        //System.out.println(count[j]);
        System.out.println("No");
        }
    }
  }
}

Measured memory_bytes: 54140
#include <iostream>
#include <vector>

#define u unsigned
#define s short
#define ll long long
#define REP(i, a, b) for (auto i = (a); i < (b); i++)
#define REPR(i, a, b) for (auto i = (a-1); i >= (b); i--)

using namespace std;

void solve() 
{
    int N; cin >> N;
    string colors; cin >> colors;

    vector<int> wArr, rArr;

    REP(i, 0, N)
    {
        if (colors[i] == 'W')
            wArr.push_back(i);
        else if (colors[i] == 'R')
            rArr.push_back(i);
    }

    int wIdx = 0, rIdx = rArr.size() - 1;

    int count = 0;
    while (wIdx < wArr.size() and rIdx >= 0 and wArr[wIdx] < rArr[rIdx])
    {
        count++;
        wIdx++;
        rIdx--;
    }

    cout << count << "\n";
}

int main()
{
    solve();

    return 0;
}

Measured memory_bytes: 4740
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define fo(i, j, n) for(int i=(j); i<(n); i++)
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; }


int main() { 
   int n, k, r, s, p; string t; 
   cin >> n >> k >> r >> s >> p >> t;

    vector<char> his;
    int res = 0;
    rep(i, k){
        char h; 
        if(t[i]=='r'){h = 'p'; res +=p;}
        if(t[i]=='p'){h = 's'; res += s;}
        if(t[i]=='s'){h = 'r'; res += r;}
        his.push_back(h);
    }
    fo(i, k, t.size()){
        int bef = i - k;
        char h;
        if(t[i]=='r'){h = 'p';}
        if(t[i]=='p'){h = 's';}
        if(t[i]=='s'){h = 'r';}
        if(his[bef] ==h){
            h = '?';
        }else{
            if(h=='r')res+=r;
            if(h=='s')res+=s;
            if(h=='p')res+=p;
        }
        his.push_back(h);
    }
    cout << res << ln;
}








Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <limits.h>
#include <vector>
#include <numeric>

using namespace std;

vector<pair<long long int, long long int>> getPrimeElements(long long int num) {

	long long int firstnum = num;

	vector<pair<long long int, long long int>> result;
	pair<long long int, long long int> wk;

	if (num % 2 == 0) {
		wk.first = 2;
		wk.second = 0;
		while (num % 2 == 0) {
			wk.second++;
			num /= 2;
		}

		result.push_back(wk);
	}

	long long int waru = 3;

	while (true) {

		if (num % waru == 0) {
			wk.first = waru;
			wk.second = 0;
			while (num % waru == 0) {
				wk.second++;
				num /= waru;
			}

			result.push_back(wk);
		}
		waru += 2;

		if (waru * waru > num) break;

	}

	if (num != 1) {
		wk.first = num;
		wk.second = 1;
		result.push_back(wk);

	}

	return result;
}


int getKeta(int num) {

	if (num == 0)return 1;

	int res = 0;

	while (num > 0) {
		num /= 10;
		res++;
	}

	return res;
}

vector<int> bunkai(int num) {

	string str = to_string(num);
	vector<int> res;

	for (int i = 0; i < str.size(); i++) {
		int a = str[i] - '0';
		res.push_back(a);
	}

	return res;

}


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

	vector<pair<int, int>> state(m);

	for (auto& i : state) {
		cin >> i.first;
		cin >> i.second;
	}

	int ans = -1;

	for (int i = 0; i <= 1000; i++) {
		if (getKeta(i) != n)continue;

		vector<int> wk = bunkai(i);
		bool isAns = true;

		for (int j = 0; j < m; j++) {

			if (wk[state[j].first - 1] != state[j].second) {
				isAns = false;
				break;
			}



		}

		if (isAns) {
			ans = i;
			break;
		}
	}


	cout << ans << endl;

	return 0;

}




Measured memory_bytes: 256
N, x = map(int, input().split())
A = [int(i) for i in input().split()]

ans = max(A[0]-x, 0)
A[0] = min(x, A[0])

for i in range(N-1):
  sur = max(A[i] + A[i+1] - x, 0)
  ans += sur
  A[i+1] -= sur

print(ans)

Measured memory_bytes: 63984
S = input()
N = len(S)
def ispalindrome(string): return True if string==string[::-1] else False

S1=S[0:(N-1)//2]
S2=S[-1+(N+3)//2:N]

if ispalindrome(S) and ispalindrome(S1) and ispalindrome(S2):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
package main

import "fmt"

func main(){
	str := [32] int{1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51}
	var K int
	fmt.Scan(&K)
	for i := 1 ; i <= K ; i++ {
		if i == K{
			fmt.Println(str[K-1])
		}
	}
}

Measured memory_bytes: 512
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <climits>
#include <iostream>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <vector>
#include <sstream>
#include <typeinfo>
#include <fstream>

#define DIV 1000000007

using namespace std;

long long N;

int main(){
	cin >> N;
	if(N == 2){
		cout << -1 << endl;
		return 0;
	}
	if(N%2 == 1){
		for(int i = 0; i < N; i++){
			for(int j = 1; j < N; j++){
				int num = (i+j)%N + 1;
				cout << num;
				if(j != N-1){
					cout << " ";
				}
			}
			cout << endl;
		}
	}else{
		for(int i = 0; i < N; i++){
			if(i == 0){
				for(int j = 1; j < N; j++){
					if(j == 1){
						cout << N;
					}else if(j == N-1){
						cout << 2;
					}else{
						int num = (i+j)%N + 1;
						cout << num;
					}
					if(j != N-1){
						cout << " ";
					}
				}
			}else if(i == N-1){
				for(int j = 1; j < N; j++){
					if(j == N-1){
						cout << 1;
					}else{
						cout << N-j;
					}
					if(j != N-1){
						cout << " ";
					}
				}
			}else{
				for(int j = 1; j < N; j++){
					if(j == N-1){
						cout << N;
					}else{
						int num = (i+j)%(N-1) + 1;
						cout << num;
					}
					if(j != N-1){
						cout << " ";
					}
				}
			}
			cout << endl;
		}
	}
}


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

using namespace std;
typedef long long LL;

#ifdef BTK
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww {cww() {CIN_ONLY{ios::sync_with_stdio(false); cin.tie(0);}}
}star;
#define DEBUG if(0)
#endif

#define ALL(v) (v).begin(),(v).end()
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l, T r){bool a = l>r; if (a)l = r; return a;}
template <typename T>inline bool chmax(T &l, T r){bool a = l<r; if (a)l = r; return a;}
template <typename T>istream& operator>>(istream &is, vector<T> &v){for (auto &it : v)is >> it;return is;}

class range {private: struct I { int x; int operator*() { return x; }bool operator!=(I& lhs) { return x<lhs.x; }void operator++() { ++x; } }; I i, n;public:range(int n) :i({ 0 }), n({ n }) {}range(int i, int n) :i({ i }), n({ n }) {}I& begin() { return i; }I& end() { return n; }};

int main() {
	LL N, K;
	cin >> N >> K;
	LL ret = (N / K)*(N / K)*(N / K);
	if (K % 2 == 0) {
		N = max(0ll, N + K / 2);
		ret += (N / K)*(N / K)*(N / K);
	}
	cout << ret << endl;
	
	return 0;
}


Measured memory_bytes: 256
//@author :  |< U $ |-|
#include<cmath>
#include<iostream>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<deque>
#include<queue>
#include<algorithm>
#include<list>
#include<cstring>
#define ll long long
#define vi vector<long long>
#define pb push_back
#define pop pop_back
#define pi pair<long long ,long long>
#define vp vector<pair<long long,long long> >
#define mkp make_pair
#define in(i,n) for(i=0;i<n;i++)
#define fon(i,n,m) for(i=n;i<m;i++)
#define rfon(i,n,m) for(i=n;i>=m;i--)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);
#define map map<long long,long long>
#define inm1(b)  memset(b,-1,sizeof(b))
#define in0(b) memset(b,0,sizeof(b))
#define ininf(b) memset(b,1000000001,sizeof(b))
#define MOD         1000000007
#define I 10000000001
#define TakeInput freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
using namespace std;
int gcd(int a, int b) {  if (a == 0)  return b; return gcd(b % a, a); }

int main()
{
    jaldi
    #ifndef ONLINE_JUDGE 
    //TakeInput
    #endif
    
    ll n,i,j;

    cin>>n;
    ll a[n];
    map mp;
    in(i,n){
        cin>>a[i];
        mp[a[i]]=i+1;
    }
    fon(i,1,n+1){
        cout<<mp[i]<<" ";
    }
}
 
 








 



Measured memory_bytes: 7936
N = int(input())
A_list = list(map(int, input().split()))

for i in range(N):
    A_list[i] = A_list[i] - i - 1

A_list = sorted(A_list)
if(N % 2 == 0):
    key = N // 2
else:
    key = (N - 1) // 2
b = A_list[key]
sadness = 0

for A in A_list:
    sadness += abs(A - b)

print(sadness)

Measured memory_bytes: 25196
#include <bits/stdc++.h>
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

ll f(ll n, ll x)
{
    if (n == -1) return 0;
    return n / x+1;
}

int main()
{
    ll a, b, x; cin >> a >> b >> x;
    ll l = f(b, x);
    ll r = f(a-1, x);
    cout << l - r << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define INF (1e9)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N; cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i];

    set<int> dic;
    rep(i,N) {
        if (dic.count(A[i])) {
            cout << "NO" << endl;
            return 0;
        }
        dic.emplace(A[i]);
    }

    cout << "YES" << endl;
}

Measured memory_bytes: 10368
aw = 0
for i in map(int, input().split()):
    if i == 1:
        aw+=300000
    elif i ==2 :
        aw+= 200000
    elif i ==3 :
        aw+= 100000
if aw== 600000:
    aw= 1000000
print(aw)

Measured memory_bytes: 3060
#include <iostream>
#include <algorithm>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<iomanip>
#include<ctime>
#include<set>
#include<map>
#include<queue>
#include<stack>
#define sqr(x) ((x)*(x))
#define fz1(i,n) for ((i)=1;(i)<=(n);(i)++)
#define fd1(i,n) for ((i)=(n);(i)>=1;(i)--)
#define fz0g(i,n) for ((i)=0;(i)<=(n);(i)++)
#define fd0g(i,n) for ((i)=(n);(i)>=0;(i)--)
#define fz0k(i,n) for ((i)=0;(i)<(n);(i)++)
#define fd0k(i,n) for ((i)=(long long)((n)-1);(i)>=0;(i)--)
#define fz(i,x,y) for ((i)=(x);(i)<=(y);(i)++)
#define fd(i,y,x) for ((i)=(y);(i)>=(x);(i)--)
#define fzin fz1(i,n)
#define fzim fz1(i,m)
#define fzjn fz1(j,n)
#define fzjm fz1(j,m)
#define ff(c,itr) for (__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)
#define rdst(st,len){static char ss[len];scanf(" %s",ss);(st)=ss;}
#define inc(x,y) {x+=(y);if(x>=mod)x-=mod;}
#define dec(x,y) {x-=(y);if(x<0)x+=mod;}
using namespace std;
long long n,m,k,i,j,mod=1e9+7,a1,a2,b1,b2,c;
char mp[1005][1005];
struct mat
{
	long long a[2][2];
}uit;
long long qp(long long x,long long y)
{
	long long z=1;
	while (y){
		if(y&1)z=1ll*x*z%mod;
		x=1ll*x*x%mod;
		y/=2;
	}
	return z;
}
mat mul(mat x,mat y)
{
	mat z;
	memset(z.a,0,sizeof(z.a));
	int i,j,k;
	fz0k(i,2)fz0k(j,2)fz0k(k,2){
		(z.a[i][j]+=x.a[i][k]*y.a[k][j])%=mod;
	}
	return z;
}
mat qp(mat x,long long y)
{
	mat z;
	memset(z.a,0,sizeof(z.a));
	z.a[0][0]=z.a[1][1]=1;
	while (y){
		if(y&1)z=mul(x,z);
		x=mul(x,x);
		y/=2;
	}
	return z;
}
int main()
{
	scanf("%lld%lld%lld",&n,&m,&k);
	fz1(i,n){
		scanf(" ");
		fz1(j,m){
			scanf("%c",&mp[i][j]);
			if(mp[i][j]=='#'){
				c++;
			}
		}
	}
	fz1(i,n){
		fz1(j,m){
			if(mp[i][j]=='#'){
				if(i<n&&mp[i+1][j]=='#'){
					a2++;
				}
				if(j<m&&mp[i][j+1]=='#'){
					a1++;
				}
			}
		}
	}
	fz1(i,n){
		if(mp[i][1]=='#'&&mp[i][m]=='#'){
			b1++;
		}
	}
	fz1(i,m){
		if(mp[1][i]=='#'&&mp[n][i]=='#'){
			b2++;
		}
	}
	if(b1&&b2){
		puts("1");
		return 0;
	}
	if(!b1&&!b2){
		printf("%lld\n",qp(c,k-1));
		return 0;
	}
	long long a=(b1?a1:a2),b=(b1?b1:b2);
	uit.a[0][0]=c;uit.a[0][1]=a;
	uit.a[1][0]=0;uit.a[1][1]=b;
	uit=qp(uit,k-1);
	cout<<(uit.a[0][0]-uit.a[0][1]+mod)%mod<<endl;
	return 0;
}

Measured memory_bytes: 1280
#include <iostream>

int main()
{
  long long int a, b, x;
  std::cin >> a >> b >> x;
  long long int ans = 0;

  ans += b / x + 1;

  if ( a != 0 ) {
    ans-= (a-1) / x + 1;
  }
  
  std::cout << ans << std::endl;
  return 0;
}


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




int main()
{
    int n;
    cin>>n;
    int t,a;
    cin>>t>>a;
    double val=1e9;
    int ans;
    
    for(int i=1;i<=n;i++){
        int h;
        cin>>h;
        double x=t-h*0.006;
        if(fabs(a-x)<val){
            val=fabs(a-x);
            ans=i;
        }
    }
    cout<<ans;






}

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

using namespace std;

#define rep(i,n) for(int i=0; i<(n); i++)
#define T int t, q=0; scanf("%d", &t); while(q++<t)
#define ll long long
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
ll x,y,z,a=0,b=0,c=0,d=0,sum,ans,total,cnt,n,m,k,p,kase,i;
string s1,s2;
#define N 100001
#define MX 1000000001
vector <ll> v;
map<ll,ll> mp;
set<ll> s;
map<ll,ll> :: iterator itr1, ptr1;
set<ll> :: iterator itr, ptr;


int main()
{

    cin>>s1;

    c=0;
    if(s1[2]==s1[3])c++;
    if(s1[4]==s1[5])c++;

    if(c==2)cout<<"Yes";
    else cout<<"No";




    return 0;
}
// Happy Coding  (:


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

#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
typedef long long ll;

int main()
{
    IOS

    string s;
    cin >> s;

    bool dec = true;
    int n = s.length();

    for ( int i = 0, j = n - 1; i < j; ++i, --j )
    {
        if ( s[i] != s[j] )
        {
            dec = false;
            break;
        }
    }

    if ( dec )
    {
        for ( int i = 0, j = ( ( n - 1 ) / 2 ) - 1; i < j; ++i, --j )
        {
            if ( s[i] != s[j] )
            {
                dec = false;
                break;
            }
        }
        if ( dec )
        {
            for ( int i = ( ( n + 3 ) / 2 ) - 1, j = n - 1; i < j; ++i, --j )
            {
                if ( s[i] != s[j] )
                {
                    dec = false;
                    break;
                }
            }

            cout << ( dec ? "Yes" : "No" );
        }
        else
        {
            cout << "No";
        }
    }
    else
    {
        cout << "No";
    }


    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<double> VI;  // VI a(n);
typedef vector<string> VS;   
typedef vector<VI> VVI;   // VVI a(n,vector<int>(m)) n * m 
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;  //ll とdoubleは違う
// cout << << endl;
// cin >> ;
int main(){
    ll a=100000,b=0,c=0,d=0,n,m,k,ans=0;
    string s,s2;
    cin >> s;
    //VI p(n);
    rep(i,s.size()-2){
        b =abs(753 - ((s[i]-'0')*100 + (s[i+1]-'0')*10 + s[i+2]-'0'));
        if(b<a){
            a=b;
        }
    }
    cout << a <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

int main(void) {
  int x, y, z;
  scanf("%d %d %d", &x, &y, &z);

  swap(&x, &y);
  swap(&x, &z);

  printf("%d %d %d\n", x, y, z);

  return 0;
}


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

int main() {
    string S;
    cin >> S;
    int ans = 0;
    for(int i = 0; i < S.size()/2; i++) {
        if(S[i] != S[S.size()-i-1]) {
            ans++;
        }
        
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#pragma GCC target("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include<bits/stdc++.h>

#define f			first
#define sz(a)       ((int)(a).size())
#define s			second
#define all(v)		v.begin(),v.end()
#define pii 		pair<int,int>
#define vpii 		vector<pii>
#define eb			emplace_back
#define pb			push_back
#define fo(i,n)		for(int i=0;i<n;i++)
#define Fo(i,k,n)	for(int i=k;i<n;i++)
#define vi			vector<ll>
#define deb(x)		cout << #x << " " << x << endl

using namespace std;
using ll  = long long;
using lld = long double;

const int oo = 0x3f3f3f3f;
const ll MOD = 1000000007;

const int N = 1e5 + 100;
ll a[N][3] , dp[N][3];

inline void relax(ll & x , ll b){
    x = max(x , b);
    return;
}

signed main(){

#ifndef ONLINE_JUDGE
	//freopen("in.txt" , "r" , stdin);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);

    int n;
    cin >> n;

    fo(i , n) fo(j , 3) cin >> a[i][j];

    fo(i , n) fo(j , 3) 
    {
        dp[i][j] += a[i][j];
        relax(dp[i + 1][(j + 2)%3] , dp[i][j]);
        relax(dp[i + 1][(j + 1)%3] , dp[i][j]);
    }

    cout << max({dp[n - 1][0] , dp[n - 1][1] , dp[n - 1][2]}) << '\n';


    return 0;
}



Measured memory_bytes: 8356
"use strict"
const create = () => {
    const input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
    const res = {
        "list": input, "index": 0, "max": input.length,
        "hasNext": function() {return this.index < this.max},
        "next": function() { if (!this.hasNext()) {throw "ArrayIndexOutOfBoundsException";}else{return this.list[this.index++];}}
    };
    return res;
}
const o = create();
const next = () => o.next()
const nextInt = () => parseInt(o.next())
const nextStrArray = () => o.next().split(" ")
const nextIntArray = () => o.next().split(" ").map(el => parseInt(el))
const nextCharArray = () => o.next().split("")
const hasNext = () => o.hasNext()
const myout = (...x) => console.log(...x)
const Main = () => {
    const s = next()
    let cnt = 0
    let curr = s[0]
    for(let i =1; i<s.length; i++){
        if(curr != s[i]){
            cnt++
            curr = s[i]
        }
    }
    console.log(cnt)
}
Main()


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

typedef long long LL;
#define dbg(x) cout << #x"=" << x << endl;
const int MAX_N = 2e5+100;
int n,k,h[MAX_N];

int main(){
   // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0); cin.tie(0);
    cin >> n >> k;
    for(int i = 0; i < n; ++i){
        cin >> h[i];
    }
    sort(h, h+n);
    LL ans = 0;
    for(int i = n-1; i >= 0; --i){
        if(k == 0) {
            ans += h[i];
        } else --k;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	
	int A,B,K;
	cin>>A>>B>>K;
	int sum=0;
	FORR(i,100,0){
		if(A%i==0&&B%i==0){
			sum++;
			if(sum==K){
				cout<<i<<endl;
				return 0;
			}
		}
	}
}

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

using namespace std;

using ll = long long;
int N;
const int maxn = 200010;
int h[maxn];
ll a[maxn];

ll seg[maxn*4]; //just storing maximum value
void upd(int spot, ll val, int ss = 1, int se = N, int si = 0) {
	if (ss == se) {
		seg[si] = val;
		return;
	}
	int mid = (ss+se)/2;
	if (spot <= mid) upd(spot, val, ss, mid, si*2+1);
	else upd(spot, val, mid+1, se, si*2+2);

	seg[si] = max(seg[si*2+1], seg[si*2+2]);
}

ll query(int qs, int qe, int ss = 1, int se = N, int si = 0) {
	if (qs > qe || ss > se || qs > se || qe < ss) return 0;
	if (qs <= ss && se <= qe) return seg[si];
	int mid = (ss+se)/2;
	return max(query(qs, qe, ss, mid, si*2+1),
		query(qs, qe, mid+1, se, si*2+2));
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> N;
	for (int i = 1; i <= N; i++) {
		cin >> h[i];
	}
	for (int i = 1; i <= N; i++) {
		cin >> a[i];
	}
	ll ans = 0;
	for (int i = 1; i <= N; i++) {
		ll cv = a[i] + query(1, h[i]);
		upd(h[i], cv);
		ans = max(ans, cv);
	}
	cout << ans << endl;
}

Measured memory_bytes: 8832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define sum accumulate
typedef long long ll;
const int INF = 100000000;
const long INF64 = 1000000000000000ll;
const ll MOD = 998244353LL;
int main(){
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
	ll n,k;
	std::cin >> n>>k;
	if(k>(n+1)/2){
		std::cout << -1 << std::endl;
		exit(0);
	}
	if(n%2==0){
		for (ll i = 1; i <=n/2; i++) {
			/* code */
			std::cout << k+2*(i-1)<< " "<<k+2*n-i <<" " << k+2*n+i+n/2-1<< std::endl;
		}
		for (ll i = 1; i <=n/2; i++) {
			/* code */
			std::cout << k+1+2*(i-1)<<" " << k+2*n-i-n/2 <<" " << k+2*n+i-1<< std::endl;
		}
	}else{
		for (ll i = 1; i <=n/2+1; i++) {
			/* code */
			std::cout << k+2*(i-1)<< " "<<k+2*n-i <<" " << k+2*n+i+n/2-1<< std::endl;
		}
		for (ll i = 1; i <=n/2; i++) {
			/* code */
			std::cout << k+1+2*(i-1)<<" " << k+2*n-i-n/2-1 <<" " << k+2*n+i-1<< std::endl;
		}
	}
}


Measured memory_bytes: 2304
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>

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

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pii;

const int INF = 1 << 30;
const long long INFL = 1LL << 60;
const int MOD = 1000000007;
const int MAX = 100000;
const int N = 100;

int main() {
	int a,b,c,d,e,f;cin>>a>>b>>c>>d>>e>>f;
	double con = -0.1;
	int ans_w=0,ans_s=0;
	rep(i,f/100/a+1) {
		rep(j,f/100/b+1) {
			int w=i*a*100+j*b*100;
			if(w==0) continue;
			if(w>f) break;
			rep(k,f/c+1) {
				if(k*c>e*w/100) break;
				rep(l,f/d+1) {
					int s=k*c+l*d;
					if(s>e*w/100) break;
					if(w+s>f) break;
					if (con<((double)100*s)/(w+s)) {
						con=((double)100*s)/(w+s);
						ans_w=w;
						ans_s=s;
					}
				}
			}
		}
	}
	cout<<ans_w+ans_s<<' '<<ans_s<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <numeric>

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

int main() {
    int n;
    vector<int> a;
    ll ans = 0;

    cin >> n;

    for (int i=0; i < n; i++) {
        int aa;
        cin >> aa;
        a.push_back (aa);
    }

    vector<int> b(a);
    sort (b.begin(), b.end(), greater<int>());

    vector<int>::iterator maxIt = max_element(a.begin(), a.end());
    size_t maxIndex = distance(a.begin(), maxIt);

    for (int i=0; i < n; i++) {
        if (i == (int)maxIndex) cout << b[1] << endl;
        else cout << b[0] << endl;
    }
}


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

#define LL long long
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL mod = 1e9+7;

int main() {
    int r, g, b;
    cin >> r >> g >> b;
    if((10*g + b)%4) {
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}



Measured memory_bytes: 256
# union-find
# こういう問題のときにUnion-Findなのか幅優先探索なのか深さ優先探索なのか迷う。
# ちなみに解説PDFはUnion-Findを挙げている。

n, m = map(int, input().split())

def find_root(x):
    if par[x] == x:
        return x
    else:
        par[x] = find_root(par[x])
        return par[x]

def unite(x, y):
    x = find_root(x)
    y = find_root(y)
    if(x == y):
        return 0

    if rank[x] < rank[y]:
        par[x] = y

        temp = size[x] * size[y]
        size[y] = size[x] + size[y]
    else:
        par[y] = x
        if (rank[x] == rank[y]):
            rank[x] += 11

        temp = size[x] * size[y]
        size[x] = size[x] + size[y]
    return temp

def is_same(x,y):
    return find_root(x) == find_root(y)

# par = [0]*n
par = list(range(n))
rank = [0]*n
size = [1]*n

init_nums = list(map(int, input().split()))

edges = [list(map(int, input().split())) for _ in range(m)]
edges = [[b[0]-1, b[1]-1] for b in edges] #1-idx -> 0-idx

for b in range(m):
    unite(edges[b][0] , edges[b][1])

ans = 0
for i in range(n):
    num = init_nums[i]
    # i+1 が init_numの中でi+1と同じグループだったら
    if is_same(i, num - 1):
        ans += 1

print(ans)


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

int main(){
  int n, m, ans = 0, c;
  string s[100], t[100];
  cin >> n; rep(i, n) cin >> s[i]; cin >> m; rep(i, m) cin >> t[i];
  rep(i, n){
    c = 0;
    rep(j, n) if (s[i] == s[j]) c++;
    rep(j, m) if (s[i] == t[j]) c--;
    ans = max(ans, c);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256