akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <iomanip>
#include <assert.h>
#include <fstream>

using namespace std;

const int MAXN = 100005;

int n;
int a[MAXN];

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	for (int i = 1;i <= n;i++)
		cin >> a[i];
	sort(a + 1,a + n + 1);
	reverse(a + 1,a + n + 1);
	int last = 1,j = 0;
	for (int i = 1;i <= n;i++)
	{
		if (a[i] > a[i + 1] && (i + a[i]) % 2 == 0)
			j = i;
		if (a[i] > a[i + 1] && ((i + a[i]) % 2 == 1 || i == n))
		{
			if (last && j && last <= j && last <= a[last] && j >= a[j + 1] + 1)
			{
				cout << "Second" << endl;
				return 0;
			}
			last = i + 1;
		}
	}
	cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define ld long double
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	read(n);
	n %= 10;
	
	if (n == 3) cout << "bon";
	else if (n == 0 || n == 1 || n == 6 || n == 8) cout << "pon";
	else cout << "hon";
}



















Measured memory_bytes: 3652
n = gets.to_i
a = gets.split.map(&:to_i)

ans_n = a.max
ans_r = 0
r0 = 0
a.each {|r|
    r1 = [r, ans_n-r].min
    if r1 > r0
        ans_r = r
        r0 = r1
    end
}

puts "#{ans_n} #{ans_r}"

Measured memory_bytes: 11012
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

  ll a,b;
  cin >> a >> b;
  ll ans = 1;
  rep(i,a){
    if(ans<=b)ans*=2;
    else ans+=b;
  }
  cout << ans << endl;

  //cout << fixed << setprecision(16) << ans << endl;
  return 0;
}


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

int main(){
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for(int i=0;i<n;i++){
    cin >> s.at(i) >> t.at(i);
  }
  string x;
  cin >> x;
  
  int ans=0;
  for(int i=0;i<n;i++){
    if(s.at(i)==x){
      for(int j=i+1;j<n;j++){
        ans+=t.at(j);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
#include <stack>
using namespace std;
using ll = long long;
class UnionFind {
public:
    vector <ll> par; 
    vector <ll> siz;
    UnionFind(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (x > y) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }
    ll size(ll x) {
        return siz[root(x)];
    }
};

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

  int32_t N;
  cin >> N; 
  vector<vector<int32_t>> cities(N, vector<int32_t>(3, 0));
  for (int i = 0; i < N; i++) {
    cin >> cities[i][0] >> cities[i][1];
    cities[i][2] = i;
  }
  sort (cities.begin(), cities.end(), [](const vector<int32_t>& r, const vector<int>& l) {return r[0] < l[0];});

  UnionFind uf(N);
  int32_t ymin_idx = 0;
  int32_t ymin = cities[0][1];
  stack<int32_t> s;
  s.push(ymin_idx);
  for (int i = 1; i < N; i++) {
    int32_t y = cities[i][1];
    if (y < ymin) {
      ymin_idx = i;
      ymin = y;
      s.push(ymin_idx);
    } else {
      uf.merge(ymin_idx, i);
      while (!s.empty() && cities[s.top()][1] < y) {
        uf.merge(ymin_idx, s.top());
        s.pop();
      }
      s.push(ymin_idx);
    }
  }

  vector<int32_t> res(N, 0);
  for (int i = 0; i < N; i++) {
    res[cities[i][2]] = uf.size(i);
  }
  for (auto r : res) {
    cout << r << endl;
  }
  
  return 0;
}


Measured memory_bytes: 17912
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int m = sc.nextInt();
		int x = sc.nextInt();
		int y = sc.nextInt();

		int max = -200, min = 200;
		for (int i = 0; i < n; i++) {
			max = Math.max(max, sc.nextInt());
		}
		for (int i = 0; i < m; i++) {
			min = Math.min(min, sc.nextInt());
		}

		for (int i = x + 1; i <= y; i++) {
			if (max < i && min >= i) {
				System.out.println("No War");
				return;
			}
		}

		System.out.println("War");

	}

}


Measured memory_bytes: 21972
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define orep(i, n) for (int i = 1; i <= (int)n; i++)
#define vec vector

class SegmentTree
{
private:
	int def = 0;
	int n;
	vec<int> data;

	int func(int vl, int vr) {
		return vl + vr;
	}

	int query_rec(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l) return def;
		if (a <= l && r <= b) return data[k];

		int vl = query_rec(a, b, k * 2 + 1, l, (l + r) / 2);
		int vr = query_rec(a, b, k * 2 + 2, (l + r) / 2, r);
		return func(vl, vr);
	}

public:
	SegmentTree(int n_) {
		n = 1;
		while(n < n_) n *= 2;
		data.resize(2 * n - 1);
		rep(i, data.size()) data[i] = def;
	}

	void update(int k, int a) {
		k += n - 1;
		data[k] += a;
		while(k > 0) {
			k = (k - 1) / 2;
			data[k] = func(data[k * 2 + 1], data[k * 2 + 2]);
		}
	}

	int query(int a, int b) {
		return query_rec(a, b, 0, 0, n);
	}
};

int main(void)
{
	int n, m;
	cin >> n >> m;
	vec<pair<int, int>> a(n);
	rep(i, n) cin >> a[i].first >> a[i].second;
	sort(a.begin(), a.end(), [](pair<int, int> p, pair<int, int> q) {
			return p.second - p.first < q.second - q.first;
			});
	SegmentTree data(m + 1);
	int c = 0;
	orep(i, m) {
		while(c < n && a[c].second - a[c].first + 1 < i) {
			data.update(a[c].first - 1, 1);
			data.update(a[c].second, - 1);
			c++;
		}
		int ans = n - c;
		orep(j, m / i) ans += data.query(0, i * j);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 4352
# include <algorithm>
# include <iostream>
# include <cmath>
# include <string>
# include <vector>

using namespace std;

bool is(vector<int> ant, int k){
    for (int i=0; i<4; i++){
        for (int j=i; j<5; j++){
            if (ant[i] - ant[j] < -k || ant[i] - ant[j] > k){
                return false;
            }
        }
    }
    return true;
}

int main() {
    int a,k;
    vector<int> ant;
    for (int i=0; i<5; i++){
        cin >> a;
        ant.push_back(a);
    }
    cin >> k;

    if (is(ant,k)){
        cout << "Yay!" << endl;
    }else{
        cout << ":(" << endl;
    }


    return 0;
}


Measured memory_bytes: 256
def bubble_sort(A, N):
    cnt = 0
    flag = True
    while flag:
        flag = False
        for j in range(N - 1, 0, -1):
            if int(A[j - 1][1]) > int(A[j][1]):
                A[j - 1], A[j] = A[j], A[j - 1]
                flag = True
                cnt += 1
    return A

def selection_sort(A, N):
    cnt = 0
    for i in range(N):
        minj = i
        for j in range(i, N):
            if int(A[j][1]) < int(A[minj][1]):
                minj = j
        A[i], A[minj] = A[minj], A[i]
        if i != minj:
            cnt += 1
    return A

N = int(input())
A = input().split()
order_A = [[] for _ in range(10)]
for s in A:
    order_A[int(s[1])].append(s)

order_bubble = [[] for _ in range(10)]
b_sorted = bubble_sort(A[:], N)
for s in b_sorted:
    order_bubble[int(s[1])].append(s)
print(*b_sorted)
print('Stable' if order_A == order_bubble else 'Not stable')

s_stability = [[] for _ in range(10)]
s_sorted = selection_sort(A[:], N)
for s in s_sorted:
    s_stability[int(s[1])].append(s)
print(*s_sorted)
print('Stable' if order_A == s_stability else 'Not stable')


Measured memory_bytes: 5620
def main():
    import sys
    from collections import Counter
    N = int(sys.stdin.readline())
    A = list(map(int, sys.stdin.readline().split()))
    Q = int(sys.stdin.readline())
    BC = [tuple(map(int, sys.stdin.readline().split())) for _ in range(Q)]
    C = Counter(A)
    '''
    L = [0 for _ in range(10**5+1)]
    for key, value in C.items():
        L[key] = value
    '''
        
    ans = 0
    for bc in BC:
        C[bc[1]] += C[bc[0]]
        tmp = C[bc[0]]
        C[bc[0]]= 0
        #print(C)
        if ans == 0:
            for key, value in C.items():
                ans += key*value
        else:
            ans +=(bc[1]-bc[0])*tmp
        print(ans)
        



if __name__=='__main__':
    main()

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

using namespace std;
const int N = 3e3 + 5, MOD = 1e9 + 7;
int dp[N][N], a[N];

int mul(int a, int b) {return 1ll * a * b % MOD;}
int Pow(int a, int b) {
    int res = 1;
    for (; b; b>>=1, a = mul(a, a)) if (b&1) res = mul(res, a);
    return res;
}
int Inv = Pow(2, MOD - 2);

int main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    int n, q; cin >> n >> q;
    for (int i = 1; i <= n; i++) cin >> a[i];
    for (int i = 1; i <= n; i++) for (int j = 1; j <= n; j++) dp[i][j] = a[i] > a[j];
    int ans = 1;
    for (int j = 0; j < q; j++) {
        int x, y; cin >> x >> y;
        for (int i = 1; i <= n; i++) if (i != x && i != y) {
			dp[i][x] = dp[i][y] = mul(dp[i][x] + dp[i][y], Inv);
			dp[x][i] = dp[y][i] = mul(dp[x][i] + dp[y][i], Inv);
		}
        dp[x][y] = dp[y][x] = mul(dp[x][y] + dp[y][x], Inv);
        ans = mul(2, ans);
    }
    int sum = 0;
    for (int i = 1; i <= n; i++) for (int j = i + 1; j <= n; j++) sum = (sum + dp[i][j]) % MOD;
    cout << mul(ans, sum) << "\n";


    return 0;
}


Measured memory_bytes: 35456
a, b, c, x, y = map(int, input().split())
n_a = x
n_b = y
n_c = 2

ans = a * n_a + b * n_b
while ans > a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c:
    ans = a * max(n_a - 1, 0) + b * max(n_b - 1, 0) + c * n_c
    n_a -= 1
    n_b -= 1
    n_c += 2
    
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
using namespace std;


void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    string n;

    cin >> n;
    int l=n.length();

    // cout << l/2 << n << n[l-1] << endl;

    for (int i=1;i<=(l/2);i++) {
        if (n[i-1]==n[l-i]){
            // cout << "fs";
        }
        else {
            cout << "No";
            break;
        }
        cout << "Yes" ; 
    }


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_set>
#include <set>
#include <cstring>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

using ll = long long;
const ll INF = 1e18 + 1;




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

    string s, t;
    cin >> s;
    cin >> t;

    ll ans = 0;
    for (int i = 0; i < s.length(); ++i) {
        if (s[i] != t[i]) {
            ans++;
        }
    }
    cout << ans << endl;






}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vl a(3);
  rep(i, 3) cin >> a[i];
  sort(all(a));
  ll ans = a[2] - a[1];
  a[0] += ans;
  ans += (a[2] - a[0] + 1) / 2;
  ans += (a[2] - a[0]) % 2;
  cout << ans << endl;
}

Measured memory_bytes: 256
//ｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwｺｹｯwwwｺｹｯｺｯwwwｺｯwwｺｯwwｺｹｯwwwｺｯwwwｺｹｯwwwｺｹｯｺｯwwwｺｹｰｰｰｰｯ!!!wwwwwｺｹｯｺｯｯｺｰｰｰｰ!!!!!!wwwwwwwwwww
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
            System.out.println("Possible");
        }else{
            System.out.println("Impossible");
        }
    }
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String i1 = sc.next(),i2=sc.next();
		char[] s=i1.toCharArray();
		char[] t=i2.toCharArray();

		java.util.Arrays.sort(s);
		Arrays.sort(t);
		char[] t2= new char[t.length];
		int cnt=0;
		for(int i=t.length-1; 0<=i;i--) {
			t2[cnt]=t[i];
			cnt++;
		}

//		for(char c: t2) {
//			System.out.print(c);
//		}

		int mini=Math.min(s.length, t2.length);
		int n=0;
		for(int i=0; i<mini;i++) {
			if(s[i]<t2[i]) {
				System.out.println("Yes");
				return;
			}else if(s.length<t2.length && s[i]==t2[i]) {
				n++;
			}

			if(n==mini) {
				System.out.println("Yes");
				return;
			}
		}
		System.out.println("No");
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll> V(N);
    rep(i,N){
        cin >> V[i];
    }
    ll ans = 0;
    rep(T,K+1){
        rep(A,K-T+1){
            ll B = K-T-A;
            priority_queue<ll> que;
            ll sum = 0;
            rep(i,min(ll(A),N)){
                que.push(-V[i]);
            }
            rep(i,min(B,N)){
                if(N-1-i <= A-1)break;
                que.push(-V[N-1-i]);
            }
            rep(i,T){
                if(que.empty())break;
                if(que.top() < 0)break;
                que.pop();
            }
            while(!que.empty()){
                sum -= que.top();
                que.pop();
            }
            cmax(ans, sum);
        }
        //cout << T << endl;
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
n=int(input())
t,a=map(int,input().split())
h=list(map(int,input().split()))

temp_abs=[]
for i in range(n):
    temp=t-h[i]*0.006
    temp_abs.append(abs(a-temp))
print(temp_abs.index(min(temp_abs))+1)

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
ll gcd(ll a, ll b) {
    return b ? gcd(b, a%b) : a;
}

//最小公倍数
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}

//char->int
int ctoi(char c){
    return c-'0';
}



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

    ll ans = k;

    for(int i=1;i<n;i++){
        ans *= k-1;
    }
    cout << ans << endl;
}

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

const long long mod=998244353LL;

int main(int argc, char const *argv[])
{
	string s;
	cin>>s;
	int n=s.size();
	int r[2*n+5],b[2*n+5];
	r[0]=0,b[0]=0;
	for (int i = 0; i < n; ++i)
	{
		r[i+1]=r[i];
		b[i+1]=b[i];
		if (s[i]=='0')
		{
			r[i+1]+=2;
		}
		else if (s[i]=='1')
		{
			++r[i+1];
			++b[i+1];
		}
		else
		{
			b[i+1]+=2;
		}
	}
	for (int i = n; i < 2*n+5; ++i)
	{
		r[i]=r[n];b[i]=b[n];
	}
	long long dp[2*n+5][2*n+5]={};
	dp[0][0]=1LL;
	for (int i = 0; i < 2*n; ++i)
	{
		for (int j = 0; j < 2*n; ++j)
		{
			if (r[i+1]>j)
			{
				dp[i+1][j+1]+=dp[i][j];
				dp[i+1][j+1]%=mod;
			}
			if (b[i+1]>i-j)
			{
				dp[i+1][j]+=dp[i][j];
				dp[i+1][j]%=mod;
			}
		}
	}
	cout<<dp[2*n][r[n]]<<endl;
	return 0;
}


Measured memory_bytes: 125568
#include<stdio.h>
#define True 1
#define False -1
int solve(int,int);
int n;
int A[20];
int main(){

  int i,q,a;
  int mi[200];

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&mi[i]);
  }
  for(i=0;i<q;i++){
    a=solve(0,mi[i]);
  if(a==False)printf("no\n");
  else printf("yes\n");
  }
}

int solve(int i,int m){
  int res,res2;
  if(m==0) return True;
  if(i>=n) return False;
  res=solve(i+1,m);
  if(res==False)res=solve(i+1,m-A[i]);
  return res;
}
  



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

#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1e9
typedef long long ll;


int main() {
    int N,M; cin >> N >> M;
    cout << (100*N + 1800*M)*pow(2,M) << endl;
    return 0;
}

Measured memory_bytes: 4272
/*
*
*Problem Link : https://atcoder.jp/contests/dp/tasks/dp_a
*Platform: atcoder
*Author: Mayukh Chakrabarti
*
*/

#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false)
#define boost cin.tie(NULL)
#define booster cout.tie(NULL)
#define endl "\n"
typedef long long int lld;

#define F(a,n) for(int i=0;i<n;i++){cin>>a[i];}
#define F1(a,n) for(int i=1;i<=n;i++){cin>>a[i];}
#define P(a,n) for(int i=0;i<n;i++){cout<<a[i]<<' ';}cout<<endl;
#define P1(a,n) for(int i=1;i<=n;i++){cout<<a[i]<<' ';}cout<<endl;
#define NF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cin>>a[i][j];}}
#define NF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cin>>a[i][j];}}
#define PNF(a,n,m) for(int i=0;i<n;i++){for(int j=0;j<m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;
#define PNF1(a,n,m) for(int i=1;i<=n;i++){for(int j=1;j<=m;j++){cout<<a[i][j]<<' ';}cout<<endl;}cout<<endl;

using namespace std;

int main(){
	
	
	int N;
	cin>>N;
	
	vector<int> ar(N);
	F(ar,N);
	
	vector<int> dp(N,INT_MAX);
	
	dp[0]=0;//first stone we have to step
	
	for(int i=0; i<N-1; i++){
		
		if(i+1 < N)
			dp[i+1]= min(dp[i+1], dp[i] + abs(ar[i+1]-ar[i]) );
		if(i+2 < N)
			dp[i+2]= min(dp[i+2], dp[i] + abs(ar[i+2]-ar[i]) );
		
	}
	
	cout<<dp[N-1];
	
	return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n, a, b;

    cin >> n >> a >> b;

    cout << max(0LL, (n * b - b +  a) - (n * a - a + b) + 1)  << endl;


  
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int llint;
typedef long long ll;
typedef long int lint;
typedef vector<char> vchar;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvint;
typedef vector<vector<char>> vvchar;
#define vsort(v) sort((v).begin(), (v).end())
#define vrsort(v) sort((v).rbegin(), (v).rend())
#define vreverse(v) reverse((v).begin(), (v).end())
#define pb(a) push_back(a)
#define INF 2000000009
#define MOD 1000000007
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //input
  ll i,n,t;cin>>n>>t;vll a(n),mx(n),pr(n-1,0);
  for(i=0;i<n;i++){cin>>a[i];mx[i]=a[i];}
  //caricurate
  for(i=n-2;i>-1;i--){
    //mx[i]=max(mx[i+1],mx[i]);
    if(mx[i+1]>mx[i]){mx[i]=mx[i+1];}
  }
  for(i=0;i<n-1;i++){
    //pr[i]=max(0,(mx[i+1]-a[i]));
    if(mx[i+1]>a[i]){pr[i]=(mx[i+1]-a[i]);}
  }
  vrsort(pr);ll ans=1;i=0;
  while(pr[i]==pr[i+1]){ans++;i++;}
  //output
  cout<<ans<<endl;
}

Measured memory_bytes: 2560
#include <cstdio>
#include <cmath>
using namespace std;

double dist2(double x1, double y1, double x2, double y2) {
  return (x2-x1)*(x2-x1) + (y2-y1)*(y2-y1);
}

int main() {
  int n, c, maxc;
  double x[100], y[100];
  bool ol[100][100];
  double vx, vy, ox, oy, t1, t2, d2;

  while (1) {
    scanf("%d", &n);
    if (!n) break;
    for (int i=0; i<n; i++) {
      scanf("%lf,%lf", &x[i], &y[i]);
    }
    for (int i=0; i<n; i++) {
      ol[i][i] = false;
      for (int j=i+1; j<n; j++) {
        ol[j][i] = ol[i][j] = (dist2(x[i], y[i], x[j], y[j]) <= 4.0) ? true : false;
      }
    }
    maxc = 1;
    for (int i=0; i<n; i++) {
      for (int j=i+1; j<n; j++) {
        if (!ol[i][j]) continue;
        if (x[i]==x[j] && y[i]==y[j]) {
          t1 = t2 = 0.0;
        } else {
          vx = x[j] - x[i];
          vy = y[j] - y[i];
          d2 = dist2(x[i], y[i], x[j], y[j]);
          t1 = atan2(vy, vx);
          t2 = atan2(sqrt(1.0-0.25*d2), sqrt(d2)*0.5);
        }
        for (int l=0; l<2; l++) {
          if (!l) {
            ox = x[i] + cos(t1+t2);
            oy = y[i] + sin(t1+t2);
          } else {
            ox = x[i] + cos(t1-t2);
            oy = y[i] + sin(t1-t2);
          }
          c = 2;
          for (int k=i+1; k<n; k++) {
            if (ol[i][k] && ol[j][k]) {
              if (dist2(ox, oy, x[k], y[k]) <= 1.0) {
                ++c;
              }
            }
          }
          if (maxc < c) maxc = c;
        }
      }
    }
    printf("%d\n", maxc);
  }
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
#define rep(i, z, n) for(int i = z; i < n; i++)
#define repB(i, z, n) for(int i = n - 1; i >= z; i--)
#define all(v) v.begin(), v.end()
typedef long long ll;
#define PI 3.14159265358979
//const int64_t INF = 1LL << 60;
const int INF = 1 << 29;
const int64_t MOD = 1000000007;
//const int64_t INF = 998244353;
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; }
using namespace std;
//#define P pair<int, int>
typedef pair<int, int> P;

int main(){
    string S;
    cin >> S;
    if(S == "Sunny") cout << "Cloudy" << endl;
    if(S == "Cloudy") cout << "Rainy" << endl;
    if(S == "Rainy") cout << "Sunny" << endl;
}

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

using namespace std;

int a[105];

int main(){
      int n;
      scanf("%d", &n);
      
      for(int i = 0; i < n; i++)
      scanf("%d", &a[i]);
      
      sort(a, a + n);
      reverse(a, a + n);
      
      int res = 0;
      int pre = 1e9;
      
      for(int i = 0; i < n; i++){
            if(a[i] < pre){
                  res++;
                  pre = a[i];
            }
      }
      
      printf("%d\n", res);
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
#include<memory>
using namespace std;
using ll=long long;

const ll MOD=1e9+7;
void add(ll& lhs,ll rhs){
    lhs=(lhs+rhs)%MOD;
}
int main(){
    int n,a,b;
    cin>>n>>a>>b;
    if(b<a) swap(a,b);
    if(a==1 || b==1){
        ll res = 1;
        for(int i=0;i<n;i++){
            res=res*2%MOD;
        }
        cout<<res<<endl;
        return 0;
    }
    vector<vector<ll>> Adp(n+1,vector<ll>(b));
    vector<vector<ll>> Bdp(n+1,vector<ll>(b));
    vector<vector<ll>> Cdp(n+1,vector<ll>(b));
    vector<ll> ok(n+1);
    Adp[0][0] = 1;
    for(int i=0;i<n;i++){
        for(int j=0;j<a;j++){
            if(j+1<a){
                add(Adp[i+1][j+1],Adp[i][j]);
            }
            add(Bdp[i+1][1],Adp[i][j]);
            if(i==0 && j==0){
                if(a==b){
                    add(ok[i+a],Adp[i][0]);
                }
                else{
                    add(Cdp[i+a][a],Adp[i][0]);
                }
            }
        }
        for(int j=0;j<b;j++){
            add(Adp[i+1][1],Bdp[i][j]);
            if(j+1<b){
                add(Bdp[i+1][j+1],Bdp[i][j]);
            }
            else{
                add(ok[i+1],Bdp[i][j]);
            }
            if(i+a<=n){
                if(j+a<b){
                    add(Cdp[i+a][j+a],Bdp[i][j]);
                }
                else{
                    add(ok[i+a],Bdp[i][j]);
                }
            }
        }        
        for(int j=0;j<b;j++){
            if(j+1<b){
                add(Bdp[i+1][j+1],Cdp[i][j]);
                add(Cdp[i+1][j+1],Cdp[i][j]);
            }
            else{
                add(ok[i+1],Cdp[i][j]);
                add(ok[i+1],Cdp[i][j]);
            }
        }
        add(ok[i+1],ok[i]);
        add(ok[i+1],ok[i]);
    }

    cout<<ok[n]<<endl;
    
    return 0;
}

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

#define loop(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < n; ++i)
#define dump(a) cerr << #a << " = " << (a) << "(L:" << __LINE__ << ")" << endl

void solve(long long K, std::string S) {
    if (S.size() <= K) {
        cout << S << endl;
        return;
    }
    cout << S.substr(0, K) << "..." << endl;
}

int main() {
    long long K;
    scanf("%lld", &K);
    std::string S;
    std::cin >> S;
    solve(K, S);
    return 0;
}


Measured memory_bytes: 3684
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
 
int gcd(ll a, ll b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}
 
int main(){
  ll N, i, j, k, ans = 0;
  cin >> N;
  for (i = 1; i < N + 1; i++){
    for(j = 1; j < N + 1; j++){
      for(k = 1; k < N + 1; k++){
        ans += gcd(gcd(i, j), k);
      }
    }
  }
 
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define LLMAX (1ll << 60) - 1
#define INTMAX (1 << 30) - 1
#define MOD 1000000007 
#define NMAX 1000*100+1

#define numberOfSetBits(S) __builtin_popcount(S) // __builtin_popcountl(S) __builtin_popcountll(S)
#define MSET(x,y) memset(x,y,sizeof(x))
#define gcd(a,b) __gcd(a,b)
#define all(x)  x.begin(),x.end()
#define isOn(S, j) (S & (1 << j))
#define endl '\n'
#define setBit(S, j) (S |= (1 << j))
#define clearBit(S, j) (S &= ~(1 << j))
#define toggleBit(S, j) (S ^= (1 << j))
#define print(x)    for(auto it:x) cout<<it<<' '; cout<<endl;
#define printii(x)  for(auto it:x) cout<<it.F<<' '<<it.S<<'\t';  cout<<endl;
#define in(x,n)   for(int e=0;e<n;e++){ll y;cin>>y;x.pb(y);}

#define vi vector<ll>
#define vvi vector<vi>
#define ii pair<ll,ll>
#define pll pair<ll,ll>
#define vii vector<ii>
#define vvii vector<vii>
#define viii vector<pair<ii,ll>>
#define pb push_back
#define F first
#define S second
#define mp make_pair
#define mc(a,b,c) mp(mp(a,b),c)


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,x,t,m,y,z;
    vi a;
    cin>>n;
    in(a,n);
    sort(all(a));
    long double curr = 0;
    curr = (a[0]+a[1])/2.0;
    for(int i=2;i<n;i++){
        curr = (curr+a[i]*1.0)/2;
    }
    cout<<curr;


    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#define LL long long
#define mod 924844033
#define g 5
#define maxn 2000000
using namespace std;
LL n,siz[maxn],f[maxn],fact[maxn],inv[maxn],a[maxn],b[maxn],c[maxn],ans[maxn];
struct node { LL v; node *nxt; } edge[maxn],*head[maxn],*ncnt;
void addedge(LL u,LL v)
{
	ncnt++;
	ncnt->v=v,ncnt->nxt=head[u];
	head[u]=ncnt;
}
void dfs(LL u,LL fa)
{
	siz[u]=1;
	for(node *p=head[u];p;p=p->nxt)
	{
		LL v=p->v;
		if(v==fa) continue;
		dfs(v,u); siz[u]+=siz[v];
	}
	f[siz[u]]--,f[n-siz[u]]--;
}
LL powmod(LL a,LL n)
{
	LL res=1;
	while(n)
	{
		if(n&1) res=1ll*a*res%mod;
		a=1ll*a*a%mod;
		n>>=1;
	}
	return res;
}
void ntt(LL a[],LL n,LL mode)
{
	for(LL i=0,j=0;i<n;i++)
	{
		if(i<j) swap(a[i],a[j]);
		LL k=(n>>1);
		while(k&&(k&j)){ j^=k; k>>=1; }
		j^=k;
	}
	for(LL i=1;i<n;i<<=1)
	{
		LL w1=powmod(g,(mod-1)/(i<<1)),w=1;
		if(mode==-1) w1=powmod(w1,mod-2);
		for(LL j=0;j<i;j++,w=1ll*w*w1%mod)
			for(LL l=j,r=l+i;l<n;l+=(i<<1),r=l+i)
			{
				LL temp=1ll*w*a[r]%mod;
				a[r]=(a[l]-temp+mod)%mod;
				a[l]=(a[l]+temp)%mod;
			}
	}
	if(mode==-1)
	{
		LL inv=powmod(n,mod-2);
		for(LL i=0;i<n;i++) a[i]=1ll*a[i]*inv%mod;
	}
}
int main()
{
	ncnt=&edge[0];
	scanf("%lld",&n);
	for(LL i=1;i<n;i++)
	{
		LL u,v;
		scanf("%lld%lld",&u,&v);
		addedge(u,v); addedge(v,u);
	}
	dfs(1,0);
	f[n]=n;
	fact[0]=1;
	for(LL i=1;i<=n*2;i++) fact[i]=1ll*fact[i-1]*i%mod;
	inv[1]=1;
	for(LL i=2;i<=n*2;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	inv[0]=1;
	for(LL i=1;i<=n*2;i++) inv[i]=1ll*inv[i-1]*inv[i]%mod;
	for(LL i=0;i<=n;i++) a[i]=1ll*f[i]*fact[i]%mod;
	for(LL i=0;i<=n;i++) b[i]=inv[n-i];
    LL len=1;
    for(;len<=n*2;len<<=1);
    ntt(a,len,1); ntt(b,len,1);
	//for(LL i=0;i<=n*2;i++) printf(" - %lld %lld\n",a[i],b[i]);
    for(LL i=0;i<=len;i++) c[i]=1ll*a[i]*b[i]%mod;
    ntt(c,len,-1);
	for(LL i=0;i<=n;i++) ans[i]=1ll*c[i+n]*inv[i]%mod;
	for(LL i=1;i<=n;i++) printf("%lld\n",ans[i]);
}

Measured memory_bytes: 58752
fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	s.next().unwrap();
	let s = s.next().unwrap();
	let mut appear = vec![vec![]; 10];
	for (i, c) in s.bytes().enumerate() {
		let d = c - b'0';
		appear[d as usize].push(i);
	}
	let mut ans = 0;
	for a in 0..10 {
		if let Some(ai) = appear[a].first() {
			for c in 0..10 {
				if let Some(ci) = appear[c].last() {
					for b in 0..10 {
						let i = appear[b].upper_bound(&ai);
						let j = appear[b].lower_bound(&ci);
						if j > i {
							ans += 1;
						}
					}
				}
			}
		}
	}
	println!("{}", ans);
}

pub trait BinarySearch<'a, T: 'a> {
	fn lower_bound(&self, x: &T) -> usize;
	fn upper_bound(&self, x: &T) -> usize;
}

impl<'a, T: 'a + Ord> BinarySearch<'a, T> for [T] {
	fn lower_bound(&self, x: &T) -> usize {
		let mut first = 0;
		let mut len = self.len() - first;
		while len > 0 {
			let half = len >> 1;
			let mid = first + half;
			use std::cmp::Ordering;
			match self[mid].cmp(x) {
				Ordering::Less => {
					first = mid + 1;
					len = len - half - 1;
				}
				Ordering::Equal | Ordering::Greater => {
					len = half;
				}
			}
		}
		first
	}

	fn upper_bound(&self, x: &T) -> usize {
		let mut first = 0;
		let mut len = self.len() - first;
		while len > 0 {
			let half = len >> 1;
			let mid = first + half;
			use std::cmp::Ordering;
			match x.cmp(&self[mid]) {
				Ordering::Less => {
					len = half;
				}
				Ordering::Equal | Ordering::Greater => {
					first = mid + 1;
					len = len - half - 1;
				}
			}
		}
		first
	}
}


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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

const double PI = acos(-1.0);

// long long積のオーバーフロー検出
bool detect_mul_overflow(ll a,ll b){
    return a>=LONG_MAX/b;   
}

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

struct edge{int from, to,cost;};

// int型の2次元配列(3×4要素の)の宣言
// vector<vector<int>> data(3, vector<int>(4));

int a,b,c,k;
// a<b<c

int main()
{
    cin>>a>>b>>c>>k;
    while(a>=b){
        b*=2;
        k--;
    }
    while(b>=c){
        c*=2;
        k--;
    }
    if(k>=0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

    return 0;

}




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

coin_num = N // 100 + 1
X = N % 100

for i in range(coin_num):
  for j in range(coin_num):
    for k in range(coin_num):
      for l in range(coin_num):
        for m in range(coin_num):
          if i+j+k+l+m <= coin_num-1:
            total = 1*i + 2*j + 3*k + 4*l + 5*m
            #print(total)
            if total == X:
              print(1)
              exit()
            
print(0)


Measured memory_bytes: 3060
#include <stdio.h>
#include <string>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

static const int MAX = 20;

int n, H[MAX], h = 0, s = 0;

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

    for ( int i = 0; i < n; i++ ) {
        scanf("%d", &H[i]);
    }
    
    for ( int i = 0; i < n; i++ ) {
        if ( h <= H[i] ) {
            s++;
            h = H[i];
        }
    }

    printf("%d\n", s);
    return 0;
}


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

int main(void)
{
    int n, i;
    double ans = 0;
    cin >> n;
    vector<double> x(n);
    vector<string> u(n);

    for (i = 0; i < n; i++) {
        cin >> x.at(i) >> u.at(i);
    }

    for (i = 0; i < n; i++) {
        if (u.at(i) == "JPY") ans += x.at(i);
        else ans += x.at(i) * 380000;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

#define MAX  1000
#define MAX_1 10000


int n, a[MAX], s;
int b[MAX], T[MAX_1 + 1];


int partition(int a[], int p, int r){
  int i, j;
  int t, x;
  x = a[r];
  i = p - 1;

  for( j = p ; j < r ; j++ ){
    if(a[j] <= x){
      i++;
      t = a[i];
      a[i] = a[j];
      a[j] = t;
    }
  }

  t = a[i + 1];
  a[i + 1] = a[r];
  a[r] = t;

  return i + 1;
}
void quickSort(int a[], int p, int r){
  int q;
  if(p < r){
    q = partition(a, p, r);
    quickSort(a, p, q - 1);
    quickSort(a, q + 1, r);
  }
}


int solve(){
  int i, cur, S, m, an, v,   ans = 0 ;

  int V[MAX];
  for(i = 0 ; i < n ; i++){
    b[i] = a[i];
    V[i] = 0;
  }

  quickSort(b, 0, n - 1);

  for(i = 0 ; i < n ; i++) T[b[i]] = i;
  for(i = 0 ; i < n ; i++){
    if(V[i]) continue;
    cur = i;
    S = 0;
    m = MAX_1;
    an = 0;
    while(1){
      V[cur] = 1;
      an++;
      v = a[cur];

      if(v < m) m = v;

      S += v;
      cur = T[v];
      if(V[cur]) break;
    }
    if(S + (an -2) * m < m + S + (an + 1) * s) ans += S + (an -2) * m;
    else ans +=  m + S + (an + 1) * s;
  }
  return ans;
}



int main(){
  int i;

  scanf("%d", &n);
  s = MAX_1;
  for(i = 0 ; i < n ; i++){
    scanf("%d", &a[i]);
    if(a[i] < s) s = a[i];
  }

  int ans = solve();
  printf("%d\n", ans);

  return 0;
}



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

int main(void){
char num_str[1002];
int num;
long sum = 0;
int i;
char tmp;

while (1){
fgets(num_str,sizeof(num_str),stdin);
if (num_str[0] =='0') break;
for (i = 0; i < strlen(num_str)-1; i++){
tmp = num_str[i];
num = atoi(&tmp);
sum = sum + num;
}
printf("%ld\n",sum);
sum = 0;
memset(num_str,1002, 0);
}
return 0;
}

Measured memory_bytes: 532
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  sort(a.begin(), a.end());
  double ans = a[0];
  for(int i = 1; i < n; ++i) {
    ans += a[i];
    ans /= 2;
  }
  printf("%.5f\n", ans);
}

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

//省略形
#define rep(i,n) for(auto i=0; i<n ; ++i)
#define REP(i,a,b) for(auto i=a; i<b; ++i)
#define all(v) (v).begin() , (v).end()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//よく使う定数
const int INF = 1e9;
const int MOD = 1e9+7;
//逆元
const int INV = 1e9+5;

//UnionFindTree
struct union_find{
  vector<int> data;
  union_find(int size) : data(size , -1) { }

  void merge(int x , int y){
    x = root(x); y = root(y);
    if(x == y) return;
    if(data[y] < data[x]) swap(x , y);
    data[x] += data[y];
    data[y] = x;
    return; 
  }

  bool same(int x , int y){
    x = root(x) , y = root(y);
    return x == y;
  }

  int root(int x){
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }

  int size(int x){
    return -data[root(x)];
  }
};

//プロトタイプ宣言
void faster(void);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);
template <class T>
T modpow(T , T , T);

//メモ
//最大公約数:__gcd　|　最小公倍数:__lcm


int main(){
  faster();
  int n,m;
  cin >> n >> m;
  vi s(m) , c(m);
  rep(i,m) cin >> s[i] >> c[i];
  int reg = 1 , bor = 0;
  rep(i,n) reg *= 10;
  if(n==1) bor = 0;
  if(n==2) bor = 10;
  if(n==3) bor = 100;
  string _s;
  REP(i,bor,reg){
    _s = to_string(i);
    bool flag = true;
    rep(i,m){
      if((_s[s[i]-1]-'0')!=c[i]){
        flag = false;
        continue;
      }
    }
    if(flag) break;
    if(i==reg-1) _s = "-1";
  }
  cout << _s;
}


























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//繰り返し自乗法
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 

//繰り返し自乗法(剰余)
template <class T>
T modpow(T x , T y , T mod){
  if(y == 0) return 1;
  if(y%2 == 1){
    ll temp = modpow(x,y-1,mod);
    return temp*x%mod;
  }
  else{
    ll temp = pow_mod(x,y/2,mod);
    return temp*temp%mod;
  }
}



Measured memory_bytes: 256
import java.util.*;
import java.lang.Math;

public class Main{
public static void main(String[] args){
try{
double r = new Scanner(System.in).nextDouble();
double S = r * r * Math.PI;
double L = 2 * r * Math.PI;

System.out.printf("%.5f %.5f\n", S, L);

}catch(InputMismatchException e){
System.out.println(e);
}
}
}

Measured memory_bytes: 18944
main :: IO ()
main = do
  n <- readLn :: IO Integer
  let divid = map (subtract 1) . concatMap (\x -> [x,n`div`x]) . filter ((==0) . (n`mod`)) $ [1..(floor . sqrt . fromIntegral $ n)]
  print $ sum $ filter (\x -> n`div`x == n`mod`x) $ filter (/=0) divid


Measured memory_bytes: 1276
program ABC156_C
  integer,dimension(:),allocatable::X
  integer,dimension(1:101)::Y=0
  read(5,*)N
  allocate(X(N))
  read(5,*)X
  do I=1,101
     do J=1,N
        Y(I)=Y(I)+(X(J)-I+1)**2
     end do
  end do
  write(6,*)Y(minloc(Y))
end program ABC156_C

Measured memory_bytes: 512
from sys import stdin

N,M = map(int, input().split(' '))
shop = [stdin.readline().rstrip().split(' ') for i in range(N)]

for i in range(N):
  shop[i][0] = int(shop[i][0])
shop = sorted(shop)
  
sum = 0
for i in range(N) :
  if M > int(shop[i][1]) :
    sum += int(shop[i][0]) * int(shop[i][1])
    M -= int(shop[i][1])
  else :
    sum += int(shop[i][0]) * M
    M = 0
    break
    
print(sum)
    

Measured memory_bytes: 37416
#include<iostream>
#include<string>

using namespace std;

#define REP(i, n) for(int i=0; i<n; i++)

int main(){
    int h, w;
    cin >> h >> w;
    cout << string(w+2, '#') << endl;

    REP(i, h){
        string s;
        cin >> s;
        s = "#" + s + "#";
        cout << s << endl;
    }

    cout << string(w+2, '#') << endl;
}


Measured memory_bytes: 256
#include<iostream>                                        
#include<algorithm>                                       
using namespace std;                                      
static const int MAX = 200000;                            
                                                          
int main(){                                               
  int R[MAX],n;                                           
                                                          
  cin >> n;                                               
  for(int i=0;i<n;i++) cin >> R[i];                       
                                                          
  int maxv = -2000000000; // ???????°??????????????????????????¨????   
  int minv = R[0];                                        
                                                          
  for(int i=1;i<n;i++){ // ????????§??????R[i]?????????????????°??????\
????????????                                                  
    maxv = max(maxv,R[i] - minv);                         
    minv = min(minv,R[i]); // ???????????§???????°???????????????????\\
??????                                                      
  }                                                       
                                                          
  cout << maxv << endl;                                   
                                                          
  return 0;                                               
} 

Measured memory_bytes: 3876
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//------------------------------------------------------------------------------
//------------------------------------------------------------------------------
void _main()
{
    int N, C;
    cin >> N >> C;
    vector<vector<int>> D(C);
    rep(i, 0, C) D[i].assign(C, 0);
    rep(i, 0, C) rep(j, 0, C) cin >> D[i][j];
    array<vector<int>, 3> counts;
    rep(i, 0, 3) counts[i].assign(C, 0);
    int c;
    rep(i, 0, N) rep(j, 0, N)
    {
        cin >> c;
        --c;
        ++counts[((i + 1) + (j + 1)) % 3][c];
    }
    vector<int> chosen;
    rep(i, 0, C - 3) chosen.push_back(0);
    rep(i, 0, 3) chosen.push_back(1);
    int ans = INT_MAX;
    do
    {
        vector<int> colors;
        rep(i, 0, C)
        {
            if (chosen[i] == 1)
            {
                colors.push_back(i);
            }
        }

        do
        {
            int d = 0;
            rep(i, 0, 3)
            {
                rep(j, 0, C)
                {
                    d += D[j][colors[i]] * counts[i][j];
                }
            }
            chmin(ans, d);
        }
        while (next_permutation(colors.begin(), colors.end()));
    }
    while (next_permutation(chosen.begin(), chosen.end()));
    cout << ans << endl;
}


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

int main() {
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  char c;
  vector<vector<int>> S(H, vector<int>(W));
  for (int i = 0; i < H; i++)
    for (int j = 0, k = 0; j < W && cin >> c; j++)
      S.at(i).at(j) += (c != '#') ? ++k : k = 0;
  for (int i = 0; i < W; i++)
    for (int j = 0, k = 0; j < H; j++)
      S.at(j).at(i) += (S.at(j).at(i)) ? ++k : k = 0;
  for (int i = 0; i < H; i++)
    for (int j = W - 1, k = 0; j >= 0; j--)
      S.at(i).at(j) += (S.at(i).at(j)) ? ++k : k = 0;

  int ans = 0;
  for (int i = 0; i < W; i++)
    for (int j = H - 1, k = 0; j >= 0; j--) {
      S.at(j).at(i) += (S.at(j).at(i)) ? ++k : k = 0;
      ans = max(ans, S.at(j).at(i) - 3);
    }

  cout << ans << "\n";
}

Measured memory_bytes: 16000
#include <stdio.h>
int main(void)
{
   int i,j,n,d,x,a[100],s=0;

   scanf("%d%d%d",&n,&d,&x);

   for(i=0;i<n;i++)
      scanf("%d",&a[i]);

   for(i=0;i<n;i++)
      for(j=1;j<=d;j=j+a[i])
         s++;

   printf("%d\n",s+x);

   return 0;
}

Measured memory_bytes: 128
import numpy as np
from itertools import combinations
h,w,k = map(int,input().split())
c = np.empty((h,w))
for i in range(h):
    c[i,:] = np.array(list(map(int,input().replace(".",'0 ').replace("#",'1 ').split())))

cnt = 0
row,col = range(h),range(w)

for i in range(1,h+1):
    for j in range(1,w+1):
        if i==h and j==w:
            break
        for x in combinations(row, i):
            for y in combinations(col,j): 
                s = c[np.array(x),:]
                s = s[:,np.array(y)].sum()
                if s==k:
                    cnt+=1
if c.sum()==k:cnt+=1
print(cnt)

Measured memory_bytes: 27216
#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>

using namespace std;

long long result, n,d,x;
long long a[100] = {};

typedef pair<long long, long long> pl;
vector<pl> re;
vector<pl> bl;
pl buf;



int main() {
	result = 0;

	cin >> n>>d>>x;
	result = x+n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		result += (d - 1) / a[i];
	}

	cout << result << endl;

return 0;
}

Measured memory_bytes: 256