akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cout<<#x<<"="<<x<<"\n"
typedef long long ll;
template<typename T>
void print_to(std::ostream &os,const char *,const char *tail,const T &fst){
  os<<fst<<tail;
}
template<typename Fst,typename... Rst>
void print_to(std::ostream &os,const char *del,const char *tail,const Fst &fst,const Rst &... rst){
  os<<fst<<del;
  print_to(os,del,tail,rst...);
}
template<typename Iter>
void print_to_(std::ostream &os,const char *del,const char *tail,Iter bgn,Iter end){
  for(Iter it=bgn;it!=end;){
    os<<*it;
    if(++it!=end)os<<del;
    else os<<tail;
  }
}
template<typename Fst,typename... Rst>
void println(const Fst &fst,const Rst &... rst){
  print_to(std::cout,"\n","\n",fst,rst...);
}
template<typename Fst,typename... Rst>
void print(const Fst &fst,const Rst &... rst){
  print_to(std::cout," ","\n",fst,rst...);
}
template<typename Iter>
void println_(Iter bgn,Iter end){
  print_to_(std::cout," ","\n",bgn,end);
}
using namespace std;
const ll MOD=(ll)1e9+7;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
string s;
ll x[100001],y[100001],sumy[100001],sumx[100001];


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  cin>>n>>m;
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  for(int i=0;i<m;i++){
    cin>>y[i];
  }
  for(int i=m-1;i>=0;i--){
    if(i==m-1){
      sumy[i]=y[i];
      continue;
    }
    sumy[i]=y[i]+sumy[i+1];
  }
  for(int i=n-1;i>=0;i--){
    if(i==n-1){
      sumx[i]=x[i];
      continue;
    }
    sumx[i]=x[i]+sumx[i+1];
  }
  ll sumyy=0;
  for(int i=0;i<m;i++){
    ll p=i;
    sumyy=(sumyy+MOD)%MOD+(sumy[p+1]+MOD)%MOD+-(((m-1-p)%MOD)*(y[p]%MOD)+MOD)%MOD;
    sumyy%=MOD;
    //print(sumyy);
  }
  ll sumxx=0;
  for(int i=0;i<n;i++){
    ll p=i;
    sumxx=(sumxx+MOD)%MOD+(sumx[p+1]+MOD)%MOD-(((n-1-p)%MOD)*(x[p]%MOD)+MOD)%MOD;
    sumxx%=MOD;
  }
  //show(sumxx);
  //show(sumyy);
  print((((sumxx+MOD)%MOD)*((sumyy+MOD)%MOD)+MOD)%MOD);
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
    return 0;
}






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

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

	int dp[n];
	for(int i=0; i<n; i++)	dp[i] = INT_MAX;
	dp[0] = 0;
	for(int i=0; i<n-1; i++)
	{
		for(int j=1; j<=k; j++)
		{
			if(i+j < n)
				dp[i+j] = min( dp[i+j], dp[i] + abs(h[i] - h[i+j]));
		}	
	}

	cout << dp[n-1];
  	return 0;
}

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

 int main()
 {
    int a,b;
    cin>>a>>b;
    if(a+b >= a-b && a+b >= a*b){
        cout << a+b << endl;
    }
    else if(a-b >= a+b && a-b >= a*b){
        cout << a-b << endl;
    }
    else if(a*b >= a+b && a*b >= a-b){
        cout << a*b << endl;
    }
    else { cout << "error" << endl;}
    return 0;
 }


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

int main() {
    int64_t a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>=k){
        cout<<k<<endl;
    }else{
        if(b>=k-a){
            cout<<a<<endl;
        }else{
            cout<<a*2-k+b<<endl;
        }

    }
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
long long c, n;
int main(){
    int k;
    cin>>k;
   int b;
   cin>>b;
   if(b%2 == 0 ) {c=1; n=2;}
   else
   {
       n=1;
       c=2;
   }
   for(int i=1;i<k;i++)
   {
      // cout<<c<<" "<<n<<endl;
       int a;
       cin>>a;
       long long  staroc =c;
       long long staron=n;
       if(a%2==1)
       {
           c=staroc*2 + staron*2 + staroc;
           n=staron;
       }
       else
       {
           c=staroc + staron + staroc*2;
           n = staron * 2;
       }
   }
    cout<<c<<endl;

return 0;}


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

int BubbleSort(int* A,int N);

int main(void){
    int N;
    cin>>N;
    int* A = (int*)malloc(N*sizeof(int));
    int count;
    for(int i=0;i<N;i++){
        cin>>A[i];
    }
    count=BubbleSort(A,N);
    for(int i=0;i<N-1;i++){
        cout<<A[i]<<" ";
    }
    cout<<A[N-1]<<endl;
    cout<<count<<endl;
}

int BubbleSort(int* A,int N){
    int tmp;
    int count=0;
    for(int i=0;i<N;i++){
        for(int j=N-1;j>i;j--){
            if(A[j]<A[j-1]){
                tmp=A[j];
                A[j]=A[j-1];
                A[j-1]=tmp;
                count++;
            }
        }
    }
    return count;
}



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

const ll INF = 1001002003004005006ll;

ll dp[305][305];

int main() {
  int n, k;
  cin >> n >> k;
  int m = n-k;
  vector<int> h(n);
  rep(i,n) cin >> h[i];
  h.insert(h.begin(),0);
  rep(i,n+1)rep(j,m+1) dp[i][j] = INF;
  dp[0][0] = 0;
  for (int i = 1; i <= n; ++i)rep(j,i+1) {
    ll now = INF;
    rep(k,i) {
      chmin(now, dp[k][j]+max(0,h[i]-h[k]));
    }
    dp[i][j+1] = now;
  }
  ll ans = INF;
  rep(i,n+1) chmin(ans, dp[i][m]);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
 
using namespace std;
 
using   ll=long long;
using   ld=long double;
 
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define int            long long 
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define ff              first
#define ss              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323

void solve()
{
	ll n;
	
	cin>>n;
	
	if(n==1)
	{
		cout<<1;
		return;
	}
	
	vector<ll> a(n);
	
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	
	ll mm=n,ans=0;
	
	for(int i=0;i<n;i++)
	{
		if(mm>=a[i])
		{
			ans++;
			mm=a[i];
		}
	}
	
	cout<<ans;
}
 
signed main()
{
 
    fast;
 
    ll t;
    
    t=1;
    
    //cin>>t;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

Measured memory_bytes: 1792
k = int(input())
a = list(map(int,input().split()))

def check(n):
    for i in a:
        n = n//i*i
    return n

bot=top=0

# 2以上最小値
l = 0
r = sum(a)+2
while r-l>1:
    mid = (l+r)//2
    if check(mid) >1:
        r = mid
    else:
        l = mid
bot = r

# 2以下最大値
l = 0
r = sum(a)+2
while r-l>1:
    mid = (l+r)//2
    if check(mid) < 3:
        l = mid
    else:
        r = mid
top = l
if bot <= top:
    print(bot, top)
else:
    print(-1)

Measured memory_bytes: 14408
#include<bits/stdc++.h>
using namespace std;
int l[110]={};
int main()
{
	int n,s=0;
	cin>>n;
	for(int i=1;i<=2*n;i++)
	 cin>>l[i];
	sort(l+1,l+2*n+1);
    for(int i=2*n;i>=1;i--)
     if(i%2==1)s+=l[i];
    cout<<s<<endl;
	return 0;
}

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

#define MAXN 1010

int n,m;
char a[MAXN][MAXN],b[MAXN][MAXN],c[MAXN][MAXN];

int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)
	{
		scanf("%s",a[i]+1);
		for(int j=1;j<=m;++j)
			if(a[i][j]=='#')
				b[i][j]=c[i][j]='#';
			else
				b[i][j]=c[i][j]='.';
	}
	for(int i=1;i<=m;++i)
		b[1][i]=c[n][i]='#';
	for(int i=2;i<n;++i)
	{
		for(int j=1;j<=m;j+=2)
			b[i][j]='#';
		for(int j=2;j<=m;j+=2)
			c[i][j]='#';
	}
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)putchar(b[i][j]);
		puts("");
	}
	puts("");
	for(int i=1;i<=n;++i)
	{
		for(int j=1;j<=m;++j)putchar(c[i][j]);
		puts("");
	}
}

Measured memory_bytes: 2176
import Control.Monad

main :: IO ()
main = do
  _ <- getLine
  a <- reverse . map read . words <$> getLine
  let ans = foldl po (Just (2, 2)) a
  putStrLn $ case ans of
    Nothing       -> "-1"
    Just (mi, ma) -> unwords $ map show [mi, ma]

po :: Maybe (Int, Int) -> Int -> Maybe (Int, Int)
po range x = do
  (mi, ma) <- range
  guard $ ma >= x
  guard $ mi <= ((ma `div` x) * x)
  let
    nmi = if mi `mod` x == 0     then mi else mi + x - (mi `mod` x)
    nma = if ma `mod` x == x - 1 then ma else ma + x - (ma `mod` x) - 1
  return (nmi, nma)

Measured memory_bytes: 62844
import java.util.Scanner;

public class Main {

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

		int n = sc.nextInt();
		int m = sc.nextInt();

		String image[] = new String[n];
		for(int i = 0; i < n; i++){
			image[i] = sc.next();
		}

		String template[] = new String[m];
		for(int i = 0; i < m; i++){
			template[i] = sc.next();
		}

//		int count = 0;
		for(int i = 0; i < n - m + 1 ; i++){
			for(int j = 0; j < n - m + 1; j++){
//				System.out.println("i = "+i+" j = "+j);
				boolean same = true;
				for(int k = 0; k < m; k++){
//					System.out.println(template[k] + " " +image[i + k].substring(j, j + m));
					if(!template[k].equals(image[i + k].substring(j, j + m))){
						same = false;
						break;
					}
				}

				if(same){
//					count++;
					System.out.println("Yes");
					return;
				}
			}
		}

		System.out.println("No");

//		System.out.println(count);
    }
}

Measured memory_bytes: 23636
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <iostream>
#include <vector>
#include <list>
 
using namespace std;
typedef long long ll;
 
#define mod 1000000007
#define INF 1000000000
#define SIZE 100000

bool ans[200000];

int main(){
  int n,m,q;
  int a,b;
  list<int> stu;

  scanf("%d%d%d",&n,&m,&q);
  
  for(int i=0;i<n;i++){
    stu.push_back(i);
  }

  list<int>::iterator it = stu.begin(),it2;
  
  for(int i=0;i<m;i++){
    scanf("%d",&a);

    for(int j=0;j<a;j++){
      if(a%2==0){
	it++;
	if(stu.end()==it) it = stu.begin();
      }else{
	if(it == stu.begin()) it = stu.end();
	it--;
      }
    }
    
    it2 = it;
    it2++;
    stu.erase(it);
    it = it2;
    if(it == stu.end()) it = stu.begin();
  }

  for(it2 = stu.begin();it2!=stu.end();it2++){
    ans[*it2]=true;
  }

  for(int i=0;i<q;i++){
    scanf("%d",&b);
    puts(ans[b] ? "1" : "0");
  }
  
  return 0;
}

Measured memory_bytes: 7420
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a[] = new int[3];
    a[0]=sc.nextInt();
    a[1]=sc.nextInt();
    a[2]=sc.nextInt();
    Arrays.sort(a);
    System.out.println(a[2]*10+a[1]+a[0]);
  }
  

  
}

Measured memory_bytes: 22100
n,m,c=map(int, input().split())
b = list(map(int, input().split()))
src_a = [0]*n
for i in range(n):
    src_a[i] = list(map(int, input().split()))

cnt=0
for a in src_a:
    sum=0
    for j in range(m):
        sum+=b[j]*a[j]
    if sum + c > 0:
        cnt+=1
print(cnt)


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

// Shortcut

#pragma optimize ("O3")
#define int long long
#define endl '\n'
#define eb emplace_back
#define pb push_back
#define pob pop_back
#define mp make_pair
#define upb upper_bound
#define lwb lower_bound
#define fi first
#define se second
#define For(i, l, r) for (int i = l; i < r; i++)
#define ForE(i, l, r) for (int i = l; i <= r; i++)
#define Ford(i, r, l) for (int i = r; i > l; i--)
#define FordE(i, r, l) for (int i = r; i >= l; i--)
#define Fora(i, a) for (auto i : a)

// I/O & Debug

#define PrintV(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << ' ';
#define PrintVl(a) for (int iiii = 0; iiii < a.size(); iiii++) cout << a[iiii] << endl;
#define PrintA(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << ' ';
#define PrintAl(a, n) for (int iiii = 0; iiii < n; iiii++) cout << a[iiii] << endl;
#define Ptest(x) return cout << x, 0;
#define gl(s) getline(cin, s);
#define setpre(x) fixed << setprecision(x)
/*
#define debug(args...){ string _sDEB = #args; replace(_sDEB.begin(), _sDEB.end(), ',', ' '); stringstream _ssDEB(_sDEB); istream_iterator<string> _itDEB(_ssDEB); DEB(_itDEB, args); }
void DEB(istream_iterator<string> it) {}
template<typename T, typename... Args>
void DEB(istream_iterator<string> it, T a, Args... args){
    cout << *it << " = " << a << endl;
    DEB(++it, args...);
}
*/

// Functions

//#define isvowel(a) (a == 'a' || a == 'e' || a == 'i' || a == 'o' || a == 'u')
#define bend(a) a.begin(), a.end()
#define rbend(a) a.rbegin(), a.rend()
#define mset(a) memset(a, 0, sizeof(a));
#define mmset(a) memset(a, 0x3f, sizeof(a));
//mt19937 rando(chrono::steady_clock::now().time_since_epoch().count());

// Data Structure

#define pque priority_queue
#define mts multiset
#define y0 _y0_
#define y1 _y1_
typedef long long ll;
typedef long double ld;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <ld> vld;
typedef vector <string> vs;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef vector <vi > vvi;
typedef vector <vll > vvll;
typedef vector <pii > vpii;
typedef vector <pll > vpll;

const int N = 2e5 + 5, mod = 1e9 + 7, inf = 1e9 + 7;

int n;
pii a[N];

bool cmp(pii x, pii y){
    if (x.se != y.se) return x.se < y.se;
    return x.fi > y.fi;
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin >> n;
    ForE(i, 1, n){
        cin >> a[i].fi >> a[i].se;
    }
    sort(a + 1, a + 1 + n, cmp);
    int t = 0;
    ForE(i, 1, n){
        if (t + a[i].fi > a[i].se) Ptest("No");
        t += a[i].fi;
    }
    cout << "Yes";
}

/*
==================================+
INPUT:                            |
------------------------------    |

------------------------------    |
==================================+
OUTPUT:                           |
------------------------------    |

------------------------------    |
==================================+
*/

Measured memory_bytes: 3328
M, D = [int(md) for md in input().split()]

ans = 0
for m in range(1, M+1):
  for d in range(1, D+1):
    # m 月 d 日
    dd = str(d)
    if len(dd) == 2:
      d10, d1 = int(dd[0]), int(dd[1])
      if d10 >= 2 and d1 >= 2 and m == d10 * d1:
        ans += 1

print(ans)

Measured memory_bytes: 3064
#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>;

int main() {
  int h,n;
  cin >> h >> n;
  // vector<int> a(n);
  int sum = 0;
  rep(i,n) {
    int a; cin >> a;
    sum += a;
  }
  cout << (h > sum ? "No" : "Yes") << endl;

  return 0;
}


Measured memory_bytes: 256
#include <string>
#include <vector>
#include <map>
#include <deque>
#include <iostream>
#include <queue>
#include <math.h>
#include <algorithm>
#include <fstream>

using namespace std;
typedef long long ll;


int main(void) {
	ll n,sum=0;
	cin >> n;
	/*
	for (int i = 1; i <= n-1; i++) {
		sum += i;
	}
	*/
	sum = ((n - 1)*n) / 2;
	cout << sum;
	return 0;
}

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

using namespace std;

int main(){
  string N;
  cin >> N;
  int i,total=0;
  
  for(i=0;i<N.length();i++){
    total=total+N.at(i)-'0';
  }
  
  if(total%9==0){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
const int INF=1001001001;

int main(){
  int n, m, x;
  cin >> n >> m >> x;
  int pri[n], arg[n][m];
  for(int i=0; i<n; ++i){
    cin >> pri[i];
    for(int j=0; j<m; ++j){
      cin >> arg[i][j];
    }
  }
  int ans = INF;
  bool ansis = false;
  for(int i=0; i<(1<<n); ++i){
    int bt=i;
    vector<int> buy(n);
    for(int j=0; j<n; ++j){
      if(bt%2) buy[j] = 1;
      bt /= 2;
    }
    vector<int> narg(m,0);
    int nans=0;
    for(int j=0; j<n; ++j){
      if(buy[j]){
        nans += pri[j];
        for(int k=0; k<m; ++k){
          narg[k] += arg[j][k];
        }
      }
    }
    bool ok= true;
    for(int j=0; j<m; ++j){
      if(narg[j] < x) ok = false;
    }
    if(ok){
      ansis = true;
      ans = min(ans, nans);
    }
  }
  if(ansis)cout << ans << endl;
  else cout << -1 << endl;
}

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

int main(){
	char ch, ch2;
	
	while(1){
		scanf("%c", &ch);
		
		if(islower(ch)){
			ch2 =  toupper(ch);
			cout << ch2;
		}else{
			ch2 = tolower(ch);
			cout << ch2;
		}
	
		if(ch == '\n'){
			break;
		}
	}
		
 	return 0;
}

Measured memory_bytes: 3076
#include <iostream>
#include <vector>
#include <functional>

template <class Cost = int>
struct Edge {
    int src, dst;
    Cost cost;
    Edge(int src = -1, int dst = -1, Cost cost = 1)
        : src(src), dst(dst), cost(cost){};

    bool operator<(const Edge<Cost>& e) const { return this->cost < e.cost; }
    bool operator>(const Edge<Cost>& e) const { return this->cost > e.cost; }
};

template <class Cost = int>
struct Graph {
    std::vector<std::vector<Edge<Cost>>> graph;

    Graph(int n = 0) : graph(n) {}

    void span(bool direct, int src, int dst, Cost cost = 1) {
        graph[src].emplace_back(src, dst, cost);
        if (!direct) graph[dst].emplace_back(dst, src, cost);
    }

    int size() const { return graph.size(); }
    void clear() { graph.clear(); }
    void resize(int n) { graph.resize(n); }

    std::vector<Edge<Cost>>& operator[](int v) { return graph[v]; }
    std::vector<Edge<Cost>> operator[](int v) const { return graph[v]; }
};

void solve() {
    int n;
    std::cin >> n;

    std::vector<int> xs(n);
    for (auto& x : xs) std::cin >> x;

    Graph<> graph(n);
    for (int i = 0; i < n - 1; ++i) {
        int u, v;
        std::cin >> u >> v;
        graph.span(false, --u, --v);
    }

    std::vector<int> dp(n, -1);
    std::function<bool(int)>
        dfs = [&](int v) -> bool {
        if (dp[v] != -1) return dp[v];

        auto& ret = dp[v];
        ret = false;

        for (auto e : graph[v]) {
            int u = e.dst;
            if (xs[u] >= xs[v]) continue;
            if (!dfs(u)) ret = true;
        }

        return ret;
    };

    for (int v = 0; v < n; ++v) {
        if (dfs(v)) std::cout << v + 1 << " ";
    }
    std::cout << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 512
N = readline()
N = parse(N)
S = readline()
S = strip(S)
str_array = ['A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z']
index_array = []
for i in S
    v = find(x->x==i,str_array)
    push!(index_array,v[1])
end

for j in index_array
    j += N
    if j <= 26
        print(str_array[j])
    else
        j -= 26
        print(str_array[j])
        end
end
print("\n")

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

using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using f64 = double;
using f80 = long double;

#define FOR(v, a, b) for(i64 v = (a); v < (b); ++v)
#define FORE(v, a, b) for(i64 v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(i64 v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}

template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}

template <typename T> void print(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void print(const T &value, const Args&... args){std::cout << value << " ";print(args...);}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;



int main(){
  int X, N;

  while(cin >> X >> N){
    vector<int> p(N); cin >> p;
    set<int> s(ALL(p));

    vector<int> a;
    FORE(i,-1000,1000){
      if(not EXIST(s, i)){
        a.push_back(i);
      }
    }

    auto ans = *min_element(ALL(a), [X](int i, int j){return abs(i-X) < abs(j-X);});

    print(ans);
    
  }
  

  return 0;
}


Measured memory_bytes: 3684
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define Fst first
#define Snd second
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int N,W;
int w1,v;
vector<int> V[5];

int main(){
	scanf("%d%d%d%d" , &N , &W , &w1 , &v);
	V[0].PB(v);
	repp(i,1,N){
		int w;
		scanf("%d%d" , &w , &v);
		V[w-w1].PB(v);
	}
	repp(i,0,4){
		V[i].PB(1e9+7);
		sort(V[i].begin(),V[i].end(),greater<int>());
		repp(j,2,V[i].size()){
			V[i][j] += V[i][j-1];
		}
		V[i][0] = 0;
	}
	int ans = 0;
	repp(a0,0,V[0].size()){
		if((LL)w1 * a0 > (LL)W) break;
		ans = max(ans , V[0][a0]);
		repp(a1,0,V[1].size()){
			if((LL)w1 * a0 + (LL)(w1+1) * a1 > (LL)W) break;
			ans = max(ans , V[0][a0] + V[1][a1]);
			repp(a2,0,V[2].size()){
				if((LL)w1 * a0 + (LL)(w1+1) * a1 + (LL)(w1+2) * a2 > (LL)W) break;
				ans = max(ans , V[0][a0] + V[1][a1] + V[2][a2]);
				repp(a3,0,V[3].size()){
					if((LL)w1 * a0 + (LL)(w1+1) * a1 + (LL)(w1+2) * a2 + (LL)(w1+3) * a3 > (LL)W) break;
					ans = max(ans , V[0][a0] + V[1][a1] + V[2][a2] + V[3][a3]);
				}
			}
		}
	}
	printf("%d\n" , ans);
	return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Numerics;
using static System.Console;
using static Func;
class Z { static void Main() => new K(); }
class K
{
	long[] GL => ReadLine().Split().Select(long.Parse).ToArray();
	readonly int M;
	readonly long[] pow10 = new long[19];
	public K()
	{
		pow10[0] = 1;
		for (var i = 1; i <= 18; i++) pow10[i] = pow10[i - 1] * 10;
		var I = GL;
		long L = I[0], A = I[1], B = I[2];
		P.M = Matrix.Mod = M = (int)I[3];
		var l = new List<long> { 0 };
		while (l.Last() < L)
		{
			var k = (A + B * l.Last()).ToString().Length;
			l.Add(FirstBinary(l.Last(), L, _j => A + B * _j >= pow10[k]));
		}
		var ans = new P(0, 1);
		for (var i = 1; i < l.Count; i++) ans = ans.Combine(Solve(l[i] - l[i - 1], A + B * l[i - 1], B));
		WriteLine(ans.Mod);
	}
	// A ~ A+B*(L-1) まで全て k 桁
	P Solve(long L, long A, long B)
	{
		var k = A.ToString().Length;
		var mat = new Matrix(3);
		mat[0, 0] = pow10[k];
		mat[0, 1] = mat[1, 1] = mat[2, 2] = 1;
		mat[1, 2] = B;
		mat = mat.Pow(L);
		return new P((mat[0, 1] * (A % M) % M + mat[0, 2]) % M, Pow(Pow(10, k, M), L, M));
	}
}
struct P
{
	public static int M;
	public readonly long Mod;
	public readonly long Pow10;
	public P(long m, long l) { Mod = m; Pow10 = l; }
	public P Combine(P p) => new P((Mod * p.Pow10 % M + p.Mod) % M, Pow10 * p.Pow10 % M);
}
static class Func
{
	public static long FirstBinary(long min, long max, Predicate<long> pred)
	{
		while (min < max)
		{
			var mid = (min + max) / 2;
			if (pred(mid)) max = mid;
			else min = mid + 1;
		}
		return min;
	}
	public static long Pow(long a, long b, long mod)
	{
		var p = 1L;
		var x = a;
		while (b > 0)
		{
			if ((b & 1) == 1) p = (p * x) % mod;
			b >>= 1;
			x = (x * x) % mod;
		}
		return p;
	}
}
class Matrix
{
	public static int Mod;
	public int Size { get; protected set; }
	readonly long[,] a;
	public long this[int r, int c] { get { return a[r, c]; } set { a[r, c] = value % Mod; } }
	public Matrix(int r) { Size = r; a = new long[r, r]; }
	public Matrix(int r, Func<int, int, long> f) : this(r) { for (var i = 0; i < r; i++) for (var j = 0; j < r; j++) a[i, j] = f(i, j) % Mod; }
	public static Matrix operator *(Matrix p, Matrix q)
		=> new Matrix(p.Size, (i, j) => { var sum = 0L; for (var k = 0; k < p.Size; k++) sum = (sum + p.a[i, k] * q.a[k, j] % Mod) % Mod; return sum; });
	public static Matrix One(int size) => new Matrix(size, (i, j) => i == j ? 1 : 0);
	public Matrix Pow(long n)
	{
		var p = One(Size);
		var x = this;
		while (n > 0)
		{
			if ((n & 1) == 1) p *= x;
			n >>= 1;
			x *= x;
		}
		return p;
	}
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define N 500003
#define MOD 1000000007
#define int long long
using namespace std;


signed main()
{
    string s;
    string t;
    cin>>s>>t;
    int dp[s.length()+1][t.length()+1];

    pair<int,int> p[s.length()+1][t.length()+1];

   // int ab[s.length()+1][t.length()+1]={0};

    for(int i=0;i<=s.length();i++){

        for(int j=0;j<=t.length();j++){

            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else{
                if(s[i-1]==t[j-1]){
                        p[i][j]={i-1,j-1};
                        dp[i][j]=1+dp[i-1][j-1];
                }

                else{

                    if(dp[i-1][j]>dp[i][j-1]){
                        p[i][j]={i-1,j};
                        dp[i][j]=dp[i-1][j];
                    }
                    else{
                        p[i][j]={i,j-1};
                        dp[i][j]=dp[i][j-1];
                    }

                }
            }
        }
    }

    p[0][0]={-1,-1};
    string ans;
    int i=s.length();
    int j=t.length();

    while(i!=0 && j!=0){
      //cout<<i<<" "<<j<<endl;
        if(s[i-1]==t[j-1])
        ans+=s[i-1];
        int temp=i;
        i=p[i][j].first;
        j=p[temp][j].second;



    }

    reverse(ans.begin(),ans.end());
    cout<<ans<<endl;


}


Measured memory_bytes: 211328
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <random>

using namespace std;


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

	int n, i, j, k, ans, a, b, id, x;
	cin >> n;

	vector<vector<pair<int, int>>> adj(n);
	for (i = 0; i < n; i++) {
		adj[i].push_back({ (i + 1) % n, 1 });
		adj[i].push_back({ (i * 10) % n, 0 });
	}

	// min dist from 1 to 0
	vector<int> dist(n, n * 100);
	dist[1] = 1;
	queue<int> q;
	q.push(1);

	while (!q.empty()) {
		id = q.front();
		q.pop();

		for (auto p : adj[id]) {
			if (dist[p.first] > dist[id] + p.second) {
				dist[p.first] = dist[id] + p.second;
				q.push(p.first);
			}
		}
	}

	ans = dist[0];

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 8864
import sys
input = lambda: sys.stdin.readline().rstrip()

H1, M1, H2, M2, K = map(int, input().split())


if M2 - M1 >= 0:
    tmp = (H2-H1) * 60 + (M2-M1)
else:
    tmp = (H2-H1-1) * 60 + 60+M2-M1

print(tmp - K)

Measured memory_bytes: 61684
#include <iostream>
using namespace std;
int main(){
  long long A[100010];
  long long K,count=0;
  int n,x,N;
  cin >> N >> K;
  for(int i=0;i<=100000;i++){
    A[i] = 0;
  }
  for(int i=0;i<N;i++){
    cin >> x >> n;
    A[x] += n;
  }
  for(int i = 0;i<=100000;i++){
    count += A[i];
    if(count >= K){
      cout << i;
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    // ifstream in("data1.txt");
    // cin.rdbuf(in.rdbuf());
    int N;
    cin >> N;
    int ans=0;
    int cnt=1;
    int l=0;
    while(l < N){
        int x;
        cin >> x;
        if(x != cnt){
            ans++;
        } else {
            cnt++;
        }
        l++;
    }
    if(ans == N){
        cout << "-1" << endl;
        return 0;
    }
    cout << ans << endl;
}
// 10
// 3 1 4 1 5 9 2 6 5 3


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
x = int(input())

tmp1 = (x % 100) // 5
tmp2 = ((x % 100) - tmp1 * 5) // 4
tmp3 = ((x % 100) - tmp1 * 5 - tmp2 * 4) // 3
tmp4 = ((x % 100) - tmp1 * 5 - tmp2 * 4 - tmp3 * 3) // 2
tmp5 = (x % 100) - tmp1 * 5 - tmp2 * 4 - tmp3 * 3 - tmp4 * 2
if x // 100 >= tmp1 + tmp2 + tmp3 + tmp4 + tmp5:
    print(1)
else:
    print(0)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;

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

    int n;
    cin >> n;
    int N = pow(2, n);
    vector<int> a(N);
    rep(i, N) cin >> a[i];
    sort(all(a));
    reverse(all(a));
    a.push_back(-1);
    vector<int> v;
    int cnt = 1;
    rep(i, N)
    {
        if (a[i] == a[i + 1])
            cnt++;
        else
        {
            v.push_back(cnt);
            cnt = 1;
        }
    }
    priority_queue<int> que;
    que.push(2 * N - 1);
    rep(i, v.size())
    {
        if (que.size() < v[i])
        {
            cout << "No" << endl;
            return 0;
        }
        vector<int> w;
        rep(j, v[i])
        {
            int tmp = que.top();
            que.pop();
            w.push_back(tmp);
        }
        rep(j, v[i])
        {
            while (w[j] / 2 > 0)
            {
                que.push(w[j] / 2);
                w[j] /= 2;
            }
        }
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 8316
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;

int main(){
  vector<int> t,v;
  double now_t = 0;
  double now_v = 0;
  double len = 0;
  int n;
  t.push_back(0);
  v.push_back(0);
  cin >> n;
  for(int i = 0; i < n ; i++){
    int a;
    cin >> a;
    t.push_back(a + t[i]);
  }
  for(int i = 0; i < n ; i++){
    int a;
    cin >> a;
    v.push_back(a);
  }
  v.push_back(0);

  int count = 0;
  for(double i = 0; i <= t[n]; i += 0.5){
    double mini = 100;
    if(i >= t[count]) count++;
    for(int j = 0; j <= n; j++){
      if(mini > (i - t[j] + v[j]) && i - t[j] >= 0){
        mini = i - t[j] + v[j];
      }
      if(mini > (t[j] - i + v[j+1]) && t[j] - i >= 0){
        mini = t[j] - i + v[j+1];
      }
    }
    if(mini > v[count]){
      mini = v[count];
    }
    len += 0.25*(now_v + mini);
    now_v = mini;
  }
  printf("%.5lf\n", len);
}


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

typedef long long ll;
#define nl "\n"
#define ff first
#define ss second
#define mod 1e9+7
#define lb lower_bound
#define ub upper_bound
#define eb emplace_back
#define pp pop_back
#define bs binary_search
#define all(x) x.begin(),x.end()
#define loop(i,s,n) for(ll i=s;i<n;i++)
#define test ll t ; cin>>t; while(t--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);

ll dp[1000000]={0},k;

ll rec(ll a[],ll n)
{
   if(n==1)     return 0;
   else if(n<=0)     return INT_MAX;
   
   if(dp[n]!=-1)    return dp[n];
   ll val=INT_MAX;
   for(ll i=1;i<=k;i++)
   {
       if(n-i<1)    return   dp[n]=val;
       val=min(val,abs(a[n]-a[n-i])+rec(a,n-i));
   }
   return   dp[n]=val;
}

int main() {
	fast_io;
	
	ll n,ans;
	cin>>n>>k;
	ll a[n+1]={0};
	loop(i,1,n+1)     cin>>a[i];
	memset(dp,-1,sizeof(dp));
	ans=rec(a,n);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 16640
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
                
#define speedio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pretime float(clock()-clk)/CLOCKS_PER_SEC
#define max2(a,b) ((a)>(b) ? (a) : (b))   
#define min2(a,b) ((a)<(b) ? (a) : (b)) 
#define rep(i,a,b) for(i=a;i<=b;++i)
#define rev(i,a,b) for(i=a;i>=b;--i) 
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define lli long long int 
#define ins insert
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
#define inf 1000000000000000

using namespace std;
typedef vector<lli>   vll;
typedef vector<int>   vi;
typedef set<lli>      sll;
typedef set<int>      si;
typedef pair<lli,lli> pll;
typedef pair<int,int> pii;
clock_t clk=clock();       

lli i,j;
void solve(void);

int main()
{
  speedio;
   int t=1;  
  // cin>>t;
   while(t--)
     solve();

  return 0;
}
//
void solve()
{
	lli n; cin>>n;
    vll div;
    rep(i,1,sqrt(n))
     if(n%i==0)
     {
     	div.pb(i);
     	if(i!=n/i)
     		div.pb(n/i);
     }

     lli sum=0;

     rep(i,0,sz(div)-1)
       if(div[i]<(n-div[i])/div[i])
       	  sum+=(n-div[i])/div[i];

      cout<<sum<<"\n";
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define MOD DEKAI
#define DEKAI (int)(1e9+7)
#define rep(i,n) lps(i,0,n)
#define lp(i,n) lps(i,0,n)
#define lps(i,j,n) for(int i = j; i < n; i++)
#define atoi(c) c-'0'

int main(){ 
  string A,B,C;
  int a,b,c;
  long long int plus1[55],plus0[55],pl11,pl10,pl01,pl00;
  while(1){
    cin>>A;
    if(A=="0") break;
    cin>>B>>C;
    for(int i=0;i<55;i++){
      plus1[i]=plus0[i]=0;
    }
    plus1[A.size()]=0;
    plus0[A.size()]=1;
    for(int i=A.size()-1;i>=0;i--){
      pl11=pl10=pl01=pl00=0;
      for(int j=0;j<=9;j++){
	if(A[i]!='?') j=atoi(A[i]);
	else if(j==0 && i==0) continue;
	for(int k=0;k<=9;k++){
	  if(B[i]!='?') k=atoi(B[i]);
	  else if(k==0 && i==0) continue;
	  //insert birou
	  if(C[i]!='?'){
	    if((j+k)>9){
	       if((j+k)%10==atoi(C[i])) pl01++;
	       if((j+k+1)%10==atoi(C[i])) pl11++;
	    }else if((j+k)==9){
	      if((j+k+1)%10==atoi(C[i])) pl11++;
	      if((j+k)%10==atoi(C[i])) pl00++;
	    }else{
	      if((j+k+1)%10==atoi(C[i])) pl10++;
	      if((j+k)%10==atoi(C[i])) pl00++;
	    }
	  }else{
	    if((j+k)>9){
	      pl11++;
	      pl01++;
	    }else if((j+k)==9){
	      pl11++;
	      pl00++;
	    }else{
	      pl10++;
	      pl00++;
	    }
	  }
	  //insaato abobu
	  if(B[i]!='?') break;
	}
	if(A[i]!='?') break;
      }
      plus1[i]=((pl11*plus1[i+1])%DEKAI+(pl01*plus0[i+1])%DEKAI)%DEKAI;
      plus0[i]=((pl10*plus1[i+1])%DEKAI+(pl00*plus0[i+1])%DEKAI)%DEKAI;
    }  
    cout<<plus0[0]<<endl;
  }
  
  
  return 0;
}
  



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

int main(){
	int n,k;
	cin>>n>>k;
	int h[n],dp[n];
	for (int i = 0; i < n; ++i)
	{
		cin>>h[i];
	}
	dp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		int temp=i;
		int minValue = INT_MAX;
		while(temp-- && temp>=(i-k)){
			minValue = min(minValue,abs(h[i]-h[temp])+dp[temp]);
		}
		dp[i] = minValue;
	}
	cout<<dp[n-1]<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<utility>
#include<queue>
using namespace std;
#define INF 1<<30
#define LL long long

LL N;
vector<LL> A, sum;

int main() {
	//input
	cin >> N;
	for (int i = 0; i < N; i++) {
		int a;  cin >> a;
		A.push_back(a);
	}
	for (int i = 0; i < N; i++) A.push_back(A[i]);
	//get sum
	for (int i = 0; i < 2 * N; i++) {
		sum.push_back(A[i]);
		if (i) sum[i] += sum[i - 1];
	}
	//binary search:ans
	LL mn = 0, mx = sum[N];
	while (mx - mn > 1) {
		LL md = (mx + mn) / 2;
		bool jud = false;
		//1st cut
		for (int fir = 0; fir < N; fir++) {
			//binary search:2nd cut(at least md)
			//range:fir to fir + N - 1
			auto beg = sum.begin();  beg += fir;
			auto lef = sum.begin();  lef += fir;
			auto rig = sum.begin();  rig += fir + N - 1;
			auto sec = lower_bound(lef, rig, md + (lef == sum.begin() ? 0 : *(lef - 1)));
			if (sec == sum.end()) continue;//NG
			lef = sec;  lef++;
			//binary search:3rd cut(at least md)
			//range:sec + 1 to fir + N - 1
			auto thr = lower_bound(lef, rig, md + *(lef - 1));
			if (thr == sum.end()) continue;//NG
			//left part is at least md?
			if (sum[N - 1] - *thr + (beg == sum.begin() ? 0 : *(beg - 1)) >= md) { jud = true; break; }
		}
		(jud ? mn : mx) = md;
	}
	cout << mn << endl;

	return 0;
}


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

ll MOD = 1e9 + 7;

int main() {
  string S;
  cin >> S;
  int N = S.size();
  vector<vector<ll>> dp(N + 1, vector<ll>(4));
  dp[N][3] = 1;
  for (int i = N - 1; i >= 0; i--) {
    int a = (S[i] == '?') ? 3 : 1, b;
    dp[i][3] = a * dp[i + 1][3] % MOD;
    b = (S[i] == '?') || (S[i] == 'C');
    dp[i][2] = (a * dp[i + 1][2] + b * dp[i + 1][3]) % MOD;
    b = (S[i] == '?') || (S[i] == 'B');
    dp[i][1] = (a * dp[i + 1][1] + b * dp[i + 1][2]) % MOD;
    b = (S[i] == '?') || (S[i] == 'A');
    dp[i][0] = (a * dp[i + 1][0] + b * dp[i + 1][1]) % MOD;
  }
  cout << dp[0][0] % MOD << endl;
}

/*
int main() {
  string S;
  cin >> S;
  ll ans = 0;
  ll a = 0, ab = 0, num = 1;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] == 'A') {
      a = (a + num) % MOD;
    } else if (S[i] == 'B') {
      ab = (ab + a) % MOD;
    } else if (S[i] == 'C') {
      ans = (ans + ab) % MOD;
    } else {
      ans = (ans * 3 + ab) % MOD;
      ab = (ab * 3 + a) % MOD;
      a = (a * 3) % MOD + num;
      num = num * 3 % MOD;
    }
  }
  cout << ans % MOD << endl;
}
*/

Measured memory_bytes: 7552
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b;
  cin >> a >> b;
  if ((a+b)%2==0)
  {
    cout << (a+b)/2 <<endl;
  }
  else 
  {
    cout << (a+b)/2+1 <<endl;
  }
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF LONG_LONG_MAX

int n,l[2000],ans;

signed main() {
    scanf("%lld", &n);
    rep(i,n) scanf("%lld", &l[i]);
    sort(l,l+n);
    rep(i,n) repo(j,i+1,n) repo(k,j+1,n) if (l[k] < l[i]+l[j]) ans++;
    printf("%lld\n", ans);
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <set>
#include <cmath>
#include <algorithm>

using namespace std;

int main(void) {
	int num, ans;
	string begin_train;
	string tr1, tr2;
	set<string> end_train;

	cin >> num;
	while(num--) {
		cin >> begin_train;
		for(int i = 1; i < begin_train.size(); i++) {
			tr1 = begin_train.substr(0, i);
			tr2 = begin_train.substr(i);
			end_train.insert(tr1 + tr2);
			end_train.insert(tr2 + tr1);
			reverse(tr1.begin(), tr1.end());
			end_train.insert(tr1 + tr2);
			end_train.insert(tr2 + tr1);
			reverse(tr2.begin(), tr2.end());
			end_train.insert(tr1 + tr2);
			end_train.insert(tr2 + tr1);
			reverse(tr1.begin(), tr1.end());
			end_train.insert(tr1 + tr2);
			end_train.insert(tr2 + tr1);
		}
		ans = end_train.size();
		printf("%d\n", ans);
		end_train.clear();
	}
	return 0;
}

Measured memory_bytes: 1300
#include <stdio.h>

int main(void)
{
    int H, W, i, j;
    
    while (1) {
        scanf("%d %d", &W, &H);
        if (H == 0 && W == 0)   break;
        
        for (i = 0; W > i; i++)
        {
            for (j = 0; H > j; j++) {
                putchar('#');
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}

Measured memory_bytes: 576
n = int(input())
x = int(n / 1.08)
if n == int(x * 1.08):
    print(x)
elif n == int((x + 1) * 1.08):
    print(x + 1)
elif n == int((x - 1) * 1.08):
    print(x - 1)
else:
    print(':(')

Measured memory_bytes: 3060
import java.util.*;
import java.math.*;
import java.io.*;
import java.lang.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t = sc.nextInt();
        int a = sc.nextInt();
        int res = 0;
        double dist = 1145141919;
        int[] height = new int[n];
        for (int i = 0; i < n; i++) {
            height[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if(dist > Math.abs((double)a - ((double)t - height[i]*0.006))){
                res = i+1;
                dist = Math.abs((double)a - ((double)t - height[i]*0.006));
            }
        }
        System.out.println(res);
    }
}

class io{
    public static void br(){
        System.out.println("");
    }

    public static void YesNo(boolean f) {
        System.out.println(f?"Yes":"No");
    }
    public static void YESNO(boolean f) {
        System.out.println(f?"YES":"NO");
    }

}

class Algo{
    public static boolean isOdd(int n){
        return n % 2 == 1;
    }
    public static boolean isEven(int n){
        return n % 2 == 0;
    }


}



Measured memory_bytes: 24532
N,M,K = map(int, input().split())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]

sumT = 0
cnt = 0
cntL = []
cntMax = 0
AMax = 0
BMax = 0

if (A[0]>K and B[0]>K):
    print(0)
    exit()

for i in range(len(A)):
    sumT += A[i]
    cnt += 1
    if (sumT > K):
        sumT -= A[i]
        cnt -= 1
        break

AMax = cnt-1
cntL.append(cnt)


for i in range(len(B)):
    sumT += B[i]
    cnt += 1
    if (sumT<=K):
        cntL.append(cnt)
    while (sumT > K):
        if (AMax<0):
            break
        sumT -= A[AMax]
        AMax -= 1
        cnt -= 1

print(max(cntL))



Measured memory_bytes: 39924
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;
using static MyIO;


public class D
{
	public static void Main()
	{
		long N = GetLong();
		int M = GetInt();

		List<int> primes = sieve((int)Math.Sqrt(M));
		long[] numPrime = new long[primes.Count + 1];

		Dictionary<int, long> numFactor = new Dictionary<int, long>();
		int tmp = M;
		for(int i = 0; i < primes.Count; i++)
		{
			int prime = primes[i];
			while(tmp % prime == 0)
			{
				tmp /= prime;
				long currentNum;
				if(!numFactor.TryGetValue(prime, out currentNum))
					currentNum = 0;
				numFactor[prime] = currentNum + 1;
			}
			if(tmp == 1)
				break;
		}
		if(tmp != 1)
			numFactor[tmp] = 1;		
		
		long mod = 1000000007;
		long ans = 1;
		foreach(int factor in numFactor.Keys)
		{
			long num = numFactor[factor];
			long modComb = ModComb(num + N - 1, num, mod);
			ans = (ans * modComb) % mod;
		}
		Console.WriteLine(ans);
	}

	private static List<int> sieve(int N)
	{
		List<int> primeList = new List<int>();
		bool[] isPrime = new bool[N+1];
		for(int i = 2; i <= N; i++)
			isPrime[i] = true;

		for(int i = 2; i <= N; i++)
		{
			if(isPrime[i])
			{
				primeList.Add(i);
				for(int j = 2 * i; j <= N; j += i)
					isPrime[j] = false;
			}
		}

		return primeList;
	}

	public static long ModComb(long n, long k, long mod)
	{
		long numerator = 1;
		for(long i = n; i >= n - k + 1; i--)
			numerator = (numerator * i) % mod;

		long denomitor = 1;
		for(long i = k; i >= 1; i--)
			denomitor = (denomitor * i) % mod;

		return (numerator * ModInv(denomitor, mod)) % mod;		
	}

	public static long ModInv(long a, long mod)
	{
		return ModPow(a, mod - 2, mod);
	}

	public static long ModPow(long x, long n, long mod)
	{
		long res = 1;
		while(n > 0)
		{
			if((n & 1) == 1)
				res = (res * x) % mod;
			x = (x * x) % mod;
			n >>= 1;
		}
		return res;
	}

}


public static class MyIO
{
	private static string[] args = null;
	private static int num = -1;
	private static int used = -1;

	private static string getArg()
	{
		if(used == num)
		{
			args = Console.ReadLine().Split(' ');
			num = args.Length;
			used = 0;
		}
		return args[used++];
	}

	public static int GetInt(){ return int.Parse(getArg()); }
	public static long GetLong(){ return long.Parse(getArg()); }
	public static double GetDouble(){ return double.Parse(getArg()); }
	public static string GetString(){ return getArg(); }
}





Measured memory_bytes: 13312
#include<iostream>
using namespace std;
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	int TakAtt,AokiAtt;
	if(c%b!=0){
		TakAtt=c/b+1;
	}
	else{
		TakAtt=c/b;
	}
	if(a%d!=0){
		AokiAtt=a/d+1;
	}
	else{
		AokiAtt=a/d;
	}
	if(TakAtt>AokiAtt){
		cout<<"No\n";
	}
	else{
		cout<<"Yes\n";
	}
	
}

Measured memory_bytes: 3596
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int q = sc.nextInt();
        int[] point = new int[n];

        for(int i = 0;i < q;i++){
            int ans = sc.nextInt()-1;
            point[ans]++;
        }
        
        for(int i = 0;i < n;i++){
            int jdg = k-q+point[i];
            if(jdg > 0){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
        }
    }
}

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

typedef long long ll;
typedef pair<int,int> pii;
int main(){
  int ans = 0;
  int N;
  cin >> N;
  for(int i = 0; i < N; i++){
    int tmp1,tmp2;
    cin >> tmp1 >> tmp2;
    ans += tmp2 - tmp1 + 1;
  }
  cout << ans << endl;
}

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

int main(){
  int M[MAX][MAX],i,j,n,m,p,r;

  scanf("%d",&n);
  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      M[i][j] = 0;
    }
  }
  for(i = 1; i <= n; i++){
    scanf("%d%d",&m,&r);
    for(j = 1; j <= r; j++){
      scanf("%d",&p);
      M[i][p] = 1;
    }
  }

  for(i = 1; i <= n; i++){
    for(j = 1; j <= n; j++){
      printf("%d",M[i][j]);
    if(j == n) break;
    printf(" ");
    }
    printf("\n");
  }
  return 0;
}



Measured memory_bytes: 2056
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <queue>
# define MOD 1000000000+7
# define INF 1000000000
#define rep(i,rept)	for(ll i = 0; i<rept;i++)
typedef long long ll;
using namespace std;
long long int a = 0, b = 0, c = 0, d = 0, e = 0, ans = 0, x = 0, y = 0, z = 0, maxy = -1,maxy2=-1, mini = 999999999, mini2 = 9999999999, counter = 0, endp = 0, checker = 0;
std::string code;
vector<long long int>vec;
long long int N = 0, M = 0,R=0;
long long int costs[201][200*199/2+1],visit[10];

int main() {
	cin >> a >> b;
	if ((a + b) % 2 == 0) {
		cout << (a + b) / 2 << endl;
	}
	else {
		cout << "IMPOSSIBLE" << endl;
	}
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    string s,t;
    cin>>s>>t;
    int i;
    bool flag=true;
    if(s.size()<t.size()){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    int begin=-1;
    for(int i=0;i<=s.size()-t.size();i++){
        flag=true;
        //cout<<s[i]<<endl;
        for(int j=0;j<t.size();j++){
            if(s[i+j]=='?'||s[i+j]==t[j]);
            else flag=false;
        }
        //cout<<flag<<endl;
        if(flag)begin=i;
    }
    if(begin==-1){
        cout<<"UNRESTORABLE"<<endl;
        return 0;
    }
    //cout<<begin<<endl;
    for(int j=begin,k=0;j<begin+t.size();j++,k++){
        s[j]=t[k];
    }
    replace(s.begin(),s.end(),'?','a');
    cout<<s<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int N,K,X,Y,kei;
	scanf("%d %d %d %d",&N,&K,&X,&Y);
	if(N>K)
		kei = K*X+(N-K)*Y;
	else
		kei = N*X;
	printf("%d\n",kei);	
	return 0;
}

Measured memory_bytes: 128