akhauriyash/Code-Regression huggingface dataset:
//Bismillahir Rahmanir Rahim
#include <bits/stdc++.h>
using namespace std;

typedef long long              ll;
typedef long double            ld;
typedef pair<int, int>         pi;
typedef vector<int>            vi;
typedef vector<pair<int, int>> vpi;

#define pb       push_back
#define all(x)   begin(x), end(x)
#define sz(x)    (int)(x).size()
#define ff       first
#define ss       second
#define mp       make_pair
#define lb       lower_bound
#define ub       upper_bound
#define tcase()  int t; cin >> t; while(t--)

const int MOD = 1e9 + 7; // 998244353;
const int MX  = 2e5 + 5;
const ll  INF = 1e18;
const ld  PI  = acos((ld) -1);

void setIO(string name = "") {
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    if(sz(name)){
        freopen((name+".in").c_str(), "r", stdin);
        freopen((name+".out").c_str(), "w", stdout);
    }
}

int main(){

    setIO();

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

    int dif = r - l - 1;

    int arr[n + 1] = {0};

    for(int i = 1; i <= n; i++){
        for(int j = i + 1; j <= n; j++){
            arr[min({j - i, abs(l - i) + 1 + abs(j - r)})]++;
        }
    }

    for(int i = 1; i < n; i++) cout << arr[i] << "\n";
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main() {
    int n,i,k,j,ans=INT_MAX;
    cin>>n>>k;
    int arr[n];
    for(i=0;i<n;i++)
    cin>>arr[i];
    int dp[n];
    dp[0]=0;
    dp[1]=abs(arr[1]-arr[0]);
    for(i=2;i<n;i++)
    {
        ans=INT_MAX;
        for(j=1;j<=k;j++)
        {
            if(i-j>=0)
            ans=min(ans,dp[i-j]+abs(arr[i]-arr[i-j]));
        }
        dp[i]=ans;
    }
    //for(i=0;i<n;i++)
    //cout<<dp[i]<<" ";
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define all(a) a.begin(),a.end()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define PI 2*acos(0.0)
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
int main()
{
    FIO;
    string s,t;
    cin>>s>>t;
    int sn=s.size(),st=t.size(),i,j;
    if(sn+1!=st)
        return cout<<"No"<<endl, 0;
    bool ok=1;
    for(i=0; i<sn; i++)
    {
        if(s[i]!=t[i]){ok=0;break;}
    }

    if(ok)
        cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3652
N = gets.to_i
A = $<.map{|s|s.split.map &:to_i}
A.map!{|a|
  cusum = [sum = 0] + a.map{|n|sum += n}
}
p N.times.map{|i|
  A[0][i+1] - A[0][0] + A[1][-1] - A[1][i]
}.max


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

int main(){
 long long M,f,g,p,N,H,count;
  cin>>N>>H;
  count=0;
  vector<long long>a(N),b(N);
  vector<pair<long long,long long>> S(N);
  for(int i=0;i<N;i++){
cin>>a[i]>>b[i];
    S[i]=make_pair(a[i],b[i]);
  }
  sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    sort(S.begin(),S.end());
    reverse(a.begin(),a.end());
    reverse(b.begin(),b.end());
    reverse(S.begin(),S.end());
  p=S[0].second;
    for(int i=0;i<N;i++){
      if(b[i]>a[0]){
        count++;
        H-=b[i];
      }
      else if(b[i]<=a[0]){
        break;
      }
      if(H<=0){
        cout<<count<<endl;
        return 0;
      }
    }
  count+=H/a[0];
  if(H%a[0]==0){
    cout<<count<<endl;
    return 0;
  }
  else{
    count++;
    cout<<count<<endl;
    return 0;
  }
   
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
ll mod=998244353;
int inf=1000001000;
ll INF=1e18+5;


int main() {
  int w,a,b;
  cin >> w >> a >> b;
  int ans=max(b-(a+w),a-(b+w));
  ans=max(ans,0);
  cout << ans << endl;
}


Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.algorithm;
import std.conv;
import std.array;
import std.math;
import std.range;

void main()
{
    auto w = readln.chomp.toLower;

    string[] ss;
    while(1){
        auto line = readln.chomp;
        if(line == "END_OF_TEXT") break;
        ss ~= line.toLower.split;
    }

    writeln(ss.count(w));
}

Measured memory_bytes: 1080
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i=0; i<(n); ++i)

int main()
{
	int N; cin >> N;
	vector<int> A(N);
	rep(i, N) cin >> A[i];
	sort(A.begin(), A.end(), greater<int>());
	ll sum = 0;
	for (int i = 1; i < N; ++i) {
		sum += A[i / 2];
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3576
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(a // b)
    else:
        break


Measured memory_bytes: 5592
N = int(input())
*a, = map(int, input().split())

dp = [[None] *  N for _ in range(N)]
for i in range(N): dp[i][i] = a[i]

for j in range(1, N):
    for i in range(j-1, -1, -1):
        dp[i][j] = max(a[i] - dp[i+1][j], a[j] - dp[i][j-1])

print(dp[0][N-1])

Measured memory_bytes: 206040
#include<stdio.h>
#include<string.h>
int main()
{
    int sum =0 ,a, b, c, k;
    scanf("%d%d%d%d",&a,&b,&c,&k);
    if(a>=k)
    {
        sum+=k;
        printf("%d",sum);
        return 0;
    }
    else
    {
        sum+=a;
        k-=a;
    }
    if(b>=k)
    {
        printf("%d",sum);
        return 0;
    }
    else
    {
        k-=b;
    }
    if(c>=k)
    {
        sum-=k;
        printf("%d",sum);
        return 0;
    }
    return 0;
}

Measured memory_bytes: 1732
/**************
*	Shell Sort
*************/

#include <iostream>
#include <vector>	//??£?¨?
#include <algorithm>
using namespace std;

void insertionSort(vector<int>* A, int g, int* cnt  ){

	for(unsigned int i=g ; i<(A->size()); i++){
		int v = (*A)[i];
		int j = i-g;
		while(j>=0 && (*A)[j]>v){
			(*A)[j+g] = (*A)[j];
			j = j-g;
			(*cnt)++;
		}
		(*A)[j+g] =v;
	}
	return ;
}
//---------------------------------------------------------
void shellSort(vector<int>* A, vector<int>* G, int* cnt){

	for(unsigned int i=0; i<(G->size()); i++){
		insertionSort(A, (*G)[i], cnt);
	}

	return;
}
//--<<???????????¢??°>>-------------------------------------------------------
int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);
	//??\???
	int n;
	cin >> n;
	vector<int> A;
	A.resize(n);
	for(unsigned int i=0; i< A.size(); i++){
		cin >> A[i];
	}

	//??????
	vector<int> G;
//	G.reserve(100);//????????????????´???°???????????£??????????????¨????????????
	int sum = 1;
	while(sum <= n){
	    G.push_back(sum);
		sum = sum * 3 + 1;
	}
	reverse(G.begin(), G.end());

	int cnt = 0;
	shellSort(&A, &G, &cnt);

	//??????
	cout << G.size() << endl;
	for(unsigned int i=0; i<(G.size()); i++){
		cout << G[i];
		if(i!=(G.size()-1)){
			 cout <<" " ;
		}
	}
	cout << endl;
	cout << cnt << endl;
	for(int i=0; i< n; i++){
		cout << A[i]<< endl;
	}

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

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

int main(){
  int N,K,sum=0;
  cin >> N >> K;
  vector<int> x(N);
  for(int i=0;i<N;i++){
    cin >> x[i];
    sum += min(x[i],K-x[i])*2;
  }
  cout << sum << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstring>
#include <sstream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <chrono>
#include <numeric>
#include <set>

using namespace std;

class cMergeSort
{
	int mn;
	string mS;
	vector<int> vS, vA;
	int count;

	void decode();
	void mSort(vector<int>&, int, int);
	void merge(vector<int>&, int, int, int);
	const int infty = pow(256, sizeof(int)) / 2 - 1;

public:
	cMergeSort(int n, const string &s)
		: mn(n), count(0)
	{
		mS = s;
		decode();
	}
	void output();
};

void cMergeSort::decode()
{
	istringstream iss;
	iss.str(mS);
	int ts;
	for (int i = 0; i < mn; ++i)
	{
		iss >> ts;
		vS.push_back(ts);
	}
}

void cMergeSort::mSort(vector<int> &va, int left, int right)
{
	if (left + 1 < right)
	{
		int mid = (left + right) / 2;
		mSort(va, left, mid);
		mSort(va, mid, right);
		merge(va, left, mid, right);
	}
}

void cMergeSort::merge(vector<int> &va, int left, int mid, int right)
{
	int n1 = mid - left;
	int n2 = right - mid;
	vector<int> vL(n1 + 1), vR(n2 + 1);

	for (int i = 0; i < n1; ++i)
	{
		vL[i] = va[left + i];
	}
	for (int i = 0; i < n2; ++i)
	{
		vR[i] = va[mid + i];
	}
	vL[n1] = infty;
	vR[n2] = infty;

	int i = 0;
	int j = 0;

	for (int k = left; k < right; ++k)
	{
		if (vL[i] <= vR[j])
		{
			va[k] = vL[i];
			++i;
		}
		else
		{
			va[k] = vR[j];
			++j;
		}
		++count;
	}
}

void cMergeSort::output()
{
	vA = vS;
	mSort(vA, 0, vA.size());

	ostringstream oss;
	for (int i = 0; i < vA.size(); ++i)
	{
		oss << vA[i] << " ";
	}
	string ans(oss.str());
	ans.replace(ans.rfind(" "),ans.size(), "");
	cout << ans << endl;
	cout << count << endl;
}
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int n;
	string S;

	cin >> n;
	cin.ignore();
	getline(cin, S);

	cMergeSort cm(n, S);
	cm.output();

	return 0;
}

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

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vector<vector<bool>>> vvvb;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<double> vd;
typedef vector<vd> vdd;

#define FOR(i,x,y) for(ll i=(ll)x; i<(ll)y; ++i)
#define REP(i,y) FOR(i, 0, y)
#define RFOR(i,x,y) for(ll i=(ll)x; i>=(ll)y; --i)
#define RREP(i,x) RFOR(i, x, 0)
#define ALL(a) a.begin(), a.end()
#define pb push_back
#define debug_print(x...) cerr << "line " << __LINE__ << " : "; debug_print_in(x);

template <typename First>
void debug_print_in(First first){
  cerr << first << endl;
  return;
}

template <typename First, typename... Rest>
void debug_print_in(First first, Rest... rest){
  cerr << first << " ";
  debug_print_in(rest...);
  return;
}

void IN(void){
  return;
}

template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
  cin >> first;
  IN(rest...);
  return;
}

template <typename First>
void OUT(First first){
  cout << first << endl;
  return;
}

template <typename First, typename... Rest>
void OUT(First first, Rest... rest){
  cout << first << " ";
  OUT(rest...);
  return;
}

template<class t, class u> void chmax(t&a,u b){if(a<b)a=b;};
template<class t, class u> void chmin(t&a,u b){if(a>b)a=b;};
int popcount(int t){return __builtin_popcount(t);} //GCC
int popcount(ll t){return __builtin_popcountll(t);} //GCC

template <typename T>
void vec_print(vector<T> VEC){
  REP(i, VEC.size()){
    cerr << VEC[i] << " ";
  }
  cerr << endl;
};

template <typename T>
void mat_print(vector<vector<T> > MAT){
  REP(i,MAT.size()){
    REP(j,MAT[i].size()){
      cerr << MAT[i][j] << " ";
    }
    cerr << endl;
  }
};

constexpr int INF = (1<<30);
constexpr ll INFLL = 1LL<<62;
constexpr long double EPS = 1e-12;
constexpr ll MOD = (ll)((1E+9)+7);

int main(){
  cin.tie(0); // cut the cin and cout (default, std::flush is performed after std::cin)
  ios::sync_with_stdio(false); // cut the iostream and stdio (DON'T endl; BUT "\n";)

  ll A, B, C, K;
  IN(A,B,C,K);
  ll ans = 0;
  if(K<=A){
    ans = K;
  }else if(K<=A+B){
    ans = A;
  }else{
    ans = A-(K-A-B);
  }

  OUT(ans);

  return 0;
}

Measured memory_bytes: 3648
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1'000'000'007;
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; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s; cin >> s;
	map<int, char> mp;
	rep(i, 0, s.size())mp[i] = s[i];
	queue<int> q;
	rep(i, 1, s.size() - 1)q.push(i);

	while (q.size()) {
		int f = q.front(); q.pop();
		if (f == 0 || f == s.size() - 1)continue;
		if (mp.count(f)) {
			auto m = mp.find(f);
			auto l = prev(m);
			auto r = next(m);
			if (l->second == r->second)
				continue;
			mp.erase(f);
			q.push(l->first);
			q.push(r->first);
		}
	}

	int c = s.size() - mp.size();

	cout << (c % 2 ? "First" : "Second") << endl;

	return 0;
}

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

int main() {
  string S , S1 , S2;
  cin >> S ;
  cin >> S1 ;
  cin >> S2 ;
  
  cout<< 'A'<< S1.at(0) << 'C' ;

   }
     

  // ここにプログラムを追記


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

int main(){
  int N, K, C; cin >> N >> K >> C;
  if(N==1){
    cout << 1 << endl;
    return 0;
  }
  string S; cin >> S;
  vector<int> A(N+2,0);
  vector<int> B(N+2,0);
  int k=1;
  while(k<=N){
    if(S[k-1]=='o'){
      A[k]++;
      k+=C+1;
    }
    else k++;
  }
  int count=0;
  for(int i=1;i<=N;i++){
    count+=A[i];
    A[i]=count;
  }
  k=N;
  while(k>0){
    if(S[k-1]=='o'){
      B[k]++;
      k-=C+1;
    }
    else k--;
  }
  count=0;
  for(int i=N;i>0;i--){
    count+=B[i];
    B[i]=count;
  }
  for(int i=0;i<N;i++){
    if(S[i]=='o' && A[i]+B[i+2]<K){
      cout << i+1 << endl;
    }
  }
}
      
  
  
  
    

Measured memory_bytes: 3332
#include<bits/stdc++.h>
using ll  = long long;
#define int ll
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,s,n) for(int i=s;i<n;i++)
#define erep(e,v) for(auto && e :v)
#define all(in) in.begin(), in.end()
#define MP make_pair
#define INF (sizeof(int) == 4 ? (int)1e9:(int)1e18)
#define EPS 0.0000000001
using namespace std;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<typename Head, typename Value> auto vectors(const Head &head, const Value &v) { return vector<Value>(head, v); }
template<typename Head, typename... Tail> auto vectors(Head x, Tail... tail) { auto inner = vectors(tail...); return vector<decltype(inner)>(x, inner); }
template<class T> void join(T a){for(auto itr :a){if(itr != *a.begin())cout << " "; cout << itr;} }
using ld  = long double;
using pii = pair<int,int>;
using piii = pair<int,pii>;
int W,H;
int dx[]={0,0,1,-1}, dy[]={1,-1,0,0};
bool valid(int x,int y){return (0<=x&&x<W)&&(0<=y&&y<H);}
signed main(){
    int n; cin >> n;
    int ans = 0;
    map<string,int>used;
    string t = "753";
    function<void(int)>dfs = [&](int num)->void{
        string s = to_string(num);
        rep(i,t.size()){
            string ts = s;
            ts.push_back(t[i]);
            if(ts.find("3") != string::npos and  ts.find("5") != string::npos and ts.find("7") != string::npos and used[ts] == 0
            and stoll(ts) <= n){
                ++ans;
                used[ts]++;
            }
            if(stoll(ts) <= n) dfs(stoll(ts));
        }
    };
    dfs(0);
    cout << ans << endl;
}



Measured memory_bytes: 10368
import sys
input = lambda: sys.stdin.readline().rstrip()
input_nums = lambda: list(map(int, input().split()))

def main():
    N = int(input())
    A = input_nums()
    idx = [i for i in range(1, N+1)]
    A = dict(zip(idx, A))
    B = dict(zip(idx,[0]*N))
    for i in reversed(range(1,N+1)):
        b = i
        cnt = 0
        while b <= N:
            cnt += B[b]
            b += i
        if not cnt % 2 == A[i]:
            B[i] = 1
    sumv = sum(B.values())
    print(sumv)
    if sumv != 0:
        print(*[k for k, v in B.items() if v == 1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 128872
n = gets.chomp.to_i
vs = gets.chomp.split(' ').map(&:to_i)

evens = vs.each_with_index.to_a.select { |_v, i| i.even? }.map(&:first)
odds = vs.each_with_index.to_a.select { |_v, i| i.odd? }.map(&:first)
e_freq = evens.group_by(&:itself).map { |k, v| [v.length, k] }.sort.reverse
o_freq = odds.group_by(&:itself).map { |k, v| [v.length, k] }.sort.reverse
e_freq.push([0, 0])
o_freq.push([0, 0])
x = [[e_freq[0], o_freq[0]], [e_freq[1], o_freq[0]], [e_freq[0], o_freq[1]]].compact.map do |e, o|
  [e[0] + o[0], e[1] != o[1]]
end.select { |x| x[1] }.sort.reverse.first.first

puts vs.count - x


Measured memory_bytes: 38904
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main(){
    ll A,B,C;
    cin>>A>>B>>C;
    cout <<min(B/A,C)<<endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main{

	public static void main(String[] args){
    
      Scanner sc=new Scanner(System.in);
      
      String str=sc.next();
      
      String[] data=str.split("");
      
      int counter=0;
      
      for(String s:data){
      		if(s.equals("1")){
            	counter++;
            }
      }
      
      System.out.println(counter);
      
    }
}

Measured memory_bytes: 21844
#include<cstdio>
#include<iostream>
#include<string>

using namespace std;

int main(void) {

	string s;
	cin >> s;

	for (int i = 0; i < s.size(); i+=2)
	{
		cout << s[i];
	}

	cout << "\n";

	return 0;
}

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

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define inf 1e18
#define all(v) v.begin(),v.end()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
template<typename T> inline bool chmax(T &a, T b){ if(a<b) a=b; return a<b; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a) a=b; return b<a; }
template<typename T> void vdeb(T v){
    cout << "#vector set debug" << endl;
    for(auto vv : v) cout << vv << " ";
    cout << endl;
}
template<typename T1, typename T2> void adeb(T1 arr[], T2 n){
    cout << "#adebug" << endl;
    for(int i=0; i<=n; i++) cout << arr[i] << " ";
    cout << endl;
}
template<typename T1> void mdeb(T1 mp){
    cout << "#map pair debug" << endl;
    for(auto const& m : mp) cout << m.first sp m.second << endl;
}
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){ fill((T*)array, (T*)(array+N), val); }
void ans(bool b){ cout << (b ? "Yes" : "No") << endl; }
void ans2(bool b){ cout << (b ? "YES" : "NO") << endl; }
int dx[] = {1, 0, -1, 0, 1, -1, 1, -1};
int dy[] = {0, 1, 0, -1, 1, -1, -1, 1};


class DLuckyPIN {
public:
	void solve(std::istream& in, std::ostream& out) {
        int n;
        string s;
        in >> n >> s;

        int res = 0;
        reps(i, 0, 999){
            ll num[3] = {i / 100, i / 10 % 10, i % 10};
            int marker = 0;
            bool flg = false;
            rep(i, n){
                if(s[i]-'0' == num[marker]) marker++;
                if(marker == 3){
                    res++;
                    break;
                }
            }
        }

        out << res << endl;
	}
};


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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		
		Scanner scan = new Scanner(System.in);
		//System.out.print(" ");
		String s =scan.next();
		

		
		if ( s.equals("ABC")) {
			//String s =scan.nextLine();
			System.out.println("ARC"); 			
		}
		else {
			System.out.println("ABC");
		}  
		scan.close();
		
	
	}
}

Measured memory_bytes: 26900
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
typedef long long ll;
using namespace std;

int main()
{
  string s; int c=0,c1=0;
  cin>>s;
  for(int i=0;i<s.size();i++)
  {
    if(s[i]=='A')
    {
      c++;
    }
    else
    {
      c1++;
    }
}
  if(c==2||c1==2)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

Measured memory_bytes: 3564
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

int main() {
    ll W, H, x, y;
    cin >> W >> H >> x >> y;
    cout << fixed << setprecision(15) <<  W * H / 2.0 << " " << (2 * x == W && 2 * y == H) << endl;
}

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

bool isPalindrome(std::string str){
    int len = str.size();
    --len;
    for(int i = 0; i < len; ++i){
        if(str[i] != str[len - i]) return false;
    }
    return true;
}

int main(){
    bool is_palindrome[10001];
    for(int i = 1; i <= 10000; ++i){
        is_palindrome[i] = isPalindrome(std::to_string(i));
        //if(is_palindrome[i]) std::cout << i << std::endl;
    }

    int n;

    std::cin >> n;

    for(int i = 0; ; ++i){
        if(n - i >= 0 && is_palindrome[n - i]){
            std::cout << n - i << std::endl;
            break;
        }
        
        if(n + i <= 10000 && is_palindrome[n + i]){
            std::cout << n + i << std::endl;
            break;
        }
    }

}

Measured memory_bytes: 3280
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int n;
long long k;
long long a[200010];
long long f[200010];
int main(){
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n;i++){
		cin>>f[i];
	}
	sort(a,a+n);
	sort(f,f+n);
	ll l=0,r=2e18;
	while(l<r){
		ll mid=(l+r)/2;
		long long cnt=0;
		vector<ll> v;
		for(int i=0;i<n;i++){
			v.push_back(mid/f[i]);
		}
		sort(v.begin(),v.end());
		for(int i=0;i<n;i++){
			if(a[i]>v[i]){
				cnt+=(a[i]-v[i]);
			}
		}
		if(cnt<=k){
			r=mid;
		}
		else{
			l=mid+1;
		}
	}
	cout<<r<<endl;
	return 0;
}

Measured memory_bytes: 7028
#include<bits/stdc++.h>
#define pi acos(-1)
#define ll long long
#define pii pair<ll,ll>
#define debug(a) cout<<a<<'\n'
#define maxn 500009 /// leave to tomorrow anything that can be done today
#define MOD 1000000007
#define F first
#define S second
#define rep(i, a, b) for(ll i = a; i < (b); ++i)
#define per(i, b, a) for(ll i = b-1; i>=a ; i--)
#define trav(a, x) for(auto& a : x)
#define allin(a , x) for(auto a : x)
#define all(x) begin(x), end(x)
#define sz(x) (ll)(x).size()
using namespace std;
const ll INF = 1e17 + 9;
int main(){
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    vector<char> ini,fim;
    ll act=1; /// 1 = normal -1 não normal
    ll q;
    cin>>q;
    while(q--){
        int t;
        cin>>t;
        if(t==1){
            act=-act;
        }
        else{
            int f;
            char c;
            cin>>f>>c;
            if(f==1){
                if(act==1)ini.push_back(c);
                else fim.push_back(c);
            }
            else{
                if(act==1)fim.push_back(c);
                else ini.push_back(c);   
            }
        }
    }
    if(act==-1){
        per(i,sz(fim),0)cout<<fim[i];
        reverse(all(s)),cout<<s;
        rep(i,0,sz(ini))cout<<ini[i];
        cout<<'\n';
    }
    else{
        per(i,sz(ini),0)cout<<ini[i];
        cout<<s;    
        rep(i,0,sz(fim))cout<<fim[i];   
        cout<<'\n';
    }
    return 0;   
}   

Measured memory_bytes: 976
//@author KhaledAlam.net
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef stringstream ss;
typedef pair<int, int> pii;
//#########################
#define fi           first
#define se           second
#define pb           push_back
#define mp           make_pair
#define out(x)       return cout<<x,0
#define all(x)       x.begin(),x.end()
#define sz(x)        ((int)(x.size()))
#define clr(x)       memset(x,0,sizeof x)
#define rep(i,n)     for(int i=0;i<n;i++)
#define debug(x)     cerr<<"[l#: "<<__LINE__<<"] "<<#x<<" = "<<x<<endl
// v0.0.2 | Github.com/khaledalam/templates/tree/master/cpp
//##########################################################################

#define maxn 101010

ll memo[100];

ll f(ll n)
{
	if (n == 0) return 2;
	if (n == 1) return 1;
	if(memo[n])return memo[n];
	return memo[n] = f(n - 1) + f(n - 2);
}
int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
//	freopen("input.txt", "r", stdin); //freopen("output.txt","w",stdout);

	ll n;
	cin >> n;
	clr(memo);
	cout << f(n);

}



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

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

  int n, x;
  cin >> n >> x;
  vector<int> m(n);
  for (int i = 0; i < n; i++) {
    cin >> m[i];
  }

  int s = 0;
  int minimum = 1001001;
  for (int &v : m) {
    minimum = min(minimum, v);
    s += v;
  }
  cout << n + (x - s) / minimum << '\n';
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
#define pb push_back
#define fs first
#define sc second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
using namespace std;
template<class S,class T> ostream& operator<<(ostream& o,const pair<S,T> &p){
	return o<<"("<<p.fs<<","<<p.sc<<")";
}
template<class T> ostream& operator<<(ostream& o,const vector<T> &vc){
	o<<"{";
	for(const T& v:vc) o<<v<<",";
	o<<"}";
	return o;
}
using ll = long long;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T>>;
constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n-1); }

#ifdef LOCAL
#define show(x) cerr << "LINE" << __LINE__ << " : " << #x << " = " << (x) << endl
#else
#define show(x) true
#endif

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);		//DON'T USE scanf/printf/puts !!
	cout << fixed << setprecision(20);
	
	int N;
	cin >> N;
	int ans = 0;
	rep1(i,N){
		if(to_string(i).size()%2 == 1) ans ++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 892
using System;
using System.Collections.Generic;
using System.Linq;

class Program {
    static string ReadLine() { return Console.ReadLine().Trim(); }
    static int ReadInt() { return int.Parse(Console.ReadLine()); }
    static int[] ReadInts() { return ReadLine().Split().Select(int.Parse).ToArray(); }
    static string[] ReadStrings() { return ReadLine().Split(); }

    static void Main() {
        int n = ReadInt();
        int a = ReadInt();
        int b = ReadInt();

        int min = Math.Min(a, b);
        int ans = b - a;
        for (int i = 2; i < n; i++) {
            int x = ReadInt();
            ans = Math.Max(ans, x - min);
            min = Math.Min(min, x);
        }
        Console.WriteLine(ans);
    }
}

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

const int maximum = 305;
double p[maximum][maximum][maximum];
double ev[maximum][maximum][maximum];

int main() {
    int n;
    cin>>n;
    vector<int> cnt(4);
    for(int i = 0; i < n; ++i) {
        int x;
        cin>>x;
        ++cnt[x];
    }

    p[cnt[1]][cnt[2]][cnt[3]] = 1;

    for(int c = cnt[3]; c >= 0; --c) {
        for(int b = cnt[2] + cnt[3]; b >= 0; --b) {
            for(int a = n; a >= 0; --a) {

                if(a == 0 && b == 0 && c == 0) {
                    continue;
                }
                if(a + b + c > n) {
                    continue;
                }

                double p_waste = (double) (n - (a + b + c)) / n;
                double ev_waste = p_waste / (1 - p_waste) + 1;

                ev[a][b][c] += ev_waste * p[a][b][c];

                if(a != 0) {
                    double prob_next = (double) a / (a + b + c);
                    p[a-1][b][c] += p[a][b][c] * prob_next;
                    ev[a-1][b][c] += ev[a][b][c] * prob_next;
                }
                if(b != 0) {
                    double prob_next = (double) b / (a + b + c);
                    p[a+1][b-1][c] += p[a][b][c] * prob_next;
                    ev[a+1][b-1][c] += ev[a][b][c] * prob_next;
                }
                if(c != 0) {
                    double prob_next = (double) c / (a + b + c);
                    p[a][b+1][c-1] += p[a][b][c] * prob_next;
                    ev[a][b+1][c-1] += ev[a][b][c] * prob_next;
                }
            }
        }
    }
    printf("%.10f\n", ev[0][0][0]);

    return 0;
}



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

int main(void)
{
  int n;
  cin >> n;
  vector<int> data(n);
  for(int i = 0; i < n ; i++)
  {
    cin >> data[i];
  }
  int sum = 0;
  for(int i = 0; i < n; i++)
  {
    for(int j = i + 1; j < n; j++)
    {
      sum += data[i] * data[j];
    }
  }
  cout << sum << endl;
}

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

int m, n;
string s, t;
int dp[2001][2001][2];

int dfs(int x, int y, char c){		
	if( x >= m && y >= n )
		return 0;
	
	if( dp[x][y][c=='I'] > 0 )
		return dp[x][y][c=='I'];
		
	int ret = 0;
	if( x < m && s[x] == c )
		ret = max(ret, dfs(x + 1, y, c == 'I' ? 'O' : 'I') + 1);
	if( y < n && t[y] == c )
		ret = max(ret, dfs(x, y + 1, c == 'I' ? 'O' : 'I') + 1);
	return (dp[x][y][c=='I'] = ret);
}

int main(){
	int ans = 0;
	
	cin >> m >> n >> s >> t;
	for( int i = 0; i < m; i++ ){
		for( int j = 0; j < n; j++ ){
			dp[0][i][j] = -1;
			dp[1][i][j] = -1;
		}
	}
	
	for( int i = 0; i < m; i++ ){
		for( int j = 0; j < n; j++ ){
			ans = max(ans, dfs(i, j, 'I'));
		}
	}
	if( ans > 0 ){
		ans -= (ans + 1) % 2;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 32800
#include<iostream>
#include<vector>
#include<set>
#include<bitset>
#include<algorithm>
using namespace std;

const int N = 49;

int w, h;
vector<vector<int>> field;
int size;
vector<vector<int>> vertex;
vector<vector<int>> edge;
bitset<N> visited;
set<unsigned long long> memo;

void make_graph() {
    enum {Y, X};
    const int NEXT[4][2] = {{0, 1}, {1, 0}, {-1, 0}, {0, -1}};
//     const int NEXT[4][2] = {{0, 1}, {0, -1}, {1, 0}, {-1, 0}};
    const int NIL = -1;
    size = 0;
    vertex = vector<vector<int>>(h, vector<int>(w, NIL));
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) vertex[y][x] = size++;
    edge = vector<vector<int>>(h * w, vector<int>());
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) {
        if(vertex[y][x] == NIL) continue;
        for(const auto &d: NEXT) {
            int ny = y + d[Y];
            int nx = x + d[X];
            if(ny < 0 || h <= ny || nx < 0 || w <= nx) continue;
            if(vertex[ny][nx] == NIL) continue;
            edge[vertex[y][x]].push_back(vertex[ny][nx]);
        }
    }
};

void reachability(const int &from, bitset<N> &visited) {
    visited.set(from);
    for(const auto &to: edge[from]) if(!visited[to]) reachability(to, visited);
}
bool cut_vertex(const int &from) {
    auto dup = visited;
    dup.set(from);
    for(const auto &to: edge[from]) {
        if(dup[to]) continue;
        reachability(to, dup);
        return dup.count() != size;
    }
    return dup.count() != size;
}

bool dfs(const int &start, int from) {
//     cout<<visited<<" "<<from<<endl;
    unsigned long long m = visited.to_ullong() * N + from;
    if(memo.count(m)) return false;
    memo.insert(m);

    // startの四方が囲まれていたらダメ
    bool deadend = true;
    for(const auto &v: edge[start]) deadend &= visited[v];
    if(deadend) return false;

    // cut vertexはダメ
    if(cut_vertex(from)) return false;

    // 現在地以外で次数1の頂点があるとダメ
    for(int u = 0; u < size; ++u) {
        if(u == from) continue;
        if(visited[u]) continue;
        int degree = 0;
        for(const auto& v: edge[u]) if(v == start || !visited[v]) ++degree;
        if(degree < 2) return false;
    }

    visited.set(from);
    for(const auto &to: edge[from]) {
        if(to == start && visited.count() == size) return true;
        if(visited[to]) continue;
        if(dfs(start, to)) return true;
    }
    visited.reset(from);
    return false;
}

bool solve() {
    visited = bitset<N>(0);
    make_graph();
    memo.clear();
    for(int y = 0; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) return dfs(vertex[y][x], vertex[y][x]);
//     for(int y = 3; y < h; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) return dfs(vertex[y][x], vertex[y][x]);
//     for(int y = 0; y < 3; ++y) for(int x = 0; x < w; ++x) if(!field[y][x]) return dfs(vertex[y][x], vertex[y][x]);
    return false;
}

int main() {
    while(cin >> w >> h, w | h) {
        field = vector<vector<int>>(h, vector<int>(w));
        for(auto &line: field) for(auto &v: line) cin >> v;
        cout << (solve() ? "Yes" : "No") << endl;
    }
}

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

int main(void)
{
	int tate, yoko;
	int menseki, syuu;

	cin >> tate;
	cin >> yoko;

	menseki = tate * yoko;

	syuu = 2 * (tate + yoko);

	cout << menseki << " " << syuu << endl;

	return 0;
}



Measured memory_bytes: 3040
#include<cstdio>
#include<algorithm>

int main(){
  int s,k;
  long long st[100001],p[100001];
  scanf("%d%d",&s,&k);
  for(int i=1;i<=s;i++){
    scanf("%lld",&st[i]);
  }
  p[0]=0;
  p[1]=0;
  p[2]=(st[2]-st[1] < 0) ? st[1]-st[2] : st[2]-st[1];
  for(int i=3;i<=s;i++){
    p[i] = 1000000001;
  }
  for(int i=3;i<=s;i++){
    for(int j=1;j<=k;j++){
      if(i-j>=1){
	long long tmp;
	tmp = (st[i]-st[i-j] < 0) ? st[i-j]-st[i] : st[i]-st[i-j];
	if(p[i] > p[i-j]+tmp){
	  p[i] = p[i-j]+tmp;
	}
	if(tmp == 0) break;
      }else{
	break;
      }
    }
  }
  printf("%lld\n",p[s]);
  return 0;
}


Measured memory_bytes: 3252
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
    int x, y;
    cin >> x >> y;
    
    int a, b;
    for ( int i = 0; i < x; ++i)
    {
        a = i * 2 + ( x - i) * 4;
        if ( a == y)
        {
            cout << "Yes" << endl;
            break;
        }
        
        b = i * 4 + ( x - i) * 2;
        if( b == y)
        {
            cout << "Yes" << endl;
            break;
        }
    }
    if ( a != y && b != y)
    {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 3600
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto nklr = readln.split.to!(long[]);
    auto N = nklr[0];
    auto K = nklr[1];
    auto L = nklr[2];
    auto R = nklr[3];
    auto as = readln.split.to!(long[]);

    if (N == 1) {
        writeln(L <= as[0] && as[0] <= R ? 1 : 0);
        return;
    }

    long[][] bs, cs;
    bs.length = 21;
    cs.length = 21;
    void make(size_t i, size_t j, long c, long s, long[][] xs) {
        if (i == j) return;
        make(i+1, j, c, s, xs);
        xs[c+1] ~= s + as[i];
        make(i+1, j, c+1, s + as[i], xs);
    }
    make(0, as.length/2, 0, 0, bs);
    foreach (ref b; bs) sort(b);
    make(as.length/2, as.length, 0, 0, cs);
    foreach (ref c; cs) sort(c);

    long res;
    foreach (i, bb; bs) {
        if (K-i.to!int < 0 || K-i.to!int > 20) continue;
        auto cc = cs[K-i.to!int];
        if (cc.empty) continue;
        foreach (b; bb) {
            if (cc[0] + b > R) continue;
            if (cc[$-1] + b < L) continue;
            int s, t;
            if (cc[0] + b >= L) {
                s = 0;
            } else {
                int l, r = cc.length.to!int;
                while (l+1 < r) {
                    auto m = (l+r)/2;
                    if (cc[m] + b >= L) {
                        r = m;
                    } else {
                        l = m;
                    }
                }
                s = r;
            }
            int l, r = cc.length.to!int;
            while (l+1 < r) {
                auto m = (l+r)/2;
                if (cc[m] + b > R) {
                    r = m;
                } else {
                    l = m;
                }
            }
            t = r;
            res += t-s;
        }
    }
    if (bs.length > K) foreach (b; bs[K]) if (L <= b && b <= R) ++res;
    if (cs.length > K) foreach (c; cs[K]) if (L <= c && c <= R) ++res;
    writeln(res);
}


Measured memory_bytes: 30908
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; ++i)  cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n % 2 != 0){
        int l = a[n >> 1], r = b[n >> 1];
        cout << r - l + 1 << '\n';
    }
    else{
        double l = (double)(a[(n >> 1) - 1] + a[n >> 1]) / 2;
        double r = (double)(b[(n >> 1) - 1] + b[n >> 1]) / 2;
        int ans = 0;
        if(l != (int)l) ++ans, l += 0.5;
        if(r != (int)r) ++ans, r -= 0.5;
        ans += (int)(r - l) * 2 + 1;
        cout << ans << '\n';
    }
}

Measured memory_bytes: 4696
/*
ID: wangyuxi20040901
TASK:  ()
LANG: C++
DATE: 20200419 20:43:11
*///using CRLF, UTF-8

#include <cstdio>
#include <algorithm>
#include <cstring>
#define pr printf
#define F(i, j, k) for(register ll i = j, kkllkl = k; i <= kkllkl; ++i)
#define G(i, j, k) for(register ll i = j, kkllkl = k; i >= kkllkl; --i)
#define clr(a, v) memset((a), v, sizeof(a))
using namespace std;
typedef long long ll;

#define isd(x) (('0' <= (x) && (x) <= '9') || (x) == '-')
ll rd() {
    ll ans = 0, sign = 1; char c = getchar();
    while(!isd(c)) c = getchar();
    if(c == '-') sign = -1, c = getchar();
    while(isd(c)) ans = (ans << 3) + (ans << 1) + c - '0', c = getchar();
    return sign == 1 ? ans : -ans;
}

/* --------------------------CSYZ1921------------------------- */

const int MOD = 1000000007;
ll n, k;

int main() {
    // freopen(".in", "r", stdin);
    // freopen(".out", "w", stdout);
    n = rd(), k = rd();
    ll ans = 0;
    F(i, k, n + 1)
        (ans += i * (n - i + 1) + 1) %= MOD;
    pr("%lld\n", ans);
    return 0;
}
/*
*/

Measured memory_bytes: 1604
a, b = map(int, input().split())
c = list(map(int, input().split()))
d = 0
e = 0
for i in range(0, a):
    if i == 0:
        d = c[i] + b
    else:
        e += min(c[i] - c[i-1], d, b)
        d = c[i] + b
print(e + b)


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

int main() {
  long long X, Y;
  scanf("%lld%lld", &X, &Y);

  long long ans = 0;
  while (X <= Y) {
    X *= 2;
    ans++;
  }

  printf("%lld", ans);
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define sayyes cout<<"Yes"<<endl;
#define sayno cout<<"No"<<endl;
using namespace std;
typedef long long ll;
const double PI=acos(-1);
typedef pair<int,int>P;
const int mod =1e9+7;

int main()
{
    int n;
    cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    sort(a.begin(),a.end());
    vector<ll> total(n,0);
    total[0]=a[0];
    rep(i,n-1)
    {
        total[i+1]=total[i]+a[i+1];
    }
    int ans=n;
    int point=0;
    ll now=a[0];
    rep(i,n-1)
    {
        if(a[i+1]>now*2)
        {
            //cout<<i+1<<endl;
            ans-=i-point+1;
            point=i+1;
        }
        now=total[i+1];
        
        
    }
    cout<<ans;
}


Measured memory_bytes: 1792
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
typedef unsigned int ui;
int main(){
	int n,p;
	cin >> n;
	int a[20000],b[20000];
	for (int i = 0; i < n; i++) {
		a[i] = 30000 * i + 30000;
		b[i] = 30000*n - 30000*i;
	}
	int check = 0;
	for (int i = 0; i < n; i++) {
		cin >> p; p--;
		b[p] += check;
		check++;
	}
	for (int i = 0; i < n; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < n; i++) {
		cout << b[i]<<" ";
	}
	cout << endl;
	char nyaa;
	cin >> nyaa;
	return 0;
}

Measured memory_bytes: 768
import java.util.*;
import java.awt.geom.*;
import java.io.*;
public class Main{
	
	class InStream{
		BufferedReader in;
		StringTokenizer st;
		public InStream() {
			this.in = new BufferedReader(new InputStreamReader(System.in));
			this.st = null;
		}
		
		boolean hasNext(){
			try {
				st = new StringTokenizer(in.readLine());
				return true;
			} catch (Exception e) {return false;}
		}
		
		String next() {
			while (st==null || !st.hasMoreTokens()) {
				try {
					st = new StringTokenizer(in.readLine());
				} catch (Exception e) {}
			}
			return st.nextToken(); 
		}

		int nextInt() {
			return Integer.parseInt(next()); 
		}

		long nextLong() {
			return Long.parseLong(next());
		}

		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
	
	private void doit(){
		InStream in = new InStream();
		int count = 0, sum = 0, total = 0;
		
		while(in.hasNext()){
			String [] input = in.next().split(",");
			sum += Integer.parseInt(input[1]);
			total += Integer.parseInt(input[0]) * Integer.parseInt(input[1]);
			count++;
		}
		
		double res = (double)sum / count;
		System.out.printf("%d\n%d\n", total, (int)(Math.round(res)));
	}

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

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

typedef long long ll;
typedef long double ld;

#define pb push_back
#define sort(s) sort(s.begin(),s.end())
#define reverse(s) reverse(s.begin(),s.end())
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)

const ll mod = 1e9+7;

//最大公約数
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;
}

//素数判定
bool isPrime(ll x){
    ll i;
    if(x < 2)return 0;
    else if(x == 2) return 1;
    if(x%2 == 0) return 0;
    for(i = 3; i*i <= x; i += 2) if(x%i == 0) return 0;
    return 1;
}

//桁和
int digsum(ll n) {
    int res = 0;
    while(n > 0) {
        res += n%10;
        n /= 10;
    }
    return res;
}

//桁数
int dignum(ll n) {
    int res = 0;
    while(n > 0) {
        res++;
        n /= 10;
    }
    return res;
}

//文字列中の特定の文字カウント
ll stringcount(string s,char c){
    return count(s.cbegin(),s.cend(),c);
}

//階乗
ll ka(ll i){
    ll res=1;
    while(i>0){
        res=res*i;
        i--;
    }
    return res;
}
 
//ncr
ll ncr(ll x,ll y){
    ll a = x;
    ll b = 1;
    if(y>(x/2)){
        y=x-y;
    }
    for(ll i=1;i<y;i++){
        a*=x-i;
        b*=i+1;
    }
    return a/b;
}

//フィボナッチ数列 -92
ll f(ll x){
    ll dp[x+1];
    dp[1]=1;
    dp[2]=1;
    for(ll i=3;i<=x;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    return dp[x];
}



int main(){
    int n;
    cin >> n;
    ll dp[n+1];
    dp[0]=2;dp[1]=1;
    for(int i=2;i<=n;i++){
        dp[i]=dp[i-1]+dp[i-2];
    }
    cout << dp[n] << endl;
}

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

using namespace std;
typedef long long ll;
#define SIZE(array) (sizeof(array) / sizeof(array[0]))

int main()
{
    ll N;
    cin >> N;
    ll a[N];
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        a[i] -= i;
    }

    sort(a, a + SIZE(a));
    ll ans = 0;
    ll b = a[N / 2];
    for (int i = 0; i < N; i++)
    {
        ans += abs(a[i] - b);
    }

    if (N % 2 == 1)
    {
        cout << ans << endl;
    }
    else
    {
        ll tmp = 0;
        ll b = a[N / 2] - 1;
        for (int i = 0; i < N; i++)
        {
            tmp += abs(a[i] - b);
        }
        cout << min(ans, tmp) << endl;
    }
    // cout << a[N - 1] - a[0] << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <iostream>
#include <vector>
#include <queue>
#include <functional>

using namespace std;

//FILE* in = freopen("./B","r",stdin);

typedef long long LL;
#define REP(i,a,b)for(LL i=(LL)a;i<(LL)b;i++)


#define MAX_V 3100
#define INF 1000000

struct edge{int to,cost,time;edge(int t,int c,int h):to(t),cost(c),time(h){}};
typedef pair<int, int> P;

int V=MAX_V;
vector<edge> G[MAX_V];
int d[MAX_V];

int dijkstra(int s,int g,bool flag){
	priority_queue<P, vector<P>, greater<P> > que;
	fill(d, d+V, INF);
	d[s] = 0;
	que.push(P(0,s));

	while(!que.empty()){
		P p=que.top(); que.pop();
		int v = p.second;
		if(v==g)return d[v];
		if( d[v] < p.first ) continue;
		for(int i = 0;i<G[v].size();i++){
			edge e = G[v][i];
			if(flag==0){
			if(d[e.to] > d[v] + e.cost ){
				d[e.to] = d[v] + e.cost;
				que.push(P(d[e.to],e.to));
			}
			}else{
				if(d[e.to] > d[v] + e.time ){
				d[e.to] = d[v] + e.time;
				que.push(P(d[e.to],e.to));
			}

			}
		}
	}
	return -1;
}

int main(void){

	while(1){

		REP(i,0,MAX_V)
			G[i].clear();

		int N,M;
		int cost,time,a,b;
		int K,start,goal,R;

		cin >> N>>M;

		if(!N&&!M)break;

		REP(i,0,N){
			cin >> a>>b>>cost>>time;
			G[a].push_back(edge(b,cost,time));
			G[b].push_back(edge(a,cost,time));
		}

		cin >> K;

		REP(i,0,K){
			cin >> start>>goal>>R;
			cout << dijkstra(start,goal,R)<<endl;
		}

	}

	return 0;
}

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

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

        public static void Solve()
        {
            var (N, M) = Scanner.Scan<int, int>();
            int Func(int n) => n * (n - 1) / 2;
            Console.WriteLine(Func(N) + Func(M));
        }

        public static class Scanner
        {
            private static Queue<string> queue = new Queue<string>();
            public static T Next<T>()
            {
                if (!queue.Any()) foreach (var item in Console.ReadLine().Trim().Split(" ")) queue.Enqueue(item);
                return (T)Convert.ChangeType(queue.Dequeue(), typeof(T));
            }
            public static T Scan<T>() => Next<T>();
            public static (T1, T2) Scan<T1, T2>() => (Next<T1>(), Next<T2>());
            public static (T1, T2, T3) Scan<T1, T2, T3>() => (Next<T1>(), Next<T2>(), Next<T3>());
            public static (T1, T2, T3, T4) Scan<T1, T2, T3, T4>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>());
            public static (T1, T2, T3, T4, T5) Scan<T1, T2, T3, T4, T5>() => (Next<T1>(), Next<T2>(), Next<T3>(), Next<T4>(), Next<T5>());
            public static IEnumerable<T> ScanEnumerable<T>() => Console.ReadLine().Trim().Split(" ").Select(x => (T)Convert.ChangeType(x, typeof(T)));
        }
    }
}


Measured memory_bytes: 28304