akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  ll N;
  cin>>N;
  ll A[N];
  for(ll i=0;i<N;++i) cin>>A[i];
  bool kai;
  ll money = 1000, kabu = 0;
  if(A[0]>=A[1]) {
    kai = false;
  }
  else {
    kai = true;
    kabu = money / A[0];
    money %= A[0];
  }
  for(ll i=1;i<N;++i) {
    if(kai) {
      if(A[i]>A[i+1]) {
        money += kabu*A[i];
        kabu = 0;
        kai = false;
      }
    }
    else {
      if(A[i]<A[i+1]) {
        kabu = money / A[i];
        money %= A[i];
        kai = true;
      }
    }
  }
  if(kabu>0) money += kabu*A[N-1];
  cout<<money<<endl;
}



Measured memory_bytes: 3612
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int n = in.ni(), k = in.ni();
        long[] gcd = new long[k];
        for (int i = k; i >= 1; i--) {
            gcd[i-1] = pow(k/i,n);
            for (int j = 2; j*i <= k; j++) {
                gcd[i-1] -= gcd[i*j-1];
                if(gcd[i-1]<0) gcd[i-1] += mod;
            }
        }
        long ans = 0;
        for (int i = 1; i <= k; i++) {
            ans += i*gcd[i-1];
            ans %= mod;
        }
        out.println(ans);
    }
    public static long pow(long x, long n){
        long res = 1;
        while(n > 0){
            if ((n & 1) == 1) {
                res *= x;
                res %= mod;
            }
            x *= x;
            x %= mod;
            n >>= 1;
        }
        return res;
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 33676
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String input = scanner.nextLine();
        String firstThree = input.substring(0,3);
        String seven = input.substring(3,4);
        String rest = input.substring(4);
        seven = "8";
        System.out.println(firstThree+seven+rest);
    }
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define sz(x) (int)(x).size()
#define For(i, a, b) for (int i = int(a); i < int(b); i++)
#define Dor(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define Foz(i, a) For(i, 0, a)
#define Doz(i, a) Dor(i, 0, a)
#define Trav(e, v) for (auto& e : v)
#define pb push_back
#define mp make_pair
#define all(x) begin(x), end(x)
using namespace std;
using ll = long long;
using ii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vii = vector<ii>;
template <typename T> bool ckmin (T& a, T b) { return (b < a) ? a = b, 1 : 0; }
template <typename T> bool ckmax (T& a, T b) { return (b > a) ? a = b, 1 : 0; }
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#ifdef XVENOM
	#define errp(...) fprintf(stderr, __VA_ARGS__)
	#define dbg(...) errp("[%s]: ", #__VA_ARGS__), dbg_str(__VA_ARGS__)
#else
	#define errp(...)
	#define dbg(...)
#endif
template <typename U, typename V> string to_string (pair<U, V>);
string to_string (string& e) { return "\"" + e + "\""; }
string to_string (char e) { return "\'" + string(1, e) + "\'"; }
string to_string (bool e) { return e ? "true" : "false"; }
template <typename T> string to_string (T e) {
	string s = "[ ";
	for (auto& x : e) s += to_string(x) + " ";
	return s + "]";
}
template <typename U, typename V> string to_string (pair<U, V> e) {
	return "(" + to_string(e.first) + ", " + to_string(e.second) + ")";
}
void dbg_str () { errp(" \n"); }
template <typename U, typename... V> void dbg_str (U u, V... v) {
 	errp(" %s", to_string(u).c_str()); dbg_str(v...);
}
/* --- */
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
	/* --- */
	int a, b, c;
	cin >> a >> b >> c;
	if (a > b) swap(a, b);
	if (b > c) swap(b, c);
	if (a > b) swap(a, b);

	if ((a == b && b < c) || (b == c && a < b)) cout << "Yes\n";
	else cout << "No\n";
}



Measured memory_bytes: 256
#include<iostream>

#define     MAX_NUMBER         2000000000
#define     __ERROR_CODE__     (-1)

using namespace std;

int Integer_LCM(const unsigned int,const unsigned int);
int Integer_GCD(const unsigned int,const unsigned int);

int main(){
	int a,b;

	while(cin >> a >> b){
		cout << Integer_LCM(a,b) << " " << Integer_GCD(a,b) << endl;
	}

	return 0;
}

int Integer_LCM(const unsigned int a,const unsigned int b){
	int p,q,r;

	// 入力値の確認
	if((a <= 0) || (b <= 0) || (a > ((int)(MAX_NUMBER))) || (b > ((int)(MAX_NUMBER)))){
		return ((int)(__ERROR_CODE__));
	}

	// 変数の初期化
	p = a;
	q = b;
	r = a % b;

	// ユークリッドの互除法
	while (r != 0){
		p = q;
		q = r;
		r = p % q;
	}

	return q;
}

int Integer_GCD(const unsigned int a,const unsigned int b){
	// 入力値の確認
	if((a <= 0) || (b <= 0) || (a > ((int)(MAX_NUMBER))) || (b > ((int)(MAX_NUMBER)))){
		return ((int)(__ERROR_CODE__));
	}

	return ((int)( ((double)a) / Integer_LCM(a,b) )) * b;
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <map>
#include <algorithm>
#include <vector>
using namespace std;

int main(void) {
	int a,b;
	string s;
	cin >> a >> b >> s;
	for(int i=0; i<s.length(); i++){
		if(i==a){
			if(s[a]!='-'){
				cout << "No" << endl;
				return 0;
			}else continue;
		}
		if(s[i] < '0' || '9' < s[i]){
				cout << "No" << endl;
				return 0;
		}
	}
	cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 256
<?php
	$n = explode(" ",trim(fgets(STDIN)));
	$a = explode(" ",trim(fgets(STDIN)));
	$sum = 0;
	for($t=0;$t < $n[0];$t++){
		$sum += $a[$t];
	}
	$x = 0;
	$min = 10000000000;
	for($i=0;$i < $n[0]-1;$i++){
		$x = $x + $a[$i];
		$min = min($min,abs($sum-(2*$x)));
	}
	echo $min;
?>

Measured memory_bytes: 39668
import sys
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9 + 7
input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int,input().split()))
def inpm():
    return map(int,input().split())

n,m = inpm()
dp = [0] * (n+2)
for _ in range(m):
    a = int(input())
    dp[a] = -1

# init
dp[0] = 1
# start
for i in range(n):
    if dp[i] == -1:continue
    dp[i] %= mod
    if dp[i+1] != -1:
        dp[i+1] += dp[i]
    if dp[i+2] != -1:
        dp[i+2] += dp[i]
print(dp[n]%mod)


Measured memory_bytes: 6900
#include<iostream>
using namespace std;
int main(){
  int A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int n;cin >> n;--n;cout << A[n];
}


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

typedef long long LL;

const int N = 5e2 + 7;
const int INF = 1e9 + 7;
const double pi = acos(-1.0);

char s[N][N];
int n, res;

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n; i++)
        scanf("%s", s[i]);
    int B = 0;
    for (int i = 0; i < n; i++) {
        int cnt = 0;
        for (int j = 0; j < n; j++)
            cnt += (s[j][i] == '#');
        if (cnt == n) B++;
    }
    int ans = INF;
    for (int i = 0; i < n; i++) {
        int tmp = 0;
        for (int j = 0; j < n; j++) {
            if (s[i][j] == '#') continue;
            int flag = 0;
            for (int k = 0; k < n; k++)
                if (s[k][i] == '#') {
                    flag = 1;
                    break;
                }
            if (!flag && i == j) {
                tmp += 2;
            } else tmp += 1;
        }
        ans = min(ans, tmp + n - B);
    }
    int cnt = 0;
    for (int i = 0; i < n; i++)
    for (int j = 0; j < n; j++)
    if (s[i][j] == '#') cnt++;

    if (!cnt) ans = -1;

    printf("%d\n", ans);
}


Measured memory_bytes: 512
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int l = sc.nextInt();
        int r = sc.nextInt();
        int d = sc.nextInt();

        int count = 0;

        for(int i=l; i<=r; i++){
            if(i % d == 0){
                count++;
            }
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 35780
#include<iostream>
#define ll long long
using namespace std;
const int mod = 1e9 + 7;
int main(){
	ll n,x,count=1;
	ll num[101000]={0};
	cin>>n;
	for(int i=2;i<=n;i++){
		x=i;
		for(int j=2;j<=x;j++){
			while(x%j==0){ 
				num[j]++;
				num[j]%=mod; 
				x/=j;
			}
		}
		if(x!=1)
			num[x]++;
	}
	for(int i=1;i<=n;i++){
		if(num[i])
			count=(count*((num[i]+1)%mod))%mod;
	}
	cout<<count;
	return 0;
}


Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int A,B;
    cin >> A >> B;
    cout << (A-1) * (B-1) << endl;   
}

Measured memory_bytes: 256
using namespace std;
#include<bits/stdc++.h>
#define BEGIN ios_base::sync_with_stdio(0);cin.tie(0)
#define END return EXIT_SUCCESS
#define FOR(I,A,B) for((I)=(A);(I)<(B);(I)++)
#define REP(I,N) FOR(I,0,N)
#define UP(I,A,B) for((I)=(A);(I)<=(B);(I)++)
#define DW(I,A,B) for((I)=(A);(I)>=(B);(I)--)
#define IN(P) cin>>(P)
#define IN2(P1,P2) cin>>(P1)>>(P2)
#define IN3(P1,P2,P3) cin>>(P1)>>(P2)>>(P3)
#define INS(I,N,V) REP(I,N) cin>>V[I]
#define INS2(I,N,V1,V2) REP(I,N) cin>>V1[I]>>V2[I];
#define INS3(I,N,V1,V2,V3) REP(I,N) cin>>V1[I]>>V2[I]>>V3[I];
#define OUT(P) cout<<P<<endl
#define OUT2(P1,P2) cout<<P1<<" "<<P2<<endl
#define OUT3(P1,P2,P3) cout<<P1<<" "<<P2<<" "<<P3<<endl
#define OUTS(I,N,V) REP(I,N) cout<<V[i]<<endl
#define ALL(C) (C).begin(),(C).end()
#define RALL(C) (C).rbegin(),(C).rend()
#define mp make_pair
#define pb push_back
typedef unsigned long ul;
typedef unsigned int ui;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int N,i,a;
multiset<int> num;

inline void solve(){
  IN(N);
  REP(i,N){
    IN(a);
    if(!num.count(a))num.insert(a);
    else num.erase(a);
  }
  OUT(num.size());
}

int main(int argc,char**argv){
  BEGIN;
  solve();
  END;
}


Measured memory_bytes: 4992
//AUTHOR:BlackBox Inc.//
#include<bits/stdc++.h>
#include<unordered_map>
#include<tr1/unordered_map>
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vlli vector<long long int>
#define vvi vector<vector<int>>
#define endl "\n"
#define vpii vector<pair<int,int>>
#define vs vector<string>
#define lin1(x) ll int x; x = scan();
#define lin2(x,y) ll int x, y; x = scan(), y = scan();
#define lin3(x,y,z) ll int x, y, z; x = scan(), y = scan(), z = scan();
#define pb(x) push_back(x)
#define makep(x,y) make_pair(x,y)
#define mx(a,b) (a)>(b)?(a):(b)
#define mn(a,b) (a)<(b)?(a):(b)
#define fori(s,e) for(i=s;i<=e;i++)
#define forj(s,e) for(j=s;j<=e;j++)
#define fork(s,e) for(k=s;k<=e;k++)
#define rep(i,s,e) for(int i=s;i<=e;i++)
#define brep(i,s,e) for(int i=s;i>=e;i--)
#define all(x) x.begin(),x.end()
#define mem(x,y) memset(x,y,sizeof(x));
#define bits1(x) __builtin_popcount(x)
#define pi 3.14159265358979323846264338327950
#define MOD7 1000000007
#define MOD9 1000000009
#define fast std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
using namespace std::tr1;

int main()
{
// #ifndef RAHUL
//     freopen("input.txt","r",stdin);
//     freopen("output.txt","w",stdout);
// #endif

 








long long a;
cin>>a;
long long area=3*a*a;
cout<<area<<endl;

return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  int x[400],y[400],b[400],p[400];
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x[i]>>y[i]>>b[i]>>p[i];
  }
  int sum[400];
  for(int i=0;i<n;i++){
    if(b[i]<5 && p[i]<2){
      sum[i]=min(x[i]*b[i]+y[i]*p[i],(x[i]*5+y[i]*2)*8/10);
    }
    else if(p[i]<2){
      sum[i]=min(x[i]*b[i]+y[i]*p[i],(x[i]*b[i]+y[i]*2)*8/10);
    }
    else if(b[i]<5){
      sum[i]=min(x[i]*b[i]+y[i]*p[i],(x[i]*5+y[i]*p[i])*8/10);
    }
    else sum[i]=(x[i]*b[i]+y[i]*p[i])*8/10;
  }

  for(int i=0;i<n;i++){
    cout<<sum[i]<<endl;
  }

  return 0;
}
  



Measured memory_bytes: 3124
#include <bits/stdc++.h>
#define rep(i,s,n) for (int i = s; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,bool>;
using graph = map<int, vector<int>>;

int n;
int inf = 100000000;

vector<int> bfs(graph &G,int v) {
  queue<int> q;
  vector<int> dist(n,-1);
  q.push(v);
  dist[v] = 0;
  while(!q.empty()) {
    int v = q.front(); q.pop();
    for (auto nv : G[v]) {
      if (dist[nv] != -1) continue;
      dist[nv] = dist[v] + 1;
      q.push(nv);
    }
  }
  return dist;
}

int main() {
  int u,v;
  cin >> n >> u >> v;
  u--, v--;
  graph G;
  rep(i,0,n-1) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> a = bfs(G,v), t = bfs(G,u);
  int ans = 0;
  rep(i,0,n) {
    if (a[i] > t[i]) {
      ans = max(ans, a[i] - 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 15156
import std.stdio, std.string, std.conv;
import std.typecons;
import std.algorithm, std.array, std.range, std.container;
import std.math;

void main() {
	auto n = readln.split[0].to!ulong;
	auto v = readln.split.to!(ulong[]);
	ulong[] v_odd, v_even;
	iota(1, n, 2).each!(x => v_even ~= v[x]);
	iota(0, n, 2).each!(x => v_odd  ~= v[x]);
	
	ulong[] count_odd, count_even; count_odd.length = 10^^5+1; count_even.length = 10^^5+1;
	
	foreach(num; v_odd)  { ++count_odd[num]; }
	foreach(num; v_even) { ++count_even[num]; }
	
	ulong odd_i, even_i;
	(10^^5+1).iota.each!( x => odd_i  = count_odd [x] < count_odd [odd_i]  ? odd_i  : x ),
	(10^^5+1).iota.each!( x => even_i = count_even[x] < count_even[even_i] ? even_i : x );
	
	if (odd_i != even_i) {
		writeln(v_odd.length - count_odd[odd_i] + v_even.length - count_even[even_i]);
	}
	else {
		ulong odd_i_, even_i_;
		ulong e, o;
		// second most frequent
		e = count_even[even_i], count_even[even_i] = 0;
		(10^^5+1).iota.each!( x => even_i_ = count_even[x] < count_even[even_i_] ? even_i_ : x );
		o = count_odd[odd_i],   count_odd[odd_i] = 0;
		(10^^5+1).iota.each!( x => odd_i_ = count_odd[x] < count_odd[odd_i_] ? odd_i_ : x );
		
		writeln(
			min(v_odd.length - o  + v_even.length - count_even[even_i_],
				v_odd.length - count_odd[odd_i_] + v_even.length - e
			)
		);
	}
	
}

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

using namespace std;

int main()
{
	int a, b;
	while (~scanf("%d %d", &a, &b)){
		int gcd = __gcd(a, b);
		printf("%d %d\n", gcd, a / gcd * b);
	}
	return (0);
}

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



int main(){
	int n;
	cin>>n;
	
	string ans="No";
	
	for (int i=1; i<10; i++){
		if (n%i==0 and n/i<10) ans="Yes";
	}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
a, b = list(map(int, input().split()))

def xor_sum(n):
    if n % 4 == 1:
        return 1
    elif n % 4 == 2:
        return n+1
    elif n % 4 == 3:
        return 0
    else:
        return n

if a == 0:
    print(xor_sum(b))
else:
    print(xor_sum(a-1) ^ xor_sum(b))

Measured memory_bytes: 61436
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <complex>
#include <stack>
#include <unordered_map>
using namespace std;

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    int x, y, z;
    x = abs(a-b);
    y = abs(b-c);
    z = abs(c-a);
    vector<int> v;
    v.push_back(x);
    v.push_back(y);
    v.push_back(z);
    sort(v.begin(), v.end());
    int ans = v[0] + v[1];
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;
const ll MOD = 1000000007;

int N, X, T;
int solver(void){
    return 0;
}

int main(void){
    cin >> N >> X >> T;
    if(N%X==0) N /= X;
    else N = (N/X)+1;
    cout << N * T << endl;
    return 0;
}



Measured memory_bytes: 3556
x, y, a, b, c = map(int, input().split())
r = sorted(list(map(int, input().split())))[a - x:]
g = sorted(list(map(int, input().split())))[b - y:]
m = list(map(int, input().split()))

ans = sorted(r + g + m)
print(sum(ans[len(ans) - x - y:]))

Measured memory_bytes: 22488
#include <bits/stdc++.h>
 
#define rep(i,n) for(ll i=0;i<n;++i)
#define all_map(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define ALL(a) (a).begin(),(a).end()
 
using namespace std;
using ll  = long long;
using pll = pair<ll, ll>;
 
const ll MOD  = 1e9+7;
const ll LINF = 1LL << 60;
const int INF = 1e9 + 7;

int main(){
    ll x;
    cin >> x;
    if(x == 7 || x == 5 || x == 3)cout << "YES";
    else cout << "NO";
}

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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

int gcd(int x, int y) { return (x % y)? gcd(y, x % y): y; }




using namespace std;

int main(){
  int K;
  cin >> K;
  int sum=0;

  for(int a=1;a<=K;a++){
    for(int b=1;b<=K;b++){
      for(int c=1;c<=K;c++){
        int buffer = gcd(a, b);
        buffer = gcd(buffer,c);
        sum+=buffer;
      }
    }
  }
  cout << sum;

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <string>

using namespace std;

int keisan(int a, int b, int c) {
	if (c == 0) {
		return a+b;
	} else if (c == 1) {
		return a-b;
	} else {
		return a*b;
	}
}

int main() {
	int y[4];
	string abc = "+-*";
	string tt[24] = {"0123", "0132", "0213", "0231", "0312", "0321",
	                 "1023", "1032", "1203", "1230", "1302", "1320",
	                 "2013", "2031", "2103", "2130", "2301", "2310",
	                 "3012", "3021", "3102", "3120", "3201", "3210"};
	while (cin >> y[0] >> y[1] >> y[2] >> y[3]) {
		if (y[0] == 0 && y[1] == 0 && y[2] == 0 && y[3] == 0) {
			break;
		}
		bool hantei = false;
		for (int t = 0; t < 24; t++) {
			int a, b, c, d;
			a = y[tt[t][0]-'0'];
			b = y[tt[t][1]-'0'];
			c = y[tt[t][2]-'0'];
			d = y[tt[t][3]-'0'];
		for (int i = 0; i < 3; i++) {
			for (int j = 0; j < 3; j++) {
				for (int k = 0; k < 3; k++) {
					for (int l = 0; l < 5; l++) {
						if (l == 0) {
							int p = keisan(a, b, i);
							p = keisan(p, c, j);
							p = keisan(p, d, k);
							if (p == 10) {
								hantei = true;
								cout << "(((" << a << abc[i] << b << ")" << abc[j] << c << ")" << abc[k] << d << ")" << endl;
								break;
							}
						} else if (l == 1) {
							int p = keisan(a, b, i);
							int q = keisan(c, d, k);
							int r = keisan(p, q, j);
							if (r == 10) {
								hantei = true;
								cout << "((" << a << abc[i] << b << ")" << abc[j] << "(" << c << abc[k] << d << "))" << endl;
								break;
							}
						} else if (l == 2) {
							int p = keisan(b, c, j);
							p = keisan(a, p, i);
							p = keisan(p, d, k);
							if (p == 10) {
								hantei = true;
								cout << "((" << a << abc[i] << "(" << b << abc[j] << c << "))" << abc[k] << d << ")" << endl;
								break;
							}
						} else if (l == 3) {
							int p = keisan(b, c, j);
							p = keisan(p, d, k);
							p = keisan(a, p, i);
							if (p == 10) {
								hantei = true;
								cout << "(" << a << abc[i] << "((" << b << abc[j] << c << ")" << abc[k] << d << "))" << endl;
								break;
							}
						} else if (l == 4) {
							int p = keisan(c, d, k);
							p = keisan(b, p, j);
							p = keisan(a, p, i);
							if (p == 10) {
								hantei = true;
								cout << "(" << a << abc[i] << "(" << b << abc[j] << "(" << c << abc[k] << d << ")))" << endl;
								break;
							}
						}
					}
					if (hantei) {
						break;
					}
				}
				if (hantei) {
					break;
				}
			}
			if (hantei) {
				break;
			}
		}
		if (hantei) {
			break;
		}
		}
		if (!hantei) {
			cout << 0 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(){
  int i,x,n,a,j,b;
  scanf("%d",&n);
  for(i=1;i<=n;i++){
    a=10;
  //CHEK_NUM
    if(i%3==0){
      printf(" %d",i);
    }
    else if(i%10==3){
      printf(" %d",i);
    }
    else{
      for(j=0;j<4;j++){
	b=i/a;
	if(b%10==3){
	  printf(" %d",i);
	  break;
	}
	a=a*10;
      }
    }
  }
      printf("\n");
  return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n; cin >> n;
	vector<ll> a(n);
	rep(i, 0, n - 1)cin >> a[i];
	vector<ll> c(n + 1);
	c[0] = 0;
	rep(i, 0, n - 1)c[i + 1] = c[i] + a[i];
	map<ll, bool> isSeen;
	ll ans = 0;
	map<ll,ll> cnt;
	rep(i, 0, n)++cnt[c[i]];
	rep(i, 0, n)
	{
		if (isSeen[c[i]])continue;

		isSeen[c[i]] = true;
		ans += cnt[c[i]] * (cnt[c[i]] - 1) / 2;
	}
	cout << ans << endl;
}


Measured memory_bytes: 28416
(* O(n) *)
open Array
open Hashtbl
let n = Scanf.scanf " %d" @@ (+) 0
let a_s = init n @@ fun _ -> Scanf.scanf " %d" @@ (+) 0
let sums = make (n + 1) 0
let h = create @@ n + 1
let f s = try let c = find h s in replace h s @@ c + 1 with _ -> add h s 1
let _ =
  iteri (fun i a -> sums.(i + 1) <- sums.(i) + a) a_s;
  Array.iter f sums;
  fold (fun s c acc -> acc + if c > 1 then c * (c - 1) / 2 else 0) h 0 |> Printf.printf "%d\n"

Measured memory_bytes: 14464
n, t = map(int, input().split())
l = []
 
for i in range(n):
  a, b = map(int, input().split())
  l.append((a, b))
 
l.sort()
 
ans = 0
dp = [[0]*t for _ in range(n+1)]
for i in range(n):
  cur = dp[i][t-1] + l[i][1]
  ans = max(ans, cur)
  for j in range(t):
    dp[i+1][j] = max(dp[i+1][j], dp[i][j])
    nj = j+l[i][0]
    if nj < t:
      dp[i+1][nj] = max(dp[i+1][nj], dp[i][j]+l[i][1])
print(ans)

Measured memory_bytes: 116184
from collections import Counter
n=input()
lists=input().split()
hi=[]
low=[]
c=True
for i in range(len(lists)):
    if(i==0):
        same_c=lists[i]
    if(same_c==lists[i] and c):
        pass
    else:
        c=False

    if(i%2==0):
        hi.append(lists[i])
    else:
        low.append(lists[i])
if(c):
    print(len(hi))
    exit(0)
hi_counter=Counter(hi)
low_counter=Counter(low)
while(True):
    if(hi_counter.most_common()[0][0]!=low_counter.most_common()[0][0]):
        print(len(hi)-hi_counter.most_common()[0][1]+len(low)-low_counter.most_common()[0][1])
        exit(0)
    else:
        if(hi_counter.most_common()[0][1]-hi_counter.most_common()[1][1]>low_counter.most_common()[0][1]-low_counter.most_common()[1][1]):
            print(len(hi)-hi_counter.most_common()[0][1]+len(low)-low_counter.most_common()[1][1])
            exit(0)
        else:
            print(len(hi)-hi_counter.most_common()[1][1]+len(low)-low_counter.most_common()[0][1])
            exit(0)



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

using namespace std;

const long long MOD = 1000000007;
const long long MX = 200005;
long long h, w, a, b, fac[MX];

long long bin(long long k, long long l){
    if(l == 0){
        return 1;
    } else {
        long long res = (bin(k, l / 2) * bin(k, l / 2)) % MOD;
        if(l & 1){
            res = (res * k) % MOD;
        }
        return res;
    }
}

long long comb(long long x, long long y){
    long long res = fac[x + y];
    res = (res * bin(fac[x], MOD - 2)) % MOD;
    res = (res * bin(fac[y], MOD - 2)) % MOD;
    return res % MOD;
}
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    fac[0] = 1;
    for(long long i = 1; i < MX; i++){
        fac[i] = (fac[i - 1] * i) % MOD;
    }
    
    cin >> h >> w >> a >> b;
    long long startr = h - a;
    long long startc = b + 1;
    long long res = 0;
    while(startr >= 1 && startc <= w){
        res += (comb(startr - 1, startc - 1) * comb(h - startr, w - startc)) % MOD;
        startr--;
        startc++;
    }
    cout << res % MOD << '\n';
    return 0;
}

Measured memory_bytes: 1792
#!/usr/bin/env python3
from itertools import product


def read_data():
    N = int(input())
    testimonies = []

    for _ in range(N):
        A = int(input())
        testimonies_i = []

        for _ in range(A):
            x, y = map(int, input().split())
            testimonies_i.append((x - 1, y))  # 0-based

        testimonies.append(testimonies_i)

    return N, testimonies


def is_honest(pattern, i):
    # i番目の人が正直者であるか (0-based)
    return pattern[i]


def contradiction_exists(pattern, testimonies_i):
    # ある人の複数の証言に矛盾があるか
    for x, y in testimonies_i:
        if is_honest(pattern, x) != y:
            return True

    return False


def is_valid_pattern(pattern, testimonies):
    for i, p in enumerate(pattern):
        if not is_honest(pattern, i):
            continue

        if contradiction_exists(pattern, testimonies[i]):
            return False

    return True


def solve():
    N, testimonies = read_data()
    max_honest = 0

    for pattern in product([0, 1], repeat=N):
        # N=3 => [(0,0,0), (0,0,1), ..., (1,1,1)]
        if is_valid_pattern(pattern, testimonies):
            count_honest = sum(pattern)
            if count_honest > max_honest:
                max_honest = count_honest

    print(max_honest)


if __name__ == "__main__":
    solve()


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

p = list(map(int, input().split()))
tres = 0
res = 0
for i in range(K):
    tres += (p[i] + 1) / 2
res = max(res, tres)
for i in range(N - K):
    tres -= (p[i] + 1) / 2
    tres += (p[i + K] + 1) / 2
    res = max(res, tres)
print(res)


Measured memory_bytes: 25060
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define DEBUG true
#ifdef ONLINE_JUDGE
#undef DEBUG
#define DEBUG false
#endif 

using namespace std;

#define TRACE(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); cerr << endl;}

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << "[" << *it << " = " << a << "]";
	err(++it, args...);
}

#define MAXN ((int)2e5+5)
#define MOD ((int)1e9 + 7)
#define INF ((int)1e9 + 9)
#define ll long long
#define _ << " " <<
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define LOG(x) if(DEBUG) cerr << x << endl;
#define pb push_back
#define all(x) x.begin(), x.end()
#define endl "\n"
#define pii pair<int,int>
#define mid ((l+r)/2)

int n,k;
vector <ll> neg, pos, neg2, pick;

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	cin >> n >> k;
	for (int i = 0; i < n; ++i)
	{
		int a;
		cin >> a;
		if(a > 0) pos.pb(a);
		else neg.pb(a);
	}

	if(n == k)
	{
		ll ans = 1;
		for (ll x : pos)
			ans = (ans * (x)) % MOD;
		for (ll x : neg)
			ans = (ans * (x)) % MOD;
	
		cout << (ans + MOD) % MOD << endl;
	}
	else if((pos.size() == 0) and (k%2))
	{
		ll ans = 1;
		sort(neg.rbegin(), neg.rend());
		for (int i = 0; i < k; ++i)
			ans = (ans * (neg[i])) % MOD;
		cout << (ans + MOD) % MOD << endl;
	}
	else
	{
		sort(all(pos));
		sort(all(neg));
		for (int i = 0; i < (int)neg.size()-1; i+=2)
			neg2.pb(neg[i] * neg[i+1]);
		sort(all(neg2));

		int t = 0;
		int pt = pos.size()-1;
		int nt = neg2.size()-1;

		if(k%2)
		{
			pick.pb(pos[pt--]);
			t++;
		}

		while(t+2 <= k and nt >= 0 and pt > 0)
		{
			if(neg2[nt] > (pos[pt] * pos[pt-1]))
				pick.pb(neg2[nt--]);
			else
			{
				pick.pb((pos[pt] * pos[pt-1]));
				pt-=2;
			}
			
			t+=2;
		}

		if(nt < 0) // pick all pos
		{
			while(t < k)
			{
				t++;
				pick.pb(pos[pt--]);
			}
		}
		else if(pt <= 0)
		{
			while(t < k)
			{
				t+=2;
				pick.pb(neg2[nt--]);
			}			
		}

		ll ans = 1;
		for (ll x: pick)
			ans = (ans * (x % MOD)) % MOD;
		cout << ans << endl;
	}
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* WRITE STUFF DOWN
*/

Measured memory_bytes: 7292
#include "iostream"
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <string>
#include <cctype>
#include <stack>
#include <vector>
#include <list>
#include <queue>
using namespace std;
using ll=long long;
#define mod  1000000007

int main(int argc, char const *argv[]) {
  ll n,k;
  std::cin >> n >> k;
  int a[n];
  for(int i=0; i<n; i++){
    std::cin >> a[i];
  }

  int xl,xr,min=mod,dist;

  for(int i=0; i+k-1<n; i++){
    xl=a[i]; xr=a[i+k-1];
    if(abs(xr)>abs(xl)) dist=abs(xl-xr)+abs(xl);
    else dist=abs(xl-xr)+abs(xr);

    if(dist<min) min=dist;
  }

  std::cout << min << '\n';
  return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

#ifdef _DEBUG
#include "../../library/library/debug_template.cpp"
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

struct init {
	init() {
		cin.tie(nullptr); ios::sync_with_stdio(false);
		cout << fixed << setprecision(10);
	}
} init_;

int main() {

	char a;
	cin >> a;

	if ('a' <= a and a <= 'z') cout << 'a' << "\n";
	else cout << 'A' << "\n";

	return 0;
}



Measured memory_bytes: 3648
#include <algorithm>
#include <cmath>
#include <complex>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define MOD 1000000007
#define MOD2 998244353
#define PRIM 3
#define INF (1 << 29)
#define LINF (1LL << 60)
#define EPS (1e-10)
#define PI 3.1415926535897932384626433832795028
typedef long long Int;
typedef pair<Int, Int> P;
typedef long double Real;
typedef complex<Real> CP;

Int fact[11000000];
Int revfact[11000000];
Int rev[11000000];

void init()
{
    Int m = MOD;
    fact[0] = 1;
    revfact[0] = 1;
    rev[0] = 0;
    rev[1] = 1;
    for (int i = 1; i < 11000000; i++) {
        fact[i] = fact[i - 1] * i % m;
        if (i > 1)
            rev[i] = MOD / i * (MOD - rev[MOD % i]) % MOD;
        revfact[i] = revfact[i - 1] * rev[i] % MOD;
    }
}

Int nCk(Int n, Int k)
{
    if (n < k)
        return 0;
    return fact[n] * revfact[n - k] % MOD * revfact[k] % MOD;
}

Int n, a, ans;
int main()
{
    init();
    cin >> n >> a;
    for (int t = 1; t <= a + 1; t++) {
        int on = t - 1;
        int free = max(0ll, a - t);
        int off = n - a;
        for (int loop = 0; loop <= on; loop++) {
            Int tmp = fact[on - loop + off + free] * (on - loop) % MOD *
                      rev[on - loop + off] % MOD * nCk(on, loop) % MOD;
            if (loop % 2 == 0)
                ans = (ans + tmp) % MOD;
            else
                ans = (ans - tmp) % MOD;
        }
    }
    if (ans < 0)
        ans += MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 260976
#include <bits/stdc++.h>
#include <atcoder/all>
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;
using namespace atcoder;

signed main(){
	fastio
	int n, q;
	cin >> n >> q;
	dsu d(n);
	while(q--){
		int a,b,c;
		cin >> a >> b >> c;
		if(a==0) d.merge(b,c);
		else{
			cout << d.same(b,c) << "\n";
		}
	}
}

Measured memory_bytes: 4004
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s; i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
typedef long long ll;
const int MOD = 1000000007;
using namespace std;


int main(){
    int n, a; cin >> n >> a;
    cout << n*n - a << "\n";
    return 0;
}


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

string s;
int n,i;

int main(){
    cin >> s >> n;
    while(n){
        if (s[i] != '1')
        {
            cout << s[i] << endl;
            return 0;
        }
        n--,i++;
    }
    cout << 1 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
using namespace std; 
//python interactive_runner.py python3 local_testing_tool.py 0 -- ./Code
 
#define x first
#define y second
#define rep(i, a,b) for(int i = int(a); i < int(b); ++i)
#define forn(i,b) for(int i = 0; i < int(b); ++i)
const long long INF =1000000000000000000;

void solve(){
//	int N;
//	cin>>N;
//	long long prod = 1;
//	forn(i,N){
//		long long a;
//		cin>>a;
//		if(a==0){
//			cout<<0<<'\n';
//			return;
//		}
//		
//		if(INF/a<prod){
//			cout<<-1<<'\n';
//			return;
//		}	
//		prod = prod * a;	
//	}
//	cout<<prod<<'\n';
	long long A;
	string B;
	cin>>A>>B;
	int st = ((B[0]-'0')*100)+((B[2]-'0')*10)+((B[3]-'0'));
	cout<<(A*st)/100<<'\n';
}
int main(){

	 solve();
	return 0;
}

Measured memory_bytes: 3632
# n = x^2 + y^2 + z^2 + xy + yz +zx = ((x+y)^2 + (y+z)^2 + (x+z)^2)/2
# 1 <= x, y, z
# n >= 6

import math

N = int(input())
ans = [0] * N

#lim = int(math.sqrt(N/2))
lim = int(math.sqrt(N))
for x in range(1, lim):
    for y in range(1, lim):
        for z in range(1, lim):
            #calc = ((x+y)**2 + (y+z)**2 + (x+z)**2) /2
            calc = x**2 + y**2 + z**2 + x*y + y*z + z*x
            if calc <= N:
                ans[calc -1] += 1

#print(ans)
for a in ans:
    print(a)



Measured memory_bytes: 9144
#include <bits/stdc++.h>
//#define local
#ifdef local
#include "dbg-macro/dbg.h"
#endif
#define ll long long
#define pi (acos(-1))
#define rep(i, n) for (unsigned long long i = 0; i < (unsigned long long)(n); ++i)
using namespace std;
std::vector<unsigned ll> genprimevec(const unsigned ll N);

int main()
{
    int n;

    cin >> n;
    vector<int> s(n, 0);
    rep(i, n) { cin >> s[i]; }
    sort(s.begin(), s.end(), [](int l, int r) { return l > r; });
    int sum = accumulate(s.begin(), s.end(), 0);
    if (sum % 10 != 0)
    {
        cout << sum << endl;
        return 0;
    }
    rep(i, s.size())
    {
        if ((sum - s[s.size() - i - 1]) % 10 != 0)
        {
            cout << sum - s[s.size() - i - 1] << endl;
            return 0;
        }
    }


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

/*author  https://qiita.com/drken/items/0c88a37eec520f82b788*/
ll extgcd(ll a, ll b, ll &x, ll &y)
{
    if (b == 0)
    {
        x = 1, y = 0;
        return a;
    }
    ll d = extgcd(b, a % b, y, x);
    y -= a / b * x;
    return d;
}


std::vector<unsigned ll> genprimevec(const unsigned ll N)
{
    std::vector<bool> is_prime(N + 1);
    for (unsigned ll i = 0; i <= N; i++) { is_prime[i] = true; }
    std::vector<unsigned ll> P;
    for (unsigned ll i = 2; i <= N; i++)
    {
        if (is_prime[i])
        {
            for (unsigned ll j = 2 * i; j <= N; j += i) { is_prime[j] = false; }
            P.emplace_back(i);
        }
    }
    return P;
}


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

n, a, *x = map(int, read().split())
dp = [[0] * max(sum(x) + 1, a * n + 1) for _ in range(n + 1)]
dp[0][0] = 1
ans = 0
for i in range(n):
    for k in range(n - 1, -1, -1):
        for j in range(sum(x)):
            if dp[k][j] != 0:
                dp[k + 1][j + x[i]] += dp[k][j]
for i in range(1, n + 1):
    ans += dp[i][a * i]
print(ans)


Measured memory_bytes: 4468
#include <iostream>

using namespace std;
int main() {
	int n;
	cin >> n;
	int c = 0;
	while (n > 0) {
		if (n % 10 == 2) {
			c++;
		}
		n /= 10;
	}
	cout << c << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, K;

int main(){
  cin >> N >> K;
  if((N - 1) * (N - 2) / 2 < K) {
    cout << -1 << endl;
    return 0;
  }

  cout << N - 1 + (N - 1) * (N - 2) / 2 - K << endl;

  REP(i, N - 1) {
    cout << N << " " << i + 1 << endl;
  }

  ll ct = 0;
  if((N - 1) * (N - 2) / 2 == K) return 0;
  for(int i = 1; i < N - 1; i++) {
    for(int j = i + 1; j < N; j++) {
      ct++;
      cout << i << " " << j << endl;
      if(ct == (N - 1) * (N - 2) / 2 - K) {
        return 0;
      }
    }
  }


  return 0;
}


Measured memory_bytes: 256
// #pragma GCC optimize("Ofast")
// #pragma GCC target("avx,avx2,fma")
// #pragma GCC optimization ("unroll-loops")
#include <bits/stdc++.h>
using namespace std;

/********************************************************************/
#define M1 1000000007
#define M3 1000000009
#define M2 998244353
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repr(i,a,b) for(ll i=b-1;i>=a;i--)
#define forr(i,n) for(ll i=0;i<n;i++)
#define F first
#define S second
#define pb push_back
#define DB pop_back
#define mp make_pair
#define MT make_tuple
#define V(a) vector<a>
#define vi vector<ll>
#define endl '\n'
#define ce(ele) cout<<ele<<' '
#define cs(ele) cout<<ele<<'\n'
#define yep cout<<"YES"<<'\n'
#define nope cout<<"NO"<<'\n'
#define CASE(te) ll te; cin>>te; while(te--)
#define sor(v) sort(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())

/********************************************************************/
const double pi = 3.1415926535;
//const int mx = 69;
//char grid[mx][mx];
// ll blocked[mx][mx];
// ll vis[mx][mx];
/********************************************************************/
//FAST IO//
void FAST() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
}

/********************************************************************/

ll power(ll x,ll y,ll p) 
{ 
    ll res = 1; 
    x = x % p; 
    while (y > 0) 
    {  
        if (y & 1) 
         res = (res * x) % p; 
        y = y >> 1; 
        x = (x * x) % p; 
    } 
    return res; 
} 

bool isprime(ll n) 
{ 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
} 
  

vector<ll> digit(ll n)
{
    ll arr[10000];
    ll i=0;
    ll j,r;
    vi v;
    while(n!=0)
    {
        r = n % 10;
        arr[i] = r;
        i++;
        n = n / 10;
    }
    for(j=i-1;j>-1;j--)
    {
        v.pb(arr[j]);
    }
    return v;
}

ll sum(ll x) {
	ll ans = 0;
	while (x > 0) {
		ans += (x % 10);
		x /= 10;
	}
	return ans;
}

bool opp(int x, int y)
{
    return ((x ^ y) < 0);
}

bool bysec(const pair<int,int> &a, const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
}

int main()
{
  FAST();
  ll a,b,c,d;
  cin>>a>>b>>c>>d;
  ll ans=max({a*c,a*d,b*c,b*d});
  if(ans<0)
  {
    if(a<0 && b>0)
    cs(0);
    else if(c<0 && d>0)
    cs(0);
    else
    {
        cs(ans);
    }
    
  }
  else
  {
      cs(ans);
  }
  
//   if(max(a,b)>0 && max(c,d)>0)
//   cs(max(a,b)*max(c,d));
//   else if(max(a,b)<0 && max(c,d)<0)
//   cs(min(a,b)*min(c,d));
  
//   else if(max(a,b)>0 && max(c,d)<0)
//   cs(min(a,b)*max(c,d));
//   else if(max(a,b)<0 && max(c,d)>0)
//   cs(max(a,b)*min(c,d));
//   else
//   {
//       cs(min(a,b)*min(c,d));
//   }
  
  
}


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

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

    string S[N];
    rep(i, N) cin >> S[i];

    int num[30] = {};
    for (int i = 0; i <= 'z' - 'a'; i++) {
        char c = 'a' + i;
        rep(n, N) {
            int num_c = 0;
            rep(k, S[n].size()) if (S[n][k] == c) num_c++;

            if (n == 0) num[i] = num_c;
            else num[i] = min(num[i], num_c);
        }
    }

    string ans = "";
    for (int i = 0; i<='z' - 'a'; i++) {
        char c = 'a' + i;
        ans.append(num[i], c);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define bFor(i,a,b) for(i=a;i>=b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
#define endl "\n"
#define output(v) do{bool f=0;for(auto i:v){cout<<(f?" ":"")<<i;f=1;}cout<<endl;}while(0)

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll modncrlistp[200000],modncrlistm[200000];

ll modncrs(ll n,ll r){
  ll i,j;
  if(modncrlistp[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistp[i])break;
    }
    if(i<0){
      modncrlistp[0]=1;
      rep1(i,n+1){
        modncrlistp[i]=(modncrlistp[i-1]*i)%mod;
      }
    }else{
      For(j,i+1,n+1){
        modncrlistp[j]=(modncrlistp[j-1]*j)%mod;
      }
    }
  }
  if(modncrlistm[n]==0){
    for(i=n;i>=0;i--){
      if(modncrlistm[i])break;
    }
    if(i<0){
      modncrlistm[0]=1;
      rep1(i,n+1){
        modncrlistm[i]=(modncrlistm[i-1]*modinv(i))%mod;
      }
    }else{
      For(j,i+1,n+1)modncrlistm[j]=(modncrlistm[j-1]*modinv(j))%mod;
    }
  }
  return (((modncrlistp[n]*modncrlistm[r])%mod)*modncrlistm[n-r])%mod;
}

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

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

vec eratosthenes(ll N){
  ll i;
  vec ch(N+1,1),p;
  ch[0]=ch[1]=0;
  rep(i,N+1){
    if(ch[i]){
      p.push_back(i);
      for(ll j=2;i*j<=N;j++){
        ch[i*j]=0;
      }
    }
  }
  return ch;
}
int main(){
  ll i,N,bf=0,ans=0;
  cin>>N;
  vec a(N);
  rep(i,N){
    cin>>a[i];
  }
  if(a[0]!=0){
    cout<<-1<<endl;
    return 0;
  }
  brep(i,N){
    if(bf<a[i]){
      bf=a[i];
      ans+=a[i];
    }else if(bf>a[i]){
      cout<<-1<<endl;
      return 0;
    }
    bf--;
  }
  cout<<ans<<endl;
  return 0;
}

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

H_sorted = sorted(H, reverse = True)
cnt = 0

for i in range(K) :
    if i < N :
        H_sorted[i] = 0

for j in H_sorted :
    if j == 0 :
        continue
    else :
        cnt = cnt + j

print(cnt)



Measured memory_bytes: 26764
#include <iostream>
using namespace std;
#define MAX 51

int main(){
    int n,p,st[MAX];
    
    while(cin >> n >> p){
        bool flg = false;
        if(!n && !p) break;
        fill(st,st+n,0);
        
        int k = 0 , t = p;
        while(true){
            if(t){
                t--;
                st[k]++;
            }
            else{
                t += st[k];
                st[k] = 0;
            }
            k++;
            if(k == n) k = 0;
            
            for(int i = 0 ; i < n ; i++){
                if(st[i]==p){
                    cout << i << endl;
                    flg = true;
                    break;
                }
            }
            if(flg) break;
        }
    }
    
    return 0;
}

Measured memory_bytes: 1160
#include<stdio.h>
int P[100010]={0};
int d[100010]={0};
int e=0;
void Marge(int p,int c){
  P[c]=p;
  if(d[p]==d[c])P[c]=p;
}
int Find(int a,int b){
  int r,n;
  for(r=a;P[r]-r;r=P[r]);
  for(;P[a]-a;){
    n=P[a];
    P[a]=r;
    a=n;
  }
  for(r=b;P[r]-r;r=P[r]);
  for(;P[b]-b;){
    n=P[b];
    P[b]=r;
    b=n;
  }
  return a-b?1:0;
}
void Union(int a,int b){
  if(Find(a,b)){
    for(;P[a]-a;a=P[a]);
    for(;P[b]-b;b=P[b]);
    d[a]<d[b]?(Marge(b,a)):(Marge(a,b));
    e++;
  }
}
int main(){
  int n,a[100010],b[100010],c[100010]={};
  int i,d[100010]={};
  scanf("%d",&n);
  for(i=0;i<100010;i++)P[i]=i;
  for(i=0;i<n;i++)scanf("%d %d",&a[i],&b[i]);
  for(i=0;i<n;i++){
    if(c[a[i]]||d[b[i]])goto END;
    c[a[i]]=d[b[i]]=1;
    Union(a[i],b[i]);
  }    
  printf("%d\n",e);
  return 0;
 END:;
  printf("-1\n");
  return 0;
}
  



Measured memory_bytes: 3752