akhauriyash/Code-Regression huggingface dataset:
import java.util.*;
 
public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		String a = sc.next();
		String[] s=a.split("");
		int r=0;
		int b=0;
		for(int i=0;i<s.length;i++){
			if(s[i].equals("0"))r++;
			if(s[i].equals("1"))b++;
		}
		System.out.print(chmin(r,b)*2);
	}
	private static int chmax(int a,int b){
		if(a>b) return a;
		else return b;
	}
	private static int chmin(int a,int b){
		if(a<b) return a;
		else return b;
	}
}

Measured memory_bytes: 46472
a = int(input())
ls = []
for i in range(a):
    b,c = input().split()
    s = [int(b),int(c)]
    ls.append(s)

ls_sorted = sorted(ls, key=lambda x: x[1], reverse=False)

def all(lst):
    cnt = 0
    for i, j in lst:
        cnt += i
        if cnt > j:
            return False
    return True
if all(ls_sorted):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 39628
s = input()
if s == "RRR":
    print(3)
elif s[0] == "R" and s[1] != "R":
    print(1)
elif s[2] == "R" and s[1] != "R":
    print(1)
elif s[1] == "R" and s[0] != "R" and s[2] != "R":
    print(1)
elif s[0] == "R" and s[1] == "R":
    print(2)
elif s[1] == "R" and s[2] == "R":
    print(2)
else:
    print(0)

Measured memory_bytes: 61956
#include <iostream>
#include <vector>
#include <tuple>
using namespace std;
using llong = long long;
using T = tuple<llong, llong, llong>;

int main() {
    llong a, b, c, n;
    llong x, y, z;
    vector<llong> X;
    vector<llong> Y;
    vector<llong> Z;

    cin >> a >> b >> c >> n;
    llong ans = a * b * 2 + a * c * 2 + b * c * 2;
    for (int i = 0; i < n; i++) {
        cin >> x >> y >> z;
        X.push_back(x);
        Y.push_back(y);
        Z.push_back(z);

        for (int j = 0; j < i; j++) {
            if (abs(x - X[j]) == 1 && y == Y[j] && z == Z[j]) ans -= 2;
            if (abs(y - Y[j]) == 1 && x == X[j] && z == Z[j]) ans -= 2;
            if (abs(z - Z[j]) == 1 && x == X[j] && y == Y[j]) ans -= 2;
        }

        if (x == 0) ans -= 2;
        if (x == a - 1) ans -= 2;
        if (y == 0) ans -= 2;
        if (y == b - 1) ans -= 2;
        if (z == 0) ans -= 2;
        if (z == c - 1) ans -= 2;

        ans += 6;
    }

    cout << ans << endl;
}



Measured memory_bytes: 3180
n, k = map(int, input().split())
ans = 0
for i in range(1, n+1):
    cur = i
    count = 0
    while True:
        if cur >= k:
            break
        cur *= 2
        count += 1
    # print(0.5 ** count)
    ans += (0.5 ** count) / n

print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <limits.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>

typedef unsigned long long ULLONG;
typedef long long LLONG;

template <class _T> static _T tp_abs(const _T& a) {
	return ((a < 0) ? (a * -1) : a);
}
template <class _T> static _T tp_min(_T a, _T b) {
	return a < b ? a : b;
}
template <class _T> static _T tp_max(_T a, _T b) {
	return a > b ? a : b;
}
template<class _T> static void getint(_T& a) {
	const char* fmt = " %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld";
	}

	if (scanf(fmt, &a) < 0) {
		printf("g1int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b) {
	const char* fmt = " %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld";
	}

	if (scanf(fmt, &a, &b) < 0) {
		printf("g2int Error\n");
	}
}
template<class _T> static void getint(_T& a, _T& b, _T& c) {
	const char* fmt = " %d %d %d";
	if (sizeof(_T) == sizeof(long long)) {
		fmt = " %lld %lld %lld";
	}

	if (scanf(fmt, &a, &b, &c) < 0) {
		printf("g3int Error\n");
	}
}
static void getstring(char* buff) {
	if (scanf(" %s", buff) < 0) {
		printf("getstr error!\n");
	}
}
static const long long MOD_NUM = 1000000007LL;

static void D_task();

int main()
{
	D_task();
	fflush(stdout);
	return 0;
}

static void D_task()
{
	int N, K;
	getint(N, K);

	std::vector<double> sep(N, 0);
	for (int i = 0; i < N; i++) {
		int tmp; getint(tmp);
/*
		double ep = 0.0;
		for (int j = 1; j <= tmp; j++) {
			ep += (double)j / (double)tmp;
		}
*/
		sep[i] = (double)(tmp + 1) / 2.0;
	}

	double maxep = 0.0;
	double sumep = 0.0;
	int stt = 0;
	for (int end = 0; end < N; end++) {
		sumep += sep[end];
		if (end - stt >= K) {
			sumep -= sep[stt];
			stt++;
		}
		maxep = tp_max<double>(maxep, sumep);
	}
	printf("%.7lf", maxep);
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define mt make_tuple
#define mp make_pair
#define pu push_back
#define INF 1000000001
#define MOD 998244353
#define EPS 1e-6
#define ll long long int
#define ld long double
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define pr(v) { for(int i=0;i<v.size();i++) { v[i]==INF? cout<<"INF " : cout<<v[i]<<" "; } cout<<endl;}
#define t1(x)                cerr<<#x<<" : "<<x<<endl
#define t2(x, y)             cerr<<#x<<" : "<<x<<" "<<#y<<" : "<<y<<endl
#define t3(x, y, z)          cerr<<#x<<" : " <<x<<" "<<#y<<" : "<<y<<" "<<#z<<" : "<<z<<endl
#define t4(a,b,c,d)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<endl
#define t5(a,b,c,d,e)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<endl
#define t6(a,b,c,d,e,f)          cerr<<#a<<" : "<<a<<" "<<#b<<" : "<<b<<" "<<#c<<" : "<<c<<" "<<#d<<" : "<<d<<" "<<#e<<" : "<<e<<" "<<#f<<" : "<<f<<endl
#define GET_MACRO(_1,_2,_3,_4,_5,_6,NAME,...) NAME
#define t(...) GET_MACRO(__VA_ARGS__,t6,t5, t4, t3, t2, t1)(__VA_ARGS__)
#define _ cerr<<"here"<<endl;
#define __ {ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);}

using namespace std;
template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){ return out<<"("<<a.first<<", "<<a.second<<")";}
template <int> ostream& operator<<(ostream& os, const vector<int>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { if(v[i]!=INF) os << v[i]; else os << "INF";if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) { os << "["; for (int i = 0; i < v.size(); ++i) { os << v[i]; ;if (i != v.size() - 1) os << ", "; } os << "]\n"; return os; } 


int main()
{
  __;
  int n,k;
  cin >> n >> k;
  vector<vector<ll> > dp(3100,vector<ll> (3100));
  vector<ll> dp_sum(3100);
  vector<int> v(n);
  for(int i=0;i<n;i++) cin >> v[i];

  for(int i=0;i<n;i++) dp[i][v[i]] = i+1;

  for(int i=0;i<n;i++)
  {
    for(int j=0;j<=k;j++)
    {
      if( j >= v[i]) 
      {
        dp[i][j] += dp_sum[j-v[i]];
        dp[i][j] %= MOD;
      }
    }
    for(int j=0;j<=k;j++)
    {
      dp_sum[j] += dp[i][j];
      dp_sum[j] %= MOD;
    }
  }

  ll ans = 0;
  for(int i=0;i<n;i++)
  {
    ans += dp[i][k]*(n-i);
    ans %= MOD;
  }

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


Measured memory_bytes: 75520
object Main extends App {
  def min(ls: Long*): Long = ls.min
    
  val n = readInt
  val monsters = readLine.split(" ").map(_.toLong)
  val savers = readLine.split(" ").map(_.toLong)
  var fii = scala.collection.mutable.ArrayBuffer[Long]()
  var fij = scala.collection.mutable.ArrayBuffer[Long]()
  
  fii += min(monsters(0), savers(0))
  fij += min(monsters(0+1), savers(0)-fii.last)
  Range(1,n).foreach{i =>
    fii += min(monsters(i)-fij.last, savers(i))
    fij += min(monsters(i+1), savers(i)-fii.last)
  }
  
  print(fii.toList.sum + fij.toList.sum)
}

Measured memory_bytes: 80828
def main():
    n = int(input())
    b_s = list(map(int, input().split(' ')))
    b_pre = 10**5 + 1
    a_s = []
    
    for b in b_s:
        a_s.append(min(b_pre, b))
        b_pre = b
    a_s.append(b)

    print(sum(a_s))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
program name
    use,intrinsic :: iso_fortran_env
    implicit none
    integer(int64):: k,i,n,a1,a2
    character(100):: s
    character(200):: s2
    logical:: one_word = .true.

    read*, s
    read*, k
    n = len_trim(s)
    do i=1,n
        if (s(1:1) /= s(i:i)) one_word = .false.
    end do

    if (one_word) then
        print'(i0)', (n*k)/2
        stop
    end if

    s2 = trim(s) // trim(s)

    a1 = serch(s,n)
    a2 = serch(s2,2*n)

    print'(i0)', a1*k + (a2-2*a1)*(k-1)

contains
    function serch(str,n) result(ret)
        character(*):: str
        integer(int64):: n,ret
        integer(int64):: i

        ret = 0
        do i=2,n
            if (str(i:i) == str(i-1:i-1)) then
                ret=ret+1
                str(i:i)='0'
            end if
        end do
    end function
end program name

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << endl;
}
const int mod = 1e9 + 7;
//const int mod = 998244353;

template< typename T >
struct BinaryIndexedTree {
  vector< T > data;

  BinaryIndexedTree(int sz) {
    data.assign(++sz, 0);
  }

  T sum(int k) {
    T ret = 0;
    for(++k; k > 0; k -= k & -k) ret += data[k];
    return (ret);
  }

  void add(int k, T x) {
    for(++k; k < data.size(); k += k & -k) data[k] += x;
  }
};


int main(){
	ll q; cin >> q;
	vector<pair<ll,P>> query(q);
	vl num;
	rep(i,q){
		cin >> query[i].first;
		if(query[i].first == 1){
			cin >> query[i].second.first >> query[i].second.second;
			num.push_back(query[i].second.first);
		}
	}
	sort(all(num));
	num.erase(unique(all(num)),num.end());
	vl cmp;
	map<ll,ll> mp;
	for(auto i : num) cmp.push_back(i), mp[i] = cmp.size();
	ll now = -1;
	ll ans = 0;
	BinaryIndexedTree<ll> bit(202020);
	ll siz = 0;
	rep(i,q){
		if(query[i].first == 1){
			siz++;
			ll a = query[i].second.first;
			ll b = query[i].second.second;
			ll t = mp[a];
			bit.add(t,1);
			ll ng = 0, ok = 200000;
			if(siz & 1 ^ 1) ans += abs(cmp[now-1] - a);
			while(ok-ng > 1){
				ll mid = (ok+ng)/2;
				if(bit.sum(mid)>=(siz+1)/2) ok = mid;
				else ng = mid;
			}
			now = ok;
			if(siz & 1) ans += abs(cmp[now-1] - a);
			ans += b;
		}else{
			print2(cmp[now-1],ans);
		}
	}
}

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

using namespace std;

int ans[100001] = {0};

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int n, k, q;
    cin >> n >> k >> q;
    for (int i = 0; i < q; i++){
        int sk;
        cin >> sk;
        ans[sk]++;
    }
    for (int i = 1; i <= n; i++){
        if (q - ans[i] < k) cout << "Yes" << "\n";
        else cout << "No" << "\n";
    }
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	int tScore = 0, hScore = 0;
	cin >> n;
	for(int i = 0;i < n;i++)
	{
		char t[100], h[100];
		cin >> t >> h;
		int j = strcmp(t, h);
		if (j > 0)
			tScore += 3;
		else if (j == 0)
		{
			tScore++; hScore++;
		}
		else
			hScore += 3;
	}
	cout << tScore << " " << hScore << endl;
	return 0;
}


Measured memory_bytes: 3096
//A - Maximize the Formula

import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());

		if(a == 1) {
			System.out.println("Hello World");
			return;
		}

		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());

			System.out.println(b + c);
	}
}

Measured memory_bytes: 21844
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int w = sc.nextInt();
        int h = sc.nextInt();
        int n = sc.nextInt();
        int[] x = new int[n];
        int[] y = new int[n];
        int[] a = new int[n];
        int[][] ans = new int[h][w];
        for (int i = 0; i < n; i++) {
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
            a[i] = sc.nextInt();
        }
        for (int i = 0; i < n; i++) {
            if (a[i] == 1) {
                for (int j = 0; j < h; j++) {
                    for (int k = 0; k < x[i]; k++) {
                        ans[j][k] = 1;
                    }
                }
            }
            if (a[i] == 2) {
                for (int j = 0; j < h; j++) {
                    for (int k = x[i]; k < w; k++) {
                        ans[j][k] = 1;
                    }
                }
            }
            if (a[i] == 3) {
                for (int j = 0; j < y[i]; j++) {
                    for (int k = 0; k < w; k++) {
                        ans[j][k] = 1;
                    }
                }
            }
            if (a[i] == 4) {
                for (int j = y[i]; j < h; j++) {
                    for (int k = 0; k < w; k++) {
                        ans[j][k] = 1;
                    }
                }
            }
        }
        int count = 0;
        for (int j = 0; j < h; j++) {
            for (int k = 0; k < w; k++) {
                if (ans[j][k] == 0)
                    count++;
            }
        }
        System.out.println(count);
    }
}


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

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

    int n;
    cin >> n;
    cout << (n % 2 == 0 ? 0.5 : 0.5 + (double)0.5 / n) << endl;

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main () {
	int N, M; cin >> N >> M;
	vector<int> X(M);
	rep(i, M) cin >> X[i];
	sort(all(X));
	vector<int> d(M-1);
	rep(i, M-1) d[i] = abs(X[i+1] - X[i]);
	sort(all(d), greater<int>());
	int ans = 0;
	REP(i, N-1, d.size()) ans += d[i];
	cout << ans << endl;
}


Measured memory_bytes: 1024
void main()
{
    long n = rdElem;
    long[] h = rdRow;

    long[] dp = new long[n];
    dp[1] = abs(h[0] - h[1]);
    foreach (i; 2 .. n)
    {
        dp[i] = min(dp[i-1]+abs(h[i-1]-h[i]), dp[i-2]+abs(h[i-2]-h[i]));
    }

    dp[n-1].writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;
enum double eps = 1.0e-9;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.mathspecial;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;
import core.bitop;

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

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

	vector<int> l(n);
	for (int i = 0; i < n; i++)
	{
		cin >> l.at(i);
	}

	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	
	int answer = 0;
	for (int i = 0; i < k; i++)
	{
		answer += l.at(i);
	}
	cout << answer << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);
    try {
      int m = scanner.nextInt();
      int d = scanner.nextInt();

      int ans = 0;
      for (int i = 1; i <= m; i++) {
        for (int j = 0; j <= d; j++) {
          if (query(j, i)) ans++;
        }
      }
      System.out.println(ans);
    } finally {
      scanner.close();
    }
  }

  private static boolean query(int d, int m) {
    int d1 = d % 10;
    int d10 = (d % 100) / 10;
    return d1 >= 2 && d10 >= 2 && d1 * d10 == m; 
  }
}


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

using namespace std;

string const X = "CODEFESTIVAL2016";

int main(void)
{
    string s;
    cin >> s;

    int result = 0;
    for (int i = 0; i < X.size(); ++i) {
        if (s[i] != X[i]) {
            ++result;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define MOD 1000000007


using namespace std;

int s[2008], t[2008];
long long dp[2008][2008];
int n, m;

int main()
{
    memset(dp, 0, sizeof(dp));
    
    int i, j;
    cin >> n >> m;
    for(i = 1; i <= n; i++)
        cin >> s[i];
    for(i = 1; i <= m; i++)
        cin >> t[i];
        
    dp[0][0] = 1;
    for(i = 1; i <= n; i++)
        dp[i][0] = 1;
    for(j = 1; j <= m; j++)
        dp[0][j] = 1;
    for(i = 1; i <= n; i++)
    {
        for(j = 1; j <= m; j++)
        {
            if(s[i] == t[j])
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            else
            {
                dp[i][j] = ((dp[i - 1][j] + dp[i][j - 1] - dp[i - 1][j - 1]) % MOD + MOD) % MOD;
            }
        }
    }
    
    cout << dp[n][m];

    
    return 0;
}

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

vector<pair<int, int>> prime_fact(int n, vector<int>& spf) {
  vector<pair<int, int>> ans;
  int posi = spf[n];
  int copy = n;

  while(posi!=1) {
    int times = 0;
    int next = posi;
    while(next==posi) {
      copy = copy/posi;
      times++;
      next = spf[copy];
    }
    pair<int, int> add;
    add.first = posi;
    add.second = times;
    ans.push_back(add);

    posi = next;
  }

  // while(posi*posi<=n) {
  //   if(copy%posi==0) {
  //     int times = 0;
  //     while(copy%posi==0) {
  //       copy = copy/posi;
  //       times++;
  //     }

  //     pair<int, int> add;
  //     add.first = posi;
  //     add.second = times;
  //     ans.push_back(add);
  //   }

  //   posi++;
  // }

  // if(copy!=1) {
  //   pair<int, int> add;
  //   add.first = copy;
  //   add.second = 1;
  //   ans.push_back(add);
  // }

  return ans;
}


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

  sort(a, a+n);

  int ma = 1000000;
  bool isprime[ma+1];
  for(int i=0; i<=ma; i++) isprime[i] = true;
  isprime[0] = false;
  isprime[1] = false;

  int posi = 2;
  while(posi*posi<=ma) {
    if(isprime[posi]) {
      int times = posi;
      while(posi*times<=ma) {
        isprime[posi*times] = false;
        times++;
      }
    }
    posi++;
  }


  vector<int> spf(ma+1);
  for(int i=0; i<=ma; i++) spf[i] = i;

  int posi2 = 2;
  while(posi2*posi2<=ma) {
    if(isprime[posi2]) {
      int times = posi2;
      while(posi2*times<=ma) {
        spf[posi2*times] = min(posi2, spf[posi2*times]);
        times++;
      }
    }
    posi2++;
  }


  int table[ma+1];
  for(int i=0; i<ma+1; i++) table[i]=0;

  for(int i=0; i<n; i++) {
    if(a[i]==1) {
      if(table[1]==0) table[1]=1;
      continue;
    }

    vector<pair<int, int>> fact = prime_fact(a[i], spf);
    int m = fact.size();
    for(int j=0; j<m; j++) {
      int p = fact[j].first;
      table[p]++;
    }
  }

  int check = *max_element(table, table+ma+1);
  if(check==1) cout<<"pairwise coprime"<<endl;
  else if(check==n) cout<<"not coprime"<<endl;
  else cout<<"setwise coprime"<<endl;



  return 0;
}

Measured memory_bytes: 15836
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define F first
#define S second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define SZ(x) (int)x.size()
#define int ll

const int N = 1e5 + 10;
int dp[N][2], a[N];

signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> a[i];
	}
	for (int i = 0; i <= n; i++) {
		dp[i][0] = dp[i][1] = -1e9;
	}
	dp[0][0] = 0;
	for (int i = 0; i < n; i++) {
		for (int ost = 0; ost < 2; ost++) {
			for (int to = 0; to < 2; to++) {
				if (a[i + 1] >= to) {
					dp[i + 1][to] = max(dp[i + 1][to], dp[i][ost] + (a[i + 1] + ost - to) / 2);
				}
			}
		}
	}
	cout << max(dp[n][0], dp[n][1]) << '\n';
}

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

int main() {
    vector<int> p(3);
    for(int i = 0; i < 3; i++){
        cin >> p.at(i);
    }
    sort(p.begin(), p.end());
    cout << p.at(0) + p.at(1);
}


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

using namespace std;

typedef long long ll;

int main(){
  string s; cin >> s;
  char L=s[0], R=s[s.size()-1];
  int countL=0, countR=0;
  for(int i=0;i<s.size();i++){
    if(s[i] == L){
      countL++;
    }else if(s[i] == R){
      countR++;
    }
  }
  int finit;
  if(L != R) finit=min(countL, countR)*2;
  else finit=min(countL, countR)*2+1;
  if((s.size()-finit) %2==1) cout << "First\n";
  else cout << "Second\n";
}

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

int main()
{
    ios::sync_with_stdio();cin.tie(0);cout.tie(0);
    #define pb push_back
    #define mk make_pair
    //#define int long long int
    int  n;
    cin>>n;
    int a[n+100],b[n+100]={0};
    for(int i=0;i<n-1;i++)
    {
        cin>>a[i];
        b[a[i]]++;
        //cout<<"b["<<"a["<<i<<"]]="<< b[a[i]]<<endl;
    }

    for(int i=1;i<=n;i++)
    {
        cout<<b[i]<<endl;
    }





    return 0;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;
string grid[800];
int dist[800][800];
int n, m, k;
int main(){
	cin >> n >> m >> k;
	for(int i = 0; i < n; i++){
		cin >> grid[i];
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			dist[i][j] = -1;
		}
	}
	vector<int> curd;
	vector<int> x, y;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(grid[i][j] == 'S'){
				x.push_back(i);
				y.push_back(j);
				curd.push_back(0);
			}
		}
	}
	int s = 0;
	while(s < curd.size()){
		if(x[s] < 0 || x[s] >= n || y[s] < 0 || y[s] >= m){
			s++;
			continue;
		}
		if(grid[x[s]][y[s]] == '#' || dist[x[s]][y[s]] >= 0){
			s++;
			continue;
		}
		dist[x[s]][y[s]] = curd[s];
		x.push_back(x[s]+1);
		y.push_back(y[s]);
		x.push_back(x[s]-1);
		y.push_back(y[s]);
		x.push_back(x[s]);
		y.push_back(y[s]+1);
		x.push_back(x[s]);
		y.push_back(y[s]-1);
		curd.push_back(curd[s]+1);
		curd.push_back(curd[s]+1);
		curd.push_back(curd[s]+1);
		curd.push_back(curd[s]+1);
		s++;
	}
	int ans = 1000000;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(dist[i][j] < 0 || dist[i][j] > k) continue;
			ans = min(ans, 1 + (min(min(i,j),min(n-1-i,m-1-j)) + k-1)/k );
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 41656
N = int(input())
Y = list(str(N))
Z =[]
for i in Y:
    Z.append(int(i))
K = int(input())
m = len(str(N))
def nn(Z,K,m):
    ans = 0
    if m < K:
        return ans
    else:
        if K == 1:
            y = Z[0]
            ans += (m-1) * 9 + y
            #print(ans)
        elif K == 2:
            #0 
            ans += ((m-1) * (m-2) // 2) * 9 * 9
            #print(ans)
            #mid
            ans += (max(0,Z[0]-1)) * (m-1) * 9
            #print(ans)
            #max
            K -= 1
            m -= 1
            Z = Z[1:]
            for _ in range(100):
                if Z[0] == 0:
                    m -= 1
                    Z = Z[1:]   
                else:
                    break
                if len(Z) == 0:
                    break            
            ans += nn(Z,K,m)
            #print(ans)
        elif K == 3:
            #0 
            ans += ((m-1) * (m-2) * (m-3) // 6) * 9 * 9 * 9
            #print(ans)
            #mid
            ans += (max(0,Z[0]-1)) * ((m-1) * (m-2) // 2) * 9 * 9
            #print(ans)
            #max
            K -= 1
            m -= 1
            Z = Z[1:]
            for _ in range(100):
                if Z[0] == 0:
                    m -= 1
                    Z = Z[1:]   
                else:
                    break
                if len(Z) == 0:
                    break
            ans += nn(Z,K,m)
        return ans
if len(str(N)) < K:
    ans = 0
else:
    ans = nn(Z,K,m)        
print(ans)

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

int main() {
  int S;
  int hh, mm, ss;
  cin >> S;
  hh = S / (60 * 60);
  mm = (S - (60 * 60) * hh) / 60;
  ss = (S - (60 * 60) * hh - 60 * mm);
  cout << hh << ":" << mm <<  ":" << ss << endl;
  return 0;
}


Measured memory_bytes: 3116
def rankmod2(A):
    global N, M
    ret = 0
    i = 0
    j = 0
    while i < N and j < M:
        if A[i][j]:
            ret += 1
        else:
            for ii in range(i+1, N):
                if A[ii][j]:
                    A[i], A[ii] = A[ii], A[i]
                    ret += 1
                    break
            else:
                j += 1
                continue
                
        for ii in range(i+1, N):
            if A[ii][j]:
                for jj in range(j, M):
                    A[ii][jj] = (A[ii][jj] + A[i][jj]) % 2
        i += 1
        j += 1
        
    return ret
                        
P = 998244353
N, M = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
r = rankmod2(A)
print((pow(2, N+M-1, P)-pow(2, N+M-r-1, P)) % P)

Measured memory_bytes: 3828
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner scan = new java.util.Scanner(System.in);
        String str = scan.nextLine();
        for(int i = 0; i < str.length(); i++){
            if(Character.isUpperCase(str.charAt(i))){
                System.out.print(Character.toLowerCase(str.charAt(i)));
            }else{
                System.out.print(Character.toUpperCase(str.charAt(i)));
            }
        }
        System.out.println();
    }
}

Measured memory_bytes: 27140
#include <cmath>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
#include <list>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <numeric>
#include <utility>
#include <iomanip>
#include <cstdio>
#include <cctype>
#include <queue>
#include <complex>
#include <climits>

typedef long long ll;

using namespace std;

void hit(int base[], int& score){
	if(base[2] == 1){
		score++;
		base[2] = 0;
	}
	if(base[1] == 1){
		base[2] = 1, base[1] = 0;
	}
	if(base[0] == 1){
		base[1] = 1;
	}
	base[0] = 1;

	return ;
}

void homerun(int base[], int& score){
	score += base[0] + base[1] + base[2] + 1;
	base[0] = base[1] = base[2] = 0;
	return ;
}

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

	for(int i=0; i<n; ++i){
		int score = 0, out = 0;
		int base[3] = {0};
		string s;
		while(1){
			cin >> s;
			if(s == "HIT")
				hit(base, score);
			if(s == "HOMERUN")
				homerun(base, score);
			if(s == "OUT"){
				out++;
				if(out == 3){
					cout << score << endl;
					break;
				}
			}
		}
	}


	return 0;
}

Measured memory_bytes: 1212
use std::io::{self, Read};
use std::str::FromStr;
pub struct Scanner<R: Read> {
    reader: R,
}
impl<R: Read> Scanner<R> {
    pub fn new(reader: R) -> Scanner<R> {
        Scanner { reader: reader }
    }
    pub fn read<T: FromStr>(&mut self) -> T {
        let s = self
            .reader
            .by_ref()
            .bytes()
            .map(|c| c.expect("failed to read char") as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        s.parse::<T>().ok().expect("failed to parse token")
    }
}

/// d: 訪問時刻
/// f: 終了時刻
/// idx: 対象の添え字
/// time: 現在時刻
fn dfs(vec: &Vec<Vec<usize>>, d: &mut Vec<Option<u32>>, f: &mut Vec<Option<u32>>, idx: usize, time: u32) -> u32 {
    if d[idx].is_none() {
        let mut time = time + 1;
        d[idx] = Some(time);    // 現在時刻を1つ進め、訪問として記録
        for i in vec[idx].iter() {
            time = dfs(vec, d, f, *i, time);
        }
        time += 1;  // 現在時刻を1つ進め、終了時刻として記録
        f[idx] = Some(time);
        time
    } else {
        // 訪問済みなら何もしない
        time
    }
}

fn main() {
    let sin = io::stdin();
    let sin = sin.lock();
    let mut sc = Scanner::new(sin);

    let n: usize = sc.read();
    let vec: Vec<Vec<usize>> = (0..n).map(|_| {
            let _i: usize = sc.read();
            let k: usize = sc.read();
            (0..k).map(|_| sc.read::<usize>() - 1)  // index変換に1減らす
                .collect::<Vec<usize>>()
        }).collect();
    let mut stamp_start: Vec<Option<u32>> = vec![None; n];   // Noneの時未訪問とする
    let mut stamp_end: Vec<Option<u32>> = vec![None; n];   // Noneの時未訪問とする

    let mut time = 0;
    for i in 0..n {
        time = dfs(&vec, &mut stamp_start, &mut stamp_end, i, time);
    }

    for i in 0..n {
        println!("{} {} {}", i+1, stamp_start[i].unwrap(), stamp_end[i].unwrap());
    }
}



Measured memory_bytes: 5036
#include<cstdio>
#include<iostream>
int n,d,m;
int main() {
    scanf("%d%d%d",&n,&m,&d);
    long long tot=1LL*n*n;
    long long ans=0;
    if(!d) ans=n;
    else ans=2LL*(n-d);
    printf("%.10f\n",1.0*(m-1)*ans/tot);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
int w,h,x,y,r;
cin >>w>>h>>x>>y>>r;
if(x+r<=w && x-r>=0 && y+r<=h && y-r>=0){
cout <<"Yes"<<endl;
}else{
cout <<"No"<<endl;
}
}


Measured memory_bytes: 3108
import java.util.*;
import java.io.*;

public class Main {	
	private static void solve(){
		//Implement solution here.
		int N = ni();
		int[] X = na(N);
		int minsum = Integer.MAX_VALUE;
		for(int i = 1; i <= 100; i++) {
			int sum = 0;
			for(int j = 0; j < N; j++) sum += Math.pow(X[j] - i, 2);
			minsum = Math.min(minsum, sum);
		}
		System.out.println(minsum);
	}
	


	//Switch input source (stdin/file)
	private static BufferedReader br;
	public static void main(String[] args){
		br = new BufferedReader(new InputStreamReader(System.in));
		String debugDataPath = System.getenv("DD_PATH");        
		if(debugDataPath != null){
			try{
				br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
			}catch(Exception e){
				throw new RuntimeException(e);
			}
		}
		solve();
	}

	//Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
	//Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
	//Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
	//Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
	//Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
	//Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}


Measured memory_bytes: 22356
#include <bits/stdc++.h>
using namespace std;
int main(){
    int v[5], n, i, min;
    for (i=0; i<5; i++){
        cin >> v[i];
    }
    min=(v[0]-1)%10;
    n=0;
    for (i=1; i<5; i++){
        if (min>(v[i]-1)%10){
            min=(v[i]-1)%10;
            n=i;
        }
    }
    int aux=v[n];
    v[n]=0;
    int sum = 0;
    for (i=0; i<5; i++)
    sum += 10*ceil((float)v[i]/10);
    sum += aux;
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int k,x; cin >> k >> x;
    for(int i=x-k+1 ; i<k+x ; i++)
        cout << i << " " ;
}

Measured memory_bytes: 256
alf = [0 for i in range(26)]
while True:
      try:
            a = input()
      except:
            break

      for i in range(len(a)):
            n = ord(a[i])-ord('A')
            if(n >= 0 and n < 26):
                  alf[n]+=1
            n = ord(a[i])-ord('a')
            if(n >= 0 and n < 26):
                  alf[n]+=1
for i in range(26):
      print(chr(i+ord('a')),":",alf[i])



Measured memory_bytes: 5568
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;


class UnionFind{
 private:
    vector<int> Parent,es;
    vector<ll> diff_weight;
 public:
    UnionFind(int N){
        es.resize(N,0);
        Parent.resize(N,-1);
        diff_weight.resize(N,0LL);
    }

    int root(int A){
        if(Parent[A]<0) return A;
        else{ 
            int r = root(Parent[A]);
            diff_weight[A] += diff_weight[Parent[A]]; // 累積和をとる
            return Parent[A]=r;
        }
    }
    bool issame(int A,int B){
        return root(A)==root(B);
    }
    ll weight(int x) {
        root(x); // 経路圧縮
        return diff_weight[x];
    }
    ll diff(int x, int y) {
        return weight(y) - weight(x);
    }
    int size(int A){
        return -Parent[root(A)];
    }
    int eize(int A){
        return es[root(A)];
    }
    bool connect(int A,int B){
        A=root(A); B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) std::swap(A,B);
        Parent[A]+=Parent[B];
        es[A]+=es[B]+1;
        Parent[B]=A;
        return true;
    }
    void unite(int A,int B){
        A=root(A); B=root(B);
        if(A==B){ 
            es[A]++;
            return;
        }
        if(size(A)<size(B)) std::swap(A,B);
        Parent[A]+=Parent[B];
        es[A]+=es[B]+1;
        Parent[B]=A;
        return;
    }
    bool merge(int A, int B, ll w) {
        // x と y それぞれについて、 root との重み差分を補正
        w += weight(A); w -= weight(B); 
        A=root(A); B=root(B);
        if(A==B) return false;
        if(size(A)<size(B)) std::swap(A,B),w=-w;
        Parent[A]+=Parent[B];
        Parent[B]=A;
        // x が y の親になるので、x と y の差分を diff_weight[y] に記録
        diff_weight[B] = w; 
        return true;
    }
};
int main(){
    int N,M;cin>>N>>M;
    vector<int> p(N);
    REP(i,N) cin>>p[i];
    UnionFind uni(N);
    REP(i,M){
        int x,y;cin>>x>>y;
        x--;y--;
        uni.connect(x,y);
    }
    int ans=0;
    REP(i,N){
        if(uni.issame(i,p[i]-1)) ans++;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 2176
#include <bits/stdc++.h>	
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                        	
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const ld eps = 1e-7;
 
ld Add(ld a, ld b)
{
	return a + b;
}

ld Sqr(ld a)
{
	return a * a;	
}

struct Point
{
	ld x, y;

	void Read()
	{
		cin >> x >> y;
	}

	ld Distance(Point a)
	{
		return sqrt(Add(Sqr(a.x - x), Sqr(a.y - y)));
	}
}a[55];

int n;
ld ansx, ansy;

bool More(ld a, ld b)
{
	return a > b + eps;
}

ld f(ld x, ld y)
{
	ld res = 0;
	Point cur;
	cur.x = x, cur.y = y;
	for(int i = 1; i <= n; i++) res = max(res, a[i].Distance(cur));		
	return res;
}

ld Ternary_y(ld x)
{
	ld l = 0, r = 1001;
	while(More(fabs(r - l), eps))
	{
		ld m1 = l + (r - l) / 3;
		ld m2 = r - (r - l) / 3;
		if(More(f(x, m1), f(x, m2))) l = m1;
		else r = m2;
	}
	ansy = r;
	return f(x, r);
}

ld Ternary_x()
{
	ld l = 0, r = 1001;
	while(More(fabs(r - l), eps))
	{
		ld m1 = l + (r - l) / 3;
		ld m2 = r - (r - l) / 3;
		if(Ternary_y(m1) > Ternary_y(m2)) l = m1;
		else r = m2;
	}
	ansx = r;
	return Ternary_y(r);
}

int main ()
{
	#ifdef JUDGE
		freopen("input.txt", "r", stdin);
	#endif		
	Fast_Read_Out();
	Random();
	cin >> n;
	for(int i = 1; i <= n; i++) a[i].Read();
	Ternary_x();
	cout << fixed << setprecision(6) << f(ansx, ansy); 
}                                

Measured memory_bytes: 256
s = input()

if s == "SUN":
  print(7)
elif s == "MON":
  print(6)
elif s == "TUE":
  print(5)
elif s == "WED":
  print(4)
elif s == "THU":
  print(3)
elif s == "FRI":
  print(2)
elif s == "SAT":
  print(1)
  

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
ll choose2(ll n) {
  return n*(n-1)/2;
}
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  rep(i,n) a[i]--;
  vector<int> cnt(n);
  rep(i,n) cnt[a[i]]++;
  ll tot = 0;
  rep(i,n) {
    tot += choose2(cnt[i]);
  }
  rep(i,n) {
    ll ans = tot;
    ans -= choose2(cnt[a[i]]);
    ans += choose2(cnt[a[i]]-1);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 4096
import sys


stdin = sys.stdin
def ns(): return stdin.readline().rstrip()
def ni(): return int(stdin.readline().rstrip())
def nm(): return map(int, stdin.readline().split())
def nl(): return list(map(int, stdin.readline().split()))


def main():
    d, n = nm()
    if n != 100:
        print(pow(100, d) * n)
    else:
        print(pow(100, d) * 101)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9084
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scn = new Scanner(System.in);

        int K = scn.nextInt();
        int ans = -1;

        int a = 7 % K;
        for(int i = 0; i < K; i++) {
            if(a == 0) {
                ans = i+1;
                break;
            }
            a = (10*a + 7) % K;
        }

        System.out.println(ans);
    }
}

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

def factorization(n):
    arr = []
    temp = n
#    for i in range(2, int(-(-n**0.5//1))+1):
    for i in range(2, int((n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
#                temp = (temp+0.5)//i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

fact_N = factorization(N)
#fact_N = np.array(fact_N)
#num_sosuu = fact_N[:,1]

num_sosuu = []
for row in fact_N:
    num_sosuu.append(row[1])

#num_sosuu_max = num_sosuu.max()
#num_sosuu_max = max(num_sosuu)

ans = 0
for i in range(len(num_sosuu)):
    num_i = num_sosuu[i]
#    for j in range(np.uint64(np.sqrt(2*num_sosuu_max))):
#    for j in range(int((2*num_sosuu_max)**0.5)):
    j = 0
    judge = True
    while judge:
        if num_i >= j+1:
            ans += 1
            num_i -= j+1
            j+=1
        else:
#            break
            judge = False

if N == 1:
    ans = 0
    
print(str(ans))

Measured memory_bytes: 63472
n=int(input())
dict_n={}
for _ in range(n):
    s = input()
    if s in dict_n:
        dict_n[s]+=1
    else:
        dict_n[s]=1
m=int(input())
dict_m={}
for _ in range(m):
    t = input()
    if t in dict_m:
        dict_m[t]+=1
    else:
        dict_m[t]=1
ans=0
for s in dict_n:
    if s in dict_m:
        ans=max(ans, dict_n[s]-dict_m[s])
    else:
        ans=max(ans, dict_n[s])
print(max(ans,0))

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

#define N 100000

long int li_max(int a, long int b){
  if (a > b) return a;
  else return b;
}

int main(void){
  long int a[N], x, y, n, cnt = 0;

  cin >> n >> x;

  for (int i = 0; i < n; i++) {
    cin >> a[i];
    if (i >= 1){
      y = a[i] + a[i-1];
      if (y > x){
        cnt += y - x;
        a[i] = li_max(0, a[i] - (y - x));
      }
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 1024
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }




int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ll N; cin >> N;
    ll ans = 0;
    FOR(i, 1, N+1){
        ll t = i; ll d = 0;
        while(t > 0){
            d++; t/=10;
        }
        if(d%2==1) ans++;
    }
    cout << ans << endstr;
    return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("unroll-loops")

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

using namespace std;

using int64 = long long;

constexpr int64 MOD = 1e9 + 7;

template<typename T> void fastin(T &num) {
  bool negative = false;
  T c;
  num = 0;
  c = getchar_unlocked();
  if (c == '-') {
    negative = true;
    c = getchar_unlocked();
  }
  for (; (c > 47 && c < 58); c = getchar_unlocked()) num = (num << 3) + (num << 1) + c - 48;
  if (negative) num *= -1;
}

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

  int n; fastin(n);
  vector<int64> a(n);
  for (int i = 0; i < n; ++i) fastin(a[i]);

  bool dp[n][61];

  for (int i = 0; i < n; ++i) {
    bitset<61> bs(a[i]);
    for (int j = 0; j < 61; ++j) {
      dp[i][j] = bs.test(j);
    }
  }

  int64 dp2[n][61];

  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < 61; ++j) {
      if (i == 0) {
        dp2[i][j] = dp[i][j];
      } else {
        dp2[i][j] = dp[i][j] + dp2[i - 1][j];
      }
    }
  }

  int64 ans = 0;

  for (int i = 1; i < n; ++i) {
    bitset<61> bs(a[i]);
    for (int j = 0; j < 61; ++j) {
      if (bs.test(j)) {
        ans += (1LL << j) % MOD * (i - dp2[i - 1][j]) % MOD;
      } else {
        ans += (1LL << j) % MOD * dp2[i - 1][j] % MOD;
      }
    }
  }

  ans %= MOD;

  printf("%lld", ans);

  return 0;
}


Measured memory_bytes: 163456
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)

	nPlayers := scanInt(sc)
	initialPoint := scanInt(sc)
	nQuestions := scanInt(sc)

	corrects := make([]int, nPlayers)
	for i := 0; i < nQuestions; i++ {
		player := scanInt(sc) - 1
		corrects[player] += 1
	}

	w := bufio.NewWriter(os.Stdout)
	for i := 0; i < nPlayers; i++ {
		nMiss := nQuestions - corrects[i]
		point := initialPoint - nMiss
		if point > 0 {
			fmt.Fprintln(w, "Yes")
		} else {
			fmt.Fprintln(w, "No")
		}
	}
	w.Flush()
}

func scanInt(sc *bufio.Scanner) int {
	sc.Scan()
	v, _ := strconv.Atoi(sc.Text())
	return v
}


Measured memory_bytes: 3968
#include<algorithm>
#include<clocale>
#include<cmath>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<deque>
#include<iostream>
#include<istream>
#include<map>
#include<math.h>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<vector>
using namespace std;
long long n,m,ans;
pair<long long,long long> p[100010];
int main(){
	cin>>n>>m;
	for (int i=0;i<n;i++) cin>>p[i].first>>p[i].second;
	sort(p,p+n);
	int i=0;
	while (m>0){
		ans+=min(p[i].second,m)*p[i].first;
		m-=p[i].second;
		i++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792