akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS

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

#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <tchar.h>
//#include <intrin.h>

#define F first
#define S second
#define LL long long
#define MOD 1000000007
#define INF 2000000000
#define LINF 1000000000000000000

using namespace std;

const int N = 1e2 + 10;

int n, m, k;
LL ans;
char c[N][N];
vector<int>vec[2];

void check() {

	int sum = 0;
	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++) {

			bool q = 0;
			for (auto x : vec[0])
				q |= x == i;
			for (auto x : vec[1])
				q |= x == j;

			if (q)continue;
			sum += c[i][j] == '#';
		}

	if (sum == k)
		ans++;
}

void bt(int i,int k) {

	if (i == n + 1 && !k) {
		bt(1, 1);
		return;
	}
	
	if (i == m + 1 && k) {
		check();
		return;
	}

	vec[k].push_back(i);
	bt(i + 1, k);
	vec[k].pop_back();
	bt(i + 1, k);
}

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

	for (int i = 1;i <= n;i++)
		for (int j = 1;j <= m;j++)
			cin >> c[i][j];

	bt(1, 0);

	cout << ans << endl;
	cin >> n;
}

Measured memory_bytes: 3140
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;
using P = pair<int, int>;

int Rs = 100000;
VI C(Rs+1, 0);

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

    int del=0;

    rep(i,n){
        int a;
        cin >> a;
        if(a > Rs){
            del++;
            continue;
        }else{
            C[a]++;
        }
    }

    rep(i,Rs+1){
        if(C[i] >= i){
            del += C[i] - i;
        }else{
            del += C[i];
        }
    }

    cout << del << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(){
  int x1,x2,x3,x4,x5;
  scanf("%d %d %d %d %d",&x1, &x2, &x3, &x4, &x5);
  if(x1 == 0){
    printf("1");
  }
  else if(x2 == 0){
    printf("2");
  }
  else if(x3 == 0){
    printf("3");
  }
  else if(x4 == 0){
    printf("4");
  }
  else{
    printf("5");
  }
}

Measured memory_bytes: 1592
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SHIFT_LEFT(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi yaku;
  for(ll i=1;i<=sqrt(n);i++){
    if(n%i == 0){
      if(i == n/i){
	yaku.pb(i);
      }else{
	yaku.pb(i);
	yaku.pb(n/i);
      }
    }
  }
  ll ans = 0;
  for(auto a:yaku){
    if(a == 1)continue;
    ll num = n;
    while(num >= a && num%a == 0){
      num /= a;
      //cout<<num<<" "<<a<<endl;
    }
    if(num % a == 1){
      ans++;
    }
  }
  vi yaku2;
  for(ll i=1;i<=sqrt(n-1);i++){
    if((n-1)%i == 0){
      if(i == (n-1)/i){
	yaku2.pb(i);
      }else{
	yaku2.pb(i);
	yaku2.pb((n-1)/i);
      }
    }
  }
  /*  ll ans2= 0 ;
  for(int i=2;i<=n;i++){
    ll num = n;
    while(num >= i && num%i == 0){
      num /= i;
      //cout<<num<<" "<<a<<endl;
    }
    if(num % i == 1)ans2++;
    }*/
  cout<<ans+yaku2.size()-1<<endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;
public class Main {
static private Scanner s = new Scanner(System.in);
public static void main(String[] args) {
	int n = s.nextInt();
	String w,d;
	Set<String> hash = new HashSet<String>();
	StringBuilder sb = new StringBuilder();

	for(int i = 0;i < n;i++) {
		w = s.next();
		d = s.next();
		if(w.equals("insert")) {
			hash.add(d);
		}else {
			if(hash.contains(d)) {
			sb.append("yes\n");
			}else {
			sb.append("no\n");
			}
		}
	}
	System.out.print(sb.toString());
}
}


Measured memory_bytes: 230468
import sys
#sys.stdin=open("data.txt")
input=sys.stdin.readline

n,m=map(int,input().split())

if n==m: cnt=2
elif abs(n-m)==1: cnt=1
else: cnt=0

# permute now
for i in range(1,n+1): cnt=(cnt*i)%(1000000007)
for i in range(1,m+1): cnt=(cnt*i)%(1000000007)

print(cnt)

Measured memory_bytes: 39408
#include <stdio.h>

int main(){
  int n = 0;
  scanf("%d\n",&n);
  int a[n];
  int i = 0;
  for(i = 0;i < n;i++){
    scanf("%d",&a[i]);
  }
  int ans = 0;
  for(i = 0;i < n;i++){
    ans = ans + a[i] - 1;
  }
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 256
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)
const ll mod = 1000000007LL;


int main() {
	ll a, b, c, d;

	cin >> a >> b >> c >> d;
	ll ans0 = max(a * c, a * d);
	ll ans1 = max(b * c, b * d);
	ll ans = max(ans0, ans1);

	if ((a <= 0 && b>= 0) || (c <= 0 && d >=0)) {
		ans = max(ans, 0LL);
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 3196
def get(text,n):
    ans = [""]*n
    i = 0
    for x in text:
        if x==" ":
            i = i + 1
        ans[i] = ans[i]+x
    return ans

text = input()
H = int(get(text,2)[0])
A = int(get(text,2)[1])

if H%A !=0:
    print(H//A+1)
else:
    print(H//A)

Measured memory_bytes: 3060
#include <math.h>

#include <algorithm>
#include <iostream>
#include <vector>

using ll = long long;
#define rep(inc, bgn, end) for (int inc = bgn; inc < end; ++inc)
#define repe(inc, bgn, end) for (int inc = bgn; inc <= end; ++inc)

using namespace std;

struct work {
    int time;
    int limit;

    bool operator<(const work &right) const {
        return this->limit == right.limit ? this->time < right.time : this->limit < right.limit;
    }
};

int main() {
    int n;
    cin >> n;
    vector<work> workList(n);
    rep(i, 0, n) {
        cin >> workList[i].time >> workList[i].limit;
    }
    sort(workList.begin(), workList.end());

    int workIdx  = 0;
    work crrWork = workList[workIdx];
    int restWork = crrWork.time;

    int passTime = 0;
    bool isEnd   = false;
    bool isOver  = false;
    while (true) {
        passTime++;
        restWork--;
        // printf("%d %d %d\n", workIdx, passTime, restWork);
        // 仕事が終わる
        if (restWork <= 0) {
            // 時間内
            if (passTime <= crrWork.limit) {
                workIdx++;
                if (workIdx > n - 1) {
                    break;
                }
                crrWork  = workList[workIdx];
                restWork = crrWork.time;
            }
            // 時間外
            else {
                isOver = true;
            }
        }

        // ---
        if (isOver) {
            break;
        }

        if (isEnd) {
            break;
        }
    }

    if (isOver) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }

    return 0;
}


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

using namespace std;

struct Prog {
	int s, t, c;
};

int main() {
	int N, C;

	cin >> N >> C;

	vector<Prog> P(N);
	vector<pair<int, int>> recorder(C, make_pair(-1, 0));
	for (int i = 0; i < N; i++)
	{
		int tmp;
		cin >> P[i].s >> P[i].t >> P[i].c;

		P[i].c--;
	}

	sort(P.begin(), P.end(),
		[](const Prog a, const Prog b)
	{
		if (a.s == b.s) {
			return a.t < b.t;
		}
		return a.s < b.s;
	});

	int ans = 0;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < C; j++) {
			if (recorder[j].first == P[i].c) {
				recorder[j].second = P[i].t;
				break;
			}
			else if (recorder[j].second < P[i].s)
			{
				if (recorder[j].second == 0) ans++;
				recorder[j].first = P[i].c;
				recorder[j].second = P[i].t;
				break;
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int N, X;
  cin >> N >> X;
  vector<int> L(N);
  rep(i,N) cin >> L[i];
  int d = 0, t = 1;
  rep(i,N) {
    d += L[i];
    if (d > X) break;
    else ++t;
  }
  cout << t << endl;
  return 0;
}

Measured memory_bytes: 3124
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  bool ans = true, dep = false;
  cin >> s;
  if(s[0] != 'A') ans = false;
  for(int i=1;i<s.size();i++){
    if(s[i] == 'C'){
      if(i == 1 || i == s.size()-1) ans = false;
      if(dep) ans = false;
      else dep = true;
    }
    else if(s[i] >= 'A' && 'Z' >= s[i]) ans = false;
  }
  cout << ((ans && dep)?"AC":"WA") << endl;
}

Measured memory_bytes: 256
var toInt = x=>parseInt(x,10);
var toIntArr = arr=>arr.map(x=>toInt(x));
var abs = x=>x>0?x:-x;
function min(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]<v)v=rest[i];return v}
function max(){var rest=arguments,v=rest[0];for(var i=1;i<rest.length;i++)if(rest[i]>v)v=rest[i];return v}
function gcd(){var rest=arguments,v=rest[0],temp=(a,b)=>b?temp(b,a%b):a;for(var i=1;i<rest.length;i++)v=temp(v,rest[i]);return v}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
 
function Main(input){
	var input = input.split('\n').map((el,ind,arr)=>toIntArr(el.split(' ')));
	var n = input[0][0];
	var as = input[1];
	var ans = as[0];
	for(var i = 1; i < n; i++){
		ans = gcd(ans,as[i]);
	}
	console.log(ans);
	return 0;
}



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


int main(){
	int a;
	int b;
	int c;
	cin >> a;
	cin >> b;
	cin >> c;
	if (a == 5 && b == 7 && c == 5) {
		cout << "YES" << endl;
	}else if (a == 5 && b == 5 && c == 7) {
		cout << "YES" << endl;
	}else if (a == 7 && b == 5 && c == 5) {
		cout << "YES" << endl;
	}else {
		cout << "NO" << endl;
	}
}

Measured memory_bytes: 256
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

int ac, wa, tle, re;
signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
            int n;
            cin >> n;

            while(n--) {
                string s;
                cin >> s;
                if(s == "AC")
                    ac++;
                else if(s == "WA")
                    wa++;
                else if(s == "TLE")
                    tle++;
                else
                    re++;
            }

            cout << "AC x " << ac << "\nWA x " << wa << "\nTLE x " << tle << "\nRE x " << re << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3620
h, w = [ int(v) for v in input().split() ]
field = []
search_list = []
adjust_list = ((0,1),(0,-1),(1,0),(-1,0))

for i in range(h):
    line = list(input())
    field.append(line)
    for j, v in enumerate(line):
        if v == "#":
            search_list.append((i,j))

t = 0
while search_list:
    new_search_list = []
    for i in search_list:
        for j in adjust_list:
            if 0 <= i[0]+j[0] < h and 0 <= i[1]+j[1] < w:
                if field[i[0]+j[0]][i[1]+j[1]] == ".":
                    field[i[0]+j[0]][i[1]+j[1]] = "#"
                    new_search_list.append((i[0]+j[0], i[1]+j[1]))
    search_list = new_search_list
    if search_list:
        t += 1

print(t)


Measured memory_bytes: 132708
#include <bits/stdc++.h>
using namespace std;
long long dp[100010];

int main()
{
	int N,K;
	int h[100015];

	cin>>N;

	for(int i=0;i<N;i++) cin>>h[i];

	for (int i = 0; i < 100010; ++i) dp[i] = INT_MAX;	
  
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);
	for (int i = 2; i < N; ++i) {
		dp[i]=min(dp[i],dp[i - 1] + abs(h[i] - h[i - 1]));
		dp[i]=min(dp[i],dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N-1] << endl;
}

Measured memory_bytes: 4756
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));
		String str = br.readLine();
		while (!str.equals("0 0")) {
			String[] nm = str.split(" ");
			int n = Integer.parseInt(nm[0]);
			int m = Integer.parseInt(nm[1]);
			int[] score = new int[m];
			int[] name = new int[m];
			for (int i = 0; i < n; i++) {
				str = br.readLine();
				String[] answer = str.split(" ");
				for (int j = 0; j < m; j++) {
					score[j] = score[j] + Integer.parseInt(answer[j]);
					name[j] = j + 1;
				}
			}
			name = Sort(score, name);
			for (int i=0;i<m;i++) {
				System.out.print(name[i]);
				if(i!=m-1)
					System.out.print(" ");
			}
			System.out.println();
			str = br.readLine();
		}
	}

	private static int[] Sort(int[] num, int[] name) {
		int length = num.length;
		for (int i = 1; i < length - 1; i++) {
			for (int j = 0; j < length - i; j++) {
				if (num[j] < num[j + 1]) {
					int tmpnum = num[j];
					int tmpname = name[j];
					num[j] = num[j + 1];
					name[j] = name[j + 1];
					num[j + 1] = tmpnum;
					name[j + 1] = tmpname;
				}
			}
		}
		return name;
	}
}

Measured memory_bytes: 42636
#include <cstdio>
#include <vector>

typedef std::vector<int> Memo;

int fib(int n, Memo& memo) {
    if(n == 0 || n == 1) return 1;
    if(memo[n] != -1) return memo[n];
    return memo[n] = fib(n-1, memo) + fib(n-2, memo);
}

int main() {
    int n = 0;
    Memo memo = Memo(50, -1);
    
    std::scanf("%d", &n);
    std::printf("%d\n", fib(n, memo));
}


Measured memory_bytes: 2744
Imports System.Collections.Generic
Imports System.Console

Module Program
    Sub Main()
        Dim S As String = NextString()
        Dim T As String = NextString()
        T = T & T

        WriteLine(New String() {"No", "Yes"}(B2I(T.Contains(S))))
    End Sub

    Function B2I(ok As Boolean) As Integer
        If ok Then Return 1
        Return 0
    End Function

    Function NextString() As String
        Dim result As New List(Of Char)
        Do
            Dim tmp As Integer = Read()
            If tmp < 0 Then Exit Do
            Dim nextChar As Char = Chr(tmp)

            If Not Char.IsWhiteSpace(nextChar) Then
                result.Add(nextChar)
            ElseIf nextChar <> vbCr Then
                Exit Do
            End If
        Loop
        Return New String(result.ToArray())
    End Function

End Module


Measured memory_bytes: 21968
i,j,o;main(r,n,s){
	for(;scanf("%d%d",&n,&s),n+s;){
		for(r=i=0;i<1024;i++){
			if(__builtin_popcount(i)==n){
			for(j=o=0;j<10;j++){
				o+=(1<<j)&i?j:0;
			}
			if(o==s)r++;
			}
		}
		printf("%d\n",r);
	}
}

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

using namespace std;
using ll = long long;

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

	bool a = (N / 100 > 0) && (N / 100 < 13);
	bool b = (N % 100 > 0) && (N % 100 < 13);

	if (a && b) { cout << "AMBIGUOUS" << endl; }
	else if (!a && b) { cout << "YYMM" << endl; }
	else if (a && !b) { cout << "MMYY" << endl; }
	else { cout << "NA" << endl; }

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <random>
#include <vector>
#include <array>
#include <bitset>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }
int bsr(int x) { return 31 - __builtin_clz(x); }

int main() {
    ios::sync_with_stdio(0);
    cout << setprecision(20);
    int n, m;
    cin >> n >> m;
    int co[n];
    bool rd[n];
    fill_n(co, n, 1);
    fill_n(rd, n, false);
    rd[0] = true;
    for (int i = 0; i < m; i++) {
        int x, y;
        cin >> x >> y; x--; y--;
        co[x]--; co[y]++;
        rd[y] |= rd[x];
        if (!co[x]) rd[x] = false;
    }

    int ans = 0;
    for (int i = 0; i < n; i++) {
        if (rd[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
N = int(input())
A = list(map(int,input().split()))
A.insert(0,0)
A = [(i,A[i]) for i in range(N+1)]
A = sorted(A,key=lambda x:x[1])
B = []
for i in range(1,N+1):
    B.append(A[i][0])
print(*B)

Measured memory_bytes: 97300
while True:
    amount, count = map(int, input().split())
    if amount == 0 and count == 0:
        break

    cards = [i for i in reversed(range(1, amount + 1))]

    for _ in range(count):
        p_th, length = map(int, input().split())
        swapper = cards[p_th - 1:p_th + length - 1]
        cards[p_th - 1:p_th + length - 1] = []
        cards[0:0] = swapper

    print(cards[0])

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

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

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

    ll N; cin >> N;
    vector<ll> X(N);
    for (int i = 0;i < N;i++){
        cin >> X[i];
    }

    ll ans = LLONG_MAX;
    for (int i = 0;i <= 100;i++){
        ll sum = 0;
        for (int j = 0;j < N;j++){
            sum += (i-X[j])*(i-X[j]);
        }
        ans = min(ans,sum);
    }

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
from scipy.sparse.csgraph import floyd_warshall as wf

H,W = map(int,input().split())
C = [[int(i) for i in input().split()] for i in range(10)]
A = [[int(i) for i in input().split()] for i in range(H)]
B = wf(C)
ans = 0

for i in range(H):
    for j in range(W):
        if A[i][j] == -1:
            continue
        ans += B[A[i][j]][1]

print(int(ans))


Measured memory_bytes: 18632
#include <stdio.h> 

int main(void)
{	
	int a,b,d,r;
	double f,x,y;

	scanf("%d %d", &a, &b);

	d = a / b;

	r = a % b;
	
	x = a;
	y = b;

	f = x / y;

	printf("%d %d %f\n", d, r, f);

	return 0;
}

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

#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define ALL(obj) (obj).begin(),(obj).end()
#define space <<" "<<
#define maxs(x,y) (x=max(x,y))
#define mins(x,y) (x=min(x,y))
#define FIX <<fixed<<setprecision(10)<<
using namespace std;

using ll = long long; using ull = unsigned long long;
using vb = vector<bool>; using vvb = vector<vb>;
using vi = vector<int>; using vvi = vector<vi>;
using vl = vector<ll>; using vvl = vector<vl>;
using pii = pair<int,int>; using pll = pair<ll,ll>;

const ll MOD = 1e9+7;

int main(){
int x,y,z;
cin>>x>>y;
while(y!=0){
z=x;
x=y;
y=z%y;
}
cout<<x<<endl;
}


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

int main(){
	long long int n;
	cin>>n;
	vector<long long int> a(n);
	vector<long long int> b(n);
	
	long long int sum=0;
	long long int fl=0;
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
		sum+=a[i];
		if(a[i]!=b[i])fl=1;
	}
	if(fl==0){
		cout<<0<<endl;
		return 0;
	}
	
	long long int ans=0;
	
	for(int i=0;i<n;i++){
		if(a[i]>b[i])ans=max(ans,sum-b[i]);
	}
	
	cout<<ans<<endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <random>
#include <chrono>
#include <string>
#include <bitset>
#include <cassert>
#include <queue>
#include <memory>

//#pragma comment(linker, "/STACK:16777216")
//#pragma GCC optimize("O3")
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC optimize("unswitch-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,abm,mmx,avx,avx2,popcnt,tune=native")

using namespace std;

//mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

#define ll long long
#define ull unsigned long long
//#define double long double
#define int ll
//#define int ull
//#define int short
//#define int unsigned short
//#define int unsigned int
#define mp make_pair
#define F first
#define S second
#define pii pair<int, int>
#define hash hash228
const int SZ = 11 + 4;
const double EPS = 1e-7;
const int mod = 998244353;
const int hashpow = 127;
const int inf = 2e9;

int k;

void read() {
    cin >> k;
}

int dp[SZ][10];
int cnt[SZ];

void solve() {
    int n = 11;
    for (int j = 0; j < 10; ++j) {
        dp[1][j] = 1;
    }
    for (int i = 2; i <= n; ++i) {
        for (int j = 1; j < 10; ++j) {
            cnt[i] += dp[i - 1][j];
        }
        cnt[i] += cnt[i - 1];
        for (int j = 0; j < 10; ++j) {
            for (int k = max(0ll, j - 1); k <= min(9ll, j + 1); ++k) {
                dp[i][j] += dp[i - 1][k];
            }
        }
    }

//    ++k;
    vector<int> ans;
    for (int i = n; i > 0; --i) {
        if (ans.empty() && cnt[i] >= k) {
            continue;
        } else {
            if (ans.empty()) {
                k -= cnt[i];
                for (int j = 1; j < 10; ++j) {
                    if (dp[i][j] >= k) {
                        ans.push_back(j);
                        break;
                    } else {
                        k -= dp[i][j];
                    }
                }
                continue;
            }
        }
        for (int j = max(0ll, ans.back() - 1); j <= min(9ll, ans.back() + 1); ++j) {
            if (dp[i][j] >= k) {
                ans.push_back(j);
                break;
            } else {
                k -= dp[i][j];
            }
        }
    }
    reverse(ans.begin(), ans.end());
    while (ans.back() == 0) {
        ans.pop_back();
    }
    reverse(ans.begin(), ans.end());
    for (int u : ans) {
        cout << u;
    }
}

signed main() {

#ifdef __LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#else
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

//    int t;
//    cin >> t;
//    for (int i = 0; i < t; ++i) {
        read();
        solve();
//    }

    return 0;
}

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

using namespace std;
typedef long long ll;
#define pb push_back

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

int f[N][N];
int n; 
string s; 

int pre[N], suf[N];

int main() {
    cin >> n;
    cin >> s;
    s += '<';

    f[0][1] = 1;
    pre[1] = 1;
    suf[1] = 1;

    for(int i = 1; i <= n; ++i) {
        for(int j = 1; j <= i+1; ++j) {
            int men = i < n and s[n - i - 1] == '>';
            if(men) {
                f[i][j] = pre[j-1];
            } else {
                f[i][j] = j <= i? suf[j] : 0;
            }
        }

        memset(pre, 0, sizeof pre);
        memset(suf, 0, sizeof suf);

        pre[1] = f[i][1];
        for(int j = 2; j <= i+1; ++j) {
            pre[j] = (pre[j-1] + f[i][j])%M;
        }

        suf[i+1] = f[i][i+1];
        for(int j = i; j >= 1; --j) {
            suf[j] = (suf[j+1] + f[i][j])%M;
        }
    }

    cout << f[n][1] << endl;
}

Measured memory_bytes: 34304
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#include<queue>
#include <sstream>
#include <set>

const long long INF = 1000000007;
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//Insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//c_str()変換
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());
//map<type, type> dict;で宣言
//グラフ理論用変数
//vector<vector<llong> > graph(N);

//ソート
//降順sort(v.begin(), v.end(), std::greater<Type>());

//大文字から小文字へんかん
//w[i] = w[i]-'A'+'a';

//vector
//assignメソッド　引数：サイズ、値
//与えられたサイズと値でvectorを初期化する

//queueクラス
//find()次に取り出す値の表示をする。
//pop()値を取り出す。戻り値はなし
//push()キューに値をプッシュする

//priority_queueクラス

//切り上げ
//ceil
//floor

int main(){
    llong A,B;
    cin >> A >> B;
    if((A>=1 && A<=9) && (B>=1 && B<=9)){
        cout << A*B << endl;
        exit(0);
    }
    cout << -1 << endl;
    return 0;
}



Measured memory_bytes: 3124
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });

			int n = int.Parse(Console.ReadLine());
			int[] l = Console.ReadLine().Split().Select(int.Parse).OrderBy(p => p).ToArray();
			long ans = 0;
			for (int i = 0; i < n - 2; i++) {
				for (int j = i + 1; j < n - 1; j++) {
					if (l[j + 1] < l[i] + l[j]) {
						int index = Array.BinarySearch(l, j + 1, n - (j + 1), l[i] + l[j]);
						if (index > 0) {
							while (l[index - 1] == l[index]) {
								index--;
							}
						} else {
							index = ~index;
						}
						ans += index - (j + 1);
					}
					//int cnt = 0;
					//for (int k = j + 1; k < n; k++) {
					//	if (l[k] < l[i] + l[j]) {
					//		cnt++;
					//	} else {
					//		break;
					//	}
					//}
					//System.Diagnostics.Debug.WriteLine($"{i} {j} {cnt}");
					//ans += cnt;
				}
			}
			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}
}


Measured memory_bytes: 13396
#include <iostream>
using namespace std;
int main(void){
    int N;
    float ans;
    cin >> N;
    if(N % 2 == 0){
        ans = (N / 2) / float(N);
    }else{
        ans = (N / 2 + 1) / float(N);
    }
    printf("%.10f\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n;
  cin >> n;
  ll a = 0, b = 0, c = 0;
  ll res = 0;
  rep(i, n) {
    string s;
    cin >> s;
    rep(j, s.size()-1) {
      if (s.at(j)=='A' && s.at(j+1)=='B') res++;
    }
    if (s.at(0)=='B' && s.at(s.size()-1)=='A') {
      a++;
    } else if (s.at(0) == 'B') {
      b++;
    } else if (s.at(s.size()-1) == 'A') {
      c++;
    }
  }
  if (a) {
    res += a-1;
    if (b) {
      res++;
      b--;
    }
    if (c) {
      res++;
      c--;
    }
    res += min(b, c);
  } else {
    res += min(b, c);
  }
  cout << res << endl;
}

Measured memory_bytes: 256
import java.util.Random;
import java.util.Scanner;

public class Main{
    public static void main(final String[] args){
        Scanner scanner = new Scanner(System.in);
        while(true){
            int n = scanner.nextInt();
            if(n == 0){
                break;
            }
            int[] s = new int[n] ;
            for (int i = 0; i < n; i++){
                s[i] = scanner.nextInt();
            }
            int sum = 0;
            for(int i = 0; i < n; i++){
                sum += s[i];
            }
            double ave = (double)sum / (double)n;
            double sum2 = 0;
            for(int i = 0; i < n; i++){
                sum2 += Math.pow((double)s[i], 2);
            }
            double ave2 = sum2/(double)n;
            double v = ave2 - Math.pow(ave, 2);
            System.out.println(Math.sqrt(v));
        }
        scanner.close();
    }
     
    

}


Measured memory_bytes: 31412
#include <bits/stdc++.h>
using namespace std;
const long long MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
  int A, B, C;
  cin >> A >> B >> C;
  if ((A == B && B != C) or (A == C && B != C) or (A != B && B == C))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


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

int main() {
    const int INF = 1001001001;
    int n, m;
    cin >> n >> m;
    vector<vector<int>> to(n);//部屋iがどの部屋につながっているか
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        to.at(a).push_back(b);
        to.at(b).push_back(a);
    }
    int v = 0;
    vector<int> dist(n,INF);
    dist.at(0) = 0;
    vector<int> pre(n);
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int i = q.front(); q.pop();
        for(int j: to.at(i)) {
            if(dist.at(j) != INF) continue;
            dist.at(j) = dist.at(i) + 1;
            pre.at(j) = i;
            q.push(j);
        }
    }

    cout << "Yes" << endl;
    rep(i,n) {
        if(i == 0) continue;
        cout << pre.at(i) + 1 << endl;
    }
}

Measured memory_bytes: 10696
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int N;
	string S, T;
	cin >> N >> S >> T;
	vector<string> vec(2 * N);
	for (int i = 0; i < 2 * N; i++) {
		if (i % 2 == 0) {
			vec.at(i) = S.at(i / 2);
		}
		else {
			vec.at(i) = T.at(i / 2);
		}
	}
	for (int j = 0; j < 2 * N; j++) {
		cout << vec.at(j);
	}
}

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

using namespace std;


//repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define euc_dis(x, y) sqrt(x*x + y*y)

#define pb push_back
#define mp make_pair
#define INF 999999999
#define MOD 1000000007
#define sp ' '
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

//typedef
typedef long long ll;
typedef pair<int, int> pint;
typedef map<int, int> mint;
typedef vector<int> vint;
typedef vector<char> vch;
typedef vector<long long> vll;
typedef vector<string> vstr;


int mod(int a, int b){return (a%b+b)%b;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powMod(ll a, ll b){ll ans=1; rep(i, b){ans=ans*a%MOD;} return ans;}

template<typename T>
void ppp(T n){cout << n << endl;}
template<typename T>
void dpp(T n){cerr << n << endl;}

const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int ddx[8] = {1,0,-1,0,1,-1,-1,1};
const int ddy[8] = {0,1,0,-1,1,1,-1,-1};




template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}


vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.pb(buffer);
    }
    return v;
}




int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    ll k;
    cin >> s >> k;
    ll five = 5000000000000000;
    vll length(s.size());

    ll one_cnt=0;
    rep(i, s.size()){
      if(s[i]=='1')
        one_cnt++;
      else
        break;
    }

    if(s[0] == '1' and k <= one_cnt){
      ppp(1);
    }
    else if(s[0] == '1' and k > one_cnt){
      ppp(s[one_cnt]);
    }
    else if(s[0] != '1'){
      ppp(s[0]);
    }

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ios std::ios::sync_with_stdio(false)
#define maxn 100005
#define int long long
using namespace std;
int n;
int x, k, d;
int a[105];
int ans;
signed main()
{
	ios;
	cin >> x >> k >> d;
	x = abs(x);
	if (x / d > k) {
		cout << abs(x - d * k) << "\n";
	}
	else {
		k = k - x / d;
		if (k & 1) {
			cout << d - x % d << "\n";
		}
		else {
			cout << x % d << "\n";
		}
	}
}
	/*if (K * D <= X)
		ans = X - K * D;
	else
	{
		K -= X / D;
		int A = X % D;

		if (K % 2 == 0)
			ans = A;
		else
			ans = D - A;
	}
	cout << ans<<endl;*/
//}
/*#include <iostream>
#include <vector>
#include <map> 
#include <algorithm>
#include <cstring>
 
#define ll long long
using namespace std; 
 
void solve(){
  ll x,k,d; 
  cin >>x>> k>> d; 
  x = abs(x);
  d = abs(d);  
  
 
}
 
int main(){
  int t=1; 
  // cin>>t; 
  while(t--){
    solve(); 
  }
 return 0;
}*/

Measured memory_bytes: 3556
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <algorithm>
using namespace std;

int main() {
  int n, W, L, E;
  bool flag = false;
  string T;
  // vector<int> vc;
  //map<int,vector<string> > res;  
  
  while(cin >> n, n) {
    vector<int> vc;
    map<int,vector<string> > res;
    if(flag) cout << endl;
    else flag = true;
    
    for(int i = 0 ; i < n ; i++) {
      cin >> T >> W >> L >> E;
      int P = -(W*3 + E);
      if(count(vc.begin(), vc.end(), P) == 0) {
	vc.push_back(P);
      }
      res[P].push_back(T);
    }
    sort(vc.begin() , vc.end());
    for(int i = 0 ; i < vc.size() ; i++)
      for(int j = 0 ; j < res[vc[i]].size() ; j++)
	cout << res[vc[i]][j] << ',' << -vc[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;





int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin >> n;
    cout << n * (n - 1) / 2;



}


Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <tuple>
#include <set>
#include <map>

#define FOR0(var, max) for (ul (var) = 0; (var) < (max); ++(var))
#define FORi(var, min, max) for (ul (var) = (min); (var) < (max); ++(var))
#define FORi_INV(var, min, max) for (ul (var) = (max) - 1; (var) + 1 > (min); --(var))
#define FORITER(var, iter) for (auto (iter) = (var).begin(); (iter) != (var).end(); (iter)++)
#define FORITER_INV(var, iter) for (auto (iter) = (var).rbegin(); (iter) != (var).rend(); (iter)++)

#define LTLT(a, b, c) (((a) < (b)) && ((b) < (c)))
#define LELT(a, b, c) (((a) <= (b)) && ((b) < (c)))
#define LTLE(a, b, c) (((a) < (b)) && ((b) <= (c)))
#define LELE(a, b, c) (((a) <= (b)) && ((b) <= (c)))

using namespace std;

using uc = unsigned char;
using ui = unsigned int;
using ul = unsigned long long int;

using sc = signed char;
using si = signed int;
using sl = signed long long int;

int main(void) {
  ui N;
  ui JPY = 0;
  double BTC = 0;
  double res = 0;
  char c;
  ui x;
  double y;

  cin >> N;
  string s1, s2;
  FOR0(i, N) {
    cin >> s1 >> s2;
    if (s2 == "JPY") {
      JPY += stoi(s1);
    } else {
      BTC += stod(s1);
    }
  }

  cout << setprecision(30) << (JPY + (BTC * 380000)) << endl;
  return 0;
}

Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))

ans = 0

for i in range(N):
    if P[i] != i+1:
        continue
    if i+1 < N and P[i] != i+2 or i == 0:
        P[i], P[i+1] = P[i+1], P[i]
        ans += 1
    else:
        P[i], P[i-1] = P[i-1], P[i]
        ans += 1

print(ans)


Measured memory_bytes: 52460
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
using ll = long long;


int main() {
	string s; cin >> s;
	string a = s.substr(0, 2), b = s.substr(2);
	bool f[2] = {};
	for (int i = 0; i < 2; i++) {
		if ("01" <= a && a <= "12") f[i] = true;
		swap(a, b);
	}
	if (f[0] && f[1]) cout << "AMBIGUOUS" << endl;
	else if (f[0]) cout << "MMYY" << endl;
	else if (f[1]) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
} 

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main(){
  char s[100002];
  int c,i;
  while(1){
    c=0;
    fgets(s,100000,stdin);
    if(strcmp(s,"END OF INPUT\n")==0)break;
    for(i=0;s[i]-10;i++){
      if(s[i]==' '){
	printf("%d",c);
	c=0;
      }
      else c++;
    }
    printf("%d\n",c);
  }
  return 0;
}

Measured memory_bytes: 524
#include<stdio.h>

int main() {
	int N, X,i,min=0,goukei=0,count=0;
	int m[100];
	scanf("%d%d", &N, &X);
	for (i = 0; i < N; i++)
	{
		scanf("%d", &m[i]);
		goukei += m[i];
		if (i == 0)min = m[i];
		if (m[i] < min)min = m[i];
	}
	X = X - goukei;
	printf("%d\n", X / min + N);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin>>N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  vector<int> B(N);
  for (int i = 0; i < N; i++) {
    B.at(i)= A.at(i);
  }
  sort(B.begin(), B.end());
  reverse(B.begin(), B.end());
  
 
  for (int i = 0; i < N; i++) {
    if(A.at(i)==B.at(0)){
      cout<<B.at(1)<<endl;
    }
    else{
      cout<<B.at(0)<<endl;
    }
  }
 
  
}

Measured memory_bytes: 3200
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
long long dp[5100];
int p[5100];
int bit[5100];
int sum(int a,int b){
	if(a)return sum(0,b)-sum(0,a-1);
	int ret=0;for(;b>=0;b=(b&(b+1))-1)ret+=bit[b];return ret;
}
void add(int a,int b){
	for(;a<5100;a|=a+1)bit[a]+=b;
}
int main(){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	for(int i=0;i<a;i++){
		scanf("%d",p+i);p[i]--;
	}
	for(int i=0;i<=a;i++)
		dp[i]=inf;
	dp[0]=0;
	long long ret=inf;
	for(int i=0;i<=a;i++){
		if(i>0){
			long long tmp=dp[i];
			for(int j=i;j<a;j++){
				if(p[j]<p[i-1])tmp+=c;
				else tmp+=b;
			}
			ret=min(ret,tmp);
		}
		long long ad=0;
		for(int j=0;j<5100;j++)bit[j]=0;
		int C=0;
		int D=0;
		for(int j=i;j<a;j++){
			if(i==0||p[i-1]<p[j]){
				int T=sum(0,p[j]);
				long long ad=(long long)C*c+(long long)T*min(b,c)+(long long)(D-T)*b;
				dp[j+1]=min(dp[j+1],dp[i]+ad);
			}
			if(i&&p[i-1]>p[j])C++;
			else{
				D++;
				add(p[j],1);
			}
		}
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 256
n=int(input())
s=input()
r=[]
g=[]
b=[]
res=0
for i in range(n):
  if s[i]=="R":
    r.append(i)
  elif s[i]=="G":
    g.append(i)
  elif s[i]=="B":
    b.append(i)

res=len(g)*len(b)*len(r)
r=set(r)
g=set(g)
b=set(b)
for i in r:
  for j in g:
    if (i+j)%2==0 and int((i+j)/2) in b:
      res-=1
    if abs(i-j)+max(i,j) in b:
      res-=1
    if min(i,j)-abs(i-j) in b:
      res-=1
print(res)

Measured memory_bytes: 9504
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#define _USE_MATH_DEFINES
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <algorithm>
#include <string>

using namespace std;

int main()
{
	int sx, sy, tx, ty;
	scanf("%d %d %d %d", &sx,&sy,&tx,&ty);
	getchar();
	int h = ty - sy, w = tx - sx;

	string ans;
	ans += "L";
	ans += string(h, 'U');
	ans += "UR";
	ans += string(w, 'R');
	ans += "D";
	ans += string(w, 'L');
	ans += string(h, 'D');
	ans += string(w, 'R');
	ans += string(h, 'U');
	ans += "R";
	ans += string(h, 'D');
	ans += "DL";
	ans += string(w, 'L');
	ans += "U";

	printf("%s\n", ans.c_str());
#ifdef _DEBUG
	printf("Press enter to exit\n");
	getchar();
#endif
	return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.HashSet;

public class Main {
    public static void main(String[] args) throws IOException {
//    	long l = System.currentTimeMillis();
        new Main().exec();
//    	long l2 = System.currentTimeMillis();
//    	System.out.println(l2 - l);
    }
    
    public void exec() throws IOException {
        InputUtil in = new InputUtil();
        PrintWriter out = new PrintWriter(System.out);
        int n = in.nextInt();
        int[] A = in.nextInt(new int[n]);
        int maxMask = (int)Math.pow(2,n);
        HashSet<Integer> okNumber = new HashSet<>();
        int mask=1;
        LOOP1:
        for(int m : in.nextInt(new int[in.nextInt()])) {
        	if(okNumber.contains(m)){
        		out.println("yes");
        		continue;
        	}
        	for(; mask<maxMask; mask++) {
        		int sum=0;
        		for(int i=0; i<n; i++) {
        			if(((1<<i)&mask) != 0){
        				sum += A[i];
        			}
        		}
        		okNumber.add(sum);
        		if(m == sum){
            		out.println("yes");
            		continue LOOP1;
        		}
        	}
        	out.println("no");
        }
        out.flush();
    }
    
}

class InputUtil {
	//Static Fields
	private static final int BUFSIZ = 50000;
	
	//Fields
	protected InputStream in;
	private char[] buf = null;
	private int ptr = 0;
	private int max = -1;
	private BufferedReader br = null;
	
	//Constructors
	public InputUtil() {this(System.in,BUFSIZ);}
	public InputUtil(InputStream in, int bufsiz) {
		initBuf(bufsiz);
		initIn(in);
	}
	
	//Methods
	//Initializer
	protected void initIn(InputStream in) {br = new BufferedReader(new InputStreamReader(this.in = in));}
	protected void initBuf(int bufsiz) {buf = new char[bufsiz];}
	
	//buffer operation
	private void next() throws IOException {ptr++; readBuf();}
	private void readBuf() throws IOException {
		if(ptr >= max && br.ready()) {
			max = br.read(buf);
			ptr = 0;
		}
	}
	//Number Input Reader/Parser
	private boolean isNum(char b) {return '0' <= b && b <= '9'; }
	private boolean isMinus(char b) {return b=='-'; }

	private int _nextInt() throws IOException {
		int sign = 1;
		int res = 0;
		char c;
		while (!isNum(c=buf[ptr]) && !isMinus(c)) 
			next();
		if (isMinus(buf[ptr])) {
			sign = -1;
			next();
		}
		while (isNum(c=buf[ptr])) {
			res *= 10;
			res += c - '0' ;
			next();
		}
		next();
		return sign * res;
	}
	
	public int nextInt() throws IOException {
		readBuf();
		return _nextInt();
	}

	public int[] nextInt(int[] result) throws IOException {
		readBuf();
		for(int i=0; i<result.length; i++) {
			result[i] = _nextInt();
		}
		return result;
	}
	
	//Close 
	public void close() throws IOException {
		if(!this.in.equals(System.in)) 
			this.in.close();
	}

}

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

using namespace std;

int main()
{
    long long x;
    long long m=100;
    int y=0;
    scanf("%lld",&x);
    while(m<x)
    {
        m+=m/(long)100;
        y++;
    }
    printf("%d\n",y);
    return 0;
}


Measured memory_bytes: 1732
#pragma optimization_level 3
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("input.txt");ofstream out("output.txt");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

int main() {
    fast;
    ll a; cin>>a;
    str t; cin>>t;
    ll ed = 0;
    for(char c : t) ed += c=='1';
    ll m1 = max(1ll, ed-1), m2 = min(a, ed+1);
    int G = 222222, o[G], pw1[G], pw2[G];
    o[0] = 0;
    for(int q=1; q<G; q++) o[q] = o[q%__builtin_popcount(q)]+1;
    pw1[0] = pw2[0]= 1;
    for(int q=1; q<G; q++){
        pw1[q] = pw1[q-1]*2;
        pw2[q] = pw2[q-1]*2;
        pw1[q]%=m1;
        pw2[q]%=m2;
    }
    ll p1 = 0, p2 = 0;
    for(ll q=0; q<a; q++){
        p1*=2, p2*=2;
        if(t[q]=='1') p1++, p2++;
        p1%=m1, p2%=m2;
    }
    for(ll q=0, i=a-1; q<a; q++, i--){
        if(ed==1 && t[q]=='1'){
            cout<<"0\n";
            continue;
        }
        ll tyt = t[q]=='0' ? m2 : m1;
        ll delta = t[q]=='0' ? pw2[i] : -pw1[i];
        ll c;
        if(tyt==m1) c = (p1+delta+m1)%m1;
        else c = (p2+delta+m2)%m2;
        cout<<1+o[c]<<"\n";
    }
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,n) for(int i=0;i<n;i++)
#define iFOR(i,x,n)for(int i=x;i<n;i++)
#define fin <<'\n'
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()

typedef long long ll;
typedef pair < int , int >  pii;
typedef vector < int > vit;
static const signed int INF = 0x3f3f3f3f;
static const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static const signed int SMOD = 1000000007;
static const signed int NMOD = 1000000009;
static const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static const signed int dy[]={0,-1,0,1,-1,1,-1,1};

bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>T abs(T &x){return x<0 ? -x : x;}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
//#define int long long
int n;
double p[3005];
double dp[3005][3005]={};
        
inline void solve(){

    cin >> n;
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    
    dp[0][0] = 1.0;
    
    for(int i = 1; i <= n; i++) {  
        for(int j = 0; j <= i; j++) {
            dp[i][j] = dp[i-1][j]*(1-p[i-1]) + (j?dp[i-1][j-1]*p[i-1]:0.0);
        }
    }
    double ans = 0.0;
    for(int i = n/2+1; i <= n; i++){
        ans += dp[n][i];
    }

    cout << ans << endl;
            
}

struct xyz{ xyz(){ cin.tie(0), ios::sync_with_stdio(false); cout <<fixed<<setprecision(12);};}xyzzy;signed main(){solve();return 0;}



Measured memory_bytes: 69120