akhauriyash/Code-Regression huggingface dataset:
import sys
import numpy as np
import numba
from numba import njit, b1, i4, i8, f8

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

uf_t = numba.types.UniTuple(i8[:], 2)


@njit((uf_t, i8), cache=True)
def find_root(uf, x):
    root = uf[0]
    while root[x] != x:
        root[x] = root[root[x]]
        x = root[x]
    return x


@njit((uf_t, i8, i8), cache=True)
def merge(uf, x, y):
    root, size = uf
    x, y = find_root(uf, x), find_root(uf, y)
    if x == y:
        return False
    if size[x] < size[y]:
        x, y = y, x
    size[x] += size[y]
    root[y] = root[x]
    return True

@njit((i8, i8[:]), cache=True)
def main(N, AB):
    root = np.arange(N + 1, dtype=np.int64)
    size = np.ones(N + 1, np.int64)
    uf = (root, size)
    for i in range(0, len(AB), 2):
        a, b = AB[i], AB[i + 1]
        merge(uf, a, b)
    return size.max()

N, M = map(int, readline().split())
AB = np.array(read().split(), np.int64)

print(main(N,AB))

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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    string s;
    cin >> n;
    cin >> s;
    int flag = 1;
    if(n%2!=0)
    {
       flag = 0;
    }
    else
    {
        for(int i=0;i<n/2;i++)
        {
            if(s[i]!=s[i+n/2])
            {
                flag=0;
            }
           /// cout << flag << endl;
        }
    }
    if(flag==1)
    {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
}


Measured memory_bytes: 3592
using System;

namespace AtCoderABC130C
{
    class Program
    {
        static void Main(string[] args)
        {
            int ans = 0;

            string[] s = Console.ReadLine().Split(' ');

            int W = int.Parse(s[0]);
            int H = int.Parse(s[1]);
            int x = int.Parse(s[2]);
            int y = int.Parse(s[3]);

            double S = (double)W * (double)H;
            S = S / 2;

            if (W == x * 2 && H == y * 2)
                Console.WriteLine(S.ToString() + " 1");
            else
                Console.WriteLine(S.ToString() + " 0");
        }
    }

}


Measured memory_bytes: 13140
import heapq
h = []

N, M = map(int, input().split())

for i in range(N):
  heapq.heappush(h, tuple(map(int, input().split())))

num = 0
result = 0

while(num < M):
  a, b = heapq.heappop(h)
  buyNum = min(b, M - num)
  num += buyNum
  result += buyNum * a
  
print(result)

Measured memory_bytes: 16668
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int, int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
int dx[8] = { 1, 0, -1, 0, 1, -1, -1, 1 };
int dy[8] = { 0, 1, 0, -1, 1, 1, -1, -1 };
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; }
struct io { io() { ios::sync_with_stdio(false); cin.tie(0); } };
const int INF = INT_MAX;
const ll LLINF = 1LL << 60;
const ll MOD = 1000000007;
const double EPS = 1e-9;
//#include <math.h>
signed main(void) 
{
    string a, b;
    cin >> a >> b;
    cout << b << a;
   
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <iomanip>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;
constexpr double PI = 3.14159265358979323846;
constexpr int di[] = {0, 0, 1, -1};
constexpr int dj[] = {1, -1, 0, 0};

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

    int n, h[112345];

    cin >> n;
    REP(i, n)
    cin >> h[i];

    int ma = h[0] - 1;

    for (int i = 1; i < n; i++)
    {
        if (ma > h[i])
        {
            cout << "No" << endl;
            return 0;
        }

        if (ma != h[i])
            h[i]--;

        ma = max(h[i], ma);
    }

    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int a,b,c,x,num;
int main()
{
	scanf("%d%d%d%d",&a,&b,&c,&x);
	for(int i=0;i<=a;i++)
		for(int j=0;j<=b;j++)
			for(int k=0;k<=c;k++)
			if(500*i+100*j+50*k==x)num++;
	printf("%d",num);
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#define MAX 110

typedef struct cell{
 int id;
 struct cell *next;
}cell;



cell* makecell(int x){
cell *new=malloc(sizeof(cell));

new->id=x;
new->next=NULL;

return new;
}

void enque(int QUE[],int x,int *left,int *right){

QUE[*right]=x;
(*right)++;

return;
}


int deque(int QUE[],int *left,int *right){


(*left)++;

return QUE[(*left)];
}






void BFS(cell *S[],int s,int n){
int F[MAX];
int i,u,v;
int QUE[MAX];
int left=-1;
int right=0;
cell *p;

for(i=1;i<=n;i++)F[i]=-1;


F[s]=0;
enque(QUE,s,&left,&right);

while(right-left!=1){
 v=deque(QUE,&left,&right);
 p=S[v];
 
 while(p!=NULL){
  if(F[p->id]==-1){
    F[p->id]=F[v]+1;
    enque(QUE,p->id,&left,&right);
  }
  p=p->next;
 }

}



for(i=1;i<=n;i++){
 printf("%d %d\n",i,F[i]);
}

return;
}


int main(){
int n,i,j;
int x,y,z;
cell *S[MAX];
cell **p;
cell *new;


scanf("%d",&n);

for(i=0;i<n;i++){
 scanf("%d %d",&x,&y);

 if(y==0)S[x]=NULL;
 else{p=&S[x];
  for(j=0;j<y;j++){
   scanf("%d",&z);
   new=makecell(z);
   (*p)=new;
   p=&((*p)->next);
  }
 }
}




BFS(S,1,n);





return 0;
}


Measured memory_bytes: 2052
/* 
    Author : Jeff Ahn
    Sun 05 Jul 2020 05:25:05 AM PDT 
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,r) for(int i = 0; i < (r); i++)
#define pb push_back
#define all(a) a.begin(), a.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define int long long
#define uint unsigned long long
#define endl '\n'

int n;
const int mn = 2e5+10;
int a [mn];

signed main() {
  fastio;
  cin >> n;
  rep(i,n) cin >> a[i];
  sort(a, a + n);
  reverse(a, a + n);
  int res = a[0];
  for (int i = 1; i < n/2; i++) {
    int ai = a[i];
    res += ai + ai;
  }
  if (n&1) res += a[n/2];
  cout << res << endl;
}


Measured memory_bytes: 5212
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 99999999999999999
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



#define SIZE 1005

int num_player,N;
bool check[SIZE];


int getNUM(char buf[10]){

	int ret = 0;

	for(int i = 0; buf[i] != '\0'; i++){

		ret = ret*10+(buf[i]-'0');
	}

	return ret;
}

bool isNUM(char buf[10]){

	for(int i = 0; buf[i] != '\0'; i++){
		if(buf[i] < '0' || buf[i] > '9'){
			return false;
		}
	}
	return true;
}


void func(){

	queue<int> Q;
	char buf[10];


	for(int i = 1; i <= num_player; i++){
		check[i] = false;
		Q.push(i);
	}

	int count = num_player;
	int tmp;

	for(int i = 1; i <= N; i++){

		scanf("%s",buf);

		if(count == 1)continue;

		tmp = Q.front();
		Q.pop();

		if(i%15 == 0){

			if(strcmp(buf,"FizzBuzz") == 0){
				Q.push(tmp);
			}else{

				count--;
			}

		}else if(i%3 == 0){

			if(strcmp(buf,"Fizz") == 0){
				Q.push(tmp);
			}else{
				count--;
			}

		}else if(i%5 == 0){

			if(strcmp(buf,"Buzz") == 0){

				Q.push(tmp);
			}else{

				count--;
			}

		}else{

			if((isNUM(buf) == true) & (getNUM(buf) == i)){

				Q.push(tmp);
			}else{

				count--;
			}
		}
	}

	while(!Q.empty()){

		check[Q.front()] = true;
		Q.pop();
	}

	bool isFirst = true;

	for(int i = 1; i <= num_player; i++){
		if(check[i]){

			if(isFirst){

				printf("%d",i);
				isFirst = false;
			}else{

				printf(" %d",i);
			}
		}
	}
	printf("\n");
}

int main(){

	while(true){
		scanf("%d %d",&num_player,&N);
		if(num_player == 0 && N == 0)break;

		func();
	}

	return 0;
}



Measured memory_bytes: 3276
#include <cstdio>

int main(){
    int n,m;
    for(;;){
        scanf("%d %d",&n,&m);
        if(n == 0 && m == 0){
            break;
        }
        int a[n];
        for(int i = 0; i < n; i++){
            scanf(" %d",&a[i]);
        }

        int max = 0;
        for(int i = 0; i < n - 1; i++){
            for(int j = i + 1; j < n; j++){
                if(a[i] + a[j] <= m && a[i] + a[j] >= max){
                max = a[i] + a[j];
                }
            }
        }
        if(max != 0){
            printf("%d",max);
        }else{
            printf("NONE");
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 2760
h, w = [int(s) for s in input().split()]
if h == 1 or w == 1:
    print(1)
    exit()
rh, rw = h%2, w%2
eh, ew = h - rh, w- rw

result = int( eh * ew //2)
if rh == 1:
    result += ew //2
if rw == 1:
    result += eh //2
if rh == rw == 1:
    result += 1

print(result)


Measured memory_bytes: 3060
#[allow(unused_imports)]
use proconio::{input, fastout};
#[allow(unused_imports)]
use proconio::marker::{Chars};

#[fastout]
fn main() {
  input!{a:char}
  if a.is_uppercase() {
    println!("A")
  } else {
    println!("a")
  }
}


Measured memory_bytes: 2120
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var M = Number(lines[0]);

    console.log(24 - M + 24);
});

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

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

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


VI e[100000], c[100000];
int par[100000][18], depth[100000];
ll dist[100000];

void dfs(int now, int past){
    REP(i,e[now].size()){
        int next = e[now][i];
        if (next == past) continue;
        dist[next] = dist[now] + c[now][i];
        par[next][0] = now;
        depth[next] = depth[now] + 1;
        dfs(next, now);
    }
}

int lca(int x, int y){
    if (depth[y] > depth[x]) swap(x,y);
    int d = depth[x] - depth[y];
    REP(i,18){
        if ((d>>i) & 1){
            x = par[x][i];
        }
    }
    if (x == y) return x;
    FORR(i,17,0){
        if (par[x][i] != par[y][i]){
            x = par[x][i];
            y = par[y][i];
        }
    }
    return par[x][0];
}

int main(){
    int n, q, k;
    cin >> n;
    REP(i,n-1){
        int x, y, z;
        scanf("%d %d %d", &x, &y, &z);
        x--; y--;
        e[x].push_back(y);
        e[y].push_back(x);
        c[x].push_back(z);
        c[y].push_back(z);
    }
    cin >> q >> k;
    k--;
    par[0][0] = 0;
    depth[0] = 0;
    dfs(k, -1);

    FOR(i,1,17){
        REP(j,n){
            par[j][i] = par[par[j][i-1]][i-1];
        }
    }

    while (q--){
        int x, y;
        scanf("%d %d", &x, &y);
        x--; y--;
        // int z = lca(x, y);
        ll ans = dist[x] + dist[y];
        printf("%lld\n", ans);
    }


    return 0;
}

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  ll H, W;
  cin >> H >> W;

  ll h, w;
  cin >> h >> w;

//  ll ans = H*W;
//  ans -= h*W;
//  H -= h;
//  ans -= H*w;
  ll ans = (H-h) * (W-w);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
typedef long long ll;
using namespace std;

ll max2(ll a,ll b){
    ll ans=a;
    if(ans<b)ans=b;
    return ans;
}
ll min2(ll a,ll b){
    ll ans=a;
    if(ans>b)ans=b;
    return ans;
}
int n;
long long calc(vector<int> const& a,int b){
    long long sum=0;
    for(int i=0;i<n;i++){
        sum+=max2(a[i]-b-i-1,b+i+1-a[i]);
    }
    return sum;
}
ll bs(vector<int> const& a){
    int max=0;
    for(int i=0;i<a.size();i++){
        if(max<a[i])max=a[i];
    }
    int left=(-1)*max-1;
    int right=max;
    int mid;
    while(right-left>1){
        mid=(left+right)/2;
        if(calc(a,mid+1)-calc(a,mid)<0)left=mid;
        else right=mid;
    }
    return min2(calc(a,left),calc(a,right));
}
int main(){
    cin>>n;
    vector<int> a(n);
    for(int i=0;i<n;i++)cin>>a[i];
    cout<<bs(a)<<endl;
    return 0;
}

Measured memory_bytes: 1024
from fractions import gcd

N,X = map(int, input().split())
x = list(map(int, input().split()))

def gcd_calc(a):
  ans = a[0]
  for i in range(1, len(a)):
    ans = gcd(ans, a[i])
  return ans

x.sort()
cnt=0
for i,_x in enumerate(x):
  if (_x-X)>0:
    x.insert(i, X)
    cnt=1
    break
if cnt!=1:
  x.append(X)
list=[]
for i in range(len(x)-1):
  list.append(x[i+1]-x[i])

print(gcd_calc(list))
  
    

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

using namespace std;

#define ll long long

ll fuc(int n) {
	vector<ll> ans;
	ans.push_back(2);
	ans.push_back(1);
	for (int i = 2; i < n+1; i++) {
		ll a = ans[i-1]+ans[i-2];
		ans.push_back(a);
	}
	return ans[n];
}

void solve() {
	int n;
	cin >> n;
	cout << fuc(n) << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String s = scanner.next();
        String t = scanner.next();

        for (int i = 0; i < 3; i++) {
            t = t.substring(2, 3) + t.substring(1, 2) + t.substring(0, 1);
        }

        String judge = "NO";
        if (s.equals(t)) {
            judge = "YES";
        }
        System.out.println(judge);
    }

}


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

int main() {
	int N, K;
	cin >> N >> K;
	
	if(N%2 == 0) {
		N = N/2;
	}
	else {
		N = N/2 +1;
	}
	
	if(N >= K) cout << "YES" << endl;
	else cout << "NO" << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int 	     	  long long   // [9,223,372,036,854,775,807 to -9.....808] 19 digits
#define pb                push_back 
#define all(x)            (x).begin(),(x).end()
#define mp                make_pair
#define vi                vector<int> 
#define vpi               vector<pair<int,int>>
#define mii               map<int,int>
#define x                 first
#define y                 second 
#define mem(a,x)          memset(a,x,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define sz(x)             (int)((x).size())

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set; // find_by_order()  // order_of_key

//const int32_t hellhsh = 444440583533; const double pi=2*acos(0.0); 
const int32_t mod = 1e9+7;
const int32_t maxn=3e3+5;
int inf=1e18;

int n;double a[maxn],dp[maxn][maxn],ans=0;


void solve(){
    cin>>n;
    rep(i,0,n) cin>>a[i];
    rep(i,0,n) rep(j,0,n+1) dp[i][j]=0;
    
    rep(i,0,n){
        if(i) dp[i][0]=(1-a[i])*dp[i-1][0];
        else dp[i][0]=1-a[i];
        rep(j,1,i+2){
            if(!i){
                dp[i][j]=a[i];
            }
            else {
                dp[i][j]=a[i]*dp[i-1][j-1]+(1-a[i])*dp[i-1][j];
            }
            if(i==n-1 and j>(n/2)) ans+=dp[i][j]; 
        }
    }
    cout<<fixed<<setprecision(10)<<ans;
}

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int tc=1,k=1;                                                                                                                  
    //cin>>tc;
    while(tc--){
        //cout<<"Case #"<<k++<<": ";
        solve();
    }
    return 0;
}

Measured memory_bytes: 74160
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

string mes[] = {
".,!? ",
  "abc",
  "def",
  "ghi",
  "jkl",
  "mno",
  "pqrs",
  "tuv",
  "wxyz"
};

int main() {
  int n;
  
  cin >> n;
  while(n--) {
    string s;
    cin >> s;
    int N = s.size();
    int pos = -1;
    int stock = -1;
    for(int i=0; i<N; i++) {
      int button = s[i]-'0'-1;
      if(button == -1) {
	if(stock != -1)
	  cout << mes[stock][pos%(mes[stock].size())];
	stock = -1;
	pos = -1;
      }
      else {
	stock = button;
	pos ++;
      }
    }
    cout << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1212
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stdio.h>
#include <string>
#include <vector>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using LP = pair<ll, ll>;
const double PI = 3.1415926535897932;

int main()
{
	int N;
	cin >> N;
	vector<string> Sn(N);
	rep(i, N) {
		cin >> Sn[i];
	}
	sort(Sn.begin(), Sn.end());

	vector<string> Ans;
	int max_cnt = 0;
	int lc_cnt = 0;
	rep(i, N-1) {
		if (Sn[i] == Sn[i + 1]) {
			lc_cnt += 1;
		}
		else {
			lc_cnt = 0;
		}

		if (max_cnt == lc_cnt) {
			Ans.push_back(Sn[i]);
		}
		else if (max_cnt < lc_cnt) {
			Ans.clear();
			max_cnt = lc_cnt;
			Ans.push_back(Sn[i]);
		}
	}
	if (max_cnt == 0) Ans.push_back(Sn[N-1]);

	for (auto s : Ans) {
		cout << s << endl;
	}
	return 0;
} 

Measured memory_bytes: 17864
#include<bits/stdc++.h>
using namespace std;
int n;
long long a[200010];
void print(long long a[],long long len){
	for(int i=0;i<len;i++)cout<<a[i]<<' ';
	cout<<endl;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
		a[i]-=i+1;
	}
//	print(a,n);
	sort(a,a+n);
//	print(a,n);
	long long b=a[n/2],ans=0LL;
	for(int i=0;i<n;i++){
		ans+=abs(a[i]-b);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#include <iomanip>
#include <iostream>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

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

int main(void){
    int N; cin >> N;
    vector<int> s(N,0); for(int i = 0; i < N; i++) cin >> s.at(i);

    int ans = 0;
    int n_min = 10000;
    for(int i = 0; i < N; i++){
        ans += s[i];
        if(s.at(i) % 10 != 0){
            n_min = min(n_min,s.at(i));
        }
    }
    
    if(ans % 10 == 0){
        if(n_min != 10000) ans -= n_min;
        else ans = 0;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <bitset>
#include <complex>
#include <unistd.h>
#include <cassert>
#include <cctype>
#include <random>
#define _USE_MATH_DEFINES
#define _GLIBCXX_DEBUG
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> plglg;
typedef pair<double, ll> pdlg;
typedef tuple<int, int, int> tiii;
typedef tuple<ll, ll, ll> tlglglg;
typedef tuple<double, double, double> tddd;
typedef complex<double> xy_t;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
double pi = 3.141592653589793;
ll mod = 1000000007;
int intmax = 2147483647;
int intmin = -2147483648;
ll llmax = 9223372036854775807;
ll llmin = -9223372036854775807;
int iinf = intmax / 8;
ll inf = llmax / 8;
double eps = 1e-11;

int main() {
    ll W, H;
    cin >> W >> H;
    ll p[W], q[H];
    for (int i = 0; i < W; i++) {
        cin >> p[i];
    }
    for (int i = 0; i < H; i++) {
        cin >> q[i];
    }
    sort(p, p + W);
    sort(q, q + H);
    ll psum[W + 1], qsum[H + 1];
    psum[0] = 0;
    qsum[0] = 0;
    for (int i = 0; i < W; i++) {
        psum[i + 1] = psum[i] + p[i];
    }
    for (int i = 0; i < H; i++) {
        qsum[i + 1] = qsum[i] + q[i];
    }
    ll ans = psum[W] + qsum[H];
    for (int i = 0; i < H; i++) {
        int id = lower_bound(p, p + W, q[i]) - p;
        ans += psum[id] + q[i] * (W - id);
    }
    cout << ans << endl;
}


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

int n;
long long v[6], sol;

int main()
{
    cin >> n;
    for(int i = 1; i <= n; i++) {
        string s;
        cin >> s;
        if(s[0] == 'M') {
            v[1]++;
        }
        if(s[0] == 'A') {
            v[2]++;
        }
        if(s[0] == 'R') {
            v[3]++;
        }
        if(s[0] == 'C') {
            v[4]++;
        }
        if(s[0] == 'H') {
            v[5]++;
        }
    }
    for(int i = 1; i <= 3; i++) {
        for(int j = i + 1; j <= 4; j++) {
            for(int k = j + 1; k <= 5; k++) {
                sol += v[i] * v[j] * v[k];
            }
        }
    }
    cout << sol;
    return 0;
}


Measured memory_bytes: 3568
import math
A,B,N = map(int,input().split())

if B == 1:
  print(0)
else:
  if N >= B-1:
    x = math.floor(A-A/B)
    y = A - math.ceil(A/B)
    ans = max(x,y)
    print(ans)
  else:
    print(math.floor(A*N/B))

  

Measured memory_bytes: 9160
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


typedef struct{
	char symbol;
	int num;
	int flag;
} cards;

int main(void){
	int num_data, num_data_1;
	char input_symbol;
	int input_num;
	int i, j;
	cards cards[52];

	for(i=0 ; i < 52 ; i++){
		if(i < 13){
			cards[i].symbol = 'S';
			cards[i].num = i + 1;
		}
		else if(i < 26){
			cards[i].symbol = 'H';
			cards[i].num = i % 13 + 1;
		}
		else if(i < 39){
			cards[i].symbol = 'C';
			cards[i].num = i % 26 + 1;
		}
		else{
			cards[i].symbol = 'D';
			cards[i].num = i % 39 + 1;
		}
		cards[i].flag = 0;
	}
	
	scanf("%d", &num_data_1);
	num_data = num_data_1;
	
	for(i=0 ; i < num_data ; i++){
		scanf("%s %d", &input_symbol, &input_num);
		
		if(input_symbol == 'S'){
			cards[input_num - 1].flag = 1;	
		}
		else if(input_symbol == 'H'){
			cards[(input_num - 1) + 13 * 1].flag = 1;
		}
		else if(input_symbol == 'C'){
			cards[(input_num - 1) + 13 * 2].flag = 1;
		}
		else{
			cards[(input_num - 1) + 13 * 3].flag = 1;
		}
	}
	
	for(i=0 ; i < 52 ; i++){
		if(cards[i].flag == 0){
			printf("%c %d\n", cards[i].symbol, cards[i].num);
		}
	}
	
	return 0;
}

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

struct Process
{
	int time;
	char name[100];
};

#define SIZE 100005
Process Q[SIZE];

class Queue
{
	int putloc;
	int getloc;
public:	
	Queue() { putloc = getloc = 0; }
	bool isEnpty();
	void push(Process p);
	Process pop();
};

void Queue::push(Process p)
{
	if (putloc + 1 == getloc || (putloc == (SIZE - 1) && getloc == 0)) exit(1);
	putloc++;
	if (putloc == SIZE) putloc = 0;
	Q[putloc] = p;
}

Process Queue::pop()
{
	getloc++;
	if (getloc == SIZE) getloc = 0;
	return Q[getloc];
}

bool Queue::isEnpty()
{
	return getloc == putloc;
}

int main()
{
	Queue que;
	Process p;
	int n, q;
	int total = 0;
	//cin >> n >> q;
	scanf("%d %d", &n, &q);

	for (int i = 0; i < n; i++) {
		scanf("%s", p.name);
		scanf("%d" ,&p.time);
		que.push(p);
	}
	while (!que.isEnpty()) {
		p = que.pop();
		if (p.time > q) {
			p.time -= q;
			que.push(p);
			total += q;
		}
		else {
			total += p.time;
			//cout << p.name << " " << total << endl;
			printf("%s %d\n", p.name, total);
		}
	}
	return 0;
}

Measured memory_bytes: 11348
import java.util.*;

public class Main {


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

        if(a >= 13){
            System.out.println(b);
        } else if(a >= 6){
            System.out.println(b/2);
        } else {
            System.out.println("0");
        }

    }
}

Measured memory_bytes: 19924
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String S = sc.next();
		StringBuilder result = new StringBuilder();
		result.append(S);
		int count = 1;
		for(int j = 0; j <= result.length(); j++) {
			for(int i = 0; i <= result.length()-2; i++) {
				if(result.substring(i,i+1).equals(result.substring(i+1,i+2))) {
					result.delete(i+1, i+2);
					count++;
					i--;
				}
			}
			if(count == 1) {
				break;
			}
			count = 1;
		}
		System.out.println(result.length());
		sc.close();
	}

}


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

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

  int n;
  cin >> n;
  bool is_ok = false;
  for (int i = 1; i <= 9; i++) {
    if (n % i == 0) {
      int d = n / i;
      if (1 <= d && d <= 9) {
        is_ok = true;
        break;
      }
    }
  }
  if (is_ok) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }
}

int main() {
  answer1();
}


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

struct Rectangle{
    // indexの地点の高さ
    int height;
    // 始点のX
    int pos;
};

// buf = Tの一行の配列
// size = Tの一行のサイズ
int getLargestRectangle(int size,int buf[]){
    // stackとして長方形を保存
    stack<Rectangle> s;
    int maxV = 0;
    // 配列の最後を0にすることで、範囲外後に最大面積を計算するようにする
    buf[size] = 0;
    // stoperまで回す
    for(int i = 0;i <= size;++i){
        Rectangle rect;
        // 高さ代入
        rect.height = buf[i];
        // 横の位置は計算を始める時点の位置
        rect.pos = i;
        // stack空ならば追加
        if(s.empty()){
            s.push(rect);
        }
        else{
            // stackのトップにあるrectの高さより高い場合
            if(s.top().height < rect.height){
                s.push(rect);
            }
            // stackのトップにあるrectの高さよりも低い場合(保存してあった最大の高さが無効になるので、無効になる高さの面積を計算する必要がある)
            else if(s.top().height > rect.height){
                // 新しく積むrectの幅を出すために保存しておく。
                int targetX = i;
                // スタックに入っているrectが対象のrectの高さ以上の場合最大面積を計算する
                while(!s.empty() && s.top().height >= rect.height){
                    Rectangle pre = s.top();
                    s.pop();
                    // 面積を計算する()
                    int area = pre.height * (i - pre.pos);
                    maxV = max(maxV,area);
                    // 始点Xを入れ替える(stackに詰むrectの高さは取り出したrectの高さよりも低いので、取り出した地点が、回診X座標になる)
                    targetX = pre.pos;
                }
                rect.pos = targetX;
                s.push(rect);
            }
        }
    }
    return maxV;
}

int H,W;
// タイル情報を2次元で保存0:綺麗なタイル,1:汚れたタイル
int tiles[MAX][MAX];
// 高さを格納する2次元配列
int T[MAX][MAX];

int getLargestRectangle(){
    // ①各々の地点における高さを格納するプロセス
    for(int j = 0;j < W;++j){
        for(int i = 0;i < H;++i){
            // 汚れたタイル
            if(tiles[i][j]){
                T[i][j] = 0;
            }
            else{
                // 対象のindex地点の高さを格納する
                // 上の地点 + 1の高さになる
                T[i][j] = (i > 0) ? T[i - 1][j] + 1 : 1;    
            }
        }
    }
    // 最大面積保存用
    int maxV = 0;
    // 最大高さ分回す
    for(int i = 0;i < H;++i){
        maxV = max(maxV,getLargestRectangle(W,T[i]));
    }
    return maxV;
}

int main(){
    scanf("%d %d",&H,&W);
    for(int i = 0;i < H;++i){
        for(int j = 0;j < W;++j){
            scanf("%d",&tiles[i][j]);
        }
    }
    printf("%d\n",getLargestRectangle());
}



Measured memory_bytes: 18524
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
import java.util.Iterator;

class Graph {
	private int totalVertex;
	private LinkedList<LinkedList<Integer>> adjList;
	int[] discover;
	int[] finish;
	
	//adjacency list of edges
	public Graph() { 
			totalVertex = 0; 
		}
	public void loadAdjList() {
		Scanner in = new Scanner(System.in);
		totalVertex = in.nextInt();
		adjList = new LinkedList<LinkedList<Integer>>();
		for(int i = 0; i < totalVertex; i ++) {
			LinkedList<Integer> tmp = new LinkedList<Integer>();
			int idx1 = in.nextInt() - 1;
			int degree = in.nextInt();
			//System.out.println("mark idx1 = " + idx1 + " degree = " + degree);
			for(int j = 0; j < degree; j ++) {
				int idx2 = in.nextInt() - 1;
				tmp.add(idx2);
			}	
			adjList.add(tmp);
		}
		in.close();
	}
	public void printAdjMatrix() {
		Integer[][] adjMatrix = new Integer[totalVertex][totalVertex];
		
		for(int i = 0; i < adjMatrix.length; i++) {
			for(int j = 0; j < totalVertex ; j++) {
				adjMatrix[i][j] = 0;
			}
		}
		
		int z = 0;
		//int j = 0;
		
		for(LinkedList<Integer> ll: this.adjList) {
			for(Integer ele : ll) {
				adjMatrix[z][ele] = 1;
			}
			z++;
		}
		
		for(int m = 0; m < adjMatrix.length; m++) {
			for(int n = 0; n < totalVertex; n++) {
				if(n == totalVertex - 1) {
					System.out.println(adjMatrix[m][n]);
				}
				else {
					System.out.print(adjMatrix[m][n] + " ");
				}
				//System.out.print(adjMatrix[m][n] + " ");
			}
		}
	}
	
	public int DFS(int v, int time) {
	    
		if(discover[v] != 0) {
			return time;
		}
		else {
			discover[v] = time;
			for(Integer ele : this.adjList.get(v)) {
				time += 1;
				DFS(ele, time);
			}
			finish[v] = time;
		}
		
		return time;
	}
	
	public void BFS() {
		//int iter = 0;
		Queue<Integer> q = new LinkedList<>();
		q.add(0);
		int[] distances = new int[totalVertex];
		distances[0] = 0;
		for(int i = 1; i < distances.length; i++) {
			distances[i] = -1;
		}
		while(q.isEmpty() != true) {
			int u = q.remove();
			//System.out.println(u+1);
			//iter += 1;
			for(Integer ele : this.adjList.get(u)) {
				//System.out.println(u);
				if(distances[ele] == -1) {
					q.add(ele);
					distances[ele] = distances[u]+1;
				}
			}
		}
		
		for(int i = 0; i < distances.length; i++) {
			System.out.println(i + 1 + " " + distances[i]);
		}
	}
	
	public void searchGraph() {
		this.discover = new int[totalVertex];
		for(int i = 0; i < discover.length; i++) {
			discover[i] = 0;
		}
		this.finish = new int[totalVertex];
		for(int i = 0; i <finish.length; i++) {
			finish[i] = 0;
		}
		
		int dis_time = 1;
		
		for(LinkedList<Integer> ll: this.adjList) {
			for(Integer ele : ll) {
				DFS(ele, dis_time);
				dis_time++;
			}
		}
		
		
		for(int i = 1; i < totalVertex; i++) {
			System.out.println(i + " " + discover[i] + " " + finish[i]);
		}
	}
}

//change class name GraphRepresentation to Main() for submission to AIZU
class Main {
	public static void main(String argv[]) {
		Graph g = new Graph();
		g.loadAdjList();
		g.BFS();
		//g.printAdjMatrix();
		//g.searchGraph();
	}
}


Measured memory_bytes: 28440
import java.io.*;
import java.util.Scanner;

public class Main {
  
  public static void main(String[] args){
    
    try {
      //ローカル変数定義
      int page;		//書類のページ
      int paper;	//用紙
      
      //標準入力受け取り
      Scanner scan = new Scanner(System.in);
      String  N    = scan.next();
      
      page = Integer.parseInt(N);
      
      //用紙算出
      if (page % 2 == 0) {
        paper = page/2;
      } else {
        paper = page/2 + 1;
      }
      
      System.out.println(paper);
      
    } catch (Exception e) {
      
      System.out.println("error");

    }
  }
}


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

using namespace std;

typedef long long ll;

#define sz(x) ((int)(x).size())
#define in(x) int x;cin>>x
#define bit(n) (1<<(n))

#define out(x) cout<<(x)<<endl;
#define err(x) cerr<<(x)<<endl;
#define errr(x,y) cerr<<(x)<<" "<<(y)<<endl;

#define rep(i,n) for (int i=0;i<(n);i++)
#define repp(i,n) for (int i=1;i<=(n);i++)

#define inf5 100002
#define inf9 1000000002

int main(){
	int ans = 0, d = 0;
	in(n);
	d = to_string(n).length();

	if (d == 1) {
		ans = n;
	} else {
		if (d % 2) {
			rep(i, (d - 1) / 2) ans += pow(10, i * 2 + 1) - pow(10, i * 2);
			int r = pow(10, d);
			ans += n % r - pow(10, d - 1) + 1;
		} else {
			rep(i, d / 2) ans += pow(10, i * 2 + 1) - pow(10, i * 2);
		}
	}

	cout << ans << endl;

	return 0;
}


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

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

int dx[] = { 0, 1, -1, 0, 1, -1, 1, -1 };  // i<4:4way i<8:8way
int dy[] = { 1, 0, 0, -1, 1, -1, -1, 1 };

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);
int a,b,c,d;
int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    int n;
    cin >> n;
    rep(i,n){
        string s;
        cin >> s;
        if(s[0] == 'A')a++;
        else if(s[0] == 'W')b++;
        else if(s[0] == 'T')c++;
        else d++;
    }
    cout << "AC x " << a << endl;
    cout << "WA x " << b << endl;
    cout << "TLE x " << c << endl;
    cout << "RE x " << d << endl;
}

Measured memory_bytes: 3672
N = int(input())
src = [tuple(map(int,input().split())) for i in range(N)]

suma = sumb = 0
elems = []
for i,(a,b) in enumerate(src):
    suma += a
    sumb += b
    elems.append((a,i))
    elems.append((b,i))
ans = min(suma, sumb)
elems.sort()

sumw = 0
used = [0]*N
dup = False
for w,i in elems[:N]:
    sumw += w
    used[i] += 1
    if used[i] > 1: dup = True

if dup:
    ans = min(ans, sumw)
    print(ans)
    exit()

for i,(a,b) in enumerate(src):
    if a > b:
        a,b = b,a
    neww = elems[N][0] if i != elems[N][1] else elems[N+1][0]
    tmp = sumw - a + neww
    ans = min(ans, tmp)
print(ans)

Measured memory_bytes: 35628
import bisect
a,b,q = map(int,input().split())
INF = 10**18
s=[-INF]+[int(input()) for _ in range(a)]+[INF]
t=[-INF]+[int(input()) for _ in range(b)]+[INF]

def kai(x):
    res = INF
    s1 = bisect.bisect_right(s,x)
    ls = [s1,s1 - 1]
    t1 = bisect.bisect_right(t,x)
    lt = [t1,t1 - 1]
    for ss in ls:
        for st in lt:
            res = min(res,abs(x-s[ss])+abs(s[ss]-t[st]),abs(x-t[st])+abs(s[ss]-t[st]))
    return res

lx = [int(input()) for _ in range(q)]
for x in lx:
    print(kai(x))


Measured memory_bytes: 93400
import math
x = int(input())

L = []
for i in range(2,int(math.floor(math.sqrt(x)))+1):
  for j in range(x//i + 1):
    if i ** j <= x:
      L.append(i ** j)
      
if L == []:
  print("1")
else:
  print(max(L))


Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int n, m;
int a[200000], b[200001];
int res = 0;
int cnt[200001];

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        b[a[i]]++;
    }
    for (int i = 1; i <= n; ++i) for (int j = 0; j < b[i]; ++j) cnt[i - j]++;
    for (int i = 1; i <= n; ++i) if (cnt[i] == 0) res++;
    for (int i = 0; i < m; ++i) {
        int pos;
        cin >> pos;
        pos--;

        b[a[pos]]--;
        if (a[pos] - b[a[pos]] > 0) {
            cnt[a[pos] - b[a[pos]]]--;
            if (cnt[a[pos] - b[a[pos]]] == 0) res++;
        }

        cin >> a[pos];
        if (a[pos] - b[a[pos]] > 0) {
            if (cnt[a[pos] - b[a[pos]]] == 0) res--;
            cnt[a[pos] - b[a[pos]]]++;
        }
        b[a[pos]]++;

        cout << res << "\n";
    }
}


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

int main(){
  string S;
  cin >> S;
  vector<string> T={"dream","dreamer","erase","eraser"};
  reverse(S.begin(),S.end());
  for(int i=0;i<4;i++){
    reverse(T.at(i).begin(),T.at(i).end());
  }
  bool all_cut=true;
  for(int i=0;i<S.size();){
    bool cut=false;
    for(int j=0;j<4;j++){
      string U=S.substr(i,T.at(j).size());
      if(U==T.at(j)){
        i+=T.at(j).size();
        cut=true;
        break;
      }
    }
    if(!cut){
      all_cut=false;
      break;
    }
  }
  if(all_cut){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 3744
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> G(N + 1, 0);
    int left = 1, right = N;
    for (int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        left = max(left, a);
        right = min(right, b);
    }
    cout << max(right - left + 1, 0) << endl;
    return 0;
}

Measured memory_bytes: 3716
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 2000000000
int main(){
	double a,b;
	while(scanf("%lf %lf",&a,&b) && a+b!=0.0){
		double w=sqrt(a*a/4.0+b*b);
		double ans=w*a*2.0;
		ans+=a*a;
		printf("%f\n",ans);
	}
}

Measured memory_bytes: 1228
n, m = [int(i) for i in input().split(" ")]
score_dict = {}
 
for i in range(m):
    p, s = input().split(" ")
    if p not in score_dict:
        score_dict[p] = []
    
    score_dict[p].append(s)
 
ac_count = 0
wa_count = 0
 
for i in score_dict.values():

    if "AC" in i:
        ac_count += 1
        wa_count += i.index("AC")
 
print("{0} {1}".format(ac_count, wa_count))

Measured memory_bytes: 31548
#include <bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define rep(i,N) for(long long i = 0; i < (long long)(N); i++)
#define repr(i,N) for(long long i = (long long)(N) - 1; i >= 0; i--)
#define rep1(i,N) for(long long i = 1; i <= (long long)(N) ; i++)
#define repr1(i,N) for(long long i = (N) ; (long long)(i) > 0 ; i--)
#define each(x,v) for(auto& x : v)
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
using namespace std; void solve();
using ll = long long; template<class T = ll> using V = vector<T>;
using vi = V<int>; using vl = V<>; using vs = V<string>;
using vd = V<double>; using vvi = V< V<int> >; using vvl = V< V<> >;
template<typename T>using heap = priority_queue< T , V<T> , greater<T> >;
constexpr int inf = 1001001001; constexpr ll infLL = (1LL << 61) - 1;
struct IoSetupNya {IoSetupNya() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); cerr << fixed << setprecision(7);} } iosetupnya;
template<typename T, typename U> inline bool amin(T &x, U y) { return (y < x) ? (x = y, true) : false; }
template<typename T, typename U> inline bool amax(T &x, U y) { return (x < y) ? (x = y, true) : false; }
template<typename T, typename U> ostream& operator <<(ostream& os, const pair<T, U> &p) { os << p.first << " " << p.second; return os; }
template<typename T, typename U> istream& operator >>(istream& is, pair<T, U> &p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator <<(ostream& os, const vector<T> &v) { int s = (int)v.size(); rep(i,s) os << (i ? " " : "") << v[i]; return os; }
template<typename T> istream& operator >>(istream& is, vector<T> &v) { for(auto &x : v) is >> x; return is; }
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
template<typename T>void die(T x){out(x); exit(0);}
#ifdef NyaanDebug
  #include "NyaanDebug.h"
  #define trc(...) do { cerr << #__VA_ARGS__ << " = "; dbg_out(__VA_ARGS__);} while(0)
  #define trca(v,N) do { cerr << #v << " = "; array_out(v , N);cout << endl;} while(0)
#else
  #define trc(...)
  #define trca(...)
  int main(){solve();}
#endif

using P = pair<int,int>; using vp = V<P>;
constexpr int MOD = /**/ 1000000007; //*/ 998244353;
//////////


void solve(){
  
  ini(N);
  vi a(N); in(a);
  int cur = inf;
  int ans = 0;
  each(x , a){
    if(amin(cur , x)) ans++;
  }
  out(ans);
  

}

Measured memory_bytes: 1024
x, n = map(int, input(). split())
p = []
if n > 0:
  p = list(map(int, input(). split()))
if n == 0:
  print(x)
else:
  if x not in p:
    print(x)
  else:
    d = 1
    while True:
      if x-d not in p:
        print(x-d)
        break
      if x+d not in p:
        print(x+d)
        break
      d += 1

Measured memory_bytes: 61820
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

#include <functional>

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n, m;
    cin, n, m;
    vector<vector<int>> g(n);
    REP(i, 0, n - 1) {
        int a, b;
        cin, a, b;
        a--;
        b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    vector<ll> dp(n, 1);
    vector<vector<ll>> sumL(n, vector<ll>(1, 1)), sumR(n, vector<ll>(1, 1));
    function<void(int, int)> dfs = [&](int v, int p) {
        vector<ll> res;
        for (int i = 0; i < g[v].size(); i++) {
            int vv = g[v][i];
            if (vv == p) continue;
            dfs(vv, v);
            res.emplace_back((dp[vv] + 1) % m);
        }
        REP(i, 0, res.size()) {
            sumL[v].emplace_back((sumL[v].back() * res[i]) % m);
        }
        REP(i, 0, res.size()) {
            sumR[v].emplace_back((sumR[v].back() * res[res.size() - i - 1]) % m);
        }
        reverse(sumR[v].begin(), sumR[v].end());
        dp[v] = sumL[v].back();
    };

    vector<ll> prop(n, 1);
    function<void(int, int)> bfs = [&](int v, int p) {
        int cnt = 0;
        for (auto vv : g[v]) {
            if (vv == p) continue;
            prop[vv] = (sumL[v][cnt] * sumR[v][cnt + 1]) % m;
            prop[vv] = (prop[vv] * prop[v] + 1) % m;
            dp[vv] = (prop[vv] * sumL[vv].back()) % m;
            bfs(vv, v);
            cnt++;
        }
    };
    dfs(0, -1);
    bfs(0, -1);

    REP(i, 0, n) {
        print(dp[i]);
    }

    return 0;
}


Measured memory_bytes: 28928
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n;
    int i, j, k;
    int[] a;

    a = new int[10];
    for(;sc.hasNext();){
      n = sc.nextInt();
      j = 1; k = 0;
      for(i = 0;i < 10;i++){
        if(n % (j * 2) != 0 && i != 9){
          a[k++] = j;
          n -= j;
        }else if(n % (j * 2) != 0 && i == 9)a[k++] = j;
        j *= 2;
      }
      for(i = 0;i < k - 1;i++)out.print(a[i] + " ");
      out.println(a[i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 17212
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

const int MAXN = 50;
bool visited[MAXN];


int main(){
    int n;
    cin >> n;
    int res = 1;
    for(;res<=n;res*=2);
    
    put(res/2);
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    long K = sc.nextLong();
    long[] A = new long[N];
    int[] bitNum = new int[64];
    for (int i = 0; i < N; i++) {
      long a = sc.nextLong();
      A[i] = a;
      int j = 0;
      while (a > 0) {
        bitNum[j++] += a%2;
        a >>= 1;
      }
    }
    
    int i = 0;
    int[] bitK = new int[64];
    while (K > 0) {
      bitK[i++] = (int)(K%2);
      K >>= 1;
    }
    
    boolean any = false;
    long x = 0;
    while (--i >= 0) {
      int b;
      if (bitNum[i] >= (N+1)/2) {
        b = 0;
      } else {
        b = 1;
      }
      x <<= 1;
      if (any) {
        x |= b;
      } else {
        if (b == 0 && bitK[i] == 1) {
          any = true;
        } else {
          x |= bitK[i];
        }
      }
    }
    
    long ans = 0;
    for (int j = 0; j < N; j++) {
      ans += x ^ A[j];
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 52036