akhauriyash/Code-Regression huggingface dataset:
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n = I()
    print(n**3)
    return

#B
def B():
    n = I()
    a = LI()
    b = LI()
    c = LI()
    ans = sum(b)
    for i in range(n-1):
        x = a[i]
        y = a[i+1]
        if y == x+1:
            ans += c[x-1]
    print(ans)
    return

#C
def C():
    n = I()
    b = LI()
    b.append(float("inf"))
    a = [min(b[i],b[i-1]) for i in range(n)]
    print(sum(a))
    return

#D
def D():

    return

#E
def E():

    return

#F
def F():

    return

#Solve
if __name__ == "__main__":
    C()


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

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

 cout << fixed << setprecision(10);
if(N%2==0){
cout << 0.5000000000000;
}else if(N%2==1){
double A=N;
cout << (double)((A+1)/(2*A))<<endl;
}
}




Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        String str;
        int i,x;
        int a;
        str = scan.nextLine();
        a = Integer.valueOf(str);
        for(i=1;i<=a;i++){
            if(i%3==0){
                System.out.print(" "+i);
            }else{
                x = i;
                while(x > 0){
                    if(x % 10==3){
                        System.out.print(" "+i);
                        break;
                    }
                    x /= 10;
                }
            }
        }
        System.out.println();
        scan.close();
    }
}


Measured memory_bytes: 28784
#include<iostream>
#include<queue>
#include<stack>
#include<vector>
#include<set>
#include<map>
#include<algorithm>
#include<cstring>
#include<string>
#include<cassert>
#include<cmath>
#include<climits>
#include<iomanip>
#include<bitset>
#include<unordered_map>

using namespace std;

#define rep(i,m,n) for(int (i)=(int)(m);(i)<(int)(n);(i)++)
#define rep2(i,m,n) for(int (i)=(int)(n)-1;(i)>=(int)(m);(i)--)
#define REP(i,n) rep(i,0,n)
#define REP2(i,n) rep2(i,0,n)
#define FOR(i,c) for(decltype((c).begin())i=(c).begin();i!=(c).end();++i)

#define ull unsigned long long
#define all(hoge) (hoge).begin(),(hoge).end()
#define en '\n'

using ll = long long;
typedef pair<ll, ll> P;
constexpr long long INF = 1LL << 60;
constexpr int INF_INT = 1 << 25;


typedef vector<ll> Array;
typedef vector<Array> Matrix;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

//constexpr long long MOD = (ll) 1e9+7;
constexpr long long MOD = 998244353;

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

struct Edge {
	int to, cap, rev;
	Edge(int _to, int _cap, int _rev) {
		to = _to; cap = _cap; rev = _rev;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

void add_edge(Graph& G, int from, int to, int cap, bool revFlag, int revCap) {
	G[from].push_back(Edge(to, cap, G[to].size()));
	if (revFlag)G[to].push_back(Edge(from, revCap, G[from].size() - 1));
}

ll n, m;
ll ans;

void dfs(vector<vector<ll>>& g, ll v, Array order) {
	order.push_back(v);
	if (order.size() == n) {
		ans++;
		return;
	}
	for (auto next : g[v]) {
		bool flag = false;
		for (auto i : order) if (i == next) flag = true;
		if (flag) continue;
		dfs(g, next, order);
	}
}

void solve() {
	
	cin >> n >> m;

	vector<vector<ll>> g(n);
	REP(i, m) {
		ll a, b;
		cin >> a >> b;
		a--; b--;
		g[a].push_back(b);
		g[b].push_back(a);
	}

	Array order;
	dfs(g, 0, order);
	cout << ans << en;
}

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

	solve();
	//int t; cin >> t; REP(i, t) solve();

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n) ;
    for(int i=0;i<n;++i){
        cin >> vec.at(i);
    }
    reverse(vec.begin(),vec.end());
    cout << vec.at(0);
    for(int i=1;i<n;++i){
        cout << " " << vec.at(i);
    }
    cout << endl;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
	ld A,B,V,W,T;cin>>A>>V>>B>>W>>T;
	if(A==B)cout<<"YES"<<endl;
	else if(V<W)cout<<"NO"<<endl;
	else cout<<(abs(A-B)/(V-W)<=T ?"YES" : "NO")<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 3748
#include<stdio.h>
int main(){
    int c=0;
    char b[10];
    gets(b);
    for(int i=0;b[i]!='\0';i++)
    {
        if(b[i]=='7'){ c++; }
    }
if(c>0)printf("Yes\n");
else printf("No\n");
return 0;
}


Measured memory_bytes: 1532
#include <stdio.h>

int check(int target, int arr[],int n){
	for (int i = 0; i < n; i++){
		if (target == arr[i]){
			return 1;
		}
	}
	return 0;
}

int main(){
	int n, q;
	int s[10000], t[500];
	int count = 0;

	scanf("%d", &n);

	for (int i = 0; i < n; i++){
		scanf("%d",& s[i]);
	}

	scanf("%d", &q);

	for (int i = 0; i < q; i++){
		scanf("%d", &t[i]);
	}

	for (int i = 0; i < q; i++){
		count += check(t[i], s, n);
	}

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


Measured memory_bytes: 2112
#include<iostream>

using namespace std;

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

	int a,b,c,d;
	cin >> a >> b >> c >> d;
	//a and c are healths, b and d are strengths
	while(a>0 and c>0){
		c = c-b;
		if(c<=0){
			cout << "Yes";
			return 0;
		}
		a = a-d;
	}
	if(a<=0) cout << "No";
	else cout << "Yes";
	return 0;
}

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

A = [int(input()) for i in range(N)]

L = [-10**9]
m = -10**9

for i in range(N):
    m=max(m,A[i])
    L.append(m)


R = [-10**9]
m = -10**9

for i in range(N):
    m=max(m,A[N-i-1])
    R.append(m)

R = R[::-1]

for i in range(N):
    print(max(L[i],R[i+1]))

Measured memory_bytes: 78420
#include<stdio.h>
#include<string.h>
int main()
{
    char S[19];
    int i;
    for(i=0;i<19;i++) scanf("%c",&S[i]);
    for(i=0;i<19;i++){
    if('a'<=S[i] && S[i]<='z'){
        if(S[5]==',' && S[13]==','){
            S[5]=' ';
            S[13]=' ';
        }
    }
}
for(i=0;i<19;i++)  printf("%c",S[i]);
return 0;
}

Measured memory_bytes: 1584
#include <stdio.h>
#include <stdlib.h>

int main(void){
	char N[3];
	for(int i=0;i<3;i++){
		scanf("%c",&N[i]);
	}
	printf("\n");

	for(int i=0;i<3;i++){
		if(N[i] =='7'){
			printf("Yes");
			return 0;
		}
	}
	printf("No");
    return 0;
}


Measured memory_bytes: 1664
#include <iostream>
int main(void){
    using namespace std;
    int S,a,b,c,d;
    cin>>S;
    a=S/1000;
    b=(S-a*1000)/100;
    c=(S-b*100-a*1000)/10;
    d=S-a*1000-b*100-c*10;
    if(a==b||b==c||c==d){
        cout<<"Bad"<<endl;
    }
    else cout<<"Good"<<endl;

return(0);
}

Measured memory_bytes: 256
a = list(map(int, input().split()))  # 入力をリストにして受け付け
b = list(map(int, input().split()))

try:
    print(max(abs(a[2] - b[-1]), abs(b[-1] - b[-2]))) # xさんが最後から二番目の数か最後の数どちらを取ればよいかを判断
except:  # 与えられる数が一つの場合
    print(abs(a[2] - b[0]))

Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {
  
  int N,K;
  string S;
  cin >> N >> S >> K;

  char ch = S.at(K-1);
  for(int i = 0;i < N;i++) {
    if(S.at(i) == ch) cout << ch;
    else cout << '*';
  }

  cout << endl;
}



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

char grid[1007][1007];
ll dp[1007][1007];
bool vis[1007][1007];
int h,w;

bool valid( int i, int j )
{
    if( i<0 or j<0 )
        return 0;
    if( i>=h or j>=w )
        return 0;
    if( grid[i][j]=='#' )
        return 0;
    return 1;
}

ll rec( int i, int j )
{
    if( i==h-1 and j==w-1 )
        return 1;
    if(vis[i][j])
        return dp[i][j];

    ll q1= 0, q2= 0;

    if( valid(i+1,j) )
        q1= rec( i+1,j )%m;
    if( valid(i,j+1) )
        q2= rec( i, j+1 )%m;

    vis[i][j]= 1;

    return dp[i][j]= (q1+q2)%m;
}

int main()
{
    cin>>h>>w;

    for(int i=0;i<h;i++)
        for(int j=0;j<w;j++)
            cin>>grid[i][j];

    cout<< rec(0,0) <<endl;

}



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

enum dir_t {north, east, south, west};

int main() {
    int w, h;
    while (cin >> w >> h) {
        if (w == 0 && h == 0) break;
        dir_t dir = north;
        int y = 1, x = 1;
        string cmd;
        while (cin >> cmd) {
            if (cmd == "STOP") {
                cout << x << ' ' << y << endl;
                break;
            } else if (cmd == "FORWARD") {
                int k; cin >> k;
                switch (dir) {
                    case north:
                        y += k;
                        if (h < y) y = h;
                        break;
                    case west:
                        x += k;
                        if (w < x) x = w;
                        break;
                    case south:
                        y -= k;
                        if (y < 1) y = 1;
                        break;
                    case east:
                        x -= k;
                        if (x < 1) x = 1;
                        break;
                }
            } else if (cmd == "BACKWARD") {
                int k; cin >> k;
                switch (dir) {
                    case south:
                        y += k;
                        if (h < y) y = h;
                        break;
                    case east:
                        x += k;
                        if (w < x) x = w;
                        break;
                    case north:
                        y -= k;
                        if (y < 1) y = 1;
                        break;
                    case west:
                        x -= k;
                        if (x < 1) x = 1;
                        break;
                }
            } else if (cmd == "RIGHT") {
                switch (dir) {
                    case north: dir = west; break;
                    case west:  dir = south; break;
                    case south: dir = east; break;
                    case east: dir = north; break;
                }
            } else if (cmd == "LEFT") {
                switch (dir) {
                    case north: dir = east; break;
                    case west:  dir = north; break;
                    case south: dir = west; break;
                    case east: dir = south; break;
                }
            }
//            cout << "DIR: " << dir << endl;
//            cout << "x: " << x << " y: " << y << endl;
        }
    }
    return 0;
}
        

Measured memory_bytes: 0
k = int(input())
a = [None for i in range(10**7) ]

ans = -1
a[1] = 7%k
for i in range(2,k+1):
    a[i] = (a[i-1]*10 + 7)%k

for i in range(1,k+1):
    if a[i] == 0:
        ans = i
        break

print(ans)


Measured memory_bytes: 118768
/*input
21
0 0 0 0 0 0 0 1 1 0 1 1 1 1 0 0 0 1 0 0 1
1 1 1 0 0 1 0 0 0 1 0 0 0 0 1 1 1 0 1 1 0
0 0 1 1 1 1 0 1 1 0 0 1 0 0 1 1 0 0 0 1 1
0 1 1 0 1 1 0 1 0 1 0 0 1 0 0 0 0 0 1 1 0
1 1 0 0 1 0 1 0 0 1 1 1 1 0 0 0 0 0 0 0 0
0 1 1 0 1 1 1 0 1 1 1 0 0 0 1 1 1 1 0 0 1
0 1 0 0 0 1 0 1 0 0 0 1 1 1 0 0 1 1 0 1 0
0 0 0 0 1 1 0 0 1 1 0 0 0 0 0 1 1 1 1 1 1
0 0 1 0 0 1 0 0 1 0 1 1 0 0 1 0 1 0 1 1 1
0 0 0 0 1 1 0 0 1 1 1 0 0 0 0 1 1 0 0 0 1
0 1 1 0 1 1 0 0 1 1 0 0 0 1 1 1 1 0 1 1 0
0 0 1 0 0 1 1 1 1 0 1 1 0 1 1 1 0 0 0 0 1
0 1 1 0 0 1 1 1 1 0 0 0 1 0 1 1 0 1 0 1 1
1 1 1 1 1 0 0 0 0 1 0 0 1 1 0 1 1 1 0 0 1
0 0 0 1 1 0 1 1 1 1 0 0 0 0 0 0 1 1 1 1 1
1 0 1 1 0 1 0 1 0 0 1 0 0 1 1 0 1 0 1 1 0
0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1 1 1 0 0 1
0 0 0 1 0 0 1 1 0 1 0 1 0 1 1 0 0 1 1 0 1
0 0 0 0 1 1 1 0 1 0 1 1 1 0 1 1 0 0 1 1 0
1 1 0 1 1 0 0 1 1 0 1 1 0 1 1 1 1 1 0 1 0
1 0 0 1 1 0 1 1 1 1 1 0 1 0 1 1 0 0 0 0 0
*/

//sometimes it's the people who no one imagines anything of 
//who do the things that no one can imagine.

//code author: iamxlr8

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define endl "\n"
#define all(c) c.begin(),c.end()
#define mod 1000000007
#define inf 1000000000000000001
#define F first
#define S second
#define dbg(x) cout << #x << " = " << x << ' '
#define off ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

ll add(ll a,ll b)
{
    return (a%mod+b%mod)%mod;
}

void solve()
{
    ll n;
    cin>>n;
    vector<vector<int>> v(n,vector<int>(n));
    for(ll i=0;i<n;i++)
    {
        for(ll j=0;j<n;j++)
        {
            cin>>v[i][j];
            // cout<<v[i][j]<<" ";
        }
        // cout<<endl;
    }
    vector<ll> dp(1<<n);
    dp[0]=1;
    // no. of bits set in mask = no. of men paired
    // if ith mask is set then, it means ith women is paired
    for(ll mask=0;mask<(1<<n)-1;mask++)
    {
        ll men=__builtin_popcount(mask);
        for(ll women=0;women<n;women++)
        {
            if(v[men][women]&&!(mask&(1<<women)))
                dp[mask|(1<<women)]=add(dp[mask|(1<<women)],dp[mask]);
        }
    }
    cout<<dp[(1<<n)-1];
}

int main() 
{
    off;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ll tests=1;
    // cin>>tests;
    while(tests--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 16640
N,K=map(int,input().split())
if K==0:
    print(N*N)
else:
    no=N*K+(N-K)*(K-1)
    for b in range(K+1,N+1):
        q=N//b
        r=N%b
        no+=q*K
        if r>=K-1:
            no+=0
        else:
            no-=(K-r-1)

    print(N*N-no)


Measured memory_bytes: 39152
#include<stdio.h>
#include<stdlib.h>

#define NEW(p,n){p=malloc((n)*sizeof(p[0]));if(p==NULL){printf("not enough memory\n");exit(1);};}
//pの型の変数n個の要素分のメモリを確保し、そのアドレスをpに代入するマクロ

#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(void){
    int N;
    scanf("%d",&N);

    //h[0]~h[N-1]に格納する
    int* h;
    NEW(h,N);
    for(int i=0;i<N;i++){
        scanf("%d",&h[i]);
    }

    int ans=0;

    int i=0;
    while(i<N){
        while(h[i]!=0){
            //h[i]から始まるブロックの中での最小値minを求める
            int j=i;
            int min=h[i];
            while(j<N-1 && h[j+1]!=0){
                min=MIN(min,h[j+1]);
                j++;
            }

            //このとき、minはh[i]~h[j]までの最小値
            //minが0でないなら、h[i]~h[j]までmin回水やり
            if(min!=0){
                ans+=min;
                for(int k=i;k<=j;k++) h[k]-=min;
            }
        }
        i++;
    }

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

    return 0;
}

Measured memory_bytes: 128
from operator import itemgetter
from heapq import heappush,heappop
N = int(input())
table=[]
for i in range(N):
    a,b = map(int,input().split())
    table.append([a,b,i])
A = sorted(table,key=itemgetter(0))
B = sorted(table,key=itemgetter(1))

graph=[]
for k in range(N):#距離、点
    graph.append((min(abs(A[k][0]-A[k-1][0]),abs( A[k][1]-A[k-1][1])),A[k][2],A[k-1][2]))
for k in range(N):
    graph.append((min(abs(B[k][0]-B[k-1][0]),abs( B[k][1]-B[k-1][1])),B[k][2],B[k-1][2]))

class Unionfindtree:
    def __init__(self,number):
        self.par = [i for i in range(number)]
        self.rank = [0]*(number)

    def find(self,x):#親を探す xの親を示す
        if self.par[x] ==x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    def union(self,x,y):#x,yを繋げる
        px = self.find(x)
        py = self.find(y)
        if px == py:
            return 
        if self.rank[px]<self.rank[py]:
            self.par[px]=py
        else:
            self.par[py]=px
        if self.rank[px]==self.rank[py]:
            self.rank[px] +=1
    
    def connect(self,x,y):#親が同じかみる
        return self.find(x)==self.find(y)
#クラスカル法
kei = Unionfindtree(N)
graph.sort()
dist =0
for d,i,j in graph:
    if not kei.connect(i,j):
        kei.union(i,j)
        dist +=d
print(dist)


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

int main() {
    int k,n;
    string s;
    char dum;
    cin >> n;
    cin >> s;
    cin >> k;
    dum = s[k-1];
    for(int i=0; i<s.size(); i++){
        if (s[i] != dum) s[i] = '*';
    }
    cout << s << endl;
}

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

using namespace std;

int main(){
    int X,Y,Z;
    cin >> X >> Y >> Z;

    int temp;

    temp =X;
    X = Y;
    Y = temp;

    temp =X;
    X =Z;
    Z=temp;

    cout << X << " " << Y<< " " << Z << endl;


}

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

int main(){
  int tmp1,tmp2,dora;
  int n; cin >> n;
  int cnt = 0;
  dora = n;
  while(1){
    cnt++;
    if( n <= 3 ) break;
    tmp1 = n / 3;
    tmp2 = (n - tmp1) / 2;
    dora = n - tmp1 - tmp2; 
    n = dora;
    // cout << "tmp1" <<" " << tmp1 << " " << "tmp2" << " " << tmp2 << 
    // "dora" << " " << dora << endl;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1164
import itertools
N,M=map(int,input().split())
edges={tuple(sorted(map(int,input().split()))) for i in range(M)}
ans=0
for i in itertools.permutations(range(2,N+1),N-1):
    l=[1]+list(i)
    ans+=sum(1 for edge in zip(l,l[1:]) if tuple(sorted(edge)) in edges)==N-1
print(ans)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
    static long N;
    static long C;

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        N = sc.nextInt();
        func(0, 0);
        System.out.println(C);
    }

    static void func(long cur, int use) {
        if(cur > N) return;
        if(use == 0b111) {
            C++;
        }

        // 7 を付け加える
       

        // 5 を付け加える
        func(cur * 10 + 5, use | 0b010);

        // 3 を付け加える
        func(cur * 10 + 3, use | 0b100);
      
       func(cur * 10 + 7, use | 0b001);
    }
}


Measured memory_bytes: 35660
n, m = map(int, input().split())
p = list(map(int, input().split()))
XY = [ map(int, input().split()) for _ in range(m) ]

class UnionFind:
    def __init__(self, n):
        self.table = [-1 for _ in range(n)]

    def _root(self, x):
        if self.table[x] < 0:
            return x
        else:
            self.table[x] = self._root(self.table[x])
            return self.table[x]

    def find(self, x, y):
        return self._root(x) == self._root(y)

    def union(self, x, y):
        r1 = self._root(x)
        r2 = self._root(y)
        if r1 == r2:
            return
        d1 = self.table[r1]
        d2 = self.table[r2]
        if d1 <= d2:
            self.table[r2] = r1
            if d1 == d2:
                self.table[r1] -= 1
        else:
            self.table[r1] = r2

uf = UnionFind(n)
for (x, y) in XY:
    uf.union(x-1, y-1)
cnt = 0
for i in range(n):
    if uf.find(i, p[i]-1): cnt += 1
print(cnt)

Measured memory_bytes: 120684
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;
using P = pair<int,int>;

int main() {
    int x,y,a,b,c;
    cin >> x >> y >> a >> b >> c;
    priority_queue<P> pq;

    for (int i=0; i<a; i++) {
        int p;
        cin >> p;
        pq.emplace(p, 1);
    }
    for (int i=0; i<b; i++) {
        int p;
        cin >> p;
        pq.emplace(p, 2);
    }
    for (int i=0; i<c; i++) {
        int p;
        cin >> p;
        pq.emplace(p, 0);
    }

    int n = x+y;
    int64 ans = 0;
    while(n > 0 && (x>0 || y>0)) {
        int p,c;
        tie(p,c) = pq.top(); pq.pop();
//        cout << n << " " << x << " " << y << " "  << p << " " << c << endl;
        if (c == 1 && x > 0) {
            ans += p;
            x--; n--;
        }
        if (c == 2 && y > 0) {
            ans += p;
            y--; n--;
        }
        if (c == 0) {
            ans += p;
            n--;
        }
//        debug(ans);
    }

    cout << ans << endl;
}

Measured memory_bytes: 6384
import java.util.Scanner;

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

        while(true) {

            int m = sc.nextInt();
            int f = sc.nextInt();
            int r = sc.nextInt();
            
            if (m + f + r == -3) break;

            if (m == -1 || f == -1) {
                System.out.println("F");
            }
            else if (m + f >= 80) {
                System.out.println("A");
            }
            else if (65 <= m + f && m + f < 80) {
                System.out.println("B");
            }
            else if (50 <= m + f && m + f < 65 || r >= 50) {
                System.out.println("C");
            }
            else if (30 <= m + f && m + f < 50) {
                System.out.println("D");
            }
            else if (m + f < 30) {
                System.out.println("F");
            }

        }

    }
}


Measured memory_bytes: 26428
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      long n;
      int a,ans;
      a =0;ans=0;
      cin >> n;
      for(int i=2;i<=sqrt(n);i++){
        while(n%i == 0){
          n/=i;
          a++;
        }
        for(int j=1;j*(j+1)/2<=a;j++){
          ans++;
        }
        a = 0;
      }
      if(n != 1)ans++;
      cout << ans << endl;
    }

Measured memory_bytes: 3680
#include <stdio.h>
#include <algorithm>
#include <math.h>
#include <vector>
#include <queue>
#include <map>

using namespace std;


int main()
{
    int a,b,c,d;
    scanf("%d%d%d%d",&a,&b,&c,&d);
    if(d==1)
        printf("1");
    else
        printf("0");


}





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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   int n;cin >>n;
   vector<int>x(n);
   vector<int>y(n);
    for (int i = 0; i < n; ++i) {
        cin >>x[i]>>y[i];
    }
    map<P,int>mp;
    for (int i = 0; i < n; ++i) {
        for (int j =i+1;j < n; ++j) {
            mp[make_pair(x[i]-x[j],y[i]-y[j])]++;
            mp[make_pair(x[j]-x[i],y[j]-y[i])]++;
        }
    }
    ll mx=0;
    for (int i = 0; i < n; ++i) {
        for (int j =i+1;j < n; ++j) {
            mx=max(mx,(ll)mp[make_pair(x[i]-x[j],y[i]-y[j])]);
            mx=max(mx,(ll)mp[make_pair(x[j]-x[i],y[j]-y[i])]);
        }
    }
    cout <<n-mx<<endl;
}


Measured memory_bytes: 3704
import java.util.*;

public class Main {
    static int modP = 1000000007;
    static long inf  = 1 << 61;
    static int[] x4 = {-1, 0, 0, 1};
    static int[] y4 = {0, -1, 1, 0};

    static String s, t;

    public static void main(String[] args) {
        input();
        solve();
    }

    static void solve() {
        s = s + s + s;
        int l = t.length();
        for(int i = 0; i < l; i++) {
            if(s.substring(i, i+l).equals(t)) {
                print("Yes");
                return;
            }
        }

        print("No");
    }

    static void input() {
        Scanner in = new Scanner(System.in);
        s = in.next();
        t = in.next();
    }

    static void print(String s) {
        System.out.println(s);
    }

    static void print(char c) {
        System.out.println(c);
    }

    static void print(int i) {
        System.out.println(i);
    }

    static void print(long i) {
        System.out.println(i);
    }

    static void print(float i) {
        System.out.println(i);
    }

    static void printArray2D(int[][] array, char del) {
        int r = array.length;
        int c = array[0].length;
        for(int i = 0; i < r; i++) {
            for(int j = 0; j < c; j++) {
                System.out.format("%3d", array[i][j]);
                if(j != c-1) System.out.print(del);
                else System.out.print('\n');
            }
        }
    }
}

Measured memory_bytes: 23124
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

using ll = long long;
using ull = uint64_t;
using P = pair<int, int>;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

template<class T>
inline bool chmax(T& x, T y){
    if(x < y){
        x = y;
        return true;
    }
    return false;
}
template<class T>
inline bool chmin(T& x, T y){
    if(x > y){
        x = y;
        return true;
    }
    return false;
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    string s, t;
    cin >> s >> t;
    int n = s.length(), m = t.length();
    set<string> ans;
    for(int i = 0; i + m <= n; ++i){
        bool ok = true;
        for(int j = 0; j < m; ++j){
            if(s[i + j] == '?') continue;
            if(s[i + j] != t[j]){
                ok = false;
                break;
            }
        }
        if(!ok) continue;
        string str = "";
        for(int j = 0; j < i; ++j){
            if(s[j] == '?') str += 'a';
            else    str += s[j];
        }
        str += t;
        for(int j = i + m; j < n; ++j){
            if(s[j] == '?') str += 'a';
            else    str += s[j];
        }
        ans.insert(str);
    }
    if(!ans.size()) cout << "UNRESTORABLE\n";
    else    cout << *(ans.begin()) << endl;
}

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

int main() {
    int x, y, t;
    while(1) {
        cin >> x >> y;
        if (x == 0 && y == 0) break;
        if (x > y) {t = x;x = y;y = t;}
        cout << x << " " << y << endl;
    }
    return 0;
}


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

int main() {
  ll n, a, b;
  cin >> n >> a >> b;
  if (n % (a + b) <= a) cout << n / (a + b) * a + n % (a + b) << endl;
  else cout << n / (a + b) * a + a << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
  using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define endl "\n"
  #define ll long long
  #define int long long
  #define double long double
  #define max(a,b) (a>b?a:b)
  #define min(a,b) (a<b?a:b)
  #define mp make_pair
  #define pb push_back
  #define inf INT_MAX
  #define f first
  #define s second
  #define all(v) v.begin(), v.end()
  #define mod INT_MAX 
  int32_t main()
  { 
   
    IOS
    string s;
    cin>>s;
    int cntb=0,sum=0;
    for(int i=0;i<s.length();i++)
    {
      if(s[i]=='W')
        sum+=cntb;
      else
        cntb++;
    }
    cout<<sum;
    return 0;
  }
    

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

int main(){
  string s,t;
  cin>>s>>t;
  int n=s.size();
  s+=s;
  
  bool p=false;
  rep(i,n){
    bool q=true;
    rep(j,n){
      if(s[i+j]!=t[j]){
        q=false;
      }
    }
    if(q) p=true;
  }
  if(p) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc= new Scanner(System.in);

		//ボールに書かれた文字列
		String s = sc.next();
		//
		String t = sc.next();

		//ボールの数
		int a = sc.nextInt();
		int b = sc.nextInt();

		//捨てるボールに書かれた文字列
		String u = sc.next();

		if(u.equals(s)) {
			a--;
		}
		else {
			b--;
		}

		System.out.println(a + " " + b);
		sc.close();

	}

}


Measured memory_bytes: 38660
/* ABC133-B.c
   Takatan */

#include<stdio.h>
#include<math.h>
#include<stdlib.h>
double distance(double *p1, double *p2, int dimension);
int main(void){
    int number, dimension, count, i, j;
    double **point, judge;

    count = 0;

    scanf( "%d %d" , &number, &dimension); /* 点の数と点の次元を入力 */

    point = malloc(sizeof(double*) * number); /* 点の座標を格納する配列を定義 */

    for(i=0; i < number; i++){

        point[i] = malloc(sizeof(double) * dimension); /* 点の座標を格納する配列を定義 */

        for(j=0; j < dimension; j++){

            scanf( "%lf" , &point[i][j]); /* 一つずつ点の座標を保存 */

        }

    }

    for(i=0; i < number; i++){

        for(j=i+1; j < number; j++){

            judge = distance(point[i], point[j], dimension);

            if(ceil(judge) == floor(judge)){
                /* 切り上げと切り下げが等しいとき整数とみなせる */

                count++;

            }

        }
    }

    printf( "%d\n" , count);

    return 0;
}

double distance(double *p1, double *p2, int dimension){ /* 距離を求める関数 */
    double answer;
    int i;

    answer = 0;

    for(i=0; i < dimension; i++){

        answer += pow(p1[i]-p2[i], 2); /* それぞれの成分の差の2乗の和を求める */

    }

    answer = sqrt(answer); /* 平方根を取る */

    return(answer);
}

Measured memory_bytes: 128
using System;


class Program
{
    static void Main(string[] args)
    {
        long x = long.Parse(Console.ReadLine());
        long yokin = 100;

        for( int i = 1; yokin < x; i++)
        {
            yokin = (long)(yokin * 1.01);
            if(yokin >= x)
            {
                Console.WriteLine(i.ToString());
            }
        }
    }
}


Measured memory_bytes: 27464
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const ll INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
using Graph = vector<vector<int>>;
ll mypow(ll x, ll n, ll m) {
	if (n == 0) {
		return 1;
	}
	if (n % 2 == 0) {
		return mypow(x*x%m, n / 2, m);
	}
	else {
		return x * mypow(x, n - 1, m) % m;
	}
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
const int MAX = 510000;
ll fac[MAX], finv[MAX], inv[MAX];
//テーブルをつくる前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;//mod pにおける1,2,,,nの逆元
	for (int i = 2; i < MAX; ++i) {
		fac[i] = fac[i - 1] * i%INF;
		inv[i] = INF - inv[INF%i] * (INF / i) % INF;
		finv[i] = finv[i - 1] * inv[i] % INF;
	}
}

ll COM(int n, int k) {
	if (n < k)return 0;
	if (n < 0 || k < 0)return 0;
	return fac[n] * (finv[k] * finv[n - k] % INF) % INF;
}
///////////////////////////////////////


int main() {
	ll N; cin >> N;
	if (N == 2) {
		cout << 1 << endl;
		return 0;
	}
	int ans = 2;//N-1,N
	for (ll i = 2; i*i <= N-1; ++i) {
		if (i*i == N-1) {
			ans++;
			break;
		}
		if ((N - 1) % i == 0) {
			ans += 2;
		}
	}
	vector<ll>key;
	for (ll i = 2; i*i <= N; ++i) {
		if (i*i == N) {
			ans++;
			break;
		}
		if (N%i == 0) {
			key.push_back(i);
		}
	}
	if (key.size() == 0) {
		cout << ans << endl;
		return 0;
	}
	REP(i, key.size()) {
		ll n = N;
		while (n >1) {
			if (n%key[i] == 0) {
				n /= key[i];
			}
			else {
				break;
			}
		}
		if (n == 1) {
			ans++;
		}
		else {
			if (n > key[i]) {
				if (n%key[i] == 1)ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
#define rep(i, n) for(int i=0; i<(int)(n); i++)
inline double sq(double a) { return a*a; }

int N, M;
double L[40], A[40], B[40];

int main() {
    scanf("%d%d", &N, &M);
    rep(i, N) scanf("%lf%lf%lf", L+i, A+i, B+i);
    double ans = 0;
    const int nn = 1<<N;
    int b = (1<<M)-1;
    while(b<nn) {
        double s = 0;
        rep(i, N) if(b&(1<<i)) rep(j, i) if(b&(1<<j)) {
            s += sq(L[i]-L[j]) + sq(A[i]-A[j]) + sq(B[i]-B[j]);
        }
        ans = max(ans, s);
        if(b==0) break;
        const int x=b&-b, y=b+x;
        b = ((b&~y)/x >> 1) | y;
    }
    printf("%.9f\n", ans);
    return 0;
}

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

const int MAX_N = 200005;

int N, K;
int ans;
int A[MAX_N];
map<int, int> mp;

int main(void){
    // Here your code !
    scanf("%d %d", &N, &K);
    for (int i = 0; i < N; ++i) {scanf("%d", &A[i]);}
    sort(A, A + N);

    for (int i = 0; i < N; ++i) {
      auto itr = mp.find(A[i]);
      if(itr != mp.end()) {mp[A[i]]++;}
      else {mp[A[i]] = 1;}
    }

    vector<int> vc;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr) {
      vc.push_back(itr->second);
    }

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

    int whole = vc.size();
    for (int i = 0; i < vc.size(); ++i) {
      if (whole <= K) break;
      else {
        ans += vc[i];
        whole--;
      }
    }
    printf("%d\n", ans);

    return 0;
}

Measured memory_bytes: 11516
import math
n, d = map(int, input().split(' '))

X = []
for i in range(n):
    X.append([int(el) for el in input().split(' ')])

count = 0
for i in range(n):
    for j in range(i+1, n):
        a = X[i]
        b = X[j]
        dist = math.sqrt(sum([(a-b)**2 for a, b in zip(a,b)]))
        if dist == int(dist):
            count += 1
print(count)

Measured memory_bytes: 3064
#include<iostream>

using namespace std;

int main(int argc, char const *argv[])
{
    long N=0,A=0,B=0;

    cin>>N>>A>>B;

    long long Max=A+(B*(N-1));
    long long Min=(A*(N-1))+B;
    long long ans =Max-Min+1;

    if(A>B)ans=0;
    if(N<=1&&A!=B)ans=0;

    cout<<ans<<endl;

    return 0;
}




Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

	n := nextInt()
	var sum float64 = 0.0
	for i := 0; i < n; i++ {
		tmp := nextInt()
		sum += 1 / float64(tmp)
	}

	fmt.Println(1 / sum)
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
/* Manish Pant - insider_pants, hello_my_friend */
    
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define endl "\n"
#define pb push_back

typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

template <class T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ", "; return os; }
template <class T> ostream& operator << (ostream &os, const set<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T> ostream& operator << (ostream &os, const multiset<T> &v) { for (T i : v) os << i << " "; return os; }
template <class T, class S> ostream& operator << (ostream &os, const pair<T, S> &v) { os << v.F << ' ' << v.S; return os; }
template <class T, class S> ostream& operator << (ostream &os, const map<T, S> &v) { for (auto i : v) os << '(' << i.F << " => " << i.S << ')' << ' '; return os; } 

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const ll MOD = 1e9 + 7;
ll n, k;

void solve()
{
    ll s = 0, e = n;
    ll prefix = 0, suffix = 0;

    for(int i = 0; i < k; i++)
    {
        prefix += s;
        suffix += e;
        s++;
        e--;
    }

    ll ans = 0;
    for(int i = k; i <= n + 1; i++)
    {
        ans += (suffix - prefix + 1);
        ans %= MOD;
        suffix += e;
        prefix += s;
        s++;
        e--;
    }
    cout<<ans<<endl;
}   

int main()
{
    fast();
    cin>>n>>k;
    solve();
}

Measured memory_bytes: 3652
#include <iostream> // cout, endl, cin
#include <cmath> //sqrt pow
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // dequef
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define rep(i,n) for(int i = 0; i < n; i++)
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int, int>
#define all(a) (a).begin(), (a).end()
#define mod 1000000007
using ll = long long;
using namespace std;
int main(){
  int d,t,s;
  cin >> d >> t >> s;
  if(d <= t * s) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

using namespace std;

const int MOD  = (int)1e9 + 7;
const int MAXN = 2000010;

int mul(int a, int b) { return ((long long) a * b) % MOD; }
int add(int a, int b) { return ((long long) a + b) % MOD; }

int fexp(int b, int e) {
    if (b == 0 || e == 1) return b;
    if (b == 1 || e == 0) return 1;
    int r = fexp(b, e / 2);
    if (e & 1) return mul(mul(r, r), b);
    return mul(r, r);
}

int fat[MAXN], ifat[MAXN];

void build() {
    fat[0] = 1;
    for(int i = 1; i < MAXN; ++i)
        fat[i] = mul(i, fat[i - 1]);

    ifat[MAXN - 1] = fexp(fat[MAXN - 1], MOD - 2);

    for(int i = MAXN - 2; i >= 0; --i)
        ifat[i] = mul(i + 1, ifat[i + 1]);
}

int comb(int n, int r) { 
    if (n < r) return 0; 
    return mul(fat[n], mul(ifat[r], ifat[n - r])); 
}

void solver() {
    build();

    int K; string S;
    cin >> K >> S;
    
    int N = S.length();

    int ans = 0;
    for(int i = N; i <= N + K; ++i) 
        ans = add(ans, mul(comb(N + K, i), fexp(25, N + K - i)));
    
    cout << ans << '\n';

}

int main() {

    ios_base :: sync_with_stdio(0); cin.tie(NULL);

    int t = 1;
    //cin >> t;
    
    while(t--)
        solver();

    return 0;
}

Measured memory_bytes: 19788
#include<bits/stdc++.h>
using namespace std;
#define maxn   200005
#define ll long long

ll dp[105][100007];

ll func(ll a[],ll w[],ll n,ll m)
{
	int i,j;
	for(i=0;i<=n;i++)
	dp[i][0]=0;
	
	for(i=0;i<=m;i++)
	dp[0][i]=0;
	
	for(i=1;i<=n;i++)
	{
		for(j=0;j<=m;j++)
		{
			if(j<a[i-1])
			dp[i][j]=dp[i-1][j];
			else
			{
				dp[i][j]=max(dp[i-1][j-a[i-1]]+w[i-1],dp[i-1][j]);
			}
		}
	}
	ll ma=0;
	for(i=0;i<=n;i++)
	ma=max(ma,dp[i][m]);
	
	return ma;
	
	
	
}

int main()
{
	cin.tie(0);
	cout.tie(0);
	ios_base::sync_with_stdio(0);
    ll n,m;
    cin>>n>>m;
    ll a[n],w[n],i;
    for(i=0;i<n;i++)
    cin>>a[i]>>w[i];
    
    cout<<func(a,w,n,m);
}

Measured memory_bytes: 80128
#include <vector>
#include <algorithm>
#include <iostream>
#include <cassert>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <ctime>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <cassert>
#include <stack> 

#define INFLL 2000000000000000000
#define INF 2000000000
#define MOD 1000000007
#define BASE 77747
#define PI acos(-1.0)
#define MAXLEN 29

typedef std::pair <int, int> pii;
typedef long long ll;
typedef std::vector <ll> vll;

using namespace std;

int n;
ll arr[200000];
ll ans = INFLL;

ll getAns(ll a, ll b, ll c, ll d) {
	ll mn = min(a, min(b, min(c, d)));
	ll mx = max(a, max(b, max(c, d)));
	return mx - mn;
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i++) cin >> arr[i];
	int m, l, r;
	m = 2;
	l = 1;
	r = n - 1;
	ll la = arr[0], lb = arr[1], ra = 0, rb = arr[n - 1];
	for (int i = 2; i < n - 1; i++) ra += arr[i];
	for (int i = r - 1; i >= m + 1; i--) {
		if (abs(ra - rb) < abs(ra - arr[i] - (rb + arr[i]))) break;
		else {
			ra -= arr[i];
			rb += arr[i];
			r = i;
		}
	}
	// cout << la << " " << lb << " " << ra << " " << rb << endl;
	// cout << l << " " << m << " " << r << endl;
	ans = min(ans, getAns(la, lb, ra, rb));
	for (int i = 3; i < n - 1; i++) {
		lb += arr[i - 1];
		ra -= arr[i - 1];
		for (int x = l + 1; x <= i - 1; x++) {
			if (abs(la - lb) < abs(la + arr[x - 1] - (lb - arr[x - 1]))) break;
			else {
				la += arr[x - 1];
				lb -= arr[x - 1];
				l = x;
			}
		}
		for (int x = r + 1; x <= n - 1; x++) {
			if (abs(ra - rb) < abs(ra + arr[x - 1] - (rb - arr[x - 1]))) break;
			else {
				ra += arr[x - 1];
				rb -= arr[x - 1];
				r = x;
			}
		}
		ans = min(ans, getAns(la, lb, ra, rb));
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1792
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
inv_A = [(0, 0)] * (H*W+1)
for y, a in enumerate(A):
    for x, a_ in enumerate(a):
        inv_A[a_] = (y, x)
C = [0] * D
c = 0
for i in range(D, H*W+1):
    y1, x1 = inv_A[i]
    y2, x2 = inv_A[i-D]
    C.append(abs(y1-y2)+abs(x1-x2)+C[i-D])
Ans = []
Q = int(input())
for _ in range(Q):
    l, r = map(int, input().split())
    Ans.append(C[r]-C[l])
print("\n".join(map(str, Ans)))


Measured memory_bytes: 34972
package main
import(
  "fmt"
)
func main(){
  var n, i, m int
  temp:=0
  fmt.Scan(&n)
  t:=make([]int, n)
  for i=0;i<n;i++{
    fmt.Scan(&t[i])
    temp+=t[i]
  }
  fmt.Scan(&m)
  p:=make([]int, m)
  x:=make([]int, m)
  ans:=make([]int, m)
  for i=0;i<m;i++{
    fmt.Scan(&p[i], &x[i])
    ans[i]=temp-t[p[i]-1]
    ans[i]=ans[i]+x[i]
  }
  for i=0;i<m;i++{
    fmt.Println(ans[i])
  }
}


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

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

inline void Main() {
  // code
  int n,p[20],r=0;
  cin>>n;
  rep(i,n) cin>>p[i];

  rep(i,n-2) {
    if(p[i+0] <= p[i+1] && p[i+1] <= p[i+2]) {
      r++;
    }
    else if(p[i+2] <= p[i+1] && p[i+1] <= p[i+0]) {
      r++;
    }
  }

  cout<<r<<endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
       
        static void SolveA()
        {
            var o = ReadAndParseIntArr();
            int n = o[0];
            int a = o[1];
            int b = o[2];
            int ans = Math.Min( a * n, b);
            Console.WriteLine(ans);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define mk make_pair
#define fi first
#define se second
#define vll vector<ll>
#define pii pair<ll,ll>
#define vvll vector< vector<ll> >
#define pb push_back
#define inf 1e16
#define M 1000000007
#define all(v) (v).begin(),(v).end()
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
#define mx 100010

int main(){
	IOS;
	ll n;cin>>n;
	ll a[n+1],b[n];rep(i,0,n+1)cin>>a[i];
	rep(i,0,n)cin>>b[i];
	ll ans=0;
	rep(i,0,n){
		if(b[i]<=a[i]){
			ans+=b[i];
		}
		else if(b[i]>a[i]){
			ans+=a[i];
			b[i]-=a[i];
			int t=min(a[i+1],b[i]);
			a[i+1]-=t;
			ans+=t;
		}
		// cout<<ans<<" ";
	}
	cout<<ans;
	return 0;
}



Measured memory_bytes: 1792
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            var R = cin.ReadInt;
            WriteLine((double)R * 3.1415 * 2.0);
        }

    }


    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; i++)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }


        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 27980