akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int MAXN = 2e5 + 50;
const int INF = 1e18;
int A[MAXN], dp[MAXN][5];
main(){
    int N; cin >> N;
    vector<int> nonzero;
    for (int i=1; i<=N; i++){
        cin >> A[i];
    }
    dp[0][0] = 0;
    dp[0][1] = INF;
    dp[0][2] = INF;
    dp[0][3] = INF;
    dp[0][4] = INF;
    int ans = INF;
    for (int i=1; i<=N; i++){
        dp[i][0] = dp[i-1][0] + A[i];
        dp[i][1] = min(dp[i-1][1], dp[i-1][0]) + (A[i]==0 ? 2 : A[i]%2);
        dp[i][2] = min({dp[i-1][2], dp[i-1][1], dp[i-1][0]}) + (A[i]==0 ? 1 : 1 - A[i]%2);
        dp[i][3] = min({dp[i-1][3], dp[i-1][2], dp[i-1][1], dp[i-1][0]}) + (A[i]==0 ? 2 : A[i]%2);
        dp[i][4] = min({dp[i-1][4], dp[i-1][3], dp[i-1][2], dp[i-1][1], dp[i-1][0]}) + A[i];
        ans = min(ans, dp[i][4]);
        //cout << dp[i][0] << " " << dp[i][1] << " " << dp[i][2] << " " << dp[i][3] << " " << dp[i][4] << "\n";
    }
    cout << min({dp[N][4], dp[N][3], dp[N][2], dp[N][1], dp[N][0]});
}


Measured memory_bytes: 9600
N,K,C = map(int,input().split())
S = input()
dp1 = [0]*N
dp2 = [0]*N

c = 0
if S[0]=='o':
    dp1[0] = 1
    c = C
for i in range(N-1):
    if c==0 and S[i+1]=='o':
        dp1[i+1] = dp1[i]+1
        c = C
    else:
        c = max(0,c-1)
        dp1[i+1] = dp1[i]

c = 0
if S[-1]=='o':
    dp2[-1] = 1
    c = C
for i in range(N-2,-1,-1):
    if c==0 and S[i]=='o':
        dp2[i] = dp2[i+1]+1
        c = C
    else:
        c = max(0,c-1)
        dp2[i] = dp2[i+1]

ans = []
for i in range(N):
    if i==0 or dp1[i]-dp1[i-1]==1:
        if i==N-1 or dp2[i]-dp2[i+1]==1:
            ans.append(i+1)
if dp1[-1]>K:
    ans = []

for i in ans:
    print(i)

Measured memory_bytes: 57056
N=int(input())
data=list(map(int, input().split(' ')))

cnt=0
for value in data:
    if value%2==0:
        if (value % 3 ==0) or (value % 5 == 0):
            None
        else:
            cnt+=1

if cnt!=0:
    print('DENIED')
else:
    print('APPROVED')

Measured memory_bytes: 3060
import java.util.Scanner;
import java.util.Stack;

class Main {

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

    void compute() {
        Scanner sc = new Scanner(System.in);
        int[] group = {0, 2, 0, 1, 0, 1, 0, 0, 1, 0, 1, 0};
        if (group[sc.nextInt() - 1] == group[sc.nextInt() - 1]) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   ll x,n;
   cin>>x>>n;
   ll a[n];
   ll b[10]={0};
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       b[a[i]]=1;
   }
   while(1)
   {
       ll y=x,f=0;
       while(y>0)
       {
           ll z=y%10;
           if(b[z]==1)
           f++;
           y=y/10;
       }
       if(f==0)
       {
           cout<<x;
           exit(0);
       }
       else
       ++x;
   }}
       
   

Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
long long n,x,y,k,i,l[1000009];
int main()
{
	cin>>n>>x>>y;
	for(k=1;k<=n;k++)
	{
		for(i=k+1;i<=n;i++)
		{
			l[min(i-k,min(abs(x-k)+1+abs(i-y),abs(y-k)+1+abs(i-x)))]++;
		}
	}
	for(k=1;k<n;k++)
	{
		cout<<l[k]<<endl;
	}
}

Measured memory_bytes: 256
/*@sh*/
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define pi 3.141592653589
#define pb push_back
#define ld long double
#define rem 1000000007
#define F first
#define S second
#define pii pair<long long,long long>
#define el "\n"
#define sp " "
typedef long long ll;
ll  p = 1000000007;
ll Pow(ll,ll,ll);
ll Pow(ll a,ll b,ll p){
	if(b==0) return 1;
	return !(b%2) ? (Pow(a,b/2,p)%p)*(Pow(a,b/2,p)%p)%p : (a%p)*(Pow(a,b-1,p))%p;
}   
main()
{ 
	// fast io
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);ll i; 
	ll n,w;
	cin>>n>>w;
	vector <ll> dp(w+1),val(n),wt(n);
	for(i=0;i<n;i++)
	cin>>wt[i]>>val[i];
	for(i=0; i < n; i++)  
    for(ll j=w; j>=wt[i]; j--) 
    dp[j] = max(dp[j] , val[i] + dp[j-wt[i]]); 
    cout<<dp[w];
}


Measured memory_bytes: 1024
/*

結果:
*/
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <limits.h>  
#include <stdbool.h>   
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r)
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r)
#define TYPE long long
#define ll long long
#define MEMSET(a) memset(a,0,sizeof(a))
#define MEMSET_U(a) memset(a,-1,sizeof(a))
const int mod = (int)1e09 + 7;
#define PI 3.14159265358979323846;

//#define DEBUG1
//#define DEBUG2
//#define DEBUGF

int in(void) { int i; scanf("%d", &i); return i; }
long long llin(void) { long long i; scanf("%lld", &i); return i; }
double din(void) { double i; scanf("%lf", &i); return i; }
void chin(char s[]) { scanf("%s", s); }

void print(int a) { printf("%d\n", a); }
void llprint(long long a) { printf("%lld\n", a); }
void dprint(double a) { printf("%.10f\n", a); }
void print2(int a, int b) { printf("%d %d\n", a, b); }

long long llmax(long long a, long long b) { return a > b ? a : b; }
long long llmin(long long a, long long b) { return a < b ? a : b; }
double dmax(double a, double b) { return a > b ? a : b; }
int cmp(const void *a, const void *b) { return *(TYPE *)a - *(TYPE *)b; }
int cmp_r(const void *a, const void *b) { return *(TYPE *)b - *(TYPE *)a; }
int char_cmp(const void *a, const void *b) { return strcmp((char *)a, (char *)b); }
int char_cmp_r(const void *a, const void *b) { return strcmp((char *)b, (char *)a); }
void swap(int *a, int *b) { int t = *a; *a = *b; *b = t; }


//int main() {
//	//
//	int ans = 0;
//	int A = in(); 
//	ans = A / 2 * (A - A / 2);
//	print(ans);
//#ifdef DEBUGF
//	getch();
//#endif
//	return 0;
//}

int main() {
	//
	int ans = 0;
	double X1, Y1, X2, Y2;
	scanf("%lf%lf%lf%lf", &X1, &Y1, &X2, &Y2);

	int xd, yd;
	xd = X2 - X1;
	yd = Y2 - Y1;

	int x3, y3, x4, y4;
	x3 = X2 - yd; y3 = Y2 + xd;
	x4 = X1 - yd; y4 = Y1 + xd;

	//printf("x3:\t%d\ty3:\t%d\nx4:\t%d\ty4:\t%d\n", x3, y3, x4, y4);
	printf("%d %d %d %d\n", x3, y3, x4, y4);
	ans = 0;
#ifdef DEBUGF
	getch();
#endif
	return 0;
}


Measured memory_bytes: 256
/*
...........__________                                                                           ___  __
.............|       |                                                                           |   /
.............|       |                                                                           |  /
.............|       |                               |                         __                | /      _______
.............|_______|  _______            _______   |______   ________   /|  /  |               |/       |      |
.............| \               | |      | |          |      |          | / | /   |               |\       |
.............|  \       _______| |      | |_______   |      |   _______|   |/    |               | \      |
.............|   \      |      | |      |         |  |      |  |       |   |     |               |  \     |
...........__|    \__|  |______| |______| ________|  |      |_ |_______|   |     |__|           _|   \__ _|        .

*/
#include<bits/stdc++.h>
using namespace std ;
#define int                 long long
#define ull                 unsigned long long int
#define ld                  long double
#define vi                  vector<int>
#define vii                 vector<pair<int,int>>
#define vvi                 vector<vector<int>>
#define pii                 pair<int,int>
#define prec(x)             fixed<<setprecision(15)<<x
#define all(x)              x.begin(),x.end()
#define rall(x)             x.rbegin(),x.rend()
#define rev(x)              reverse(x.begin(),x.end())
#define mset(a,b)           memset(a,b,sizeof(a))
#define mcpy(a,b)           memcpy(a,b,sizeof(a))
#define fo0(i,n)            for(int i=0,i##end=n;i<i##end;i++)
#define fo1(i,n)            for(int i=1,i##end=n;i<=i##end;i++)
#define fo(i,a,b)           for(int i=a,i##end=b;i<=i##end;i++)
#define foe(i,x)            for(__typeof((x).end())i=(x).begin();i!=(x).end();++i)
#define fre(i,x)            for(__typeof((x).rend())i=(x).rbegin();i!=(x).rend();++i)
#define fast ios_base::sync_with_stdio(false); cin.tie(0);cout.tie(0)
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
const int inf=1e18;const int mod=1e9+7;const int N=2e5+9;
void read_And_write(){
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void raushan_kumar(){
    int d=0,e=0,f=0,g=0,p=0,w=0,flag=0,ans=0,res=0,cnt=0,sum=0;double f1=0.0,f2=0.0,f3=0.0;
    int n;cin>>n;
    int a[n];
    fo0(i,n) cin>>a[i];
    map<int,int> m;
    fo0(i,n){
		ans+=m[i-a[i]]; /*cout<<m[i-a[i]]<<" "<<(i-a[i])<<" "<<(i+a[i])<<endl;*/
		m[i+a[i]]++;    	
    }
    cout<<ans;
}

int32_t main()
{
    read_And_write();fast;int t=1;
    // cin>>t;
    while(t--){raushan_kumar();}
}

Measured memory_bytes: 27860
h, w = map(int, input().split())
n = int(input())
a = list(map(int, input().split()))
b = [0 for _ in range(n)]
b[0] = a[0]
for i in range(1, n):
    b[i] = b[i - 1] + a[i]
ans = [[0 for _ in range(w)] for _ in range(h)]
c, k, m = 0, 0, 0
for i in range(h):
    for j in range(w):
        c += 1
        if b[k] < c:
            k += 1
        if i % 2 == 0:
            ans[i][j] = k + 1
        else:
            ans[i][w - j - 1] = k + 1

for i in range(h):
    print(" ".join(map(str, ans[i])))

Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i0,n) for(int i=i0;i<n;++i)
#define ll long long
#define ALL(x) (x).begin(),(x).end()
#define INF12 1000000000000 //10^12
#define INF9 1000000000 //10^9
#define MOD 10000007 //10^9+7


int main() {
    ll N;
    cin >> N;
    ll ans = (N-1) * N / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define itn int
#define REP(i, n) for (ll i = 0; i < n; i++)
#define IREP(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i < b + 1; i++)
#define all(v) v.begin(), v.end()
#define SENTINEL 2000000000
#define NIL -1
using namespace std;
typedef long long ll;

const ll MAX = 510000;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template <class T>inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}


int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    int ans=0;
    REP(i,n){
        cin >> a[i];
        if(i%2==0&&a[i]%2==1){
            ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long N, count = 0;
  cin >> N;
  if (N % 2 == 1) {
    cout << 0 << endl;
  }
  else {
    long NK = N / 2;
    while (NK > 0) {
      NK = (NK - NK % 5) / 5;
      count += NK;
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class Program
{
    static void Main()
    {
        var VE = ReadLine().Split().Select(int.Parse).ToArray();
        var V = VE[0];
        var E = VE[1];
        var graph = new List<int>[V];
        for (int i = 0; i < graph.Length; i++)
        {
            graph[i] = new List<int>();
        }
        for (int i = 0; i < E; i++)
        {
            var st = ReadLine().Split().Select(int.Parse).ToArray();
            graph[st[0]].Add(st[1]);
        }

        var ans = StronglyConnectedComponentDeconpositon(graph);


        var Q = int.Parse(ReadLine());
        var sb = new System.Text.StringBuilder(Q*2);


        for (int i = 0; i < Q; i++)
        {
            var uv = ReadLine().Split().Select(int.Parse).ToArray();
            sb.AppendLine(ans[uv[0]] == ans[uv[1]] ? "1" : "0");
        }
        Write(sb);
    }

    public static int[] TSort(List<int>[] G)//dfs木帰りがけ順
    {
        var r = new int[G.Length];
        var visited = new bool[G.Length];
        var a = G.Length;


        Action<int> DFS = null;
        DFS = v =>
          {
              if (visited[v]) return;
              visited[v] = true;
              foreach (var u in G[v])
              {
                  DFS(u);
              }
              r[--a] = v;
          };


        for (int i = 0; i < G.Length; i++)
        {
            DFS(i);
        }
        return r;


#if false
        void DFS(int v)
        {
            if (visited[v]) return;
            visited[v] = true;
            foreach (var u in G[v])
            {
                DFS(u);
            }
            r[--a] = v;
        }
#endif
    }

    public static List<int>[] Reverse(List<int>[] G)
    {
        var R = new List<int>[G.Length];
        for (int i = 0; i < R.Length; i++)
        {
            R[i] = new List<int>();
        }
        for (int i = 0; i < R.Length; i++)
        {
            for (int j = 0; j < G[i].Count; j++)
            {
                R[G[i][j]].Add(i);
            }
        }
        return R;
    }

    public static int[] StronglyConnectedComponentDeconpositon(List<int>[] G)//バグ
    {
        var R = Reverse(G);
        var order = TSort(G);

        var r = new int[R.Length];
        var s = new Stack<int>();
        var visited = new bool[R.Length];
        var l = 0;
        var a = 0;
        while (l != R.Length)
        {
            
            s.Push(order[l]);
            while (s.Count != 0)
            {
                var v = s.Pop();
                if (visited[v]) continue;
                visited[v] = true;
                r[v] = a;
                foreach (var u in R[v])
                {
                    if (!visited[u])
                    {
                        s.Push(u);
                    }
                }
            }
            s.Clear();
            a++;
            while (l<R.Length&&visited[order[l]])
            {
                l++;
            }
        }
        return r;
    }
}



Measured memory_bytes: 26900
#include<stdio.h>
#include<map>
#include<queue>
#define INF 10000000
using namespace std;
typedef pair<int,int> P;
int h,w;
bool pos[1000][1000];
int d[1000][1000];
P p[10];
queue<P> que;
int dx[4]={-1,0,1,0};
int dy[4]={0,1,0,-1};
int bfs(P s,P g){
	int i,j;
	for(i=0;i<h;i++)for(j=0;j<w;j++)d[i][j]=INF;
	d[s.first][s.second]=0;
	que.push(s);
	while(!que.empty()){
		P x=que.front();que.pop();
		for(i=0;i<4;i++){
			int nx=x.first+dx[i];
			int ny=x.second+dy[i];
			if(nx>=0&&nx<h&&ny>=0&&ny<w&&pos[nx][ny]&&d[nx][ny]==INF){
				d[nx][ny]=d[x.first][x.second]+1;
				que.push(P(nx,ny));
			}
		}
	}
	return d[g.first][g.second];
}
int main(){
	int n;
	int i,j;
	scanf("%d %d %d",&h,&w,&n);
	for(i=0;i<h;i++)for(j=0;j<w;j++)pos[i][j]=true;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			char c;
			scanf(" %c",&c);
			if(c=='X')pos[i][j]=false;
			if(c=='S')p[0]=P(i,j);
			if(c>='1'&&c<='9')p[c-'0']=P(i,j);
		}
	}
	int ans=0;
	for(i=0;i<n;i++){
		ans+=bfs(p[i],p[i+1]);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5928
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a,b,c;
	cin>>a>>b>>c;
	if(a=='A'&&b=='A'&&c=='A'){
		cout<<"No"<<endl;
	}else if(a=='B'&&b=='B'&&c=='B'){
		cout<<"No"<<endl;
	}else{
		cout<<"Yes"<<endl;
	}
	return 0;
} 

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional> // for less 
#define pb push_back
#define For(i,s,e) for (ll i=(s); i<(e); i++)
#define Debug_array(a,n) for (ll i=(0); i<(n); i++) cout<<a[i]<<" "
#define Foe(i,s,e) for (ll i=(s); i<=(e); i++)
#define Fod(i,s,e) for (ll i=(s)-1; i>=(e); i--)
#define Mod 1000000007
#define pii pair<ll,ll>
#define fi first
#define se second
#define endl "\n"
#define mp make_pair
#define big_prime 15486277
#define bigger_prime 179424697
#define biggest_prime 32416188691
//#define random_shuffle(indices.begin(), indices.end());
//std::random_device rd;
//std::mt19937 g(rd());
//std::shuffle(v.begin(), v.end(), g);
using namespace __gnu_pbds; 
using namespace std;

typedef long long ll;
typedef tree<ll, null_type, less<ll>, rb_tree_tag,tree_order_statistics_node_update> ordered_set; 

#define MAX 5002

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	cout<<setprecision(8)<<fixed;
	double w,h,x,y;cin>>w>>h>>x>>y;

	if(abs(w-x)+abs(h-y)==abs(x)+abs(y)){
		cout<<(w*h)/(2.0)<<" "<<1<<endl;
	}else{
		cout<<(w*h)/(2.0)<<" "<<0<<endl;
	}











	
}

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

int main()
{
    int a, b;
    cin >> a >> b;
  	if(a == 1) a = 14;
  	if(b == 1) b = 14;
    if (a > b)
        cout << "Alice" << endl;
  	else if (a == b)
      	cout << "Draw" << endl;
    else
        cout << "Bob" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<bitset>
using namespace std;
const int maxn = 5005;
const int inf = 0x3f3f3f3f;
typedef long long ll;
int a[maxn];
int n , k;
int b[maxn];
bitset<maxn> dp;
int judge(int x)
{
    if(a[x]>=k) return 1;
    ///剔除当前数，剩余的数dp一发；存在性判断.
    dp.reset();
    dp[0] = 1;
    for(int i = 0; i < n; i++){
        if(i==x) continue;
        dp|=(dp<<a[i]);//cout<<dp<<endl;
    }
    for(int i = k-1; i >= k-a[x]; i--){
        if(dp[i]){
            return 1;
        }
    }
    return 0;
}
int solve()
{

    sort(a,a+n);

    int lo = -1, hi = n;
    while(hi-lo>1){
        int m = (lo+hi)/2;
        if(judge(m)) hi = m;
        else lo = m;
    }
    return hi;

//    int lo = 0, hi = n-1;
//    int mas = -1;///这里必须-1，因为我后面+1了，如果不这样的话，结果>=1;
//    while(lo<=hi){
//        int m = (lo+hi)/2;
//        if(judge(m)) hi = m-1;
//        else{
//            lo = m+1;
//            mas = max(mas,m);
//        }
//    }
//    return mas+1;///下标是mas，所以要再加一；
}
int main()
{
    while(scanf("%d%d",&n,&k)==2)
    {
        for(int i = 0; i < n; i++){
            scanf("%d",&a[i]);
        }
        printf("%d\n",solve());
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#pragma warning(disable : 4996)
using namespace std;
int n, m;
int main() {
	scanf("%d%d", &n, &m);
	bool f = m > n;
	if (f) m = 2 * n - m;
	if (m == 1) printf("No\n");
	else {
		printf("Yes\n");
		vector<int> v;
		for (int i = 1; i <= n; i++) v.push_back(m + i - 2);
		for (int i = 1; i <= 2 * n - 1; i++) {
			if (!(m - 1 <= i && i < m + n - 1)) v.push_back(i);
		}
		sort(v.begin(), v.begin() + n, greater<int>());
		sort(v.begin() + n, v.end(), greater<int>());
		if (f) {
			for (int i = 0; i < 2 * n - 1; i++) v[i] = 2 * n - v[i];
		}
		for (int i = 0; i < 2 * n - 1; i++) {
			if (i) printf(" ");
			printf("%d", v[i]);
		}
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 2420
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#define ll long long int
#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
using namespace std;
int mx4[] = {0,1,0,-1};
int my4[] = {1,0,-1,0};
int mx2[] = {1,0};
int my2[] = {0,1};

class ABA {
public:
	void solve(istream& in, ostream& out) {
        int a,b;
        in >> a >> b;
        if(b % a == 0) out << a + b << endl;
        else out << b - a << endl;
	}
};

int main() {
	ABA solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

int main() {
	string s;
	cin>>s;
	int l = 0;
	int r = s.size()-1;
	int cnt = 0;
	while(l<=r) {
		if(s[l]!=s[r]) {
			cnt++;
		}
		l++;
		r--;
	}
	cout << cnt;
	return 0;
}

Measured memory_bytes: 256
#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 n;
  cin >> n;
  vector<int>a(n);
  rep(i,n) cin >> a[i];
  string ans = "APPROVED";
  rep(i,n){
    if ( a[i]%2 != 0 )continue;
    if ( a[i]%3 != 0 && a[i]%5 != 0 ) {
      ans = "DENIED";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<bitset>
#include<string.h>
#define For(i,a,b) for(register int i=a;i<=b;i++)
using namespace std;
const int maxn=1e5+1000;
int n,m,pos[maxn],x[maxn],cf[maxn],a,s[maxn];
long long ans[maxn],k;
bitset <maxn> vis;
inline void swap(int &a,int &b){int c=a;a=b;b=c;}

inline int rd(){
		int ans=0,f=1;char c=getchar();
		while(!isdigit(c)){ f^=(c=='-'); c=getchar(); }
		for(;isdigit(c);c=getchar()) ans=(ans<<1)+(ans<<3)+(c^48); return f?ans:-ans;
}
/*inline void pr(long long x){
    if(x<0){putchar('-');x=~(x-1);}
    int s[30],top=0;
    while(x){s[++top]=x%10;x/=10;}
    if(!top)s[++top]=0;
    while(top)putchar(s[top--]+'0');
}*/

signed main(){
	//scanf("%d",&n);
	n=rd();
	For(i,1,n){
		x[i]=rd();
		//scanf("%d",&x[i]);
		pos[i]=i;
		cf[i]=x[i]-x[i-1];
	}
	m=rd();scanf("%lld",&k);
	//scanf("%d%lld",&m,&k);
	For(i,1,m){
		//scanf("%d",&a);
		a=rd();
		swap(pos[a],pos[a+1]);
	}
	For(i,1,n){
		if(vis[i]){
			continue ;
		}
		int cnt=0;
		for(int j=i;!vis[j];j=pos[j]) {
			s[++cnt]=j;
			vis[j]=1;
		}
		For(j,1,cnt) {
			ans[s[j]]=1ll*cf[s[(k+j-1)%cnt+1]];
		}
	}
	For(i,1,n){
		ans[i]+=ans[i-1];
		printf("%lld",ans[i]);
		//pr(ans[i]);
		putchar('.');
		putchar('0');
		putchar('\n');
	}
	return 0;
}


Measured memory_bytes: 3712
import java.io.*;
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner in = new Scanner(System.in);
		int L = in.nextInt();
		/*
		 let a, b, and c represent the side lengths
		 a + b + c = L
		 volume = a*b*c
		 according to the AM-GM inequality:
		 (a*b*c)^(1/3) <= (a+b+c)/3
		 (a*b*c)^(1/3) <= L/3
		 a*b*c <= (L/3)^3
		 */
		System.out.printf("%.15f\n", ((double)L*L*L)/27.0);
	}
}


Measured memory_bytes: 21460
//
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long int tt;
    tt = 1;
    while (tt--)
    {
        int n, i, j, k, count = 0;
        cin >> n;
        int a[n + 1];
        for (i = 1; i <= n; i++)
        {
            cin >> a[i];
        }
        for (i = 1; i <= n; i++)
        {
            for (j = i + 1; j <= n; j++)
            {
                if (a[i] != a[j])
                {
                    for (k = j + 1; k <= n; k++)
                    {
                        if (a[k] != a[i] && a[k] != a[j])
                        {
                            if (a[i] + a[j] <= a[k] || a[i] + a[k] <= a[j] || a[j] + a[k] <= a[i])
                            {
                                continue;
                            }
                            else
                            {
                                count++;
                            }
                        }
                    }
                }
            }
        }
        cout << count << " " << endl;
    }
    return 0;
}

Measured memory_bytes: 3620
import Data.Bits
import Data.List
import qualified Data.Vector.Unboxed as VU

modulus :: Int
modulus = 10 ^ 9 + 7

addMod :: Int -> Int -> Int
addMod x y = (x + y) `mod` modulus

mulMod :: Int -> Int -> Int
mulMod x y = (x * y) `mod` modulus

powMod :: Int -> Int -> Int
powMod _ 0 = 1
powMod n m
    | m .&. 1 == 0 = mulMod x x
    | otherwise = mulMod n . powMod n $ m - 1 where
          x = powMod n $ m `div` 2

newFacts :: Int -> VU.Vector Int
newFacts n =
  VU.scanl (\x y -> if x == 0 then 1 else mulMod x y) 1 $ VU.enumFromTo 1 $ n - 1

invFacts :: Int -> VU.Vector Int -> Int
invFacts 0 facts = 1
invFacts x facts =
  if x == 0 then 1 else powMod (facts VU.! x) $ modulus - 2

cmb :: Int -> Int -> VU.Vector Int -> Int
cmb x y facts = (facts VU.! (x + y)) `mulMod` (invFacts x facts) `mulMod` (invFacts y facts)

routesVia :: Int -> Int -> Int -> Int -> VU.Vector Int -> Int
routesVia x y w h facts =
  (cmb x y facts) `mulMod` (cmb x' y' facts)
  where
    x' = w - x
    y' = h - y

allRoutes :: Int -> Int -> Int -> Int -> VU.Vector Int -> Int
allRoutes h w a b facts =
  foldl'
    (\acc x -> acc `addMod` routesVia (b+x) (h-a-1-x) (w-1) (h-1) facts)
    0
    [0..(h-a-1) `min` (w-b-1)]

main = do
  [h, w, a, b] <- map (read :: String -> Int) . words <$> getLine
  let facts = newFacts(h+w-2)
  putStrLn $ show $ allRoutes h w a b facts

Measured memory_bytes: 5116
object Main {

  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    val N = sc.nextInt()

    // 締め切り順にソート
    val AB: Array[(Long, Long)] =
      Array.fill(N)((sc.nextLong(), sc.nextLong())).sortBy(_._2)

    // 既に, 期限が過ぎていれば, 失敗.
    // まだ 期限が過ぎていなければ 次に進める.
    // どちらにせよ, 全ての仕事を終わらせる必要がある.
    // 短いものを先にやるのと, あとでやるのとでは, その仕事自体の成功には関係ない
    def solve(): Boolean = {
      var i = 0L
      AB.foreach { case (a, b) =>
        if (i + a > b) {
          return true
        }
        i += a
      }
      false
    }

    println(if (solve()) "No" else "Yes")
  }

}

Measured memory_bytes: 128188
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n))
#define Vec(a,n) vector<string> (a)((n))
using namespace std;
signed main(){
	string s,t;
	cin >> s >> t;
	int n = s.size();
	int m = t.size();
	int a = 1;
	for(int i=n-m;i >= 0;i--){
		REP(j,m){
			if(s[i+j] != t[j] && s[i+j] != '?'){
				a = 0;
				continue;
			}
		}
		if(a == 1){
			REP(k,i){
				if(s[k] == '?'){
					cout << "a";
				}
				else cout << s[k];
			}
			cout << t;
			FOR(l,i+m,n){
				if(s[l] == '?'){
					cout << "a";
				}
				else cout << s[l];
			}
          a=2;
			break;
		}
      a = 1;
	}
	if(a == 1){
		cout << "UNRESTORABLE" << endl;
	}

    return 0;
}


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

//input
int N, A;
int x[51];

long long  dp[51][51][2510] = {0};

int main() {
    cin >> N >> A;
    for (int i = 0; i < N; ++i) cin >> x[i];
    dp[0][0][0] = 1;
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j <= i + 1; ++j) {
            for (int k = 0; k <= A * N; ++k) {
                dp[i+1][j][k] = dp[i][j][k];
                if (j - 1 >= 0 && k - x[i] >= 0) {
                    dp[i+1][j][k] += dp[i][j-1][k-x[i]];
                }
            }
        }
    }
    long long ans = 0;
    for (int i = 1; i <= N; ++i) {
        ans += dp[N][i][i*A];
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 49280
#include<bits/stdc++.h>
#define fi first
#define se second
#define int long long
using namespace std;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int a,b=0,c=0;
  int r=0,l=0;
  string d,e;
  cin>>a;
  cin>>d;
  for(int i=0;i<a;i++){
    if(d[i]==')'){
      if(b) b--;
      else c++;
    }
    else b++;
  }
  for(int i=0;i<c;i++){
    cout<<"(";
  }
  c=0,b=0;
  cout<<d;
  for(int i=a-1;i>=0;i--){
    if(d[i]=='('){
      if(b) b--;
      else c++;
    }
    else b++;
  }
  for(int i=0;i<c;i++) cout<<")";
  cout<<"\n";
}
  

Measured memory_bytes: 256
from collections import defaultdict

N=int(input())
A=list(map(int,input().split()))
count=defaultdict(int)
ans=0
for i in range(N):
    count[A[i]]+=1
    ans+=A[i]

Q=int(input())
for _ in range(Q):
    B,C=map(int,input().split())
    ans-=B*count[B]
    ans+=C*count[B]
    count[C]+=count[B]
    count[B]=0
    print(ans)

Measured memory_bytes: 24272
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(s,i, n) for (int i = (int)s; i < (int)(n); i++)
#define pb push_back
typedef long long ll;
  
int main(){
    int n;
    cin>>n;
    vector<int> p;
    rep(i,n){
        int a;
        cin>>a;
        p.pb(a);
    }
    int ans=0;
    for(int i=0;i<n-2;i++){
        if(p[i]<p[i+1] &&p[i+1]<p[i+2])ans++;
        else if(p[i]>p[i+1] &&p[i+1]>p[i+2])ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


int main(){
  
  ll x,k,d;
  cin >> x >> k >> d;
  x = abs(x);
  ll a = (x+d-1)/d;
  if(a > k){
    cout << abs(x-k*d) << "\n";
  }else{
    if((a & 1) == (k & 1))cout << abs(x-a*d) << "\n";
    else cout << abs(x-(a-1)*d) << "\n";
  }



  return 0;
}

Measured memory_bytes: 3632
n,W=map(int,input().split())
l=[list(map(int,input().split())) for _ in range(n)]
w1=l[0][0]
l.sort(key=lambda x : x[1]*-1)
l0,l1,l2,l3 = [],[],[],[]
for w,v in l:
    if w==w1:
        l0.append(v)
    if w==w1+1:
        l1.append(v)
    if w==w1+2:
        l2.append(v)
    if w==w1+3:
        l3.append(v)
sl1,sl2,sl3,sl0=[0],[0],[0],[0]
tl=0
for i in range(len(l0)):
    tl += l0[i]
    sl0.append(tl)
tl=0
for i in range(len(l1)):
    tl += l1[i]
    sl1.append(tl)
tl=0
for i in range(len(l2)):
    tl += l2[i]
    sl2.append(tl)
tl=0
for i in range(len(l3)):
    tl += l3[i]
    sl3.append(tl)
res = 0
for a in range(len(sl0)):
    for b in range(len(sl1)):
        for c in range(len(sl2)):
            for d in range(len(sl3)):
                if w1*a+(w1+1)*b+(w1+2)*c+(w1+3)*d <= W:
                    res = max(res,sl0[a]+sl1[b]+sl2[c]+sl3[d])
print(res)

Measured memory_bytes: 40944
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    int a[n];
    rep(i,n){
        cin >> a[i];
        a[i]--;
    }
    int ans = 0;
    rep(i,n){
        if(i==a[a[i]]) ans++;
    }
    cout << ans/2 << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 40005
#define eps 1e-12
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
	res = 0;T f = 1;char c = getchar();
	while(c < '0' || c > '9') {
		if(c == '-') f = -1;
		c = getchar();
	}
	while(c >= '0' && c <= '9') {
		res = res * 10 + c - '0';
		c = getchar();
	}
	res *= f;
}
template<class T>
void out(T x) {
	if(x < 0) {x = -x;putchar('-');}
	if(x >= 10) {
		out(x / 10);
	}
	putchar('0' + x % 10);
}
const db PI = acos(-1.0);
int N,id[MAXN],tr[MAXN];
int64 ALL;
db A[MAXN],B[MAXN],C[MAXN];
pair<db,int> t[MAXN];
int lowbit(int x) {
	return x & (-x);
}
void Insert(int x) {
	while(x <= N) {
		tr[x]++;
		x += lowbit(x);
	}
}
int Query(int x) {
	int res = 0;
	while(x > 0) {
		res += tr[x];
		x -= lowbit(x);
	}
	return res;
}
bool dcmp(db a,db b) {
	return fabs(a - b) < eps;
}
void Calc_y() {
	for(int i = 1 ; i <= N ; ++i) {
		t[i] = mp(atan2(-A[i],B[i]),i);
		if(t[i].fi < 0) t[i].fi += PI;
	}
	sort(t + 1,t + N + 1);
	for(int i = 1 ; i <= N ; ++i) id[t[i].se] = i;
	db L = -1e9,R = 1e9;
	int cnt = 200;
	while(cnt--) {
		db mid = (L + R) * 0.5;
		int64 res = 0;
		for(int i = 1 ; i <= N ; ++i) {
			t[i] = mp((C[i] - B[i] * mid) / A[i],id[i]);
		}
		sort(t + 1,t + N + 1);
		int p = N + 1;
		memset(tr,0,sizeof(tr));
		for(int i = N ; i >= 1 ; --i) {
			if(i != N && !dcmp(t[i + 1].fi,t[i].fi)) {
				res += 1LL * (p - i - 1) * (p - i - 2) / 2;
				for(int j = p - 1 ; j >= i + 1; --j) {
					Insert(t[j].se);
				}
				p = i + 1;
			}
			res += Query(t[i].se - 1);
		}
		res += 1LL * (p - 1) * (p - 2) / 2;
		if(res >= (ALL + 1) / 2) R = mid;
		else L = mid;
	}
	printf("%.10lf",R);
}
void Calc_x() {
	for(int i = 1 ; i <= N ; ++i) {
		t[i] = mp(atan2(-A[i],B[i]),i);
		if(t[i].fi < 0) t[i].fi += PI;
		if(t[i].fi * 2 > PI) t[i].fi -= PI;
	}
	sort(t + 1,t + N + 1);
	for(int i = 1 ; i <= N ; ++i) id[t[i].se] = i;
	db L = -1e9,R = 1e9;
	int cnt = 200;
	while(cnt--) {
		db mid = (L + R) * 0.5;
		int64 res = 0;
		for(int i = 1 ; i <= N ; ++i) {
			t[i] = mp((C[i] - A[i] * mid) / B[i],id[i]);
		}
		sort(t + 1,t + N + 1);
		int p = 0;
		memset(tr,0,sizeof(tr));
		for(int i = 1 ; i <= N ; ++i) {
			if(i != 1 && !dcmp(t[i - 1].fi,t[i].fi)) {
				res += 1LL * (i - 1 - p) * (i - 1 - p - 1) / 2;
				for(int j = p + 1 ; j <= i - 1 ; ++j) {
					Insert(t[j].se);
				}
				p = i - 1;
			}
			res += Query(t[i].se - 1);
		}
		res += 1LL * (N - p) * (N - p - 1) / 2;
		if(res >= (ALL + 1) / 2) R = mid;
		else L = mid;
	}
	printf("%.10lf",R);
}
void Solve() {
	read(N);
	for(int i = 1 ; i <= N ; ++i) {
		scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
	}
	ALL = 1LL * N * (N - 1) / 2;
	Calc_x();space;Calc_y();enter;
}
int main() {
#ifdef ivorysi
	freopen("f1.in","r",stdin);
#endif
	Solve();
}


Measured memory_bytes: 2432
N = int(input())

out=10**10
for A in range(1,int(N**(1/2))+2):
    if N%A == 0:
        B = N//A
        KA, KB = len(str(A)), len(str(B))
        dam = max(KA,KB)
        out=min(out,dam)

print(out)

Measured memory_bytes: 64888
#include<stdio.h>

int main(void){
    
    int A,B,C,ans;
    scanf("%d %d %d",&A,&B,&C);

    ans = C - (A - B);
  	if(ans < 0){
      printf("0");
    }else{
      printf("%d",ans);
    }
    return 0; 
}

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

bool binary_search(vector<int>A, int n, int key) {
  int left = 0;
  int right = n;
  int mid;
  while (left < right) {
    mid = (left + right) / 2;
    if (A.at(mid) == key) return 1;
    if (key > A.at(mid))
      left = mid + 1;
    else if (key < A.at(mid))
      right = mid;
  }
  return 0;
}

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  
  int M;
  cin >> M;
  vector<int> B(M);
  int sum = 0;
  for (int i = 0; i < M; i++) {
    cin >> B.at(i);
    if (binary_search(A, N, B.at(i))) sum++;
  }

  cout << sum << endl;
}


Measured memory_bytes: 3860
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb push_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}

int main(){
    ll n;cin>>n;
    vvi v(n,vi(n));
    vi dp(1<<n);
    rep(i,n)rep(j,n)cin>>v[i][j];
    vb used(1<<n,false);
    queue<ll> q;
    q.push(0);
    dp[0]=1;
    while(!q.empty()){
        ll i=q.front();q.pop();
        int cnt=0;
        rep(j,n)if(i>>j&1)cnt++;
        if(cnt==n)break;
        rep(j,n)if(!(i>>j&1)){
            if(v[cnt][j]){
                dp[i+(1<<j)]=(dp[i+(1<<j)]+dp[i])%mod;
                if(!used[i+(1<<j)]){
                    used[i+(1<<j)]=true;
                    q.push(i+(1<<j));
                }
            }
        }
    }
    out(dp[(1<<n)-1]);
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int b[n];
    for (int i=0; i<n; i++){
        cin >> a[n-i-1];
    }
    for (int i=0; i<n; i++){
        if (i%2==0){
            b[i/2]=a[i];
        }
        else {
            b[n-i/2-1]=a[i];
        }
    }
    for (int i=0; i<n-1; i++){
        cout << b[i] << " " ;
    }
    cout << b[n-1];
}

Measured memory_bytes: 3712
#include <iostream>

using namespace std;

int main(){
	int a,b,x,i;
	char op;
	i=0;
	
	
	for(i;;i++){
	cin >> a >> op >> b;
	
	if(op=='?'){
		break;
	}
			
	if(op=='+'){
		x=a+b;
	}
	else if(op=='-'){
		x=a-b;
	}
	else if(op=='*'){
		x=a*b;
	}
	else if(op=='/'){
		x=a/b;
	}
	
	else{
		break;
	}
		
	cout << x << endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,l,n) for(int i=l; i<n; ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using mii = map<int,int>;
using pii = pair<int,int>;
using vpii = vector<pair<int,int>>;
using ti3 = tuple<int,int,int>;

int main(){
  ll n,m,x; cin>>n>>m>>x;
  vi a(m);
  REP(i,m) cin>>a[i];
  ll cost0=0,cost1=0;
  REP(i,m){
    if(a[i]<x) cost0+=1;
    else cost1+=1; 
  }
  cout<<min(cost0,cost1)<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define sz(x) ll(x.size())
using namespace std;

int main() {
  ll n,ans;
  cin >> n;
  vector<ll>a(n); vector<ll>b(n); vector<ll>c(n);
  cin >> a.at(0); b.at(0)=a.at(0);
  rep(i,n-1){
  	cin >> a.at(i+1);
  	b.at(i+1)=b.at(i)+a.at(i+1);
  }
  rep(i,n) c.at(i)=b.at(n-1)-b.at(i);
  ans=abs(b.at(n-2)-c.at(n-2));
  rep(i,n-2) ans=min(ans,abs(b.at(i)-c.at(i)));
  cout << ans << endl;
}


Measured memory_bytes: 4992
#include <iostream>

int main() {
  int A,B,K;
  std::cin >> A >> B >> K;
  int cnt = 0;
  for(int i=std::min(A,B);i>0;i--){
    if(A%i==0 && B%i==0)
      cnt++;
    if(cnt==K) {
      std::cout << i << std::endl;        
      break;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std ;
typedef long long ll ;
int main()
{
  int n ;
  cin >> n ;
   ll mx = 0,mn = INT_MAX ;
   while(n--)
   {
      ll x,y ;
      cin >> x >> y ;
      if(x > mx)
      mx = x ; 
      if(y < mn)
      mn = y ;
     }
    cout << mx+mn << endl;
   return 0 ;
}
  

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

int main(){
  int n, i, j, u, adj, num;

  scanf("%d", &n);

  int ans[n+1][n+1];

  for( i=0; i<n+1; i++){
    for( j=0; j<n+1; j++){
      ans[i][j] = 0;
    }
  }

  for( i=0; i<n; i++){
    scanf("%d %d", &u, &adj);
    if( adj == 0 )continue;

    for( j=0; j<adj; j++){
      scanf("%d", &num);
      ans[u][num] = 1;
    }
 }

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

  return 0;
}

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

inline long long read()
{
	long long x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}

long long S;
signed main()
{
	S=read();
	long long t=S/1000000000ll+1ll;
	if(S==1000000000000000000) puts("0 0 0 1000000000 1000000000 0");
	else printf("0 0 1 1000000000 %lld %lld\n",t,1000000000ll-S%1000000000ll);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000

int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j,max = 0;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */

  for(i = 0;i <= VMAX;i++) C[i] = 0;

  for(i = 0;i < n;i++){
    scanf("%hu",&A[i+1]);
    C[A[i+1]]++;
  }
 
  for(i = 1; i< VMAX + 1;i++) C[i] = C[i] + C[i-1];
  
  for(j = 1;j <= n;j++){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }


  for(i = 1;i<n+1;i++){
    printf("%d",B[i]);
    if(i != n) printf(" ");
  }

  printf("\n");
  return 0;
}



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

int main()
{
	long long n, k; cin >> n >> k;
	long long ans = 0;
	for (long long b = k + 1; b <= n; b++) {
		long long m = n / b;
		ans += (b - k) * m;
		ans += max(n - (b * m + k - 1), 0LL);
		ans -= (k == 0 ? 1 : 0);		
	}
	cout << ans << endl;

	return 0;
}

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

int main(){
  vector<int> a(3);
  cin >> a.at(0) >> a.at(1) >> a.at(2);

  sort(a.begin(), a.end());
  int x=a.at(2)*2-a.at(1)-a.at(0);
  if(x%2==0) cout << x/2 << endl;
  else cout << x/2+2 << endl;
}


Measured memory_bytes: 256
//teja349
#include <bits/stdc++.h>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <climits>
#include <utility>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <iomanip> 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx


using namespace std;
#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll long long
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >

//std::ios::sync_with_stdio(false);
set<string> seti;
string s,t;   
int match(int val){
	if(val+t.length()>s.length())
		return 0;
	//cout<<val<<endl;
	//val=2;
	string boo=s;
	int i;
	rep(i,t.length()){
		if(boo[val+i]=='?'){
			boo[i+val]=t[i];
		}
		else if(boo[val+i]!=t[i]){
			//cout<<boo[val+i]<<endl;
			return 0;
		}
	}
	rep(i,s.length()){
		if(boo[i]=='?')
			boo[i]='a';
	}
	//cout<<boo<<endl;
	seti.insert(boo);
	return 0;
}
int main(){
    std::ios::sync_with_stdio(false);
    //string s,t;
    cin>>s>>t;
    int i;
    rep(i,s.length()){
    	match(i);
    }
    if(seti.empty()){
    	cout<<"UNRESTORABLE"<<endl;
    }
    else{
    	cout<<*seti.begin()<<endl;
    }
    return 0;  
    
}



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

using namespace std;

string solve(vector<int>& xs, int k)
{
    for (int i = 0; i < 5; i++)
    {
        for (int j = i + 1; j < 5; ++j)
        {
            if (xs[j] - xs[i] > k)
            {
                return ":(";
            }
        }
    }
    return "Yay!";
}

int main()
{
    ios::sync_with_stdio(false);

    vector<int> xs(5);

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

    int k;
    cin >> k;

    auto ans = solve(xs, k);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#define MAXN 200010
#define LL long long

const LL P=1000000007;

LL getPow(LL x,LL y){
	LL res=1;
	while(y){
		if(y&1) res=res*x%P;
		x=x*x%P;
		y>>=1;
	}
	return res;
}

int n;
LL c[MAXN],w[MAXN],l1,l2;
LL fac[MAXN],invfac[MAXN];
LL min_w[MAXN],min_tot,sec_min=1LL<<40,min_c;
bool use[MAXN];
LL usecnt[MAXN];

LL getC(LL x,LL y){
	if(x<y) return 0;
	return fac[x]*invfac[y]%P*invfac[x-y]%P;
}

void init(){
	fac[0]=1;
	for(int i=1;i<MAXN;i++) fac[i]=fac[i-1]*i%P;
	invfac[MAXN-1]=getPow(fac[MAXN-1],P-2);
	for(int i=MAXN-2;i>=0;i--) invfac[i]=invfac[i+1]*(i+1)%P;
}

int main(){
#ifdef DEBUG
	freopen("D.in","r",stdin);
#endif
	scanf("%d%lld%lld",&n,&l1,&l2);
	init();
	for(int i=1;i<=n;i++) scanf("%lld%lld",c+i,w+i);
	min_tot=w[1]; min_c=c[1];
	for(int i=2;i<=n;i++) if(w[i]<min_tot) min_tot=w[i],min_c=c[i];
	use[min_c]=1;
	min_w[min_c]=min_tot;
	for(int i=1;i<=n;i++)
		if(c[i]!=min_c && w[i]+min_tot<=l2){
			if(!use[c[i]]) use[c[i]]=1,min_w[c[i]]=w[i];
			if(w[i]<min_w[c[i]]) min_w[c[i]]=w[i];
		}
	for(int i=1;i<=n;i++) if(c[i]!=min_c && w[i]<sec_min) sec_min=w[i];
	for(int i=1;i<=n;i++)
		if(c[i]==min_c){
			if(w[i]+min_w[c[i]]<=l1 || w[i]+sec_min<=l2) 
				usecnt[c[i]]++;
		}else if(use[c[i]]){
			if(w[i]+min_w[c[i]]<=l1 || w[i]+min_tot<=l2)
				usecnt[c[i]]++;
		}
	LL m=0;
	for(int i=1;i<=n;i++) m+=usecnt[i];
	LL ans=1;
	for(int i=1;i<=n;i++)
		if(usecnt[i]){
			ans=ans*getC(m,usecnt[i])%P;
			m-=usecnt[i];
		}
	printf("%lld\n",ans);
}


Measured memory_bytes: 9728
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
 
using namespace std;
using ll = long long;
 
void _cin(){} template <class Head, class... Tail> void _cin(Head&& head, Tail&&... tail){ cin >> head; _cin(forward<Tail>(tail)...); }
void _cout(){ cout << "\n"; } template <class Head, class... Tail> void _cout(Head&& head, Tail&&... tail){ cout << head; _cout(forward<Tail>(tail)...); }
ll gcd(ll a, ll b){ return (b == 0) ? a : gcd(b, a % b); }
ll lcm(ll a, ll b){ return a/gcd(a, b)*b; };
 
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Rep(n) For(_, n)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) (find(Range(c), x) != c.end())
#define Search(rb, re, x) distance(rb, find(rb, re, x))
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Unique(a) a.erase(unique(Range(a)), a.end());
#define Reverse(c) reverse(Range(c))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, ...) T __VA_ARGS__; _cin(__VA_ARGS__)
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; Rep(n){ Cin(T, x); map[x] ++; }
#define Cout(...) _cout(__VA_ARGS__)
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Coutyn(cond) Cout((cond) ? "yes" : "no")
#define CoutYn(cond) Cout((cond) ? "Yes" : "No")
#define CoutYN(cond) Cout((cond) ? "YES" : "NO")

int main(void){
    Cin(int, n);
    Cins(int, n, a);
    Cusum(ll, n, a, sa);

    ll ans = 1e16;
    for(int i = 1; i < n; i ++){
        ans = min(ans, abs(sa[i] - sa[0] - sa[n] + sa[i]));
    }
    Cout(ans);
}


Measured memory_bytes: 2560