akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define endl '\n'
int mod=1e9+7;
int mod2=998244353;
const int INF=1e9;

signed main(){
  int n;
  cin>>n;
  int np=0;
  int ans=0;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    if(np<a){
      ans+=a-np;
      np=a;
    }else{
      np=a;
    }
  }
  cout<<ans<<endl;
}


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

int main()
{
  double t1,t2;

  while(scanf("%lf %lf",&t1,&t2)!=EOF){

    if(t1<35.5 && t2<71.0)
      cout<<"AAA"<<endl;

    else if(t1<37.5 && t2<77.0)
      cout<<"AA"<<endl;

    else if(t1<40.0 && t2<83.0)
      cout<<"A"<<endl;

    else if(t1<43.0 && t2<89.0)
      cout<<"B"<<endl;

    else if(t1<50.0 && t2<105.0)
      cout<<"C"<<endl;

    else if(t1<55.0 && t2<116.0)
      cout<<"D"<<endl;

    else if(t1<70.0 && t2<148.0)
      cout<<"E"<<endl;

    else
      cout<<"NA"<<endl;
  }
}

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

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    map<int,int> mp;
    int count = 0;
    for(int i = 0; i < n; i++){
        int t;
        cin >> t;
        if(mp.find(t) != mp.end())
            mp[t]++;
        else{
            mp[t] = 1;
            count++;
        }
    }
    if(count <= k){
        cout << "0";
        return 0;
    }
    int c = 0;
    vector<int> tmp;
    for(auto x:mp)
        tmp.push_back(x.second);
    sort(tmp.begin(),tmp.end());
    int i = 0;
    while(count > k){
        c += tmp[i];
        count--;
        i++;
    }
    cout << c;
}

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

using namespace std;

//#define MD 100010

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> v(k);
    for(int i=0;i<k;i++){
        cin>>v[i];
    }
    vector<int> data(10-k);
    int j=0,m=0;
    for(int i=0;i<10;i++){
        if(i==v[j]){
           j++;
        }else{
            data[m]=i;
            m++;
        }
    }
    
    int ans=n;
    while(1){
        int l=0;
        int dig=(log10(ans)+1),t=ans;
        for(int i=0;i<dig;i++){
            int ke=t%10;
            for(l=0;l<10-k;l++){
                if(ke==data[l]){
                    break;
                }   
            }
            if(l==10-k){
                break;
            }
            if(i+1==dig){
                cout<<ans<<endl;
                return 0;
            }
            t/=10;
        }
        ans++;
    }
    
    return 0;
}

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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int n;
    static pair<int, int> ab[200000];
    cin >> n;
    for(int i=0;i<n;++i){
        int a, b;
        cin >> a >> b;
        ab[i] = {a, b};
    }
    sort(ab, ab+n);
    int ml, mh;
    if(n & 1) ml = ab[n/2].first;
    else ml = ab[n/2-1].first + ab[n/2].first;
    sort(ab, ab+n, [](auto x, auto y){ return pair<int, int>{x.second, x.first} < pair<int, int>{y.second, y.first}; });
    if(n & 1) mh = ab[n/2].second;
    else mh = ab[n/2-1].second + ab[n/2].second;

    cout << mh - ml +1 << endl;   
    return 0;
}

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

class Solve
{
	const int mod = 1000000007;
	static void Main(string[] args)
	{
		var p = Console.ReadLine().Split().Select(int.Parse).ToArray();
		string ans = "No";
		if (p[2]>=p[0] && p[2] <= p[1]){ ans = "Yes"; }
		Console.WriteLine(ans);

	}
}

Measured memory_bytes: 13396
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
using namespace std;


int main()
{
	long long x,y;
	cin>>x>>y;
	if(abs(x-y)<=1) puts("Brown");
	else puts("Alice");
}
	
	
			
	

Measured memory_bytes: 256
program decrementing
  implicit none
  integer :: n, a(100000) = 0, i, m, g, c = 0
  character(6) :: s(0:1) = (/"First ","Second"/)
  read(*,*) n
  read(*,*) a(1:n)
  do
    m = sum(mod(a,2))
    if (mod(n-m,2) == 1) exit
    c = c+1
    if (m /= 1) exit
    do i = 1, n
      if (mod(a(i),2) == 1) then
        if (a(i) == 1) goto 100
        a(i) = a(i)-1
        exit
      end if
    end do
    g = arr_gcd(a(1:n))
    a(1:n) = a(1:n)/g
  end do
100 write(*,'(a)') trim(s(mod(c,2)))
contains
  integer function arr_gcd(a)
    integer, intent(in) :: a(:)
    integer :: i
    arr_gcd = a(1)
    do i = 2, n
      arr_gcd = gcd(arr_gcd,a(i))
    end do
  end
  integer function gcd(a,b)
    integer, intent(in) :: a, b
    integer :: x, y
    x = max(abs(a),abs(b))
    y = min(abs(a),abs(b))
    do while (y > 0)
      gcd = y
      y = mod(x,y)
      x = gcd
    end do
  end
end program decrementing

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


int main() {
  int n;
  cin >> n;
  vector<int> w(n);
  rep(i,n) cin >> w[i];
  for(int i = 1; i < n; i++) w[i] += w[i-1];
  int ans = w[n-1];
  rep(i,n) ans = min(ans,abs(w[n-1]-2*w[i]));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include <iostream>

using namespace std;

int main()
{
    string s;
    cin>>s;
    if (s=="SAT") cout<<1;
    else if (s=="FRI") cout<<2;
    else if (s=="THU") cout<<3;
    else if (s=="WED") cout<<4;
    else if (s=="TUE") cout<<5;
    else if (s=="MON") cout<<6;
    else cout<<7;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int H,A[20000000];
void maxHeapify(int A[],int i){
  int l,r,largest;
      l= 2*i;
      r = 2*i+1;
      // 左の子、自分、右の子で値が最大のノードを選ぶ
      if (l <= H && A[l] > A[i]){
          largest = l;
        }
      else{
          largest = i;
        }
      if (r <= H && A[r] > A[largest]){
         largest = r;
       }

     if (largest != i){
         swap(A[i],A[largest]); //を交換
         maxHeapify(A, largest); // 再帰的に呼び出し
       }
     }
void buildMaxHeap(int A[],int H){
      for (int i = H/2; i>= 1;i--){
          maxHeapify(A, i);
        }
      }
int main(){
    cin>>H;
      for(int j=1;j<H+1;j++){
          cin>>A[j];
      }
      buildMaxHeap(A,H);
      for(int j=1;j<H+1;j++){
        cout<<" "<<A[j];
      }
      cout<<endl;
}



Measured memory_bytes: 5008
// This amazing code is by Eric Sunli Chen.
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
using namespace std;
template<typename T> void get_int(T &x)
{
	char t=getchar();
	bool neg=false;
	x=0;
	for(; (t>'9'||t<'0')&&t!='-'; t=getchar());
	if(t=='-')neg=true,t=getchar();
	for(; t<='9'&&t>='0'; t=getchar())x=x*10+t-'0';
	if(neg)x=-x;
}
template<typename T> void print_int(T x)
{
	if(x<0)putchar('-'),x=-x;
	short a[20]= {},sz=0;
	while(x>0)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1; i>=0; i--)putchar('0'+a[i]);
}
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define get1(a) get_int(a)
#define get2(a,b) get1(a),get1(b)
#define get3(a,b,c) get1(a),get2(b,c)
#define printendl(a) print_int(a),puts("")
typedef long long LL;
typedef unsigned long long uLL;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const LL Linf=1ll<<61;
const double pi=acos(-1.0);
int n,d,x;
long double st,ed,ans;
int main()
{
	cin>>n>>d>>x;
	st=d;ed=d+(n+n-1)*x;
	for(int i=n;i>=1;i--)
	{
		ans+=(st+ed)/2;
		long double t=(ed-st)/(i+i-1);
		st+=(2*st+5*t)/2/i;
		ed+=(2*ed-5*t)/2/i;
	}
	cout<<fixed<<setprecision(10)<<ans<<endl;
	return 0;
}

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

public class Hello{
    public static void Main(){
        var n = Int32.Parse(Console.ReadLine());
        var li = Console.ReadLine().Split(' ').Select(s => Int32.Parse(s)).OrderBy(i => i).ToList();
        var ret = 0;
        for(var i = 0; i < n * 2; i +=2)  ret += li[i];
        Console.WriteLine(ret);
    }
}


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

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	string prev, curr;
	prev = "";
	curr = "";
	for (int i = 0; i < s.length(); i++) {
		curr = curr + s[i];
		if (prev != curr) {
			ans++;
			prev = curr;
			curr = "";
		}
	}
	cout << ans;
}

Measured memory_bytes: 640
cost = list()
p = [int(i) for i in input().split()]
for j in range(p[0]):
    ipt = [int(i) for i in input().split()]
    if p[1]>=ipt[1]:
        cost.append(ipt[0])
if cost==list():
    print('TLE')
else:
    print(min(cost))

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

using namespace std;

#ifndef ONLINE_JUDGE
  #define pr_debug(...) do { printf("DEBUG: line %d: %s: ", __LINE__, __PRETTY_FUNCTION__); printf(__VA_ARGS__); } while(0)
  #define pr_vars(...) do { pr_debug(" "); pr_var(split(#__VA_ARGS__, ',').begin(), __VA_ARGS__); } while(0)
#else
  __attribute__ ((constructor)) static void fast_cin() { ios_base::sync_with_stdio(false); cin.tie(0); }
  #define pr_debug(...) do { } while(0)
  #define pr_vars(...) do { } while(0)
#endif /* ONLINE_JUDGE */

using ll = int64_t;
using ull = uint64_t;

template<typename X, typename Y> ostream &operator<< (ostream &fout, const pair<X, Y> &p)
{ fout << '{' << p.first << ", " << p.second << "} "; return fout; }

template<typename T> ostream &operator<< (ostream &fout, const vector<T> &vec)
{ for (const auto &el : vec) fout << el << ' '; return fout; }

template<typename T> istream &operator>> (istream &fin, vector<T> &vec)
{ for (size_t i = 0; i < vec.size(); i++) fin >> vec[i]; return fin; }

vector<string> split(const string &s, char c) { vector<string> v; ull st = 0, fn = 0, lvl = 0;
for ( ; fn < s.size(); fn++ ) { if (s[fn] == c && lvl == 0) { v.push_back(s.substr(st, fn - st)); st = fn + 1; }
if (s[fn] == '(') { lvl++; } if (s[fn] == ')') { lvl--; } } v.push_back(s.substr(st, fn - st)); return v; }

void pr_var(vector<string>::iterator it) { (void) it; cout << endl; }
template<typename T, typename... Args> void pr_var(vector<string>::iterator it, T a, Args... args)
{ cout << *it << "=" << a << "  "; pr_var(++it, args...); }

ll div_ceil(ll n, ll d) { ll res = n / d; if (res >= 0) res += n % d ? 1 : 0; return res; }
ll gcd(ll a, ll b) { a = llabs(a); b = llabs(b); while (a && b) a > b ? a %= b : b %= a; return a + b; }
ll lcm(ll a, ll b) { ll c = gcd(a, b); return c == 0 ? 0 : llabs(a / c * b); }

#define setp(a) fixed << setprecision(a)
const double PI = acos(-1.0);
constexpr double EPS = 1e-9;
constexpr double INF = 2e18;

using mp = pair<ll, ll>;
using mt = tuple<ll, ll, ll>;    // unpack: tie(ll, ll, ll) = mt;

constexpr ll MAX = 1e3 + 5;

int main()
{
    ll res = 0;
    ll n; cin >> n;
    int p = 0, w = 0, g = 0, y = 0;
    for (ll i = 0; i < n; i++) {
        string s; cin >> s;
        if (s[0] == 'P') p++;
        if (s[0] == 'W') w++;
        if (s[0] == 'G') g++;
        if (s[0] == 'Y') y++;
    }
    if (y) cout << "Four";
    else cout << "Three";

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i,n,total,total_foot,crane_foot=2,turtle_foot=4;

	scanf("%d%d",&total,&total_foot);

	for(i=total;i>=0;i--){
		n = crane_foot * i + turtle_foot * (total - i);
		if(n == total_foot)
			break;
	}

	if(n == total_foot){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}

	return 0;

}


Measured memory_bytes: 1640
def solve():
    n = int(input())
    arr = list(map(int, input().split()))
    arr_sum = sum(arr)
    arr_sum_sqr = arr_sum**2
    res = sum(i**2 for i in arr)
    res = (arr_sum_sqr - res) // 2
    print(res % (10**9+7))


def main():
    t = 1
    while t > 0:
        solve()
        t -= 1


main()

Measured memory_bytes: 31436
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(ll i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<< endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N, K);
  VEC(char, D, K);
  rep(i, N, INF) {
    bool f = true;
    each(x, to_string(i)) {
      each(y, D) {
        if (x == y) f = false;
      }
    }
    if (f) {
      print(i);
      return;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <algorithm>

using namespace std;

int main()
{
    long long n, p;
    cin >> n >> p;
    long long ans = 1;
    vector<long long> v(1000001, 0);
    if(n == 1){
        cout << p << endl;
        return 0;
    }
    for (long long i = 2; i <= 1000000; ++i){
        while(p % i == 0){
            v[i]++;
            p = p / i;
            //cout << i << " ";
        }
    }
    //cout << endl;
    long long l = 0;
    for (long long i = 2; i <= 1000000; ++i){
        if(v[i] >= n){
            l = v[i] / n;
            for (long long j = 0; j < l; ++j){
                ans *= i;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 8064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
  
class Main {
    public static void main(String[] args)throws IOException {
        //経過週の取得
        int n = Integer.parseInt(new BufferedReader(new InputStreamReader(System.in), 64).readLine()); 

        //借金の金額
        int result = 100000;
          
        //n週後の借金の残高を演算する
        //一週間ごとに 5% の利子を借金に加え、さらに借金の 1,000 円未満を切り上げる。
        if (n != 0) {
            for(int i = 0; i < n;i++){
                //借金の5% を利子として追加
                result =(int)(result + (result * 0.05));
                //借金の 1,000 円未満を切り上げ
                if((result % 1000) != 0 ){
                    result = ((int)(result / 1000) + 1) * 1000;
                }
            }
        }
        //結果の出力
        System.out.println(result);
    }
}

Measured memory_bytes: 16844
#include<stdio.h>
#include<stdlib.h>
int comp(const void *a,const void *b){
	return *(int *)b - *(int *)a;
}
int main(){
	int n,a[105],ans,i;
	while(1){
		scanf("%d",&n);
		if(!n)break;ans=0;
		for(i=0;i<n;i++)scanf("%d",&a[i]);
		qsort(a,n,sizeof(int),comp);
		for(i=1;i<n-1;i++)ans+=a[i];
		ans=ans/(n-2);
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 0
H,W = map(int,input().split())
A = [list(map(int,input().split())) for _ in range(H)]
B = [list(map(int,input().split())) for _ in range(H)]
D = [[abs(A[h][w]-B[h][w]) for w in range(W)] for h in range(H)]
def cal():
    dp1 = [set() for _ in range(W)]
    dp2 = [set() for _ in range(W)]
    for h in range(H):
        for w in range(W):
            d = D[h][w]
            if h==0 and w==0:
                dp2[0].add(d)
            for v in dp1[w]:
                v1 = v+d
                v2 = v-d if v>=d else -v+d
                dp2[w].add(v1)
                dp2[w].add(v2)
            if 0 < w:
                for v in dp2[w-1]:
                    v1 = v+d
                    v2 = v-d if v>=d else -v+d
                    dp2[w].add(v1)
                    dp2[w].add(v2)
        dp1 = dp2
        dp2 = [set() for _ in range(W)]
    return min(dp1[W-1])
ans = cal()
print(ans)

Measured memory_bytes: 177160
#include<bits/stdc++.h>
using namespace std;
int sumofdigits(int n){
  int sum=0;
  while(n>0){
    sum+=n%10;
    n/=10;
  }
  return sum;
}
int main(){
  int n;cin>>n;
  if(n%sumofdigits(n)==0)cout<<"Yes";
  else cout<<"No";
}

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

namespace ABC
{
    class ProgramC
    {
        static void Main(string[] args)
        {
            var inputs = Console.ReadLine().Split(" ");
            var w = long.Parse(inputs[0]);
            var h = long.Parse(inputs[1]);
            var x = long.Parse(inputs[2]);
            var y = long.Parse(inputs[3]);

            var result1 = w * h / 2d;
            var result2 = 2 * x == w && 2 * y == h ? 1 : 0;

            Console.WriteLine(string.Format("{0} {1}", result1, result2));
        }
    }
}


Measured memory_bytes: 27432
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll arr[100001];
ll  sum=0;
int main(){

	ll n;	cin>>n;

	ll arr[n], ans=0;
	for(int i=0; i<n; i++){
		cin>>arr[i]; ans = ans^arr[i];
	}
	for(int i=0; i<n; i++){
		arr[i] = ans^arr[i];
		cout<<arr[i]<<" ";
	}
	cout<<endl;

return 0;
}

Measured memory_bytes: 5232
#include<bits/stdc++.h>
using namespace std;
const string pp = "23456789TJQKA";

int main()
{
  string S;
  
  while(cin >> S, S != "#") {
    string p[4][13];
    for(int i = 0; i < 4; i++) {
      for(int j = 0; j < 13; j++) cin >> p[i][j];
    }
    int score[2] = {}, leader = 0;
    for(int i = 0; i < 13; i++) {
      int winner = 0, best = 0;
      for(int j = 0; j < 4; j++) {
        if(p[leader][i][1] != p[j][i][1] && S[0] != p[j][i][1]) continue;
        int point = pp.find(p[j][i][0]);
        if(S[0] == p[j][i][1]) point += 810;
        if(best < point) {
          best = point;
          winner = j;
        }
      }
      leader = winner;
      ++score[winner & 1];
    }
    if(score[0] > score[1]) {
      cout << "NS " << score[0] - 6 << endl;
    } else {
      cout << "EW " << score[1] - 6 << endl;
    }
  }
}

Measured memory_bytes: 1192
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cmath>
#include<queue>
#include<stack>
#include<functional>
using namespace std;

int main(){
    for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			printf("%dx%d=%d\n",i,j,i*j);
		}
	}
    return 0;
}

Measured memory_bytes: 1096
#include <bits/stdc++.h>
using namespace std;
#define eps 1e-7
#define PI acos(-1)
#define de(x) cout<<#x<<'='<<x<<" , "
#define dee(x) cout<<#x<<'='<<x<<endl
#define sz(x) x.size()
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<(b);++i)
#define mset(a,b) memset(a,b,sizeof(a))
#define fi first
#define se second
#define all(x) x.begin(),x.end()
#define pb push_back
typedef long long LL;
typedef pair<int,int> pii;
typedef vector<int> vi;

int main(){
    int a[3];
    cin>>a[0]>>a[1]>>a[2];
    sort(a,a+3);
    if(a[1]==a[0]) cout<<a[2]<<endl;
    else cout<<a[0]<<endl;
}























/*
struct Edge{
    int nx,v,w;
}e[MAXE];
int Fi[MAXN],sz;
void E_add(int u,int v,int w){
    e[sz].v=v,e[sz].w=w,e[sz].nx=Fi[u],Fi[u]=sz++;
}
void SPFA(int st){
    mset(dis,0x3f);
    mset(vis,0); dis[st]=0;
    queue<int> q;
    q.push(st);
    while(!q.empty()){
        int u=q.front(); q.pop();
        vis[u]=0;
        for(int i=Fi[u];i!=-1;i=e[i].nx){
            int v=e[i].v;
            if(dis[v]>dis[u]+e[i].w){
                dis[v]=dis[u]+e[i].w;
                if(!vis[v]){ vis[v]=1; q.push(v); }
            }
        }
    }
}
*/


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int r,g,b; cin>>r>>g>>b;
	cout<<(((100*r+10*g+b)%4==0)?"YES":"NO")<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val month = arrayOf(0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0)
    val x = sc.nextInt() - 1
    val y = sc.nextInt() - 1
    println(if (month[x] == month[y]) "Yes" else "No")
}

Measured memory_bytes: 29472
// C++ Program to find the minimum of maximum 
// differerence between adjacent elements 
// after at most K insertions 

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

int minMaxDiff(int arr[], int n, int k) 
{ 
	int max_adj_dif = *max_element(arr,arr+n);

	// If the maximum adjacent 
	// difference is already zero 
	if (max_adj_dif == 0) 
		return 0; 

	// best and worst specifies 
	// range of the maximum 
	// adjacent difference 
	int best = 1; 
	int worst = max_adj_dif; 
	long long mid, required; 

	while (best < worst) { 

		mid = (best + worst) / 2; 

		// To store the no of insertions 
		// required for respective 
		// values of mid 
		required = 0; 

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

			required += (arr[i]
						- 1) 
						/ mid; 
		} 

		// If the number of insertions 
		// required exceeds K 
		if (required > k) 
			best = mid + 1; 

		// Otherwise 
		else
			worst = mid; 
	} 

	return worst; 
} 

// Driver code 
int main() 
{ 
  

	int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    {
    	cin>>a[i];}

	cout << minMaxDiff(a, n, k); 
	return 0; 
} 


Measured memory_bytes: 4372
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define pb push_back
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

int n, a[N];

void solve(){
   cin>>n;

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

int ans[n+100];
for (int i = 0; i < n; ++i)
{
	ans[i] = -inf;
}

int vals = 0;
for (int i = 0; i < n; ++i)
{
	if(a[i] > 1){
		if(ans[a[i]-1] != -1)
			ans[a[i]] = ans[a[i]-1] + 1;
	}
	else{
		ans[a[i]] = 1;
	}
	smax(vals, ans[a[i]]);
}

if(vals == 0){
	cout<<-1;
	exit(0);
}

cout<<n-vals;

}

int32_t main(){_
   
   int t = 1;
   //cin >> t;

   while(t--){
     solve();
     cout << endl;
   }
   

   return 0;
}

Measured memory_bytes: 3456
import java.util.*;
 
public class Main {
	
    public static void main(String[] args) {
    	Scanner sc = new Scanner(System.in);
    	int N = sc.nextInt();
    	int L = sc.nextInt();
    	List<String> list = new ArrayList<>();
    	for (int i = 0; i < N; i++) {
    		list.add(sc.next());
    	}
    	Collections.sort(list);
    	StringBuilder sb = new StringBuilder();
    	for (String s : list) {
    		sb.append(s);
    	}
    	System.out.println(sb);
    }
}

Measured memory_bytes: 22868
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;

int main(void) {
    int sum = 0, kosu = 0, count = 0;
    int tanka, suuryou;
    while(scanf("%d,%d", &tanka, &suuryou) != EOF) {
        sum += tanka * suuryou;
        kosu += suuryou;
        count++;
    }
    int ave = round(kosu / (double)count);
    cout << sum << endl << ave << endl;
    
    return(0);
}

Measured memory_bytes: 1216
#include<bits/stdc++.h>
using namespace std;
#define lint long long
#define ll long long
#define pq priority_queue
#define mp make_pair
#define vl vector<long long>
long long INF = 1e10;
#define pii pair<long long,long long>
#define all(x) (x).begin(),(x).end()
#define rep(x) for(int i = 0;i < (x);i++)
#define repj(x) for(int j = 0;j < (x);j++)
#define REP(i,x) for(int (i) = 0;(i) < (x);(i)++)
#define rrep(x) for(int i = (x);i >= 0;i--)
#define mod 1000000007
/******************************define**********************************/

/*****************************functions********************************/

/****************************main function*****************************/
int main(void){
    int k,s;cin>>k>>s;
    int cnt = 0;
    for(int i=0;i<=k;i++)
        for(int j=0;j<=k;j++)if(s-i-j<=k&&s-i-j>=0) cnt++;
    cout << cnt << endl;
    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();
		int r = loop(n);
		System.out.println(r);
		sc.close();
	}

	static int loop(int n) {
		if (n > 0 && n < 4)
			return 1;
		else if (n % 3 == 0)
			return loop(n / 3) + 1;
		else
			return Math.max(loop(n / 3 + 1) + 1, loop(n / 3) + 1);
	}
}

Measured memory_bytes: 19224
#include <stdio.h>
int main() {
    int W,H,x,y,r;
    scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
    if(x<r || y<r){
        printf("No\n");
    }else if((x+r)>W || (y+r)>H){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    return 0;
}

Measured memory_bytes: 1816
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 1000000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    string s; cin >> s;
    ll ans = 0;
    for (int i = 0; i < s.size(); ++i) {
        if (s[i] != 'A') continue;
        vector<ll> a, bc;
        while (s[i] == 'A') {
            int cnt_a = 0, cnt_bc = 0;
            for (; i < s.size(); ++i) {
                if (s[i] != 'A') break;
                ++cnt_a;
            }
            for (; i < s.size() - 1; i += 2) {
                if (s[i] == 'B' && s[i + 1] == 'C') ++cnt_bc;
                else break;
            }
            a.push_back(cnt_a);
            bc.push_back(cnt_bc);
        }
        for (int j = bc.size() - 2; j >= 0; --j) {
            bc[j] += bc[j + 1];
        }
        for (int i = 0; i < a.size(); ++i) {
            ans += a[i] * bc[i];
        }
    }

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

Measured memory_bytes: 644
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
#include <math.h>
#include <string>
#include <sstream>
#include <stack>
#include <deque>
#define pb push_back
#define make make_pair
#define kaku(a) cout << a << endl
#define isort(a) sort(a.begin(),a.end())
 
using namespace std;
 
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
#define PI 3.14159265359
long long gcd(long long a,long long b){ return b==0?a:gcd(b,a%b);}
long long lcm(long long a,long long b){ return a/gcd(a,b)*b;}
 
typedef pair<ll,ll> Pair;
const ll inf =1000000007;



void dsolve(){
    ll n;
    string s;
    cin >> n >> s;
    vector<ll> r,g,b;
    rep(i,n){
        if(s[i]=='R') r.pb(i);
        if(s[i]=='G') g.pb(i);
        if(s[i]=='B') b.pb(i);
    }
    ll ans=r.size()*g.size()*b.size();
    
    ll dpr[n+10],dpg[n+10],dpb[n+10];
    for(ll i=0;i<n;i++){
        dpr[i]=0;dpg[i]=0;dpb[i]=0;
    }
    for(ll i=0;i<n;i++){
        for(ll j=1;j<=i/2;j++){
            //i,i-j,i-2*j
            if(i-2*j>=0){
                if(s[i]!=s[i-j]&&s[i-j]!=s[i-2*j]&&s[i]!=s[i-2*j]){
                    ans--;
                    //cout << i<<" "<< i-j << i-2*j << endl;
                }
            }
        }
    }
    cout << ans << endl;
}


//繰り返し
ll RepeatSquaring(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P%2==0){
        ll t = RepeatSquaring(N, P/2, M);
        return t*t % M;
    }
    return N * RepeatSquaring(N, P-1, M);
}




int main(){
    dsolve();
}




Measured memory_bytes: 3808
#include<bits/stdc++.h>
using namespace std;
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define pb push_back
#define for_t int t;cin>>t;while(t--)
#define MOD 1000000007
#define fi first
#define se second
#define le length
#define debug(n1) cout << n1 << endl
#define set_bits(n) __builtin_popcount(n);
#define rep(i , j , n) for(ll i = j ; i <= n ; i++)
#define per(i , j , n) for(ll i = j ; i >= n ; i--)
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef map<int, int>mapp;
int main() {
    SPEED;
    int a,b;
    cin>>a>>b;
    int ans = 0;
    a = a-1;
    b = b-1;
    if(b%a==0){
        ans = b/a;
    }
    else{
        ans = (b/a)+1;
    }
    cout<<ans;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

// 区間の更新と要素の取得ができる BIT
// 1-indexed であることに注意
template<typename T>
class BITree2 {
    private:
        // 隣接する値との差分を管理する BIT
        class BITree {
            public:
                BITree() {}
                void Init(int n) {
                    m_N = n + 1;
                    m_Tree.assign(m_N, 0);
                }
                T Sum(int i) {
                    assert(i >= 1 && i < m_N);
                    T s = 0;
                    while(i > 0) { s += m_Tree[i]; i -= i & -i; }
                    return s;
                }
                void Add(int i, T x){ while(i < m_N) { m_Tree[i] += x; i += i & -i; } }
            private:
                int m_N;
                vector<T> m_Tree;
        };
    public:
        BITree2() {}
        BITree2(int n) { Init(n); }
        void Init(int n) { fenwick.Init(n); }
        // 区間 [l, r] の各要素に x を加える O(log m_N)
        void Add(int l, int r, T x) {
            assert(l <= r);
            fenwick.Add(l, x);
            fenwick.Add(r+1, -x);
        }
        // i 番目の要素の値を返す O(log m_N)
        T Get(int i) { return fenwick.Sum(i); }
    private:
        BITree fenwick;
};

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 100010
#define MAX_M 300010

ll N, M;
vector<ll> L, R;

vector< vector< pair<ll, ll> > > dist;  // 長さ i の区間 first: l, second: r

signed main()
{
    cin >> N >> M;
    L.resize(N);
    R.resize(N);
    dist.assign(M+10, vector< pair<ll, ll> >());
    REP(i, N) {
        cin >> L[i] >> R[i];
        dist[R[i] - L[i] + 1].push_back(make_pair(L[i], R[i]));
    }

    BITree2<ll> fenwick(M);
    printf("%lld\n", N);
    ll cur = N;
    // i: 区間の長さ
    for(int i = 2; i <= M; ++i) {
        // 区間の長さが i 以上のものは、必ずカウントする
        cur -= dist[i-1].size();
        ll res = cur;
        // 区間の長さが i 未満のもので、かぶるかどうか探索する
        for(auto& interval : dist[i-1]) {
            ll l = interval.first;
            ll r = interval.second;
            fenwick.Add(l, r, 1);
        }
        for(int j = i; j <= M; j += i) {
            res += fenwick.Get(j);
        }
        printf("%lld\n", res);
    }
    return 0;
}


Measured memory_bytes: 15872
N=int(input())
order = list(map(int, input().split()))
sati1 = list(map(int, input().split()))
sati2 = list(map(int, input().split()))

score=sati1[order[0]-1]
for i in range(1,N):
    score+=sati1[order[i]-1]
    if order[i]-order[i-1]==1:
        score+=sati2[order[i-1]-1]

print(score)

Measured memory_bytes: 3064
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
//#include <algorithm>
#include <vector>
 
bool Check( long n )
{
    if(n==0) {
        return true;
    }
    if(n>=4 && Check(n-4) ) {
        return true;
    }
    if(n>=7 && Check(n-7) ) {
        return true;
    }

    return false;
}

int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    if( Check(n) ) {
        printf("Yes\n");
    }
    else {
        printf("No\n");
    }

    return 0;
}


Measured memory_bytes: 128
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Queue;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int h = Integer.parseInt(sa[0]);
		int w = Integer.parseInt(sa[1]);
		int k = Integer.parseInt(sa[2]);
		char[][] a = new char[h][w];
		for (int i = 0; i < h; i++) {
			a[i] = br.readLine().toCharArray();
		}
		br.close();

		int s = 0;
		label:
		for (int i = 0; i < h; i++) {
			for (int j = 0; j < w; j++) {
				if (a[i][j] == 'S') {
					s = i * 1000 + j;
					break label;
				}
			}
		}

		int ans = Integer.MAX_VALUE;
		int[][] d = new int[h][w];
		for (int i = 0; i < h; i++) {
			Arrays.fill(d[i], -1);
		}
		int[] dx = {-1, 1, 0, 0};
		int[] dy = {0, 0, -1, 1};
		Queue<Integer> que = new ArrayDeque<>();
		que.add(s);
		d[s / 1000][s % 1000] = 0;
		while (!que.isEmpty()) {
			int cur = que.poll();
			int cx = cur / 1000;
			int cy = cur % 1000;
			ans = Math.min(ans, (cx + k - 1) / k + 1);
			ans = Math.min(ans, (h - 1 - cx + k - 1) / k + 1);
			ans = Math.min(ans, (cy + k - 1) / k + 1);
			ans = Math.min(ans, (w - 1 - cy + k - 1) / k + 1);
			if (d[cx][cy] >= k) {
				continue;
			}
			for (int i = 0; i < 4; i++) {
				int nx = cx + dx[i];
				int ny = cy + dy[i];
				if (0 <= nx && nx < h && 0 <= ny && ny < w &&
						a[nx][ny] == '.' && d[nx][ny] == -1) {
					if (nx == 0 || nx == h - 1 || ny == 0 || ny == w - 1) {
						System.out.println(1);
						return;
					}
					que.add(nx * 1000 + ny);
					d[nx][ny] = d[cx][cy] + 1;
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    bool is_yes=true;
    if(N%3!=0){
        for (int i = 1; i < N; i++)
            if(a[0]!=a[i])
                is_yes=false;
    }else{
        sort(a.begin(), a.end());
        for (int j = 0; j < 3; j++)
            for (int k = 1; k < N/3; k++)
                if(a[j*(N/3)] != a[j*(N/3)+k])
                    is_yes = false;
        if(is_yes)
            if((a[0*(N/3)] ^ a[1*(N/3)]) != a[2*(N/3)])
                is_yes = false;
    }
    cout << (is_yes ? "Yes" : "No") << endl;

    return 0;  
} 

Measured memory_bytes: 640
#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
#include<climits>
#include <string>
#include <map>
#include <set>
#include <list>

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////

ll A,B,K;

int main(){
    scanf("%lld%lld%lld",&A,&B,&K);
    
    for(int i=0;i<K;i++){
        A=A%2?A-1:A;
        B+=A/2;
        A/=2;
        i++;
        if(K==i)
            break;
        B=B%2?B-1:B;
        A+=B/2;
        B/=2;
    }
    printf("%lld %lld",A,B);
    
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s, ans;
   cin >> s;
   if(s == "Sunny")
      ans = "Cloudy";
   else if (s == "Cloudy" )
      ans = "Rainy";
   else
      ans = "Sunny";
   
   cout << ans << endl;
   return 0;
}


Measured memory_bytes: 256
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

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


	int N = getint();

	int A[1001][1000];
	rep1(i, N) {
		rep(j, N - 1) A[i][j] = getint();
		A[i][N - 1] = 0;
	}
	int* k[1001];
	rep1(i, N) k[i] = A[i];
	int k2[1001] = {};
	k2[0] = 1e9;
	vector<int> V;
	rep1(i, N) V.pb(i);

	int kotae = 0;
	while (V.size()) {
		kotae++;
		vector<int> kari;
		for (auto v : V) {
			if (k2[v] < kotae) {
				int a = *k[v];
				if (k2[a] < kotae && *k[a] == v) {
					kari.pb(v);
					k[v]++;
					k2[v] = kotae;
					kari.pb(a);
					k[a]++;
					k2[a] = kotae;
				}
			}
		}
		swap(V, kari);
	}

	int OK = 1;
	rep1(i, N) if (k[i] - A[i] != N - 1) OK = 0;
	if (OK) printf("%d", kotae - 1);
	else printf("-1");

	Would you please return 0;
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
namespace mine
{
    typedef long long ll;
    #define pr pair<int,int>
    #define FR first
    #define SE second
    #define MP make_pair
    #define PB push_back
    #define vc vector
    #define all(x) (x).begin(),(x).end()
    #define sz(x) ((int)(x).size())
    #define bin(x) (1ll<<(x))
    #define GG(x) if(x) {puts("error");exit(666);}
    #define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
    #define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num)
    {
        if(num<0) putchar('-'),num=-num;
        if(num>=10) write(num/10);
        putchar('0'+num%10);
    }
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

    const int INF=0x3f3f3f3f;
    const int MOD=998244353;
    inline int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> inline void add(T &x,const T y){x=mm(x+y);}
    inline ll qpower(ll x,ll e,int mod=MOD){ll ans=1;GG(e<0);while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e6+10;

    void gg(){puts("Impossible");exit(0);}
    int a[N],ct[N];
    void main()
    {
        int n=qread();fo(i,1,n) a[i]=qread(),ct[a[i]]++;sort(a+1,a+n+1);
        if(a[n-1]!=a[n]) gg();int ln=a[n];
        if(a[1]!=(ln+1)/2) gg();
        if(ln&1 and (a[2]!=(ln+1)/2 or (n>=3 and a[3]==(ln+1)/2)) ) gg();
        else if(a[2]==ln/2) gg();
        fo(i,(ln+1)/2+1,ln-1) if(ct[i]<=1) gg();
        puts("Possible");
    }
};//(ans+MOD)%MOD
signed main()
{
    // freopen("a.in","r",stdin);
    srand(time(0));
    mine::main();
}


Measured memory_bytes: 2432
import sys
input = lambda : sys.stdin.readline().rstrip()
sys.setrecursionlimit(max(1000, 10**9))
write = lambda x: sys.stdout.write(x+"\n")


n,m,q = list(map(int, input().split()))
s = [None]*n
for i in range(n):
    s[i] = list(map(int, input()))
e1 = [[0]*(m) for _ in range(n-1)]
e2 = [[0]*(m-1) for _ in range(n)]
for i in range(n):
    for j in range(m):
        if i<n-1 and s[i][j]==s[i+1][j]==1:
            e1[i][j] = 1
        if j<m-1 and s[i][j]==s[i][j+1]==1:
            e2[i][j] = 1
def cumsum2(v):
    # v: h*wの2次元リスト
    h,w = len(v), len(v[0])
    v.insert(0, [0]*w)
    for l in v:
        l.insert(0, 0)
    for i in range(1,h+1):
        for j in range(1,w+1):
            v[i][j] = v[i-1][j] + v[i][j-1] - v[i-1][j-1] + v[i][j]
    return v
s = cumsum2(s)
if e1:
    e1 = cumsum2(e1)
if e2:
    e2 = cumsum2(e2)
ans = [None]*q
for i in range(q):
    x1,y1,x2,y2 = map(lambda x: int(x)-1, input().split())
    val = s[x2+1][y2+1] - s[x1][y2+1] - s[x2+1][y1] + s[x1][y1]
    if e1:
        val2 = e1[x2][y2+1] - e1[x2][y1] - e1[x1][y2+1] + e1[x1][y1]
    else:
        val2 = 0
    if e2:
        val3 = e2[x2+1][y2] - e2[x2+1][y1] - e2[x1][y2] + e2[x1][y1]
    else:
        val3 = 0
    ans[i] = val - (val2+val3)
write("\n".join(map(str, ans)))

Measured memory_bytes: 225276
a=input("").split(" ")
x=int(a[0])
n=int(a[1])
if(n!=0):
    p=input("").split(" ")
    listp=[]
    c=0
    for i in range(n):
        listp+=[int(p[i])]
    for i in range(100):
        if not(x-i in listp):
            c=x-i
            break
        elif(not (x+i in listp)):
            c=x+i
            break
else:
    c=x


print(c)




Measured memory_bytes: 9168
#include <string>
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <queue>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <cstring>
#include <numeric>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define F0(i,n) for (int i = 0; i < n; i++)
#define F1(i,n) for (int i = 1; i <= n; i++)
#define CL(a,x) memset(x, a, sizeof(x));
#define SZ(x) ((int)x.size())
const double eps = 1e-10;
const int inf = 1000000009;
int i, j, k, m, n, l;
int a[100005], ans[100005];


int cnt;
void unk(int i) {
	cnt++;
	ans[i] = cnt;
}

int main() {
	//freopen("x.in", "r", stdin);
	cin >> n >> l;
	F1(i, n) cin >> a[i];

	F1(i, n - 1) if (a[i] + a[i + 1] >= l) {
		cout << "Possible" << endl;
		F1(j, i - 1) unk(j);
		for (int j = n - 1; j >= i; j--) unk(j);
		F1(i, n - 1) cout << ans[i] << endl; 
		return 0;
	}
	cout << "Impossible" << endl;
	return 0;
}


Measured memory_bytes: 1536
n,k=map(int,input().split())
a=sorted([list(map(int,input().split())) for i in range(n)])
i=0
while True:
  if k-a[i][1]>0:
    k-=a[i][1]
  else:
    print(a[i][0])
    exit()
  i+=1

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K,C;
char S[202020];
ll mk[202020];
ll i, j, k;
vector<ll> anss;

int main(){
    scanf("%lld%lld%lld%s", &N,&K,&C,S);
    j = -1;
    k = 0;
    fornum(i,0,N){
        if(j<i&&S[i]=='o'){
            mk[i] = 1;
            j = i + C;
            ++k;
        }
    }
    if(k>K){
        printf("\n");
        return 0;
    }
    for (i = N - 1; i >= 0;--i){
        if(mk[i]==1){
            fornum(j,0,C){
                ll ii = i + C - j;
                if(mk[ii]!=2&&S[ii]=='o'){
                    break;
                }
            }
            if(j==C){
                anss.push_back(i + 1);
            }
            j = i + C - j;
            fornum(k,0,C){
                mk[max(j - 1 - k,0ll)] = 2;
            }
        }
    }
    sort(anss.begin(), anss.end());
    fornum(i,0,anss.size()){
        printf("%lld\n", anss[i]);
    }
    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int ans = 0;
    vector<int> x(n);
    for (int i = 0; i < n; i++)
    {
        cin >> x.at(i);
    }
    sort(x.begin(), x.end());
    reverse(x.begin(),x.end());
    for (int i = 0; i < n; i++)
    {

        if (i % 2 == 0){
            ans += x.at(i);}
        else{
            ans -= x.at(i);}
    }
    cout << ans << endl;
}

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

const int N = 3005;
int n, m, k, a[N][N];
long long dp[N][N][4];
long long yo(int i, int j, int k) {
	if (i > n || j > m) return 0;
	long long &ret = dp[i][j][k];
	if (ret != -1) return ret;
	long long ans = yo(i + 1, j, 0) + (k < 3 ? a[i][j] : 0);
	if (k < 3) ans = max(ans, yo(i, j + 1, k + 1) + a[i][j]);
	ans = max(ans, yo(i, j + 1, k));
	return ret = ans;
}
int32_t main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n >> m >> k;
	for (int i = 1; i <= k; i++) {
		int r, c, x; cin >> r >> c >> x;
		a[r][c] = x;
	}
	memset(dp, -1, sizeof dp);
	cout << yo(1, 1, 0) << '\n';
    return 0;
}

Measured memory_bytes: 321472
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (Scanner sc = new Scanner(System.in)) {
            int N = sc.nextInt();
            int Q = sc.nextInt();

            Node[] nodes = new Node[N];
            for (int i = 0; i < N; i++) {
                nodes[i] = new Node();
            }

            for (int i = 0; i < N - 1; i++) {
                int a = sc.nextInt();
                int b = sc.nextInt();

                nodes[a - 1].children.add(nodes[b - 1]);
            }

            for (int i = 0; i < Q; i++) {
                int p = sc.nextInt();
                long x = sc.nextLong();

                nodes[p - 1].counter += x;
            }

            addCounter(nodes[0]);

            StringBuffer ans = new StringBuffer();
            ans.append(nodes[0].counter);
            for (int i = 1; i < N; i++) {
                ans.append(" ").append(nodes[i].counter);
            }
            System.out.println(ans.toString());
        }
    }

    public static void addCounter(Node node) {
        for (Node child : node.children) {
            child.counter += node.counter;
            addCounter(child);
        }
    }

    public static class Node {

        public long counter = 0;

        public List<Node> children = new ArrayList<>();

    }

}


Measured memory_bytes: 200572
#include<bits/stdc++.h>
using namespace std;
#define debug(x) cout << #x << " " << x << endl
inline void filehandling()
{
  #ifndef ONLINE_JUDGE
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
  #endif
}
#define int long long
#define MOD 1000000007
int power(int x,int y)
{
  int res = 1LL ;
  while(y > 0)
  {
    if(y & 1)
    {
      res = ((res % MOD) * (x % MOD)) % MOD;
    }
      
      y >>= 1 ;
      x = ( (x % MOD) * (x % MOD) ) % MOD;
  }

  return res % MOD;
} 
void Solve_Case()
{
   int r;
   cin >> r;
   cout << r*r;
}
signed main()
{
  // filehandling();
   int TestCases = 1;
  // cin >> TestCases;
   while(TestCases--)
   {
      Solve_Case();
   }
}

Measured memory_bytes: 256
import java.util.*;
import java.lang.*;
import java.math.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	void run(){
		for(;;){
			int n = sc.nextInt();
			
			if(n == 0){
				break;
			}
			
			int map[] = new int[n];
			LinkedList<Integer> used =  new LinkedList<Integer>();
			for(int i = 1; i < n ; i++ ){
				map[i] = i * i % n;
				if(!used.contains(map[i])){
					used.add(map[i]);
				}
			}
			int ans[] = new int[(n+1)/2];
			
			for(int z : used){
				for( int y : used){
					if(z == y){
						continue;
					}
					int x = z- y;
					if( x < 0 ){
						x += n;
					}
					if(x > (n-1)/2){
						x = n-x;
					}
					ans[x] ++;
				}
			}
			for(int i = 1; i < (n+1)/2 ; i++){
				System.out.println(ans[i]);
			}
		}
		
	}
	public static void main(String[] args){
		Main m = new Main();
		m.run();
	}
}

Measured memory_bytes: 13000
/*
 * ID: ITP1_7_C
 * Problem: Spreadsheet
 */

#include <stdio.h>

int main(void)
{
    int a[101][101];
    int row, column;

    scanf("%d %d", &row, &column);
    int i, j;
    for (i = 0; i < row; i++)
        for (j = 0; j < column; j++)
            scanf("%d", &a[i][j]);

    for (i = 0; i < row; i++) {
        int sum = 0;
        for (j = 0; j < column; j++)
            sum += a[i][j];
        a[i][column] = sum;
    }

    for (j = 0; j < column + 1; j++) {
        int sum = 0;
        for (i = 0; i < row; i++)
            sum += a[i][j];
        a[row][j] = sum;
    }

    for (i = 0; i < row + 1; i++) {
        for (j = 0; j < column + 1; j++)
            printf("%d%s", a[i][j], j != column ? " " : "");
        printf("\n");
    }

    return 0;
}




Measured memory_bytes: 2044