akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll N=1e5+10,M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
const int INF=1e9+7;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}

#define trace(...) cerr<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char *name, Arg1 &&arg1) {
    cerr<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma=strchr(names+1,',');
    cerr.write(names,comma-names)<<" : "<<arg1<<" | ";
    __f(comma+1,args...);
}

int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
//assic value of ('0'-'9') is(48 - 57) and (a-z) is (97-122) and (A-Z) is(65-90) and 32 for space
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}

int h,w;
string s[21];
int vis[21][21],ways[21][21],dist[21][21];

int bfs(int x, int y){
    mst(vis,0);
    queue<pair<int,int> > q;
    q.push({x,y});
    vis[x][y]=1;
    dist[x][y]=0;
    int maxi=0;
    while(!q.empty()){
        int x=q.front().first;
        int y=q.front().second;
        q.pop();
        for(int i=0; i<4; i++){
            int nx=x+X[i];
            int ny=y+Y[i];
            if(nx<0 || nx>=h || ny<0 || ny>=w) continue;
            if(s[nx][ny]=='#') continue;
            if(!vis[nx][ny]){
                dist[nx][ny]=dist[x][y]+1;
                maxi=max(maxi,dist[nx][ny]);
                vis[nx][ny]=1;
                ways[nx][ny]+=ways[x][y];
                q.push({nx,ny});
            }
            else{
                if(dist[x][y]+1==dist[nx][ny]) ways[nx][ny]+=ways[x][y];
            }
        }
    }
    return maxi;
}

int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> h >> w;
    rep(i,0,h){
        cin >> s[i];
    }
    int ans=0;
    rep(i,0,h){
        rep(j,0,w){
            if(s[i][j]=='.'){
                ans=max(ans,bfs(i,j));
            }
        }
    }
    cout << ans;
    return 0;
}


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

#define mod 998244353
#define pi 3.14159265358979
#define  PRE(x,p) cout<<setprecision(x)<<p; 
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define endl "\n"
#define high INT_MAX
#define low INT_MIN
#define ll long long int
using namespace std;
ll a[500005],n;
vector<ll>v; 
void solve() 
{ 
  ll n,x,t;
  cin>>n>>x>>t;
  if(n%x==0)
  cout<<(n/x)*t;
  else
  cout<<(n/x)*t +t;
}
 
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
ll t=1;
//cin>>t;
while(t--)
solve();
 
return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;
    
    int X, Y;
    io.read(X, Y);
    cout << X + Y / 2;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn main() {
    input! {
        n: usize,
        pv: [f64; n]
    };

    let mut dp = vec![vec![0_f64; n + 1]; n + 1];
    dp[0][0] = 1.0;
    for i in 0..n {
        for j in 0..i + 1 {
            dp[i + 1][j] += dp[i][j] * (1.0 - pv[i]);
            dp[i + 1][j + 1] += dp[i][j] * pv[i];
        }
    }
    let mut res = 0_f64;
    for i in n / 2 + 1..=n {
        res += dp[n][i];
    }
    println!("{}", res);
}


Measured memory_bytes: 72468
from itertools import combinations
import math


def solve():
    l, r = map(int, input().split())
    a = 2018
    for i in range(l, r):
        for j in range(i + 1, r + 1):
            amari = (i * j) % 2019
            if amari == 0:
                return 0
            elif amari < a:
                a = amari
    return a


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 3060
import java.util.*;
import java.math.BigDecimal;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		String x[] = sc.next().split("");
        String y[] = sc.next().split("");
        
        Arrays.sort(x);
        Arrays.sort(y, Collections.reverseOrder());
        String xx = String.join("", x);
        String yy = String.join("", y);
      
        if(xx.compareTo(yy) < 0){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
        
        
        
    }
}

Measured memory_bytes: 35820
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(x) x.begin(), x.end()

int main() {
    string s;
    int q;
    cin >> s >> q;
    deque<char> x;
    rep(i, (int)s.size()) {
        x.push_back(s[i]);
    }
    bool rev = false;
    rep(i, q) {
        int t;
        cin >> t;
        if (t == 1) {
            rev = not rev;
        } else if (t == 2) {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (rev) x.push_back(c);
                else x.push_front(c);
            } else if (f == 2) {
                if (rev) x.push_front(c);
                else x.push_back(c);
            }
        }
    }
    if (rev) reverse(ALL(x));
    rep(i, (int)x.size()) {
        cout << x[i];
    }
    cout << endl;
}

Measured memory_bytes: 4012
#include <cstddef>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>
#include <regex>
#include <complex>

using ll = long long;
using ull = unsigned long long;
using ld = long double;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;
    // cerr.rdbuf(nullptr);

    int n, a, b;
    cin >> n >> a >> b;

    cout << min({n * a, b}) << endl;

    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            String s = in.next();

            long ans = 0;
            for (int i = 0; i < (1 << s.length() - 1); i++) {
                long cnt = 0;
                long cn = s.charAt(0) - '0';
                for (int j = 0; j < s.length() - 1; j++) {
                    if (((i >> j) & 1) == 1) {
                        cnt += cn;
                        cn = 0;
                    }
                    cn *= 10;
                    cn += s.charAt(1 + j) - '0';
                }
                ans += cnt + cn;
            }

            out.println(ans);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isPrintableChar(int c) {
            return c >= 33 && c <= 126;
        }

        public String next() {
            StringBuilder sb = new StringBuilder();

            int b = readByte();
            while (!isPrintableChar(b))
                b = readByte();

            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }

            return sb.toString();
        }

    }
}



Measured memory_bytes: 21460
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Scanner;

public final class Main {

    public static void main(String[] args) {
        final Scanner in = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        final int n = in.nextInt() + 1;
        in.nextLine();
        final int[] leaves = new int[n];
        long branch = 0;
        for (int i = 0; i < n; i++) {
            leaves[i] = in.nextInt();
            branch += leaves[i];
        }
        branch--;
        long res = 0;
        long nowLeaf = 1;
        for (int i = 0; i < n; i++) {
            res += nowLeaf;
            nowLeaf -= leaves[i];
            if (nowLeaf < 0) {
                res = -1;
                break;
            }
            if (nowLeaf <= branch) {
                branch -= nowLeaf;
                nowLeaf *= 2;
            } else {
                nowLeaf += branch;
                branch = 0;
            }
        }
        System.out.println(res);
    }
}


Measured memory_bytes: 58972
#include<bits/stdc++.h>
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define pc _putchar_nolock
#define mp make_pair
#define mt make_tuple
#define um unordered_map
#define inf (ll)9223372036854775807
using namespace std;
using ll=long long int;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
void input(vector<int>&a,int n)
{
   rep(i,0,n-1)
   cin>>a[i];
}
int fact(int n)
{
	int res=1; 
	rep(i,1,n) res*=i;
	return res;
}
void solve()
{
 int n; cin>>n; vector<int>a,p(n),q(n);
 input(p,n); input(q,n);
 rep(i,1,n) a.eb(i);
 vector<vector<int>>v(fact(n));
 v[0]=a;
 rep(i,1,fact(n)-1)
 {  
   next_permutation(all(a)); v[i]=a;
 }
 int i1,i2;
 rep(i,0,(int)v.size()-1)
 {
 	if(v[i]==p) i1=i; 
 	if(v[i]==q) i2=i;
 }
 cout<<abs(i1-i2)<<"\n"; return;
}
int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  while(t--)
  {
	 solve();
  }
  return 0;
}


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

int main() {
	int n,k,ans=0,cur=1,i;
	cin >> n >> k;
	string s;
	cin >> s;
	for(i=1; i<n; i++){
		if(s[i-1]!=s[i]) cur++;
	}
	cur=max(cur-2*k,1);
	cout << n-cur;
}

Measured memory_bytes: 512
n=int(input())
a=list(map(int,input().split()))
j=0
c=0
import sys
a.sort()

for i in range(1,n+1):
    while 1:
        if j==n-1:
            
            break
        if i!=a[j]:
            break
        else:
            c+=1
            j+=1
    print(c)
    c=0
    




Measured memory_bytes: 32236
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
    int a;
    cin >> a;
    vector<int> li(a+1);
    for (int i = 0; i < a; i++) {
		cin >> li[i];
	}
	sort(li.begin(),li.end());
	int c = 0;
	for (int i = 0; i < a; i++) {
	    //cout << i << "/" << li[i] << endl;
	     //for (int j = i; j < a; j++) {
	         //if(i !=j){
	             if(li[i] == li[i+1]){
	                 //cout << "-" << i << "/" << j << "/" << c << "-" << li[i] << "/" << li[j] << endl;
    	              c = 1;
    	              goto ra;
	             }
	             //cout << i << "/" << j << "/" << c << endl;
	         //}
	     //}
	}
	ra:
	if (c==0){
	    cout << "YES";
	}else{
	    cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<map>
#include<math.h>
#include<set>
#include<string>
#include<vector>
using namespace std;


static const double pi = 3.14159265358979323846;

int main()
{
  double r;
  cin >> r;
  double c = 2 * pi * r;
  cout << c;
  return 0;
}


Measured memory_bytes: 3260
#!/usr/bin/python3
# vim: set fileencoding=utf-8:

import sys


def main():
    N, K = [int(ele) for ele in input().split()]
    N = N - 1
    K = K - 1
    S = list(input())
    S[K] = S[K].lower()
    print("".join(S))


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
s = int(input())

def calc(n):
  if n % 2 == 0:
    return n // 2
  else:
    return 3 * n + 1

l = [s]
a = s
cnt = 2
while True:
  tmp = calc(a)
  if tmp in l:
    print(cnt)
    exit()
  else:
    l.append(tmp)
    a = tmp
    cnt = cnt + 1


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

using namespace std;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define all(x) (x).begin (),(x).end()
#define sqrt(x) sqrt(abs(x))
#define re return
#define sz(x) ((int)(x).size ())
#define prev PREV
#define next NEXT

using ll = long long;
using ii = pair<int, int>;
using ld = long double;
using D = double;
using vi = vector<int>;
using vii = vector<ii>;
using vvi = vector<vi>;
using vs = vector<string>;

template<typename T> T abs (T x) { re x < 0 ? -x : x; }
template<typename T> T sgn (T x) { re x < 0 ? -1 : (x > 0 ? 1 : 0); }
template<typename T> T sqr (T x) { re x * x; }
template<typename T> T gcd (T a, T b) { re a != 0 ? gcd (b % a, a) : b; }

int n;
int m;
ll a, b, c;

int main () {
	cin >> a >> b >> c;
	ll ans = 0;
	if (a + b + 1 >= c) ans = b + c; else ans = 2 * b + a + 1;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
#define rep(i,N) for(int i=0;i<N;i++)

long long  INF=1000000000000000000;
long long mod=1000000007;
using namespace std;

int main(){
int a,b,c;
cin>>a>>b>>c;
int sum=a+b+c;
int k;
cin>>k;
int M=max(a,b);
M=max(M,c);
sum-=M;
rep(i,k){
    M*=2;
}
long long ans=sum+M;
cout<<ans<<endl;
 return 0;
}
/*
5 3 11
1

30

3 3 4
2

22

*/

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <cstdlib>
#include <algorithm>

#include <stdio.h>
#include <stdlib.h>

using namespace std;

int main(int argc, char *argv[]){
  char X;
  char Y;
  cin >> X >> Y;

  int tmp = (int)(X-Y);
  if(tmp == 0){
    cout << '=' << endl;
  }else if(tmp > 0){
    cout << '>' << endl;
  }else{
    cout << '<' << endl;
  }
  return 0;
}


Measured memory_bytes: 256
IDENTIFICATION DIVISION.
PROGRAM-ID. 159A.
 
DATA DIVISION.
WORKING-STORAGE SECTION.
01 INP        PIC X(10).
01 N          PIC 9(3).
01 M          PIC 9(3).
01 OUT        PIC ZZZZ9.
*>
PROCEDURE DIVISION.
MAIN-001.
  ACCEPT INP.
  UNSTRING INP DELIMITED BY ALL ' '
      INTO N M.
*>
  EVALUATE TRUE
    WHEN N = 1 AND M = 1
      MOVE 0 TO OUT
    WHEN N <= 1 
      COMPUTE OUT =  M * (M - 1) / 2
    WHEN M <= 1 
      COMPUTE OUT =  N * (N - 1) / 2
    WHEN OTHER  
      COMPUTE OUT = N * (N - 1) / 2 + M * (M - 1) / 2
  END-EVALUATE.
*>
  DISPLAY FUNCTION TRIM(OUT).
  STOP RUN.


Measured memory_bytes: 764
//////////////////////////////////////////////
//root@NULLCT$(☝ ՞ਊ ՞)☝  << "Be accept!!"//
//////////////////////////////////////////////
//#define BOOST
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <bitset>    // bitset
#include <cctype>    // isupper, islower, isdigit, toupper, tolower
#include <cstdint>   // int66_t, int*_t
#include <cstdio>    // printf
#include <deque>     // deque
#include <iomanip>   //setfill(char)
#include <ios>       //left,right
#include <iostream>  // cout, endl, cin
#include <map>       // map
#include <queue>     // queue, priority_queue
#include <set>       // set
#include <stack>     // stack
#include <string>    // string, to_string, stoi
#include <tuple>     // tuple, make_tuple
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <utility>       // pair, make_pair
#include <vector>        // vector
#ifdef BOOST
#include <boost/multiprecision/cpp_int.hpp> // cpp_int
using namespace boost::multiprecision;
#endif
#define rep(i, n) for (int i = 0; i < n; i++)
using ll = long long;
using namespace std;
int setup(void) { ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); return 0; }
int lenght(char* str) { int i = 0; while (str[i])i++; return i; }
int gcd(int a, int b) { if (a % b == 0) { return(b); } else { return(gcd(b, a % b)); } }
int lcm(int a, int b) { return a * b / gcd(a, b); }
int iinput(void) { int a = 0; cin >> a; return a; }
int dinput(void) { double a = 0; cin >> a; return a; }
string sinput(void) { string a = ""; cin >> a; return a; }
int kuriup(double a) { int b = int(a); if (a != b) { return b + 1; } else { return b; } }
int kuridown(double a) { int b = int(a); return b; }
int run(void);
int main() { setup(); run(); return 0; }
int run(void) {

  double a=0,b=0;
  cin>>a>>b;
  double eightp = a/0.08;
  double tenp = b/0.1;
  int ans=0;
  for(int i=0;;i++){
      ans=i+1;
      if(int(ans*0.08) == a && int(ans*0.1) == b){
          cout<<ans<<endl;
          return 0;
        }

      if(int(ans*0.08)>a && int(ans*0.1) > b){
          cout<<"-1"<<endl;
          return 0;
        }

    }


  return 0;
}


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

using namespace std;

queue<char> que[3];

int main()
{
    int n, k;
    int ans = 1;

    cin >> n >> k;

    ans = k;
    for (int i = 1; i < n; i++) {
        ans *= k - 1;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
// arc082_a
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif

template <typename A, typename B> bool cmin(A &a, const B &b) {
  return a > b ? (a = b, true) : false;
}
template <typename A, typename B> bool cmax(A &a, const B &b) {
  return a < b ? (a = b, true) : false;
}
const double PI = acos(-1);
const double EPS = 1e-9;
int inf = sizeof(int) == sizeof(long long) ? 2e18 : 1e9 + 10;
int dx[] = {0, 1, 0, -1};
int dy[] = {1, 0, -1, 0};
#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, A, ans = 0;
  cin >> N;
  int cnt[100001];
  REP(i, 100001) cnt[i] = 0;
  REP(i, N) {
    cin >> A;
    cnt[A]++;
  }

  for (int i = 1; i < 100000; ++i) {
    int now = cnt[i - 1] + cnt[i] + cnt[i + 1];
    ans = max(ans, now);
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline


class Ruiseki2D:
    """二次元累積和を構築する"""
    def __init__(self, matrix):
        self.h = len(matrix)
        self.w = len(matrix[0])
        self.ru = [[0] * (self.w + 1) for _ in range(self.h + 1)]

        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] = self.ru[i + 1][j] + matrix[i][j]
        for i in range(self.h):
            for j in range(self.w):
                self.ru[i + 1][j + 1] += self.ru[i][j + 1]

    def get_sum(self, hl, hr, wl, wr):
        """[hl, hr), [wl, wr) で囲まれた部分の和を求める"""
        return (self.ru[hr][wr] + self.ru[hl][wl]
                - self.ru[hr][wl] - self.ru[hl][wr])


n, m, q = map(int, input().split())
info = [list(map(int, input().split())) for i in range(m)]
query = [list(map(int, input().split())) for i in range(q)]

matrix = [[0] * (n + 1) for i in range(n + 1)]
for l, r in info:
    matrix[l][r] += 1
ru = Ruiseki2D(matrix)

for l, r in query:
    ans = ru.get_sum(l, r + 1, l, r + 1)
    print(ans)

Measured memory_bytes: 100060
N, A, B = [int(x) for x in input().split()]
S = input()
total = 0
Btotal = 0
for n in range(N):
  if S[n]=="a" and total<A+B:
    print("Yes")
    total += 1
  elif S[n]=="b" and total<A+B and Btotal<B:
    print("Yes")
    total += 1
    Btotal += 1
  else:
    print("No")

Measured memory_bytes: 4016
#include<stdio.h>
#include<string.h>

int main (void)
{
	int i,j,out = 0;
	char str[128];
	
	fgets(str,sizeof(str),stdin);
	
	for(i=0;i<26;i++)
	{
		int count = 0;
		char alpha = 'a'+i;
		for(j=0;j < strlen(str)-1;j++)
		{
			if(str[j] == alpha)
			{
				count++;
			}
		}

		if(count%2 == 1)
		{
			out++;
			break;
		}
	}
	
	if(out == 0)
	{
		puts("Yes");
	}else
	{
		puts("No");
	}
	
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    if(a==b)
        cout<<c<<endl;
    else if(b==c)
        cout<<a<<endl;
    else
        cout<<b<<endl;
    return 0;
}


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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, q;
num a[100005], pre[100005], pres[2][100005], ans;

int main() {
	ios_base::sync_with_stdio(0);
	cin >> n >> q;
	loop (i, n) {
		cin >> a[i];
		pre[i + 1] = pre[i] + a[i];
		pres[i % 2][i + 1] = pres[i % 2][i] + a[i];
		pres[(i % 2) ^ 1][i + 1] = pres[(i % 2) ^ 1][i];
	}
	cont (cas, q) {
		num x, l = 0, r = n, mid;
		cin >> x;
		while (l < r) {
			mid = (l + r) >> 1;
			int pos = (int) (lower_bound(a, a + n, x - (a[mid] - x)) - a);
			if (mid - pos < n - mid - 1) {
				l = mid + 1;
			} else {
				r = mid;
			}
		}
		ans = pre[n] - pre[l] + pres[(n % 2) ^ 1][l - (n - l)];
		cout << ans << '\n';
	}
}

// 大概的选取方法:
// T A T A T A T A ... T | A A A ... A A A | T T T ... T T T
//                                         ^ 二分该端点
// 时间复杂度:
// O(n log^2 n)


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

namespace A
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var ABC = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var (A, B, C) = (ABC[0], ABC[1], ABC[2]);
            Console.WriteLine(A - B == B - C ? "YES" : "NO");
        }
    }
}


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

import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main{

	Scanner sc=new Scanner(System.in);

	int INF=1<<28;
	double EPS=1e-9;

	int n, k;
	int[] a, b;
	TreeSet<String> set;

	void run(){
		for(;;){
			n=sc.nextInt();
			k=sc.nextInt();
			if((n|k)==0){
				break;
			}
			a=new int[n];
			for(int i=0; i<n; i++){
				a[i]=sc.nextInt();
			}
			solve();
		}
	}

	void solve(){
		set=new TreeSet<String>();
		b=new int[k];
		int comb=(1<<k)-1;
		for(; comb<1<<n;){
			int j=0;
			for(int i=0; i<n; i++){
				if((comb>>i&1)!=0){
					b[j++]=a[i];
				}
			}
			rec(0);
			int x=comb&-comb, y=comb+x;
			comb=((comb&~y)/x>>1)|y;
		}
		println(set.size()+"");
	}

	void rec(int j){
		if(j==k){
			String s="";
			for(int e : b){
				s+=e;
			}
			set.add(s);
			return;
		}

		for(int i=j; i<k; i++){
			int t=b[i];
			b[i]=b[j];
			b[j]=t;
			rec(j+1);
			t=b[i];
			b[i]=b[j];
			b[j]=t;
		}
	}

	void debug(Object... os){
		System.err.println(Arrays.deepToString(os));
	}

	void print(String s){
		System.out.print(s);
	}

	void println(String s){
		System.out.println(s);
	}

	public static void main(String[] args){
		// System.setOut(new PrintStream(new BufferedOutputStream(System.out)));
		new Main().run();
	}
}

Measured memory_bytes: 13000
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long w=sc.nextInt();
        long h=sc.nextInt();
        long x=sc.nextInt();
        long y=sc.nextInt();
       System.out.println((w*h)*0.5+" "+(w==x*2 && h==y*2 ? 1:0));
    }
}


Measured memory_bytes: 24148
#include<bits/stdc++.h>
#define res register int
#define ll long long
#define inf 0x3f3f3f3f
#define N 100050
using namespace std;
int a[N],n,m,ans;
bool vis[N];
int main()
{
   scanf("%d%d",&n,&m);
   for(res i=1;i<=n;i++)
   a[i]=1;
   vis[1]=true;
   for(res i=1;i<=m;i++)
   {
   	  int x,y;
   	  scanf("%d%d",&x,&y);
   	  if(vis[x]==true)
   	  vis[y]=true;
   	  a[x]--;
   	  if(!a[x])vis[x]=false;
   	  a[y]++;
   }
   for(res i=1;i<=n;i++)
   if(vis[i]) ans++;
   printf("%d\n",ans);
}


Measured memory_bytes: 768
#include <vector>
#include <math.h>
#include <iostream>

using namespace std;

const double INF = 1e18;

struct Point {
    double X, Y;
};

struct Circle {
    Point C;
    double R;
};


double dist(const Point &a, const Point &b) {
    return sqrt(pow(a.X - b.X, 2) + pow(a.Y - b.Y, 2));
}

bool is_inside(const Circle &c, const Point &p) {
    return dist(c.C, p) <= c.R;
}

Point get_circle_center(double bx, double by, double cx, double cy) {
    double B = bx * bx + by * by, C = cx * cx + cy * cy, D = bx * cy - by * cx;
    return {(cy * B - by * C) / (2 * D), (bx * C - cx * B) / (2 * D)};
}

Circle circle_from(const Point &A, const Point &B, const Point &C) {
    Point I = get_circle_center(B.X - A.X, B.Y - A.Y, C.X - A.X, C.Y - A.Y);
    I.X += A.X;
    I.Y += A.Y;
    return {I, dist(I, A)};
}

Circle circle_from(const Point &A, const Point &B) {
    Point C = {(A.X + B.X) / 2.0, (A.Y + B.Y) / 2.0};
    return {C, dist(A, B) / 2.0};
}

bool is_valid_circle(const Circle &c, const vector<Point> &P) {
    for (const Point &p : P)
        if (!is_inside(c, p))
            return false;
    return true;
}

Circle minimum_enclosing_circle(const vector<Point> &P) {
    int n = (int) P.size();

    if (n == 0)
        return {{0, 0}, 0};
    if (n == 1) {
        return {P[0], 0};
    }
    Circle mec = {{0, 0}, INF};

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            Circle tmp = circle_from(P[i], P[j]);
            if (tmp.R < mec.R && is_valid_circle(tmp, P))
                mec = tmp;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                Circle tmp = circle_from(P[i], P[j], P[k]);
                if (tmp.R < mec.R && is_valid_circle(tmp, P))
                    mec = tmp;

            }
        }
    }
    return mec;
}


int main() {
    int n = 10;
    cin >> n;
    vector<Point> v;
    for (int i = 0; i < n; i++) {
        double a, b;
        cin >> a >> b;
        v.push_back({a, b});
    }
    Circle c = minimum_enclosing_circle(v);
//    printf("%.8f %.8f\n", c.C.X, c.C.Y);
    printf("%.8f\n", c.R);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
 
 
template <class T> void chmin(T&a, const T&b) { a = min(a,b); }
template <class T> void chmax(T&a, const T&b) { a = max(a,b); }
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1000000007; //10^9+7
#define PI 3.14159265258979
 
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

int main(void){
	int H,W;
	string S;

	cin>>H>>W;
	REP(i,H){
		cin>>S;
		cout<<S<<endl;
		cout<<S<<endl;
	}
	return 0; 
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
using P = pair<int,int>;
using pq = priority_queue<int>;
typedef long long ll;
string yes = "Yes\n";
string no = "No\n";

int  main()
{
	int n; cin >> n;

	int x = n * 800;
	int y = n / 15 * 200;
	cout << x - y;
	return (0);
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    int n,m,b=0;
    int a;
    int e;
    int d[10000]={0};
    cin>>n>>m;
    for (int i=0; i<n; i++)
    {
        cin>>a;
        for (int k=0; k<a; k++)
        {
            cin>>e;
            d[e-1]+=1;
        }
    }
    for (int i=0; i<m; i++)
    {
        if (d[i]==n)
        {
            b+=1;
        }
    }
    
    cout<<b;
    
    
    return 0;
}

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

// O(1)
// O(N)

// Avoid this
// for(int i = 1;i <= 1000000;i++) if(memo[pos] == 0) cout << "YES"; // O(log(N)) -> memorinya sejuta
// Use this instead
// for(int i = 1;i <= 1000000;i++) if(memo.count(pos)) cout << "YES"; // O(log(n)) -> memorinya 0
// O(log N)
// (memo[pos] != 0)
// C++ bakal giniin : memo[pos] = int(0);, return memo[pos]; // O 
// memo.count(pos);

const LL LINF = 4557430888798830399LL;

LL n, d;
map <LL, LL> memo;
LL cost[3];
LL fact[3] = {2,3,5};

LL dp(LL pos){
    
    if(pos == 0) return 0;
    if(pos == 1) return d;

    if(memo.count(pos)) return memo[pos];
    
    LL ret = pos*d;
    if(pos > (1'000'000'000'000'000'000LL)/d) ret = LINF;

    // Coba dibagi X
    // Ada 2 cara, jadiin lowerbound X dimana, 2|X
    for(int i = 0;i < 3;i++){
        int x = fact[i];

        // misal x = 5
        // 12 -> 10/2
        LL rem = pos%x; // rem -> 2

        LL nx = pos-rem; // nx = 10
        LL nxcost = (pos-nx)*d; // pos dikurang kurangin sampe nx, terus bagi 5

        if(nx/x != 0) nxcost += cost[i];
        ret = min(dp(nx/x)+nxcost, ret);

        if(rem == 0) continue;
        
        // 12 -> 15/2
        nx = pos-rem+x; // nx = 15
        nxcost = (nx-pos)*d; // pos ditambah tambahin sampe nx, terus bagi 5

        if(nx/x != 0) nxcost += cost[i];
        ret = min(dp(nx/x)+nxcost, ret);
    }

    return memo[pos] = ret;
}

int main(){
    int testCases; cin >> testCases; int tc = 0;
    while(++tc <= testCases){

        memo.clear();
        cin >> n >> cost[0] >> cost[1] >> cost[2] >> d;
        cout << dp(n) << endl;
    
    }
}

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

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

void addedge(int u, int v){ printf("%d %d\n", u, v); }

int main()
{
	int n = read();
	for (int i = 0; (1 << i) <= n; ++i) 
		if (n == (1 << i)) return puts("No"), 0;
	
	puts("Yes");
	for (int i = 2; i <= n - 1; i += 2)
	{
		addedge(1, i);
		addedge(i, i + 1);
		addedge(1, i + n + 1);
		addedge(i + n + 1, i + n);
	}
	addedge(3, n + 1);
	
	if (n % 2 == 0)
	{
		int j = 0;
		for (int i = 0; (1 << i) <= n; ++i)
			if (n & (1 << i)) j = i;
		addedge(n, ((1 << j) ^ 1) + n);
		addedge(n + n, n ^ (1 << j));
	}
	return 0;
}


Measured memory_bytes: 2304
#define _USE_MATH_DEFINES
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <complex>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
#include <iterator>
using namespace std;

const long long INF = LLONG_MAX / 2;

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> a(m), b(m), c(m);
    for(int i=0; i<m; ++i){
        cin >> a[i] >> b[i] >> c[i];
        -- a[i];
        -- b[i];
    }

    vector<bool> used(n, false);
    used[n-1] = true;
    for(int i=0; i<n; ++i){
        for(int j=0; j<m; ++j){
            if(used[b[j]])
                used[a[j]] = true;
        }
    }

    vector<long long> v(n, -INF);
    v[0] = 0;
    for(int i=0; i<n; ++i){
        bool isUpdate = false;
        for(int j=0; j<m; ++j){
            long long x = v[a[j]] + c[j];
            if(used[b[j]] && v[b[j]] < x){
                v[b[j]] = x;
                isUpdate = true;
            }
        }

        if(!isUpdate){
            cout << v[n-1] << endl;
            return 0;
        }
    }

    cout << "inf" << endl;
    return 0;
}


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

int main(){
  char a, b;
  cin >> a >> b;
  if((a == 'H' && b == 'H') || (a == 'D' && b == 'D')){
    cout << 'H' << endl;
  } else {
    cout << 'D' << endl;
  }
  return 0;
}

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

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;
inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}


 main()

{
    fast
    int n,r;
    cin>>n>>r;
    if(n>=10)
    {
        cout<<r<<endl;
    }
    else
    {
        int val=100*(10-n);
       // cout<<val<<endl;
        int ses=r+val;
        cout<<ses<<endl;
    }

















    return 0;

}














Measured memory_bytes: 256
n = int(input())

count = 0

if n%2==0:
    for i in range(int(n/2)-1):
        count += int((n-1)/(i+1))
    count += int(n/2)

else:
    for i in range(int(n/2)):
        count += int((n-1)/(i+1))
    count += int(n/2)

print(count)


Measured memory_bytes: 9144
#pragma region

#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (register int i = (begin); i < (end); i++)
#define IFOR(i, begin, end) for (register int i = (end)-1; i >= (begin); i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define MOD 1000000007
#define debug(x) cerr << #x << " = " << (x) << " (line: " << __LINE__ << ") " << endl;
typedef long long ll;
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (auto &v : vec) is >> v;
  return is;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "vec[ ";
  REP(i, vec.size())
  i == 0
      ? os << vec[i]
      : os << ", " << vec[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const deque<T> &deq) {
  os << "deq[ ";
  REP(i, deq.size())
  i == 0
      ? os << deq[i]
      : os << ", " << deq[i];
  os << " ]";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_set<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T>
ostream &operator<<(ostream &os, const unordered_multiset<T> &set) {
  os << "{ ";
  for (auto &&s : set) &s == &(*set.begin()) ? os << s : os << ", " << s;
  os << " }";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << "(" << p.first << ", " << p.second << ")";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}
template <typename TK, typename TV>
ostream &operator<<(ostream &os, const unordered_map<TK, TV> &m) {
  os << "{ ";
  for (auto &&k : m) &k == &(*m.begin()) ? os << k.first << " => " << k.second : os << ", " << k.first << " => " << k.second;
  os << " }";
  return os;
}

#pragma endregion

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(16);

  int A, B;
  cin >> A >> B;
  cout << max(A - 2 * B, 0) << "\n";
}


Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <fstream>
#include <cassert>
using namespace std;

#define sz(a) int((a).size())
#define rep(i, s, n)  for(int i = s; i <= (n); ++i)
#define rev(i, n, s)  for(int i = (n); i >= s; --i)
#define fore(x, a) for(auto &&x : a)
typedef long long ll;
const int mod = 1000000007;
const int N = 100005;


int main() {
#ifdef loc
  if(!freopen((string(FOLDER) + "inp.txt").c_str(), "r", stdin)) {
    assert(0);
  }
  freopen((string(FOLDER) + "out.txt").c_str(), "w", stdout);
#endif
  ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  vector<int> a;
  int n;
  cin >> n;
  rep(i, 1, 2 * n) {
    int x;
    cin >> x;
    a.push_back(x);
  }
  sort(a.begin(), a.end());
  int res = 0;
  rep(i, 0, 2 * n-1) {
    res += a[i];
    i++;
  }
  cout << res << endl;
  return 0;
}

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

#define F first 
#define S second
#define PB push_back

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef priority_queue<int> HEAP;
typedef priority_queue<int, vector<int>, greater<int> > RHEAP;

const int N = 200010, M = 1010, mod = 998244353;

int n, m, k;
int infact[N], fact[N];

int qp(int a, int b)
{
	int res = 1;
	while (b)
	{
		if (b & 1) res = (LL)res * a % mod;
		a = (LL)a * a % mod;
		b >>= 1;
	}
	return res;
}

int C(int a, int b)
{
	return (LL)fact[a] * infact[b] % mod * infact[a - b] % mod;
}

int main()
{
	cin >> n >> m >> k;
	
	fact[0] = infact[0] = 1;
	for (int i = 1; i <= n; i ++ )
	{
		fact[i] = (LL)fact[i - 1] * i % mod;
		infact[i] = (LL)infact[i - 1] * qp(i, mod - 2) % mod;
	}
	
	int res = 0;
	for (int i = 0; i <= k; i ++ )
		res = (res + (LL)m * C(n - 1, i) % mod * qp(m - 1, n - 1 - i) % mod) % mod;
	cout << res << endl;
    return 0;
}

Measured memory_bytes: 5192
K,A,B = map(int,input().split())
if B<=A+2 or K<=A-1:
    ans = 1+K
else:
    cnt = A-1
    ans = A
    while cnt<=K:
        k = min(ans//A,(K-cnt)//2)
        if k>=1:
            cnt += 2*k
            ans = ans-k*A + k*B
        else:
            ans += (K-cnt)
            break
print(ans)

Measured memory_bytes: 38868
#include<iostream>

using namespace std;

int min(int x, int y);
int max(int x, int y);

int main(void)
{
	int n, rt, __min, maxans;
	cin >> n;
	cin >> __min;
	maxans = -2000000000;
	for(int i = 0; i < n - 1; i++){
		cin >> rt;
		maxans = max(maxans, rt-__min);
		__min = min(__min, rt);
	}
	cout << maxans << endl;
	return 0;
}

int min(int x, int y){
	int tmp;
	if(x > y){
		tmp = x;
		x = y;
		y = tmp;
	}
	return x;
}

int max(int x, int y){
	int tmp;
	if(x < y){
		tmp = x;
		x = y;
		y = tmp;
	}
	return x;
}

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

int main() {
  ll N, K;
  cin >> N >> K;
  vector<ll> A(N);
  
  for (ll i = 0; i < N; i++) {
    cin >> A[i];
    A[i]--;
  }
  vector<ll> v;
  ll i = 1;
  ll p = A[0];
  ll f = N-1;
  set<ll> s;
  for (i = 0; i < N; i++) {
    v.push_back(p);
    if (s.count(p)) {
      auto itr = find_if(v.begin(), v.end(), [&](ll x) { return (x == p); });
        f = ll(distance(v.begin(), itr));
        break;
    }
    s.insert(p);
    if (i < N) p = A[p];
  }
  
  if (K <= i) cout << v[K-1]+1 << endl;
  else {
    ll rp = i-f;
    cout << v[(K-1-i)%rp+f]+1 << endl;
  }
}

Measured memory_bytes: 15396
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A = sc.nextInt();
		int B = sc.nextInt();
		int s =0;
		for (int i=1;i<=N;i++) {
			String temp = String.valueOf(i);
			int sum =0;
			for (int j=0;j<temp.length();j++) {
				sum +=temp.charAt(j)-'0';
			}
			if (sum<=B&&sum>=A) {
				s+=i;
			}
		}
		System.out.println(s);
	}
}

Measured memory_bytes: 36712
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  YES(n==3||n==5||n==7);


}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define clear(v) memset(v,0,sizeof(v))
#define ALL(v) (v).begin(),(v).end()
int main(){
	string s;
	int cnt = 0;
	while (cin >> s){
		string ss;
		ss = s;
		reverse(ALL(s));
		if (s == ss) cnt++;
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1196
import sys
sys.setrecursionlimit(10000000)
MOD = 10 ** 9 + 7
INF = 10 ** 15
Dy = (-1,0,1,0)
Dx = (0,1,0,-1)

MAXH = 25
MAXW = 25
dist = [[100]*MAXW for _ in range(MAXH)]
grid = [[-1]*MAXH for _ in range(MAXH)]

def dfs(ny,nx,t,H,W):
    if t == 11:
        return
    for dy,dx in zip(Dy,Dx):
        y,x = ny,nx
        before_y,before_x = ny,nx
        while True:
            y += dy
            x += dx
            if y < 0 or y >= H:
                break
            if x < 0 or x >= W:
                break
            if grid[y][x] == 1:
                if (before_y,before_x) != (ny,nx):
                    grid[y][x] = 0
                    if dist[before_y][before_x] > t:
                        dist[before_y][before_x] = t
                    dfs(before_y,before_x,t + 1,H,W)
                    grid[y][x] = 1
                break
            if grid[y][x] == 3:
                dist[y][x] = min(t,dist[y][x])
                return
            before_y = y
            before_x = x

def solve(H,W):
    sy,sx,gy,gx = -1,-1,-1,-1
    for i in range(H):
        A = list(map(int,input().split()))
        for j in range(W):
            if A[j] == 2:
                sy,sx = i,j
            if A[j] == 3:
                gy,gx = i,j
            grid[i][j] = A[j]
            dist[i][j] = 100
    
    dist[sy][sx] = 0
    dfs(sy,sx,1,H,W)
    ans = dist[gy][gx] if dist[gy][gx] <= 10 else -1
    print(ans)

def main():
    while True:
        W,H = map(int,input().split())
        if H == 0 and W == 0:
            return
        solve(H,W)
if __name__ == '__main__':
    main()


Measured memory_bytes: 5648