akhauriyash/Code-Regression huggingface dataset:
#include"bits/stdc++.h"
using namespace std;

#define ll long long
#define INF INT_MAX/3
#define pi 2*acos(0.0)
#define eps 1e-14

const int MAX_N = (int)1e+3;
const int MAX_M = (int)1e+2;
const int MOD = 1e+9 + 7;
int N;
int ind[1001]; //約数の出現回数を記録する.
void input()
{
	cin >> N;
}

void divisor(int n) {
	vector<int> res;
	for (int i = 1; i*i <= n; i++) {
		if (n%i == 0) {
			res.push_back(i);
			ind[i]++;
			if (i != n / i) {
				res.push_back(n / i);
				ind[n / i]++;
			}
		}
	}
	return;
}
void prime_factor(int n) {
	map<int, int> res;
	for (int i = 2; i*i <= n; i++) {
		while (n%i == 0) {
			++res[i];
			n /= i;
			ind[i]++;
		}
	}
	if (n != 1) {
		res[n] = 1;
		ind[n]++;
	}
	return ;
}
int main() {
	input();
	ll ans = 1;
	for (int i = 2; i <= N; i++) {
		prime_factor(i);
	}
	for (int i = 2; i <= N; i++) {
		ans = (ans*(ind[i] + 1)) % MOD;
	}

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll t[200000] = {};
int main()
{
    ll n, T;
    cin >> n >> T;
    for (ll i = 0; i < n;i++)
    {
        cin >> t[i];
    }
    ll sum = 0;
    for (ll i = 0; i < n-1;i++)
    {
        sum += min(T, t[i + 1] - t[i]);
    }
    cout << sum+T;
}

Measured memory_bytes: 1792
n, Y = gets.split.map(&:to_i)

ret = "-1 -1 -1"
(0..n).each do |x|
  (0..n - x).each do |y|
    z = n - x - y
    next unless 10000 * x + 5000 * y + 1000 * z == Y

    ret = "#{x} #{y} #{z}"
    break
  end
end
puts ret


Measured memory_bytes: 1788
import sys
from collections import deque 

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

input()
a = deque()

while True:
	op = input().split()
	if not op:
		break
	if op[0] == 'insert':
		a.appendleft(int(op[1]))
	elif op[0] == 'delete':
		try:
			a.remove(int(op[1]))
		except:
			pass
	elif op[0] == 'deleteFirst':
		a.popleft()
	elif op[0] == 'deleteLast':
		a.pop()

while True:
	x = a.popleft()
	print(x, end="")
	if len(a)>0:
		print(" ", end="")
	else:
		print("")
		break



Measured memory_bytes: 45940
import java.text.NumberFormat;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {

    	Scanner parameter = new Scanner(System.in);

    	String[] line1 = parameter.nextLine().split(" ");
        String[] line2 = parameter.nextLine().split(" ");

        int[] intNumber = new int[line2.length];

        for (int i = 0; i < line2.length; i++) {

        	intNumber[i] = Integer.parseInt(line2[i]);
        }

        double sumNumber = 0;

        for (int nowNumber : intNumber) {

        	sumNumber = sumNumber + Double.valueOf(1) / nowNumber;
        }

        double lastNumber = Double.valueOf(1) / sumNumber;

        System.out.println(lastNumber);
    }
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  double W,H,x,y,A,sc;
  cin>>W>>H>>x>>y;
  sc=W*H/2;
  if(x==W/2 && y==H/2){
    A=1;
  }
  else{
    A=0;
  }
  cout<< sc <<" "<< A <<endl;
}

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

int w,h;
int g[100][100];

void dfs(int y, int x){
  g[y][x] = 0;

  for(int i=-1;i<=1;i++){
    for(int j=-1;j<=1;j++){
      if(y+i<0 || x+j<0 || y+i>=h || x+j>=w)continue;
      if(g[y+i][x+j])dfs(y+i,x+j);
    }
  }
}

int main(){
  while(cin >> w >> h, w){
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++)cin >> g[i][j];
    }

    int cnt = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(g[i][j])cnt++, dfs(i,j);
      }
    }
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1364
/****JMD****/
/*
Nagendra Jha-11011
acm18in1495
*/
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define ll long long int
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define f(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll(a.size())

using namespace std;

inline void display(vector<ll> v)
{
    for(auto x:v) cout<<x<<" ";
    cout<<"\n";
}

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

    ll n;
    cin>>n;

    bool flag=0;

    f(i,n)
    {
        ll x;
        cin>>x;

        if(x%2) flag=1;
    }

    if(flag) cout<<"first";
    else cout<<"second";
    return 0;
}


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


def main():
    """Function."""
    s = str(input())

    total = 0
    b_count = 0
    for i in range(len(s)):
        if s[i] == "B":
            b_count += 1
        if s[i] == "W":
            total += b_count

    print(total)


if __name__ == "__main__":
    main()


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

int main() {
  int N;
  cin >> N;
  int a;
  set<int> S;
  for (int i = 0; i < N; i++) {
    cin >> a;
    if (S.count(a)) {
      S.erase(a);
    } else {
      S.insert(a);
    }
  }
  cout << S.size() << endl;
}

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

int main(){
  int A,B; cin >> A >> B;
  
  int ans;
  if(A >= 13) ans = B;
  if(6 <= A && A <= 12) ans = B/2;
  if(A <= 5) ans = 0;
  cout << ans << endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[3][100000],f[3][100000];
int m;
int main(){
    cin>>m;
    for(int i=1;i<=2;i++)
		for(int j=1;j<=m;j++)
			cin>>a[i][j];
	f[1][1]=a[1][1];
	for(int i=1;i<=2;i++)
		for(int j=1;j<=m;j++)
			a[i][j]+=max(a[i-1][j],a[i][j-1]);
	cout<<a[2][m];
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define UM unordered_map
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    vi ABC;
    ABC.resize(3);
    cin >> ABC[0] >> ABC[1] >> ABC[2];
    vi A;
    vi B;
    REP(i, 3)
    {
        if (ABC[i] % 2 == 0)
            A.push_back(ABC[i]);
        else
            B.push_back(ABC[i]);
    }
    int ans = 0;
    if (A.size() == 2)
        swap(A, B);
    if (B.size() == 2)
    {
        B[0]++;
        B[1]++;
        ans++;
    }
    vi AB;
    REP(i, A.size())
    AB.push_back(A[i]);
    REP(i, B.size())
    AB.push_back(B[i]);

    sort(ALL(AB));
    ans += (AB[2] - AB[0]) / 2;
    ans += (AB[2] - AB[1]) / 2;
    cout << ans << endl;

    // system("pause");
}

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

using namespace std;

const int N=1e4;
int ans[N+1]={0};

void pre() {
	for(int i=1;i<=100;i++) {
		for(int j=1;j<=100;j++) {
			for(int k=1;k<=100;k++) {
				long long temp=i*i+j*j+k*k+i*j+j*k+i*k;
				if(temp<=N) {
					ans[temp]++;
	//				if(temp<=20) cout<<temp<<"		"<<i<<" "<<j<<" "<<k<<endl;
				}
			}
		}
	}
}

void solve() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++) {
		cout<<ans[i]<<endl;
	}
}

int main() {
//	freopen("input.txt","r",stdin);
	int t=1;
	pre();
	//cin>>t;
	while(t--) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 3672
/*
ID: alec3
LANG: C++14
PROG: highcard
*/


#include <bits/stdc++.h>

#define check(x) cout<<(#x)<<": "<<x<<" ";
#define io ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ss second
#define ff first
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define ld long double
#define all(c) (c).begin(), (c).end()
#define FOR(i, a, b) for (int i = a; i < b; i++)

typedef long long ll;
typedef unsigned long long ull;

using namespace std;

int pct(int x) { return __builtin_popcount(x); }

ll FIRSTTRUE(function<bool(ll)> f, ll lb, ll rb) {
	while(lb<rb) {
		ll mb=(lb+rb)/2;
		f(mb)?rb=mb:lb=mb+1;
	}
	return lb;
}


//ifstream fin("zerosum.in");
//ofstream fout("zerosum.out");
const int N=2e6+1;

int n, k;
ll a[N];
int main() {
    io;
    cin >> n >> k;
    ll l= 1, r;
    
    // read logs
    for (int i= l; i <= n; i++){
        cin >> a[i];
        // set r to be the longest log
        r = max(r, a[i]);
    }
    
    //binary search
    while (l != r){
        ll mid = (l + r) /2;
        ll s = 0;
        
        // loop through logs
        for (int i =1; i <= n; i++){
            // add half the lengths of each of the logs to s
            s += (a[i] -1) / mid;
        }
        // 
        if (s <= k) r = mid;
        else
            l = mid + 1;
    }
    cout << l << endl;
    return 0;
}


Measured memory_bytes: 5160
import sys
from bisect import *
from heapq import *
from collections import *
from itertools import *
from functools import *
from math import *
from fractions import *

sys.setrecursionlimit(100000000)
input = lambda: sys.stdin.readline().rstrip()

A, B, C = map(int, input().split())
print(min(C, B // A))


Measured memory_bytes: 65132
#include<stdio.h>
#define N 101
int main(){
  int a[N][N],v[N];
  int n,i,j,u,k;


  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      a[i][j]=0;
    }
  }
    
  for(i=1;i<=n;i++){
    scanf("%d %d",&u,&k);
    for(j=1;j<=k;j++){
      scanf("%d",&v[j]);
      a[u][v[j]]=1;
    }
  }

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      printf("%d",a[i][j]);
      if(j!=n)printf(" ");
    }
    printf("\n");
  }

  
  return 0;
}
       

Measured memory_bytes: 636
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0;i<(int)(n);i++)
using namespace std;
 
int main(){
    int a,b,c,d,e,i;
    cin>>a>>b>>c>>d>>e;

    if(a==0){
        cout<<1<<endl;
    }
    if(b==0){
        cout<<2<<endl;
    }
    if(c==0){
        cout<<3<<endl;
    }
    if(d==0){
        cout<<4<<endl;
    }
    if(e==0){
        cout<<5<<endl;
    }

}

Measured memory_bytes: 3624
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val n = sc.nextInt()
    val s = sc.next()
    val t = sc.next()
    var ans = ""
    for (index in 0 until n) {
        ans += s[index]
        ans += t[index]
    }
    println(ans)
}

Measured memory_bytes: 31268
import java.util.Scanner;

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

		String s = sc.next();
		int n = 0;
		for(int i = 0; i < s.length(); i++) {
			if(s.charAt(i) == '+') {
				n++;
			} else {
				n--;
			}
		}
		System.out.println(n);
	}
}

Measured memory_bytes: 21588
/*
 *  Author : Jun_SH
 *  12/11/2019
 */
#include<bits/stdc++.h>
#pragma GCC optimize(3,"Ofast","inline")
#define int long long
using namespace std;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'&&ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin>>n;
    cout<<(n-1)/2<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	cin>>n>>k;
	bool p[n+5]={0};
	for(int i=1;i<=k;i++){
	    int x;
	    cin>>x;
	    for(int j=1;j<=x;j++){
	        int w;
	        cin>>w;
	        p[w]=1;
	    }
	}
	int ans=0;
	for(int i=1;i<=n;i++){
	    if(!p[i])ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 3520
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>

#define PI acos(-1)

using namespace std;

typedef struct Point{
  double x, y;
} P;

int n;

void koch(int cnt, P p1, P p2){
  P s, t, u;

  if(cnt == n) return ;

  s.x = (2 * p1.x + p2.x) / 3;
  s.y = (2 * p1.y + p2.y) / 3;
  t.x = (p1.x + 2 * p2.x) / 3;
  t.y = (p1.y + 2 * p2.y) / 3;
  u.x = (t.x - s.x) * cos(PI / 3) - (t.y - s.y) * sin(PI / 3) + s.x;
  u.y = (t.x - s.x) * sin(PI / 3) + (t.y - s.y) * cos(PI / 3) + s.y;

  koch(cnt + 1, p1, s);
  printf("%.8f %.8f\n", s.x, s.y);
  koch(cnt + 1, s, u);
  printf("%.8f %.8f\n", u.x, u.y);
  koch(cnt + 1, u, t);
  printf("%.8f %.8f\n", t.x, t.y);
  koch(cnt + 1, t, p2);
}

int main(){

  P l, r;

  l.x = 0.0;
  l.y = 0.0;
  r.x = 100.0;
  r.y = 0.0;

  cin >> n;

  printf("%.8f %.8f\n", l.x, l.y);
  koch(0, l, r);
  printf("%.8f %.8f\n", r.x, r.y);

  return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define M 1000000007
#define N 100001
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

int t, n;
void printArray(int*, int);

int main() {
    string s;   cin>>s;
    if(s[s.length() - 1] == 's') cout<<s + "es\n";
    else cout<<s + "s\n";
	return 0;
}

void printArray(int *nums, int n) {
    for(int i=0; i<n; i++) printf("%d ", nums[i]);
    printf("\n");
}

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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define repr(i,a,b) for(int i=(int)(a-1);i>=b;i--)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout << #x" = " << x << endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

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

#define INF INT_MAX/3

int main(){
    cin.sync_with_stdio(false);
    int n;
    cin >> n;
    int a[n];
    rep(i, n) cin >> a[i];
    int cnt = 0;
    rep(i, n) {
        if (a[i] == i + 1) {
            if (i < n - 1 && a[i] != i + 2) swap(a[i], a[i + 1]);
            else if (i > 0 && a[i] != i) swap(a[i], a[i - 1]);
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 640
import itertools
n=int(input())

x,y=[],[]
for _ in range(n):
    a,b=map(int,input().split())
    x.append(a)
    y.append(b)

l=list(itertools.permutations(range(n)))

a=0
for p in l:
    for j in range(0,n-1):
        a+=((x[p[j]]-x[p[j+1]])**2+(y[p[j]]-y[p[j+1]])**2)**0.5
print(a/len(l))

Measured memory_bytes: 8052
#include<stdio.h>
int main()
{
  double x[2],y[2];
  int i,j;
  double r;
  double n=0;
  double dis2=0;
  scanf("%lf%lf%lf%lf",&x[0],&y[0],&x[1],&y[1]);
  dis2=(x[1]-x[0])*(x[1]-x[0])+(y[1]-y[0])*(y[1]-y[0]);
  for(i=0;i<9;i++)
    {
      r=1;
      for(j=0;j<i;j++) r/=10.0;
      while(1)
	{
	 
	  if((n+r)*(n+r)>=dis2) break;
	  else n+=r;
	}
    }
  printf("%10.8f\n",n);
  return 0;
}

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

// 同じ方向を向いて連続するx人のうち、x-1人が幸福である
// パターンA：端を含まない連続するx人を操作すると、幸福な人は2人増える（x-1 -> x+1）
// パターンB：端を含む連続するx人を操作すると、幸福な人は1人増える（x-1 -> x）
// ⇒ 幸福な人数を最大にしたいので、まずAの場合を可能な限り行い、次にBの場合を行う
int main() {
  size_t N = 0;  // 人数
  size_t K = 0;  // 操作回数の上限
  std::cin >> N >> K;

  std::vector<char> S(N);
  for (size_t i = 0; i < N; ++i) {
    std::cin >> S[i];
  }

  // 初期状態を調べる
  size_t pair_count = 0;  // LとRの連続部分のペアの個数
  size_t happiness = 0;  // 幸福度
  auto head_iter = S.cbegin();  // 連続部分の先頭のイテレータ
  for (auto iter = ++S.cbegin(); iter != S.cend(); ++iter) {
    if (*iter != *head_iter) {
      if (*head_iter != S.front()) pair_count++;
      happiness += (iter - head_iter) - 1;
      head_iter = iter;
    }
  }
  if (*head_iter != S.front()) pair_count++;
  happiness += (S.cend() - head_iter) - 1;

  if (S.front() == S.back()) {
    // 端を含む連続部分が同じ方向を向いている場合、
    // すべての連続部分をその向きに揃えるように可能な限り操作を行う
    const size_t a = 2 * std::min(pair_count, K);  // パターンA
    happiness += a;
  } else {
    // 端を含む連続部分が異なる方向を向いている場合、
    // どちらかの向きに揃えるように可能な限り操作を行う
    const size_t n = pair_count - 1;
    const size_t a = 2 * std::min(n, K);  // パターンA
    const size_t b = n < K ? 1 : 0;  // パターンB（操作回数が余る場合のみ）
    happiness += a + b;
  }

  // 結果発表
  std::cout << happiness;

  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(void)
{
   int n,w;
   cin>>n>>w;
   int val[n+1];int wg[n+1];
   for(int  i =1 ;i<=n;i++)
   {
      cin>>wg[i]>>val[i];
   }
   val[0] = 0;
   wg[0] = 0;
   int dp[n+1][w+1];
   for(int  i = 0;i<=n;i++)
   {
      for(int j = 0;j<=w;j++)
      {
         if(j == 0 || i == 0){
          dp[i][j] = 0;
          continue; 
         }
         
         dp[i][j] = dp[i-1][j];  
         if(j-wg[i]>=0)
         dp[i][j]  = max(dp[i][j],(dp[i-1][(j-wg[i])]+val[i]));

      }
   }

   cout<<dp[n][w]<<endl;

}

Measured memory_bytes: 79104
#!/usr/bin/env python3
import sys
from collections import defaultdict

def main():
    N = int(input())
    S = defaultdict(int)
    for _ in range(N):
        S[input()] += 1
    S = sorted(S.items(), key=lambda x:x[1])

    ans = []
    cnt = S[-1][1]
    for i in range(len(S)-1, -1, -1):
        if cnt == S[i][1]:
            ans.append(S[i][0])
        else:
            break

    ans.sort()
    for x in ans:
        print(x)

if __name__ == "__main__":
    main()

Measured memory_bytes: 43484
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}
const int NM = 1e5+10;
const int MOD = 1e9+7;
int dp[NM][13]; // dp[i][j] : i桁目までで、13で割ってあまりがjになる数の個数

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s; cin>>s;
    int n = s.size();
    reverse(s.begin(), s.end());
    if(s[0]=='?'){
        rep(i, 10) dp[0][i]=1;
    } else {
        int idx = s[0]-'0';
        dp[0][idx]=1;
    }
    int digit = 1;
    for(int i=1; i<n; i++){
        digit *= 10;
        digit %= 13;
        if(s[i]=='?'){
            for(int j=0; j<10; j++){ // ?の候補
                for(int k=0; k<13; k++) { // 前桁でのあまり
                    int idx = (k+j*digit) % 13;
                    dp[i][idx]+=dp[i-1][k];
                    dp[i][idx]%=MOD;
                }
            }
        }else{
            for(int k=0; k<13; k++){ // 前桁でのあまり
                int j = (s[i]-'0');
                int idx = (k+j*digit)%13;
                dp[i][idx] += dp[i-1][k];
                dp[i][idx] %= MOD;
            }
        }
    }
    cout << dp[n-1][5]<<endl;
}

Measured memory_bytes: 5584
#include<vector>
#include<string>
#include<algorithm>
#include <iostream>
#include<cmath>
using namespace std;

int main() {

	int N, T;
	double A;
	int bestp = -1;
	double bestt = 4000000;

	cin >> N;

	cin >> T >> A;



	for (int i = 0; i < N; i++) {
		//cin >> Hs[i];
		int s;
		cin >> s;
		if (bestt >= std::abs(((T - s * 0.006) - A))) {
			bestp = i;
			bestt = std::abs((T - s * 0.006) - A);
		}
		if (bestt == 0) {
			cout << bestp + 1 << endl;
			return 0;
		}

	}


	cout << bestp + 1 << endl;


	return 0;

}

Measured memory_bytes: 256
tailrec fun gcd(a: Int, b: Int): Int = if (b == 0) a else gcd(b, a % b)

fun main(args: Array<String>) {
    val k = readLine()!!.toInt()
    (1..k).sumBy { a ->
        (1..k).sumBy { b ->
            (1..k).sumBy { c ->
                gcd(gcd(a,b),c)
            }
        }
    }.let { println(it) }
}


Measured memory_bytes: 36496
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i, n) FOR(i, 0, (n))
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define LAR(a, b) ((a)=max((a),(b)))
#define SML(a, b) ((a)=min((a),(b)))
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define ALL(a) (a).begin(), (a).end()
#ifdef LOCAL_DEBUG
#define DEBUG(...) printf(__VA_ARGS__)
#else
#define DEBUG(...)
#endif
template<typename T>
using pque = priority_queue<T, vector<T>, greater<T>>;

int n;
#define N 112345
vector<pii> v;
int memo[N];
int dp(int a){
	int &ret = memo[a];
	if(~ret) return ret;
	if(a == n) return ret = 0;
	ret = 1 + dp(a+1);
	int b = lower_bound(ALL(v), MP(v[a].second, INT_MIN)) - v.begin();
	SML(ret, (b - a - 1) + dp(b));
	DEBUG("dp(%d) = %d (b=%d)\n", a, ret, b);
	return ret;
}

int main(){
	scanf("%d", &n);
	REP(i, n){
		int p, q; scanf("%d%d", &p, &q);
		v.EB(p-q, p+q);
	}
	sort(ALL(v));
	REP(i, N) memo[i] = -1;
	printf("%d\n", n-dp(0));
}


Measured memory_bytes: 4724
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n;
	cin >> n;
	set<string> s;
	while(n--) {
		string str;
		cin >> str;
		s.insert(str);
	}
	cout << (int)s.size() << endl;
	return 0;
}

Measured memory_bytes: 19168
#include<bits/stdc++.h>
using namespace std;
#pragma comment(linker, "/STACK:102400000,102400000")
#define rep(i,a,b) for (int i=a;i<=b;i++)
#define per(i,b,a) for (int i=b;i>=a;i--)
#define mes(a,b)  memset(a,b,sizeof(a))
#define INF 0x3f3f3f3f
typedef long long ll;
const int N = 200005;

int n, m, d[N], ans, path[N], mx=INF, mi;
bool vis[N], flag=0;
vector<int > G[N];
void dfs(int u, int fa)
{
    vis[u]=1;
    bool flag1=0;
    for(auto v : G[u]) if(vis[v]==0) {
        flag1=1;
        dfs(v, u);
        if(flag==1) break;
    }
    if(flag1==0) {
        bool flag2=0;
        for(auto v : G[mi]) if(vis[v]==0) flag2=1;
        if(flag2==0) flag=1;
    }
    if(flag==1) path[++ans]=u;
}
int main()
{
    scanf("%d %d", &n, &m);
    int u, v;
    rep(i,1,m) {
        scanf("%d %d", &u, &v);
        G[u].push_back(v);  G[v].push_back(u);
        d[u]++, d[v]++;
    }
    rep(i,1,n) mx=min(mx, d[i]);
    rep(i,1,n) if(mx==d[i]) {
        mi=i;
        dfs(i, i);
        if(flag==1) break;
    }
    printf("%d\n", ans);
    per(i,ans,1) printf("%d ", path[i]);

    return 0;
}


Measured memory_bytes: 13184
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(),(x).end())
#define ALL(x) (x).begin(),(x).end()
#define rep(i, n) for(int i = 0; i < n; i++)
#define reps(i, m, n) for(int i = m; i < n; i++)
#define repr(i, m, n) for(int i = m; i >= n; i--)
template<class T>bool maxi(T &a,const T &b){if(a<b){ a=b; return 1;} return 0;}
template<class T>bool mini(T &a,const T &b){if(b<a){ a=b; return 1;} return 0;}
#define y0 y3487465 //j0
#define y1 y1347829 //j1
#define INF2 4000000000000000037
#define INF 1000000007
#define PI (acos(-1))
#define MOD 1000000007
using namespace std;
typedef long long ll;

void Main(){
  int N;
  cin>>N;
  vector<int> a,b;
  rep(i,N){
    int aa;cin>>aa;
    a.emplace_back(aa);
  }

  rep(i,N){
    int aa;cin>>aa;
    b.emplace_back(aa);
  }

  int ans=0;

  rep(k,29){
    ll t= 1<<(k);
    vector<ll> ax,bx;
    rep(i,N){ // a+bがt<= <2t, 3t<= <4t
      ax.emplace_back(a[i]%(2*t));
      bx.emplace_back(b[i]%(2*t));
    }

    SORT(bx);

    ll buff=0;

    rep(i,N){
      ll A=ax[i];
      // cout<< "A="<<A<<"\n";
      //cout<<lower_bound(bx.begin(),bx.end(),2*t-A)-lower_bound(bx.begin(),bx.end(),t-A) <<" "<<lower_bound(bx.begin(),bx.end(),4*t-A)-lower_bound(bx.begin(),bx.end(),3*t-A) <<"\n";
      buff+=(lower_bound(bx.begin(),bx.end(),2*t-A)-lower_bound(bx.begin(),bx.end(),t-A))+(lower_bound(bx.begin(),bx.end(),4*t-A)-lower_bound(bx.begin(),bx.end(),3*t-A));
    }
    //cout<< "buff="<<buff<<"\n";
    ans+=(buff%2)*(1<<k);
  }

  cout<< ans<<"\n";

}

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


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

int main() {
    int N,mx=0,mn=1000,a;
    cin >> N;

    rep(i,N) {
        cin >> a;
        mx = max(mx,a);
        mn = min(mn,a);
    }

    cout << mx-mn << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long
#define ull unsigned long long
#define ar array
 
int main() {
    ios::sync_with_stdio(0); cin.tie(0);
 
    int d = 101, n, x, ans = -1;
    vector<bool> has(101, false);
    cin >> x >> n;
    for (int i = 0, p; i < n; i++) {
        cin >> p;
        has[p] = true;
    }
    for (int i = 0; i <= 200; i++) {
        if (!has[i] && abs(x - i) < d) {
            d = abs(x - i);
            ans = i;
        }
    }
    cout << ans << '\n';
}

Measured memory_bytes: 3652
import java.util.Scanner;

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

            int a = sc.nextInt();
            int b = sc.nextInt();

            int d = a / b;
            int r = a % b;
            double f = 1.0 * a / b;

            System.out.println(d + " " + r + " " + String.format("%.5f", f));

    }
}


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

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

Measured memory_bytes: 3612
import java.util.Scanner;

 class Main
 {
     static int Search(int[]s, int key,int n)
     {
         for(int i = 0; i < n; i++)
             {
                 if(s[i] == key)
                     return 1;
             }
         return 0;

     }

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

         int n = In.nextInt();
         int []S = new int[n];

         for(int i = 0; i < n; i++)
             {
                 S[i] = In.nextInt();
             }

         int q = In.nextInt();
         int []T = new int[q];

         for(int i = 0; i < q; i++)
             {
                 T[i] = In.nextInt();
             }
         int count = 0;


         for(int i = 0; i < q; i++)
             {
                 count += Search(S,T[i],n);
             }
         System.out.println(count);
     }
 }

Measured memory_bytes: 40188
#include <bits/stdc++.h>
using namespace std;
int main(){
    long long X;cin>>X;
    long long P=100;
    long long ans=0;
    for (int i = 0; i < 1e18; i++)
    {
        P+=P/100;
        ans=i+1;
        if(P>=X)break;
    }
    cout<<ans<<endl;
}

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

  int main(){
    int n;
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4]==s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;   
    return 0;
  }


Measured memory_bytes: 256
a,b = gets.split(/\s/).map {|s|s.to_i}

if(a > 0)then
  puts "Positive"
elsif(a == 0 || b == 0)then
  puts "Zero"
else
  if(b > 0)then
    puts "Zero"
  elsif(a%2 == 0 && b%2 != 0 ||
        a%2 != 0 && b%2 == 0)then
    puts "Positive"
  else
    puts "Negative"
  end
end


Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for (int i=x;i<=y;i++)
 
long long C[100][100];
int n,a,b;
long long f[100];
int cmp(long long  a,long long  b)
{
	return a>b;
}
int main()
{
	C[0][0]=1;
	rep(i,1,50) rep(j,0,i) C[i][j]=C[i-1][j-1]+C[i-1][j];
	scanf("%d%d%d",&n,&a,&b);
	rep(i,1,n) cin>>f[i];
	sort(f+1,f+n+1,cmp);
	long long ans=0;
	rep(i,1,a) ans+=f[i];
	long double pp=ans;
	pp/=a;
	printf("%.8Lf\n",pp);
	int x=0,y=0;
	rep(i,1,n) if (f[i]==f[a]) y++;
	rep(i,1,a) if (f[i]==f[a]) x++;	
	ans=0;
	if (x!=a) ans+=C[y][x]; else rep(i,x,b) ans+=C[y][i];
	cout<<ans<<endl;
}

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

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;
}
ll func2(ll n){
  ll res = 0;
  while(n%2 == 0){
    n /= 2;
    res++;
  }
  return res;
}

ll zyou(ll a,ll b){//a＾b
  ll res = 1;
  for(int i = 1;i<=b;i++){
    res *= a;
  }
  return res;
}
struct Edge{
  int to;
  int weight;
  Edge(int t, int w) : to(t),weight(w){ }
};

typedef pair<int,int> P;
using Graph = vector<vector<Edge>>;

ll calc(ll a, ll b, ll p){//aのb乗をpで割った余り
  if(b == 0) return 1;

  else if(b%2 == 0){
    ll d = calc(a,b/2,p);
    return (d*d)%p;
  }
  else if(b%2 == 1){
    return (a * calc(a,b-1,p))%p;
  }
}



bool is_prime(int n){//nが素数であるかどうか判定 iで割り切れると素数でない
    if(n == 1) return false;//1は例外
    for(int i = 2;i*i <= n;i++){
        if(n%i == 0) return false;
    }
    
    return true;
}
int dfs(int x,int y,int H,int W,vector<vector<char>> &masu){
  if(masu[x][y] == '#'){

  }
}
bool palin(string S){
  int n = S.size();
  bool flag = true;
  if(n%2 == 0){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  else if(n%2 == 1){
    for(int i = 0;i<=n/2-1;i++){
      if(S[i] != S[n-i-1]){
        flag = false;
        break;
      }
    }
  }
  return flag;
}
int main(){
  string S;
  cin >> S;
  int m = 0;
  int N = S.size();
  rep(i,N){
    if(S[i] == '0') m++;//0の個数
  }
  int ans = 1000000;
  //cout << m << endl;
  ans = min(m,N-m) * 2;
  cout << ans << endl;

}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef long long int ll;
#define ll long long
#define dd double
#define MOD 1000000007
#define nl cout<<endl
#define rt ll Q[100005]={0}
#define mp make_pair
#define test() ull t;cin>>t;while(t--)
#define pb push_back
#define ff first    
#define ss second
#define all(v) v.begin(),v.end()
#define s(ar,n) sort(ar,ar+n)
#define rs(ar,n) sort(ar, ar+n, greater<ll>()) 
#define oa(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define cn(a,n) for(ll i=0;i<n;i++)cin>>a[i];
#define ov(a,n) for(ll i=0;i<n;i++)cout<<a[i]<<" ";nl
#define ovp(a,n) for(ll i=0;i<n;i++)cout<<a[i].ff<<" "<<a[i].ss<<endl;
#define maxa(ar,N) *max_element(ar,ar+N)
#define mina(ar,N) *min_element(ar,ar+N)
#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
typedef pair<int,int> pii;
ll powe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);if(m%2==0)return (t*t);return (((t*t))*n);}
ll mpowe(ll n,ll m){if(m==0)return 1;ll t=powe(n,m/2);t%=MOD;if(m%2==0)return (t*t)%MOD;return (((t*t)%MOD)*n)%MOD;}
ll logtwo(ll n){if(n==1)return 0;return logtwo(n/2)+1;}

int main()
{
    fastio();
    ll h,c,k,sum=0;
    cin >> h  >> k;
    ll a[h];
    for(c=0;c<h;c++)
    {
        cin >> a[c];
    }
    sort(a,a+h);
    if(k>=h)
    {
        cout << 0 << endl;
    }
    else
    {
    for(c=0;c<(h-k);c++)
        sum=sum+a[c];
    cout << sum << endl;
    }
    
}

Measured memory_bytes: 1792
#include <algorithm>
#include <assert.h>
#include <bitset>
#include <cfloat>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits.h>
#include <list>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <time.h>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define rep(i,n) for(int i = 0;i < n; i++)
#define REP(i,n) for(int i = 1;i <= n; i++)
// ----GCC ONLY---- //
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
// ----        ---- //
#define ll long long
#define PB push_back
#define MOD 10000007
#define PI 3.14159265359

using namespace std;

int main(){

    int n;
    cin >> n;

    cout << n*n*n << "\n";

}

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

    int d[10]{};

    int main()
    {
        ll n{},k{};
        cin>>n>>k;
        for(ll i=0;i<k;i++){
            int t{};
            cin>>t;
            d[t] = 1;
        }
        for(ll i=n;i<1000005;i++){
            string s = to_string(i);
            for(ll j=0;j<s.size();j++){
                if(d[ s[j] - '0']){
                    goto j;
                }
            }
            cout<<i;
            break;
            j:;
        }

        return 0;
    }

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

public class Main {

	private static int[] DP = new int[10010];

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int H = sc.nextInt();
		int N = sc.nextInt();
		int[] A = new int[N];
		int[] B = new int[N];
		for(int i = 0;i < N;i++){
			A[i] = sc.nextInt();
			B[i] = sc.nextInt();
		}
		sc.close();

		Arrays.fill(DP, 0);
		for(int i = 0;i < H;i++){
			for(int j = 0;j < N;j++){
				int cnt = 0;
				cnt = (i - A[j] < 0) ? B[j] : B[j]+DP[i-A[j]];
				if(cnt < DP[i] || DP[i]==0){
					DP[i] = cnt;
				}
			}
		}
		System.out.println(DP[H-1]);
	}
}

Measured memory_bytes: 25940
//Coded by Abhijay Mitra
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cstdio>
#include <numeric>
#include <cstring>
#include <numeric>
#include <vector>
#include <iterator> 
#include <map>
#include <set>
#include <climits>
#include <queue>
#include <cmath>
#include <stack>
#include <cctype>
#include <bitset>
// #include <bits/stdc++.h>
#define double long double
#define int long long int
#define ll int
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define bp __builtin_popcount
#define pb push_back
#define koto_memory(a) cout<<(sizeof(a)/1048576.0)<<" MB";
#define res(v) v.resize(unique(v.begin(), v.end()) - v.begin());
#define cnt_res(v) std::distance(v.begin(),std::unique(v.begin(), v.end())); 
#define timer cerr << "Time elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
using vi = std::vector<int>;
using vvi = std::vector<vi>;
using pii = std::pair<int,int>;
using vpii = std::vector<pii>;
using vvpii = std::vector<vpii>;
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define per(i,b,a) for (int i = b; i >= a; i--)
#define all(x)     x.begin(), x.end()
using namespace std;
const int N=2e6+10;
const int inf = /*0x3f3f3f3f*/1e18+10;
// const ll M = 998244353 ; // Mulo
// const int M = 1e9+7 ; // Mulo
const double Pi = 3.14159265;
#define F first
#define S second
int n,l[N],k[N],r[N],ans;vpii f,b;

void Solve(vector<pair<int, int>>& cams)
{
    priority_queue<int> pq;
    // int result = 0;
    int initalAns = ans;

    for(auto i : cams)
    {
        pq.push(-i.second);
        ans+=i.second;
        //we assume its left is best
        while(pq.size()>i.first)ans+=pq.top(),pq.pop();
    }

}

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

    int testcases;
    cin >> testcases;
    while(testcases--)
    {

        cin>>n;ans=0;f.clear(),b.clear();
    rep(i,1,n)cin>>k[i]>>l[i]>>r[i];
    rep(i,1,n){
        if(l[i]>r[i]){
            ans+=r[i];
            f.pb({k[i],l[i]-r[i]});
        }
        else{
            ans+=l[i];
            b.pb({n-k[i],r[i]-l[i]});
        }
    }
    sort(all(f)),sort(all(b));

    Solve(f);
    Solve(b);

        std::cout << ans << "\n";

    }

    return 0;
}


Measured memory_bytes: 12904
n = int(input())
ba = []

for i in range(n):
    a, b = map(int, input().split())
    ba.append([b, a])

ba.sort()

tm = 0
flg = True
for b, a in ba:
    if tm + a <= b:
        tm += a
    else:
        flg = False

print('Yes' if flg else 'No')


Measured memory_bytes: 38076
# -*- coding: utf-8 -*-
"""
A - キャンディーと2人の子供 / Fighting over Candies
https://atcoder.jp/contests/abc047/tasks/abc047_a

"""
import sys


def solve(a, b, c):
    candies = sorted([a, b, c])
    if candies[0] + candies[1] == candies[2]:
        return 'Yes'
    return 'No'


def main(args):
    a, b, c = map(int, input().split())
    ans = solve(a, b, c)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


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

#define ll long long
#define db double
#define pb push_back
#define ppb pop_back
#define F first
#define S second
#define mp make_pair
#define all(x) (x).begin(), (x).end()

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;



int main() {
	ios_base::sync_with_stdio(false), cin.tie(NULL);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	
	int n;
	cin >> n;
	ll ans = 0;
	for (int i = 1; i <= n; i++) {
		if (i % 3 && i % 5) {
			ans += i;
		}
	}
	cout << ans;
}


Measured memory_bytes: 3656
#include <stdio.h>          // printf(), scanf()
#include <stdbool.h>

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

long
gcd(long a, long b)
{
	if (b == 0)
		return a;

	return gcd(b, a % b);
}

long
lcm(long a, long b)
{
	return (a * b / gcd(max(a, b), min(a, b)));
}

int
main(int argc, char **argv)
{
	while (true)
	{
		int a1, a2, a3;
		int m1, m2, m3;
		int x, y, z;
		long c1, c2, c3;

		scanf("%d %d %d %d %d %d", &a1, &m1, &a2, &m2, &a3, &m3);

		if (a1 == 0 && m1 == 0 && a2 == 0 && m2 == 0 && a3 == 0 && m3 == 0)
			break;

		x = 1;
		c1 = 0;
		do
		{
			x = a1 * x % m1;
			c1++;
		} while (x != 1);

		y = 1;
		c2 = 0;
		do
		{
			y = a2 * y % m2;
			c2++;
		} while (y != 1);

		z = 1;
		c3 = 0;
		do
		{
			z = a3 * z % m3;
			c3++;
		} while (z != 1);

		printf("%ld\n", lcm(lcm(c1, c2), c3));
	}

	return 0;
}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
  int n = 0;
  int ichi,ju,hyaku;
  scanf("%d",&n);
  ichi = n % 10;
  hyaku = n / 100;
  ju = (n - hyaku*100 - ichi) / 10;
  if(ichi==7||hyaku==7||ju==7)
    printf("Yes");
  else
    printf("No");
  return 0;
}
  

Measured memory_bytes: 1728
#include <stdio.h>

long retans(long a, long b, long c){
	if(a + b + 1 >= c)	return b + c;
	else return b + (a + b + 1);
}

int main(int argc, char const *argv[]){
	long a,b,c;
	scanf("%ld %ld %ld",&a,&b,&c);
	printf("%ld\n", retans(a,b,c));
	return 0;
}


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

int main(){
	int H, W;
	int a = 1;
	while (a == 1) {
		cin >> H >> W;
		if (!(H == 0 && W == 0)) {
			for (int i = 1; i <= H; i++) {
				for (int j = 1; j <= W; j++) {
					cout << "#" << flush;
				}
				cout << endl;
			}
			cout << endl;
		}
		else if (H == 0 && W == 0) {
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 3048
#include <bits/stdc++.h>
#define fim '\n'
using namespace std;

double vet[3000], dp[3000][3000];

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

    for(int i = 0; i <= n; i++){
        if(2*(n-i) < n) continue;
        dp[0][i] = 1;
    }

    for(int i = 1; i <= n; i++)
        for(int j = 1; j <= n; j++) {
            if( 2*(n-i+j) < n) continue;
            dp[i][j] = dp[i-1][j]*(1-vet[i]) + dp[i-1][j-1]*vet[i];
        }
    cout << fixed << setprecision(15) << dp[n][n] << fim;
}


Measured memory_bytes: 70400
require 'set'

class Hash
  def push(key, value)
    self[key] = [] if self[key] == nil
    self[key].push(value)
  end
end

class Array
  def lower_bound(value)
    left = -1;
    right = self.length;
    while left + 1 < right
      mid = left + (right - left) / 2;
      if self[mid] >= value
        right = mid
      else
        left = mid
      end
    end
    right
  end

  def unique
    res = [self.first]
    each_cons(2) do |a, b|
      if a != b
        res.push(b)
      end
    end
    res
  end
end

def get_ints
  gets.split.map(&:to_i)
end

def get_ints_minus_one
  get_ints.map { |x| x - 1 }
end

def get_int
  gets.chomp.to_i
end

N, M = get_ints
A = get_ints

sum = A.sum

threshold = sum / (4.0 * M)

count = A.count do |a|
  a >= threshold
end


puts count >= M ? 'Yes' : 'No'


Measured memory_bytes: 14428
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
const int INF = 2000000000;
using namespace std;

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

    int i = 1;
    while(true){
        if(i + i * i >= x * 2){
            cout << i << endl;
            return 0;
        }
        i++;
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
//cout << fixed << setprecision(8) << a << endl;
#define Fast_Input ios_base :: sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);
#define pb push_back
#define mem(a, b)     memset(a, b, sizeof(a))
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef long long ll;
typedef tree<int,null_type,greater<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;
/*sort(v.begin(), v.end(),
     [](const pair<int, int>& x, const pair<int, int>& y)
{
    if (x.first != y.first)
        return x.first < y.first;
    return x.second < y.second;
});
*/
int const fx[]= {+1,+0,-1,+1};
int const fy[]= {-1,+1,+0,+0};
const int inf = numeric_limits<int>::max();
const int mx=2e5;
const ll mod=1e9+7;
int main()
{
    int n,i,x;
    ll sum=0;
    cin >> n;
    map<int,int>m;
    for(i=1;i<=n;i++)
    {
        cin >> x;
        m[x]++;
        sum+=x;
    }
    int q,y;
    cin>>q;
    while(q--)
    {
        cin >> x>>y;
        sum-=(x*1ll*m[x]);
        sum+=(y*1ll*m[x]);
        m[y]+=m[x];
        m[x]=0;
        cout << sum << endl;
    }
    return 0;
}




Measured memory_bytes: 7956
#include <iostream>
#include <limits.h>
#include <string>
using namespace std;

int main(void){
    int h, w;
    char s[55][55];
    bool ans = true;
    cin >> h >> w;
    for (int i = 0; i < h; i++) cin >> s[i];
    for (int i = 0; i < h; i++) {
        for (int j = 0; j < w; j++) {
            if (s[i][j] == '#') {
              if (s[i - 1][j] != '#' && s[i + 1][j] != '#' && s[i][j - 1] != '#' && s[i][j + 1] != '#') ans = false;
            }
        }
    }
    if (ans) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 256
import math

K = int(input())

sum = 0

for a in range(K):
    sum += a + 1
    #print(a + 1, a + 1)
    for b in range(K):
        if a < b:
            gcd2_sum = math.gcd(a + 1, b + 1) * 3 * 2
            sum += gcd2_sum
            #print(a + 1, b + 1, gcd2_sum)
            for c in range(K):
                if b < c:
                    gcd3_sum = math.gcd(math.gcd(a + 1, b + 1), c + 1) *  6
                    sum += gcd3_sum
                    #print(a + 1, b + 1, c + 1, gcd3_sum)
print(sum)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define rep1(i, n) for(int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;

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

    int n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n) cin >> l[i];

    int res = 0;
    rep(a, n) rep(b, n) rep(c, n){
        if(!(a < b && b < c)) continue;

        if(l[a] != l[b] && l[b] != l[c] && l[c] != l[a]){
            if(l[a]+l[b] > l[c] && l[b]+l[c] > l[a] && l[c]+l[a] > l[b]) ++res;
        }
    }

    cout << res << endl;

    return 0;
}

Measured memory_bytes: 3660
#include<stdio.h>

int n,k,ans=1;

int min(int,int);

int main(void){
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        ans=min(ans<<1,ans+k);
    printf("%d\n",ans);
    return 0;
}

int min(int a,int b){
	return a<b?a:b;
}

Measured memory_bytes: 128
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    String s=sc.next();
    int n=s.length();
    int[][] a=new int[2][n];
    for(int i=0;i<n;i++){
      a[0][i]=i+(s.charAt(i)=='R'?1:-1);
    }
    for(int k=0;k<9;k++){
      for(int i=0;i<2;i++){
        for(int j=0;j<n;j++){
          a[m(i)][j]=a[i][a[i][j]];
        }
      }
    }
    int[] ans=new int[n];
    for(int i=0;i<n;i++){
      ans[a[0][i]]++;
    }
    for(int i=0;i<n-1;i++){
      System.out.print(ans[i]+" ");
    }
    System.out.println(ans[n-1]);
  }
  static int m(int i){
    return i==0?1:0;
  }
}

Measured memory_bytes: 43608
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int sum= (n*(n+1))>>1;
    if(!(sum&1))
    {
        vector<int>v1, v2;
        sum/= 2;
        for(int i=n; i>=1; i--)
        {
            if(sum>=i)v1.push_back(i), sum-= i;
            else v2.push_back(i);
        }
        printf("%d\n", v1.size()*v2.size());
        for(int i=0; i<v1.size(); i++)
        {
            int x= v1[i];
            for(int j=0; j<v2.size(); j++)
            {
                int y= v2[j];
                printf("%d %d\n", x, y);
            }
        }
    }
    else
    {
        vector<int>vec[102];
        int cnt= 0;

        for(int i=1, j=n-(n%2); i<=n/2; i++, j--)
        vec[++cnt].push_back(i), vec[cnt].push_back(j);
        if(n&1)vec[++cnt].push_back(n);

        int res= 0;
        for(int i=1; i<cnt; i++)
        res+= vec[i].size()*vec[i+1].size();
        res+= vec[cnt].size()*vec[1].size();
        printf("%d\n", res);

        for(int i=1; i<cnt; i++)
        for(int j=0; j<vec[i].size(); j++)
        {
            int x= vec[i][j];
            for(int k=0; k<vec[i+1].size(); k++)
            {
                int y= vec[i+1][k];
                printf("%d %d\n", x, y);
            }
        }
        for(int j=0; j<vec[cnt].size(); j++)
        {
            int x= vec[cnt][j];
            for(int k=0; k<vec[1].size(); k++)
            {
                int y= vec[1][k];
                printf("%d %d\n", x, y);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int sizeA = sc.nextInt();
    int sizeB = sc.nextInt();
    String[] pictureA = new String[sizeA];
    String[] pictureB = new String[sizeB];
    for(int i = 0; i < sizeA; i++) {
      pictureA[i] = sc.next();
    }
    for(int i = 0; i < sizeB; i++) {
      pictureB[i] = sc.next();
    }
    int count = 0;
    for(int i = 0; i <= sizeA - sizeB; i++) {
      for(int j = 0; j <= sizeA - sizeB; j++) {
        int a = 0;
        for(int k = i; k < i + sizeB; k++) {
          if(!((pictureA[k].substring(j, j + sizeB)).equals(pictureB[k - i]))) a++;
        }
        if(a == 0) count++;
      }
    }
    String res = "";
    if(count > 0) {
      res = "Yes";
    } else {
      res = "No";
    }
    System.out.println(res);
  }
}

Measured memory_bytes: 11728
#include <vector>
#include <algorithm>
#include <cstdio>
using namespace std;
 
vector<int> mul(vector<int> &a,vector<int> &b){
	int i=0,n=a.size();
	vector<int> r(n);
	for(i=0;i<n;i++)r[i]=a[b[i]];
	return r;
}
 
int main(){
	int n,m,i,x,s;
	long long k;
	scanf("%d",&n);
	vector<int> t(n),d(n),e(n),a(n);
	for(i=0;i<n;i++)scanf("%d",&a[i]),t[i]=i,e[i]=i;
	for(i=0;i<n-1;i++)d[i]=a[i+1]-a[i];
	scanf("%d%lld",&m,&k);
	for(i=0;i<m;i++)scanf("%d",&x),swap(t[x-2],t[x-1]);
	//置換tのd乗を繰り返し二乗法により計算する
	for(;k;k>>=1){
		if(k&1)e=mul(e,t);
		t=mul(t,t);
	}
	k=a[0];
	for(i=0;i<n;i++)printf("%lld\n",k),k+=d[e[i]];
}

Measured memory_bytes: 3176
M, D = map(int, input().split())

ans = 0
for i in range(1, M + 1):
    for j in range(1, D + 1):
        a = j // 10
        b = j % 10
        if a * b == i and a >= 2 and b >= 2:
            ans += 1

print(ans)

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);for(int i=0;i<n;i++) cin >> a[i];
    sort(a.begin(),a.end());
    ll ans=0;
    for(int i = 0; i < n; i++) {
        for(int j = i+1; j < n; j++) {
            for(int k = j+1; k < n; k++) {
                if(a[i]!=a[j] && a[j] !=a[k] && a[i]+a[j]>a[k] && a[j] +a[k] >a[i]){
                    ans ++;
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3552
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <numeric>

using namespace std;

#define mod 1000000007

int main()
{
	int a[3];
	int evennum = 0;
	for(int i = 0; i < 3; i++){
		cin >> a[i];
		if(a[i] % 2 == 0) evennum++;
	}
	int ans = 0;
	if(evennum == 1){
		ans = 1;
		for(int i = 0; i < 3; i++){
			if(a[i] % 2 == 1) a[i]++;
		}
	} else if(evennum == 2){
		ans = 1;
		for(int i = 0; i < 3; i++){
			if(a[i] % 2 == 0) a[i]++;
		}
	}
	sort(a, a + 3);
	ans += (a[2] - a[0]) / 2 + (a[2] - a[1]) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256