akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
    final Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        String s = sc.next();

        int count = 0;
        for (int i = 0; i < s.length()/2; i++) {
            if (s.charAt(i) != s.charAt(s.length()-i-1)) count++;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 23508
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
    #endif
    // int T;cin>>T;while(T--) 
    {
        string s, t;
        cin>>s>>t;
        int ans = 0;
        ifr(i, 0, s.length()) {
            if(s[i]!=t[i]) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 3804
#include <stdio.h>
 
int main(void) {

	// ??????????????\??????????????°?????\???????????°
	int line;
	scanf("%d", &line);
	
	int column;
	scanf("%d", &column);
	
	int grid[line + 1][column];
	
	// ????????????????????????
	//int *p_line = calloc(line, sizeof(int));


	// ????¬???????????????????
	for (int left = 0; left <= line; left++) {

		for (int right = 0; right < column; right++) {

			grid[left][right] = 0;
		}
	}
	
	// ??\??????????????°?????????????????\??????
	for (int left = 0; left <= line; left++) {

		for (int right = 0; right < column; right++) {

			scanf("%d", &grid[left][right]);
		}
	}

	// ????¨??????\?????????????????????
	int sum[line];
	
	for (int cnt = 0; cnt < line; cnt++) {
		
		sum[cnt] = 0;
	}

	// ???????????????
	for (int cnt1 = 0; cnt1 < line; cnt1++) {

		for (int cnt2 = 0; cnt2 < column; cnt2++) {

			sum[cnt1] += grid[cnt1][cnt2] * grid[line][cnt2];

		}
		printf("%d\n", sum[cnt1]);
	}
	return 0;
}

Measured memory_bytes: 1852
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: String,
    }
    let s = s.chars().collect::<Vec<_>>();
    let n = s.len();
    let mut odd = vec![0; n];
    let mut even = vec![0; n];
    let mut count = 0;
    for i in 0..n {
        if s[i] == 'L' {
            even[i] = count / 2;
            odd[i] = count - even[i];
            count = 0;
            continue;
        }
        count += 1;
    }
    for i in (0..n).rev() {
        if s[i] == 'R' {
            even[i] = count / 2;
            odd[i] = count - even[i];
            count = 0;
            continue;
        }
        count += 1;
    }
    for i in 0..n {
        if odd[i] == 0 {
            print!("0 ");
        } else {
            print!("{} ", if s[i] == 'R' {
                even[i] + odd[i + 1]
            } else {
                even[i] + odd[i - 1]
            });
        }
    }
    println!("");
}


Measured memory_bytes: 4476
import java.io.IOException;
import java.io.InputStream;
import java.util.InputMismatchException;

public class Main {

	public static void main(String[] args) {
		Task task = new Task();
		task.solve();
	}

	public static class Task {
		static final long MOD = (long) 1e9 + 7;

		public void solve() {
			Scan sc = new Scan();
			int n = (int) sc.scanLong();
			int[] primes = new int[n + 1];
			int res = 1;
			for (int i = 2; i <= n; ++i) {
				if (primes[i] == 0) {
					res = modMul(res, getPow(i, n) + 1);
					for (int j = i; j <= n; j += i) {
						primes[j] = 1;
					}
				}
			}
			System.out.println(res);
		}

		private int modMul(int a, int b) {
			return (int) (((long) a * b) % MOD);
		}

		private int getPow(int f, int n) {
			if (n < f)
				return 0;
			int curr = n / f;
			return curr + getPow(f, curr);
		}
	}

	public static class Scan {
		private byte[] buf = new byte[1024];
		private int index;
		private InputStream in;
		private int total;

		public Scan() {
			in = System.in;
		}

		public int scan() {
			if (total < 0)
				throw new InputMismatchException();
			if (index >= total) {
				index = 0;
				try {
					total = in.read(buf);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
				if (total <= 0)
					return -1;
			}
			return buf[index++];
		}

		public long scanLong() {
			long integer = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n)) {
				if (n >= '0' && n <= '9') {
					integer *= 10;
					integer += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			return neg * integer;
		}

		public double scanDouble() throws IOException {
			double doub = 0;
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			int neg = 1;
			if (n == '-') {
				neg = -1;
				n = scan();
			}
			while (!isWhiteSpace(n) && n != '.') {
				if (n >= '0' && n <= '9') {
					doub *= 10;
					doub += n - '0';
					n = scan();
				} else
					throw new InputMismatchException();
			}
			if (n == '.') {
				n = scan();
				double temp = 1;
				while (!isWhiteSpace(n)) {
					if (n >= '0' && n <= '9') {
						temp /= 10;
						doub += (n - '0') * temp;
						n = scan();
					} else
						throw new InputMismatchException();
				}
			}
			return doub * neg;
		}

		public String scanString() {
			StringBuilder sb = new StringBuilder();
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			while (!isWhiteSpace(n)) {
				sb.append((char) n);
				n = scan();
			}
			return sb.toString();
		}

		public char scanChar() {
			int n = scan();
			while (isWhiteSpace(n))
				n = scan();
			return (char) n;
		}

		private boolean isWhiteSpace(int n) {
			if (n == ' ' || n == '\n' || n == '\r' || n == '\t' || n == -1)
				return true;
			return false;
		}
	}
}


Measured memory_bytes: 32368
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define loop(i,n) for(int i=0 ; i<n ; i++)
#define rep(i,x,n) for(int i=x ; i<=n ; i++)
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
const int N=5e3 + 5,M=5e5+5, MOD=1e9 + 7;
int memo[N][N];
int n,arr[N],k;
map<int,int> ind;
vector<int> vec;
bool valid(int j){
    int x=vec[j];
    int bad=ind[x];
    for(int i=n-1 ; ~i ; --i){
        for(int sum=k-1 ; ~sum ; --sum){
            if(i==bad || sum+arr[i]>=k){
                memo[i][sum]=memo[i+1][sum];
            }else{
                memo[i][sum]=max(memo[i+1][sum+arr[i]],memo[i+1][sum]);
            }
        }
    }
    return memo[0][0]>=k-x;
}
int main() {
#ifndef ONLINE_JUDGE
  //  freopen("in.txt", "rt", stdin);
#endif
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n>>k;
    set<int> nums;
    loop(i,n){
        cin>>arr[i];
        nums.insert(arr[i]);
        ind[arr[i]]=i;
    }
    for(int x:nums){
        vec.push_back(x);
    }
    loop(j,k+3){
        memo[n][j]=j;
    }
    int st=0,en=vec.size()-1;
    while(st<=en){
        int mid=(st+en)/2;
        if(valid(mid)){
            en=mid-1;
        }else{
            st=mid+1;
        }
    }
    vec.push_back(1e9 + 5);
    int ans=0;
    loop(i,n){
        if(arr[i]<vec[en+1])ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 98560
def main():
  n = int(input())
  ary = list(map(int, input().split()))
  ary.sort()
  i = 0
  while (i < n) and (ary[i] != ary[i - 1]):
    i += 1
  if i == n:
    print("YES")
  else:
    print("NO")
    
if __name__ == '__main__':
  main()


Measured memory_bytes: 26808
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define LOOP(i,x,n) for(int i=x;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define MP make_pair
#define FR first
#define SC second
#define int long long
using namespace std;
const int MOD=1000000007;
const int INF=1000000009;


signed main(){
  int n,y;
  cin>>n>>y;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=n;j++){
      if(n-i-j>=0){
        if(i*10000+j*5000+(n-i-j)*1000==y){
          cout<<i<<' '<<j<<' '<<n-i-j<<endl;
          return 0;
        }
      }
    }
  }
  cout<<-1<<' '<<-1<<' '<<-1<<endl;

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using System.IO;

namespace atcorder2
{
    class Program
    {
        public static long Read()
        {
            return long.Parse(Console.ReadLine());
        }

        public static long[] Reads()
        {

            return Console.ReadLine().Split().Select(long.Parse).ToArray();
        }


        public static long GCM(long x, long y)
        {
            var s = x;
            var t = y;
            if (x < y) GCM(y, x);
            while (y != 0)
            {
                var z = x % y;
                x = y;
                y = z;
            }
            return s / x * t;
        }



        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var input = Reads();
            var n = input[0];
            var k = input[1];
            var a = Reads();
            /*decimal memo = 0;
            for (int i = 0; i < n; i++)
            {
                if (a[i] == 1) memo = i;
            }
            decimal ans = 0;
            if (memo >= k)
                ans = Math.Ceiling(memo / (k - 1)) + Math.Ceiling((n - 1 - memo) / (k - 1));
            else
                ans = Math.Ceiling((decimal)(n - k) / (k - 1))+1;*/
            
            Console.WriteLine(Math.Ceiling((decimal)(n-1)/(k-1)));

            Console.Out.Flush();
        }
    }
}




Measured memory_bytes: 20064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define ALL(a) (a).begin(), (a).end()
const ll mod = 1e9 + 7;

int main()
{
    string s, t;
    cin >> s >> t;
    for (int i = s.length() - t.length(); i >= 0; i--)
    {
        int count = 0;
        rep(j, t.length())
        {
            if (s[i + j] == t[j] || s[i + j] == '?' || t[j] == '?')
                count++;
            else
                break;
        }
        if (count == t.length())
        {
            rep(j, t.length())
            {
                if (s[i + j] == '?' && t[j] == '?')
                    s[i + j] = 'a';
                else if (s[i + j] == '?')
                    s[i + j] = t[j];
            }
            rep(k, s.length())
            {
                if (s[k] == '?')
                    s[k] = 'a';
            }
            cout << s << endl;
            return 0;
        }
    }
    cout << "UNRESTORABLE" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int a,b,c,x,tll;
	cin >> a >> b >> c;
	tll=0;
	for(x=a;x<=b;x++){
		if(c%x==0)tll++;

	}
cout << tll << endl;
return 0;
};

Measured memory_bytes: 1160
/* bimillahir rahmanir rahim...
 * AUTHOR
 * mubin_akib */
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair <int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<ld, ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

#define FOR(i, a, b) for (int i = a; i < (b); i++)
#define F0R(i, a) for (int i = 0; i < (a); i++)
#define FORd(i,a,b) for (int i = (b) - 1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a) - 1; i >= 0; i--)
#define REP(i, a, b) for(int i = a; i <= (b); ++i)
#define trav(a,x) for(auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int mod = 1e9 + 7;
const char nl = '\n';

int solve() {
    ll n, m;
    cin >> n >> m;
    if(n == m){
        cout << "Yes" << nl;
    }
    else{
        cout << "No" << nl;
    }
    return 0;
}

int main() {
#ifndef ONLINE_JUDGE
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 3652
#include<iostream>

using namespace std;

int main()
{
  int r, c;
  cin >> r >> c;

  int a[101][101];

  for ( int i = 0; i < r; i++ )
    {
      int sum = 0;
      for ( int j = 0; j < c; j++ )
        {
          cin >> a[i][j];
          sum += a[i][j];
        }
      a[i][c] = sum;
    }

  for ( int i = 0; i < r; i++ )
    {
      for ( int j = 0; j <= c; j++ )
        {
          if ( j ) cout << " ";
          cout << a[i][j];
        }
      cout << endl;
    }

  for ( int i = 0; i <=c; i++ )
    {
      int sum = 0;
      for ( int j = 0; j < r; j++ )
        {
          sum += a[j][i];
        }
      if ( i ) cout << " ";
      cout << sum;
    }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 1200
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <iomanip>
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<long double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }
#define INF 1LL<<60

struct ConvexHullTrick{
  std::deque<std::pair<long long, long long> > dq; //（傾き、切片）

  void add(long long a, long long b){
    std::pair<long long, long long> p0=std::make_pair(a, b);
    while(dq.size()>=2){
      int sz=dq.size();
      std::pair<long long, long long> p1=dq[sz-1];
      std::pair<long long, long long> p2=dq[sz-2];
      if((p0.second-p1.second)*(p0.first-p2.first) < (p0.second-p2.second)*(p0.first-p1.first))break;//交点のx座標を比較
      dq.pop_back();
    }
    dq.push_back(p0);
  }

  long long query(long long x){
    while(dq.size()>=2){
      long long v1=dq[0].first*x+dq[0].second;
      long long v2=dq[1].first*x+dq[1].second;
      if(v1<=v2)break;
      dq.pop_front();
    }
    return dq[0].first*x+dq[0].second;
  }

};

int main() {
    int N;
    ll C;
    cin >> N >> C;
    vector<ll> h(N);
    REP(i, N) cin >> h[i];

    vector<ll> dp(N);
    ConvexHullTrick cht;
    REP(i, N-1) {
        cht.add(-2*h[i], h[i]*h[i] + dp[i]);
        dp[i+1] = cht.query(h[i+1]) + h[i+1] * h[i+1] + C;
    }
    
    cout << dp[N-1] << endl;
    return 0;
}

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

int main() {
  ll n, Min = INF, s = 0, cnt = 0; cin >> n;
  vector<ll> a(n);
  rep(i, n) {
    cin >> a[i];
    if (a[i] < 0) cnt++;
    s += abs(a[i]);
    Min = min(Min, abs(a[i]));
  }
  if (cnt % 2 == 1) s -= 2 * Min;
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rpt(n) for(register int ttxyc=0;ttxyc<n;++ttxyc)
using namespace std;
int a,n,i,last,ans;
main()
{
    scanf("%d",&n);
    rpt(n)
    {
        scanf("%d",&a);
        if(a>last)ans+=a-last;
        last=a;
    }
    printf("%d",ans);
}/**/

Measured memory_bytes: 256
s=input()
t=input()
a=[]
ans=[]
for i in range(len(s)-len(t)+1):
  flg=0
  for j in range(len(t)):
    if s[i+j]!=t[j] and s[i+j]!='?':
      flg=1
  if flg==0:
    a.append(i)
for i in a:
  tmp=s[:i]+t+s[i+len(t):]
  for j in range(len(tmp)):
    if tmp[j]=='?':
      tmp=tmp[:j]+'a'+tmp[j+1:]
  ans.append(tmp)
ans.sort()
if ans==[]:
  print('UNRESTORABLE')
else:
  print(ans[0])

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

using namespace std;
int main(){
    int n;
    cin>>n;
    vector<int>p(n),m(n);
    for(int i=0;i<n;i++){
        cin>>p[i];
        if(i!=0)m[i]=min(m[i-1],p[i]);
        else m[0]=p[0];
    }
    m.erase(unique(m.begin(),m.end()),m.end());

    cout<<m.size()<<endl;
    return 0;
}

Measured memory_bytes: 1792
k = int(input())
d = 0
t = 0
l = [0] * k
l[0] = 1 % k
for i in range(1, k):
  l[i] = (l[i-1] * 10) % k
for i in range(k):
  t = t + 7 * l[i]
  if t % k == 0:
    print(i + 1)
    exit()
  else:
    t = t % k
print(-1)


Measured memory_bytes: 72108
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

// difine
typedef pair<int, int> pii;

int dx[4] = {0, 1, 0, -1};
int dy[4] = {1, 0, -1, 0};

// input
int m, n;
bool prime[1010][1010];
int map[1010][1010];

int med = 1010/2;
int MAX = (int)1e6;

// method
bool isPrime(int x) {
	for (int i=2; i*i<=x; i++) if (x%i==0) return false;
	return x>1;
}

void make_map() {
	memset(map, 0, sizeof(map));
	
	int num = 1, d = 0;
	int x = med, y = med;
	
	for (int i=1; i<=MAX; i++) {
		map[y][x] = num;
		prime[y][x] = isPrime(num);
		
		if (map[y + dy[(d+1)%4]][x + dx[(d+1)%4]]==0) d = (d+1)%4;
		x += dx[d]; y += dy[d];
		num++;
	}
	
	/*
	for (int i=med - 5; i<med + 5; i++) {	
		for (int j=med-5; j<med + 5; j++) {
			printf("%3d ", map[i][j]);
		}
		cout << endl;
	}
	*/
}

pii dp[1010][1010];

void solve() {
	for (int i=0; i<1010; i++) for (int j=0; j<1010; j++) {
		dp[i][j] = make_pair(-1, 0);
		if (map[i][j] == n && prime[i][j]) dp[i][j] = make_pair(1, n);
		else if (map[i][j] == n) dp[i][j] = make_pair(0, 0);
	}
	
	for (int i=0; i<1009; i++) {
		for (int j=0; j<1009; j++) {
			if (dp[i][j].first < 0) continue;
			
			if (map[i+1][j-1] <= m) {
				if (prime[i+1][j-1]) {
					pii nxt(dp[i][j].first + 1, map[i+1][j-1]);
					dp[i+1][j-1] = max(dp[i+1][j-1], nxt);
				} else {
					dp[i+1][j-1] = max(dp[i+1][j-1], dp[i][j]);
				}
			}
			
			if (map[i+1][j] <= m) {
				if (prime[i+1][j]) {
					pii nxt(dp[i][j].first + 1, map[i+1][j]);
					dp[i+1][j] = max(dp[i+1][j], nxt);
				} else {
					dp[i+1][j] = max(dp[i+1][j], dp[i][j]);
				}
			}
			
			if (map[i+1][j+1] <= m) {
				if (prime[i+1][j+1]) {
					pii nxt(dp[i][j].first + 1, map[i+1][j+1]);
					dp[i+1][j+1] = max(dp[i+1][j+1], nxt);
				} else {
					dp[i+1][j+1] = max(dp[i+1][j+1], dp[i][j]);
				}
			}
		}
	}
	
	pii ans(-1, 0);
	for (int i=0; i<1010; i++) for (int j=0; j<1010; j++) ans = max(ans, dp[i][j]);
	cout << ans.first << " " << ans.second << endl;
}

int main() {
	make_map();
	
	while (1) {
		cin >> m >> n; if (m==0 && n==0) break;
		solve();
	}
	
	return 0;
}

Measured memory_bytes: 14120
#include <stdio.h>
int main(void){
    int A1,A2,A3;
    
    scanf("%d %d %d", &A1, &A2, &A3);
    
    if(A1+A2+A3>21){
        printf("bust\n");
    }else{
        printf("win\n");
    }
    
    return 0;

}

Measured memory_bytes: 128
s = input()

a = int(s[0] + s[1])
b = int(s[2] + s[3])

if 1 <= a <= 12 and 1 <= b <= 12:
    print('AMBIGUOUS')
elif 1 <= a <= 12:
    print('MMYY')
elif 1 <= b <= 12:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
k, x = gets.split.map(&:to_i)

MIN = -1_000_000
MAX = 1_000_000

head = x - (k - 1)
tail = x + (k - 1)

if head <= MIN
  puts (MIN..(x + k - 1)).to_a.join(' ')
elsif tail >= MAX
  puts (MAX - (k - 1)..MAX).to_a.join(' ')
else
  puts (head..tail).to_a.join(' ')
end


Measured memory_bytes: 1788
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);

using namespace std;
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};
const long double Pi=acos(-1),e=2.718;
const int N=1e5+10,mod=1e9+7;
ll n,k,dp[2][N],a[110],Pre[N];

int main()
{
    FASTIO
    cin >> n >> k;
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    dp[n%2][k]=1;
    for(int i=n-1;i>=0;i--){
        Pre[0]=dp[(i+1)%2][0];
        for(int j=1;j<=k;j++){
            Pre[j] = Pre[j-1]+dp[(i+1)%2][j];
            Pre[j] %= mod;
        }
        for(int j=0;j<=k;j++){
            dp[(i+1)%2][j]=0;
        }
        for(ll j=0;j<=k;j++){
            dp[i%2][j] += Pre[min(k,j+a[i])]-Pre[j-1];
            dp[i%2][j] += mod;
            dp[i%2][j] %= mod;
        }
    }
    cout << dp[0][0] << endl;
    return 0;
}
/**

*/


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

int main() {
  int n,m;
  cin >> n >> m;
  
  Graph G(n);
  for(int i = 0;i<m;i++){
    int a,b;
    cin >> a >> b;
    G[a-1].push_back(b-1);
    G[b-1].push_back(a-1);
  }
  vector<int> dist(n,-1);
  queue<int> que;
  
  dist[0] = 0;
  que.push(0);
  
  while(!que.empty()){
    int v = que.front();
    que.pop();
    
    for (int nv:G[v]) {
      if(dist[nv] != -1) continue;
    dist[nv] = v+1;
    que.push(nv);
    }
  }
  vector<int> abc;
  abc = dist;
  sort(abc.begin(),abc.end());
  if(abc[0] == -1)
    cout << "No" << endl;
  else{
  cout << "Yes" << endl;
  
  for(int v = 1; v<n ; ++v) 
    cout << dist[v] << endl;
  }
  
  
  return 0;
  
  
}

Measured memory_bytes: 10548
#include <iostream> // cin, cout, cerr, clog
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota, accumulate, inner_product
#include <cstdio> // printf, scanf
#include <climits> // INT_MIN, LLONG_MIN
#include <cmath> // long, trig, pow
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <stack> // stack
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <unordered_map> // hashed by keys
#include <unordered_set> // hashed by keys
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(int)>

#define rep(i,n) for(int i = 0; i < (n); i++)
#define ENDL '\n'
#define print(i) std::cout << (i) << '\n'

#define int long long // at least int64 > 9*10^18
#define all(v) (v).begin(), (v).end()
/* libraries */

struct FastIO
{
  FastIO() {
    std::cin.tie(0);
    std::ios_base::sync_with_stdio(0); 
  }
} fastio;


inline int signof(int a) {
	if(a>0) return 1;
	if(a<0) return -1;
	return 0;
}

signed main() {
	int n;
	std::cin >> n;
	std::vector<int> a(n);
	rep(i,n) std::cin >> a[i];

	int count = 0;
	for(int i=0;i<n;i++) {
		count++;
		if(i+1==n) goto stop;
		while(a[i+1]-a[i]==0) {
			i++;
			if(i+1==n) goto stop;
		}
		int sign = signof(a[i+1]-a[i]);
		while((a[i+1]-a[i])*sign>=0) {
			i++;
			if(i+1==n) goto stop;
		}
	}

stop:
	print(count);

	return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
using namespace std;

#define FOR(i,m,n) for(int i=(m);i<(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()

const int INF = 0x3f3f3f3f;
const long long LINF = 0x3f3f3f3f3f3f3f3fLL;
/*----------------------------------------*/
// http://drken1215.hatenablog.com/entry/2019/02/03/224200
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  // freopen("input.txt", "r", stdin);

  int n; cin >> n;
  long long k; cin >> k;
  vector<long long> a(n); REP(i, n) cin >> a[i];
  int start_bit = 60;
  // while (true) {
  //   if ((1LL << start_bit) > k) break;
  //   ++start_bit;
  // }
  long long ans = 0;
  for (int i = start_bit-1; i >= 0; --i) if (k & (1LL << i)) { // 緩和させられる
    long long tmp = 0;
    // 上から i - 1 桁までは K と同じ
    for (int j = start_bit-1; j > i; --j) {
      long long bit = 1LL << j;
      int zero = 0, one = 0; // 上から j 桁目の 0/1 の個数
      REP(k, n) {
        if (a[k] & bit) ++one;
        else ++zero;
      }
      if (k & bit) tmp += bit * zero; // 上から j 桁目の K は 1
      else tmp += bit * one; // 上から j 桁目の K は 0
    }
    // 上から i 桁目で緩和する
    for (int j = i; j >= 0; --j) {
      long long bit = 1LL << j;
      int zero = 0, one = 0;
      REP(k, n) {
        if (a[k] & bit) ++one;
        else ++zero;
      }
      if (j == i || one > zero) tmp += bit * one;
      else tmp += bit * zero;
    }
    ans = max(ans, tmp);
  }
  long long same = 0;
  REP(i, n) same += (a[i] ^ k);
  ans = max(ans, same);
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  cin >> A;
  
  int o, p, q, r;
  int w, x;
  o = A / 1000; 	//千の位
  w = A - 1000 * o;	//A - 千の位
  p = w / 100;		//百の位
  x = w - 100 * p;	//A - 千の位 - 百の位
  q = x / 10;		//十の位
  r = x - 10 * q;	//一の位
  
  if (p == q){
    if(o == p || q == r){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
  	}
  }else{
      cout << "No" << endl;
  }
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
using namespace std;
#define repr(i,a,b) for(long long i=(long long)(a);i<(long long)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define PI 3.1415926535
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<Pll> vPll;
typedef vector<vector<int>> vvi;
typedef vector<vector<bool>> vvb;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<string>> vvs;
typedef vector<vector<double>> vvd;
typedef vector<vector<Pi>> vvPi;
typedef priority_queue<int, vector<int>, greater<int>> pqli;
typedef priority_queue<ll, vector<ll>, greater<ll>> pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi>> pqlP;
string YN(bool y) { return (y?"YES":"NO"); }
string yn(bool y) { return (y?"Yes":"No"); }
string ON(bool y) { return (y?"OK":"NG"); }
int main(void)
{
	ll n, x;

	cin>>n>>x;

	vll p(n+1, 1), sum(n+1, 1);

	rep(i, n){
		p[i+1]=2*p[i]+1;
		sum[i+1]=2*sum[i]+3;
	}

	ll mid=(pow(2, n+2)-3)/2;
	ll ans=0;
	x--;
	reprev(i, n){
		//cout<<mid<<" "<<x<<endl;
		if(i==0){
			if(x>3){
				ans+=3;
			} else if(x>0){
				ans+=x;
			}
		} else{
			if(mid==x){
				ans+=p[i]+1;
				break;
			} else if(x<mid){
				x--;
			} else{
				ans+=p[i]+1;
				x-=mid+1;
			}
			if(mid>2){
				mid=mid/2-1;
			} else{
				mid=1;
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=3e5+5;
map<int,int>ma;
int n,l,r,a[N],b[N],c[N];
bool check(int x){
    int l=0,r=0,tl=0,tr=0;
    for(register int i=1;i<=n;i++) b[i]=(a[i]>x);
    for(register int i=(n+1)>>1;i<=n;i++){
        if(b[i]==b[i+1]){
            tr=b[i];
            break;
        }
        ++r;
    }
    for(register int i=(n+1)>>1;i;i--){
        if(b[i]==b[i-1]){
            tl=b[i];
            break;
        }
        ++l;
    }
    if(l<r) tr=tl;
    if(min(l,r)>=(n+1)/2)    tr=b[(n+1)/2]^(((n+3)/2)%2);
    return tr;
}
int main(){
    scanf("%d",&n),n=n*2-1;
    for(register int i=1;i<=n;i++)
        scanf("%d",&a[i]),c[i]=a[i];
    sort(c+1,c+n+1),b[0]=b[n+1]=-1;
    for(register int i=1;i<=n;i++)   ma[c[i]]=i;
    for(register int i=1;i<=n;i++)   a[i]=ma[a[i]];
    register int l=1,r=n;
    while(l<r){
        int mid=(l+r)>>1;
        if(check(mid))  l=++mid;
        else    r=mid;
    }
    printf("%d\n",c[l]);
    return 0;
}

Measured memory_bytes: 12032
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func out(x ...interface{}) {
	fmt.Println(x...)
}

var sc = bufio.NewScanner(os.Stdin)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

// min, max, asub, absなど基本関数
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func asub(a, b int) int {
	if a > b {
		return a - b
	}
	return b - a
}

func abs(a int) int {
	if a >= 0 {
		return a
	}
	return -a
}

func solve(n int) {
	d := 10
	ans := 0
	for {
		x := n / d
		if x == 0 {
			break
		}
		ans += x
		d *= 5
	}
	out(ans)
}

func main() {
	sc.Split(bufio.ScanWords)

	N := getInt()

	if N%2 == 1 {
		out(0)
		return
	}

	solve(N)
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
#define ll long long
#define F(i,n) for(int i=0;i<n;i++)
#define pb push_back
#define i64 int64_t
#define fi first
#define se second
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	int n;set<ll>s;
	cin>>n;
	vector<ll>a(n);
	F(i,n){cin>>a[i];s.insert(a[i]);}
	if(s.size()==n)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;

}

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



#define SIZE 105


struct Point{
	Point(double arg_x,double arg_y){
		x = arg_x;
		y = arg_y;
	}

	Point(){
		x = y = 0.0;
	}

	Point operator + (Point p){ return Point(x+p.x,y+p.y); }
	Point operator - (Point p){ return Point(x-p.x,y-p.y);}
	Point operator * (double a){ return Point(a*x,a*y); }
	Point operator / (double a){ return Point(x/a,y/a); }

	double abs(){ return sqrt(norm()); }
	double norm(){ return x*x + y*y; }

	int loc() const{
		if(y > 0){
			if(x > 0){

				return 1;
			}else{

				return 2;
			}
		}else{
			if(x > 0){

				return 4;
			}else{

				return 3;
			}
		}
	}

	bool operator<(const Point &p) const{
		int this_loc = loc(),p_loc = p.loc();
		if(this_loc != p_loc){

			return this_loc < p_loc;
		}else{

			double tmp = x*p.y-y*p.x;
			return tmp > 0;
		}
	}

	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}

	double x,y;
};

typedef Point Vector;

double norm(Vector a){
	return a.x*a.x+a.y*a.y;
}

double abs(Vector a){
	return sqrt(norm(a));
}

double cross(Vector a,Vector b){
    return a.x*b.y-a.y*b.x;
}

double dot(Vector a,Vector b){
    return a.x*b.x + a.y*b.y;
}

int N;
Point point[SIZE];


int main(){

	scanf("%d",&N);

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

		scanf("%lf %lf",&point[i].x,&point[i].y);
	}
	sort(point,point+N);

	double ans = 0;

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

		for(int len = 1; len <= N; len++){
			double X = 0;
			double Y = 0;

			for(int k = 0; k < len; k++){
				X += point[(i+k)%N].x;
				Y += point[(i+k)%N].y;
			}
			ans = max(ans,sqrt(X*X+Y*Y));
		}
	}

	printf("%.15lf\n",ans);

	return 0;
}


Measured memory_bytes: 256
import itertools

n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for _ in range(q)]

AA=itertools.combinations_with_replacement(range(1,m+1),n)		#結果はsortされる

res=0

for A in AA:
	cnt=0
	for a,b,c,d in abcd:
		if A[b-1]-A[a-1]==c:
			cnt+=d
	res=max(res,cnt)
	
print(res)

Measured memory_bytes: 9228
import sys
import Queue

sys.setrecursionlimit(1000000)

def s(m, v, q):
    if q.empty(): return -1
    k, i, j = q.get()
    if i == len(m) - 1 and j == len(m[i]) - 1: return k
    if i > 0 and m[i - 1][j] == '.' and (i - 1, j) not in v:
        q.put((k + 1, i - 1, j))
        v.add((i - 1, j))
    if i < len(m) - 1 and m[i + 1][j] == '.' and (i + 1, j) not in v:
        q.put((k + 1, i + 1, j))
        v.add((i + 1, j))
    if j > 0 and m[i][j - 1] == '.' and (i, j - 1) not in v:
        q.put((k + 1, i, j - 1))
        v.add((i, j - 1))
    if j < len(m[i]) - 1 and m[i][j + 1] == '.' and (i, j + 1) not in v:
        q.put((k + 1, i, j + 1))
        v.add((i, j + 1))
    return s(m, v, q)
     
h, w = map(int, raw_input().split())
m = [raw_input() for _ in range(h)]
q = Queue.PriorityQueue()
q.put((1, 0, 0))
v = set((0, 0))
c = s(m, v, q)
if c == -1: print -1
else: print h * w - c - sum([r.count('#') for r in m])


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

using namespace std;

#define DIM 3007
#define DIM2 1007
#define MAXN 107
#define INF 1000000007
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef ll arr[DIM];
typedef vector<ll> graph[DIM];
typedef vector<ll> vec;
typedef pair<char,ll> pc;

string s1,s2,s;
ll n,m,D[DIM][DIM];
pll P[DIM][DIM];


int main() {
    cin>>s1>>s2;
    n = s1.length();
    m = s2.length();
    for (int i = 1;i<=n;i++){
        for (int j = 1;j<=m;j++){
            if (s1[i-1]==s2[j-1]){
                    D[i][j] = D[i-1][j-1]+1;
                P[i][j] = {i-1,j-1};
            }
            else {
                if (D[i][j-1]>D[i-1][j]){
                    P[i][j]={i,j-1};
                    D[i][j] = D[i][j-1];
                }
                else{
                    P[i][j] = {i-1,j};
                    D[i][j] = D[i-1][j];
                }
            }
        }
    }
    ll i= n,j= m;
    while(i> 0 && j>0){
        if (s1[i-1]==s2[j-1])s+=s1[i-1];
        ll ii,jj;
        ii = P[i][j].first; jj = P[i][j].second;
        i = ii; j = jj;
    }
    reverse(s.begin(),s.end());
    cout<<s<<endl;
}


Measured memory_bytes: 211968
#include <algorithm>
#include <iostream>
#include <cstring>
#include <map>
using namespace std;

typedef long long ll;

const ll MAX_N = 2e5 + 10;
ll n, k, ans;
ll Arr[MAX_N];
ll psum[MAX_N];
map <ll, ll> Map;

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> n >> k;
    for (ll i = 1; i <= n; i++) {
        cin >> Arr[i];
        Arr[i]--;
    }

    Map[0] = 1;
    for (ll i = 1; i <= n; i++) {
        psum[i] = (psum[i - 1] + Arr[i]) % k;
        if (k <= i)
            Map[psum[i - k]]--;

        ans += Map[psum[i]];
        Map[psum[i]]++;
    }

    cout << ans << "\n";
}

Measured memory_bytes: 15872
// 2016-11-25
#include <iostream>

int main() {
	int n;
	int h, s, c;
	while (true) {
		std::cin >> n;
		if (n == 0) {
			break;
		}
		h = 1;
		s = 0;
		c = 0;
		for (int i = 1; i < n + 1; i++) {
			while (s >= n) {
				if (s == n) {
					c++;
				}
				s -= h;
				h++;
			}
			s += i;
		}
		std::cout << c << std::endl;
	}
	return 0;
}

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

int main(void){
    
    map<string,string> mp;
    string SA,SB,SC;
    cin >> SA >> SB >> SC;
    mp["a"] = SA;
    mp["b"] = SB;    
    mp["c"] = SC;    
    string turn = "a";
    string temp;
    while(true){
        if(mp[turn].size()==0)break;
        //cout <<turn<<" "<< mp[turn].substr(0,1) <<endl;
        //cout <<mp["a"].size()<<endl;
        temp = mp[turn].substr(0,1);
        mp[turn] = mp[turn].erase(0,1);
        turn = temp;
        //cout << turn <<endl;
        

    }
    
    cout << char(turn[0] + 'A' - 'a') <<endl;
    
}


Measured memory_bytes: 256
S = input()
if S.count('N') > 0 and S.count('S') == 0 or S.count('N') == 0 and S.count('S') > 0 or S.count('W') > 0 and S.count('E') == 0 or S.count('W') == 0 and S.count('E') > 0:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 61888
w,h,x,y,r = map(int,input().split())
xx = [0] * 3
yy = [0] * 3
xx_b = 0
yy_b = 0

for i in range(3):
    xx[i] = x + (r * (-1 + i))
    yy[i] = y + (r * (-1 + i))
    if w >= xx[i] >= 0:
        xx_b += 1
    if h >= yy[i] >= 0:
        yy_b += 1

if xx_b == 3 and yy_b == 3:
    print('Yes')
else:
    print('No')


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

using ll = long long;

#define vl vector<long long>
using pll = pair<long long, long long>;
#define __ << '\n'
#define _ << ' '
#define all(x) (x).begin(), (x).end()

void error()
{
    cout << "-1";
    exit(0);
}

#define flush fflush(stdout)


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

    ll t, x;
    cin >> t >> x;

    cout << fixed << setprecision(15) << double(t) / x;


    return 0;
}

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

using ll = long long;
using ld = long double;

int main()
{
    string a,b,c;
    cin >> a>>b>>c;
    cout <<a.at(0)<<b.at(0)<<c.at(0)<<endl;    
    
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
public static void main(String[] args){
Scanner s=new Scanner(System.in);
  int a=s.nextInt();
  int b=s.nextInt();
  if(a<2*b)
    System.out.println(0);
  else{
  System.out.println(a-2*b);
  }
}
}

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

int main(void) {
    int X,N, ans=0;
    cin >> X>> N;

    if(N==0){
      cout << X << endl;
      return 0;
    }

    int p[N];
    rep(i,N){
      cin >> p[i];
    }
    sort(p,p+N);
    int min_val=200;

    for(int i=-200; i<=200; i++){
      bool flag = true;
      rep(j,N){
        if(i==p[j])
          flag = false;
      }
      if(flag){
        if(min_val>abs(i-X)){
          ans = i;
          min_val = abs(i-X);
        }
      }
    }


    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3676
def GCD(a, b):
    if(a % b == 0):
        return(b)
    return(GCD(b, a % b))

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

gcd = a[0]
for i in range(1, len(a)):
    if(gcd < a[i]):
        ret = GCD(a[i], gcd)
    else:
        ret = GCD(gcd, a[i])
    gcd = gcd * a[i] // ret
ans = 0
for i in range(len(a)):
    ans += (gcd - 1) % a[i]
print(ans)

Measured memory_bytes: 3316
program ioi_to_oio
  implicit none
  integer :: n, a(500000), x(0:500000), dp(500000), i, j, k, d
  character(500000) :: s
  a = 0
  x = 0
  dp = 0
  read(*,*) n
  read(*,*) s
  do i = 1, n
    if (s(i:i).eq."1") then
      a(i) = 1
      x(i) = x(i-1)+1
    end if
  end do
  do i = 3, n
    dp(i) = dp(i-1)
    if (a(i).eq.0) cycle
    if (a(i-2)-a(i-1).eq.1) then
      do d = 0, 2
        if (x(i-2).le.d) exit
        j = i-2-(x(i-2)-d)
        k = 0
        if (j.ge.1) k = dp(j)
        dp(i) = max(dp(i),x(i-2)-d+k)
      end do
    end if
    if (i-x(i)-1.ge.1.and.a(i-x(i)-1).eq.1) then
      j = i-2-x(i)
      k = 0
      if (j.ge.1) k = dp(j)
      dp(i) = max(dp(i),x(i)+k)
    end if
  end do
  write(*,'(i0)') dp(n)
  stop
end program ioi_to_oio

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

typedef long long int ll;


int main()
{
    ll n;
    cin >> n;
    vector<ll> d(n), c(n);
    for(ll i = 0;i < n;i++){
        cin >> d[i];
        c[d[i]]++;
    }

    if(d[0] != 0 || c[0] != 1){
        cout << 0;
        return 0;
    }

    ll ans = 1;
    for(ll i = 1;i < n;i++){
        ans %= 998244353;
        ll t = 1;
        for(ll j = 0;j < c[i];j++){
            t *= c[i - 1];
            t %= 998244353;
        }
        ans *= t;
    }
    cout <<setprecision(20) << ans;

    return 0;
}

Measured memory_bytes: 1792
local mma, mmi = math.max, math.min
local n, k = io.read("*n", "*n")
local sushi = {}
local neta = {}
for i = 1, n do
  sushi[i] = {}
  local t, d = io.read("*n", "*n")
  sushi[i].t, sushi[i].d = t, d
  neta[t] = true
end
local total_neta_cnt = 0
for z, v in pairs(neta) do total_neta_cnt = total_neta_cnt + 1 end
local lim_neta_cnt = mmi(total_neta_cnt, k)
table.sort(sushi, function(a, b) return a.d > b.d end)

local num_per_neta = {}
local cur_neta_cnt = 0
local score_d = 0
for i = 1, k do
  score_d = score_d + sushi[i].d
  local t = sushi[i].t
  if not num_per_neta[t] then
    cur_neta_cnt = cur_neta_cnt + 1
    num_per_neta[t] = 1
  else
    num_per_neta[t] = num_per_neta[t] + 1
  end
end
local optimal_score = score_d + cur_neta_cnt * cur_neta_cnt

local add_start_pos = k + 1
local remove_start_pos = k
while cur_neta_cnt < lim_neta_cnt do
  while num_per_neta[sushi[add_start_pos].t] do
    add_start_pos = add_start_pos + 1
  end
  cur_neta_cnt = cur_neta_cnt + 1
  num_per_neta[sushi[add_start_pos].t] = 1
  score_d = score_d + sushi[add_start_pos].d
  add_start_pos = add_start_pos + 1
  while num_per_neta[sushi[remove_start_pos].t] == 1 do
    remove_start_pos = remove_start_pos - 1
  end
  num_per_neta[sushi[remove_start_pos].t] = num_per_neta[sushi[remove_start_pos].t] - 1
  score_d = score_d - sushi[remove_start_pos].d
  remove_start_pos = remove_start_pos - 1
  optimal_score = mma(optimal_score, score_d + cur_neta_cnt * cur_neta_cnt)
end
print(optimal_score)


Measured memory_bytes: 23528
//コンパイラ最適化用
#pragma GCC optimize("Ofast")
//インクルード(アルファベット順)
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<iterator>//集合演算(積集合,和集合,差集合など)
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() //sortなどの引数を省略したい
#define SIZE(x) ll(x.size()) //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define Umap unordered_map
#define Uset unordered_set

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
    ll t;cin>>t;
    REP(_,t){
        ll n;cin>>n;
        vector<pair<ll,ll>> candl,candr;
        //選ばれていないインデックスを保存しておく
        set<ll> memol,memor;
        REP(i,n){memol.insert(i);memor.insert(i);}
        ll ans=0;
        REP(i,n){
            ll K,L,R;cin>>K>>L>>R;
            if(L>R){ans+=R;candl.PB({L-R,K-1});}
            else if(R>L){ans+=L;candr.PB({R-L,K});}
            else{ans+=L;}
        }
        //降順でソートしておく
        sort(ALL(candl),greater<pair<ll,ll>>());sort(ALL(candr),greater<pair<ll,ll>>());
        ll sl=SIZE(candl);ll sr=SIZE(candr);
        REP(i,sl){
            auto now=memol.upper_bound(candl[i].S);
            if(now!=memol.begin()){memol.erase(--now);ans+=candl[i].F;}
            //else{cout<<candl[i].F<<endl;}
        }
        REP(i,sr){
            auto now=memor.lower_bound(candr[i].S);
            if(now!=memor.end()){memor.erase(now);ans+=candr[i].F;}
            //else{cout<<candr[i].F<<endl;}
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 25152
#include<iostream>
int main() {
	int a = 0, b = 0, c = 0, d = 0, e = 0;
	std::cin >> a >> b;
	c = a + b;
	d = a - b;
	e = a * b;
	if (c >= d && c >= e) {
		std::cout << c << std::endl;
	}
	else if (d >= e) {
		std::cout << d << std::endl;
	}
	else {
		std::cout << e << std::endl;
	}
}

Measured memory_bytes: 256
import numpy as np

def a():
  n, m = list(map(int,input().split()))
  x = list(map(int,input().split()))
  if(m <= n):
    return(0)
  x = np.array(sorted(x))
  d = x[1:] - x[:-1]
  d.sort()
  return((x[-1] - x[0]) - sum(d[m-n:]))
print(a())

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

int main ()
{
	int n;
  	cin >> n;
  	for (int i = 0; i < 3; i++)
    {
    	if (n % 10 == 7)
        {
        	cout << "Yes" << endl;
          	break;
        }
      	else if (i == 2)
        {
        	cout << "No" << endl;
        }
      	n /= 10;
    }
}


Measured memory_bytes: 3640