akhauriyash/Code-Regression huggingface dataset:
// by Batrrr
// This will be Accepted!
// Happy new year !!!
 
#include <bits/stdc++.h>
 
#define jyldam ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
#define pb push_back
#define mp make_pair
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
#define all(x) (x).begin(), (x).end()
 
#define F first
#define S second          
 
#define st(x) st+=x
#define pii pair<int, int>
#define pli pair<long long, int>
#define pil pair<int, long long>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;     
 
const int N = 2e5 + 17, M = N * 4, D = 2e3 + 17, mod = 1e9 + 7;
const ll INF = 1e9 + 17;
 
int tt = 1;
ll a[N];
ll dp[N];
int n;
int t[M];
 
void upd () {
		for (int i = 1; i <= M; i++) {
			t[i] = 0;
		}
}
 
void build (int v, int tl, int tr, int a[]) {
		if (tl == tr) {
			t[v] = a[tl];
			return;
		}
		int tm = (tl + tr) >> 1;
		build(v + v, tl, tm, a);
		build(v + v + 1, tm + 1, tr, a);
		t[v] = max(t[v + v], t[v + v + 1]);
}
 
int get (int v, int tl, int tr, int l, int r) {
		if (l > tr || tl > r) {
			return -INF;
		}
		if (l <= tl && tr <= r) {
			return t[v];
		}
		int tm = (tl + tr) >> 1;
		return max(get(v + v, tl, tm, l, r), get(v + v + 1, tm + 1, tr, l, r));
}
                                                
void solve () {
		int k;                
		cin >> n >> k;
		for (int i = 1; i <= n; i++) {
				cin >> a[i];                                    	
				dp[i] = INF;
		}             
		dp[1] = 0;
		for (int i = 1; i <= n; i++) {
				for (int j = 1; j <= k; j++) {
						dp[i+j] = min(dp[i+j], dp[i] + abs(a[i+j] - a[i]));
				}
		}
		cout << dp[n];
}
		    
int main() {
		jyldam;
						                  
		while (tt--) {   
			solve();
		}
   	
		return 0;
}

Measured memory_bytes: 4352
function calc(dp,a,b,c)
	next=ones(Int,401,401)*1145141919810
	for i=1:401,j=1:401
		next[i,j]=min(next[i,j],dp[i,j])
		if i+a<=401&&j+b<=401
			next[i+a,j+b]=min(next[i+a,j+b],dp[i,j]+c)
		end
	end
	next
end
function main()
	N,Ma,Mb=map(x->parse(Int,x),split(readline()))
	dp=ones(Int,401,401)*1145141919810
	dp[1,1]=0
	for i=1:N
		a,b,c=map(x->parse(Int,x),split(readline()))
		dp=calc(dp,a,b,c)
	end
	ans=1145141919810
	for i=1:401,j=1:401
		if i==j==1
			continue
		end
		if (i-1)Mb==(j-1)Ma
			ans=min(ans,dp[i,j])
		end
	end
	println(ans<1145141919810 ? ans : -1)
end
main()


Measured memory_bytes: 159652
#include <stdio.h>
struct data{
    int par;
    int left;
    int right;
};
typedef struct data node;
void Preorder(int);
void Inorder(int);
void Postorder(int);
node tree[100000];
int main(){
    int n,i,j,cur,cur_n,root;
    for(i=0;i<100000;i++){
        tree[i].par=-1;
        tree[i].left=-1;
        tree[i].right=-1;
    }
    scanf("%d",&n);
    for(i=0;i<n;i++){
        scanf("%d",&cur);
        scanf("%d %d",&tree[cur].left,&tree[cur].right);
        if(tree[cur].left!=-1) tree[tree[cur].left].par=cur;
        if(tree[cur].right!=-1) tree[tree[cur].right].par=cur;
    }
   root=0;
   while(1){ 
        if(tree[root].par==-1) break;
        root=tree[root].par;
    }
    printf("Preorder\n");
    Preorder(root);
    printf("\nInorder\n");
    Inorder(root);
    printf("\nPostorder\n");
    Postorder(root);
    printf("\n");
    return 0;
}
void Preorder(int u){
    if(u==-1){
        return;
    }
    printf(" %d",u);
    Preorder(tree[u].left);
    Preorder(tree[u].right);
}
void Inorder(int u){
    if(u==-1){
        return;
    }
    Inorder(tree[u].left);
    printf(" %d",u);
    Inorder(tree[u].right);
}
void Postorder(int u){
    if(u==-1){
        return;
    }
    Postorder(tree[u].left);
    Postorder(tree[u].right);
    printf(" %d",u);
}


Measured memory_bytes: 2916
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
using namespace std;
#define ll long long
#define MAX 100100
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
int n,a[MAX],ans;
int vis[MAX];
int main()
{
	n=read();
	for(int i=1;i<=n;++i)a[i]=read();
	for(int i=1;i<=n;i+=2)vis[a[i]]++;
	int mx1=0,mx2=0,s1=0,s2=0;;
	for(int i=1;i<MAX;++i)if(vis[i]>vis[mx1])mx1=i;
	s1=vis[mx1];memset(vis,0,sizeof(vis));
	for(int i=2;i<=n;i+=2)vis[a[i]]++;
	for(int i=1;i<MAX;++i)if(vis[i]>vis[mx2]&&i!=mx1)mx2=i;
	s2=vis[mx2];ans=(n/2-s1)+(n/2-s2);
	
	memset(vis,0,sizeof(vis));
	mx1=mx2=s1=s2=0;
	for(int i=2;i<=n;i+=2)vis[a[i]]++;
	for(int i=1;i<MAX;++i)if(vis[i]>vis[mx2])mx2=i;
	s2=vis[mx2];memset(vis,0,sizeof(vis));
	for(int i=1;i<=n;i+=2)vis[a[i]]++;
	for(int i=1;i<MAX;++i)if(vis[i]>vis[mx1]&&i!=mx2)mx1=i;
	s1=vis[mx1];ans=min(ans,(n/2-s1)+(n/2-s2));
	printf("%d\n",ans);
	return 0;
}


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

static int[] dp=new int[10000001];
	
	
	public static int solve(int[] arr,int i,int n)
	{
		if(i==n-1)
		{
			return Math.abs(arr[i]-arr[n-1]);
		}
		if(dp[i]!=-1)
		{
			return dp[i];
		}
		int ans=solve(arr,i+1,n)+Math.abs(arr[i]-arr[i+1]);
		if(i<n-2)
		{
			ans=Math.min(ans,solve(arr,i+2,n)+Math.abs(arr[i]-arr[i+2]));
		}
		return dp[i]=ans;
	}

	public static void main(String[] args) {
		Arrays.fill(dp, 0,10000000,-1);
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int[] arr=new int[n];
		for(int i=0;i<n;i++)
		{
			arr[i]=sc.nextInt();
			
		}
		System.out.println(solve(arr,0,n));
		sc.close();

	}

}


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

struct node{
  struct node *r;
  struct node *l;
  struct node *p;
  int key;
};

typedef struct node *Node;
#define NIL NULL

Node root;

Node find(Node u,int k){
  while(u != NIL && k != u->key){
    if(k < u->key)u = u->l;
    else u = u->r;
  }
  return u;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->r = NIL;
  z->l = NIL;

   while(x != NIL){
    y = x;
    if(z->key < x->key){
      x = x->l;
      
    }else{
      x = x->r;
    }
  }
  z->p = y;
  if(y == NIL){
    root = z;
  }else{
    if(z ->key < y->key){
      y->l = z;
      
    }else{
      y->r = z;
    }
  }
}
    
void inorder(Node u){
    if(u == NIL){
  return;
}
  inorder(u->l);
  printf(" %d",u->key);
  inorder(u->r);
}

void preorder(Node u){
 if(u == NIL)return;
  printf(" %d",u->key);
  preorder(u->l);
  preorder(u->r);
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);

   if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
      
    }
  }
  return 0;
}



Measured memory_bytes: 20496
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int ans =
				Integer.parseInt(scan.next())+Integer.parseInt(scan.next());
		if(ans>=10){
			System.out.println("error");
		}else{
			System.out.println(ans);
		}

	}
}

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

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	list<int> b;
	for (int i = 0; i < n; i++) {
		if (i % 2 == 0)
			b.push_back(a[i]);
		else
			b.push_front(a[i]);
	}
	if (n % 2 == 0) {
		while (!b.empty()) {
			cout << b.front() << " ";
			b.pop_front();
		}
	}
	else {
		while (!b.empty()) {
			cout << b.back() << " ";
			b.pop_back();
		}
	}
	cout << endl;
	return 0;
}


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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (ll)(b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl

const int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int H, W; cin >> H >> W;
    string board[H];
    REP(i, H) {
        cin >> board[i];
    }
    REP(i, H) {
        REP(j, W) {
            int cnt = 0;
            if (board[i][j] == '#') {
                cout << "#";
                continue;
            }
            REP(k, 8) {
                int ni = i + dy[k], nj = j + dx[k];
                if(ni < 0 || ni >= H || nj < 0 || nj >= W) {
                    continue;
                }
                if(board[ni][nj] == '#') {
                    cnt++;
                }
            }
            cout << cnt;
        }
        cout << "\n";
    }
}

Measured memory_bytes: 3520
#include <stdio.h>

int main() {
    int N, K, output = 1;
    scanf("%d %d", &N, &K);
    
    for(int i = 0; i < N; i++){
    	(output + K > output * 2) ? output *=2 : output += K;
	}
	
	printf("%d\n", output);
	
	return 0;
	
}

Measured memory_bytes: 1728
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

#define next(a) ( ((a)+1)%SIZE )
#define ABS(x) ( (x)>0 ? x : -(x) )
#define MIN(x,y) ( (x) < (y) ? (x) : (y) )
#define MAX(x,y) ( (x) > (y) ? (x) : (y) )
#define INF 1000000000
#define SIZE 100000

typedef struct queue
{
	int front;
	int rear;
	int data[200];
}queue;

void init(queue* p)
{
	p->front = 0;
	p->rear = 0;
}

void enqueue(queue *p,int x)
{
	if (next(p->rear) == p->front)
		printf("OVERFLOW!\n");
	p->data[p->rear] = x;
	p->rear = next(p->rear);
}

int dequeue(queue *p)
{
	int x;

	if (p->front == p->rear)
		printf("NO DADA\n");

	x = p->data[p->front];
	p->front = next(p->front);

	return x;
}

int empty(queue *p)
{
	return p->front == p->rear;
}

void print(char* str, int a, int b)
{
	int i;

	for (i = a; i <= b; i++)
		printf("%c", str[i]);
	printf("\n");
}

void reverse(char* str, int a, int b)
{
	int i,j=0;
	char t;

	for (i = a; i <= (a + b) / 2; i++)
	{
		t = str[i];
		str[i] = str[b - j];
		str[b - j] = t;
		j++;
	}
}

void replace(char* str, int a, int b, char* temp)
{
	int i, j=0;

	for (i = a; i <= b; i++)
	{
		str[i] = temp[j];
		j++;
	}
}

double rad(int C)
{
	return M_PI * C / 180;
}

int main()
{
	int a, b, C;

	scanf("%d%d%d", &a, &b, &C);

	printf("%lf\n", (double)a * sin(rad(C)) * b * 0.5);
	printf("%lf\n", a+b+ sqrt(pow(a, 2) + pow(b, 2) - 2 * a * b * cos(rad(C))));
	printf("%lf\n", (double)b * sin(rad(C)));

	return 0;
}



Measured memory_bytes: 2060
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		
		while (true) {
			int n = scan.nextInt();
			int x = scan.nextInt();
			scan.nextLine();
			
			if(n==0 && x==0) {
				break;
			}
			
			int count=0;
			for(int i=1;i<=n;i++) {
				for(int j=i+1; j<=n; j++) {
					for(int k=j+1; k<=n; k++) {
						if(i+j+k == x) {
								count++;
						}
					}
				}
			}
			
			System.out.println(count);
		}
		
		scan.close();
	}
}


Measured memory_bytes: 26956
// @samraj2k #2ksr 
//Not showoff, but solid.
//Not handsome, but likeable.
//Not intelligent, but hardworking.
//Not with good speaking skills, but great thoughts.
//This is me.
#include<bits/stdc++.h>
#define ll long long int
#define endl '\n'
#define pb push_back
#define F first
#define S second
#define mod 1000000007
#define see(x) cout << (#x) << " is " << (x) << endl
#define see2(x,y) cout << (#x) <<" "<<(#y)<< " are " << (x) <<" "<<(y)<< endl
#define samraj2k ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;

int main()
{  
  samraj2k;
  int n;
  cin>>n;
  int arr[n][3];
  int dp[n][3]={0};
  for(int i=0;i<n;i++)
  {
    for(int j=0;j<3;j++)
      cin>>arr[i][j];
  }
  dp[0][0]=arr[0][0];
  dp[0][1]=arr[0][1];
  dp[0][2]=arr[0][2];
  for(int i=1;i<n;i++)
  {
    dp[i][0]=max(arr[i][0]+dp[i-1][1],arr[i][0]+dp[i-1][2]);
    dp[i][1]=max(arr[i][1]+dp[i-1][0],arr[i][1]+dp[i-1][2]);
    dp[i][2]=max(arr[i][2]+dp[i-1][1],arr[i][2]+dp[i-1][0]);
  }
  cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]));
  return 0;
}

Measured memory_bytes: 2560
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
using namespace std;

#define ll         long long
#define PI         acos(-1.0)
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)

int A, B, C, X;

int main(){
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> X;
    int ct = 0;
    for (int i = 0; i <= A; ++i) {
      for (int j = 0; j <= B; ++j) {
        for (int l = 0; l <= C; ++l) {
          if (X == 500 * i + 100 * j + 50 * l) ++ct;
        }
      }
    }
    cout << ct; 
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;


	public class Main{
		public static void main(String[] args){
			Scanner sc = new Scanner(System.in);
			int N = Integer.parseInt(sc.next());
			int M = Integer.parseInt(sc.next());
			String[] imgA=new String[N];
			String[] imgB=new String[M];
			Boolean checkAB;
			int j;
			int k;
			String s = "No";
			for(int i = 0;i<N;i++){
				imgA[i]="";
				imgA[i]=sc.next();
			}
			for(int i = 0;i<M;i++){
				imgB[i]="";
				imgB[i]=sc.next();
			}
			for(int i=0;i<(N-M+1);i++){
				for(j=0;j<(N-M+1);j++){
					checkAB = true;
					for (k=0;k<M;k++){
						checkAB = (checkAB) && imgA[j+k].substring(i, i+M).equals(imgB[k]);
					}

					if(checkAB){
						s="Yes";
					}
				}
			}
			System.out.println(s);
			sc.close();
		}
}

Measured memory_bytes: 22612
#include <iostream>
using namespace std;
#define ll long long int
#define mod 1000000007


char arr[10001][10001];
int n,m;
ll fun(int i, int j,ll **dp){ 
     if(i >=n || j >=m)
        return 0;
     if(i == n-1 && j == m-1)   
        return 1;
     if(arr[i][j] =='#')   
         return 0;
     if(dp[i][j] != -1)  {
         return dp[i][j];
     }
       dp[i][j] = (fun(i+1,j,dp) + fun(i,j+1,dp))%mod;
      return dp[i][j];

}


int main() {
    
    cin >> n >> m;

    for(int i=0; i<n; i++){       
         for(int j=0; j<m; j++)
          cin >> arr[i][j];
    }

    ll **dp = new ll*[n];
    for(int i=0; i<n; i++)
          dp[i] = new ll[m];
    for(int i=0; i<n; i++){ 
      for(int j=0; j<m; j++)
           dp[i][j] = -1;
    }
   
    cout <<  fun(0,0,dp);
    return 0;         
}


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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'

// n回繰り返し
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) // 1-indexed昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  // 0-indexed降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   // 1-indexed降順
#define all(x) (x).begin(),(x).end()

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii;  // 2次元配列
typedef vector<ll> vll;
typedef vector<double> vd;
typedef pair<int, int> PII;

template<typename T>
using vec = vector<T>;
template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
const ll infll = (1LL<<62)-1;
const int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int _StartTime_ = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化
    // cout << fixed << setprecision(15);

    int a,b,m; cin >> a >> b >> m;
    vi aa(a); rep(i,a) cin >> aa[i];
    vi bb(b); rep(i,b) cin >> bb[i];
    vi mm(m);
    rep(i,m) {
        int x,y,c; cin  >> x >> y >> c;
        --x;--y;
        mm[i] = aa[x] + bb[y] - c;
    }
    sort(all(aa));sort(all(bb));
    mm.push_back(aa[0] + bb[0]);

    sort(all(mm));
    cout << mm[0] << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-_StartTime_)/CLOCKS_PER_SEC));
}

Measured memory_bytes: 1792
//https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8 より
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// ここまで

fn run() {
    input! {
        s: chars,
        d: usize,
    }
    const MOD: u64 = 1_000_000_007;
    let mut dp = vec![0; d];
    let mut sup = 0;
    for x in s {
        let x = x as usize - '0' as usize;
        let mut next = vec![0; d];
        for i in 0..d {
            for k in 0..10 {
                next[(i + k) % d] += dp[i];
            }
        }
        for k in 0..x {
            next[(sup + k) % d] += 1;
        }
        sup = (sup + x) % d;
        for i in 0..d {
            dp[i] = next[i] % MOD;
        }
    }
    let ans = (dp[0] + MOD - 1 + if sup == 0 {1} else {0}) % MOD;
    println!("{}", ans);
}

fn main() {
    run();
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define dhoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);  
typedef long long ll;
typedef long double ld;
const ll inf = 1e18;
const int nax = 2e6 + 7;
const ll mod = 1e9 + 7;
//ll tree[4 * nax];
//9uS-22RSwk7gQqh
ll gcd(ll a , ll b){
	if(b == 0) return a;
	return gcd(b , a % b);	
}
ll lcm(ll a , ll b){
	ll g = gcd(a , b);
	ll lc = (a/g) * b;
	return lc;
}
//char a[55][55];
int dx[] = {1,0,-1,0,1,1,-1,-1};
int dy[] = {0,1,0,-1,1,-1,-1,1};
ll a[100];
int main()
{
	dhoom;
	int n , a , b;
	cin >> n >> a >> b;
	cout << min(n * a , b) << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

B, C = [], []
for i in range(N):
    B.append(A[i]+i)
    C.append(-A[i]+i)

B.sort()
C.sort()

num = [0] * 500000
for i in range(N):
    if B[i] < 0 or B[i] >= 500000:
         continue
    num[B[i]] += 1
ans = 0
for i in range(N):
    if C[i] < 0 or C[i] >= 500000:
         continue
    ans += num[C[i]]
print(ans)


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



signed main(){
    int n,a,b,k;
    int mod =998244353;
    cin >> n>>a>>b>>k;
    int b0=b,a0=a,t;
    if(a0>b0){
        t=b0;
        b0=a0;a0=t;
    }
    while(a0!=0){
        t=b0%a0;
        b0=a0;
        a0=t;
    }
    int q=a/b0,p=b/b0;
   // cerr <<p<<' '<<q<<endl;
   int x=0,k0=k;
    while(k0%b!=0&&k0>=0){
        x++;
        k0-=a;
    }
    if(k0<0){
        cout<<0;
    }
    else{
    
    int y=k0/b;
   //
    while(y>n){
        x+=p;
        y-=q;
    }
    // cerr << x<<' '<<y<<endl;
    if(x>n)cout<<0;
    else{
    int inv[n+1]={};
    inv[1] = 1;
    for(int i=2;i<=n;i++){
        inv[i]=mod-( inv[mod%i]*(mod/i))%mod;
       
    }
    int ans2=1, ans=1,qwe1=1,qwe2=1;
    for(int i=1;i<=x;i++){
        ans =(ans*(n+1-i)%mod)*inv[i]%mod;
     // if(ans<=0)cerr<<i<<endl;
    }
    // cerr <<ans<<endl;
     
    for(int i=1;i<=n-y;i++){
        ans=(ans*(n+1-i))%mod*inv[i]%mod;
      // if(ans<=0)cerr<<i<<endl;
    }    
    ans2=ans;
    cerr <<ans<<endl;
    for(int t=0;x+(t+1)*p<=n&&y-(t+1)*q>=0;t++){
        qwe1=1;qwe2=1;
        for(int i=1;i<=p;i++)qwe1 =(qwe1*(n+1-x-t*p-i)%mod)*inv[x+t*p+i]%mod;
        for(int i=1;i<=q;i++)qwe2=(qwe2*(y+1-t*q-i)%mod)*inv[n-y+t*q+i]%mod;
     //  cerr <<qwe1<<' '<<qwe2<<' '<<qwe2*3%mod<<endl;
        ans=ans*((qwe1*qwe2)%mod)%mod;
        ans2=(ans2+ans)%mod;
       cerr <<ans<<endl;
    }
    cout <<ans2;
    }
    }
    return 0;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  double m;
  cin >> n >> m;
  vector<int> a(n);
  double summation = 0;
  for (int i = 0; i < n; i++){
    double c;
    cin >> c;
    a.at(i) = c;
    summation = summation + c; 
  }
  double border = summation / (4 * m);
  int judge = 0;
  for (int i = 0; i < n; i++){
    if (a.at(i) >= border){
      judge++;
    }
  }
  if (judge >= m){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3732
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, K;
    cin >> N >> K;
    vector<double> p(N), sum(N + 1, 0);

    rep(i, N) {
        cin >> p[i];
        sum[i + 1] = sum[i] + p[i];
    }
    int m = 0;
    int index = 0;
    repd(i, K, N + 1) {
        if (m < sum[i] - sum[i - K]) {
            m = sum[i] - sum[i - K];
            index = i - K;
        }
    }

    double ans = 0;
    repd(i, index, index + K) {
        double res = ((p[i] + 1) * p[i]) / 2.0;
        ans += res / p[i];
    }

    printf("%.8lf", ans);
    return 0;
}


Measured memory_bytes: 6388
#include<iostream>
#include<vector>
#include<cstdio>
#include<string>
#include<cmath>
#include<math.h>
#include<algorithm>
#include<string.h>
#include <iomanip>
#include <sstream>
using namespace std;

int main() {
  string s;

  cin >> s;

  int N = 0;
  bool ans = true;
  N = s.size();
  if(s[2] == s[3] && s[4] == s[5]){

  }else{
    ans = false;
  }
  if(ans){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(void)
{
    int W, H, x, y, r;
    int left, right, top, bottom;
    
    cin >> W >> H >> x >> y >> r;
    
    left = x - r;
    right = x + r;
    top = y + r;
    bottom = y - r;
    
    if ((left >= 0) && (right <= W) && (bottom >= 0) && (top <= H))
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
ll mod=1e9+7;

int main() {
  ll n;
  cin >> n;
  vec b(n);
  vec a(n);
  for(ll i=0;i<n;i++) {
    cin >> b[i];
  }
  for(ll i=n-1;i>-1;i--) {
    for(ll j=b.size()-1;j>-1;j--) {
      if(b[j]==j+1) {
        a[i]=j+1;
        b.erase(b.begin()+j);
        break;
      }
    }
    if(a[i]==0) {
      cout << -1 << endl;
      return 0;
    }
  }
  for(ll i=0;i<n;i++) {
    cout << a[i] << endl;
  }
}

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

int main() {
	char a,b;
	cin >> a>>b;
	
	if(a=='H'){
		cout<<b<<endl;
	}else{
		if(b=='H'){
			cout<<'D'<<endl;
			
		}else{
			cout<<'H'<<endl;
		}
	}
	return 0;
}

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

using namespace std;

int main(){
    double a, b, x;
    cout<<setprecision(10);
    cin>>a>>b>>x;
    double ans;
    if(a*a*b/2 < x){
        double bd = (a*a*b-x)*2/(a*a);
        double rad = atan(bd/a);
        ans = rad * 180 / M_PI;
    }else{
        double ad = 2*x/(a*b);
        double rad = atan(b/ad);
        ans = rad * 180 / M_PI;
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 512
# TPBC201C - Stones
import sys
input = sys.stdin.readline

n = int(input())
s = input().rstrip()
ans = 0
blk = 0
for i in s:
    if i == "#":
        blk += 1
    else:
        if blk > 0:
            ans += 1
            blk -= 1
print(ans)


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

using namespace std;


int main (void) 
{

  int N; // 駐車時間
  int A; // plan1
  int B; // plan2

  int plan_1, plan_2;
  int x; // output


  cin >> N;
  cin >> A >> B;

  plan_1 = A*N;
  plan_2 = B;

  if(plan_1 <= plan_2)
  {
    x = plan_1;
  }
  else
  {
    x = plan_2;
  }
  
  cout << x << endl;


  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const double pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
REP(i,v.size()){if(i)os<<" ";os<<v[i];}return os;}
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) {
REP(i,v.size()){if(i)os<<endl;os<<v[i];}return os;}

int main() {
    
ll A,B;
cin>>A;
B=A-2;
cout<<180*B<<endl;
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<stdlib.h>
#include<utility>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define vint vector<int>
#define vvint vector<vint>
#define P pair<ll,ll>

using namespace std;
typedef long long ll;



int main(void) {
	int n, m; cin >> n >> m;
	if (n == m)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Runtime.Remoting.Contexts;
using System.Security.Cryptography.X509Certificates;

namespace Contest
{
    class Scanner
    {
        private string[] line = new string[0];
        private int index = 0;
        public string Next()
        {
            if (line.Length <= index)
            {
                line = Console.ReadLine().Split(' ');
                index = 0;
            }
            var res = line[index];
            index++;
            return res;
        }
        public int NextInt()
        {
            return int.Parse(Next());
        }
        public long NextLong()
        {
            return long.Parse(Next());
        }
        public string[] Array()
        {
            line = Console.ReadLine().Split(' ');
            index = line.Length;
            return line;
        }
        public int[] IntArray()
        {
            var array = Array();
            var result = new int[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = int.Parse(array[i]);
            }

            return result;
        }
        public long[] LongArray()
        {
            var array = Array();
            var result = new long[array.Length];
            for (int i = 0; i < array.Length; i++)
            {
                result[i] = long.Parse(array[i]);
            }

            return result;
        }
    }

    class Program
    {
        private long N, H;
        private long[] A, B;
        private void Scan()
        {
            var sc = new Scanner();
            N = sc.NextInt();
            H = sc.NextInt();
            A = new long[N];
            B = new long[N];
            for (int i = 0; i < N; i++)
            {
                A[i] = sc.NextInt();
                B[i] = sc.NextInt();
            }
        }

        public void Solve()
        {
            Scan();
            Array.Sort(B, (a, b) => -a.CompareTo(b));
            long max = A.Max();
            long cnt = 0;
            foreach (var i in B)
            {
                if (H <= 0)
                {
                    Console.WriteLine(cnt);
                    return;
                }

                if (i < max)
                {
                    break;
                }
                H -= i;
                cnt++;
            }

            cnt += (H + max - 1) / max;
            Console.WriteLine(cnt);
        }


        static void Main(string[] args)
        {
            new Program().Solve();
        }
    }
}

Measured memory_bytes: 16716
import sys

h, w = map(int, input().split())
s = [['.'] + list(input()) + ['.'] for i in range(h)]
s = [['.'] * (w+2)] + s + [['.'] * (w+2)]

for i in range(1, h+1):
    for j in range(1, w+1):
        if s[i][j] == '#':
            if s[i-1][j] == '.' \
                and s[i+1][j] == '.' \
                and s[i][j+1] == '.' \
                and s[i][j-1] == '.':
                print('No')
                sys.exit(0)
print('Yes')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int n,q;
  cin >> n >> q;
  string s;
  cin >> s;
  VI l(q), r(q);
  rep(i,q) cin >> l[i] >> r[i];
  
  VI v;
  bool a = false;
  rep(i,n){
    if(a && s[i]=='C') v.push_back(i);
    if(s[i] == 'A'){
      a = true;
    }else{
      a = false;
    }
  }
  
  rep(i,q){
    int L = l[i] - 1;
    int R = r[i] - 1;
    VI::iterator left,right;
    left = lower_bound(v.begin(), v.end(), L+1);
    right = upper_bound(v.begin(), v.end(), R);
    cout << (right-left) << endl;
  }
  
  return 0;
}

Measured memory_bytes: 2044
#include <assert.h>
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <string.h>
#include <vector>
#include <map>
#include <algorithm>
using namespace std;

const int inf = 10000000;

int main(int argc, char **argv) {
    int n, best = -inf, least = inf;
	int a;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &a);
		if (a > best) best = a;
		if (a < least) least = a;
	}
	cout << best - least << endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
data=[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    if data[i][2] >0:
        base=i
        break

for cx in range(101):
    for cy in range(101):
        h = data[base][2] + abs(cx-data[base][0]) + abs(cy - data[base][1])
        flag=0
        for i in range(N):
            if data[i][2] != max(h - abs(cx-data[i][0]) - abs(cy-data[i][1]),0):
                flag=1
                break
        if flag==0:
            ans = [cx,cy,h]
            
print('{0[0]} {0[1]} {0[2]}'.format(ans))

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

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))

#define INF 2e9
#define INF_LL 1LL<<60
#define ll long long

#define MAX_V 105

typedef pair<int, int> P; 


int main(){
    string s;
    cin >> s;
    REP(i, s.size()) {
        cout << 'x';
    }
    cout << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int d[26];

int main()
{
    string a;
    int flag;
    char b[26],c='a';
    cin>>a;
    for(int i=0; i<26; i++)
    {
        b[i]=c;
        c++;
    }
    for(int i=0; i<a.size(); i++)
    {
        for(int j=0; j<26; j++)
        {
            if(b[j]==a[i])
            {
                d[j]++;
            }
        }
    }
    for(int i=0; i<26; i++)
    {
        if(d[i]>0 && d[i]%2==0)
        {
            flag=0;
        }
        else if(d[i]>0)
        {
            flag=1;
            break;
        }
    }
    if(flag)
    {
        cout<<"No"<<endl;
    }
    else
    {
        cout<<"Yes"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
int main()
{
    int n;
    scanf("%d", &n);

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

        a[idx]++;
        a[idx + 1]++;
        a[idx - 1]++;
    }
    std::sort(a, a + 1000000);
    printf("%d\n", a[999999]);
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<string,int>;
const double PI = acos(-1);
int main() {
  int w,h,n;
  cin >> w >> h >> n;
  vector<vector<int>> s(h,vector<int>(w,0));
  rep(i,n){
    int x,y,a;
    cin >> x >> y >> a;
    if(a == 1){
      rep(j,h)rep(k,x) s.at(j).at(k) = 1;
    }
    else if(a == 2){
      rep(j,h)for(int k = x; k < w; k++) s.at(j).at(k) = 1;
    }
    else if(a == 3){
      rep(k,w)rep(j,y) s.at(j).at(k) = 1;
    }
    else{
      rep(k,w)for(int j = y; j < h; j++) s.at(j).at(k) = 1;
    }
  }
  int ans = 0;
  rep(i,h)rep(j,w){
    if(s.at(i).at(j) == 0) ans++;
  }
  cout << ans << endl;
}



Measured memory_bytes: 3676
n=int(input())
a=[list(map(int,input().split()))for _ in range(n)]
for k in range(n):
 b=a[k];b[3],b[4]=b[4],b[3]
def f():
 for i in range(n-1):
  d=a[i]
  for j in range(i+1,n):
   e=a[j]
   for p in('012345','152043','215304','302541','410352','514320'):
    f=[d[int(k)]for k in p]
    if f[0]==e[0]and f[5]==e[5]:
     f=f[1:5]*2
     for k in range(4):
      if f[k:k+4]==e[1:5]:return 1
 return 0
print(('Yes','No')[f()])


Measured memory_bytes: 5608
from fractions import gcd
N,X = map(int,input().split())
x = list(map(int,input().split()))
x.append(X)
x.sort()
m = x[1]-x[0]

for i in range(1,N+1):
    n = x[i]-x[i-1]
    v = gcd(m,n)
    m = v

print(m)






Measured memory_bytes: 16240
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define INF 1000000000
#define mod 1000000007
using ll=long long;
const ll LINF=1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

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

    int n,m;cin>>n>>m;
    cout<<n*(n-1)/2+m*(m-1)/2<<endl;

    return 0;
}


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

int main()
{
    char s[11], t[12];
    cin >> s >> t;

    for(int i=0; i<strlen(s); i++){
        if(s[i] != t[i]) {cout << "No" << endl; return 0;}
    }

    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3040
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

ll lcm(ll a,ll b){
   return a/gcd(a,b)*b;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll a,b;
    cin>>a>>b;
    if(a<=9 && b<=9) cout<<a*b<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<bits/allocator.h>
#include<bits/basic_ios.h>
#include<bits/basic_string.h>
#include<bits/basic_string.tcc>
#include<bits/c++config.h>
#include<bits/char_traits.h>
#include<bits/cpp_type_traits.h>
#include<bits/cxxabi_forced.h>
#include<bits/ios_base.h>
#include<bits/locale_classes.h>
#include<bits/localefwd.h>
#include<bits/ostream_insert.h>
#include<bits/postypes.h>
#include<bits/range_access.h>
#include<bits/stl_algobase.h>
#include<bits/stl_function.h>
#include<bits/stl_iterator.h>
#include<bits/stl_iterator_base_funcs.h>
#include<bits/stl_iterator_base_types.h>
#include<bits/stringfwd.h>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwchar>
#include<cwctype>
#include<debug/debug.h>
#include<deque>
#include<exception>
#include<ext/atomicity.h>
#include<ext/numeric_traits.h>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<utility>
#include<valarray>
#include<vector>
using namespace std;
int main()
{
	int n,ans=0;
	cin>>n;
	if (n%10==1) ans++;
	n/=10;
	if (n%10==1) ans++;
	n/=10;
	if (n%10==1) ans++;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc093/tasks/arc094_a
# C - Same Integers

a, b, c = list(map(int, input().split()))

abc_list = sorted([a, b, c])
c = 0

if (abc_list[1] - abc_list[0]) % 2 != 0:
    # 2番目と3番目に+1することで、最小値と2番目の差を偶数にする
    c += 1
    abc_list[1] += 1
    abc_list[2] += 1

# 最小値と2番目の値を揃える
c += (abc_list[1] - abc_list[0]) / 2
abc_list[0] += 2 * ((abc_list[1] - abc_list[0]) / 2)

# 両方をmax値まで揃える
c += (abc_list[2] - abc_list[1])
c = int(c)

print(c)


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

using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPR(i,n) for(int i=n; i>-1; --i)
#define ALL(a) (a).begin(),(a).end()
#define FILL(a,n,x); REP(i,(n)){ (a)[i]=(x); }
#define CINA(a,n); REP(i,(n)){ cin >> (a)[i]; }
#define FILL2(a,n,m,x); REP(i,(n)){ REP(j,(m)){(a)[i][j]=(x);} }
#define CINA2(a,n,m); REP(i,(n)){ REP(j,(m)){cin >> (a)[i][j];} }
#define Liny "Yes\n"
#define Linn "No\n"
#define LINY "YES\n"
#define LINN "NO\n"

//cout << setfill('0') << right << setw(4) << 12; // "0012"
int keta(ll x){ if(x<10){return 1;} else{return keta(x/10) + 1;}}
int keta_wa(ll x){ if(x<10){return x;} else{return keta_wa(x/10) + x%10;} }
int ctoi(char c){ return ( (c>='0' && c<='9')? c - '0': 0 );}
int __stoi(string s){ return atoi(s.c_str()); }
ll sum(ll a[],ll N){ return accumulate(a,a+N,0LL);}
ll gcd(ll a,ll b){if(a<b)swap(a,b); return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){if(a<b){swap(a,b);} return a/gcd(a,b)*b;}
template<class T> void chmax(T& a, T b){ if(a<b){a=b;} }
template<class T> void chmin(T& a, T b){ if(a>b){a=b;} }
template<class T> bool isIn(T a,vector<T> v){ for(T x:v){ if(a==x){return true;}} return false;}
string strReplace(string s,string target, string replacement){
    if (!target.empty()) {
      std::string::size_type pos = 0;
      while ((pos = s.find(target, pos)) != std::string::npos) {
        s.replace(pos, target.length(), replacement);
        pos += replacement.length();
      }
    }
    return s;
}
const ll MOD = 1e9+7;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define MP make_pair

bool DEBUG = 0;

int main(){
    int D; cin>>D;
    int c[27]; for(int i=1;i<=26;++i){ cin >> c[i]; }
    int s[D+1][27]; for(int d=1;d<=D;++d){ for(int i=1;i<=26;++i){ cin >> s[d][i]; } }
    
    int last[27] = {0};
    
    ll score = 0;
    for(int d=1;d<=D;++d){
        int i; cin>>i;
        score += s[d][i];
        last[i] = d;
        for(int j=1;j<=26;++j){
            score -= c[j]*(d-last[j]);
        }
        cout << score << "\n";
        
    }
    
}

Measured memory_bytes: 3636
# ####################################################################
# import io
# import sys

# _INPUT = """\
# 84 97 66
# 79 89 11
# 61 59 7
# 7
# 89
# 7
# 87
# 79
# 24
# 84
# 30

# """
# sys.stdin = io.StringIO(_INPUT)
####################################################################
import sys
def p(*_a):
  # return
  _s=" ".join(map(str,_a))
  #print(_s)
  sys.stderr.write(_s+"\n")
####################################################################
yn = lambda b: print('Yes') if b else print('No')
####################################################################
A = [[int(i) for i in input().split()] for _ in range(3)]

N = int(input())
B = [int(input()) for _ in range(N)]

for i in range(3):
  for j in range(3):
    if A[i][j] in B:
      A[i][j]=0

p(A)
a = A[0][0] + A[1][1] + A[2][2]
if a == 0:
  yn(True)
  exit()

a = A[0][2] + A[1][1] + A[2][0]
if a == 0:
  yn(True)
  exit()

a = 0
for i in range(3):
  a = 0
  for j in range(3):
    a += A[i][j]
  if a == 0:
    yn(True)
    exit()

a = 0
for j in range(3):
  a = 0
  for i in range(3):
    a += A[i][j]
  if a == 0:
    yn(True)
    exit()

yn(False)


Measured memory_bytes: 9292
A = int(input())
B = int(input())
C = int(input())
X = int(input())
count = 0

req_500 = X//500
max_500 = min(req_500, A)

for i in range(0, max_500+1):
	X_sub500 = X - 500*i
	req_100 = X_sub500//100
	max_100 = min(req_100, B)
		
	for j in range(0, max_100+1):
		X_sub100 = X_sub500 - 100*j
		req_50 = X_sub100//50
		if req_50 <= C:
			count += 1

print(count)

Measured memory_bytes: 3064
from fractions import gcd

def prime_factors(n):
    l=[]
    while n%2==0:
        l.append(2)
        n//=2
    while n%3==0:
        l.append(3)
        n//=3
    f=5
    limit=int(n**.5)
    while f<=limit:
        while n%f==0:
            l.append(f)
            n//=f
        f+=2
        while n%f==0:
            l.append(f)
            n//=f
        f+=4
    if n!=1:l.append(n)
    return l

a,b=map(int,input().split())
print(len(set(prime_factors(gcd(a,b))))+1)

Measured memory_bytes: 5684
#include<stdio.h>
int H;
int A[500002];
void maxHeapify(int i){
  int l = i*2;
  int r = l+1;
  int largest;
  int tmp;
  if(l<=H && A[l]>A[i]){
    largest = l;
  }
  else largest = i;
  if(r<=H && A[r]>A[largest]){
    largest = r;
  }

  if(largest !=i){
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }
}
void buildMaxHeap(void){
  int i;
  for(i=H/2;i>0;i--) maxHeapify(i);
}
int del(int i){
  int tmp;
  tmp = A[i];
  A[i] = A[H];
  A[H] = tmp;
  return A[H];
}
int main(){
  int i;
  scanf("%d",&H);
  for(i=1;i<=H;i++){
    scanf("%d",&A[i]);
  }
  buildMaxHeap();
  
  for(i=1;i<=H;i++){
    printf(" %d",A[i]);
  }
  printf("\n");
    
  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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 (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	ll h;
	cin >> h;
	cout << (ll)pow(2, (ll)log2(h) + 1) - 1 << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N=sc.nextInt();
        int A=sc.nextInt();
        int B=sc.nextInt();
        int ans=A*N;
        if(ans>B){
            System.out.println(B);
        }
        else{
            System.out.println(ans);
    }
}
}

Measured memory_bytes: 23124
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <set>
#include <map>

using namespace std;

int A[1000];

int main()
{
    int N, i, K, minimum;

    scanf("%d%d", &N, &K);
    for(i = 0; i < N; ++i)
        scanf("%d", &A[i]);
    sort(A, A + N);
    minimum = 0;
    for(i = 0; i < K; ++i)
        minimum += A[i];
    printf("%d", minimum);

    return 0;
}


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

int main(int argc, char const *argv[]) {
  int a,b,cnt=0;
  std::cin >> a >> b;
  for(int i=a; i<=b; i++){
    int j=i;
    if(j/10000==((j%10000)%1000)%100%10 && j%10000/1000 == j%10000%1000%100/10 ) cnt++;
  }

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


Measured memory_bytes: 256