akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.Threading.Tasks;
using System.IO;
using System.Diagnostics;
class Program
{
    public static Scanner cin;
    static void Main()
    {
        cin = new Scanner();
        long[] xyzk = cin.ArrayLong(4);
        long[][] abc = new long[3][];
        
        for(int a = 0; a < abc.Length; a++)
        {
            abc[a]= cin.ArrayLong((int)xyzk[a]);
        }
        Array.Sort(abc[0]);
        Array.Reverse(abc[0]);
        Array.Sort(abc[1]);
        Array.Reverse(abc[1]);
        Array.Sort(abc[2]);
        Array.Reverse(abc[2]);
        List<long> abc2 = new List<long>();
        for (int a = 0; a < xyzk[0]; a++)
        {
            if ((a + 1) > xyzk[3]) break;
            for (int b = 0; b <xyzk[1]; b++)
            {
                if ((a + 1) * (b + 1)  > xyzk[3]) break;
                for (int c = 0; c < xyzk[2]; c++)
                {
                    if ((a + 1) * (b + 1) * (c + 1) > xyzk[3]) break;
                    abc2.Add(abc[0][a] + abc[1][b] + abc[2][c]);
                }
            }
        }
        abc2.Sort();
        abc2.Reverse();
        for(int a = 0; a < xyzk[3]; a++)
        {
            Console.WriteLine(abc2[a]);
        }
        
        Console.ReadLine();

    }
}





class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

    public int nextInt()
    {
        return int.Parse(next());
    }
    public int[] ArrayInt(int N, int add = 0)
    {
        int[] Array = new int[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextInt() + add;
        }
        return Array;
    }

    public long nextLong()
    {
        return long.Parse(next());
    }

    public long[] ArrayLong(int N, long add = 0)
    {
        long[] Array = new long[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextLong() + add;
        }
        return Array;
    }

    public double nextDouble()
    {
        return double.Parse(next());
    }


    public double[] ArrayDouble(int N, double add = 0)
    {
        double[] Array = new double[N];
        for (int i = 0; i < N; i++)
        {
            Array[i] = nextDouble() + add;
        }
        return Array;
    }
}

Measured memory_bytes: 15584
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define gcd __gcd
#define all(x) (x).begin(), (x).end()
template<class T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<class T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
const int INF = 1e18, MOD = 1e9 + 7;
signed main() {
    INCANT;
    int n, a, res = 0;
    cin>>n>>a;
  	if(500*n>=a)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 256
N, K = map( int, input().split() )
result = 0.0

for i in range(1, N+1):
    tmp = 1.0 / N
    if i < K:
        point = i
        while point < K:
            point *= 2
            tmp /= 2
        result += tmp
    else:
        result += tmp

print("{:.12f}".format(result))

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

int main() {
    int N, L;
    cin >> N >> L;
    vector<string> S(N);

  for(int i=0; i<N; i++){
    cin >> S.at(i);
  }

  sort(S.begin(), S.end());

  for(int i=0; i<N; i++){
    cout << S.at(i);
  }

  cout << endl;

return 0;  
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <cstring>
#include <unordered_set>
#include <unordered_map>

using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
static const ll INF = 1000010000;
static const ll MOD = 1000000007;
 
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};


int main(){

    ll n;
    cin >> n;

    vector<ll> a(n * 3);
    REP(i, n * 3) cin >> a[i];

    priority_queue<ll, vector<ll>, greater<ll>> pq;
    priority_queue<ll, vector<ll>> bq;
    ll frontsum = 0, backsum = 0;
    ll fs[100010], bs[100010];

    REP(i, n){
       frontsum += a[i];
       pq.push(a[i]);
    }

    fs[0] = frontsum;
    
    REP(i, n){
        if(pq.top() < a[n + i]){
            frontsum = frontsum - pq.top() + a[n + i];
            pq.pop();
            pq.push(a[n + i]);
        }
        fs[i + 1] = frontsum;
    }

    
    REP(i, n){
        backsum += a[n * 2 + i];
        bq.push(a[n * 2 + i]);
    }

    bs[n] = backsum;

    for(ll i = n - 1; i >= 0; i--){
        if(bq.top() > a[n + i]){
            backsum = backsum - bq.top() + a[n + i];
            bq.pop();
            bq.push(a[n + i]);
        }
        bs[i] = backsum;
    }

    ll ans = -100000 * INF;

    REP(i, n + 1){
        ans = max(ans, fs[i] - bs[i]);
    }

    cout << ans << endl;

}

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

int main(){
    int N; cin >> N;
    int cnt=0;
    int cnt_a=0;
    int cnt_b=0;
    int cnt_c=0;
    for(int i=0;i<N;i++){
        string s;
        cin >> s;
        for(int j=0;j<s.size()-1;j++){
            if(s[j]=='A'&&s[j+1]=='B') cnt++;
        }
        if(s[0]=='B'&&s.back()!='A') cnt_b++;
        if(s[0]!='B'&&s.back()=='A') cnt_a++;
        if(s[0]=='B'&&s.back()=='A') cnt_c++;
    }
    int ans;
    if(cnt_c==0){
        ans=cnt+min(cnt_a,cnt_b);
    }else{
        if(cnt_a+cnt_b==0){
            ans=cnt+cnt_c-1;
        }else{
            ans=cnt+cnt_c+min(cnt_a,cnt_b);
        }
    }
    cout << ans << endl;
}

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

price = 0
in_four = 0
in_seven = 0
check = False

for i in range(30):
    price = 0
    price += i * 4
    if price == n:
        check = True
        break
    for j in range(20):
        price += j * 7
        if price == n:
            check = True
            break
        if price > n:
            break

if check:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9104
S = input()
acgt = ['A', 'C', 'G', 'T']
ans = 0
for i in range(len(S), 0, -1):
    for j in range(len(S) - i + 1):
        for k, s in enumerate(S[j:i + j]):
            if not s in acgt:
                break
            if k == len(S[j:i + j]) - 1:
                ans = len(S[j:i + j])
            
        if ans != 0:
            break
    else:
        continue
   
    break    
    
print(ans)

Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			int a = in.nextInt();
			int b = in.nextInt();
			int c = in.nextInt();
			int ans = Math.min(a + b, Math.min(b + c, a + c));
		    out.println(ans);
		}
	}
		
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

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

Measured memory_bytes: 22740
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

const int dy[] = {-1, 0, 1, 0}, dx[] = {0, -1, 0, 1};
vector<vi> move(const vector<vi> &a, int y, int x, int co){
	vector<vi> b = a;
	int f[4][4] = {};
	
	if(++b[y][x] == 5){
		b[y][x] = 0;
		f[y][x] = (1 << 4) - 1;
	}
	while(1){
		bool update = 0;
		int pf[4][4];
		rep(i, 4) rep(j, 4) pf[i][j] = f[i][j], f[i][j] = 0;
		rep(i, 4) rep(j, 4) if(pf[i][j]){
			update = 1;
			rep(d, 4) if(pf[i][j] & 1 << d){
				int ny = i + dy[d], nx = j + dx[d];
				if(ny < 0 || nx < 0 || ny >= 4 || nx >= 4) continue;
				f[ny][nx] |= 1 << d;
			}
		}
		if(!update) break;
		rep(i, 4) rep(j, 4) if(b[i][j]){
			b[i][j] += __builtin_popcount(f[i][j]);
			if(b[i][j] >= 5){
				b[i][j] = 0;
				f[i][j] = (1 << 4) - 1;
			}
			else f[i][j] = 0;
		}
	}
	rep(i, 4) rep(j, 4) if(b[i][j]) return b;
	cout << co + 1 << endl;
	exit(0);
}

int main(){
	bool ng = 0;
	vector<vi> a(4, vi(4));
	rep(i, 4) rep(j, 4) cin >> a[i][j], ng |= a[i][j];
	queue<pair<int, vector<vi> > > q;
	set<vector<vi> > s;
	s.insert(a);
	q.push(mp(0, a));
	
	if(!ng){
		cout << 0 << endl;
		return 0;
	}
	
	while(!q.empty()){
		a = q.front().second;
		int co = q.front().first; q.pop();
		
		int mx = 0;
		rep(i, 4) rep(j, 4) mx = max(mx, a[i][j]);
		if(co > mx) continue;
		
		rep(i, 4) rep(j, 4){
			if(a[i][j] == 0){
				a[i][j] = 1;
				if(!s.count(a)){
					q.push(mp(co + 1, a));
					s.insert(a);
				}
				a[i][j] = 0;
			}
			else{
				vector<vi> b = move(a, i, j, co);
				if(co == 4 || s.count(b)) continue;
				s.insert(b);
				q.push(mp(co + 1, b));
			}
		}
	}
	cout << -1 << endl;
	
	return 0;
}

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

const long long mod = 1e9 + 7;

int main() {
    int n;
    string s;
    cin >> n >> s;
    int cnt[26];
    for (int i = 0; i < 26; ++i) cnt[i] = 0;
    for (int i = 0; i < n; ++i) cnt[s[i] - 'a']++;
    long long ans = 1;
    for (int i = 0; i < 26; ++i) {
        ans *= (long long)(cnt[i] + 1);
        ans %= mod;
    }
    cout << (ans ? --ans : --ans + mod) << endl;
}

Measured memory_bytes: 3700
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

const int maxn = 1e5+5;
int sum[maxn];

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    ios::sync_with_stdio(false);
    int n,m;
    while (cin >> n >> m) {
        sum[0] = 0;
        FOR(i,1,n+1) {
            int a; cin >> a;
            sum[i] = (sum[i-1]+a) % m;
        }
        LL ans = 0;
        FOR(i,1,n+1)
            ans += (sum[i] == 0);
        map<int,int> cnt;
        FOR(i,1,n+1) {
            ans += cnt[sum[i]];
            cnt[sum[i]]++;
        }
        cout << ans << endl;
    }
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
    }
    
    map<int, int> funami;
    vi nxt(n, -1);
    for (int i = data.size()-1; i >= 0; i--) {
        if (funami.find(data[i]) == funami.end()) {
            funami[data[i]] = i;
        } else {
            nxt[i] = funami[data[i]];
            funami[data[i]] = i;
        }
    }

    //rep(i, nxt.size()) std::cout << nxt[i] << " "; cout << endl;

    vi dp(n+1, 0);
    dp[0] = 1;
    rep(i, n) {
        dp[i+1] = (dp[i+1] + dp[i]) % MOD;
        if (nxt[i] != -1 && nxt[i] != i+1) {
            dp[nxt[i]] = (dp[nxt[i]] + dp[i]) % MOD;
        }
    }

    std::cout << dp[n] << std::endl;

    return 0;
}


Measured memory_bytes: 17408
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
N = lines.shift() * 1
sum = 0
for (i=0; i<N; i++) {
    line = lines[i].split(' ')
    x = line[0] * 1
    y = line[1]
    if (y == 'BTC') {
        x *= 380000.0
    }
    sum += x
}
console.log(sum)


Measured memory_bytes: 7372
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;

int n,m;
const long long mod=1e9+7;
long long tmp=1;

int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        tmp*=i;
        tmp%=mod;
    }
    for(int i=1;i<=m;i++)
    {
        tmp*=i;
        tmp%=mod;
    }
    if(abs(n-m)==0)
    {
        tmp*=2;
        tmp%=mod;
    }
    else if(abs(n-m)>1) tmp=0;
    cout<<tmp;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<deque>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<iterator>
#include<complex>
#include<stack>
#include "stdio.h"
using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
using Pii = pair<int, int>;

const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const long long mod_const = 1e9+7;

int dy[] = { 0, 0, 1, -1, 0 };
int dx[] = { 1, -1, 0, 0, 0 };

using MIte = multimap<ll, ll, greater<ll> >::iterator;

ll dp[101][100001] = { 0 };

//2053
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);

	// long long?
	ll N, W;
	cin >> N >> W;

	vector<int> vw(N, 0);
	vector<int> vv(N, 0);
	rep(i, N) {
		cin >> vw[i] >> vv[i];
	}

	for (int i = 0; i != N; ++i) {
		for (int j = 0; j != W+1; ++j) {
			if (j >= vw[i]) {
				dp[i + 1][j] = max(dp[i][j - vw[i]] + vv[i], dp[i][j]);
			}
			else {
				dp[i + 1][j] = dp[i][j];
			}
		}
	}

	ll ans = 0;
	for (int j = 0; j != W+1; ++j) {
		ans = max(ans, dp[N][j]);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 78464
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define repi(i,a,b) for(int i=a; i<=(b); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using ll = long long;
using namespace std;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return (a*b)/gcd(a,b);}
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int M;
int main(){
    cin >> M;
    cout << 24 - M + 24 << endl;
}

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

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

    if((B-A) < 1)
        cout << "delicious" << endl;
    else if((B-A) < (X+1))
        cout << "safe" << endl;
    else
        cout << "dangerous" << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <deque>
#include <list>
#include <stack>
#include <queue>
#include <functional>
#include <set>
#include <tuple>
#include <map>
#include <numeric>

using namespace std;
#define PI 3.14159265359
#define ll long long int

bool isPrime(ll x)
{   
    bool ans = true;
    if(x == 1) ans = false;
    else{

        for(ll i = 2; i * i <= x; i++){
            if(x % i == 0) ans = false;
        }
    }

    return ans;
}

int main(void)
{
    ll x;
    cin >> x;
    while(1){
        if(isPrime(x)){
            cout << x << endl;
            break;
        }
        x++;
    }

    return 0;
}

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

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> broken(n+1);
    rep(i, m){
        int a;
        cin >> a;
        broken[a] = 1;
    }
    vector<int> dp(n+2);
    //rep(i, n) cout << dp[i] << endl;
    const int mod = 1000000007;
    dp[n] = 1;
    for(int i = n-1; i >= 0; i--){
        if(broken[i]){
            dp[i] = 0;
            continue;
        }
        dp[i] = (dp[i+1] + dp[i+2]) % mod;
    }

    cout << dp[0] << endl;
    //cout << dp[n+1] <<endl;
    
    return 0;
}


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

using namespace std;

#define endl '\n'
#define fi first
#define se second
#define MOD(n,k) ( ( ((n) % (k)) + (k) ) % (k))
#define FOR(i,n) for (int i = 0; i < n; i++)
#define FORR(i,a,b) for (int i = a; i <= b; i++)
#define ALL(v) v.begin(), v.end()
#define pb(x) push_back(x)

typedef long long ll;
typedef long double ld;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<ii> vii;

const int MX = 200005;
int n;
ll a[MX], x;
__int128 res = __int128(1) << 126;

ll query (int i, int j) { return a[j] - a[i-1]; }

int main () {
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	cin >> n >> x;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
		a[i] += a[i-1];
	}

	for (int i = 1; i <= n; i++) {
		__int128 acu = i * x + 5 * query(n-i+1, n);

		for (int j = 2, k = n - i; k > 0; j++, k -= i)
			acu += (2 * j + 1) * query(max(1, k-i+1), k);

		res = min(res, acu); 
	}

	cout << ll(res + __int128(n * x)) << endl;

	return 0;
}

Measured memory_bytes: 1792
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        long[] a = new long[k];
        for (int i = 0; i < k; i++) {
            a[i] = sc.nextInt();
        }
        long min = 2;
        long max = 2;
        boolean able = true;
        for (int i = k-1; i >= 0; i--) {
            long r = (min + a[i] -1) / a[i];
            min = a[i] * r;
            if(max < min){
                able = false;
                break;
            }
            r = max / a[i];
            max = a[i] * r + a[i] - 1;
        }
        System.out.println(able ? min + " " + max : -1);
        sc.close();

    }

}


Measured memory_bytes: 50120
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <math.h>
using namespace std;

const int MAXN = 2e6 + 10;
int N, V;
int X[MAXN];
int v[MAXN], vn;
int l[19][MAXN], r[19][MAXN];
int f[MAXN], g[MAXN], h[MAXN];

int main() {
	register int s, i, j;
	scanf("%d%d", &N, &V);
	for(i = 1; i <= N; ++i)
		scanf("%d", X + i);
	v[0] = V; V >>= 1;
	while(V)
		v[++vn] = V, V >>= 1;
	v[++vn] = 0;
	reverse(v, v + vn + 1);
	for(i = 0; i <= vn; ++i) {
		l[i][1] = 1;
		for(j = 2; j <= N; ++j)
			l[i][j] = X[j] - X[j - 1] <= v[i] ? l[i][j - 1] : j;
		r[i][N] = N;
		for(j = N - 1; j; --j)
			r[i][j] = X[j + 1] - X[j] <= v[i] ? r[i][j + 1] : j;
	}
	f[0] = 0; g[0] = N + 1;
	for(s = 1; s <= (1 << (vn + 1)) - 1; ++s) {
		f[s] = 0; g[s] = N + 1;
		for(i = 0; i <= vn; ++i)
			if(s & (1 << i)) {
				int x = s ^ (1 << i);
				f[s] = max(f[s], f[x] == N ? N : r[i][f[x] + 1]);
				g[s] = min(g[s], g[x] == 1 ? 1 : l[i][g[x] - 1]);
			}
	}
	for(i = 0; i <= N; ++i)
		h[i] = N + 2;
	for(i = 0; i <= (1 << vn) - 1; ++i)
		h[f[i]] = min(h[f[i]], g[((1 << vn) - 1) ^ i]);
	for(i = N - 1; i >= 0; --i)
		h[i] = min(h[i], h[i + 1]);
	for(i = 1; i <= N; ++i)
		puts(h[l[vn][i] - 1] <= r[vn][i] + 1 ? "Possible" : "Impossible");
	return 0;
}

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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

ll dp[200010] = {0};

void Main()
{
	int N, K;
	cin >> N >> K;

	std::vector<pair<int, int>> S;
	for (int i = 0; i < K; ++i) {
		int L, R;
		cin >> L >> R;
		S.push_back({ L, R });
	}

	dp[0] = 1;
	dp[1] = -1;
	for (int i = 0; i < N; ++i) {
		if (i > 0 ) dp[i] = (dp[i] + dp[i - 1]) % 998244353;
		for (int j = 0; j < (int)S.size(); ++j) {
			int l = S[j].first;
			int r = S[j].second;
			if (i + l <= N) {
				dp[i + l] = (dp[i + l] + dp[i]) % 998244353;
			}
			if (i + r + 1 <= N) {
				dp[i + r + 1] = (dp[i + r + 1] + 998244353 - dp[i]) % 998244353;
			}
		}
	}

	cout << dp[N - 1];
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 5100
use proconio::input;

fn main() {
    input! {
        n: usize,
        mut numbers: [u128; n],
    }
    let value = 1000000000000000000u128;
    let mut start = 1;

    numbers.sort();
    if numbers[0] == 0 {
        println!("{}", 0);
        return;
    }    
    for n in &numbers {
        start *= n;
        if start > value {
            println!("{}", -1);
            return;
        }
    }
    println!("{}", start);

}


Measured memory_bytes: 6104
object Main {

  def main(args: Array[String]): Unit = {
    val _ = io.StdIn.readLine.toInt
    val pList = io.StdIn.readLine.split(" ").map(_.toInt).toList

    def solve(list: List[Int]): String = {

      val number = list.zipWithIndex.count(
        z => z._1 != z._2 + 1
      )



      if (number <= 2) "YES"
      else "NO"
    }

    println(solve(pList))
  }

}


Measured memory_bytes: 27208
#include "bits/stdc++.h"
using namespace std;
///////////////////////////////////////////
const long long int INF = 1LL<<60;
const long long int Mod = 1000000007;
using ll = long long int; using ci = const int;
using vi = vector<int>;  using Vi = vector<long long int>;
using P = pair<int, int>;  using PLL = pair<ll, ll>;
using matrix = vector<vector<ll>>;
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,N) for(ll i = 0; i < (ll)N; i++)
#define repi(i,a,b) for(ll i = ll(a); i < ll(b); ++i)
template<class T>bool chmax(T &former, const T &b) { if (former<b) { former=b; return true; } return false; }
template<class T>bool chmin(T &former, const T &b) { if (b<former) { former=b; return true; } return false; }
template<class T>T sqar(T x){ return x*x; }//sqrt(x)は平方根;
#define Sort(v) std::sort(v.begin(), v.end(), std::greater<decltype(v[0])>()) //降順でVをソート
#define p_queue(v) priority_queue<v, vector<v>, greater<v> >
template<class T> inline void princ(T x){cout<<x<<" ";}; 
template<class T> inline void print(T x){cout<<x<<"\n";};
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
///////////////////////////////////////////////////////////////////////////////////

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	std::cout<<std::fixed<<std::setprecision(30);
	string s,t;
	cin>>s>>t;
	ll ans = 0;
	rep(i,s.size()){
		if(s[i]==t[i])ans++;
	}	
	print(ans);
	return 0;
}

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

int main(){
  ll n, m;
  cin >> n >> m;

  vector<ll> v1(m, 0);
  vector<ll> v2(m, 0);
  for(int i = 0; i < m; i++){
      cin >> v1[i] >> v2[i];
  }

  sort(v1.begin(), v1.end());
  sort(v2.begin(), v2.end());

  ll ans = v2[0] - v1[m-1] + 1;
  if(ans < 0){ans = 0;}
  cout << ans << endl;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define vi vector<int>
#define pb push_back
#define LIM 210005

using namespace std;

vi lft,rgt;
int n, xx[LIM], yy[LIM];

#define MAX 200105

int arr[LIM];

int notun()
{
//    int n;
//    sf(n);
    for(int i=0; i<n; i++)
    {
//        int a,b;

//        sff(a,b);
        arr[ xx[i] ]++;
        arr[ yy[i] ]--;
    }

    int mx = INT_MIN;

    for(int i=1; i<=MAX; i++)
    {
        arr[i] += arr[i-1];
        mx = max(mx,arr[i]);
    }

    cout << " " << mx << endl;



    return 0;
}

int main() {
    scanf("%d", &n);
    for(int i=0; i<n; i++) {
        int x,y;
        scanf("%d %d", &x,&y);
        xx[i] = x; yy[i] = y;
        lft.pb(x); rgt.pb(y);
    }
    sort(lft.begin(), lft.end());
    sort(rgt.begin(), rgt.end());

    int ans = 0;
    for(int i=0; i<n; i++) {
        int pise = upper_bound(rgt.begin(), rgt.end(), xx[i])-rgt.begin();
        int samne= n-(lower_bound(lft.begin(), lft.end(), yy[i])-lft.begin());
        ans = max( ans, n - pise - samne );
//        cout << i << ' ' << pise << ' ' << samne << endl;
    }
    cout << ans ;

    notun();
}



Measured memory_bytes: 7220
#include <bits/stdc++.h>
using namespace std;
// type alias
typedef long long LL;
typedef pair<int,int> II;
typedef tuple<int,int,int> III;
typedef vector<int> VI;
typedef vector<string> VS;
typedef unordered_map<int,int> MAPII;
typedef unordered_set<int> SETI;
template<class T> using VV=vector<vector<T>>;
// minmax
template<class T> inline T SMIN(T& a, const T b) { return a=(a>b)?b:a; }
template<class T> inline T SMAX(T& a, const T b) { return a=(a<b)?b:a; }
// repetition
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)
#define REPE(i,n)  for(int i=0;i<=(n);++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORR(x,arr) for(auto& x:arr)
#define SZ(a) int((a).size())
// collection
#define ALL(c) (c).begin(),(c).end()
// DP
#define MINUS(dp) memset(dp, -1, sizeof(dp))
#define ZERO(dp) memset(dp, 0, sizeof(dp))
// stdout
#define println(args...) fprintf(stdout, ##args),putchar('\n');
// debug cerr
template<class Iter> void __kumaerrc(Iter begin, Iter end) { for(; begin!=end; ++begin) { cerr<<*begin<<','; } cerr<<endl; }
void __kumaerr(istream_iterator<string> it) { (void)it; cerr<<endl; }
template<typename T, typename... Args> void __kumaerr(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<"="<<a<<", ",__kumaerr(++it, args...); }
template<typename S, typename T> std::ostream& operator<<(std::ostream& _os, const std::pair<S,T>& _p) { return _os<<"{"<<_p.first<<','<<_p.second<<"}"; }
#define __KUMATRACE__ true
#ifdef __KUMATRACE__
#define dump(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); __kumaerr(_it, args); }
#define dumpc(ar) { cerr<<#ar<<": "; FORR(x,(ar)) { cerr << x << ','; } cerr << endl; }
#define dumpC(beg,end) { cerr<<"~"<<#end<<": "; __kumaerrc(beg,end); }
#else
#define dump(args...)
#define dumpc(ar)
#define dumpC(beg,end)
#endif

// $ cp-batch League | diff League.out -
// $ g++ -std=c++14 -Wall -O2 -D_GLIBCXX_DEBUG -fsanitize=address League.cpp && ./a.out

/*
 
 9/1/2019
 
 5:26-
 
 */

const int MAX_N=1e3+1;
int A[MAX_N][MAX_N];
int N;

map<II,int> ids;
VI G[MAX_N*MAX_N];
void solve() {
  REP(i,N) REP(j,N-2) {
    int a=A[i][j],b=A[i][j+1];
    G[a].push_back(b);
  }
  int M=SZ(ids);
  vector<int> D(M,0);
  for(int u=0; u<M; ++u) for(auto v : G[u]) D[v]++;
//  dumpc(D);
  vector<int> seq;
  queue<II> Q;
  for(int u=0; u<M; ++u) if(D[u]==0) Q.emplace(u,1);
  int res=0;
  while(Q.size()) {
    int u,len; tie(u,len)=Q.front(); Q.pop();
    seq.push_back(u);
    SMAX(res,len);
    for(auto v : G[u]) {
      D[v]--;
      if(D[v]==0) Q.emplace(v,len+1);
    }
  }
//  dumpc(seq);
//  dump(SZ(seq));
  if(SZ(seq)<M) res=-1;
  cout<<res<<endl;
}

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cout<<setprecision(12)<<fixed;
  
  cin>>N;
  
  int id=0;
  REP(i,N)FOR(j,i+1,N) ids[{i,j}]=id++;
  REP(i,N)REP(j,N-1) {
    int x=i;
    int y; cin>>y;
    --y;
    if(x>y) swap(x,y);
    A[i][j]=ids[{x,y}];
  }
  solve();
  
  return 0;
}


Measured memory_bytes: 78580
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <numeric>

using namespace std;

using ll =long long;
const ll L = 1e18;

int main()
{
    ll K, N;
    cin >> N >> K;
    ll a[10005];
    for(int i = 0;i < N;i++)
    {
        cin >> a[i];
    }
    sort(a, a+N);
    cout << accumulate(a, a+K, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 3176
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int INF = LLONG_MAX;
int dp[(1 << 16)];
int sums[(1 << 16)];

int calculate(vector<vector<int>> &score, int mask) {
	int ans = 0;
	for (int i = 0; i < 17; i++)
		for (int j = i + 1; j < 17; j++)
			if (((mask & (1 << i)) != 0) and ((mask & (1 << j)) != 0))
				ans += score[i][j];

	return ans;
}

void prepareSums(vector<vector<int>> &score, int n) {

	for (int subset = 1; subset < (1 << n); subset++)
		dp[subset] = INF;

	for (int subset = 1; subset < (1 << n); subset++)
		sums[subset] = calculate(score, subset);
}

int solve(vector<vector<int>> &score, int mask) {
	if (mask == 0)
		return 0;

	if (dp[mask] != INF)
		return dp[mask];

	int ans = 0;
	for (int submask = mask; submask != 0; submask = (submask - 1) & mask)
		ans = max(ans, sums[submask] + solve(score, mask ^ submask));

	return dp[mask] = ans;
}

int32_t main()
{
	int n; cin >> n;
	vector<vector<int>> score(n, vector<int>(n));
	for (int i = 0; i < n; i++)
		for (int j = 0; j < n; j++)
			cin >> score[i][j];
	prepareSums(score, n);
	cout << solve(score, (1 << n) - 1);
	return 0;
}


Measured memory_bytes: 1280
using System;
class Program{
	public static void Main(){
		string[] str = Console.ReadLine().Split(' ');
		int N = int.Parse(str[0]);
		int M = int.Parse(str[1]);
		int t = 1900 * M + 100 * (N - M);
		Console.WriteLine(Math.Pow(2.0 ,M ) * t);
	}
}

Measured memory_bytes: 11220
N = int(input())
cnt = 0
for n in range(1, N + 1, 2):
    route_n = int(n ** (1 / 2))
    by = [] 
    for i in range(1, route_n + 1, 2):
        if n % i == 0:
            by.append(i)
            a = n // i
            if a != i:
                by.append(a)
    if len(by) == 8:
        cnt += 1

print(cnt)

Measured memory_bytes: 62336
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>

using namespace std;

int main(void){
  int N,k;
  cin>>N;
  cin>>k;
  int A[N];
  int min_i;
  for(int i=0;i<N;i++){
    cin>>A[i];
    if(A[i]==1) min_i=i;
  }

  int cnt=0;
  if(N==k){
    cout << 1 << endl;
    return 0;
  }
  if(min(min_i,N-min_i)<=k){
    cnt=(N-k)/(k-1)+1;
    if((N-k)%(k-1)!=0) cnt++;
    cout << cnt << endl;
    return 0;
  }
  /*
  if(N%k==0 ){
    cnt=N/k;
    cout << cnt << endl;
    return 0;
  }
  */
  /*
  cnt=(min_i)/(k-1) + (N-1-min_i)/(k-1);
  if((min_i)%(k-1)!=0 ) cnt++;
  if((N-1-min_i)%(k-1)!=0) cnt++;
  */
  cnt=(N-k)/(k-1)+1;

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int x,a;
   cin >> x >> a;

   if(x<a) cout << 0 << endl;
   else cout << 10 << endl; 


   return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int h,n;
pair<int,int> a[1002];
int dp[20002];
int main(){
	scanf("%d%d",&h,&n);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i].first,&a[i].second);
	for(int i=1;i<=20000;i++) dp[i]=1e9+7;
	dp[0]=0;
	for(int i=0;i<h;i++){
		for(int j=1;j<=n;j++){
			dp[i+a[j].first]=min(dp[i+a[j].first],dp[i]+a[j].second);
		}
	}
	int ans=1e9+7;
	for(int i=h;i<=20000;i++){
		ans=min(ans,dp[i]);
	}
	printf("%d\n",ans);
}


Measured memory_bytes: 384
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        char[] str = line.toCharArray();

        line = sc.nextLine();
        int n = Integer.parseInt(line);

        for(int i = 0; i < n; i++) {
          line = sc.nextLine();
          String[] l = line.split(" ");
          String command = l[0];
          int start = Integer.parseInt(l[1]);
          int target = Integer.parseInt(l[2]);

          int len = target - start + 1;
          char[] tmp = new char[len];
          if(command.equals("replace")) {
            char rep[] = l[3].toCharArray();
            for(int j = 0; j < len; j++) {
              str[j + start] = rep[j];
            }
          } else if(command.equals("reverse")) {
            for(int j = 0; j < len; j++) {
              tmp[j] = str[j + start];
            }
            for(int j = 0; j < len; j++) {
              str[target - j] = tmp[j];
            }
          } else if(command.equals("print")) {
            for(int j = 0; j < len; j++) {
              tmp[j] = str[j + start];
            }
            System.out.println(String.valueOf(tmp));
          }

        }

    }
}

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

int n,d,x;
vector<vector<int>> p;

vector<int> dodp(const vector<int> &p, const vector<int> &q){
    vector<pair<int,int>> stf;
    for(int i = 0; i < n; i++){
        rep(i,p.size()){
            int bef = p[i], aft = q[i];
            while(bef < 100010){
                stf.emplace_back(bef,aft);
                bef *= 2;
                aft *= 2;
            }
        }
    }
    vector<int> dp(100010);
    for(auto & e : stf){
        int w, v; tie(w,v) = e;
        for(int j = 0; j < 100010; j++){
            if(j+w < 100010) dp[j+w] = max(dp[j+w], dp[j] + v);
        }
    }
    return dp;
}

int solve(){
    rep(i,d-1){
        vector<int> opt = dodp(p[i], p[i+1]);
        int y = x;
        rep(i,x+1){
            y = max(y, x-i + opt[i]);
            // cout << opt[i] << " ";
        }
        x = y;
        // cout << endl;
    }
    return x;
}

int main(){
    while(cin >> n >> d >> x && n){
        p.assign(d, vector<int>(n));
        rep(i,d)rep(j,n) cin >> p[i][j];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1616
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)
	var ans int
	for i := 1; i <= n; i++ {
		var a int
		fmt.Scan(&a)
		if i%2 == 1 && a%2 == 1 {
			ans++
		}
	}
	fmt.Println(ans)
}


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

/* define const */

/* finish defineing const */
int n;

int main()
{
    cin >> n;

    if (n < 1000)
    {
        cout << "ABC" << endl;
    }
    else
    {
        cout << "ABD" << endl;
    }
}


Measured memory_bytes: 256
# -*- coding:utf-8 -*-
import math

def is_prime(N):
    if N == 1:
        return False
    for k in range(2, int(math.sqrt(N))+1):
        if N%k == 0:
            return False
    return True

X = int(input())

while True:
    if is_prime(X):
        print(X)
        exit()
    X += 1
    


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

int dp[450][450];

int main() {
	int n, m1, m2; scanf("%d%d%d", &n, &m1, &m2);
	memset(dp, 0x3f, sizeof(dp));
	dp[0][0] = 0;
	rep(i, n) {
		int a, b, c; scanf("%d%d%d", &a, &b, &c);
		for (int j = i * 10; j >= 0; j--)for (int k = i * 10; k >= 0; k--) {
			dp[j + a][k + b] = min(dp[j + a][k + b], dp[j][k] + c);
		}
	}
	int Min = INF;
	for (int i = 1; i*m1 <= 400 && i*m2 <= 400; i++)
		Min = min(Min, dp[m1*i][m2*i]);
	if (Min == INF)puts("-1");
	else printf("%d\n", Min);
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

int main(void){
    int n;
    cin >> n;
    if(n % 10 == 3){
        cout << "bon" << endl;
    }
    else if(n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8){
        cout << "pon" << endl;
    }
    else{
        cout << "hon" << endl;
    }
    return 0;
}

Measured memory_bytes: 3548
#include <iostream>
#include<bits/stdc++.h>
#include <stdio.h>
#include <stdlib.h>

using namespace std;

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}

int main()
{
    int n;
    cin >> n;
    vector<pair<int ,int>> v;
    for (int i = 0; i < n; i++){
        int x;
        cin >> x;
        pair<int, int> p;
        p.first = i+1;
        p.second = x;
        v.push_back(p);
    }

    sort(v.begin(), v.end(), compare);

    for(int i = 0; i < n ;i++){
        cout << v[i].first << " ";
    }
    return 0;
}


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

int main() {
  int N,M;
  cin>>N;
  vector<string>red(N);
  rep(i,N){
    cin>>red.at(i);
  }
  cin>>M;
  vector<string>blue(M);
  rep(i,M){
    cin>>blue.at(i);
  }
  int ct=0;
  int cnt=0;
  rep(i,N){
    ct=0;
    rep(j,N){
      if(red.at(i)==red.at(j)){
        ct+=1;
      }
    }
    rep(j,M){
      if(red.at(i)==blue.at(j)){
        ct-=1;
      }
    }
    if(ct>cnt){
      cnt=ct;
    }
    }
  cout<<max(0,cnt);
}


Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        StringBuilder builder  = new StringBuilder();
        int i=1;
        while(true){
            int data = Integer.parseInt(br.readLine());
            if(data==0)
                break;
            builder.append("Case ").append(Integer.toString(i++)).append(": ").append(Integer.toString(data)).append("\n");
        }
        System.out.print(builder);
        }
}

Measured memory_bytes: 31208
n = int(input())
count = 0
p = [int(i) for i in input().split()]
for i in range(n):
    temp_p = p[i]
    if i + 1 != temp_p:
        count += 1
if count in [0, 2]:
    ans = "YES"
else:
    ans = "NO"
print(ans)

Measured memory_bytes: 3064
// #define _GLIBCXX_DEBUG // for STL debug (optional)
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>
using namespace std;
using ll = long long int;
using int64 = long long int;
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const int INF = 1LL << 29;
const ll LONGINF = 1LL << 60;
const ll MOD = 1000000007LL;

// ModInt begin

using ll = long long;
template<ll mod>
struct ModInt {
    ll v;
    ll mod_pow(ll x, ll n) const {
        return (!n) ? 1 : (mod_pow((x*x)%mod,n/2) * ((n&1)?x:1)) % mod;
    }
    ModInt(ll a = 0) : v((a %= mod) < 0 ? a + mod : a) {}
    ModInt operator+ ( const ModInt& b ) const {
        return (v + b.v >= mod ? ModInt(v + b.v - mod) : ModInt(v + b.v));
    }
    ModInt operator- () const {
        return ModInt(-v);
    }
    ModInt operator- ( const ModInt& b ) const {
        return (v - b.v < 0 ? ModInt(v - b.v + mod) : ModInt(v - b.v));
    }
    ModInt operator* ( const ModInt& b ) const {return (v * b.v) % mod;}
    ModInt operator/ ( const ModInt& b ) const {return (v * mod_pow(b.v, mod-2)) % mod;}
    
    bool operator== ( const ModInt &b ) const {return v == b.v;}
    bool operator!= ( const ModInt &b ) const {return !(*this == b); }
    ModInt& operator+= ( const ModInt &b ) {
        v += b.v;
        if(v >= mod) v -= mod;
        return *this;
    }
    ModInt& operator-= ( const ModInt &b ) {
        v -= b.v;
        if(v < 0) v += mod;
        return *this;
    }
    ModInt& operator*= ( const ModInt &b ) {
        (v *= b.v) %= mod;
        return *this;
    }
    ModInt& operator/= ( const ModInt &b ) {
        (v *= mod_pow(b.v, mod-2)) %= mod;
        return *this;
    }
    ModInt pow(ll x) { return ModInt(mod_pow(v, x)); }
    // operator int() const { return int(v); }
    // operator long long int() const { return v; }
};

template<ll mod>
ostream& operator<< (ostream& out, ModInt<mod> a) {return out << a.v;}
template<ll mod>
istream& operator>> (istream& in, ModInt<mod>& a) {
    in >> a.v;
    return in;
}

// ModInt end
using mint = ModInt<MOD>;

int dp[1 << 20];
int main() {
    int N; cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i], dp[ A[i] ]++;

    const int B = 20;
    for(int i=0; i<B; i++) {
        for(int bit=0; bit<(1<<B); bit++) {
            if(bit >> i & 1) dp[bit ^ (1 << i)] += dp[bit];
        }
    }

    mint ans = 0;
    for(int bit=0; bit<(1<<B); bit++) {
        mint p = mint(2).pow(dp[bit]) - mint(1);
        if(__builtin_parity(bit)) ans -= p;
        else ans += p;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7288
# define _CRT_SECURE_NO_WARNINGS 1
# define _USE_MATH_DEFINES
# include <iostream>
# include <numeric>
# include <string>
# include <bitset>
# include <vector>
# include <algorithm>
# include <cstdlib>
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iomanip>
# include <queue>
# include <sstream>
# include <climits>
# include <cmath>
# include <list>
# include <functional>
# include <string>
# include <ctime>
# include <set>
# include <forward_list>
# include <map>
# include <stack>
using namespace std;
# define INF ((int)(1<<25))
# define REP(i,n) for(int i=0;i<(int)n;i++)
# define FOR(i,n) REP(i,n)
# define TORAD 2.0*M_PI/360.0
# define INT(x) int x;cin>>x;
# define ALL(x) (x).begin(),(x).end()
# define RALL(x) (x).rbegin(),(x).rend()
# define DEBUG(x) cout<<#x<<" :"<<x<<endl;
# define EPS 1e-12
template<class T> void debug(T a) { for (auto i : a)cout << i << endl; }
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
int dx[4] = { 0,1,0,-1 }, dy[4] = { -1,0,1,0 };

int main()
{
	int n;
	while (cin >> n&&n)
	{
		int ans = 0;
		int s[6] = { 60,80,100,120,140,160 };
		int w[6] = { 2,5,10,15,20,25 };
		int v[7] = { 600,800,1000,1200,1400,1600,0 };
		FOR(i, n)
		{
			int X, Y, H, W; cin >> X >> Y >> H >> W;
			int S = X + Y + H;
			int a=6, b=6;
			for (int i = 5; i >= 0; i--)
			{
				if (S <= s[i]) {
					a = i; 
				}
			}
			for (int i = 5; i >=0; i--)
			{
				if (W <= w[i]){
					b = i; 
				}
			}
			ans += v[max(a, b)];
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
#define Hello ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n'
#define ll long long
int main(){
    Hello
    int a, b, c;
    cin >> a >> b >> c;
    cout << min(c, b/a);
    return 0;
}

Measured memory_bytes: 3608
using System;
using System.Linq;

class Program {
    private static int Main() {
        while( true ) {
            var input = Console.ReadLine();
            if( string.IsNullOrEmpty( input ) ) { break; }

            var values = input.Split( ' ' );
            var sum = values.Select( _ => int.Parse( _ ) ).Sum();
            var digit = sum.ToString().Length;

            Console.WriteLine( digit );
        }

        return 0;
    }
}

Measured memory_bytes: 5884