akhauriyash/Code-Regression huggingface dataset:
/*
 *  Lang    : C++
 *  Author  : little_angel
 */

#include <bits/stdc++.h>

using namespace std;
#define int long long

const int mod = 1e9L + 7;

int power(int x, int y) {
    int res = 1;
    while (y) {
        if (y & 1)res = res * x % mod;
        x = x * x % mod;
        y >>= 1;
    }
    return res;
}

inline int inv(int x) {
    return power(x, mod - 2);
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    struct L {
        int a, b;

        int val(int x) const {
            return a * x + b;
        }

        pair<int, int> inter(L &l2) const {
            int num = l2.b - b;
            int den = a - l2.a;
            if (den < 0) {
                den *= -1ll;
                num *= -1ll;
            }
            return {num, den};
        }
    };

    int n, c;
    cin >> n >> c;
    vector<int> h(n);
    for (int i = 0; i < n; ++i) cin >> h[i];

    vector<L> lines;
    int start = 0;

    auto remove = [&](int x) {
        while (lines.size() - 2 >= start) {
            if (lines[start].val(x) >= lines[start + 1].val(x))start++;
            else break;
        }
    };

    auto add = [&](int a, int b) -> void {
        if (lines.empty()) {
            lines.push_back(L{a, b});
            return;
        }
        L C{a, b};
        while (lines.size() >= 2) {
            L A = lines.end()[-2];
            L B = lines.end()[-1];
            auto p1 = A.inter(B);
            auto p2 = B.inter(C);

            if (p1.first * p2.second >= p2.first * p1.second)lines.pop_back();
            else break;
        }
        lines.push_back(C);
    };

    auto get = [&](int x) -> int {
        remove(x);
        return lines[start].val(x);
    };

    vector<int> dp(n);
    add(-2 * h[0], h[0] * h[0]);
    for (int i = 1; i < n; ++i) {
        dp[i] = get(h[i]) + (c + h[i] * h[i]);
        add(-2 * h[i], h[i] * h[i] + dp[i]);
    }
    cout << dp[n - 1] << endl;
}


Measured memory_bytes: 9584
n,k,s=map(int,input().split())
if n!=k:
  if s==int(10**9)-1:
    p=s+1
  else:
    p=int(10**9)-1
  ans=[p for _ in range(n)]
  for i in range(k):
    ans[i]=s
else:
  ans=[s for _ in range(n)]
    

print(*ans)

Measured memory_bytes: 6592
import numpy as np


def solve(slots_array, K):
    MOD = 998244353
    dp = np.zeros((K+1, K+1), np.int64)
    dp[0][0] = 1
    for i in range(len(slots_array) - 1, -1, -1):
        new_dp = dp.copy()
        for j in range(K, -1, -1):
            for k in range(K-1, -1, -1):
                new_dp[j][k] += new_dp[j][k+1]
        new_dp %= MOD
        for t in range(1, slots_array[i] + 1):
            new_dp[t:, t:] += dp[:-t, :-t]
        dp = new_dp
    # print(dp)
    return np.sum(dp[:K+1, 0]) % MOD

def main():     
    S, K_str = input().split()
    K = int(K_str)

    slots = []
    index = 0
    while index < len(S):
        prev_index = index
        while index < len(S) and S[index] == '1':
            index += 1
        slots.append(index - prev_index)
        index += 1

    K = min(sum(slots) + 1, K)
    print(solve(np.array(slots, np.int64), K))


def cc_export():
    from numba.pycc import CC
    cc = CC('my_module')
    cc.export('solve', 'i8(i8[:], i8)')(solve)
    cc.compile()

if __name__ == '__main__':
    main()

Measured memory_bytes: 28160
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部定数
#define D_CHAR_CNT		26										// 文字種類数

// 内部変数
static FILE *szpFpI;											// 入力
static int siH, siW;											// 幅・高さ
static int si1CCnt[D_CHAR_CNT];									// 各文字数
static int siGrp2;												// ２文字グループ数
static int siGrp4;												// ４文字グループ数

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpA;
#endif

// グループ数 - セット
int
fSetGrp(
	int piH						// <I> 高さ
	, int piW					// <I> 幅
)
{
	// 高さが１
	if (piH == 1) {
		siGrp2 += piW / 2;		// ２文字グループ数
		return 0;
	}

	// 高さが奇数
	if (piH % 2 == 1) {
		fSetGrp(1, piW);
		piH--;
	}

	// 幅が奇数
	if (piW % 2 == 1) {
		fSetGrp(1, piH);
		piW--;
	}

	// ４文字グループ数
	siGrp4 += (piH * piW) / 4;

	return 0;
}

// 判定 - グループ単位
int
fJudgeGrp(
	int piGCnt					// <I> グループ数
	, int piDel					// <I> 減算値
)
{
	int liCNo = 0;
	while (piGCnt > 0) {
		while (1) {
			if (liCNo >= D_CHAR_CNT) {
				return -1;
			}
			if (si1CCnt[liCNo] >= piDel) {
				si1CCnt[liCNo] -= piDel;
				break;
			}
			else {
				liCNo++;
			}
		}

		piGCnt--;
	}

	return 0;
}

// 判定
int
fJudge(
)
{
	int liRet;

	// ４文字グループ数
	liRet = fJudgeGrp(siGrp4, 4);
	if (liRet != 0) {
		return -1;
	}

	// ２文字グループ数
	liRet = fJudgeGrp(siGrp2, 2);
	if (liRet != 0) {
		return -1;
	}

	return 0;
}

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i, j;
	char lc1Buf[1024], lc1Out[1024];

	// データ - 初期化
	memset(si1CCnt, 0, sizeof(si1CCnt));						// 各文字数
	siGrp2 = 0;													// ２文字グループ数
	siGrp4 = 0;													// ４文字グループ数

	// 入力 - セット
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpI = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#else
	szpFpI = stdin;
#endif

	// 幅・高さ - 取得
	fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
	sscanf(lc1Buf, "%d%d", &siH, &siW);

	// 各文字数 - 取得
	for (i = 0; i < siH; i++) {
		fgets(lc1Buf, sizeof(lc1Buf), szpFpI);
		for (j = 0; j < siW; j++) {
			si1CCnt[lc1Buf[j] - 'a']++;
		}
	}

	// グループ数 - セット
	fSetGrp(siH, siW);

	// 判定
	int liRet = fJudge();

	// 結果 - セット
	if (liRet == 0) {
		sprintf(lc1Out, "Yes\n");
	}
	else {
		sprintf(lc1Out, "No\n");
	}

	// 結果 - 表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// 残データ有無
#ifdef D_TEST
	lc1Buf[0] = '\0';
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, "")) {
		siRes = -1;
	}
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpI);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (ll i = 0;i < (a);++i)
#define FOR(i,a,b) for (ll i = (a);i < (b); ++i)
#define FORR(i,a,b) for (ll i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    ll n,k;
    cin >> n >> k;
    vector<ll>a(n);
    vector<ll>town(n+1);
    vector<ll>junban(n);
    REP(i,n){
        ll tmp;
        cin >> tmp;
        a[i] = --tmp;

        junban[i]=-1;
    }
    REP(i,n+1)town[i]=-1;

    ll now = 0;
    ll diff,offset;

    town[0] = 0;
    junban[0] = 0;

    REP(i,n){
        now = a[now];
        if(junban[now]!=-1){
            diff = (i+1)-junban[now];
            offset = junban[now];
            break;
        }else{
            junban[now] = i+1;
            town[i+1] = now;
        }
    }
    /*REP(i,n+1){
        cout << town[i] << " ";
    }
    cout << endl;*/
    if(n > k){
        now = 0;
        REP(i,k){
            now = a[now];
        }
        cout << now + 1 << endl;
    }else{
        cout << town[((k-offset)%diff)+offset]+1 << endl;
    }
    
    
    //cout << diff << " " << offset << endl;

    return 0;
}

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

using namespace std;

typedef long long ll;
int main()
{
    int n;  cin >> n;
    vector <ll> occ(1e5 + 100);
    ll sum = 0;
    for (int i = 0; i < n; i++)
    {
        ll num;    cin >> num;
        sum += num;
        occ[num]++;
    }

    int q;  cin >> q;
    while (q--)
    {
        ll a, b;   cin >> a >> b;
        if (occ[a] > 0)
        {
            sum -= (occ[a] * a);
            sum += (b * occ[a]);
            occ[b] += occ[a];
            occ[a] = 0;
        }
        cout << sum << "\n";
    }

}


// ab



// 1 2 3 4


// 1 2 3 4      =  sum: 10
// 1 1 1 1





Measured memory_bytes: 4000
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String input = sc.next();
        String[] inputArr = input.split("");

        Arrays.sort(inputArr);
        if(inputArr[0].equals(inputArr[1]) && inputArr[2].equals(inputArr[3]) && !inputArr[0].equals(inputArr[2])){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define pow(x,y) modpow(x,y)
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template <class T = int>T in(){
    T x;
    cin >> x;
    return (x);
}

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

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

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    int N = in(),C = in();
    vector<vector<int>> cost(C,vector<int>(C));
    REP(i,C){
        REP(l,C){
            cost[i][l] = in();
        }
    }
    vector<int> ze(C);
    vector<int> on(C);
    vector<int> tw(C);
    REP(i,N){
        REP(l,N){
            if((i+l)%3 == 0)ze[in()-1]++;
            if((i+l)%3 == 1)on[in()-1]++;
            if((i+l)%3 == 2)tw[in()-1]++;
        }
    }
    ll answer = INT32_MAX;
    vector<ll> zes(C);
    vector<ll> ons(C);
    vector<ll> tws(C);
    REP(i,C){
        REP(l,C){
            zes[i] += ze[l]*cost[l][i];
        }
    }
    REP(i,C){
        REP(l,C){
            ons[i] += on[l]*cost[l][i];
        }
    }
    REP(i,C){
        REP(l,C){
            tws[i] += tw[l]*cost[l][i];
        }
    }
    REP(i,C){
        REP(l,C){
            if(i == l)continue;
            REP(j,C){
                if(i == j)continue;
                if(l == j)continue;
                chmin(answer,zes[i] + ons[l] + tws[j]);
            }
        }
    }
    cout << answer << "\n";
}

Measured memory_bytes: 256
N, M = map(int, input().split())
ans = 0
if N < M:
	X = list(map(int, input().split()))
	X.sort()
	D = []
	for i in range(0, M-1):
		D.append(X[i+1]-X[i])
	D.sort()
	for i in range(0, M-N):
		ans += D[i]
print(ans)

Measured memory_bytes: 56872
a, b, c, d, e, f = map(int, input().split())
ms = 0
mt = 100
for i in range(f//(100*a) + 1):
    for j in range((f-100*i*a)//(100*b) + 1):
        for k in range((f-i*a*100 - j*b*100)//(c)+1):
            for l in range((f-i*a*100 - j*b*100-k*c)//(d)+1):
#                print(i, j, k, i*a*100 + j*b*100+c*k+d*l)
                ss, tt = c*k+d*l, i*a*100 + j*b*100+c*k+d*l
                if ss*100 > e*(tt-ss):
                    continue
                if ss*mt >= tt*ms:
                    ms, mt = ss, tt
print(mt, ms)
#        if i*a*100 + j*b*100 > f:
#            break


Measured memory_bytes: 42732
#include<stdio.h>
#include<algorithm>
using namespace std;
int n,t,DT[3010][6010];
struct dish{
	int t,w;
}A[3010];
bool cmp(dish a,dish b){
	if(a.t==b.t) return a.w<b.w;
	return a.t<b.t;
}
int max(int a,int b){
	return a>b?a:b;
}
int main(){
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++){
		scanf("%d%d",&A[i].t,&A[i].w);
	}
	sort(A+1,A+n+1,cmp);
	for(int i=1;i<=n;i++)
		for(int j=0;j<6000;j++){
			if(j<A[i].t) DT[i][j]=DT[i-1][j];
			else if(j-A[i].t>t-1) DT[i][j]=-(1LL<<31);
			else DT[i][j]=max(DT[i-1][j],DT[i-1][j-A[i].t]+A[i].w);
		}
	int ans=0;
	for(int i=0;i<6000;i++)
		if(ans<DT[n][i]) ans=DT[n][i];
	printf("%d",ans);
}

Measured memory_bytes: 70656
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b;
	cin>>a>>b;
	if(b==1)
		cout<<0<<endl;
	else
		cout<<a-b<<endl;
}

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

int main()
{
  int n, k;
  cin >> n >> k;
  int i, j;
  int p = (int)sqrt(n);
  vector<vector<long long>> dp(k+1, vector<long long>(2*p+10, 0));
  for(i = 1; i <= p; i++)dp.at(2).at(i) = n/i;
  for(i = p+1; i <= p+n/(p+1); i++)
  {
    int l = p+1+n/(p+1)-i;
    dp.at(2).at(i) = l*(n/l-n/(l+1));
  }
  long long ans = 0;
  for(i = 2; i <= k-1; i++)
  {
    vector<long long> sum(2*p+10, dp.at(i).at(1));
    for(j = 2; j <= p+n/(p+1); j++)sum.at(j) = (sum.at(j-1)+dp.at(i).at(j))%1000000007;
    for(j = 1; j <= p; j++)
    {
       int l = p+1+n/(p+1)-j;
       dp.at(i+1).at(j) = sum.at(l);
    }
    for(j = p+1; j <= p+n/(p+1); j++)
    {
      int l = p+1+n/(p+1)-j;
      dp.at(i+1).at(j) = sum.at(l)*(n/l-n/(l+1))%1000000007;
    }
  }
  for(i = 1; i <= p+n/(p+1); i++)ans = (ans+dp.at(k).at(i))%1000000007;
  cout << ans << endl;
}

Measured memory_bytes: 50832
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
using namespace std;

int main(void){
        int i,j;
        int n;
        int a[200200];

        scanf("%d",&n);
        for(i=0;i<n;i++){
                scanf("%d",&a[i]);
        }
        sort(a,a+n);
        bool b = true;
        for(i=0;i<n-1;i++){
                if(a[i]==a[i+1]){
                        b = false;
                }
        }
        if(b){
                printf("YES\n");
        } else {
                printf("NO\n");
        }
        return 0;
}



Measured memory_bytes: 896
import sys, os, math, bisect, itertools, collections, heapq, queue, copy, array

# from scipy.sparse.csgraph import csgraph_from_dense, floyd_warshall
# from decimal import Decimal
# from collections import defaultdict, deque

sys.setrecursionlimit(10000000)

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)

MOD = 10 ** 9 + 7
INF = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    L = il()

    ret = 0
    for i in range(N):
        for j in range(i, N):
            for k in range(j, N):
                if i != j and i != k and j != k and L[i] != L[j] and L[i] != L[k] and L[j] != L[k]:
                    if L[i] + L[j] > L[k] and L[j] + L[k] > L[i] and L[k] + L[i] > L[j]:
                        ret += 1
    print(ret)


if __name__ == '__main__':
    main()


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

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; }

int main(){
    int h, w;
    cin >> h >> w;
    int ch, cw, dh, dw;
    cin >> ch >> cw >> dh >> dw;
    --ch; --cw; --dh; --dw;
    vs s(h);
    rep(i, h) cin >> s[i];
    priority_queue<pair<int, pii>, vector<pair<int, pii>>, greater<pair<int, pii>>> q;
    vector<vi> dist(h, vi(w, INF));
    q.push({0, {ch, cw}});
    dist[ch][cw] = 0;
    while (!q.empty()) {
        auto p = q.top(); q.pop();
        int y = p.second.first, x = p.second.second, d = p.first;
        if (d != dist[y][x]) continue;
        const vi dy = { -1, 0, 1, 0 }, dx = { 0, 1, 0, -1 };
        rep(i, 4) {
            int ny = y + dy[i], nx = x + dx[i];
            if (ny<0||ny>=h||nx<0||nx>=w) continue;
            if (s[ny][nx] == '#') continue;
            if (dist[ny][nx] <= d) continue;
            q.push({d, {ny, nx}});
            dist[ny][nx] = d;
        }
        const vi dy2 = { -2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2 };
        const vi dx2 = { -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2 };
        rep(i, sz(dy2)) {
            int ny = y + dy2[i], nx = x + dx2[i], nd = d+1;
            if (ny<0||ny>=h||nx<0||nx>=w) continue;
            if (s[ny][nx] == '#') continue;
            if (dist[ny][nx] <= nd) continue;
            q.push({nd, {ny, nx}});
            dist[ny][nx] = nd;
        }
    }
    if (dist[dh][dw] != INF) cout << dist[dh][dw] << endl;
    else cout << -1 << endl;
    return 0;
}


Measured memory_bytes: 9520
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
template <class T>
class bit
{
public:
    vector<T> dat;
    int n;

    bit(int n) : n(n) { dat.assign(n, 0); }
    bit(int n, T ini) : n(n) { dat.assign(n, ini); }
    // sum [0,i)
    T sum(int i)
    {
        int ret = 0;
        for (--i; i >= 0; i = (i & (i + 1)) - 1)
            ret += dat[i];
        return ret;
    }
    // sum [i,j)
    T sum(int i, int j) { return sum(j) - sum(i); }
    // add x to i
    void add(int i, T x)
    {
        for (; i < n; i |= i + 1)
            dat[i] += x;
    }
};
int main()
{
    string s;
    cin >> s;
    int n = s.size();
    int cnt[30] = {};
    rep(i, s.size()) cnt[s[i] - 'a']++;
    int odd = 0;
    int memo = -1;
    rep(i, 26)
    {
        odd += (cnt[i] & 1);
        if (cnt[i] & 1)
            memo = i;
    }
    if (odd > 1 or (odd == 1 and (s.size() & 1) == 0)) {
        cout << -1 << endl;
        return 0;
    }
    vector<pair<int, int>> left, right;
    int m[30] = {};
    lli sum = 0;

    rep(i, s.size())
    {
        int c = s[i] - 'a';
        if (m[c] < cnt[c] / 2)
            left.push_back(make_pair(i, c));
        else
            right.push_back(make_pair(i, c));
        m[c]++;
    }
    queue<int> st[30];
    bit<int> bi(n + 10);
    rep(i, left.size())
    {
        //cout << left[i].second << endl;
        sum += abs(left[i].first - i);
        //bi.add(left[i].first, 1);
    }
    //cout << sum << endl;
    vector<int> next;
    bool f = false;
    rep(i, right.size())
    {
        if (!f and right[i].second == memo) {
            sum += i;
            f = true;
        } else {
            next.push_back(right[i].second);
        }
    }
    //cout << sum << endl;

    reverse(left.begin(), left.end());
    rep(i, left.size())
    {
        st[left[i].second].push(i);
    }
    vector<int> v;
    rep(i, next.size())
    {
        v.push_back(st[next[i]].front());
        st[next[i]].pop();
    }
    rep(i, v.size())
    {
        //cout << v[i] << " ";
        sum += bi.sum(v[i], n);
        bi.add(v[i], 1);
    }
    cout << sum << endl;
}


Measured memory_bytes: 4600
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] A = new int[N];
		Arrays.setAll(A, i -> sc.nextInt());
		Arrays.sort(A);
		int ans = 0, min = A[N-1];
		for(int i = 0; i < N-1; i++) {
			if(Math.abs(A[N-1]/2 - A[i]) < min) {
				min = Math.abs((A[N-1]+1)/2 - A[i]);
				ans = A[i];
			}
		}
		System.out.println(A[N-1] + " " + ans);
	}

}

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

//#define MAX 2000001
#define CMAX 10000
int main()
{
	int nIn = 0;
	cin >> nIn;

	int *nA = new int[nIn];
	int *nB = new int[nIn];
	int nC[CMAX + 1] = { 0 };
	for (int i = 0; i < nIn; ++i)
	{
		cin >> nA[i];
		++nC[nA[i]];
		//nB[i] = nA[i];
	}

	for (int j = 1; j <= CMAX; ++j)
	{
		nC[j] = nC[j] + nC[j - 1];
	}

	for (int j = nIn - 1; j >= 0; --j)
	{
		nB[nC[nA[j]]] = nA[j];
		nC[nA[j]]--;
	}

	for (int i = 1; i <= nIn; ++i)
	{
		if (i > 1)
		{
			cout << " ";
		}
		cout << nB[i];
	}
	cout << endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 18732
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef pair<int, int> Pint;
typedef pair<int64_t, int64_t> Pll;


int main() {
    int N, x, sum = 0;
    cin >> N >> x;
    vector<int> A(N);
    for (int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    sort(ALL(A));
    for (int i = 0; i < N - 1; i++){
        sum += A.at(i);
        if (sum > x){
            cout << i << endl;
            return 0;
        }
    }
    if (sum + A.at(N - 1) == x){
        cout << N << endl;
    }
    else {
        cout << N - 1 << endl;
    }

}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
   char op;
   scanf("%d %c %d",&a,&op,&b);
   if(op=='+')
    printf("%d\n",a+b);
  else printf("%d\n",a-b);
 return 0;

}



Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bits/stdc++.h>
using namespace std;
multiset <int> Set;
int n,res;
int main(){
	int i,a;
	scanf ("%d",&n);
	for (int i=0;i<n;i++){
		scanf ("%d",&a);
		Set.insert(a);
	}
	while (!Set.empty()){
		auto it=Set.end();
		it--;
		int x=*it;
		Set.erase(it);
		for (i=1;i<=x;i*=2);
		if (Set.find(i-x)!=Set.end()){
			Set.erase(Set.find(i-x));
			res++;
		}
	}
	printf ("%d",res);
	return 0;
}

Measured memory_bytes: 9600
x,n = map(int,input().split())
if n==0:
    print(x)
else:
    p = list(map(int,input().split()))
    p.sort()
    if x not in p:
        print(x)
    else:
        for i in range(200):
            if x-i not in p:
                print(x-i)
                break
            if x+i not in p:
                print(x+i)
                break

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

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

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


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,a;
	cin>>n>>a;
	puta(n<a?0:10);
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
struct UnionFind{
    vector<int> d;
    UnionFind(int n) : d(n,-1) {}
    //根なら、-サイズを格納それ以外は、親を格納
    int find(int x){
        if(d[x] < 0) return x;
        return d[x] = find(d[x]); //経路縮約
    }
    bool unite(int x,int y){
        //二つ頂点を持ってくる
        x = find(x);
        y = find(y);
        if(x == y) return false;//根が一致するなら何もしない
        if(d[x] > d[y]) swap(x,y);
        //ex:d[x]=-5,d[y]=-2
        //小さい方が、大きい方に引っ付く
        d[x] += d[y];//この場合、yがxにくっつく
        d[y] = x;
        return true; 
    }
    bool same(int x,int y) {return find(x) == find(y);}
    int size(int x) {return -d[find(x)];}
};

int deg[100005]; //iの持つ友達関係の個数
vector<int> to[100005]; //iに関するブロック関係の隣接リスト

int main(){
    int n,m,k;
    cin>>n>>m>>k;
    UnionFind uf(n);
    //cout<<"first"<<endl;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        --a; --b;
        deg[a]++; 
        deg[b]++;
        uf.unite(a,b);
    }
    //cout<<"second"<<endl;
    rep(i,k){
        int a,b;
        cin >> a >> b;
        --a,--b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    //cout<<"last"<<endl;
    rep(i,n){
        int ans  = uf.size(i) -1 -deg[i];
        for(int u : to[i]){
            if(uf.same(i,u)) --ans;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 6784
#include <iostream>
using namespace std;
int main(void){
    int n, k;
    cin >> n >> k;
    int x, count=0, sum=1;
    for(x = k; (x > 0) && (n>0); x /= 2){
        count++;
        sum *=2;
        n--;
    }
    
    cout << sum + n*k << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

#define N 8
#define M (N*(N-1)/2)

int n, m, a[M], b[M];

int search(int noArray, int *isStoraged, int *seq, int *cnt){
  if(noArray==n){
//    for(int j=0; j<n; j++) { printf("%d",seq[j]); } printf("\n");
    *cnt = *cnt + 1;
  }
  else{
    for(int i=0; i<m; i++){
      if(a[i]==seq[noArray-1] && isStoraged[b[i]-1]==0){
        isStoraged[b[i]-1] = 1;
        seq[noArray] = b[i];
        search(noArray+1, isStoraged, seq, cnt);
        isStoraged[b[i]-1] = 0;
      }
      if(b[i]==seq[noArray-1] && isStoraged[a[i]-1]==0){
         isStoraged[a[i]-1] = 1;
         seq[noArray] = a[i];
         search(noArray+1, isStoraged, seq, cnt);
         isStoraged[a[i]-1] = 0;
      }
    }
  }
  return 0;
}

int main(){
  scanf("%d %d", &n, &m);
  for(int i=0; i<m; i++){
    scanf("%d %d", &a[i], &b[i]);
  }
  
  int isPass[N]={0}, orderPassed[N]={0}, cnt=0;
  isPass[0]=1;  // node 1 is Passed initially
  orderPassed[0]=1; //  node 1 is Storaged
  search(1, isPass, orderPassed, &cnt);
  
  printf("%d",cnt);
  
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
using namespace std;
int main()
{
	string s,t;
	cin >> s;
	cin >> t;

	if(s.size() != t.size() -1){
		cout << "No";
		return 0;
	}

	else{
		for(int i=0;i<s.size();i++)
		{
			if(s[i] != t[i]){
				cout << "No";
				return 0;
			}
		}
		cout << "Yes";	
	}
	return 0;
	
}

Measured memory_bytes: 3628
#include<stdio.h>
#include<iostream>
#include<vector>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<string.h>
#include<functional>
#include<limits.h>
#include<stdlib.h>
#include<cmath>
#include<cstring>
#include<set>
#include<climits>
#include<deque>
#include <iomanip>
#include<utility>
using namespace std;

#define intmax INT_MAX
#define lmax LONG_MAX
#define uintmax UINT_MAX
#define ulmax ULONG_MAX
#define llmax LLONG_MAX
#define ll long long
#define rep(i,a,N) for((i)=(a);(i)<(N);(i)++)
#define rrp(i,N,a) for((i)=(N)-1;(i)>=(a);(i)--)
#define llfor ll i,j
#define sc(a) cin>>a
#define pr(a) cout<<a<<endl
#define pY puts("YES")
#define pN puts("NO")
#define py puts("Yes")
#define pn puts("No")
#define pnn printf("\n")
#define all(a) a.begin(),a.end()
#define push(a,b) (a).push_back(b)
#define llvec vector<vector<ll>>
#define charvec vector<vector<char>>
#define size(a,b) (a,vector<ll>(b))
#define llpvec vector<pair<ll,ll>>
#define S 21 
llfor;ll mod=1000000007;
/*pi*/double pi=acos(-1);
/*繰り上げ除算*/ll cei(ll x,ll y){ll ans=x/y;if(x%y!=0)ans++;return ans;}
/*最大公約数*/ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
/*最小公倍数*/ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
/*n乗*/ll llpow(ll x,ll n){ll ans=1;rep(i,0,n){ans*=x;ans%=mod;}return ans;}
/*階乗*/ll fact(ll x){ll ans=1;rep(i,0,x)ans*=(x-i);return ans;}
/*nCr*/ll ncr(ll n,ll r){return fact(n)*fact(n-r)/fact(r);}
/*nPr*/ll npr(ll n,ll r){return fact(n)/fact(n-r);}
/*primejudge*/bool prime(ll a){if(a<=1)return false;for(i=2;i*i<=a;i++){if(a%i==0)return false;}return true;}
/*Fibonacci数列*/ll fib(ll x){ll fibo[x+10];fibo[0]=1;fibo[1]=1;fibo[2]=1;rep(i,3,x+1)fibo[i]=fibo[i-1]+fibo[i-2];return fibo[x];}
/*桁数*/ll dig(ll n){ll d=1,tmp=n;while(tmp/10>0){tmp/=10;d++;}return d;}
/*行列のコピー*/void matcpy(ll a[S][S],ll b[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)b[i][j]=a[i][j];/*(aをbに)*/i=t;}
/*行列のリセット*/void matrst(ll a[S][S]){ll t=i;rep(i,0,S)rep(j,0,S)a[i][j]=0;i=t;}
/*行列の2乗*/void matpow(ll a[S][S]){ll ans[S][S];matrst(ans);ll t=i,k;rep(i,0,S)rep(j,0,S)rep(k,0,S)ans[i][j]+=a[i][k]*a[k][j];matcpy(ans,a);i=t;}
/*行列の乗算*/void matmul(ll a[S][S],ll b[S][S], ll as[S][S]){ll t=i,k;matrst(as);rep(i,0,S)rep(j,0,S)rep(k,0,S)as[i][j]+=a[i][k]*b[k][j];i=t;}
//ll ans=0;
////////////////////////////////////////////////////////////
int main(){
 string s; 
 cin>>s;
 ll n=s.length();
 map<char,bool>map;
 rep(i,0,n)map[s[i]]=true;
 if(map['W']!=map['E']||map['S']!=map['N'])pn;
 else py;
return 0;}




Measured memory_bytes: 3600
#include <cstdio>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <cassert>
#include <numeric>
#include <functional>
//#include <numeric>
#pragma warning(disable:4996) 
 
typedef long long ll;
typedef unsigned long long ull;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF  9223300000000000000
#define LINF2 1223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;

using namespace std;

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

void solve()
{
    int n, K;
    scanf("%d%d", &n, &K);
    int curr = 0, max = 0;
    int i;
    for (i = 0; i < n; i++) {
        int tmp;
        scanf("%d", &tmp);
        max = MAX(max, tmp);
        curr = gcd(curr, tmp);
    }
    if (K > max) {
        printf("IMPOSSIBLE\n"); return;
    }
    if ((max - K) % curr == 0) {
        printf("POSSIBLE\n");
    }
    else {
        printf("IMPOSSIBLE\n");
    }



    return;
}


int main(int argc, char* argv[])
{
#if 1
    solve();
#else
    int T;
    scanf("%d", &T);
    int t;
    for(t=0; t<T; t++) {
        //printf("Case #%d: ", t+1);
        solve();
    }
#endif
    return 0;
}


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

void get_int2(char *line, int size, int *a1, int *a2) {
  if(!fgets(line, size, stdin)) return;
  sscanf(line, "%d %d", a1, a2);
}

#define BUF_SIZE 10
#define VERTEX_MAX 8

static int mat[VERTEX_MAX+1][VERTEX_MAX+1];
int cnt = 0;

void swap(int *a, int *b) {
  int tmp = *a;
  *a = *b;
  *b = tmp;
}

void permute(int *arr, int size, int start, int end) {
  int i;
  if(start+1 >= end) {
    int prev = arr[1];
    int flag = 1;
    for(i = 2; i < size; i++) {
      int cur = arr[i];
      if(!mat[prev][cur]) {
        flag = 0; break;
      }
      prev = cur;
    }
    if (flag) cnt++;
    return;
  }
  for(i = start; i < end; i++) {
    swap(&arr[start], &arr[i]);
    permute(arr, size, start+1, end);
    swap(&arr[start], &arr[i]);
  }
}

int main(void) {
  int vs, es;
  char line[BUF_SIZE];
  get_int2(line, BUF_SIZE, &vs, &es);
  int i, j;
  for(i = 0; i < es; i++) {
    int v1, v2;
    get_int2(line, BUF_SIZE, &v1, &v2);
    mat[v1][v2] = mat[v2][v1] = 1;
  }
  int *arr = malloc(sizeof(int)*(vs+1));
  for(i = 1; i <= vs; i++) {
    arr[i] = i;
  }

  // start: 1 fixed
  permute(arr, vs+1, 2, vs+1);
  printf("%d\n", cnt);



  return 0;
}

Measured memory_bytes: 256
n,l=map(int,input().split())
a = [int(x) for x in input().split()]
for i in range(1,n):
    if a[i-1] +a[i]>= l:
        print("Possible")
        for j in range(1,i):
            print(j)
        for j in range(n-1,i-1,-1):
            print(j)
        break
else:
    print("Impossible")

Measured memory_bytes: 14060
#include <stdio.h>

int main(void) {
  int A, B, C;
  scanf("%d%d%d",&A,&B,&C);

  if(B>=A*C){
   printf("%d\n",C);
  }
  else{
    printf("%d\n",B/A);
  }


  
  return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cstring>
using namespace std;
int main(void)
{
	int i,j,h,w,a[501][501],q[250000][2],p1,p2,p3,x,y,x1,y1;
	int n,xy[250000][4];
	scanf("%d %d",&h,&w);
	for(i=1;i<=h;i++)	{
		for(j=1;j<=w;j++)	{
			scanf("%d",&a[i][j]);
		}
	}
	p1=0;
	for(i=1;i<=h;i++)	{
		if(i%2==1)	{
			for(j=1;j<=w;j++)	{
				q[p1][0]=i;
				q[p1][1]=j;
				p1++;
			}
		}
		else {
			for(j=w;j>=1;j--)	{
				q[p1][0]=i;
				q[p1][1]=j;
				p1++;
			}
		}
	}
	p2=0;
	for(i=0;i<p1-1;i++)	{
		y=q[i][0];	x=q[i][1];
		y1=q[i+1][0];	x1=q[i+1][1];
		if(a[y][x]%2==1)	{
			a[y][x]--;	a[y1][x1]++;
			xy[p2][0]=y;	xy[p2][1]=x;
			xy[p2][2]=y1;	xy[p2][3]=x1;
			p2++;
		}
	}
	printf("%d\n",p2);
	for(i=0;i<p2;i++)	{
		printf("%d %d %d %d\n",xy[i][0],xy[i][1],xy[i][2],xy[i][3]);
	}
	return 0;
}

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

int main(void)
{
	int n,m;
	int b[101],a[101][101],c[101];

	cin >> n >> m;
	rep(i, n)
		rep(j, m)
			cin >> a[i][j];

	rep(i, m)
		cin >> b[i];

	rep(i, n)
	{
		c[i] = 0;
		rep(j,m)
		{
			c[i] += a[i][j] * b[j];
		}
	}

	rep(i,n)
		cout << c[i] << endl;
}



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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var NAB = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            Console.WriteLine(NAB[0]*NAB[1]<NAB[2]?NAB[0]*NAB[1]:NAB[2]);
        }   
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 11092
use std::fmt;
use std::io::stdin;
use std::io::BufRead;
use std::str;
use std::str::FromStr;

#[derive(Clone,Copy)]
pub enum Expr {
	Num(i32),
	Plus,
	Minus,
}
impl fmt::Display for Expr {
	fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
		match self {
			&Expr::Num(n) => {
				write!(f, "{}", n)
			},
			&Expr::Plus => {
				write!(f,"+")
			},
			&Expr::Minus => {
				write!(f,"-")
			}
		}
	}
}
fn main() {
	let stdin = stdin();
	let mut scan = InputScanner::new(stdin.lock(),256);

	let s:String = scan.next();

	let chars = s.chars().collect::<Vec<char>>();

	let a = chars[0] as i32 - '0' as i32;
	let b = chars[1] as i32 - '0' as i32;
	let c = chars[2] as i32 - '0' as i32;
	let d = chars[3] as i32 - '0' as i32;

	exec(a,b,c,d,&vec![]);
}
fn exec(a:i32,b:i32,c:i32,d:i32,op:&Vec<Expr>) -> bool {
	if op.len() == 3 {
		solve(Expr::Num(a),Expr::Num(b),Expr::Num(c),Expr::Num(d),op[0],op[1],op[2])
	} else {
		{
			let mut op = op.clone();

			op.push(Expr::Plus);

			if exec(a,b,c,d,&op) {
				return true;
			}
		}

		{
			let mut op = op.clone();

			op.push(Expr::Minus);

			if exec(a,b,c,d,&op) {
				return true;
			}
		}

		false
	}
}
fn solve(a:Expr,b:Expr,c:Expr,d:Expr,op1:Expr,op2:Expr,op3:Expr) -> bool {
	let mut stack = Vec::new();

	stack.push(op3);
	stack.push(d);
	stack.push(op2);
	stack.push(c);
	stack.push(op1);
	stack.push(b);
	stack.push(a);

	while stack.len() > 1 {
		let l = match stack.pop().unwrap() {
			Expr::Num(n) => n,
			_ => panic!(),
		};
		let r = match stack.pop().unwrap() {
			Expr::Num(n) => n,
			_ => panic!(),
		};
		let op = stack.pop().unwrap();

		match op {
			Expr::Plus => {
				stack.push(Expr::Num(l+r));
			},
			Expr::Minus => {
				stack.push(Expr::Num(l-r));
			},
			_ => panic!(),
		}
	}

	match stack.pop().unwrap() {
		Expr::Num(n) if n == 7 => {
			println!("{}{}{}{}{}{}{}=7",a,op1,b,op2,c,op3,d);
			true
		},
		Expr::Num(_) => {
			false
		},
		_ => {
			panic!()
		}
	}
}
struct InputScanner<R: BufRead> {
	reader: R,
	buf: Vec<u8>, // Should never be empty
	pos: usize,   // Should never be out of bounds as long as the input ends with '\n'
}
impl<R: BufRead> InputScanner<R> {
	fn new(reader: R, capacity: usize) -> Self {
		InputScanner {
			reader: reader,
			buf: Vec::with_capacity(capacity),
			pos: 0,
		}
	}

	#[inline]
	fn next<T: FromStr>(&mut self) -> T
	where
		T::Err: fmt::Debug,
	{
		if self.buf.is_empty() {
			self._read_next_line();
		}
		let mut start = None;
		loop {
			match (self.buf[self.pos], start.is_some()) {
				(b' ', true) | (b'\n', true) | (b'\r', true) => break,
				(_, true) | (b' ', false) => self.pos += 1,
				(b'\n', false) | (b'\r', false) => self._read_next_line(),
				(_, false) => start = Some(self.pos),
			}
		}
		let target = &self.buf[start.unwrap()..self.pos];
		unsafe { str::from_utf8_unchecked(target) }.parse().unwrap()
	}

	#[inline]
	fn _read_next_line(&mut self) {
		self.pos = 0;
		self.buf.clear();
		if self.reader.read_until(b'\n', &mut self.buf).unwrap() == 0 {
			panic!("Reached EOF");
		}
	}
}


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

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

	int count[4] = {};
	int count_num = 0;

	for (int i = 0; i < 4; i++) {
		for (int j = i+1; j < 4; j++) {
			if (s[i] == s[j]) {
				count[i]++;
			}
		}
		if (count[i] == 1) {
			count_num++;
		}
	}
	if (count_num == 2) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<utility>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<vector>
#include<array>
#include<functional>
#include<type_traits>
using namespace std;

using pint = pair<int, int>;
using pstr = pair<string, string>;
using vint = vector<int>;
using vstr = vector<string>;

#define rep(i,N) for(int(i) = 0; (i) < int(N) ; (i)++)
#define all(A) begin(A),end(A)


int main()
{
	int n;
	cin >> n;
	vint v;
	rep(i, n * 2) {
		int tmp=0;
		cin >> tmp;
		v.emplace_back(tmp);
	}
	sort(all(v));
	int sum = 0;
	for (size_t i = 0; i < 2*n; i+=2)
	{
		sum += v[i];
	}
	cout << sum;
	return 0;
}


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

namespace ABC128_1
{
    class B
    {
        static void Main(string[] args)
        {
            var a = int.Parse(Console.ReadLine());
            //var b = Enumerable.Repeat(0, a).Select(_ => Console.ReadLine().Split().Select(int.Parse).ToArray()).OrderBy(x => x[0]).ThenByDescending(x => x[1]).ToArray();
            var t = new List<Tuple<int, string, int>>();
            for (int i = 0; i < a; i++)
            {
                var b = Console.ReadLine().Split().ToArray();
                var s = b[0];
                var p = int.Parse(b[1]);

                t.Add(Tuple.Create(i + 1, s, p));
            }

            t = t.OrderBy(x => x.Item2).ThenByDescending(x => x.Item3).ToList();
            foreach (var i in t)
            {
                Console.WriteLine(i.Item1);
            }
        }
    }
}


Measured memory_bytes: 13664
import java.util.*;
import java.math.*;
public class Main {
     public static String mul(String v1, String v2, int scale) {
        if (scale < 0) {
            throw new IllegalArgumentException(
                    "The scale must be a positive integer or zero");
        }
        BigDecimal b1 = new BigDecimal(v1);
        BigDecimal b2 = new BigDecimal(v2);
        return b1.multiply(b2).setScale(scale, BigDecimal.ROUND_DOWN).toString();
    }
    public static void main(String[] args)
    {
       Scanner input =new Scanner(System.in);
String str1=input.next();
        String str2=input.next();//会从控制5261台读入一4102个字符串，1653以空格版为标志权
        Main c=new Main();
        System.out.println(c.mul(str1,str2,0));

    }
}


Measured memory_bytes: 35992
N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
count = 0
for i in range(N):
  if B[i] > A[i]:
    count += A[i]
    if B[i] - A[i] > A[i+1]:
      count += A[i+1]
      A[i+1] = 0
    else:
      count += B[i] - A[i]
      A[i+1] = A[i+1] - (B[i] - A[i])
  else:
    count += B[i]
print(count)

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

const int maxn=1e5+5;
vector<int>adj[maxn];
int visited[maxn];

//void bfs(int v){
//    visited[v]=1;
//    queue<int>q;
//    q.push(v);
//    while(!q.empty()){
//        int p=q.front();
//        q.pop();
//        for(auto u:adj[p]){
//            if(!visited[u]){
//                visited[u]=p;
//                q.push(u);
//            }
//        }
//    }
//}
void solve()
{
    string s,t;
    cin>>s>>t;
    int m=s.length();int n=t.length();
    if(m+1!=n){
        cout<<"No"<<endl;
    }
    else{
        bool flag=false;
        for(int i=0;i<m;i++){
            if(s[i]!=t[i]){
                flag=true;
            }
        }
        if(flag){
            cout<<"No"<<endl;
        }
        else{
            cout<<"Yes"<<endl;
        }
    }
}

    int main()
    {
        ios::sync_with_stdio(0);
        cin.tie(0);
        solve();
        return 0;
    }


Measured memory_bytes: 5996
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
  int n,ans; string s;
  ans=0;
  cin>>n>>s;
  rep(i,n-2) if(s.substr(i,3)=="ABC")ans++;
  cout<<ans<<endl;
}

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

int main()
{
    int n;
    cin >> n;
    int a = n % 10 + (n % 100 / 10)*10;
    int b = n / 1000*10 + (n % 1000 / 100);
	
  	//cout << a << endl << b<<endl;
  
    if(a==0){
        if(b==0)
            cout << "NA" << endl;
        else if(b<13)
            cout << "MMYY" << endl;
        else
            cout << "NA" << endl;
    }
    else if(a<13){
        if (b == 0)
            cout << "YYMM" << endl;
        else if (b < 13)
            cout << "AMBIGUOUS" << endl;
        else
            cout << "YYMM" << endl;
    }
    else{
        if (b == 0)
            cout << "NA" << endl;
        else if (b < 13)
            cout << "MMYY" << endl;
        else
            cout << "NA" << endl;
    }
   
    
    return 0;
}

Measured memory_bytes: 256