akhauriyash/Code-Regression huggingface dataset:
use proconio::input;

fn main() {
  input! {
    n: usize,
    k: usize,
  }
  
  let f_n = n as f64;
  let mut total = 0f64;
  for mut i in 1..=n {
    let mut count = 1f64;
    while i < k {
      i *= 2;
      count *= 2f64;
    }
    total += 1f64 / (f_n * count);
  }
  
  println!("{}", total);
}

Measured memory_bytes: 2160
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <bitset>

using namespace std;

int n;
vector<int> graph[500000];
int col[500000];
int sz[500000];

void dfs(int v)
{
    col[v] = 1;
    sz[v] = 1;
    for (auto u : graph[v])
    {
        if (col[u] == 0)
        {
            dfs(u);
            sz[v] += sz[u];
        }
    }
}

int main()
{
    cin >> n;
    if (n % 2 == 1)
    {
        cout << "First";
        return 0;
    }
    for (int i = 0; i < n - 1; i++)
    {
        int v, u;
        cin >> v >> u;
        graph[v].push_back(u);
        graph[u].push_back(v);
    }
    dfs(1);
    for (int i = 1; i <= n; i++)
    {
        int cnt = 0;
        for (auto u : graph[i])
        {
            if (min(sz[u], sz[i]) % 2 == 1) cnt++;
        }
        if (cnt != 1)
        {
            cout << "First";
            return 0;
        }
    }
    cout << "Second";
}


Measured memory_bytes: 18044
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int m = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> array(n),sarray(n);
    ll sum = 0;
    for(int i=0;i<n;i++){
        ll num;
        cin >> num;
        array.at(i) = num % m;
        if(i > 0){
            sarray.at(i) = (sarray.at(i-1)+num) % m;
        }else{
            sarray.at(i) = num % m;
        }
    }
    for(int i=1;i<n;i++){
        sum += (sarray.at(i-1) * array.at(i)) % m;
    }

    cout << sum % m << endl;
    
    /*ll s = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            s += (array.at(i) * array.at(j)) % 1000000007;
        }
    }
    cout << s << endl;*/
}

Measured memory_bytes: 6316
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if (s.length()==2) {
			if (s.charAt(0)==s.charAt(1)) {
				System.out.println("1 2");
			} else {
				System.out.println("-1 -1");
			}
			return ;
		}
		for (int i=0;i<s.length()-2;i++) {
			String temp = s.substring(i,i+3);
			if (temp.charAt(0)==temp.charAt(1)||temp.charAt(1)==temp.charAt(2)||temp.charAt(0)==temp.charAt(2)) {
				System.out.println(i+1+" "+(i+3));
				return;
			}
		}
		System.out.println("-1 -1");
	}
}

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

int main() {
  int N;
  cin >> N;
  
  vector<int> a(N);
  for (int i=0; i<N; i++) {
    cin >> a.at(i);
  }
  
  int alice=0, bob=0;
  
  vector<int>::iterator iter;
  for (int i=0; i<a.size(); i++) {
    iter = max_element(a.begin(), a.end());
    if (*iter == 0) break;
    if (i%2==0) {
      alice += *iter;
    } else {
      bob += *iter;
    }
    size_t index = distance(a.begin(), iter);
    a.at(index)=0;
  }
  
  cout << alice - bob << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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(){
int n,m;
cin>>n>>m;
V<string> a(n),b(m);
for(int i=0;i<n;i++)cin>>a[i];
for(int i=0;i<m;i++)cin>>b[i];
for(int i=0;i<n-m+1;i++){
  for(int j=0;j<n-m+1;j++){
      if(a[i][j]==b[0][0]){
          bool flag=true;
          for(int k=0;k<m;k++){
              for(int r=0;r<m;r++){
                  if(a[i+k][j+r]!=b[k][r])flag=false;
              }
          }
          if(flag){
              cout<<"Yes"<<endl;
              return 0;
          }
      }
  }
}
cout<<"No"<<endl;
}

Measured memory_bytes: 256
n = input()

if len(n) < 2:
    print(n)
    exit()

kumi = []
iti = 0

for x in range(2 ** (len(n) -1)):
    for m in range(len(n) -1):
        if (x >> m) & 1:
            kumi.append(n[iti:m+1])
            iti = m+1
        if m == len(n) -2:
            kumi.append(n[iti:m+2])
    iti = 0

kumi_int =[int(s) for s in kumi]
print(sum(kumi_int))

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

bool can(string &s, int i) {
  if (i == s.size() - 1) {
    return false;
  }
  if (s.at(i) == 'C') {
    for (int j = i + 1; j < s.size(); j++) {
      if (s.at(j) == 'F') {
        return true;
      }
    }
    return false;
  }
  return can(s, i + 1);
}

int main() {
  string t;
  cin >> t;
  if (can(t, 0)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		ArrayList<Integer> ans = new ArrayList<>();
		for(int i=1 ; i <= 100 ; i++) {
			if(a%i == 0 && b%i ==0) {
				ans.add(i);
			}
		}
		System.out.println(ans.get(ans.size()-k));
	}
}


Measured memory_bytes: 21972
#include <iostream>

using namespace std;

#define MAX 50

int main(){
    int N,K,m,x,R,p,q;
    bool b[MAX][MAX] = {{0}},c[MAX] = {0};
    cin >> N >> K;
    for(int i = 0 ; i < K ; i++){
        cin >> m;
        for(int j = 0 ; j < m ; j++){
            cin >> x;
            b[i][--x] = 1;
        }
    }
    cin >> R;
    for(int i = 0 ; i < R ; i++){
        cin >> p >> q; --p; --q;
        for(int j = 0 ; j < K ; j++){
            if(b[j][p] && b[j][q]){
                c[p] = c[q] = true;
            }
        }
    }
    int res = 0;
    for(int i = 0 ; i < MAX ; i++){
        if(c[i]) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1164
/*
 ╔═══╦═══╦═══╗
 ║╔═╗║╔══╩╗╔╗║
 ║║░║║╚══╗║║║║
 ║║░║║╔══╝║║║║
 ║╚═╝║╚══╦╝╚╝║
 ╚══╗╠═══╩═══╝
 ░░░╚╝░░░░░░░░
 */

#include <bits/stdc++.h>
#define ll					long long
#define MOD					1000000007
#define MAX					1e9
#define MIN                 -1e9
#define PI					acos(-1.0)
#define vi					vector<int>
#define vii					vector<vi>
#define vll					vector<ll>
#define mid(s,e)			(s+(e-s)/2)
#define clz(n)				__builtin_clzll(n))

using namespace std;

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
template<typename T>
void printVec(const T &v, char sep=' ') {for (auto &i: v) cout << i << sep;}
template<typename T>
void printVecPair(const T &v, char sep=' ') {for (auto &i: v) cout << i.first <<" " << i.second<< sep;}


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

int main() {
	ios::sync_with_stdio(false);
 	cin.tie(0);
	int n;
	cin>>n;
	vi a(n);
	for(int& i: a) cin>>i;
	vi b = a;
	sort(b.begin(),b.end(),greater<int>());
	for(int i=0;i<n;i++) {
			cout<<(a[i] == b[0] ? b[1] : b[0])<<endl;
	}
	return 0;
}





Measured memory_bytes: 3200
using System;
using System.Collections.Generic;
using System.Linq;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp2
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = GetLongNumArray();
            var N = input[0];
            var K = input[1];
            var tensuuList = GetLongNumArray();

            for (int i = 0; i < N - K; i++)
            {
                if (tensuuList[i] < tensuuList[K + i])
                {
                    Console.WriteLine("Yes");
                }
                else
                {
                    Console.WriteLine("No");
                }
            }
        }

        private static long[] GetLongNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => long.Parse(x)).ToArray();
        }

        private static int[] GetIntNumArray()
        {
            var input = Console.ReadLine().Split(' ');
            return input.Select(x => int.Parse(x)).ToArray();
        }

        private static long GetLongNum()
        {
            return long.Parse(Console.ReadLine());
        }

        private static string[] GetStringArray()
        {
            return Console.ReadLine().Split(' ');
        }

        private static string GetString()
        {
            return Console.ReadLine();
        }
    }
}


Measured memory_bytes: 46856
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define maxn 60005
const ll inf=1e9+7;
#define pb push_back
#define PI 3.14159265
void solve();
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout<<fixed;
	cout<<setprecision(10);
	int t=1;
	//cin>>t;
	while(t--)
	solve();
	return 0;
}
void solve()
{
	ll a,b;
	cin>>a>>b;
	cout<<a*b;
}


Measured memory_bytes: 3640
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>
#include <string.h>
using namespace std;
int a[3001];
int f[3000];
int main()
{
    int n;
    scanf("%d",&n);
    int sum = 0;
    for (int i = 0;i<n;i++) {
        scanf("%d",&a[i]);
        sum+=(a[i]-1);
    }
    printf("%d",sum);
	return 0;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) for(int i = 0 ; i < n ; ++i)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort((x).begin(), (x).end())

const int IINF = 1e9 + 10;
const long long LLINF = (long long)1e18 + 10;
const long long MOD = (long long)1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int main(){
    while(1){
        string s;
        int degree[110] = {0};
        bool flag = false;
        while(1){
            getline(cin, s);
            if(s == "0 0"){
                break;
            }
            if(s == ""){
                flag = true;
                break;
            }
            int a = 0, b = 0, j = 0;
            while('0' <= s[j] && s[j] <= '9'){
                a *= 10;
                a += s[j] - '0';
                ++j;
            }
            ++j;
            while(j < s.size()){
                b *= 10;
                b += s[j] - '0';
                ++j;
            }
            ++degree[a];
            ++degree[b];
        }
        if(flag){
            break;
        }
        bool ans = true;
        int cnt = 0;
        rep(i, 110){
            cnt += degree[i] % 2;
            if(i > 2 && degree[i] == 1){
                ans = false;
                break;
            }
        }
        ans &= cnt <= 2;
        ans &= degree[1] % 2 == 1 && degree[2] % 2 == 1;
        if(ans){
            cout << "OK" << endl;
        }else{
            cout << "NG" << endl;
        }
    }
    return 0;
}


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

int main() {
    int n,k;
    cin >> n >> k;
    int a[n], dp[n];
    for(int i=0;i<n;i++) cin >> a[i];
    memset(dp,  999999, sizeof(dp));
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i=2;i<n;i++){
        for(int j=i-1;j>=i-k && j>=0 ;j--){
            dp[i] = min(dp[i], dp[j] + abs(a[i] - a[j]));
        }
    }
    // for(int i=0;i<n;i++) cout << dp[i] << " ";
    // cout << endl;
    cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 4416
#include<bits/stdc++.h>
#define pb push_back
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int maxn=1e3+233;
const int maxl=1e6+233;
ll x,y,z,k;
ll a[maxn],b[maxn],c[maxn],d[maxl];
vector<ll>ans;
bool cmp(ll u,ll v){
	return u>v;
}
int main()
{
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	cin>>x>>y>>z>>k;
	for(int i=1;i<=x;i++)cin>>a[i];
	for(int i=1;i<=y;i++)cin>>b[i];
	for(int i=1;i<=z;i++)cin>>c[i];
	ll sz=0;
	for(int i=1;i<=x;i++){
		for(int j=1;j<=y;j++){
			d[++sz]=a[i]+b[j];
		}
	}
	sort(d+1,d+sz+1,cmp);
	sort(c+1,c+1+z,cmp);
	for(int r=1;r<=min(3000LL,sz);r++){
		for(int i=1;i<=z;i++){
			ans.pb(d[r]+c[i]);
		}
	}
	sort(ans.begin(),ans.end(),cmp);
	for(int i=0;i<k;i++)cout<<ans[i]<<"\n";
    return 0;
}


Measured memory_bytes: 42980
#include <iostream>
#include <sstream>
#include <stack>
#include <iomanip>
#include <numeric>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <cassert>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >
#define endl '\n'
#define FIR first
#define SEC second
#define PB push_back
#define SZ(x) ((int)x.size())

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;
typedef pair<int, int> Pii;
typedef pair<int, lint> Pil;
typedef pair<lint, lint> Pll;
typedef pair<lint, int> Pli;

template<class U, class V>
istream& operator >>(istream& in, pair<U, V>& pr) {
    return in >> pr.first >> pr.second;
}

template<class U, class V>
ostream& operator <<(ostream& out, pair<U, V>& p) {
    return out << p.first << " " << p.second;
}

template<class T>
ostream& operator <<(ostream& out, vector<T> vec) {
    for (T& e : vec)
        out << e << " ";
    return out << endl;
}

// ---- BEGIN LIBRARY CODE ----
// ---- END LIBRARY CODE ----
void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

void solveSingleCase(int caseNo)
{
    int N;
    cin >> N;
    VEC(int) A(N);
    READVEC(A);

    int total = accumulate(ALL(A), 0);
    if (total % 10 != 0) {
        cout << total << endl;
        return;
    }

    int ret = 0;
    for (int a : A)
        if (a % 10 != 0) {
            ret = max(ret, total - a);
        }
    cout << ret << endl;
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int T = 1;
    // cin >> T;
    FOR(tcase, 1, T + 1) {
        solveSingleCase(tcase);
    }
    return 0;
};


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    // Your code here!
    int n=0;
    char s[101]={};
    char t[101]={};
    
    scanf("%d\n",&n);
    gets(s);
    gets(t);
    
    int max=0;
    for(int i=0;i<n;i++){
        int count=0;
        for(int j=0;j<n-i;j++){
            if(s[i+j]==t[j]){
                count++;
            }else{
                count=0;
                break;
            }
        }
        if(count>max){
            max=count;
        }
        //printf("%d %d\n",i,count);
    }
    printf("%d\n",2*n-max);
}

Measured memory_bytes: 1700
import scala.io.StdIn
import scala.math._, BigDecimal._

object Main extends App {
  val Array(a, b, c, d)  = StdIn.readLine.toString.split(" ").map(BigDecimal(_))

  def solve(a: BigDecimal, b: BigDecimal , c: BigDecimal, d: BigDecimal) : BigDecimal  = {
    val g = gcd(c.longValue(), d.longValue())
    val l = c.longValue() * d.longValue() / g


    val amod_c = ((a - 1) / c).setScale(0, RoundingMode.FLOOR)
    val amod_d = ((a - 1) / d).setScale(0, RoundingMode.FLOOR)
    val amod_cd = ((a - 1) / l).setScale(0, RoundingMode.FLOOR)

    val bmod_c = (b / c).setScale(0, RoundingMode.FLOOR)
    val bmod_d = (b / d).setScale(0, RoundingMode.FLOOR)
    val bmod_cd = (b / l).setScale(0, RoundingMode.FLOOR)


    (b - (bmod_c + bmod_d - bmod_cd)) - ((a - 1) - (amod_c + amod_d - amod_cd)) 

  }
  println(solve(a, b, c, d))

  def gcd(c: BigDecimal, d: BigDecimal): BigDecimal = {
    if (d == 0) c else gcd(d, c % d)
  }


}
  



Measured memory_bytes: 25656
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int INF=1e9;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
 
int main(){
  string s;
  cin>>s;
  int ans=(len(s)-1)/2;
  while(true){
    if(s.substr(0,ans)==s.substr(ans,ans)){
      break;
    }
    ans--;
  }
  cout<<ans*2<<endl;
}


Measured memory_bytes: 3612
using System;
    using System.Linq;
    using System.Collections.Generic;

    public class Program
    {
        public static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();
            int count = 0;

            while (input.Where(y => y % 2 == 0).Count() == num)
            {
                count++;
                input = input.Select(x => x / 2).ToList();
            }

            Console.WriteLine(count);
        }
    }

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

#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define mem(x,val) memset((x),(val),sizeof(x))
#define all(x) x.begin(),x.end()
#define pb push_back
#define mp make_pair
#define PI acos(-1.0) 
#define N 111111

const int INF = 1 << 30 ;
typedef long long ll ;
typedef pair < int , int > pii ;

int main() {
  int n , temp, sum = 0;
  cin >> n ;

  temp = n; 

  while(temp){
    sum+=(temp%10) ;
    temp/=10 ;
  }

  if(n%sum== 0) cout <<"Yes" << endl ;
  else cout <<"No"<<endl ;
	
  return 0 ;
}

Measured memory_bytes: 256
using System.Linq;
using static System.Math;
using System;

public class P
{
    public long act { get; set; }
    public int id { get; set; }
}

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, long.Parse);
        var ps = new P[n];
        for (int i = 0; i < n; i++)
            ps[i] = new P { id = i, act = a[i] };
        ps = ps.OrderByDescending(x => x.act).ToArray();
        goDP(n, ps);
    }
    static void goDP(int n, P[] ps)
    {
        var dp = new long[n + 1, n + 1];
        for (int i = 0; i < n; i++)
            for (int j = 0; j <= i; j++)
            {
                var te = dp[i, j] + calcL(j, ps[i]);
                dp[i + 1, j + 1] = Max(dp[i + 1, j + 1], te);
                var te2 = dp[i, j] + calcR(n, i, j, ps[i]);
                dp[i + 1, j] = Max(dp[i + 1, j], te2);
            }
        var ans = 0L;
        for (int i = 1; i < n + 1; i++)
            ans = Max(ans, dp[n, i]);
        Console.WriteLine(ans);
    }
    static long calcL(int y, P p) => p.act * Abs(y - p.id);
    static long calcR(int n, int x, int y, P p) => p.act * Abs(n - (x - y) - 1 - p.id);
}



Measured memory_bytes: 51476
#include <iostream>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <math.h>
using namespace std;
typedef long long int lli;
const long long int MaxN=300005;
const lli mod=1e9+7;
#define fst first
#define snd second
#define mp make_pair
const float pi=3.1415926535897932384626433832795028;
	lli mcd(lli a,lli b){
		if(a==0)return b;
		return mcd(b%a,a);
	}
	int arr[MaxN];
	void solve(){
		lli N,i,j,K,in=1;
		cin>>N>>K;
		for(i=0;i<N;i++){
			if(in<=K)in*=2;
			else in+=K;
		}
		cout<<in;
	}
int main(){
	//cin.tie(0),ios_base::sync_with_stdio(0);
	lli i,t;
	t=1;
	for(i=1;i<=t;i++){
		solve();
	}
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
import bisect
import heapq
import math
import random
import sys
from collections import Counter, defaultdict, deque
from decimal import ROUND_CEILING, ROUND_HALF_UP, Decimal
from functools import lru_cache, reduce
from itertools import combinations, combinations_with_replacement, product, permutations
from operator import add, mul, sub

sys.setrecursionlimit(100000)
input = sys.stdin.readline
INF = 2**62-1

def read_int():
    return int(input())


def read_int_n():
    return list(map(int, input().split()))


def read_float():
    return float(input())


def read_float_n():
    return list(map(float, input().split()))


def read_str():
    return input().strip()


def read_str_n():
    return list(map(str, input().split()))


def error_print(*args):
    print(*args, file=sys.stderr)


def mt(f):
    import time

    def wrap(*args, **kwargs):
        s = time.time()
        ret = f(*args, **kwargs)
        e = time.time()

        error_print(e - s, 'sec')
        return ret

    return wrap


@mt
def slv(N):
    c = 'abcdefghij'
    a = [-1] * N
    a[0] = 0
    def f(a):
        for i in range(N):
            if a[i] == -1:
                break
        else:
            return [a[:]]
        b = max(a[:i])
        ans = []
        for j in range(b+2):
            a[i] = j
            ans.extend(f(a))
            a[i] = -1
        return ans

    for b in f(a):
        print(''.join([c[i] for i in b]))




def main():
    N = read_int()
    (slv(N))


if __name__ == '__main__':
    main()


Measured memory_bytes: 26768
#include "bits/stdc++.h"
#define REP(i, n, N) for(ll i=(n); i<(N); i++)
#define RREP(i, n, N) for(ll i=(N-1); i>=n; i--)
#define CK(n, a, b) ((a)<=(n)&&(n)<(b))
#define ALL(v) (v).begin(),(v).end()
#define MCP(a,b) memcpy(b,a,sizeof(b))
#define p(s) cout<<(s)<<endl
#define p2(a, b) cout<<(a)<<" "<<(b)<<endl
#define v2(T) vector<vector<T>>
typedef long long ll;
using namespace std;
const ll mod = 1e9 + 7;
const ll inf = 1e18;

ll N;
ll A[200010];

int main(){
    cin>>N;
    REP(i,0,N){
        cin>>A[i];
        A[i]-=i+1;
    }
    sort(A,A+N);
    ll b=A[N/2];
    ll mn=inf,ans=0;
    if(N%2==0){
        b+=A[N/2-1];
        if(b%2){
            mn=0;
            ll bb=b/2+1;
            REP(i,0,N){
                mn+=abs(A[i]-bb);
            }
        }
        b/=2;
    }
    REP(i,0,N){
        ans+=abs(A[i]-b);
    }
    p(min(ans,mn));
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Beg049C
{
    class Program
    {
        static void Main(string[] args)
        {
            var dividers = new string[4] { "dream", "dreamer", "erase", "eraser" };
            var s = Console.ReadLine();
            var n = s.Length;
            var dp = new int[n + 1];
            dp[0] = 1;
            for(int i =0; i< n;i++)
            {
                if(dp[i] == 1)
                {
                    foreach(var div in dividers)
                    {
                        if (n - i >= div.Length && s.Substring(i, div.Length) == div)
                            dp[i + div.Length] = 1;
                    }
                }
            }
            var ans = dp[n] == 1 ? "YES" : "NO";
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13664
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
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; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    ll su = a[0];
    FOR(i,1,n-1) {
        su = su ^ a[i];
    }
    rep(i,n) {
        ll ans = su ^ a[i] ;
        cout << ans << " ";
    }
}


Measured memory_bytes: 3944
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int X, Y;
  cin>>X>>Y;
  bool ok = true;
  int A, B;
  if((Y-2*X)%2==0 && (Y-2*X)>=0) {
    B = (Y-2*X)/2;
    A = X-B;
    if(A<0||B<0) ok = false;
  }
  else {
    ok = false;
  }
  if(ok) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3588
def f(l,a):
	q=a[:n];s=sum(q);heapify(q);l+=[s]
	for e in a[n:2*n]:s+=e-heappushpop(q,e);l+=[s]
from heapq import*;n,*a=map(int,open(0).read().split());l=[];f(l,a);f(l,[-i for i in a[::-1]]);m=len(l)//2;print(max(l[i]+l[-i-1]for i in range(m)))

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

typedef long long ll;
typedef pair<int,int> ii;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	vector<int> v(n), c(n);
	int ret=0;
	for (int i=0; i<n; i++)
		cin>>v[i];
	for (int i=0; i<n; i++)
		cin>>c[i];
	for (int i=0; i<n; i++)
		ret+=max(0,v[i]-c[i]);
	cout<<ret<<"\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define N 100010
char str[N];
int n,ans;
int main(){
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=2;i<=n;++i) if(str[i]!=str[i-1]) ans++;
	printf("%d\n",ans);
	return 0; 
} 

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<iostream>
using namespace std;
int n,m,dis[20][20],id[1<<16],sum=0,p[1<<16],f[1<<16][20],ans;
const int inf=1<<28;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++) id[1<<(i-1)]=i;
	for(int i=1;i<=m;i++)
	{
		int x,y,c;scanf("%d %d %d",&x,&y,&c);
		dis[x][y]=c;dis[y][x]=c;sum+=c;
	}
	for(int i=1;i<1<<n;i++)
	{
        int x=id[i&(-i)];
        p[i]=p[i^(1<<(x-1))];
        for(int j=x+1;j<=n;j++) if(i&(1<<(j-1))) p[i]+=dis[x][j];
    }
    for(int i=0;i<=n;i++) for(int j=0;j<1<<n;j++) f[j][i]=-inf;
    f[1][1]=0;ans=-inf;
    for(int s=1;s<1<<n;s++)
	{
        for(int i=1;i<=n;i++)
		{
            int r=s;
            while(r)
			{
                if((r&(1<<(i-1)))) f[s][i]=max(f[s][i],f[(s-r)|(1<<(i-1))][i]+p[r]);
                r=(r-1)&s;
            }
            for(int j=1;j<=n;j++)
                if (!(s&(1<<(j-1)))&&dis[i][j]) f[s|(1<<(j-1))][j]=max(f[s|(1<<(j-1))][j],f[s][i]+dis[i][j]);
        }
        if((s&(1<<(n-1)))) ans=max(ans,f[s][n]);
    }
    printf("%d",sum-ans);
}

Measured memory_bytes: 4480
N = int(input())
txt = ["AC","WA","TLE","RE"]
ans = [0] * 4
for _ in range(N):
    S = input()
    for i in range(4):
        if S == txt[i]:
            ans[i] = ans[i] + 1
for i in range(4):
    print(txt[i] + " x " + str(ans[i]))


Measured memory_bytes: 9196
# AtCoder Beginner Contest 045 - B
# -*- encoding: UTF-8 -*-

sa = list(input())
sb = list(input())
sc = list(input())

sdic = {"a": sa, "b" : sb , "c" : sc}

result = ""
b = True

c = sdic["a"].pop(0)
if len(sdic["a"]) == 0:
  result = "a"
  b = False

while b:
   c = sdic[c].pop(0)
   if len(sdic[c]) == 0 :
     result = c
     break

print(result.upper())


Measured memory_bytes: 3064
// Problem E : Optimal Rest

#include <iostream>
#include <string>
#include <sstream>

using namespace std;

int main(){
	// x\»ðÅãÉRðÁ¦½êÌ«ÅSÊèðÀ×½àÌ
	string str[] = {"R1......", "R1.....", "R1....", "R1...", "R1..", "R1.", "R16..", "R16.", "R16", "R1", 
				    "R2....." , "R2...." , "R2...", "R2..", "R2.", "R2", "R32.", "R32",
			    	"R4....", "R4...", "R4..", "R4.", "R4", "R64", "R8...", "R8..", "R8.", "R8" };
	// ãÌÅx\»Ì·³ð«ºµ½àÌ
	int back[] = {127, 126, 124, 120, 112, 96, 7, 6, 4, 64, 63, 62, 60, 56, 48, 32, 3, 2, 31, 30, 28, 24, 16, 1, 15, 14, 12, 8};
	static int len[3200001]; len[0] = 0;
	for(int i=1;i<=3200000;i++){
		len[i] = len[i-1]+3;
		for(int j=0;j<28;j++){
			if(i-back[j] < 0) continue;
			len[i] = min(len[i], len[i-back[j]] + (int)str[j].size());
		}
	}
	int test; cin >> test;
	string s;
	while(test--){
		cin >> s;
		// üÍ¶ñª\»·éxÌ·³ð²×é
		for(int i=0;i<s.size();i++) if(s[i]=='R') s[i] = ' ';
		istringstream iss(s);
		string tmp;
		int lest = 0;
		while(iss >> tmp){
			tmp = "R"+tmp;
			for(int i=0;i<28;i++)
				if(tmp == str[i]) lest += back[i];
		}
		while(lest > 0){
			for(int i=0;i<28;i++){
				if(lest-back[i] < 0) continue;
				if(len[lest] == len[lest-back[i]] + str[i].size()){
					cout << str[i];
					lest -= back[i];
					break;
				}
			}
		}
		cout << endl;
	}
}

Measured memory_bytes: 13000
#include<bits/stdc++.h>
using namespace std;
int a[200001];
int main()
{
	int n;
	cin>>n;
	int ans;
	cin>>a[1]>>a[2];
	ans=(a[1] xor a[2]);
	for(int i=3;i<=n;i++)
	{
		cin>>a[i];
		ans=(ans xor a[i]);
	}
	for(int i=1;i<=n;i++)
		cout<<(ans xor a[i])<<" ";
	return 0;
}

Measured memory_bytes: 4272
import sys
input=sys.stdin.readline
class UnionFind():
  def __init__(self,n):
    self.par=list(range(n))
   # print(self.par)
    self.size=[1]*n
  def find(self,x):
    if self.par[x]==x:
      return x
    else:
      self.par[x]=self.find(self.par[x])
      return self.par[x]
  def merge(self,x,y):
    x=self.find(x)
    y=self.find(y)
    if x==y:
      return
    else:
      if self.size[x]>=self.size[y]:
        self.par[y]=x
        self.size[x]+=self.size[y]
      else :
        self.par[x]=y
        self.size[y]+=self.size[x]
  def cnt(self,x):
    x=self.find(x)
    return self.size[x]

n,m=map(int,input().split())
edges=[ list(map(int,input().split())) for _ in range(m)]
uf=UnionFind(n)
ans=[]
curr=(n*(n-1))//2
for a,b in edges[::-1]:
  a-=1
  b-=1
  ans.append(curr)
  if uf.find(a)==uf.find(b):
    continue
  curr-=uf.cnt(a)*uf.cnt(b)
  uf.merge(a,b)
for i in ans[::-1]:
  print(i)


Measured memory_bytes: 36332
/*
ID: leezhen
TASK: practice
LANG: C++11
*/
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <fstream>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<pair<int, int> > vii;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define inf 1e9
#define REP(i, a, b) for (int i = int(a); i < int(b); i++)

// struct

// data
int n;

void solve() { printf("%d\n", (n - 1) / 2); }

int main() {
  scanf("%d", &n);
  solve();
  return 0;
}


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


int main(){
  string S,T;
  cin >> S >> T;
  int num=0;
  for(int i=0;i<3;i++){
    if(S.at(i)==T.at(i)){
      num++;
    }
  }
  cout<< num << endl;
    
}
      


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

const int MAX = 200000;

int main(){
    int N;
    int A[MAX];

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

    long long ans = 0;
    int t = 0;
    for(int i = 0;i < N;i++){
        if(A[i] < t){
            ans += t - A[i];
            A[i] = t;
        }
        t = A[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3996
#include <stdio.h>

int BubbleSort_Scount(int *, int);

int main(){
  int N,i,SwapCount;
  int A[100];

  scanf("%d",&N);
  for(i=0;i<N; i++){
    scanf("%d",&A[i]);
  }

  SwapCount = BubbleSort_Scount(A,N);
  for(i=0; i<N; i++){
    printf("%d",A[i]);
    if(i==N-1) printf("\n");
    else printf(" ");
  }
  printf("%d\n",SwapCount);
  return 0;
}

int BubbleSort_Scount(int *A, int len){
  int tmp,i,j,Scount=0;

  for(i=0; i<len-1; i++){
    for(j=len-1; j>=i+1; j--){
      if(A[j] < A[j-1]){
	tmp = A[j];
	A[j] = A[j-1];
	A[j-1] = tmp;
	Scount++;
      }
    }
  }

  return Scount;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main(){
  int n;
  cin >> n;
  if(n>=1000) cout << "ABD" << endl;
  else cout << "ABC" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define pf push_front
#define ll long long

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    char ch;
    cin>>ch;
    if(ch >= 'A' && ch <= 'Z')cout << "A\n";
    else cout << "a\n";
    
    return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = A[N-1];
    for (int i = N-2, c = 1; c < N-1; i--, c+=2) {
        if (c == N-2) {
            ans += A[i];
        }
        else {
            ans += A[i]+A[i];
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4012
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    Set<String> var = new HashSet<String>();
    for(int i = 0; i<n; i++){
      var.add(sc.next());
    }
    System.out.println(var.size());
  }
}

Measured memory_bytes: 77176
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll N = 2e5 + 5;
const ll MOD = 1e9 + 7;
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
#define pis pair<ll,string>
#define F first
#define S second
#define LCM(a,b) ((a*b)/__gcd(a,b))
#define inf 1e15
#define test ll cse;cin>>cse;for(ll _i=1;_i<=cse;_i++)
#define PI 3.14159265
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
const double EPS = 1E-9;
typedef vector< vector<double> > matrix;
typedef vector<int> vi;


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

int main() {
    fast;

    ll x; cin >> x;
    ll y = 360;

    ll circle = (x * y) / gcd(x, y);
    cout << circle / x << "\n";
    return 0;
}

Measured memory_bytes: 3564
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
    ll N;
    cin >> N;
    vvi G(N+1);
    rep(i, N - 1) {
        int a, b;
        cin >> a >> b;
        G[a].pb(b);
        G[b].pb(a);
    }
    queue<int> q;
    
    q.push(1);
    vi dist1(N + 1, -1);
    dist1[1] = 0;
    while (!q.empty()) {
        int v = q.front();
        q.pop();
        for (int u : G[v]) {
            if (dist1[u] != -1) continue;
            dist1[u] = dist1[v] + 1;
            q.push(u);
        }
    }
    q.push(N);
    vi dist2(N + 1, -1);
    dist2[N] = 0;
    while (!q.empty()) {
        int v = q.front(); 
        q.pop();
        for (int u : G[v]) {
            if (dist2[u] != -1) continue;
            dist2[u] = dist2[v] + 1;
            q.push(u);
        }
    }
    int black = 0;
    int white = 0;

    for (int i = 2; i < N; i++) {
        if (dist1[i] <= dist2[i]) black++;
        else white++;
    }
    if (black > white) cout << "Fennec" << endl;
    else cout << "Snuke" << endl;
}

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

int main() {
    int n; cin >> n;
    int d[n];
    rep(i, n) cin >> d[i];
    int ans = 0;
    rep(i, n-1){
        for(int j = i+1; j < n; j++) ans += d[i]*d[j];
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
from math import pi, cos, sin, sqrt
def main():
    a, b, h, m = map(int, input().split())
    m_rad = 2*pi * m / 60
    h_rad = 2*pi * (h/12 + 1/12*m/60)
    h_x, h_y = a*cos(h_rad), a*sin(h_rad)
    m_x, m_y = b*cos(m_rad), b*sin(m_rad)
    print(sqrt(abs(h_x - m_x)**2 + abs(h_y - m_y)**2))

if __name__ == "__main__":
    main()

Measured memory_bytes: 9516
#include <iostream>
#include <string>
#include <map>

using namespace std;

typedef long long LL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)


int main() {
  int N;
  cin >> N;
  map<char, LL> counter;
  counter['M'] = counter['A'] = counter['R'] = counter['C'] = counter['H'] = 0;

  REP(i, N) {
    string s;
    cin >> s;
    ++counter[s[0]];
  }
  char combination[10][3] = {
    {'M','A','R'},
    {'M','A','C'},
    {'M','A','H'},
    {'M','R','C'},
    {'M','R','H'},
    {'M','C','H'},
    {'A','R','C'},
    {'A','R','H'},
    {'A','C','H'},
    {'R','C','H'}
  };
  LL res = 0;
  REP(i, 10)
    res += counter[combination[i][0]] * counter[combination[i][1]] * counter[combination[i][2]];

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int a, b, ans; cin>> a >> b;
    int hi = max(a, b);
    ans = max(a+b, 2 * hi - 1);
    cout << ans << "\n";

    
    
    
    return 0;
}

Measured memory_bytes: 3648
#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];
  }
  sort(A,A+N);
  int flag=0;
  if(N%2==1){
    if(A[0]!=0) flag=1;
    for(int i=1;i<N;i++){
      if(A[i]!=((i+1)/2)*2) flag=1;      
    }
  }
  if(N%2==0){
    if(A[0]!=1) flag=1;
    if(A[1]!=1) flag=1;
    for(int i=2;i<N;i++){
      if(A[i]!=(i/2)*2+1) flag=1;
    }
  }
  if(flag){
    cout<<0<<endl;
    return 0;
  }
  long long ans=1;
  if(N%2==0){
    for(int i=0;i<N/2;i++){
      ans=(ans*2)%1000000007;
    }
  }
  if(N%2==1){
    for(int i=0;i<(N-1)/2;i++){
      ans=(ans*2)%1000000007;
    }
  } 
  cout<<ans<<endl;
  return 0;
}

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(int i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl


int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    int X, N; cin >> X >> N;
    vector<bool> A(100, true);
    REP(i, N) {
        int p; cin >> p;
        A[p] = false;
    }
    REP(i, 100) {
        if(A[X - i]) {
            cout << X - i << "\n";
            return 0;
        }
        if(A[X + i]) {
            cout << X + i << "\n";
            return 0;
        }
    }
    cout << X << "\n";
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    long long x[n][3];
    for(int i=0;i<n;i++)for(int j=0;j<3;j++)cin>>x[i][j];
    long long ma=0;
    for(int i=0;i<8;i++){
        int I=i;
        long long status[n]={};
        for(int j=0;j<3;j++){
            if(I%2)for(int k=0;k<n;k++)status[k]+=x[k][j];
            else for(int k=0;k<n;k++)status[k]-=x[k][j];
            I/=2;
        }
        sort(status,status+n,greater<long long>());
        long long X=0;
        for(int i=0;i<m;i++)X+=status[i];
        ma=max(ma,X);
    }
    cout<<ma<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl "\n"
#define ll long long
#define BUF 1e5
#define INF 1LL << 30
#define vi vector<int>
#define vvi vector<vector<int>>
#define all(a) (a).begin(), (a).end()
#define bit(n) (1LL << (n))
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
constexpr ll mod = 1e9 + 7;
ll A, B, C, D, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

template <typename Monoid>
class SegmentTree {
public:
    using F = function<Monoid(Monoid, Monoid)>;

    vector<int> node;
    int size;
    int n;
    F f;
    Monoid ie;

    SegmentTree(vector<int> &in, F f, Monoid ie) : f(f), ie(ie) {
        int in_sz = in.size();
        n = 1;
        while (n < in_sz) {
            n *= 2;
        }
        size = n * 2 - 1;
        node.resize(size, 0);
        for (int i = 0; i < in_sz; i++) {
            node[n - 1 + i] = in[i];
        }
        init_dfs(0);
    }

    int init_dfs(int now) {
        if (2 * now + 1 >= size)
            return node[now];
        node[now] = f(init_dfs(2 * now + 1), init_dfs(2 * now + 2));
        return node[now];
    }

    void add(int index, int val) {
        index += n - 1;
        node[index] += val;
        while (index > 0) {
            index = (index - 1) / 2;
            node[index] = f(node[2 * index + 1], node[2 * index + 2]);
        }
    }

    void update(int index, int val) {
        index += n - 1;
        node[index] = val;
        while (index > 0) {
            index = (index - 1) / 2;
            node[index] = f(node[2 * index + 1], node[2 * index + 2]);
        }
    }

    int query(int a, int b) {
        return _query(a, b, 0, 0, n);
    }

    int _query(int a, int b, int now, int l, int r) {
        if (r <= a || b <= l)
            return ie;
        if (a <= l && r <= b)
            return node[now];
        int val_l = _query(a, b, 2 * now + 1, l, (l + r) / 2);
        int val_r = _query(a, b, 2 * now + 2, (l + r) / 2, r);
        return f(val_l, val_r);
    }
};

signed main() {
    cin >> N >> Q;
    int ie = (1LL << 31) - 1;
    vector<int> v(N, ie);
    SegmentTree<int> sg(v, [](int x, int y) { return min(x, y); }, ie);
    for (int q = 0; q < Q; q++) {
        int c, x, y;
        cin >> c >> x >> y;
        if (c == 0) {
            sg.update(x, y);
        } else {
            cout << sg.query(x, y + 1) << endl;
        }
    }
}


Measured memory_bytes: 4132
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ll long long
using namespace std;

int main(){
	string N;cin >> N;

	if(N[1] == 'B'){
		cout << "ARC"<< endl;
	}else{
		cout << "ABC" << endl;
	}
	
}


Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, end) for (long long int i=0; i<end; i++)
#define repp(i, begin, end) for (long long int i=begin; i<end; i+)
#define srt(x) sort((x).begin(), (x).end());
#define rsrt(x) sort((x).rbegin(), (x).rend());
#define deb(x) cout<<#x<<" = "<<(x)<<" (L"<<__LINE__<<")"<<endl;
using namespace std;
using ll = long long int;
using vi = vector<int>;
using vll = vector<long long int>;
using vs = vector<string>;
ll sm(vll x) {ll sum=0; rep(i, x.size()) sum+=x[i]; return sum;}
void vdeb(string s, vector<int> x) {cout<<s<<" = { "; rep(i, x.size()) cout<<x[i]<<' '; cout <<'}'<<endl;}
//=======================================================================================================

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    ll pro;
    pro = n * a;
    if(pro < b) cout << pro;
    else cout << b;
    cout << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    set<int> st = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
    for (int i = 0; i < k; ++i) {
        int x;
        cin >> x;
        st.erase(x);
    }
    while (true) {
        string s = to_string(n);
        bool flag = true;
        for (char i : s) {
            if (!st.count(i - '0')) {
                flag = false;
                break;
            }
        }
        if (flag) {
            cout << n << endl;
            break;
        }
        ++n;
    }
}


Measured memory_bytes: 256