akhauriyash/Code-Regression huggingface dataset:
// c++include
#include <iostream>
// cinclude
#include <stdio.h>
#include<string.h>
#include<math.h>
//c++標準ライブラリ
#include<vector>
#include<string>
//std使用
using namespace std;

// define, typedef
#define rpt(i, n) for(i = 0; i < (n); i++)
typedef long long ll;

// main関数
int main(void) {
	int n, count = 0;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		double j = (double)i;
		j = log10(j);
		int l = (int)j;
		if (l % 2 == 0) {
			count++;
		}
	}
	cout << count;
	return 0;
}

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


public class Main{
 public static void main(String args[]){
  Scanner scanner = new Scanner(System.in);
  String esu = scanner.next();
  String t = scanner.next();   
  int kaisu = esu.length() - t.length() + 1;
  
  //ArrayList<Integer> mat = new ArrayList<Integer>(); 
  int mat[];
  mat = new int[kaisu];
   
   for(int i=0;i<kaisu;i++){
      for(int j=0;j<t.length();j++){
        if(esu.charAt(i+j)==t.charAt(j)){
         mat[i]++;
        }else{
        }
      }  
    }
   int min =0;
   for(int i=0;i<kaisu;i++){
     if(mat[i]>min){
       min = mat[i];
     }else{
     }
   } 

  System.out.println(t.length()-min);
   
 }
}

Measured memory_bytes: 27212
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  int n;
  cin >> n;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
    a[i]--;
  }
  int cnt = 0;
  REP(i, 0, n) {
    if (a[a[i]] == i) {
      cnt++;
    }
  }
  assert (cnt % 2 == 0);
  cout << cnt / 2 << endl;
}


Measured memory_bytes: 640
#include <cstdio>
#define scanf __builtin_scanf
#include <utility>
#include <algorithm>
using namespace std;

pair<int, int> v[200010];

int main()
{
    int n; scanf("%d", &n);
    for(int i=0; i<n; ++i) {
        int a, b; scanf("%d%d", &a, &b);
        v[i]={b, -a};
    }
    sort(v, v+n);
    int t=0;
    for(int i=0; i<n; ++i) {
        int a=-v[i].second;
        int b=v[i].first;
        t+=a;
        if (t>b) return puts("No")<0;
    }
    puts("Yes");
}


Measured memory_bytes: 1664
#include<cstdio>
using namespace std;
int k,a,b;
int main(){
    scanf("%d%d%d",&k,&a,&b);
    int ans=b/k-(a-1)/k;
    if(ans>0){
        printf("OK\n");
    }else{
        printf("NG\n");
    }
    return 0;
}


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

ans = 1
R = int(P**(1/N)) + 1
if N == 1:
	ans = P
elif N > 40:
	ans = 1
else:
	for l in range(R):
		if P % (R-l)**N == 0:
			ans = R-l
			break
print(ans)



Measured memory_bytes: 3060
# undo が出来るゲームは全て2手だけ見ればよい
ops = ["+", "*", "-", "&", "^", "|"]
numbers = ["1", "2", "3", "4", "5", "6", "7", "8", "9", "0"]


def check(x):
    # +*
    op = 0
    for c in x:
        if c in ops:
            op += 1
            if op >= 2:
                return None
        else:
            op = 0
    # +...
    for op in ops:
        if x.startswith(op):
            return None
        if ("(" + op) in x:
            return None
    # 0がないか
    zero_ok = False
    for c in x:
        if not zero_ok and c == "0":
            return None
        if c in ops:
            zero_ok = False
        elif c in numbers:
            zero_ok = True
        else:  # ( )
            zero_ok = False
    try:
        val = int(eval(x))
        return val
    except:
        return None


def get_nexts(x):
    # 削除
    result = []
    for i in range(len(x)):
        y = x[:i] + x[i + 1:]
        val = check(y)
        if val != None:
            result.append((val, y))
    # 追加
    for i in range(len(x) + 1):
        add_list = numbers + ops
        for s in add_list:
            y = x[:i] + s + x[i:]
            val = check(y)
            if val != None:
                result.append((val, y))
    return result


while True:
    n, x = input().split(" ")
    n = int(n)
    if n == 0:
        quit()
    nexts = get_nexts(x)
    if n == 1:
        nexts.sort(key=lambda a: - a[0])
        print(nexts[0][0])
        continue
    maxval = eval(x)
    tele = x
    minvals = []
    for (val, y) in nexts:
        nextss = get_nexts(y)
        nextss.sort(key=lambda a: a[0])
        minvals.append(nextss[0][0])
        if maxval < nextss[0][0]:
            maxval = nextss[0][0]
            tele = nextss[0][1]
    if n % 2 == 0:
        print(max(minvals))  # 999+9999 -> 9&99+9999
        continue
    nexts = get_nexts(tele)
    if n % 2 == 1:
        nexts.sort(key=lambda a: -a[0])
        print(nexts[0][0])
        continue



Measured memory_bytes: 5624
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using LayoutKind = System.Runtime.InteropServices.LayoutKind;
using StructLayoutAttribute = System.Runtime.InteropServices.StructLayoutAttribute;
using FieldOffsetAttribute = System.Runtime.InteropServices.FieldOffsetAttribute;

static class P
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(double.Parse).ToArray();
        double[] currentProb = new double[n + 1];
        currentProb[0] = 1;
        for (int i = 0; i < a.Length; i++)
        {
            double[] newProb = new double[n + 1];
            newProb[0] = currentProb[0] * (1 - a[i]);
            for (int j = 1; j < currentProb.Length; j++) newProb[j] = currentProb[j - 1] * a[i] + currentProb[j] * (1 - a[i]);
            currentProb = newProb;
        }
        Console.WriteLine(currentProb.Skip((n + 1) / 2).Sum());
    }
}


Measured memory_bytes: 30416
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n = Integer.parseInt(scan.next());
        int m = Integer.parseInt(scan.next());
        int[] h = new int[n];
        for (int i = 0; i < n; i++) {
            h[i] = Integer.parseInt(scan.next());
        }

        boolean[] isPeak = new boolean[n];
        Arrays.fill(isPeak, true);

        for (int i = 0; i < m; i++) {
            int a = Integer.parseInt(scan.next());
            int b = Integer.parseInt(scan.next());
            a--;
            b--;

            if (h[a] > h[b]) {
                isPeak[b] = false;
            } else if (h[a] < h[b]) {
                isPeak[a] = false;
            } else {
                isPeak[a] = false;
                isPeak[b] = false;
            }
        }
        scan.close();

        int ans = 0;
        for (int i = 0; i < n; i++) {
            if (isPeak[i]) {
                ans++;
            }
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 59220
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ld eps = 1e-9;
const ll MOD = 1000000007;
const int INF = 1000000000;
const ll LINF = 1ll<<50;
template<typename T>
void printv(const vector<T>& s) {
  for(int i=0;i<(int)(s.size());++i) {
    cout << s[i];
    if(i == (int)(s.size())-1) cout << endl;
    else cout << " ";
  }
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
const bool comp (const P &p1, const P &p2) {
  if(p1.first == p2.first) {
    return p1.second < p2.second;
  } else {
    return p1.first > p2.first;
  }
}
P min(const P &p1, const P &p2) {
  if(comp(p1, p2)) return p1;
  else return p2;
}
void solve(int n) {
  vi p(n);
  int ma = 0;
  for(int i=0;i<n;++i) {
    cin >> p[i];
    ma = max(ma, p[i]);
  }
  ma = 1000;
  vector<P> d(n*ma+1, {-INF, INF});
  d[0] = {0, 0};
  for(int i=0;i<n;++i) {
    int mod = p[i] % 1000;
    vector<P> dnxt(n*ma+1, {-INF, INF});
    for(int j=0;j<=n*ma;++j) {
      if(d[j] == make_pair(-INF, INF)) continue;
      if(1 <= mod && mod <= 500) {
        dnxt[j+500-mod] = min(dnxt[j+500-mod], {d[j].first + 1, d[j].second + p[i]});
      } else {
        dnxt[j] = min(dnxt[j], d[j]);
        if(mod == 0 && j >= 500) dnxt[j-500] = min(dnxt[j-500], {d[j].first + 1, d[j].second + p[i]});
        if(mod != 0 && j >= mod - 500) dnxt[j-(mod - 500)] = min(dnxt[j - (mod - 500)], {d[j].first + 1, d[j].second + p[i]});
        if(mod != 0) dnxt[j+1000-mod] = min(dnxt[j+1000-mod], {d[j].first, d[j].second + p[i]});
      }
    }
    d = dnxt;
  }
  P ans = {-INF, INF};
  for(int i=0;i<=n*ma;++i) {
    ans = min(ans, d[i]);
  }
  cout << ans.first << " " << ans.second << endl;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  while(1) {
    int n; cin >> n;
    if(n == 0) break;
    solve(n);
  }
}



Measured memory_bytes: 4496
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  int N;
  cin >> N;
  int A;
  cin >> A;
  cout << N * N - A << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<vector>
#include<array>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
#include<cstring>
#include<string>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    string S;cin>>S;
    int N=S.size();
    int ans=N;
    for(int i=0;i<N-1;i++){
        if(S[i]!=S[i+1]){
            ans=min(ans,max(i+1,N-i-1));
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 512
#include <stdio.h>
#include <iostream>
#include <string>

using namespace std;

#define REP(a, i, n) for (int i = a; i < n; ++i)
#define RREP(a, i, n) for (int i = n - 1; i >= a; --i)

int main() {

    int N;
    scanf("%d", &N);

    string s;
    cin >> s;

    int W[N];
    REP(0, i, N) {
        W[i] = s[i] == 'W' ? 1 : 0;
        W[i] += i == 0 ? 0 : W[i - 1];
        // cout << "W[" << i << "]: " << W[i] << endl;
    }
    int E[N];
    RREP(0, i, N) {
        E[i] = s[i] == 'E' ? 1 : 0;
        E[i] += i == N - 1 ? 0 : E[i + 1];
        // cout << "E[" << i << "]: " << E[i] << endl;
    }

    int ans = N;
    REP(0, i, N) {
        // リーダーの西側に並んでいるひとは東を向く。
        // => 0 から i - 1 までで西を向いている人を数える。
        int l = i == 0 ? 0 : W[i - 1];

        // リーダーの東側に並んでいるひとは西を向く。
        // => i + 1 から N までで東を向いている人を数える。
        int r = i == N - 1 ? 0 : E[i + 1];

        if (l + r < ans) ans = l + r;
    }

    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 2948
#include <iostream>
#include <algorithm>
#include <math.h>
#include <stdio.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    int gokei = 0;
    for(int i=1; i<=n; i++){
        gokei += i;
    }
    cout<<gokei<<endl;
    return 0;
}


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

#define debug(x) cout<<#x<<"="<<x<<endl
#define pii pair<int,int>
#define PQ priority_queue
#define ll long long
#define pb push_back
#define mp make_pair

ll ans;
int n,a,b;

int main(){
	cin>>n;
	for (int i=0;i<n;i++){
		cin>>a>>b;
		ans+=b-a+1;
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
L=[]
for i in range(n):
    L.append(list(map(int,input().split())))
sub=[]
for i in range(3):
    L_i=[]
    for j in range(n):
        L_i.append(sum(L[j])-L[j][i]*2)
    L_i.sort()
    sub.append(sum(L_i[n-m:]))
    sub.append(sum(L_i[:m])*(-1))
    
L_x=[]
for j in range(n):
    L_x.append(sum(L[j]))
L_x.sort()
sub.append(sum(L_x[n-m:]))
sub.append(sum(L_x[:m])*(-1))

print(max(sub))

Measured memory_bytes: 3700
import sys


def input():
    return sys.stdin.readline().strip()


def main():
    N, M = map(int, input().split())
    A = list(map(int, input().split()))
    answer = N - sum(A)
    if answer >= 0:
        print(answer)
    else:
        print(-1)


if __name__ == "__main__":
    main()


Measured memory_bytes: 10056
#include <iostream>

int main() {
    int n = 0;
    std::cin >> n;
    if (n <= 0) {
        return 1;
    }


    int d1, d2;
    int zoromeCount = 0;
    bool zorome3 = false;
    for (int i=0; i<n; ++i)
    {
        std::cin >> d1 >> d2;
        if (d1 == d2)
        {
            zoromeCount++;
            if (zoromeCount >= 3) {
                zorome3 = true;
            }
        }
        else
        {
            zoromeCount = 0;
        }
    }

    if (zorome3)
    {
        std::cout << "Yes" << std::endl;
    }
    else
    {
        std::cout << "No" << std::endl;
    }

    return 0;
}


Measured memory_bytes: 3620
N=int(input())
A=list(map(int,input().split()))
A.sort()
indexA=0
A.append(N+10)
for x in range(N):
  check=1
  countA=0
  while check==1:
    if A[indexA]!=x+1:
      check=0
      countA-=1
      indexA-=1
    indexA+=1
    countA+=1
  print(countA)

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

using namespace std;

#define PB push_back
#define f first
#define s second
#define what_is(x) cerr << #x << " is " << x << endl;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    int h, w, k;
    cin >> h >> w >> k;
    string grid[h];
    for(int i=0; i<h; i++)
    {
        cin >> grid[i];
    }
    int ans = 0;
    for(int i=0; i<(1<<h); i++)
    {
        for(int j=0; j<(1<<w); j++)
        {
            int t = 0;
            bool rseen[h], cseen[w];
            memset(rseen, false, sizeof(rseen));
            memset(cseen, false, sizeof(cseen));
            for(int k=0; k<h; k++)
            {
                if((1<<k)&i)
                {
                    rseen[k] = true;
                }
            }
            for(int k=0; k<w; k++)
            {
                if((1<<k)&j)
                {
                    cseen[k] = true;
                }
            }
            for(int i=0; i<h; i++)
            {
                for(int j=0; j<w; j++)
                {
                    if(rseen[i] || cseen[j])
                        continue;
                    t += (grid[i][j] == '#');
                }
            }
            ans += (t==k);
        }
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int a;
    string s;
    cin>>a;
    cin>>s;
    if(a>=3200)
      cout<<s<<endl;
    else
      cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 31;
// clang-format on

int N;

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

  int sum = 0;
  int n = N;
  while (n > 0) {
    sum += (n % 10);
    n /= 10;
  }

  cout << (N % sum == 0 ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 632
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        while(true) {
            int H = scanner.nextInt();
            int W = scanner.nextInt();

            if(H == 0 && W == 0) break;
            for(int h = 0; h < H; h++) {
                char c = (h % 2 == 0 ? '#' : '.');
                for(int w = 0; w < W; w++) {
                    System.out.print(c);
                    c = (c == '.' ? '#' : '.');
                }
                System.out.println("");
            }
            System.out.println("");
        }
    }
}


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

int main(){
    int h,w,m;    cin >> h >> w >> m;
    set<pair<int, int>>bom;
    vector<int>row(h);
    vector<int>col(w);
    int row_max = 0;
    int col_max = 0;
    rep(i, m){
        int h_i, w_i;   cin >> h_i >> w_i;
        h_i--;
        w_i--;
        bom.emplace(h_i, w_i);
        row_max = max(row_max, ++row[h_i]);
        col_max = max(col_max, ++col[w_i]);
    }
    vector<int>row_max_ptr;
    vector<int>col_max_ptr;
    rep(i, h)   if(row[i] == row_max)   row_max_ptr.push_back(i);
    rep(i, w)   if(col[i] == col_max)   col_max_ptr.push_back(i);
    for(int i : row_max_ptr)  for(int j : col_max_ptr){
        if(bom.count(pair<int, int>(i, j))) continue;
        cout << row_max + col_max << endl;
        return 0;
    }
    cout << row_max + col_max - 1<< endl;
    return 0;
}


Measured memory_bytes: 23760
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={0,1,0,-1,1,-1,-1,1};
int dy[]={1,0,-1,0,1,1,-1,-1};
const int MOD = 1e9+7;
const int INF = 1e18+10;

/*----------------------------------------------*/

signed main(){
  string s;
  cin>>s;
  int ans=0;
  int cnt=0;
  rep(i,s.size()){
    if(s[i]=='A'||s[i]=='T'||s[i]=='C'||s[i]=='G') cnt++;
    else {
      chmax(ans,cnt);
      cnt=0;
    }
  }
  chmax(ans,cnt);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
N=int(input())
AB=[list(map(int,input().split())) for _ in range(N)]

dist=[[0]*N for _ in range(N)]
ans=0
for i in range(N):
  for j in range(N):
    if i==j:
      continue
    ans+=((AB[i][0]-AB[j][0])**2+(AB[i][1]-AB[j][1])**2)**0.5
ans/=N
print(ans)

Measured memory_bytes: 3064
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    int n;
    while(cin>>n){
        if(n==0)break;
        queue<int> output;
        ll man[5000]={};
        rep(i,n){
            int a,b,c;
            cin>>a>>b>>c;
            if(man[a]==0){
                output.push(a);
            }
            if(man[a]<1000000){
                man[a]+=(ll)b*c;
            }
        }
//        while(output.size()){cout<<output.front();output.pop();}
        bool flag=true;
        while(output.size()){
            if(man[output.front()]>=1000000){
                cout<<output.front()<<endl;
                flag=false;
            }
            output.pop();
        }
        if(flag)cout<<"NA"<<endl;
    }
    
    return 0;
}

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

int main() {
    int n, q; cin >> n >> q;
    vector<vector<int>> A(n);
    
    for (int i = 0; i < q; ++i) {
        int command; cin >> command;
        
        int t;
        switch(command) {
            case 0:
                int x; cin >> t >> x;
                A[t].push_back(x);
                break;
                
            case 1:
                cin >> t;
                
                if (A[t].empty()) {
                    cout << endl;
                    break;
                }
                
                for (int i = 0; i < (int) A[t].size() - 1; ++i) cout << A[t][i] << " ";
                cout << A[t][A[t].size() - 1] << endl;
                break;
                
            case 2:
                cin >> t;
                if (!A[t].empty()) A[t].clear();
                break;
        }
    }
    
    return 0;
}


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

using namespace std;

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

const int N = 100005;

int n;

int main() {

	FAST;

	string s;
	cin >> s;
	int posa = 0, posb = 0;
	for (int i = 0; i < s.size(); i ++) {
		if (s[i] == 'A') {
			posa = i;
			break;
		}
	}	
	for (int i = s.size() - 1; i >= 0; i --) {
		if (s[i] == 'Z') {
			posb = i;
			break;
		}
	}
	cout << posb - posa + 1 << '\n';
	return 0;  
}

Measured memory_bytes: 720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
const int mod = 1000000007;

int main(){
  ll x;
  cin >> x;
  ll ans = 0;
  for(int i = 2; i <= 1000; ++i){
    ll num;
    for(int j = 2; ; ++j){
      num = pow(i, j);
      if(num > x) break;
      ans = max(num, ans);
    }
    
  }
  if(x == 1)  ans = 1;
  cout << ans << endl;
}


Measured memory_bytes: 512
import bisect

n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))
a.sort()
b.sort()
c.sort()
ans = 0
for i in b:
  smaller = bisect.bisect_left(a, i)
  bigger = n - bisect.bisect(c, i)
  ans += smaller * bigger
print(ans)

Measured memory_bytes: 23232
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  string s;
  cin >> s;

  int n = s.length();

  int ans = 0;
  for(int i = 0; i < n; i++){
    for(int j = i + 1; j <= n; j++){
      string t = s.substr(i, (j - i));
      bool found = false;
      for(char c: t){
        if(!(c == 'A' || c == 'C' || c == 'G' || c == 'T')){
          found = true;
          break;
        }
      }
      if(!found) ans = max(ans, (int)t.length());
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF 1000000000
#define pb push_back
#define EPS 1e-9
const int MOD = 1000000007; // 998244353
int tab[100001],n,dp[100001],k;
int solve(int idx){
    if(idx==(n-1))return 0;
    if(dp[idx]!=-1)
        return dp[idx];
    int ans=INF;
    for (int i = 1; i <= k; ++i)
        if((idx+i)<n)
            ans=min(ans,abs(tab[idx]-tab[idx+i])+solve(idx+i));
    return dp[idx]=ans;
}
int main(){
    boost;
    memset(dp,-1,sizeof dp);
    cin>>n>>k;
    for (int i = 0; i < n; ++i)
        cin>>tab[i];
    cout<<solve(0);
    return 0;
}
//long long
//array bounds
//special cases
//binary search

Measured memory_bytes: 5760
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

#define unordered_map __fast_unordered_map
template<class Key, class Value, class Hash = std::hash<Key>>
using unordered_map = __gnu_pbds::gp_hash_table<Key, Value, Hash>;

template<class C> void mini(C &a4, C b4) { a4 = min(a4, b4); }
template<class C> void maxi(C &a4, C b4) { a4 = max(a4, b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.st << "," << P.nd << ")";
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif


int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);

  int N, K;
  cin >> N >> K;
  vector<int> data(N);

  for (int &x : data) { cin >> x; }

  set<PII, greater<PII>> misses;
  int total_misses = 0;
  for (int i = 0; i < N; ++i) {
    int amount = K + 1 - data[i];
    misses.emplace(amount, i);
    if (data[i] <= K) {
      total_misses += amount;
    }
  }

  VI answer;
  int last_miss = -1;

  auto Add = [&](int next_miss) {
    debug("Add", next_miss);
    assert(last_miss != next_miss);
    if (last_miss != -1) { answer.PB(last_miss); }
    for (int i = 0; i < N; ++i) {
      if (i == last_miss || i == next_miss) { continue; }
      answer.PB(i);
    }
    last_miss = next_miss;
  };

  for (int i = 0; i < K + 1; ++i) {
    int which_found = -1;
    PII pair_found;
    for (auto x : misses) {
      if (x.nd == last_miss) { continue; }
      which_found = x.nd;
      pair_found = x;
      break;
    }

    misses.erase(pair_found);
    Add(which_found);
    misses.insert(PII{pair_found.st - 1, pair_found.nd});
  }

  answer.PB(last_miss);
  
  for (int v : answer) {
    --data[v];
    if (data[v] < 0) { cout << "-1\n"; return 0; }
  }

  cout << SZ(answer) << "\n";
  for (int v : answer) { cout << v + 1 << " "; }
  cout << "\n";

}



Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

ll gcd(ll x,ll y) { return y ? gcd(y,x%y) : x; }

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  ll n,k;
  cin>>n>>k;
  n = n%k;
  cout << min(n,k-n) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1000000 + 5;
const ll mod = 1000000007;

int main()
{
    int a[40] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int k;
    cin >> k;
    cout << a[k-1] << endl;
    return 0;
}

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

class Main{
    public static void main(String[] args){
        FastScanner fsc=new FastScanner();
        int n=fsc.nextInt(), k=fsc.nextInt();
        int[] cnt=new int[200000];
        for(int i=0;i<n;i++){
            int a=fsc.nextInt()-1;
            cnt[a]++;
        }
        fsc.close();
        revSort(cnt);
        int sum=0;
        for(int i=0;i<k;i++){
            sum+=cnt[i];
        }
        System.out.println(n-sum);
    }
    static void revSort(int[] a){
        Arrays.sort(a);
        int l=a.length;
        int tmp;
        for(int i=0;i<l/2;i++){
            tmp=a[i];
            a[i]=a[l-i-1];
            a[l-i-1]=tmp;
        }
    }
    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;
        private boolean hasNextByte(){
            if(ptr<buflen) return true;
            else{
                ptr = 0;
                try{
                    buflen = in.read(buffer);
                }
                catch(IOException e){
                    e.printStackTrace();
                }
                if(buflen<=0) return false;
            }
        return true;
        }
        private int readByte() { if (hasNextByte()) return buffer[ptr++]; else return -1;}
        private static boolean isPrintableChar(int c) { return 33 <= c && c <= 126;}
        public boolean hasNext() { while(hasNextByte() && !isPrintableChar(buffer[ptr])) ptr++; return hasNextByte();}
        public String next() {
            if (!hasNext()) throw new NoSuchElementException();
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while(isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }
        public long nextLong() {
            if (!hasNext()) throw new NoSuchElementException();
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) throw new NumberFormatException();
            while(true){
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                }
                else if(b == -1 || !isPrintableChar(b)) return minus ? -n : n;
                else throw new NumberFormatException();
                b = readByte();
            }
        }
        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
            return (int) nl;
        }
        public double nextDouble() { return Double.parseDouble(next());}
        public void close(){
            try{in.close();}
            catch(IOException e){e.printStackTrace();}
        }
    }
}


Measured memory_bytes: 25560
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 1000000007 // //100000000 998244353 //
#define inf 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

ll lx[4] = {0, 0, 1, -1};
ll ly[4] = {1, -1, 0, 0};
ll dx[8] = {0, 0, 1, -1, 1, -1, 1, -1};
ll dy[8] = {1, -1, 0, 0, 1, 1, -1, -1};
void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}
ll lcm(ll a, ll b) {return (a*b)/__gcd(a, b); }



void solve()
{
    ll s, c;
    cin >> s >> c;
    ll ans = min(s, c/2);
    s -= ans;
    c -= 2*ans; //cout << s << " " << c << endl;
    ans += c/4;
    cout << ans;

}

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif*/
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <stack>
#include <climits>
#include <map>
#include <set>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const ll mod = 1000000007;
const int inf = 1e9;
const long long INF = 1LL << 60;   // INFの値は1152921504606846976

struct UnionFind{
    vector<int> rank,p,size;
    UnionFind(int n){
        rank.resize(n,0);
        p.resize(n,0);
        size.resize(n,0);
        for(int i = 0; i < n; i++){
            p[i] = i;
            rank[i] = 0;
            size[i] = 1;
        }
    }
    bool same(int x,int y){
        return root(x) == root(y);
    }
    int root(int x){
        if(x != p[x]){
            p[x] = root(p[x]);
        }
        return p[x];
    }
    bool unite(int x,int y){
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return false;
        if(rank[rx] > rank[ry]){
            p[ry] = rx;
            size[rx] += size[ry];
        }else{
            p[rx] = ry;
            size[ry] += size[rx];
            if(rank[rx] == rank[ry]){
                rank[ry]++;
            }
        }
        return true;
    }
    int tree_size(int x){
        return (size[root(x)]);
    }
};



double pow (double a){
    return a * a;
}

int main()
{
    while(true){
        int n;cin >> n;
        if(n == 0) break;
        double x[n],y[n],z[n],r[n];
        for(int i = 0; i < n; i++){
            cin >> x[i] >> y[i] >> z[i] >> r[i];
        }
        vector<pair<double,pair<int,int> > > vec;
        UnionFind uf(n);
        for(int i = 0; i < n; i++){
            for(int j = i+1; j < n; j++){
                double d = pow(x[i]-x[j]) + pow(y[i]-y[j]) + pow(z[i]-z[j]);
                d = sqrt(d);
                if(d <= r[i] + r[j]){
                    uf.unite(i,j);
                }else{
                    vec.push_back(make_pair(d-r[i]-r[j],make_pair(i,j)));
                }
            }
        }
        double ans = 0;
        sort(vec.begin(),vec.end());
        for(auto edge : vec){
            if(!uf.same(edge.second.first,edge.second.second)){
                uf.unite(edge.second.first,edge.second.second);
                ans += edge.first;
            }
        }
        printf("%.3lf\n",ans);
    }
}


Measured memory_bytes: 3432
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int H, W;
	cin >> H >> W;

	vector<vector<Int>> C(10, vector<Int>(10, 0));
	for (Int i = 0; i < 10; i++) {
		for (Int j = 0; j < 10; j++) {
			cin >> C[i][j];
		}
	}

	for (Int k = 0; k < 10; k++) {
		for (Int i = 0; i < 10; i++) {
			for (Int j = 0; j < 10; j++) {
				C[i][j] = min(C[i][j], C[i][k] + C[k][j]);
			}
		}
	}

	Int ans = 0;
	Int tempa;
	for (Int i = 0; i < H; i++) {
		for (Int j = 0; j < W; j++) {
			cin >> tempa;
			if (tempa == -1)continue;
			else {
				ans += C[tempa][1];
			}
		}

	}
	cout << ans << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int strToInt(string a){
    int res = 0;
    REP(i,a.size()){
        res*=10;
        res += a[i]-'0';
    }
    return res;
}

bool isSquare(int n){
    for(int i=0;i*i<=n;++i){
        if(i*i==n){
            return true;
        }
    }
    return false;
}

int main(){
    string a,b;
    cin >> a >> b;
    string c = a+b;
    int n = strToInt(c);
    if(isSquare(n)){
        put("Yes");
    }else{
        put("No");
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>
#include <sstream>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) x.begin(),x.end()
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

int main(){
    ll N,rs = 0;
    long double D;
    cin >> N >> D;

    vector<ll> X(N),Y(N);

    for(ll i = 0;i < N;i++)
        cin >> X.at(i) >> Y.at(i);

    long double hako;
    for(ll i = 0;i < N;i++){
        hako = sqrt(X.at(i) * X.at(i) + Y.at(i) * Y.at(i));
        if(hako <= D)
            rs++;
    }

    cout << rs << endl;


}

Measured memory_bytes: 6504
import Control.Applicative
import Data.List (group, sort, delete, tails)

-- http://tsumuji.cocolog-nifty.com/tsumuji/2010/07/project-euler-h.html
-- より
{- 素数関連 -}

-- 素数列
-- http://d.hatena.ne.jp/notogawa/20110114/1295006865 を参考に
-- gcd の使い方が秀逸
primes :: Integral a => [a]
primes = map fromIntegral primes'
    where
      primes' = [2, 3, 5] ++ f 5 7 (drop 2 primes')
      f m s (p : ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
          where ns = [x + y | x <- [s, s + 6 .. p * p - 2], y <- [0, 4]]

-- 素数判定 --
isPrime :: Integral a => a -> Bool
isPrime n = (n > 1) && isPrime' primes
    where
      isPrime' (x : xs)
          | x * x > n    = True
          | rem n x == 0 = False
          | otherwise    = isPrime' xs

{- 素因数分解関連 -}

-- 素因数分解
factorize :: Integral a => a -> [(a, Int)]
factorize 1 = [(1, 0)]
factorize n = format $ factorize' n primes
    where
      format ps = [(x, length xs) | xs@(x : _) <- group ps]
      factorize' n ps@(p : ps')
          | p * p > n    = [n]
          | rem n p == 0 = p : factorize' (div n p) ps
          | otherwise    = factorize' n ps'

-- 約数
divisor :: Integral a => a -> [a]
divisor n = sort $ foldr distribute [1] ns
    where
      ns = [map (f^) [0 .. i] | (f, i) <- factorize n]
      distribute ns1 ns2 = [x * y | x <- ns1, y <- ns2]
      
digits :: Int -> Int
digits = length . show

f :: Int -> Int -> Int
f a b =
  if a < b
    then digits b
    else digits a

searcher :: Int -> [Int] -> Int
searcher n numList = minimum [f x (n `div` x) | x <- numList]

main = do
  n <- readLn
  let numList = divisor n 
  print $ searcher n numList

Measured memory_bytes: 1404
#include<bits/stdc++.h>
using namespace std;
long long ans;
const int mod = 1e9+7;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<long long> A(N);
    for (auto & a : A) cin >> a;

    vector<vector<int> > CS(N, vector<int>(60));
    for (int i = 0; i < N-1; ++i) {
        for(int j = 0; j < 60; ++j) {
            CS[i + 1][j] = CS[i][j];
            if (((A[i] >> j) & 1) == 1) CS[i + 1][j] += 1;
        }
    }
    for (int i = 1; i < N; ++i) {
        for(int j = 0; j < 60; ++j) {
            if (((A[i] >> j) & 1) == 1) ans += (1LL << j)%mod*(i-CS[i][j]);
            else ans += (1LL << j)%mod*CS[i][j];
            ans %= mod;
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 84608
#[allow(unused_imports)]
use std::cmp;

fn run() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let s = sc.read_chars();
    let t = sc.read_chars();

    let ans = s
        .into_iter()
        .zip(t.into_iter())
        .filter(|(s, t)| s != t)
        .count();
    println!("{}", ans);
}

fn main() {
    std::thread::Builder::new()
        .name("run".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(run)
        .unwrap()
        .join()
        .unwrap();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> IO<R, W> {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: std::ops::Deref<Target = str>>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn read_vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn read_pairs<T: std::str::FromStr>(&mut self, n: usize) -> Vec<(T, T)> {
        (0..n).map(|_| (self.read(), self.read())).collect()
    }
    pub fn read_pairs_1_indexed(&mut self, n: usize) -> Vec<(usize, usize)> {
        (0..n)
            .map(|_| (self.read::<usize>() - 1, self.read::<usize>() - 1))
            .collect()
    }
    pub fn read_chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
    pub fn read_char_grid(&mut self, n: usize) -> Vec<Vec<char>> {
        (0..n).map(|_| self.read_chars()).collect()
    }
    pub fn read_matrix<T: std::str::FromStr>(&mut self, n: usize, m: usize) -> Vec<Vec<T>> {
        (0..n)
            .map(|_| (0..m).map(|_| self.read()).collect())
            .collect()
    }
}


Measured memory_bytes: 2932
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int d = sc.nextInt();
		int x = sc.nextInt();
		for (int i = 0; i < 10; i++) {
			int result = r * x - d;
			System.out.println(result);
			x = result;
		}	
	}
}

Measured memory_bytes: 21588
#define DIN freopen("input.txt","r",stdin);
#define DOUT freopen("output.txt","w",stdout);
#include <iostream>
#include <cstdio>
#include <algorithm>
#define mem(a,b) memset(a,b,sizeof(a))
#define REP(i,a,b) for(int i=(a);i<=(int)(b);i++)
#define REP_(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
using namespace std;
typedef long long LL;
typedef vector<int> VI;
typedef pair<LL,LL> P;
int read()
{
    int x=0,flag=1; char c=getchar();
    while((c>'9' || c<'0') && c!='-') c=getchar();
    if(c=='-') flag=0,c=getchar();
    while(c<='9' && c>='0') {x=(x<<3)+(x<<1)+c-'0';c=getchar();}
    return flag?x:-x;
}

const int maxn=2e5+5;
LL K,n;
double a[maxn],eps=1e-6;

bool can(double len)
{
    LL tot=0;
    REP(i,1,n)
    {
        LL x=a[i]/len;
        if(fabs(a[i]-len*x)>eps) x++;
        tot+=x-1;
        if(tot>K) return 0;
    }
    return 1;
}

int main()
{
    n=read(),K=read();
    REP(i,1,n) a[i]=read();
    double l=1e-5,r=1e9,mid;
    while(l<r-0.000001)
    {
        mid=(l+r)/2;
        if(can(mid)) r=mid;
        else l=mid;
    }
    LL x=r+1;
    cout<<x;

    return 0;
}


Measured memory_bytes: 4680
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int a[n+1];
    int ans[n+1];
    int M=0;
    vector <int> v;
    for(int i=1;i<=n;i++){
        cin>>a[i];
    }
    for(int i=n;i>0;i--){
        int k=2*i;
        int s=0;
        while(k<=n){
            s=s+ans[k];
            k=k+i;
        }
        if(s%2==a[i]){ans[i]=0;}
        else{ans[i]=1;M++;v.push_back(i);}
    }
    cout<<M<<endl;
    for(int i=1;i<v.size();i++){
        cout<<v[i]<<' ';
    }
    if(!v.empty()){cout<<v[0]<<endl;}
    return 0;
}

Measured memory_bytes: 3064