akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define sz size
#define se second
#define fe first
#define mper make_pair
#define all(x) x.begin(), x.end()
#define mal ios_base::sync_with_stdio(NULL);cin.tie(NULL);cout.tie(NULL);
#define saken string
#define erba continue
using namespace std;

int n, m;
map < pair <int, int>, bool > mp;
string s[10];
bool check = 0;

void rec(int x, int y) {

    if(check) {return;}


    if(x == n && y == m) {mp[mper(x, y)] = 1; return;}


    int cnt = 0;

    if(s[x][y - 2] == '#' && !mp[mper(x, y - 1)]) {cnt++;}
    if(s[x][y] == '#' && !mp[mper(x, y + 1)]) {cnt++;}
    if(s[x + 1][y - 1] == '#' && !mp[mper(x + 1, y)]) {cnt++;}
    if(s[x - 1][y - 1] == '#' && !mp[mper(x - 1, y)]) {cnt++;}

    if(cnt != 1) {check = 1; return;}


    mp[mper(x, y)] = 1;

    if(s[x][y] == '#' && !mp[mper(x, y + 1)]) {rec(x, y + 1);}
    else if(s[x + 1][y - 1] == '#' && !mp[mper(x + 1, y)]) {rec(x + 1, y);}
    else {check = 1;return;}

}

int main(){

mal

cin >> n >> m;

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

if(s[1][0] != '#') {cout << "Impossible";return 0;}

rec(1, 1);

if(check) {cout << "Impossible";return 0;}

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

    for(int j = 1; j <= m; ++j) {

        if(s[i][j - 1] == '#' && !mp[mper(i, j)]) {cout << "Impossible";return 0;}

    }

}

cout << "Possible";

return 0;
}



Measured memory_bytes: 256
module ABC136

  ! <module>s to import
  use, intrinsic :: iso_fortran_env

  ! require all variables to be explicitly declared
  implicit none

  ! accessibility of <subroutine>s and <function>s in this <module>
  public  :: task_C
  private :: judge_isPossible
  
  contains
  
  subroutine task_C

    ! variables for this <subroutine>
    integer(INT32) :: num_cell
    logical        :: isPossible
  
    ! arrays for this <subroutine>
    integer(INT32), dimension(:), allocatable :: val_height

    ! STEP.01
    ! read out the number of cells
    read(unit=INPUT_UNIT, fmt=*) num_cell

    ! STEP.02
    ! allocate the array to store the height of each cell
    allocate( val_height(1:num_cell) )

    ! STEP.03
    ! read out the height of each cell
    read(unit=INPUT_UNIT, fmt=*) val_height(:)

    ! STEP.04
    ! calculate the answer of this task
    call judge_isPossible(num_cell, val_height(:), isPossible)

    ! STEP.04
    ! output the answer of this task
    if ( isPossible ) then
      write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') 'Yes'
    else
      write(unit=OUTPUT_UNIT, fmt='(A)', advance='yes') 'No'
    end if

    ! STEP.END
    return

  end subroutine task_C

  subroutine judge_isPossible (num_cell, val_height, isPossible)

    ! arguments for this <subroutine>
    integer(INT32), intent(in)    :: num_cell
    integer(INT32), intent(inout) :: val_height(:)
    logical,        intent(inout) :: isPossible

    ! support variables for this <subroutine>
    integer(INT32) :: itr

    ! STEP.01
    ! initialize the return value of this subroutine
    isPossible = .true.

    ! STEP.02
    ! judge the possibility using the number of cells
    if (num_cell .eq. 1_INT32) then
      return
    end if

    ! STEP.03
    ! judge the possibility using the value of height
    do itr = num_cell - 1_INT32, 1_INT32, -1_INT32

      if ( val_height(itr) .le. val_height(itr + 1_INT32) ) then
        continue
      else if ( val_height(itr) - val_height(itr + 1_INT32) .eq. 1_INT32 ) then
        val_height(itr) = val_height(itr) - 1_INT32
      else
        isPossible = .false.
        exit
      end if

    end do

    ! STEP.END
    return

  end subroutine judge_isPossible

end module ABC136

program main

  ! <module>s to import
  use, non_intrinsic :: ABC136

  call task_C

end program main

Measured memory_bytes: 1280
import numpy as np


def main(n, k, heights):
    heights = np.array(heights, dtype=int)
    costs = np.zeros(n, dtype=int)
    for i in range(1, n):
        start = max(0, i - k)
        costs[i] = np.min(costs[start:i] + np.abs(heights[i] - heights[start:i]))
    return costs[-1]


if __name__ == '__main__':
    N, K = map(int, input().split())
    H = list(map(int, input().split()))
    print(main(N, K, H))


Measured memory_bytes: 22840
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MMOD 998244353
#define MAX 2010101
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

int main(){
  ll N,ans=0;
  cin>>N;
  
  ll X[N],Y[N];
  vector<ll> LX,LY;
  REP(i,N){
    cin>>X[i]>>Y[i];
    LX.PB(X[i]+Y[i]);
    LY.PB(Y[i]-X[i]);
  }
  SORT(LX);
  SORT(LY);
  
  chmax(ans,LX[N-1]-LX[0]);
  chmax(ans,LY[N-1]-LY[0]);
  co(ans);
  return 0;
}

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

using namespace std;
typedef long long ll;
#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define fore(i,a) for(auto &i:a)

typedef pair <int, int> P;
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
const int  INF = 1<<25;
const ll INFL = 1223372036854775807;
const ll mod = 1000000007;






int main() {

	int n, l;
	cin >> n >> l;

	VI a(n);
	REP(i, n)cin >> a[i];

	bool b = true;

	int c;

	REP(i, n - 1) {
		if (a[i] + a[i + 1] >= l) {
			b = false;
			c = i + 1;
			break;
		}
	}
	if (b) {
		cout << "Impossible" << endl;
		return 0;
	}

	cout << "Possible" << endl;

	FOR(i, 1, c) {
		cout << i << endl;
	}
	for (int i = n-1; i >= c; i--) {
		cout << i << endl;
	}


	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <math.h>

int ispime(int);

int main(void){

  int n,x,i,count=0;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&x);
    if(isprime(x)) count++;
  }

  printf("%d\n",count);

  return 0;
}


int isprime(int x){
  if(x==2) return 1;
  if(x<2 || x%2==0) return 0;
  int i;
  for(i=3;i*i<=x;i+=2)
    if(x%i==0)
      return 0;
  return 1;
}

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

typedef long long int ll;

ll ar[1<<17+5];

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


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

#define endl '\n'
#define Int long long
#define Double long double
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define CLR(a, b) memset(a, b, sizeof a)
#define debug(x) cerr << #x << " " << x << endl;
#define MOD 1000000007
#define MAXN 1000010

using namespace std;

int main() {
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n; cin >> n;
    priority_queue<int> pq;
    for(int i = 0; i < 2*n; ++i) {
        int l; cin >> l;
        pq.push(l);
    }
    int ans = 0;
    while(!pq.empty()) {
        int i = pq.top();
        pq.pop();
        int j = pq.top();
        pq.pop();
        ans += min(i, j);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <iomanip>
#include <math.h>
#include <limits.h>
#include <algorithm>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <string>
#include <string.h>
#include <sstream>
#include <ctime>

using namespace std;

#define eps 1e-12
#define pi 3.14159265358979323846
#define pb push_back
#define mp make_pair
#define st first
#define nd second
#define bgn begin
#define ll long long
#define ld long double
#define ull unsigned long long
#define ii pair<ll,ll>










const int N=1e5+10;
ll n,a[N],b[N],c[N],res[N],res2;



void solve()
{
	cin>>n;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>b[i];
	for(int i=1;i<=n;i++)cin>>c[i];
	sort(a+1,a+n+1);
	sort(b+1,b+n+1);
	sort(c+1,c+n+1);
	res[0]=0;
	for(int i=1,j;i<=n;i++)
	{
		j=lower_bound(a+1,a+n+1,b[i])-a;
		j--;
		res[i]=res[i-1]+j;
	}
	res2=0;
	for(int i=1,j;i<=n;i++)
	{
		j=lower_bound(b+1,b+n+1,c[i])-b;
		j--;
		res2+=res[j];
	}
	cout<<res2<<"\n";
}

int main()
{
	std::ios::sync_with_stdio(0);
	cin.tie(0);
#ifdef localProject
	freopen("in.txt","r",stdin);
#endif
	solve();
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007ll
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define sorrev(v) sort(v.begin(),v.end(),greater<ll>())
#define uni(v) unique(v.begin(),v.end())
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 
auto random_address = [] { char *p = new char; delete p; return sll(p); };
const sll SEED = chrono::steady_clock::now().time_since_epoch().count() * (random_address() | 1);
mt19937_64 rng(SEED);

int main()
{
    FAST;
    ll n,k;
    cin>>n>>k;
    ve<ll> l(k),r(k),dp(n+2,0),vis(n+2,0);
    for(ll i=0;i<k;i++)
        cin>>l[i]>>r[i];
    dp[1]=1;
    dp[2]=-1;
    ll sum=0;
    vis[1]=1;
    vis[2]=-1;
    for(ll i=1;i<=n;i++)
    {   
        sum=(sum+dp[i])%B;
        vis[i]+=vis[i-1];
        if(vis[i]!=0)
        {
            for(ll j=0;j<k;j++)
            {
                if(l[j]+i<=n+1)
                {
                    dp[l[j]+i]=(dp[l[j]+i]+sum)%B;
                    vis[l[j]+i]++;
                }
                if(r[j]+i+1<=n+1)
                {
                    dp[r[j]+i+1]=(dp[r[j]+i+1]-sum)%B;
                    vis[r[j]+i+1]--;
                }
            }
        }
    }
    cout<<(sum+B)%B;
    subt;
    return 0;
}


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

#if __has_include("print.hpp")
  #include "print.hpp"
#endif

#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define MOD 1000000007

typedef long long ll;
typedef pair<int, int> p;


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  int mujun = 0;
  for (int i = 0; i < n; i++) {
    cin >> v[i];
    if(v[i] != i+1) mujun++;
  }
  if(mujun == 2 || mujun == 0){
    cout << "YES" << endl;
  }else{
    cout << "NO" << endl;
  }

}


Measured memory_bytes: 256
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;


struct edge
{
	long long to; long long len;
	bool operator<(const edge& rhs) const {
		return len > rhs.len;
	}
};

ll f(ll n, ll p) {
	ll ans = 1;
	for (ll i = 2; i*i <= p; i++) {
		ll cnt = 0;
		while (p%i == 0) {
			cnt++;
			p /= i;
		}
		//cout << cnt << " " <<p <<" "<< i << endl;
		REP(j, 1, cnt / n) {
			ans *= i;
		}
	}
	return ans;
}

int main() {
	ll n, p;
	cin >> n >> p;
	if (n == 1) {
		cout << p << endl;
		return 0;
	}
	ll ans = f(n, p);
	cout << ans << endl;
}

Measured memory_bytes: 256
/*  
    Come feed the rain
	Cos I'm thirsty for your love
	Dancing underneath the skies of lust
	Yeah feed the rain...
	Cos without your love my life
	Ain't nothing but this carnival of rust
    _________________________
    _________________________
    816 Hours of Solitude
    Quarantine_Day : 34
*/

#include<bits/stdc++.h>

using namespace std;

typedef long long int       ll;
typedef vector<int>         vi;
typedef vector<ll>          vl;
typedef pair<int, int>      pii;

#define pb(n)           push_back(n)
#define GSORT(v)        sort(v.begin(), v.end(), greater<int>())
#define SORT(v)         sort(v.begin(), v.end());
#define REV(v)          reverse(v.begin(), v.end());
#define db(a)           cout<<#a<<" = "<<a<<endl;
#define FIN             freopen("in.txt","r",stdin);
#define FOUT            freopen("out.txt","w",stdout);
#define REP(i,n)        for(int i = (int)(0); i < (int)(n); i++)
#define FOR(i, a, b)    for(int i = (int)a; i <= (int)b; i++)    

#define MAX 50005

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

	ll n; cin>>n;
	vl v(n + 5);
	
	ll sum = 0;
	FOR(i, 1, n){
		cin>>v[i];
		sum += v[i];
	}
	ll m; cin>>m;
	REP(i, m){
		ll p, x;
		cin>>p>>x;
		ll temp = sum;
		temp -= v[p];
		temp += x;
		cout<<temp<<"\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
template <class T>
bool chmax(T &a, const T &b)
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b)
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    int A, B, C, D, E, F;
    double ans = 0;
    cin >> A >> B >> C >> D >> E >> F;
    for (int n = 0; 100 * n * A <= F; n++)
    {
        for (int m = 0; 100 * n * A + 100 * m * B <= F; m++)
        {
            if (n == m and n == 0)
            {
                continue;
            }
            int W = 100 * (n * A + m * B);
            for (int l = 0; l * C + W <= F and l * C <= W * E / 100; l++)
            {
                int k = 1;
                while (l * C + k * D + W <= F and l * C + k * D <= W * E / 100)
                {
                    k++;
                }
                k--;
                int s = l * C + k * D;
                chmax(ans, (double)(100 * s) / (double)(W + s));
            }
        }
    }
    for (int n = 0; 100 * n * A <= F; n++)
    {
        for (int m = 0; 100 * n * A + 100 * m * B <= F; m++)
        {
            if (n == m and n == 0)
            {
                continue;
            }
            int W = 100 * (n * A + m * B);
            for (int l = 0; l * C + W <= F and l * C <= W * E / 100; l++)
            {
                int k = 1;
                while (l * C + k * D + W <= F and l * C + k * D <= W * E / 100)
                {
                    k++;
                }
                k--;
                int s = l * C + k * D;
                if (abs(ans - (double)(100 * s) / (double)(W + s)) < 1e-6)
                {
                    cout << W + s << " " << s;
                    return 0;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

if n % 2 == 1:
    a = [i for i in range(1, m+1)]
    b = [i for i in reversed(range(m+1, 2*m+1))]
    ab = [(x, y) for x, y in zip(a, b)]
else:
    ab = []
    x, y = (n-1)//2, n//2
    if x % 2 != 0:
        x, y = y, x

    evenl = 1
    evenr = x
    while evenl < evenr:
        ab.append((evenl, evenr))
        evenl += 1
        evenr -= 1

    oddl = x+1
    oddr = n-1
    while oddl < oddr:
        ab.append((oddl, oddr))
        oddl += 1
        oddr -= 1

    ab = ab[:m]


for a, b in ab:
    print(a, b)

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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>h(n); for(auto&&i:h)cin>>i;
	h.emplace_back(0),h.emplace_back(0);
	vector<int>dp(n+2,1e9+1); dp.front()=0;
	for(int i=0;i<n;++i){
		dp.at(i+1)=min(dp.at(i+1),dp.at(i)+abs(h.at(i+1)-h.at(i)));
		dp.at(i+2)=min(dp.at(i+2),dp.at(i)+abs(h.at(i+2)-h.at(i)));
	}
	cout<<dp.at(n-1)<<"\n"s;
}


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

#define all(v) v.begin(), v.end()
typedef long long ll;

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

    ll ans = 0;
    if(a[0] > x){
        ans += a[0] - x;
        a[0] = x;
    }
    for(int i = 1; i < n; i++){
        if(a[i] + a[i - 1] > x){
            ll tmp = a[i] + a[i - 1] - x;
            ans += tmp;
            a[i] -= tmp;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 1024
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	int r, D, x;
	cin >> r >> D >> x;

	rep(i, 0, 10)
	{
		x = r * x - D;
		cout << x << endl;
	}

	return 0;
}

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

int main(void)
{
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;
    cin >> k;

    cout << a[k-1] << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#define N 25010
#define M 410
#define ll long long
#define mod 1000000007
using namespace std;
int num[N],n,m,k;
int cnt[N];
ll ksm(ll a,ll b=mod-2)
{
	ll ans=1;
	for(;b;b>>=1)
	{
		if(b&1) ans=ans*a%mod;
		a=a*a%mod;
	}
	return ans;
}
bool is_colorful()
{
	if(m<k) return false;
	int res=0;
	for(int i=1;i<=m;i++)
	{
		if(i>k) res-=(--cnt[num[i-k]])<=0;
		res+=(++cnt[num[i]])==1;
		if(res==k) return true;
	}
	return false;
}
bool have_same()
{
	if(m>k) return true;
	memset(cnt,0,sizeof(cnt));
	for(int i=1;i<=m;i++)
	if(cnt[num[i]]++) return true;
	return false;
}
ll f[N][M],g[N][M],fac[N],inv[N];
ll sf[M],sg[M];
ll work1()
{
	sf[0]=sg[0]=f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=min(i,k);j++)
		{
			f[i][j]=(f[i][j]+sf[j]+f[i-1][j-1]*(k-j+1)%mod)%mod;
			g[i][j]=(g[i][j]+sg[j]+g[i-1][j-1]*(k-j+1)%mod)%mod;
			if(j>=m) g[i][j]=(g[i][j]+f[i][j])%mod;
		}
		for(int j=k-1;j>=0;j--)
		sf[j]=(sf[j+1]+f[i][j])%mod,sg[j]=(sg[j+1]+g[i][j])%mod;
	}
	ll ans=0;
	for(int i=1;i<k;i++) ans=(ans+g[n][i])%mod;
	return ans*fac[k-m]%mod*inv[k]%mod;
}
ll C(int a,int b){return b>a?0:fac[a]*inv[b]%mod*inv[a-b]%mod;}
ll work2()
{
	sf[0]=f[0][0]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=min(i,k);j++) f[i][j]=(f[i][j]+sf[j]+f[i-1][j-1]*(k-j+1)%mod)%mod;
		sf[k]=0;
		for(int j=k-1;j>=0;j--) sf[j]=(sf[j+1]+f[i][j])%mod;
	}
	memset(cnt,0,sizeof(cnt));
	int l,r;
	for(l=1;l<=m;l++) if(cnt[num[l]]++) break;
	--l;
	memset(cnt,0,sizeof(cnt));
	for(r=m;r;r--) if(cnt[num[r]]++) break;
	r=m-r;
	ll ans=0;
	for(int i=l;i+m-l<=n;i++)
	{
		ll res1=0,res2=0;
		for(int j=l;j<k;j++) res1=(res1+f[i][j]*fac[k-j]%mod*inv[k]%mod*C(k-l,j-l)%mod*fac[j-l]%mod)%mod;
		for(int j=r;j<k;j++) res2=(res2+f[n-(i-l+m)+r][j]*fac[k-j]%mod*inv[k]%mod*C(k-r,j-r)%mod*fac[j-r]%mod)%mod;
		ans=(ans+res1*res2%mod)%mod;
	}
	return ans;
}
int main()
{
	scanf("%d%d%d",&n,&k,&m);
	for(int i=1;i<=m;i++) scanf("%d",&num[i]);
	fac[0]=1;
	for(int i=1;i<=M;i++) fac[i]=fac[i-1]*i%mod;
	inv[M]=ksm(fac[M]);
	for(int i=M-1;i>=0;i--) inv[i]=inv[i+1]*(i+1)%mod;
	ll ans=ksm(k,n-m)*(n-m+1)%mod;
	if(is_colorful()){printf("%lld\n",ans);return 0;}
	if(have_same()){printf("%lld\n",(ans-work2()+mod)%mod);return 0;}
	printf("%lld\n",(ans-work1()+mod)%mod);
	return 0;
}


Measured memory_bytes: 160512
n,k=map(int,input().split())
mod=10**9+7
ans=0
for kk in range(k,n+2):
  mi=kk*(kk-1)//2
  ma=n*(n+1)//2-(n-kk)*(n-kk+1)//2
  ans+=ma-mi+1
  ans%=mod
print(ans)

Measured memory_bytes: 9192
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBUG = false;

struct info
{
    ll x;
    ll y;
    ll h;
};

bool cmp( const info &a, const info &b){
    return a.h < b.h;
}

int main(){

    int N;
    cin >> N;

    vector<info> v(N);

    for(int i = 0; i < N; i++){
        cin >> v[i].x >> v[i].y >> v[i].h;
    }
    sort(rall(v), cmp);

    for(int cx = 0; cx <= 100; cx ++){
        for(int cy = 0; cy <= 100; cy ++){
            bool init = false;
            ll H = 1e10;
            bool ans = true;
            for(int i = 0; i < N; i++){
                if(!init){
                    H = v[i].h + abs(v[i].x - cx) + abs(v[i].y - cy);
                    init = true;
                }
                if(init){
                    if( v[i].h != max( H - abs(v[i].x - cx) - abs(v[i].y - cy), 0ll ) ) {
                        ans = false;
                        break;
                    }
                }
            }
            if(ans){
                cout << cx << " " << cy << " " << H << endl;
                return 0;

            }
        }
    }

}

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

int main() {
  int A, B;
  cin >> A >> B;

  if ((1 <= A) && (A <= 9) && (1 <= B) && (B <= 9)) {
    cout << A * B << endl;
  } else {
    cout << "-1" << endl;
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <ctype.h>

#define MAX_N 2000001
#define MAX_K 10001

char buf[MAX_N*5];

int getInteger();
void countingSort(int,int*);

int main(){
  int n,i;
  static int A[MAX_N];
  fread(buf,1,MAX_N*5,stdin);
  n = getInteger();
  for(i = 0 ; i < n ; i++){
    A[i] = getInteger();
  }
  countingSort(n,A);
  return 0;
}

int getInteger(){
  int res = 0;
  static int c = 0;
  while(isdigit(buf[c])){
    res *= 10;
    res += (buf[c++]-'0');
  }
  c++;
  return res;
}

void countingSort(int n,int *A){
  int i,C[MAX_K] = {0};
  static int B[MAX_N];
  for(i = 0 ; i < n ; i++){ C[A[i]]++; }
  for(i = 1 ; i < MAX_K ; i++){ C[i] += C[i-1]; }
  for(i = n-1 ; i >= 0 ; i--){
    B[C[A[i]]] = A[i]; C[A[i]]--;
  }
  for(i = 0 ; i < n ; i++){
    printf("%d%c",B[i+1],i < n-1 ? ' ' : '\n');
  }
}


Measured memory_bytes: 27020
#include<bits/stdc++.h> 
using namespace std;
long long n;
long long f[17*9+10];
int main()
{
	for(int i=1;i<=17*9;i++)
	{
		long long x=i;
		f[i]=x%9;
		x-=x%9;
		while(x)
		{
			f[i]=f[i]*10+9;
			x-=9;
		}
	}
	cin>>n;
	cout<<upper_bound(f,f+17*9,n)-f-1<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <bits/stdc++.h>
#include <iostream>
#include <math.h>
using namespace std;
int main() {
    int D, N;
    cin >> D >> N;
    int n = pow(100, D);
    if (N == 100) {
        N += 1;
    }

    int ans = n * N;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
MOD = int(1e9) + 7


def binsearch(num, ary):
    left = 0
    right = len(ary)
    while left < right:
        center = (left + right) // 2
        if num <= ary[center]:
            left = center + 1
        else:
            right = center
    return left


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    sortA = sorted(A, reverse=True)
    sortB = sorted(B, reverse=True)
    for i in range(1, N):
        if sortA[i] == sortA[i-1]:
            print(0)
            return
    for j in range(1, M):
        if sortB[j] == sortB[j-1]:
            print(0)
            return
    retval = 1
    for num in range(N*M, 0, -1):
        just = 1
        icandidates = binsearch(num, sortA)
        jcandidates = binsearch(num, sortB)
        if icandidates >= 1 and sortA[icandidates-1] == num:
            icandidates = 1
            just = 0
        if jcandidates >= 1 and sortB[jcandidates-1] == num:
            jcandidates = 1
            just = 0
#        print(icandidates, jcandidates, sortA, num)

        retval *= icandidates * jcandidates - (N*M - num) * just
        retval %= MOD

    print(retval)


if __name__ == "__main__":
    main()


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

long long arr[52][3000][52]; int x[51];
int main(){
    int n, avg;
    cin>>n>>avg;
    for(int i =1; i<n+1; i++){
        cin>>x[i];
    }
    
    for(int i=1; i<n+1; i++){
        arr[i-1][0][0]=1;
        for(int j=0; j<2700; j++){
            for(int z=0; z<n+1; z++){
                arr[i][j+x[i]][z+1]+=arr[i-1][j][z]; 
                arr[i+1][j][z]=arr[i][j][z];
            }
        }
    }
    
    long long answer =0;
    
    for(int i=0; i<n+1; i++){
        answer+=arr[n][i*avg][i];
    }
    
    cout<<answer;
    return 0;
}

Measured memory_bytes: 62208
#include<stdio.h>

int main(){
  int n,y,sa;
  scanf("%d %d", &n,&y);
  sa = y - 1000*n;
  for(int i=0;i<=n;++i){
    if(sa == 4000*i){
      printf("0 %d %d\n", i,n-i);
      return 0;
    }else{
      for(int j=0;j<=n-i;++j){
        if(sa == 4000*i + 9000*j){
          printf("%d %d %d\n", j,i,n-i-j);
          return 0;
        }
      }
    }
  }
  printf("-1 -1 -1\n");
  return 0;
}


Measured memory_bytes: 128
N = int(input())
robots = [tuple(map(int,input().split())) for _ in range(N)]
 
robots = [(x+l,x-l) for x,l in robots]
 
robots.sort()
 
cnt = 0
last = -float('inf')
for r,l in robots:
    if last <= l:
        cnt += 1
        last = r
 
print(cnt)

Measured memory_bytes: 30036
#include<bits/stdc++.h>
#define ll long long int
#define pb push_back
#define PB push
#define N 100005
#define nd second
#define st first
#define ii pair<ll,ll>
#define p_q priority_queue
using namespace std;

ll n, eb;
string s;
map <string, ll> mp;
set <string> se;

int main(){
	cin >> n;
	while(n--){
		cin >> s;
		se.insert(s);
		mp[s]++;
		if(mp[s] > eb)
			eb = mp[s];
	}
	for(auto itr = mp.begin(); itr != mp.end(); itr++){
		if(itr->second == eb)
			cout << itr->first << endl;

	}

return 0;
}

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

const long long INF = 1LL << 60;

int main() {
  int n, k, x, cnt=0;
  cin >> n >> k;
  
  int A[n+100],B[n+100];
  
  rep(i,n+10){
  	B[i] = 0;
  }
  
  rep(i,n){
    cin >> A[i];
    B[A[i]]++;
  }
  
  sort(B,B+n+1);

  
  for(int i=1;i<=n;i++){
    if(B[i])
      cnt++;
  }
  //cnt種類のボールがある
  

  int res=0;
  if(cnt > k){
    for(int i=1;i<=n-k;i++){
      res += B[i];
    }
  }
  
  cout << res << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const long long mod = 1e9 + 7;

const int N = 200200;
long long p2[N];
long long gcd(long long a, long long b)
{
	return b ? gcd(b, a % b) : a;
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	p2[0] = 1; 
	for (int i=1; i<N; i++){
		p2[i] = (p2[i-1]*2)%mod;
	} 
	int n;
	cin>>n;
	
	map<pair<long long, long long>, pair<int, int>> m;
	long long zeros = mod-1;
	
	for (int i=0; i<n; i++){
		long long a, b;
		cin>>a>>b;
		if (a==0 && b==0) {
			zeros++;
			continue;
		}
		
		long long g = gcd(abs(a), abs(b));
		a /= g;
		b /= g;
		
		if (a>0 and b>0){
		  m[{b, a}].first++;
		}
		else if (a<0 and b<0){
		  m[{-b,-a}].first++;
		}
		else if(a>0 and b<0){     
		  m[{a,-b}].second++;
		}
		else if (a<0 and b>0){
		  m[{-a, b}].second++;
		}
		else if ((a==0 and abs(b)==1)){
		  m[{1, 0}].first++;
		}
		else if ((b==0 and abs(a)==1)){
		  m[{1, 0}].second++;
		}		
	}

	long long ans = 1;
	for (auto e: m){
		pair<int, int> cnt = e.second;
		ans = ans * (p2[cnt.first] + p2[cnt.second] - 1) % mod;
	}
	ans = (ans+zeros)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 17532
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    unordered_set<string> s;
    int n;
    cin >> n;
    while (n--) {
        string ss;
        cin >> ss;
        s.insert(ss);
    }
    cout << s.size() << endl;
}


Measured memory_bytes: 17752
#include<iostream>
#include<queue>
#include<string>
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<iomanip>
#include<cstdlib>
#include<ctime>
#include<set>
#include<map>
#include<utility>
#include<vector>
#include<stack>
#include<sstream>
#include<algorithm>
using namespace std;
/****************************/
#define ll long long
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pair<int,int> >
#define qi queue<int>
#define mii map<int,int>
#define msi map<string,int>
#define vs vector<string>
#define vc vector<char>
/****************************/
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep2(i,n) for(ll i=(n)-1;i>=0;i--)
#define rep3(i,a,n) for(ll i=(a);i<(n);i++)
#define rep4(i,a,n) for(ll i=(a)-1;i>=n;i--)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define pi 3.1415926535897932384626433832795
#define zero(n) memset(n,0,sizeof(n));
#define SZ(n) n.size()
#define sn st.nd 
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
/****************************/
int n;
int a[200010];
bool cmp(int a,int b)
{
	return a>b;
}
int main()
{
	cin>>n;
	rep(i,n)
	{
		cin>>a[i];
	}
	sort(a,a+n,cmp);
	ll ans=0;
	queue<int> q;
	while(!q.empty()) q.pop();
	q.push(a[0]);
	rep3(i,1,n)
	{
		ans+=q.front();
		q.pop();
		q.push(a[i]);
		q.push(a[i]);
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 5020
n, m = map(int, input().split())
x = sorted(list(map(int, input().split())))
val = []
if n >= m:
    print(0)
    exit()

for i in range(m-1):
    p = x[i+1]-x[i]
    val.append(p)
val.sort()
print(sum(val[:m-n]))

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

using namespace std;

int main(){
    int N;
    cin >> N;
    vector<int> h(N);
    for(int i = 0; i < N; i++){
        cin >> h[i];
    }
    
    int ans = 0;
    int height = 0;
    
    for(int i = 0; i < N; i++){
        if(h[i] > height){
            ans += h[i] - height;
            height = h[i];
        }
        else{
            height = h[i];
        }
    }
    
    cout << ans << endl;
}

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

 
 
using namespace std;
 
 
int main() {
    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
 
    vector<int> p(a); for (int i=0; i<a; i++) cin >> p[i];
    vector<int> q(b); for (int i=0; i<b; i++) cin >> q[i];
    vector<int> r(c); for (int i=0; i<c; i++) cin >> r[i];
 
    sort(p.begin(), p.end(), greater<int>());
    sort(q.begin(), q.end(), greater<int>());
    sort(r.begin(), r.end(), greater<int>());
 
    vector<int> s;
    for (int i=0; i<x; i++) s.push_back(p[i]);
    for (int i=0; i<y; i++) s.push_back(q[i]);
 
    sort(s.begin(), s.end());
 
    int cur = 0;
    long long ans = 0;
    for (int i=0; i<x+y; i++) {
        if (cur < x+y and r[cur] > s[i]) {
            ans += r[cur];
            cur++;
        }
        else {
            ans += s[i];
        }
    }
 
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2552
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N;
ll L[MAX_N], R[MAX_N];

void solve() {
	cin >> N;
	rep(i, 0, N) {
		cin >> L[i] >> R[i];
		L[i] *= -1;
	}
	L[N] = 0; R[N] = 0;
	N++;
	ll res = 0;
	sort(L, L + N); sort(R, R + N);
	ll sl = 0, sr = 0;
	rep(i, 0, N) {
		sl += L[i]; sr += R[i];
		MAX(res, -(sl + sr));
	}
	cout << 2 * res << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>

using namespace std;

typedef long long ll;

ll n;
ll a[300005];

int main()
{
    ll ans = 0;
    ll cnt = 0;
    
    cin >> n;
    for (ll i = 0; i < 3 * n; i++) {
        cin >> a[i];
    }

    sort(a, a + (3 * n), greater<ll>());

    for (ll i = 1, cnt = 0; cnt < n; i += 2, cnt++) {
        ans += a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
def B_NotFound(lst):
    comparison = 'abcdefghijklmnopqrstuvwxyz'
    lst = sorted(set(lst))  # 文字列をソート(重複はいらないので除く)

    string = [''] * len(comparison)
    for i in range(len(lst)):
        string[i] = lst[i]

    for i in range(len(string)):
        if string[i] != comparison[i]:
            return comparison[i]
    return 'None'

s = input()
print(B_NotFound(s))

Measured memory_bytes: 3188
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
string a,b;
int main()
{
  cin>>a>>b;
  int ans;
  ans=b.size();
  int n=a.size(),m=b.size();
  for (int i=0;i<n;i++)
  {
  	int tot=0;
  	if (i+m-1>=n) break;
    for (int j=0;j<m;j++)
    {
      if (a[i+j]!=b[j]) tot++;
    }
    if (tot<ans) ans=tot;
  }
  printf("%d\n",ans);
  return 0;	
} 

Measured memory_bytes: 3744
N = int(input())
xy = [list(map(int,input().split())) for _ in range(N)]

def search(i,j):
    p = xy[i][0]-xy[j][0]
    q = xy[i][1]-xy[j][1]
    res = N
    for k in range(N):
        for l in range(N):
            if xy[k][0]-xy[l][0]==p and xy[k][1]-xy[l][1]==q:
                res -= 1
    return res

ans = N
for i in range(N):
    for j in range(N):
        if i!=j:
            ans = min(ans,search(i,j))
print(ans)

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

int main()
{
	long long int N,tmp,res=0,lim=2;
	cin >> N;

	for(int i=0;i<N;i++){
		cin>>tmp;
		if(i==0){
		res = tmp-1;
		}else if(tmp > lim){
			res=res+(tmp/lim);
			if(tmp%lim==0){
			res--;
				}
			}else if(tmp ==lim){
			lim=lim+1;
			}
	}
	cout<<res<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main ()
{
  int N,A,B,X;
  scanf("%d %d %d",&N,&A,&B);
  X=N*A;
  if(X<B)
  {
       printf("%d",X);
  }
  else if (X>B)
  {
      printf("%d",B);
  }
  else if (X=B)
  {
       printf("%d",B);
  }
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A;
  cin >> A;
  vector<string> week;
  week = {"SAT", "FRI", "THU", "WED", "TUE", "MON", "SUN"};
  for(int i = 0; i < 7; i++) {
    if(A == week.at(i)) {
      cout << i + 1 << endl;
    }
  }
}

Measured memory_bytes: 3604
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <iostream>

using namespace std;

#define rep(i, N) for (int i = 0; i < N; ++i)


int main() {
    int n, strMax = 12;
    scanf("%d", &n);
    char action[strMax], key[strMax];
    char *ins = "insert";
    char *fin = "find";
    map<string, bool> data;
    rep(i, n) {
        scanf("%s %s", action, key);
        if (strcmp(ins, action) == 0) {
            data[key] = 1;
        } else if (strcmp(fin, action) == 0) {
            if (data[key] == 1) {
                printf("yes\n");
            } else {
                printf("no\n");
            }
        }
    }

    return 0;
}


Measured memory_bytes: 47524
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] input = Console.ReadLine().Split(' ');
            int N = int.Parse(input[0]);
            int i = int.Parse(input[1]);

            int result = (N - i) +1;

            Console.WriteLine(result);
        }
    }
}

Measured memory_bytes: 11092
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>

using namespace std;

int N;
int A[100000], B[100000], C[100000];
int smaller[100000], bigger[100000];
int p;
long long ans;

int main() {
	scanf("%d", &N);
	for (int i = 0; i < N; i++) {
		scanf("%d", &A[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &B[i]);
	}
	for (int i = 0; i < N; i++) {
		scanf("%d", &C[i]);
	}

	sort(A, A + N);
	sort(B, B + N);
	sort(C, C + N);

	/*各iに対して、B[i] < C[j]となるjの個数を数える*/
	p = 0;
	for (int i = 0; i < N; i++) {
		while (B[i] >= C[p] && p < N) {
			p++;
		}
		bigger[i] = N - p;
	}
	/*	
	for (int i = 0; i < N; i++) {
		printf("bigger[%d] = %d\n", i, bigger[i]);
	}
	*/

	p = N-1;
	for (int i = N-1; i >= 0; i--) {
		while (B[i] <= A[p] && p >= 0) {
			p--;
		}
		smaller[i] = p+1;
	}
	/*
	for (int i = 0; i < N; i++) {
		printf("smaller[%d] = %d\n", i, smaller[i]);
	}
	*/

	ans = 0;
	for (int i = 0; i < N; i++) {
		ans = ans + (long long)bigger[i] * smaller[i];
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 2176
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>
#include <unordered_set>
#include <unordered_map>

using namespace std;
typedef long long ll;
typedef pair<int,int> pii;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
#define rep(i, n) for(int i = 0;i < n;i++)
const int INF = 1LL << 30;

int MOD = 1000000007;

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

    int a,b,x; cin >> a >> b >> x;

    double s = (x+0.0)/(a+0.0);

    double deg = 0.0;

    if(s>=(a+0.0)*(b+0.0)/2.0){

        double h = ((a*b)+0.0-s)*2/(a+0.0);

        deg = atan2(h, a) * 180.0 / acos(-1);

    } else {

        double a_ = 2*s/(b+0.0);


        deg = atan2(b, a_) * 180.0 / acos(-1);

    }

    cout << setprecision(20) << deg  << endl;

    return 0;
}

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

//typedef
//------------------------------------------
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define PB push_back
#define MP make_pair
#define SORT(c) sort((c).begin(),(c).end())
#define COUT(x) cout<<x<<endl

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double PI = acos(-1.0);
const LL MOD = 1e9 + 7;
const ULL INF = 1e18;
const int dx[]{ 1,-1,0,0 }, dy[]{ 0,0,1,-1 };

//function
//--------------------------------------------
LL gcd(LL, LL);
bool isEven(LL);
void coutY();
void coutN();
LL ave(LL, LL);

int main() {
	int n; cin >> n;
	cout << "ABC" << n;
}

LL gcd(LL a, LL b) {
	if (a == 0 || b == 0)return 0;
	if (a < b)swap(a, b);
	if (a % b == 0)return b;
	else gcd(b, a % b);
}
bool isEven(LL a) {
	return !((bool)(a % 2));
}
void coutY() {
	cout << "Yes" << endl;
	return;
}
void coutN() {
	cout << "No" << endl;
	return;
}
LL ave(LL a, LL b) {
	return (a + b) / 2;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
//cout<<setprecision(20)
const llint mod=1000000007;
const llint big=1e17+10;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-9;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
int LBI(vector<int>&ar,int in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
int UBI(vector<int>&ar,int in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}
int main(void){
	int i,a,b,ans=0;cin>>a>>b;
	for(i=a;i<=b;i++){
		if(i/10000==i%10 && (i/1000)%10==(i/10)%10){ans++;}
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

bool is_inside(int H, int W, int y, int x, int r) {
    if (x - r < 0 || W < x + r) return false;
    if (y - r < 0 || H < y + r) return false;
    return true;
 }

int main() {
    int W, H, x, y, r;
    std::cin >> W >> H >> x >> y >> r;

    std::cout << (is_inside(H, W, y, x, r) ? "Yes" : "No") << std::endl;
}



Measured memory_bytes: 3092
#include <algorithm>
#include <climits>
#include <iostream>

using namespace std;

int main(void)
{
	int N;
	cin >> N;
	int W;
	cin >> W;
	int w[N], v[N];
	for (int i = 0; i < N; i++) {
		cin >> w[i] >> v[i];
	}
	unsigned long long d[N][W+1];
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < W+1; j++) {
			d[i][j] = 0;
		}
	}
	for (int j = w[0]; j < W+1; j++)
		d[0][j] = v[0];
	for (int i = 1; i < N; i++) {
		for (int j = 1; j < W+1; j++) {
			unsigned long long a = 0, b = 0;
			if (j >= w[i]) {
				a = d[i-1][j-w[i]] + v[i];
			}
			b = d[i-1][j];
			d[i][j] = max(a, b);
		}
	}
	cout << d[N-1][W] << endl;

	return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)


int main(void){
  string a,b;
  cin>>a>>b;
  if(a.size()>b.size())cout<<"GREATER";
  else if(a.size()<b.size())cout<<"LESS";
  else if(a.size()==b.size()){
      if(a==b)cout<<"EQUAL";
      else if(a>b)cout<<"GREATER";
      else if(a<b)cout<<"LESS";
  }
  cout<<endl;


  return 0;
}


Measured memory_bytes: 256