akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <iomanip>
#include <stdlib.h>

using namespace std;

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

  vector <int> A(N), B(N), C(N);
  for (int i = 0; i < N; i++){
    cin >> A[i] >> B[i] >> C[i];
  }
  
  int DP[N][3];

  DP[0][0] = A[0];
  DP[0][1] = B[0];
  DP[0][2] = C[0];

  for (int i = 1; i < N; i++){
    DP[i][0] = A[i] + max(DP[i - 1][1], DP[i - 1][2]);
    DP[i][1] = B[i] + max(DP[i - 1][0], DP[i - 1][2]);
    DP[i][2] = C[i] + max(DP[i - 1][0], DP[i - 1][1]);
  }

  cout << max(DP[N - 1][0], max(DP[N - 1][1], DP[N - 1][2])) << endl;
  


  return 0;
}


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

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

    string S;
    cin >> S;

    string a = S.substr(0,N/2);
    string b = S.substr(N/2,N);

    if(a == b)
    {
        cout << "Yes"<<endl;
    }
    else
    {
        cout << "No" <<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define mp make_pair
#define pb push_back
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void Taka() { cout << "Takahashi" << endl; }
void Aoki() { cout << "Aoki" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

int main() {
	string s, t;
	cin >> s >> t;
	sort(all(s));
	sort(t.rbegin(), t.rend());

	if (s < t)
		Yes();
	else
		No();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;

// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;

int main ()
{
  prep();
  
  long long h, w, n;
  cin >> h >> w >> n;
  vector<pair<int, int> > v;
  set<pair<int, int> > have;
  for (int i=0; i<n; i++){
      int x, y;
      cin >> x >> y;
      have.emplace(x, y);
      v.emplace_back(x, y);
  }
  long long ones[10] = {0}; // don't count 0's
  for (pair<int, int> p : v){
      int x = p.first;
      int y = p.second;
      for (int i=x-2; i<x+1; i++){
          for (int j=y-2; j<y+1; j++){
              int cnt = 0;
              for (int k=0; k<9; k++){
                  int newx = i+k/3;
                  int newy = j+k%3;
                  if (newx <= 0 || newy <= 0 || newx > h || newy > w){
                      cnt = 0;
                      break;
                  }
                  if (have.count({newx, newy})){
                      cnt++;
                  }
              }
              ones[cnt]++;
          }
      }
  }
  long long full = 0;
  for (int i=1; i<=9; i++){
      ones[i] /= i;
      full += ones[i];
  }
  cout << (h-2)*(w-2)-full << '\n';
  for (int i=1; i<=9; i++){
      cout << ones[i] << '\n';
  }
  return 0; 
}

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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)
#define mp make_pair

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int32 n;
    cin >> n;
    vector<int32> hint(n,-1);
    int32 m;
    cin >> m;
    REP(i,m){
        int32 s,c;
        cin >> s >> c;
        s--;
        if(hint[s] != -1 && hint[s] != c){
            cout << -1 << endl;
            return 0;
        }
        hint[s] = c;
    }
    if(n != 1 && hint[0] == 0){
        cout << -1 << endl;
        return 0;
    }
    REP(i,n){
        if(hint[i] == -1){
            if(n != 1 && i == 0){
                cout << 1;
            }else{
                cout << 0;
            }
        }else{
            cout << hint[i];
        }
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<algorithm>
#include<vector>
#include<set>
#include<map>
#include<cmath>
#define int long long int
int power(int a,int b,int k)
{
	if(b==0)
	   return 1%k;
	else
	{
		int r=power(a,b/2,k);
		if(b%2==0)
		{
			return (r*r)%k;
		}
		else
		{
			int x=(r*r)%k;
			return (a*x)%k;
		}
	}
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int k;
	cin>>k;
	int j;
	int val=0;
	for(j=1;j<=k+10;j++)
	{
		val*=10;
		val+=7;
		val=val%k;
		if(val==0)
		{
			cout<<j<<endl;
			exit(0);
		}
	}
	cout<<-1<<endl;
}


Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iterator>
using namespace std;
typedef long long unsigned int ll;

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

int main() {

	int A, B, T;
	cin >> A >> B >> T;

	cout << (T / A) * B;
	return 0;
}

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

int main(){
    int x[11];
    int r;
    int D;
    cin >> r >> D >> x[0];
    for(int i = 0; i < 10; i ++){
        x[i + 1] = (r * x[i]) - D;
        cout << x[i + 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
	int n, x[100000], y[100000];
	cin >> n;
	for (int i = 0; i < n/2; i++) cin >> x[i] >> y[i];
	int ans = 0;
	int numx[100001] = { 0 }, numy[100001] = { 0 }, numX[100001] = { 0 }, numY[100001] = { 0 };
	for (int i = 0; i < n; i++) numx[x[i]]++, numy[y[i]]++, numX[x[i]]++, numY[y[i]]++;
	sort(numx + 1, numx + 100000,greater<int>());
	sort(numy + 1, numy + 100000,greater<int>());
	if (numx[1] == numx[2] || numy[1] == numy[2]) cout << n - numx[1] - numy[1];
	else {
		int X, Y;
		for (int i = 1; i <= 100000; i++) {
			if (numx[1] == numX[i]) X = i;
			if (numy[1] == numY[i]) Y = i;
		}
		if (X == Y) cout << min(n - numx[1] - numy[2], n - numx[2] - numy[1]);
		else cout << n - numx[1] - numy[1];
	}
}

Measured memory_bytes: 2560
/* Filename: ARC083D.java
 * Author: Mushiyo
 */

import java.util.Scanner;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) {
		final int INF = Integer.MAX_VALUE;
		Scanner input = new Scanner(System.in);

		while (input.hasNext()) {
			int N = input.nextInt();
			long[][] shortestPath = new long[N][N];

			for (int u = 0; u < shortestPath.length; ++u) {
				for (int v = 0; v < shortestPath[u].length; ++v) {
					shortestPath[u][v] = input.nextInt();
				}
			}

			long[][] graph = new long[N][N];
			for (int u = 0; u < graph.length; ++u) {
				graph[u][u] = 0;
				for (int v = u + 1; v < graph[u].length; ++v) {
					graph[u][v] = INF;
					graph[v][u] = INF;
				}
			}

			for (int u = 0; u < shortestPath.length; ++u) {
				for (int v = 0; v < shortestPath[u].length; ++v) {
					boolean hasMid = false;
					for (int mid = 0; mid < shortestPath.length; ++mid) {
						if (shortestPath[u][mid] + shortestPath[mid][v] == shortestPath[u][v]) {
							if (mid != u && mid != v) {
								hasMid = true;
							}
						}
					}

					if (hasMid == false) {
						graph[u][v] = shortestPath[u][v];
						graph[v][u] = shortestPath[u][v];
					}
				}
			}

			long[][] Floyd_Warshall = new long[N][N];
			for (int i = 0; i < Floyd_Warshall.length; ++i) {
				System.arraycopy(graph[i], 0, Floyd_Warshall[i], 0, graph.length);
			}

			for (int mid = 0; mid < Floyd_Warshall.length; ++mid) {
				for (int u = 0; u < Floyd_Warshall.length; ++u) {
					for (int v = 0; v < Floyd_Warshall[u].length; ++v) {
						Floyd_Warshall[u][v] = Math.min(Floyd_Warshall[u][v],
								Floyd_Warshall[u][mid] + Floyd_Warshall[mid][v]);
					}
				}
			}

			boolean isExist = true;
			for (int i = 0; i < shortestPath.length; ++i) {
				if (Arrays.equals(shortestPath[i], Floyd_Warshall[i]) == false) {
					isExist = false;
					break;
				}
			}

			if (isExist) {
				long pathLen = 0;
				for (int u = 0; u < graph.length; ++u) {
					for (int v = u + 1; v < graph[u].length; ++v) {
						if (graph[u][v] != INF) {
							pathLen += graph[u][v];
						}
					}
				}

				System.out.println(pathLen);
			} else {
				System.out.println(-1);
			}
		}
	}

}


Measured memory_bytes: 62508
def main():
    n = input()[::-1] + "0"
    s = 0
    cnt = 0
    for i, ni in enumerate(n[:-1]):
        k = int(ni) + s
        if k < 5 or k == 5 and int(n[i + 1]) < 5:
            cnt += k
            s = 0
        else:
            cnt += 10 - k
            s = 1
    cnt += s
    print(cnt)

if __name__ == '__main__':
    main()

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

int main()
{
    int s; cin >> s;
    vector<int> dp(s+1, 0);
    dp[0] = 1;
    for(int i=1; i<=s; i++){
        for(int j=0; j<=i-3; j++){
            dp[i] += dp[j];
            dp[i] %= mod;
        }
            
    }

    cout << dp[s] << endl;
    return 0;
    
}

Measured memory_bytes: 3620
#include<queue>
#include<cstdio>
#include<vector>
#include<cstring>
#include<algorithm>
using namespace std;

int read(){
    int x=0;bool f=0;char c=getchar();
    while(c<'0'||c>'9') f|=c=='-',c=getchar();
    while(c>='0'&&c<='9') x=x*10+(c^48),c=getchar();
    return f?-x:x;
}

#define MAXN 50000
#define MAXM 1000000
#define INF 1ll<<60
#define int long long
struct Edge{
    int v,w,c,Next;
}E[MAXM+5];
int Adj[MAXN+5],ecnt;
void AddEdge(int u,int v,int Cap,int Cost){
    E[ecnt].v=v,E[ecnt].w=Cap,E[ecnt].c= Cost,E[ecnt].Next=Adj[u],Adj[u]=ecnt++;
    E[ecnt].v=u,E[ecnt].w=0,  E[ecnt].c=-Cost,E[ecnt].Next=Adj[v],Adj[v]=ecnt++;
}

int pre[MAXN+5];
int Dist[MAXN+5];
bool vis[MAXN+5];
int cnt[MAXN+5];
bool SPFA(int S,int T,int N,int &Flow,int &Cost){
    for(int i=0;i<=N;i++)
        Dist[i]=INF,pre[i]=-1,vis[i]=0,cnt[i]=0;
    queue<int> Q;
    Q.push(S);
    Dist[S]=0,vis[S]=1;
    while(!Q.empty()){
        int u=Q.front();Q.pop();vis[u]=0;
        for(int i=Adj[u];i!=-1;i=E[i].Next){
            int v=E[i].v,c=E[i].c;
            if(E[i].w&&Dist[v]>Dist[u]+c){
                Dist[v]=Dist[u]+c;
                pre[v]=i;
                if(!vis[v]){
                    ++cnt[v];
                    vis[v]=1,Q.push(v);
                }
            }
        }
    }
    if(Dist[T]==INF)
        return 0;
    int Min=INF;
    for(int i=pre[T];i!=-1;i=pre[E[i^1].v])
        Min=min(Min,E[i].w);
    for(int i=pre[T];i!=-1;i=pre[E[i^1].v])
        E[i].w-=Min,E[i^1].w+=Min,Cost+=E[i].c*Min;
    Flow+=Min;
    return 1;
}
pair<int,int> Dinic(int S,int T,int N){
    int Flow=0,Cost=0;
    while(1)
        if(!SPFA(S,T,N,Flow,Cost))
            break;
    return make_pair(Flow,Cost);
}

#undef MAXN
#undef MAXM

#define MAXM 1000
int N,M,K;
int A[MAXM+5];

signed main(){
    N=read();
    ecnt=0;
    memset(Adj,-1,sizeof Adj);
    for(int i=1;i<=N;i++){
        int x=read(),y=read(),c=read();
        AddEdge(1,i+1,c,0);
        AddEdge(i+1,N+2,INF,x+y);
        AddEdge(i+1,N+3,INF,-x+y);
        AddEdge(i+1,N+4,INF,x-y);
        AddEdge(i+1,N+5,INF,-x-y);
    }
    for(int i=1;i<=N;i++){
        int x=read(),y=read(),c=read();
        AddEdge(i+5+N,2*N+6,c,0);
        AddEdge(N+2,i+5+N,INF,-x-y);
        AddEdge(N+3,i+5+N,INF,x-y);
        AddEdge(N+4,i+5+N,INF,-x+y);
        AddEdge(N+5,i+5+N,INF,x+y);
    }
    printf("%lld",-Dinic(1,2*N+6,2*N+6).second);
    return 0;
}


Measured memory_bytes: 3200
package main

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

func main() {
	sc := NewScanner()
	A, B := sc.NextInt(), sc.NextInt()

	fmt.Println(max(A-2*B, 0))
}
func max(a int, b int) int {
	if a < b {
		return b
	}
	return a
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}
func (s *Scanner) NextInt64() int64 {
	v, _ := strconv.ParseInt(s.Next(), 10, 64)
	return v
}

func (s *Scanner) NextFloat() float64 {
	v, _ := strconv.ParseFloat(s.Next(), 64)
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 0)
			result = append(result, int(v))
			start = s.p + 1
		}
	}

	return result
}
func (s *Scanner) NextInt64Array() []int64 {
	s.pre()
	start := s.p
	result := []int64{}
	for ; s.p < len(s.buf)+1; s.p++ {
		if s.p == len(s.buf) || s.buf[s.p] == ' ' {
			v, _ := strconv.ParseInt(string(s.buf[start:s.p]), 10, 64)
			result = append(result, v)
			start = s.p + 1
		}
	}
	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 640
#include<iostream>
#include<vector>
#include<math.h>

#define REP(i,n) for(int i=0; i<n; ++i)

using namespace std;

double distance(vector<double> y, vector<double> z){
    double sum = 0;
    REP(i,(int)y.size()){
        sum += (y[i]-z[i])*(y[i]-z[i]);
    }
    return sqrt(sum);
}

double distance2(double* y, double* z, int D){
    double sum = 0;
    REP(i,D){
        sum += (y[i]-z[i])*(y[i]-z[i]);
    }
    return sqrt(sum);
}

int second(){
    double X2[10][10];
    int N,D=0;
    cin >> N >> D;
    for(int i=0;i<N;++i){
        for(int j=0;j<D;++j){
            cin >> X2[i][j];
        }
    }
    //mainloop
    int cnt=0;
    for(int i=0; i<N; ++i){
        for(int j=i+1; j<N; ++j){
            if(i==j) continue;
            double d = distance2(X2[i],X2[j],D);
            if((int)d==d) ++cnt;
        }
    }
    cout << cnt << endl;
    return 0;    
}

//なんかエラー(no type named iterator_category)になるのでvector使わない...
int main(){
    if(true){
        second();
        return 0;
    }
    /*
    int N,D=0;
    cin >> N >> D;
    vector<vector<double> > X(N,vector<double>(D,0));
    REP(i,N){
        REP(j,D){
            cin >> X[i][j];
        }
    }
    //mainloop
    int cnt=0;
    for(int i=0; i<N; ++i){
        for(int j=i; j<N; ++j){
            if(i==j) continue;
            double d = distance(X[i],X[j]);
            if((int)d!=d) ++cnt;
        }
    }
    cout << cnt;
    */
    return 0;    
}



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

using namespace std;

int dp[32][15]; // dp[Y][X]
int field[32][16];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    while(true) {
        int X, Y;
        cin >> X >> Y;
        if(!X && !Y) break;

        // Initialize
        for(int i = 0; i < Y; ++i) {
            for(int j = 0; j < X; ++j) {
                cin >> field[i][j];
                dp[i][j] = 0;
            }
        }
        for(int j = 0; j < X; ++j) {
            dp[Y][j] = 0;
        }

        // Base case
        for(int i = 0; i < X; ++i) {
            if(field[0][i] == 0) dp[0][i] = 1;
            else dp[0][i] = 0;
        }
        for(int i = 0; i < Y-1; ++i) {
            for(int j = 0; j < X; ++j) {
                if(field[i][j] == 0) {
                    // Move
                    for(int dx = -1; dx <= 1; ++dx) {
                        const int nx = j + dx;
                        if(nx < 0 || nx >= X) continue;
                        if(field[i+1][nx] == 0) dp[i+1][nx] += dp[i][j];
                        else if(dx == 0 && field[i+1][nx] == 2) dp[i+1][nx] += dp[i][j];
                    }
                } else if(field[i][j] == 2) {
                    // Jump
                    if(field[i+2][j] != 1) dp[i+2][j] += dp[i][j];
                }
            }
        }
        int ans = 0;
        for(int i = 0; i < 2; ++i) {
            for(int j = 0; j < X; ++j) {
                ans += dp[Y-1+i][j];
            }
        }
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 1200
import java.util.Scanner;
 
public class Main {
	public static void main(String[] args) {
		
		Scanner sc=new Scanner(System.in);
		
		int X=sc.nextInt();
		
		int A=X/500;
		int B=(X-(500*A))/5;
		
		System.out.println((A*1000)+(B*5));
		
		sc.close();
	}
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define int long long
using namespace std;

signed main(){
  
  int A, B;
  cin>>A>>B;
  
  if( A <= 5 ) cout<<0<<endl;
  else if( A <= 12 ) cout<<B/2<<endl;
  else cout<<B<<endl;
  
  return 0;
}


Measured memory_bytes: 764
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n := scanInt()
	v := scanInts(n)
	cnt0 := map[int]int{}
	cnt1 := map[int]int{}
	for i := 0; i < n; i++ {
		if i&1 == 0 {
			cnt0[v[i]]++
		} else {
			cnt1[v[i]]++
		}
	}

	ma := [2][2]int{}
	memo := [2][2]int{}
	for v, e := range cnt0 {
		if ma[0][0] < e {
			ma[0][1] = ma[0][0]
			memo[0][1] = memo[0][0]
			ma[0][0] = e
			memo[0][0] = v
		} else if ma[0][1] < e {
			ma[0][1] = e
			memo[0][1] = v
		}
	}
	for v, e := range cnt1 {
		if ma[1][0] < e {
			ma[1][1] = ma[1][0]
			memo[1][1] = memo[1][0]
			ma[1][0] = e
			memo[1][0] = v
		} else if ma[1][1] < e {
			ma[1][1] = e
			memo[1][1] = v
		}
	}

	ans := n
	if memo[0][0] == memo[1][0] {
		if ma[0][0] > ma[1][0] || (ma[0][0] == ma[1][0] && ma[0][1] < ma[1][1]) {
			ans -= ma[0][0] + ma[1][1]
		} else {
			ans -= ma[0][1] + ma[1][0]
		}
	} else {
		ans -= ma[0][0] + ma[1][0]
	}
	fmt.Fprintln(wr, ans)
}


Measured memory_bytes: 7296
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		if(s[1] != s[2]) {
			System.out.println("No");
		}else if(s[0] == s[1] || s[2] == s[3]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		sc.close();
	}
}

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

public class Main {
	private static void solve(){
	//Implement solution here.
		int n = ni();
		int[] p = na(n);
		int result = 0;
		for(int i = 1; i < n -1; i++) {
			if((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) {
				result++;
			}
		}
		System.out.println(result);
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include <memory.h>

#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>

using namespace std;

#define MOD 1000000007
#define INIT -1

int main() {
	int n;
	cin >> n;
	int a[50];
	int maxabsidx = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (abs(a[i]) > abs(a[maxabsidx])) {
			maxabsidx = i;
		}
	}
	cout << 2 * n - 1 << endl;
	for (int i = 0; i < n; i++) {
		cout << maxabsidx + 1 << " " << i + 1 << endl;
	}
	if (a[maxabsidx] > 0) {
		for (int i = 1; i < n; i++) {
			cout << i << " " << i + 1 << endl;
		}
	} else {
		for (int i = n - 2; i >= 0; i--) {
			cout << i + 2 << " " << i + 1 << endl;
		}
	}
}

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

using namespace std;
int main(){
  string weather;
  cin >> weather;
  if(weather == "Sunny")
    cout << "Cloudy" << endl;
  if(weather == "Cloudy")
    cout << "Rainy" << endl;
  if(weather == "Rainy")
    cout << "Sunny" << endl;
  return 0;
}

Measured memory_bytes: 256
function main(input) {
	var n = input.split(' ');
  	var a = parseInt (n[0], 10);
  	var b = parseInt (n[1], 10);
  
  	if ((a * b) % 2 === 0) {
      	console.log('Even');
    } else {
      	console.log('Odd');
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29508
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int N = scan.nextInt();
        int taco[] = new int[N];
        int sum = 0;
        for (int i = 0; i < N; i++) {
            taco[i] = scan.nextInt();
        }
        for (int i = 0; i < N; i++) {
            for (int j = i + 1; j < N; j++) {
                sum += taco[i] * taco[j];
            }
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 21716
#include <iostream>
//#include <stdio.h>
using namespace std;

int main(){
	int n;
	long a;
	long max=100000, min=-1000000,sum = 0;
	
	cin >> n;
	for (int i=0;i < n;i++){
		cin >> a;
		sum += a;
		if (i == 0) {max = a; min = a;} 
		if (max <= a) max = a;
		if (min >= a) min = a;
		}
	cout << min << " " << max << " " << sum << endl;
	return 0;
}

Measured memory_bytes: 1164
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 1000000007
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0,1,1,-1,-1};
int dy[8]={0,-1,0,1,1,-1,1,-1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------


//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    int n;cin>>n;
    vector<int>a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    sort(all(a));
    cout<<a[n-1]-a[0]<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






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

int main(void){
	int n, h;
	cin >> n >> h;
	vector<int> a(n), b(n);
	for(int i = 0; i < n; ++i){
		cin >> a[i] >> b[i];
	}
	sort(a.rbegin(), a.rend());
	sort(b.rbegin(), b.rend());
	vector<long long> bb(n+1);
	bb[0] = 0;
	for(int i = 0; i < n; ++i){
		bb[i+1] = bb[i] + b[i];
	}
	long long ans = INT_MAX;
	for(int i = 0; i <= n; ++i){
		long long cnt;
		if(h-bb[i]>=0) cnt = i + ceil(((double)h-bb[i])/a[0]);
		else cnt = i;
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false), cin.tie(0);
#define ll long long
#define endl '\n'

const int N = 1e5+10;
const int M = 1e9+7;

using namespace std;

ll fexp (ll x, ll y)
{
    ll r=1;
    x=x%M;
    while (y)
    {
        if (y&1)
            r=(r*x)%M;
        x=(x*x)%M;
        y>>=1;
    }
    return r;
}

main()
{
    fast;
    ll n,k,i,j,ans=0;
    cin>>n>>k;
    ll factors,Kcnt[N],cnt;
    memset(Kcnt,0LL,sizeof(Kcnt));
    for (i=k;i>=1;i--)
    {
        factors=k/i;
        cnt=fexp(factors,n)%M;
        for (j=2*i;j<=k;j+=i)
            cnt=(cnt%M-Kcnt[j]%M+M)%M;
        Kcnt[i]=cnt%M;
        ans=(ans%M+((Kcnt[i]%M)*(i%M))%M)%M;
    }
    cout<<ans%M<<endl;
}

Measured memory_bytes: 4428
import sys
 
stdin = sys.stdin
inf = 1 << 60
mod = 1000000007
 
ni = lambda: int(ns())
nin = lambda x: [ni() for _ in range(x)]
na = lambda: list(map(int, stdin.readline().split()))
nan = lambda x: [na() for _ in range(x)]
ns = lambda: stdin.readline().rstrip()
nsn = lambda x: [ns() for _ in range(x)]
nas = lambda: stdin.readline().split()

n, i = na()

print(n - i + 1)

Measured memory_bytes: 3064
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <bitset>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <queue>
#include <functional>

#define mp make_pair
#define pb push_back


typedef long long ll;
typedef long long llong;
typedef long double ld;

using namespace std;

#ifndef LOCAL
#define cerr _cer
struct _cert
{
    template <typename T> _cert& operator << (T) { return *this; }
};
_cert _cer;
#endif

template <typename T> void dprint(T begin, T end) {
    for (auto i = begin; i != end; i++) {
        cerr << (*i) << " ";
    }
    cerr << "\n";
}


vector<int> eds[120000];
int was[120000];
int n; 
int dfs1(int v) {
    was[v] = 1;
    int sum = 0;
    for (int u: eds[v]) {
        if (!was[u])
            sum += dfs1(u);
    }
    if (sum >= 2) {
        cout << "First\n";
        exit(0);
    }
    if (sum) {
        return 0;
    }
    else {
        return 1;
    }
}

int main() {
    scanf("%d", &n);
    for (int i = 0; i < n - 1; ++i) {
        int a, b;
        scanf("%d%d", &a, &b);
        --a, --b;
        eds[a].push_back(b);
        eds[b].pb(a);
    }
    int x = dfs1(0);
    if (x == 1) {
        cout << "First\n";
    }
    else {
        cout << "Second\n";
    }
    return 0;
}




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

int main() {
  int a,b,v;
  string op;
  
  cin >> a>>op>>b;
  
if(op == "+"){
  v=a + b;
}else if(op == "-"){
  v=a - b;
}
  cout<<v<<endl;
}


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

int main() {
	string s,t;
	cin>>s>>t;
	int ans=0;
	for(int i=0;i<t.size();i++)
	{
		if(s[i]!=t[i]) ans++;
	}
	cout<<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 3836
N = int(input())


S = input()
S = S.split()
A = list(map(int, S))
A_copy = list(map(int, S))

S = input()
S = S.split()
B = list(map(int, S))


remain = 0

for i in range(len(B)):
    remain = int(A[i]-B[i])
    if remain <= 0:
        if A[i+1]+remain >= 0:
            A[i+1] = int(A[i+1] + remain)
        else:
            A[i+1] = 0
        A[i] = 0
    elif remain > 0:
        A[i] = remain



print(sum(A_copy)-sum(A))


Measured memory_bytes: 22332
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll mod = 1000000007;

const ll LINF = 1e13;
const ll LLINF = 1e18;
const ll ALPHABET = 26;

template <class T>
void Swap(T& r, T& l) {
  T tmp = r;
  r = l;
  l = tmp;
}

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
  for (T& x : vec) is >> x; //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいい
  return is;
}



// check
// 問題文を復唱する


int main() {
  ll n,k,h,w;
  ll a,b;
  cin >> a >> b ;
  // string s;
  // cin >> s;
  // vector<ll> a(n,0);
  // cin >> a;

  ll ans = (3*a + b)/2;
  // for (int i = 0; i < n; i++) {
      
  // }




  cout << ans <<endl;

  
  // cout << (true? "Yes":"No");


}




















Measured memory_bytes: 764
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final long MOD = (long) (1e9) + 7;
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();

        long[] frac = new long[n + 1];
        long[] frac_inv = new long[n + 1];

        frac[0] = 1;
        frac_inv[0] = 1;
        for (int i = 1; i <= n; i++) {
            frac[i] = (frac[i-1] * i) % MOD;
            frac_inv[i] = modinv(frac[i], MOD);
        }

        k = Math.min(k, n - 1);

        long ans = 0;
        for (int j = 0; j <= k; j++) {
            long nCj = (frac[n] * frac_inv[j] % MOD) * frac_inv[n - j] % MOD;
            long pCq = (frac[n - 1] * frac_inv[n - j - 1] % MOD) * frac_inv[j] % MOD;
            ans = (ans + ((nCj * pCq) % MOD)) % MOD;
        }

        System.out.println(ans);
    }

    static long modpow(long a, long n, long MOD) {
        long res = 1;
        while (n > 0) {
            if ((n & 1) == 1) {
                res = (res * a) % MOD;
            }
            a = (a * a) % MOD;
            n >>= 1;
        }

        return res;
    }

    static long modinv(long a, long MOD) {
        return modpow(a, MOD - 2, MOD);
    }
}



Measured memory_bytes: 25940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#define REP(i,k,n) for(int i=k;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;

int main()
{
	int b,r,g,c,s,t;
	while(cin >> b >> r >> g >> c >> s >> t)
	{
		if(b == 0 && r == 0 && g == 0 && c == 0 && s == 0 && t == 0) break;

		int ans = 100;

		ans += b*15 + b*5*(15-2) + r*15 + r*3*(15-2) + g*7 + c*2;
		ans -= (t - b*5 - r*3 - s)*3;

		cout << ans << endl;
	}
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
 
using namespace std;
 
long long n, ans, cnt;
 
int main () {
  cin >> n;
  while(n != 0) {
  	n /= 2;
  	ans+= pow(2, cnt);
  	cnt++;
  }
  cout << ans;
  return 0;
}

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

	public static void main(String[] args) throws Exception{
		int num = 998244353;

		// TODO Auto-generated method stub
 		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
 		PrintWriter out = new PrintWriter(System.out);
 		String s = bf.readLine().trim();
 		String t = bf.readLine().trim();
 		int min = Integer.MAX_VALUE;
 		for(int j = 0;j<=s.length()-t.length();j++){
 			int count = 0;
 			for(int k = 0;k<t.length();k++){
 				if (t.charAt(k) != s.charAt(j+k))
 					count++;
 			}
 			min = Math.min(count,  min);
 		}
 		
 		
 		out.println(min);
	 		
 		out.close();
 		
 		
 		
 	}
}
 	
 
//StringJoiner sj = new StringJoiner(" "); 
//sj.add(strings)
//sj.toString() gives string of those stuff w spaces or whatever that sequence is

 		
 		
 		
 		
	




Measured memory_bytes: 25936
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <numeric>
#include <map>
#include <set>
#include <limits>

using namespace std;

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

const int maxn=1e5+10;
int p[maxn];



int main()
{
    //freopen("/Users/qianjay/Documents/apac/in", "r", stdin);
    int n,m;
    scanf("%d%d",&n,&m);
    memset(p,0,sizeof(p));
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        if(u>v) swap(u,v);
        p[u]++;
        p[v]--;
    }
    for(int i=1;i<n;i++)
    {
        p[i]+=p[i-1];
        if(p[i]%2)
        {
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
    return 0;
}
    

Measured memory_bytes: 640
//{{{
#include<algorithm>
#include<cmath>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printw) FUNC(printwe) FUNC(printb) FUNC(printbe) FUNC(printd) FUNC(printde) FUNC(printdu);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ return in >> p.first >> p.second; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, x;
    cin >> n >> x;
    int pos = 0;
    int ans = 0;
    for(int i = 0; i < n; i++){
        int l; cin >> l;
        ans += pos <= x;
        pos += l;
    }
    ans += pos <= x;
    cout << ans << '\n';
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>
#include<cstring>
#include<bitset>
#include<cassert>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
using ll = long long int;

const int inf = 1001001000;
const long long int Inf = 1001001001001001000;



void print(vector<vector<int>> a){
	for (int i = 0; i < a.size(); i++)
	{
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(vector<long long int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

void print(set<int> a){
	for (auto x:a)
		cout << x << " ";
	cout << endl;
}


int main(){
	string s;
	cin >> s;
	map<char, int> a;
	rep(i,s.size()){
		a[s[i]]++;
	}
	for(auto x:a){
		if(x.second!=2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}

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

int main(void){
   string s;
   cin >> s;
   if(s.size() == 1){
       cout << 0 << endl;
       return 0;
   }
   int ans = 0;
   if(s[0] == '1'){
       for(int i = 1;i < s.size();i++){
           if((i % 2 == 1 && s[i] == '1') ||
                (i % 2 == 0 && s[i] == '0')
            ){
               ans++;
           }
       }
   }else{
       for(int i = 1;i < s.size();i++){
           if((i % 2 == 1 && s[i] == '0') ||
              (i % 2 == 0 && s[i] == '1')
           ){
               ans++;
           }
       }
       
   }
   cout << ans << endl;
   
    return 0;
}


Measured memory_bytes: 512
// Karm Karta ja, Phal Ki Chinta na Kar:)
#include <bits/stdc++.h>
using namespace std;
#include<stdio.h>
typedef long long int ll;
int main()
{
   ll N;
   cin>>N;
   ll ok=0,i;
   for(i=1;i<=9;i++)
   {
       if(N%i==0)
       {
           ll p=N/i;
           if(p>=1&&p<=9)
           {
               ok=1;
               break;
           }
       }
   }
   if(ok==1)
    cout<<"Yes";
   else
    cout<<"No";
}



Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
int n, a, b;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;

    cout << min(a * n, b) << "\n";
}

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

int main(){
	int n;
	cin>>n;
	int arr[n];
	for(int i=0; i<n; i++){
		cin>>arr[i];
	}
	int arr1[n];
	for(int i=0; i<n; i++){
		arr1[i] = arr[i];
	}
	sort(arr1,arr1+n);
	
	
	int cntr = 0;
	bool flag = true;
	for(int i=0; i< n; i++){
		if(arr1[i] != arr[i]){
			cntr++;
		}
	} 
	if(cntr == 2 || cntr == 0){
		cout<<"YES";
	} else{
		cout<<"NO";
	}
}

Measured memory_bytes: 256
#ifdef DBG1
  #define LOCAL
#endif

#ifdef LOCAL
  #define _GLIBCXX_DEBUG
#endif

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

#ifdef DBG1
    #define dbg(...) fprintf(stderr, __VA_ARGS__)
#else
    #define dbg(...)
#endif

using namespace std;

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

const int P = int(1e9) + 7;

#define div divadadsd

int diff(int a, int b) {
  if ((a -= b) < 0) {
    a += P;
  }
  return a;
}

int sum(int a, int b) {
  if ((a += b) >= P) {
    a -= P;
  }
  return a;
}

int& add(int &a, int b) {
  return a = sum(a, b);
}

int prod(int a, int b) {
  return int(ll(a) * b % P);
}

int power(int a, int n) {
  int b = 1;
  while (n) {
    if (n & 1) {
      b = prod(a, b);
    }
    a = prod(a, a);
    n /= 2;
  }
  return b;
}

int inv(int a) {
  return power(a, P - 2);
}

int div(int a, int b) {
  return prod(a, inv(b));
}

int getC(const vector<int> & fact, int n, int k) {
  return div(fact[n], prod(fact[k], fact[n - k]));
}

bool solve() {
  int n;
  if (scanf("%d", &n) != 1) { return false; }

  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    scanf("%d", &a[i]);
  }
  vector <int> fact(n + 1);
  fact[0] = 1;
  for (int i = 1; i <= n; ++i) {
    fact[i] = prod(fact[i - 1], i);
  }

  vector <int> pref(n);
  for (int i = 0; i < n; ++i) {
    pref[i] = (i == 0 ? 0 : pref[i - 1]);
    add(pref[i], a[i]);
  }
  vector <int> pref2(n);
  for (int i = 0; i < n; ++i) {
    pref2[i] = (i == 0 ? 0 : pref2[i - 1]);
    add(pref2[i], pref[i]);
  }

  for (int i = 0; i < n; ++i) {
    dbg("i %d pref %d pref2 %d\n", i, pref[i], pref2[i]);
  }

  int res = prod(pref[n - 1], fact[n]);
  for (int i = 0, sum = 0; i < n - 1; ++i) {
    int len = i + 1;
    add(sum, a[i]);
    int factor = prod(fact[n - len - 1], prod(fact[len], getC(fact, n, len + 1)));
    add(res, prod(sum, factor));
    dbg("pref len %d sum %d factor %d = res %d\n", len, sum, factor, res);
  }
  for (int i = n - 1, sum = 0; i > 0; --i) {
    int len = n - i;
    add(sum, a[i]);
    int factor = prod(fact[n - len - 1], prod(fact[len], getC(fact, n, len + 1)));
    add(res, prod(sum, factor));
    dbg("suff len %d sum %d factor %d = res %d\n", len, sum, factor, res);
  }
  for (int len = 1; len <= n - 2; ++len) {
    int totS = (ll(pref2[n - 2] - pref2[len - 1]) - ll(pref2[n - len - 2])) % P;
    if (totS < 0) { totS += P; }
    int factor = prod(fact[n - len - 2], prod(prod(2, fact[len]), getC(fact, n, len + 2)));
    add(res, prod(totS, factor));
    dbg("in len %d sum %d factor %d = res %d\n", len, totS, factor, res);
  }
  printf("%d\n", res);

  return true;
}

int main() {
  while (solve());
  return 0;
}

Measured memory_bytes: 1792
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

A, B, H, M = LI()

h = H * (360 / 12) + (M / 2)
m = M * (360 / 60)

cosa = math.cos(math.radians(abs(h-m)))
c2 = A**2 + B**2 - (2*A*B*cosa)

print(math.sqrt(c2))


Measured memory_bytes: 66124
#include<stdio.h>
#include<math.h>
#include<queue>
#include<stack>
#include<string.h>
#include<algorithm>
#include<cctype>
#include<map>
#include<set>
typedef long long ll;
using namespace std;
int main()
{
	ll n,cou=0;
	scanf("%lld",&n);
	if(n%2==1){printf("0\n");return 0;}
	n/=10;
	while(n){
		cou+=n;
		n/=5;
	}printf("%lld\n",cou);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define LOG 25
#define N 100005
using namespace std;

int n,l,q,x,y,a[N],dp[LOG][N];

int main() {

  scanf("%d",&n);
  for(int i=1;i<=n;i++) {
    scanf("%d",&a[i]);
  }
  scanf("%d",&l);
  int son=1;
  for(int i=1;i<=n;i++) {
    while(a[i]+l>=a[son+1] && son+1<=n) son++;
    dp[0][i]=son;
  }
  for(int p=1;p<=20;p++) {
    for(int i=1;i<=n;i++) {
      dp[p][i]=dp[p-1][dp[p-1][i]];
    }
  }
  scanf("%d",&q);
  while(q--) {
    int ans=0;
    scanf("%d %d",&x,&y);
    if(x>y) swap(x,y);
    for(int p=20;p>=0;p--) {
      if(dp[p][x]<y) {
        ans+=(1<<p);
        x=dp[p][x];
      }
    }
    printf("%d\n",ans+1);
  }

}


Measured memory_bytes: 9472
N = int(input())

A = list(map(int,input().split()))

A.sort()

npl = A[-1]
nmi = A[0]

del A[0]
del A[-1]
lis = []

for i in A:

    if i < 0:
        lis.append([npl,i])
        npl -= i

    else:
        lis.append([nmi,i])
        nmi -= i

lis.append([npl,nmi])
print (npl-nmi)

for i in lis:

    print (i[0],i[1])


Measured memory_bytes: 22340
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

bool cmp(pair<int, long long int> a, pair<int, long long int> b) {
    if(a.second!=b.second) {
        return a.second>b.second;
    } else {
        return a.first>b.first;
    }
}

int main() {
    int N, M;
    cin >> N >> M;
    
    vector<long long int> A(N);
    vector<long long int> S(N+1, 0);
    for(int n=0; n<N; n++) {
        cin >> A[n];
    }
    sort(A.begin(), A.end());
    
    for(int n=0; n<N; n++) {
        S[n+1] = A[n]+S[n];
    }
    
    
    vector<pair<int, long long int> > BC(M);
    for(int m=0; m<M; m++) {
        cin >> BC[m].first >> BC[m].second;
    }
    
    sort(BC.begin(), BC.end(), cmp);
    
    // //debugging
    // for(int m=0; m<M; m++) {
    //     cout << BC[m].second << endl;
    // }

    vector<long long int> SBC(N+1, 0);
    vector<long long int> BCN(N);
    int bc_c=0;
    for(int m=0; m<M; m++) {
        for(int mi=0; mi<BC[m].first; mi++) {
            BCN[bc_c] = BC[m].second;
            SBC[bc_c+1] = SBC[bc_c] + BCN[bc_c];
            bc_c++;
            if(bc_c==N) break;
        }
        if(bc_c==N) break;
    }
    
    long long int sum=0;
    int n;
    for(n=0; n<N; n++) {
        if(BCN[n]<A[n]) break;
    }

    // cout << sum << endl;
    sum += S[N] - S[n];
    sum += SBC[n] - S[0];
    // cout << S[N] - S[count_sum] << endl;

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

Measured memory_bytes: 4992
h, w, k = map(int, input().split())
c = []
for _ in range(h):
    c.append(input())
ans = 0
for i in range(2**h):
    for j in range(2**w):
        tmp = 0
        for y in range(h):
            for x in range(w):
                if i>>y&1 or j>>x&1 or c[y][x]=='.':
                    continue
                tmp += 1
        if tmp==k:
            ans += 1
print(ans)

Measured memory_bytes: 9196