akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
string s;
int main(){
	G:
	while(getline(cin,s),s!="."){
		stack<char> p;
		for(int i=0;i<s.length();i++){
			if(s[i]=='('||s[i]=='[')p.push(s[i]);
			if(s[i]==')'){
				if(p.empty()||p.top()!='('){cout<<"no"<<endl;goto G;}
				p.pop();
			}
			if(s[i]==']'){
				if(p.empty()||p.top()!='['){cout<<"no"<<endl;goto G;}
				p.pop();
			}
		}
		cout<<(p.empty()?"yes":"no")<<endl;
	}

}

Measured memory_bytes: 3144
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
using namespace std;
#define rep(i, n) for ( int i = 0; i < (int)n; i++)
#define MAX 12
#define INFTY (1<<21)
int W, L[MAX], n;

double getL(int r1, int r2){
    double d = r1 - r2;
    return sqrt((r1+r2)*(r1+r2)-d*d);
}

void compute(){
    double T[1<<MAX][MAX];
    rep(i, 1<<n) rep(j, n) T[i][j] = INFTY;
    rep(i, n) T[1<<i][i] = L[i]*2;
    for ( int k = 1; k < n; k++ ){
	rep(i, 1<<n) rep(j, n){
	    if ( T[i][j] == INFTY ) continue;
	    rep(l, n){
		if ( j == l || (1<<l) & i ) continue;
		int v = ((1<<l) | i);
		T[v][l] = min(T[v][l], T[i][j] - L[j] + L[l] + getL(L[j], L[l]));
	    }
	}
    }
    double minv = INFTY;
    rep(i, n) minv = min(minv, T[(1<<n)-1][i]);
    if ( minv > W ) cout << "NA" << endl;
    else cout << "OK" << endl;
}

main(){
    string line;
    int l;
    while( getline(cin, line) && !cin.eof() ){
	stringstream sin(line);
	n = 0;
	sin >> W; 
	while( sin >> l ) L[n++] = l;
	compute();
    }
}

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

#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define pll         pair<long,long>
#define vi          vector<int>
#define vll         vector<ll>
#define vii         vector<pii>
#define vpll        vector<pair<ll,ll>>
#define Mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define mod        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
#define rem(i,a,b)  for(int i=a;i>b;i--)
#define mp(a,b)     make_pair(a,b)
#define vvi(a,b,name)    vector<vector<int>> name(a,vector<int>(b,-1))


void solve(){
    int a,b,c;cin>>a>>b>>c;
    if(a+b+c>=22)cout<<"bust";
    else cout<<"win";


}
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    long t=1;
    //cin>>t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<string>
#include<iostream>
using namespace std;
struct Node{
  int key;
  Node *right,*left,*parent;
};
Node *root,*NIL;
void insert(int k){
  Node *y=NIL;
  Node *x=root;
  Node *z;
  z = (Node *)malloc(sizeof(Node));
  z->key=k;
  z->left=NIL;
  z->right=NIL;
  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else{
    if(z->key<y->key){
      y->left=z;
    }else{
      y->right=z;
    }
  }
}
void inorder(Node *u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node *u){
  if(u==NIL) return;
  printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
int main(){
  int n,i,x;
  string com;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    cin>>com;
    if(com=="insert"){
      scanf("%d",&x);
      insert(x);
    }
    else if(com=="print"){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
      



Measured memory_bytes: 26720
import sys
from collections import deque
input = sys.stdin.readline

N = int(input())
p = list(map(int, input().split()))
counter = 0

for i in range(N):
    if p[i] != i+1:
        counter += 1

if counter == 2 or counter == 0:
    print('YES')
else:
    print('NO')

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

const int INF = 1 << 27;
const int MAX_N = 1001;
const int MAX_W = 1001;
// ???????????????
int v[MAX_N], a[MAX_N];
int dp[MAX_N][MAX_W];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int w, n;
	int cnt = 1;
	while(cin >> w && w != 0){
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		char c;
		cin >> v[i] >> c >> a[i];
	}
	
	for(int i = 0; i < n; ++i){
		for(int j = 0; j <= w; ++j){
			if(j < a[i])
				dp[i + 1][j] = dp[i][j];
			else
				dp[i + 1][j] = max(dp[i][j], dp[i][j - a[i]] + v[i]);
		}
	}
	
	int m = INF;
	for(int i = 0; i < n; ++i){
		for(int j = 0; j <= w; ++j){
			if(dp[i + 1][j] == dp[n][w]){
				m = min(m, j);
			}
		}
	}
	
	cout << "Case " << cnt << ":" << endl;
	cout << dp[n][w] << endl;
	cout << m << endl;
	cnt++;
	}
}

Measured memory_bytes: 5116
s=input()

#＋を入れられる数
n=len(s)-1
ans=0
for i in range(2**n):
    f=s[0]
    for j in range(n):

        if (i>>j)&1:
            f+='+'
        f+=s[j+1]

    ans+=sum(map(int,f.split('+')))
print(ans)

Measured memory_bytes: 3060
//Bokan ga bokka--nn!!
//Daily Lunch Special Tanoshii !!
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
typedef long long ll;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
#define s(x) scanf("%d",&x)
#define rep(i,x) for(int i=0;i<x;i++)
#define geta 200000
vector<int>za[400005];
vector<int>all;
int main()
{
	int n;
	scanf("%d",&n);
	P p[100005];
	int xmi=INF,xma=-INF,ymi=INF,yma=-INF;
	for(int i=0;i<n;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		p[i]=mp(x+y,x-y);
		xmi=min(xmi,x+y);
		xma=max(xma,x+y);
		ymi=min(ymi,x-y);
		yma=max(yma,x-y);
	}
	if(xma-xmi<yma-ymi)
	{
		for(int i=0;i<n;i++)swap(p[i].first,p[i].second);
		swap(xma,yma);
		swap(xmi,ymi);
	}
	for(int i=0;i<n;i++)
	{
		za[p[i].second+geta].pb(p[i].first);
		all.pb(p[i].first);
	}
	sort(all.begin(),all.end());
	for(int  i=0;i<400005;i++) sort(za[i].begin(),za[i].end());
	int lb=0;
	int ub=xma-xmi;
	int ano=yma-ymi;
	while(ub-lb>1)
	{
		int mid=(lb+ub)>>1;
		if(mid>=ano)
		{
			int d=upper_bound(all.begin(),all.end(),all[0]+mid)-all.begin();
			if(d==all.size() || all[all.size()-1]-all[d]<=mid) ub=mid;
			else lb=mid;
		}
		else
		{
			for(int i=yma+geta;i>ymi+mid+geta;i--)
			{
				if(za[i].empty())  continue;
				if(za[i][za[i].size()-1]>xmi+mid) goto next;
			}
			for(int i=ymi+geta;i<yma-mid+geta;i++)
			{
				if(za[i].empty())  continue;
				if(za[i][0]<xma-mid) goto next;
			}
			for(int i=yma-mid+geta;i<=ymi+mid+geta;i++)
			{
				if(za[i].empty())  continue;
				int d=upper_bound(za[i].begin(),za[i].end(),xmi+mid)-za[i].begin();
				int e=lower_bound(za[i].begin(),za[i].end(),xma-mid)-za[i].begin();
				if(d<e) goto next;
			}
			ub=mid;
			continue;
			next:;
			for(int i=yma+geta;i>ymi+mid+geta;i--)
			{
				if(za[i].empty())  continue;
				if(za[i][0]<xma-mid) goto next2;
			}
			for(int i=ymi+geta;i<yma-mid+geta;i++)
			{
				if(za[i].empty())  continue;
				if(za[i][za[i].size()-1]>xmi+mid) goto next2;
			}
			for(int i=yma-mid+geta;i<=ymi+mid+geta;i++)
			{
				if(za[i].empty())  continue;
				int d=upper_bound(za[i].begin(),za[i].end(),xmi+mid)-za[i].begin();
				int e=lower_bound(za[i].begin(),za[i].end(),xma-mid)-za[i].begin();
				if(d<e) goto next2;
			}
			ub=mid;
			continue;
			next2:;
			lb=mid;
		}
	}
	printf("%d\n",ub);
}

Measured memory_bytes: 14192
#include<stdio.h>
#include<string.h>
 
int main(void)
{
    int N;
  	int M;
  	int count=0;
  	int i=0;
    // 整数の入力
    scanf("%d %d\n",&N,&M);
  	if(N==M)
      printf("Yes\n");
	else
      printf("No\n");
    return 0;
}

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

ans = []
r = n
if n % 2 == 0:
  r = n+1
      
for i in range(n):
  for j in range(i+1,n):
    if i+j+2 == r:
      continue
    ans.append([i+1,j+1])
      
print(len(ans))
for a in ans:
  print(*a)

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

string s;
int a[11234586];
int dp[2][1123456];


int main(){
    ios_base::sync_with_stdio(0);
    //freopen("input.txt","r",stdin);

    cin>>s;
    int n = s.size();
    for(int i=n-1;i>=0;i--){
        a[n-i-1] = s[i] - '0';
    }
    dp[0][0] = a[0];
    dp[1][0] = 10-a[0];
    for(int i=1;i<=n;i++){
        dp[0][i] = a[i] + min(dp[0][i-1],dp[1][i-1]+1);
        dp[1][i] = 10-a[i] + min(dp[0][i-1],dp[1][i-1]-1);
    }
    cout << dp[0][n];
}


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

const int M = 5e5 + 10;
const int MD = 1e9 + 7;
int n, m;
int f[M], rf[M];

int C(int n, int k) {
    if (k < 0 || k > n) return 0;
    return 1ll * f[n] * rf[n - k] % MD * rf[k] % MD;
}

int main() {
    f[0] = 1;
    for (int i = 1; i < M; i++) f[i] = 1ll * f[i - 1] * i % MD;
    rf[M - 1] = 266864782;
    for (int i = M - 2; i >= 0; i--) rf[i] = 1ll * rf[i + 1] * (i + 1) % MD;
    while (scanf("%d %d", &n, &m) == 2) {
        int res = 1ll * C(m, n) * f[n] % MD % MD;

        int c = 0;
        for (int k = 0; k <= n; k++) c = (c + (k & 1 ? MD - 1 : 1ll) * C(m - k, n - k) % MD * C(n, k) % MD * f[n - k] % MD) % MD;
        res = 1ll * res * c % MD;
        printf("%d\n", res);
    }
}


Measured memory_bytes: 7744
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<queue>
using namespace std;
typedef long long LL;
int n,m;
LL a[100000+10];
int par[100000+10];
priority_queue<LL> mini[100000+10];

int fpar(int x){
	if (par[x]==-1)return x;
	par[x]=fpar(par[x]);
	return par[x];
}
priority_queue <LL > pq1;
LL ans=0;
int main(){
	scanf("%d%d",&n,&m);
	for (int f1=0;f1<n;f1++)scanf("%lld",&a[f1]);
	for (int f1=0;f1<n;f1++){par[f1]=-1;}
	for (int f1=0;f1<m;f1++){
		int i,j;
		scanf("%d%d",&i,&j);
		i=fpar(i);
		j=fpar(j);
		par[j]=i;
	}
	for (int f1=0;f1<n;f1++){
		int j=fpar(f1);
		mini[j].push(-a[f1]);
	}
	if (n==1+m){
		printf("0\n");
		return 0;
	}
	for (int f1=0;f1<n;f1++){
		if (par[f1]==-1){
			ans-=mini[f1].top();
			mini[f1].pop();
			while (!mini[f1].empty()){
				pq1.push(mini[f1].top());
				mini[f1].pop();
			}	
		}
	}
	
	if (int(pq1.size())>=n-m-2){
		for (int f1=1;f1<=n-m-2;f1++){
			ans-=pq1.top();
			pq1.pop();
		}
		printf("%lld\n",ans);
	} else printf("Impossible\n");
}
//

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

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ll long long
using namespace std;


int main() {
  int x, y;
  cin >> x >> y;
  rep (i, x + 1) {
    if (2 * i + 4 * (x - i) == y) {
      cout << "Yes" << endl;
      // cout << i << " " << x - i << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


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

using namespace std;

#define ff first
#define ss second

typedef long long ll;
typedef long double ld;
typedef pair<int, int> pi;

const int MOD = 1e9 + 7;
const ll INF = 1e18;
const double EPS = 1e-6;
const int MAX_N = 1e5 + 5;

int N;
int h[MAX_N], dp[MAX_N];

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> N;
	for (int i = 0; i < N; ++i) {
		cin >> h[i];
	}

	for (int i = 0; i < N; ++i) {
		if (i != 0) dp[i] = (1 << 29);
		if (i - 1 >= 0) dp[i] = min(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i - 2 >= 0) dp[i] = min(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
	}

	cout << dp[N - 1] << '\n';

	return 0;
}

Measured memory_bytes: 1024
#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() {
    int n, d;
    cin >> n >> d;
    cout << (n+(2*d+1)-1)/(2*d+1) << endl;

    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define int long long

using namespace std;


signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n, a, b;
    cin >> a >> b >> n;
    cin >> n >> a >> b;
    cout << a * min(b - 1, n) / b;
    return 0;
}


Measured memory_bytes: 3600
// 基本テンプレート

#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

signed main() {
    int digit = -1;
    rep(i,0,12) {
        int val = 1;
        rep(j,0,i) val *= 10;
        printf("? %lld\n", val);
        fflush(stdout);
        char c; cin >> c;
        if(c == 'N') {
            digit = i-1;
            break;
        }
    }

    if(digit == -1) {
        rep(i,0,12) {
            int val = 2;
            rep(j,0,i) val *= 10;
            printf("? %lld\n", val);
            fflush(stdout);
            char c; cin >> c;
            if(c == 'Y') {
                digit = i;
                break;
            }
        }
        int ans = 1;
        rep(i,0,digit) ans *= 10;
        printf("! %lld\n", ans);
        return 0;
    }

    int ub = 1, lb = 1;
    rep(i,0,digit) lb *= 10;
    rep(i,0,digit+1) ub *= 10;
    ub--;
    while(ub - lb > 1) {
        int mid = (ub + lb) / 2;
        printf("? %lld\n", mid*10);
        fflush(stdout);
        char c; cin >> c;
        if(c == 'Y') ub = mid;
        else lb = mid;
    }
    printf("! %lld\n", ub);
    fflush(stdout);
    return 0;
}

Measured memory_bytes: 596
"""
    Template written to be used by Python Programmers.
    Use at your own risk!!!!
    Owned by enraged(rating - 5 star at CodeChef and Specialist at Codeforces).
"""
import sys
import bisect
import heapq
from math import *
from collections import defaultdict as dd  # defaultdict(<datatype>) Free of KeyError.
from collections import deque  # deque(list) append(), appendleft(), pop(), popleft() - O(1)
from collections import Counter as c  # Counter(list)  return a dict with {key: count}
from itertools import combinations as comb
from bisect import bisect_left as bl, bisect_right as br, bisect
# sys.setrecursionlimit(2*pow(10, 6))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = pow(10, 9) + 7
mod2 = 998244353
def data(): return sys.stdin.readline().strip()


def out(var): sys.stdout.write(var)


def l(): return list(map(int, data().split()))


def sl(): return list(map(str, data().split()))


def sp(): return map(int, data().split())


def ssp(): return map(str, data().split())


def l1d(n, val=0): return [val for i in range(n)]


def l2d(n, m, val=0): return [[val for i in range(n)] for j in range(m)]


s = data()
s = sorted(s)
if s[0] == s[2]:
    out("No")
    exit()
out("Yes")


Measured memory_bytes: 38256
#include "bits/stdc++.h"
using namespace std;

#define ASC(vec) vec.begin(), vec.end()    // 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend() // 降順ソート 例：sort(DESC(vec));
#define rep(i, n) for (int i = 0; i < (n); i++)
#define Rep(i, n) for (int i = 1; i < n; i++)
#define REP(i, vec) for (auto i = vec.begin(); i != vec.end(); ++i)

const int       mod = 1000000007;
const int       inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T>
inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T>
inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T>
T GCD(T a, T b) {
	if (b == 0) return a;
	else return GCD(b, a % b);
}
template<class T>
T LCM(T a, T b) {
	return a / GCD(a, b) * b;
}
template<class T>
inline T upper(T a, T b) {return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	int sz = s.size(), tz = t.size();

	rep(i, min(sz, tz)) {
		cout << s[i] << t[i];
	}

	if (sz > tz) cout << s.back();
	else if (sz < tz) cout << t.back();
	cout << endl;
}

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

using namespace std;

int main() {
	int k; cin >> k;
	queue<long long> q;
	for (int i = 1; i <= 9; ++i) q.push(i);
	int cnt = 0;
	while (true) {
		++cnt;
		long long t = q.front(); q.pop();
		if (cnt == k) {
			cout << t << endl;
			break;
		}
		for (int i = -1; i < 2; ++i) {
			int d = t % 10 + i;
			if (0 <= d && d <= 9) q.push(t * 10 + d);
		}
	}

	return 0;
}

Measured memory_bytes: 1792
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ld long double
#define al(a) (a).begin(),(a).end()
#define mk make_pair
#define check cout<<"?"<<endl;

ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;

int main() {
    int n,m; cin>>n>>m;
    set<int> e;
    vector<int> c(n,1);
    e.insert(0);
    rep(i,m){
        int x,y; cin>>x>>y;
        x--; y--;
        if(e.count(x)) e.insert(y);
        c[x]--; c[y]++;
        if(c[x]==0) e.erase(x);
    }
    cout<<e.size()<<endl;
}

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

int A[100005];

bool cmp(int a, int b)
{
    return abs(a) < abs(b);
}

int main() {
    
    ios::sync_with_stdio(0);
    cin.tie(NULL), cout.tie(NULL);

    int N;
    cin >> N;

    for(int i=1; i<=N; i++)
        cin >> A[i];

    sort(A+1, A+1+N, cmp);

    int neg = 0;
    long long ans = 0;

    for(int i=1; i<=N; i++)
        neg += (A[i] < 0);

    ans += (neg % 2 ? - abs(A[1]) : abs(A[1]));

    for(int i=2; i<=N; i++)
        ans += abs(A[i]);

    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 640
import java.io.File;
import java.io.FileInputStream;
import java.util.Scanner;
import java.util.Map.Entry;
import java.util.function.DoubleToLongFunction;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.Comparator;
import java.util.Deque;
import java.util.HashMap;
import java.util.List;
import java.util.NoSuchElementException;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int K = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();
		int ans = ((N >= K) ? K : N) * X + (((N >= K) ? N-K : 0)) * Y;
		System.out.println(ans);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}

Measured memory_bytes: 22100
#[allow(dead_code)]
fn main() {
    let (n, m) = i::u2();
    let mut d = HashSet::new();
    let mut l = 1;
    while l * l <= m {
        if m % l == 0 {
            d.insert(m / l);
            d.insert(l);
        }
        l += 1;
    }
    let mut ans = 1;
    for d_i in d {
        if m / d_i >= n {
            ans = max(ans, d_i);
        }
    }
    println!("{}", ans);
}

#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::num::*;
#[allow(unused_imports)]
use std::str::*;

#[allow(dead_code)]
mod i {
    use super::*;

    pub fn read<T: FromStr>() -> T {
        stdin()
            .bytes()
            .map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>()
            .parse::<T>()
            .ok()
            .unwrap()
    }

    pub fn str() -> String {
        read()
    }

    pub fn s() -> Vec<char> {
        str().chars().collect()
    }

    pub fn i() -> i64 {
        read()
    }

    pub fn u() -> usize {
        read()
    }

    pub fn u2() -> (usize, usize) {
        (read(), read())
    }

    pub fn u3() -> (usize, usize, usize) {
        (read(), read(), read())
    }

    pub fn f() -> f64 {
        read()
    }

    pub fn c() -> char {
        read::<String>().pop().unwrap()
    }

    pub fn iv(n: usize) -> Vec<i64> {
        (0..n).map(|_| i()).collect()
    }

    pub fn iv2(n: usize) -> Vec<(i64, i64)> {
        (0..n).map(|_| iv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv(n: usize) -> Vec<usize> {
        (0..n).map(|_| u()).collect()
    }

    pub fn uv2(n: usize) -> Vec<(usize, usize)> {
        (0..n).map(|_| uv(2)).map(|a| (a[0], a[1])).collect()
    }

    pub fn uv3(n: usize) -> Vec<(usize, usize, usize)> {
        (0..n).map(|_| uv(3)).map(|a| (a[0], a[1], a[2])).collect()
    }

    pub fn fv(n: usize) -> Vec<f64> {
        (0..n).map(|_| f()).collect()
    }

    pub fn cmap(h: usize) -> Vec<Vec<char>> {
        (0..h).map(|_| s()).collect()
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using p = pair<int,int>;
const long long INF = 1ll << 60;



int main() {

  int N, M, C; cin >> N >> M >> C;
  int B[M];
  rep(i,M) cin >> B[i];
  int A[N][M];
  rep(i,N)rep(j,M) cin >> A[i][j];

  int ans = 0;

  rep(i,N){
    ll sum = 0;
    rep(j,M) {
    sum += A[i][j] * B[j];
    }
    if(sum + C > 0) ans++;
  }
  cout << ans << endl;
	return 0;
}



Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
typedef long long LL;
int main() {
	int n = 0, m = 0, ans = 0, sum = 0;
	std::string s[100], t[100];
	std::cin >> n;
	for (int i = 0; i < n; i++) { std::cin >> s[i]; }
	std::cin >> m;
	for (int i = 0; i < m; i++) { std::cin >> t[i]; }
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			if (s[i] == s[j]) { sum++; }
		}
		for (int j = 0; j < m; j++) {
			if (s[i] == t[j]) { sum--; }
		}
		ans = std::max(ans, sum);
		sum = 0;
	}
	std::cout << ans << std::endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


n, k = list(map(int, input().split()))
x = list(map(int, input().split()))

k -= x.count(0)

if k <= 0:
  print(0)
  exit()

n = [0]
for e in reversed(x):
  if e < 0:
    n.append(-e)

p = [0]
for e in x:
  if e > 0:
    p.append(e)


dprint(n, p)

anses = []

for i in range(k + 1):
  j = k - i
  if 0 <= i < len(p) and 0 <= j < len(n):
    anses.append(p[i] * 2 + n[j])
    anses.append(p[i] + n[j] * 2)

dprint(anses)

print(min(anses))


Measured memory_bytes: 14172
a,b,c,x,y = map(int, input().split())
if a > 2*c:
    a = 2*c
if b > 2*c:
    b = 2*c
xy = min(x, y)
x -= xy
y -= xy
print(min(c*xy*2 + a * x + b * y, (xy + x) * a + (xy + y) * b))

Measured memory_bytes: 3060
n,*a=map(int,open(0).read().split())
a.sort()
b=a.pop()
dif=float("inf")
ans=0
for i in range(n-1):
    if abs(a[i]-b/2)<dif:
        ans=a[i]
        dif=abs(a[i]-b/2)
print(b,ans)

Measured memory_bytes: 14028
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoderProject
{
    public static class Program
    {
        public static void Main()
        {
            var today = Console.ReadLine();
            string tommorow = "";
            switch (today)
            {
                case "Sunny":
                    tommorow = "Cloudy";
                    break;
                case "Cloudy":
                    tommorow = "Rainy";
                    break;
                case "Rainy":
                    tommorow = "Sunny";
                    break;
            }

            Console.WriteLine(tommorow);
        }

        private static List<int> ReadArgsAsInt()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => int.Parse(x)).ToList();
        }

        private static List<long> ReadArgsAsLong()
        {
            var str = Console.ReadLine().Split(' ');
            return str.Select(x => long.Parse(x)).ToList();
        }
    }
}


Measured memory_bytes: 11092
#include<iostream>

using namespace std;

int main(){
  int w,h;

  while(true){
    cin >> w >> h;

    if((w==0) && (h==0))
      break;

    for(int i=0;i<w;i++){
      for(int j=0;j<h;j++){
	cout << '#';
      }
      cout << endl;
    }
    cout << endl;
  }
}

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
 
int main(){
	int N = 0;
	char op;
	for(int i = 0; i < 4; i++){
  		cin >> op;
  		if(op == '+'){
  			N++;	
  		}
  		else if(op == '-'){
  			N--;
  		}
	}
  	cout << N << endl;
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto a=scanElem;
  auto b=scanElem;
  auto c=scanElem;
  if(b-a==c-b)end("YES");end("NO");
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.array;
void main()
{
	auto param = readln.chomp.split(' ').map!(to!long).array;
    long W = param[0];
    long H = param[1];
    long N = param[2];
    long left = 0;
    long right = W;
    long top = H;
    long bottom = 0;
    foreach(i;0 .. N)
    {
        auto cmd = readln.chomp.split(' ').map!(to!long).array;
        switch(cmd[2])
        {
            case 1:
                left = max(cmd[0],left);
                break;
            case 2:
                right = min(cmd[0],right);
                break;
            case 3:
                bottom = max(cmd[1],bottom);
                break;
            case 4:
                top = min(cmd[1],top);
                break;
            default:
                assert(0);
        }
    }
    bool isZero = (right < left) || (top < bottom);
    if (isZero)
    {
        writeln(0);
        return;
    }
    long S = (right - left) * (top - bottom);
    writeln(S);
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String N = s.next();
        char[] chars = N.toCharArray();
        int n = 0;
        for (char aChar : chars) n += (aChar - 48);
        if (n % 9 == 0) System.out.println("Yes");
        else System.out.println("No");
    }
}

Measured memory_bytes: 40580
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const ll INF = 1001001001;
const ll LINF = 1001001001001001001;

void prvec(vector<ll> vec){
    ll n = vec.size();
    rep(i,n) cout << i << " " << vec.at(i) << "\n";
}

void pr2d(vector<vector<ll>> vvec){
    ll h = vvec.size();
    ll w = vvec.at(0).size();
    rep(i,h){
        rep(j,w){
            cout << vvec.at(i).at(j) << " ";
        }
        cout << "\n";
    }
}

int main(){
    ll n , d; cin >> n >> d;
    ll cnt = 0;
    rep(i,n){
        ll x,y; cin >> x >> y;
        if(x*x + y*y <= d*d) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3592
S = input()

if S == 'SUN':
    print(7)

elif S == 'MON':
    print(6)

elif S =='TUE':
    print(5)

elif S =='WED':
    print(4)

elif S =='THU':
    print(3)

elif S =='FRI':
    print(2)

elif S =='SAT':
    print(1)

Measured memory_bytes: 9112
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>

using namespace std;

struct Pair{
  long long score;
  int index;
  Pair(long long s, int i){
    score = s;
    index = i;
  }
  bool operator<(const Pair &another) const{
    return score < another.score;
  };
};
int main (){
  int n; 
  cin >> n;
  long long a[n], b[n];
  vector<Pair> pairs;
  long long bufa, bufb;
  for(int i = 0; i < n ; i++){
    cin >> bufa >> bufb;
    a[i] = bufa;
    b[i] = bufb;
    pairs.push_back(Pair(bufa+bufb, i));
  }
  sort(pairs.begin(), pairs.end());

  long long answer = 0;
  for(int i = 0; i < n; i++){
    int ind = pairs[n - i - 1].index;
    if(i%2==0){
      answer += a[ind];
    } else {
      answer -= b[ind];
    }
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3444
package main

import (
  "fmt"
)

func main() {
  var n int
  fmt.Scan(&n)
  cards := make([]int, n)
  for i := 0; i < n; i++ {
    fmt.Scan(&cards[i])
  }
  var list []int
  for _, v := range cards {
    count := 0
    for _, w := range list {
      if v == w {
        count++
      }
    }
    if count == 0 {
      list = append(list, v)
    }
  }
  fmt.Println(len(list))
}

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

using namespace std;
typedef long long ll;

int main(){
ll N; scanf("%lld", &N);
vector<pair<ll,ll>> a(N); 
for(ll i = 0; i < N; i++){ scanf("%lld", &a[i].first); a[i].second = i+1;}

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

set<ll> se;

se.insert(0); se.insert(N+1);

ll ans = 0;

for(ll i = 0; i < N; i++){
 ll r = a[i].second; 
 se.insert(r);
 auto itr = se.lower_bound(r);
 auto itr1 = itr; auto itr2 = itr;
 
 itr1--; itr2++;
 
 ll res = (r-*itr1)*(*itr2-r);
 ans += res*a[i].first;
 
 }
 
 printf("%lld\n", ans);
 
 return 0;
 }



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

int main() {
  int a, b, X;
  cin >> a >> b;
  X = a*b;
  
  if (X % 2 == 0) {
    cout << "Even" << endl;
  }
  
  if (X % 2 == 1) {
    cout << "Odd" << endl;
  }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

const string YES = "Yes";
const string NO = "No";

int turn(int a, int h) {
    return (h + a - 1) / a;
}

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    if (turn(b, c) <= turn(d, a)) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


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

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

    if(m <= n) swap(n,m);

    if(n == 1 && m == 1) cout << 1 << endl;
    else if(n == 1 && m != 1) cout << m - 2 << endl;
    else cout << (n - 2) * (m - 2) << endl;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (a <= b && b <= c) cout <<a << " " <<b << " " <<c << endl;
    else if (a <= c && c <= b) cout <<a << " " <<c << " " <<b << endl;
    else if (b <= a && a <= c) cout <<b << " " <<a << " " <<c << endl;
    else if (b <= c && c <= a) cout <<b << " " <<c << " " <<a << endl;
    else if (c <= a && a <= b) cout <<c << " " <<a << " " <<b << endl;
    else if (c <= b && b <= a) cout <<c << " " <<b << " " <<a << endl;
    
    
}


Measured memory_bytes: 3116
#include<stdio.h>

int main(){
  int A[100];
  int number,key,i,j,k;

  scanf("%d", &number);
  for(i = 0 ; i < number ; i ++){
    scanf("%d", &A[i]);
  }
  
  for( i = 0 ; i < number ; i ++){
    key = A[i];
    j = i-1;
    while(j >= 0 && A[j] > key){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = key;
    
    for(k = 0 ; k < number ; k++){
      printf("%d", A[k]);
      if( k == number-1){
	printf("\n");
	break;
      }
      printf(" ");
    }
  }
  return 0;
}

Measured memory_bytes: 2728
#include<stdio.h>
#define int long long
int n,i,j,d[2010][2010]={0};
int MAX(int a,int b){return a<b?b:a;}
int pr(int i){return (i+n-1)%n;}
int nx(int i){return (i  +1)%n;}
signed main(){
  scanf("%lld",&n);
  for(i=0;i<2010*2010;i++)d[i/2010][i%2010]=-1000000000;
  for(i=0;i<n;i++)scanf("%lld",&d[1][i]);
  for(i=1;i<n;i++){
    for(j=0;j<n;j++){
      if(i%2){
	if(d[1][pr(j)]>d[1][nx(i+j-1)])d[i+1][pr(j)]=MAX(d[i+1][pr(j)],d[i][j]);
	else d[i+1][j]=MAX(d[i+1][j],d[i][j]);
      }
      else d[i+1][j]=MAX(d[i][j]+d[1][nx(i+j-1)],d[i][nx(j)]+d[1][j]);
    }
  }
  for(i=j=0;i<n;i++)j=MAX(j,d[n][i]);
  printf("%lld\n",j);
  return 0;
}

Measured memory_bytes: 32156
#include<iostream>

#include <vector>
#include <list>
#include<stack>
#include<queue>
#include<array>

#include <set>
#include<map>

#include<string>
#include<stdlib.h>
#include<memory>

#include<algorithm>
#include <functional>
#include<math.h>

#include<fstream>
#include<iomanip>

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7
constexpr ll ALLt = (1ll << 24);

//変数
ll N;
vector<ll> D;





//サブ関数
//入力
void input()
{
	cin >> N;
	D.resize(N);
	REP(i, N)cin >> D[i];
}

bool duplicate(ll num)
{
	int res = 0;
	while(num > 0)
	{
		res += num&1;
		num>>=1;
	}
	return res!=N+1;
}

array<bool, ALLt> make_all(vector<ll> D)
{
	array<bool, ALLt> res;
	REP(i, ALLt)res[i] = false;
	ll siz = D.size();
	REP(i, (1 << siz))
	{
		ll tmp = 1;
		REP(j, siz)
		{
			bool isBef = ((i >> j) & 1) == 1;
			ll hour = isBef ? D[j] : 24 - D[j];
			hour%=24;
			ll flag = (1 << hour);
			if((flag&tmp)==1)goto stop;
			tmp|=flag;
		}
		res[tmp] = true;
		stop:;
	}
	return res;
}

ll judge(ll num)
{
	if(duplicate(num))return 0;
	//REP(i,24) cerr<<(num>>i&1)<<" ";
	//cerr<<endl<<endl;
	ll res = 24;
	REP(i, 24)FOR(j, i + 1, 24) if(((num >> i) & 1) && ((num >> j) & 1))
		res = min((ll)res, min(j - i, 24 - (j - i)));
	return res;
}

//計算
void calc()
{
	if(N >= 24)
	{
		cout << 0 << endl;
		return;
	}

	auto allp = make_all(D);

	ll res = 0;
	REP(i, ALLt) if(allp[i]) res = max(res, judge(i));
	cout << res << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin >> N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();

	return 0;
}


Measured memory_bytes: 16640
import java.util.*

fun main(args:Array<String>){
    val (n,m) = readLine()!!.split(" ").map{it.toInt()}
    var s = Array(m) {ArrayList<Int>()}
    for(i in 0 until m){
        val k = readLine()!!.split(" ").map{it.toInt()}
        for(j in 1 .. k[0]) s[i].add(k[j])
    }
    val p = readLine()!!.split(" ").map{it.toInt()}
    var ans = 0
    for(mask in 0 until (1 shl n)){
        var ok = true
        for(i in 0 until m){
            var cnt = 0
            for(j in 0 until s[i].size){
                if(((mask shr (s[i][j] - 1)) and 1) == 1){
                    cnt++
                }
            }
            if(cnt % 2 != p[i]) ok = false
        }
        if(ok) ans++
    }
    println(ans)
}


Measured memory_bytes: 38192
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
typedef pair<int, int> pii;
main(){
	int i,n,m;
	while(cin >> n >> m){
		vector<pii> d(n);
		for(i=0;i<n;i++) cin >> d[i].first >> d[i].second;
		sort(d.begin(), d.end());
		for(i=0;i<m;i++){
			int x1,y1,x2,y2,ans=0;
			cin >> x1 >> y1 >> x2 >> y2;
			vector<pii>::iterator itr1 = lower_bound(d.begin(), d.end(), pii(x1, y1));
       		vector<pii>::iterator itr2 = upper_bound(d.begin(), d.end(), pii(x2, y2));
       		for(;itr1!=itr2;++itr1) if(y1 <= (*itr1).second && (*itr1).second <= y2) ans ++;
			cout << ans << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1240
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstdio>
#include<ctype.h>
#include<stdio.h>
#include<set>
#include<map>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<numeric>
#include<string>
typedef long long ll;
using namespace std;

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N; cin >> N;
	ll a[N+100];
	for (ll i = 0; i <N; i++)
		cin >> a[i];
	map<ll, ll>mp;
	for (ll i = 0; i <N; i++) {
		mp[a[i]]++;
	}
	ll x = 0;
	for (ll i = 0; i<100000-2; i++) {
		x=max(x, (mp[i]+mp[i+1]+mp[i+2]));
		}
	cout << x << endl;
	}
 

Measured memory_bytes: 7296
#include <algorithm>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    ll k;
    cin >> k;
    ll x;
    cin >> x;
    if(k * 500 >= x){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
s=list(input())
t=list(input())
s_res = sorted(set(s), key=s.index)
t_res = sorted(set(t), key=t.index)
sl = [s.count(e) for e in s_res]
tl = [t.count(e) for e in t_res]
if sl==tl:
    print('Yes')
else:
    print('No')

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

int a[20005];
int b[20005];


int main()
{

    int n;
    cin >> n;

    for (int i = 1; i <= n; i++)
    {
        a[i] = i*n;
        b[i] = (n-i)*n;
    }

    for (int i = 1; i <= n; i++)
    {
        int p;
        cin >> p;
        b[p] += i;
    }

    for (int i = 1; i <= n; i++)
        cout << a[i] << " ";
    cout << endl;
    for (int i = 1; i <= n; i++)
        cout << b[i] << " ";

    return 0;
}


Measured memory_bytes: 768
#include <stdio.h>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <math.h>
#include <map>
using namespace std;

int main()
{
    long long int n, h, ct = 0;
    vector<long long int> a, b;

    cin >> n >> h;

    for (int i = 0; i < n; i++)
    {
        long long int tmp1, tmp2;
        cin >> tmp1 >> tmp2;
        a.push_back(tmp1);
        b.push_back(tmp2);
    }

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

    while (h > 0 && ct < n && a[0] < b[ct])
    {
        h -= b[ct];
        ct++;
    }

    if (h > 0)
    {
        ct += (h + (a[0] - 1)) / a[0];
    }

    cout << ct;
    return 0;
}


Measured memory_bytes: 2036
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        int count=0;
        int max = 0;
        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);
            switch(c){
                case 'A':count++;max = Math.max(max,count); break;
                case 'C':count++;max = Math.max(max,count); break;
                case 'G':count++;max = Math.max(max,count); break;
                case 'T':count++;max = Math.max(max,count); break;
                default:count=0;break;
            }
        }

        System.out.println(max);

    }
}

Measured memory_bytes: 23636
b = list(map(int, input().split()))
n = b[0]
m = b[1]
a = list(map(int, input().split()))
sum = sum(a)
a = sorted(a, reverse=True)

if a[m - 1] < (1 / (4 * m)) * sum:
    print("No")
else:
    print("Yes")

Measured memory_bytes: 3060
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <queue>
#include <queue>
#include <stack> 
#include <sstream>
#include <set>

typedef  long long ll;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};
const int dr[4] = {-1, 0, 1, 0};
const int dc[4] = { 0, 1, 0,-1};
const int INF = 1e9;
#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
int guki (int a){
    if(a%2==0) return 0;
    else return 1;
}
int gcd(int a, int b){
    if(a%b==0){
        return b;
    }else{
        return (gcd(b,a%b));
    }
}
int lcm(int a, int b){
    int x = gcd(a,b);
    return (a*b/x);
}

using namespace std;
ll k (ll a){
    a--;
    ll ans =0;
    while(a != 0){
        ans += a;
        a--;
        
    }
    return ans;
}


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

    FOR(i,1,10){
        if(n%i==0 && (n/i) < 10){
            cout <<"Yes"<<endl;
            return 0;
        }
    }
    cout << "No"<<endl;
}



Measured memory_bytes: 256
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine().trim.toInt
  val a = StdIn.readLine().trim.split(' ').map(_.toInt)

  val last = a(n - 1)

  @inline private def swap(from: Int, to: Int): Unit = {
    //println(s"from: $from  to: $to")
    val temp = a(from)
    a(from) = a(to)
    a(to)   = temp
  }
  
  def partition(arr: Array[Int], p: Int, r: Int): Int = {
    var i = p - 1
    (p until r).foreach{ j =>
      if(arr(j) <= last){
        i += 1
        swap(i, j)
        //println(a.toList.mkString(" "))
      }
    }
    swap(i+1, r)
    //println("last:" + a.toList.mkString(" "))
    i + 1
  }
  
  val partitionIndex = partition(a, 0, n-1)
  //println(s"num: $partitionIndex")
  val a1 = new Array[Int](partitionIndex)
  Array.copy(a, 0, a1, 0, partitionIndex)
  print(a1.mkString(" ") + (if(a1.nonEmpty) " " else "" ))
  print(s"[$last]")
  val overIndex = partitionIndex + 1
  val a2 = new Array[Int](n - (overIndex))
  Array.copy(a, overIndex, a2, 0, n - (overIndex))
  println( (if(a2.nonEmpty) " " else "" ) + a2.mkString(" "))
  
  
}




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

#define what_is(x)    cerr<<#x<<" is "<<x<<"\n";
#define rep(i,a,n)    for(int i=a; i<=n; ++i)
#define rep1(i,a,n)   for(int i=a; i>=n; --i)
#define pb            push_back
#define mp            make_pair
#define int           long long
#define fr            first
#define sc            second
#define vc            vector
#define sz(v)         (int)v.size()
#define all(x)        (x).begin(),(x).end()
#define rall(x)       (x).rbegin(),(x).rend()
#define M             1000000007
#define MM            998244353
#define PI            3.14159265358979
#define INF           1000000000000000

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef map<int,int> mii;

int n,m,ans; string str;

int solve(){
    cin>>str;
    n=str.length();
    rep(i,0,n/2-1){
        if(str[i]!=str[n-i-1]) ans++;
    }
    cout<<ans;
    return 0;
}

signed main() {
    ios::sync_with_stdio(0);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t=1;
    //cin>>t;
    while(t--) solve();
    return 0;
}

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

using namespace std;

int main() {
  int n, m, c;
  cin >> n >> m >> c;
  vector<int> B(m);
  for (int i = 0; i < m; ++i) {
    cin >> B[i];
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) {
    vector<int> A(m);
    int solve = c;
    int a;
    for (int j = 0; j < m; ++j) {
      cin >> a;
      solve += a * B[j];
    }
    if (solve > 0) {
      ++ans;
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3596