akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <queue>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define INF 1e9 + 1
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define REP(i, n) for (int i = 0; i < n; i++)
using namespace std;

int n, A[110];
int i, j, v;

void print(int n, int A[]) {
    REP(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

void insertionSort(int n, int A[]) {
    for (i = 1; i < n; i++) {
        v = A[i];
        j = i - 1;
        while (j >= 0 && A[j] > v) {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = v;
        print(n, A);
    }
}

int main() {
    cin >> n;
    REP(i, n) cin >> A[i];
    print(n, A);
    insertionSort(n, A);
}


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

#define REP(i, n) for(int (i) = 0; (i) < (int)(n); (i)++)
#define REPR(i, n) for(int (i) = (n); (i) >= 0; (i)--)
#define FOR(i, m, n) for(int (i) = (m); (i) < (n); (i)++)
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 1e9

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 long long ll;

using namespace std;

int main(int argc, char const *argv[])
{
    int N;
    cin >> N;
    vector<int> A(N, INF);
    REP(i, N) cin >> A[i];
    
    sort(ALL(A));

    cout << A[N-1] - A[0] << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define F first
#define S second
#define INF 3000000000
#define inf -10000000
#define pb push_back
#define forr(i,p,n) for(int i=p;i<n;i++)
#define mpk make_pair
#define upb(a,s) upper_bound(a.begin(),a.end(),s)
#define lwb(a,s) lower_bound(a.begin(),a.end(),s)
#define D(x) cout << #x " = " << (x) << endl
#define mem(a,val) memset(a,val,sizeof a)
#define ulti(a) for(int i=0;i<a.size();i++)cout<<a[i]<<" "
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ii> vii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
//priority_queue<ll> pq;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie();
    ll a,b,c,d,n,t,m,k;
    cin>>n;
    ll mini=INF;
    vi v;
    forr(i,0,n){
      cin>>a;
      v.pb(a);
    }
    ll ans=0;
    forr(i,0,n){
      if(v[i]<mini){
	ans++;
      }
      mini=min(mini,v[i]);
    }
    cout<<ans<<endl;
}


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

int main() {
	string S; cin >> S;
	bool flag=true;
	for(int i=1; i<S.size(); ++i){
	    if(i>1){
	        if(S[i-2]==S[i]){
	            flag=false;
	            cout << i-1 << ' ' << i+1 << endl;
	            break;
	        }
	    }
	        if(S[i-1]==S[i]){
	            flag=false;
	            cout << i << ' ' << i+1 << endl;
	            break;
	        }
	}
	if(flag) cout << -1 << ' ' << -1 << endl;
	return 0;
}


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

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
ostream &operator<<(ostream &os, pair<ll, ll>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,0,n){
    cin>>a[i];a[i]--;
  }
  vector<ll>idx(n);
  rep(i,0,n)idx[a[i]]=i;
  ll now=0,cnt=0;
  rep(i,0,n){
    if(now<=idx[i]){
      now=idx[i];
      cnt++;
    }
    else{
      chmax(res,cnt);
      cnt=1;
      now=idx[i];
    }
  }
  chmax(res,cnt);
  cout<<n-res<<endl;
  return 0;
}

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

int main() {
    int h,w;
    while(1){
        cin>>h>>w;
        if(h==0 && w==0){
            break;
        }
        for(int i=0;i<h;i++){
          if(i%2==0){
            for(int j=0;j<w;j++){
              if(j%2==0){
                cout<<"#";
              }else{
                cout<<".";
              }
            }
          }else{
            for(int j=0;j<w;j++){
              if(j%2!=0){
                cout<<"#";
              }else{
                cout<<".";
              }
            }
          }
        cout<<endl;
      }
      cout<<endl;
    }
}


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

if n == 100000:
    print(90909)
elif n <= 99999 and n >= 10000:
    print(n - 9999 + 909)
elif n <= 9999 and n >= 1000:
    print(909)
elif n <= 999 and n >= 100:
    print(n - 99 + 9)
elif n <= 99 and n >= 10:
    print(9)
elif n <= 9:
    print(n)

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B > C + D) {
        cout << "Left" << endl;;
    } else if (A + B < C + D) {
        cout << "Right" << endl;
    } else {
        cout << "Balanced" << endl;
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

const int N = 100007;
const int M = 1e9 + 7;

int f[2][N];
int acc[N];

int a[N];

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

    for(int i = 0; i < n; ++i) cin >> a[i];
    // pra 0
    f[0][0] = 1;
    for(int j = 0; j <= k; j++) {
        acc[j] = 1;
    }

    int cur = 1;
    for(int i = 0; i < n; ++i) {
        for(int j = 0; j <= k; ++j) {
            f[cur][j] = acc[j];
            if(j - a[i] > 0) f[cur][j] = (f[cur][j] - acc[j - a[i] - 1] + M)%M;
        }

        acc[0] = f[cur][0];
        for(int j = 1; j <= k; ++j) {
            acc[j] = (f[cur][j] + acc[j-1])%M;
        }
        cur = 1 - cur;
    }

    cout << f[1-cur][k] << endl;
}

Measured memory_bytes: 1408
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<climits>
#include<cstdlib>
#include<map>
#include<math.h>
#include<utility>
using namespace std;
typedef long long ll;

int main(){
  string a, b;
  cin >> a >> b;
  int num = stoi(a+b);
  bool flag = false;
  for(int i=1; i<1000; i++){
    if(i*i==num) flag = true;
  }
  if(flag) cout << "Yes" << endl;
  else cout << "No" << endl;
}



Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define F first
#define S second
ll mod=1000000007;

int main(){
    std::ios::sync_with_stdio(false);
    int a,b;
    cin>>a>>b;
    //a--;
    for(int i=b-a+1;i<b;i++)cout<<i<<" ";
    for(int i=b;i<b+a;i++)cout<<i<<" ";

    return 0;
}


Measured memory_bytes: 256
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "ctime"

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(begin, i, end) for (int i = begin; i < (int)(end); i++)
#define all(v) v.begin(), v.end()
const int MOD = 1000000007;

int main()
{
    string S;
    cin >> S;
    ll N = stol(S);
    ll f = 0;
    ll size = S.size();
    rep(0, i, size)
    {
        f += S.at(i) - '0';
    }

    if (N % f == 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include<map>

using namespace std;


int main() {
	long long int N,H,W;
	cin >> H >> W >> N;
	int A[10008];
	int a;
	int k = 0;
	for (int i = 1; i <= N; i++) {
		cin >> a;
		for (int j = 0; j < a; j++) {
			A[k] = i;
			k++;
		}
		
	}
	int q = 0;
	for (int i = 0; i < H; i++) {
		if (i % 2 ==0 ) {
			for (int j = 0; j < W; j++) {
				cout << A[q] << " ";
				q++;
			}
			cout << " " << endl;
		}
		else {
			q += W-1;
			
			for (int j = 0; j < W; j++) {
				cout << A[q-j] << " ";
				
			}
			cout << " " << endl;
			q++;
		}
	}

	return 0;
}


Measured memory_bytes: 384
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    n,a,b=parseMap(split(readline()))
    println("$(min(a,b)) $(max(0,a+b-n))")
end
main()

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

using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int A[1000][1000];
int main(){
    int h, w, a, b;
    cin >> h >> w >> a >> b;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            A[i][j] = (i<b ? 1 : 0) ^ (j<a ? 1 : 0);
        }
    }
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cout << A[i][j];
        }
        cout << endl;
    }
}

Measured memory_bytes: 5120
n = int(input())
a = list(map(int, input().split()))
cnt = 0

while True:
    judge = [a[i]%2 for i in range(len(a))]
    if any(judge):
        break
    else:
        a = [a[i]//2 for i in range(len(a))]
        cnt += 1

print(cnt)


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

using namespace std;
int main(){
	string s;
	cin>>s;
	int n1=0,n2=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='0')n1++;
		else n2++;
	}
	cout<<(min(n1,n2))*2;
	return 0;
}

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

const ll p = 1e9+7;

ll n;
ll dp[20][2], m[20];

int main() {
	cin >> n;
	for (int i = 0; i < 19; ++i) {
		m[i] = n%10;
		n /= 10;
	}

	dp[19][1] = 0; dp[19][0] = -1000;

	for (int i = 18; i >= 0; --i) {
		//transition from dp[i+1][0]
		dp[i][0] = -1000;
		dp[i][0] = max(dp[i+1][0] + 9, dp[i][0]);
		if (m[i] != 0)
			dp[i][0] = max(dp[i][0], dp[i+1][1] + m[i] - 1);
		dp[i][1] = dp[i+1][1] + m[i];
	}

	cout << max(dp[0][0], dp[0][1]) << endl;
}

Measured memory_bytes: 764
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <fstream>
#include <functional>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <vector>
using namespace std;

int main(){
    int  a,b,c,d;
    cin >> a >> b >> c >>d;
    cout << (a*b > c*d ? a*b:c*d) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cctype>
#include<utility>
#include<string>
#include<cmath>
#include<numeric>
#include<map>
#include<cstdio>

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

typedef long long int ll;


typedef struct mp{

    int pre;
    int year;
    int index;

}MP;

bool comp(const MP& a,const MP& b){

    if(a.pre == b.pre){
        return a.year < b.year;
    }else{
        return a.pre < b.pre;
    }
}


int main(){

    ll n,m;
    cin >> n >> m;
    vector<MP> a(m);
    vector<string> ans(m);
    vector<int> count(n,1);//n番目の県で何番目かを記録
    REP(i,n){
        count[i] = 1;
    }

    REP(i,m){
        cin >> a[i].pre >> a[i].year;
        a[i].index = i;
    }
    sort(a.begin(),a.end(),comp);
    /*REP(i,m){
        printf("%d %d %d\n",a[i].pre,a[i].year,a[i].index);
    }*/

    REP(i,m){
        string tmp = to_string(a[i].pre);
        int len = tmp.length();
        REP(j,6-len){
            ans[a[i].index].push_back('0');
        }
        ans[a[i].index]+=tmp;
        //
        string tmp2 = to_string(count[a[i].pre-1]);
        int len2 = tmp2.length();
        //cout << len2 << " " << tmp2 << endl;
        REP(j,6-len2){
            ans[a[i].index].push_back('0');
        }
        ans[a[i].index]+=tmp2;
        count[a[i].pre-1]++;
    }

    REP(i,m){
        cout << ans[i] << endl;
    }

    return 0;
}

Measured memory_bytes: 9728
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

long long int gcd(long long int a,long long int b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b,a%b);
    }
}
long long int fac(long long int n){
    if(n==0){
        return 1;
    }
    else{
        return n*(fac(n-1))%1000000007;
    } 
}

int main(){
    long long int n,k,ans=0;
    cin>>n;
    ans+=2*((n-1)/11);
    if(n%11<7&&n%11>0){
        ans++;
    }
    else{
        ans++;
        ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
#define int ll
#define fi first
#define se second
#define SORT(a) sort(a.begin(),a.end())
#define rep(i,n) for(int i = 0;i < (n) ; i++) 
#define REP(i,n) for(int i = 0;i < (n) ; i++) 
#define MP(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define INF LLONG_MAX/2
#define INTINF INT_MAX/2
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl
#define debug_vec(v) cerr<<#v<<":";rep(i,v.size())cerr<<" "<<v[i];cerr<<endl
template<class T> inline bool chmax(T &a, T b){if(a < b){a = b;return true;}return false;}
template<class T> inline bool chmin(T &a, T b){if(a > b){a = b;return true;}return false;}
/*----------------------------------------------------------------*/
// int MOD = 998244353;
int MOD = 1000000007;

/*----------------------------------------------------------------*/
signed main(){

	int k,n;
	cin >> k >> n;
	vll a(n);
	rep(i,n)cin >> a[i];
	int maxi = 0;
	rep(i,n-1)chmax(maxi,a[i+1]-a[i]);
	chmax(maxi,a[0]+k-a[n-1]);
	cout << k-maxi << endl;
	

	

	return 0;
}
/*----------------------------------------------------------------*/

// g++ -std=c++14 code1.cpp
// sudo pip3 install --upgrade online-judge-tools
// rm -r -f test;oj dl https://code-festival-2018-quala.contest.atcoder.jp/tasks/code_festival_2018_quala_c
// rm -r -f test;oj dl https://pakencamp-2019-day3.contest.atcoder.jp/tasks/pakencamp_2019_day3_c
// rm -r -f test;oj dl https://abc160.contest.atcoder.jp/tasks/abc160_a

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-


def main():
    """Function."""
    n = str(input())
    if n[0] == n[1] and n[0] == n[2]:
        print("Yes")
    elif n[1] == n[2] and n[1] == n[3]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

int main(){
	int a,b;
	cin>>a>>b;
	int ans = 0;
	int ana=1;
	while(ana<b){
		--ana;
		ana += a;
		++ans;
	}
	cout<<ans<<endl;
	return 0;		
}

Measured memory_bytes: 384
#include <iostream>

using namespace std;

int main(void){
    char c;
    cin >> c;
    char v[5] = {'a', 'e', 'i', 'o', 'u'};
    for(int i = 0; i < 6; i++){
        if(i == 5)  cout << "consonant"<< endl;
        else if(c == v[i]){
            cout << "vowel"<< endl;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, H, W;
  cin >> N >> H >> W;
  int a, b;
  int ans = 0;
  for(int i = 0; i < N; i++){
    cin >> a >> b;
    if(a >= H && b >= W)ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define ll long long
#define ull unsigned long long
#define ii pair<int,int>
#define iii pair <int,ii>
#define iil pair<ll,ll>
#define iiil pair<ll,iil>
#define max3(a,b,c) max(a, max(b,c))
#define min3(a,b,c) min(a, min(b,c))
#define s(v) sort(v.begin(),v.end())
#define pf printf
#define sf scanf
#define MIN INT_MIN
#define MAX INT_MAX
#define accepted 0
using namespace std;
//long long int factorial(long long int n){if (n == 0)return 1;return n * factorial(n - 1);}
//
//bool prime[n];
//vector<int> v;
//void sieve(){
//    prime[0]=prime[1]=1;
//    for(int i=2;i*i<=n;i++){
//        if(prime[i]==0){
//            for(ll j = i*i;j<=n;j+=i){
//                prime[j]=true;
//            }
//        }
//    }
//    for(int i=2;i<=n;i++){
//        if(prime[i]==0)v.push_back(i);
//    }
//}
//
//bool ispalindrome(string s){
//
//    for(int i=0,j=s.size()-1;i<s.size();i++,j--){
//        if(s[i]!=s[j])
//            return false;
//    }
//    return true;
//}
#include<bits/stdc++.h>
using namespace std;
int H2D(long long x){
char a[]={(char)x};
int len = strlen(a);
int base =1,D=0;
for(int i=len-1;i>=0;i--){
    if(a[i]>='0' && a[i]<='9'){
        D+=(a[i]-48)*base;
        base*=16;
    }
    else if(a[i]>='A' && a[i]<='F'){
        D+=(a[i]-55)*base;
        base*=16;
    }
}
    return D;
}


int B2D(long long x){
long long rem,ans=0,s=0;
while(x!=0){
    rem=x%10;
    ans+=rem*pow(2,s);
    s++;
    x/=10;
}
    return ans;
}
int D2B(long long x){
long long rem,s=0,ans=0;
while(x!=0){
    rem=x%2;
    s=(s*10)+rem;
    x/=2;
}
while(s!=0){
    rem=s%10;
    ans=(ans*10)+rem;
    s/=10;
}
    return ans;
}





int main(){
    int n,value,s,ans,sum = 0,ans1,ans2,p,x,y;
    vector<int> v;
        cin>>n;
        while(n--){
            cin>>value;
            sum+=value;
            v.push_back(value);
        }
        n = v.size();
        p = sum / n;
         x = (sum / n) + 1;
         y = (sum/n) - 1;

        sum = 0;
        ans1 = 0;
        ans2 = 0;
        for(int i=0;i<v.size();i++){
            ans = abs(v[i]-p);
            sum+= (ans*ans);
            ans = abs(v[i]-x);
            ans1+= (ans*ans);
            ans = abs(v[i]- y);
            ans2 += (ans*ans);
        }
        x = min(ans1,ans2);
        ans = min(x,sum);
            cout<< ans <<endl;
    return accepted;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n, l;
    cin >> n >> l;
    int ans = 0, mn = INF;
    rep(i, n){
        ans += l+i;
        if(abs(mn) > abs(l+i)) mn = l+i;
    }
    cout << ans - mn << endl;
}

Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}

fn main() {
    let abk: String = read();
    let abk_array: Vec<u64> = abk.split_whitespace().map(|e| e.parse().ok().unwrap()).collect::<Vec<_>>();
    let a: u64 = abk_array[0];
    let b: u64 = abk_array[1];
    let k: u64 = abk_array[2];

    let a_res: u64;
    let b_res: u64;


    if (a + b) < k {
        a_res = 0;
        b_res = 0;
    } else {
        if a <= k {
            a_res = 0;
        } else {
            a_res = a - k;
        }

        if a_res == 0 {
            b_res = b - (k - a);
        } else {
            b_res = b;
        }
    }

    let mut ans: String = a_res.to_string() + " ";
    ans = ans + &b_res.to_string();

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const ll INF = 1LL << 60;

int main() {
    string s; cin >> s;
    int n = s.size();
    cout << "2018/01/" << s.substr(n - 2, 2) << endl;
    return 0;
}

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

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

  if(A == 0 && N % 500 == 0){
    cout << "Yes" << endl;
  }    
  else if (N % 500 <= A) {
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#define PB push_back
#define ll long long
using namespace std;
template <class T>
inline void rd(T &x) {
	x=0; char c=getchar(); int f=1;
	while(!isdigit(c)) { if(c=='-') f=-1; c=getchar(); }
	while(isdigit(c)) x=x*10-'0'+c,c=getchar(); x*=f;
}
const int N=2e5+10;
int S,T,ncnt;
namespace Flow {
	int head[N],cur[N],dep[N],ecnt;
	struct ed { int to,next,f; };
	vector<ed> e;
	void init() { memset(head,-1,sizeof(head)); e.clear(); }
	void ad(int x,int y,int f) {
		e.PB((ed){y,head[x],f}); head[x]=e.size()-1;
		e.PB((ed){x,head[y],0}); head[y]=e.size()-1;
	}
	queue<int> que;
	bool bfs() {
		for(int i=1;i<=ncnt;++i) dep[i]=-1,cur[i]=head[i];
		while(!que.empty()) que.pop();
		que.push(S),dep[S]=0;
		while(!que.empty()) {
			int u=que.front(); que.pop();
			if(u==T) return 1;
			for(int k=head[u];~k;k=e[k].next) if(e[k].f) {
				int v=e[k].to;
				if(dep[v]==-1) {
					dep[v]=dep[u]+1;
					que.push(v);
				}
			}
		}
		return 0;
	}
	int dfs(int u,int f) {
		if(u==T||!f) return f; int tmp,ret=0;
		for(int &k=cur[u];~k;k=e[k].next) if(e[k].f) {
			int v=e[k].to;
			if(dep[v]==dep[u]+1&&(tmp=dfs(v,min(e[k].f,f)))) {
				e[k].f-=tmp,e[k^1].f+=tmp;
				f-=tmp,ret+=tmp;
				if(!f) break;
			}
		}
		return ret;
	}
	int work() { int ans=0; while(bfs()) ans+=dfs(S,1e9); return ans; }
}
int P[N],Q[N],n;
int bP[N],bQ[N],cntP,cntQ;
int id[N][2];
int a[N],b[N],ans;
void dfsP(int u) { if(bP[u]) return; bP[u]=cntP,dfsP(P[u]); }
void dfsQ(int u) { if(bQ[u]) return; bQ[u]=cntQ,dfsQ(Q[u]); }
int main() {
	Flow::init();
	rd(n);
	for(int i=0;i<n;++i) rd(P[i]);
	for(int i=0;i<n;++i) rd(Q[i]);
	
	for(int i=0;i<n;++i) if(!bP[i]) cntP++,dfsP(i);
	for(int i=0;i<n;++i) if(!bQ[i]) cntQ++,dfsQ(i);
	S=++ncnt,T=++ncnt;
	for(int i=1;i<=cntP;++i) id[i][0]=++ncnt;
	for(int i=1;i<=cntQ;++i) id[i][1]=++ncnt;
	
	for(int i=0;i<n;++i) {
		if(P[i]==i&&Q[i]==i) continue;
		if(P[i]==i) b[bQ[i]]++;
		else if(Q[i]==i) a[bP[i]]++;
		else if(Q[i]!=P[i]) ans++,Flow::ad(id[bP[i]][0],id[bQ[i]][1],1);
		else ans++,Flow::ad(id[bP[i]][0],id[bQ[i]][1],1),Flow::ad(id[bQ[i]][1],id[bP[i]][0],1);
	}
	for(int i=1;i<=cntP;++i) {
		ans+=a[i];
		Flow::ad(S,id[i][0],0);
		Flow::ad(id[i][0],T,a[i]);
	}
	for(int i=1;i<=cntQ;++i) {
		ans+=b[i];
		Flow::ad(S,id[i][1],b[i]);
		Flow::ad(id[i][1],T,0);
	}
	ans-=Flow::work();
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 21228
#include <cstdio>
#include <stdlib.h>
#include <ctype.h>
#include <cstring>
#include <math.h>


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

    for(int i = 0; i < M; ++i){
        S -=  A[i];
    }
    if(S >= 0) {
        printf("%d", S);
    }
    else{
        printf("-1");
    }

    return 0;
}

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

int main() {
  int a, b, t;
  cin >> a >> b;
  if(a <= 9 && b <= 9) {
    t = a * b;
    cout << t << endl;
  } else {
  	cout << -1 << endl;
  }
}



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

int main(void) {
  char s[18];
  int count = 0;
  cin >> s;
  char ans[18] = "CODEFESTIVAL2016";
  for (int i = 0; i < 16; i++) {
    if(s[i] != ans[i]) count++;
  }
  cout << count << "\n";
  return 0;
}


Measured memory_bytes: 256
N, K = [int(x) for x in input().split()]
A_lst = [int(x) for x in input().split()]
r = -1
l = -1
for i in range(N):
    if A_lst[i] == 1:
        r = i
        l = N - i - 1
print((r + l + K - 2)//(K - 1))


Measured memory_bytes: 13880
#include<iostream>
#include<sstream>
#include<vector>
#include<iterator>
using namespace std;

int N;
long long X;
vector<long long> p, b;
long long ans;

void calc(int lv, long long life)
{
	if(life == 0)
		return;

	if(lv==0){
		life--;
		ans++;
		return;
	}

	long long half = (p[lv] + b[lv]) / 2;
	if(life >= half){
		life -= half;
		ans += p[lv]/2;

		if(life > 0){
			life--;
			ans++;

			calc(lv-1, life);
		}
		
	}
	else{
		life--;
		calc(lv-1, life);
	}
}

int main(void)
{
	cin >> N >> X;

	p = vector<long long>(N+1, 0);
	b = vector<long long>(N+1, 0);
	p[0] = 1;
	for(int i=0; i<N; i++){
		p[i+1] = 2*p[i] + 1;
		b[i+1] = 2*b[i] + 2;
	}

	//for(int i=0; i<N; i++)
	//	cout << i << " : " << p[i]+b[i] << endl;

	ans = 0;
	calc(N, X);

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


Measured memory_bytes: 256
#include<stdio.h>
#define N 1000
int main(){
  int key,num,i,j,k,math[N];
  scanf("%d",&num);
  for(i=0;i<num;i++){
    scanf("%d",&math[i]);
  }
  printf("%d",math[0]);
  for(k=1;k<num;k++){
    printf(" %d",math[k]);
  }
  

  for(i=1;i<num;i++){
    key = math[i];
    j = i-1;
    while(j>=0 && math[j]>key){
      math[j+1]=math[j];
      j--;
    }
    math[j+1] = key;
    printf("\n");
    printf("%d",math[0]);
    for(k=1;k<num;k++){
      printf(" %d",math[k]);
    }
   
  }
  printf("\n");
}



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

#define mod 1000000007
#define sp ' '
#define intmax 2147483647
#define llmax 9223372036854775807
#define nyan "(=^･ω･^=)"
#define mkp make_pair
#define lP pair<ll, ll>
#define iP pair<int,int>

using namespace std;
typedef long long ll;

int N;

int main() {
	cin >> N;
	if (N & 1) {
		if (N == 3) {
			cout << 2 << endl;
			cout << 1 << sp << 3 << endl;
			cout << 2 << sp << 3 << endl;
		}
		else {
			cout << N * 2 - 2 << endl;
			for (int i = 1; i <= N / 2 - 1; ++i) {
				cout << i << sp << i + 1 << endl;
				cout << i << sp << N - i - 1 << endl;
				cout << N - i << sp << i + 1 << endl;
				cout << N - i << sp << N - i - 1 << endl;
			}
			cout << N << sp << 1 << endl;
			cout << N << sp << N - 1 << endl;
			cout << N << sp << N / 2 << endl;
			cout << N << sp << N / 2 + 1 << endl;
		}
	}
	else {
		if (N == 4) {
			cout << 4 << endl;
		}
		else {
			cout << N * 2 << endl;
		}
		for (int i = 1; i <= N / 2 - 1; ++i) {
			cout << i << sp << i + 1 << endl;
			cout << i << sp << N - i << endl;
			cout << N + 1 - i << sp << i + 1 << endl;
			cout << N + 1 - i << sp << N - i << endl;
		}
		if (N != 4) {
			cout << N / 2 << sp << 1 << endl;
			cout << N / 2 << sp << N << endl;
			cout << N / 2 + 1 << sp << 1 << endl;
			cout << N / 2 + 1 << sp << N << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptor/reversed.hpp>
#include <boost/range/algorithm/sort.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using boost::irange;
using boost::sort;
using boost::adaptors::reversed;

int main() {
    int a, b;
    cin >> a >> b;
    cout << a * b << endl;
}


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

int n;
int p[200001],f[200001];

int main()
{
	cin>>n;
	int t;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&p[i]);
		f[p[i]]=f[p[i]-1]+1;
		t=max(t,f[p[i]]);
	}
	cout<<n-t<<endl;
}

Measured memory_bytes: 1792
/* 
	Author: ankrypt
*/


#include <bits/stdc++.h>

using namespace std;

#define MOD 1000000007
#define ll long long int
#define u64 unsigned long long int

ll N;
string S = "";
map<char, int> mp;

int main() {
	scanf("%lld", &N);
	cin >> S;
	for(int i = 0; i < S.size(); i++) {
		mp[S[i]]++;
	}
	ll sum = 1;
	map<char, int> :: iterator itr;
	for(itr = mp.begin(); itr != mp.end(); itr++) {
		sum *= (itr->second + 1);
		sum %= MOD;
	}
	sum -= 1;
	sum += MOD;
	sum %= MOD;
	printf("%lld\n", sum);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 512
#include<iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define MAX_V 50
vector<int> graph[MAX_V];
bool used_v[MAX_V],used_e[MAX_V][MAX_V];
int ord[MAX_V],lowlink[MAX_V];
int k=0;
using namespace std;
void dfs(int v){
    used_v[v] = true;
    ord[v] = lowlink[v] = k++;
    for(int i=0;i<graph[v].size();i++){
        if(!used_v[graph[v][i]]){
            used_e[v][graph[v][i]] = true;
            dfs(graph[v][i]);
            lowlink[v]=min(lowlink[v],lowlink[graph[v][i]]);
        }
        else if(!used_e[graph[v][i]][v]){
            lowlink[v]=min(lowlink[v],ord[graph[v][i]]);
        }
    }
}

int main(){
    int N,M;
    int a,b;
    int ans=0;
    cin >> N >> M;
    for(int i=0;i<M;i++){
        cin >> a >> b;
        graph[a-1].push_back(b-1);
        graph[b-1].push_back(a-1);
    }
    dfs(0);
    for(int i=0;i<N;i++){
        for(int j=0;j<graph[i].size();j++){
            if(ord[i] < lowlink[graph[i][j]]) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
type t = { v : int; w : int }

let solve a n w =
  let dp = Array.make_matrix 2 (w + 1) 0 in
  for i = 1 to n do
    for j = 1 to w do
      dp.(1).(j) <-
        if j - a.(i-1).w < 0 || dp.(0).(j - a.(i-1).w) + a.(i-1).v <= dp.(0).(j)
        then dp.(0).(j)
        else dp.(0).(j - a.(i-1).w) + a.(i-1).v;
    done;
    for i = 0 to w do dp.(0).(i) <- dp.(1).(i) done;
  done;
  dp.(1).(w)

let () =
  let (n, w) = Scanf.scanf "%d %d " (fun n w -> n, w) in
  let a = Array.init n (fun _ -> Scanf.scanf "%d %d " (fun v w -> { v; w })) in
  solve a n w |> Printf.printf "%d\n"

Measured memory_bytes: 2568
#[allow(unused_imports)]
use proconio::input;
use proconio::marker::Chars;
use std::cmp::{max, min};
#[allow(unused)]
const alpha: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const Alpha: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];

fn main() {
    input!(L: usize, R: usize, d: usize);
    let mut ans = 0;
    for i in L..=R {
        if i % d == 0 {
            ans += 1;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2092
#include <stdio.h>

int gcd(int x, int y) {
  int r;
  if(x < y) {
    r = x;
    x = y;
    y = r;
  }
  while(y > 0) {
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

int main() {
  int x,y;
  scanf("%d%d", &x, &y);
  printf("%d\n", gcd(x, y));
  return 0;
}



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

int main(){
  int n;
  cin>>n;
  int *array = new int[n];
  for(int i=0;i<n;i++){
    cin>>array[i];
  }
  bool flag = 1;
  int count=0;
  while(flag){
    flag = 0;
    for(int j=n-1;j>=1;j--){
      if(array[j] < array[j-1]){
	swap(array[j],array[j-1]);
	flag = 1;
	count++;
      }
    }
  }
  cout<<array[0];
  for(int i=1;i<n;i++)
    cout<<" "<<array[i];
  cout<<'\n'<<count<<endl;
  delete []array;
  return 0;
}

Measured memory_bytes: 1200
#include<iostream>
#include<vector>
#include<utility>
#include<algorithm>
using namespace std;
typedef pair<int,int> pii;
#define rep(i,n) for(int i = 0 ;i < (n); i++)
int main(){
    int n;
    cin >> n;
    vector<pii> in(n);
    vector<int>cnt1(n,0),cnt2(n,0);
    rep(i,n){
        cin >> in[i].first >> in[i].second;
        in[i].first--;
        in[i].second--;
        cnt1[in[i].first]++;
        cnt2[in[i].second]++;
    }
    sort(in.begin(),in.end());
    rep(i,n)if(cnt1[i] > 1 || cnt2[i] > 1){
        cout << -1 << endl;
        return 0;
    }
    int ans = 0;
    vector<int> used(n,0);
    rep(i,n)if(used[i] == 0){
        int cnt = 1;
        int j = in[i].second;
        used[i]++;
        while(used[j] == 0){
            used[j]++;
            j = in[j].second;
            cnt++;
        }
        ans += cnt-1;
    }
    cout << ans << endl;
}



Measured memory_bytes: 4600
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'
const int INF = 1000000001;
const long double E = 0.00000001;

using namespace std;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int x, n;
    cin >> x >> n;
    set<int> a;
    for (int q = 0; q < n; q++){
        int w;
        cin >> w;
        a.insert(w);
    }
    for (int q = 0; q < n+1; q++){
        if (a.find(x-q) == a.end()){
            cout << x-q << endl;
            break;
        }
        if (a.find(x+q) == a.end()){
            cout << x+q << endl;
            break;
        }
    }
    return 0;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define ALL(c) (c).begin(), (c).end()

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

const ll INF = TEN(10);

int main() {
    int N, T;
    cin >> N >> T;
    V<ll> t(N);
    ll ans = 0;
    rep(i, N) cin >> t[i];
    t.pb(INF);
    rep(i, N) { ans += min<ll>(t[i + 1] - t[i], T); }
    cout << ans << endl;
    return 0;
}

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

using namespace std;

int n;
vector<vector<int>> in(100000, vector<int>(4));
int tb[100000][3];

int dp(int i, int past){
	if(i == n) return 0;
	
	if(tb[i][past] != -1) return tb[i][past];
	
	int total = 0;
	for(int next = 1; next <= 3; ++next){
		if(next != past){
			total = max(total, dp(i+1, next) + in[i][next]);
		}
	}
	
	return tb[i][past] = total;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	memset(tb, -1, sizeof(tb));
	
	cin >> n;
	
	for(int i = 0; i < n; ++i){
		cin >> in[i][1] >> in[i][2] >> in[i][3];
	}
	
	cout << dp(0,0) << endl;
	
	return 0;
}

Measured memory_bytes: 14720
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>

using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
//SOLVE

void solve (void)
{
  int A,B,X;
  cin>>X>>A>>B;
  if(A >= B)
  {
    cout<<"delicious"<<endl;
  }
  else if(A + X < B)
  {
    cout<<"dangerous"<<endl;
  }
  else
  {
    cout<<"safe"<<endl;
  }
  

  return;
}

int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = [LI() for _ in range(n)]
    m = 2**n
    s = [[0] * m for _ in range(n+1)]
    s[0][0] = 1
    ii = [2**i for i in range(n)]
    for i in range(n):
        t = s[i+1]
        u = s[i]
        b = [ii[c] for c in range(n) if a[i][c]]
        for k in range(m):
            v = u[k]
            v = v % mod
            if v < 1:
                continue
            for j in b:
                if not (j & k):
                    t[k | j] += v

    return s[-1][-1] % mod


print(main())



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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0);

const int N = 1005;

int main() {

	FAST;

	string s;
	cin >> s;
	set <char> ss;
	ss.insert(s[0]);
	ss.insert(s[1]);
	ss.insert(s[2]);
	cout << ((ss.size() == 2) ? "Yes\n" : "No\n");
	return 0;
}

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

def shitigosan(x):
  if int(x) > N:
    return 0
  cnt = 1 if all(x.count(c) > 0 for c in '753') else 0
  for i in "753":
    cnt += shitigosan(x+i)
  return cnt
  
print(shitigosan("0"))

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

#define vec              vector<int>
#define vecll            vector<ll>
#define vecd             vector<double>
#define vecst            vector<string>
#define vecb             vector<bool>
#define v2(v,n,m,init)   vector<vector<int>>  v(n, vector<int>(m, init))
#define vb2(v,n,m,init)  vector<vector<bool>> v(n, vector<bool>(m, init))
#define vll2(v,n,m,init) vector<vector<ll>>   v(n, vector<ll>(m, init))

#define rep(i,n)         for(ll i=(ll)0; i<(ll)n; i++)
#define REP(i,m,n)       for(ll i=(ll)m; i<(ll)n; i++)
#define arr(var, n)      vec var(n); rep(i,n){cin >> var[i];}
#define arrll(var, n)    vecll var(n); rep(i,n){cin >> var[i];}
#define arrst(var, n)    vecst var(n); rep(i,n){cin >> var[i];}
#define all(var)         (var).begin(), (var).end()
#define sortall(var)     sort(all(var))
#define uniqueall(v)     v.erase(unique(v.begin(), v.end()), v.end());
#define pb(var)          push_back(var)
#define prt(var)         cout << (var) << "\n"
#define prtd(n, var)     cout << fixed << setprecision(n) << (var) << "\n"
#define prtfill(n, var)  cout << setw(n) << setfill('0') << (var);
#define prt2(v1, v2)     cout << (v1) << " " << (v2) << "\n"
#define prt3(v1, v2, v3) cout << (v1) << " " << (v2) << " " << (v3) << "\n"
#define prtall(v)        rep(i,v.size()){cout<<v[i]<<(i!=v.size()-1?" ":"\n");}
template <typename T>
bool chmax(T &a, const T& b){if(a<b){a=b; return true;} return false;}
template <typename T>
bool chmin(T &a, const T& b){if(a>b){a=b; return true;} return false;}
//----------------------------------------------------------------

int main(void) {
  int n, r;
  cin >> n >> r;
  int ans;
  if(n>9) ans=r;
  else ans = r+100*(10-n);
  prt(ans);
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    LL n, m;
    cin >> n >> m;
    vector<LL> a(n);
    rep(i, n)  cin >> a[i];
    sort(all(a));
    vector<pair<LL, LL>> b(m);
    rep(i, m){
        LL x, y;
        cin >> x >> y;
        b[i] = make_pair(y, x);
    }
    sort(all(b));
    reverse(all(b));
    //epe(i, a) cout << i << " "; cout << endl;
    LL now = 0, k = 0;
    while(now < n && k < m){
        while(now < n && a[now] > b[k].first) now++;
        if(now == n) break;
        rep(i, b[k].second){
            if(a[now] > b[k].first) break;
            a[now] = b[k].first;
            now++;
            if(now == n) break;
        }
        k++;
    }
    //repe(i, a) cout << i << " "; cout << endl;
    cout << accumulate(all(a), 0LL) << endl;
}

Measured memory_bytes: 2560
/*
	dp[i][j] = max value possible to collect from i,i+1,....n if only j more wt. can be taken inside
	
	dp[i][j] = max(dp[i+1][j], dp[i+1][j-w[i]]+v[i])
*/

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

int main(){
	int n, W;
	vector<int> w;
	vector<ll> v;
	vector<vector<ll> > dp;
	cin>>n>>W;
	w.assign(n, 0);
	v.assign(n, 0);
	dp.assign(n+1, vector<ll>(W+1, 0));
	for(int i=0;i<n;i++){
		cin>>w[i]>>v[i];
	}
	for(int i=n-1;i>=0;i--){
		for(int j=W;j>=0;j--){
			dp[i][j] = dp[i+1][j];
			if(w[i]<=j)
				dp[i][j] = max(dp[i][j], dp[i+1][j-w[i]]+v[i]);
		}
	}
	cout<<dp[0][W]<<"\n";
	return 0;
}

Measured memory_bytes: 80256
#include<stdio.h>
typedef int ii;
ii check(ii x,ii n,ii arr[])
{
	if(x==0||x==n-1)
	{
		return 0;
	}
	ii num =0;
	if(arr[x] > arr[x-1])
	{
		num++;
	}
	if(arr[x] > arr[x+1])
	{
		num++;
	}
	if(num == 1)
	{
		return 1;
	}
	else
	{
		return 0;
	}
}
ii main()
{
	ii n;
	scanf("%d",&n);
	ii arr[21];
	for(ii i=0;i<n;i++)
	{
		scanf("%d",&arr[i]);
	}
	ii ans =0;
	for(ii i=0;i<n;i++)
	{
		ans += check(i,n,arr);
	}
	printf("%d\n",ans);
	return 0;
}


Measured memory_bytes: 128
///////////////////////////////////////////////////////////////
//__________________________________________________________//
// \\\\\\\\\\\---------------------------------------------//
//          //                 __    __                   // 
//         //     \\\\\\\\    |. \  / .|    /////////    //
//    ///////       ||   \\   |.|\\//|.|   //           //
//    /  // /       ||    \\  |.| \/ |.|  //   /////// //
//    / //  /       ||    //  |.|    |.|  \\     \\    \\
//    ///////      ////////   |.|    |.|   \\\\\\\\\\   \\
//    //                                                 \\
// \\\\\\\\\\\\-------------------------------------------\\
// ________________________________________________________\\
/////////////////////////////////////////////////////////////
 
#include <bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define MAX 100005
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#define vi vector<ll>
#define vp vector<pii >
#define vs vector<string>
#define all(v) v.begin(),v.end()
#define lb(v,x) lower_bound(all(v),x)
#define ub(v,x) upper_bound(all(v),x)
#define sz(x) x.size()
#define F first
#define S second
#define FOR(i,a,b) for(ll i=a;i<b;++i)
#define ROF(i,a,b) for(ll i=a;i>=b;--i)
typedef long long ll;
using namespace std;
 
ll modexp(ll base,ll exp){
    if(exp==1)return base;
    else if(exp==0)return 1;
    else{
        if(exp%2 == 0){
            ll base1=pow(modexp(base, exp/2),2);
            if(base1 >= MOD)
            return base1%MOD;
            else return base1;
        }
        else{
            ll ans = (base *  pow(modexp(base,(exp-1)/2),2));
            if(ans >= MOD)return ans%MOD;
            else return ans;
        }
    }
}
 
ll gcd(ll a,ll b){
    if(!a)return b;
    return gcd(b%a,a);
}

int main(){
    IOS
    int n;
    cin>>n;
    int a[2*n];
    FOR(i,0,2*n)cin>>a[i];
    sort(a,a+2*n);
    int sum=0;
    for(int i=0;i<2*n;i+=2)sum+=a[i];
    cout<<sum;
}

Measured memory_bytes: 256
//** aman**/
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define dl          double
#define hell        1000000007
#define endl        '\n'
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define lb lower_bound
#define ub upper_bound
#define bs          binary_search
#define ios         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
using namespace std;
ll a[2005]={0},p[2005]={0},h[2005]={0};
ll power(ll x,ll y)
{
	ll res=1;
	while(y>0)
	{
		if(y&1)
		res=res*x%hell;
		y=y>>1;
		x=x*x%hell;
	}
	return res;
}
int main(){
	ll n,k;cin>>n>>k;
	for(ll i=1;i<=n;i++)cin>>a[i];
	if(k==0)return cout<<"0",0;
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<=n;j++){
			if(a[j]>a[i])p[i]++;
		}
	}
	for(ll i=1;i<=n;i++){
		for(ll j=1;j<i;j++){
			if(a[j]>a[i])h[i]++;
		}
	}
	ll ans=0;
	ll f=k*(k-1)%hell;
	f=f*power(2,hell-2)%hell;
	for(ll i=1;i<=n;i++){
		ans=(ans+f*p[i])%hell;
		ans=(ans+h[i]*k)%hell;
	}
	cout<<ans<<endl;
	
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>

char s[100010];

int main(){
	
	int count[200];
	for(int i=0; i<200; i++)
		count[i]=0;
	
	scanf("%s", s);
	int len=strlen(s);
	if(len<2){
		printf("-1 -1");
		return 0;
	}

	for(int i=0; i<len; i++){
		count[s[i]]++;
	}

	for(int i=0; i<len-1; i++){
		if(s[i]==s[i+1]){
			printf("%d %d", i+1, i+1+1);	
			return 0;
		}
		if(i<len-2 && s[i]==s[i+2]){
			printf("%d %d", i+1, i+2+1);
			return 0;
		}
	}

	printf("-1 -1");
	return 0;
}

Measured memory_bytes: 256