akhauriyash/Code-Regression huggingface dataset:
n = int(raw_input())
   
d = [99999 for i in range(n)]
G = [0 for i in range(n)]
v = [[0 for i in range(n)] for j in range(n)]
   
def BFS(s):
  for e in range(n):
    if v[s][e] == 1:
      if d[e] > d[s] + 1:
        d[e] = d[s]+1
        BFS(e)
   
for i in range(n):
  G = map(int, raw_input().split())
  for j in range(G[1]):
    v[G[0]-1][G[2+j]-1] = 1
   
d[0] = 0
for s in range(n):
  BFS(s)
for s in range(n):
  if d[s] == 99999:
    d[s] = -1
for s in range(n):
  print'{0} {1}'.format(s+1, d[s])

Measured memory_bytes: 6488
D, N = map(int, input().split())

def calc(x):
    ret = 0
    while x % 100 == 0:
        x /= 100
        ret += 1
    return ret

cnt = 0
val = 0
while cnt < N:
    val += 1
    if calc(val) == D:
        cnt += 1

print(val)

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


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

	int cnt1 = 0, cnt2 = 0;

	while(a > 0){
		a = a - d;
		cnt2++;
	}

  // cout<<"a => "<<a<<"cnt1 "<<cnt1<<"\n";

	while(c > 0){
		c = c - b;
		cnt1++;
	}

  // cout<<"c => "<<c<<"cnt2 "<<cnt2<<"\n";

	if(cnt1<= cnt2){
		cout<<"Yes\n";
	}
	else{
		cout<<"No\n";
	}


	return 0;
}

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

L=list(map(int,input().split()))
ans = 0

for i in range(N):
	for j in range(i+1, N):
		for k in range(j+1, N):
			m = max(max(L[i], L[j]), L[k])
			if m < L[i]+L[j]+L[k]-m and L[i] != L[j] and L[j] != L[k] and L[k] != L[i]:
				ans+=1
				
print(ans)

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

int main() {
	int t;
	scanf("%d", &t);
	for(int i = 0; i < t; i++) {
		int n, d;
		scanf("%d %d", &n, &d);
		if(n > 1) {
			int add = (n%2 == 0) ? 127-d : d;
			printf("%d\n", (n-1)*127 + add);
		} else {
			printf("%d\n", d);
		}
	}
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

class Main{
    static node[] t;
    static StringBuilder sb = new StringBuilder();
    public static void main(String[] args) throws IOException{
        final BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        final int n = Integer.parseInt(br.readLine());
        t = new node[n];
        for(int i = 0; i<n; i++)
            t[i] = new node();
        for(int i = 0; i<n; i++){
            final StringTokenizer st = new StringTokenizer(br.readLine(), " ");
            final int id = Integer.parseInt(st.nextToken());
            final int left = Integer.parseInt(st.nextToken());
            final int right = Integer.parseInt(st.nextToken());
            t[id].left = left;
            t[id].right = right;
            if(left!=-1) t[left].parent = id;
            if(right!=-1) t[right].parent = id;
        }
        int root = 0;
        while(t[root].parent!=-1){
            root = t[root].parent;
        }
        sb.append("Preorder\n");
        preorder(root);
        sb.append('\n');
        sb.append("Inorder\n");
        inorder(root);
        sb.append('\n');
        sb.append("Postorder\n");
        postorder(root);
        sb.append('\n');
        System.out.print(sb);
    }
    static void preorder(int root){
        if(root==-1) return;
        sb.append(' ').append(root);
        preorder(t[root].left);
        preorder(t[root].right);
    }
    static void inorder(int root){
        if(root==-1) return;
        inorder(t[root].left);
        sb.append(' ').append(root);
        inorder(t[root].right);

    }
    static void postorder(int root){
        if(root==-1) return;
        postorder(t[root].left);
        postorder(t[root].right);
        sb.append(' ').append(root);
    }
}
class node{
    int parent;
    int left;
    int right;
    node(){
        parent = -1;
        left = -1;
        right = -1;
    }
}

Measured memory_bytes: 24452
import java.util.Scanner;

public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        int [] array = new int [n];
          for (int i = 0; i < array.length; i++) {
                  array[i]=scan.nextInt();
            }
            search(array);
        }
        static void search( int arr[] ){
          int max = arr[0];
          int min = arr[0];
          long sum=0;
          for (int i = 1; i < arr.length; i++) {
              if (arr[i] > max) {
                  max = arr[i];
              }
          }  
          for (int i = 1; i < arr.length; i++) {
              if (arr[i] < min) {
                  min = arr[i];
              }
          }
            for (int i = 0; i < arr.length; i++) {
              sum = sum + arr[i];
          }
          System.out.printf("%d %d %d\n",min,max,sum);
    }
}


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

typedef long long ll;
typedef pair<int,int> P;
ll const INF = 1LL<<60;

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

struct LazySegmentTree {
private:
    int n;
    vector<ll> node,lazy;
    vector<bool> upd;
public:
    LazySegmentTree(vector<ll> v) {
        int sz = v.size();
        n = 1;
        while (n < sz) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,INF);
        upd.resize(2*n-1,false);
        for (int i = 0;i < sz;++i) node[i+n-1] = v[i];
        for (int i = n-2;i >= 0;--i) node[i] = min(node[i*2+1],node[i*2+2]);
    }

    void eval(int k,int l,int r) {
        if (upd[k]) {
            if (node[k] > lazy[k]) node[k] = lazy[k];
            if (r-l > 1) {
                // lazy[2*k+1] = lazy[2*k+2] = lazy[k];
                if (lazy[2*k+1] > lazy[k]) lazy[2*k+1] = lazy[k];
                if (lazy[2*k+2] > lazy[k]) lazy[2*k+2] = lazy[k];
                upd[2*k+1] = upd[2*k+2] = true;
            }
            lazy[k] = INF;
            upd[k] = false;
        }
    }

    void update(int a,int b,ll x,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        eval(k,l,r);
        if (b <= l || r <= a) return;
        if (a <= l && r <= b) {
            if (upd[k]) {
                if (lazy[k] > x) lazy[k] = x;
            } else {   
                lazy[k] = x;
                upd[k] = true;
            }
            eval(k,l,r);
        } else {
            update(a,b,x,2*k+1,l,(l+r)/2);
            update(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = min(node[2*k+1],node[2*k+2]);
        }
    }

    ll getmin(int a,int b,int k = 0,int l = 0,int r = -1) {
        if (r < 0) r = n;
        if (b <= l || r <= a) return INT64_MAX;
        eval(k,l,r);
        if (a <= l && r <= b) return node[k];
        ll vl = getmin(a,b,k*2+1,l,(l+r)/2);
        ll vr = getmin(a,b,2*k+2,(l+r)/2,r);
        return min(vl,vr);
    }
};

struct interval {
    int l,r,c;
    bool operator<(const interval& a) const {
        return l < a.l;
    }
};

int main() {
    int n,m;
    cin >> n >> m;
    vector<interval> a(m);
    for (int i = 0;i < m;++i) cin >> a[i].l >> a[i].r >> a[i].c;
    LazySegmentTree seg(vector<ll>(n+10,INF));
    seg.update(1,2,0);
    sort(a.begin(),a.end());
    for (int i = 0;i < m;++i) {
        ll mn = seg.getmin(a[i].l,a[i].r+1);
        seg.update(a[i].l,a[i].r+1,mn+a[i].c);
    }
    ll ans = seg.getmin(n,n+1);
    if (ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 6272
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    S=ST()
    before=""
    for i,s in enumerate(S,start=1):
        if before==s:
            print(i-1,i)
            exit()
        before = s
    substr = "   "
    for i,s in enumerate(S,start=1):
        substr = substr[1:]+s
        if substr[0]==substr[-1]:
            print(i-2,i)
            exit()        
    print(-1,-1)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3700
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{1, 0, -1, 0, 1, -1, -1, 1};

inline bool inside(int y, int x, int h, int w) { return y >= 0 && x >= 0 && y < h && x < w; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int n;
  cin >> n;
  int maxi = -1;
  int ans = -1;
  for (int i = 1; i <= n; ++i) {
    int cnt = 0;
    int t = i;
    while (t % 2 == 0) {
      t /= 2;
      cnt++;
    }
    if (maxi < cnt) {
      maxi = cnt;
      ans = i;
    }
  }
  print(ans);
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <functional>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < int(n); ++(i))
#define whole(x) begin(x), end(x)
using namespace std;

int main() {
    int n; scanf("%d", &n);
    vector<vector<int> > g(n);
    repeat (i, n - 1) {
        int a_i_1; scanf("%d", &a_i_1); -- a_i_1;
        g[a_i_1].push_back(i + 1);
    }
    vector<int> dp(n);
    function<void (int)> go = [&](int i) {
        if (g[i].empty()) 
        if (g[i].empty()) return;
        vector<int> acc;
        for (int j : g[i]) {
            go(j);
            acc.push_back(dp[j]);
        }
        sort(whole(acc));
        reverse(whole(acc));
        repeat (k, acc.size()) acc[k] += k + 1;
        dp[i] = *max_element(whole(acc));
    };
    go(0);
    printf("%d\n", dp[0]);
    return 0;
}


Measured memory_bytes: 15488
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


struct mint {
    ll x;
    mint(ll x=0):x(x%MOD){}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
};

int main() {
    int n, k;
    cin >> n >> k;

    mint ans = 0;
    vll sum(n+2, 0);
    rep(i, n+1) sum[i+1] = i;
    rep(i, n+1) sum[i+1] += sum[i];
    
    srep(i, k, n+2) {
        ans += sum[n+1]-sum[n+1-i];
        ans -= sum[i]-1;
    }

    cout << ans.x << endl;
    return 0;
}

Measured memory_bytes: 4716
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <iostream>
#include <ctype.h>
#include <string>
typedef long long ll;
using namespace std;

int main(){
  int a,b;
  cin>>a>>b;
  int ans=a+b;
  if(ans<a*b) ans=a*b;
  if(ans<a-b) ans=a-b;
  cout<<ans;
    
  
    
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,x;
int main()
{
  cin >> a >> b >> x;
  ll res;
  if(a==0){
    res=b/x+1;
  }
  else{
    res=b/x-(a-1)/x;
  }
  cout << res << "\n";
  return 0;
}


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

#define MAX 100001
#define NIL -1

struct Node {
  int p; //親
  int l; //一番左の子
  int r; //右の兄弟
};

Node T[MAX];
int n, D[MAX];

void print(int u) {
  int i, c;
  cout<< "node "<<u<<": ";
  cout<<"parent = "<< T[u].p <<", ";
  cout<<"depth = "<<D[u]<<", ";

  if(T[u].p == NIL) cout<<"root, ";
  else if(T[u].l == NIL) cout<<"leaf, ";
  else cout<<"internal node, ";

  cout<<"[";

  for(i = 0, c = T[u].l; c!= NIL; i++, c = T[c].r) {
    if(i) cout<<", ";
    cout<<c;
  }
  cout<<"]"<<endl;
}

void rec(int u, int p) {
  D[u] = p;
  if(T[u].r != NIL) rec(T[u].r, p);
  if(T[u].l != NIL) rec(T[u].l, p+1);
}

int main() {
  int i, j, d, v, c, l, r;
  cin >> n;
  for(i = 0; i < n; i++) T[i].p = T[i].l = T[i].r = NIL;

  for(i = 0; i < n; i++) {
    cin>>v>>d;
    for(j = 0; j < d; j++) {
      cin >> c;
      if(j == 0) T[v].l = c;
      else T[l].r = c;
      l = c;
      T[c].p = v;
    }
  }
  for(i = 0; i < n; i++) {
    if(T[i].p == NIL) r = i;
  }

  rec(r, 0);

  for(i = 0; i < n; i++) print(i);
  return 0;
}



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

int main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while(1){
        c -= b;
        a -= d;
        if(c <= 0){
            cout << "Yes" << endl;
            break;
        }
        else if(a <= 0){
            cout << "No" << endl;
            break;
        }
    }
}

Measured memory_bytes: 3024
import sys
S = input()
S1 = S[0]
S2 = S[1]
S3 = S[2]
S4 = S[3]
S = [S1, S2, S3, S4]
kind = set([S1, S2, S3, S4])

if len(kind) == 2:
    for k in kind:
        if S.count(k) != 2:
            print("No")
            sys.exit()
    else:
        print("Yes")
        sys.exit()
else:
    print("No")

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

int main(){
  int K, S; cin >> K >> S;
  
  int cnt=0;
  for (int x=0; x<=K; x++){
    for (int y=0; y<=K; y++){
      int z=S-x-y;
      if(z>=0 && z<=K){cnt++;}
    }
  }
  cout << cnt << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define rando mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int invGeneral(int a, int b) {
    a %= b; if (a == 0) return b == 1 ? 0 : -1;
    int x = invGeneral(b,a); 
    return x == -1 ? -1 : ((1-(ll)b*x)/a+b)%b;
}
int32_t main(){
	boost;
	int n,k;
	cin>>n>>k;
	v vec(n);
	for (int i = 0; i < n; ++i)
		cin>>vec[i];
	int ans=0;
	for (int i = 0; i < n; ++i)
	{
		int c=0;
		for (int j = 0; j < n; ++j)
			if(vec[j]<vec[i])c++;
		int comp=0;
		for (int j = 0; j < i; ++j)
			if(vec[j]<vec[i])comp++;
		int val=0;
		for (int j = i+1; j < n; ++j)
			if(vec[j]<vec[i])val++;
		c=(c*(k))%MOD;
		c=(c-comp+MOD)%MOD;
		int a=((((c+val)%MOD)*(k))%MOD);
		ans=(ans+(invGeneral(2LL,MOD)*a)%MOD)%MOD;
	}
	cout<<ans;
	return 0;
}
//long long
//array bounds
//special cases
//binary search

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

int main() {
  char X;
  cin >> X;

  if ((X >= 'A') && (X <= 'Z')) {
    cout << 'A' << endl;
  }
  
  else if ((X >= 'a') && (X <= 'z')) {
    cout << 'a' << endl;
  }
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
const int MAXN = 2e5 + 7;
const int mod = 1e9 + 7;
inline int add(int x, int y) {int res = x + y; if (res >= mod) res -= mod; return res;}
int dp[MAXN], a[MAXN], b[MAXN], lst[MAXN], pos[MAXN];
int main()
{
    int n; scanf("%d", &n);
    int tot = 0;
    for (int i = 1; i <= n; i++) 
    {
        scanf("%d", &a[i]);
        if (a[i] != a[i - 1]) b[++tot] = a[i];
    }
    for (int i = 1; i <= tot; i++)
    {
        lst[i] = pos[b[i]];
        pos[b[i]] = i;
    }
    dp[0] = 1;
    for (int i = 1; i <= tot; i++)
    {
        dp[i] = dp[i - 1];
        if (lst[i]) dp[i] = add(dp[i], dp[lst[i]]);
    }
    printf("%d\n", dp[tot]);
    return 0;
}

Measured memory_bytes: 4096
using System;
public class A009{
    public static void Main(){
        string[] line = Console.ReadLine().Split(' ');
        int a = int.Parse(line[0]);
        int b = int.Parse(line[1]);
        int c = int.Parse(line[2]);
        
        if(a<b+c) Console.WriteLine(b+c-a);
        else Console.WriteLine("0");
    }
}

Measured memory_bytes: 11092
using System;
using System.Linq;

namespace ConsoleApplication5
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] array = new int[26];
            string alpha = "abcdefghijklmnopqrstuvwxyz";

            while (true)
            {
                string input = Console.ReadLine();

                if (input == null || input.Length == 0)
                {
                    break;
                }

                for (int i = 0; i < input.Length; i++)
                {
                    if (char.IsLower(input[i]))
                    {
                        int num = input[i] - 'a';
                        array[num]++;
                    }
                    else if (char.IsUpper(input[i]))
                    {
                        int num = input[i] - 'A';
                        array[num]++;
                    }
                }
            }

            for (int i = 0; i < array.Count(); i++)
            {
                Console.WriteLine(alpha[i] + " : " + array[i]);
            }
        }
    }
}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
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; }
const int INF=1001001001;
const int mod=10007;


int main() {
  int N;
  cin>>N;
  string t;
  int x=N;
  if(x==0){cout<<0<<endl;return 0;}
  while(x){
    int a=x%(-2);
    if(a<0){a+=2;x-=2;}
    t.push_back(a+'0');
    x/=(-2);
  }
  reverse(t.begin(),t.end());
  cout<<t<<endl;
  return 0;  
}

Measured memory_bytes: 3608
//#include "debug.h"
#include <string.h>
#include <limits.h>
#include <map>
#include <set>
#include <vector>
#include <algorithm>
using namespace std;

#define MAXN 100000

int n;
int a[MAXN];
int b[MAXN];
vector<int> op;

int input() {
	if (scanf("%d", &n) < 0) return 0;
	for (int i=0; i<n; i++) scanf("%d", &a[i]);
	return 1;
}

void init() {
}

vector<int> build(int *b) {
	vector<int> c(b, b+n), r;
	while (1) {
		int n=c.size();
		if (n==1) break;
		int p = -1;
		if (c[0]==0) p = 0;
		else if (c[n-1]==0) p = n-1;
		else {
			for (int i=1; i<n-1; i++)
				if (c[i]==0 && c[i-1] == c[i+1]) {
					p = i;
					break;
				}
		}
		//cout << p << ':' << c << endl;
		if (p<0) break;
		r.push_back(p);
		if (p==0 || p==n-1) {
			c.erase(c.begin()+p);
		}
		else {
			c[p] = c[p+1];
			c.erase(c.begin()+p+1);
			c.erase(c.begin()+p-1);
		}
	}
	return r;
}

long solve() {
	long ans = LONG_MIN;
	for (int k=0; k<2; k++) {
		memset(b, 0, sizeof(b));
		int maxi = k;
		long s = 0;
		for (int i=k; i<n; i+=2) {
			if (a[i] > a[maxi])
				maxi = i;
			if (a[i]>0) {
				s+= a[i];
				b[i] = 1;
			}
		}
		if (s==0) {
			s = a[maxi];
			b[maxi] = 1;
		}
		if (s>ans) {
			ans = s;
			op = build(b);
		}
	}
	return ans;
}

void output(long ans) {
	printf("%ld\n%d\n", ans, (int)op.size());
	for (auto x: op) {
		printf("%d\n", x+1);
	}
}

void cleanup() {
}

int main() {
	//int ca; scanf("%d", &ca);
	while (input()) {
		init();
		output(solve());
		cleanup();
		//break;
	}
}





Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
#define rer(i, a, b) for(ll i = ll(a) - 1; i >= ll(b); i--)
#define sz(v) (int)(v).size()
#define pb push_back
#define sc second
#define fr first
#define sor(v) sort(v.begin(),v.end())
#define rev(s) reverse(s.begin(),s.end())
#define lb(vec,a) lower_bound(vec.begin(),vec.end(),a)
#define ub(vec,a) upper_bound(vec.begin(),vec.end(),a)
#define uniq(vec) vec.erase(unique(vec.begin(),vec.end()),vec.end())
using namespace std;
typedef long long int ll;
typedef pair <int, int> P;

const ll MOD=1000000007;
const int MAX_V=700;
bool used[MAX_V][MAX_V];
vector <int> G[MAX_V];
int color[MAX_V];
int b,w;
//頂点を１と−１で塗る
bool dfs(int v,int c){
    color[v] = c;
    if(c==1) b++;
    else w++;
    bool t=true;
    rep(i, 0, G[v].size()){
        //隣接している頂点が同じ色ならfalse
        if (color[G[v][i]] == c) t=false;
        //隣接している頂点がまだ塗られていないなら-cで塗る
        if (color[G[v][i]] == 0 && !dfs(G[v][i], -c)) t=false;
    }
    //すべて塗れたらtrue
    return t;
}

int N, M;
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin>>N>>M;
    rep(i,0,N){
        rep(j,0,N){
            used[i][j]=1;
        }
    }
    rep(i,0,M){
        int a,b;
        cin>>a>>b;
        used[a-1][b-1]=0;
        used[b-1][a-1]=0;
    }
    rep(i,0,N){
        rep(j,0,N){
            if(i!=j&&used[i][j]) G[i].pb(j);
        }
    }
    vector<int> v;
    rep(i,0,N){
        if(color[i]==0){
            b=0, w=0;
            if(!dfs(i,1)){
                cout <<-1<<"\n";
                return 0;
            }
            v.pb(abs(b-w));
        }
    }
    bitset<710> bit;
    int sum=0;
    for(int k: v){
        bit=bit|(bit<<k);
        bit[k]=1;
        sum+=k;
    }
    ll ans=1000;
    rep(i,0,sum+1){
        if(bit[i]){
            if(abs(i-sum/2)<abs(ans-sum/2)) ans=i;
        }
    }
    ans+=(N-sum)/2;
    cout <<(ans)*(ans-1)/2+(N-ans)*(N-ans-1)/2<<"\n";
    
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
typedef long long int ll;
#define vaibhavv06               \
	ios::sync_with_stdio(false); \
	cin.tie(NULL);               \
	cout.tie(0);
#define int long long
#define MM(a,b) memset(a,b,sizeof(a))
const ll MOD = 1000000007;
using namespace std;

int32_t main(){
    vaibhavv06;
    
	int n; cin>>n;
	int arr[n];
	for(int i=0;i<n;i++) cin>>arr[i];
	int ans=0;
	int cnt=1;
	for(int i=0;i<n;i++){
		if(arr[i]==cnt) cnt++;
		else ans++;
	}
	if(ans==n) cout<<-1<<endl;
	else cout<<ans<<endl;
}


Measured memory_bytes: 1920
#include<iostream>
#include<math.h>

using namespace std;

int abs(int a, int b){
    if(b > a)return b - a;
    return a-b;
}

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

    long ans;
    if(K%2 == 0){
        int c1 = 0;
        int c2 = 0;
        for(int i = 1; i <= N; i++){
            if(i%K == 0)c1++;
            else if(i%K == K/2)c2++;
        }
        if(c1 == 0)ans = pow(c2, 3);
        else if(c2 == 0)ans = pow(c1, 3);
        else ans = pow(c1, 3) + pow(c2, 3);
    }
    else{
        int count = 0;
        for(int i = 1; i <= N; i++){
            if(i%K == 0)count++;
            ans = pow(count, 3);
        }
        
    }
    cout << ans << endl;
    
}
    

Measured memory_bytes: 256
# include <bits/stdc++.h>
# define rep(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
# define reps(i, n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
# define rrep(i, n) for(int i=((int)(n)-1); i>=0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>0; --i)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define optimize_cin() cin.tie(0); ios::sync_with_stdio(false)
# define MSG(x) std::cout << #x << " : " << x << "\n";
using namespace std;
using lint = 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; }

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if ((a*b) % 2)
    {
        printf("Odd\n");
    }
    else
    {
        printf("Even\n");
    }

    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
1000000

output:
400000
"""

import sys


def min_prime_factor(n):
    k = 2
    while True:
        if pow(k, 2) > n:
            return n
        if not n % k:
            return k
        k += 1


def phi(n):
    ans = n
    while True:
        p = min_prime_factor(n)
        if n == 1:
            break
        while not n % p:
            n //= p
        ans *= (1 - 1 / p)
    return int(ans)


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    n1 = int(_input[0])
    print(phi(n1))

Measured memory_bytes: 7724
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
int main() {
  int n,ans=10000;
  cin>>n;
  rep(i,n){
  int a,cnt=0;
  cin>>a;
  while(a%2==0){
  a/=2;
  cnt++;
  }
  ans = (ans<cnt ? ans : cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
const ll INF=1000000000000001;
const double PI=3.141592653589;


int main(){
  int n,k; cin>>n>>k;
  vector<int> x(n);
  rep(i,n) cin>>x[i];

  int ans=1000000009;
  int i=0;
  while(k+i-1<n){
    int l=x[i];
    int r=x[k-1+i];
    // cout<<"l "<<l<<" r "<<r<<endl;
    if(l<0){
      if(r<=0)
      ans=min(ans,-l);
      else{
        int g=min(-l*2+r,r*2-l);
        ans=min(ans,g);
      }
    }else{
      ans=min(ans,r);
    }
    i++;
    // cout<<"ans "<<ans<<endl;
  }
  cout<<ans<<endl;


  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
 
using namespace std;
 
#define rep(i, n) for(int i=0; i<(n); ++i)

bool isPrime[999999];

int main(void){
    int n;
    while(cin >> n) {
        rep(i, n+1) isPrime[i] = true;
        for(int i=2; i*i <= n; ++i) {
            if(isPrime[i]) {
                for(int j=2; i*j <= n; ++j) {
                    isPrime[i*j] = false;
                }
            }
        }
        int ans = 0;
        for(int i=2; i<=n; ++i) {
            if(isPrime[i]) ans++;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define REP(i,a,b) for(int i=int(a);i<(int)b;++i)
#define Graph vector<vecctor<ll>>
#define pairs vector<pair<ll,ll>>
#define pb push_back



using namespace std;
using ll = long long;
const ll INF = 1e18;
const double PI = acos(-1);

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 main(void)
{
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int a,b;
    cin >> a >> b;
    cout << 6-a-b << endl;
    return 0;
}


Measured memory_bytes: 3592
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b) = sc.nextLine.split(" ").map(_.toInt)
    if (a <= b) println(a)
    else println(a - 1)

  }

}


Measured memory_bytes: 25548
# include <bits/stdc++.h>
#define INF 9223372036854775807
using namespace std;

int main(){

  int H, W;
  int h, w;
  cin >> H >> W;
  cin >> h >> w;
  int ans = h*W + w*H - h*w;
  cout << H*W - ans << endl;

}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Main {

	public static void main(String[] a){

		BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));

		String tmpString = null;
		int[][] ans = new int[10][10];
		int count = 0;
		int max_color = 0;

		try {
			while(null != (tmpString = bf.readLine())){
				String[] tmp = tmpString.split(",");
				ans = poton(ans, Integer.parseInt(tmp[0]), Integer.parseInt(tmp[1]), Integer.parseInt(tmp[2]));
			}
			for(int i = 0; i < 10; i++){
				for(int j = 0; j < 10; j++){
					if(ans[i][j] == 0){
						count++;
					} else if(ans[i][j] > max_color) {
						max_color = ans[i][j];
					}
				}
			}
			System.out.println(count);
			System.out.println(max_color);
		} catch (IOException e) {
		}
	}

	private static int[][] poton(int[][] ans, int x, int y, int size){
		switch(size){
		case 3:
			if(x + 2 < 10)ans[x + 2][y] -= -1;
			if(x - 2 >= 0)ans[x - 2][y] -= -1;
			if(y + 2 < 10)ans[x][y + 2] -= -1;
			if(y - 2 >= 0)ans[x][y - 2] -= -1;
		case 2:
			if(x + 1 < 10 && y + 1 < 10)ans[x + 1][y + 1] -= -1;
			if(x + 1 < 10 && y - 1 >= 0)ans[x + 1][y - 1] -= -1;
			if(x - 1 >= 0 && y + 1 < 10)ans[x - 1][y + 1] -= -1;
			if(x - 1 >= 0 && y - 1 >= 0)ans[x - 1][y - 1] -= -1;
		case 1:
			ans[x][y] -= -1;
			if(x + 1 < 10)ans[x + 1][y] -= -1;
			if(x - 1 >= 0)ans[x - 1][y] -= -1;
			if(y + 1 < 10)ans[x][y + 1] -= -1;
			if(y - 1 >= 0)ans[x][y - 1] -= -1;
		}
		return ans;
	}
}

Measured memory_bytes: 9344
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let S: Vec<char> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.trim().chars().collect()
    };

    let ans = if (0..3).any(|i| S[i] == S[i + 1]) {
        "Bad"
    } else {
        "Good"
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define ls(x) (x)<<1
#define rs(x) (x)<<1|1
#define lson l,m,rt<<1
#define rson m+1,r,rt<<1|1
#define ll rt<<1
#define rr rt<<1|1
#define PI acos(-1)
#define MM int m=(l+r)>>1;
#define fu(i,r,t) for(int i=r;i<=t;i++)
#define fd(i,r,t) for(int i=r;i>=t;i--)
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl '\n'
#define lcm(a,b) (a*b)/__gcd(a,b)
#define Case(i,ans) cout<<"Case "<<i<<": "<<ans<<endl;
#define cp(i,ans) printf("%.if",ans);
#define cpp(i,ans) cout<<setprecision(i)<<fixed<<ans<<endl;
#define ppb pop_back
#define ppf pop_front
#define pb push_back
#define pf push_front
#define pq priority_queue
#define lowbit(x) (x)&(-x)
#define all(V) V.begin(),V.end()
#define ms multiset
#define mod(x) ((x+mo_num)%mo_num)
#define vc vector
#define vct vector<int>
#define fa(i,V) for(auto i:V)
#define out(i) cout<<(i)<<endl;
#define fi first
#define se second
#define fun(i) fu(i,1,n)
#define fut(i) fu(i,1,t)
#define fum(i) fu(i,1,m)
#define ld long double
//#define P pair<int,int>
using namespace std;
const int INF=LLONG_MAX;
const int maxn=300;
const int mo_num=1e9+7;
int n,m,a[maxn],b[maxn],ans;
ms<int>t,all;
int32_t main()
{
    IOS
    cin>>n>>m;
    fun(i) {
        cin >> a[i];
        all.insert(a[i]);
    }
    fu(i,1,m)//花多少在取上！
    {
        int out=m-i;//则就有out个可以扔掉
        if(i>=n)
        {
            int have=out;
            int this_time=0;
            fa(k,all)
            {
                if(k<0 && have){
                    have--;
                }else this_time+=k;
            }
            ans=max(ans,this_time);
            continue;
        }
        fu(zuo,0,i)//那么左边我要取zuo个
        {
            int you=i-zuo;//那么右边自然就是取you个
            t.clear();
            int have=out;
            fu(l,1,zuo)t.insert(a[l]);
            fd(l,n,n-you+1)t.insert(a[l]);
            int this_time=0;
            fa(k,t)
            {
                if(k<0 && have){
                    have--;
                }else this_time+=k;
            }
            ans=max(ans,this_time);
        }
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define REP(i, n) for(int i = 1; i < (int)(n); ++i)
using namespace std;

int main() {
    int n, m;
    cin >> n >> m;
    cout << (n - 1) * (m - 1) << endl;
    return 0;
}


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

long long gcd(long long a, long long b) {
    return (a == 0 ? b : gcd(b % a, a));
}

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

int main() {
    long long a[3], m[3], p[3], x;
    while (cin >> a[0] >> m[0] >> a[1] >> m[1] >> a[2] >> m[2], a[0]) {
        for (int i=0; i<3; ++i) {
            x = 1;
            for (int j=1; ; ++j) {
                x = (a[i] * x) % m[i];
                if (x == 1) {
                    p[i] = j;
                    break;
                }
            }
        }
        cout << lcm(p[0], lcm(p[1], p[2])) << endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
int main(){
	vector<int> times;
	int tmp;

	// a-e
	for (size_t i = 0; i < 5; ++i) {
		cin >> tmp;
		times.push_back(tmp);
	}

	sort(begin(times), end(times), [](int a, int b) {
		return a % 10 > b % 10;
	});

	size_t size = times.size();
	for (size_t i = 0; i < size; ++i) {
		if (times.at(i) % 10 == 0) {
			tmp = times.at(i);
			// 消して
			times.erase(begin(times) + i);
			// insert
			times.insert(begin(times), tmp);
		}
	}

	// calc time
	int sum = 0;
	size = times.size();
	for (size_t i = 0; i < size; ++i) {
		if (i == size - 1) {
			sum += times.at(i);
			break;
		}
		sum += static_cast<int>(ceil(static_cast<double>(times.at(i)) / 10.0) * 10);
	}

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

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

using namespace std;

#define pq priority_queue
#define MZ 1000000007

int n;
bool ok[606][605][305];
char s[605][605];

bool go(int x,int y)
{
    for(int i=1;i<=n;i++)
    {
        if(!ok[x+i-1][y][i])
            return 0;
        if(!ok[x+n-1][y+n-i][i])
            return 0;
    }
    return 1;
}

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

    }
    for(int i=1;i<2*n;i++)
        for(int j=1;j<2*n;j++)
        {
            ok[i][j][1]=1;
            if(s[i][j]==s[i-1][j+1])
                ok[i][j][2]=1;
        }
    for(int k=3;k<=n;k++)
    {
        for(int i=1;i<2*n;i++)
            for(int j=1;j<2*n;j++)
            {
                if(ok[i-1][j+1][k-2] && s[i][j]==s[i-k+1][j+k-1])
                    ok[i][j][k]=1;
            }
    }
    for(int i=1;i<=n;i++)
        for(int j=1;j<=n;j++)
            ans+=go(i,j);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 108672
#include <stdio.h>
#include <string.h>
int main(){
    
    int arr[3][3]={0};
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            scanf("%d", &arr[i][j]);
        }
    }
    int N;
    scanf("%d", &N);
    int matrix[N]={0};
    
    for (int k=0;k<N;k++){
        scanf("%d", &matrix[k]);
        for(int l=0;l<3;l++){
            for(int m=0;m<3;m++){
                if(matrix[k] == arr[l][m]){
                    arr[l][m] = 0;
                }
            }
        }
    }
    if(arr[0][0]==0 && arr[0][1]==0 && arr[0][2]==0){
        printf("Yes");
    } else if(arr[1][0]==0 && arr[1][1]==0 && arr[1][2]==0){
        printf("Yes");
    } else if(arr[2][0]==0 && arr[2][1]==0 && arr[2][2]==0){
        printf("Yes");
    } else if(arr[0][0]==0 && arr[1][0]==0 && arr[2][0]==0){
        printf("Yes");
    } else if(arr[0][1]==0 && arr[1][1]==0 && arr[2][1]==0){
        printf("Yes");
    } else if(arr[0][2]==0 && arr[1][2]==0 && arr[2][2]==0){
        printf("Yes");
    } else if(arr[0][0]==0 && arr[1][1]==0 && arr[2][2]==0){
        printf("Yes");
    } else if(arr[0][2]==0 && arr[1][1]==0 && arr[2][0]==0){
        printf("Yes");
    } else {
        printf("No");    
    }
    
    return 0;
}

	
			

Measured memory_bytes: 1676
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
const int inf = 1e9 + 7;
const ll INF = 1e18;
// int mod = 998244353;
int mod = 1000000007;
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { if (b == 0) return a; return gcd(b, a % b); }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
ll pow(ll a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }
ll modpow(ll a, ll b, ll _mod) { return b ? modpow(a * a % _mod, b / 2, _mod) * (b % 2 ? a : 1) % _mod : 1; }
template<class T, class U> ostream& operator << (ostream& os, const pair<T, U>& p) { os << p.F << " " << p.S; return os; }
template<class T> ostream& operator << (ostream& os, const vector<T>& vec) { rep(i, sz(vec)) { if (i) os << " "; os << vec[i]; } return os; }
template<typename T> inline istream& operator >> (istream& is, vector<T>& v) { rep(j, sz(v)) is >> v[j]; return is; }
template<class T, class T2> inline void add(T &a, T2 b) { a += b; if (a >= mod) a -= mod; }


void solve();

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cout << fixed << setprecision(10);

  int T;
  // cin >> T;
  T = 1;

  while (T--) {
    solve();
  }
}

void solve() {
  int n;
  cin >> n;
  int a, b;
  cin >> a >> b;
  cout << min(a * n, b) << endl;
}


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

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        System.out.println(in.readLine().charAt(1) == 'B' ? "ARC" : "ABC");
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    int i() {
        int k = next() - '0';
        boolean minus = k == -3;
        int n = minus ? 0 : k;
        while (0 <= (k = next() - '0') && k <= 9) n = 10 * n + k;
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    char[] s(final int N) {
        char[] s = new char[N];
        for (int i = 0; i < N; i++) {
            s[i] = next();
        }
        next();
        return s;
    }

    public int read(char[] cbuf) {
        int i;
        char c;
        for (i = 0; i <= cbuf.length; i++) {
            if ((c = next()) == ' ' || c == '\n') break;
            cbuf[i] = c;
        }
        return i;
    }

    public String readLine() {
        try {
            return super.readLine();
        } catch (IOException e) {
            return null;
        }
    }
}


Measured memory_bytes: 32644
#include<iostream>
using namespace std;
int main(){
    int n; cin>>n;
    int a[4][3][10] = {{{}}}, b, f, r, v;
    for(int i=0; i<n; i++){
        cin>>b>>f>>r>>v;
        a[b-1][f-1][r-1] += v;
    }
    for(int i=0; i<4; i++){
        if(i){
            for(int h=0; h<20; h++){
                cout<<"#";
            }
            cout<<endl;
        }
        for(int j=0; j<3; j++){
            for(int h=0; h<10; h++){
                cout<<" ";
                cout<< a[i][j][h];
            }
            cout<<endl;
        }
    }
}


Measured memory_bytes: 3096
import math
 
def make_prime_list_2(num):
    if num < 2:
        return []
 
    # 0のものは素数じゃないとする
    prime_list = [i for i in range(num + 1)]
    prime_list[1] = 0 # 1は素数ではない
    num_sqrt = math.sqrt(num)
 
    for prime in prime_list:
        if prime == 0:
            continue
        if prime > num_sqrt:
            break
 
        for non_prime in range(2 * prime, num, prime):
            prime_list[non_prime] = 0
 
    return [prime for prime in prime_list if prime != 0]
 
def prime_factorization_2(num):
    if num <= 1:
        return False
    else:
        num_sqrt = math.floor(math.sqrt(num))
        prime_list = make_prime_list_2(num_sqrt)
 
        dict_counter = {}
        for prime in prime_list:
            while num % prime == 0:
                if prime in dict_counter:
                    dict_counter[prime] += 1
                else:
                    dict_counter[prime] = 1
                num //= prime
        if num != 1:
            if num in dict_counter:
                dict_counter[num] += 1
            else:
                dict_counter[num] = 1
 
        return dict_counter
 
def search_divisor_num_2(num):
    if num < 0:
        return None
    elif num == 1:
        return 1
    else:
        divisor_num = 1
        dict_fact = prime_factorization_2(num)
        for value in dict_fact.values():
            divisor_num *= (value + 1)
        return divisor_num
 
eight_list = []
for i in range(100):
    ii = i * 2 + 1
    if search_divisor_num_2(ii) == 8:
        eight_list.append(ii)
 
n = int(input())
use_list = [1 for i in eight_list if i <= n]
print(sum(use_list))

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.substring(0,1).equals(s.substring(2,3))) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 23508
n=list(map(int,input()))
d=[0]*2019
d[0]=1
a=0
b=len(n)
for i in reversed(range(b)):
    a+=(n[i]*pow(10,(b-i-1),2019))
    a%=2019
    d[a]+=1

ans=0

for i in range(2019):
    c=d[i]
    ans+=c*(c-1)//2
        
print(ans)

Measured memory_bytes: 10728
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c,d; 
  cin>>a>>b>>c>>d;
  if(a+b==c+d)cout<<"Balanced"<<endl;
  else if(a+b>c+d)cout<<"Left"<<endl;
  else cout<<"Right"<<endl;
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int d[N+10];
    for (int i = 0; i < N; ++i) cin >> d[i];
    int num[110] = {0};
    for (int i = 0; i < N; ++i){
        num[d[i]]++;
    }
    int ans = 0;
    for(int i = 0; i <= 100; ++i){
        if(num[i]) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
public class Main {
	public static void main(String[] args) {
		int a;
		for (int i = 1; i < 10; i++) {
			for (int j = 1; j < 10; j++) {
				a = i * j;
				System.out.println(i + "x" + j + "=" + a);
			}
		}
	}
}


Measured memory_bytes: 24096
#!/usr/bin/env python

N=int(input())
a=[int(i) for i in input().split()] 
a.sort()
numbers=[int(i) for i in set(a)]
numbers.sort()

# dictの初期化
numbers_count = {}
# for i in numbers:
for i in numbers:
    numbers_count[i] = 0 

# 数値別の集計
for i in a:
    numbers_count[i] += 1

# 取り除く数を算出
remove=0
for i in numbers:
    # 3が2つある
    if(i > numbers_count[i]):
        remove += numbers_count[i]
    # 3が4つある
    elif(i < numbers_count[i]):
        remove += numbers_count[i] - i

print(remove)

Measured memory_bytes: 20340
n = gets.to_i

a = 0
b = 0
c = 0
d = 0
e = 0

n.times do
  char = gets.chomp
  case char[0]
  when "M"
    a += 1
  when "A"
    b += 1
  when "R"
    c += 1
  when "C"
    d += 1
  when "H"
    e += 1
  end
end

ans = a*b*c + a*b*d + a*b*e + a*c*d + a*c*e + a*d*e + \
b*c*d + b*c*e + b*d*e + \
c*d*e

puts ans

Measured memory_bytes: 3964