akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()




using namespace std;

  ll N,M,X;
  ll A[15][15];
  ll C[15];

ll dfs(vector <ll> pf,int now,ll cost);

int main(){
 cin>>N>>M>>X;
 
 REP(i,14){
   REP(j,14){
     A[i][j] = -90000;
   }
 }


 REP(i,N){
   cin>>C[i];
   REP(j,M){
     cin>>A[i][j];
   }
 }

  vector <ll> p0(M,0);
  //set <int> c0;

  ll ans = dfs(p0,0,0);

  if(ans == 4000000000) ans = -1;

  cout<<ans<<endl;




  return 0;
}

ll dfs(vector <ll> pf,int now,ll cost){
  if(now == N){
    REP(i,M){
      assert(pf[i] >= 0);
      if(pf[i] < X) return 4000000000;
    }
    return cost;
  }

  ll res1 = dfs(pf,now+1,cost);
  //ll res1 = 10000000000;
  vector <ll> pf1 = pf;
  REP(i,M){
    assert(now < N and i < M);
    pf1[i] += A[now][i];
    assert(A[now][i] >= 0);
  }

  ll res2 = dfs(pf1,now+1,cost + C[now]);

  //cout<<res1<<" "<<res2<<endl;

  return min(res1,res2);


}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pq priority_queue
using namespace std;
const ll INF=(ll)1e9;
const ll MOD=(ll)1e9+7;
const ll MAX=510000;
vector<int> dx={1,0,-1,0},dy={0,1,0,-1};
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; }
ll K;
vector<string> v;

int main(){
    cin>>K;
    for(int i=0;i<9;i++){
        char cha='1';
        string s;
        s=cha+i;
        v.push_back(s);
    }
    ll k=0;
    while(v.size()<=K+1){
        ll N=v.size();
        for(ll j=k;j<N;j++){
            for(int i=0;i<3;i++){
                char cha=v[j][v[j].size()-1]-1+i;
                if(cha>'9'||cha<'0') continue;
                string s=v[j]+cha;
                v.push_back(s);
            }
        }
        k=N;
    }
    cout<<v[K-1]<<endl;
}

Measured memory_bytes: 13936
// We only fail when we stop trying
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define endl '\n'
#define D(x) cerr << #x << " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
typedef long long ll;

const int N = 2e5 + 5;

int n;
int a[N], h[N];
long long st[N << 2];

long long query(int cur, int s, int e, int l, int r) {
  if(s > r || e < l) return 0;
  if(s >= l && e <= r) return st[cur];
  int mid = (s + e) / 2;
  return max(query(2 * cur + 1, s, mid, l, r), query(2 * cur + 2, mid + 1, e, l, r));
}

void update(int cur, int s, int e, int i, long long dp) {
  if(s > i || e < i) return;
  if(s == e) {
    st[cur] = dp;
    return;
  }
  int mid = (s + e) / 2;
  update(2 * cur + 1, s, mid, i, dp);
  update(2 * cur + 2, mid + 1, e, i, dp);
  st[cur] = max(st[2 * cur + 1], st[2 * cur + 2]);
}

int main()
{
  scanf("%d", &n);
  for(int i = 0; i < n; i++)
    scanf("%d", &h[i]), h[i]--;
  for(int i = 0; i < n; i++)
    scanf("%d", &a[i]);
  long long best = 0;
  for(int i = 0; i < n; i++) {
    long long cur = a[i] + query(0, 0, n - 1, 0, h[i]);
    best = max(best, cur);
    update(0, 0, n - 1, h[i], cur);
  }
  cout << best << endl;
  return 0;
}


Measured memory_bytes: 7936
#include <iostream>
#include<cstdio>
using namespace std;
int main(void){
   int S,h,m,s;
   cin>>S>>h>>m>>s;
   h=S/3600;
   m=S%3600/60;
   s=S%3600%60;
   cout<<h;
   cout<<":";
   cout<<m;
   cout<<":";
   cout<<s;
   cout<<endl;
   
}



Measured memory_bytes: 3108
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

void yes(){
    cout << "Yes" << endl;
}

void no (){
    cout << "No" << endl;
}

ll cel (ll a, ll b){
    if (a % b == 0) return a / b;
    else return a / b + 1;
}

ll gcds(ll a, ll b){
    ll c = a % b;
    while (c != 0){
        a = b;
        b = c;
        c = a % b;
    }
    return b;
}

int main() {
    int a, b; cin >> a >> b;
    if (a == 2 || b == 2) no();
    else yes();
}

Measured memory_bytes: 3628
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int ans = 0;

		// 500
		for (int i = 0; i <= A; i++) {
			// 100
			for (int j = 0; j <= B; j++) {
				// 50
				for (int k = 0; k <= C; k++) {
					if (500*i+100*j+50*k == X) ans++;
				}

			}
		}
		System.out.println(ans);
		sc.close();
	}

}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
	int z;
	cin>>z;
	int arr[105];
	for(int q=1;q<=z;q++)
	{
		cin>>arr[q];
	}
	
	sort(arr+1,arr+1+z);
	int temp=200,ans=0;
	for(int q=z;q>=1;q--)
	{
		if(arr[q]<temp)ans++,temp=arr[q];
	}
	cout<<ans<<endl;
}

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

int main(){
    int n;
    cin >> n;
    set<string> s;
    vector<string> v(n);
    for(int i = 0; i < n; i++){
        cin >> v[i];
        s.insert(v[i]);
    }

    bool flag = true;
    for(int i = 0; i < n-1; i++){
        int len = v[i].size();
        if(v[i][len-1] != v[i+1][0]) flag = false;
    }
    if(flag && (int)s.size() == n) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
def gcd_core(a, b):
    if b == 0:
        return a
    else:
        return gcd_core(b, a % b)


def gcd(arr):
    g = gcd_core(arr[0], arr[1])
    for i in range(2, len(arr)):
        g = gcd_core(g, arr[i])
    return g

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

if a < c and c < b:
    print("Yes")
elif b < c and c < a:
    print("Yes")
else:
    print("No")













Measured memory_bytes: 3064
n500 = gets.to_i
n100 = gets.to_i
n50  = gets.to_i
sum  = gets.to_i

ans = 0

for i in 0 .. n500
  for j in 0 .. n100
    left = sum - (500 * i + 100 * j)
    if left >= 0 && left % 50 == 0 && left / 50 <= n50
      ans += 1
    end
  end
end

puts ans


Measured memory_bytes: 1788
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define LEN 100005

typedef struct pp{
	char name[100];
	int t;
}P;

P Q[LEN];
int head, tail, n, total;

void enqueue(P x){
	Q[tail] = x;
	tail = (tail + 1) % LEN;
}

P dequeue(){
	P x = Q[head];
	head = (head + 1) % LEN;
	return x;
}

int roundrobin(int rest, int q){
	if (q < rest){
		total += q;
		rest -= q;
	}
	else{
		total += rest;
		rest = 0;
	}
	return rest;
}

int main(){
	total = 0;
	P u;
	int q;
	scanf("%d %d", &n, &q);
	for (int i = 1; i <= n; i++){
		scanf("%s %d", Q[i].name, &Q[i].t);
	}
	head = 1;
	tail = n + 1;
	while (head != tail){
		u = dequeue();
		u.t = roundrobin(u.t, q);
		if (u.t > 0){
			enqueue(u);
		}
		else{
			printf("%s %d\n", u.name, total);
		}
	}
	return 0;
}

Measured memory_bytes: 13296
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
ll modpow(ll n, ll x, ll MOD){
	ll ret = 1;
	while(x){
		if(x&1){
			(ret*=n)%=MOD;
		}
		x >>= 1;
		(n*=n)%=MOD;
	}
	return ret;
}
int main(){
	int k;
	cin >> k;
	if(k%7==0){
		for(int i = 1; i <= k; ++i){
			if(__gcd(10, 9*(k/7)) != 1){
				cout << -1;
				return 0;
			}
			if(modpow(10, i, 9*(k/7)) == 1){
				cout << i;
				return 0;
			}
		}
	}
	else{
		for(int i = 1; i <= k; ++i){
			if(__gcd(10, 9*k) != 1){
				cout << -1;
				return 0;
			}
			if(modpow(10, i, 9*k) == 1){
				cout << i;
				return 0;
			}
		}

	}
	if(k == 1){
		cout << 1;
	}
	else{
		cout << -1;
	}
}


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

using namespace std;
typedef long long ll;
const int maxn = 3000 + 10;
const int mod = 998244353;

int dp[maxn][maxn];

int main(){
	ios_base::sync_with_stdio(false);
	int A, B, C, D;
	cin >> A >> B >> C >> D;
	dp[A][B] = 1;
	for (int i = A; i <= C; i++){
		for (int j = B; j <= D; j++){
			if (i + j == A + B)
				continue;
			dp[i][j] = (1ll * j * dp[i-1][j] + 1ll * i * dp[i][j-1] - 1ll * (i-1) * (j-1) * dp[i-1][j-1]) % mod;
			dp[i][j] = (dp[i][j] + mod) % mod;
		}
	}
	cout << dp[C][D] << endl;
}


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

typedef long long ll;

int main()
{
    int a,b;
    cin >> a >> b;
    int i;
    vector<int> temp_a(2000);
    for(i = 0;i < 2000;++i){
        double ti = i;
        temp_a.at(i) = (int)(ti*1.08) - i;
    }
    vector<int> temp_b(2000);
    for(i = 0;i < 2000;++i){
        double ti = i;
        temp_b.at(i) = (int)(ti*1.1) - i;
    }
    int ans = -1;
    for(i = 0;i < 2000;++i){
        if(temp_a.at(i) == a && temp_b.at(i) == b){
            ans = i;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

class Main {
	public static void main(String args[]) {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String buf;

		try {
			while ((buf = br.readLine())!=null) {
				int n = Integer.parseInt(buf);
				StringTokenizer st = new StringTokenizer(br.readLine());
				int p[] = new int[n];
				for (int i=0;i<n;i++) {
					p[i] = Integer.parseInt(st.nextToken());
				}
				Arrays.sort(p);
				int sum[] = {0,0};
				for (int i=0;i<n;i++) {
					sum[1] += p[i];
					sum[0] += sum[1];
				}
				System.out.println(sum[0]);
			}
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 20800
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT {
	__INIT() {
		cin.tie(0);
		ios::sync_with_stdio(false);
		cout << fixed << setprecision(15);
	}
}__init;


int main(void) {
	ll n;
	cin >> n;
	ll al = 1;
	ll ans = 0;
	vl as(n);
	rep(i, n) cin >> as[i];
	sort(all(as));
	if (as[0] == 0) {
		cout << 0 << endl;
		return 0;
	}
	rep(i, n) {
		ll a;
		a = as[i];
		if (a <= 1000000000000000000 / al) {
			al *= a;
		}
		else {
			cout << -1 << endl;
			return 0;
		}
	}
	cout << al << endl;
	return 0;
}


Measured memory_bytes: 3924
#![allow(non_snake_case)]
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 main() {
    input!(
        n: usize,
        pn: [usize; n],
    );
    let mut diff_count = 0;
    for i in 0..n {
        if pn[i] != (i + 1) {
            diff_count += 1;
        }
    }
    if diff_count > 2 {
        println!("NO");
    } else {
        println!("YES");
    }
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin>>s;
  sort(s.begin(),s.end());
  if(s[0]==s[1] && s[1]!=s[2] && s[2]==s[3]){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
}


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

int main()
{
	cin >> N;
	int a = N % 10;
	switch (a)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
			cout << "hon" << endl;
				break;

	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;

	case 3:
		cout << "bon" << endl;
		break;
}
	return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <queue>

using namespace std;
typedef long long ll;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  int k;
  cin>>n>>k;
  queue<int> yet;
  queue<int> cul;
  for(int i=0;i<k;i++){
    int a;
    cin>>a;
    cul.push(a);
  }
  for(int i=k;i<n;i++){
    int a;
    cin>>a;
    yet.push(a);
  }

  for(int i=0;i<n-k;i++){
    int a,b;
    a = cul.front();
    b = yet.front();
    cul.pop();
    yet.pop();
    if(a<b) cout<<"Yes\n";
    else cout<<"No\n";
    cul.push(b);
  }

  return 0;
}


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

int main() {
    ll n, x, m;
    cin >> n >> x >> m;
    vector<ll> r;
    set<ll> s;
    r.push_back(x);
    s.insert(x);
    for (ll i = 1; i <= n; ++i) {
        x *= x;
        x %= m;
        if (s.count(x)) {
            break;
        }
        r.push_back(x);
        s.insert(x);
        if (x == 0) {
            ll ans = 0;
            for (auto j : r) ans += j;
            cout << ans << endl;
            return 0;
        }
    }

    int len = r.size();
    int start = 0;
    rep(i, len) if (r.at(i) == x) start = i;
    ll sum = 0, ans = 0;
    
    rep(i, len) sum += r.at(i);

    rep(i, start) {
        sum -= r.at(i);
        ans += r.at(i);
    }
    n -= start;
    len -= start;
    ans += sum * ((ll) n / len);
    rep(i, n % len) ans += r.at(start + i);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5928
n = int(input())
s = input() + ' '

w = [0] * (n + 1)
e = [0] * (n + 1)
bfW = 0
bfE = 0
for i in range(n+1):
    w[i] = bfW
    e[i] = bfE
    if s[i] == 'W':
        bfW += 1
    elif s[i] == 'E':
        bfE += 1

ans = n - 1
for i in range(n):
    myW = w[i]
    myE = e[n] - e[i + 1]
    ans = min(ans, myE + myW)
    
print(ans)

Measured memory_bytes: 17568
#include <iostream>

bool isPostalCode(int, int, std::string);
int main()
{
    int a, b;
    std::string s;
    std::cin >> a >> b >> s;
    std::cout << (isPostalCode(a, b, s) ? "Yes" : "No") << std::endl;

    return 0;
}

bool isPostalCode(int a, int b, std::string s)
{
    if (s[a] != '-')
        return false;

    for (int i = 0; i < a; ++i)
        if (!isdigit(s[i]))
            return false;

    for (int i = a+1; i < a+b+1; ++i)
        if (!isdigit(s[i]))
            return false;

    return true;
}

Measured memory_bytes: 256
'use strict'
function Main(hoge){
  var input=hoge.trim();
  input=input.split(/\s+/);
  for(let i=0;i<input.length;i++)
    input[i]=+input[i];
  var A=input.shift();
  var B=input.shift();
  var Q=input.shift();
  var s=input.splice(0,A);
  var t=input.splice(0,B);
  var x=input;
  var y=binarySort(x);
  var s_before=[];
  var s_after=[];
  var t_before=[];
  var t_after=[];
  var p=0,q=0;
  for(let i=0;i<Q;i++){
    while(s[p]<y[i][0])
      p++;
    s_before[i]=(s[p-1]||-1e14);
    s_after[i]=(s[p]||1e14);
    while(t[q]<y[i][0])
      q++;
    t_before[i]=(t[q-1]||-1e15);
    t_after[i]=(t[q]||1e15);
  }
  var ans=[];
  for(let i=0;i<Q;i++){
    let j=y[i][1];
    let Y=y[i][0];
    let sb=s_before[i],sa=s_after[i],tb=t_before[i],ta=t_after[i]; 
    let abs=Math.abs;
    ans[j]=Math.min(
      abs(sa-Y)+abs(ta-sa),
      abs(sa-Y)+abs(tb-sa),
      abs(sb-Y)+abs(ta-sb),
      abs(sb-Y)+abs(tb-sb),
      abs(ta-Y)+abs(sa-ta),
      abs(ta-Y)+abs(sb-ta),
      abs(tb-Y)+abs(sa-tb),
      abs(tb-Y)+abs(sb-tb)
    );
  }
  return (ans.join('\n'));
}

function binarySort(A){ 
  var a=A.length;
  var B=[[A[0],0]];
  for(let i=1;i<a;i++){
    let u=B.length-1;
    let d=0;
    let m=Math.floor((d+u)/2);
    while(!(d>u)){
      if(B[m][0]<A[i]){
        d=m+1;
      }else{
        u=m-1;
      }
      m=Math.floor((d+u)/2);
    }
    B.splice(m+1,0,[A[i],i]);
  }
  return B;
}

var myAns=Main(require('fs').readFileSync('/dev/stdin','utf8'));

console.log(myAns);


Measured memory_bytes: 97020
#include<iostream>
#include<algorithm>
using namespace std;
long long int n,k,s=0,a[100001];
int main()
{
	cin>>n>>k;
	for(long long int i=1;i<=n;i++)
	cin>>a[i];
	sort(a+1,a+1+n);
	for(long long int i=n;i>=n-k+1;i--)
	s+=a[i];
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll IV[100010], ans, D[100010]={1}, F[100010]={1}, M=1000000007;
int n, i, a[100010], tmp[100010], m, x, y, N;
ll pw(ll r, ll e){
	if(e==0)	return 1;
	ll t=pw(r, e/2);
	return ((t*t)%M*((e&1)?r:1))%M;
}
ll inv(ll r){
	return pw(r, M-2);
}
ll f(ll x){
	if(x<0)	return x+M;
	return x;
}
int main(){
	for(cin>>n, i=1; i<=n+1; i++)
		cin>>a[i], tmp[a[i]]++;
	for(i=1; i<=n; i++)
		if(tmp[i]==2)
			m=i;
	for(i=1; i<=n+1; i++)
		if(a[i]==m){
			if(x==0)	x=i;
			else		y=i;
		}
	N=x+n-y;
	for(i=1; i<=n+1; i++)	IV[i]=inv(i);
	for(i=1; i<=N; i++)
		D[i]=((D[i-1]*(N-i+1))%M*IV[i])%M;
	for(i=1; i<=n+1; i++)
		F[i]=((F[i-1]*(n-i+2))%M*IV[i])%M;
	for(i=1; i<=n+1; i++)
		printf("%lld\n", f(F[i]-D[i-1]));
	return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define POP pop_back()
#define ll long long
#define db double
#define POP pop_back()
#define endl '\n'
const int maxn = 1e5 + 5;
const int inf = 0x3f3f3f3f;
const int mod = 1e9 + 7;
struct edg{
	int to , nxt;
};
struct node{
	int e , s;
};
edg e[maxn];
int head[maxn] , in[maxn] , s[maxn];
int main(){
	int n , m;cin >> n >> m;
	int u , v;
	for(int i = 1;i <= m;i++){
		scanf("%d%d",&u,&v);
		e[i].nxt = head[u];
		e[i].to = v;
		head[u] = i;
		in[v]++;
	}
	queue<node>q;
	for(int i = 1;i <= n;i++){
		if(in[i] == 0)q.push((node){i,0});
	}
	node now;
	while(!q.empty()){
		now = q.front() , q.pop();
		for(int i = head[now.e];i != 0;i = e[i].nxt){
			in[e[i].to]--;
			s[e[i].to] = max(s[e[i].to] , now.s+1);
			if(in[e[i].to] == 0)q.push((node){e[i].to , s[e[i].to]});
		}
	}
	int ans = 0;
	for(int i = 1;i <= n;i++)ans = max(ans , s[i]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000000;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

///////////////////////////

	
int main() {

	ll r, d, x;
	cin >> r>> d>> x;

	repn(i, 10) {
		x = x * r - d;
		cout << x <<endl;
	}
	
	

	
	system("PAUSE");
}

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

#define ll long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long,long long>

#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define endl "\n"

#define Debug(x) cout<<(#x)<<" >> "<<(x)<<endl

using namespace std;

ll fastpow(ll angka,ll pangkat,ll MOD){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka)%MOD;
		angka=(angka*angka)%MOD;
		pangkat=pangkat>>1;
	}
	return res;
}

ll fastpow(ll angka,ll pangkat){
	ll res=1;
	while(pangkat){
		if(pangkat&1) res=(res*angka);
		angka=(angka*angka);
		pangkat=pangkat>>1;
	}
	return res;
}

ll gcd(ll angka1,ll angka2){
	while(angka2){
		swap(angka1,angka2);
		angka2=angka2%angka1;
	}
	return angka1;
}

ll lcm(ll angka1,ll angka2){
	return (angka1/gcd(angka1,angka2))*angka2;
}


void solve(){
	ll d,t,s;
	cin>>d>>t>>s;
	if(d<=t*s) cout<<"Yes\n";
	else cout<<"No\n";

}

int main(){
	
	fastio();

	int t=1;
//	cin>>t;
	
	for(int tt=0;tt<t;tt++){
//		cout<<"Case "<<tt+1<<":\n";solve();
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 3604
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
/*---------------for_stuff-------------------*/
#define f(i,a,b) for (int i=a;i<=b;i++)
#define f_(i,a,b) for (int i=a;i>=b;i--)
/*---------------pair_stuff------------------*/
#define MP make_pair
#define ii pair<char,char>
#define fi first
#define se second
/*--------------vector_stuff-----------------*/
#define pb push_back
#define ppb pop_back
/*--------------const_stuff-----------------*/
const ll mod=1000000007;
const int N=100005;

string s,t;
int dem=0;
vector<int> v[30];
int find(int vtri,int chu) {
	if (vtri>v[chu][v[chu].size()-1]) {
		dem++;
		return v[chu][0];
	}
	if (vtri<=v[chu][0]) return v[chu][0];
	int l,r;
	l=0;
	r=v[chu].size()-1;
	while (l<r) {
		int mid=(l+r)/2;
//		 cout<<"fuck\n";
		if (v[chu][mid]<vtri) l=mid+1;
		else r=mid;
	}
	return v[chu][r];
}
signed main() {
	cin>>s>>t;
	for (int i=0;i<s.size();i++) {
		v[s[i]-'a'].pb(i);
	}
	int pos=0;
	for (int i=0;i<t.size();i++) {
		if (v[t[i]-'a'].size()==0) {
			printf("-1");
			return 0;
		}
		pos=find(pos,t[i]-'a')+1;
//		cout<<pos<<" ";
	}
	// cout<<"\n";
	cout<<pos+dem*s.size();
	// cout<<"\n"<<pos<<" "<<dem;
	return 0;
}

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

//#pragma GCC optimize("O3")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("avx,avx2,fma")

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;
typedef vector<pii> vpii;
typedef vector<pil> vpil;
typedef vector<pli> vpli;
typedef set<int> si;
typedef set<ll> sll;

const double pi = acos(-1.0);
const long long INF = 2e18;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz size()
#define in insert
#define endl "\n"

#define sqr(a) ((a) * (a))
#define jor(a) !(a&1)// jor means EVEN number
#define bjor(a) (a&1)// bjor means ODD number

#define all(a)  a.begin(), a.end()
#define mem(arr, b) memset(arr, b, sizeof(arr)) //memset only for -1 and 0
//fill(a, a+n, 5) //fill for any value

#define for0(i,b) for(int i=0;i<(b);i++)
#define for1(i,b) for(int i=1;i<=(b);i++)
#define forab(i,a,b) for(int i=(a);i<=(b);i++)
#define forba(i,b,a) for(int i=(b);i>=(a);i--)
#define rep(i,a,b,c) for(int i=(a);i!=(b);i+=(c))

void print(int a[], int n){ // for testing or debugging
    for(int i=0;i<n;i++)cout<<a[i]<<" "; cout<<endl;
}
//_____________________________________________________\\

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
    //freopen("input.txt", "r", stdin);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        int n; cin>>n; int a[n+5];
        for0(i,n) cin>>a[i];

        int dp[n+5]={};
        dp[0]=0;
        dp[1]=abs(a[1]- a[0]);
        forab(i, 2, n-1) dp[i] = min( dp[i-1] + abs(a[i]-a[i-1]) , dp[i-2] + abs(a[i]-a[i-2]) );
        cout<<dp[n-1];
    }
}

Measured memory_bytes: 1024
using System;

public class Program
{
    private string S;
    private int K;

    private int[,,] Memo;

    public void Solve()
    {
        var sc = new Scanner();
        S = sc.Next();
        K = sc.NextInt();
        Memo = new int[S.Length+1,S.Length+1,K+1];
        for (int i = 0; i <=S.Length ; i++)
        {
            for (int j = 0; j <=S.Length ; j++)
            {
                for (int k = 0; k <=K ; k++)
                {
                    Memo[i, j, k] = -1;
                }
            }
        }
        Console.WriteLine(Count(0, S.Length, K));
    }

    private int Count(int l, int r, int k)
    {
        if (r - l == 0) return 0;
        if (r - l == 1) return 1;
        if (Memo[l, r, k] != -1)
        {
            return Memo[l, r, k];
        }
        int result;
        if (S[l] == S[r - 1])
        {
            result = Count(l + 1, r - 1, k) + 2;
        }
        else
        {
            result = Math.Max(Count(l + 1, r, k), Count(l, r - 1, k));
            if (k > 0)
            {
                result = Math.Max(result, Count(l + 1, r - 1, k - 1) + 2);
            }
        }

        Memo[l, r, k] = result;
        return result;
    }

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

class Scanner
{
    public Scanner()
    {
        _pos = 0;
        _line = new string[0];
    }

    const char Separator = ' ';
    private int _pos;
    private string[] _line;

    #region スペース区切りで取得

    public string Next()
    {
        if (_pos >= _line.Length)
        {
            _line = Console.ReadLine().Split(Separator);
            _pos = 0;
        }

        return _line[_pos++];
    }

    public int NextInt()
    {
        return int.Parse(Next());
    }

    public long NextLong()
    {
        return long.Parse(Next());
    }

    public double NextDouble()
    {
        return double.Parse(Next());
    }

    #endregion

    #region 型変換

    private int[] ToIntArray(string[] array)
    {
        var result = new int[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = int.Parse(array[i]);
        }

        return result;
    }

    private long[] ToLongArray(string[] array)
    {
        var result = new long[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = long.Parse(array[i]);
        }

        return result;
    }

    private double[] ToDoubleArray(string[] array)
    {
        var result = new double[array.Length];
        for (int i = 0; i < array.Length; i++)
        {
            result[i] = double.Parse(array[i]);
        }

        return result;
    }

    #endregion

    #region 配列取得

    public string[] Array()
    {
        if (_pos >= _line.Length)
            _line = Console.ReadLine().Split(Separator);

        _pos = _line.Length;
        return _line;
    }

    public int[] IntArray()
    {
        return ToIntArray(Array());
    }

    public long[] LongArray()
    {
        return ToLongArray(Array());
    }

    public double[] DoubleArray()
    {
        return ToDoubleArray(Array());
    }

    #endregion
}

Measured memory_bytes: 115424
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
#define endl "\n"
using namespace std;
const ll N=300010;

ll ar[N];
ll sgt[4*N];

void build(ll st,ll en,ll pos)
{
    if(st==en){
        sgt[pos]=ar[st];
        return ;
    }
    ll mid=(st+en)/2;
    build(st,mid,2*pos+1);
    build(mid+1,en,2*pos+2);
    sgt[pos]=max(sgt[2*pos+1],sgt[2*pos+2]);
}

ll range(ll st,ll en,ll pos,ll l,ll r)
{
    if(st>r||en<l){return INT_MIN;}
    if(st>=l&&en<=r){return sgt[pos];}
    ll mid=(st+en)/2;
    return max(range(st,mid,2*pos+1,l,r),range(mid+1,en,2*pos+2,l,r));
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n,m,k;
    cin>>n>>m>>k;
    vector<pi> ch(k);
    for(ll i=0;i<k;++i){
        cin>>ch[i].first>>ch[i].second;
        ar[ch[i].second]+=1;
    }
    sort(ch.begin(),ch.end());
    ll ans=0;

    build(1,m,0);

    ll idx=0;
    for(ll x=1;x<=n;++x){
        if(idx<k&&ch[idx].first==x){
            ll j=idx+1;
            while(j<k&&ch[j].first==ch[idx].first){++j;}
            ll last=0;
            for(ll i=idx;i<j;++i){
                ans=max(ans,j-idx + range(1,m,0,last+1,ch[i].second-1));
                ans=max(ans,j-idx + ar[ch[i].second] -1);
                last=ch[i].second;
            }
            ans=max(ans,j-idx + range(1,m,0,last+1,m));
            idx=j;
        }
        else{
            ans=max(ans,range(1,m,0,1,m));
        }
    }

    cout<<ans;

    return (0);
}


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

int main(){
 int H, W;
    while(1){
     cin >> H >> W;
     if( H == 0 && W  == 0 ) break;

        for( int i = 0; i < H; i++ ){
            for( int j = 0; j < W; j++ ){
             cout << "#";
         }
        cout << "\n";
    }
    cout << endl;
   }
    
 return 0;
}

Measured memory_bytes: 1152
def main():
    N = int(input())
    l = list(map(int, input().split()))
    ans = int(2e+9)
    X = sum(l)
    x = 0
    for i in range(N-1):
        x += l[i]
        ans = min(ans, abs(X-2*x))
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 24832
a, b, c = gets.split.map(&:to_i)
flag = false
remain1 = a % b
if remain1 == c
  puts "YES"
else
  aa = a * 2
  while aa % b != remain1 do
    if aa % b == c
      flag = true
      break
    else
      aa += a
    end
  end
  puts flag ? "YES" : "NO"
end


Measured memory_bytes: 1788
n = int(input())
L = [[[0]*10 for _ in range(3)] for _ in range(4)]
for _ in range(n):
    b,f,r,v = map(int, input().split())
    L[b-1][f-1][r-1] += v
    
for i in range(4):
    for j in range(3):
        for k in range(10):
            L[i][j][k] = str(L[i][j][k])
        print(" " + " ".join(L[i][j]))
    if i < 3:
        print("#"*20)


Measured memory_bytes: 5608
N, Q = map(int, input().split())
S = input()
A = [0]
j = 0
for i in range(N-1):
  if S[i:i+2] == "AC":
    j += 1
  A.append(j)
for i in range(Q):
  q = list(map(int, input().split()))
  print(A[q[1]-1] - A[q[0]-1])

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

template<class T> inline void chmin(T& a, const T& b) { if(b < a) a = b; }

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

	int n, d;
	cin >> n >> d;

	vector<vector<int>> p(n, vector<int>(d));
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < d; ++j) {
			cin >> p[i][j];
		}
	}

	constexpr int INF = 0xffffff;
	vector<vector<vector<int>>> dp(d + 1, vector<vector<int>>(n, vector<int>(d, INF)));
	for(int i = 0; i < n; ++i) {
		dp[d][i][0] = 0;
	}

	for(int i = d - 1; i >= 0; --i) {
		for(int j = 0; j < n; ++j) {
			const int max_move = d - i;
			for(int k = 0; k < max_move; ++k) {
				dp[i][j][k] = dp[i + 1][j][k] + p[j][i];
			}

			for(int k = 1; k < max_move; ++k) {
				for(int l = 0; l < n; ++l) {
					if(j != l) chmin(dp[i][j][k], dp[i + 1][l][k - 1] + p[j][i]);
				}
			}
		}
	}

	int min_cost = INF;
	int num_move;
	int cur_hotel;
	for(int i = 0; i < d; ++i) {
		for(int j = 0; j < n; ++j) {
			if(min_cost > dp[0][j][i]) {
				min_cost = dp[0][j][i];
				num_move = i;
				cur_hotel = j;
			}
		}
	}

	cout << min_cost << " " << num_move << endl;

	vector<int> stay;
	stay.reserve(d);
	for(int i = 1; i <= d; ++i) {
		stay.emplace_back(cur_hotel + 1);
		if(num_move) {
			int next_hotel;
			int next_cost = INF;
			for(int j = 0; j < n; ++j) {
				int rest_move = (cur_hotel == j ? num_move : num_move - 1);
				if(next_cost > dp[i][j][rest_move]) {
					next_cost = dp[i][j][rest_move];
					next_hotel = j;
				}
			}
			if(cur_hotel != next_hotel) {
				cur_hotel = next_hotel;
				--num_move;
			}
		}
	}

	for(int i = 0; i < d; ++i) {
		cout << stay[i] << endl;
	}

	return EXIT_SUCCESS;
}

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

int main() {
    int N,K;
    cin >> N >> K;
    vector<int> A(N);
    for(int i=0; i<N; ++i) cin >> A[i];

    int res = 1001001001;
    for(int l=0; l+K-1<N; ++l) {
        res = min(res, min(abs(A[l]), abs(A[l+K-1])) + abs(A[l+K-1] - A[l]));
    }
    cout << res << endl;
    return 0; 
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>

#define _GLIBCXX_DEBUG
#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,m,k,a;
    cin >> n >> m;
    vi ans(m,0);
    rep(i,n){
        cin >> k;
        rep(j,k){
            cin >> a;
            ans.at(a-1)++;
        }
    }
    int64_t counter=0;
    rep(i,m){
        if(ans.at(i)==n) counter++;
    }
    cout << counter << endl;
}


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

using namespace std;

#define INF 100000000
#define YJ 1145141919
#define INF_INT_MAX 2147483647
#define INF_LL 9223372036854775
#define INF_LL_MAX 9223372036854775807
#define EPS 1e-10
#define MOD 1000000007
#define MOD9 998244353
#define Pi acos(-1)
#define LL long long
#define ULL unsigned long long
#define LD long double

#define int long long

using II = pair<int, int>;

int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int extgcd(int a, int b, int &x, int &y) { int g = a; x = 1; y = 0; if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x; return g; }

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(a)  begin((a)), end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

int X, Y;

int myPow(int p, int n) {
  int ret = 1, tmp = p;
  while(n) {
    if(n&1) {
      ret *= tmp;
      ret %= MOD;
    }
    tmp *= tmp;
    tmp %= MOD;
    n /= 2;
  }
  return ret;
}

const int MAX_X = 1000005;
const int MAX_D = 2 * MAX_X;
int D[MAX_D];

signed main()
{
  cin >> X >> Y;
  if((X+Y)%3 != 0) {
    cout << 0 << endl;
    return 0;
  }

  D[0] = D[1] = 1;
  FOR(n,2,MAX_D) {
    D[n] = D[n-1] * n;
    D[n] %= MOD;
  }

  int cnt = (X+Y)/3;
  X -= cnt; Y-= cnt;

  if(X < 0 || Y < 0) {
    cout << 0 << endl;
    return 0;
  }

  if(X == 0 || Y == 0) {
    cout << 1 << endl;
    return 0;
  }

  cout << (((D[X+Y] * myPow(D[X],MOD-2))%MOD)*myPow(D[Y],MOD-2)) % MOD << endl;

  return 0;
}


Measured memory_bytes: 15872
import java.io.IOException;
import java.io.InputStream;
import java.util.HashSet;
import java.util.NoSuchElementException;

class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	
	void run() {
		FastScanner sc=new FastScanner();
		int[][] A=new int[3][3];
		for(int i=0;i<3;++i)for(int j=0;j<3;++j)A[i][j]=sc.nextInt();
		int n=sc.nextInt();
		int[] b=new int[n];
		HashSet<Integer> set=new HashSet<>();
		for(int i=0;i<n;++i) {
			b[i]=sc.nextInt();
			set.add(b[i]);
		}
		boolean[][] a=new boolean[3][3];
		for(int i=0;i<3;++i)
			for(int j=0;j<3;++j) a[i][j]|=set.contains(A[i][j]);
		boolean ans=false;
		for(int i=0;i<3;++i) {
			ans|=a[i][0]&&a[i][1]&&a[i][2];
		}
		for(int i=0;i<3;++i) {
			ans|=a[0][i]&&a[1][i]&&a[2][i];
		}
		ans|=a[0][0]&&a[1][1]&&a[2][2];
		ans|=a[2][0]&&a[1][1]&&a[0][2];
		System.out.println(ans?"Yes":"No");
	}
	
	static void tr(Object... objects) {
	}

}


class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
    private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
    public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() { return Double.parseDouble(next());}
}

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

int main(){
	int a,b,k;
	cin>>a>>b>>k;
	for(int i=min(a,b);i>=1;i--){
		if(a%i==0 && b%i==0)k--;
		if(k==0){
			cout<<i<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws IOException {

		new Main().run();
	}

	private void run() throws IOException {
		Scanner scanner = new Scanner(System.in);
		int mod = 100000;
		while (true) {
			int w = scanner.nextInt();
			int h = scanner.nextInt();
			if ((w | h) == 0)
				break;
			int[][][] dp = new int[4][h][w];
			for (int i = 0; i < h; i++)
				dp[0][i][0] = 1;
			for (int i = 0; i < w; i++)
				dp[2][0][i] = 1;
			for (int i = 1; i < h; i++) {
				for (int j = 1; j < w; j++) {
					dp[0][i][j] = (dp[0][i - 1][j] + dp[1][i - 1][j]) % mod;
					dp[1][i][j] = dp[2][i - 1][j] % mod;
					dp[2][i][j] = (dp[2][i][j - 1] + dp[3][i][j - 1]) % mod;
					dp[3][i][j] = dp[0][i][j - 1] % mod;
				}

			}
			int ans = 0;
			for (int i = 0; i < 4; i++) {
				ans += dp[i][h - 1][w - 1];
			}
			System.out.println(ans % mod);

		}
	}
}

Measured memory_bytes: 18332
#include <stdio.h>

int main(){
    int n, a, b, c;
    
   scanf("%d%d%d", &n, &a, &b);

   c = n*a;

   if(c <= b){
   printf("%d\n",c);
   }else{
   printf("%d\n",b);
   }

   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define fi first
#define se second
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,A,B;
string S;
string alpha = "abcdefghijklmnopqrstuvwxyz";
string ALPHA = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";

mat G(2e+5,vec(0));
vec used(2e+5,0);
void dfs(ll v,ll &e,vec &n, ll id){
    used.at(v)=true;
    id = id^1;
    rep(i,G.at(v).size()){
        ++e;
        if(!used.at(G.at(v).at(i))){
            ++n.at(id);
            dfs(G.at(v).at(i),e,n,id);
        }
    }
    return;
}
ll solve(ll v){
    if(G.at(v).size() != 1) return 0;
    ll e = 0;
    vec n= {1,0};
    dfs(v,e,n,0);
    return n.at(0)*n.at(1)-e/2;

}
int main() {
    cin>>N;
    ll p = 1e+5;
    for(int i = 0; i < N; i++) {
        // sからtへの辺を張る
        int s,t;
        scanf("%d %d", &s, &t);
        G[s-1].push_back(t+p-1);
        G[t+p-1].push_back(s-1);
    }
    ll ans = 0;
    rep(i,2e+5){
        ans += solve(i);
        /*if(i==1||i==5) {
            cout<<i<<' '<<ans<<endl;
        } */
    }
    //ans /= 2;
    cout<<ans<<endl;
}


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

using namespace std;

#define int long long
#define FOR(i, j, k) for(int i = j; i < k; ++i)
#define rep(i, j) FOR(i, 0, j)
#define INF 1e9
#define LINF 1e18

typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> Pi;
typedef pair<P, P> PP;

const int MOD = 1e9 + 7;
const int dy[]={0, 0, 1, -1};
const int dx[]={1, -1, 0, 0};

template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }

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

    int A, B;
    cin >> A >> B;
    if(A >= 9 || B >= 9) cout << ":(" << endl;
    else cout << "Yay!" << endl;
    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 = sc.nextInt();
		String string = sc.next();
		char c = ' ';
		int ans = 0;
		for (int i = 0; i < N; i++) {
			char target = string.charAt(i);
			if (c != target) {
				ans++;
				c = target;
			}
		}
		System.out.println(ans);
	}

}

Measured memory_bytes: 39636
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate, product
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def debug(table, *args):
    ret = []
    for name, val in table.items():
        if val in args:
            ret.append('{}: {}'.format(name, val))
    print(' | '.join(ret), file=sys.stderr)


yn = {False: 'No', True: 'Yes'}
YN = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

import random

def main():
    s = list(map(int, S()[::-1]))
    N = len(s)
    P = 2019
    ans = 0
    cnts = [0] * P
    cnts[0] = 1
    A = [0] * N
    D = [0] * N

    for i in range(N):
        d = s[i] * pow(10, i, P)
        A[i] = d % P
        if i == 0:
            D[i] = A[i]
        else:
            D[i] = (D[i-1] + A[i]) % P
        # sum_of_d = (sum_of_d + d) % p
        # cnts[sum_of_d] += 1

    for d in D:
        cnts[d] += 1

    for i in cnts:
        ans += i * (i - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 89672
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long

template<class T> vector<T> make_vec(size_t a) { return vector<T>(a); }
template<class T, class... Ts> auto make_vec(size_t a, Ts... ts) {
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template<class T, class V>
typename enable_if<is_class<T>::value == 0>::type fill(T &t, const V &v) {
    t = v;
}
template<class T, class V>
typename enable_if<is_class<T>::value != 0>::type fill(T &t, const V &v) {
    for (auto &e : t) fill(e, v);
}
// auto v = make_vec<int>(h, w);
// fill(v, 0);
const int INF = 1LL << 60;

signed main(){

  int h, w; cin >> h >> w;
  vector<string> s(h);
  for(int i = 0; i < h; i++){
    cin >> s[i];
  }

  auto dp = make_vec<int>(h, w);
  auto dfs = [&](auto&& dfs, int x, int y)->void{
    int dx[4] = {0, 1, 0, -1}, dy[4] = {1, 0, -1, 0};
    for(int i = 0; i < 4; i++){
      int nx = x + dx[i];
      int ny = y + dy[i];
      if(nx < 0 || w <= nx || ny < 0 || h <= ny) continue;
      if(s[ny][nx] == '.' && dp[ny][nx] > dp[y][x] + 1){
        dp[ny][nx] = dp[y][x] + 1;
        dfs(dfs, nx, ny);
      }
    }
    return;
  };

  int ans = -1;
  for(int i = 0; i < h; i++){
    for(int j = 0; j < w; j++){
      if(s[i][j] == '#') continue;
      fill(dp, INF);
      dp[i][j] = 0;
      dfs(dfs, j, i);
      for(int k = 0; k < h; k++){
        for(int l = 0; l < w; l++){
          if(dp[k][l] != INF) ans = max(ans, dp[k][l]);
        }
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
/*
我的心脏怦怦跳，监管者就在附近
*/
#include<bits/stdc++.h>
#include<string>
#include<iostream>
#include<cmath>
#include<set>
#include<stack>
#include<queue>
#include<unistd.h>
#include<stdio.h>
#include<cstring>
#define random(a,b) (rand()%(b-a+1)+a)
using namespace std;
int a[1001],b[1001],z;int f[100001];
int find(int x)
{
	if(x==f[x])
	{
		return x;
	}
	else
	{
		return f[x]=find(f[x]);
	}
}
int main()
{
	int n,m,cut=0;
	cin>>n>>m;int i;
	for(i=1;i<=n;i++)
	{
		f[i]=i;
	}
	int x,y,z;
	for(i=0;i<m;i++)
	{
		cin>>x>>y>>z;
		int fx=find(x),fy=find(y);
		if(fx!=fy) {
			f[fx]=fy;cut++;
		}
	}
	cout<<n-cut;
	return 0;
}


Measured memory_bytes: 640
n,y=map(int,input().split())
for a in range(y//10000+1):
  rest=y-a*10000
  for b in range(rest//5000+1):
    c=rest-b*5000
    c//=1000
    if a+b+c==n:
      print(a,b,c)
      exit()
print(-1,-1,-1)

Measured memory_bytes: 3060