akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

int main(){

  int i,j,n,u,k,l,v[100],res[100][100] = {0};
  //入力
  scanf("%d",&n);
  for (i = 0;i < n;i++){
    scanf("%d%d",&u,&k); 
    for ( j = 0; j < k; j++){
      scanf("%d",&v[j]);	
      res[i][v[j]-1] = 1; 
    }
  
  }

 
  

  //出力
  for (i = 0;i < n;i++){ 
    for (j = 0;j < n;j++){
      printf("%d",res[i][j]); 
      if (j == n-1){
	printf("\n");
      }
      else{
	printf(" ");
      }
    
    }

  
  }
  return 0;
}

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

const long long mod = 1e9 + 7;

long long powmod(long long a, long long b){
	long long c = 1;
	while(b > 0){
		if(b & 1){
			c = a * c % mod;
		}
		a = a * a % mod;
		b >>= 1;
	}
	return c;
}

int main()
{
	int n, k;
	cin >> n >> k;
	vector<long long> d(k + 1);
	for(int i = 1; i < k + 1; i++){
		d[i] = powmod(k / i, n);
	}
	for(int i = k; i >= 1; i--){
		for(int j = 2 * i; j < k + 1; j += i){
			d[i] -= d[j];
			d[i] = (d[i] + mod) % mod;
		}
	}
	long long ans = 0;
	for(int i = 0; i < k + 1; i++){
		ans += d[i] * i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 4044
import sys
sys.setrecursionlimit(4100000)

n,k= [int(i) for i in input().split()]
pts = {}
pts["s"],pts["p"],pts["r"] = [int(i) for i in input().split()]
t = input()
take,notake, chose = [0 for _ in range(n)], [0 for _ in range(n)], ["w" for _ in range(n)]
for i in range(len(t)):
    if i == 0:
        take[0] = pts[t[i]]
        notake[0] = 0
        chose[0] = t[i]
    else:
        if t[i] == chose[i-k]:
            take[i] = max(take[i-1],notake[i-1])
            notake[i] = max(take[i-1],notake[i-1])
        else:
            take[i] = take[i-1] + pts[t[i]]
            notake[i] = max(take[i-1],notake[i-1])
            chose[i] = t[i]
print(max(take[-1],notake[-1]))


Measured memory_bytes: 8852
#include <stdio.h>
int cnt[105],tot;
int main(){
	int n,k,m,i,j,a;
	scanf("%d%d",&n,&k);
	for(i=1;i<=k;i++){
		scanf("%d",&m);
		for(j=1;j<=m;j++){
			scanf("%d",&a);
			cnt[a]++;
		}
	}	
	for(i=1;i<=n;i++)
		if(cnt[i])tot++;
	printf("%d\n",n-tot);
	return 0;
}

Measured memory_bytes: 1724
#include<bits/stdc++.h>
using namespace std;
#define ll long long
ll keta(ll x){
  ll t = 0;
  while(x!=0){
    t++;
    x/=10;
  }
  return t;
}

int main(){
  ll n,x,y;
  cin>>n;
  for(ll i=sqrt(n);i>0;i--){
    if(n%i!=0) continue;
    x=keta(i);y=keta(n/i);
    cout<<max(x,y)<<endl;
    break;
  }
}



Measured memory_bytes: 256
#include <iostream>
#include <locale>
#include <algorithm>
using namespace std;
int main(){
  int N,K;
  char c[55];
  cin >> N >> K;
  for(int i = 0; i< N;i++){
    cin >> c[i];
  }
  for(int i = 0; i< N;i++){
    char a = tolower(c[i]);
    if(i == K-1) cout << a;
    else cout << c[i];
  }
  cout << endl;
}



Measured memory_bytes: 256
#coding:utf-8
import sys,os
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = (lambda *something: print(*something)) if 'TERM_PROGRAM' in os.environ else lambda *x: 0
def main(given=sys.stdin.readline):
    input = lambda: given().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    XLMIIS = lambda x: [LMIIS() for _ in range(x)]
    YN = lambda c : print('Yes') if c else print('No')
    MOD = 10**9+7

    # def gen_primes2(upper_bound):
    #     upper_bound += 1
    #     P = [True] * upper_bound
    #     P[0] = P[1] = False
    #     for i in range(4,upper_bound,2):
    #         P[i] = False
    #     for i in range(3,int(upper_bound**0.5),2):
    #         if P[i]:
    #             for j in range(i**2,upper_bound,i):
    #                 P[j] = False
    #     res = []
    #     for i in range(upper_bound):
    #         if P[i]:
    #             res.append(i)
    #     return res

    N = II()
    A = LMIIS()
    # upper_bound = max(A)
    # primes = gen_primes2(upper_bound)
    # LCMP = [0]*len(primes)
    # for i in range(N):
    #     # if i % 100 == 0:
    #     #     print(i)
    #     a = A[i]
    #     for j,p  in enumerate(primes):
    #         t = 0
    #         while a % p == 0:
    #             a //= p
    #             t += 1
    #         LCMP[j] = max(t, LCMP[j])
    #         if a == 1:
    #             break
    # lcm = 1
    # for i in range(len(primes)):
    #     lcm = lcm * pow(primes[i],LCMP[i],MOD) % MOD
    lcm = A[0]
    from fractions import gcd

    for i in range(1,N):
        lcm = lcm * A[i] // gcd(lcm,A[i])

    invans = 0
    for a in A:
        invans += pow(a, MOD-2, MOD)
        invans %= MOD
    print(lcm*invans%MOD)

if __name__ == '__main__':
    main()

Measured memory_bytes: 67048
def getN():
    return int(input())
def getNM():
    return map(int, input().split())
def getList():
    return list(map(int, input().split()))
def getArray(intn):
    return [int(input()) for i in range(intn)]
def input():
    return sys.stdin.readline().rstrip()
def rand_N(ran1, ran2):
    return random.randint(ran1, ran2)
def rand_List(ran1, ran2, rantime):
    return [random.randint(ran1, ran2) for i in range(rantime)]
def rand_ints_nodup(ran1, ran2, rantime):
  ns = []
  while len(ns) < rantime:
    n = random.randint(ran1, ran2)
    if not n in ns:
      ns.append(n)
  return sorted(ns)

def rand_query(ran1, ran2, rantime):
  r_query = []
  while len(r_query) < rantime:
    n_q = rand_ints_nodup(ran1, ran2, 2)
    if not n_q in r_query:
      r_query.append(n_q)
  return sorted(r_query)

from collections import defaultdict, deque, Counter
from sys import exit
from decimal import *
import heapq
import math
from fractions import gcd
import random
import string
import copy
from itertools import combinations, permutations, product
from operator import mul
from functools import reduce
from bisect import bisect_left, bisect_right

import sys
sys.setrecursionlimit(1000000000)
mod = 10 ** 9 + 7

#############
# Main Code #
#############

N = getN()
query = [getList() for i in range(N)]

r_l = []
for x, l in query:
    r_l.append([x - l, x + l])
r_l.sort(key = lambda i:i[1])

cnt = 0
last = r_l[0][1]
for i in range(1, N):
    if r_l[i][0] < last:
        cnt += 1
    else:
        last = r_l[i][1]
print(N - cnt)

Measured memory_bytes: 112752
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<int>vec(N);
  for(int i=0; i<N; i++){
    cin >> vec[i];
  }
  sort(vec.begin(),vec.end());
  for(int i=0; i<N-1; i++){
    if(vec[i] == vec[i+1]){
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}
      

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

int n, k;
int t[100002];

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

  while(T--){
    vector<int> vec;

    cin >> n >> k;
    k = min(k, n);

    for(int i = 0; i < n; i++){
      cin >> t[i];
      if(i != 0) vec.push_back(t[i] - t[i - 1]);
    }

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

    int ans = 0;
    for(int i = 0; i < n - k; i++){
      ans += vec[i];
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 2472
import java.io.*;
import java.util.*;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

public class Main{
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String[] line = br.readLine().split(" ");
    Stack<String> stack = new Stack<String>();

    for(int i = 0; i < line.length; i++){
      if(isNumber(line[i])){
          stack.push(line[i]);
      }else{
        int b = Integer.parseInt(stack.pop());
        int a = Integer.parseInt(stack.pop());  
        if(line[i].equals("+")){
          stack.push(String.valueOf(a+b));
        }else if(line[i].equals("-")){
            stack.push(String.valueOf(a-b));
        }else if(line[i].equals("*")){
            stack.push(String.valueOf(a*b));
        }else if(line[i].equals("/")){
            stack.push(String.valueOf(a/b));
        }
      }
    }

    System.out.println(stack.pop());
  }

  public static boolean isNumber(String term) {
      Pattern patternNum = Pattern.compile("-*[0-9]+");
      Matcher matcherNum = patternNum.matcher(term);

      return matcherNum.matches();
  }
}

Measured memory_bytes: 24592
// 繰り上がり
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007

int main(){
    int n;
    int k; cin >> n >> k;
    bool d[10];
    for(int i = 0; i < 10; i++) d[i] = false;
    for(int i = 0; i < k; i++){
        int D; cin >> D;
        d[D] = true;
    }

    int ans = n;
    while(1){
        int w = ans;
        bool f = true;
        while(w != 0){
            if(d[w%10]){
                f = false; break;
            }
            w/=10;
        }
        if(f){
            cout << ans << endl; return 0;
        }
        ans++;

    }
    return 0;
}

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

#define MAXN 200007
#define OFFSET 100


int n ;

long long cnt[ 207 ][ 207 ] ;

void input ( ) {
    cin >> n ;
    string s ;
    for ( int i = 1 ; i <= n ; ++ i ) {
        cin >> s ;
        long long h1 , h2 ;
        h1 = h2 = 0 ;
        bool fl = false ;
        int sz = s.size ( ) ;
        for ( int j = 0 ; j < sz ; ++ j ) {
            if ( s[ j ] == '.' ) {
                fl = true ;
                h2 = 1 ;
                continue ;
            }
            h1 = ( h1 * 10 + ( s[ j ] - '0' ) ) ;
            if ( fl == true ) {
                h2 = h2 * 10 ;
            }
        }
        pair < int , int > aux ;
        while ( h1 > 0 && ( h1 % 2 ) == 0 ) {
            h1 /= 2 ;
            ++ aux.first ;
        }
        while ( h1 > 0 && ( h1 % 5 ) == 0 ) {
            h1 /= 5 ;
            ++ aux.second ;
        }

        while ( h2 > 0 && ( h2 % 2 ) == 0 ) {
            h2 /= 2 ;
            -- aux.first ;
        }
        while ( h2 > 0 && ( h2 % 5 ) == 0 ) {
            h2 /= 5 ;
            -- aux.second ;
        }
        ++ cnt[ aux.first + OFFSET ][ aux.second + OFFSET ] ;
    }
}

void solve ( ) {
    long long ans = 0 ;
    for ( int i = -50 ; i <= 50 ; ++ i ) {
        for ( int j = -20 ; j <= 20 ; ++ j ) {
            if ( cnt[ i + OFFSET ][ j + OFFSET ] == 0 ) { continue ; }
            for ( int x = -50 ; x <= 50 ; ++ x ) {
                if ( x + i < 0 ) { continue ; }
                for ( int y = -20 ; y <= 20 ; ++ y ) {
                    if ( x + i >= 0 && y + j >= 0 ) {
                        if ( x != i || y != j ) { 
                            ans += cnt[ i + OFFSET ][ j + OFFSET ] * cnt[ x + OFFSET ][ y + OFFSET ] ;
                        }
                        else {
                            ans += cnt[ i + OFFSET ][ j + OFFSET ] * ( cnt[ x + OFFSET ][ y + OFFSET ] - 1 ) ;
                        }
                    }
                }
            }
        }
    }
    ans /= 2 ;
    cout << ans << "\n" ;
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 3676
#include<iostream>
#include<cstdio>
#include<cctype>
using namespace std;

string toUpper(string s){
    string t = s;
    for (int i = 0; i < s.size(); i++){
        t[i] = toupper(s[i]);
        
    }
    return t;
}

int main(){
    string target, source;
    cin >> target;
    target = toUpper(target);
    
    int cnt =0;
    while(1){
        cin >> source;
        if (source == "END_OF_TEXT")break;
        source = toUpper(source);
        if (target == source)cnt++;
        
    }
    cout << cnt << endl;
    return 0;
    
}


Measured memory_bytes: 3180
#include <bits/stdc++.h>
#define rt "\n"
#define sp " "
#define test1 cout << "test1" << endl;
#define test2 cout << "test2" << endl;
#define fixprecision(n) fixed; cout << setprecision(n)
#define kyopro ios::sync_with_stdio(false);cin.tie(NULL);
#define MOD 1000000007
#define rep(i, s, N) for(ll i{s}; i < N; i++)
#define iikae auto&
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

int main(){
  kyopro;
  ll N;
  cin >> N;
  vector<pair<pair<string, ll>, ll>> SP(N);
  rep(i, 0, N){
    iikae youso = SP.at(i);
    ll gyaku;
    cin >> youso.first.first >> gyaku;
    youso.first.second = 100 - gyaku;
    youso.second = i + 1;
  }
  sort(SP.begin(), SP.end());
  for(auto&& youso : SP){
    cout << youso.second << rt;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
int n,r,l,a;
int main()
{
    scanf("%d",&n);
    for(int i=1;i<=n;i++)
    {
	scanf("%d%d",&l,&r);
    a+=r-l+1;
	}
    printf("%d\n",a);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int n,l,r,q,a[100008];
int main(){
	cin>>n>>q;
string s;
cin>>s;
for(int i=1;i<s.size();i++)
{
	
	if(s[i]=='C'&&s[i-1]=='A')a[i]++;
     a[i]+=a[i-1];
}
  for(int i=1;i<=q;i++)
  {
  	cin>>l>>r;
  	l--,r--;
  	cout<<a[r]-a[l]<<endl;
  }
	return 0;
}

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


using namespace std;
 
int main(){
  
  int N;
  cin >> N;

  vector<int> a(N);
  vector<int> b(N);

  for(int i = 0; i < N; i++) cin >> a[i];
  for(int i = 0; i < N; i++) cin >> b[i];
  int max = 0;
  int candy;
 for(int i = 0; i < N; i++){
   candy = 0;
   for(int j = 0; j <= i; j++){
     candy += a[j];
   }
   for(int k = i; k < N;k++){
     
     candy += b[k];
   }

   if(candy > max) max = candy;
 }
  cout << max;
        return 0;

}


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

int main(void)
{
  char str0[4];
  char str1[]="abc",str2[]="acb",str3[]="bac",str4[]="bca",str5[]="cab",str6[]="cba";
  
  scanf("%s",str0);
  
  if( (strcmp(str0,str1)==0) || (strcmp(str0,str2)==0) || (strcmp(str0,str3)==0) || (strcmp(str0,str4)==0) || (strcmp(str0,str5)==0) || (strcmp(str0,str6)==0) ){
    printf("Yes");
  }else{
    printf("No");
  }
    
  return 0;
      
}

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

int main() {
    int n;
    cin >> n;
    int sum=0, max=0;
    int tmp;
    for (int i=0; i<n; i++) {
        cin >> tmp;
        sum += tmp;
        if (tmp>max) {
            max = tmp;
        }
    }
    if (sum>2*max) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

#define ld long double
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

//-------------------------------------------------

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    ll k; cin>>k;
    int sz = s.size();
    int cnt1=0, next;
    rep(i,sz){
        if (s[i]!='1'){
            next = s[i]-'0';
            break;
        }
        cnt1++;
    }
    if (cnt1>=k){
        cout<<"1\n";
    }else{
        cout<<next<<"\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#define INF 1000000000
#define MOD 1000000007

using namespace std;

int main()
{
    int n;
    int a[105];
    int ans;

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

    ans = abs(a[0] - a[1]);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            ans = max(abs(a[i] - a[j]), ans);
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}




int main(void) {
  ll p, q, r;
  cin >> p >> q >> r;
  
  ll ans=min(p+q, q+r);
  chmin(ans, r+p);
  pt(ans);
  
}
  
  


Measured memory_bytes: 256
# 気分的に降順ソート
x, y, z = sorted([int(i) for i in input().split()])[::-1]
# x, y, z = 6, 3, 2
cnt = 0
if (y % 2 == 0 and z % 2 == 0) or (y % 2 != 0 and z % 2 != 0):
    # 中央が偶数オンリーor奇数オンリーならまず値を揃える
    # +2 を繰り返して揃える
    cnt += (y - z) // 2
else:
    # x と y を増やして（yとzの偶奇を揃えて）からzをyにを追いつかせる
    x += 1
    y += 1
    # +1 は xとyを増やす時、(y - z) // 2 はzに追いつかせる時
    cnt += 1 + (y - z) // 2

print(cnt + (x - y))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
using namespace std;
typedef long long ll;
const int MAXN = 100005;

vector <pair<ll, ll>> st;
ll grt[MAXN];
ll ans[MAXN];
ll a[MAXN];

int main()
{
	//freopen("input.in", "r", stdin);
	int n;
	cin >> n;
	st.pb({0,0});
	a[0] = 0;
	for (ll i = 1; i <= n; i++)
	{
		cin >> a[i];
		if (st[st.size()-1].first < a[i])
		{
			st.pb({a[i],i});
			grt[st.size()-1]++;
		}
		else
		{
			auto hj = lower_bound(st.begin(), st.end(), make_pair(a[i], -1LL));
			int x = int (hj - st.begin());
			ans[st[x].second] += a[i] - a[st[x-1].second];
			grt[x-1]++;
		}
	}

	for (int i = st.size()-1; i >= 1; i--)
	{
		grt[i-1] += grt[i];
	}

	for (int i = 1; i <= st.size()-1; i++)
	{
		ans[st[i].second] += grt[i] * (a[st[i].second] - a[st[i-1].second]);
	}

	for (int i = 1; i <= n; i++)
	{
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 5104
import sys
sdin = sys.stdin.readline

from collections import defaultdict, Counter

h, w, n = map(int, sdin().split())
ab = []
for _ in range(n):
    ab.append(tuple(map(int, sdin().split())))
    
# フィールドを作って塗る
field = defaultdict(int)
grid_num = (h-2)*(w-2)

x = [-1,-1,-1, 0, 0, 0, 1, 1, 1]
y = [-1, 0, 1,-1, 0, 1,-1, 0, 1]

for a, b in ab:
    for dx,dy in zip(x, y):
        if a+dx > 1 and a+dx < h and b+dy > 1 and b+dy < w:
            field[(a+dx, b+dy)] += 1


# 数え上げる
cnt = Counter(field.values())

for j in range(10):
    if j == 0:
        print(grid_num - sum(cnt.values()))
    else:
        print(cnt[j])    

Measured memory_bytes: 163964
package main

import (
	"fmt"
	"os"
)

func run() int {
	var s string
	fmt.Scanf("%s\n", &s)

	for i := 0; i < len(s); i++ {
		fmt.Print("x")
	}
	fmt.Println()

	return 0
}

func main() {
	os.Exit(run())
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define In_The_Name_Of_Allah_The_Merciful ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define Alhamdulillah return 0;
#define all(v) v.begin(),v.end()
#define debug(n) cerr << "[" << #n << " = " << n << "]" << endl 

void Suhaib_Sawalha (){

    int n , m;
    cin >> n >> m;
    int k , ans = 0 , p[m] = {};
    for (int i = 0 ; i < n ; ++i){
        cin >> k;
        int a;
        while (k--){
            cin >> a;
            p[a-1]++;
            ans += (p[a-1] == n);
        }
    }

    cout << ans;

}

int main(){
                                In_The_Name_Of_Allah_The_Merciful   /* بسم الله الرحمن الرحيم  */
#ifndef ONLINE_JUDGE
    freopen("SuhaibSawalha1.txt","r",stdin);
#endif
//int _;for(cin>>_;_;--_,cout<<'\n')
        Suhaib_Sawalha();
                                         Alhamdulillah                    /* الحمد لله */
}

Measured memory_bytes: 3604
# -*- coding: utf-8 -*-

def readInts():
  return [int(s) for s in input().split(" ")]

def is_ok(N, p):
  for k in range(N-1):
    if p[k] > p[k+1]:
      return False
  return True

def solve(N, p):
  if is_ok(N, p):
    return "YES"

  for i in range(N-1):
    for j in range(i, N):
      ps = p[:]
      ps[i], ps[j] = p[j], p[i]
      if is_ok(N, ps):
        return "YES"
  return "NO"

def main():
  N = readInts()[0]
  p = readInts()
  print(solve(N, p))

if __name__ == "__main__":
  main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string s;
  cin >> s;

  int n = s.length();
  vector<ll> dp(n + 1, INF);
  dp[n] = 0;
  map<int, int> mp;
  mp[0] = n;
  int res = 0;
  repr(i, n - 1) {
    dp[i] = min(dp[i], dp[i + 1] + 1);
    int t = s[i] - 'a';
    res ^= (1 << t);
    if (mp[res]) dp[i] = min(dp[i], dp[mp[res]] + 1);
    rep(j, 26) {
      int res2 = res ^ (1 << j);
      if (mp[res2]) dp[i] = min(dp[i], dp[mp[res2]] + 1);
    }
    if (dp[i] < dp[mp[res]]) mp[res] = i;
  }
  cout << dp[0] << '\n';

  




  
  return 0;
}

Measured memory_bytes: 208660
#include <bits/stdc++.h>
using namespace std;
//関数
const long INF=1000000000000000;

int main(void){
    long N,M;
    cin>>N>>M;
    
    vector<long> a(N),b(N),c(M),d(M);
    for(int i=0;i<N;i++) cin>>a.at(i)>>b.at(i);
    for(int i=0;i<M;i++) cin>>c.at(i)>>d.at(i);
    
    for(int i=0;i<N;i++){
        long ans=-1,pre=INF;
        for(int j=0;j<M;j++){
            long dis=abs(a.at(i)-c.at(j))+abs(b.at(i)-d.at(j));
            if(pre>dis){
                ans=j+1;
                pre=dis;
            }
        }
        cout<<ans<<endl;
    }
}


Measured memory_bytes: 256
/**
题意:从给定数组中,选择两个相同的数字,可将相同数字之间的数字变为和该相同数字一样,该操作可以进行不定次数;
思路:考虑存在交叉的情况,记录相邻相等数的位置,利用鸽巢定理直接进行dp即可;
*/
 
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
 
const ll mod = 1e9+7;
const int maxn = 5e5+7;
 
int pre[maxn],pos[maxn],a[maxn];;
ll dp[maxn];
 
int main (){
    int n;cin>>n;
    for(int i=0;i<n*2;i++) pre[i]=0;
    for(int i=1;i<=n;i++) cin>>a[i];
    for(int i=1;i<=n;i++) pre[i]=pos[a[i]],pos[a[i]]=i;
    dp[0]=1;
    for(int i=1;i<=n;i++){
        dp[i]=dp[i-1];
        if(pre[i]!=0&&pre[i]!=i-1) dp[i]=(dp[i]+dp[pre[i]])%mod;
    }
    cout<<dp[n]<<endl;
    return 0;
}
 
 

Measured memory_bytes: 8252
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

int n;
vector<vector<pair<ll,int>>> g;
ll ans=0;

ll dfs(int pre,int now){
    vector<ll> v;
    for(auto to:g[now])if(pre!=to.second){
        v.push_back(to.first+dfs(now,to.second));
    }
    sort(ALL(v));reverse(ALL(v));
    if(v.size()==1) chmax(ans,v[0]);
    else if(v.size()>=2) chmax(ans,v[0]+v[1]);
    else return 0;
    return v[0];
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    cin>>n;
    g.resize(n);
    rep(i,n-1){
        int u,v;ll w;cin>>u>>v>>w;
        g[u].push_back(make_pair(w,v));
        g[v].push_back(make_pair(w,u));
    }    
    dfs(-1,0);
    cout<<ans<<endl;
    return 0;
}



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

count_list=[]
for i in range(1,n+1):
    count=0
    while True:
        
        if i%2==0:
            i//=2
            count+=1
        else:
            break
    count_list.append(count)

print(count_list.index(max(count_list))+1)

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

#ifdef _DEBUG
#define debug(x) cout << "line: " << __LINE__ << ", func: " << __func__ << " ->  " << #x << " = " << x << endl
#define INFILE freopen("input.txt", "r", stdin)
#else
#define debug(x)
#define INFILE
#endif

#define ALL(s) begin(s), end(s)
#define RALL(s) rbegin(s), rend(s)
#define REP(i, a, b) for (int i = (a); i < (b); i++)
#define RREP(i, a, b) for (int i = (a); i >= (b); i--)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using i_i = pair<int, int>;
using ll_ll = pair<ll, ll>;
using d_ll = pair<double, ll>;
using ll_d = pair<ll, double>;
using d_d = pair<double, double>;

static constexpr ll LL9_MOD = 1000000009LL;
static constexpr ll LL7_MOD = 1000000007LL;
static constexpr ll INF = 1LL << 60;
static constexpr double PI = static_cast<double>(3.14159265358979323846264338327950288);
static constexpr double EPS = numeric_limits<double>::epsilon();

static map<type_index, const char* const> scanType = {
    {typeid(int), "%d"}, {typeid(ll), "%lld"}, {typeid(double), "%lf"}, {typeid(char), "%c"}};

template <class T> static void scan(vector<T>& v);
[[maybe_unused]] static void scan(vector<string>& v, bool isWord = true);
template <class T> static inline bool chmax(T& a, T b);
template <class T> static inline bool chmin(T& a, T b);
template <class A, size_t N, class T> static void Fill(A (&arr)[N], const T& val);

bool dp[100010];

int main(int argc, char* argv[]) {
  INFILE;

  ll n, k;
  cin >> n >> k;

  vector<int> stones(n);
  scan(stones);

  REP(i, 0, k + 1) {
    bool result = false;
    for (int stone : stones) {
      int num = i - stone;
      if (num < 0) continue;
      if (!dp[num]) {
        result = true;
        break;
      }
    }
    dp[i] = result;
  }

  cout << (dp[k] ? "First" : "Second") << endl;
  return 0;
}

template <class T> static void scan(vector<T>& v) {
  auto tFormat = scanType[typeid(T)];
  for (T& n : v) {
    scanf(tFormat, &n);
  }
}

static void scan(vector<string>& v, bool isWord) {
  if (isWord) {
    for (auto& n : v) {
      cin >> n;
    }
    return;
  }

  int i = 0, size = v.size();
  string s;
  getline(cin, s);

  if (s.size() != 0) {
    i++;
    v[0] = s;
  }

  for (; i < size; ++i) {
    getline(cin, v[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;
}

template <class A, size_t N, class T> void Fill(A (&arr)[N], const T& val) {
  std::fill((T*)arr, (T*)(arr + N), val);
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(int argc, char **argv) {
    int n, a, b, num, sum;
    int sum_total = 0;

    cin >> n >> a >> b;

    for (; n >= 1; n--) {
        num = n;
        sum = 0;

        while (num != 0) {
            sum += num % 10;
            num /= 10;
        }
        if (sum >= a && sum <= b) {
            sum_total += n;
        }
    }

    cout << sum_total << endl;

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>			/* ヘッダファイルの指定 */

int main(void) {			/* main 関数はここからスタート */

    float a,b;
    scanf("%f %f",&a,&b);
    printf("%f",a/b);		/* 関数の本体を記述 */

    return 0;				/* 正常終了時の戻り値は 0 とする */
}

Measured memory_bytes: 1712
#include <iostream>
#include <stdio.h>
#include <vector> 
#include <math.h> 
using namespace std;
int main(void) {
    int L,R,d; cin >> L >> R >> d;
    int i = L;
    int ans = 0;
    while(i <= R) {
        if (i % d == 0) ans++;
        i++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,K;cin>>N>>K;
  int ans=INT_MAX;
  vector<vector<int>> A(N);
  vector<vector<int>> dist(N,vector<int>(N,-1));
  for(int i=0;i<N;i++){
    int a,b;cin>>a>>b;
    A[a-1].push_back(b-1);
    A[b-1].push_back(a-1);
  }
  for(int s=0;s<N;s++){  //sは開始ポイント
    queue<int> q;
    q.push(s);dist[s][s]=0;
    while(q.size()){
      int attend=q.front();q.pop();  //aは今見つめているやつ
      for(int next:A[attend]){
        if(dist[s][next]==-1){
          q.push(next);
          dist[s][next]=dist[s][attend]+1;
        }
      }     
    }
  }
  
  if(K%2==0){
    for(int i=0;i<N;i++){
      int tmp=0;
      for(int j=0;j<N;j++){
        if(dist[i][j]>K/2)tmp++;
      }
      if(tmp<ans)ans=tmp;
    }
  }
  else{
    for(int c1=0;c1<N;c1++){
      for(int c2:A[c1]){
        int tmp=0;
        for(int i=0;i<N;i++){
          if(min(dist[i][c1],dist[i][c2])>K/2)tmp++;
        }
        if(tmp<ans)ans=tmp;
      }
    } 
  }
  cout<<ans;
}

Measured memory_bytes: 16128
<?php 
 $array = explode(" ",trim(fgets(STDIN)));
 
 $stack = [];
 
 foreach($array as $ar){
     if(preg_match('#^[0-9\.]+$#',$ar)){
         $stack[] = intval($ar); 
         continue;
    }
    $b = array_pop($stack);
    $a = array_pop($stack);
    
    switch ($ar) {
        case '+':
            // code...
            $c = $a + $b;
            break;
        case '-':
            $c = $a - $b;
            break;
        case '*':
            $c = $a * $b;
            break;
        case '/':
            $c = $a / $b;
            break;
        default:
            // code...
            echo "error";
            break;
    }
    $stack[] = $c;
    
 }
 
  print array_pop($stack) . "\n";
 
?>


Measured memory_bytes: 9412
// {{{ Boilerplate Code <--------------------------------------------------
// vim:filetype=cpp:foldmethod=marker:foldmarker={{{,}}}

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define ALL(A)     (A).begin(), (A).end()

using namespace std;

// }}}

int main(){
        int N;
        cin>>N;
        vector <int> x,y;

        int totalcount = 0;
        vector <int> eachcount;

        FOR(i,0,N){
                int tmpx,tmpy;
                cin>>tmpx>>tmpy;
                x.push_back(tmpx);
                y.push_back(tmpy);
                eachcount.push_back(0);
        }


        for (double a = 0; a < 2 * 3.14159265358979; a+=0.00002) {
                long long testx = (long long) ((double) (1LL << 60) * cos(a));
                long long testy = (long long) ((double) (1LL << 60) * sin(a));

                int nearest = -1;
                __int128 nearest_ever = 1;
                nearest_ever <<= 126;

                FOR(i,0,N) {
                        __int128 distx = testx - x[i];
                        __int128 disty = testy - y[i];

                        __int128 dest = distx * distx + disty * disty;

                        if (dest < nearest_ever) {
                                nearest_ever = dest;
                                nearest = i;
                        }
                }

                eachcount[nearest]++;
                totalcount++;
        }

        FOR(i,0,N){
                cout<<(double)eachcount[i] / (double)totalcount << endl;
        }

}


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

int main() {
    int N; cin >> N;
    if (N <= 10) {
        cout << N << endl;
    } else {
        int len = 1; int tail = N % 10;
        int top = N / 10;
        int i = N;
        while (i > 0) {
            top = i;
            len++;
            i /= 10;
        }
        int amount[10][10];
        for (int a = 1; a <= 9; a++) {
            for (int b = 1; b <= 9; b++) {
                int i = 10;
                int k = a * i + b;
                amount[a][b] = 0;
                if (a == b) amount[a][b]++;
                while (N >= k) {
                    if (N >= k + i) {
                        amount[a][b] += i / 10;
                    } else {
                        amount[a][b] += (N - k) / 10 + 1;
                    }
                    i *= 10;
                    k = a * i + b;
                }
            }
        }
        int ans = 0;
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                if (i == j) {
                    ans += amount[i][j] * amount[i][j];
                } else {
                    ans += amount[i][j] * amount[j][i];
                }
            }
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<limits.h>
using namespace std;
int main()
{
int n,k;
cin>>n>>k;
int *dp=new int[n];
int *a=new int[n];

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

//for(int i=0;i<n;i++)
//int mini=INT_MAX;

dp[0]=0;



for(int i=1;i<n;i++)
	dp[i]=INT_MAX;

//cout<<endl;


for(int i=1;i<n;i++)
{
for(int j=1;(i-j>=0) && (j<=k);j++)
{
if((dp[i-j]+std::abs(a[i]-a[i-j]))<dp[i])
	dp[i]=dp[i-j]+std::abs(a[i]-a[i-j]);

}


//mini=INT_MAX;

}
//for(int i=0;i<n;i++)
cout<<dp[n-1]<<endl;
return 0;
}



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

l = list(input())

begin = 0
end = n-1

cnt = 0
while(True):
    
    if(end==-1):
        break
    if(begin==n):
        break
    for i in range(begin,end+1):
        w_place = i
        if(l[w_place]=='W'):
            begin=w_place
            break
        if(i==end):
            begin=end
    for j in range(end,begin-1,-1):
        r_place = j
        if(l[r_place]=='R'):
            end=r_place
            break
        if(j==begin):
            end=begin
    if(begin>=end):
        break
    else:
        cnt += 1
        l[begin] = 'R'
        l[end] = 'W'
    begin += 1
    end -= 1

print(cnt)


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

int main(void)
{
    char c;
    char a = 'a';
    char z = 'z';
    char A = 'A';
    char Z = 'Z';
    scanf("%cn", &c);
    if ((c >= a) && (c <= z))
    {
        cout << "a"
             << "\n";
    }
    else if ((c >= A) && (c <= Z))
    {
        cout << "A"
             << "\n";
    }
    return 0;
}


Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);(i)++)
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);(i)++)
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);(i)--)
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);(i)--)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }

int main() {
    init();

    int n;
    cin >> n;
    priority_queue<int, VI, greater<int>> pos;
    priority_queue<int> neg;
    int in;
    FOR(i, 0, n) {
        cin >> in;
        if (in < 0)neg.push(in);
        else pos.push(in);
    }

    if (pos.empty()) {
        pos.push(neg.top());
        neg.pop();
    }
    if (neg.empty()) {
        neg.push(pos.top());
        pos.pop();
    }

    int a = neg.top(), b = pos.top();
    pos.pop(), neg.pop();
    string ans = "\n";
    while (!pos.empty()) {
        int t = pos.top(); pos.pop();
        ans += to_string(a) + " " + to_string(t) + "\n";
        a -= t;
    }
    while (!neg.empty()) {
        int t = neg.top(); neg.pop();
        ans += to_string(b) + " " + to_string(t) + "\n";
        b -= t;
    }
    ans += to_string(b) + " " + to_string(a) + "\n";
    b -= a;
    cout << b << ans;

}

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


public class Main {
    static int mod = (int)1e9+7;
    public static void main(String[] args) {

        FastReader f = new FastReader();
        int n =f.nextInt();
        int k = f.nextInt();
        int candies [] = new int[n];
        for(int i=0;i<n;i++)
            candies[i] =f.nextInt();
        System.out.println(solve(candies,n,k));



    }

    static int solve(int[] candies ,int n,int k)
    {
        int dp[][] = new int[n+1][k+1];
        dp[0][0] =1;
        int[] ways  =new int[k+1];

        for(int i=1;i<=n;i++) {
            dp[i][0]=1;
        }

        for(int i=1;i<=n;i++)
        {
            ways[0] =dp[i-1][0];
            for(int j=1;j<=k;j++)
            {
                ways[j] =  ways[j-1]+dp[i-1][j];
                if (ways[j] >mod)
                    ways[j]-=mod;
            }
            for(int j=1;j<=k;j++)
            {
                 dp[i][j] += ways[j]-((j-candies[i-1]-1) >=0?ways[j-candies[i-1]-1]:0);
                 if (dp[i][j]<0)
                     dp[i][j]+=mod;
            }
        }
//        for(int i=0;i<=n;i++)
//        {
//            System.out.println();
//            for(int j=0;j<=k;j++)
//            {
//                System.out.print(dp[i][j]+" ");
//            }
//
//        }


        return dp[n][k];
    }




    static  class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 80340
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(){
    string input;
    vector<bool> chr;
    chr.resize(26);
    for(vector<bool>::iterator itr = chr.begin(); itr < chr.end(); itr++)
        *itr = false;
    getline(cin, input);
    for(string::iterator itr = input.begin(); itr < input.end(); itr++){
        chr[int(*itr) - 97] = true;
    }
    for(int i = 0; i < chr.size(); i++){
        if(!chr[i]){
            cout << (char)(i + 97) << endl;
            return 0;
        }
    }
    cout << "None" << endl;
    return 0;
}


Measured memory_bytes: 512
N  = int(input())
d = [0 for i in range(N)]
for i in range(N):
    S,P = map(str, input().split())
    d[i] = [S,int(P),i+1]
d.sort()
i = 0
while i < N:
    if i != N-1:
        if d[i][0] != d[i+1][0]:
            print(d[i][2])
            i += 1
        else:
            j = i+1
            while d[j][0] == d[i][0]:
                j += 1
                if j >= N:
                  break
                
                
            for k in reversed(range(i,j)):
                print(d[k][2])
            i = j
    else:
        print(d[i][2])
        break

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

using namespace std;

int main() {

    int n, len = 0;

    cin >> n;

    int num[n], dp[n];

    fill(dp, dp + n, 1 << 30);

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

    dp[0] = num[0];
    for(int i = 1; i < n; ++i) {
        if(dp[len] < num[i]) {
            dp[++len] = num[i];
        } else {
            *lower_bound(dp, dp + len, num[i]) = num[i];
        }
    }
    
    cout << len + 1 << endl;

}

Measured memory_bytes: 1940
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <tuple>
#include <map>
#include <math.h>
#include <algorithm> // std::sort, std::min
#include <iomanip> // std::setprecision
#include <cmath> // std::ceil

int main() {
  long int N;
  std::cin >> N;
  std::string S;
  std::cin >> S;
  std::vector<int> R, G, B;
  
  for (int i=0; i<N; ++i) {
    if (S[i]=='R') R.push_back(i);
    else if (S[i]=='G') G.push_back(i);
    else if (S[i]=='B') B.push_back(i);
  }
  long int count = R.size() * G.size() * B.size();
  // std::vector<int> RGB(3);
  
  for (int i=1; i < (N+1)/2; ++i) {
    for (int j=i; j < N - i; ++j) {
      if ((S[j-i] != S[j] && S[j-i] != S[j+i] && S[j] != S[j+i])) count--;
    }
  }
/*  
  for (int i=0; i<R.size(); ++i) {
    for (int j=0; j<G.size(); ++j) {
      for (int k=0; k<B.size(); ++k) {
        RGB = {R[i], G[j], B[k]};
        std::sort(RGB.begin(), RGB.end());
        if(RGB[1]-RGB[0] != RGB[2]-RGB[1]) count++;
      }
    }
  }
*/
  std::cout << count << std::endl;   
  return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];
  sort(rall(h));

  ll ans = 0;
  REP(i, k, n) ans += h[i];

  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

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

  ll l, r;
  cin >> l >> r;

  if (l/2019 == r/2019) {
    ll ans = 2020;
    for (ll i = l; i <= r; i++) {
      for (ll j = i+1; j <= r; j++) {
        if (i < j) {
          cmin(ans, i*j%2019);
        }
      }
    }
    cout << ans << endl;
  } else {
    cout << 0 << endl;
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
   int n;
   cin>>n;
   vector<int>d(n);
   for(int i=0;i<n;i++){
       cin>>d[i];
   }
   ll sum = 0;
   for(int i=0;i<n-1;i++){
       for(int j =i+1;j<n;j++){
           sum += d[i]*d[j];
       }
   }
   cout<<sum<<endl;
}



Measured memory_bytes: 256
# coding: utf-8
# Your code here!

MAX = 1000000
s = [1] * MAX
s[0] = 0
s[1] = 0

start = 2
while True:
    pmb = 0
    for i in range(start, MAX):
        if s[i] == 1:
            pmb = i
            break

    if pmb == 0:
        break 
    for i in range(pmb ** 2, MAX, pmb):
        s[i] = 0 

    start += 1

while True:
   n = int(input())
   if n == 0: break
        
   c = 0
   for i in range(n + 1, n + n + 1):
      if s[i] == 1:
         # print("@", i)
         c += 1
   print(c)

       



Measured memory_bytes: 13180
#include <iostream>

using namespace std;

int main() {
  int m, c[4], r[4]; // money, coins, returned coins
  int d[4] = {10, 50, 100, 500};

  bool firstline = true;
  while (cin >> m, (m)) {
    if (!firstline) { cout << endl; }
    firstline = false;

    int sum = 0;
    for (int i=0; i<4; i++) {
      cin >> c[i];
      sum += d[i] * c[i];
      r[i] = 0;
    }

    sum -= m;
    for (int i=3; i>=0; i--) {
      while (sum >= d[i]) { sum -= d[i]; r[i]++; }
    }

    for (int i=0; i<4; i++) {
      int x = c[i] - r[i];
      if (x > 0) {
        cout << d[i] << " " << x << endl;
      }
    }
  }
}

Measured memory_bytes: 1160
def main():
    primes = [2]
    for x in range(3, 1000, 2):
        if any(map(lambda p: x % p == 0, primes)):
            continue
        primes.append(x)

    powers = dict()
    for p in primes:
        powers[p] = 0

    n = int(input())
    for i in range(2, n + 1):
        for p in primes:
            if p > i:
                break
            ii = i
            while ii % p == 0:
                ii //= p
                powers[p] += 1

    res = 1
    for power in powers.values():
        res = (res * (power + 1)) % 1000000007
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
# -*- coding: utf-8 -*-

import sys
from collections import defaultdict, Counter

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W, N = MAP()
D = defaultdict(int)

# あるマスが黒いことで黒マスが増える1〜9個の3*3正方形に+1する
for _ in range(N):
    a, b = MAP()
    for i in range(max(a-2, 1), min(a+1, H-1)):
        for j in range(max(b-2, 1), min(b+1, W-1)):
            D[(i, j)] += 1

C = Counter(D.values())
total = (H-2) * (W-2)
# 0は 全体 - 合計 で出す
print(total - sum(C.values()))
for i in range(1, 10):
    print(C[i])


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

template <typename T> T gcd(T x, T y) {
  if (y == 0)
    return x;
  return gcd(y, x % y);
}

template <typename T> T lcm(T x, T y) {
  if (x == 0 || y == 0)
    return 0;
  return x / gcd(x, y) * y;
}

int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}

vector<int> p;
vector<int> r;

void init(int n) {
  p.reserve(n);
  r.reserve(n);
  for (int i = 0; i < n; i++) {
    p[i] = i;
    r[i] = 0;
  }
}

int root(int x) { return p[x] == x ? x : p[x] = root(p[x]); }

bool same(int x, int y) { return root(x) == root(y); }

void unite(int x, int y) {
  x = root(x);
  y = root(y);
  if (x == y)
    return;

  if (r[x] < r[y])
    p[x] = y;
  else {
    p[y] = x;
    if (r[x] == r[y])
      r[x]++;
  }
}

int main() {
  int D, N;
  cin >> D >> N;
  int a = 1;
  for (int i = 0; i < D; i++) {
    a *= 100;
  }
  int num = 0;
  if (N == 100)
    num = a;
  cout << a * N + num << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <ctime>
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define fs first
#define sc second
#define INF 1000000000
#define MOD 1000000007
#define EPS 0.00000001


int main(){
    ll A, B, C; cin >> A >> B >> C;
    if(A%2==0 || B%2==0 || C%2==0){
        cout << 0 << endl;
        return 0;
    }
    
    cout << min(A*B, min(A*C, B*C)) << endl;
    
    return 0;
}





Measured memory_bytes: 256