akhauriyash/Code-Regression huggingface dataset:
#[allow(dead_code)]
fn getline() -> String {
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

#[allow(unused_macros)]
macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
}

#[allow(unused_macros)]
macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

#[allow(unused_macros)]
macro_rules! debug { ($x: expr) => { println!("{}: {:?}", stringify!($x), $x) } }
// macro_rules! debug { ($x: expr) => () }

#[allow(dead_code)]
fn show<T>(iter: T) -> String
where
    T: Iterator,
    T::Item: std::fmt::Display
{
    let mut res = iter.fold(String::new(), |sum, e| sum + &format!("{} ", e));
    res.pop();
    res
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BinaryHeap, HashMap, HashSet};
#[allow(unused_imports)]
use std::collections::btree_map::Entry::{Occupied, Vacant};

fn naive(a: i64, b: i64) -> i64 {
    let m = a*b;
    debug!(m);
    let count: HashSet<_> = (1..m)
        .filter(|&x| x != a && (m-1)/x != b)
        .map(|x|{
            (m-1)/x
        }).collect();
    // debug!(count);
    count.len() as i64
}

fn solve(a: i64, b: i64) -> i64 {
    let m = a*b - 1;
    if m == 0 {
        return 0;
    }
    let mut ans = f(m);
    if (a == 1 || m/a != m/(a-1)) && m/a != m/(a+1) {
        ans -= 1;
    }
    if (b == 1 || m/b != m/(b-1)) && m/b != m/(b+1) {
        ans -= 1;
    }
    if m/a == b {
        ans += 1;
    }
    ans
}

// fn f(m: i64) -> i64 {
//     let count: HashSet<_> = (1..m+1)
//         .map(|x|{
//             m/x
//         }).collect();
//     // debug!(count.len());
//     count.len() as i64
// }

fn f(x: i64) -> i64 {
    let mut l = 0;
    let mut r = 1_000_000_000 + 2;
    while l+1 < r {
        let m = (l+r)/2;
        if m*m <= x {
            l = m;
        } else {
            r = m;
        }
    }
    if x/l == l {
        2*l-1
    } else {
        2*l
    }
}

fn main() {
    use std::io::Write;
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    macro_rules! printf { ($($arg:tt)*) => (write!(out, $($arg)*).unwrap()); }
    macro_rules! printfln { () => (writeln!(out).unwrap()); ($($arg:tt)*) => (writeln!(out, $($arg)*).unwrap()); }
    
    // for i in 1..200 {
    //     debug!(i);
    //     f(i);
    // }

    let q = readl!(usize);
    let ab: Vec<_> = (0..q).map(|_| readl!(i64, i64)).collect();


    for &(a, b) in &ab {
        printfln!("{}", solve(a, b));
    }

}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
#include <memory>
#include <regex>
using namespace std;

int main()
{
    int n;
    cin >> n;
    vector<vector<int> > edges(n);
    for(int i=0; i<n-1; ++i){
        int a, b;
        cin >> a >> b;
        -- a;
        -- b;
        edges[a].push_back(b);
        edges[b].push_back(a);
    }
    vector<int> c(n);
    for(int i=0; i<n; ++i)
        cin >> c[i];
    sort(c.rbegin(), c.rend());

    vector<bool> used(n, false);
    queue<int> q;
    used[0] = true;
    q.push(0);
    vector<int> ans(n);
    for(int i=0; i<n; ++i){
        int a = q.front();
        q.pop();
        ans[a] = c[i];
        for(int b : edges[a]){
            if(!used[b]){
                used[b] = true;
                q.push(b);
            }
        }
    }

    cout << accumulate(c.begin() + 1, c.end(), 0) << endl;
    cout << ans[0];
    for(int i=1; i<n; ++i)
        cout << ' ' << ans[i];
    cout << endl;

    return 0;
}


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

int main(){

    int n,j = 1,big = -1,con;
    set <char> st,st1;
    set <char> :: iterator m;

    string s;

    scanf("%d",&n);

    cin>>s;

    while(j != n){
        con = 0;
        for(int i = 0; i < j; i++)
            st.insert(s[i]);

        for(int l = j; l < n; l++){
            st1.insert(s[l]);
        }

        for(m = st.begin(); m != st.end(); m++){
            int len = st1.size();
            char it = *m;
            st1.insert(it);
            if(st1.size() == len)
                con++;
        }
        if(con > big) big = con;
        j++;

        st.clear();
        st1.clear();
    }

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

    return 0;
}


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

#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll ;
typedef unsigned long long ull ;
typedef long double ld ;

const ll MOD = 998244353, INF = 2E18 + 5 ;
const double PI = 2 * acos(0.0) ;
const long double EPS = 1.0E-14 ;

vector <ll> vec[100005] ;
ll arr[100005] ;

int main()
{
    ll n, h, a, b, flag = 0, ans = 0 ;
    cin >> n >> h ;

    for (int i = 1; i <= n; i++) {
        scanf("%lld", &arr[i]) ;
    }
    for (int i = 0; i < h; i++) {
        scanf("%lld %lld", &a, &b) ;
        vec[a].push_back(b) ;
        vec[b].push_back(a) ;
    }

    for (int i = 1; i <= n; i++) {
        if (vec[i].size() == 0) {
            ans++ ;
            continue ;
        }
        flag = 0 ;
        for (int j = 0; j < vec[i].size(); j++) {
            if (arr[i] <= arr[vec[i][j]]) {
                flag = 1 ;
                break ;
            }
        }
        if (!flag)  ans++ ;
    }
    cout << ans ;

    return 0 ;
}


Measured memory_bytes: 10272
import java.util.Scanner;
import java.util.Arrays;

class Main{
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    int[] candy = new int[3];
    for(int i=0; i<3; i++){
      candy[i] = Integer.parseInt(scanner.next());
    }

    Arrays.sort(candy);

    if(candy[2] == candy[0]+candy[1]){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}


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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> ls(n);
    for (auto& l : ls) {
        cin >> l;
    }
    int max_l = *max_element(ls.begin(), ls.end());
    vector<int> count(2*max_l+1, 0);
    for (auto l : ls) {
        ++count[l];
    }
    vector<int> count_sum(2*max_l+1, 0);
    count_sum[0] = count[0];
    for (int i = 1; i < (int)count.size(); ++i) {
        count_sum[i] = count_sum[i-1] + count[i];
    }
    // num_1 counts all with a <= b < c
    long long num_1 = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (make_pair(ls[i], i) < make_pair(ls[j], j)) {
                num_1 += count_sum[ls[i]+ls[j]-1]-count_sum[ls[j]];
            }
        }
    }
    // num_2 counts all with a = b = c
    long long num_2 = 0;
    for (int i = 0; i <= 2*max_l; ++i) {
        num_2 += ((long long) count[i])*(count[i]-1)*(count[i]-2)/6;
    }
    // num_3 counts all with a < b = c
    long long num_3 = 0;
    for (int i = 0; i <= 2*max_l; ++i) {
        long long bc = count[i]*(count[i]-1)/2;
        long long a = count_sum[i-1];
        num_3 += a*bc;
    }
    cout << num_1+num_2+num_3 << endl;
    return 0;
}


Measured memory_bytes: 256
#![allow(non_snake_case)]
use proconio::input;
// use std::collections::HashMap;

fn calc_gcd(a: i64, b: i64) -> i64 {
    if b == 0 {
        return a;
    } else {
        return calc_gcd(b, a % b);
    }
}

fn main() {
    input! {
        A: i64,
        B: i64,
    }

    let gcd = calc_gcd(A, B);

    if gcd == 1 {
        println!("1");
        return;
    }

    let mut ans = 1;
    let mut N = gcd;
    for i in 2..((gcd as f64).sqrt() as i64 + 2) {
        if N % i == 0 {
            while N % i == 0 {
                N /= i;
            }
            ans += 1;
        }

        if N == 1 {
            break;
        }
    }

    // 残ったものが素数の場合
    if N != 1 {
        ans += 1;
    }

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


Measured memory_bytes: 2132
#include<iostream>
#include<string>
#include<vector>

using namespace std;

int main() {
	int H, W;

	cin >> H >> W;

	string grid[H];
	for (int i =  0; i < H; i++) {
		cin >> grid[i];
	}

	for (int i = 0; i < H; i++) {
		bool f = true;

		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '#') {
				f = false;
				break;
			}
		}

		if (f) {
			for (int j = 0; j < W; j++) {
				grid[i][j] = '?';
			}
		}
	}

	for (int j = 0; j < W; j++) {
		bool f = true;

		for (int i = 0; i < H; i++) {
			if (grid[i][j] == '#') {
				f = false;
				break;
			}
		}

		if (f) {
			for (int i = 0; i < H; i++) {
				grid[i][j] = '?';
			}
		}
	}

	for (int i = 0; i < H; i++) {
		int count = 0;
		for (int j = 0; j < W; j++) {
			if (grid[i][j] == '?') {
				count++;
				continue;
			}
			else {
				cout << grid[i][j];
			}
		}

		if (count == W) {
			continue;
		}
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 256
n = int(input())
a = input()
b = input()
c = input()

ans = 0
for i in range(n):
  if (a[i] != b[i]) and (b[i] != c[i]) and (c[i] != a[i]):
    ans += 2
  elif not (a[i] == b[i] == c[i]):
    ans += 1
  else:
    pass
print(ans)

Measured memory_bytes: 9152
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	string s,t;cin>>s>>t;
	string s2 = s + s;//sを繰り返すと折返しが考えやすいってエラい人が言ってた
	vector<vector<ll>> a(26);

	for(int i = 0; i < s2.size(); i++) {
		a[s2[i] - 'a'].pb(i);
	}

	if (a[t[0] - 'a'].size() == 0){
			cout << -1 << endl;
			return 0;
		}
	ll tmp = a[t[0] - 'a'][0];//最初の一文字
	ll ans = tmp + 1;//0オリを考慮しますた
	for(int i = 1; i < t.size(); i++) {
		if (a[t[i] - 'a'].size() == 0){
			cout << -1 << endl;
			return 0;
		}
		auto ite = upper_bound(ALL(a[t[i] - 'a']),tmp);
		if (*(ite) < s.size()){//折返しがない時
			ans += (*(ite) - tmp);
			tmp = *(ite);
		}
		else{//折返しのときはリセット
			ans += (*(ite) - tmp);
			tmp = a[t[i] - 'a'][0];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3000
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
#include <bitset>
using namespace std;

typedef long long ll;

ll mod = 1e9 + 7;
ll sumr[1000005], sumc[1000005];
int ir[1000005], ic[1000005];

int main() {
	int N, M; cin >> N >> M;
	for (int i = 0; i <= 1000000; i++) ir[i] = ic[i] = -1;
	for (int i = 0; i < N; i++) {
		int a; cin >> a;
		if (ir[a] != -1) {
			cout << 0 << endl;
			return 0;
		}
		ir[a] = i;
		sumr[a] += 1;
	}
	for (int j = 0; j < M; j++) {
		int b; cin >> b;
		if (ic[b] != -1) {
			cout << 0 << endl;
			return 0;
		}
		ic[b] = j;
		sumc[b] += 1;
	}
	for (int i = 1000000; i > 0; i--) sumr[i - 1] += sumr[i];
	for (int j = 1000000; j > 0; j--) sumc[j - 1] += sumc[j];
	ll cnt = 0;
	ll ans = 1;
	for (int i = N*M; i > 0; i--) {
		if (ir[i] != -1 && ic[i] != -1) {
			cnt += ((sumc[i] + sumr[i])%mod - 2 + mod) % mod;
		}
		else if (ir[i] != -1) {
			cnt += sumc[i] - 1;
			ans *= sumc[i];
			ans %= mod;
		}
		else if (ic[i] != -1) {
			cnt += sumr[i] - 1;
			ans *= sumr[i];
			ans %= mod;
		}
		else {
			ans *= cnt;
			ans %= mod;
			cnt--;
		}
	}
	for (ll i = 1; i <= cnt; i++) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 23808
#include <iostream>
#include <cmath>
using namespace std;
int r,n;
int main(){while(cin>>r>>n,r){int L,R,h;int A[41]={},B[41]={};for(int i=0;i<n;i++){cin>>L>>R>>h;for(int x=L;x<=R;x++){if(x!=R)A[x+20]=max(A[x+20],h);if(x!=L)B[x+20]=max(B[x+20],h);}}double res=100;for(int i=-r;i<=r-1;i++){res=min(res,min(r-sqrt(r*r-i*i)+A[i+20],r-sqrt(r*r-(i+1)*(i+1))+B[i+1+20]));}cout<<res<<"\n";}return 0;}

Measured memory_bytes: 3252
#include<iostream>
#include<iomanip>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
 
using namespace std;
 
#define P(p) cout<<(p)<<endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define vsort(v) sort(v.begin(), v.end());
#define rvsort(v) sort(v.begin(), v.end(),greater<int>());
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return
#define C(i) cin>>i
#define C2(i,j) cin>>i>>j
#define C3(i,j,k) cin>>i>>j>>k
#define C4(i,j,k,m) cin>>i>>j>>k>>m
////////////////////////////////////////////////////////////

int main(){
	int x,a,b;
	C3(x,a,b);

	cout << ( x - a ) % b << endl;
	ret 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> ppair;

int main(){
    ll N, K;
    cin >> N >> K;
    vector<ppair> ab(N);
    for(int i=0; i<N; i++){
        int a, b;
        cin >> a >> b;
        ab[i] = make_pair(a,b);
    }
    sort(ab.begin(),ab.end(),greater<ppair>());
    ll k=0;
    int ans;
    for(int i=0; i<N; i++){
        ppair now = ab.back();
        ab.pop_back();
        int tmp=now.second;
        //cout << tmp << endl;
        if(k+tmp<K){
            k+=tmp;
            continue;
        }else{
            ans = now.first;
            break;
        }
        /*
        for(int j=0; j<tmp; j++){
            ans = now.first;
            k++;
            if(k==K){
                break;
            }
        }
        if(k==K){
            break;
        }
        */
    }
    cout << ans << endl;

    return 0;
}

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

bool SecondCompare(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second<b.second;
}

bool SecondCompareDes(const pair<int,int> &a,const pair<int,int> &b)
{
       return a.second>b.second;
}

int n;
int f[101][11], p[101][12], co[101];

int main(){
    cin >> n;
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 10; j++){
            cin >> f[i][j];
            if(f[i][j] == 1)    co[i]++;
        }
    }
    
    for(int i = 0; i < n; i++){
        for(int j = 0; j < 11; j++){
            cin >> p[i][j];
        }
    }
    int membit = 1;
    int cou;
    long long ans = -9223372036854775807, memans = 0;
    for(int i = 1; i < 1024; i++){
        for(int j = 0; j < n; j++){
            cou = 0;
            for(int k = 0; k < 10; k++){
                if(i & (1 << k)){
                    cou += f[j][k];
                }
            }
            memans += p[j][cou];
        }
        ans = max(ans, memans);
        memans = 0;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
#define MAX 10100
    int n; //荷物の個数
    int x[MAX], y[MAX], h[MAX], w[MAX]; //荷物の縦の長さ、横の長さ、高さ、重量

    while(true){
        cin >> n;
        if(n == 0) break;
        
        int l[MAX]; //荷物の大きさ
        for(int i = 0; i < n; i++){
            cin >> x[i] >> y[i] >> h[i] >> w[i];
            l[i] = x[i] + y[i] + h[i];
        }
        
        int sum = 0; //荷物の料金の総計
        for(int i = 0; i < n; i++){
            if(l[i] <= 60){
                if(w[i] <= 2) sum += 600;
                else if(w[i] <= 5) sum += 800;
                else if(w[i] <= 10) sum += 1000;
                else if(w[i] <= 15) sum += 1200;
                else if(w[i] <= 20) sum += 1400;
                else if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else if(60 < l[i] && l[i] <= 80){
                if(w[i] <= 5) sum += 800;
                else if(w[i] <= 10) sum += 1000;
                else if(w[i] <= 15) sum += 1200;
                else if(w[i] <= 20) sum += 1400;
                else if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else if(80 < l[i] && l[i] <= 100){
                if(w[i] <= 10) sum += 1000;
                else if(w[i] <= 15) sum += 1200;
                else if(w[i] <= 20) sum += 1400;
                else if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else if(100 < l[i] && l[i] <= 120){
                if(w[i] <= 15) sum += 1200;
                else if(w[i] <= 20) sum += 1400;
                else if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else if(120 < l[i] && l[i] <= 140){
                if(w[i] <= 20) sum += 1400;
                else if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else if(140 < l[i] && l[i] <= 160){
                if(w[i] <= 25) sum += 1600;
                else sum += 0;
            }
            else sum += 0;
        }
        cout << sum << endl;
    }
}



Measured memory_bytes: 3280
// -----------------------------------
// Author     : MatsuTaku
// Country    : Japan
// Created    : 04/14/20 07:28:46
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n; cin>>n;
  vector<ll> A(3*n); for(auto& a:A) cin>>a;
  sort(A.rbegin(), A.rend());
  ll ans = 0;
  for (int i = 0; i < n; i++) {
    ans += A[2*i+1];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
int x[99][2],y[99][20],n,a,b,c,d,e,f,g,h,p,i,j,k;
int main() {
while(true) {
memset(x,0,sizeof(x));memset(y,0,sizeof(y));
cin>>n>>a>>b>>c;
if(n==0){break;}
for(i=0;i<c;i++){
cin>>d>>e>>f>>g;
if(g!=0){y[e][f]+=20;}
else{x[e][1]+=d+y[e][f];x[e][0]++;}
}p=0;
for(i=b;i>=0;i--){
for(j=0;j<=49999;j++){h=0;
for(k=a;k>0;k--){
if(x[k][0]==i&&x[k][1]==j){
if(h>=1){cout<<'=';}else if(p>=1){cout<<',';}cout<<k;p++;h++;
}
}}}
cout<<endl;}}

Measured memory_bytes: 1168
n = int(input())

tree = [[] for i in range(n)]
connect = [0 for i in range(n)]

inf = float('inf')

for i in range(n-1):
    a,b = map(int, input().split())
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
    connect[a]+=1
    connect[b]+=1

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

c.sort()

m = 0
d = [0 for i in range(n)]

for i in range(n):
    ind = connect.index(min(connect))
    m += max(connect[ind] * c[i], 0)
    d[ind]=c[i]
    connect[ind] = inf
    for j in range(len(tree[ind])):
        connect[tree[ind][j]]-=1
        if connect[j]==0:
            connect[j] = inf

print(m)
print(' '.join(map(str,d)))



Measured memory_bytes: 52056
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define mp make_pair
#define ALL(obj) (obj).begin(),(obj).end()
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n) 
#define SIZE(x) ((int)(x).size())
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef pair<int, int> pint;
typedef pair<lint, lint> plint;
typedef vector<lint> vec;
typedef vector<vector<lint>> matrix;
typedef priority_queue<lint> p_que;
typedef priority_queue<lint, vector<lint>, greater<lint>> p_que_rev;
const lint INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};

lint gcd(lint a, lint b) {
    lint r;
    while (b != 0) {
        r = a % b;
        a = b; 
        b = r;
    }
    return a;
}

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

lint power(lint x, lint n, lint mod = MOD) {
    lint ret = 1;
    while(n > 0) {
        if(n & 1){
            (ret *= x) %= mod;
        }
        (x *= x) %= mod;
        n >>= 1;
    }
    return ret;
}

vector<lint> make_power(int n, lint base){
    lint num = 1;
    vector<lint> ret;
    for (int i=0; i<=n; ++i){
        ret.push_back(num);
        num *= base;
    }
    return ret;
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    REP(i, n){
        cin >> a[i];
    }
    int dp[k+1];
    REP(i, k+1){
        dp[i] = 0;
    }
    for (int i=1; i<=k; ++i){
        for (int j : a){
            if(i - j >= 0){
                dp[i] = dp[i] | !dp[i-j];
            }
        }
    }
    cout << ((dp[k] == 1) ? "First" : "Second") << endl;
    return 0;
}

Measured memory_bytes: 640
#include<stdio.h>

int main(){
    unsigned long int n, q;
    long int k;
    scanf("%lu%ld%lu", &n, &k, &q);
    unsigned long int a[q], b[n];
    for(unsigned long int i=0; i<q; i++){
        scanf("%lu", &a[i]);
        a[i]--;
    }
    for(unsigned long int i=0; i<n; i++){
        b[i] = 0;
    }
    for(unsigned long int i=0; i<q; i++){
        b[a[i]]++;
    }
    for(unsigned long int i=0; i<n; i++){
        if(q-b[i] >= k){
            printf("No");
        }else{
            printf("Yes");
        }
        if(i<n-1){
            printf("\n");
        }
    }

    return 0;
}

Measured memory_bytes: 2048
import numpy as np
N = int(input())
data = np.zeros((N,3))
for i in range(N):
    data[i] = np.array(input().split())

# data = np.array([[2,3,0],[2,1,0],[1,2,0],[3,2,5]])

if len(np.where(data[:,2]!=0)[0]) == 1:
    C_x, C_y, H = map(int,data[np.where(data[:,2]!=0)[0][0]])
    print(C_x, C_y, H)
else:
    for n in range(10201):
        C_x = n // 101
        C_y = n % 101
        correctflg = True
        unsetflg = True
        for x,y,h in data:
            if unsetflg:
                if h >= 1:
                    H = abs(x-C_x)+abs(y-C_y)+h
                    unsetflg = False
            else:
                if h >= 1 and H != abs(x-C_x)+abs(y-C_y)+h:
                    correctflg = False
                    break 
        if correctflg:
            print(C_x,C_y,int(H))
            break
        
            
            


Measured memory_bytes: 12516
num = input().split()
tmp = [2,3,4,5,6,7,8,9,10,11,12,13,1]

if int(num[0])==int(num[1]): print('Draw')
elif tmp.index(int(num[0]))>tmp.index(int(num[1])): print('Alice')
elif tmp.index(int(num[1]))>tmp.index(int(num[0])): print('Bob')

Measured memory_bytes: 3064
a,b=map(str,input().split())
a=int(a)
B=0
if b[0]=='0':
    pass
else:
    B+=int(b[0])*100

if b[2]=='0':
    pass
else:
    B+=int(b[2])*10

if b[3]=='0':
    pass
else:
    B+=int(b[3])

print((a*B)//100)


Measured memory_bytes: 9184
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
ll gcd(ll a,ll b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}

int main() {
    int n;
    cin >> n;
    if(n %2 == 1) cout << n/2 << endl;
    else cout << n/2-1 << endl;
    return 0;
}


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


int main (){
    int N;
    cin>>N;
    vector<int> L(N);
    int Sum=0;
    for(int i=0; i<N; i++){
        cin>>L.at(i);
        Sum +=L.at(i);
    }
    sort(L.begin(), L.end());
    if(L.at(N-1)*2<Sum){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

}

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

typedef long long ll;
const ll MOD = 1e9 + 7;
vector<int> G[100000];
int solve(int v, int p) {
	if (G[v].size() == 1) return 0;
	int cnt = 0;
	int sum = 0;
	for (int to : G[v]) {
		if (to == p) continue;
		int d = solve(to, v);
		if (d > 0) sum += d;
		else cnt++;
	}
	sum += max(cnt - 1, 0);
	return sum;
}
int main() {
	int N;
	cin >> N;
	for (int i = 0; i < N - 1; i++) {
		int a, b;
		cin >> a >> b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int r = 0;
	for (int i = 0; i < N; i++) if (G[r].size() < G[i].size()) r = i;
	if (G[r].size() <= 2) {
		cout << 1 << endl;
		return 0;
	}
	cout << solve(r, -1) << endl;
}


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

long long int MOD = 998244353;

long long int modpow(long long int a, long long int n) {
  long long int res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1;
  }
  return res;
}

int main() {
  long long int N, S;
  cin >> N >> S;
  vector<long long int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  vector<vector<long long int>> DP(N + 1, vector<long long int>(S + 1, 0));
  DP.at(0).at(0) = modpow((long long int)2, (long long int)N);
  for (int i = 0; i < N; i++) {
    for (int j = 0; j <= S; j++) {
      if (j >= A.at(i)) {
        DP.at(i + 1).at(j) = (DP.at(i).at(j) + DP.at(i).at(j - A.at(i)) * (MOD - (MOD / 2) % MOD)) % MOD;
      }
      else DP.at(i + 1).at(j) = DP.at(i).at(j);
    }
  }
  cout << DP.at(N).at(S) << endl;
}


Measured memory_bytes: 73708
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;

int main(void) {
    ll n;
    string s[2];
    cin >> n>>s[0]>>s[1];
    ll res=1;
    int cnt=0;
    int state=0;
    while(cnt<n){
        if(s[0][cnt]!=s[1][cnt]){
            if(state==2){
                res*=3;
            }else{
                res*=(3-state)*(2-state);
            }
            state=2;
            cnt+=2;
        }else{
            res*=3-state;
            state=1;
            cnt++;
        }
        DEBUG{cout <<"res : " << res << endl;}
        DEBUG{cout <<"cnt : " << cnt << endl;}
        res%=MOD;
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int n,i,j,k;
unsigned int ccc,cost[100][100],front[100][100],back[100][100];

int main(){
	scanf("%d",&n);
	for(i=0;i<n;i++)scanf("%d %d",&front[0][i],&back[0][i]);
	for(i=1;i<n;i++){
		for(j=0;j<n-i;j++){
			cost[i][j]=2147483648;
			for(k=0;k<i;k++){
				ccc=cost[k][j]+cost[i-k-1][j+k+1]+front[k][j]*front[i-k-1][j+k+1]*back[k][j]*back[i-k-1][j+k+1];
				if(ccc<cost[i][j]){
					cost[i][j]=ccc;
					front[i][j]=front[k][j];
					back[i][j]=back[i-k-1][j+k+1];
				}
			}
		}
	}
	printf("%d\n",cost[n-1][0]);
	return 0;
}

Measured memory_bytes: 700
#include <cstdio>
#include <algorithm>

typedef long long LL;
const LL Infll = 0x3f3f3f3f3f3f3f3f;
const int MN = 200005;

int N, E, T, A[MN];
LL f[MN], g[MN];

int main() {
	scanf("%d%d%d", &N, &E, &T);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	g[0] = Infll;
	for (int i = 1, j = 1; i <= N; ++i) {
		while (2 * (A[i] - A[j]) > T) ++j;
		f[i] = std::min(f[j - 1] + T, 2 * A[i] + g[j - 1]);
		g[i] = std::min(g[i - 1], f[i - 1] - 2 * A[i]);
	}
	printf("%lld\n", E + f[N]);
	return 0;
}

Measured memory_bytes: 3664
import bisect,collections,copy,itertools,math,string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())
def main():
    n = I()
    a = LI()
    tasi = sum(a)
    num = 10**9+7
    ans = 0
    
    for i in range(n):
        tasi -= a[i]
        tasi %= num
        ans += a[i]*tasi
        ans %= num

    print(ans)
main()            


Measured memory_bytes: 96744
#include <cstdio>
#include <iostream>
#include <string>
#include <set>

using namespace std;

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

    set<string> st;
    for(int i = 0; i < n; i++){
        string tmp;
        cin >>tmp;
        st.insert(tmp);
    }

    printf("%d\n", st.size());

    return 0;
}

Measured memory_bytes: 19296
#C for submisstion
import numpy as np
from itertools import combinations
H, W, K = map(int, input().split())
C=[input() for i in range(H)]
C_list=[list(C[i]) for i in range(H)]
C_cols=['c'+str(i) for i in range(H)]
C_rows=['r'+str(i) for i in range(W)]
C_comb=C_cols + C_rows

Comb=[]
for i in range(1, H+W):
    Comb+=combinations(C_comb,i)
    
result=0
for i in range(len(Comb)):
    C_array=np.array(C_list)
    for j in Comb[i]:
        if j[0]=='c':
            c_r=int(j[1:])
            C_array[c_r,:]='r'
        else:
            c_r=int(j[1:])
            C_array[:,c_r]='r'
    df_bool = (C_array=='#')
    result+= df_bool.sum()==K
    
if (np.array(C_list) =='#').sum() ==K:
    result+=1
    
print(result)

Measured memory_bytes: 27292
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (ll i=1; i<=(n); ++i)
typedef long long ll;
bool debug=false;
string yes = "Yes";
string no = "No";
int main(){
  ll k; cin >> k;
  ll ans=0;
  rep(i,k){
    if(i%3==0||i%5==0) continue;
    else ans+=i;
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 3676
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <cmath>

using namespace std;
#define M_PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define swap(a, b, type) { type _tmp = a; a = b; b = _tmp; }
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	string s, t = "";
	stack<char> ans;

	cin >> s;
	rep(i, s.length()) {
		if (s[i] == 'B') {
			if (!ans.empty()) ans.pop();
		}
		else ans.push(s[i]);
	}

	while (!ans.empty()) {
		t = ans.top() + t;
		ans.pop();
	}

	cout << t << endl;

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int bucket[26] = {0};
	char str[101];

	scanf("%s", str);

	for(int i=0; str[i] != '\0'; i++) {
		bucket[str[i]-'a']++;
	}

	for(int i=0; i < 26; i++) {
		if(bucket[i]%2) {
			printf("No");
			return 0;
		}
	}
	printf("Yes");

	return 0;
}


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

long long n,poss;
int main(){
cin>>n;
int min=1001,max=0;
for(int i=1;i<=n;i++){
	cin>>poss;
	if(poss>max){
		max=poss;
	}if(poss<min){
		min=poss;
	}
}
cout<<max-min<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
//#define MOD 1000000007
const int INF = 1LL<<30;

vector<vector<int>> G;
vector<int> ans;

void dfs(int cu,int pa,int c){
    ans[cu]=c;
    for(auto to : G[cu]){
        if(pa==to) continue;
        dfs(to,cu,1-c);
    }
}

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

    G.resize(3*n);
    ans.resize(3*n);
    int nxt=n;
    rep(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--,v--;
        if(w%2==1){
            G[u].push_back(v);
            G[v].push_back(u);
        }
        else{
            G[u].push_back(nxt);
            G[nxt].push_back(u);
            G[v].push_back(nxt);
            G[nxt].push_back(v);
            nxt++;
        }
    }

    dfs(0,-1,0);

    rep(i,n){
        cout<<ans[i]<<endl;
    }

}

Measured memory_bytes: 15872
// luogu-judger-enable-o2
#include <bits/stdc++.h>
using namespace std;

const int maxn = 500005, Inf = (1 << 30);
char s[maxn];
int n, f[maxn], cnt[maxn][26];

void dfs(int k, int len)
{
	if(len == 1) {
		for(int i = 0; i < 26; ++i)
			if(cnt[k][i] == n + 1) {
				printf("%c", 'a' + i); return;
			}
	}
	for(int i = 0; i < 26; ++i)
		if(f[cnt[k][i]] == len) {
			printf("%c", 'a' + i); dfs(cnt[k][i] + 1, len - 1);
			break;
		}
}

inline void chkmin(int &a, int b)
{
	if(a > b) a = b;
}

int main()
{
	scanf("%s", s + 1); n = strlen(s + 1);

	for(int i = 0; i < 26; ++i) cnt[n + 1][i] = n + 1;

	f[n + 1] = 1;
	for(int i = n; i >= 1; --i) {
		memcpy(cnt[i], cnt[i + 1], sizeof(cnt[i]));
		f[i] = Inf;
		for(int j = 0; j < 26; ++j) chkmin(f[i], f[cnt[i][j]] + 1);
		cnt[i][s[i] - 'a'] = i;
	}

	for(int i = 0; i < 26; ++i)
		if(cnt[1][i] == n + 1) printf("%c", 'a' + i), exit(0);
	int ans = Inf;
	for(int i = 0; i < 26; ++i) chkmin(ans, f[cnt[1][i]]);
    dfs(1, ans);
	return 0;
}


Measured memory_bytes: 23424
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<long long,long long>
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 long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m; cin >> n >> m;
	vector<int>a(n), b(n); rep(i, n) cin >> a[i] >> b[i];
	vector<pair<int, int>> AandB;
	rep(i, n) {
		AandB.push_back(make_pair(a[i], b[i]));
	}
	sort(AandB.begin(), AandB.end());
	int ans = 0;
	rep(i, n) {
		if (AandB[i].second < m) {
			ans += AandB[i].first * AandB[i].second;
			m -= AandB[i].second;
		}
		else {
			ans += AandB[i].first * m;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3956
def main():
  N, M, X = [int(x) for x in input().split()]
  costs = [0] * (N + 1)
  for x in [int(x) for x in input().split()]:
    costs[x] = 1

  print(min(sum(costs[X:]), sum(costs[:X])))


if __name__ == "__main__":
  main()


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

using namespace std;
typedef long long ll;

int N;
ll H[int(1e5+5)], DP[int(1e5+5)];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++) cin >> H[i];
  fill(DP, DP + N, 1e18); 
  // ここでDP[0]からDP[N-1]に10^18を入れる
  DP[0] = 0;
  for (int i = 0; i < N; i++){
    DP[i+1] = min(DP[i+1], DP[i] + abs(H[i] - H[i+1])); 
    // DP[i+1]のコストの更新
    DP[i+2] = min(DP[i+2], DP[i] + abs(H[i] - H[i+2]));
    //DP[i+2] のコストの更新
  }
  cout << DP[N-1] << endl;

  return 0;
}

Measured memory_bytes: 5192
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

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

    map<string, vector<pair<int, int>>> mp;
    
    for (size_t i = 1; i <= n; i++)
    {
        string s;
        int p;
        cin >> s >> p;
        mp[s].push_back(make_pair(p, i));
    }

    for (auto &&e : mp)
    {
        sort(e.second.begin(), e.second.end(), [](pair<int, int> lhs, pair<int, int> rhs) {
            return lhs.first > rhs.first;
        });
        for (auto &&i : e.second)
        {
            cout << i.second << endl;
        }
        
    }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
se = set()
for i in range(K):
    d = int(input())
    A = list(map(int, input().split()))
    for a in A:
        se.add(a-1)
ans = 0
for i in range(N):
    if not i in se:
        ans += 1
print(ans)


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

/*
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <ctype.h>
*/
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main() {
    init();
string s,c="";
cin>>s;

for(int i=0;i<s.size();i++){
    if(s[i]!='B'){

    c+=s[i];
}
else if(c.size()!=0){
    c.pop_back();
}

}
cout<<c<<endl;
}



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

#define FOR(i, a, b) for (int i = (a); i < (b); i++)

typedef long long ll;

int main() {
  int x;
  cin >> x;
  if (x < 100) {
    cout << 0 << endl;
    return 0;
  }
  if (x >= 2000) {
    cout << 1 << endl;
    return 0;
  }
  int y = x / 100;
  int c = ceil((x % 100) / (double)y);
  if (c <= 5) {
    cout << 1 << endl;
    return 0;
  }
  cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a, b;
    cin >> a >> b;
    vector< int > c(2);
    c[0] = a, c[1] = b;
    sort(c.begin(), c.end());
    if (c[0] == 1 && c[1] == 2) {
        cout << 3 << endl;
    } else if (c[0] == 1 && c[1] == 3) {
        cout << 2 << endl;
    } else {
        cout << 1 << endl;
    }
    return 0;
}

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

long long GCD(long long X, long long Y) {
	if (Y == 0) return X;
	return GCD(Y, X % Y);
}

int main() {
	long long A, B;
	while (cin >> A >> B) {
		cout << GCD(A, B) << " " << A * (B / GCD(A, B)) << endl;
	}
}


Measured memory_bytes: 3072
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
# 
# 
# @stop_watch
def solve(S, T):
    ans = 10000
    for i in range(len(S) - len(T) + 1):
        tmp = 0
        for j in range(len(T)):
            if S[i + j] != T[j]:
                tmp += 1
        ans = min(ans, tmp)
    print(ans)


if __name__ == '__main__':
    S = input()
    T = input()
    # N = int(input())
    # N, M = map(int, input().split())
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(S, T)


Measured memory_bytes: 9112
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    int n, a, b;
    cin >> n >> a >> b;
    cout << min(a * n, b) << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int  H, W, i, j;
	
	while(1)
	{
        scanf("%d %d", &H, &W);


	if(H!=0 && W!=0){
	for(i=1; i<=H; i++)
	  {{
	  	for(j=1; j<=W; j++)
	    printf("#");
	  }
	  putchar('\n');
	  }
	  putchar('\n');
	} else break;
       }
	  
	    
	return 0;
}

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

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

	cin >> a >> b >> c;

	if(a<b){
		if(b<c){
			cout << "Yes" << endl;
		}else if(b>c){
			cout << "No" << endl;
		}
	}else{
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef pair<long long, long long> P;
#define override_rep(i, l, r, mes, ...) mes
#define rep1(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = l; i < r; i++)
#define rep(...) override_rep(__VA_ARGS__, rep2, rep1)(__VA_ARGS__)
#define int long long
template <typename T, typename U>
istream &operator>>(istream &in, pair<T, U>& p) {
    in >> p.first >> p.second;
    return in;
}
signed main(signed argc, char* argv[]) {
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	const int MOD=1e9+7;
	int a,b;
	cin>>a>>b;
	if(a<b){
	    rep(i,b)cout<<a;
	    cout<<endl;
	}
	else{
	    rep(i,a)cout<<b;
	    cout<<endl;
	}
}

Measured memory_bytes: 256
import Data.List
import qualified Data.ByteString.Char8 as B
import qualified Data.IntSet as S
import qualified Data.Vector.Unboxed as UV
main=do
    [n,k]<-map read.words<$>getLine::IO[Int]
    as<-UV.unfoldr(B.readInt.B.dropWhile(<'!'))<$>B.getLine
    putStrLn $ if S.member k $ f k as then "First" else "Second"

f k as = UV.foldl' p S.empty $ UV.enumFromTo 0 k where
    p s i | S.member i s = s
          | otherwise = UV.foldl' (flip S.insert) s $ UV.filter (<=k) $ UV.map (+i) as

Measured memory_bytes: 2044
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
using namespace std;

#define MAX_N 1000000

struct UFSet {
    vector<int> par;
    int sz;
    UFSet():sz(MAX_N) {}
    UFSet(int _sz):sz(_sz) { for(int i = 0; i < _sz; ++i) par.push_back(i); }
    int find(int x) {if(x==par[x]) return x;else return par[x] = find(par[x]);}
    void unite(int x, int y) {
        int fx = find(x);
        int fy = find(y);
        if(fx == fy) return;
        par[fx] = fy;
    }
    bool same(int x, int y) { return find(x) == find(y); }
};

int main() {
    int N, Q;
    scanf("%d%d", &N, &Q);
    UFSet set = UFSet(N);
    for(int i = 0; i < Q; ++i) {
        int c, a, b;
        scanf("%d%d%d",&c, &a, &b);
        if(c == 0) {
            set.unite(a, b);
        } else {
            bool f = set.same(a, b);
            if(f) printf("1\n");
            else printf("0\n");
        }
    }
    return 0;
}

Measured memory_bytes: 1208
# -*- coding: utf-8 -*-
import sys
from collections import defaultdict

H, W = (int(i) for i in sys.stdin.readline().rstrip().split())
S = (sys.stdin.readline().rstrip() for _ in range(H))

dd = {}
for i, x in enumerate(S):
  for j, y in enumerate(x):
    dd[(i, j)] = 1 if y == '#' else 0

all_pos = {}
for pos in sorted(dd.keys()):
  x, y = pos
  state = 0
  state += dd.get((x + 1, y), 0)
  state += dd.get((x - 1, y), 0)
  state += dd.get((x, y + 1), 0)
  state += dd.get((x, y - 1), 0)
  state += dd.get((x + 1, y + 1), 0)
  state += dd.get((x - 1, y - 1), 0)
  state += dd.get((x + 1, y - 1), 0)
  state += dd.get((x - 1, y + 1), 0)
  all_pos[(x, y)] = state
  
for i in range(H):
  for j in range(W):
    if dd[(i, j)]:
      print('#', end='')
    else:
      print(all_pos[(i, j)], end='')
  print()

Measured memory_bytes: 4332
#include <iostream>
#include <cstdio>
#include <map>
using namespace std;

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

    map<long long, long long> T;

    for(long long i = 0; i < n; i++){
        long long a;
        cin >> a;

        if(T.find(a) == T.end()){
            T[a] = 1;
        }
        else{
            T[a] += 1;
        }
    }

    map<long long, long long>::iterator it;

    long long count = 0;
    for(it = T.begin(); it != T.end(); it++){
        //printf("it->first %lld it->second %lld\n", it->first, it->second);

        if(it->first == it-> second){
            continue;
        }

        if(it->first < it->second){
            count += it->second - it->first;
        }
        else if(it->first > it->second){
            count += it->second;
        }
    }

    cout << count << endl;

    return 0;

}

Measured memory_bytes: 6272
import std;

alias P = Tuple!(long, "x", long, "y");
const MOD = 10^^9 + 7;

long calc(P[] ps, int zeros) {
    long[P] m;
    foreach (p; ps) m[p]++;

    bool[P] used;
    long[] group;
    foreach (p; ps) {
        if (used.get(p, false)) continue;

        // p に属するグループ数
        auto a1 = p;
        auto a2 = P(-p.x, -p.y);
        long acnt = m.get(a1, 0) + m.get(a2, 0);

        // p と垂直な位置関係にある点のグループ数
        auto b1 = P(-p.y, p.x);
        auto b2 = P(p.y, -p.x);
        long bcnt = m.get(b1, 0) + m.get(b2, 0);

        long cnt = 0;
        // s のグループからのみ選ぶ組み合わせ数
        cnt += modpow(2, acnt) - 1; // -1 は何も選ばない分を引いている
        // t のグループからのみ選ぶ組み合わせ数
        cnt += modpow(2, bcnt) - 1;
        // s からも t からも選ばない
        cnt += 1;
        cnt %= MOD;

        group ~= cnt;
        used[a1] = used[a2] = used[b1] = used[b2] = true;
    }

    long ans = 0;
    if (group.length > 0) {
        ans += group.fold!((a, b) => a * b % MOD)(1L);
        ans -= 1; // 全てのグループにおいて何も選ばなかった分の 1 を引く
    }
    ans += zeros;
    ans += MOD;
    return ans % MOD;
}

void main() {
    int n; scan(n);
    P[] ps;
    int zeros = 0;
    foreach (_; 0..n) {
        long a, b; scan(a, b);
        if (a == 0 && b == 0) zeros++;
        else {
            long g = gcd(abs(a), abs(b));
            ps ~= P(a/g, b/g);
        }
    }
    writeln(calc(ps, zeros));
}

void scan(T...)(ref T a) {
    string[] ss = readln.split;
    foreach (i, t; T) a[i] = ss[i].to!t;
}
T read(T=string)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readints = reads!int;

long modpow(long x, long k) {
    if (k == 0) return 1;
    if (k % 2 == 0) return modpow(x * x % MOD, k / 2);
    return x * modpow(x, k - 1) % MOD;
}


Measured memory_bytes: 91400
inp = require('fs').readFileSync('/dev/stdin', 'utf8').trim().split('\n')
l = inp.shift().split(' ')
N = l.shift() * 1
K = l.shift() * 1 
s = inp.map(x => x.split(' ')).sort((a,b) => {
    return a[0] - b[0]
})
c = 0
i = 0
while (c < K) {
    c+= s[i][1] * 1
    last = s[i][0]
    i++
}
console.log(last)

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

using namespace std;
typedef long long ll;

int main() {
    int n, sum = 0, ans;
    cin >> n;
    vector<int> s(n);
    for(int i=0;i<n;i++) {
        cin >> s[i];
        sum += s[i];
    }
    sort(s.begin(), s.end());
    if(sum % 10 == 0) {
        int idx = -1;
        for(int i=0;i<n;i++) {
            if(s[i] % 10 != 0) {
                idx = i;
                break;
            }
        }
        if(idx >= 0)
            ans = sum - s[idx];
        else
            ans = 0;
    } else {
        ans = sum;
    }
    cout << ans << endl;
}


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

using namespace std;
const int N=1e5+55;
const int M=155;
int dp[N];
int a[N];

int main()
{
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++)
		cin>>a[i];
	dp[0]=1;
	for(int i=1;i<=k;i++)
	{
		dp[i]=1;
		for(int j=0;j<n;j++)
		{
			if(a[j]<=i)
				dp[i]&=dp[i-a[j]]^1;
		}
	}
	if(dp[k])
	cout<<"Second\n";
	else
	cout<<"First\n";
	
	
	return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N, T, A;
    cin >> N >> T >> A;
    
    int current_closest = 99999999;
    int best_candidate = 999999;
    for (int i = 1; i <= N; i++) {
        int x;
        cin >> x;
        int temp = (T*1000-x*6)-A*1000;
        if (temp < 0) temp = -(temp);
        if (temp < current_closest) {
            current_closest = temp;
            best_candidate = i;
        }
        
    }
    
    cout << best_candidate << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>

int main(){

    char num[3];
    char *pch;

    scanf("%s",&num);
    pch = strstr (num,"7");
    if (pch != NULL)
        puts("Yes");
    else 
        puts("No");

    return 0;
}
//todo
// !
// ?
// * 

Measured memory_bytes: 1664