akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        long[] b = new long[n];
        int aidx = 0;
        long amax = 0;
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
            b[i] = sc.nextLong();
            if (amax <= a[i]) {
                aidx = i;
                amax = a[i];
            }
        }
        System.out.println(amax + b[aidx]);
    }

}


Measured memory_bytes: 91172
N = int(input())

num_len = len(str(N))

lis = []

def dfs(cur, number, count):
    if '3' in number and '5' in number and '7' in number:
        if int(number) <= N:
            lis.append(number)
    if num_len == cur:
        return

    ret1 = dfs(cur + 1, number + '3', count)
    ret2 = dfs(cur + 1, number + '5', count)
    ret3 = dfs(cur + 1, number + '7', count)
    
    return lis


print(len(dfs(0, '', count=0)))

Measured memory_bytes: 4980
#include <bits/stdc++.h>
using namespace std;
template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << "(" << p.first << "," << p.second << ")";
  return os;
}
#ifdef __LOCAL
#define debug(x) cerr << __LINE__ << ": " << #x << " = " << x << endl
#define debugArray(x, n)                           \
  cerr << __LINE__ << ": " << #x << " = {";        \
  for (long long hoge = 0; (hoge) < (n); ++(hoge)) \
    cerr << ((hoge) ? "," : "") << x[hoge];        \
  cerr << "}" << endl
#else
#define debug(x) (void(0))
#define debugArray(x, n) (void(0))
#endif

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S, T;
  cin >> S >> T;
  cout << (S == T.substr(0, S.length()) ? "Yes" : "No") << endl;
  return 0;
}


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

void call(int n);
void mycall(int n);
bool include_three(int x);

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

void mycall(int n){
  for(int i=1; i<=n;i++){
    if((i%3==0|include_three(i))){
      cout << " " << i;
    }
  }
  cout << endl;
}

bool include_three(int x){
  for (x; x>0; x/=10) {
    if (x%10==3) return true;
  }
  return false;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
using ll = long long ;
using P = pair<ll, ll>;
using Vec = vector<ll>;
using VecP = vector<P>;
#define FOR(i, m, n) for(ll (i) = (m); (i) < (n); ++(i))
#define FORN(i, m, n) for(ll (i) = (m); (i) <= (n); ++(i))
#define FORR(i, m, n) for(ll (i) = (m); (i) >= (n); --(i))
#define rep(i, n) FOR(i, 0, n)
#define repn(i, n) FORN(i, 1, n)
#define repr(i, n) FORR(i, n, 0)
#define repnr(i, n) FORR(i, n, 1)
#define co(n) cout << (n) << endl
#define cosp(n) cout << (n) << ' '
#define setp(n) cout << fixed << setprecision(n);
#define all(s) (s).begin(), (s).end()
#define pb push_back
#define mp make_pair
#define fs first
#define sc second

const ll INF = 1e9+1;
const ll LINF = 1e18+1;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const double PI = acos(-1);
const double EPS = 1e-9;

int main(void){
	ll n;
	cin >> n;
	repn(i, n){
		ll x = i*1.08;
		if(x == n){
			co(i);
			return 0;
		}
	}

	puts(":(");
	return 0;
}


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

int main(){
	int a, b, f = 0;
	scanf("%d%d", &a, &b);
	if(a%3 == 0)f = 1;
	if(b%3 == 0)f = 1;
	if((a+b)%3 == 0)f = 1;
	if(f)printf("Possible\n");
	else printf("Impossible\n");
	return 0;
}

Measured memory_bytes: 256
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1
//{
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)

//{
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{
    private:
        int i;
    public:
        mint() : i(0){}
        mint(int i):i((i%m+m)%m){}
        mint operator+(const mint& o){return o.i+i;}
        mint operator*(const mint& o){return o.i*i;}
        mint operator-(){return -i;}operator int() {return i;}
        mint& operator+=(const mint& o){
            i = ((i + o.i)%m + m)%m;
            return *this;
        }
        mint& operator-=(const mint& o){
            i = ((i - o.i)%m + m)%m;
            return *this;
        }
};

//}

//typedef mint<1234567> itn;

int n,m,x,y;

main(){
    cin>>n>>m>>x>>y;
    rep(i,n){
        int t;
        cin>>t;
        chmax(x,t);
    }
    rep(i,m){
        int t;
        cin>>t;
        chmin(y,t);
    }
    cout<< ((y-x>0)?"No War":"War")<<endl;
}




Measured memory_bytes: 256
using System;

class M {
  public static void Main(String[] a) {
    var A = Console.ReadLine().Split(' ');
    var C = DateTime.Parse(A[0]);   
    if ( C <= new DateTime(2019,4,30) ) {
      Console.Write("Heisei");
    } else {
      Console.Write("TBD");
    }
      
  }
    
}


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

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

    string a, b;
    cin >> a >> b;

    if(a[0]==b[2] && a[1]==b[1] && a[2]==b[0]) puts("YES");
    else puts("NO");
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main{

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int V = sc.nextInt();
        int E = sc.nextInt();
        int[][] edge = new int[E][3];
        for (int i = 0; i < E; i++) {
            edge[i][0] = sc.nextInt();
            edge[i][1] = sc.nextInt();
            edge[i][2] = sc.nextInt();
        }

        System.out.println(kruskal(V, edge));
        sc.close();
    }
    public static long kruskal(int n, int[][] edge){
        Arrays.sort(edge, (x, y) -> x[2] - y[2]);
        DJSet ds = new DJSet(n);

        long ret = 0;
        for (int i = 0; i < edge.length; i++) {
            int from = edge[i][0];
            int to = edge[i][1];
            int weight = edge[i][2];

            if(!ds.same(from, to)){
                ds.union(from, to);
                ret += (long)weight;
            }
        }

        return ret;
    }

}

class DJSet {
    /**
     * 各要素の親を保持する配列。
     * 自信が根である要素は負の数を持つ。
     * （負の数の場合、絶対値がその集合の要素数）
     */
    public int[] upper;

    /**
     * コンストラクタ。
     * @param n 対象となる要素数
     */
    public DJSet(int n) {
        upper = new int[n];
        Arrays.fill(upper, -1);
    }

    /**
     * 要素xが含まれる集合のrootを求める。
     * rootを求める過程で経路圧縮しrootが親になるようにする。
     * @param x 要素x
     * @return 要素xが含まれる集合のroot
     */
    public int root(int x) {
        return upper[x] < 0 ? x : (upper[x] = root(upper[x]));
    }

    /**
     * 要素xと要素yが同じ集合か判定する。
     * @param x 要素x
     * @param y 要素y
     * @return 要素xと要素yが同じ集合であればtrue、そうでなければfalseを返す。
     */
    public boolean same(int x, int y) {
        return root(x) == root(y);
    }

    /**
     * 要素xと要素yを含むそれぞれの集合を合併する。
     * 要素数の多い集合のrootを残し、少ないほうのrootをその下に合併する。
     * @param x 要素x
     * @param y 要素y
     * @return 要素xと要素yを含むそれぞれの集合を合併できたらtrue、もともと同じ集合で合併しなかったらfalseを返す。
     */
    public boolean union(int x, int y) {
        x = root(x);
        y = root(y);
        if (x != y) {
            if (upper[y] < upper[x]) {
                int t = x;
                x = y;
                y = t;
            }
            upper[x] += upper[y];
            upper[y] = x;
        }
        return x != y;
    }

    /**
     * 集合の数を数える。
     * @return 集合の数
     */
    public int countSet() {
        int c = 0;
        for (int u : upper) {
            if (u < 0)
                c++;
        }
        return c;
    }

    /**
     * 要素ｘが含まれる集合の要素数を数える。
     * @param x 要素ｘ
     * @return 要素ｘが含まれる集合の要素数
     */
    public int countElement(int x) {
        return root(x) * -1;
    }
}



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

#define x first
#define y second
#define rs resize
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a);i!=(b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()

typedef long long ll;
typedef pair<int, int> ii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
template<class T> using min_queue = priority_queue<T, vector<T>, greater<T>>;

template<class T1, class T2>
ostream& operator<<(ostream &out, const pair<T1,T2> &a) { return out << '(' << a.x << ", " << a.y << ')'; }
template<class T1, class T2>
istream& operator>>(istream &in, pair<T1,T2> &a) { return in >> a.x >> a.y; }

const int INF = 2147483647;
const ll LLINF = 9223372036854775807LL;

// lambda-expression: [] (args) -> retType { body }

void run() {
	int n;
	cin >> n;
	vector<vii> testimonies(n);
	REP(i, n) {
		int m;
		cin >> m;
		while (m--) {
			int x, y;
			cin >> x >> y;
			testimonies[i].eb(x - 1, y);
		}
	}

	int mhw = -1;
	REP(p, 1<<n) {
		// check if this is consistent.
		bool consistent = true;
		REP(i, n) {
			bool ishonest = (p >> i) & 1;
			if (!ishonest) continue; // ignores this persons testimonies
			for (auto test : testimonies[i]) {
				consistent &= ((p >> test.x)&1) == test.y;
			}
		}
		if (consistent)
			mhw = max(mhw, __builtin_popcount(p));
	}

	cout << mhw << endl;
}

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cerr << boolalpha;
	(cout << fixed).precision(10);

	run();

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<iomanip>
#include<sstream>
#include<map>
#include<cmath>
using namespace std;
#define rep(i,n) for(int i = 0;i < n;i++)
#define req(i,n) for(int i = 1;i <=n;i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
typedef long double ld;
const ll MOD =  1000000007;
const ll INF =  1LL << 60;
int n, m, x, y,z,w,h, sum= 0, ans = 0;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
    std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
    cin >> n; vector<pair<int, int>> p;
    vector<vector<int>> G(n);
    rep(i, n - 1) {
        cin >> x >> y; x--; y--;
        p.push_back({ x ,y });
        G[x].push_back(y);
        G[y].push_back(x);
    }
    map<pair<int, int>, int> mp;
    z = 0; vector<int> cs(n, 0), used(n, 0);
    queue<int> q; used[0] = 1;
    q.push(0);
    while (!q.empty()) {
        int v = q.front(); q.pop();
        if (z < G[v].size()) z = G[v].size();
        int cnt = 1;
        for (int u : G[v]) {
            if (used[u]) continue;
            if (cnt == cs[v])cnt++;
            cs[u] = mp[{u, v}] = mp[{v,u}] = cnt++;
            used[u] = 1;
            q.push(u);
        }
    }
    cout << z << endl;
    for (auto pq : p) cout << mp[pq] << endl;
}

Measured memory_bytes: 20084
#include <iostream>
#include <vector>
#include <functional>
#include <algorithm>
#include <cmath>

using namespace std;

typedef pair<int, int> P;

int main() {
	int n, w, h;
	cin >> n >> w >> h;
	int x, y, ww;
	vector<P> xx;
	vector<P> yy;
	for (int i = 0; i < n; i++) {
		cin >> x >> y >> ww;
		xx.push_back(P(x - ww, x + ww));
		yy.push_back(P(y - ww, y + ww));
	}
	sort(xx.begin(), xx.end());
	sort(yy.begin(), yy.end());
	bool hx, hy;
	hx = hy = true;
	P px = xx[0];
	for (int i = 1; i < n; i++) {
		if (xx[i].first <= px.second) {
			px.second = max(px.second, xx[i].second);
		}
		else {
			hx = false;
		}
	}
	if (px.first <= 0 && w <= px.second) {
	}
	else {
		hx = false;
	}
	P py = yy[0];
	for (int i = 1; i < n; i++) {
		if (yy[i].first <= py.second) {
			py.second = max(py.second, yy[i].second);
		}
		else {
			hy = false;
		}
	}
	if (py.first <= 0 && h <= py.second) {

	}
	else {
		hy = false;
	}
	if (hx||hy) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

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

int low[200000];
int high[200000];
int a[200000];

int part(int a[],int l,int r){
  int i,j,x,t;

  i = l - 1;
  j = r;

  x = a[r];

  while(1){
    while(a[++i] < x);
    while(i < --j && x < a[j]);

    if(i >= j) break;

    t = a[i]; a[i] = a[j]; a[j] = t;
  }

  t = a[i]; a[i] = a[r]; a[r] = t;
  return i;
}

void quicksort(int a[],int n){
  int l,r,v;
  int sp;

  low[0] = 0;
  high[0] = n - 1;
  sp = 1;

  while(sp > 0){
    sp--;
    l = low[sp];
    r = high[sp];

    if(l >= r);

    else {
      v = part(a,l,r);

      if(v - l < r - v){
        low[sp] = v + 1;
        high[sp++] = r;
        low[sp] = l;
        high[sp++] = v - 1;
      }

      else{
        low[sp] = l;
        high[sp++] = v - 1;
        low[sp] = v + 1;
        high[sp++] = r;
      }
    }
  }
}

int main(){
  int n,i;
  int flag = 0;

  scanf("%d", &n);

  for(i = 0;i < n;i++) scanf("%d", &a[i]);

  quicksort(a,n);

  for(i = 0;i < n - 1;i++){
    if(a[i] == a[i + 1]){
      printf("NO\n");
      flag = 1;
      break;
    }
  }

  if(flag == 0) printf("YES\n");

  return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include <string>
using namespace std;
int main()
{
	string s;
  	cin >> s;
  	int count = 0;
  	int length = s.length();
  	for (int i = 0; i < length ; i++) {
      if (s[i] == '1') {
        count++;
      }
    }
  	cout << count << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define co(n) cout<<n<<endl
#define all(n) (n).begin(),(n).end()
#define pb(n,m) n.push_back(m)
#define pi(n,m) n.insert(n.begin(),m);
#define ee(n) n.erase(n.end()-1)
#define eb(n) n.erase(n.begin())
#define check(n) reverse(all(n));rep(z,0,n.size())cout<<n[z];co("");reverse(all(n));
using namespace std;
using bint=boost::multiprecision::cpp_int;
typedef long long ll;
typedef unsigned long long ull;

int main(){//幅優先探索
  int n; cin>>n;
  n%=10;
  if(n==3) co("bon");
  else if(n==1||n==0||n==6||n==8) co("pon");
  else co("hon");
  return 0;
}

Measured memory_bytes: 3584
import sys
import numpy as np
# from numba import njit#,i8

#@njit(cache=True)
# @jit(返り値の型(引数1の型,引数2の型,．．．,引数nの型))
#@jit(i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:]))
def main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):

	def add(itemCount, items, i, value):
		while i <= itemCount:
			items[i] += value
			i += (i & (-i))

	def sumFromStart(items, end):
		summary = 0
		i = end
		while i > 0:
			summary += items[i]
			i -= (i & (-i))
		return summary

	def sum(items, start,end):
		summary = sumFromStart(items, end) - sumFromStart(items, start-1)
		return summary

	# 答え配列
	ans=np.zeros(Q, dtype=np.int64)
	#ans=[0]*Q
	# 左からBITと現在色の更新をしながら、クエリのrightに到達したときにBITにクエリ発行する
	qindex = 0

	for n in range(N):
		# 外側のループでは、全部の色をループ

		if Q <= qindex:
			break

		if 0 < mostRightColorIndex[C[n]]:
			# ループ中の場所の色のindexが既にある場合(=過去に、同じ色が登録されていた場合)
			# 今回で、同じ色の一番右側の要素はループ中の要素になる
			# 前登録したこの色の一番右のindexを一度BITから抜く(↓で再度登録される)
			add(N,bitArray,mostRightColorIndex[C[n]], -1 )

		# この要素の色の一番右のindexを、BITに登録
		mostRightColorIndex[C[n]] = n+1
		add(N,bitArray,n+1, 1)

		# while qindex < Q and n+1 == queries[qindex][2]:
		while qindex < Q and n+1 == queries[orderByR[qindex]][1]:
			# 今のBITが次のクエリ発行するための状態(n==query.right)だったら、クエリ発行
			tmpIndex = orderByR[qindex]
			start = queries[tmpIndex][0]
			end = queries[tmpIndex][1]
			ans[tmpIndex]=sum(bitArray,start,end)
			# print(tmpIndex,start,end,ans[tmpIndex])
			qindex += 1

	return ans

if sys.argv[-1]=='ONLINE_JUDGE':
	from numba import njit
	from numba.pycc import CC
	cc=CC('my_module')
	cc.export('main','i8[:](i8,i8,i8[:],i8[:,:],i8[:],i8[:],i8[:])')(main)
	main=njit(main)
	cc.compile()
	exit(0)
from my_module import main



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

N,Q = map(int,input().split())

C=np.array(input().split(), int)

# Query取得-rightでソート
# dtypeQuery = [("index", int), ("start", int), ("end", int)]
queries=np.empty((Q,2),int)
# #rights=[[] for _ in range(N+1)]

for q in range(Q):
	l,r=map(int,input().split())
	#queries[q] = (q,l,r)
	queries[q][0] = l
	queries[q][1] = r
	#queries=np.sort(queries,order="end")

#queries=np.array(sys.stdin.buffer.read().split(),int).reshape(Q,2)

orderByR=np.argsort(queries[:,1])

# 各色の現在の一番右のindex
mostRightColorIndex = np.zeros(N+1, int)
# bit indexed tree
bitArray=np.zeros(N+1,int)

for a in main(N,Q,C,queries,orderByR,mostRightColorIndex,bitArray):
	print(a)


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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[9] = { 0,0,1, 1, 1, 0,-1,-1,-1};
const int dy[9] = { 0,1,1, 0,-1,-1,-1 ,0,1};

bool isDebugMode=1;
//--------------------------------------//
ll h,w,n;
int a[100000],b[100000];
map<P,int> m;
ll ans[10];

bool is_in(int y,int x)
{
	return x>=2&&x<w&&y>=2&&y<h;
}
void solve(){
	rep(i,n){
		rep(j,9){
			int ny=a[i]+dy[j],nx=b[i]+dx[j];
			if(is_in(ny,nx)){
				ans[m[P(ny,nx)]]--;
				m[P(ny,nx)]++;
				ans[m[P(ny,nx)]]++;
			}
		}
	}
	
	ans[0]=(h-2)*(w-2);
	reps(i,9)
		ans[0]-=ans[i];
	rep(i,10)
		cout<<ans[i]<<endl;
}

int main(){
	cin>>h>>w>>n;
	rep(i,n) {
		cin>>a[i]>>b[i];
	}
	solve();
	return 0;
}


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

using ll = long long;
// #define int long long

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define REPS(i, r, n) for (int i = (r); i < (n); ++i)
#define REPR(i, n) for(int i = (n); i >= 0; --i) // from n to 0
#define REPRS(i, r, n) for(int i = (n); i >= (r); --i) // from n to r
#define COUTB(x) cout << (x) << "\n"
#define COUTS(x) cout << (x) << " "
#define PB push_back
#define SORT(obj) sort((obj).begin(), (obj).end())
#define SORTR(obj) sort((obj).begin(), (obj).end(), greater<>())
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define PI (acos(-1))
/***** MAIN *****/
signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> monster(n);
  REP(i,n) {
    cin >> monster[i];
  }
  SORTR(monster);
  ll ans = 0;
  if(n <= k) {
    cout << 0 << endl;
    return 0;
  }
  REPS(i,k,n) {
    ans += monster[i];
  }
  cout << ans;
  
  
  cout << "\n";
  return 0;
}
/***** MAIN *****/


Measured memory_bytes: 1024
a, b, c, x, y = list(map(int, input().split()))

sum1 = a * x + b * y
sum2 = c * 2 * max(x, y)
if x <= y:
    sum3 = c * 2 * x + b * (y - x)
else:
    sum3 = c * 2 * y + a * (x - y)
    
print(min(sum1, sum2, sum3))

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

int main()
{
	int n,m;
	int* list;
	int* tmp;
	int i,j;
	scanf("%d",&n);
	list = (int*)malloc(sizeof(int)*2*n);
	tmp = (int*)malloc(sizeof(int)*2*n);
	for(i = 0;i < n*2;i++)
	{
		list[i] = i+1;
	}
	scanf("%d",&m);
	for(i = 0;i < m;i++)
	{
		int cmd;
		scanf("%d",&cmd);
		if(cmd == 0)
		{
			for(j = 0;j < n;j++)
			{
				tmp[2*j] = list[j];
				tmp[2*j+1] = list[j+n];
			}
		}
		else
		{
			for(j = 0;j < cmd;j++)
			{
				tmp[2*n-cmd+j] = list[j];
			}
			for(j = 0;j < (2*n-cmd);j++)
			{
				tmp[j] = list[j+cmd];
			}
		}
		int* tmptmp = tmp;
		tmp = list;
		list = tmptmp;
	}
	for(i = 0;i < 2*n;i++)
	{
		printf("%d\n",list[i]);
	}
	return 0;
}

Measured memory_bytes: 0
A,B=map(int,input().split())
S=list(input())
a=[]
for i in range(len(S)):
    if 0<=i and i<=A-1:
        if S[i].isdecimal()==True:
            a.append('Yes')
        else:
            a.append('No')
    elif i==A:
        if S[i]=='-':
            a.append('Yes')
        else:
            a.append('No')
    elif i>A: 
        if S[i].isdecimal()==True:
            a.append('Yes')
        else:
            a.append('No')
if 'No' in a:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61988
def solve():
  N, P = map(int, input().split())
  A = list(map(int, input().split()))
  zero,one = 0,0
  for i in range(N):
    if A[i]%2==0:
      zero += 1
    else:
      one += 1
  ans = pow(2,N-1)
  if P==1 and one == 0:
    return 0
  if P==0 and one == 0:
    return pow(2,N)
  return ans
print(solve())

Measured memory_bytes: 61860
#define _USE_MATH_DEFINES
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<list>
#include<stack>
#include<queue>
#include<cctype>
#include<iomanip>
#include<functional>
#include<numeric>
#include<map>
#include<set>
#define EPS 1e-10
using namespace std;
typedef long long llong;
void print(double *a) {
	for (int i = 0; i < 10; i++) {
		if (i)cout << " ";
		cout << a[i];
	}
}
int main() {
	cout << setprecision(10);
	double a;
	while (cin >> a) {
		double s[10];
		s[0] = a;
		for (int i = 1; i < 10; i++) {
			if (i & 1) {
				s[i] = s[i - 1] * 2;
			}
			else {
				s[i] = s[i - 1] / 3;
			}
		}
		//print(s);
		double sum = 0;
		for (int i = 0; i < 10; i++)sum += s[i];
		cout <<sum << endl;
	}
	return 0;
}

Measured memory_bytes: 3120
#include<stdio.h>


void swap(int *x, int *y)
{
  int tmp;

  tmp = *x;
  *x = *y;
  *y = tmp;
 
}


int bubbleSort(int *A, int N)
{
  int count = 0;

  int flag = 1; // 逆の隣接要素が存在するかどうか
  while(flag){
    flag = 0;
    int j = N-1;
    while(j >= 1){
      if (A[j] < A[j-1]) {
        swap(&A[j], &A[j-1]);

        flag = 1;
        count++;
      }
      j--;
    }
  }
  return count;
}


int main(void)
{
  int A[100], N, i;
  int count;
  
  scanf("%d",&N);
  for(i=0;i<N;i++) {
    scanf("%d", &A[i]);//配列読み込み
  }    

  count = bubbleSort(A, N);

  for (int i = 0; i< N-1; i++)
    printf("%d ", A[i]);
  printf("%d\n", A[N-1]);

  printf("%d\n", count);

  return 0;
}

  



Measured memory_bytes: 2100
N=input()
ls=[int(s) for s in input().split()]
ans=1
flag=1
for e in ls:
  ans*=e
  if ans>10**18:
    flag=0
    break
zeroflag=1
for e in ls:
  if e==0:
    zeroflag=0
if flag==1:
  print(ans)
else:
  print(-1*zeroflag)


Measured memory_bytes: 21696
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <numeric>
#include <bitset>
#include <vector>
#include <queue>

using namespace std;

typedef long long ll;
#define FOR(i,a,b)   for(ll i = (a); i < (b); i++ )
#define REP(i, n)    FOR(i,0,n)
typedef pair< ll, ll >   cp2;
typedef pair< ll, cp2 >   cp3;
#define fi first
#define se second
#define sec  se.fi
#define thr  se.se
const ll mod = 1000000007;
//              123456789

 
///////////////////////////////////////////////
//
//
///////////////////////////////////////////////

////////////////////////////////////////////////
////////////////////////////////////////////////

ll A, B, X;
ll ans;

int main(){
	
	cin>>A>>B>>X;
	
	ans = B/X;
	ans++;
	
	if( A ) ans -= (A-1)/X+1;
	
	cout<<ans<<endl;
	
	return 0;

}

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

int main() {
    int a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;

    if (a + b <= 2 * c) cout << a * x + b * y << endl;
    else {
        if (x >= y) cout << min(2 * c * x, 2 * c * y + a * (x - y)) << endl;
        else cout << min(2 * c * y, 2 * c * x + b * (y - x)) << endl;
    }
}

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

#define pb push_back
#define mk make_pair
#define sc second
#define fr first

using namespace std;

typedef long long ll;

const long long N = (long long) 1e6 + 5;
const long long mod = (long long) 1e18 + 7;

long long n,W,mx,st,sum,c = 402;
long long w[102],v[102],dp[5][102];

vector<int> vec[5];

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

        cin >> n >> W;

        for (int i = 1; i <= n; i ++) {
                cin >> w[i] >> v[i];
        }
        st = w[1];
        for (int i = 1; i <= n; i ++) {
                vec[w[i] - st + 1].pb(v[i]);
        }

        for (int i = 1; i <= 4; i ++)
                sort (vec[i].rbegin(),vec[i].rend());

        for (int i = 1; i <= 4; i ++) {
                 for (int j = 0; j < vec[i].size(); j ++) {
                        int l = j + 1;
                        dp[i][l] = dp[i][l - 1] + vec[i][j];
                 }
        }

        int stt = 1;
        for (int i = 0; i <= vec[stt].size(); i ++) {
                for (int j = 0; j <= vec[stt + 1].size(); j ++) {
                        for (int l = 0; l <= vec[stt + 2].size(); l ++) {
                                for (int r = 0; r <= vec[stt + 3].size(); r ++) {
                                        if ((st * i) + ((st + 1) * j) + ((st + 2) * l) + ((st + 3) * r) <= W)
                                                mx = max (mx,dp[1][i] + dp[2][j] + dp[3][l] + dp[4][r]);
                                }
                        }
                }
        }
        cout << mx << endl;
        return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<vector>

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

using namespace std;

typedef long long ll;

const int P_MAX=100000;
vector<int> P;
void sieve(){
	static bool er[P_MAX+1];
	rep(i,P_MAX+1) er[i]=(i>=2);
	for(int i=2;i*i<=P_MAX;i++) if(er[i]) for(int j=i*i;j<=P_MAX;j+=i) er[j]=false;
	rep(i,P_MAX+1) if(er[i]) P.push_back(i);
}

vector< pair<double,ll> > sa; // <σ(n)/n, n>
void dfs(int i,long double a,int e,ll sigma){
	sa.push_back(make_pair(sigma/a,a));
	ll sigma2=sigma;
	for(int j=1;j<=e;j++){
		if(a>1e15) return;
		a*=P[i];
		sigma2=P[i]*sigma2+sigma;
		dfs(i+1,a,j,sigma2);
	}
}

int main(){
	sieve();

	dfs(0,1,77,1);

	for(ll n;scanf("%lld",&n),n;){
		double ans=1;
		rep(i,sa.size()) if(sa[i].second<=n && sa[i].first>ans) ans=sa[i].first;
		printf("%.9f\n",ans);
	}

	return 0;
}

Measured memory_bytes: 1640
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
int main(){
  char A,B,C,D;
  str N,N2;
  cin>>A>>B;
  if(A>B)cout<<">"<<endl;
  else if(A==B)cout<<"="<<endl;
  else cout<<"<"<<endl;
}


Measured memory_bytes: 256
from sys import stdin

N, M = [int(x) for x in stdin.readline().rstrip().split()]
Xs = [int(x) for x in stdin.readline().rstrip().split()]
Xs.sort()
dist = []
for i in range(len(Xs)-1):
    dist.append(abs(Xs[i] - Xs[i+1]))
dist.sort(reverse=True)
ans = 0
for x in dist[N-1:]:
    ans = ans + x
print(ans)


Measured memory_bytes: 13192
let m=1000000open Array;;let a,b=make m 1,make m 0;;a.(0)<-0;;let rec($)i j=if i*j<m then(a.(i*j)<-0;i$(j+1));;for i=2to m-1do if a.(i)=1then i$2;b.(i)<-b.(i-1)+a.(i)done;;let rec f()=f(Printf.printf"%d
"b.(read_int()));;try f()with _->()

Measured memory_bytes: 18172
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

int main(){
    int n;
    cin>>n;
    double ans=0;
    rep(i,n){
        double x;
        cin>>x;
        string a;
        cin>>a;
        if(a=="JPY")ans+=x;
        else ans+=380000.0*x;
    }
    cout<<ans<<endl;
    return 0;
}

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

#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())
#define endl "\n"

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
void initialize( void );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;
template <typename T, typename K> struct P {
	T a; K b;
};
typedef struct {
	vector <int> to;
	int cost;
} edge;

int main( void ){
	// initialize();
	int N;
	cin >> N;
	vector <int> vec( N );
	rep( i, 0, N )
	cin >> vec[ i ];
	sort_asc( vec );
	ll sum = 0;
	rep( i, 0, N - 1 ){
		sum += vec[ N - ( i + 3 ) / 2 ];
	}
	cout << sum << endl;
}

template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}
void initialize( void ){
	cout << fixed << setprecision( 10 );
}


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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define bug(x) cerr << __LINE__ << " says: " << #x << " = " << (x) << "\n"

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}

inline int addmod(lli x,lli y)
{
    return (x%mod + y%mod)%mod;
}
inline int submod(lli x,lli y)
{
    return (x%mod - y%mod + mod)%mod;
}
inline int mulmod(lli x,lli y)
{
    return (x%mod * y%mod)%mod;
}


inline int nextSubMask(int i, int mask)
{
    return (i-1)&mask;   /// returns next  submask
}

template<typename T>
void we_r_done(T mssg)
{
    cout<<mssg;
    exit(0);
}
const int N = 1e5 +6 ;
vector<pii>tree[N];
lli dist[N];

void dfs(int x , int p = -1){
    for(pii u : tree[x]){
        if(p != u.fi){
            dist[u.fi] = dist[x] + u.se;
            dfs(u.fi,x);
        }
    }
}

int main()
{
    ///freopen("output.txt","w",stdout);
  //  freopen("input.txt","r",stdin);
    FastIO;
    int n;
    while(cin>>n){
        for(int i=1; i<n; i++){
            int a,b,c;
            cin>>a>>b>>c;
            tree[a].pb({b,c});
            tree[b].pb({a,c});
        }
        int q,k;
        cin>>q>>k;
        dist[k] = 0;
        dfs(k,-1);
        while(q--){
            int a,b;
            cin>>a>>b;
            cout<<(dist[a]+dist[b])<<endl;
        }
    }

    return 0;
}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?
///sort(atoz(v), [](const data x, const data y){return (x.a==y.a?x.b>y.b : x.a<y.a);});


Measured memory_bytes: 12800
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <cmath>

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

constexpr ll LLINF {1001002003004005006};//ll = 9*LLINF
constexpr int INTINF {1000000000};//int = 2*INTINF

#define  rep(i,n)   for(int i = 0; i < (n); ++i)
#define rrep(i,n)   for(int i = 1; i <= (n); ++i)
#define drep(i,n)   for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for(int i = s; i < t;  ++i)

template<typename T>
void maxs(T& x, T&& y) {
  x=std::max(x,y);
}
template<typename T>
void maxs(T& x, T& y) {
  x=std::max(x,y);
}

template<typename T>
void mins(T& x, T&& y) {
  x=std::min(x,y);
}
template<typename T>
void mins(T& x, T& y) {
  x=std::min(x,y);
}

bool is_ok(const vector<vector<char>>& Board, const int& H, const int& W, const int& K, const vector<int>& judge) {
  vector<vector<char>> B = Board;
  rep(i, W) {
    if (judge[i] == 1) {
      rep(j, H) B[j][i] = '.';
    }
  }
  srep(i, W, W+H) {
    if (judge[i] == 1) {
      rep(j, W) B[i-W][j] = '.';
    }
  }

  int p {};
  rep(i, H) {
    rep(j, W) {
      if (B[i][j] == '#') ++p;
    }
  }
  return (p==K);
}
ll answer_judge(int index, const vector<vector<char>>& Board, vector<int> judge, const int& K, const int& H, const int& W) {
  if (index == H + W) {
    return (is_ok(Board, H, W, K, judge)?1:0);
  }
  judge[index] = 0;
  ll c = answer_judge(index+1, Board, judge, K, H, W);
  judge[index] = 1;
  c   += answer_judge(index+1, Board, judge, K, H, W);
  return c;
}

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

  int H, W, K;
  cin >> H >> W >> K;

  std::vector<std::vector<char>> Board(H, vector<char>(W, 0));
  rep(i, H) {
    rep(j, W) {
      cin >> Board[i][j];
    }
  }

  std::vector<int> judge(H+W, 0);
  ll answer = answer_judge(0, Board, judge, K, H, W);
  cout << answer << '\n';
}


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

using namespace std;

int main() {
  int N, max = -1, max_i = 0;
  
  cin >> N;
  
  vector<int> A;
  
  for (int i = 0; i < N; i++) {
    int A_i;
    
    cin >> A_i;
    
    A.push_back(A_i);
    
    if (max < A_i) {
      max = A_i;
      max_i = i;
    }
  }
  
  sort(A.begin(), A.end());
  
  for (int i = 0; i < N; i++) {
    if (max_i == i) {
      cout << A[N - 2] << endl;
    } else {
      cout << A[N - 1] << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 2548
#include <cstdio>
#include <algorithm>

using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0' || ch>'9') {if(ch=='-') f=-1;ch=getchar();}
	while(ch>='0' && ch<='9') x=x*10+ch-'0',ch=getchar();
	return x*f;
}

int main()
{
	int a,b,c,d;
	a=read(); b=read(); c=read(); d=read();
	a=max(a,c); b=min(b,d);
	printf("%d\n",max(0,b-a));
	return 0;
}


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

typedef long long ll;

using namespace std;

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

template<class T>
using vt = vector<T>;
template<class T>
using vvt = vector<vector<T>>;

int edges[50][50];

int main(){
    int a,b,c;
    cin >> a >> b >> c;
    if(a <= c && c <= b) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;  
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>
#include <queue>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = true;

struct Dish{
    ll a;
    ll b;
    ll sum;
};

bool cmp(const Dish &a, const Dish &b){
    return a.sum < b.sum;
}

int main(){

    ll n;
    cin >> n;

    vector<Dish> d(n);
    for(int i = 0; i < n; i++){
        cin >> d[i].a >> d[i].b;
        d[i].sum = d[i].a + d[i].b;
    }

    sort(all(d), cmp);

    ll taka = 0;
    ll aoki = 0;
    while(true){
        taka += d.back().a;
        d.pop_back();
        if(d.size() == 0) break;
        
        aoki += d.back().b;
        d.pop_back();
        if(d.size() == 0) break;
    }

    cout << taka - aoki << endl;

}

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

void solve() {
  double a, b, x;
  cin >> a >> b >> x;
  double area = x / a;
  double ans;
  if (area <= a * b / 2) {
    double t = 2 * x / (a * b);
    double r = atan2(b, t);
    ans = r * (180 / PI);
  } else {
    double u = (2 / a) * (a * b - x / a);
    double r = atan2(u, a);
    ans = r * (180 / PI);
  }
  cout << fixed << setprecision(10) << ans << endl;
}

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

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

int main() {
  int n;
  scanf("%d", &n);
  if (n < 15) {
    printf("%d", (n * 800));
  } else
  {
    int cost = (n * 800);
    int reward = (n / 15) * 200;
    printf("%d", (cost - reward));
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using ll = int_fast64_t;
#define REP(i,b,e) for(ll i=b; i<e; i++)
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)

int main(){
        int x, y, z, k;
        scanf("%d %d %d %d", &x, &y, &z, &k);
        ll a[x], b[y], c[z];
        SCAN(a);SCAN(b);SCAN(c);
        ll d[x*y], cnt = 0;
        REP(i, 0, x) REP(j, 0, y) d[cnt++] = a[i]+b[j];
        std::sort(d, d+x*y, std::greater<ll>());
        int len = std::min(x*y, k);
        ll ans[len*z];
        cnt = 0;
        REP(i, 0, len) REP(j, 0, z) ans[cnt++] = d[i]+c[j];
        std::sort(ans, ans+len*z, std::greater<ll>());
        REP(i, 0, k) printf("%ld\n", ans[i]);
        return 0;
}

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

int main() {
  int N;
  cin >> N;
  string S;
  cin >> S;
  int K;
  cin >> K;
  
  for(int i = 0; i < N; i++) {
    if(S.at(i) != S.at(K - 1)) {
      S.at(i) = '*';
    }
  }
  
  cout << S << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(200000)
from collections import deque


def read():
    N, M = map(int, input().strip().split())
    G = [list() for i in range(N+1)]
    for i in range(M):
        a, b = map(int, input().strip().split())
        G[a].append(b)
        G[b].append(a)
    return N, M, G


def solve(N, M, G, INF = 10**8):
    depth = [-1 for i in range(N+1)]
    landmark = [-1 for i in range(N+1)]
    q = deque()
    q.append(1)
    depth[1] = 0
    while q:
        x = q.popleft()
        d = depth[x]
        for y in G[x]:
            if depth[y] < 0:
                landmark[y] = x
                depth[y] = d + 1
                q.append(y)
    
    if not all([d>=0 for d in depth[1:]]):
        print("No")
    else:
        print("Yes")
        for a in landmark[2:]:
            print(a)


if __name__ == '__main__':
    inputs = read()
    outputs = solve(*inputs)
    if outputs is not None:
        print("%s" % str(outputs))


Measured memory_bytes: 36032
#[allow(unused_macros)]
macro_rules! scan {
    () => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().to_string()
        }
    };
    (;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().split_whitespace().map(|s| s.to_string()).collect::<Vec<String>>()
        }
    };
    (;;$n:expr) => {
        {
            (0..$n).map(|_| scan!()).collect::<Vec<_>>()
        }
    };
    ($t:ty) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t:ty),*) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            (
                $(iter.next().unwrap().parse::<$t>().unwrap(),)*
            )
        }
    };
    ($t:ty;;) => {
        {
            let mut line: String = String::new();
            std::io::stdin().read_line(&mut line).unwrap();
            line.split_whitespace()
                .map(|t| t.parse::<$t>().unwrap())
                .collect::<Vec<_>>()
        }
    };
    ($t:ty;;$n:expr) => {
        (0..$n).map(|_| scan!($t;;)).collect::<Vec<_>>()
    };
    ($t:ty; $n:expr) => {
        (0..$n).map(|_|
                    scan!($t)
        ).collect::<Vec<_>>()
    };
    ($($t:ty),*; $n:expr) => {
        (0..$n).map(|_|
                    scan!($($t),*)
        ).collect::<Vec<_>>()
    };
}

fn main() {
    let (n, k) = scan!(usize, usize);
    let s = scan!(String).chars().collect::<Vec<_>>();
    for (i, &c) in s.iter().enumerate() {
        if i + 1 == k {
            print!("{}", c.to_lowercase().collect::<Vec<_>>()[0]);
        } else {
            print!("{}", c);
        }
    }
    println!();
}


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

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

ll n, m, q, ans = 0;
ll a[50], b[50], c[50], d[50];
ll A[10];

void dfs(int dep, int num) {
  if (dep == n) {
    ll t = 0;
    rep(i, q) if (A[b[i]] - A[a[i]] == c[i]) t += d[i];
    ans = max(ans, t);
    // for (int i = 0; i < n; ++i)  cout << A[i];
    // cout << endl;
    return;
  }

  for (int i = num; i <= m; ++i) A[dep] = i, dfs(dep + 1, i);
}

void dfs2(vector<int> A2) {
  if (A2.size() == n) {
    ll t = 0;
    rep(i, q) if (A2[b[i]] - A2[a[i]] == c[i]) t += d[i];
    ans = max(ans, t);
    // for (int i = 0; i < n; ++i) cout << A2[i];
    // cout << endl;
    return;
  }

  A2.push_back(A2.back());
  while (A2.back() <= m) {
    dfs2(A2);
    A2.back()++;
  }
}

int main() {
  cin >> n >> m >> q;
  rep(i, q) {
    cin >> a[i] >> b[i] >> c[i] >> d[i];
    a[i]--, b[i]--;
  }

  // dfs(0, 1);
  dfs2(vector<int>(1, 1));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3556
#include<stdio.h>
int main()
{
    int N, max=0, i, sum=0, sum1=0;
    scanf("%d",&N);
    int L[N];

    for(i=0; i<N; i++)
        scanf("%d",&L[i]);
        
    max = L[0];
    for(i=0; i<N; i++)
        if(L[i] > max)
            max = L[i];
            
    for(i=0; i<N; i++)
        sum = sum + L[i];
        
    sum1 = sum - max;
    if(sum1>max)
        printf("Yes\n");
    else
        printf("No\n");

}

// Author: Sorowar Mahabub


Measured memory_bytes: 1644
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
// #include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()
#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
string BinaryNum(int N)
{
        string S;
        while (N != 0)
        {
                if (N % 2 == 1)
                {
                        N--;
                        S = '1' + S;
                }
                else
                {
                        S = '0' + S;
                }
                N /= 2;
        }
        return S;
}

int main() //input->compute->output
{
        int N, K;
        cin >> N >> K;

        vector<int> vec(N);
        rep(i, N) { cin >> vec[i]; }

        ll dp[100010];
        rep(i, N) { dp[i] = 1e9; }

        dp[0] = 0;

        rep2(i, 0, N)
        {
                rep2(j, 1, K + 1)
                {
                        if (i + j <= N - 1)
                        {
                                dp[i + j] = min(dp[i + j], dp[i] + abs(vec[i + j] - vec[i]));
                        }
                }
        }

        cout << dp[N - 1] << endl;

        return 0;
}

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

int main()
{
    ll n;
    cin >> n;
    vector<ll>v(n);
    for(ll i=0;i<n;i++)
    {
        cin >> v[i];
    }
    map<ll,ll>mp;
    for(ll i=0;i<n;i++)
    {
        mp[v[i]]++;
    }
    ll c=0;
    for(auto it=mp.begin();it!=mp.end();it++)
    {
        c+=(it->second*(it->second-1))/2;
    }
    //cout << c << "******" << endl;
    for(int i=0;i<n;i++)
    {
        cout << c-mp[v[i]]+1 << endl;
    }
}


Measured memory_bytes: 11008
N=int(input())
ans=0
yakusu=[0]*(10**7+1)
for i in range(1,N+1):
    for j in range(i,N+1,i):
        yakusu[j]+=1
for i in range(len(yakusu)):
    ans+=(i)*yakusu[i]
print(ans)

Measured memory_bytes: 146100
N,D = map(int,input().split())
d = {}
for i in range(40*4):
    d[i**2] = 0

def dist(y,z):
    res = 0
    for i in range(D):
        res += (y[i]-z[i])**2
    return res
ans = 0
X = [list(map(int,input().split())) for _ in range(N)]
for i in range(N):
    for j in range(i+1,N):
        d2 = dist(X[i],X[j])
        if d2 in d:
            ans += 1

print(ans)

Measured memory_bytes: 3064