akhauriyash/Code-Regression huggingface dataset:
N, X, Y = list(map(int, input().split()))

X, Y = X-1, Y-1

def solve_shortest(a, b):
    if a > b:
        a, b = b, a
    l = [
        b - a,
        abs(X - a) + 1 + abs(b - Y)
    ]
    # print(min(l), (a, b), X, Y, l)
    return min(l)

counts = [0]*N
for i in range(N):
    for j in range(N):
        if i < j:
            counts[solve_shortest(i, j)] += 1

for i in range(1, N):
    print(counts[i])

Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,i,ans=-1;
	cin>>a>>b;
	for(i=1;i<1020;++i)
	{
		if(int(i*0.08)==a && int(i*0.1)==b)
		{
			ans=i;
			break;
		}
	}
cout<<ans;
}

Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b; cin >> n >> a >> b;
    string s; cin >> s;
    int cnt = 0;
    int rank = 0;
    rep(i, n) {
        int flg = 0;
        if(s[i] == 'a' && cnt + rank < a + b){
            cnt++;
            flg = 1;
        } else if(s[i] == 'b' && cnt + rank < a + b && rank < b){
            rank++;
            flg = 1;
        }
        if(flg) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}


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

int main()
{
  ll N;
  cin >> N;
  vector<ll> P(N);
  for (int i=0; i<N; i++){
    cin >> P[i];
  }

  ll t = 2000000;
  ll ans = 0;
  for (int i=0; i<N; i++) {
    if (t > P[i]) {
      ans++;
      t = P[i];
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1792
/**********************
 * Author: Cloud_     *
 * Date:   06.07.2020 * 
 * Time:   15.45.10   *
 *                    *
***********************/
#include <bits/stdc++.h>
using namespace std;

#define gap " "
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ok cout<<"ok"<<endl
#define dbg(x) cout<<(#x)<<" is "<<x<<endl
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;

const int N=100009;

int main()
{
  //fastio; 
  int n,ans;
  cin>>n;
  ans=n%1000;
  if(ans!=0) ans=1000-ans;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3608
S = input()
first = int(S[:2])
second = int(S[2:])
if first < 13 and first > 0:
  if second < 13 and second > 0:
    print('AMBIGUOUS')
  else:
    print('MMYY')
elif second < 13 and second > 0:
  print('YYMM')
else:
  print('NA')

Measured memory_bytes: 3060
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <algorithm>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<double, double> Pdd;
typedef pair<ll, ll> P;
typedef pair<P, ll> PP;

const ll mod = 1e9+7;
const ll INF = 2e9;
const double epsilon = 1e-7;
const double PI = 3.1415926535;

char s[200001], t[200001];
int cha[26], chb[26];
int main(void){
    scanf("%s", &s); scanf("%s", &t);
    fill(cha, cha + 26, -1);
    fill(chb, chb + 26, -1);
    int le = 0;
    while(s[le] != '\0'){
        if(cha[s[le] - 'a'] == -1 || cha[s[le] - 'a'] == t[le] - 'a')cha[s[le] - 'a'] = t[le] - 'a';
        else {printf("No\n"); return 0;}
        if(chb[t[le] - 'a'] == -1 || chb[t[le] - 'a'] == s[le] - 'a')chb[t[le] - 'a'] = s[le] - 'a';
        else {printf("No\n"); return 0;}
        le++;
    }
    //for(int i = 0;i < 26;i++)printf("%d\n", cha[i]);
    printf("Yes\n");
	return 0;
}

Measured memory_bytes: 640
import itertools as it

def get_ceil_10(target) :
    if (str(target)[-1] == "0") :
        return target
    
    return ((target // 10) + 1) * 10
    
     # return target + (5 - target % 5) % 5


# 5!は120なので全部試す
menu = {}
# A = int(input())
# B = int(input())
# C = int(input())
# D = int(input())
# E = int(input())
menu["A"]= int(input())
menu["B"] = int(input())
menu["C"] = int(input())
menu["D"] = int(input())
menu["E"] = int(input())

all_pattern  = list(it.permutations(["A","B","C","D","E"], 5))
# all_pattern  = [["A", "B","C", "E", "D"]]
min_time = 1000 # がんばっても600とかしかいかないはず
for pattern in all_pattern :
    # if (pattern[0] == ["A"] and pattern[1] == "B" and pattern[2] == "C" and pattern[3] == "E" and pattern[4] == "D") : 
    #     print("aaa")

    time = 0
    for action in pattern :
        time += menu[action]

        if (action != pattern[-1]) :
            # 最後は待たなくていい。
            # TODO ださい。。。

            # 時間ごと切り上げちゃってOK。
            time = get_ceil_10(time)  

    if (min_time > time) :
        min_time = time

print(min_time)



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

int main() {
  int N;
  cin >> N;
  LL base = 0;
  priority_queue<LL> small;
  priority_queue<LL, vector<LL>, greater<LL>> large;
  LL INF = 1LL << 60;
  small.push(-INF);
  large.push(INF);
  for (int i = 0; i < N; i++) {
    int k;
    cin >> k;
    auto p1 = small.top();
    auto p2 = large.top();
    if (k == 2) {
      cout << p1 << " " << base << endl;
      continue;
    }
    LL a, b;
    cin >> a >> b;
    base += b;
    if (a < p1) {
      base += p1 - a;
      small.push(a);
      small.push(a);
      small.pop();
      large.push(p1);
    } else if (p2 < a) {
      base += a - p2;
      large.push(a);
      large.push(a);
      large.pop();
      small.push(p2);
    } else {
      small.push(a);
      large.push(a);
    }
  }
  return 0;
}


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

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

  if (n <= 9){
    cout << n << endl;
  }
  else if (n <= 99){
    cout << 9 << endl;
  }
  else if (n <= 999){
    cout << n-90 << endl;
  }
  else if (n <= 9999){
    cout << 909 << endl;
  }
  else if (n <= 99999){
    cout << n-9090 << endl;
  }
  else{
    cout << 90909 << endl;
  }
}



Measured memory_bytes: 3644
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cassert>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = long long;
using vi = vector<int>;
using vl = vector<int64>;
using pii = pair<int, int>;
using pll = pair<int64, int64>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'
#define debug(x) cerr << #x << ": " << (x) << '\n'
#define dbg(v) for (size_t _ = 0; _ < v.size(); ++_){cerr << #v << "[" << _ << "] : " << v[_] << '\n';}
// variadic template
template<typename T> inline void chmin(T &a, T b) {if (a > b) a = b; return;}
template<typename T> inline void chmax(T &a, T b) {if (a < b) a = b; return;}
// constant
const int INF = (1<<30) - 1;
const int64 INF64 = (1LL<<62) - 1;
const int MOD = 1000000007;

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

  int n, m; cin >> n >> m;
  priority_queue<pii, vector<pii>, greater<pii>> pq;
  rep(i, n) {
    int a, b; cin >> a >> b;
    pq.push({a, b});
  }

  priority_queue<int> award;
  int ans = 0;
  for (int i = 1; i <= m; ++i) {
    while (!pq.empty() && pq.top().first <= i) {
      award.push(pq.top().second);
      pq.pop();
    }
    if (award.empty()) continue;
    ans += award.top(); award.pop();
  }
  print(ans);

  return 0;
}

Measured memory_bytes: 1908
#include <iostream>

using namespace std;

int main() {
    string ABCD;
    cin >> ABCD;
    string result = ABCD;
    int init = stoi(ABCD.substr(0, 1));
    int sum = init;
    for (int bit = 0; bit < (1<<3); ++bit) {
        for (int i = 0; i < 3; ++i) {
            if (bit & (1<<i)) {
                result.insert(result.begin() + 2 * i + 1, '+');
                sum += stoi(ABCD.substr(i+1, 1));
            } else {
                result.insert(result.begin() + 2 * i + 1, '-');
                sum -= stoi(ABCD.substr(i+1, 1));
            }
        }
        if (sum == 7) {
            cout << result << "=7" <<endl;
            return 0;
        }
        sum = init;
        result = ABCD;
    }
}

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

using namespace std;

int main() {

	long long n,m;

	cin >> n >> m;

	int a;
	int total;
	total = 0;
	for (int i = 0; i < m; i++) {
		cin >> a;
		total += a;
	}

	if (n - total >= 0) {
		cout << n - total << endl;
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}

Measured memory_bytes: 3636
#include <stdio.h>

int main () {
	int n , i , rent = 100000;
	scanf("%d",&n);
	for ( i = 0; i < n; i++ ) {
		rent *= 1.05;
		int up = rent % 1000;
		if ( up > 0 )
			rent += (1000 - up);
	}
	printf("%d\n",rent);
	return 0;
}

Measured memory_bytes: 0
import sys


def input(): return sys.stdin.readline().strip()
def I(): return int(input())
def LI(): return list(map(int, input().split()))
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def S(): return input()
def LS(): return input().split()


INF = float('inf')


n = I()
a = LI()
MOD = 10**9 + 7
sum_ai = a[0]
ans = 0
for ai in a[1:]:
    ans += ai * sum_ai
    ans %= MOD
    sum_ai += ai
print(ans)


Measured memory_bytes: 30960
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <string.h>
#define MOD 1000000007
typedef long long ll;
using namespace std;

#define MAX_V 1010
#define INF 1e9+10

struct edge {int to,cap,rev;};

vector<edge> G[MAX_V];
bool used[MAX_V];

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

int dfs(int v,int t,int f){
  if(v==t) return f;
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    edge &e=G[v][i];
    if(!used[e.to]&&e.cap>0){
      int d=dfs(e.to,t,min(f,e.cap));
      if(d>0){
        e.cap-=d;
        G[e.to][e.rev].cap+=d;
        return d;
      }
    }
  }
  return 0;
}

int max_flow(int s,int t){
  int flow=0;
  for(;;){
    memset(used,0,sizeof(used));
    int f=dfs(s,t,INF);
    if(f==0) return flow;
    flow+=f;
  }
}


int main(){
  int N,M;
  cin>>N>>M;
  string U;
  cin>>U;
  int A[N+1]={};
  for(int i=1;i<=N;i++){
      cin>>A[i];
      if(U[i-1]=='L') add_edge(i,N+1,A[i]);
      else add_edge(0,i,A[i]);
  }
  int S[M+1]={},T[M+1]={},B[M+1]={};
  for(int i=0;i<M;i++){
      cin>>S[i]>>T[i]>>B[i];
      if(S[i]<T[i]){
          add_edge(S[i],T[i],B[i]);
      }else{
          add_edge(T[i],S[i],B[i]);
      }
  }

  cout<<max_flow(0,N+1)<<endl;

  return 0;
}



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

void parent_search(int parent , vector<vector<int>> &T , vector<int> &P){
  for(int i=0;i<T[parent].size();i++){
    if(P[T[parent][i]]==-1 && T[parent][i]!=1){
      P[T[parent][i]] = parent;
      parent_search(T[parent][i],T,P);
    }
  }
  return;
}

void count(int p , vector<vector<int>> &C , vector<int> &Counter){
  for(int i=0;i<C[p].size();i++){
    Counter[C[p][i]] += Counter[p];
    count(C[p][i],C,Counter);
  }
  return;
}

int main() {
  int N,Q;
  cin >> N >> Q;
  vector<vector<int>> T(N+1,vector<int>(0));
  for(int i=1;i<N;i++){
    int a,b;
    cin >> a >> b;
    T[a].push_back(b);
    T[b].push_back(a);
  }
  vector<int> P(N+1,-1);
  parent_search(1,T,P);
  vector<vector<int>> C(N+1,vector<int>(0));
  for(int i=1;i<=N;i++){
    if(P[i]!=-1) C[P[i]].push_back(i);
  }
  
  vector<int> Counter(N+1,0);
  for(int i=0;i<Q;i++){
    int p,x;
    cin >> p >> x;
    Counter[p] += x;
  }
  count(1,C,Counter);
  
  for(int i=1;i<=N;i++) cout << Counter[i] << " ";
  return 0;
}


Measured memory_bytes: 35200
import sys
stdin = sys.stdin

ns = lambda: stdin.readline().rstrip()
ni = lambda: int(stdin.readline().rstrip())
nm = lambda: map(int, stdin.readline().split())
nl = lambda: list(map(int, stdin.readline().split()))

K,X=nm()
ans=[X-K+1+i for i in range(2*K-1)]
print(*ans)

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

void Main(){
    int n, m;
    cin >> n >> m;
    VI hv(n);
    REP(i, n) cin >> hv[i];
    VVI gv(n, VI(0));
    REP(i, m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        gv[a].push_back(b);
        gv[b].push_back(a);
    }
    int ans = 0;
    REP(i, n) {
        int flag = 0;
        REP(j, gv[i].size()) {
            if (hv[i] <= hv[gv[i][j]]) {
                flag = 1; 
                break;
            }
        }
        if (flag == 0) ans++;
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}


Measured memory_bytes: 8720
#include <stdio.h>

int main()
{
  int a;
  int b = 0;
  scanf("%d", &a);

  if(a%10 == 1){
    b += 9;
  }
  else{
    b += 1;
  }

  if((a-(a%10))%100 == 10){
    b += 90;
  }
  else{
    b += 10;
  }

  if(a-(a%10)-(a-(a%10))%100 == 100){
    b += 900;
  }
  else{
    b += 100;
  }

  printf("%d", b);

  return 0;


}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cctype>
#include <cmath>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <climits>
#include <string>
#include <vector>
#include <utility>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <set>
#define fr(a) freopen(a,"r",stdin)
#define fw(a) freopen(a,"w",stdout)
#define reset(a) memset(a,0,sizeof(a))
#define all(a) a.begin(),a.end()
#define pb push_back
#define ins insert
#define mp make_pair
#define fi first
#define se second
#define bug(x) cout << #x << " = " << x << endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int llu;
typedef long double lf;
typedef pair<int,int>pii;
typedef pair<ll,ll>pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
ll n,a[100005],b[100005],Ti=0;
int main(){
    cin>>n;
    for(int i=1;i<=n;i++) cin>>a[i]>>b[i];
    for(int i=n;i>=1;i--){
        a[i]+=Ti;
        if(a[i]%b[i]==0) continue;
        else Ti+=(a[i]/b[i]+1)*b[i]-a[i];
    }
    cout<<Ti<<endl;
    return 0;
}





Measured memory_bytes: 1920
#include <algorithm>
#include <array>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
using namespace std;

int main() {
    int A, B;
    cin >> A >> B;
    cout << A *B << endl;

    return 0;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
int main(){
	string s,t;
	cin>>s;
	cin>>t;
	int ans=0,sum;
	for(int i=0;i<=s.length()-t.length();i++){
		sum=0;
		for(int j=0;j<t.length();j++){
			if(s[i+j]==t[j])
			sum++;
		}
		ans=max(ans,sum);
	}
	cout<<t.length()-ans<<endl;
}

Measured memory_bytes: 3608
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = list(map(int, readline().split()))

    first = x[0] + x[1]
    second = x[2] + x[3]

    if first > second:
        print("Left")
    elif first < second:
        print("Right")
    else:
        print("Balanced")


if __name__ == '__main__':
    main()


Measured memory_bytes: 61908
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <utility>
 
using namespace std;

int main() {

int H;
int W;
cin >>H>>W;

int a[501][501];
for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
cin >>a[i][j];}
}

int nbs[501][501];//一次元にのばす写像
int ch[260000];//縮める写像h座標
int cw[260000];

for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
if(i%2==1){nbs[i][j]=(i-1)*W+j;}
if(i%2==0){nbs[i][j]=i*W-j+1;}

ch[nbs[i][j]]=i;
cw[nbs[i][j]]=j;
}
}

int b[260000];//一次元にのばしたところでの偶奇の情報
int od=0;//いくつ奇数があるか

for(int i=1;i<=H;i++){
for(int j=1;j<=W;j++){
b[nbs[i][j]]=a[i][j]%2;
if(b[nbs[i][j]]==1){od++;}
}
}

int c[260000];//自分と自分より前の奇数の個数をカウント
c[0]=0;

int N=0;//cが奇数であるようなものの個数

for(int i=1; i<=H*W; i++){
if(b[i]%2==1){c[i]=c[i-1]+1;}
else{c[i]=c[i-1];}

if(c[i]%2==1&&i<H*W){N++;}

}

//cが奇数ならコインを動かす。偶数なら動かさない。

cout <<N<<endl;

for(int i=1; i<H*W; i++){
if(c[i]%2==1){
cout <<ch[i]<<" "<<cw[i]<<" "<<ch[i+1]<<" "<<cw[i+1]<<endl;}
}

}




Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

const ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC" << endl;
    else cout << "ABC" << endl;
    return 0;
}

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

// Define
using ll = int64_t;
using ul = uint64_t;
using ld = long double;
const ll MOD = 1e9 + 7;
const ll INF = LONG_MAX;
const ul MAX = ULONG_MAX;
const char nl = '\n';

#define elif else if
#define def inline auto
#define run __attribute__((constructor)) def _

// Debug
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'

// Loop
#define inc(i, a, n) for (ll i = (a), _##i = (n); i < _##i; ++i)
#define dec(i, a, n) for (ll i = (a), _##i = (n); i > _##i; --i)
#define rep(i, n) inc(i, 0, n)
#define be(c) begin(c), end(c)

// Stream
#define fout(n) cout << fixed << setprecision(n)
#define fasten cin.tie(0), ios::sync_with_stdio(0)

// Speed
run() { fasten, fout(10); }
#pragma GCC optimize("-O3")
#pragma GCC target("avx")

int main() {
    int n;
    cin >> n;
    vector<ll> as(n), bs(n);
    rep(i, n) {
        cin >> as[i];
    }
    rep(i, n) {
        cin >> bs[i];
    }
    ll tmp = 0;
    int count = 0;
    vector<int> vec;
    rep(i, n) {
        if(as[i] < bs[i]) {
            tmp += bs[i] - as[i];
            count++;
        } else if(as[i] > bs[i]) {
            vec.push_back(as[i] - bs[i]);
        }
    }
    sort(be(vec), greater<int>());
    for(auto v : vec) {
        if(tmp <= 0) break;
        tmp -= v;
        count++;
    }
    if(tmp > 0)
        cout << "-1" << nl;
    else
        cout << count << nl;
}


Measured memory_bytes: 2176
#include <iostream>
#include <cstdio>
#include <algorithm>
const int N = 1000;
using namespace std;
int h,w,a,b,f[N + 5][N + 5],sh[N + 5][2],sw[N + 5][2];
int main()
{
    scanf("%d%d%d%d",&h,&w,&a,&b);
    for (int i = 1;i <= h;i++)
        sh[i][0] = w;
    for (int i = 1;i <= w;i++)
        sw[i][0] = h;
    b = max(b,h - b);
    a = max(a,w - a);
    for (int i = 1;i <= h;i++)
        for (int j = 1;j <= w;j++)
            /*if (sh[i][0] < a && sw[j][0] < b)
                f[i][j] = 0;
            else*/
            if (sh[i][1] < a && sw[j][1] < b)
                f[i][j] = 1,sh[i][1]++,sw[j][1]++;
    for (int i = 1;i <= h;i++)
    {
        for (int j = 1;j <= w;j++)
            printf("%d",f[i][j]);
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 5120
from heapq import heappop, heappush

inf = float('inf')

N = int(input())
A = list(map(int,input().split()))

# sum_max[k] : [0,k)のうちN個までの総和の最大値
# sum_min[k] : (3N-1-k,3N-1]のうちN個までの総和の最小値
sum_max = [0]*(3*N+1)
sum_min = [0]*(3*N+1)

def init_max():
    res = 0
    hq = []
    for i, a in enumerate(A):
        if len(hq) < N:
            heappush(hq,a)
            res += a
        else:
            if hq[0] < a:
                res -= heappop(hq)
                heappush(hq,a)
                res += a
        sum_max[i+1] = res

def init_min():
    res = 0
    hq = []
    for i, a in enumerate(A[::-1]):
        if len(hq) < N:
            heappush(hq,-a)
            res += a
        else:
            if -hq[0] > a:
                res -= -heappop(hq) 
                heappush(hq,-a)
                res += a
        sum_min[i+1] = res

init_max()
init_min()

ans = -inf

for k in range(N,2*N+1):
    res = sum_max[k] - sum_min[3*N-k]
    ans = max(ans, res)

print(ans)

Measured memory_bytes: 43308
import math

N, D = map(int, input().split())
xy = [map(int, input().split()) for _ in range(N)]
x, y = [list(i) for i in zip(*xy)]

d = D**2

count = 0
for i in range(N):
  x2 = x[i] ** 2
  y2 = y[i] ** 2
  if x2 > d:
    continue
  elif y2 > d:
    continue
  elif (x2 + y2) <= d:
    count += 1

print(count)


Measured memory_bytes: 116732
import sys
from collections import deque


def bfs(x1, y1, d):
    q = deque([])
    q.append((d, x1, y1))
    M[x1][y1] = d

    while q:
        d, x1, y1 = q.popleft()

        if [x1, y1] == [xg, yg]:
            print(d)
            return

        for dx, dy in ((0, 1), (1, 0), (0, -1), (-1, 0)):
            for k in range(1, K + 1):
                x2 = x1 + dx * k
                y2 = y1 + dy * k
                # if m[x2][y2] == '@':
                #     break
                # if x2 < 0 or x2 >= H:
                #     break
                # if y2 < 0 or y2 >= W:
                #     break
                # if M[x2][y2] < d + 1:
                #     break
                # if M[x2][y2] == d + 1:
                #     continue

                if (0 <= x2 < H) and (0 <= y2 < W):
                    if m[x2][y2] == '@':
                        break
                    elif M[x2][y2] == -1:
                        M[x2][y2] = d + 1
                        q.append((d + 1, x2, y2))
                    elif M[x2][y2] <= d:
                        break
                    elif M[x2][y2] == d + 1:
                        continue
                    else:
                        break
                else:
                    break
    print(-1)


H, W, K = map(int, sys.stdin.readline().strip().split())
xs, ys, xg, yg = map(int, sys.stdin.readline().strip().split())
xg -= 1
yg -= 1

m = []
for _ in range(H):
    m.append(list(map(str, sys.stdin.readline().strip())))

M = [[-1] * W for _ in range(H)]

bfs(xs - 1, ys - 1, 0)


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

int main() {
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;

	if (x - r >= 0 && x + r <= W && y - r >= 0 && y + r <= H) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


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

bool sp(string s){
  
  string t = s;
  reverse(t.begin(),t.end());
  
  return s == t;
}

int main(){
  
  string s;
  cin >> s;
  bool ans = true;
  
  if(!sp(s)) ans = false;
  if(!sp(s.substr(0,s.size()/2))) ans = false;
  
  cout << (ans ? "Yes" : "No") <<endl;
  return 0;
}
  
  


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

int main(void) {
    int N;
    cin >> N;
    int cnt=0;
    for (int i=1; i<N;i++) {
        for (int j=1;i*j<N; j++) {
            cnt++;
            
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3564
#include<stdio.h>
#include<string.h>

int ele[1000000],i,j,n,c,t;

int main(){
	while(0<=scanf("%d",&n)){
		if(n==0)break;
		c=0;
		
		for(i=0;i<n;i++){
			scanf("%d",&ele[i]);
		}
		
		
		for(i=0;i<n;i++){
			for(j=0;j<n-1;j++){
				if(ele[j]>ele[j+1]){
					++c;
					t=ele[j];
					ele[j]=ele[j+1];
					ele[j+1]=t;
				}
			}
		}
		
		printf("%d\n",c);
	}
	return 0;
}

Measured memory_bytes: 0
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <queue>
#include <sstream>
#include <stack>
#include <time.h>
#include <vector>
#include <complex>
#include <map>
#include <set>
#include <iomanip>
#include <math.h>
#include <stdlib.h>
#include <list>
#include <utility>
#include <memory>
#include <cstring>
#include <fstream>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <ios> 
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,m,n1,m1;
	cin>>n>>m>>n1>>m1;
	cout<<n*m-n1*m-m1*n+n1*m1;
}

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

using namespace std;

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

int main() {
  int n;
  string s;
  cin >> n >> s;
  string answer;
  Rep(i, s.size()) {
    answer += 'A' + (s[i] - 'A' + n) % 26;
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a'||c=='e'||c=='i'||c=='o'||c=='u'){
    cout << "vowel" <<endl;
  }
  else{
    cout << "consonant" <<endl;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string>
#include <cstdio>
#include <vector>
#include <set>
#include <cassert>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <sstream>
#include <functional>
#include <iomanip>
//#include <windows.h>  //Should be deleted when using AtCoder&POJ
using namespace std;

#define ll long long
#define pq_small priority_queue<int,vector<int>,greater<int> >
/**==Info==
*Program:
*Problem:
*Date:
*Algorithm:
*Stats:*/
int main(int argc,char* argv[]){
	string s;
	cin>>s;
	s=s.substr(0,s.size()-8);
	cout<<s;
	return 0;
}


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

int main(){
    string s;
    cin >> s;
    ll ans = 0;
    ll n = s.size();

    ll cur;
    for (ll bit = 0; bit < (1 << (n-1)); bit++){
        cur = 0;
        for (ll i = 0; i < n; i++){
            cur = cur*10 + (s[i] - '0');
            if (bit & (1 << i)){
                ans += cur;
                cur = 0;
            }
        }
        ans += cur;
    }
    cout << ans << endl;
}

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

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; }

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;


int main() {
    int k, s;
    cin >> k >> s;
    int ans = 0;
    rep(i, 0, k+1){
        int temps = s;
        temps -= i;
        rep(j, 0, k+1){
            if(temps-j<0 || temps-j>k)continue;
            ans++;
        }
    }
    cout << ans << endl;
}

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

// @author: pashka

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

    int n, d, a;
    cin >> n >> d >> a;
    vector<pair<int, int>> m(n);
    for (int i = 0; i < n; i++) {
        cin >> m[i].first >> m[i].second;
    }
    sort(m.begin(), m.end());
    
    long damage = 0;
    long total_bombs = 0;
    queue<pair<int, long>> right_borders;
    for (int i = 0; i < n; i++) {
        while (!right_borders.empty()) {
            if (m[i].first > right_borders.front().first) {
                damage -= right_borders.front().second;
                right_borders.pop();
            } else {
                break;
            }
        }
        long hp = m[i].second - damage;
        if (hp > 0) {
            long bombs = (hp + a - 1) / a;
            total_bombs += bombs;
            damage += bombs * a;
            right_borders.push({m[i].first + 2 * d, bombs * a});
        }
    }
    cout << total_bombs;

    return 0;
}

Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
	ll n,k; cin>>n>>k;
	if(k>=n)
		cout<<0<<endl;
	else
	{
		ll a[n];
		for(int i = 0 ; i < n ; i++)
			cin>>a[i];
		sort(a,a+n);
		ll tot = 0;
		for(int i = 0 ; i < n-k; i++)
			tot+=a[i];
		cout<<tot<<endl;
	}
	return 0;
}

Measured memory_bytes: 1792
from itertools import product

S = input()
N = len(S)
ans = 0
for opes in product(("", "+"), repeat=N - 1):
    eqn = []
    for s, o in zip(S[:-1], opes):
        eqn += s + o
    eqn = "".join(eqn) + S[-1]
    ans += sum(map(int, eqn.split("+")))
print(ans)



Measured memory_bytes: 9096
import java.util.Scanner;
 
public class Main {
    private static int n;
    private static int q;
    private static int[] p;
    private static int[] rank;
 
    private static boolean same(int x, int y) {
        return findSet(x) == findSet(y);
    }
 
    private static void unite(int x, int y) {
        int i = findSet(x);
        int j = findSet(y);
 
        if (i == j){
            return;
	}
        if (rank[i] > rank[j]){
            p[j] = p[i];
            rank[i] += rank[j];
            rank[j] = 0;
        }
        else {
            p[i] = p[j];
            rank[j] += rank[i];
            rank[i] = 0;
        }	
	
    }
 
    private static int findSet(int i) {
        while (i != p[i]){
            p[i] = p[p[i]];
            i = p[i];
        }
        return i;
    }
 
    private static void DisjointSet() {
        p = new int[n];
        rank = new int[n];
 
        for (int i = 0; i < n; i++) {
            p[i] = i;
            rank[i] = 1;
        }
    }
 
 
    public static void main (String[] args){
        Scanner scanner = new Scanner(System.in);
        n = scanner.nextInt();
        q = scanner.nextInt();
 
        DisjointSet();
        for (int i = 0; i < q; i++) {
            int com = scanner.nextInt();
            int x = scanner.nextInt();
            int y = scanner.nextInt();
 
            if (com == 0){
                unite(x, y);
            }
            if (com == 1){
                if (same(x, y)){
                    System.out.println(1);
                }else{
                    System.out.println(0);
		}
            }
	    
 
        }
    }
}

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

int main(){
    int h,w;
    cin>>h>>w;
    vector<vector<char>> a(h,vector<char>(w));
    rep(i,h) rep(j,w) cin>>a[i][j];

    rep(i,w+2) cout<<'#';
    cout<<"\n";
    rep(i,h){
        cout<<'#';
        rep(j,w) cout<<a[i][j];
        cout<<'#'<<"\n";
    }
    rep(i,w+2) cout<<'#';
    return 0;
}

Measured memory_bytes: 3672
import sys
sys.setrecursionlimit(10**8)

input=sys.stdin.readline

n,q=map(int,input().split())

tree=[[] for _ in range(n)]

for _ in range(n-1):
    a,b=map(int,input().split())
    tree[a-1].append(b-1)
    tree[b-1].append(a-1)

point=[0]*n
for _ in range(q):
    q,x=map(int,input().split())
    point[q-1]+=x

result=["no"]*n

def counter(chouten,count):
    global result,point,tree
    count+=point[chouten]
    result[chouten]=count

    #print(chouten,result)

    for item in tree[chouten]:
        if result[item]=="no":
            counter(item,count)

counter(0,0)

result=map(str,result)
print(" ".join(result))


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

int main(){
   int n,t;
   double a;
   cin >> n >> t >> a;
   vector<int> h(n);
   vector<double> tt(n);
   for (int i=0;i<n;i++) {
      cin >> h.at(i);
      tt.at(i)=t-h.at(i)*0.006;
   }
   double min=1000000;
   int index=-1;
   for (int i=0;i<n;i++) {
      if (min>abs(tt.at(i)-a)){
         min=abs(a-tt.at(i));
         index=i;
      }
   }
   cout << index+1 << endl;
}


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

int main() {
    int N, K;
    cin >> N >> K;
    double res = 0;


    for(int i=1; i<=N; i++) {
        double temp = 1.0/N;
        int score = i;
        while(score <= K-1) {
            score *= 2;
            temp /= 2.0;
        }
        res += temp;
    }

    cout << setprecision(12);
    cout << res << endl;
    return 0;
}

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

int main()
{
    int N, M;
    vector<pair<long long int, long long int>> n, m;

    cin >> N >> M;

    for (int i = 0; i < N; ++i)
    {
        long long int x, y;
        cin >> x >> y;
        n.push_back(make_pair(x, y));
    }

    for (int i = 0; i < M; ++i)
    {
        long long int x, y;
        cin >> x >> y;
        m.push_back(make_pair(x, y));
    }

    for (int i = 0; i < N; i++)
    {
        int out = 0;
        long long int ans = 10000000000;
        for (int j = 0; j < M; j++)
        {
            long long int distance = abs(n[i].first - m[j].first) + abs(n[i].second - m[j].second);
            if (ans != min(ans, distance))
            {
                ans = min(ans, distance);
                out = j + 1;
            }
        }
        cout << out << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int a,b,z=1;
    
    scanf("%d %d",&a,&b);
    
    if(a<b){
        z=b;
        b=a;
        a=z;
    }
    
    while(z!=0){
        z=a%b;
        a=b;
        b=z;
    }
    
    printf("%d\n",a);
    
    return 0;
}


Measured memory_bytes: 2092
#include <iostream>
#include <sstream>
#include <string>
#include <vector>

constexpr double BTC_YEN = 380000.0l;

int main(int argc, char* args[]) {
  using std::string;
  int line;
  int jpy = 0;
  double btc = 0.0l;
  
  std::cin >> line;
  for (int i = 0; i < line; ++i) {
    string cur;
    double amount;
    std::cin >> amount;
    std::cin >> cur;
    if (cur == "JPY") {
      jpy += amount;
    } else {
      btc += amount;
    }
  }
  double total = static_cast<double>(jpy);
  total += btc * BTC_YEN;
  
  std::cout << total;
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int v[50];
    v[0]=1;
    v[1]=v[0];
    v[2]=v[1]+v[0];
    for(int i=3;i<=30;i++){
        v[i]=v[i-1]+v[i-2]+v[i-3];
    }
    int n;
    while(1){
        cin>>n;
        if(n==0)break;
        cout<<((v[n]+9)/10+364)/365<<endl;
    }
}

Measured memory_bytes: 2980
# -*- coding: utf-8 -*-
N = int(input())
S = input()

sum = 0
if N % 2 == 0:
  for i in range(int(N/2)):
    if S[i] != S[i+int(N/2)]:
      sum += 1
else:
  sum = 1

if sum == 0:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
//Created Time:2019年12月23日 星期一 14时08分16秒
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#define N 5003

using namespace std;

int s[N];
char t[10], res[N];

int main(){
	int a, b, n, cnt = 0; cin >> a >> b; n = a + b;
	if(a <= b){
		puts("Impossible");
		return 0;
	}
	for(int i = 0; i < n; ++i){
		if(!cnt) s[++cnt] = i;
		else{
			printf("? %d %d\n", s[cnt], i);
			fflush(stdout);
			scanf("%s", t + 1);
			if(t[1] == 'Y') s[++cnt] = i;
			else cnt--;
		}
	}
	for(int i = 0; i < n; ++i){
		printf("? %d %d\n", s[cnt], i);
		fflush(stdout);
		scanf("%s", t + 1);
		res[i] = t[1] == 'Y' ? '1' : '0';
	}
	printf("! %s\n", res);
	return 0;
}


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

template<class T> inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    ll n, a, b;
    read(n);
    for (int i = sqrt(n); i >= 1; --i) {
        if (n % i == 0 && i * (n / i) == n) {
            a = i, b = n / i;
            break;
        }
    }
    cout << a + b - 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ll long long
#define bit(x,i) (x&(1<<i))
#define pi 3.1415926535897932384626
#define pb push_back
#define pf push_front
#define mt make_tuple
#define ff first
#define ss second
#define debug(x) cout << #x " = " << (x) << endl
#define DESYNC ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define endl '\n'
#define EPS 1e-9
#define INF 1e18
#define ALL(x) for(int i=0; i<x; i++)
#define fori(a,b,c) for(int a=b; a<c; a++)
#define PRESENT(c,x) ((c).find(x) != (c).end())
#define m0(x) memset((x), 0, sizeof(x))
#define m1(x) memset((x), -1, sizeof(x))

const int dx[] = {0,1,0,-1};
const int dy[] = {1,0,-1,0};
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> pii;
typedef vector<pii> vii;
typedef __gnu_pbds::tree<int, __gnu_pbds::null_type, std::less<int>, __gnu_pbds::rb_tree_tag,__gnu_pbds::tree_order_statistics_node_update> indexed_set;

inline int mod(int n){ return (n%1000000007); }

int gcd(int a, int b){
  if(a == 0 || b == 0) return 0;
  if(b == 1) return b;
  else return gcd(b, a%b);
}

int fpow(int x, unsigned int y, int p){ 
    int res = 1;
    x = x % p;
    while (y > 0){
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;
        x = (x*x) % p;   
    } 
    return res; 
} 
const int maxn = 1e5+10;

int32_t main(){
	DESYNC;
    int n, x, tmp;
    pair<int,int> ans = {500,500};
    cin>>x>>n;
    map<int,bool> arr;

    for(int i=0; i<n; i++){
        cin>>tmp;
        arr[tmp] = 1;
    }

    if(n == 0)
        return cout<<x<<endl, 0;

    for(int i=-10; i<110; i++)
        if(arr[i] == 0)
            ans = min(make_pair(abs(x-i),i),ans);

    cout<<ans.ss<<endl;
}

Measured memory_bytes: 3664
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)
	for i := 0; i < len(s)-1; i++ {
		if s[i] == 'A' && s[i+1] == 'C' {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define FORD(i,a,b) for(ll i=a;i>=b;i--)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define SORT(c) sort((c).begin(),(c).end())
#define PB push_back
#define MP make_pair
#define MEMSET(v, h) memset((v), h, sizeof(v))
#define sqr(x)  ((x) * (x)) 
#define cub(x)  ((x) * (x) * (x))
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; }
// ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
// ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

bool isprime(int x){
  int i = 2;
  while(i<=sqrt(x)){
    if(x%i==0) return false;
    ++i;
  }
  return true;
}

int main(){
  int n; cin >> n;
  int ans = 0;
  FOR(i,0,n-1){
    int a; cin >> a;
    if(isprime(a)) ++ans;
  }

  cout << ans << endl;
}



Measured memory_bytes: 3084
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    vector<int> a;
    int n;
    cin>>n;
    while(n--){
        int t;
        for(int i=0;i<3;i++){
            cin>>t;
            a.push_back(t);
        }
        sort(a.begin(),a.end());
        if(a[0]*a[0]+a[1]*a[1]==a[2]*a[2])
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
        a.clear();
    }
}

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

const int MAX = 105;
const int INFTY = (1 << 30);
int A[MAX], n, cnt;

void insertion_sort() {
  for (int i = 0; i < n; i++) {
    int mini {i}; 
    bool is_swap = false;
    for (int j = i; j < n; j++) {
      if (A[mini] > A[j]) {
        is_swap = true;
        mini = j;
      }
    }
    int tmp = A[mini];
    A[mini] = A[i];
    A[i] = tmp;
    if (is_swap) cnt++;
  }
}

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

  insertion_sort();

  for (int i = 0; i < n; i++) {
    if (i == 0) {
      cout << A[i];
    } else {
      cout << " " << A[i];
    }
  }
  cout << endl;
  cout << cnt << endl;
  return 0;
}



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

int main(){
	int n; cin >> n;
	vector<string> prev_words;
	string prev = "";
	cin >> prev;
	prev_words.push_back(prev);
	for(size_t i = 1 ; i < n  ; i++){
		string tmp = ""; cin >> tmp;
		if(tmp[0] != prev[prev.size()-1]){
			cout <<  "No" << endl;
			exit(0);
		}
		if( find(prev_words.begin(), prev_words.end(), tmp) != prev_words.end() ){
			cout <<  "No" << endl;
			exit(0);
		}
		prev_words.push_back(tmp);
		prev = tmp;
	}

	cout <<  "Yes" << endl;

}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <string>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>

#include <numeric>
#include <utility>
#include <complex>

#include <sstream>
#include <iostream>
#include <iomanip>

#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <ctime>

// namespace
using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;
using comp = complex<double>;

// constant
static const ll MOD = 1000000007LL;
static const double PI = 3.14159265358979323846;

// conversion
inline ll toint(string s) { ll v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

// print
#define RET(x) return cout << x << endl, 0;

// for loop
#define REP(i, a, b) for ((i) = (ll)(a);(i) < (ll)(b);(i)++)
#define REPD(i, a, b) for (ll i = (ll)(a);(i) < (ll)(b);(i)++)
#define REPI(v, vs) for (auto& v : vs)

//debug
#ifdef LOCAL_ENV
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __LINE__ << ")" << " " << __FILE__ << endl
#else
#define DUMP(x)
#define DEBUG(x)
#endif

#define MAX_VALUE 9223372036854775807

int solve() {
	ll N;
	cin >> N;

	vector<ll> As(N);
	REPD(i, 0, N) cin >> As[i];

	ll res = 0;
	ll max_A = As[0];
	REPD(i, 1, N) {
		res += max(max_A - As[i], 0LL);
		max_A = max(As[i], max_A);
	}

	RET(res);

	return 0;
}

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

	solve();
	// ll t;
	// cin >> t;
	// REPD(i, 0, t) solve();

	return 0;
}


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

int main()
{
    int h,w,a,b; scanf("%d%d%d%d",&h,&w,&a,&b);

    for(int i=0;i<h;i++)
    {
        if(i<b)
        {
           for(int j=0;j<w;j++)
           {
               if(j<a) printf("1");
               else printf("0");
           }
        }
        else
        {
           for(int j=0;j<w;j++)
           {
               if(j<a) printf("0");
               else printf("1");
           }
        }
        cout<<endl;
    }
}


Measured memory_bytes: 1280
n,m = map(int,input().split()) #n種類　M個えらぶ
a = list(map(int,input().split()))
sum_list = sum(a)

count = 0
for i in range(n):
    if a[i] >= sum_list/(4 * m):
        count +=1

if count >= m:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
typedef long long ll;
typedef vector<int> vint;
typedef pair<int, int> pint;
typedef vector<long long> vlong;
typedef vector<string> vstring;
#define vpush(a,x) a.push_back(x);
#define rep(i, n) REP(i, 0, n)
#define all(v) v.begin(), v.end()
#define REP(i, x, n) for(int i = x; i < n; i++)
const int INF = 1 << 30;
const int dx[] = {1,0,-1,0,1,1,-1,-1};
const int dy[] = {0,-1,0,1,1,-1,-1,1};
#define stp(x)  setprecision(x)
const long double PI=3.14159265358979323846264338327950;
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n;
  cin>>n;
  vint h(n+1);
  rep(i,n){
    cin>>h[i+1];
  }

  vector<int> dp(n+1,INF);
  dp[1]=0;
  dp[2]=abs(h[1]-h[2]);
  REP(i,3,n+1){
    dp[i]=min(dp[i-2]+abs(h[i]-h[i-2]),dp[i-1]+abs(h[i]-h[i-1]));
  }
  cout<<dp[n]<<'\n';
  return(0);
}

Measured memory_bytes: 3988
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
typedef long long int ll; 
typedef long double ld; 

ll n;
ll arr[1000005];


int main()
{
    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    string s,t;

    cin>>s>>t;

    if(s.size()>=t.size())
    {
        cout<<"No"<<endl;
    }
    else{
    
        for(ll i=0;i<s.size();i++)
        {
            if(s[i]!=t[i])
            {
                cout<<"No"<<endl;
                return 0;
            }
        }
        cout<<"Yes"<<endl;

    }
    
    
    
}

Measured memory_bytes: 3616