akhauriyash/Code-Regression huggingface dataset:
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif

#include <bits/stdc++.h>

using namespace std;

mt19937 mrand(random_device{} ()); 

int rnd(int x) {
  return mrand() % x;
}

typedef long double ld;
typedef long long ll;

#ifdef DEBUG
#define eprintf(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
#else
#define eprintf(...) ;
#endif

#define pb push_back
#define mp make_pair
#define sz(x) ((int) (x).size())
#define TASK "text"

const int inf = (int) 1.01e9;
const ld eps = 1e-9;
const ld pi = acos((ld) -1.0);

const int mod = (int) 1e9 + 7;

void add(int &x, int y) {
  if ((x += y) >= mod) {
    x -= mod;
  }
}

int mult(int x, int y) {
  return (long long) x * y % mod;
}

int myPower(int x, int pw) {
  int res = 1;
  for (; pw; pw >>= 1) {
    if (pw & 1) {
      res = mult(res, x);
    }
    x = mult(x, x);
  }
  return res;
}

void precalc() {
}


int n;
const int maxn = (int) 1e5 + 10;
int a[maxn];

int odd;

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

void solve() {
  printf(odd ? "NO\n" : "YES\n");
}

int main() {
  precalc();
#ifdef LOCAL
  freopen(TASK ".out", "w", stdout);
  assert(freopen(TASK ".in", "r", stdin));
#endif

  while (1) {
    if (!read()) {
      break;
    }
    solve();
#ifdef DEBUG
    eprintf("Time %.2f\n", (double) clock() / CLOCKS_PER_SEC);
#endif
  }
  return 0;
}


Measured memory_bytes: 768
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
x, t = M()
print(max(0, x-t))

Measured memory_bytes: 74528
#include <bits/stdc++.h>
#define debug(x) cout << #x << " -> " << x << endl
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;


void testcase(){
	int n,ans = 0,a[200005];
	cin >> n;
	for(int i{0};i < n;i++){
		cin >> a[i];
		if(i % 2 == 0 && (a[i]&1)){
			ans++;
		}
	}
	cout << ans << "\n";
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t = 1;
	while(t--){
		testcase();
	}
	return 0;
}


Measured memory_bytes: 3656
#include <iostream>

using namespace std;

int main() {
	int n, d;
	long long ans;
	std::cin >> n;
	int a[n];
	for(int i=0; i<n; i++) std::cin >> a[i];

	ans = 0;

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

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <ios>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
using namespace std;
typedef long long ll;
#define mp make_pair;
#define pb push_back;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll s;
  cin >> s;
  vector<ll> v;
  v.push_back(s);
  while(1){
    if(s%2==0){
      s /= 2;
    }
    else{
      s = s*3+1;      
    }
    rep(i, v.size()){
      if(v[i] == s) {
	cout << v.size()+1 << endl;
	return 0;
      }
    }
    v.push_back(s);
  }
  return 0;

}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <tuple>
#include <sstream>
#include <typeinfo>
#include <fstream>
#include <random>
#include <queue>
#include <deque>
#include <iterator>
#include <map>
#include <functional>
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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define pb(a) push_back(a)
#define llong long long
#define INF 1145141919
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;
int dy[] = { 1, 0, -1, 0 };
int dx[] = { 0, 1, 0, -1 };
template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
int n;
const int N_MAX = 101;
string w[N_MAX];
string solve() {
	cin >> n;
	REP(i, n) {
		cin >> w[i];
	}
	for (int i = 0; i < n-1; i++) {
		for (int j = i+1; j < n; j++) {
			if (w[i] == w[j]) return "No";
		}
	}

	string firsts = w[0];					// 最初の文字列
	char last = firsts[firsts.size()-1];	// 当該文字列の最後の文字

	for (int i = 1; i < n; i++) {
		firsts = w[i];
		char first = firsts[0];
		if (first == last) {
			last = firsts[firsts.size() - 1];
		} else {
			return "No";
		}
	}
	return "Yes";
}
int main() {
	cout << solve() << endl;
	return 0;
}

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

int n, a[1025][1025], vis[1025];
bool flag;
bool ok() {
  for (int i = 1; i <= n; i++)
    if (a[i][0] != n) return 0;
  return 1;
}

int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n - 1; ++j) cin >> a[i][j];
    a[i][0] = 1;
  }
  for (int z = 1; z <= 0x3f3f3f3f; z++) {
    if (ok()) {
      cout << z - 1 << '\n';
      return 0;
    }
    flag = 0;
    // memset(vis, 0, sizeof vis);
    for (int i = 1; i <= n; i++) {
      if (vis[i] == z || a[i][0] == n) continue;
      int x = a[i][a[i][0]];
      if (a[x][a[x][0]] == i && vis[i] != z && vis[x] != z) {
        a[i][0]++;
        a[x][0]++;
        vis[i] = vis[x] = z;
        a[i][0]++;
        a[i][0]--;
        flag = 1;
      }
    }
    if (!flag) {
      cout << -1 << '\n';
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 4352
import sys,bisect

from sys  import stdin,stdout

from bisect import bisect_left,bisect_right,bisect,insort,insort_left,insort_right

from math import gcd,ceil,floor,sqrt

from collections import Counter,defaultdict,deque,OrderedDict

dx=[-1,1,0,0]
dy=[0,0,1,-1]


sys.setrecursionlimit(10**6)
INF = float('inf')
MOD = 998244353
mod = 10**9+7

def isPrime(n):
    if (n <= 1) :return False
    if (n <= 3) :return True
    if (n%2 == 0 or n%3 == 0):return False
    for i in range(5,ceil(sqrt(n))+1,6):
        if (n%i==0 or n%(i+2)==0):
            return False
    return True

def st():
    return list(stdin.readline().strip())

def inp():
    return int(stdin.readline())

def li():
    return list(map(int,stdin.readline().split()))

def mp():
    return map(int,stdin.readline().split())

def pr(n):
    stdout.write(str(n)+"\n")


def soe(limit):
    l=[1]*(limit+1)
    l[0]=0
    l[1]=0
    prime=[]
    for i in range(2,limit+1):
        if l[i]:
            for j in range(i*i,limit+1,i):
                l[j]=0
    
    for i in range(2,limit+1):
        if l[i]:
            prime.append(i)
    return prime

                
def gcd(a,b):
    while b:
        a=a%b
        b,a=a,b
    return a

def power(a,n):
    r=1
    while n:
        if n&1:
            r=(r*a)
        a*=a
        n=n>>1
    return r
    
def solve():
    s=input()
    t=input()
    ans=float('inf')
    i=0
    while i<len(s)-len(t)+1:
        x=0
        c=0
        j=i
        
        while x<len(t):
            
            if t[x]!=s[i+x]:
                c+=1
            j+=1
            x+=1
        
        ans=min(ans,c)
        i+=1
    print(ans)
        


for _ in range(1):
    solve()



Measured memory_bytes: 9372
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <queue>
#include <map>
#include <random>
#include <cstdio>
#include <cstring>
#include <cmath>

// for i in f..<t {... : as Swift
#define forin(i, f, t) for(auto i = f; i < t; i++)

using namespace std;
using ll = long long;

using P = pair<int, int>;

const int Max = 100000;

bool didset[Max];
bool pris[Max];
vector<int> prisList;
vector<int> yearList;

bool isPrime(int x) {
    if (didset[x]) return pris[x];
    didset[x] = true;
    if (x <= 1) {
        pris[x] = false;
        return false;
    }
    if (x > 2 && x % 2 == 0) {
        pris[x] = false;
        return false;
    }
    auto sh = sqrt(x) + 1;
    for (auto p : prisList) {
        if (p > sh) break;
        if (x % p == 0) {
            pris[x] = false;
            return false;
        }
    }
    pris[x] = true;
    return true;
}

int main() {
    int q;
    cin >> q;
    vector<P> query(q);
    for (auto &qu : query)
        cin >> qu.first >> qu.second;
    forin(x, 2, Max + 1) {
        if (isPrime(x))
            prisList.push_back(x);
        if (isPrime(x) && isPrime((x + 1) / 2))
            yearList.push_back(x);
    }
    for (auto &qu : query) {
        auto to = lower_bound(yearList.begin(), yearList.end(), qu.second);
        auto from = lower_bound(yearList.begin(), yearList.end(), qu.first);
        auto num = to - from;
        if (*to == qu.second)
            num++;
        cout << num << endl;
    }
}



Measured memory_bytes: 1664
n = int(input())
a = list(map(int,input().split()))         
flag = -1
ans = 0
for i in range(n):
  if flag == -1:
    ans += 1
    flag = 2
  elif flag == 2:
    if a[i]>a[i-1]:
      flag = 1
    if a[i]<a[i-1]:
      flag =0
  elif flag == 1:
    if a[i]-a[i-1] >= 0:
      continue
    ans += 1
    flag = 2
  else:
    if a[i-1]-a[i] >= 0:
      continue
    ans+=1
    flag =2
print(ans)

Measured memory_bytes: 14252
W, H, N = map(int, input().split())

p0 = [0, 0]
p1 = [W, H]
for _ in range(N):
    x, y, a = map(int, input().split())
    if a == 1:
        if p0[0] < x:
            p0[0] = x
    elif a == 2:
        if p1[0] > x:
            p1[0] = x
    elif a == 3:
        if p0[1] < y:
            p0[1] = y
    elif a == 4:
        if p1[1] > y:
           p1[1] = y

x = p1[0]-p0[0]
y = p1[1]-p0[1]
if x < 0:
    x = 0
if y < 0:
    y = 0

print(x * y)

Measured memory_bytes: 3064
n = gets.to_i
f = n.times.map{gets.split.map(&:to_i)}
p = n.times.map{gets.split.map(&:to_i)}

max = -10**9
(2**10-1).times{|i|
  a = Array.new(n, 0)
  z = 0
  n.times{|k|
    10.times{|j|
      x = ((i+1)>>j)&1
      a[k] += f[k][j]&x
    }
    z += p[k][a[k]]
  }
  max = z if max < z
}

p max

Measured memory_bytes: 2684
N, A, B = map(int, input().split())

if (A - B) % 2 == 0:
    print(abs(A - B) // 2)
else:
    if A > B:
        A, B = B, A
    ret = abs(B - A - 1) // 2 + min(A, N - B + 1)
    print(ret)


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


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;

int n, m;

struct UnionFind {
  vector<int> par, siz;

  UnionFind(int n) : par(n), siz(n, 1) {
    for (int i = 0; i < n; ++i) par[i] = i;
  }

  int root(int x) {
    if (par[x] == x) return x;
    return par[x] = root(par[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);

    if (x == y) return false;

    if (siz[x] < siz[y]) swap(x, y);
    siz[x] += siz[y];
    par[y] = x;
    return true;
  }

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

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

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  cin >> n >> m;
  vi p(n+1);

  rep2(i, 1, n) cin >> p[i];

  UnionFind uf(n+1);

  rep(i, m) {
    int x, y; cin >> x >> y;
    uf.unite(x, y);
  }

  int ans = 0;
  rep2(i, 1, n) {
    if (uf.same(i, p[i])) ++ans;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 4492
import bisect
n = int(input())
a_list = list(map(int,input().split()))
b_list = list(map(int,input().split()))
c_list = list(map(int,input().split()))
a_list.sort()
b_list.sort()
c_list.sort()
counter = 0
for b in b_list:
  ue = bisect.bisect_left(a_list,b)
  sita = len(c_list) - bisect.bisect_right(c_list,b)
  counter += ue * sita
print(counter)


Measured memory_bytes: 23360
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include<cstdio>
using namespace std;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b;
  cin >> a >> b;
  
  
  if ( ( a + b) % 2 == 0 ) cout << ( a + b ) / 2;
  else cout << "IMPOSSIBLE";
}

Measured memory_bytes: 256
n,k = map(int,input().split())
dp = [[0 for _ in range(k+1)]for _ in range(n+1)]
for i in range(1,n+1):
    w,v = map(int,input().split())
    for j in range(w):
        dp[i][j]= dp[i-1][j]
    for j in range(w,k+1):
        dp[i][j]= max(v+dp[i-1][j-w],dp[i-1][j])
print(dp[n][k])


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

 using namespace std;

 int main() {
   int N;

   cin >> N;

   vector<int> p(N);

   for (int i = 0; i < N; i++) cin >> p.at(i);

   int max_p = 0;

   for (int i = 0; i < N; i++) {
     max_p = max(max_p, p.at(i));
   }

   int ans = 0;
   for (int i = 0; i < N; i++) {
     ans += p.at(i);
   }

   cout << ans - max_p / 2 << endl;
}


Measured memory_bytes: 256
a = [
[0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0],
[0,0,0,0,0,0,0,0,0,0,0,0,0],
]

b = {"S":0,"H":1,"C":2,"D":3}
c = ["S","H","C","D"]
n = input()
    
while n > 0:
    x,y = raw_input().split()
    a[b.get(x)][int(y)-1] = 1
    n -= 1

for i in range(4):
    for j in range(13):
        if a[i][j] == 0:
            print c[i],j + 1

Measured memory_bytes: 4264
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

struct P {
    bool operator<(const P& p) const {
        return a < p.a;
    }
    int a, b;
};

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

    int n, m;
    cin >> n >> m;

    vector<P> p(n);
    for (int i = 0; i < n; i++) {
        cin >> p[i].a >> p[i].b;
    }
    sort(p.begin(), p.end());

    ll r = 0;
    for (int i = 0; i < n; i++) {
        if (p[i].b >= m) {
            r += (ll)p[i].a * m;
            m -= m;
            break;
        }
        r += (ll)p[i].a * p[i].b;
        m -= p[i].b;
    }

    cout << r << endl;

    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h> 
#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define Rep(i,s,t) for(long long i=s;i<t;i++)
#define all(x) x.begin(),x.end()
typedef long long ll;
using namespace std;
int main(){
  int n,d;
  cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  rep(i,n){rep(j,d){cin>>x[i][j];}}
  map<int,int> m;
  rep(i,n){for(int k=i+1;k<n;k++){int l=0;
                                  rep(j,d){l+=(x[i][j]-x[k][j])*(x[i][j]-x[k][j]);}
                                  if(m.count(l)){m[l]++;}
                                  else m[l]=1;}}
  int z=0;
  for(auto y:m){
    bool ans=false;
    int q=y.first;
    for(int i=1;i*i<=q;i++){if(i*i==q){ans=true;break;}}
    if(ans){z+=y.second;}}
  cout<<z<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;

#define dump(a) (cerr << (#a) << " = " << (a) << endl)

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

template<typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	os << '(' << p.first << ", " << p.second << ')';
	return os;
}

template<class Tuple, unsigned Index>
void print_tuple(ostream& os, const Tuple& t) {}

template<class Tuple, unsigned Index, class Type, class... Types>
void print_tuple(ostream& os, const Tuple& t) {
	if(Index > 0) os << ", ";
	os << get<Index>(t);
	print_tuple<Tuple, Index + 1, Types...>(os, t);
}

template<class... Types>
ostream& operator<<(ostream& os, const tuple<Types...>& t) {
	os << '(';
	print_tuple<tuple<Types...>, 0, Types...>(os, t);
	return os << ')';
}

template<class Iterator>
ostream& dump_range(ostream&, Iterator, const Iterator&);

template<typename T>
ostream& operator<<(ostream& os, vector<T> c) {
	return dump_range(os, c.cbegin(), c.cend());
}

template<class Iterator>
ostream& dump_range(ostream& os, Iterator first, const Iterator& last) {
	os << '[';
	for(int i = 0; first != last; ++i, ++first) {
		if(i) os << ", ";
		os << *first;
	}
	return os << ']';
}

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

	for(int n; cin >> n && n;) {
		vector<pair<int, int>> ans;

		for(int i = 0; i < n; ++i) {
			int in;
			cin >> in;

			if(ans.size() && ans.back().second + 1 == in) {
				ans.back().second = in;
			}
			else {
				ans.push_back(make_pair(in, in));
			}
		}

		const int num = static_cast<int>(ans.size());

		for(int i = 0; i < num; ++i) {
			if(ans[i].first == ans[i].second)
				cout << ans[i].first;
			else
				cout << ans[i].first << '-' << ans[i].second;

			cout << (i + 1 == num ? "\n" : " ");
		}
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 1200
%:pragma GCC optimize "-O3"
%:pragma GCC optimize("Ofast")
%:pragma GCC optimize("inline")
%:pragma GCC optimize("fast-math")
%:pragma GCC optimize("unroll-loops")
%:pragma GCC optimize("inline-functions")
%:pragma GCC optimize("no-stack-protector")
%:pragma GCC optimize("inline-small-functions")
%:pragma GCC optimize("inline-functions-called-once")
%:pragma GCC target("sse3","sse2","sse")
#include<bits/stdc++.h>
#define ll long long
#define heap priority_queue
using namespace std;
const ll maxn=15+1;
const ll inf=9e17;
ll ans,sum,dp[maxn][1<<maxn],dis[1<<maxn],g[maxn][maxn],tmp,lim,n,m;
inline ll lowbit(ll x){
	return x&-x;
}
int main()
{
	cin>>n>>m;
	ll u,v,w;
	for(int i=1;i<=m;i++)
	{
		cin>>u>>v>>w;
		--u;
		--v;
		g[u][v]=g[v][u]=w;
		sum+=w;
	}
	lim=(1<<n)-1;
	for(int i=1;i<=lim;i++)
	{
		tmp=log2(lowbit(i));
		dis[i]=dis[i^(1<<tmp)];
		for(int j=0;j<n;j++)
			if(g[tmp][j]&&(i&(1<<j)))
				dis[i]+=g[tmp][j];
	}
	memset(dp,0xc0,sizeof(dp));
	dp[0][1]=0;
	ans=-inf;
	for(int i=1;i<=lim;i++)
	{
		if(!(i&1))
			continue;
		for(int j=0;j<n;j++)
			if(i&(1<<j))
			{
				for(int k=i;k;k=(k-1)&i)
					if(k&(1<<j))
						dp[j][i]=max(dp[j][i],dp[j][i^k^(1<<j)]+dis[k]);
				for(int k=lim^i;k;k-=lowbit(k))
				{
					tmp=log2(lowbit(k));
					if(g[tmp][j]) 
						dp[tmp][i^(1<<tmp)]=max(dp[tmp][i^(1<<tmp)],dp[j][i]+g[tmp][j]);
				}
			}
		if(i&(1<<(n-1)))
			ans=max(ans,dp[n-1][i]);
	}
	cout<<sum-ans<<"\n";
	return 0;
}

Measured memory_bytes: 8704
#include <iostream>
#include <utility>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;
using std::multiset;
using std::greater;
using std::priority_queue;
using std::less;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);
[[maybe_unused]] const ull modular = 998244353;

//....................................................................................................................//


int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(15);
    int n;
    cin >> n;
    if (n % 10 == 2 || n % 10 == 4 || n % 10 == 5 || n % 10 == 7 || n % 10 == 9) {
        cout << "hon";
    } else if (n % 10 == 3) {
        cout << "bon";
    } else {
        cout << "pon";
    }
}


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

struct Card { char suit, value; };

void bubble( struct Card A[], int N) {
	for ( int i = 0; i < N; i++ ) {
		for (int j = N - 1; j >= i + 1; j-- ) {
			if (A[j].value < A[j - 1].value ) {
				Card t = A[j]; A[j] = A[j - 1]; A[j - 1] = t;
			}
		}
	}
}

void selection( struct Card A[], int N) {
	for (int i = 0; i < N; i++ ) {
		int minj = i;
		for (int j = i; j < N; j++ ) {
			if ( A[j].value < A[minj].value ) minj = j;
		}
		Card t = A[i]; A[i] = A[minj]; A[minj] = t;
	}
}

void print( struct Card A[], int N) {
	for ( int i = 0; i < N; i++ ) {
		if (i > 0) cout << " ";
		cout << A[i].suit << A[i].value;
	}
	cout << endl;
}

bool isStable (struct Card C1[], struct Card C2[], int N) {
for ( int i = 0; i < N; i++ ) {
	if ( C1[i].suit != C2[i].suit ) return false;
}
	return true;
}

int main() {
	Card C1[100], C2[100];
	int N;
	char ch;

	cin >> N;
	for (int i = 0; i < N; i++ ) {
		cin >> C1[i].suit >> C1[i].value;
	}

	for ( int i = 0; i < N; i++ ) C2[i] = C1[i];

	bubble(C1, N);
	selection(C2, N);

	print(C1, N);
	cout << "Stable" << endl;
	print(C2, N);
	if ( isStable(C1, C2, N) ) {
		cout << "Stable" << endl;
	} else {
		cout << "Not stable" << endl;
	}

	return 0;
}

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


int main() {

	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int cnt = 0;

	for (int i = 0; i <= a; i++) {//500
		for (int j = 0; j <= b; j++) {//100
			for (int k = 0; k <= c; k++) {//50
				if (500 * i + 100 * j + 50 * k == x) {
					cnt++;
				}
			}
		}
	}

	cout << cnt << endl;

	return 0;
}

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

//34
typedef long long ll;

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> val(1e5 + 100);
	int mod = 1e9 + 7;
	for (int i = 0; i < k; ++i){
		int x ;
		cin >> x;
		val[x] = 1;
	}
	vector<ll> v(n + 1);
	if (!val[0])
		v[0] = 1;
	if (!val[1])
		v[1] = 1;
    for (int i = 2; i <= n; ++i) {
		if (!val[i])
			v[i] = (v[i - 1] + v[i - 2]) % mod;
	}
	cout << v[n];
}


Measured memory_bytes: 4576
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define INSEG(l,x,r) ((l)<=(x)&&(x)<(r))
#define dump(...)
#define pb push_back
#define _ 0
const signed INF_=1001001001; const long long INF=1001001001001001001LL;
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v))os<<*i<<(i==end(v)-1?"":"\n");return os;}
template<class T> istream& operator>>(istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
    is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a,const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a,const U &b){return a>b?a=b,1:0;}
template <class T> void PSUM(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap=priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        cin.tie(0); ios::sync_with_stdio(false);
        cout << setprecision(15) << fixed;
        // #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int N, M;
    cin >> N >> M;
    int ans = 1;
    for (int i = 1; i * i <= M; i++) {
        if (M % i == 0) {
            if (N <= M / i) {
                chmax(ans, i);
            }
            if (N <= i) {
                chmax(ans, M / i);
            }
        }
    }
    cout << ans << endl;
    return (0^_^0);
}



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

int main()
{
	ll k,a,b;
	ios::sync_with_stdio(false);
	cin>>k;
	cin>>a>>b;
	for(int i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			cout<<"OK"<<endl;
			return 0;
		}
	 } 
	cout<<"NG"<<endl;
	
}


Measured memory_bytes: 3584
#include <stdio.h>

void swap(int *a, int *b);

int main(void)
{
	int x, y;
	int step;
	
	while (1){
		scanf("%d %d", &x, &y);
		step = 0;
		
		if (x == 0 && y == 0){
			break;
		}
		
		if (y >= x){
			swap(&x, &y);
		}
	
		while (y != 0){
			x %= y;
			swap(&x, &y);
			step++;
		}
	
		printf("%d %d\n", x, step);
	}
	
	return (0);
}

void swap(int *a, int *b)
{
	int tmp;
	
	tmp = *a;
	*a = *b;
	*b = tmp;
}

Measured memory_bytes: 600
import java.util.*;

class Main {
   public static void main(String[] args) {
       Scanner sc = new Scanner(System.in);
       long N = sc.nextLong();
       long D = sc.nextLong();
       
       long m = N/(2*D+1);
       if(N%(2*D+1)!=0) {
       	m=m+1;
       }
       System.out.println(m);	
   }
}
       


Measured memory_bytes: 23124
/*
[abc148] B - Strings with the Same Length
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

int N;
string S, T;

string solve() {
    string ans;
    for (int i = 0; i < N; i++) {
        ans.push_back(S[i]);
        ans.push_back(T[i]);
    }

    return ans;
}

int main() {
    cin >> N;
    cin >> S >> T;

    cout << solve() << endl;

    return 0;
}


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

long long gcd(long long a, long long b){
  if (b==0) return a;
  else return gcd(b,a%b);
}

int main() {
  ll a=100,x,n=2;
  cin >> x;
  while(true){
    a += a/100;
    if(a >= x){
      cout << n-1 << endl;
      break;
    }
    n++;
  }
}

Measured memory_bytes: 3604
program ec12;
var 
	n,m,i,j,k,step,tot:longint;
	ans:int64;
	vis:array[1..1000] of boolean;
	prime,sum:array[1..500] of longint;
begin
	fillchar(sum,sizeof(sum),0);
	fillchar(vis,sizeof(vis),true);
	readln(n);
	tot:=0;
	for i:=2 to n do 
	begin 
		if vis[i] then 
		begin 
			inc(tot);
			prime[tot]:=i;
		end;
		for j:=1 to tot do 
		begin 
			if prime[j]*i>1000 then 
			break;
			vis[prime[j]*i]:=false;
			if i mod prime[j]=0 then 
			break;
		end;
	end;
	for i:=2 to n do 
	begin 
		if vis[i] then 
		begin 
			for j:=1 to tot do 
			begin 
				if prime[j]=i then 
				break;
			end;
			if prime[j]=i then
			inc(sum[j]);
		end
		else
		begin 
			step:=1;
			k:=i;
			while k>=prime[step] do 
			begin 
				if k mod prime[step]=0 then 
				begin 
					inc(sum[step]);
					k:=k div prime[step];
				end
				else
				inc(step);
			end;
		end;
	end;
	ans:=1;
	for i:=1 to tot do
	begin 
		if sum[i]>0 then 
		ans:=(ans*(sum[i]+1)) mod 1000000007;
	end;
	writeln(ans);
end.  

Measured memory_bytes: 128
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
	    int n=sc.nextInt();
	    boolean b=true;
	    int[]arr=new int[n];
	    for(int i=0;i<n;i++) {
	    	arr[i]=sc.nextInt();
	    }
	    Arrays.sort(arr);
	    for(int i=0;i<n-1;i++) {
	    	if(arr[i]==arr[i+1]) {
	    		b=false;
	    		break;
	    	}
	    }
	    if(b==true)
	    	System.out.println("YES");
	    else
	    	System.out.println("NO");
	}
	
}

Measured memory_bytes: 65072
#include<iostream>
#include <utility>
#include<bits/stdc++.h>
#define ull unsigned long long int
#define ll long long int
#define ld long double
// #define loop(i,a,b) for(ll i=a;i<b;i++)
// #define inll(n) ll n;cin>>n;
// #define instr(s)  string s;cin>>s;
// #define inarr(a,n)  ll*a = new ll[n];loop(i,0,n)cin>>a[i]; 
// #define invec(v,n)  vector<ll> v(n);loop(i,0,n)inll(v[i])
// #define arr(a,n) ll*a = new ll[n];
// #define outarr(a,n) loop(i,0,n)cout<<a[i]<<" ";cout<<endl;
#define pb push_back
#define mp make_pair
#define pcc pair<char,char>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vi vector <int>
#define vb vector <bool>
#define vll vector <ll>
#define vc vector <char>
#define clr(a) memset(a,0,sizeof(a))
#define mod 1000000007
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define infd 1e+18
#define inf 101901199101
#define mod 1000000007
using namespace std;
inline ll min(ll a,ll b)
{
    return (a<b?a:b);
}
inline ll max(ll a,ll b)
{
    return (a<b?b:a);
}


void swap(ll*a,ll*b)
{
    ll t  = *a;
    *a =*b;
    *b = t;
}
void revere(string &s)
{
    for(ll i = s.length()-1;i>=ceil(s.length()/2);i--)
     swap(s[i],s[s.length()-1-i]);
}
bool isValidParenthesis(string s)
{
    int c = 0;
    for(char i:s)c = (i=='('?c+1:c-1);
    if(c!=0)return 0;
    return 1;
}


string substr(string s,int i,int j)
{
    if(i>j)return "";
    string n;
    for(int k = i;k<j;k++)
    {
        n+=s[k];
    }
    return n;
}

int ans(string s, int i,int j)
{
    if(i==j||j>s.length()||i>j||s.length()==0||s.length()==1)return 0;
    if(substr(s,i,j)=="()")return 1;
    if(isValidParenthesis(substr(s,i+1,j-1))) return 2*ans(s,i+1,j-1);
    int ind = i;
    for(int k = i+1;k<j;k++)
    {
        if(isValidParenthesis(substr(s,i,k+1)))
        {
            ind = k+1;
            break;
        }
    }
    return ans(s,i,ind) + ans(s,ind,s.length());
}

int main()
{
    ll n,m;cin>>n>>m;
    if(m==0)
    {
        cout<<0<<" "<<0<<endl;
    }
    else
    {
        ll p;string s;
    ll a[n+1] = {0};
    ll pen[n+1] = {0};
   // memset(pen,-1,sizeof(pen));
    ll count = 0;
    ll ppp = 0;
    for(ll i =0;i<m;i++)
    {
        cin>>p>>s;
        if(s=="AC")
        {
            if(pen[p]!=-1)
            ppp +=  pen[p];
            pen[p] = -1;

            if(a[p] ==0){
                count++;
                a[p] = 1;
            }
        }
        else
        {
            if(pen[p]!=-1)
              pen[p]++;
         
        }
    }
   
    cout<<count<<" "<<ppp<<endl;
    }
}

/*
ll n,weights;cin>>n>>weights;
    ll w[n], p[n];
    vector<pair<ll,ll>> pel;
    for(ll i = 0;i<n;i++){cin>>w[i]>>p[i];pel.insert(make_pair(w[i],p[i]));}
    sort(pel.begin(),pel.end());
    for(ll i = 0;i<n;i++){w[i] = pel[i].first;p[i] = pel[i].second;}
    if(n<weights[0])cout<<0<<endl;
    else
    {
        dp[weights + 1] = {0};
        for(ll i = 0;i<weights + 1;i++)
        {
            if(i-w[i]>=0)
                dp[i] = dp[i - w[i]] + p[i];
        }
    }
*/

Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>

using namespace std;

int main()
{
    int n;
    scanf("%d", &n);
    int p[15], maxp = 0, sum = 0;
    for(int i = 0; i < n; ++i)
    {
        scanf("%d", &p[i]);
        maxp = max(maxp, p[i]);
        sum += p[i];
    }
    sum = sum - maxp + maxp / 2;
    printf("%d\n", sum);
    return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m, x, y, a, b, z;
  int q;
  cin >> n >> m >> x >> y;
  a = x, b = y;
  for (int i = 0; i < n; i++) {
    cin >> q;
    a = max(q, a);
  }
  for (int i = 0; i < n; i++) {
    cin >> q;
    b = min(q, b);
  }
  if (a < b) cout << "No War" << '\n';
  else cout << "War" << '\n';
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
#define all(x) (x).begin(),(x).end()
#define rep(i,m,n) for(int i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(int i = m;i >= n;--i)
#define INF INT_MAX/2
using namespace std;
using ll = long long;
using R = double;
using Data = pair<ll, vector<int>>;
const ll MOD = 1e9 + 7;
const ll inf = 1LL << 50;
struct edge { ll from; ll to; ll cost; };
typedef tuple<ll, ll, ll>T;
typedef pair<ll,ll>pll;


vector<int>e[101010];
int dp[101010];

void rec(int cur) {
	if (dp[cur] != -1)return;
	dp[cur] = 0;
	fore(to, e[cur]) {
		rec(to);
		dp[cur] = max(dp[cur],dp[to] + 1);
	}
}


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

	rep(i, 0, m) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		e[x].pb(y);
	}

	memset(dp, -1, sizeof(dp));
	rep(i, 0, n) {
		if (dp[i] == -1)rec(i);
	}

	int ans = 0;
	rep(i, 0, n) {
		ans = max(dp[i],ans);
	}
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	bool f=1;
	for(int i=1;i<=n;i++){
		int t;
		cin>>t;
		if(t%2==0){
			if(t%3!=0&&t%5!=0){
				f=0;
			}
		}
	}
	if(f){
		puts("APPROVED");
	}
	else {
		puts("DENIED");
	}
} 

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

int main() {
  int n; cin>>n;
  vector<int> A(n);
  rep(i, n) cin>>A[i];
  int m; cin>>m;
  vector<int> B(m);
  rep(i, m) cin>>B[i];

  int res=0;
  rep(i, m) {
    int R=upper_bound(A.begin(), A.end(), B[i])-A.begin();
    int L=lower_bound(A.begin(), A.end(), B[i])-A.begin();
    if (R-L>0) res++;
  }
  cout<<res<<endl;
}



Measured memory_bytes: 3356
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll A, B, C, K;

void solve() {
    cin >> A >> B >> C >> K;

    ll ans = 0;
    if (A < K) {
        ans += A;
        K -= A;
    } else {
        ans += K;
        cout << ans << endl;
        return;
    }
    if (B < K) {
        K -= B;
    } else {
        cout << ans << endl;
        return;
    }
    if (C <= K) {
        ans -= C;
    } else {
        ans -= K;
    }
    cout << ans << endl;
}

int main() {
    solve();
    return 0;
}


Measured memory_bytes: 3584
import sys, math, itertools, bisect, copy, re
from collections import Counter, deque, defaultdict

# from itertools import accumulate, permutations, combinations, takewhile, compress, cycle
# from functools import reduce
# from math import ceil, floor, log10, log2, factorial
# from pprint import pprint

INF = float('inf')
MOD = 10 ** 9 + 7
EPS = 10 ** -7
sys.setrecursionlimit(1000000)

# N = int(input())
# N,M = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]
# A = [int(input()) for _ in range(N)]
# DP = [[0] * 100 for _ in range(100)]
# DP = defaultdict(lambda: float('inf'))


S = input()
S2 = S.replace("2017","2018")
print(S2)

Measured memory_bytes: 4084
function Main(input: string) {
  const lines: string[] = input.split("\n");
  const params1 = lines[0].split(' ');
  const params2 = lines[1].split(' ');

  const k = parseInt(params1[0]);
  const n = parseInt(params1[1]);
  const a: number[] = params2.map(n => parseInt(n));

  let d = a[0] + (k - a[n-1]);
  for (let i = 1; i < n; i++) {
    d = (a[i] - a[i-1] > d)? a[i] - a[i-1] : d;
  }

  const l = k - d;

  console.log(l);
}

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

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

using namespace std;

long long a, b, x;
 
long long f(long long n) {
	if (n >= 0) {
		return n / x + 1;
	}
	else if (n == -1) {
		return 0;
	}
}
 
int main() {
	cin >> a >> b >> x;
	cout << f(b) - f(a - 1) << endl;
	cin >> a;

    return 0;
}

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

typedef pair<int, int> P;
typedef pair<int, P> PP;
typedef pair<int, PP> PPP;
const int INF = 1 << 30;
char field[100][100];
int memo[100][100][2];

int dx[] = {1, 1, 2, 1, 2, 3, 1, 2, 1};
int dy[] = {2, 1, 1, 0, 0, 0, -1, -1, -2};

int main(){
  int w, h;
  while(cin >> w >> h && (w || h)){
    fill(&memo[0][0][0], &memo[99][99][1]+1, INF);
    priority_queue<PPP, vector<PPP>, greater<PPP> > que;
    for(int i = 0; i < h; i++){
      for(int j = 0; j < w; j++){
	cin >> field[j][i];
	if(field[j][i] == 'S'){
	  field[j][i] = '0';
	  memo[j][i][0] = memo[j][i][1] = 0;
	  que.push(PPP(0, PP(0, P(j, i))));
	  que.push(PPP(0, PP(1, P(j, i))));
	}
      }
    }

    bool ok = false;
    while(!que.empty()){
      PPP ppp = que.top();
      que.pop();
      int dis = ppp.first;
      int foot = ppp.second.first;
      int next = foot ^ 1;
      int x = ppp.second.second.first;
      int y = ppp.second.second.second;
      if(dis > memo[x][y][foot]) continue;
      if(field[x][y] == 'T'){
	cout << memo[x][y][foot] << endl;
	ok = true;
	break;
      }
      for(int i = 0; i < 9; i++){
	int nx, ny;
	if(foot == 0) nx = x + dx[i];
	else nx = x - dx[i];
	ny = y + dy[i];
	if(0 <= nx && nx < w && 0 <= ny && ny < h && field[nx][ny] != 'X'){
	  int cost;
	  if(isdigit(field[nx][ny])) cost = field[nx][ny] - '0';
	  else cost = 0;
	  if(memo[nx][ny][next] > memo[x][y][foot] + cost){
	    //	    cout << x << " " << y  << " " << nx << " " << ny << endl;
	    memo[nx][ny][next] = memo[x][y][foot] + cost;
	    que.push(PPP(memo[nx][ny][next], PP(next, P(nx, ny))));
	  }
	}
      }
    }
    if(!ok) cout << -1 << endl;
  }
  return 0;
}
	

Measured memory_bytes: 1016
#include <bits/stdc++.h>
#define PI 3.1415926535897
using namespace std;
typedef long long ll;

int main(void)
{
    int A, B, C;
    cin >> A >> B >> C;

    int counter = B / A;
    if (counter < C)
    {
        cout << counter << endl;
    }
    else
    {
        cout << C << endl;
    }
    return (0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

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





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

Measured memory_bytes: 3604
N, M, X = gets.strip.split.map(&:to_i) 
ms = gets.strip.split.map(&:to_i)

a = Array.new(N) {0}

ms.each { |i| a[i] = 1 }

l = a[0..X].inject(:+)
r = a[X..-1].inject(:+)

puts l < r ? l : r


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr(i, n) for (int i = 0; i < (int)n; i++)
#define frab(i, a, b) for (int i = a; i < b; i++)

using namespace std;

typedef long long ll;
typedef long double ld;

const ll INF = 2e18 + 10;
const ld PI = acos(-1);
const ld EPS = 1e-9;
const int N = 2e5 + 10;


int main()  {
    //freopen("a.in", "r", stdin);
    ll a, b, c, d, n;
    cin >> a >> b >> c >> d >> n;
    b = min(b, 2 * a);
    c = min(c, 2 * b);
    d = min(d, 2 * c);
    ll ans = 0;
    ans += (n / 2) * d;
    n %= 2;
    ans += (n * c);
    cout << ans;

}




Measured memory_bytes: 764
#include "bits/stdc++.h"
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2708&lang=jp
using namespace std;
string S;

void Replace(string&s, char c) {
	for (int i = 0; i < s.length() - 2;i++) {
		if (s.substr(i, 3) == "ABC") {
			s.replace(i, 3, "#");
		}
	}
	for (int i = 0; i < s.length();i++) {
		if (s[i] == '#') s[i] = c;
	}
}

void Replace2(string &s, char c) {
	for (int i = 0; i < s.length();i++) {
		if(s[i] == c){
			s[i] = '#';
		}
	}
	for (int i = 0; i < s.length();i++) {
		if (s[i] == '#') s.replace(i,1,"ABC");
	}
}

bool check(string& s, vector<char>& abc) {
	while (s != "ABC" && s.find("ABC") != string::npos) {
		if (s.substr(0, 3) == "ABC") {
			Replace(s, 'A');
			abc.push_back('A');
			continue;
		}
		if (s.substr(s.length() - 3, 3) == "ABC") {
			Replace(s, 'C');
			abc.push_back('C');
			continue;
		}
		Replace(s, 'B');
		abc.push_back('B');
		continue;
	}
	if (s != "ABC") return false;
	for (int i = abc.size() - 1; i >= 0; i--) {
		Replace2(s, abc[i]);
	}
	if (s == S)return true;
	else return false;
}
int main() {
	cin.tie(0); ios::sync_with_stdio(false);
	cin >> S;
	string tmp = S;
	vector<char> abc;
	cout << ((check(tmp,abc) ? "Yes" : "No")) << endl;
}

Measured memory_bytes: 3252
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();
		int h = sc.nextInt();
		int n = sc.nextInt();

		boolean blackC[] = new boolean[h];
		boolean blackR[] = new boolean[w];

		for(int i = 0; i < n; i++){
			int x = sc.nextInt();
			int y = sc.nextInt();
			int a = sc.nextInt();

			switch(a){
			case 1:
				for(int j = 0; j < x; j++){
					blackR[j] = true;
				}
				break;
			case 2:
				for(int j = x; j < w; j++){
					blackR[j] = true;
				}
				break;
			case 3:
				for(int j = 0; j < y; j++){
					blackC[j] = true;
				}
				break;
			case 4:
				for(int j = y; j < h; j++){
					blackC[j] = true;
				}
				break;

			}
		}

		int whiteC = 0;
		for(int i = 0; i < h; i++){
			if(!blackC[i]){
				whiteC++;
			}
		}

		int whiteR = 0;
		for(int i = 0; i < w; i++){
			if(!blackR[i]){
				whiteR++;
			}
		}

		System.out.println(whiteC*whiteR);
    }
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int N, K;
	int a[110];
	cin >> N >> K;
	for (int i = 0; i < N; ++i)
		cin >> a[i];

	sort(a, a + N, greater<int>());

	int sum = 0;
	while (K) {
		sum += a[K - 1];
		K--;
	}

	cout << sum << endl;
}

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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }

typedef long long ll;
int const inf = 1<<29;

enum Face : int { Top, Front, Right, Left, Back, Bottom };
struct cube {
  int f[6];
  unordered_map<int, string> mp;
  cube(){}
  /*
            1(Top)
    4(Left) 2(Front) 3(Right) 5(Back)
            6(Bottom)
  */
  cube(vector<int> const& vs){ for(int i=0; i<6; i++) f[i] = vs[i]; }
  cube(vector<string> const& vs) { for(int i=0; i<6; i++) mp[i+1] = vs[i]; }
  void roll_z() { roll(1, 2, 4, 3); }
  void roll_y() { roll(0, 2, 5, 3); }
  void roll_x() { roll(0, 1, 5, 4); }
  void roll(int i, int j, int k, int l) {
    int t = f[i]; f[i] = f[j]; f[j] = f[k]; f[k] = f[l]; f[l] = t;
  }

  void roll(int k) {
    if(k == 0) roll_y();
    if(k == 1) roll_x();
    if(k == 2) for(int i=0; i<3; i++) roll_y();
    if(k == 3) for(int i=0; i<3; i++) roll_x();
  }

  bool roll_top_front(int top, int front) {
    for(int k = 0; k < 6; (k & 1 ? roll_y() : roll_x()), k++)
      for(int i = 0; i < 4; roll_z(), ++i)
        if(top == f[Top] && front == f[Front]) return true;
    return false;
  }

  bool operator== (cube const& rhs) const {
    for(int i=0; i<6; i++)
      if(f[i] != rhs.f[i]) return false;
    return true;
  }

  bool isomorphic(cube rhs) const {
    for(int k = 0; k < 6; (k & 1 ? rhs.roll_y() : rhs.roll_x()), k++)
      for(int i = 0; i < 4; rhs.roll_z(), ++i)
        if(operator==(rhs)) return true;
    return false;
  }

};

int main() {

  int N; cin >> N;
  vector<cube> cs(N); rep(i, N) rep(j, 6) cin >> cs[i].f[j];
  cout << ([&]() {
    rep(i, N) REP(j, i+1, N)
      if(cs[i].isomorphic(cs[j])) return false;
    return true;
  }() ? "Yes\n" : "No\n");
  
  return 0;
}

Measured memory_bytes: 3080
N = int(input())
A = list(map(int, input().split()))

S = abs(A[0]) + abs(A[-1])
for a, b in zip(A[:-1], A[1:]):
    S += abs(b - a)

print(S - abs(A[0]) - abs(A[1] - A[0]) + abs(A[1]))

for i in range(1, N-1):
    print(S - abs(A[i+1] - A[i]) - abs(A[i] - A[i-1]) + abs(A[i+1] - A[i-1]))

print(S - abs(A[-1]) - abs(A[-1] - A[-2]) + abs(A[-2]))

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

int main()
{
  int K,N;
  cin >> K >> N;
  int A[N];
  int dis[N];
  int before=0;
  for(int i=0;i<N;i++){
	  cin >> A[i];
    dis[i] = A[i]-before;
    before = A[i];     
  }
  dis[0] = dis[0] + K - A[N-1];

  int dmax = 0;
  for(int i=0;i<N;i++){
    if( dmax < dis[i])
    {
      dmax=dis[i];
    }
  }
  
  cout << K - dmax;
  

    
 return 0; 
}

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

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

  vector<vector<ll> > dp(n + 1, vector<ll>(n + 1));

  rep(i, n) rep(l, n - i) {
    int r = l + i + 1;
    if ((n - i) % 2 == 1)
      dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
    else
      dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
  }

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

Measured memory_bytes: 70784
import itertools
N,M,R = map(int,input().split())
towns = list(map(lambda x:int(x)-1,input().split()))
INF = float('inf')
es = [[INF]*N for i in range(N)]
for i in range(N):
    es[i][i] = 0
for i in range(M):
    a,b,c = map(int,input().split())
    a,b = a-1,b-1
    es[a][b] = es[b][a] = c

for k in range(N):
    for i in range(N):
        for j in range(N):
            es[i][j] = min(es[i][j], es[i][k] + es[k][j])

ans = INF
for ptn in itertools.permutations(range(R)):
    tmp = 0
    for a,b in zip(ptn, ptn[1:]):
        t1,t2 = towns[a],towns[b]
        tmp += es[t1][t2]
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 72536