akhauriyash/Code-Regression huggingface dataset:
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

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


// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

int main() {
	int N; cin >> N;
	for (int i = 0; i < N; ++i) cin >> h[i];

	// 初期化 (最小化問題なので INF に初期化)
	for (int i = 0; i < 100010; ++i) dp[i] = INF;

	// 初期条件
	dp[0] = 0;

	// ループ
	for (int i = 0; i < N; ++i) {
		chmin(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]));
		chmin(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]));
	}

	// 答え
	cout << dp[N - 1] << endl;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    int dp[2][101]={0};
    vvl a(2,vl(n));
    rep(i,2)rep(j,n)cin>>a[i][j];
    rep1(i,n+1)dp[0][i] = dp[0][i-1]+a[0][i-1];
    rep1(i,n+1)dp[1][i] = max(dp[0][i],dp[1][i-1]) + a[1][i-1];
    out(dp[1][n]);
}


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

int main(){
    int M, D;
    cin >> M >> D;

    int d1, d10;
    d1 = 0;
    d10 = 0;

    int cnt = 0;
    if(D >= 22){
        for(int i = 1; i <= M; i++){
            for(int j = 22; j <= D; j++){
                d1 = j % 10;
                d10 = j / 10;
                if(d1 >= 2 && d10 >= 2){
                    if(d1*d10 == i){
                        cnt++;
                    }
                }
            }
        }
    }

    cout << cnt << endl;

    return 0;
}

Measured memory_bytes: 256
from itertools import product
n,m = (int(i) for i in input().split())
x,ans = [],0
for i in range(m):
    y = [int(i)-1 for i in input().split()]
    x.append(y[1:])
z = [int(i) for i in input().split()]
def check(q):
    p = 0
    for i in range(m):
        num = 0
        for j in x[i]:
            if q[j]: num+=1
        if num%2==z[i]: p+=1
    return p==m
for i in product((0,1), repeat=n):
    if check(i): ans+=1
print(ans)

Measured memory_bytes: 3064
n,k=map(int,input().split())
list_1=[]
for _ in range(n):
    list_1.append(0)
#print(list_1)

for i in range (k):
    d=int(input())
    list_temp=list(map(int,input().split()))
    for j in list_temp:
        list_1[j-1]+=1
#print(list_1)

print(list_1.count(0))

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

void solve()
{
	ll x;
	cin >> x;

	ll s = 100;
	int cnt = 0;
	while(s < x)
	{
		cnt++;
		s += s/100;
	}
	cout << cnt << "\n";
}

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


Measured memory_bytes: 3632
#include<iostream>
using namespace std;
int main()
{
	int n;
	cin>>n;
	const int N=n;
	int Y[N],M[N],D[N],S[N],p[N];
	for(int i=0;i<N;i++){
		cin>>Y[i];
		cin>>M[i];
		cin>>D[i];
		int r=333-(Y[i]/3);
		p[i]=Y[i]%3;
		switch(p[i]){
		case 0:S[i]=(999-Y[i])*39*5+5*r+(10-M[i])*20+(21-D[i]);
			break;
		default:if(M[i]==2||M[i]==4||M[i]==6||M[i]==8||M[i]==10)
			S[i]=(999-Y[i])*39*5+5*r+(10-M[i])*39/2+(20-D[i]);
		else
		S[i]=(999-Y[i])*39*5+5*r+(9-M[i])*39/2+20+(20-D[i]);
		}
	}
	for(int i=0;i<N;i++){
		cout<<S[i]<<"\n";
	}
}

Measured memory_bytes: 1160
#include <stdio.h>
#include <string.h>
#define N 10001
#define N2 1000001
int main(){
  char T[N2],P[N];
  int i,j,n,m,flag;
  
  scanf("%s",T);
  scanf("%s",P);
  
  n=strlen(T);
  m=strlen(P);
  
  for(i=0;i<n;i++) if(strncmp(&T[i],P,m)==0) printf("%d\n",i);

  return 0;
}

Measured memory_bytes: 1548
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=998244353,MAX=103,INF=1<<30;
const double eps=1e-12;

int par[MAX],size[MAX];

void init(int n){
    for(int i=0;i<n;i++){
        par[i]=i;
        size[i]=1;
    }
}

int root(int a){
    if(par[a]==a) return a;
    else return par[a]=root(par[a]);
}

void unite(int a,int b){
    if(root(a)!=root(b)){
        size[root(a)]+=size[root(b)];
        par[root(b)]=root(a);
    }
}

bool check(int a,int b){
    return root(a)==root(b);
}

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        int N;cin>>N;
        if(N==0) break;
        
        init(N);
        
        vector<double> x(N),y(N),z(N),r(N);
        vector<pair<double,pair<int,int>>> S;
        
        for(int i=0;i<N;i++) cin>>x[i]>>y[i]>>z[i]>>r[i];
        
        for(int i=0;i<N;i++){
            for(int j=i+1;j<N;j++){
                double d=hypot(hypot(x[i]-x[j],y[i]-y[j]),z[i]-z[j]);
                if(d<=r[i]+r[j]+eps) unite(i,j);
                else S.push_back({d-(r[i]+r[j]),{i,j}});
            }
        }
        
        sort(all(S));
        bool ok=false;
        
        for(int i=0;i<N;i++){
            if(size[root(i)]==N) ok=true;
        }
        
        if(ok){
            cout<<"0.000"<<endl;
            continue;
        }
        
        double ans=0.0;
        
        for(int i=0;i<S.size();i++){
            int a=S[i].second.first,b=S[i].second.second;
            if(check(a,b)) continue;
            unite(a,b);
            ans+=S[i].first;
            
            if(size[root(a)]==N) break;
        }
        
        cout<<fixed<<setprecision(3)<<ans<<endl;
    }
}






Measured memory_bytes: 3432
import sys
readline = sys.stdin.readline

N, M = map(int, readline().split())
MOD = 10**9+7

N -= 1
M -= 1
X = list(map(int, readline().split()))
CX = [x2 - x1 for x1, x2 in zip(X, X[1:])]
CX = [CX[i]*(N-i)*(i+1) for i in range(N)]
Y = list(map(int, readline().split()))
CY = [y2 - y1 for y1, y2 in zip(Y, Y[1:])]
CY = [CY[j]*(M-j)*(j+1) for j in range(M)]
print(sum(CX)%MOD*sum(CY)%MOD)   

Measured memory_bytes: 78436
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

int main(void) {
    int N, M;
    cin >> N >> M;
    vector<int> A(N);
    for(int i=0; i<N; i++) {
        cin >> A[i];
    }
    while(M>0) {
        sort(A.rbegin(), A.rend());
        int mid = A[0]/2;
        for(int i=0; i<N; i++) {
            if(M > 0 && A[i] >= mid) {
                A[i] /= 2;
                M--;
            } else {
                break;
            }
        }
    }
    long long int sum = 0;
    for(int i=0; i<N; i++) {
        sum += A[i];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define repdi(i,a,b) for(ll i=(a)-1;i>=(b);--i)
#define repd(i,a) repdi(i,a,0)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

using ll = long long;
using P = std::pair<ll, ll>;

constexpr ll INF = 1ll<<60;

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

template<class S, class T>
std::ostream& operator<< ( std::ostream& out, const std::pair<S,T>& a )
{ std::cout << '(' << a.first << ", " << a.second << ')'; return out; }

template<class T>
std::ostream &operator<< ( std::ostream& out, const std::vector<T>& a )
{ std::cout << '['; rep( i, a.size() ){ std::cout << a[i]; if( i != a.size()-1 ) std::cout << ", "; } std::cout << ']'; return out; }

ll N;
ll A[100010];
ll dp[100010];

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

  rep( i, N )
    std::cin >> A[i], A[i] *= -1;

  std::fill( dp, dp+N+1, INF );

  rep( i, N ) {
    ll idx = std::lower_bound( dp, dp+N+1, A[i]+1 )-dp;

    dp[idx] = A[i];
  }

  repd( i, N+1 ) if( dp[i] != INF ) {
    std::cout << i+1 << std::endl;

    break;
  }

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define int long long int
#define pb push_back
#define N 200100
#define MOD 1000000007
#define fn(i,n) for(int i=0;i<n;i+=1)
#define rep(i,l,r) for(int i=l;i<=r;i+=1)
#define INF 100000000000000
#define pii pair<int,int>
#define speed ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int power(int x,int y){
    int res=1LL;
    while(y){
        if(y&1){
            res=(res*x)%MOD;
        }
        x=(x*x)%MOD;
        y=(y>>1);
    }
}

signed main()
{
    
    speed
    int n;cin>>n;
    cout<<(n+1)/2<<endl;



    

    
    
    
    return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
l = []

#if a % 2 == 0:
#    print("NO")
#else:
for i in range(1,b+1):
    l.append((a * i) % b)

if l.count(c) != 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
n = int(input())
D = list(map(int, input().split()))

if D[0] != 0:
    print(0)
    exit()

A = [0]*n

for i in range(n):
    A[D[i]] += 1

#print(A)

if A[0] != 1:
    print(0)
    exit()

ans = 1
mod = 998244353
for i in range(1, n):
    ans *= A[i-1]**A[i]
    ans %= mod
print(ans)


Measured memory_bytes: 14396
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scanf("%d", &n)
	as := scanIntSlice(n)

	sum := 0
	values := map[int]int{}
	for _, a := range as {
		sum += a
		values[a]++
	}

	var q int
	fmt.Scanf("%d", &q)
	for i := 0; i < q; i++ {
		var b, c int
		fmt.Scanf("%d %d", &b, &c)
		n := values[b]
		sum += n * (c - b)
		if b != c {
			values[c] += n
			values[b] = 0
		}
		fmt.Printf("%d\n", sum)
	}

}

func scanIntSlice(size int) []int {
	input := []int{}
	for i := 0; i < size; i++ {
		var in int
		fmt.Scanf("%d", &in)
		input = append(input, in)
	}
	return input
}


Measured memory_bytes: 11320
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main(){
	int N, M;
  	cin >> N >> M;
  	vector<vector<string>> ans(N);
  	for(int i = 0; i < M; i++){
    	int p;
      	string s;
      	cin >> p >> s;
      	ans[p-1].push_back(s);
    }
  	long long ac = 0;
  	long long wa = 0;
  	for(int i = 0; i < N; i++){
      	bool solved = false;
      	int wa_ = 0;
    	for(int j = 0; j < ans[i].size(); j++){
          	if(ans[i][j] == "AC"){
            	solved = true;
            	break;
            }
        	if(!solved && ans[i][j] == "WA") wa_++;
        }
    	if(solved){
          ac++;
          wa += wa_;
        }
    }
  	cout << ac << ' ' << wa << endl;
}

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

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define repb(i, n) for (ll i = (n)-1; i >= 0; i--)
#define rep(i, n) repd(i, 0, n)

using namespace std;

using ll = long long;
using ul = unsigned long long;
using ld = long double;
ll mod = 1000000007;

int main() {
    string n;
    cin >> n;
    ll sum = 0;
    ll len = n.length();
    rep(i, len) { sum += n[i] - '0'; }
    cout << (sum % 9 ? "No" : "Yes") << endl;
    return 0;
}



Measured memory_bytes: 3688
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define intput(i) cout << i << endl
#define ll long long
#define stringput(s) cout << (string)(s) << endl

int main(){
  int a, b;
  cin >> a >> b;
  if(a%b == 0) cout << 0 << endl;
  else cout << 1 << endl;
}

Measured memory_bytes: 256
H, W, D = map(int, input().split())
x = [0] * (H * W + 1)
for i in range(H):
  a = list(map(int, input().split()))
  for j in range(W):
    x[a[j]] = [i, j]
    
#print(x)
d = [0] * (H * W + 1)
for i in range(1, H * W + 1):
  if i > D:
    d[i] = d[i - D] + abs(x[i][0] - x[i - D][0]) + abs(x[i][1] - x[i - D][1])

#print(d)    
Q = int(input())
for i in range(Q):
  l, r = map(int, input().split())
  print(d[r] - d[l])

Measured memory_bytes: 20460
(let ((s (read-line))
      (a (make-array (1+ (- (char-code #\z) (char-code #\a)))
                     :initial-element t)))
  (loop for c across s
        do (setf (aref a (- (char-code c) (char-code #\a))) nil))

  (let ((x (position t a)))
    (princ (if x
               (code-char (+ x (char-code #\a)))
               "None"))
    (terpri)))


Measured memory_bytes: 16864
#include<vector>
#include<queue>
#include<iostream>
#include<algorithm>
using namespace std;

#define INF 1e9

int cost[101][101];
int times[101][101];
int cost_d[101];
int time_d[101];
bool used[101];
int V;
int E;

void cost_dijkstra(int s) {
	for (int i = 0; i < V; i++) {
		cost_d[i] = INF;
		used[i] = false;
	}
	cost_d[s] = 0;
	
	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] && (v == -1 || cost_d[u] < cost_d[v])) {
				v = u;
			}
		}
		//全ての頂点が到達済み
		if (v == -1) {
			break;
		}
		//集合に新たに頂点を追加
		used[v] = true;
		for (int u = 0; u < V; u++) {
			if (cost[v][u] != -1) {
				cost_d[u] = min(cost_d[u], cost_d[v] + cost[v][u]);
			}
		}

	}
}
void time_dijkstra(int s) {
	for (int i = 0; i < V; i++) {
		time_d[i] = INF;
		used[i] = false;
	}
	time_d[s] = 0;

	while (true) {
		int v = -1;
		for (int u = 0; u < V; u++) {
			if (!used[u] &&( v == -1 || time_d[u] < time_d[v])) {
				v = u;
			}
		}
		//全ての頂点が到達済み
		if (v == -1) {
			break;
		}
		//集合に新たに頂点を追加
		used[v] = true;
		for (int u = 0; u < V; u++) {
			if (cost[v][u] != -1) {
				time_d[u] = min(time_d[u], time_d[v] + times[v][u]);
			}
		}

	}
}

int main() {


	while (cin >> E >> V, (E != 0 && V != 0)) {
		for (int i = 0; i < V; i++) {
			for (int j = 0; j < V; j++) {
				cost[i][j] = -1;
				times[i][j] = -1;
			}
		}
		
		for (int i = 0; i < E; i++) {
			int a, b,c,t;
			cin >> a >> b>>c>>t;
			cost[a - 1][b - 1] = cost[b - 1][a - 1] = c;
			times[a - 1][b - 1] = times[b - 1][a - 1] = t;
		}
	
		int k;//クエリの数
		cin >> k;
		
		for(int i=0;i<k;i++){
			int p, q, r;
			cin >> p>>q>>r;
			
			//cost
			if (r == 0) {
				cost_dijkstra(p-1);
				cout << cost_d[q-1] << endl;
			}
			//time
			else if(r==1){

				time_dijkstra(p-1);
				cout << time_d[q-1] << endl;
			}
			
		}
	}
	return 0;
}











Measured memory_bytes: 3132
#include <iostream>
#include <stdlib.h>
 
#define N 99999
 
using namespace std;
 
typedef struct p{
    char name[10];
    int time;
};
 
int main(){
 
    int i;
    int n;
    int q;
    int head;
    int tail;
    int res_time = 0;
    char temp[10];
    p A[N];
 
    cin >> n;
    cin >> q;
 
    for (i = 0; i < n; i++){
        cin >> A[i].name;
        cin >> A[i].time;
    }
 
    head = 0;
    tail = n - 1;
 
    while (1){
        A[head].time -= q;
        if (A[head].time <= 0){
            res_time += q + A[head].time;
            cout << A[head].name << ' ' << res_time << endl;
            if (tail == head){
                break;
            }
        }
        else {
            tail++;
            if (tail == N){
                tail = 0;
            }
            A[tail] = A[head];
            res_time += q;
        }
        head++;
        if (head == N){
            head = 0;
        }
    }
 
    return 0;
}


Measured memory_bytes: 4620
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> qua;
vector<qua> v;
const double epx=1e-7;
int ccw(qua a,qua b,qua c)
{
    b-=a,c-=a,a=c*conj(b);
    if(a.imag()>epx) return 1;
    if(a.imag()<-epx) return -1;
    if(a.real()<-epx) return 2;
    if(abs(b)+epx<abs(c)) return -2;
    return 0;
}
bool judge_convex(vector<qua> &ve)
{
    int len_ve=ve.size();
    int flag1=1,flag2=1;
    for(int i=0;i<len_ve;i++)
    {
        if(ccw(ve[i],ve[(i+1)%len_ve],ve[(i+2)%len_ve])==-1) flag1=0;
        if(ccw(ve[i],ve[(i+1)%len_ve],ve[(i+2)%len_ve])==1) flag2=0;
    }
    return flag1|flag2;
}
int main()
{
    int n;
    double x,y;
    scanf("%d",&n);
    while(n--)
    {
        scanf("%lf%lf",&x,&y);
        v.push_back(qua(x,y));
    }
    printf("%d\n",judge_convex(v));
}



Measured memory_bytes: 3284
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <cmath>

using namespace std;
using ll = long long int;

template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}


void solve(long long N, long long M, std::vector<long long> X, std::vector<long long> Y, std::vector<long long> Z){
  map<ll, vector<ll>> m;
  for(ll i=1; i<=N; i++) {
    vector<ll> v;
    m[i] = v;
  }
  for(ll i=0; i<M; i++) {
    m[X[i]].push_back(Y[i]);
    m[Y[i]].push_back(X[i]);
  }
  vector<ll> vis(N+1, 0);
  ll cnt = 0;
  for(ll i=1; i<=N; i++) {
    if(vis[i]) continue;
    cnt++;
    queue<ll> q;
    q.push(i);
    while(!q.empty()) {
      ll x = q.front();
      q.pop();
      vis[x] = 1;
      for(auto suc: m[x]) {
	if(vis[suc]) continue;
	q.push(suc);
      }
    }
  }
  std::cout << cnt << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  long long M;
  scanf("%lld",&M);
  std::vector<long long> X(M);
  std::vector<long long> Y(M);
  std::vector<long long> Z(M);
  for(int i = 0 ; i < M ; i++){
    scanf("%lld",&X[i]);
    scanf("%lld",&Y[i]);
    scanf("%lld",&Z[i]);
  }
  solve(N, M, std::move(X), std::move(Y), std::move(Z));
  return 0;
}



Measured memory_bytes: 15988
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long
int main () {
  ll n, m;
  cin >> n >> m;
  if (n % 3 == 0 || m % 3 == 0 ) { 
    cout << 0 << endl;   
  }  
  else {
    vector<ll> sub(3);
    // まずはどの程度やるか決める
    ll min = -1;
    ll l = n / 3;
    ll v[5] = {0, -1, 1, -2, 2};
    for (ll i = 0; i < 5; i++) {
      ll j = l + v[i];
      sub[0] = j * m;
      if (j <= 0 || j >= n) {
        
      }
      else {
        for (ll q = j + 1; q < n; q++) {
          sub[0] = j * m;
          sub[1] = (q - j) * m;
          sub[2] = (n - q) * m;
          sort(sub.begin(), sub.end());
          if (min == -1 || sub[2] - sub[0] <= min) {
            min = sub[2] - sub[0];  
          }    
        }
        for (ll q = 1; q < m; q++) {
          sub[0] = j * m;
          sub[1] = q * (n - j);
          sub[2] = (n - j) * (m - q);
          sort(sub.begin(), sub.end());
          if (min == -1 || sub[2] - sub[0] <= min) {
            min = sub[2] - sub[0];  
          }    
        }  
      }    
    }
    l = m / 3;
    for (ll i = 0; i < 5; i++) {
      ll j = l + v[i];
      sub[0] = j * n;
      if (j <= 0 || j >= m) {
        
      }
      else {
        for (ll q = j + 1; q < m; q++) {
          sub[0] = j * n;
          sub[1] = (q - j) * n;
          sub[2] = (m - q) * n;
          sort(sub.begin(), sub.end());
          if (min == -1 || sub[2] - sub[0] <= min) {
            min = sub[2] - sub[0];  
          }  
        }
        for (ll q = 1; q < n; q++ ) {
          sub[0] = j * n;
          sub[1] = q * (m - j);
          sub[2] = (m - j) * (n - q);
          sort(sub.begin(), sub.end());
          if (min == -1 || sub[2] - sub[0] <= min) {
            min = sub[2] - sub[0];  
          }  
        }  
      }  
    }
    cout << min << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
    string S;
    long long K;
    cin >> S >> K;
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == '1') {
            K--;
        }
        else {
            cout << S[i] << endl;
            break;
        }
        if (K == 0) {
            puts("1");
            break;
        }
    }
}

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

int a[110];

int main(){
	int n;
	scanf("%d", &n);
	double sum = 0;
	for (int i = 0; i < n; i++){
		scanf("%d", &a[i]);
		sum += a[i];
	}
	sum /= n;
	int pos = -1;
	for (int i = 0; i < n; i++){
		if (pos == -1 || abs(sum - a[pos]) > abs(sum - a[i])) pos = i;
	}
	printf("%d\n", pos);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define int long long
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	int n, r;
	cin >> n >> r;
	if(n >= 10) cout << r << endl;
	else cout << r + 100 * (10 - n) << endl;
}

Measured memory_bytes: 256
S = list(input())

a = "<"
b = ">"

def nasu(n):
  return (n * (n + 1)) // 2

L = len(S)
t = 0

bc = 0
if S[0] == b:
  bc = 0
  for i in range(L):
    if S[i] == b:
      bc += 1
    else:
      t = i
      break
  else:
    print(nasu(bc))
    exit()
      
ans = nasu(bc)
bc = 0
ac = 0
f = True

while t < L:
  if f:
    if S[t] == a:
      ac += 1
    else:
      bc += 1
      f = False
  else:
    if S[t] == b:
      bc += 1
    else:
      if ac > bc:
        ac, bc = bc, ac
      ans += nasu(ac - 1) + nasu(bc)
      ac = 1
      bc = 0
      f = True
  t += 1

if bc != 0:
  if ac > bc:
    ac, bc = bc, ac
  ans += nasu(ac - 1) + nasu(bc)
else:
  ans += nasu(ac)

print(ans)

Measured memory_bytes: 91112
# https://atcoder.jp/contests/m-solutions2019/submissions/5741430
from operator import mul
import sys

input = sys.stdin.readline

MOD = 10 ** 6 + 3


def inv(n):
    return pow(n, MOD - 2, MOD)


def mod_mul(x, y):
    return mul(x, y) % MOD


fact = [1]
for n in range(1, MOD):
    fact.append(mod_mul(fact[-1], n))
    # d>1 の数列を d=1 となる数列に変換する
    # MODの倍数を含む数列の積は0になるので,
    # MODの倍数を含まない区間の積が計算できればよい
    # そのような区間の右端はMOD-1であり,fact[MOD-1]が計算できればよい

Q = int(input())
for _ in range(Q):
    x, d, n = map(int, input().split())

    if x == 0:
        print(0)
        continue

    if d == 0:
        print(pow(x, n, MOD))
        continue

    xd = mod_mul(x, inv(d))
    if MOD - xd < n:
        print(0)
        continue

    dn = pow(d, n, MOD)
    print(mod_mul(mod_mul(fact[xd + n - 1], inv(fact[xd - 1])), dn))


Measured memory_bytes: 45500
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cmath>     // pow
#include <cstdint>   // int64_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   // setprecision
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
using namespace std;

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

int main() {
    int N;
    cin >> N;
    int prev = 100100;
    int ans = 0;
    for(size_t i = 0; i < N - 1; i++) {
        int b;
        cin >> b;
        ans += b <= prev ? b : prev;
        prev = b;
    }
    ans += prev;
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const unsigned int M = 1000000007;
int main(){
 string s;
 cin >> s;
 if(s=="SSS"){
    cout << 0 << endl;
 }else if(s == "RRS" || s == "SRR"){
     cout << 2 << endl;
 }else if(s == "RRR"){
     cout << 3 <<endl;
 }else{
     cout << 1 << endl;
 }
 return 0;
}

Measured memory_bytes: 3628
H, W = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
B = [list(map(int, input().split())) for _ in range(H)]
C = [[abs(A[i][j] - B[i][j]) for j in range(W)] for i in range(H)]

M = (H+W)*80
dp = [[0] * W for _ in range(H)]
dp[0][0] |= 1 << (M-C[0][0])
for i in range(H):
    for j in range(W):
        if i == j == 0:
            continue
        bit = 0
        if i > 0:
            bit |= dp[i-1][j]
        if j > 0:
            bit |= dp[i][j-1]
        dp[i][j] = (bit >> C[i][j]) | (bit << C[i][j])
ans = M
for i in range(M+1):
    if (dp[-1][-1] >> i) & 1:
        ans = min(ans, abs(M-i))
print(ans)

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

signed main(){
  int n;
  cin >> n;
  vector<int> v(n);
  vector<int> c(n);
  for(int i = 0; i < n; i++){
    cin >> v[i];
  }
  for(int i = 0; i < n; i++){
    cin >> c[i];
  }
  int ans = 0;
  for(int i = 0; i < n; i++){
    if(v[i] > c[i]) ans += v[i] - c[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3600
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <map>
#include <iomanip>
#include <set>
#include <ctime>
#include <tuple>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

/*
using PAIR = pair<string, int>;
sort(sp.begin(), sp.end(), [](PAIR l, PAIR r){
        return l.first<r.first || (l.first==r.first && l.second > r.second);
        });
*/

typedef long long ll;

#define fi first
#define se second
#define rep(i, n) for (ll i = 0; i < n; i++)
#define debugA() cerr << "AAAAA" << endl
#define debug_() cerr << "-------------" << endl
#define debug(x) cerr << #x << ": " << x << endl
#define debug_vec(v)                   \
    for (int i = 0; i < v.size(); i++) \
    {                                  \
        cout << v[i] << " ";           \
    }                                  \
    cout << endl;

using Graph = vector<vector<int>>;

int main()
{
    int n;
    cin >> n;
    vector<pair<int, int>> vec(n);
    for (int i = 0; i < n; i++)
    {
        int a, b;
        cin >> a >> b;
        vec[i] = {b, a};
    }
    sort(vec.begin(), vec.end());
    int tmp = 0;
    for (int i = 0; i < n; i++)
    {
        tmp += vec[i].se;
        if (tmp > vec[i].fi)
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 1792
import java.util.*;
 
public class Main{
 
    int[] v;
    int[] dx = {0,0,1,-1};
    int[] dy = {1,-1,0,0};
 
    void solve(){
        Scanner sc = new Scanner(System.in);

        calc();
 
        while(sc.hasNext()){
            String pzl = "";
            for(int i=0; i<2; i++){
                for(int j=0; j<4; j++){
                    pzl += sc.next();
                }
            }

            int ans = v[Integer.parseInt(pzl.substring(0,7))];
 
            System.out.println(ans);
        }
    }
 
    void calc(){
        Queue<int[]> q = new LinkedList<int[]>();
        q.add(new int[]{1234567,0,0,0});
        v = new int[7654322];
        Arrays.fill(v,-1);
 
        while(q.size()>0){
            int[] pp = q.poll();
            int pzz = pp[0], x = pp[1], y = pp[2], cnt = pp[3];
  
            if(v[pzz/10]!=-1) continue;
            v[pzz/10] = cnt;
 
            String pzzs = String.valueOf(pzz);
            if(pzzs.length()==7) pzzs = "0" + pzzs;
            char[] c = pzzs.toCharArray();
 
            for(int i=0; i<4; i++){
                int nx = x+dx[i], ny = y+dy[i];
                if(nx<0 || nx>=4 || ny<0 || ny>=2) continue;
                c[y*4+x] = c[ny*4+nx];
                c[ny*4+nx] = '0';
                int ns = Integer.parseInt(String.valueOf(c));
                q.add(new int[]{ns,nx,ny,cnt+1});
                c[ny*4+nx] = c[y*4+x];
                c[y*4+x] ='0';
            }
        }
    }
 
    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 43000
class Combination:
    def __init__(self, mod, max_num):
        self.mod = mod
        self.fac = [0] * max_num
        self.finv = [0] * max_num
        self.inv = [0] * max_num

        self.fac[0], self.fac[1] = 1, 1
        self.finv[0], self.finv[1] = 1, 1
        self.inv[1] = 1

        for i in range(2, max_num):
            self.fac[i] = self.fac[i-1] * i % mod
            self.inv[i] = mod - self.inv[mod % i] * (mod // i) % mod
            self.finv[i] = self.finv[i - 1] * self.inv[i] % mod

    def calc(self, n, k):
        if n < k:
            return 0
        if n < 0 or k < 0:
            return 0
        return self.fac[n] * (
            self.finv[k] * self.finv[n - k] % self.mod) % self.mod


n, k = map(int, input().split())
com = Combination(1000000007, 500000)

ret = 1

min_val = min(n, k)

for i in range(1, min_val+1):
    if i != n:
        ret += com.calc(n, i) * com.calc(n-1, i)
        ret %= 10 ** 9 + 7
    else:
        ret += 0

print(ret)


Measured memory_bytes: 64372
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <string.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;


int main()
{
int n,l;
int i=0;
cin >> n;
int table[n+1];
for (int i = 0; i < n; i++) {
    cin >> table[i];
}


table[n+1]=0;
int max=0,count=0;

for(i=0;i<n;++i){
    if(max<table[i])
    max=table[i];
}

while(max!=0){
    for(i=0;i<n;++i){
        if(max==table[i]){
            if(table[i]==table[i+1])table[i]--;
            else {table[i]--;count++;}
        }
    }
    max--;
}

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

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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

typedef pair<int, int> P;

int main(){
  int h, w;
  while(cin >> h >> w && (h != 0 && w != 0)){
    P base(h * h + w * w, h);
    P ans(INF, INF);
    int ans_x, ans_y;
    for(int y = 1; y <= 150; y++){
      for(int x = y + 1; x <= 150; x++){
        P p(x * x + y * y, y);
        if(p > base && p < ans){
          ans = p;
          ans_x = x, ans_y = y;
        }
      }
    }
    printf("%d %d\n", ans_y, ans_x);
  }
  return 0;
}

Measured memory_bytes: 1144
#include<bits/stdc++.h>
#define int long long int
using namespace std;
signed main(){
  	int n;
  	cin>>n;
  	int a[n];
  	for(int i=0;i<n;i++){
  	    cin>>a[i];
  	}
  	stack<int> st;
  	
  	int cnt=0;
  	for(int i=0;i<n;i++){
  	    if(!st.empty()&&st.top()>a[i]){
  	        cnt+=(st.top()-a[i]);
  	    }
  	   else{
  	        st.push(a[i]);
  	    }
  	}
  	cout<<cnt;
  	return 0;
}
  

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

using namespace std;

int main(){
    int n;
    cin >> n;
    
    long a[n];
    
    for(int i = 0; i < n; i ++){
        cin >> a[i];
    }
    
    long max = a[0], min = a[0];
    
    for(int i = 1; i < n; i ++){
        if(a[i] > max)
            max = a[i];
        else if(a[i] < min)
            min = a[i];
    }
    
    cout << max-min << endl;
    
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define INF 1000000000000000000
typedef pair<ll, ll> pll;

int main() {
    int H, W;
    cin >> H >> W;
    vector<vector<char>> G(H, vector<char>(W));

    rep(i, H) {
        rep(j, W) { cin >> G[i][j]; }
    }

    vector<vector<int>> dp(H + 5, vector<int>(W + 5, 1e9));
    dp[0][0] = 0;
    if (G[0][0] == '#')
        dp[0][0] = 1;

    int dx[2] = {1, 0};
    int dy[2] = {0, 1};
    rep(i, H) {
        rep(j, W) {
            for (int k = 0; k < 2; k++) {
                int nx = j + dx[k];
                int ny = i + dy[k];
                if (nx >= W || ny >= H)
                    continue;
                if (G[i][j] == '.' && G[ny][nx] == '#')
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j] + 1);
                else
                    dp[ny][nx] = min(dp[ny][nx], dp[i][j]);
            }
        }
    }

    cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 3660
import java.util.Scanner;

class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext())
		{
			String str = sc.next();
			int joi = 0, ioi = 0;
			int length = str.length();
			StringBuffer buf = new StringBuffer(str.substring(0, 3));
			if (buf.toString().equals("JOI")) joi++;
			if (buf.toString().equals("IOI")) ioi++;
			for (int i = 3; i < length; i++)
			{
				buf.setCharAt(0, buf.charAt(1));
				buf.setCharAt(1, buf.charAt(2));
				buf.setCharAt(2, str.charAt(i));
				if (buf.toString().equals("JOI")) joi++;
				if (buf.toString().equals("IOI")) ioi++;
			}
			System.out.println(joi);
			System.out.println(ioi);
		}
	}
}

Measured memory_bytes: 12000
from collections import deque
from typing import List, Optional, Tuple


def cycle_detectable_topological_sort(
    graph: List[List[int]], in_degrees: List[int], first_index: int = 0
) -> Tuple[Optional[List[int]], Optional[List[int]]]:
    """Topological sort that uses Kahn's algorithm and detects a loop (DAG or not).
    Returns:
        if the given graph is DAG, a list of sorted vertices and a list of depths of
        each vertex is returned.
        Otherwise, (None, None) is returned.
    """
    V = len(graph) + first_index
    order = []
    depths = [-1] * V  # depths[i] := the length of the longest path to V_i
    for i in range(first_index, V):
        if not in_degrees[i]:
            order.append(i)
            depths[i] = 0

    queue = deque(order)
    while queue:
        u = queue.popleft()
        cur_depth = depths[u]
        for v in graph[u]:
            in_degrees[v] -= 1
            if not in_degrees[v]:
                depths[v] = max(depths[v], cur_depth + 1)
                queue.append(v), order.append(v)
    return (order, depths) if len(order) + first_index == V else (None, None)


def grl_4_a():
    # https://onlinejudge.u-aizu.ac.jp/courses/library/5/GRL/4/GRL_4_A
    V, _, *ST = map(int, open(0).read().split())
    graph = [[] for _ in range(V)]
    in_degrees = [0] * V
    for s, t in zip(*[iter(ST)] * 2):
        graph[s].append(t)
        in_degrees[t] += 1

    res, _ = cycle_detectable_topological_sort(graph, in_degrees)
    print(1 if res is None else 0)


if __name__ == "__main__":
    grl_4_a()



Measured memory_bytes: 7380
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<ll>;
using pll = pair<ll, ll>;
using qll = queue<ll>;
using vb = vector<bool>;
using mll = map<ll, ll>;
using sll = stack<ll>;
#define REP(i,n) for(ll i(0);(i)<(n);(i)++)
#define rep(i,n) for(ll i(0);(i)<(n);(i)++)
#define ALL(a) a.begin(), a.end()
#define elnd endl //* missspell check
const ll INF = 1LL << 60;

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

bool checkGood(string s){
    ll N = s.length();
    REP(i, N-1){
        if(s[i]=='#' && s[i+1]=='#'){
            return false;
        }
    }
    return true;
}

bool checkPass(string s){
    ll N = s.length();
    REP(i, N-2){
        if(s[i]=='.' && s[i+1]=='.' && s[i+2]=='.'){
            return true;
        }
    }
    return false;
}

void solve(long long N, long long A, long long B, long long C, long long D, std::string S){
    bool isGood = checkGood(S.substr(B+1, D-B)) && checkGood(S.substr(A+1, C-A));
    if(C<D){
        if(isGood)
            cout << YES << endl;
        else
            cout << NO<<endl;
        return;
    }
    else{
        bool canPass = checkPass(S.substr(B-1, D-B+3));
        if(isGood && canPass)
            cout << YES << endl;
        else
            cout << NO<<endl;
        return;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    A--; B--; C--; D--;
    std::string S;
    std::cin >> S;
    solve(N, A, B, C, D, S);
    return 0;
}


Measured memory_bytes: 772
#include <iostream>

using namespace std;

int main(){

  int a,b,c=0,sum=0;

  char e;

  cin >> sum;


  while(1){

    cin >> e;

    if(e=='='){
      // printf("%d\n",sum);
      cout << sum << '\n';
      break;
    }

    cin >> a;
    //     cout << e << '\n';


     if(e=='+'){
      sum+=a;
      // cout << e << '\n';
    }

    else if(e=='-'){
      sum-=a;
      // cout << e << '\n';
    }

    else if(e=='*'){
      sum*=a;
      // cout << e << '\n';
    }

    else if(e=='/'){
      sum/=a;
      // cout << e << '\n';
    }

  }

  return 0;
}

Measured memory_bytes: 1160
#!/usr/bin/env python3
import sys
INF = float("inf")


def solve(A: int, B: int):
    if A+B >= 10:
        print('error')
    else:
        print(A+B)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    solve(A, B)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
solve :: Int -> [Int] -> String
solve n p
    | diffCount <= 2 = "YES"
    | otherwise = "NO"
        where diffCount = length $ filter (\(a, b) -> a /= b) $ zip [1..n] p


main :: IO()
main = do
    line <- getLine
    let n = read line :: Int
    line <- getLine
    let p = map read $ words line :: [Int]
    putStrLn $ solve n p

Measured memory_bytes: 3932
n, m, c = map(int, input().split())
b = [int(inp) for inp in input().split()]
cnt = 0

for i in range(n) :
    sum = 0
    a = [int(inp) for inp in input().split()]
    for j in range(m) :
        sum += a[j] * b[j]
    if sum + c > 0 :
        cnt += 1

print(cnt)


Measured memory_bytes: 3060
from collections import defaultdict
import sys,heapq,bisect,math,itertools,string,queue,datetime
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
AtoZ = [chr(i) for i in range(65,65+26)]
atoz = [chr(i) for i in range(97,97+26)]

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

N,A,B = inpl()

print(min(N*A,B))


Measured memory_bytes: 4200
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <math.h>
#include <limits.h>
#include <stack>
#include <complex>
#include <stdlib.h>
#include <stdio.h>
#include <functional>
#include <cfloat>
#include <math.h>


#define fs first
#define sc second

using namespace std;


typedef long long ll;
typedef pair<ll, ll> P;


int main(){
    ll W, H;
    ll x, y;
    cin >> W >> H >> x >> y;
    ll res = W * H / 2;
    if((W * H) % 2 == 0){
        cout << res << ".000000 ";

    }
    else{
        cout << res << ".500000 ";
    }

    if(2 * x == W && 2 * y == H){
        cout << 1 << endl;
    }
    else{
        cout << 0 << endl;
    }


    

    return 0;
}


Measured memory_bytes: 256
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()
    val H = Array.fill(N)(sc.nextInt())

    def solve(): Int = {
      var count = 0
      while (true) {
        var i = 0
        var flag = false
        while (i < N && H(i) == 0) {
          i += 1
        }
        while (i < N) {
          while (i < N && H(i) > 0) {
            H(i) -= 1
            i += 1
            flag = true
          }
          count += 1
          while (i < N && H(i) == 0) {
            i += 1
          }
        }
        if (!flag)
          return count
      }
      count
    }

    println(solve())
  }

}

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

int main() {
    int q;
    deque<int>Q;
    cin >> q;
    while (q--) {
        int a, b, c;
        cin >> a >> b;
        if (!a) {
            cin >> c;
            if (b)Q.push_back(c);
            else Q.push_front(c);
        }
        else if (a == 1)cout << Q[b] << endl;
        else {
            if (b)Q.pop_back();
            else Q.pop_front();
        }
    }
}


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

#define int long long
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; }

signed main(){
	int a, b, c, k;
	cin >> a >> b >> c >> k;

	int ans = 0;
	int tmp = min(a, k);
	ans += tmp;
	k -= tmp;
	if(k == 0){
		cout << ans << endl;
		return 0;
	}
	tmp = min(b, k);
	k -= tmp;
	if(k == 0){
		cout << ans << endl;
		return 0;
	}

	cout << ans - k << endl;

	return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define mod 1000000007
void solve(){
	int n;
	cin>>n;
	int pr[1000001]={0};
	pr[0]=1;
	pr[1]=1;
	for(int i=2;i*i<=1000000;i++){
		if(!pr[i]){
			for(int j=i*i;j<1000001;j+=i){
				pr[j]=1;
			}	
		}
	}
	for(int i=n;i;i++){
		if(!pr[i]){
			cout<<i<<endl;
			break;
		}
	}
}

int main(){
    int t=1;
	//cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 7372
import bisect
A, B, Q = map(int, input().split())
INF = 10 ** 18
s = [-INF]
t = [-INF]
for _ in range(A):
    s.append(int(input()))
s.append(INF)
for _ in range(B):
    t.append(int(input()))
t.append(INF)
for q in range(Q):
    x = int(input())
    i, j = bisect.bisect_right(s, x), bisect.bisect_right(t, x)
    ans = min(
        max(abs(s[i] - x), abs(t[j] - x)),
        max(abs(s[i - 1] - x), abs(t[j - 1] - x)),
        2 * min(abs(s[i] - x), abs(t[j - 1] - x)) + max(abs(s[i] - x), abs(t[j - 1] - x)),
        2 * min(abs(s[i - 1] - x), abs(t[j] - x)) + max(abs(s[i - 1] - x), abs(t[j] - x))
    )
    print(ans)


Measured memory_bytes: 12084
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <climits>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define ALL(A)		(A).begin(),(A).end()
#define DUMP(A)    cout<<#A<<"="<<(A)<< endl
#define SIZE(A)    (int)((A).size())
#define MP  make_pair
using namespace std;
typedef long long ll;

int vx[]={1,0,-1,0},vy[]={0,1,0,-1};

int main(){
    int N,A,B,C,cs[100];
    scanf("%d%d%d%d",&N,&A,&B,&C);
    for(int i=0;i<N;i++){
        scanf("%d",&cs[i]);
    }
    sort(cs,cs+N,greater<int>());
    int ma,amo=C;
    ma=amo/A;
    for(int i=0;i<N;i++){
        amo+=cs[i];
        ma=max(ma,amo/(A+B*(i+1)));
    }
    printf("%d\n",ma);
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<string>
#include<tuple>
#include<algorithm>
#include<iomanip>
#include<math.h>
#include<stdio.h>

using namespace std;

int main(){
    int a, b;

    cin >> a >> b;

    int dif = b-a;
    int oriA = 0;

    for(int i=0; i<dif; i++)
    {
        oriA += i;
    }

    int ans = oriA -a;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <list>
#include <string>
#include <vector>
#include <cinttypes>

struct Union {
  std::vector<std::vector<int> > a;
  std::vector<int> b;
  Union (int n) {
    a.resize(n);
    for (int i = 0; i < n; i++)
      a[i] = {i};
    b.resize(n);
    for (int i = 0; i < n; i++)
      b[i] = i;
  }
  void unite(int x, int y) {
    if (same(x,y)) return;
    x = b[x];
    y = b[y];
    if (a[x].size() < a[y].size()) std::swap(x,y);
    for (auto i : a[y]) {
      b[i] = b[x];
      a[x].push_back(i);
    }
    a[y].clear();
  }
  bool same(int x, int y) {
    return b[x] == b[y];
  }
  int size(int x) { return a[b[x]].size(); }
};

int main() {
  int n;
  scanf("%d", &n);
  int m;
  scanf("%d", &m);
  int a[m];
  int b[m];
  for (int i = 0; i < m; i++) {
    scanf("%d", a+i);
    a[i]--;
    scanf("%d", b+i);
    b[i]--;
  }
  int64_t res[m];
  int64_t cur = n * ((int64_t) n-1) / 2;
  Union uni(n);
  for (int i = m-1; i >= 0; i--) {
    res[i] = cur;
    if (uni.same(a[i],b[i])) continue;
    cur -= uni.size(a[i]) * (int64_t)uni.size(b[i]);
    uni.unite(a[i], b[i]);
  }
  for (int i = 0; i < m; i++) printf("%" PRId64 "\n", res[i]);
}



Measured memory_bytes: 12536
parseInt(x) = parse(Int, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
    n=parseInt(readline())
    h=reverse(parseMap(split(readline())))
    flg=true
    for i in 2:n
        if h[i]-h[i-1]==1
            h[i]-=1
        elseif h[i]-h[i-1]>1
            flg=false
        end
    end
    println(ifelse(flg,"Yes","No"))
end
main()

Measured memory_bytes: 120156
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		int k;
		k=sc.nextInt();
		if(k%2==0)
		{
			System.out.println((k*k)/4);
		}
		else
		{
			System.out.println((k+1)/2*(k-1)/2);
		}
	}
	
}


Measured memory_bytes: 20948