akhauriyash/Code-Regression huggingface dataset:
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 10 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

N = int(input())
A = list(map(int, input().split()))
def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

# calc prime
MAX = 10 ** 6 + 2
is_prime = [True] * (MAX + 1)
is_prime[0] = False
is_prime[1] = False
i = 2
primes = []
cnt_a = Counter(A)
if cnt_a[1] == N:
    print('pairwise coprime')
    exit()
cnt_facts = defaultdict(int)
while i < MAX:
    if is_prime[i]:
        if cnt_a[i]:
            cnt_facts[i] += cnt_a[i]
        for j in range(i+i, MAX, i):
            is_prime[j] = False
            if cnt_a[j]:
                cnt_facts[i] += cnt_a[j]
        primes.append(i)
    i += 1
if cnt_facts and max(cnt_facts.values()) <= 1:
    print('pairwise coprime')
    exit()
setwise = False
g = A[0]
for a in A:
    g = gcd(g, a)
if g == 1:
    setwise = True

if setwise:
    print('setwise coprime')
if not setwise:
    print('not coprime')

Measured memory_bytes: 245364
#include <stdio.h>
#include <string.h>
#include <iostream>
#include <stack>
#include <queue>
#include <vector>
#include <cmath>
#include <algorithm>
#define LL long long
using namespace std;
/*int main()
{
    int x=11,j=0,i=0;
    while(j<56)
    {
        for( i=2; i<x/2; i++)
            if(x%i==0)break;
        if(i>=x/2)
        {
            printf("%d,",x);
            j++;
        }
        x+=10;
    }
}*/
int main()
{
    int zishu1[56]={11,31,41,61,71,101,131,151,181,191,211,241,251,271,281,311,331,401,421,431,461,491,521,541,571,601,631,641,661,691,701,751,761,811,821,881,911,941,971,991,1021,1031,1051,1061,1091,1151,1171,1181,1201,1231,1291,1301,1321,1361,1381,1451};
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
    {
        if(i==0)printf("%d",zishu1[i]);
        else printf(" %d",zishu1[i]);
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
typedef long long LL;
const int maxn = 2e5 + 100;
int n, k;
LL a[maxn], c[maxn*4];
map<LL, int> M;
vector<LL> V;
void Modify(int x, int s){
    for(; x <= n; x += x&(-x)) c[x] += s;
}
LL Query(int y){
    if(y <= 0) return 0;
    LL ans = 0;
    for(int x = y; x; x -= x&(-x)) ans += c[x];
    return ans;
}

int main()
{
    int x;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) scanf("%d", &x), a[i] = x;
    LL sum = 0;
    for(int i = 1; i <= n; i++) {
        sum += a[i];
        sum -= k;
        V.push_back(sum);
    }
    sort(V.begin(), V.end());
    for(int i = 0; i < V.size(); i++) M[V[i]] = i+1;
    sum = 0;
    LL ans = 0;
    for(int i = 1; i <= n; i++){
        sum += a[i];
        sum -= k;
        ans += Query(M[sum]);
        if(sum >= 0) ans++;
        Modify(M[sum], 1);
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 17392
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;

#define REP(i,n) for ( int i=1; i<=int(n); i++ )  
#define MP make_pair
#define PB push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()
#define X first
#define Y second
template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef pair<int, int> pii;
typedef long double LD;
const int INF = 0x3f3f3f3f;

template <class T>  
inline bool RD(T &ret) {  
        char c; int sgn;  
        if (c = getchar(), c == EOF) return 0;  
        while (c != '-' && (c<'0' || c>'9')) c = getchar();  
        sgn = (c == '-') ? -1 : 1 , ret = (c == '-') ? 0 : (c - '0');  
        while (c = getchar(), c >= '0'&&c <= '9') ret = ret * 10 + (c - '0');  
        ret *= sgn;  
        return 1;  
}  
template <class T>  
inline void PT(T x) {  
        if (x < 0) putchar('-') ,x = -x;  
        if (x > 9) PT(x / 10);  
        putchar(x % 10 + '0');  
}  

const int N = 1e6 + 10;
int a[N];

int main() {
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++) RD(a[i]);
	int c = 0;
	for(int i = 1; i <= n; i ++) if(a[a[i]] == i) c ++;
	cout << c / 2 << endl;
}


Measured memory_bytes: 768
W, H, N = map(int, input().split())
X1 = 0
X2 = W
Y1 = 0
Y2 = H
for i in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if X1 <= x:
            X1 = x
        else:
            pass
    elif a == 2:
        if x <= X2:
            X2 = x
        else:
            pass
    if a == 3:
        if Y1 <= y:
            Y1 = y
        else:
            pass
    if a == 4:
        if y <= Y2:
            Y2 = y
        else:
            pass
if X1 >= X2 or Y1 >= Y2:
    print(0)
else:
    print((X2 - X1) * (Y2 - Y1))

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

namespace abc001
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();
            var (a, b, c, d) = (input[0], input[1], input[2], input[3]);

            long max = long.MinValue;

            foreach (var x in new long[] {a, b}) {
                foreach (var y in new long[] {c, d}) {
                    max = Math.Max(max, x * y);
                }
            }

            Console.WriteLine(max);
        }
    }
}


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

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

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

    long long x = 0;
    for (int i = 0; i < n; i++)
    {
        x = (long long)a[i] - x;
    }

    vector<long long> ans(n);
    ans[0] = x / 2;

    for (int i = 1; i < n; i++)
    {
        ans[i] = (long long)a[i - 1] - ans[i - 1];
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << ans[i] << (i + 1 != n ? " " : "\n");
    }

    return 0;
}

Measured memory_bytes: 2432
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

int B[1000010];

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

	int N;
	cin >> N;

	vector<int> A(N);
	rep(i, 0, N)cin >> A[i], B[A[i]] ++;
	int ans = 0;
	rep(i, 0, N)
	{
		int sn = sqrt(A[i]);
		bool ok = false;
		rep(j, 1, sn + 1)
		{
			if (A[i] % j == 0)
			{
				int x = j, y = A[i] / j;
				if (x != A[i])
				{
					if (B[x] > 0)ok = true;
				}
				else
				{
					if (B[x] > 1)ok = true;
				}
				if (y != A[i])
				{
					if (B[y] > 0)ok = true;
				}
				else
				{
					if (B[y] > 1)ok = true;
				}
			}
		}
		if (!ok)ans++;
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef vector<long long> vll;
typedef vector<vector<long long>> mll;
typedef vector<pair<long long, long long>> vpl;
typedef pair<long long, long long> pll;
#define minimize(var, val) (var = min((val), var))

int main() {
    ll n;
    cin >> n;
    vll a(n);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    mll dp_max(n, vll(n, 0)), dp_min(n, vll(n, 0));
    for (int i = 0; i < n; i++)
        dp_max[i][i] = a[i];
    for (int i = 0; i < n; i++)
        dp_min[i][i] = -a[i];
    for (int len = 2; len <= n; len++) {
        for (int i = 0; i + len <= n; i++) {
            int j = len + i - 1;
            dp_max[i][j] =
                max(a[i] + dp_min[i + 1][j], dp_min[i][j - 1] + a[j]);
            dp_min[i][j] =
                min(dp_max[i + 1][j] - a[i], dp_max[i][j - 1] - a[j]);
        }
    }
    cout << dp_max[0][n - 1] << endl;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define repp(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const lint MOD   = 1e9 + 7;
const double EPS = 1e-10;

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

    int cnt = 0;
    while (a >= b) {
        b *= 2;
        cnt++;
    }
    while (b >= c) {
        c *= 2;
        cnt++;
    }
    if (cnt <= k) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
int main() {
  lli A,B,C=1,D=0,E=0,F=0,G=0,H=0,N,M;
  string S;
  cin >> S;
  A=S.size();
  vector<char>P(0);
  rep(i,0,A){
    if(S[i]=='B'&&P.size()!=0)P.pop_back();
    else if(S[i]!='B')P.pb(S[i]);
  }
  A=P.size();
  rep(i,0,A)NeOut(P[i]);
  cout << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include <cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back

void Yes(){
	cout<<"Yes"<<endl;
	exit(0);
}
 
void No(){
	cout<<"No"<<endl;
	exit(0);
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
    int a, b, c, d, e, f;
    cin >> a >> b >> c >> d >> e >> f;
    int a_max = f / (100 * a);
    ld percent_max = 0;
    int ans_sugarwater = 100 * a, ans_sugar = 0;
    rep(i, a_max + 1) {
        int b_max = (f - 100 * a * i) / (100 * b);
        rep(j, b_max + 1) {
            int water = 100 * a * i + 100 * b * j;
            int sugar_max = f - water;
            int c_max = sugar_max / c;
            if(water == 0) continue;
            rep(k, c_max + 1) {
                int d_max = (sugar_max - c * k) / d;
                rep(l, d_max + 1) {
                    ld percent = (ld)(100 * (c * k + d * l)) / (((ld)(a * i + b * j) * 100) + (ld)(c * k + d * l));
                    if(percent > percent_max && percent <= ((ld)(100 * e) / (100 + e))) {
                        percent_max = percent;
                        ans_sugarwater = 100 * (a * i + b * j) + c * k + d * l;
                        ans_sugar = c * k + d * l;
                    }
                }
            }

        }
    }
    cout << ans_sugarwater << " " << ans_sugar << endl;
 	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
  char c,ans;
  scanf("%c",&c);
  switch(c){
    case 'A':
      ans='T';
      break;
    case 'C':
      ans='G';
      break;
    case 'G':
      ans='C';
      break;
    case 'T':
      ans='A';
      break;
    default:
      break;
  }
  printf("%c",ans);
  return 0;
}

Measured memory_bytes: 128
h,w,d=map(int,input().split())
e={}
for i in range(1,h+1):
    a=list(map(int,input().split()))
    for j in range(w):
        e[a[j]]=(i,j+1)
q=int(input())
ans=[0]*(h*w+1)
for i in range(d+1,h*w+1):
    x,y=e[i]
    z,m=e[i-d]
    ans[i]=abs(x-z)+abs(y-m)+ans[i-d]
    
for i in range(q):
    l,r=map(int,input().split())
    print(ans[r]-ans[l])

Measured memory_bytes: 66396
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;

 
lint fac[MAX], finv[MAX], inv[MAX];

void COMinit() // 二項係数を求める時は前処理としてCOMinit()をする
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
// 二項係数計算
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0; // 偶数はあらかじめ除く

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

    // 素数である
    return 1;
}

   

int main(){
 lint A,B,C;
 string s;
 cin>>A>>B;

cout<<6-A-B;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n;
	cin >> n;
  int a[5]={2,4,5,7,9};
  int b[4]={0,1,6,8};
  
  for(int i=0;i<5;i++)
  {
    if(n%10==a[i])
  cout<<"hon"<<endl;
  }
  for(int i=0;i<4;i++)
  {if(n%10==b[i])
       cout<<"pon"<<endl;
       }
       
  if(n%10==3)
      cout<<"bon"<<endl;
      return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <queue>

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

void seach(int x,int y,int X,int Y);

int speace[5000][5000],n;

int main(){
	int X,Y,N,x1,y1,x2,y2;
	while(1){
	cin >> X >> Y;
		if(X==0&&Y==0){
			break;
		}
	cin >> N;
	n=0;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			speace[i][j]=-1;
		}
	}
	for(int i=0;i<N;i++){
		cin >> x1>>y1>>x2>>y2;
		for(int j=x1;j<x2;j++){
			for(int k=y1;k<y2;k++){
				speace[j][k]=n;
			}
		}
	}
	n++;
	for(int i=0;i<X;i++){
		for(int j=0;j<Y;j++){
			if(speace[i][j]==-1){
				seach(i,j,X,Y);n++;
				
			}
		}
	}
		/*cout << "\n";
		for(int i=0;i<X;i++){
			for(int j=0;j<Y;j++){
				cout << speace[i][j] << " ";
			}
			cout << "\n";
		}*/
	cout << n-1 <<"\n";
	}
	return 0;
}

void seach(int x,int y,int X,int Y){
	int dx[4]={-1,0,0,1},dy[4]={0,1,-1,0};
	queue<P> que;
	que.push(P(x,y));
	while(que.size()){
		P p=que.front();
		que.pop();
		for(int i=0;i<4;i++){
			if(0<=p.first+dx[i]&&p.first+dx[i]<X&&0<=p.second+dy[i]&&p.second+dy[i]<Y){
				if(speace[p.first+dx[i]][p.second+dy[i]]==-1){
					speace[p.first+dx[i]][p.second+dy[i]]=n;
					que.push(P(p.first+dx[i],p.second+dy[i]));
				}
			}
		}
	}
}
			
	

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

#define PI 3.14159265358979323846264338327950288419

using namespace std;

int n;
int a[200005], b[200005];

long long ans = 0;

queue<int> Q;
bool in_queue[200005];

int nx(int id){
	return (id + 1) % n;
}
int pv(int id){
	return (id + n - 1) % n;
}

void check(int i){
	if(!in_queue[i] && b[i] >= b[nx(i)] + b[pv(i)]){
		in_queue[i] = true;
		Q.push(i);
	}
}

int main(){
	scanf("%d", &n);
	for(int i = 0; i < n; i++){
		scanf("%d", &a[i]);
	}
	for(int i = 0; i < n; i++){
		scanf("%d", &b[i]);
		if(b[i] < a[i]){
			printf("-1\n");
			return 0;
		}
	}
	
	for(int i = 0; i < n; i++){
		check(i);
	}
	while(!Q.empty()){
		int i = Q.front();
		Q.pop();
		in_queue[i] = false;
		int gap = b[nx(i)] + b[pv(i)];
		int op = (b[i] - a[i]) / gap;
		ans += op;
		b[i] -= op * gap;
		check(nx(i));
		check(pv(i));
	}
	for(int i = 0; i < n; i++){
		if(a[i] != b[i]){
			printf("-1\n");
			return 0;
		}
	}
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 2432
n = int(input())
sum = 0

def gcd(a, b):
    if a < 1 or b < 1 :
        if a > 0:
            return a
        return b
    remainder = 0
    if a % b == 0 :
        return b
    remainder = a % b
    a = b
    b = remainder
    return gcd(a, b)

for i in range(1, n+1):
    for j in range(1, n+1):
        for k in range(1, n+1):
            sum += gcd(gcd(i, j), k)
print(sum)




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

int main() {
  int n; cin >> n;
  bool ok=1, z=0;
  ll ans = 1;
  for (int i= 0; i < n; i++) {
    ll tmp; cin >> tmp;
    if (tmp==0) {
      ans=0;
      z=1;
      continue;
    }
    if (ans > ((ll)1e18)/tmp)ok=0;
    ans *= tmp;
  }
  if (!ok && !z) cout << -1;
  else cout << ans;
}


Measured memory_bytes: 3652
import networkx as nx
import sys
input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 7)


G = nx.Graph()
N, M = map(int, input().split())
edge = [tuple(map(int, input().split())) for _ in range(M)]
G.add_edges_from(edge)
pre = nx.predecessor(G, 1)

print("Yes")
for i in range(2, N + 1):
    print(pre[i][0])

Measured memory_bytes: 212644
N, K = list(map(int, input().split()))

f = 0
ans = 0

if N >= K:
    ans = (N - K + 1) / 1.0
    f = 1
K = K - 1

a = []
i = 0
while(2 * N < K):
    a.append(0)
    i += 1
    K = K // 2

if f == 0:
    i += 1
    a.append(N - K //2)
    K = K // 2

while(K != 0):
    a.append(K - K // 2)
    i += 1
    K = K // 2

bunsi = 0

for j in range(len(a)):
    bunsi += a[j] * pow(2, i - j - 1)
ans += bunsi / pow(2, i)

print(ans / N)




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

int main() {
    int d; cin >> d;
    int n = 26;
    vector<int> c(n);
    rep(i,n) cin >> c[i];
    vector<vector<int>> s(d,vector<int>(n));
    rep(i,d){
        rep(j,n){
            cin >> s[i][j];
        }
    }

    vector<int> t(d);

    vector<int> last(n,1);

    rep(i,d){
        int ti;
        int h;
        rep(j,n){
            int hj = c[j]*last[j]+s[i][j];
            if(j == 0) {
                h = hj;
                ti = j;
            }
            else if(h < hj){
                h = hj;
                ti = j;
            }
        }
        t[i] = ti+1;
        last[ti] = 1;
        rep(j,n){
            if(j != ti){
                last[ti]++;
            }
        }
    }

    rep(i,d) cout << t[i] << endl;
}


Measured memory_bytes: 3680
#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 bitmask(int n){
	
	int a = 1;
	
	return ( a << n );
	
}

int main(){

	//input
	int N, M, X, tmp;
	int maxcost = 0;
	
	cin >> N >> M >> X;
	
	vector<int> C(N);
	vector<vector<int> > A(N);
	
	for(int i = 0;i < N;i++){
		cin >> C[i];
		for(int j = 0;j < M;j++){
			cin >> tmp;
			A[i].push_back(tmp);
		}
		maxcost = maxcost + C[i];
	}
	
	//calc effect
	vector<int> Effect(M);
	for(int m = 0;m < M;m++){
		Effect[m] = 0;
		for(int n = 0;n < N;n++){
			Effect[m] = Effect[m] + A[n][m];
		}
		if( Effect[m] < X ){
			cout << -1;
			return 0;
		}
	}
	
	//calc
	int mincost = maxcost;
	bool flag;
	for(int i = 0;i < pow(2,N);i++){
		int cost = 0;
		vector<int> L(M);
		flag = true;
		for(int n = 0;n < N;n++){
			cost = cost + ( ((i & bitmask(n)) > 0) ? C[n] : 0 );
		}
		for(int m = 0;m < M;m++){
			L[m] = 0;
			for(int n = 0;n < N;n++){
				L[m] = L[m] + ( ((i & bitmask(n)) > 0) ? A[n][m] : 0 );
			}
			if( L[m] < X ){
				flag = false;
				break;
			}
		}
		
		if( flag ){
			if( cost < mincost ){
				mincost = cost;
			}
		}
	}
	
	cout << mincost;
	
	return 0;
	
}


Measured memory_bytes: 4080
h,w=map(int,input().split())
grid=[]
for i in range(h):
    *x,=map(int,input().split())
    grid.append(x)
oper=[]
d=[(1,0),(0,1)]
flg=False
cand=[]
for i in range(h):
    if i%2==0:
        s=0
        e=w
        b=1
    else:
        s=w-1
        e=-1
        b=-1
    for j in range(s,e,b):
        if flg:
            grid[i][j]+=1
            flg=False
            cand+=[i+1,j+1]
            oper.append(cand)
            cand=[]
        if grid[i][j]%2==1:
            grid[i][j]-=1
            flg=True
            cand+=[i+1,j+1]

print(len(oper))
for i in oper:
    print(*i)


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

typedef long long       ll;
const int MOD=1000000007;
const int MAX=1e5+9;
ll cnt[MAX];

ll fastPow(ll a, ll b) {
    if (!b) {
        return 1;
    }

    ll sq=fastPow(a, (b>>1LL));
    sq*=sq;

    if (b&1LL) {
        sq%=MOD;
        sq*=a;
    }

    return sq%MOD;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n, k;
    cin >> n >> k;
    ll ans=0;
    for (int i=k; i>=1; --i) {
        int mul=k/i;
        if (!mul) {
            continue;
        }

        cnt[i]=fastPow(mul, n);
        for (int j=2; 1LL*j*i<=k; ++j) {
            cnt[i]-=cnt[j*i];
            if (cnt[i]<MOD) {
                cnt[i]+=MOD;
            }
        }

        ans+=(1LL*i*cnt[i])%MOD;
        ans%=MOD;
    }

    cout << ans;

    return 0;
}


Measured memory_bytes: 4396
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int n,k,l,h,cnt,ans;
struct node {
	int val,pos;
	bool hand;
} r[100000010];
char s[100010];
bool f,a[100010];
int main() {
	scanf("%d%d\n%s",&n,&k,&s);
	l=strlen(s);
	for(register int i=0; i<l; i++)if(s[i]=='1')a[i]=1;
	if(s[0]=='1')f=1;
	for(register int i=0; i<l; i++) {
		if((s[i]=='1'&&f)||(s[i]=='0'&&!f))cnt++;
		else {
			r[++h].val=cnt;
			cnt=1;
			r[h].pos=i-1;
			if(f) {
				f=0;
				r[h].hand=1;
			} else f=1;
		}
	}
	r[++h].val=cnt;
	r[h].pos=l-1;
	r[0].pos=-1;
	if(k>h/2)k=h/2;
	for(register int i=1; i<=h-k*2; i++)if(r[i].hand)ans=max(ans,r[i+k*2].pos-r[i-1].pos);
	if(s[0]=='0')ans=max(ans,r[2*k].pos+1);
	if(s[l-1]=='0')ans=max(ans,l-1-r[h-2*k].pos);
	printf("%d",ans==0?l:ans);
}

Measured memory_bytes: 1536
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func isValidGrid(c [3][3]int) bool {
	for a0 := 0; a0 <= c[0][0]; a0++ {
		b0 := c[0][0] - a0
		b1 := c[0][1] - a0
		b2 := c[0][2] - a0
		if b0 < 0 || b1 < 0 || b2 < 0 {
			continue
		}

		a1 := c[1][0] - b0
		if (a1 < 0 || c[1][1] != a1+b1) || (c[1][2] != a1+b2) {
			continue
		}
		a2 := c[2][0] - b0
		if (a2 < 0 || c[2][1] != a2+b1) || (c[2][2] != a2+b2) {
			continue
		}
		return true
	}
	return false
}

func main() {
	sc.Split(bufio.ScanWords)

	var c [3][3]int
	for i := 0; i < 3; i++ {
		for j := 0; j < 3; j++ {
			c[i][j] = nextInt()
		}
	}

	if isValidGrid(c) {
		fmt.Print("Yes")
		return
	}
	fmt.Print("No")
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N, Y;
    cin >> N >> Y;
    rep(i, N + 1){
        if(Y >= i * 1000){
            int YY = Y - i * 1000;
            int NN = N - i;
            if(YY % 5000 == 0){
                YY /= 5000;
                int b = 2 * NN - YY;
                int a = YY - NN;
                if(a >= 0 && b >= 0){
                    cout << a << " " << b << " " << i << endl;
                    return 0;
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int price=700;
  for(int i=0;i<3;i++){
    if(S[i]=='o'){
      price += 100;
    }
  }
  cout << price << endl;
}

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

int main() {
  int n,cnt=0;
  cin >> n;
  rep1(i,n){
    if(to_string(i).length()%2 == 1){
      cnt++;
    }
  }
  cout << cnt << endl;
}

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

typedef long long int llint;

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

  int a[200001];
  map<int, int> m;
  
  for(int i = 0; i < n; i++) {
    cin>> a[i];
    if(!m[a[i]]) m[a[i]] = 0;
    m[a[i]]++;
  }

  if(m.size() <= k) cout<< 0 <<endl;
  else {
    int cnt = 0;
    vector<int> v;
    for(auto i = m.begin(); i != m.end(); ++i) {
      v.push_back(i->second);
    }

    sort(v.begin(), v.end());
    for(int i = 0; i < m.size() - k; i++) cnt += v[i];

    cout<< cnt <<endl;
  }
    
  return 0;
}


Measured memory_bytes: 11516
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

static const int MOD = 1e9 + 7;

long long GCD(long long A, long long B) {
    if (A == 0)return B;
    else return GCD(B % A, A);
}

long long NumberOfPrimeFactor(long long x) {
    long long cnt = 0;
    for (long long i = 2; i*i <=x ; i++){
        if (x%i == 0) {
            cnt++;
            while (x%i == 0)x /= i;
        }
    }
    return cnt + (x != 1);
}

int main() {

    long long A, B;
    cin >> A >> B;

    if (A > B)swap(A, B);
    cout << NumberOfPrimeFactor(GCD(A, B)) + 1;

}

Measured memory_bytes: 256
import sys
def rs(): return sys.stdin.readline().rstrip()
def ri(): return int(sys.stdin.readline())
def ria(): return list(map(int, sys.stdin.readline().split()))
def ws(s): sys.stdout.write(s + '\n')
def wi(n): sys.stdout.write(str(n) + '\n')
def wia(a): sys.stdout.write(' '.join([str(x) for x in a]) + '\n')


def solve(n, k, a):
    # wia(a)
    for _ in range(k):
        b = [0] * n
        for i in range(n):
            l = max(0, i - a[i])
            r = min(n-1, i + a[i])
            b[l] += 1
            if r < n-1:
                b[r+1] -= 1
        for i in range(1, n):
            b[i] += b[i-1]
        a = b
        # wia(a)
        if sum(a) == n * n:
            break
    return a


def main():
    n, k = ria()
    a = ria()
    wia(solve(n, k, a))


if __name__ == '__main__':
    main()


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

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> po;
    vector<int> ne;
    po.push_back(0);
    ne.push_back(0);
    for (int i = 0; i < n; i++)
    {
        int t;
        cin >> t;
        if (t >= 0)
            po.push_back(t);
        else
            ne.push_back(-t);
    }
    sort(ne.begin(), ne.end());
    sort(po.begin(), po.end());
    int ans = 0x3f3f3f3f;

    for (int i = max(0, k - (int)po.size() + 1); (i < (int)ne.size() && i <= k); i++)
    {
        if (ne[i] + po[k - i] + min(ne[i], po[k - i]) < ans)
            ans = ne[i] + po[k - i] + min(ne[i], po[k - i]);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3848
#include <iostream>
#include <cstring>

using namespace std;

typedef long long ll;

const int LGN = 63;
const int Z = 1e9+7;

void addm(int &a, int b) {
    a = a + b >= Z ? a + b - Z : a + b;
}

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

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

    int p3[LGN];
    for (int i = 0; i < LGN; i++) {
        p3[i] = i == 0 ? 1 : 3ll * p3[i-1] % Z;
    }

    int dp[LGN+1][2][2][2];
    memset(dp, 0, sizeof(dp));
    for (int fl = 0; fl <= 1; fl++) {
        for (int fr = 0; fr <= 1; fr++) {
            for (int sb = 0; sb <= 1; sb++) {
                dp[0][fl][fr][sb] = 1;
            }
        }
    }
    for (int i = 1; i <= LGN; i++) {
        bool bl = l >> (i - 1) & 1, br = r >> (i - 1) & 1;
        for (int fl = 0; fl <= 1; fl++) {
            for (int fr = 0; fr <= 1; fr++) {
                for (int sb = 0; sb <= 1; sb++) {
                    if (!(bl && fl)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][fl][br?0:fr][sb]);
                    }
                    if (!sb && !(bl && fl) && !(!br && fr)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][fl][fr][sb]);
                    }
                    if (!(!br && fr)) {
                        addm(dp[i][fl][fr][sb], dp[i-1][!bl?0:fl][fr][0]);
                    }
                }
            }
        }
    }

    cout << dp[LGN][1][1][1] << endl;

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int h,m,s;
	scanf("%d",&s);

	h=s/3600;
	s=s-h*3600;
	m=s/60;
	s=s-m*60;
	printf("%d:%d:%d\n",h,m,s);
	return 0;
}

Measured memory_bytes: 592
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <algorithm>
using namespace std;

int main(){
	string s;
	cin >> s;

	cout << s.at(0) << s.length()-2 << s.at(s.length()-1) << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
#define fst first
#define snd second
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
template<typename T> inline bool chmin(T& a, T b) {if(a>b) {a=b; return true;} return false;}
template<typename T> inline bool chmax(T& a, T b) {if(a<b) {a=b; return true;} return false;}
inline int Log2(ll x) {int k; for(k=0; x>0; ++k) x>>=1; return k;} // number of binary digits
template<typename T> inline int count_between(vector<T>& a, T l, T r) {
  return lower_bound(all(a), r) - lower_bound(all(a), l); // [l, r)
}
template<typename T> istream& operator>>(istream& is, vector<T>& v) {
  rep(i, v.size()) is >> v[i]; return is;
}
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
  rep(i, v.size()) os << v[i] << " "; os << endl; return os;
}
const int INF = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS = 1e-10;
const int MOD = int(1e9)+7;


int main() {
  ll n; cin >> n;
  V l(n), r(n);
  rep(i, n) cin >> l[i] >> r[i];
  sort(all(l), greater<int>());
  sort(all(r));

  Vll sl(n+1), sr(n+1);
  rep(i, n) sl[i+1] = sl[i] + l[i];
  rep(i, n) sr[i+1] = sr[i] + r[i];

  ll ans = 0;
  rep(i, n) chmax(ans, sl[i]-sr[i]);
  rep(i, n-1) chmax(ans, sl[i+1]-sr[i]);
  rep(i, n-1) chmax(ans, sl[i]-sr[i+1]);

  ans *= 2;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int

struct edge
{
  int to, cost;
};
typedef std::vector<std::vector<edge>> graph;
const ll MOD = 1000000007;
using namespace std;

int main()
{
  int a, b;
  cin >> a >> b;
  if (a == 1)
    a = 14;
  if (b == 1)
    b = 14;
  if (a > b)
  {
    cout << "Alice" << endl;
  }
  else if (a == b)
  {
    cout << "Draw" << endl;
  }
  else
  {
    cout << "Bob" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <string>
#include <sstream>
#include <algorithm>
#include <random>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cmath>
#include <cassert>
#include <climits>
#include <bitset>
#include <functional>

#define FOR_LT(i, beg, end) for (int i = beg; i < end; i++)
#define FOR_LE(i, beg, end) for (int i = beg; i <= end; i++)
#define FOR_DW(i, beg, end) for (int i = beg; end <= i; i--)

using namespace std;

int matrix[1000][1000] = {};
class UnionFind
{
public:
	UnionFind(int min, int max)
		: elems_(max - min + 1)
		, min_(min)
		, rank_(max - min + 1)
	{
		for (int i = min; i <= max; i++) {
			Elem& elem = this->elems_[i - min];
			elem.i = i;
			elem.num = 1;
		}
	}

	int find(int i) {
		int idx = i - this->min_;
		if (this->elems_[idx].i == i) return i;

		int root = this->find(this->elems_[idx].i);
		this->elems_[idx].i = root; // 簡略化
		return root;
	}

	int size(int i) {
		int root = this->find(i);
		int idx = root - this->min_;
		return this->elems_[idx].num;
	}

	int rank() {
		return rank_;
	}

	void merge(int i, int j) {
		int i_root = this->find(i);
		int j_root = this->find(j);
		if (i_root == j_root) return;

		int i_idx = i_root - this->min_;
		int j_idx = j_root - this->min_;

		int i_size = this->elems_[i_idx].num;
		int j_size = this->elems_[j_idx].num;

		if (i_size < j_size) {
			this->elems_[i_idx].i = j_root;
			this->elems_[j_idx].num += this->elems_[i_idx].num;
		}
		else {
			this->elems_[j_idx].i = i_root;
			this->elems_[i_idx].num += this->elems_[j_idx].num;
		}
		this->rank_--;
	}

private:
	struct Elem {
		int i;
		int num; // root 以外は無効
	};

	vector<Elem> elems_;
	int          min_;
	int          rank_;
};

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);

	int n, k; cin >> n >> k;

	vector<int> vals(n + 1);
	FOR_LT(i, 0, n) {
		cin >> vals[i];
	}

	UnionFind uf = UnionFind(0, n - k);

	set<int> sets;
	FOR_LT(i, 0, k) {
		sets.insert(vals[i]);
	}

	FOR_LT(i, 0, n - k) {
		if (*sets.begin() == vals[i] && *sets.rbegin() < vals[i + k]) {
			uf.merge(i, i + 1);
		}
		sets.erase(vals[i]);
		sets.insert(vals[i + k]);
	}

	int prev = -1;
	int count = 0;
	FOR_LT(i, 0, n - 1) {
		if (vals[i] < vals[i + 1]) {
			count++;
		}
		else {
			count = 0;
		}
		if (k - 1 <= count) {
			if (prev != -1) {
				uf.merge(prev, i - (k - 2));
			}
			prev = i - (k - 2);
		}
	}

	cout << uf.rank() << endl;

	return 0;
}

Measured memory_bytes: 10368
# -*- coding: utf-8 -*-
# ITP1_11_C

class Dice:
    def __init__(self, num):
        self.num = num
        
    def roll(self, direction):
        """ 転がす処理 """
        data = []
        new_num = []
        if direction == "N":
            data = [1, 5, 2, 3, 0, 4]
        elif direction == "S":
            data = [4, 0, 2, 3, 5, 1]
        elif direction == "E":
            data = [3, 1, 0, 5, 4, 2]
        elif direction == "W":
            data = [2, 1, 5, 0, 4, 3]
        elif direction == "L":
            data = [0, 2, 4, 1, 3, 5]
        elif direction == "R":
            data = [0, 3, 1, 4, 2, 5]

        for i in data:
            new_num.append(self.num[i])
        self.num = new_num
        
def dice_roll1(dice, dice_tf):
    dice_roll = ""
    top = dice_tf[0]
    
    if dice.num.index(top) == 1:
        dice_roll = "N"
    elif dice.num.index(top) == 2:
        dice_roll = "W"
    elif dice.num.index(top) == 3:
        dice_roll = "E"
    elif dice.num.index(top) == 4:
        dice_roll = "S"
    elif dice.num.index(top) == 5:
        dice_roll = "NN"
        
    return dice_roll

def dice_roll2(dice, dice_tf):
    dice_roll = ""
    front = dice_tf[1]

    if dice.num.index(front) == 2:
        dice_roll = "L"
    elif dice.num.index(front) == 3:
        dice_roll = "R"
    elif dice.num.index(front) == 4:
        dice_roll = "LL"
        
    return dice_roll

dice_list = []
n = int(input())

for _ in range(n):
    dice_list.append(Dice(list(map(int, input().split()))))

dice_tf = dice_list[0].num[:2]
is_same = True
for i in dice_list[1:]:
    """ 構成が違ったら位置の判定を飛ばす """
    if set(dice_list[0].num) != set(i.num):
        continue
    direction = dice_roll1(i, dice_tf)
    for j in direction:
        i.roll(j)
    direction = dice_roll2(i, dice_tf)
    for j in direction:
        i.roll(j) 
    if i.num == dice_list[0].num:
        is_same = False
        break
if is_same == True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5624
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (1e+18) + 7;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

ll mod_pow(ll a, ll n) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%mod;
		a = a * a%mod; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 20;
modint fact[max_n], factinv[max_n];
void init() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}


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

void solve() {
	int n, k; cin >> n >> k;
	vector<ll> a(n);
	rep(i, n) {
		cin >> a[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	ll s = 0;
	Rep(i, k, n)s += a[i];
	cout << s << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	//int t; cin >> t; rep(i, t)solve();
	//while (cin >> n, n)solve();
	solve();
	stop
		return 0;
}


Measured memory_bytes: 18304
def main():
    N, M = map(int, input().split())
    C = list(map(int, input().split()))
    dp = [float('inf')] * (N + 5)
    dp[0] = 0
    for i in range(N+1):
        for c in C:
            if i + c > N + 1:
                continue
            dp[i+c] = min(dp[i+c], dp[i] + 1)

    print(dp[N])


if __name__ == "__main__":
    main()


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

int main(){
int a,b;
scanf("%d%d",&a,&b);
if(a+b>=10){
	
	
	
	
	printf("error\n");
	
	
}else{
	
	
	printf("%d\n",a+b);
}
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <sstream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <string>
#include <cstring>
#include <bitset>
#include <functional>
#include <random>
#define REP(i,a,n) for(int i=a;i<=n;++i)
#define PER(i,a,n) for(int i=n;i>=a;--i)
#define hr putchar(10)
#define pb push_back
#define lc (o<<1)
#define rc (lc|1)
#define mid ((l+r)>>1)
#define ls lc,l,mid
#define rs rc,mid+1,r
#define x first
#define y second
#define io std::ios::sync_with_stdio(false)
#define endl '\n'
#define DB(a) ({REP(__i,1,n) cout<<a[__i]<<',';hr;})
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int P = 1e9+7, INF = 0x3f3f3f3f;
ll gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
ll qpow(ll a,ll n) {ll r=1%P;for (a%=P;n;a=a*a%P,n>>=1)if(n&1)r=r*a%P;return r;}
ll inv(ll x){return x<=1?1:inv(P%x)*(P-P/x)%P;}
inline int rd() {int x=0;char p=getchar();while(p<'0'||p>'9')p=getchar();while(p>='0'&&p<='9')x=x*10+p-'0',p=getchar();return x;}
//head



const int N = 5e3+10;
int n,dp[N][N][2],sz[N],a[N],tmp[N][2];
vector<int> g[N];
void add(int &a, ll b) {a=(a+b)%P;}

void dfs(int x, int f) {
	sz[x] = 1;
	dp[x][1][0] = 1;
	for (int y:g[x]) if (y!=f) {
		dfs(y,x);
		REP(i,0,sz[x]+sz[y]) REP(j,0,1) tmp[i][j]=0;
		REP(i,1,sz[x]) REP(z1,0,1) REP(j,1,sz[y]) REP(z2,0,1) {
			ll t = (ll)dp[x][i][z1]*dp[y][j][z2]%P;
			add(tmp[i][z1^z2^1],t*a[j]);//删边
			add(tmp[i+j][z1^z2],t);//不删边
		}
		REP(i,0,sz[x]+sz[y]) REP(j,0,1) dp[x][i][j]=tmp[i][j];
		sz[x] += sz[y];
	}
}

int main() {
	scanf("%d", &n);
	REP(i,2,n) {
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].pb(v),g[v].pb(u);
	}
	a[0] = 1;
	for (int i=2; i<=n; i+=2) a[i] = a[i-2]*(i-1ll)%P;
	dfs(1,0);
	int ans = 0;
	REP(i,1,n) add(ans,(dp[1][i][0]-dp[1][i][1])*(ll)a[i]);
	if (ans<0) ans += P;
	printf("%d\n", ans);
}








Measured memory_bytes: 195456
#include <bits/stdc++.h>
#define INF (1LL<<60)
#define MOD7 1000000007LL
#define PREP(i, s, x) for(ll i = (s); i < (x); i ++)
#define MREP(i, s, x) for(ll i = (s); i >= (x); i --)
#define REP(i, x) PREP(i, 0, x)
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;
template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return 1;}return 0;}

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

ll llpow(ll a, ll n){
    ll res = 1;
    while(n > 0){
        if(n & 1)
            res = res * a % MOD7;
        a = a * a % MOD7;
        n >>= 1;
    }
    return res;
}

int main(){
    ll n;
    cin >> n;
    vector<string> s(n);
    REP(i, n){
        cin >> s[i];
    }

    ll cnt = 1;
    sort(s.begin(), s.end());
    REP(i, n-1){
        if(s[i] != s[i+1]){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 9600
#include<bits/stdc++.h>
#define LL long long
#define db double

using namespace std;
const int N=2000+10,mod=1e9+7;
int rd()
{
    int x=0,w=1;char ch=0;
    while(ch<'0'||ch>'9'){if(ch=='-') w=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+(ch^48);ch=getchar();}
    return x*w;
}
void ad(int &x,int y){x+=y,x-=x>=mod?mod:0;}
int fpow(int a,int b){int an=1;while(b){if(b&1) an=1ll*an*a%mod;a=1ll*a*a%mod,b>>=1;}return an;}
int ginv(int a){return fpow(a,mod-2);}
int n,k,fac[N*N],iac[N*N],f[2][N];
int C(int a,int b){return b<0||a<b?0:1ll*fac[a]*iac[b]%mod*iac[a-b]%mod;}

int main()
{
	n=rd(),k=rd();
	if(k==1){puts("1");exit(0);}
	fac[0]=1;
	for(int i=1;i<=n*k;++i) fac[i]=1ll*fac[i-1]*i%mod;
	iac[n*k]=ginv(fac[n*k]);
	for(int i=n*k;i;--i) iac[i-1]=1ll*iac[i]*i%mod;
	int nw=1,la=0;
	f[la][0]=1;
	for(int i=1;i<=n+n;++i)
	{
		for(int j=0;j<i&&j<=n;++j)
		{
			if(!f[la][j]) continue;
			if(j<=n) ad(f[nw][j+1],1ll*f[la][j]*C(i-1+(k-2)*(j+1),k-2)%mod);
			if(j>=i-j) ad(f[nw][j],f[la][j]);
			f[la][j]=0;
		}
		nw^=1,la^=1;
	}
	printf("%d\n",(int)(1ll*fac[n]*f[la][n]%mod));
	return 0;
}


Measured memory_bytes: 31616
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
static const int MAX = 200000;

int main()
{
	string s;
	cin >> s;
	for (int i = 0; i < 19; i++) {
		if (s[i] == ',') {
			s[i] = ' ';
		}
	}
	cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    X = list(map(int, input().split()))
    if N >= M:
        print('0')
        return 
    X_sort = sorted(X)
    diff = []
    for i in range(M - 1):
        diff.append(X_sort[i + 1] - X_sort[i])
    diff_sort = sorted(diff)
    if N != 1:
        for _ in range(N - 1):
            diff_sort.pop()
    ans = 0
    for d in diff_sort:
        ans += d
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define ALL(v) (v).begin(), (v).end()

int main()
{
  int A, B, C, D, E, F; cin >> A >> B >> C >> D >> E >> F;

  double concentration = -1.0;
  int ans_w = 0, ans_s = 0;
  for (int a_i = 0; a_i*100*A <= F; ++a_i) {
    for (int b_i = 0; b_i*100*B <= F; ++b_i) {
      for (int c_i = 0; c_i*C <= F; ++c_i) {
        for (int d_i = 0; d_i*D <= F; ++d_i) {
          int water = a_i*A*100+b_i*B*100;
          int sugar = c_i*C+d_i*D;

          if (sugar > water*E/100.0 or
              water+sugar > F) continue;

          double tmpconc = 100.0*sugar/(water+sugar);

          if (concentration < tmpconc) {
            concentration = tmpconc;
            ans_w = water;
            ans_s = sugar;
          };
        }
      }
    }
  }

  printf("%d %d\n", ans_w+ans_s, ans_s);
}

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

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

Measured memory_bytes: 512
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)


n, k, *a = map(int, read().split())
dp = [False] * (k + 1)
for i in range(k + 1):
    for j in range(n):
        if i - a[j] >= 0:
            dp[i] |= not dp[i - a[j]]
if dp[k]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 41964