akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d, x;
    cin >> n >> d >> x;
    REP(i, n) {
        int a;
        cin >> a;
        x += (d - 1) / a + 1;
    }
    cout << x << endl;
    
    return 0;
}


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

int main() {
	int n;
	cin>>n;
	vector<int> h(n+1);
	vector<int> b(n+1);
	for(int i=0;i<n;i++){
	    cin>>h[i+1];
	}
	for(int i=0;i<n;i++){
	    cin>>b[i+1];
	}
	map<long,long> map;
	vector<long> dp(n+1,0);
	dp[1] = b[1];
	map[h[1]] = dp[1];
	long ans = dp[1];
	for(int i=2;i<=n;i++){
	    dp[i] = b[i];
	    auto it = map.lower_bound(h[i]+1);
	    if(it!=map.begin()){
	        it--;
	        dp[i] += it->second;
	    }
	    map[h[i]]=dp[i];
	    it = map.upper_bound(h[i]);
	    while(it!=map.end()&&it->second<=dp[i]){
	        auto temp = it;
	        temp++;
	        map.erase(it);
	        it=temp;
	    }
	    
	    ans = max(ans,dp[i]);
	}
	cout<<ans<<'\n';
	
	return 0;
}

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

/*int main(void)
{
    int n, k;
    cin >> n >> k;
    int a[n];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }

    int b[n+1] = {0};
    for (int i = 0; i < n; i++)
    {
        b[a[i]]++;
    }
    int kind = 0;
    for (int i = 0; i <= n; i++)
    {
        if (b[i] > 0) { kind++; }
    }
    sort(b, b+n+1);

    cout << "kind:" << kind << endl;
    int ans = 0;
    int j = 1;
    while (kind > k)
    {
        kind -= 1;
        ans += b[j];
        j++;
    }

    cout << ans << endl;

}*/

/*int main(void)
{
    int n, k;
    cin >> n >> k;
    int a[n];
    int b[n+1] = {0};
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        b[a[i]]++;
    }
    sort(b, b+n+1, greater<int>());

    int ans = 0;
    for (int i = 0; i < n-k; i++)
    {
        ans += b[i];
    }
    cout << ans << endl;
}*/

int main(void)
{
    int n, k;
    cin >> n >> k;
    int cnt[n] = {0};
    for (int i = 0; i < n; i++)
    {
        int a;
        cin >> a;
        cnt[a-1]++;
    }
    sort(cnt, cnt+n);
    int ans = 0;
    for (int i = 0; i < n-k; i++)
    {
        ans += cnt[i];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
n, k = [int(i) for i in input().split()]
s = [i + 1 for i in range(n)]
for i in range(k):
  d = int(input())
  ns = [int(j) for j in input().split()]
  for l in ns:
    s.remove(l) if l in s else None
print(len(s))

Measured memory_bytes: 9148
#include <stdio.h>

int main() {

	int W, a, b;

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

	if ((a <= b&&b <= a + W&&a + W <= b + W) || (b <= a&&a <= b + W&&b + W <= a + W)) {
		printf("0\n");
	}
	else if (a <= a + W&&a + W <= b&&b <= b + W) {
		printf("%d\n",b-a-W);
	}
	else if (b <= b + W&&b + W <= a&&a <= a + W) {
		printf("%d\n",a-b-W);
	}

	return 0;
}

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

int main(){
	int ans, t;
	char a;
	for(int i = 0;;i++){
		if(i%2 == 0){
			cin >> t;
			if(i == 0) ans = t;
			else{
				if(a == '+') ans += t;
				else if(a == '-') ans -= t;
				else if(a == '*') ans *= t;
				else ans /= t;
			}
		} else{
			cin >> a;
			if(a == '=') break;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1160
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
string ma[10];
int main(){
	int h,w,a,out=0;
	cin>>h>>w>>a;
	rep(i,h) cin>>ma[i];
	rep(i,(1<<h)) rep(j,(1<<w)){
		int b=0;
		rep(k,h) rep(l,w){
			if(ma[k][l]=='#' && !(i&(1<<k)) && !(j&(1<<l))) b++;
		}
		if(a==b) out++;
	}
	cout<<out<<endl;
}


Measured memory_bytes: 3636
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define N 3010
using namespace std;
int nxt[N<<1],to[N<<1],head[N],cnt;
int w[N];
void add(int u,int v)
{
	nxt[++cnt]=head[u];
	to[cnt]=v;
	head[u]=cnt;
}
bool dfs(int u,int pre)
{
	bool win=false;
	for(int i=head[u];i;i=nxt[i])
	{
		int v=to[i];
		if(v==pre || w[v]>=w[u]) continue;
		win|=!dfs(v,u);
	}
	return win;
}
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;i++) scanf("%d",&w[i]);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		add(u,v);
		add(v,u);
	}
	for(int i=1;i<=n;i++)
	if(dfs(i,0)) printf("%d ",i);
	return 0;
}


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

int main()
{

    int count[26]={0};
    char c;
    while(cin>>c){
        c = tolower(c);
        if(isalpha(c))  count[c - 'a']++;
    }
    for(int i=0;i<26;i++){
        cout<<static_cast<char>(i + 'a')<<" : "<<count[i]<<'\n';
    }
}



Measured memory_bytes: 3084
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
const int INF = 1e9;
const int MAX_V = 10000;
typedef pair<int, int>P;
    struct edge{
        int to, cap, rev;
    };
    vector<edge> G[MAX_V];//隣接リスト
    bool used[MAX_V];

    void add_edge(int from, int to, int cap){
        G[from].push_back((edge){to, cap, (int)G[to].size()});//from -> to
        G[to].push_back((edge){from, 0, (int)G[from].size() - 1});//to -> from
    }

    //増加パスを探す
    int dfs(int v, int t, int f){
        if(v == t) return f;
        used[v] = true;
        for (int i = 0; i < G[v].size(); ++i){
            edge &e = G[v][i];
            if(!used[e.to] && e.cap > 0){
                int d = dfs(e.to, t, min(f, e.cap));
                if(d > 0){
                    e.cap -= d;
                    G[e.to][e.rev].cap += d;
                    return d;
                }
            }
        }
        return 0;
    }
    //sからtへの最大流
    int max_flow(int s, int t){
        int flow = 0;
        while(1){
            memset(used, 0, sizeof(used));
            int f = dfs(s, t, INF);
            if(f == 0) return flow;
            flow += f;
        }
    }

int main(){
  int N;
  cin>>N;
  vector<P>A(N);
  vector<P>B(N);
  rep(i,N){
    int a,b;
    cin>>a>>b;
    A[i]=P(a,b);
  }
  rep(i,N){
    int c,d;
    cin>>c>>d;
    B[i]=P(c,d);
  }
  rep(i,N){
    add_edge(500,i,1);
    add_edge(N+i,501,1);
  }
  rep(i,N){
    rep(j,N){
      if(A[i].first<B[j].first&&A[i].second<B[j].second){
        add_edge(i,j+N,1);
      }
    }
  }
  cout<<max_flow(500,501);
  
}

Measured memory_bytes: 640
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor
from functools import reduce



INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


h, w = LI()
L = SR(h)
u = [[0]*w for _ in range(h)]
d = [[0]*w for _ in range(h)]
l = [[0]*w for _ in range(h)]
r = [[0]*w for _ in range(h)]
for y in range(h):
    l[y][0] = 1 if L[y][0] == '.' else 0
    for x in range(1, w):
        if L[y][x] == '.':
            l[y][x] = l[y][x-1] + 1



for y in range(h):
    r[y][w-1] = 1 if L[y][w-1] == '.' else 0
    for x in range(w-2, -1, -1):
        if L[y][x] == '.':
            r[y][x] = r[y][x+1] + 1



for x in range(w):
    u[0][x] = 1 if L[0][x] == '.' else 0
    for y in range(1, h):
        if L[y][x] == '.':
            u[y][x] = u[y-1][x] + 1


for x in range(w):
    d[h-1][x] = 1 if L[h-1][x] == '.' else 0
    for y in range(h-2, -1, -1):
        if L[y][x] == '.':
            d[y][x] = d[y+1][x] + 1



print(max([u[y][x] + d[y][x] + l[y][x] + r[y][x] for y in range(h) for x in range(w)]) - 3)

Measured memory_bytes: 327192
#include <bits/stdc++.h>
using namespace std;
#define int ll
#define ll long long
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353
#define MEM_SIZE 101010
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template <typename T>
void DEBUG(T e)
{
  if (DEBUG_OUT == false)
    return;
  std::cout << e << " ";
}
template <typename T>
void DEBUG(const std::vector<T> &v)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &e : v)
  {
    std::cout << e << " ";
  }
  std::cout << std::endl;
}
template <typename T>
void DEBUG(const std::vector<std::vector<T>> &vv)
{
  if (DEBUG_OUT == false)
    return;
  for (const auto &v : vv)
  {
    DEBUG(v);
  }
}
template <class T, class... Ts>
void DEBUG(T d, Ts... e)
{
  if (DEBUG_OUT == false)
    return;
  DEBUG(d);
  DEBUG(e...);
}
template <class T>
void corner(bool flg, T hoge)
{
  if (flg)
  {
    cout << hoge << endl;
    abort();
  }
}
template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }

void solve(void)
{
  int n, x;
  cin >> n >> x;
  vector<int> vec(n, 0);
  vector<int> cost(n, 0);
  for (int i = 0; i < n; i++)
  {
    cin >> vec[i];
    cost[i] = vec[i];
  }
  int res = 0;
  for (int i = 0; i < n; i++)
  {
    res += cost[i];
  }

  for (int i = 1; i <= n; i++)
  {
    int c = i * x;
    for (int j = 0; j < n; j++)
    {
      cost[j] = min(cost[j], vec[(n + j - i) % n]);
      // DEBUG((n + j - i) % n);
    }
    for (int i = 0; i < n; i++)
    {
      c += cost[i];
    }
    // DEBUG(cost);
    chmin(res, c);
  }
  cout << res << endl;

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

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

	std::vector<bool> a(8);
	int over = 0;
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		int t;
		std::cin >> t;
		if (t >= 3200) {
			over++;
		} else {
			if (!a[t / 400]) {
				a[t / 400] = true;
				cnt++;
			}
		}
	}

	std::cout << std::max(1, cnt) << std::endl;
	std::cout << (cnt + over) << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int N,A,B,C;
const int INF=1e9;

vector<int>l;

int dfs(int a,int b,int c,int d){
 if(d==N){
    if(min(a,min(b,c))==0) return INF;
    else return abs(a-A) + abs(b-B) + abs(c-C) - 30;
  }
  
  int MP1=dfs(a,b,c,d+1);
  int MP2=dfs(a+l[d],b,c,d+1)+10;
  int MP3=dfs(a,b+l[d],c,d+1)+10;
  int MP4=dfs(a,b,c+l[d],d+1)+10;
  
  return min(min(MP1,MP2),min(MP3,MP4));
}

  
int main(){
  
  cin>>N>>A>>B>>C;
  l.resize(N);
  for(int i=0;i<N;i++){
    cin>>l[i];
  }
  
  
  cout<<dfs(0,0,0,0)<<endl;

}

Measured memory_bytes: 256
n = int(input())
def divminus2(n):
    if n%2 == 1:
        q = n // -2 + 1
        r = n % 2
    else:
        q = n // -2
        r = 0
    return q,r

ans_list = []
while n != 0:
    q,r = divminus2(n)
    n = q
    ans_list.append(str(r))

ans_list.reverse()
if ans_list == []:
    print("0")
else:
    print("".join(ans_list))


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
namespace mp = boost::multiprecision;

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

	cout << (float)(n - n / 2) / n;

	return 0;
}

Measured memory_bytes: 888
#include<bits/stdc++.h>
using namespace std;
int main(){
  string x="abcdefghijklnmopqrstuvwxyz";
  string s;
  cin>>s;
  int h=0;
  for(int i=0;i<26;i++){
    int z=0;
    for(int j=0;j<s.size();j++){
      if(x[i]==s[j]){
        h++;
        z++;
        break;
      }
    }
    if(z==0){
      cout<<x[i];
      break;
    }
  }
  if(h==26){
    cout<<"None"<<endl;
  }
}

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

int main(){
  ll N;
  cin >> N;
  map<ll, ll> A;
  vector<ll> B(N);
  rep(i, N){
    ll a;
    cin >> a;
    A[a] += 1;
    B[i] = a;
  }
  
  ll whole = 0;
  for (auto p : A){
    ll num = p.second;
    whole += (num * (num -1)) / 2;
  }
  
  rep(i, N){
    ll num = A[B[i]];
    ll before = num * (num - 1) / 2;
    ll after = (num - 1) * (num - 2) / 2;
    cout << whole - before + after << endl;
  }
  
}


Measured memory_bytes: 11008
#include<iostream>

using namespace std;

int main(){

  int n;
  int i=1;
  cin>>n;
  while(1){
    while(1){
      int x=i;
      if(x%3==0){
	cout<<" "<<i;
	break;
      }
      while(1){
	if(x%10==3){
	  cout<<" "<<i;
	  break;
	}
	x/=10;
	if(!x) break; 
      }
      break;
    }
    if(++i>n) break;
  }
  cout<<endl;
}

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

int h, w, k, ans = 0;
vector<int> v;
vector<vector<char>> c(10, vector<char>(10));

void func(){
  if(v.size() == h + w){
    int sum = 0;
    rep(i, h){
      if(v[i] == 1) continue;
      rep(j, w){
        if(v[h + j] == 1) continue;
        if(c[i][j] == '#') sum++;
      }
    }
    if(sum == k) ans++;
    return;
  }
  v.push_back(0);
  func();
  v.pop_back();
  v.push_back(1);
  func();
  v.pop_back();
}

int main(){
  cin >> h >> w >> k;

  rep(i, h) rep(j, w) cin >> c[i][j];
  func();
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include<iostream>
#include<string>
#include<vector>
using namespace std;
vector<vector<int> > v(1100);
vector<string> s(1100);
void dfs(int i,int d)
{
	for (int j = 0; j < d; j++)
	{
		cout << ".";
	}
	cout << s[i] << endl;

	for (int j = 0; j < v[i].size(); j++)
	{
		dfs(v[i][j], d + 1);
	}
}
int main()
{
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int k;
		cin >> k;
		cin >> s[i];
		if (k != 0)
		{
			v[k - 1].push_back(i);
		}
	}
	dfs(0, 0);
	return 0;
}

Measured memory_bytes: 1424
/*package whatever //do not write package name here */

import java.io.*;
import java.io.BufferedReader; 
import java.io.IOException; 
import java.io.InputStreamReader; 
import java.util.Scanner; 
import java.util.StringTokenizer; 

class Main {
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st==null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }
                catch(IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
    }
	public static void main (String[] args) {
		FastReader ob = new FastReader();
		int n = ob.nextInt();
		System.out.println(n*(n+1)/2);
	
	}
}

Measured memory_bytes: 21332
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007  
#define fi first
#define se second
vector<int> adj[100002];
int main()
{  
	ll n,i,j;
	cin>>n;
	vector<ll> a(n);
	for(i=0;i<n;i++)
		cin>>a[i];
	ll b[n],c[n];
	map<ll,ll> mp;
	for(i=0;i<n;i++)
	{
		b[i]=a[i]+i;
		mp[b[i]]+=1;
		c[i]=i-a[i];
	}
	ll ans = 0;
	for(i=0;i<n;i++)
		if(mp[c[i]]!=0)
			ans+=mp[c[i]];
	cout<<ans;
}

Measured memory_bytes: 33092
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <queue>
#include <map>

int main(){
    std::string s, t;

    std::cin >> s >> t;

    s += s;

    for (int i = 0; i < s.length() / 2; i++) {
        if(s.substr(i, t.length()) == t){
            std::cout << "Yes" << std::endl;
            return 0;
        }
    }

    std::cout << "No" << std::endl;
    return 0;
}

Measured memory_bytes: 3148
def main():
    N, K = map(int, input().split())
    AB = []
    for i in range(N):
        a, b = map(int, input().split())
        AB.append([a, b])
    AB.sort(key=lambda x: x[0])

    c = 0
    for a, b in AB:
        if c <= K <= c + b:
            ans = a
            break
        c += b
    print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 21248
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    string s;
    cin>>s;
    if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
        cout<<"Bad"<<endl;
    }else{
        cout<<"Good"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
    long long dm_sum = 0;
    int n, ans = 0, b;
    cin >> n;
    vector<int> a(n);
    vector<int> d(n);
    for(int i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
    for(int i = 0; i < n; i++){
        scanf("%d", &b);
        d[i] = a[i] - b;
        if(d[i] < 0){
            dm_sum += d[i];
            ans++;
        }
    }
    sort(d.begin(), d.end());
    reverse(d.begin(), d.end());
    for(int i = 0; dm_sum < 0 && i < n; i++){
        dm_sum += d[i];
        ans++;
    }
    cout << (dm_sum < 0 ? -1 : ans) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,k;
int a[600];
int msum[600],psum[600];
vector<int> divisor(int x){
  vector<int> res;
  for(int i=1;i*i<=x;i++){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i) res.push_back(x/i);
    }
  }
  return res;
}

int main()
{
  int res=1;
  cin >> n >> k;
  for(int i=0;i<n;++i){
    cin >> a[i];
  }
  int sum=0;
  for(int i=0;i<n;++i){
    sum+=a[i];
  }
  vector<int> div = divisor(sum);
  int s = div.size();
  for(int i=0;i<s;++i){
    int x = div[i];
    vector<int> mi,pl;
    for(int j=0;j<n;++j){
      int v = a[j]-a[j]/x*x;
      if(v==0) continue;;
      mi.push_back(v);
      pl.push_back(x-v);      
    }
    sort(mi.begin(), mi.end());
    sort(pl.begin(), pl.end());
    msum[0]=0;
    psum[0]=0;
    for(int l=0;l<mi.size();++l){
      msum[l+1]=msum[l]+mi[l];
    }
    for(int l=0;l<pl.size();++l){
      psum[l+1]=psum[l]+pl[l];
    }
    int ms = mi.size();
    for(int l=0;l<ms;++l){
      if(msum[l]>k) break;
      if(msum[l]==psum[ms-l]){
	res = max(res,x);
	break;
      }
    }
  }
  cout << res << "\n";
  
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#define Max 100000


int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int i,H,A[Max+1];
  
  scanf("%d",&H);
  
  for(i=1;i<=H;i++) scanf("%d",&A[i]);
  for(i=1;i<=H;i++){
    printf("node %d: key = %d, ",i,A[i]);
    if(parent(i) >= 1)printf("parent key = %d, ",A[parent(i)]);
    if(left(i) <= H)printf("left key = %d, ",A[left(i)]);
    if(right(i) <= H)printf("right key = %d, ",A[right(i)]);
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2036
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int X = sc.nextInt();
        int[] A = new int[N];
        
        for(int i = 0; i < M; i++){
            A[i] = sc.nextInt();
        }
        
        int count = 0;
        for(int i = 0; i < M; i++){
            if(X > A[i]){
                count++;
            }
        }
        System.out.println(Math.min(count,M-count));
    }
}


Measured memory_bytes: 23124
#include<stdio.h>
int n,ans;char a[200001];
main()
{
	scanf("%d%s",&n,a);
	for(register int l=0,r=n-1;l<r;)
	{
		for(;l<n&&a[l]=='R';++l);
		for(;r&&a[r]=='W';--r);
		if(l<r){++ans;++l;--r;}
	}
	printf("%d",ans);
}

Measured memory_bytes: 1920
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<iomanip>
#include<set>
#include<queue>

using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0;i<n;i++)
		cin >> a[i];

	int bef=0;
	for(int i=0;i<n;i++)
	{
		if(bef>a[i])
		{
			cout << "No" << endl;
			return 0;
		}
		else if(bef==a[i])
			bef=a[i];
		else
			bef=a[i]-1;
	}

	cout << "Yes" << endl;



}


Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(){
	int n;
	cin >> n;
	string s, t;
	cin >> s >> t;
	for (int i = 0; i < n; i++){
		cout << s[i] << t[i];
	}
	cout << endl;

	return 0;
}


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

using namespace std;

int main()
{
	static bool era[1000000];
	for(int i=1;i<1000000;i++)	era[i]=true;
	for(int i=2;i<1000;i++){
		if(era[i])	for(int j=i*i;j<1000000;j+=i)	era[j]=false;
	}

	for(int n,bud;scanf("%d%d",&n,&bud),n;){
		int menu[30];
		for(int i=0;i<n;i++)	scanf("%d",menu+i);

		static bool knap[1000001];
		knap[0]=true;
		for(int i=1;i<=bud;i++)	knap[i]=false;
		for(int i=0;i<n;i++){
			for(int j=0;j<bud;j++){
				if(knap[j] && j+menu[i]<=bud)
					knap[j+menu[i]]=true;
			}
		}

		bool b=false;
		for(int i=bud;i>=0;i--){
			if(knap[i] && era[i]){
				printf("%d\n",i);
				b=true;
				break;
			}
		}
		if(!b)	puts("NA");
	}

	return 0;
}

Measured memory_bytes: 2712
#include<iostream>
#include<cstdio>
using namespace std;
const int N=1000005;
const int MOD=1000000007;
int n,h,d;
long long ksm(long long a,long long b)
{
	long long res=1;
	while(b)
	{
		if(b&1) res=res*a%MOD;
		a=a*a%MOD,b>>=1;
	}
	return res;
}
long long fac,sum;
long long s[N],f[N];
int main()
{
	scanf("%d%d%d",&n,&h,&d);
	fac=1;
	for(int i=1;i<=n;i++)
		fac=fac*i%MOD,sum=(sum+fac)%MOD;
	s[0]=f[0]=1;
	for(int i=1;i<=h+1;i++)
	{
		long long p=(s[i-1]-(i-d-1>=0?s[i-d-1]:0)+MOD)%MOD;
		f[i]=p*sum%MOD;
		s[i]=(s[i-1]+f[i])%MOD;
	}
	printf("%lld",f[h]*fac%MOD*ksm(sum,MOD-2)%MOD);
	return 0;
}

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

int main() {
	long h,a=0,n,i,j;
	cin>>h>>n;
	for(i=0;i<n;i++)
	{
		cin>>j;
		a+=j;
	}
	if(a>=h) cout<<"Yes";
	else cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define Khela ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long int
#define llu long long unsigned int
#define pf printf
#define sf scanf
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define pii pair<int ,int>
#define PII pair<ll ,ll>
 
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
 
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
int Set(int N,int pos){return N=N | (1<<pos);}
int reset(int N,int pos){return N= N & ~(1<<pos);}
bool check(int N,int pos){return (bool)(N & (1<<pos));}
const int Max=1e9+100;
const ll  MAX=1e18+500;
const int sz=1e3+100;
 
int main()
{
    Khela
    ll a,b,c,i,j,k,q,p,x,y,ct,ct1,m,l,r,x1,y1,mn,h,sum1,in,z,mid,n,mx,tmp;
    char ch;
    double d;
    string str1,str2,str;
    bool bl,bl1;
    int t,cs=1;
    vector<ll> sir,temp,inp;
    while(cin>>a>>b>>k)
    {
        sir.clear(),temp.clear(),inp.clear();
        for(i=0;i<a;i++){
            cin>>x;
            sir.push_back(x);
        }

        for(j=0;j<b;j++){
            cin>>x;
            temp.push_back(x);
        }

        sort(sir.begin(),sir.end());
        sort(temp.begin(),temp.end());

        for(i=0;i<k;i++){
            cin>>x;
            ll mn=MAX;
            p=upper_bound(sir.begin(),sir.end(),x)-sir.begin();
            if(p-1>=0){
                y=abs(x-sir[p-1]);
                tmp=sir[p-1];
                q=upper_bound(temp.begin(),temp.end(),tmp)-temp.begin();
                if(q-1>=0) mn=min(mn,y+abs(temp[q-1]-tmp)),mn=min(mn,abs(temp[q-1]-x)+abs(temp[q-1]-sir[p-1]));
                if(q<temp.size()) mn=min(mn,y+abs(temp[q]-tmp)),mn=min(mn,abs(temp[q]-x)+abs(temp[q]-sir[p-1]));
            }
            if(p<sir.size()){
                y=abs(x-sir[p]);
                tmp=sir[p];
                q=upper_bound(temp.begin(),temp.end(),tmp)-temp.begin();
                if(q-1>=0) mn=min(mn,y+abs(temp[q-1]-tmp)),mn=min(mn,abs(temp[q-1]-x)+abs(temp[q-1]-sir[p]));
                if(q<temp.size()) mn=min(mn,y+abs(temp[q]-tmp)),mn=min(mn,abs(temp[q]-x)+abs(temp[q]-sir[p]));
            }

            inp.pb(mn);
        }

        for(auto xx: inp) cout<<xx<<endl;

        
    }





}

Measured memory_bytes: 3828
#include<stdio.h>

int main(void){
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);
	
	int min = a+b;
	
	if(a==b==c){
		printf("%d\n",min);
	}else if(min>=a+c){
		min = a+c;
		
		if(min>b+c){
			min = b+c;
		}
		printf("%d\n",min);
	}else if(min>=b+c){
		min = b+c;
		
		if(min>a+c){
			min = a+c;
		}
		printf("%d\n",min);
	}else{
		printf("%d\n",min);
	}
}

Measured memory_bytes: 128
(defun main ()
  (let ((x (read))
        (n (read))
        (p)
        (ans))
    (dotimes (i n)
      (push (read) p))
    (setf ans (do ((i x (1- i))
                   (j x (1+ j)))
                  ((or (not (member i p)) (not (member j p))) (list i j))))
    (if (member (first ans) p)
        (second ans)
        (first ans))))
    



(format t "~a~%" (main))


Measured memory_bytes: 24340
#include<stdio.h>

int main(){

int m,f,r;
while(1){
scanf("%d %d %d",&m,&f,&r);
  if(m==-1 && f == -1 && r == -1){
  break;
  }
int sum;
sum = m+f;

if(m == -1 || f == -1){
  printf("F\n");
}else if(sum >= 80 ){
  printf("A\n");
}else if(sum >= 65 && sum < 80){
  printf("B\n");
}else if(sum >= 50 && sum < 65 || sum >= 30 && sum < 50 && r >= 50){
  printf("C\n");
}else if(sum >= 30 && sum < 50){
  printf("D\n");
}else if(sum < 30){
  printf("F\n");
}

}
return 0;
}


Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, a, b; cin >> n >> a >> b;
	vi cnt(3);
	
	rep(i, n){
		int p; cin >> p;
		if(p <= a) cnt[0]++;
		else if(p <= b) cnt[1]++;
		else cnt[2]++;
	}
	cout << min(
		{cnt[0], cnt[1], cnt[2]}) << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int a;
	int b;
	int sum = 0;
	int i;

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


	for(i = 1; i < (b-a); i++)
		sum+=i;
	
	printf("%d", (sum-a));
	
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e10;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}



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

  int ans=0;
  rep(i,n-1){
    int diff=x[i+1]-x[i];
    ans+=diff*a<b?diff*a:b;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (int)n; i++)
int H, W, D, Q;

int main(){
  int H, W, D, Q;
  cin >> H >> W >> D;
  int px[H*W+1], py[H*W+1];
  int d[H*W+1];
  rep(i, H){
    rep(j, W){
    int a;
    cin >> a;
    px[a] = i, py[a] = j;
    }
  }
  for(int i = D+1; i <= H*W; i++){
    d[i] = d[i-D] +  abs(px[i]-px[i-D])+ abs(py[i]-py[i-D]);
  }
  cin >> Q;
  int ans[Q];
  rep(i, Q) {
    int L, R;
    cin >> L >> R;
    ans[i] = d[R] - d[L];
  }
  rep(i, Q) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 2560
import collections

N,K = map(int,input().split())
A = list(map(int,input().split()))
type = len(set(A))
con = 0

if K >= type:
  print(0)
  
else:
  C = collections.Counter(A)
  C = C.most_common()
  
  for i in range(1,type - K + 1):
    con += C[-i][1]
  
  print(con)

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

int main(){
	int N, K;
	cin >> N >> K;
	int cnt = 0, ans;
	while(cnt < N){
		if(cnt == 0) cnt += K;
		else cnt += K-1;
		ans++;
	}
	cout << ans << endl;
	
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int n; scanf("%d",&n);
	int pry[n+1]; for (int i=1; i<=n; i++) scanf("%d",&pry[i]);
	
	int error = 0;
	for (int i=1; i<=n; i++) {
		if (pry[i] != i) error++;
	}
	if ((error == 0) || (error == 2)) {
		puts("YES");
	} else {
		puts("NO");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i< (n);i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, ll> pil;

//priority_queue<int, vector<int>, greater<int>> min_heap;
//long long ccw(const Point& A, const Point& B, const Point& C) {
//	return 1LL * (B.x - A.x)*(C.y - A.y) - 1LL * (B.y - A.y)*(C.x - A.x);
//}
int main() { // E 
	ios_base::sync_with_stdio(false); cin.tie(NULL); /*cout.tie(NULL);*/
	int n; cin >> n;
	double ans = 0.0;

	for (int i = 0; i < n; i++) {
		double x; cin >> x;
		ans += (double)1 / x;
	}
	ans = (double)1 / ans;
	printf("%.12f", ans);


	

}


Measured memory_bytes: 256
# coding: utf-8
import sys

stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline().rstrip() # ignore trailing spaces


def floor(a,b):
    return int(a//b)


def main():
    a,b,n = na()
    if n >= b-1:
        x = b-1
    else:
        x = n
    print(floor(a*x,b) - a*floor(x,b))
    return


if __name__ == '__main__':
    main()

Measured memory_bytes: 61916
import sys
import math
X, K, D = map(int, input().split())
if X == 0 and K % 2 == 0:
    print(X)
    sys.exit()
elif X == 0 and K % 2 == 1:
    print(D)
    sys.exit()

if abs(X // D) >= K:
    ans = X - (D * K) * (X // abs(X))
    ans = abs(ans)
else:
    K -= abs(X//D)
    ans = X - (D * abs(X//D)) * (X // abs(X))
    if K % 2 == 0 and K == 0:
        ans = abs(ans)
    elif K % 2 == 0 and K >= 2:
        ans = min([abs(ans), abs(ans-D*2), abs(ans+D*2)])
    else:
        ans = min(abs(ans+D), abs(ans-D))
print(ans)


Measured memory_bytes: 62060
#include<bits/stdc++.h>
#include<cstdlib>
#define ll long long int
using namespace std;
int main()
{
    ll n;
    cin>>n;
    if(n%1000==0)
    	cout<<0;
    else
    {
    	ll res=(n/1000)+1;
    	cout<<(1000*res)-n;
	}
}

Measured memory_bytes: 3628
#include <stdio.h>
int main(){
    // Your code here!
    int N;
    int L;
    int aji=0;
    scanf("%d %d",&N,&L);
    for(int i=0;i<N;i++){
            aji+=L+i;
    }
    if(L<0 && L+N <= 0){
        aji -= L+N-1;
    }else if(L>0){
        aji -= L;
    }
    printf("%d",aji);
  	return 0;
}


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

int main() {
    ios_base::sync_with_stdio(false);	
    cin.tie(0);
	int n;
	cin >> n;
	vector<int> a(n - 1);
	map<int, int> ans;
	for (int i = 0; i < n - 1; i++) {
		cin >> a[i];
	}
	for (int i = 0; i < n; i++) {
		ans[a[i]]++;
	}
	for (int i = 1; i <= n; i++) {
		cout << ans[i] << "\n";
	}
	return 0;
}


Measured memory_bytes: 13516
n, m = map(int, input().split())
a = [input() for i in range(n)]
b = [input() for i in range(m)]

flag = [[True for j in range(n)] for i in range(n)]
for i in range(n):
    for j in range(n):
        for k in range(min(m, i + 1)):
            for l in range(min(m, j + 1)):
                if a[i][j] != b[k][l]:
                    flag[i - k][j - l] = False

for i in range(n-m+1):
    for j in range(n-m+1):
        if flag[i][j]:
            print("Yes")
            exit()

print("No")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define FAST ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
#define ll long long
const int mod = 1e9 + 7;
int h, w;
bool isValid(int x, int y)
{
    return (x >= 0 and x<h and y >= 0 and y < w);
}
void findAns()
{

    cin >> h >> w;

    int grid[h][w];
    char ch;

    for (int i = 0; i < h; i++)
        for (int j = 0; j < w; j++)
        {
            cin >> ch;
            ch == '.' ? grid[i][j] = 0 : grid[i][j] = 1;
        }

    int dp[h][w];
    memset(dp, 0, sizeof(dp));
    dp[0][0] = 1;

    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            if (i == 0 and j == 0) continue;
            else
            {
                if (isValid(i, j - 1) and grid[i][j - 1] == 0)
                {
                    dp[i][j] = (dp[i][j] % mod +  dp[i][j - 1] % mod) % mod;
                }
                if (isValid(i - 1, j) and grid[i - 1][j] == 0)
                    dp[i][j] = (dp[i][j] % mod + dp[i - 1][j] % mod) % mod;

            }

        }
    }
    cout << dp[h - 1][w - 1] ;


}
int main()
{


    FAST;

    // ll int t;
    // cin >> t;
    // while (t--)
    findAns();

    return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define ll long long
 
int main() {
  int A, B, C;
  cin >> A >> B >> C;
  int a = 0;
  for(int i = min(A,B); i > -1; i--){
    if(A % i == 0 && B % i == 0) a++;
    if(a == C){
      cout << i << endl;
      break;
    }
  }
}

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

priority_queue<int> B;
int main() {
	int N, H, a, t, mx=0; cin >> N >> H;
	for(int i=0; i<N; ++i){
	    cin >> a >> t;
	    mx=max(mx, a);
	    B.push(t);
	}
	int ans=0;
	while(B.size()>0 && B.top()>mx){
	    H -= B.top();
	    B.pop();
	    ++ans;
	    if(H<=0){
	        cout << ans << endl;
	        return 0;
	    }
	}
	ans += (H+mx-1)/mx;
	cout << ans << endl;
	return 0;
}


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

// @author: pashka

int main() {
    ios::sync_with_stdio(false);

    int n;
    cin >> n;
    vector<int> a(n + 1);
    for (int i = 0; i <= n; i++) cin >> a[i];

    if (n == 0) {
        if (a[0] != 1) {
            cout << -1;
        } else {
            cout << 1;
        }
        return 0;
    }
    if (a[0] != 0) {
        cout << -1;
        return 0;
    }

    vector<long> b(n + 1);
    for (int i = n; i > 0; i--) {
        b[i - 1] = b[i] + a[i];
    }
    if (b[0] < 1) {
        cout << -1;
        return 0;
    }
    b[0] = 1;
    for (int i = 0; i < n; i++) {
        b[i + 1] = min(b[i + 1], 2 * b[i] - a[i + 1]);
        if (b[i + 1] < 0) {
            cout << -1;
            return 0;
        }
    }
    long s = 0;
    for (int i = 0; i <= n; i++) s += a[i] + b[i];
    cout << s;

    return 0;
}

Measured memory_bytes: 4528
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
#define maxN 100007
using namespace std;
int main()
{
    fastio;
    vector<ll>adj[maxN];
    ll n=0,m=0;
    cin>>n>>m;
    queue<ll>q;
    vector<bool>used(maxN);
    vector<ll>sign(maxN);
    for(ll i=0;i<m;++i){
        ll u=0,v=0;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    q.push(1);
    sign[1]=0;
    used[1]=true;
    while(!q.empty()){
        ll i=q.front();
        q.pop();
        for(auto j:adj[i]){
            if(!used[j]){
                used[j]=true;
                q.push(j);
                sign[j]=i;
            }
        }
    }
    vector<ll>ans;
    bool possible=true;
    for(ll i=2;i<=n;++i){
        if(!used[i]){
            possible=false;
            break;
        }
        else
            ans.pb(sign[i]);
    }
    if(!possible) cout<<"No\n";
    else{
        cout<<"Yes\n";
        for(auto i:ans) cout<<i<<"\n";
    }
    return 0;
}


Measured memory_bytes: 14104
#include<iostream>
#include<iomanip>

#include<vector>
#include<queue>
#include<set>
#include<map>
#include<string>

#include<algorithm>
#include<cmath>

using namespace std;
typedef long long ll;
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 INF = 1LL << 60;
typedef pair<int, int> P;

int main() {

    int n,a,b;
    cin >> n >> a >> b;
    chmin(b,a * n);
    cout << b << "\n";



}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main ()
{
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    string t;
    cin>>t;
    sort(t.begin(),t.end());
    reverse(t.begin(),t.end());
    if (s<t) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
/**akshaykumar99**/
 
#include<bits/stdc++.h>
using namespace std;
 
#define f(i,x,n) for(i=x;i<n;i++)
#define pu push_back           
#define pp pop_back
#define mp(a,b) make_pair(a,b)
#define F first
#define S second
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define IOS() ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
const int MOD=1e9+7 ;
const long long INF=INT_MAX;
const long long LINF=LLONG_MAX;
const long long N=2e5+1;
 
typedef long long ll;
typedef long double ld;
typedef vector<ll> ivc;
typedef pair<ll,ll> ipr;
int main()
{
    IOS();
   
    int n,i,k,ans=0;
    cin>>n>>k;
    int a[n];
    f(i,0,n)
    {
    	int x;
    	cin>>x;
    	if(x>=k)
    		ans++;
    }
    cout<<ans<<'\n';

    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <vector>
#include <string>
#include <iostream>
#include <fstream>
#include <sstream>
#include <list>
#include <algorithm>
#include <sstream>
#include <set>
#include <math.h>
#include <cmath>
#include <map>
#include <stack>
#include <queue>
#include <stdio.h>
#include <string.h>
#include <numeric>
 
using namespace std;

string s,t;
 
int main(){
 
cin>>s;

t="CODEFESTIVAL2016"; int ans=0;

for(int i=0; i<s.size(); i++){
  if(s[i]!=t[i]) ans++;
}
    
 printf("%d\n",ans);
  

return 0;
 
}

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

typedef long long i64;

template<class T>
void selectMin(T & x, const T & y)
{
	if (x > y)
		x = y;
}
template<class T>
void selectMax(T & x, const T & y)
{
	if (x < y)
		x = y;
}

const int MAXN = 2e5 + 10;
const int MAXLOG = 20 + 5;
const int PINF = 0x3F3F3F3F;

const char NSOL[] = "Impossible";
const char FSOL[] = "Possible";

int N, V;
int lg2 = -1;
int exp_2[MAXLOG];
int R[MAXLOG][MAXN];
int cnt[MAXLOG];
int dp1[MAXN << 3], dp2[MAXN << 3];
int A[MAXN];

void prepare()
{
	exp_2[0] = 1;
	for (int i = 1; i < MAXLOG; i++)
		exp_2[i] = exp_2[i - 1] * 2;
}

int main()
{
	prepare();
	cin >> N >> V;
	for (int i = 1; i <= N; i++)
		cin >> A[i];

	int x = V * 2;
	while (x)
	{
		x /= 2, lg2++;

		// Split segments
		for (int i = 1; i < N; i++)
		{
			if (A[i + 1] - A[i] <= x)
				continue;
			R[lg2][++cnt[lg2]] = i;
		}
		R[lg2][++cnt[lg2]] = N;
	}

	if (cnt[0] > lg2 + 1)
	{
		for (int i = 1; i <= N; i++)
			puts(NSOL);
		return 0;
	}

	for (int s = 0; s < exp_2[lg2]; s++)
		dp2[s] = N + 1;
	for (int s = 0; s < exp_2[lg2]; s++)
		for (int i = 1; i <= lg2; i++)
		{
			if (s & exp_2[i - 1])
				continue;
			selectMax(dp1[s | exp_2[i - 1]],
					*upper_bound(R[i] + 1, R[i] + cnt[i] + 1, dp1[s]));
			selectMin(dp2[s | exp_2[i - 1]],
					R[i][lower_bound(R[i] + 1, R[i] + cnt[i] + 1, dp2[s] - 1)
							- R[i] - 1] + 1);
		}

	for (int i = 1; i <= cnt[0]; i++)
	{
		bool solution = false;
		for (int s = 0; s < exp_2[lg2]; s++)
			if (dp1[s] >= R[0][i - 1] && dp2[exp_2[lg2] - s - 1] <= R[0][i] + 1)
			{
				solution = true;
				break;
			}

		for (int j = R[0][i - 1] + 1; j <= R[0][i]; j++)
			puts(solution ? FSOL : NSOL);

	}

}


Measured memory_bytes: 22656
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int solve(int n){
    int ans = 0;
    int i, j, k, l;
    if(n > 36) return 0;
    for(i=0; i<=min(n, 9); i++){
      for(j=0; j<=min(n-i, 9); j++){
        for(k=0; k<=min(n-i-j, 9); k++){
          if(0 <= n-i-j-k && n-i-j-k <= 9) {
          	ans++;
          	//cout << n-i-j-k << endl;
          }
        }
      }
    }
    return ans;
}




int main() {
    ios::sync_with_stdio(false);
    int n;
    while(cin >> n){
      cout << solve(n) << endl;
    }
    return 0;
}

Measured memory_bytes: 1192
import pprint

H, W = list(map(int, input().split()))
A = []
for h in range(H):
    A.append([s for s in input()])
x, y = 0, 0
goal_x, goal_y = W - 1, H - 1
count = 0
while not (x == goal_x and y == goal_y):
    for diff_x, diff_y in [(1, 0), (0, 1), (-1, 0), (0, -1)]:
        tmp_x = x + diff_x
        tmp_y = y + diff_y
        if tmp_x < 0 or tmp_x >= W or tmp_y < 0 or tmp_y >= H:
            continue
        if A[tmp_y][tmp_x] == "#":
            if diff_x == -1 or diff_y == -1:
                print("Impossible")
                exit()
            A[y][x] = "."
            x += diff_x
            y += diff_y
            # print(y, x)
            # pprint.pprint(A)
            break
    count += 1
    if (W + H - 2) < count:
        print("Impossible")
        exit()

A[goal_y][goal_x] = "."
# pprint.pprint(A)

for h in range(H):
    for w in range(W):
        if A[h][w] == "#":
            print("Impossible")
            exit()
print("Possible")


Measured memory_bytes: 3572
#include<iostream>

using namespace std;

int main () {
  int n, m;
  cin >> n >> m;
  int a[n];
  int total = 0;
  for (int i = 0; i < n; ++i) {
  	  cin >> a[i];
     total += a[i];
  }
  int cnt = 0;
  for (int i = 0; i < n; ++i) {
  	if (a[i] * 4 * m >= total)
      cnt++;
  }
  if (cnt >= m) cout << "Yes\n";
  else cout << "No\n";
  
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

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

	for (int ix = 0; ix <= n; ++ix) {
		for (int i = 0; i <= n - ix; ++i) {
			if (ix * 10000 + i * 5000 + (n - ix - i) * 1000 == y) {
				printf("%d %d %d\n", ix, i, n - ix - i);
				return 0;
			}
		}
	}

	printf("-1 -1 -1\n");
}

Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <tuple>
typedef long long ll;
#define N_MAX 21
using namespace std;
int main(){
    int n;
    cin >> n;
    int a[N_MAX];
    int b[N_MAX];
    int c[N_MAX];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int i=0;i<n;i++){
        cin>>b[i];
    }
    for(int i=0;i<n-1;i++){
        cin>>c[i];
    }
    int sum_happy=0;
    for(int i=0;i<n;i++){
        sum_happy+=b[a[i]-1];
        if(i>0){
            if(a[i]==a[i-1]+1){
              sum_happy += c[a[i-1]-1];  
            }
        }
    }

    cout<<sum_happy<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

struct Pt{
	double x,y;
	Pt(){}
	Pt(double x,double y) : x(x),y(y){}
	Pt operator+(const Pt &a) const {return Pt(x+a.x,y+a.y);}
	Pt operator-(const Pt &a) const {return Pt(x-a.x,y-a.y);}
	Pt operator*(const Pt &a) const {return Pt(x*a.x-y*a.y,x*a.y+y*a.x);}
	Pt operator*(const double &k) const {return Pt(x*k,y*k);}
	Pt operator/(const double &k) const {return Pt(x/k,y/k);}
	double abs() const {return sqrt(x*x+y*y);}
	double dot(const Pt &a) const {return x*a.x+y*a.y;}
	double det(const Pt &a) const {return x*a.y-y*a.x;}
};

int main() {
	Pt a,b,c;
	int n;
	n=in();
	int i;
	for(i=0;i<n;i++){
		cin>>a.x>>a.y>>b.x>>b.y>>c.x>>c.y;
		Pt bc=c-b,ca=a-c,ab=b-a;
		Pt res=(b+c-bc*Pt(0,1)*ca.dot(ab)/ca.det(ab))/2;
		printf("%.3f %.3f %.3f\n",res.x,res.y,(res-a).abs());
	}
	return 0;
}

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

int main()
{
	int n;
	string s;
	cin >> n >> s;
	int e = 0, w = 0;
	for(auto c : s) if(c == 'E') ++e;
	int ans = e;
	for(auto c : s){
		if(c == 'E') --e;
		ans = min(ans, e + w);
		if(c == 'W') ++w;
	}
	cout << ans << endl;
	return 0;
}

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

class Main {

    public static void main(String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] A = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                A[i] = sc.nextLong();
        }
        long[] B = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                B[i] = sc.nextLong();
        }
        long[] C = new long[(int)(N-1)];
        for(int i = 0 ; i < N-1 ; i++){
                C[i] = sc.nextLong();
        }
        solve(N, A, B, C);
    }

    static void solve(long N, long[] A, long[] B, long[] C){
        long ans = 0;
        long ex = N+1;
        for (long a : A) {
            ans += B[(int)(a) - 1];
            if (a - ex == 1) {
                ans += C[(int)(ex) - 1];
            }
            ex = a;
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int main(){
	vector<int> v;
	for(int i=0;i<5;++i){
		int ele=0;
		cin>>ele;
		v.push_back(ele);
		if(ele==0){
			cout<<i+1;
			}
		}
	return 0;
	}


Measured memory_bytes: 3628