akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

#define irep(i,n) for(int i = 0; i < (int)(n); i++)
#define irep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define irrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define irrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)
#define fi first
#define se second

using ll = long long;
using v_int = std::vector<int>;
using v2_int = std::vector<v_int>;
using v_ll = std::vector<ll>;
using v2_ll = std::vector<v_ll>;
using v_string = std::vector<std::string>;
using v_bool = std::vector<bool>;
using v2_bool = std::vector<v_bool>;
using pii = std::pair<int, int>;
using pll = std::pair<ll, ll>;
using mii = std::map<int, int>;
using mll = std::map<ll, ll>;

const double PI = 3.1415926535897932;
const int INF = 2*(int)1e9;
const ll LINF = (ll)1e18;
const ll MOD = 1000000007;
const int dc[4] = {1, -1, 0,  0};
const int dr[4] = {0,  0, 1, -1};
//const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
//const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

using namespace std; 

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p)
{
    return o << "{" << p.first << "," << p.second << "}";
}

template<typename T> inline
istream& operator>>(istream &is, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) {
        is >> v[i]; 
    }
    return is;
}

template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &v)
{
    int len = (int)v.size();
    for(int i = 0; i < len; i++) { 
        os << v[i];
        if(i != len-1) { os << ","; } 
    } 
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }

template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

int main(void)
{
    ll n,yen;
    cin >> n >> yen;
    
    irep2(x,0,n) {
        irep2(y,0,n) {
            int z = n-x-y;
            if(z < 0) { continue; }
            ll sum = 1000*x+5000*y+10000*z;
            if(sum == yen) { 
                printf("%d %d %d\n",z,y,x);
                return 0;
            }
        }
    }
    printf("-1 -1 -1\n");

    return 0;
}
/*atcoder*/


Measured memory_bytes: 3708
/*
このコード、と～おれ!
Be accepted!
∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
 　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
		  　　　　　　　　　　(¸.·´ (¸.·'* ☆
					*/

#pragma GCC optimize("Ofast")
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i <= (n); ++i)
#define repr(i, n) for(int i = n; i >= 0; --i)
#define reprm(i, n) for(int i = n - 1; i >= 0; --i)
#define printynl(a) printf(a ? "yes\n" : "no\n")
#define printyn(a) printf(a ? "Yes\n" : "No\n")
#define printYN(a) printf(a ? "YES\n" : "NO\n")
#define printfin(a) printf(a ? "possible\n" : "inposible\n")
#define all(x) (x).begin(), (x).end()
using ll = long long;

const int INF = 2147483647;
//const ll LINF = ll();今度書く

//マクロとかここまで

#include <stdio.h>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstring>
#include <vector>

using namespace std;

int main() {
	
	ll n, t, count = 0, time, tamount = 0;
	scanf("%lld%lld", &n, &t);
	rep(i, n) {
		scanf("%lld", &time);
		count += min(t, time - tamount);
		tamount = time;
	}
	printf("%lld\n", count + t);

	return 0;
}


Measured memory_bytes: 128
import sys
import numpy as np

INF = 10 ** 18

def main():
    x, y, z, K = map(int, sys.stdin.readline().split())
    abc = np.array(sys.stdin.read().split(), dtype=np.int64)
    a = np.append(abc[:x], INF)
    b = np.append(abc[x:x + y], INF)
    c = np.append(abc[x + y:x + y+ z], INF)
    a = np.sort(a)[::-1]
    b = np.sort(b)[::-1]
    c = np.sort(c)[::-1]
 
    res = []
    for i in range(1, min(K, x) + 1):
        for j in range(1, min(y, K // i) + 1):
            for k in range(1, min(z, K // (i * j)) + 1):
                res.append(a[i] + b[j] + c[k])

    res = sorted(res, reverse=True)[:K]
    print('\n'.join(map(str, res)))

if __name__ == "__main__":
    main()

Measured memory_bytes: 19892
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>

using namespace std;

typedef long long ll;

ll d;
ll c[29];
ll a[369][29];
ll t[369];
ll b[29];
ll b2[29];
ll now[369];
ll ans;

bool g()
{
    ll re = 0;
    for(ll i = 1; i <= d; i++)
    {
        b[now[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            re -= (i - b2[j]) * c[j];
        }
        re += a[i][now[i]];
    }
    if(ans < re) {ans = re; return true;}
    else return false;
}

bool f()
{
    ll x = rand() % 26 + 1;
    ll y = rand() % d + 1;
    ll ans2 = 0;
    ll t2 = now[y];
    now[y] = x;
    bool v = false;
    if(rand() % 100 == 0) v = f();
    else v = g();
    if(!v) now[y] = t2;
    return v;
}

int main()
{
    srand(time(NULL));
    scanf("%lld", &d);
    for(ll i = 1; i <= 26; i++)
    {
        scanf("%lld", &c[i]);
    }
    for(ll i = 1; i <= d; i++)
    {
        for(ll j = 1; j <= 26; j++)
        {
            scanf("%lld", &a[i][j]);
        }
    }
    ans = 0;
    for(ll i = 1; i <= d; i++)
    {
        ll mx = -4e18, mi = 0;
        for(ll ii = 1; ii <= 26; ii++)
        {
            t[i] = ii;
            ll ans2 = 0;
            ll tt = b[t[i]];
            b[t[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b[j]) * c[j];
            }
            ans2 += a[i][t[i]];
            if(mx < ans2) mx = ans2, mi = ii;
            b[t[i]] = tt;
        }
        t[i] = mi;
        b[t[i]] = i;
        for(ll j = 1; j <= 26; j++)
        {
            ans -= (i - b[j]) * c[j];
        }
        ans += a[i][t[i]];
        now[i] = mi;
    }
    ll k = 20000;
    while(k--)
    {
        ll x = rand() % 26 + 1;
        ll y = rand() % d + 1;
        ll ans2 = 0;
        ll t2 = now[y];
        now[y] = x;
        for(ll i = 1; i <= d; i++)
        {
            b[now[i]] = i;
            for(ll j = 1; j <= 26; j++)
            {
                ans2 -= (i - b2[j]) * c[j];
            }
            ans2 += a[i][now[i]];
        }
        if(ans2 < ans) now[y] = t2;
        else ans = ans2;
    }
    for(ll i = 1; i <= d; i++) printf("%lld\n", now[i]);
    return 0;
}


Measured memory_bytes: 3836
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int a, b, c;
    cin >> a >> b >> c;
    if(a + b == c || a + c == b || b + c == a)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#表計算を行うプログラムを作成。

r,c=gets.split(" ").map(&:to_i)
h = Array.new(r+1).map{Array.new(c+1,0)} 

for i in 0..r-1                                       # 変数 i を1からr-1まで増やして繰り返し処理する。(arrayゼロから始めるから)
    
a= gets.split.map(&:to_i)
    for j in 0..c-1                                   # 変数 i を0からc-1回まで増やして繰り返し処理する。
    h[i][j] =  a[j]                                   # array のループひとつづつ足していく
    h[i][c] += a[j]
    h[r][j] += a[j]
    h[r][c] += a[j]
    end
end
for i in 0..r
    for j in 0..c
      print " " unless j == 0
      print h[i][j]
    end
    print "\n"
  end




Measured memory_bytes: 7052
#include<bits/stdc++.h>
const int N=52,M=1000000007;
using namespace std;
int n;
long long ans,f[N][N],inv[N];
int main(){
	scanf("%d",&n);
	inv[0]=inv[1]=1;
	for(int i=2;i<=n;i++)
	inv[i]=(M-M/i)*inv[M%i]%M;
	for(int i=2;i<=n;i++)
	(inv[i]*=inv[i-1])%=M;
	f[1][0]=f[1][1]=1;
	for(int i=1;i<n;i++)
	for(int j=0;j<=i;j++)
	for(int x=0;i+x<=n;x++)
	for(int y=j-x>0?j-x:!x;i+x+y<=n;y++)
	if(y+j+x&1^1)
	(f[i+x+y][abs((y+j-x)/2)]+=f[i][j]*inv[x]%M*inv[y])%=M;
	ans=f[n][0];
	for(int i=1;i<=n;i++)ans=ans*i%M;
	printf("%d",ans);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N;
	cin >> N;
	if (N == 3) {
		cout << "YES" << endl;
	}
	else if (N == 5) {
		cout << "YES" << endl;
	}
	else if (N == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

}

Measured memory_bytes: 384
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;
    cin >> n;
    cout << (n + 1) / 2 << "\n";

    return 0;
}

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

long long mod = 1e9+7;

long long modpow(long long x, long long n) {
    x = x%mod;
    if(n == 0){
        return 1;
    }
    else if(n%2 == 1){
        return(x*modpow(x, n-1))%mod;
    }
    else{
        return modpow((x*x)%mod, n/2)%mod;
    }
}

/*コンビネーションの高速化
フェルマーの小定理と逆元の利用*/
long long comb(long long n, long long k){
    long long x = 1;

    for(long long i = n-k+1; i <= n; i++){
        x = x*i;
        x = x%mod;
    }
    long long y = 1;
    for(long long i = 1; i <= k; i++){
        y = y*i;
        y = y%mod;
    }

    y = modpow(y, mod-2);//フェルマーの小定理と逆元を使うことで、計算できない割り算を掛け算にして計算可能にする
    //yで割りたい時はy^(mod-2)を掛ければ良い
    return x*y%mod;//計算可能
}

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

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

    long long maxv = a[n-1];
    long long distance = 1e15;

    for(long long i = 0; i < n-1; i++){
        if(distance > abs(maxv/2 - a[i])) distance = abs(maxv/2 - a[i]);
    }

    long long r;
    for(long long i = 0; i < n-1; i++){
        if(distance == abs(maxv/2 - a[i])) r = a[i];
    }

    printf("%lld %lld\n", maxv, r);
    return 0;
}

Measured memory_bytes: 4180
#include<stdio.h>
int ab(int n)
{
	if(n>=0)
	return n;
	return -n;
}
int main()
{
	int x,a,b;
	scanf(" %d %d %d",&x,&a,&b);
	if(ab(x-a)>ab(x-b))
	printf("B\n");
	else 
	printf("A\n");
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define endl "\n"
#define F first
#define S second
#define mod 1000000007
#define pb push_back
#define FOR(i,a,n) for(int i=a;i<n;i++)
#define REV(i,a,n) for(int i=a;i>=n;i--)
#define all(a) a.begin(),a.end()
#define UB upper_bound
#define LB lower_bound
const int NUM = 2e5 + 5;

int32_t main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int num_tests=1; 
    //cin >> num_tests;
    while(num_tests-->0){
        int n; cin >> n;
        int a[n][3];
        FOR(i,0,n){
            FOR(j,0,3)
                cin >> a[i][j];
        }
        int dp[n][3];
        FOR(i,0,3)
            dp[0][i] = a[0][i];
        FOR(day,1,n){
            dp[day][0] = a[day][0] + max(dp[day-1][1],dp[day-1][2]);
            dp[day][1] = a[day][1] + max(dp[day-1][0],dp[day-1][2]);
            dp[day][2] = a[day][2] + max(dp[day-1][0],dp[day-1][1]);
        }
        cout << max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
    }   
}

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

bool judge(string S){
  vector<char> s(S.size());
  for(int i = 0; i < S.size(); i++){
    s.at(i) = S.at(i);
  }
  vector<char> t = s;
  reverse(s.begin(), s.end());
  if(s == t) return true;
  return false;
}
     
  

int main(){
  string S;
  cin >> S;
  
  string a, b;
  a = S.substr(0, (S.size() - 1)/2);
  b = S.substr((S.size() - 1)/2 + 1);
  if(judge(a) && judge(b) && judge(S)){
    cout << "Yes" <<endl;
  }else{
    cout << "No" <<endl;
  }
}
  

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Text;

class Program
{
	static void Main(string[] args)
	{
		char[] s = Console.ReadLine().ToCharArray();
		char[] t = Console.ReadLine().ToCharArray();
		int count = 0;
		for(int i=0; i<s.Length; i++)
		{
			if(s[i]!=t[i]) count++;
		}
		Console.WriteLine(count);
	}
}


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

const int mx=1e6+5;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef pair<ii,ll> iii;

int par[mx], rnk[mx];

void init(int n) {
	for (int i=0; i<n; i++)
		par[i]=i, rnk[i]=0;
}

int find(int x) {
	if(par[x]==x) return x;
	else return par[x]=find(par[x]);
}

void unite(int x, int y) {
	x=find(x);
	y=find(y);
	if(x==y) return;
	if(rnk[x]<rnk[y]) par[x]=y;
	else {
		par[y]=x;
		if(rnk[x]==rnk[y]) rnk[x]++;
	}
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int N; cin>>N;
	vector<iii> v(N);
	for (int i=0; i<N; i++) {
		int x,y; cin>>x>>y;
		v[i]={{x,y},i+1};
	}
	vector<iii> edges;
	sort(v.begin(),v.end(),[&](const iii &a, const iii &b) {
		return a.first.first<b.first.first;
	});
	for (int i=1; i<N; i++) {
		int x=v[i].second, y=v[i-1].second, w=v[i].first.first-v[i-1].first.first;
		edges.push_back({{x,y},w});
	}
	sort(v.begin(),v.end(),[&](const iii &a, const iii &b) {
		return a.first.second<b.first.second;
	});
	for (int i=1; i<N; i++) {
		int x=v[i].second, y=v[i-1].second, w=v[i].first.second-v[i-1].first.second;
		edges.push_back({{x,y},w});
	}
	sort(edges.begin(),edges.end(),[&](const iii &a, const iii &b) {
		return a.second<b.second;
	});
	init(N+1);
	ll ret=0;
	for (auto e : edges) {
		int x=e.first.first, y=e.first.second, w=e.second;
		if(same(x,y)) continue;
		unite(x,y);
		ret+=w;
	}
	cout<<ret<<"\n";
	return 0;
}

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

int main() {
        ll a,b,c,k;
        cin >> a >> b >> c >> k;
        ll ans = 0;
        ll t = k;
        k -= a;
        if(k<=0){
                ans += t;
                cout << ans << endl;
                return 0;
        }else{
                ans += a;
                k -= b;
                if(k<0){
                        cout << ans << endl;
                        return 0;
                }else{
                        ans -= k;
                        cout << ans << endl;
                        return 0;
                }
        }

}

Measured memory_bytes: 3580
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		long[] vals = new long[N];
		
		long sum = 0;
		int count = 0;
		long min = Long.MAX_VALUE;
		
		for(int i = 0; i < N; i++){
			vals[i] = sc.nextInt();
			if(vals[i] < 0) {
				count++;
				vals[i] = -vals[i];
			}
			if(vals[i] < min) min = vals[i];
			sum += vals[i];
		}
		
		System.out.println(count % 2 == 0? sum : sum - 2 * min);
	}
}


Measured memory_bytes: 60972
//Littleboy123 Template 1.6
#include <bits/stdc++.h>
using namespace std;

//pragmas
/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
*/

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;

const long double pi = acos(-1.0);

#define FOR(a,b,c) for(ll (a)=(b);(a)<(c);++(a))
#define FORE(a,b,c) for(ll (a)=(b);(a)<=(c);++(a))
#define FORN(a,b,c) for(ll (a)=(b);(a)>(c);--(a))
#define FORNE(a,b,c) for(ll (a)=(b);(a)>=(c);--(a))
#define COUT(n) printf("%d\n", (n))
#define COUTLL(n) printf("%lld\n", (n))
#define CIN(n) scanf("%d", &(n))
#define CINLL(n) scanf("%lld", &(n))
#define MEM(a,b) memset((a), (b), sizeof((a)))
#define MAX(a,b) (a) = max((a), (b))
#define MIN(a,b) (a) = min((a), (b))
#define nl '\n'
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back

void init(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
}

void infile(){
	freopen("input.in", "r", stdin);
}

void outfile(){
	freopen("output.out", "w", stdout);
}

ll modex(ll a, ll b, ll mod){
	if(b == 0)
		return 1;
	if(b == 1)
		return a;
	ll tmp = modex(a, b/2, mod);
	tmp = (tmp * tmp) % mod;
	if(b & 1)
		tmp = (tmp * a) % mod;
	return tmp;
}

//End of template

int n;
ll val[105];
ll we[105];
ll memo[105][100005];

ll dp(int id, int remw){
	if(remw < 0)
		return INT_MIN;
	if(remw == 0){
		return 0;
	}
	if(id == n){
		return 0;
	}
	if(memo[id][remw] != -1)
		return memo[id][remw];
	return memo[id][remw] = max(val[id] + dp(id+1, remw-we[id]), dp(id+1, remw));
}

int main(){
	init();

	int w;
	cin >> n >> w;
	FOR(i, 0, n){
		cin >> we[i] >> val[i];
	}
	MEM(memo, -1);
	cout << dp(0, w) << nl;
	return 0;	
}

Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
    int l, r, d; cin >> l >> r >> d;
    int a = r/d - (l-1)/d;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
#define mov(i,a,b) for(int i = a; i < b; i++)
#define MOD 1000000007
#define INF 1e9+5
typedef long long ll;
using namespace std;
bool isPowerOfTwo(ll n){
	return (ceil(log2(n)) == floor(log2(n)));
}
long long binpow(long long a, long long b){
	long long res = 1;
	while(b>0){
		if(b&1) res *= a;
		a = a*a;
		b >>= 1;
	}
	return res;
}
bool sortbysec(const pair<string,int> &a, 
              const pair<string,int> &b) 
{ 
	bool x = false;
	if( a.second > b.second  && a.first < b.first ) {
		x = true;
	}
    return x;
}
int main(){
	
	string s;
	cin>>s;
	int win = 0, lose = 0;
	for(int i = 0; i < s.size(); i++){
		if(s[i] == 'o') win++;
		else lose++;
	}
	int ans = 15-s.size();
	ans += win;
	if(ans >= 8) cout<<"YES"<<"\n";
	else cout<<"NO"<<"\n";
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
}

Measured memory_bytes: 256
#coding:utf-8
'''
a ÷ b ： d (整数)
a ÷ b の余り ： r (整数)
a ÷ b ： f (浮動小数点数)
'''
a, b = map(int, input().split())
d = a // b
r = a % b
f = a / b
print('%d %d %.8f' % (d, r, f))




Measured memory_bytes: 5624
#include<iostream>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<stack>
#include<queue>
#include<string>
#include<set>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;
#define rep(i,n) for(int i=0;(i)<(n);(i)++)
#define FOR(i,m,n) for(int i=(m);(i)<(n);(i)++)
typedef long long ll;

int main(){
    vector<int> A(3);
    rep(i,3)cin >> A[i];
    sort(A.begin(),A.end());
    reverse(A.begin(),A.end());
    cout << A[0]*10+A[1]+A[2] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>                                                                                                                  
#include <vector>
 
using namespace std;
int main(){
        int N,M,X;
        cin >> N >> M >> X;
        int A[M];
        for(int i=0;i < M ;i++){
                cin >> A[i];
        }
        int right = 0;
        int left = 0;
        for(int j=0;j < M;j++){
                if(A[j] < N && A[j] > X){ 
                        right++;
                }else if(A[j] > 0 && A[j] < X){ 
                        left++;
                }
        }
        if(right <= left){
                cout << right << endl;
        }else{
                cout << left << endl;
        }
 
        return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */


ll solve(){
    ll res = 0;
    map<ll,ll> mp;
    ll N,K; cin >> N >> K;
    for(int i = 0; i < N;i++){
        ll A; cin >> A;
        mp[A]++;
    }
    vector<pll> ps;
    for(auto it = mp.begin();it!=mp.end(); it++){
        ps.push_back({it->second,it->first});
    }
    sort(ps.begin(),ps.end());
    ll Size = (ll)ps.size();
    for(int i = 0; i < ps.size();i++){
        if(Size <= K) break;
        res += ps[i].first;
        Size--;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


Measured memory_bytes: 17520
n = int(input())
B = [[0 for i in range(n)] for j in range(n)]

for i in range(n):
    A = list(map(int,input().split()))
    for j in range(A[1]):
        B[A[0]-1][A[j+2]-1] = 1

for i in range(n):
    for j in range(n):
        print(B[i][j],end="")
        if(j == n-1):
            print()
        else:
            print(" ",end="")


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl
#define possible(n) cout << ((n) ? "possible" : "impossible"  ) << endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//long long int kaizyo(long long int hh){
  //  cmp=1;
    //while(hh>1){
      //  cmp=(cmp*hh)%MOD;
        //hh--;
    //}
    //return cmp;
//}

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n,cnt=0,ans=0,a,b,c,cmp,cmpp,m,h,w,x,y,sum=0,pos;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
string alph("snuke"),alphh("ABCDEFGHIJK"),s;

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


  cin >> n >> a >> b >> s;
  cmp=a+b;
  cmpp=b;
  rep(i,n){
      if(s[i]=='a' && cmp!=0){
          Cout("Yes");
          cmp--;
      }
      else if(s[i]=='b'&&cmp!=0&&cmpp!=0){
          Cout("Yes");
          cmp--;
          cmpp--;
      }
      else{
          Cout("No");
      }
  }
return 0;
}


Measured memory_bytes: 848
import numpy as np
[N,M]=list(map(int,input().split(" ")))
A=list(map(int,input().split(" ")))
B=[0]*M
C=[0]*M
for i in range(0,M):
    [B[i],C[i]]=list(map(int,input().split(" ")))
A=np.sort(A)
D=np.sort(C)[-1::-1]
I=np.argsort(C)[-1::-1]
i=0
j=0
count=0;
while i<N and j<M:
    if A[i]<D[j]:
        A[i]=D[j]
        i=i+1
        count=count+1
        if count==B[I[j]]:
            count=0;
            j=j+1
    else :
        break
print(sum(A))

Measured memory_bytes: 25836
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;
using pii = pair<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}
int binary_search_index(Int Y, vi &q){
    int left = 0, right = q.size() - 1;
    while (right >= left) {
        int mid = left + (right - left) / 2;
        if (q[mid] == Y) return mid;
        else if (q[mid] > Y) right = mid - 1;
        else if (q[mid] < Y) left = mid + 1;
    }
    return -1;
}


int main() {
    Int N;
    vi H;
    cin >> N;
    H = vi(N);

    string ans ="Yes";
    rep(i,N){
        cin>>H[i];
    }

    if(N==1){
        cout << "Yes" << endl;
        return 0;
    }

    rep(i,N-1){
        Int now = H[i];
        Int next = H[i+1];

        Int diff = next-now;

        if(diff>0){
            H[i+1] = next-1;
        }
        if(diff<0){
            ans = "No";
            break;
        }
    }


    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cstring>
#include<queue>
#include<tuple>
#include<utility>
#include<map>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include<stdlib.h>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define range(a) a.begin(), a.end()
#define endl "\n"
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define MP make_pair
using Graph = vector<vector<int>>;
const unsigned long long mod = 1e9 + 7;
const long long INF = 1LL<<60;
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
void chmax(long long &a, long long b) { if (a < b) a = b; }

int main(void){
	ios::sync_with_stdio(0);
	cin.tie(0);
	ll a1, a2, b1, b2, t1, t2;
	cin >> t1 >> t2 >> a1 >> a2 >> b1 >> b2;
	if(t1*(a1-b1)==t2*(b2-a2)){
		cout << "infinity" << endl;
		return 0;
	}
	if(a1<b1){
		swap(a1, b1);
		swap(a2, b2);
	}

	if(a2>b2){
		cout << 0 << endl;
		return 0;
	}
	if(t1*(a1-b1)>t2*(b2-a2)){
		cout << 0 << endl;
		return 0;
	}

	ll L=t1*(a1-b1), l=(t2*(b2-a2)+t1*(b1-a1));
	ll K = L / l;
	if(K*l==L)
		cout << K * 2 << endl;
	else
		cout << K * 2 + 1 << endl;

	return 0;
}



Measured memory_bytes: 3628
import math
A,B,H,M=map(int, input().split())
zikan=0
hun=0
zikan=(M*0.5)+(30*H)
hun=M*6
hari=abs(zikan-hun)
if hari>180:
    hari=360-hari
ans=0
ans_kari=0
ans_kari=A**2+B**2-2*A*B*math.cos(math.radians(hari))
ans=math.sqrt(ans_kari)
print(ans)

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

const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int &i : a) {
    cin >> i;
  }
  sort(a.begin(), a.end());
  int s = (n % 2) + 1;
  bool pos = true;
  if (n % 2) {
    if (a[0] != 0) {
      cout << 0 << '\n';
      return 0;
    }
    for (int i = 1; i < n; i++) {
      if (i != 1 && i % 2 == 1) {
        s += 2;
      }

      if (a[i] != s) {
        pos = false;
        break;
      }
    }
  } else {
    for (int i = 0; i < n; i++) {
      if (i != 0 && i % 2 == 0) {
        s += 2;
      }
      if (a[i] != s) {
        pos = false;
        break;
      }
    }
  }
  if (pos) {
    ll ans = 1;
    for (int i = 0; i < n/2; i++) {
      ans = (ans * 2) % mod;
    }
    cout << ans << '\n';
  } else {
    cout << 0 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3800
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long N = scan.nextLong();
		long A = scan.nextLong();
		long B = scan.nextLong();

		if (A == 0) {
			System.out.println(0);
		} else {
			long count = N / (A+B);
			if (N % (A+B) < A) {
				System.out.println(A*count + N % (A+B));
			} else {
				System.out.println(A*count + A);

			}
		}
	}

}

Measured memory_bytes: 35644
h,w=map(int,input().split())
d=[0]+[300]*w
for i in range(h):
  s=input()
  if i==0:
    a=s[0]
  for j in range(w):
    t=s[j]==a
    d[j]+=t^(d[j]%2==0)
    if j>0:
      d[j]=min(d[j],d[j-1]+t^(d[j-1]%2==0))
print((d[-2]+(a=="#")+1)//2)

Measured memory_bytes: 42608
#include<bits/stdc++.h>
using namespace std;
#define long long int lld
#define MAX 2000000
#define MAX_A 10000
int main(void){
	int num;
	cin >> num;
	int c[MAX_A], *a,*b;
	//配列の動的確保
	a = new int[num];
	b = new int[num];
	//全てを０で初期化
	memset(c,0,sizeof(c));

	for(int i = 0 ; i < num ; i++){
		cin >> a[i];
	}
	for(int i = 0 ; i < num ; i++){
		c[a[i]]++;
	}
	for(int i = 1; i <= MAX_A; i++){
		c[i] = c[i] + c[i-1];
	}
	for(int i = num-1; i >= 0 ; i--){
		b[c[a[i]]] = a[i];
		c[a[i]]--;
	}
	for(int i = 1; i<=num ;i++){
		if(i-1) cout << " " ;
		cout << b[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 16852
package main

import (
	"fmt"
)

func main() {
	var a string
	fmt.Scan(&a)
	var cnt int
	if a[0] == '1' {
		cnt++
	}
	if a[1] == '1' {
		cnt++
	}

	if a[2] == '1' {
		cnt++
	}

	fmt.Println(cnt)
}


Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#define INF 100000000
 
#include <iostream>
#include <cstdio>
#include <sstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>
#include <cctype>
#include <utility>
 
using namespace std;
 
typedef long long ll;
typedef pair <int,int> P;
typedef pair <int,P> PP;
 
static const double EPS = 1e-8;
 
int tx[] = {0,1,0,-1};
int ty[] = {-1,0,1,0};
 
int main(){
	string stage;
 
	while(cin >> stage){
 
		int m = 0;
		char prev = 'z';
		for(int i=0;i<stage.size();i++){
			if(stage[i] != prev && stage[i] == 'o'){
				m++;
			}
			prev = stage[i];
		}
 
		int b = 0;
		prev = 'z';
		for(int i=0;i<stage.size();i++){
			if(stage[i] != prev && stage[i] == 'x'){
				b++;
			}
			prev = stage[i];
		}
 
		if(m >= b) printf("%c\n",'o');
		else printf("%c\n",'x');
	}
}

Measured memory_bytes: 1180
#include<bits/stdc++.h>
using namespace std;
long long int calc(string s)
{
    long long int ret=stoll(s);
    for(size_t i=1;i<s.size();i++)
    {
        long long int memory=0;
        auto sx=s.substr(0,i);
        ret += stoi(sx)*powl(2,s.size()-i-1);
        auto sy =s.substr(i,s.size()-i);
        ret += calc(sy);
    }
    return ret;
}
int main()
{
    ios_base::sync_with_stdio(false);
    string s;
    cin>>s;
    cout<<calc(s)<<endl;


}



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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n, p; cin>>n>>p;
    bool o_exist=false;
    for(int i=0; i<n; i++){
        int a; cin>>a;
        if(a%2 == 1) o_exist=true;
    }

    ll ans=1;
    for(int i=0; i<n; i++) ans*=2;
    if(o_exist) cout << ans/2 << endl;
    else cout << (p == 1 ? 0 : ans) << endl;
}

Measured memory_bytes: 256
def get_prime_set(ub):
    from itertools import chain
    from math import sqrt

    if ub < 4:
        return ({}, {}, {2}, {2, 3})[ub]

    ub, ub_sqrt = ub+1, int(sqrt(ub))+1
    primes = {2, 3} | set(chain(range(5, ub, 6), range(7, ub, 6)))
    du = primes.difference_update
    for n in chain(range(5, ub_sqrt, 6), range(7, ub_sqrt, 6)):
        if n in primes:
            du(range(n*3, ub, n*2))

    return primes


import sys
from bisect import bisect_right
primes = list(get_prime_set(999999))
print(*(bisect_right(primes, int(n)) for n in sys.stdin), sep="\n")


Measured memory_bytes: 40592
#include <iostream>

using namespace std;

int
main()
{
    int N, K;
    int count = 0;
    int okasi[101] = {0};
    cin >> N >> K;
    for(int i = 0; i < K; ++i) {
        int d;
        cin >> d;
        for(int j = 0; j < d; ++j) {
            int a;
            cin >> a;
            okasi[a]++;
        }
    }
    for(int i = 1; i <= N; ++i) {
        if(!okasi[i]) count++;
    }
    cout << count << endl;
}


Measured memory_bytes: 3608
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <stdbool.h>
#include <limits.h>
#include <cinttypes>
#include <string.h>

#define max(a,b) (((a) > (b)) ? (a) : (b))
#define min(a,b) (((a) < (b)) ? (a) : (b))
#define abs(a) (((a) < 0) ? -(a) : (a))

#define FOR(var, to)          for (register int var = 0; var < to; var++)
#define FROMTO(var, from, to) for (register int var = from; var <= to; var++)

typedef uint8_t u8;
typedef uint16_t u16;
typedef uint32_t u32;
typedef uint64_t u64;
typedef int8_t s8;
typedef int16_t s16;
typedef int32_t s32;
typedef int64_t s64;

static inline int ri() {
	int a;
	scanf("%d", &a);
	return a;
}

static inline s64 rs64() {
	s64 a;
	scanf("%" SCNd64, &a);
	return a;
}

static inline void wi(int a) {
	printf("%d", a);
}

static inline void wu64(u64 a) {
	printf("%" PRIu64, a);
}

int main() {
	int n = ri();
	int t = ri();
	int times[n];
	FOR(i,n) times[i] = ri();
	
	u64 x = 0;
	
	FOR(i,n) {
		if (i == n-1) {x += t;break;}
		if (times[i+1] - times[i] < t) x += (times[i+1] - times[i]);
		else x += t;
	}
	
	wu64(x);
	
	
	return 0;
}


Measured memory_bytes: 896
#define LOCAL
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rrep(i, n) for(int i=(n-1); i>=0; --i)
#define rep2(i, s, n) for(int i=s; i<(n); ++i)
#define ALL(v) (v).begin(), (v).end()
#define memr(dp, val) memset(dp, val, sizeof(dp))
using namespace std;
typedef long long ll;
static const int INTINF = (INT_MAX >> 1); // 10^9 + 10^7
static const ll LLINF = (LLONG_MAX >> 1);
static const int MAX = 1e5+1;
static const ll MOD = 1e9+7;
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; }
string to_string(string s) { return '"' + s + '"'; }
string to_string(bool b) { return b ? "true" : "false"; }
template <size_t N> string to_string(bitset<N> bs) {
  string res;
  for (size_t i = 0; i < N; ++i) res += '0' + bs[i];
  return res;
}
string to_string(vector<bool> v) {
  string res = "{";
  for (bool e : v) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p);
template <class C> string to_string(C c) {
  string res = "{";
  for (auto e : c) res += to_string(e) + ", ";
  return res += "}";
}
template <class T, class U> string to_string(pair<T, U> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
void debug() { cerr << '\n'; }
template <class Head, class... Tail> void debug(Head head, Tail... tail) {
  cerr << '\t' << to_string(head), debug(tail...);
}
#ifdef LOCAL
#define DEBUG(...) cerr << "[" << #__VA_ARGS__ << "]:", debug(__VA_ARGS__)
#else
#define DEBUG(...)
#endif

const int nMax = 500000;
ll dp[nMax];
int main(int argc, const char * argv[]) {
	std::cout << std::fixed << std::setprecision(15);

	int n, m; cin >> n >> m;
	vector<int> c(m);
	rep(i, m) cin >> c[i];
	fill(dp, dp+nMax, INTINF);
	dp[0] = 0;
	rep(i, nMax){
		rep(j, m){
			if(i+c[j] > n) continue;
			if(dp[i] == -1) continue;
			chmin(dp[i+c[j]], dp[i]+1);
		}
	}

	cout << dp[n] << endl;
}



Measured memory_bytes: 6992
#In[]:
import math

n, d = map(int,input().split())
x = [list(map(int,input().split())) for _ in range(n)]

ans = 0
for i in range(n):
    num = (x[i][0])*(x[i][0]) + (x[i][1])*(x[i][1])
    root_num = math.sqrt(num)
    if root_num <= d:
        ans += 1
print(ans)


Measured memory_bytes: 102536
using System;
using System.Linq;
using System.Collections.Generic;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();
            char[] input_c = input.ToCharArray();
            for (int i = 0; i < 3; i++)
            {
                if (input_c[i] == input_c[i+1])
                {
                    Console.WriteLine("Bad");
                    return;
                }
            }
            Console.WriteLine("Good");
        }
    }
}   

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

using namespace std;

static long long mod = 1e9+7;

int main()
{
    vector<long long> a;
    vector<long long> astare;
    vector<long long> ile;
    set<long long> dzielnikiset;
    vector<long long> dzielniki;
    long long N,K;
    cin>>N>>K;
    for(int i = 1;i<=sqrt(N);i++)
    {
        dzielnikiset.insert(i);
        dzielnikiset.insert(N/i);
    }
    for(set<long long>::iterator i = dzielnikiset.begin();i!=dzielnikiset.end();i++)
    {
        dzielniki.push_back(*i);
    }
    sort(dzielniki.begin(),dzielniki.end());
    a.assign(dzielniki.size(),1);
    astare.assign(dzielniki.size(),1);
    ile.assign(dzielniki.size(),0);
    for(int i = 0;i<dzielniki.size();i++)
    {
        if(i==0)
        {
            ile[i]=1;
        }else{
            ile[i]=dzielniki[i]-dzielniki[i-1];
        }
    }
    for(int k = 1;k<K;k++)
    {
        a.assign(dzielniki.size(),0);
        long long pom  = 0;
        for(int i = 0;i<dzielniki.size();i++)
        {
            pom=(pom+astare[i]*ile[i])%mod;
            a[ile.size()-i-1]=pom;
        }
        for(int j=0;j<a.size();j++)astare[j]=a[j];
    }
    long long odp=0;
    for(int i = 0;i<a.size();i++)
    {
        //cout<<a[i]<<" ";
        odp=(odp+a[i]*ile[i])%mod;
    }
    cout<<odp;
}


Measured memory_bytes: 5372
#include <stdio.h>

int main()
{
	int a[4], b[4], i, j, hit, blow;

	while(scanf("%d %d %d %d %d %d %d %d", &a[0], &a[1], &a[2], &a[3], &b[0], &b[1], &b[2], &b[3]) != EOF){
		hit = 0;
		blow = 0;

		for(i = 0; i < 4; i++){
			for(j = 0; j < 4; j++){
				if(a[i] == b[j]) blow++;
			}
		}

		for(i = 0; i < 4; i++){
			if(a[i] == b[i]) {hit++; blow--;}
		}

		printf("%d %d\n", hit, blow);
	}

	return 0;
}

Measured memory_bytes: 596
#include <cstdio>
#include <algorithm>
typedef long long ll;
const int M = 200010;
int n;
int x[M],y[M],a[M],d[M],ans[M],top = 0;

template <typename T>
inline void read(T &x){
    x = 0; char ch = getchar(); int f = 1;
    for(;ch < '0' || ch > '9'; ch = getchar()) if(ch == '-') f = -1;
    for(;ch >= '0' && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
    x *= f;
}
int main(){
    read(n);
    for(int i = 1;i <= n; i++) read(x[i]), read(y[i]), a[x[i]] = y[i];
    int m = n + 1;
    for(int i = 1;i <= n; i++){
        m = std::min(m,a[i]);
        if(m == n - i + 1) d[++top] = i;
    }
    for(int i = 1;i <= n; i++)
        for(int j = d[i];j > d[i - 1]; j--)
            ans[j] = d[i] - d[i - 1];
    for(int i = 1;i <= n; i++) printf("%d\n",ans[x[i]]);
    return 0;
}
/*
7
6 4
4 3
3 5
7 1
2 7
5 2
1 6

3
3
1
1
2
3
2
*/

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << fixed << setprecision(15);

  int n;
  cin >> n;
  vector<int> a(n);

  int mn = 0;
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    mn = max(mn, a[i]);
  }
  vector<int> sa = a;
  sort(sa.begin(), sa.end(), greater<int>());

  for (int i = 0; i < n; ++i) {
    if (a[i] == mn) {
      cout << sa[1] << '\n';
    } else {
      cout << sa[0] << '\n';
    }
  }

  return 0;
}


Measured memory_bytes: 4748
// AUTHOR : Kishan Srivastav
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define mod 1000000007
#define in freopen("input.txt", "r", stdin)
#define out freopen("output.txt", "w", stdout)
#define ios ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);


int main() {
	ios
#ifndef ONLINE_JUDGE
	in;
	out;
#endif
	int n;
	cin>>n;
	
	if (n/100*5 >= n%100) cout<<1<<endl;
	else cout<<0<<endl;
}

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

ma = 50
result=[]
for i in range(ma):
  if n==((-2)**i):
    result.append("1")
    break
  
  if (n%(2**(i+1)))==0:
    result.append("0")
  else:
    result.append("1")
    n-=((-2)**i)

result.reverse()
head=0
for x in result:
  if x=="1":
    break
  if x=="0" and (len(result)-1)>head:
    head+=1

print("".join(result[head:]))
    


Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <utility>
#include <cstring>
#define rep(i,n) for(int i=0;i<n;i++)
using ll =long long;
using namespace std;


int main(){
	string s,flnt;
	cin >> s;
	int n,flg=0;
	cin >> n;
	rep(i, n) {
		int k;
		cin >> k;
		if (k == 1)flg++;
		else if (k == 2) {
			int a;
			string tmp;
			cin >> a;
			cin >> tmp;
			if ((a+flg)%2 == 1) flnt=flnt+tmp;
			else s = s + tmp;
		}
	}
	reverse(flnt.begin(), flnt.end());
	s = flnt + s;
	if (flg % 2 == 1)reverse(s.begin(), s.end());

	cout << s << endl;
	return 0;

}

Measured memory_bytes: 1744
n=int(input())
open_other=[]
for i in range(n):
    open_other.append(list(map(int,input().split())))
benefit_other=[]
for i in range(n):
    benefit_other.append(list(map(int,input().split())))

max_benefit=-10**10
def convert(num):
    res=[]
    for i in range(10):
        res.append(num%2)
        num=num//2
    return res

for opennum in range(1,2**10):
    opentime=convert(opennum)
    benefit=0
    for i in range(n):
        count=0
        for j in range(10):
            if open_other[i][j]==1 and opentime[j]==1:
                count+=1
        benefit+= benefit_other[i][count]
    max_benefit=max(max_benefit,benefit)
print(max_benefit)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n;
void dfs(string s,char watch)
{
	if(s.size()==n){
		cout<<s<<endl;
		return ;
	}
	for(char i='a';i<watch;i++)
		dfs(s+i,watch);
	dfs(s+watch,watch+1);
}
int main()
{
	cin>>n;
	dfs("",'a');
	return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<string>
#include<functional>
using namespace std;
typedef	long long int ll;

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i = 0; i < n; i++){
        while(1){
            if(a[i]%2 == 1) break;
            a[i] = a[i]/2;
            sum++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <fstream>
using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<long, long> PLL;
typedef long long LL;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
#define INF 10000000


int main(){
	string str;
	while(cin>>str){
		int cnt1=0,cnt2=0;
		string::size_type index = str.find("JOI",0);
		while(index!=string::npos){
			index=str.find("JOI",index+1);
			cnt1++;
		}
		index=str.find("IOI",0);
		while(index!=string::npos){
			index=str.find("IOI",index+1);
			cnt2++;
		}
		cout<<cnt1<<endl;
		cout<<cnt2<<endl;
	}
	return 0;
}

Measured memory_bytes: 1200
from sys import stdin
n,m = map(int,stdin.readline().split())
#ll = [list(map(int,input().split())) for _ in [0]*m]
#l=[]
#r=[]
#for i in range(m):
#  l.append(ll[i][0])
#  r.append(ll[i][1])
#l = max(l)
#r = min(r)

l=0
r=n
for _ in range(m):
  a,b = map(int,stdin.readline().split())
  l = l if l>a else a
  r = r if r<b else b
print(max([0,r-l+1]))

Measured memory_bytes: 3060
import math
N, M = (int(a) for a in input().split())
X = [list(map(int,input().split())) for i in range(N)]
count = 0
for i in range(N-1):
    for j in range(i+1,N):
        sum = 0
        squ = 0
        for k in range(M):
            sum += abs(X[j][k]-X[i][k])**2
        squ = pow(sum,0.5)
        if math.ceil(squ) == math.floor(squ):
            count += 1
print(count)

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

long long mod = 1000000007;

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

	vector<long long> checker(60,1);
	for (long long i = 0; i < 60; ++i) {
		checker[i] <<= i;
	}

	vector<long long> ca(60, 0);

	for (long long i = 0; i < n; ++i) {
		long long a;
		cin >> a;
		for (long long j = 0; j < 60; ++j) {
			if (checker[j] & a) {
				++ca[j];
			}
		}
	}

	long long ret = 0;
	for (long long i = 0; i < 60; ++i){
		long long temp = ca[i] * (n - ca[i]) % mod;
		for (long long j = 0; j < i; ++j) {
			temp = temp * 2 % mod;
		}
		ret = (ret + temp) % mod;
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
void OUT(bool b){cout<<(b?"YES":"NO")<<endl;}
void Out(bool b){cout<<(b?"Yes":"No")<<endl;}
void out(bool b){cout<<(b?"yes":"no")<<endl;}
template<class T>
void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>
void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}

/*他のライブラリを入れる場所*/

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a,b,c,d,e,f;
	cin>>a>>b>>c>>d>>e>>f;
	vi s,w;
	rep(i,31)rep(j,31)if(i*a*100+j*b*100<=f)w.push_back(i*a*100+j*b*100);
	rep(i,3001)rep(j,3001)if(i*c+j*d<=f)s.push_back(i*c+j*d);
	ll x=0,y=0;
	double p=-1;
	for(auto&W:w)for(auto&S:s){
		if(W==0)continue;
		if(W+S>f)continue;
		if(W/100*e<S)continue;
		double t=100.0*S/(W+S);
		if(t>p){
			p=t;
			x=W+S;
			y=S;
		}
	}
	puta(x,y);
	return 0;
}

Measured memory_bytes: 1400