akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  n, l = map(int, input().strip().split())
  if l <= 0 <= l+n-1:
    print(l*n + ((n * (n-1))//2))
  elif l < 0:
    print(l*(n-1) + (((n-1) * (n-2))//2))
  elif l > 0:
    print(l*(n-1) + ((n * (n-1))//2))

if __name__=='__main__':
  main()



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, j, k) for(int i=j; i<=k; i++)
#define FFOR(i, j, k) for(int i=j; i<k; i++)
#define DFOR(i, j, k) for(int i=j; i>=k; i--)
#define bug(x) cerr<<#x<<" = "<<x<<'\n'
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
template <typename T> inline void read(T &x){
    char c;
    bool nega=0;
    while((!isdigit(c=getchar()))&&(c!='-'));
    if(c=='-'){
        nega=1;
        c=getchar();
    }
    x=c-48;
    while(isdigit(c=getchar())) x=x*10+c-48;
    if(nega) x=-x;
}
template <typename T> inline void writep(T x){
    if(x>9) writep(x/10);
    putchar(x%10+48);
}
template <typename T> inline void write(T x){
    if(x<0){
        putchar('-');
        x=-x;
    }
    writep(x);
}
template <typename T> inline void writeln(T x){
    write(x);
    putchar('\n');
}
#define taskname "D"
ll x[100001];
int n;
ll a, b;
int main(){
    #ifdef Megumin
        if(fopen(taskname".inp", "r"))
            freopen(taskname".inp", "r", stdin);
    #endif // Megumin
    read(n);
    read(a);
    read(b);
    FOR(i, 1, n) read(x[i]);
    ll ans=0;
    FOR(i, 2, n) ans+=min((x[i]-x[i-1])*a, b);
    writeln(ans);
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<stdlib.h>
#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007

using namespace std;


int main(void) {
	int n, m, k;
	bool flag = false;
	int *dp;
	int p = 1;

	cin >> n >> m >> k;

	dp = new int[(n + 2)*(m + 2)]();
	FOR(i, 0, n) {
		FOR(t, 0, m) {
			dp[p] = (m - t)*i + t*(n - i);
			p++;
		}
	}
	FOR(i, 0, p-1) {
		if (dp[i] == k) {
			flag = true;
			break;
		}
	}
	
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	delete[] dp;
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min(a * b, min(a * c, b * c)) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
// Author: getharshkumar

#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
const ll N = 1e6 + 6, M = 1e9 + 7;
ll a[N];
int main()
{
    ios::sync_with_stdio(false), cin.tie(nullptr);
    ll n, x = 1, s = 0;
    cin >> n;
    for (ll i = 0; i < n; i++, x *= -1)
        cin >> a[i], s += x * a[i];
    s /= 2;
    for (ll i = 0; i < n; i++)
        cout << 2 * s << " ", s = a[i] - s;
    return 0;
}

Measured memory_bytes: 2176
import java.util.*;
public class Main {
        static Scanner sc = new Scanner(System.in);
        static void myout(Object t){System.out.println(t);}//standard output
        static void myerr(Object t){System.err.println(t);}//standard error
        static String getStr(){return sc.next();}
        static int getInt(){return Integer.parseInt(getStr());}
        static long getLong(){return Long.parseLong(getStr());}
        static boolean isNext(){return sc.hasNext();}
        static String[] mySplit(String str){return str.split("");}
        public static void main(String[] args){
          long N = getLong();
          long output = (long)( Math.ceil((double)N / 11) )*2;
          long amari = N % 11;
          if(amari != 0 && amari <= 6){
            output--;
          }
          myout(output);
        }
        //便利メソッド追加枠ここから

        //便利メソッド追加枠ここまで
}


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

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int inf_int = 1e9 + 100;
const ll inf_ll = 1e15;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double dbl;
#define pb push_back
const double pi = 3.1415926535898;
#define dout if(debug) cout
#define fi first
#define se second
#define sp setprecision
#define sz(a) (int(a.size()))
#define all(a) a.begin(),a.end()
bool debug = 0;
const int MAXN = 2e5 + 100;
const int LOG = 20;
const int mod = 1e9 + 7;
const int MX = 1e6 + 100;
typedef long long li;
const li MOD = 1000000000949747713ll;

struct Fenwick_tree {
    ll t[MAXN];

    Fenwick_tree() {
        memset(t, 0, sizeof t);
    }

    void upd(int pos, ll val) {
        for (; pos < MAXN; pos = (pos | (pos + 1))) {
            t[pos] = max(t[pos], val);
        }
    }

    ll get(int r) {
        ll res = 0;
        for (; r >= 0; r = (r & (r + 1)) - 1) {
            res = max(res, t[r]);
        }
        return res;
    }
};

typedef vector<vector<ll> > matrix;

ll SQR = 1ll * mod * mod;

void add_sqr(ll &a, ll val) {
    a += val;
    if (a >= SQR)
        a -= SQR;
}

matrix mult(matrix &a, matrix &b) {
    int n = sz(a);
    int m = sz(b[0]);
    int k = sz(a[0]);
    assert(sz(a[0]) == sz(b));
    matrix res(n, vector<ll>(m));
    for (int i = 0; i < n; ++i) {
        for (int e = 0; e < m; ++e) {
            ll val = 0;
            for (int j = 0; j < k; ++j) {
                add_sqr(val, a[i][j] * b[j][e]);
            }
            res[i][e] = val % mod;
        }
    }
    return res;
}

matrix bin_pow(matrix &a, ll n) {
    matrix res(sz(a), vector<ll>(sz(a)));
    for (int i = 0; i < sz(a); ++i) {
        res[i][i] = 1;
    }

    while (n) {
        if (n & 1) {
            res = mult(res, a);
        }
        a = mult(a, a);
        n >>= 1;
    }
    return res;
}

ll dp[1<<16];
ll cost[1<<16];

int a[16][16];
void solve() {
    int n;
    cin >> n;
    for(int i=0;i<n;++i){
        for(int e=0;e<n;++e){
            cin >> a[i][e];
        }
    }
    for(int mask = 0;mask<(1<<n);++mask){
        for(int i=0;i<n;++i){
            if(mask&(1<<i)){
                for(int j=i+1;j<n;++j){
                    if(mask&(1<<j)){
                        cost[mask]+=a[i][j];
                    }
                }
            }
        }
        dp[mask] = -inf_ll;
    }
    dp[0] = 0;

    for(int mask=0;mask<(1<<n);++mask){
        int other = ((1<<n)-1)^mask;
        for(int nxt_mask = other;nxt_mask;nxt_mask=((nxt_mask - 1)&other) ){
            dp[mask | nxt_mask] = max(dp[mask | nxt_mask],dp[mask] + cost[nxt_mask]);
        }
    }
    cout << dp[(1<<n)-1];
}

signed main() {
#ifdef zxc
    debug = 1;
    freopen("../input.txt", "r", stdin);
#else

#endif //zxc
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.precision(20);

    int t = 1;

    while (t--)
        solve();
    dout << endl << (1.0 * clock() / CLOCKS_PER_SEC) << endl;
}

Measured memory_bytes: 1280
MOD = 10 ** 9 + 7
cnt = [1 for _ in range(26)]
n = int(input())
string = input()
for s in string:
    cnt[ord(s) - 97] += 1
ans = 1
for num in cnt:
    ans *= num
    ans %= MOD
print((ans - 1) % MOD)

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


// --- FIX begin --- cut here ---
template<typename F>
class FixPoint : private F {
public:
  explicit constexpr FixPoint(F&& f) noexcept : F(forward<F>(f)) {}

  template<typename... Args>
  constexpr decltype(auto) operator()(Args&&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template<typename F>
static inline constexpr decltype(auto) fix(F&& f) noexcept {
  return FixPoint<F>{forward<F>(f)};
}
// --- FIX end --- cut here ---

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  int N, K; cin >> N >> K;
  vector<int> A(N);
  vector<vector<int>> src(N);
  for (int i = 0; i < N; i++) {
    int a; cin >> a; a--;
    A.at(i) = a;
    if (i > 0) src.at(a).push_back(i);
  }
  int cnt = 0;
  auto dfs = fix([&](const auto& recF, int x) -> int {
      int dd = 0;
      for (int y : src.at(x)) dd = max(dd, recF(y));
      if (x == 0 || dd + 1 == K) {
	if (A.at(x) != 0) cnt++;
	return 0;
      }
      return dd + 1;
    });
  dfs(0);
  cout << cnt << endl;

  return 0;
}



Measured memory_bytes: 10240
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long N; cin >> N;
  int lim = pow(N, 0.5) + 1;
  int temp_count, i, ans = 0;
  for(int d = 2; d <= lim; d++){
    if(N % d == 0){
      temp_count = 0, i = 1;
      while(N % d == 0){
        if(N % (long long)(pow(d, i)) == 0){
          temp_count += 1;
          N = N / (long long)(pow(d, i));
          i++;
        }
        else N = N / d;
      }
      ans += temp_count;
    }
    if(N == 1) break;
  }
  if(N != 1) ans += 1;
  cout << ans;
  return 0;
}

Measured memory_bytes: 4084
#include <bits/stdc++.h>
    
using namespace std;
typedef long long ll;
    
int main()
{
    int H, A;
    cin >> H >> A;
    
    if (H%A == 0) {
        cout << H/A;
    } else {
        cout << H/A+1;
    }

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define repr(i,from,to) for(int (i)=(from);(i)<(to);(i)++)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
// const bool debug=true;
const bool debug=false;
#define DEBUG if(debug==true)
#define vprint(x) for(auto a:(x)) cout << x << endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 1000000007;
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;
}
int main(void) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;cin>>s;
    int n = s.size();
    if(s[n-1]=='1'||s[0]=='0'){
        cout << -1 << endl;
        return 0;
    }
    rep(i,n-1){
        if(s[i]!=s[n-i-2]){
            cout << -1 << endl;
            return 0;
        }
    }
    vector<pair<int,int>> edges;
    int source = 1;
    int target = 2;
    int cnt = 2;
    repr(i,0,n){
        target = i+2;
        edges.push_back(make_pair(source,target));
        if(s[i]=='1'){
            source = i+2;
        }
    }
    rep(i,n-1){
        cout << edges[i].first << " " << edges[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 2372
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String one = br.readLine();
		String two = br.readLine();
		int count = 0;
		for (int i = 0; i < one.length(); i++) {
			if (one.charAt(i) != two.charAt(i)) {
				++count;
			}
		}
		System.out.println(count);

	}
}


Measured memory_bytes: 37256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = (1ll << 31) - 1;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template<typename T>
struct RangeUpdateQuery {
	int n;
	vector<int>d;
	RangeUpdateQuery(int m) {
		for (n = 1; n < m; n <<= 1);
		d.assign(2 * n, INF);
	}
	int find(int i) {
		update(i, i + 1);
		return d[n + i];
	}
	void update(int a, int b, int x=-1, int k = 1, int l = 0, int r = -1) {
		if (r < 0)r = n;

		if (r <= a || b <= l)return;
		else if (a <= l&&r <= b) {
			if (x >= 0)d[k] = x;
			return;
		}
		else {
			if (d[k] != INF)d[2 * k] = d[2 * k + 1] = d[k], d[k] = INF;
			update(a, b, x, 2 * k, l, (l + r) / 2);
			update(a, b, x, 2 * k + 1, (l + r) / 2, r);
		}
	}
};
signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, q; cin >> n >> q;
	RangeUpdateQuery<int>ruq(n);
	rep(i, 0, q) {
		int com; cin >> com;
		if (com) {
			int x; cin >> x;
			cout << ruq.find(x) << endl;
		}
		else {
			int s, t, x; cin >> s >> t >> x;
			ruq.update(s, t + 1, x);
		}
	}
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s[0]==s[1]&&s[1]==s[2]){
    cout<<"Yes"<<endl;
  }
  else if(s[1]==s[2]&&s[2]==s[3]){
    cout<<"Yes"<<endl;
  }
  
  else{
    cout<<"No"<<endl;
  }
}


Measured memory_bytes: 256
K = int(input())
S = input()
L = len(S)
MOD = 10 ** 9 + 7

factorials = [1]
fact_invs = [1]
for i in range(1, L+K+1):
    factorials.append((factorials[-1]*i) % MOD)
    fact_invs.append(pow(factorials[-1], MOD-2, MOD))

ans = 1
for i in range(K):
    b = L + i
    a = L - 1
    nans = factorials[b]
    nans *= fact_invs[a]
    nans %= MOD
    nans *= fact_invs[b-a]
    nans %= MOD
    nans *= pow(25, b-a, MOD)
    nans %= MOD
    nans += ans * 26
    nans %= MOD
    ans = nans
print(ans)


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

int main()
{
    int N, M; cin >> N >> M;

    auto adjacency_list = vector<vector<int>>(N);
    for (auto i = 0; i < M; i++)
    {
        int a, b; cin >> a >> b;
        a--; b--;
        adjacency_list[a].push_back(b);
        adjacency_list[b].push_back(a);
    }

    int Q; cin >> Q;
    struct Operation { int center, radius, color; };
    auto operations = vector<Operation>(Q);
    for (auto& op : operations)
    {
        cin >> op.center >> op.radius >> op.color;
        op.center--;
    }
    reverse(begin(operations), end(operations));

    auto colors = vector<int>(N), already = vector<int>(N, -1);
    const function<void(int, int, int)> dfs = [&](const int v, const int radius, const int color)
    {
        if (already[v] >= radius) return;
        else already[v] = radius;

        if (colors[v] == 0) colors[v] = color;

        if (radius >= 0)
            for (const auto w : adjacency_list[v])
                dfs(w, radius-1, color);
    };

    for (const auto op : operations)
        dfs(op.center, op.radius, op.color);

    for (const auto x : colors) cout << x << "\n";
}


Measured memory_bytes: 8440
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

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

  int n;  
  cin >> n;
  vector<int> w(n);
  REP(i, n) cin >> w[i];

  int ans = 1e9;
  REP(i, n){
    int sum1 = 0, sum2 = 0;
    FOR(j, 0, i){
      sum1 += w[j];
    }
    FOR(j, i, n){
      sum2 += w[j];
    }
    ans = min(abs(sum1-sum2), ans);
  }

  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define ll long long
#define N 105
#define mod 1000000007
using namespace std;
ll n,f[N][N],h[N],w[N],tot;
inline ll ksm(ll x,ll p){
	if(p<0)return 1;
	ll ret=1;
	while(p){
		
		if(p&1)ret=ret*x%mod;
		x=x*x%mod;
		p>>=1;
	}
	return ret;
}
int main(){
	scanf("%lld",&n);
	for(ll i=1;i<=n;++i)scanf("%lld",&h[i]),w[++tot]=h[i];
	sort(w+1,w+tot+1);
	tot=unique(w+1,w+tot+1)-w-1;
	for(ll i=1;i<=n;++i)h[i]=lower_bound(w+1,w+tot+1,h[i])-w;
	f[0][0]=1;
	for(ll i=1;i<=n;++i){
		for(ll j=h[i]+1;j<=h[i-1];++j)(f[i][0]+=f[i-1][j]*2%mod)%=mod;
		(f[i][0]+=f[i-1][0]*2%mod)%=mod;
		for(ll j=1;j<=h[i];++j){
			f[i][j]=(ll)f[i-1][j]*ksm(2,w[h[i]]-w[h[i-1]])%mod;
			if(h[i-1]>=j)continue;
			if(j>1)(f[i][j]+=(ll)f[i-1][0]*(ksm(2,w[j]-w[j-1])-1)%mod*2%mod*ksm(2,w[h[i]]-w[j])%mod)%=mod;
			else (f[i][j]+=(ll)f[i-1][0]*(ksm(2,w[j])-2)%mod*ksm(2,w[h[i]]-w[j])%mod)%=mod;
		}
	}
	ll ans=0;
	for(ll i=0;i<=tot;++i)(ans+=f[n][i])%=mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 384
from itertools import permutations
from math import sqrt

n=int(input())
lst=[list(map(int,input().split())) for i in range(n)]

kyori=[]
for i in range(n):
    kyori.append([])

for i in range(n):
    for j in range(n):
        kyori[i].append(sqrt((lst[i][0]-lst[j][0])**2 + (lst[i][1]-lst[j][1])**2))

pmt=list(permutations(range(0,n)))
ans=0
for i in range(len(pmt)):
    for j in range(n-1):
        ans+=kyori[pmt[i][j]][pmt[i][j+1]]

print(ans/len(pmt))

Measured memory_bytes: 80188
#include <bits/stdc++.h>
using namespace std;
#define itn int
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) x.begin(), x.end()
#define pb  push_back
#define mb  make_pair
#define fi  first
#define se  second

typedef vector<int> vi;
typedef long long ll;
typedef pair<int, int> pii;
const ll mod = 1000000007;

void solve()
{
    ll x;
    cin >> x;
    for(ll i = -120; i < 121; i++)
    {
        for(ll j = -120; j < 121; j++)
        {
            if(pow(i,5)-pow(j,5) == x)
            {
                cout <<  i << " " << j;
                return;
            }
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    //int t; cin >> t; while(t--)
    solve();
	return 0;
}


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

#define MAX 200000

int main() {
	long long N, T, t[MAX], X = 0;
	cin >> N >> T;
	for (int i = 0; i < N; i++)
		cin >> t[i];
	for (int i = 0; i < N - 1; i++)
		X += min(t[i + 1] - t[i], T);
	X += T;
	cout << X << endl;
	return 0;
}


Measured memory_bytes: 1792
def findDivisors(n): 
      
    # List to store the count 
    # of divisors 
    div = [0 for i in range(n + 1)] 
      
    # For every number from 1 to n 
    for i in range(1, n + 1): 
          
        # Increase divisors count for 
        # every number divisible by i 
        for j in range(1, n + 1): 
            if j * i <= n: 
                div[i * j] += 1
            else:
              break
    return div

n=int(input())
ans=0
dp=findDivisors(n)
for i in range(len(dp)):
	ans+=(dp[i]*(i))
#print(*dp)
print(ans)

Measured memory_bytes: 224964
import java.time.LocalDate;
import java.util.Scanner;

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

		int[] day1 = new int[2];
		int[] day2 = new int[2];

		for (int i = 0; i < day1.length; i++) {
			day1[i] = scanner.nextInt();
		}
		for (int i = 0; i < day2.length; i++) {
			day2[i] = scanner.nextInt();
		}
		scanner.close();

		LocalDate day11 = LocalDate.of(2019, day1[0], day1[1]);
		LocalDate day22 = LocalDate.of(2019, day2[0], day2[1]);

		if (day2[0]> day1[0]) {
			if(day11.plusDays(1).equals(day22)) {
				System.out.println("1");
			}
		}else {
			System.out.println("0");
		}
	}
}

Measured memory_bytes: 26708
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt();
        int n = sc.nextInt();
        ArrayList<Integer> list = new ArrayList<>();
        int nowMin = Integer.MAX_VALUE;
        for (int i = 0; i < n; i++) {
            list.add(sc.nextInt());
        }
        if (!list.contains(x)) {
            System.out.println(x);
            return;
        }
        int min = x - 1;
        int max = x + 1;
        while (true) {
            if (!list.contains(min)) {
                System.out.println(min);
                return;
            }
            min--;
            if (!list.contains(max)) {
                System.out.println(max);
                return;
            }
            max++;
        }
    }
}

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

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	long long A, B; cin >> A >> B;
	if (A % 2 != B % 2) {
		cout << "IMPOSSIBLE\n";
	} else {
		cout << (A+B)/2 << '\n';
	}

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 
  int N;
  cin >> N;
  
  int A[N];
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  
  int64_t count = 0;
  
  for (int i = 1; i < N; i++) {
    if(A[i-1] > A[i]){
      count += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }
  
  cout << count << endl;

}

Measured memory_bytes: 4320
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

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

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;

ll a[N];
int main() {ikarus_101

    ll n,m,i,j,k,x;

    mem(a,0);
    cin >> n;

    for(i=1;i<=100;i++)
    {
        for(j=1;j<=100;j++)
        {
            for(k=1;k<=n;k++)
            {
                x = sqr(i+j) + sqr(j+k) + sqr(k+i);
                ll idx = x/2;
                if(idx*10 < N) a[idx]++;
            }
        }
    }
    rep1(i,n) cout << a[i] << nn;












}


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

int main() {
  // input
  int N;  cin >> N;
  vector<int> spots(N);
  for (int i = 0; i < N; i++) {
    cin >> spots.at(i);
  }
  
  // sum
  int sum = 0;
  for (int i = 0; i < N - 1; i++) {
    sum += abs(spots.at(i) - spots.at(i + 1));
  }
  sum += abs(spots.at(0)) + abs(spots.at(N - 1));
  
  // output
  int ans;
  ans = sum - abs(spots.at(0)) - abs(spots.at(0) - spots.at(1)) + abs(spots.at(1));
  cout << ans << endl;
  for (int i = 1; i < N - 1; i++) {
    if (spots.at(i - 1) <= spots.at(i + 1)) {
      if (spots.at(i) < spots.at(i - 1)) ans = sum - (spots.at(i - 1) - spots.at(i)) * 2;
      else if (spots.at(i + 1) < spots.at(i)) ans = sum - (spots.at(i) - spots.at(i + 1)) * 2;
      else ans = sum;
    }
    if (spots.at(i + 1) < spots.at(i - 1)) {
      if (spots.at(i) < spots.at(i + 1)) ans = sum - (spots.at(i + 1) - spots.at(i)) * 2;
      else if (spots.at(i - 1) < spots.at(i)) ans = sum - (spots.at(i) - spots.at(i - 1)) * 2;
      else ans = sum;
    }
    cout << ans << endl;
  }
  ans = sum - abs(spots.at(N - 1)) - abs(spots.at(N - 2) - spots.at(N - 1)) + abs(spots.at(N - 2));
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 1664
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<stack>
#include<queue>
using namespace std;
typedef long long ll;

const int maxn = 2000010;

ll n;
int cnt;
char nam[maxn];

ll read(){ ll s=0,f=1; char ch=getchar(); while(ch<'0' || ch>'9'){ if(ch=='-') f=-1; ch=getchar(); } while(ch>='0' && ch<='9'){ s=s*10+ch-'0'; ch=getchar(); } return s*f; }

int main(){
	n=read();
	while(n){
		n--;
		int t = n % 26;
		nam[++cnt] = 'a' + t;
		n /= 26;
	}
	
	for(int i = cnt;i >= 1;i--) printf("%c",nam[i]);
	
	return 0;
}

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

int main()
{
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    if (s.compare(u) == 0)
        a--;
    else
        b--;
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 3632
import numpy as np
import copy

d=int(input())
c=np.array(list(map(int,input().split())))
curc=copy.deepcopy(c)
s=[]
ans=[]
score=0
for i in range(d):
    s.append(list(map(int,input().split())))

for i in range(d):
    t=int(input())
    score+=s[i][t-1]
    curc[t-1]=0
    score-=sum(curc)
    curc+=c
    print(score)

Measured memory_bytes: 27224
using System;
using System.Linq;

class Sine
{
    static void Main()
    {
        int[] input = Console.ReadLine().Split(' ').Select(a => int.Parse(a)).ToArray();
        var k = input[0];
        var x = input[1];

        var min = x - (k - 1);
        var max = x + (k - 1);

        for (int i = min; i <= max; i++)
        {
            Console.WriteLine(i);
        }
    }
}

Measured memory_bytes: 13268
using System;

public class Program
{
	public static void Main(string[] args)
	{
		//var ss = new StreamScanner();
		//---------------------------------
		//????????????int, double, string?????????????????£????????????
	
		while (true)
		{

			string str = Console.ReadLine();
			if (str == "-")
			{
				break;
			}
			string ans = str;
			string strM = Console.ReadLine();
			int m = int.Parse(strM);



			for (int i = 0; i < m; i++)
			{
				string strH = Console.ReadLine();
				int h = int.Parse(strH);
				ans = ans.Substring(h, ans.Length - h) + ans.Substring(0, h);
			}

			Console.WriteLine(ans);




		}


		//int x = ss.Next<int>();
		//double d = ss.Next<double>();
		//string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		//int[] array = ss.Next<int>(10);
		//---------------------------------

	}
}
public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 8948
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B;
string S, T;
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

mat dp(1e+6 + 10, vec(4, 0));
int main() {
    cin>>S;
    reverse(ALL(S));
    rep(i,S.size()){
        int a = S[i] - '0';
        dp[i][0] = a + (i ? min(dp[i-1][0], dp[i-1][1] + 1) : 0);
        dp[i][1] = 10 - a + (i ? min(dp[i-1][0], dp[i-1][1] - 1) : 0);
    }
    cout<<min(dp[S.size() - 1][0], dp[S.size() - 1][1] + 1)<<endl;
}

Measured memory_bytes: 71684
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
ll Q=1000000007;

int main(){
  ll N;
  cin >> N;
  ll count=N;
  for(ll x=1;x*x<=N;x++){
    if(N%x==0){
      count = min(count,x+N/x-2);
    }
  }
  cout << count << endl;
}

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

int main() {
  int a, b, c;
  cin >> a >> b;
  if(b < 10)
    c = a * 10 + b;
  else if(b < 100)
    c = a * 100 + b;
  else
    c = a * 1000 + b;
  for(int i = 1; i < 317; i++) {
    if(i * i == c) {
      printf("Yes\n");
      return 0;
    }
  }
  printf("No\n");
}

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

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int n;
	cin >> n;
	int cnt = 0;
	bool flag =false;
	while (n--) {
		int x, y;
		cin >> x >> y;
		if (x == y)	cnt++;
		else	cnt = 0;

		if(cnt == 3)	flag = true;
	}
	if (flag) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}


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

#define rep(i,N) repf(i,0,N)
#define reps(i,N) repfs(i,0,N)
#define repf(i,a,b) for(int i=a;i<b;i++)
#define repfs(i,a,b) for(int i=a+1;i<=b;i++)
#define repr(i,N) for(int i=N-1;i>=0;i--)
#define reprs(i,N) for(int i=N;i>0;i--)

#define d(a) if(isDebugMode) cout<<#a<<"="<<a<<"."
#define d2(a,b) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<"."
#define d3(a,b,c) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<"."
#define d4(a,b,c,d) if(isDebugMode) cout<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<","<<#d<<"="<<d<<"."
#define da(arr,N){if(isDebugMode){rep(i,N){if(arr[i]==INF)printf("INF ");else cout<<arr[i]<<" ";} cout<<endl;}}
#define da2(arr,N,M){if(isDebugMode)rep(i,N){rep(j,M){if(arr[i][j]==INF)printf(" INF");else printf(" %3d",arr[i][j]);}cout<<endl;}}
#define pb push_back
#define pob pop_back

auto chmax =[](int &a,int b){ a = max(a, b);};
auto chmin =[](int &a,int b){ a = min(a, b);};

typedef long long ll;
typedef pair<int,int> P;
const int INF = 100000000;
const int MOD = 1000000007;
const int dx[4] = { 0, 1, 0,-1};
const int dy[4] = { 1, 0,-1, 0};

bool isDebugMode=1;
//--------------------------------------//
ll n;

int q[]={3,5,7};

int hatena(int c){
	bool b[3]={};
	int cc=c;
	while(c!=0){
		if(c%10==3)b[0]=true;
		if(c%10==5)b[1]=true;
		if(c%10==7)b[2]=true;
		c/=10;
	}
	return n>=cc&&b[0]&&b[1]&&b[2]?1:0;
}
int bfs(int d,int n){
	if(d==0) return hatena(n);
	int rec=0;
	rep(i,3){
		rec+=bfs(d-1,n*10+q[i]);
	}
	return rec;
}
void solve(){
	ll ans=0;
	int c=3;
	int a=0;
	repf(c,3,11){
		ans+=bfs(c,0);
	}
	cout<<ans<<endl;
}

int main(){
	cin>>n;
	solve();
	return 0;
}


Measured memory_bytes: 256
def main():
    N, M = map(int, input().split())
    query = [ [int(a) for a in input().split()] for i in range(M)]
    query.sort(key=lambda x : x[0])
    mid = set()

    possible = False
    for q in query:
        a = q[0]
        b = q[1]

        if a == 1:
            mid.add(b)

        if b == N:
            if a in mid:
                possible = True
                break
    if possible:
        print("POSSIBLE")
    else:
        print("IMPOSSIBLE")
if __name__ == "__main__":
    main()

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

int main(){
  int sum = 0;
  vector<int> A(3);
  cin >> A[0] >> A[1] >> A[2];
  int ans = 0;
  if(A[0]%2 == A[1]%2 && A[1]%2 == A[2]%2) ;
  else if(A[0]%2 == A[1]%2){
    A[0] +=1;
    A[1] +=1;
    ans  +=1;
  }
  else if(A[0]%2 == A[2]%2){
    A[0] +=1;
    A[2] +=1;
    ans  +=1;
  }
  else{
    A[1] +=1;
    A[2] +=1;
    ans  +=1;
  }
  sort(A.begin(),A.end());
  ans += (2*A[2]-A[1]-A[0])/2;
  cout << ans << endl;
}

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

int main() {
	int h, w;
	cin >> h >> w;
	vector<vector<int>> a(h, vector<int>(w));
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			cin >> a[i][j];
			a[i][j] = !a[i][j];
		}
	}
	for (int i = 1; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (a[i][j] == 0) {
				continue;
			}
			a[i][j] += a[i - 1][j];
		}
		a[i].emplace_back(0);
	}
	int ans = 0;
	for (int i = 0; i < h; i++) {
		int tmp = 0;
		stack<pair<int, int>> st;
		for (int j = 0; j <= w; j++) {
			if (st.empty() || st.top().first < a[i][j]) {
				st.emplace(make_pair(a[i][j], j));
			} else {
				if (a[i][j] < st.top().first) {
					int target = j;
					while (!st.empty() && a[i][j] <= st.top().first) {
						int height = st.top().first;
						int pos = st.top().second;
						st.pop();
						int area = height * (j - pos);
						tmp = max(tmp, area);
						target = pos;
					}
					st.emplace(make_pair(a[i][j], target));
				}
			}
		}
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16996
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef long double ld;
typedef vector<vector<ll> > mat;

ll n,k,p[5005],c[5005],ans;


int main()
{ios_base::sync_with_stdio(false);
cin.tie(0);
cin>>n>>k;
rep(i,1,n)cin>>p[i];
rep(i,1,n)cin>>c[i];

ans=c[1];
rep(i,1,n)
{
	ans=max(ans,c[i]);
}

rep(i,1,n)
{
	vii cyc;
	int at=p[i];
	cyc.pb(i);
	while(1)
	{
		if(at==i)break;
		cyc.pb(at);
		at=p[at];
	}
	vll pre;
	ll s=0,sz=cyc.size();
	rep(j,0,sz-1)
	{
		s+=c[cyc[j]];
		pre.pb(s);
	}
	ll rot=k/sz,s1=-1e18,s2=-1e18,s3=-1e18;
	rep(j,0,sz-1)
	{
		if(j+1<=k)s1=max(s1,pre[j]);
		if(rot*sz+j+1<=k)s2=max(s2,rot*s+pre[j]);
		if(rot>=1&&(rot-1)*sz+j+1<=k)s3=max(s3,(rot-1)*s+pre[j]);
	}
	ans=max(ans,s1);
	ans=max(ans,max(s2,s3));
}
ol(ans);
return 0;
}



Measured memory_bytes: 3796
#include <iostream>
#include <stdio.h>
using namespace std;

int main(void)
{
	float a, b, c, d, e, f;

	while (cin >> a >> b >> c >> d >> e >> f)
	{
		float x = (c * e - b * f) / (a * e - b * d);
		float y = (c * d - a * f) / (b * d - a * e);
		if (x == -0) x = 0;
		if (y == -0) y = 0;
		printf("%.3f %.3f\n", x, y);
	}
	return 0;

}


Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0, max_i = (n); i < max_i; i++)
#define REPI(i, a, b) for (int i = (a), max_i = (b); i < max_i; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define fi first
#define se second
#define int long long
using namespace std;
using ll = long long;
using II = pair<int, int>; using VII = vector<II>; using VVII = vector<VII>;
using VI = vector<int>; using VVI = vector<VI>; using VVVI = vector<VVI>;
template <class T> using V = vector<T>; template <class T> using VV = V<V<T>>; template <class T> using VVV = V<VV<T>>;
template <class T = int> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template <class T = int> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }
template <class T> ostream& operator<<(ostream &s, const vector<T>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : " "); return s; }
template <class T> ostream& operator<<(ostream &s, const vector<vector<T>>& d) { REP (i, d.size()) s << d[i] << (i == d.size() - 1 ? "" : "\n"); return s; }
template <class T, class S> ostream& operator<<(ostream &s, const pair<T, S>& p) { s << "{" << p.first << ", " << p.second << "}"; return s; }
template <class T, class S> ostream& operator<<(ostream& s, const map<T, S> m) { for (auto it = m.begin(); it != m.end(); it++) { s << *it << (next(it) == m.end() ? "" : "\n"); } return s; }
#ifdef _MY_DEBUG
  #define dump(...) cerr << "/* " << #__VA_ARGS__ << " :[" << __LINE__ << ":" << __FUNCTION__ << "]" << endl, dump_func(__VA_ARGS__), cerr << "*/\n\n";
#else
  #define dump(...)
#endif
void dump_func() { cerr << endl; }
template <class Head, class... Tail> void dump_func(Head&& h, Tail&&... t) { cerr << h << (sizeof...(Tail) == 0 ? "" : ", "), dump_func(forward<Tail>(t)...); }
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); } } fast;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
constexpr int MOD = 1e9 + 7;

int dif(int type, int x) {
  if (type == 0 || type == 4) return x;
  if (type == 1 || type == 3) return x == 0 ? 2 : x % 2;
  return (x + 1) % 2;
}
signed main() {
  int n; cin >> n;
  VI dp(5);
  REP (i, n) {
    int a; cin >> a;
    for (int j = 4; j >= 0; j--) {
      dp[j] = dp[j] + dif(j, a);
    }
    REP (j, 4) {
      dp[j + 1] = min(dp[j + 1], dp[j]);
    }
  }
  cout << dp[4] << endl;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
//constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcountll(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;
//struct edge{lint to,num;};

struct edge{lint to,cost;};
lint V;
vector<edge> G[200000]; // MAX_V
lint d[200000]; // MAX_V
void dijkstra(lint S){
  priority_queue<plint,vector<plint>,greater<plint>> que;
  fill(d,d+V,LINF);
  d[S]=0;
  que.push(plint(0,S));
  while(!que.empty()){
    plint p=que.top();
    que.pop();
    lint v=p.second;
    if(d[v]<p.first) continue;
    rep(i,G[v].size()){
      edge e=G[v][i];
      if(d[e.to]>d[v]+e.cost){
        d[e.to]=d[v]+e.cost;
        que.push(plint(d[e.to],e.to));
      }
    }
  }
}


int main(void){
    int N,M;
    cin >> N >> M;
    V=N;
    rep(i,M){
        int u,v;
        cin >> u >> v;
        u--,v--;
        G[u].push_back({v,1});
        G[v].push_back({u,1});
    }
    dijkstra(0);
    if(d[N-1]==2) cout << "POSSIBLE" << endl;
    else cout << "IMPOSSIBLE" << endl;
}

Measured memory_bytes: 21856
#include<bits/stdc++.h>
#define ll long long
#define fast ios::sync_with_stdio(false); cin.tie(0);
#define f(i,s,e) for(ll i=s;i<e;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define mod 1000000007
#define all(x) x.begin(),x.end()
using namespace std;
int dp[100005][3],n;
int arr[105];

int func(int num,int turn){

    if(dp[num][turn] != -1)
        return dp[num][turn];

    int flag = 0;
    for(int i=0;i<n;i++){
        if(num-arr[i]>=0 && func(num-arr[i],turn^1)==turn)
            flag++;
    }

    if(flag>0)
        dp[num][turn] = turn;
    else
        dp[num][turn] = turn^1;

    return dp[num][turn];
}

int main(){
    fast;

    int k;
    cin>>n>>k;

    f(i,0,n)cin>>arr[i];

    memset(dp,-1,sizeof(dp));
    int ans = func(k,1);

    if(ans==1)
        cout<<"First";
    else
        cout<<"Second";

}

Measured memory_bytes: 7680
n,A,B,C = map(int,input().split())
flag = True
ans = []
s = []
for i in range(n):
    s.append(input())
s.append("")
for i in range(n):
    if s[i] == "AB":
        if A == 0 and B == 0:
            flag = False
        elif A == 1 and B == 1:
            if s[i+1] == "BC":
                A -= 1
                B += 1
                ans.append("B")
            else:
                B -= 1
                A += 1
                ans.append("A")
        elif A >= B:
            A -= 1
            B += 1
            ans.append("B")
        else:
            B -= 1
            A += 1
            ans.append("A")
    if s[i] == "AC":
        if A == 0 and C == 0:
            flag = False
        elif A == 1 and C == 1:
            if s[i+1] == "BC":
                A -= 1
                C += 1
                ans.append("C")
            else:
                C -= 1
                A += 1
                ans.append("A")
        elif A >= C:
            A -= 1
            C += 1
            ans.append("C")
        else:
            C -= 1
            A += 1
            ans.append("A")
    if s[i] == "BC":
        if B == 0 and C == 0:
            flag = False
        elif B == 1 and C == 1:
            if s[i+1] == "AC":
                B -= 1
                C += 1
                ans.append("C")
            else:
                C -= 1
                B += 1
                ans.append("B")
        elif B >= C:
            B -= 1
            C += 1
            ans.append("C")
        else:
            C -= 1
            B += 1
            ans.append("B")
if flag:
    print("Yes")
    for i in ans:
        print(i)
else:
    print("No")

Measured memory_bytes: 85636
#include <bits/stdc++.h> //library
#define rep(i, n) for(int i = 0; i < (int)(n); i++) //for-loop (from 0)
#define reps(i,n) for(int i = 1; i <= (int)(n); i++) //for-loop (from 1)
#define all(x) (x).begin(),(x).end() //start-to-end iteration, mainly in upper_bound, lower_bound
#define SZ(x) ((int)(x).size()) //unsigned to signed

using namespace std;
using ll = long long; //long long
ll M = 1000000000 + 7;
const ll INF = 1LL << 60;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; } //compare a,b and replace by greater
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; } //compare a,b and replace by smaller
ll qp(int a, ll b) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a; a = 1ll * a*a; } while (b >>= 1); return ans; } //power
ll qp(int a, ll b, ll Mod = M) { int ans = 1; do { if (b & 1)ans = 1ll * ans*a%Mod; a = 1ll * a*a%Mod; } while (b >>= 1); return ans; } //power(mod)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; } //gcd
int dx[4] = { 1,0,-1,0 }; //path
int dy[4] = { 0,1,0,-1 }; //path
ll RS(ll N, ll P, ll Mod = M) { if (P == 0)return 1; else if (P % 2 == 0) { ll sq = RS(N, P / 2, Mod); return sq*sq%Mod; } else { return N*RS(N, P - 1, Mod) % Mod; } } //power(mod)(repeat-square,fast)
ll nPr(ll n, ll r, ll Mod = M) { ll ans = 1; rep(i, r) { ans = ans * (n - i) % Mod; } return ans; } //permutation
ll nCr(ll n, ll r, ll Mod = M) { ll bunbo = 1; ll bunshi = 1; rep(i, r) { bunbo = bunbo * (i + 1) % Mod; bunshi = bunshi * (n - i) % Mod; } return bunshi * RS(bunbo, Mod - 2, Mod) % Mod; } //combination

int main(void) {
  string S; cin >> S;
  int Q; cin >> Q;
  int rev_num=0;
  
  string backS="",frontS="";
  rep(i,Q){
    int q,qc; char c; cin >> q;
    if (q==1){
      rev_num++;
    }else{
      cin >> qc >> c;
      if (qc==1){
        if (rev_num%2==1){
          backS+=c;
        }else{
          frontS+=c;
        }
      }else{
        if (rev_num%2==1){
          frontS+=c;
        }else{
          backS+=c;
        }
      }
    }
  }
  reverse(frontS.begin(),frontS.end());
  S = frontS + S + backS;
  if (rev_num%2) reverse(S.begin(), S.end());
  cout << S << endl;

  return 0;
}


Measured memory_bytes: 1348
H, W = map(int, input().split())
gridgraph = ['.'*(W+2)]
for _ in range(H):
    area = input()
    gridgraph.append('.'+area+'.')
gridgraph.append('.'*(W+2))
# print(*gridgraph, sep='\n')

flag = True
for i in range(1, H+1):
    for j in range(1, W+1):
        if gridgraph[i][j] == '#':
            if gridgraph[i-1][j] == '#' or gridgraph[i+1][j] == '#' or gridgraph[i][j-1] == '#' or gridgraph[i][j+1] == '#':
                continue
            else:
                flag = False
if flag:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3064
import sys

sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n, r = map(int, input().split())
    diff = 100 * (max(0, 10 - n))
    print(r + diff)

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
double solve(int x)
{
    double sol = sqrt(1+8*x);
    sol += 1;
    sol = (1.0*sol)/2;
    return sol;
}
int main()
{
   int n;
   cin>>n;
   int ans = INT_MAX;
   for(int i =0;i<=n;i++)
   {
       int res = 0;
       int x = i;
       while(x>0)
       {
           res+=x%6;
           x=x/6;
       }
       x = n-i;
        while(x>0)
       {
           res+=x%9;
           x=x/9;
       }
       ans = min(res,ans);
   }
   cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cstdlib>
#include<vector>
#include<map>
#include<cmath>
#define ll long long
#define INF 0x3f3f3f3f
#define maxn 1005
using namespace std;
int read()
{
    int l=0,w=1;
    char ch=getchar();
    while(ch<'0'||ch>'9')
    {
        if(ch=='-')
        w=-1;
        else
        ch=getchar();
    }
    while(ch<='9'&&ch>='0')
    {
        l*=10;
        l+=ch-'0';
        ch=getchar();
    }
    return l*w;
}
int n,h,w;
int main()
{
	n=read(),h=read(),w=read();
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		int a,b;
		a=read(),b=read();
		while(a-h>=0&&b-w>=0)
		{
			ans++;
			a-=h;
			b-=w;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

int main(){
	char ch;
	
	while(1){
		scanf("%c", &ch);
		
		if(islower(ch)) printf("%c", toupper(ch));
		else if(isupper(ch)) printf("%c", tolower(ch));
		else printf("%c", ch);
		
		if(ch=='\n') break;
	}

	return 0;
}



Measured memory_bytes: 2688