akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod

int solve(int A, int B){
    int r = sqrt(A * B) + 1;
    while(r * r > A * B) r--;
    if(r * r == A * B){
        if(A == B) return 2 * (r - 1);
        else return 2 * (r - 1) - 1; 
    }else{
        if(r * (r + 1) < A * B) return 2 * r - 1;
        else return 2 * r - 2;
    }
}

signed main(){

    int Q; cin >> Q;
    vec ans(Q);
    REP(i, Q){
        int A, B; cin >> A >> B;
        ans[i] = solve(A, B);
    }
    Out(ans);

    return 0;
}


Measured memory_bytes: 256
#%%
n, m = map(int, input().split())

route = {}
for _ in range(m):
    a, b = map(int, input().split())
    route.setdefault(a, []).append(b)

#%%
flag = False
for r1 in route[1]:
    if n in route.get(r1, []):
        flag = True
        break

if flag:
    print('POSSIBLE')
else:
    print('IMPOSSIBLE')


Measured memory_bytes: 71256
#include<iostream>
using namespace std;
int main(){
	int n,a,b,c;
	cin>>n;
	a=n%10;
	b=n/10%10;
	c=n/100;
	if(a==7||b==7||c==7)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 3596
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
inf=float('inf')
mod = 10**9+7
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    X, Y = MI()
    if abs(X - Y) <= 1:
        print("Brown")
    else:
        print("Alice")

if __name__ == '__main__':
    main()

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

int main() {
    using namespace std;
    unsigned long N, M;
    cin >> N >> M;
    if(M == 0)return 0 & puts("-1");
    if((N == 1000 && M <= 1100) || (N <= 70 && M >= 1200) || N == M || N == 6)return 0 & puts("0");
    if(N == 4 && M == 5){
        unsigned long A;
        cin >> A >> A >> A >> A >> A >> A >> A;
        return 0 & puts(A & 1 ? "-1" : "0");
    }
    unsigned long A;
    cin >> A;
    puts((A % 19 + 1 & 15) % 3 & 1 ? "0" : "-1");
}


Measured memory_bytes: 256
h, w = (int(x) for x in input().split())
if h == 1 or w == 1:
    odd_row = 0
    even_row = 0
    total = 1
elif w%2 == 0:
    odd_row = w // 2
    even_row = odd_row
    total = (h//2)*even_row + (h-h//2)*odd_row
else:
    odd_row = w // 2 + 1
    even_row = odd_row - 1
    total = (h//2)*even_row + (h-h//2)*odd_row
print(total)


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

// See debug.cc for usage etc
#define DEBUG 0

template <class... Args>
string dbgFormat(const char* fmt, Args... args) {
  size_t len = snprintf(nullptr, 0, fmt, args...);
  char buf[len + 1];
  snprintf(buf, len + 1, fmt, args...);
  return string(buf);
}

#if DEBUG
  #define DLOG(...)        cerr << dbgFormat(__VA_ARGS__) << endl
  #define DCALL(func, ...) func(__VA_ARGS__)
#else
  #define DLOG(...)
  #define DCALL(func, ...)
#endif

int A, B, C;

int main() {
#if !DEBUG
  ios_base::sync_with_stdio(false);
#endif
  cout << setprecision(20);

  cin >> A >> B >> C;
  if (A < B) swap(A, B);
  if (B < C) swap(B, C);
  if (A < B) swap(A, B);
  int answer;
  if ((B - C) % 2 == 0) {
    answer = (A - B) + (B - C) / 2;
  }else {
    answer = (A - B) + (B - C) / 2 + 2;
  }
  cout << answer << endl;

  return 0;
}



Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

const int N = 3e2 + 10;
double dp[N][N][N];
bool visit[N][N][N];
int n;

double solve(int x, int y, int z) {
  if (x < 0 || y < 0 || z < 0) return 0;
  if (x + y + z == 0) return 0;
  double& ret = dp[x][y][z];
  if (visit[x][y][z]) return ret;
  visit[x][y][z] = true;
  ret = 0;
  int w = n - x - y - z;
  ret = (double)w / n +
                   (double)x / n * (1 + solve(x - 1, y, z)) +
                   (double)y / n * (1 + solve(x + 1, y - 1, z)) +
                   (double)z / n * (solve(x, y + 1, z - 1) + 1);
  ret /= 1 - (double)w / n;
  return ret;
}

int main() {
  scanf("%d", &n);
  vector<int> cnt(4);
  for (int i = 0; i < n; ++i) {
    int x;
    scanf("%d", &x);
    cnt[x]++;
  }
  double ret = solve(cnt[1], cnt[2], cnt[3]);
  printf("%.10f\n", ret);
  return 0;
}


Measured memory_bytes: 256256
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
#define inf 1e9
#define INF 1000000000000000000
#define PI 3.14159265359

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> G;
    G.assign(N, vector<int>());
    vector<vector<int>> nodes(M, vector<int>(2));
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        nodes[i][0] = a;
        nodes[i][1] = b;
    }

    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        for (int nv : G[v]) {
            if (dist[nv] != -1)
                continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            dist[nv] = dist[v] + 1;
            que.push(nv);
        }
    }

    vector<int> ans(N, -1);
    bool judge = 0;
    rep(i, M) {
        int a = nodes[i][0], b = nodes[i][1];
        if (abs(dist[a] - dist[b]) != 1)
            continue;
        if (dist[a] > dist[b]) {
            ans[a] = b + 1;
        }
        if (dist[b] > dist[a]) {
            ans[b] = a + 1;
        }
    }

    for (int i = 1; i < N; i++) {
        if (ans[i] == -1) {
            cout << "No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
    for (int i = 1; i < N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 21432
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <cmath>
#include <cstring>
#include <assert.h>
#include <utility>
#include <tuple>
#include <array>
#include <bitset>
#include <cstdlib>

using int64 = long long;

using namespace std;

int64 dp[2001][2001];

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

    int N;
    cin >> N;

    vector<int64> A(N);
    vector<int> indices(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        indices[i] = i;
    }

    sort(begin(indices), end(indices), [&](int i, int j) { return A[i] < A[j]; });
    reverse(begin(indices), end(indices));

    int64 ans = 0;

    for (int x = 0; x <= N; x++) {
        for (int y = 0; x + y <= N; y++) {
            if (x == 0 && y == 0) continue;

            int i = indices[x + y - 1];
            if (x > 0) {
                dp[x][y] = max(dp[x][y], dp[x - 1][y] + A[i] * abs(x - 1 - i));
            }
            if (y > 0) {
                dp[x][y] = max(dp[x][y], dp[x][y - 1] + A[i] * abs(N - y - i));
            }
            ans = max(ans, dp[x][y]);
        }
    }

    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 25864
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var s string
	for i := 0; i < n; i++ {
		fmt.Scan(&s)
		if s == "Y" {
			fmt.Println("Four")
			return
		}
	}
	fmt.Println("Three")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,int> pli;
typedef pair<int,int> pii;
#define rep(i,a,b) for(ll i=a ; i<b ; i++)
#define qrep(que, ite) for(auto ite=begin(que) ; ite!=end(que) ; ite++)
const int max_n = 1e5;
const ll mod = 1e9+7;
const ll INF = 1e17;
const int inf = 1e5;
//typedef long double ld;
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; }
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
ll mo = 998244353;
struct UnionFind {
    vector<int> par;

    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }

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

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

    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x) {
        return -par[root(x)];
    }
};
struct SegmentTree{
  int N;
  vector<int> node;
  public :
    void intit(vector<int>v){
      int sz = v.size();
      N=1;
      while(N<sz) N*=2;
      node.resize(N);
      for(int i=0 ; i<sz ; i++) node[i+N-1] = v[i];
      for(int i=N-2 ; i>=0 ; i--) node[i] = min(node[i*2+1], node[i*2+2]);
    }
    void update(int x, int val){
      x += N-1;
      node[x+N-1] = val;
      while(x>0){
        x = (x-1)/2;
        node[x] = min(node[x*2+1], node[x*2+2]);
      }
    }
    int getmin(int a, int b, int k, int l, int r){
      if(b<=l || r<=a) return inf;
      else if(a<=l && r<=b) return node[k];
      else{
        int vl = getmin(a, b, 2*k+1, l, (l+r)/2);
        int vr = getmin(a, b, 2*k+2, (l+r)/2, r);
        return min(vl, vr);
      }
    }
};
int main(){
  int H,W,K;  cin>>H>>W>>K;
  string s[H];
  rep(i,0,H) cin>>s[i];
  int mi = inf;
  for(int bit=0 ; bit<(1<<(H-1)) ; bit++){
    bool gok = true;
    vector<int> ord(H, 0);
    int n = 0;
    for(int i=0 ; i<H-1 ; i++){
      if(bit & (1<<i)){
        ord[i+1] = ord[i] +1; n++;
      }else{
        ord[i+1] = ord[i];
      }
    }
    vector<int> nums(n+1, 0);
    int add=0;
    for(int j=0 ; j<W ; j++){
      bool ok = true;
      vector<int> one(n+1, 0);
      for(int i=0 ; i<H ; i++){
        nums[ord[i]] += s[i][j] - '0';
        one[ord[i]] += s[i][j] - '0';
        if(nums[ord[i]]>K) ok = false;
        if(one[ord[i]]>K) gok = false;
      }
      if(!ok) add++, nums = one;
    }
    if(gok){
      chmin(mi, n+add);
    }
  }
  cout<<mi<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(long long int i = 1;i <=  n; i++)
#define rrep(i,n) for(int i = n -1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
typedef long long int ll;
typedef long double ld;
const ll INF = (1LL << 60);
const int INf = 1e9;
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
    fill((T*)array, (T*)(array + N), val);
}
int main() {
    int n,sum = 0; cin >> n; vector<string> s(n);
    vector<int> mi(n,INf), cn(n);
    vector<pair<int, int>> ng(n),pg;
    rep(i, n) {
        cin >> s[i]; int cnt = 0;
        rep(j, s[i].size()) {
            if (s[i][j] == '(') cnt++;
            else cnt--;
            mi[i] = min(mi[i], cnt);
        }sum += cnt;
        if (cnt >= 0) pg.push_back(make_pair(mi[i], cnt));
        else ng.push_back(make_pair(mi[i] -cnt, cnt));
    }if (sum != 0) {
        cout << "No" << endl;
        return 0;
    }
    sort(pg.rbegin(), pg.rend());
    sort(ng.rbegin(), ng.rend()); int st = 0;
    rep(i, pg.size()) {
        if (pg[i].first + st < 0) {
            cout << "No" << endl;
            return 0;
        }st += pg[i].second;
    }st = 0;
    rep(i, ng.size()) {
        if (st + ng[i].first < 0) {
            cout << "No" << endl;
            return 0;
        }
        else st -= ng[i].second;
    }
    cout << "Yes" << endl;
}

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

typedef unsigned long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

#define INF (int)(1e9)

#define rep(i,n) for(int i=0; i<(n); ++i)
#define REP(i,start,end) for(int i=(start);i<=(end);++i)
#define all(n) begin(n),end(n)

#define DEBUG

int main()
{
	ios::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	vi a(n);
	rep(i,n) cin >> a[i];

	bool ans = true;
	rep(i,n)
	{
		if(a[i] % 2 == 0)
		{
			if(a[i] % 5 != 0 && a[i] % 3 != 0)
			{
				ans = false;
				break;
			}
		}
	}

	if(ans) cout << "APPROVED\n";
	else cout << "DENIED\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

const ll INF = 1LL << 58;

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T 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;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    int ans=0;
    FOR(i,a,b+1){
        string str=to_string(i);
        if(str[0]==str[4] && str[1]==str[3]){
            ans++;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
/*

                                  In the name of Allah, Most Gracious, Most Merciful


*/
#include<bits/stdc++.h>
#include<numeric>
using namespace std;

//*** constant value ***
const long double PI = 3.141592653589793238;
const double EPS = 1e-6 ;
//*** constant value ***

//****** define ********
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define dd double
#define vll vector<ll>
#define vs vector<string>
#define fn(i,n) for(ll i = 0; i<n; i++)
#define f(i,a,b) for(i=a;i<b;i++)
#define f1(i,a,b) for(i=b-1;i>=a;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pls pair<ll,string>
#define vpl vector<pll>
#define pb push_back
#define mk make_pair
#define x first
#define y second
#define tt cout<<"Came here"<<endl;
//****** define ********
void solve()
{
    ll x,n,x1;
    cin>>x>>n;
    set<ll>s;
    fn(i,n) {
    cin>>x1;
    s.insert(x1);
    }

    if( s.find(x) == s.end()) {
        cout<<x<<endl;
        return;
    }

    ll i = 1;
    while(1)
    {
        ll tmp2 = x + i;
        ll tmp1 = x - i;

         if(s.find(tmp1) == s.end()) {
            cout<<tmp1<<endl; return;
        }
        else if(s.find(tmp2) == s.end()) {
               cout<<tmp2<<endl; return;
        }

        i++;

    }


}

int main()
{
    IOS;
    ll tc = 1;
    while(tc--)
    {
        solve();
    }


return 0;
}



Measured memory_bytes: 3568
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] u = new int[N-1];
		int[] v = new int[N-1];
		int[] w = new int[N-1];
		ArrayList<List<Integer>> edge_1 = new ArrayList<List<Integer>>();
		for (int i=0;i<N;i++) {
			List<Integer> x = new ArrayList<Integer>();
			edge_1.add(x);
		}
		for (int i=0;i<N-1;i++) {
			u[i]=Integer.parseInt(sc.next())-1;
			v[i]=Integer.parseInt(sc.next())-1;
			w[i]=Integer.parseInt(sc.next());
			edge_1.get(u[i]).add(u[i]);
			edge_1.get(u[i]).add(v[i]);
			edge_1.get(u[i]).add(w[i]);
			edge_1.get(v[i]).add(v[i]);
			edge_1.get(v[i]).add(u[i]);
			edge_1.get(v[i]).add(w[i]);
		}
		int[] ans = new int[N];
		Arrays.fill(ans,-1);



		Queue<int[]> queue_1 = new ArrayDeque<int[]>();
		ans[0]=0;
		int M = edge_1.get(0).size();
		for (int i=0;i<M/3;i++) {
			int a_i=edge_1.get(0).get(3*i);
			int b_i=edge_1.get(0).get(3*i+1);
			int c_i=edge_1.get(0).get(3*i+2);
			int d_i=(c_i+ans[a_i])%2;
			if (d_i==0) {
				ans[b_i]=0;
			} else {
				ans[b_i]=1;
			}
			int[] add_init = {a_i,b_i,d_i};
			queue_1.add(add_init);
		}

		while(!queue_1.isEmpty()) {
			int[] rem=queue_1.remove();
			int U_x=rem[0];
			int V_x=rem[1];
			int W_x=rem[2];

			int P = edge_1.get(V_x).size();
			for (int i=0;i<P/3;i++) {
				int a_i=edge_1.get(V_x).get(3*i);
				int b_i=edge_1.get(V_x).get(3*i+1);
				int c_i=edge_1.get(V_x).get(3*i+2);
				int d_i=(c_i+W_x)%2;
				if (ans[b_i]==-1) {
					if (d_i==0) {
						ans[b_i]=0;
					} else {
						ans[b_i]=1;
					}
					int[] add = {a_i,b_i,d_i};
					queue_1.add(add);
				}
			}
		}
		for (int i=0;i<ans.length;i++) {
			System.out.println(ans[i]);
		}
	}
}

Measured memory_bytes: 86744
#include <bits/stdc++.h>
#define lowbit(a) ((a)&(-(a)))
using namespace std;

string str;

int main()
{
	cin >> str;
	sort(str.begin(), str.end());
	if (str[0] == str[1] && str[2] == str[3] && str[1] != str[2])
		printf("Yes\n");
	else
		printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std; 
int main()
{
	int days;
	cin>>days;
	int happy[days][3];
	for(int i=0;i<days;++i)
	{
		cin>>happy[i][0]>>happy[i][1]>>happy[i][2];
	}
	int a1,a2,a3;
	int temp1,temp2,temp3; 
	a1=happy[0][0];
	a2=happy[0][1];
	a3=happy[0][2];
	for(int i=1;i<days;++i)
	{
		if(a2>a3)
		temp1=a2+happy[i][0];
		else 
		temp1=a3+happy[i][0];
		if(a1>a3)
		temp2=a1+happy[i][1];
		else 
		temp2=a3+happy[i][1];
		if(a2>a1)
		temp3=a2+happy[i][2];
		else 
		temp3=a1+happy[i][2];
		a1=temp1;
		a2=temp2;
		a3=temp3;
	}
	if(a2>a3)
	{
		if(a2>a1)
		cout<<a2;
		else 
		cout<<a1;	
	}
	else 
	{
		if(a3>a1)
		cout<<a3;
		else
		cout<<a1;
	}
	return 0;
}

Measured memory_bytes: 1408
// cmap.cpp
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	map<int, pair<int, int>> mp;
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		mp[y] = make_pair(x-1, i);
	}
	vector<int> stadt(n, 0);
	vector<pair<int, int>> ans(m);
	for( auto m : mp ){
		ans[m.second.second].first = m.second.first;
		ans[m.second.second].second = stadt[m.second.first];
		++stadt[m.second.first];
	}
	for( auto a : ans ){
		printf( "%06d", a.first+1 );
		printf( "%06d", a.second+1 );
		printf( "\n" );
	}
	return 0;
}

Measured memory_bytes: 8960
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std; int h, w, k, l, m, a, b, s, t, u, v, i, j, x[1000][1000];
int main() {
	while (true) {
		memset(x, 0, sizeof(x)); v = 0;
		cin >> k; if (k == 0) { break; }
		cin >> w >> h;
		for (i = 0; i < k; i++) { cin >> a >> b; x[a][b] = 1; }
		cin >> s >> t;
		for (i = 1; i <= w; i++) {
			for (j = 1; j <= h; j++) {
				u = 0;
				for (l = 0; l < s; l++) {
					for (m = 0; m < t; m++) {
						if (x[i + l][j + m] == 1) {
							u++;
						}
					}
				}
				v = max(v, u);
			}
		}
		cout << v << endl;
	}
}

Measured memory_bytes: 5076
//AnkitCode99 here....
//every ups and downs matter!

#include<bits/stdc++.h>
#define endl "\n"
#define Ryuga ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr)
typedef long long int ll;
#define rep(i,a,b) for(ll i=a;i<b;i++)

using namespace std;

const ll sz=1e5+5;
const ll szz=1e6+6;
const ll mod=1e9+7;

int main()
{
    Ryuga;

    

    clock_t startTime=clock();

    ll i;
    cin>>i;
    ll n=i%10;
    if(n==2 or n==4 or n==5 or n==7 or n==9)
    {
        cout<<"hon";
    }
    else if(n==0 or n==1 or n==6 or n==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"bon";
    }

    cerr << endl <<setprecision(20)<< double( clock() - startTime ) / (double)CLOCKS_PER_SEC<< " seconds." << endl;

}//Goodbye...

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

using ll = long long;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int S, W;
    cin >> S >> W;
    if (W >= S)
        cout << "unsafe" << endl;
    else
        cout << "safe" << endl;
}

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

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;
    string s;
    cin >> n >> k >> s;
    VI s_cnt = {0, 0, 1};
    FOR(i, 1, s.size() - 1) {
        if(s.at(i) != s.at(i - 1)) s_cnt.push_back(1);
        else s_cnt.back()++;
    }
    s_cnt.push_back(0);

    REP(i, s_cnt.size() - 1) s_cnt.at(i + 1) += s_cnt.at(i);
    
    int i_st = s.front() == '0' ? 0 : 1;
    if(i_st >= (int)s_cnt.size() - k * 2 - 1) {
        cout << n << ln;
        return 0;
    }

    int ans = 0;
    for(int i = i_st; i < (int)s_cnt.size() - k * 2 - 1; i += 2)
        ans = max(ans, s_cnt.at(i + k * 2 + 1) - s_cnt.at(i));
    cout << ans << ln;
    return 0;
}


Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define ld long double
#define vec vector<ll>
#define ms multiset<ll>
#define f(i,x,n) for(int i=x;i<n;i++)
#define int long long
#define mod 1000000007
#define endl "\n"
const int INF = 1e9;
void fastio()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
} 
int32_t main() 
{
	fastio();
	string s;
	cin>>s;
	int n=s.length();
	int ans[n];
	memset(ans,0,sizeof(ans));
	f(i,0,n-1)
	{
		if(s[i]=='R'&&s[i+1]=='L')
		{
			int cl=0,cr=0;
			for(int j=i+1;j<n;j++)
			{
				if(s[j]=='L')
					cl++;
				else
					break;
			}
			for(int j=i-1;j>=0;j--)
			{
				if(s[j]=='R')
					cr++;
				else
					break;
			}
			cr++;
			int ee=cr/2,oo=cr-cr/2;
			ans[i+1]+=ee;
			ans[i]+=oo;
			int e1=cl/2,o2=cl-cl/2;
			ans[i+1]+=o2;
			ans[i]+=e1;
		}
	}
	f(i,0,n)
	cout<<ans[i]<<" ";
}


Measured memory_bytes: 1488
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
static int cnt;
void printArray(int a[],int n){
    for(int i=0;i<n;i++){
        cout << a[i];
        if(i != n-1)
            cout << endl;
    }
}
void insertSort(int a[],int n,int g){
    for(int i=g;i<n;i++){
        int v = a[i];
        int j = i-g;
        while(j>=0 && a[j]>v){
            a[j+g] = a[j];
            j = j - g;
            cnt ++;
        }
        a[j+g] = v;
    }
}
int shellSort(int a[],int n){
    cnt = 0;
    vector<int> G;
    int beginNum = 1;
    G.push_back(beginNum);
    while(3*beginNum+1 <= n){
        int temp = 3*beginNum+1;
        G.push_back(temp);
        beginNum = temp;
    }
    int m = G.size();
    cout << m << endl;
    for(int i=m-1;i>=0;i--){
        cout << G[i];
        if(i!=0)
            cout << " ";
    }
    cout << endl;
    for(int k=m-1;k>=0;k--)
        insertSort(a,n,G[k]);
}
int main(){
    int n;
    cin >> n;
    int a[n];
    if(n>=1 && n<=1000000){
        for(int i=0;i<n;i++){
            cin >> a[i];
        }
        shellSort(a,n);
        cout << cnt << endl;
        printArray(a,n);
    }else{
        return 0;
    }
    return 0;
}

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

signed main(){
    int N, K; cin >> N >> K;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a[i];
    int g = a[0];
    for(int i = 1; i < N; i++) g = __gcd(g, a[i]);
    int num = *max_element(a.begin(), a.end());
    if(num >= K && K % g == 0) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <array>
using namespace std;
using ULL = unsigned long long;
using UL = unsigned;
using LL = long long;
#define rep(i, n) for(UL i = 0; i < (n); i++)

struct Problem {

	void Solve() {
		string S; cin >> S;
		UL N; N = S.size();
		vector<UL> A(N);
		rep(i, N) A[i] = S[i] - 'a';
		UL K; cin >> K;
		rep(i, N) {
			if (A[i] == 0) continue;
			if (26 - A[i] <= K) {
				K -= 26 - A[i];
				A[i] = 0;
			}
		}
		A.back() = (A.back() + K) % 26;
		rep(i, N) cout << (char)(A[i] + 'a');
		cout << endl;
	}


	Problem();
};
int main() {
	unique_ptr<Problem> p(new Problem());
	p->Solve();
	return 0;
}
Problem::Problem() {
	cout << fixed << setprecision(10);
}


Measured memory_bytes: 1024
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 110
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int n,m; //总点数
int Map[MaxN][MaxN],dis[MaxN][MaxN];  //dis[i][j]存储i到j的最短路
pair<int,int> edge[1001];

void Floyd()
{
    int ans = 0;
    for(int k=1;k<=n;k++)
        for(int i=1;i<=n;i++)
            for(int j=1;j<=n;j++)
                if(dis[i][j]>dis[i][k]+dis[k][j])
                {
                    dis[i][j]=dis[i][k]+dis[k][j];
                }

    for(int i=0;i<m;i++)
    {
        int x = edge[i].first, y = edge[i].second;
        if(dis[x][y]<Map[x][y]) ans++;
    }
    printf("%d\n", ans);
}
void init()
{
    for(int i=1;i<=n;i++)
    {
        for(int j=1;j<=n;j++)
        {
            dis[i][j] = dis[j][i] = INF;
        }
    }
}
int main()
{
    //std::ios::sync_with_stdio(false);
    scanf("%d%d", &n, &m);
    init();
    int a,b,c;
    for(int i=0;i<m;i++)
    {
        scanf("%d%d%d", &a, &b, &c);
        Map[a][b] = Map[b][a] = c;
        dis[a][b] = dis[b][a] = c;
        edge[i].first = a, edge[i].second = b;
    }
    Floyd();
   // system("pause");
}


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

int main() {
    int N, M, ans = 0;
    cin >> N >> M;
    vector<long long>H(N+1);
    vector<bool>check(N+1);
    vector<int>A(M), B(M);
    for (int i = 1; i <= N; i++) {
        cin >> H.at(i);
        check.at(i) = true;
    }
    for (int i = 0; i < M; i++) {
        cin >> A.at(i) >> B.at(i);
    }
    for (int j = 0; j < M; j++) {
        if (H.at(A.at(j)) == H.at(B.at(j))) {
            check.at(A.at(j)) = false;
            check.at(B.at(j)) = false;
        }
        else if (H.at(A.at(j)) < H.at(B.at(j))) {
            check.at(A.at(j)) = false;
        }
        else {
            check.at(B.at(j)) = false;
        }
    }
    for (int i = 1; i <= N; i++) {
        if (check.at(i)) {
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 4788
import logging

logging.basicConfig(level=logging.INFO, format="%(message)s")
#logging.disable(logging.CRITICAL)


def main():
    N, K = map(int, input().split())
    A_i = list(map(int, input().split()))
    B_i = [0 for i in range(N)]
    cycle_list = []
    diff_list = []
    cycle = 0
    diff = 0
    counter = 0
    machi = 1

    while counter < N:
        if B_i[machi - 1] == 1:
            diff = cycle_list.index(machi)
            cycle = counter - diff
            diff_list = cycle_list[:diff]
            cycle_list = cycle_list[diff:]
            break
        else:
            counter += 1
            B_i[machi - 1] = 1
            cycle_list.append(machi)
            machi = A_i[machi - 1]

    if K < diff:
        print(diff_list[K])
    else:
        mod_K = (K - diff) % cycle
        print(cycle_list[mod_K])

if __name__ == "__main__":
    main()


Measured memory_bytes: 33972
#include<iostream>
using namespace std;
int main()
{
    int n,s,t=0;
    cin>>n;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            s=i*j;
           if(s==n)
           {
              t=1;
              break;
           }

        }
    }

    if(t==1)
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }

    return 0;
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main() {
    string S; cin >> S;
    int res = 0,tmp=0;
    string a = "ACGT";
    for (auto s : S){
        if (a.find(s)!=string::npos) tmp++;
        else tmp = 0;
        res = max(tmp, res);

    }
    cout << res << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,m;
  cin>>n>>m;
  int x[100000];
  for(int i=0;i<m;i++){
    cin>>x[i];
  }
  sort(x,x+m);
  vector<int> d;
  for(int i=1;i<m;i++){
    d.push_back(x[i]-x[i-1]);
  }
  sort(begin(d),end(d));
  int ans=x[m-1]-x[0];
  for(int i=0;i<min<int>(n-1,d.size());i++){
    ans-=d[d.size()-1-i];
  }
  cout<<ans<<endl;
}

  


Measured memory_bytes: 4240
#include <bits/stdc++.h>
#define SZ(x) ((int) (x).size())
using namespace std;

int main() {
    #ifdef LOCAL_RUN
    freopen("task.in", "r", stdin);
    freopen("task.out", "w", stdout);
    //freopen("task.err", "w", stderr);
    #endif // ONLINE_JUDGE
    ios::sync_with_stdio(false);
    cin.tie(0);


    string s;
    cin >> s;

    int freq[26] = {0};
    int64_t ans = 1;
    int total = 0;
    for (char c: s) {
        ans += total - freq[c - 'a'];
        total += 1;
        freq[c - 'a']++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 720
public class Main {
	public static void main(String[] args) {
		try (java.util.Scanner sc = new java.util.Scanner(System.in)) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			System.out.println(a * b + " " + (a + b) * 2);
		}
	}
}


Measured memory_bytes: 26252
#include<stdio.h>
int M,N,P,i,t[101],s;
int main()
{
	for(;scanf("%d%d%d",&N,&M,&P),M;)
	{
		for(i=1,s=0;i<=N;i++)
		{
			scanf("%d",&t[i]);
			s+=t[i];
		}
		printf("%d\n",t[M]?s*(100-P)/t[M]:0);
	}
	return 0;
}

Measured memory_bytes: 600
import java.io.*;
import java.util.*;
public class Main
{
	
	private void solve()throws Exception
	{
		int n=nextInt();
		int m=nextInt();
		int k=nextInt();
		int c[][]=new int[n+1][m+1];
		for(int i=1;i<=n;i++)
		{	
			String s=nextLine();
			for(int j=1;j<=m;j++)
			{
				if(s.charAt(j-1)=='#')
					c[i][j]=1;
			}	
		}
		int bigmask=(1<<(n+m))-1;
		int ans=0;
		for(int mask=0;mask<=bigmask;mask++)
		{
			int curr=0;
			for(int i=1;i<=n;i++)
				for(int j=1;j<=m;j++)
				{
					int bitrow=(mask>>(i-1))&1;
					int bitcol=(mask>>(n+j-1))&1;
					if(bitrow==0 && bitcol==0)
						curr+=c[i][j];
				}
			if(curr==k)
				ans++;
		}
		out.println(ans);
	}

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

	public void run()throws Exception
	{
		br=new BufferedReader(new InputStreamReader(System.in));
		st=null;
		out=new PrintWriter(System.out);

		solve();
		
		br.close();
		out.close();
	}
	public static void main(String args[])throws Exception{
		new Main().run();
	}
	BufferedReader br;
	StringTokenizer st;
	PrintWriter out;
	String nextToken()throws Exception{
		while(st==null || !st.hasMoreTokens())
		st=new StringTokenizer(br.readLine());
		return st.nextToken();
	}
	String nextLine()throws Exception{
		return br.readLine();
	}
	int nextInt()throws Exception{
		return Integer.parseInt(nextToken());
	}
	long nextLong()throws Exception{
		return Long.parseLong(nextToken());
	}
	double nextDouble()throws Exception{
		return Double.parseDouble(nextToken());
	}
}

Measured memory_bytes: 32988
#include <bits/stdc++.h>
using namespace std;
typedef long long int64;
 
struct BinaryIndexedTree
{
  vector< int64 > data;
  int curr;
   
  BinaryIndexedTree(int sz)
  {
    data.assign(++sz, 0);
    curr = 1;
    while(curr < data.size()) curr <<= 1;
    for(int i = 0; i < data.size(); i++) data[i] = i & -i;
  }
  inline int64 sum(int k)
  {
    int64 ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return(ret);
  }
  inline int upper_bound(int64 w)
  {
    int i = 0;
    for(int k = curr; k > 0; k >>= 1) {
      if(i + k < data.size() && data[i + k] <= w) {
        w -= data[i + k];
        i += k;
      }
    }
    return(i);
  }
  inline void add(int k, int64 x)
  {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};
  
int N, Q;
int X[200000], D[200000], L[200000];
char buff[32];
 
int main()
{
  scanf("%d %d", &N, &Q);
  for(int i = 0; i < Q; i++) {
    scanf("%d %d %d", &X[i], &D[i], &L[i]);
  }
  BinaryIndexedTree xpy(N), xmy(N);
  for(int i = Q - 1; i >= 0; i--) {
    if(D[i] == 1) {
      xmy.add(0, -L[i] * 2);
      xmy.add(xpy.upper_bound(X[i]), L[i] * 2);
    } else {
      xpy.add(xmy.upper_bound(X[i]), L[i] * 2);
    }
  }
  for(int i = 0; i < N; i++) {
    printf("%lld\n", (xpy.sum(i) - xmy.sum(i)) / 2);
  }
}

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

VI a;
int n;
int maxGrade()
{
	int tot = accumulate(ALL(a), 0);
	if(tot % 10 != 0)
		return tot;
	
	sort(ALL(a));

	int ans = 0;
	for(int i = 0; i < n; ++i)
	{
		if(a[i] % 10 == 0)
			continue;
		if((tot - a[i]) % 10 != 0) {
			ans = tot - a[i];
			break;
		}
	}
	return ans;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;
	a = VI(n);

	REP(i, 0, n)
		cin >> a[i];

	cout << maxGrade() << endl;

	return 0;
}

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

int main()
{
	long long A,B,N;
	cin >> A >> B >> N;
	if(N < B) cout << (long long)(A*N/B);
	if(N == B)  cout << (long long)(A*(N-1)/B);
	if(N > B) cout << (long long )(A*(B-1)/B);
	return 0;
	
}


Measured memory_bytes: 3636
typedef long long ll;
#include <bits/stdc++.h>
using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
int main() {
    ll n,m;
    bool ok[100010];
    std::cin >> n>>m;
    Fill(ok,true);
    for (int i = 0; i < m; i++) {
        ll tmp;
        std::cin >> tmp;
        tmp--;
        ok[tmp]=false;
    }
    ll dp[100010];
    Fill(dp,0);
    if(ok[0]){
        dp[0]=1;
    }
    if(ok[1]){
        
        dp[1]=dp[0]+1;
    }else{
    
    }
    for (int i = 2; i < n; i++) {
        if(ok[i])dp[i]=dp[i-1]+dp[i-2];
        dp[i]%=1000000007;
    }
    std::cout << dp[n-1] << std::endl;
}


Measured memory_bytes: 1152
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <iterator>
#include <assert.h>
#include <time.h>
#pragma warning(disable:4996) 
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
const long long MOD = 1000000007;
//const long long MOD = 998244353;
 
using namespace std;


int main(int argc, char* argv[])
{
    int h,n;
    scanf("%d%d", &h, &n);
    int i;
    ll sum=0;
    for(i=0; i<n; i++) {
        int tmp;
        scanf("%d", &tmp);
        sum+=tmp;
    }
    if(sum>=h) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }


    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18;
int mod = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
int cnt[9] = {2,5,5,4,5,6,3,7,6};
string dp[10005];
signed main() {
    int N,M;
    cin >> N >> M;
    vector<bool>A(9,false);
    for(int i = 0; i < M; i++) {
        int a;
        cin >> a;
        a--;
        A[a] = true;
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 0; j < 9; j++) {
            if(A[j]) {
                if(i >= cnt[j]) {
                    if(i-cnt[j] != 0 && dp[i-cnt[j]] == "") {
                        continue;
                    }
                    bool ok = false;
                    string S = dp[i-cnt[j]];
                    for(int k = 0; k < S.size(); k++) {
                        if(S[k]-'0' <= j) {
                            ok = true;
                            S = S.substr(0,k)+to_string(j+1)+S.substr(k,S.size()-k);
                            break;
                        }
                    }
                    if(!ok) {
                        S += to_string(j+1);
                    }
                    if(dp[i].size() < S.size()) {
                        dp[i] = S;
                    }
                    else if(dp[i].size() == S.size() && dp[i] < S) {
                        dp[i] = S;
                    }
                }
            }
        }
    }
    cout << dp[N] << endl;
}


Measured memory_bytes: 32504
import java.util.*;
 
public class Main {
  public static void main(final String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt(); 
    
    if(K==1){
      System.out.println(0);
    }else{
      System.out.println(N-K);
    }
  }
}

Measured memory_bytes: 35624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;
    ll a[n];
    rep(i, n){
        cin >> a[i];
    }

    sort(a, a+n);
    reverse(a, a+n);

    queue<ll> que_gen, que_pnt;
    rep(i, n){
        que_gen.push(a[i]);
    }

    que_pnt.push(que_gen.front());
    que_gen.pop();

    ll ans = 0;
    while(!que_gen.empty()){
        ans += que_pnt.front();
        que_pnt.pop();
        que_pnt.push(que_gen.front());
        que_pnt.push(que_gen.front());
        que_gen.pop();
    }

    cout << ans << endl;


}

Measured memory_bytes: 6920
#include <bits/stdc++.h>
using namespace std;
bool solve(vector<int> const &v, int target) {
    vector<map<int, bool>> dp(v.size() + 1);

    dp[0][0] = true;
    for (int i = 0; i < v.size(); i++) {
        for (auto const &pair: dp[i]) {
            dp[i+1][pair.first + v[i]] = true;
            dp[i+1][pair.first - v[i]] = true;
        }
    }
    return dp[v.size()][target];
}
int main(void)
{
    string s;
    vector<int> v[2];
    int init_x = 0;
    bool first = true;
    bool just_changed = true;
    int dir = 0; // 0: x, 1: y

    cin >> s;
    for (int i = 0; i < s.size(); i++) {
        switch (s[i]) {
            case 'F':
                if (just_changed) {
                    just_changed = false;
                    v[dir].push_back(1);
                } else {
                    v[dir].back()++;
                }
                break;
            case 'T':
                dir++;
                dir &= 1;
                if (first && !v[0].empty()) {
                    init_x = v[0][0];
                    v[0].erase(v[0].begin());
                    assert(v[0].size() == 0 && v[1].size() == 0);
                }
                first = false;
                just_changed = true;
                break;
        }
    }

    int x, y;
    cin >> x >> y;
    if (first && !v[0].empty()) {
        init_x = v[0][0];
        v[0].erase(v[0].begin());
        assert(v[0].size() == 0 && v[1].size() == 0);
    }

    cout << ((solve(v[0], x - init_x) && solve(v[1], y)) ? "Yes" : "No") << endl;
    
    return 0;
}


Measured memory_bytes: 167296
import math
# N = int(input())
D, G = [int(i) for i in input().split()]
problems = []
for i in range(D):
    p, c = [int(_) for _ in input().split()]
    bit = 0
    problems.append([p, c])

ans = 1001
for i in range(2**D):
    score = 0
    p_num = 0
    for j, p in enumerate(problems):
        if i >> j & 1:
            score += p[0] * 100 * (j + 1) + p[1]
            p_num += p[0]
    if score < G:
        rest = G - score
        for j in range(D-1, -1, -1):
            if i >> j & 1:
                continue
            n = math.ceil(rest / (100 * (j + 1)))
            if n <= problems[j][0] - 1:
                rest -= n * 100 * (j + 1)
                p_num += n
                break
            rest -= problems[j][0] * 100 * (j + 1)
            p_num += problems[j][0]
        if rest <= 0:
            ans = min(ans, p_num)
    else:
        ans = min(ans, p_num)
print(ans)


Measured memory_bytes: 41456
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    ll h;
    cin >> h;
    int k=0;
    while(h/2>0){
        k++;h/=2;
    }
    ll ans=pow(2,k+1)-1;
    cout << ans;
    return 0;
}

Measured memory_bytes: 3992