akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<math.h>

using namespace std;

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

double p[300][2];
int n;

double dis(double x1, double y1, double x2, double y2){
    return sqrt(pow(x1-x2, 2) + pow(y1-y2, 2));
}

int circle(double x, double y, int i, int j){
    int count = 2;
    REP(k, n){
        if(k!=i && k!=j){
            if(dis(x, y, p[k][0], p[k][1]) < 1){
                count += 1;
            }
        }
    }
    return count;
}

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

        if(n==0) break;

        REP(i, n){
            cin >> p[i][0];
            cin >> p[i][1];
        }

        int output = 1;
        REP(i, n){
            for(int j=i+1; j<n; j++){
                double cx = (p[i][0]+p[j][0]) / 2;
                double cy = (p[i][1]+p[j][1]) / 2;
                double d = dis(p[i][0], p[i][1], p[j][0], p[j][1]);

                if(d>2){
                    continue;
                } else if (d==2){
                    output = max(output, circle(cx, cy , i, j));
                } else {
                    double a1 = acos(d/2);
                    double a2 = atan2((p[j][1]-p[i][1]), p[j][0]-p[i][0]);

                    double x1 = p[i][0] + cos(a2+a1);
                    double y1 = p[i][1] + sin(a2+a1);

                    double x2 = p[i][0] + cos(a2-a1);
                    double y2 = p[i][1] + sin(a2-a1);

                    output = max(output, circle(x1, y1, i, j));
                    output = max(output, circle(x2, y2, i, j));
                }
            }
        }

        cout << output << endl;
    }
}

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

int n;
double a[3005];
double ans;
double f[3005][3005];

int main()
{
	cin>>n;
	for(int i=1;i<=n;cin>>a[i++]);
	f[0][0] = 1.0;
	for(int i=1;i<=n;i++)
		for(int j=0;j<=i;j++)
			f[i][j] = f[i-1][j-1]*a[i]+f[i-1][j]*(1-a[i]);
	for(int i=n/2+1;i<=n;i++)
		ans += f[n][i];
	printf("%.11lf\n",ans);
	
	return 0;
}

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

using namespace std;

int main(){
    int n,m,t;
    cin>>n>>m>>t;
    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        cin>>a[i];
    }
    sort(a.begin(),a.end());
    int ans=a.front()-m;
    for (int i = 1; i < n; ++i) {
        if(a[i]-a[i-1]>2*m)ans+=(a[i]-a[i-1])-2*m;
    }
    if(t-a.back()>m)ans+=t-a.back()-m;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3144
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
using vc = pair<ll,vector<ll>>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
int n = 200005;
vector<int> a(n);

vc count(int l,int r){
    if(l+1 == r) return vc(0,{a[l]});
    if(l+2==r){
        if(a[l]<a[l+1]){
            return vc(0,{a[l],a[l+1]});
        }else{
            return vc(1,{a[l+1],a[l]});
        }
    }

    vc vc1 = count(l,(l+r)/2);
    vc vc2 = count((l+r)/2,r);
    vector<ll> V1 = vc1.second;
    vector<ll> V2 = vc2.second;

    ll res = 0;
    vector<ll> V;

    res += vc1.first + vc2.first;

    int j = 0;
    for(int i=0;i<V1.size();i++){
        if(j!=V2.size()){
            while(V2[j] < V1[i]){
                V.push_back(V2[j]);
                ++j;
                if(j==V2.size()) break;
            }
        }

        V.push_back(V1[i]);
        res += j;
    }

    while(j < V2.size()){
        V.push_back(V2[j]);
        ++j;
    }

    return vc(res,V);
}

int main(){
    cin >> n;
    rep(i,n) cin >> a[i];
    vc ans = count(0,n);
    cout << ans.first << endl;
    /*
    rep(i,n){
        cout << ans.second[i] << " ";
    }
    */
    return 0;
}


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

int main(){
  int n, num;
  char suit;
  cin >> n;
  int S_check[13] = {};
  int H_check[13] = {};
  int C_check[13] = {};
  int D_check[13] = {};

  for(int i=0; i<n; i++){
    cin >> suit >> num;
    switch(suit){
      case 'S': S_check[num-1] = 1; break;
      case 'H': H_check[num-1] = 1; break;
      case 'C': C_check[num-1] = 1; break;
      case 'D': D_check[num-1] = 1; break;
    }
  }
  for(int i=0; i<13; i++){
    if(S_check[i] == 0)
      cout << "S " << i+1 << endl;
  }
  for(int i=0; i<13; i++){
    if(H_check[i] == 0)
      cout << "H " << i+1 << endl;
  }
  for(int i=0; i<13; i++){
    if(C_check[i] == 0)
      cout << "C " << i+1 << endl;
  }
  for(int i=0; i<13; i++){
    if(D_check[i] == 0)
      cout << "D " << i+1 << endl;
  }
  return 0;  
}


Measured memory_bytes: 3084
import java.util.*;

public class Main{
  public static void main(String[]args){
    Scanner sc = new Scanner(System.in);
    long s = sc.nextLong();
    long c = sc.nextLong();
    long ans = 0;
    if(s > c/2){
      ans = c/2;
    }else{
      ans = (c-s*2)/4 + s;
    }
    
    System.out.println(ans);
  }
}

Measured memory_bytes: 21716
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}


int main() {
    int n;
    cin >> n;
    map<int,ll> mp;
    ll sum = 0;
    rep(i,n) {
        int a;
        cin >> a;
        sum += a;
        mp[a]++;
    }
    int q;
    cin >> q;
    rep(i,q) {
        int b,c;
        cin >> b >> c;
        sum -= mp[b]*b;
        sum += mp[b]*c;
        mp[c] += mp[b];
        mp[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 9544
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    int x = readint;

    int ans = 1;
    for (int b = 2; b <= x; b++) {
        int a = b * b;
        while (a <= x) {
            ans = max(ans, a);
            a *= b;
        }
    }
    writeln(ans);
}


Measured memory_bytes: 256
n = int(input())
c0 = 0
c1 = 0
c2 = 0
c3 = 0
for _ in range(n):
  s = input()
  if s == 'AC':
    c0 += 1
  elif s == 'WA':
    c1 += 1
  elif s == 'TLE':
    c2 += 1
  elif s == 'RE':
    c3 += 1
print('AC x', c0)
print('WA x', c1)
print('TLE x', c2)
print('RE x', c3)

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

#define FAST ios_base::sync_with_stdio(false); cin.tie(0);
#define pb push_back
#define eb emplace_back
#define ins insert
#define ph push
#define f first
#define s second
#define cbr cerr << "hi\n"
#define mmst(x, v) memset((x), v, sizeof ((x)))
#define siz(x) ((ll)x.size())
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define btinpct(x) __builtin_popcountll((x))
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline long long rand(long long x, long long y) { return (rng() % (y+1-x)) + x; } //inclusivesss
string inline to_string(char c) {string s(1,c);return s;} template<typename T> inline T gcd(T a,T b){ return a==0?llabs(b):gcd(b%a,a); }

typedef long long ll; 
typedef long double ld;
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
typedef pair <ll, ll> pi; typedef pair <ll, pi> spi; typedef pair <pi, pi> dpi;

#define LLINF ((long long) 1e18)//1234567890987654321
#define INF 1234567890ll
// #define cerr if(0)cout
#define MAXN (2006)
ll n,k,mi[MAXN*2],dp[MAXN][MAXN][2][2],f[MAXN*2];
const ll mod=998244353;
int main()
{
	FAST
	cin>>k>>n; mmst(dp,-1);
	function<ll(ll,ll)> qexp=[&](ll x,ll e) {
		if(e==0) return 1ll;
		ll half=qexp(x,e>>1);
		half*=half, half%=mod;
		if(e&1) half*=x, half%=mod;
		return half;
	};
	auto C=[&](ll n,ll k) {
		if(n<k) return 0ll;
		return f[n]*mi[k]%mod*mi[n-k]%mod;
	};
	function<ll(ll,ll,ll,ll)> FF=[&](ll n,ll k,ll full,ll fixed) {
		// if empty, but fixed, return 0, thanks
		if(n==0) return ll(fixed==0);
		if(k==0) return 0ll;
		if(~dp[n][k][full][fixed]) return dp[n][k][full][fixed];
		ll &ans=dp[n][k][full][fixed];
		if(fixed) {
			ans=FF(n-1,k-1,1,0) + FF(n-1,k,0,1);
			ans%=mod;
		} else {
			ans=FF(n,k-1,1,0)+FF(n-1,k,0,1)*(full+1)%mod+FF(n-1,k-1,1,0)*(full+1)%mod;
			ans%=mod;
		}
		return ans;
	};
	auto F=[&](ll n,ll k) {
		assert(k%2==0);
		return FF(n, k/2ll,1,0);
	};
	mi[0]=1; f[0]=1;
	FOR(i,1,4002) f[i]=f[i-1]*i%mod, mi[i]=qexp(f[i], mod-2);
	vector<ll> v;
	FOR(i,2,2*k) {
		if(i>k+1) continue;
		ll ans = 0;
		ll x = max(0ll, k-i+1);
		ll val = (i>k?k:i-1);
		// cerr<<x<<' ';
		FOR(j,0,n) {
			// cerr<<"n-j: "<<n-j<<' '<<val<<' '<<F(n-j, val-(val%2==1))<<'\n';
			ans += (x?C(j+x-1, x-1):(j==0)) * F(n-j, val-(val%2==1)) % mod, ans %= mod;
		}
		if(val%2 == 1) {
			-- n;
			FOR(j,0,n) {
				ans += (x?C(j+x-1, x-1):(j==0)) * F(n-j, val-(val%2==1)) % mod, ans %= mod;
			}
			++ n;
		}
		// cerr<<i<<": ";
		cout<<ans<<'\n';
		v.pb(ans);
	}
	v.pop_back();
	while(v.size()) cout<<v.back()<<'\n', v.pop_back();
}


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

int main()
{
	ll k,a,b,f=0;
	cin>>k>>a>>b;
	for(ll i=a;i<=b;i++)
	{
		if(i%k==0)
		{
			f=1;
			break;
		}
	}
	if(f==1)
	{
		cout<<"OK"<<endl;
	}
	else
	{
		cout<<"NG"<<endl;
	}
}

Measured memory_bytes: 3624
#!/usr/bin/ruby
#encoding: utf-8

n,k,q = gets.split.map(&:to_i)
a = Array.new(q)
(0..q-1).each do |i|
  a[i] = gets.to_i - 1
end

ans = Array.new(n,k-q)
(0..q-1).each do |i|
  ans[a[i]] += 1
end

(0..n-1).each do |i|
  if ans[i] > 0
    puts "Yes"
  else
    puts "No"
  end
end

Measured memory_bytes: 3964
def solution
  a, b, c, d = gets.chomp.split('').map(&:to_i)
  operator = { '+' => 1, '-' => -1 }
  %w[+ -].repeated_permutation(3).each do |p|
    return "#{a}#{p[0]}#{b}#{p[1]}#{c}#{p[2]}#{d}=7" if a + operator[p[0]]*b + operator[p[1]]*c + operator[p[2]]*d == 7
  end
end

puts solution


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<ll> A(N);
    for (auto &i : A) cin >> i;

    auto check = [&]() {
        bool res = false;
        for (auto &i : A) {
            if (N <= i) res = true;
        }
        return res;
    };

    ll ans = 0;
    vector<ll> count(N);
    while (check()) {
        rep(i, N) {
            count[i] = A[i] / N;
        }
        ll sum = accumulate(count.begin(), count.end(), 0L);
        rep(i, N) {
            A[i] = A[i] % N + (sum - count[i]);
        }
        ans += sum;
    }

    cout << ans <<endl;
}

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

template<class T> void chmin(T &a, T b) {
    if (a > b) a = b;
}

const long long INF = 1LL<<60;

int main() {
    int N; cin >> N;
    vector<int> h(N);
    for (int i = 0; i < N; ++i) cin >> h[i];
    
    vector<long long> dp(N, INF);
    dp[0] = 0;
    
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i-1] + abs(h[i] - h[i-1]));
        if (i > 1) {
            chmin(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }   
    }
    
    cout << dp[N-1] << endl;
}

Measured memory_bytes: 4588
from re import match
s, t = input().replace('?', '.'), input()

for i in range(len(s) - len(t) + 1)[::-1]:
    if match(s[i:i + len(t)], t):
        key = s.replace(s[i:i + len(t)], t).replace('.', 'a')
        s = s.replace('.', 'a')
        print(s[:i] + t + s[i + len(t):])
        #print(key)
        break
else:
    print('UNRESTORABLE')


Measured memory_bytes: 3188
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
                Out.Flush();
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var lis = new List<string>();
            lis.Add("AKIHABARA");
            lis.Add("AKIHABAR");
            lis.Add("AKIHABRA");
            lis.Add("AKIHBARA");
            lis.Add("KIHABARA");
            lis.Add("AKIHABR");
            lis.Add("AKIHBRA");
            lis.Add("KIHBARA");
            lis.Add("KIHABRA");
            lis.Add("KIHABAR");
            lis.Add("AKIHBAR");
            lis.Add("AKIHBR");
            lis.Add("KIHABR");
            lis.Add("KIHBAR");
            lis.Add("KIHBRA");
            lis.Add("KIHBR");

            var s = ReadLine();
            IO.WriteLineYES_or_NO(lis.Contains(s));
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

using namespace std;

int main() {
	ios_base::sync_with_stdio(false);
	int n, l;
	cin >> n >> l;
	vector<string> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(v.begin(), v.end());
	for (int i = 0; i < n; i++) {
		cout << v[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.HashMap;
import java.util.Map;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int N=scan.nextInt();
		String S[]=new String[N];
		int count=0;
		Map<String,Integer>map=new HashMap<String,Integer>();
		for(int i=0;i<N;i++){
			S[i]=scan.next();
			map.put(S[i],1);
		}
		for(Integer val:map.values()){
			count++;
		}
		System.out.println(count);

	}

}


Measured memory_bytes: 78868
//#include <bits/stdc++.h>
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
//#include "boost/multiprecision/cpp_int.hpp"
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2

ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
typedef pair<dd,dd> d_d;
ll inf=(ll)1E16;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fi first
#define se second
#define endl "\n"
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
//template<class T>void max(T a,T b){if(a<b)return b;else return a;}
//template<class T>void min(T a,T b){if(a>b)return b;else return a;}
//template<class T>bool Max(T&a, T b){if(a < b){a = b;return 1;}return 0;}
//template<class T>bool Min(T&a, T b){if(a > b){a = b;return 1;}return 0;}

//////////////////////////


ll po(ll i,ll p){
    if(p==0)return 1;
    else{
        i=mod(i);
        if(p==1)return i;
        if(p%2==0)return po(mod(i*i),p/2);
        return mod(i*po(i,p-1));
    }
}
ll bunbo(ll n){
    return po(n,i_5);
}


#define N 6000004
ll kai[N];
ll kai2[N];
void calc(){
    kai[0]=1;
    kai2[0]=1;
    rep(i,1,N-1){
        kai[i]=mod(kai[i-1]*i);
    }
    kai2[N-1]=po(kai[N-1],i_5);
    for(ll i=N-2;i>=0;i--){
        kai2[i]=mod(kai2[i+1]*(i+1));
    }
}
ll comb(ll n,ll k){
    if(n<k)return 0;
    if(n==0)return 1;
    return mod(mod(kai[n]*kai2[n-k])*kai2[k]);
}

int main(){fastio
    calc();
    ll n,m;cin>>n>>m;
    ll a1,a2=0,a3=0;
    a1=comb(3*m+n-1,n-1);
    rep(ma,2*m+1,3*m){
        ll res=3*m-ma;
        Add(a2,comb(res+n-2,n-2));
    }
    a2=mod(a2*n);
    rep(i,m+1,3*m){
        if((3*m-i)%2==1)continue;
        if(n<i)continue;
        ll res=(3*m-i)/2;
        Add(a3,comb(n,i)*comb(res+n-1,n-1));
    }
    cout<<mod(a1-a2-a3)<<endl;
    return 0;
}


Measured memory_bytes: 94080
import sys
import math

(a, b) = tuple([int(s) for s in input().split()])

if a==b:
    print(a)
    sys.exit(0)

min = a if a < b else b
divisor = 1

i = 2
while i < math.sqrt(min):
    if a % i == 0 and b % i == 0:
        a = a / i
        b = b / i
        divisor = divisor * i
    else:
        i = i + 1

print(divisor)

Measured memory_bytes: 7780
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>


#define rep(p,q) for(int i = p;i < q;i++)
#define ll long long

using namespace std;

const int CONS = 1e9 + 7;
const ll INF = 1e16 + 7;

//61D
int main(void) {
	ll n, m;
	cin >> n >> m;
	vector<ll>a = vector<ll>(m);
	vector<ll>b = vector<ll>(m);
	vector<ll>c = vector<ll>(m);
	vector<ll>dist = vector<ll>(n);
	dist[0] = 0;
	rep(1, n)dist[i] = INF;
	rep(0, m) {
		cin >> a[i] >> b[i] >> c[i];
		c[i] = -c[i];
	}

	rep(0, n - 1) {
		for (int j = 0; j < m; j++) {
			if (dist[a[j] - 1] == INF)continue; //まだ到達していない

			if (dist[b[j] - 1] > dist[a[j] - 1] + c[j]) {
				dist[b[j] - 1] = dist[a[j] - 1] + c[j];
			}
		}
	}
	ll ans = dist[n - 1];

	bool negative[1000]{ false };
	
	rep(0, n - 1) {
		for (int j = 0; j < m; j++) {
			if (negative[a[j] - 1]) negative[b[j] - 1] = true;
			if (dist[a[j] - 1] == INF)continue; //まだ到達していない

			if (dist[b[j] - 1] > dist[a[j] - 1] + c[j]) {
				 negative[b[j] - 1] = true;
			}
		}
	}
	if (negative[n - 1]) cout << "inf" << endl;
	else cout << -dist[n - 1] << endl;
}


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

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

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

    return arr


N = int(input())

prime_dict = dict()
for i in range(1, N+1):
    primes = factorization(i)
    for j in range(len(primes)):
        if primes[j][0] in prime_dict:
            prime_dict[primes[j][0]] += primes[j][1]
        else:
            prime_dict[primes[j][0]] = primes[j][1]
            
ans = 1
for k, v in prime_dict.items():
    if k != 1:
        ans *= v+1

print(ans % (10**9+7))

Measured memory_bytes: 3188
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>

using namespace std;

int gcd(int n, int m) {
    if (n == 0)
        return m;
    return gcd(m % n, n);
}

int bit_count(int i) {
    i = i - ((i >> 1) & 0x55555555);
    i = (i & 0x33333333) + ((i >> 2) & 0x33333333);
    i = (i + (i >> 4)) & 0x0f0f0f0f;
    i = i + (i >> 8);
    i = i + (i >> 16);
    return i & 0x3f;
}

int main() {
    int n, k;
    cin >> n >> k;
    if (k == 1) {
        cout << 0 << endl;
    } else {
        cout << n - k << endl;
    }
}


Measured memory_bytes: 256
n, l = map(int, input().split())

a = range(l, l+n)
b = []
for i in a:
  b.append(abs(i))
  
if 0 in a:
  print(sum(a))
elif max(a) < 0:
  print(sum(a)-max(a))
else:
  print(sum(a)-min(b))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
 
int main() {
 int C,i =0,j=0;
 cin >> C;
 while(1){
   if (C>=500){
     i++;
     C = C -500;
   }
   else 
     break;
 }
  while(1){
   if (C>=5){
     C = C -5;
     j++;
   }
   else 
     break;
 }
  cout << i*1000 + j*5 << endl;
  
}

Measured memory_bytes: 256
from math import gcd
from functools import reduce
from collections import Counter


class Osa_k:
    def __init__(self, maximum):
        self.table = [-1] * (maximum+1)
        for i in range(2, maximum+1):
            if self.table[i] != -1:
                continue
            for j in range(2, int(i**0.5)+1):
                if i%j == 0:
                    self.table[i] = j
                    for k in range(2*i, maximum+1, i):
                        if self.table[k] != -1:
                            self.table[k] = j
                    break

    def factorize(self, n):
        res = Counter()
        b = n
        while 1:
            if self.table[b] == -1:
                break
            res[self.table[b]] += 1
            b //= self.table[b]
        res[b] += 1
        return res


N = int(input())
*A, = map(int, input().split())
def f():
    cnt = Counter()
    ins = Osa_k(max(A))
    for i in A:
        res = ins.factorize(i) if i!=1 else {}
        for j in res.keys():
            cnt[j] += 1
            if cnt[j] >= 2:
                return False
    return True

cond1 = f()
cond2 = (reduce(gcd, A)==1)

if cond1:
    print("pairwise coprime")
elif cond2:
    print("setwise coprime")
else:
    print("not coprime")


Measured memory_bytes: 229636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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 long long INF = 1LL << 60;
const int mod = 1000000007;

ll dp[100100];
int main() {
    int n,m;
    cin >> n >> m;
    vector<int>a(m);
    rep(i,m) cin >> a[i];
    vector<bool> ok(100100,true);
    rep(i,m){
        ok[a[i]]=false;
    }
    dp[0]=1;
    for(int i = 0;i<=n;++i){
        if(ok[i+1]){
            dp[i+1]+=dp[i];
            dp[i+1]%=mod;
        }
        if(ok[i+2]){
            dp[i+2]+=dp[i];
            dp[i+2]%=mod;
        }
    }
    cout << dp[n] <<endl;
}

Measured memory_bytes: 1280
#define _CRT_SECURE_NO_WARNINGS
#define REL
#include <algorithm>
#include <string>
#include <iostream>
#include <complex>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <stack>
#include <map>
#include <list>
#include <queue>
#include <deque>
#include <random>
#include <set>
#include <vector>
#include <unordered_map>
#include <bitset>
#include <unordered_set>
#include <array>
#include <forward_list>
#include <chrono>
#include <iomanip>
#include <utility>
#include <assert.h>

#define mp make_pair
#define pb push_back

using namespace std;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

mt19937 gen(34);

ll h, a;

int main()
{
#ifdef _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#else
	//freopen("threesum.in", "r", stdin);
	//freopen("threesum.out", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> h >> a;
	cout << (h + a - 1) / a;



	return 0;
}

Measured memory_bytes: 256
#36
N,M = map(int,input().split())
li = []
ri = []
num = 0


for i in range(M):
    L,R = map(int,input().split())
    li.append(L)
    ri.append(R)
L = max(li)
R = min(ri)
num = R-L+1
if num <0:
    num= 0
    
print(num)
        
    

Measured memory_bytes: 16744
n = input()
answer = 0
if len(n)<=1:
    pass
else:
    for i in range(1,len(n)):
        if n[i]==n[i-1]:
            answer+=1
            if n[i]=='0':
                n = n[:i]+'1'+n[i+1:]
            else:
                n = n[:i]+'0'+n[i+1:]

print(answer)

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

int main()
{
  int k, n;
  cin >> k >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  a.push_back(k + a[0]);
  int len = 0;
  for (int i = 0; i < n; i++)
  {
    len = max(len, a[i + 1] - a[i]);
  }
  int ans = k - len;
  cout << ans << endl;
}


Measured memory_bytes: 4848
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int n;
	cin>>n;
	pair<int,int> a[n];
	int cnt=0;
	rep(i,n){
		cin>>a[i].second;
		a[i].first=cnt;
		if(i%2){
			cnt*=-1;
		}else{
			cnt*=-1;
			cnt--;
		}
	}
	sort(a,a+n);
	if(n%2==0){
		rep(i,n){
			if(i)cout<<" "<<a[i].second;
			else cout<<a[i].second;
		}
		cout<<endl;
	}else{
		rep(i,n){
			if(i)cout<<" "<<a[n-1-i].second;
			else cout<<a[n-1-i].second;
		}
		cout<<endl;
	}
	return 0;
}

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

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<63;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

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; }

int main(void){
    int n; cin >> n;
    VI a1(n/2), a2(n/2);
    REP(i,n){
        int v;
        cin >> v;
        if(i%2) a1[(i-1)/2] = v;
        else a2[i/2] = v;
    }
    SORT(a1); SORT(a2);

    vector<P> p1,p2;
    p1.emplace_back(1,a1[0]); p2.emplace_back(1,a2[0]);
    REP(i,n/2-1){
        if(p1.back().second == a1[i+1]) p1.back().first++;
        else p1.emplace_back(1,a1[i+1]);
        if(p2.back().second == a2[i+1]) p2.back().first++;
        else p2.emplace_back(1,a2[i+1]);
    }

    SORT(p1); SORT(p2); REVERSE(p1); REVERSE(p2);

    if(p1[0].second != p2[0].second) cout << n-p1[0].first-p2[0].first << endl;
    else{
        int ans, ch1, ch2;

        if(p1.size() < 2 && p2.size() < 2){
            int ans1, ans2;
            ans = n/2;
        }
        else if(p1.size() < 2){
            int ans1, ans2;
            ch1 = 0; ch2 = n/2 - p2[1].first;
            ans1 = n-ch1-ch2;

            ch1 = n/2; ch2 = n/2 - p2[0].first;
            ans2 = n-ch1-ch2;

            ans = min(ans1, ans2);
        }
        else if(p2.size() < 2){
            int ans1, ans2;
            ch1 = p1[1].first; ch2 = 0;
            ans1 = n-ch1-ch2;

            ch1 = p1[0].first; ch2 = n/2;
            ans2 = n-ch1-ch2;

            ans = min(ans1, ans2);
        }
        else{
            int ans1, ans2;
            ch1 = p1[1].first; ch2 = p2[0].first;
            ans1 = n-ch1-ch2;

            ch1 = p1[0].first; ch2 = p2[1].first;
            ans2 = n-ch1-ch2;

            ans = min(ans1, ans2);
        }

        cout << ans << endl;
    }

    return 0;
} 

Measured memory_bytes: 1660
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define INF 1e9
#define INFL 1e18
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BDigits {
public:
	void solve(std::istream& in, std::ostream& out) {
	    ll N, K;
	    in >> N >> K;
	    ll ans = 0;
	    while (N > 0) {
	        ans++;
	        N /= K;
	    }
	    out << ans << '\n';
	}
};


int main() {
	BDigits solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    template<typename T>
    vector<T> read_vec(size_t n){
        vector<T> tmp(n);
        for(size_t i = 0; i < n; i++){
            cin >> tmp[i];
        }
        return tmp;
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

int main(){
    Stream io;

    int X, N;
    io.read(X, N);
    vector<int> p;
    if(N > 0) {
        p = io.read_vec<int>(N);
    }
    vector<int> v(102, 0);
    for(int i = 0; i < N; i++){
        v[p[i]] = 1;
    }
    int ans = X;
    int d = 0;
    while(true){
        if(v[X - d] == 0){
            ans = X - d;
            break;
        }
        if(v[X + d] == 0){
            ans = X + d;
            break;
        }
        d++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<typename T> istream& operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream& operator<<(ostream &os, vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream& operator<<(ostream &os, set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream& operator<<(ostream &os, pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream& operator<<(ostream &os, map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;


vector<vector<int>> uv(601, vector<int>(601));

lint coun(int x, int d)
{
    lint ans = 0;
    int s = 0, t = abs(d);
    
    lint eff = 0;
    REP(i, min(t, 601)) eff += uv[x + d][i];
    
    while (t < 601)
    {
        eff += uv[x + d][t];
        if (uv[x][s] && uv[x][t])
        {
            ans += eff * 2 - uv[x + d][s] - uv[x + d][t];
        }        
        eff -= uv[x + d][s];
        s++; t++;
    }
    return ans;
}

lint solve()
{
    lint ans = 0;
    REP(x, 601) FOR(d, 1, 601)
    {
        if (x - d >= 0) ans += coun(x, -d);
        if (x + d < 601) ans += coun(x, d);
    }
    return ans;
}

int main()
{
    int H, W;
    cin >> H >> W;
    REP(h, H)
    {
        string S;
        cin >> S;
        REP(w, W) if (S[w] == '#')
        {
            int u = h + w;
            int v = h - w + 301;
            uv[u][v] = 1;
        }
    }

    lint ans1 = solve();
    REP(i, 601) REP(j, i) swap(uv[i][j], uv[j][i]);
    lint ans2 = solve();
    cout << (ans1 + ans2) / 2 << endl;
}


Measured memory_bytes: 1664
#include<stdio.h>
#include<string.h>

int main(void){
	int i,l,n,ans;
	char a[105],b[105];
	
	ans=0;
	
	for(i=0;i<105;i++){
		a[i]=NULL;
		b[i]=NULL;
	}
	
	while(scanf("%s",a)!=EOF){
		strcpy(b,a);
		for(i=0;i<(int)strlen(a);i++)b[i]=a[(int)strlen(a)-i-1];
		
		if(strcmp(a,b)==0)ans++;
		
			for(i=0;i<105;i++){
			a[i]=NULL;
			b[i]=NULL;
		}
		
	}
	
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 556
m,*t=map(int,open(0).read().split())
a=b=0
for d,c in zip(*[iter(t)]*2):
    m=[b]
    while c//2:
        cd=c//2
        a+=cd
        if c%2:
            m+=d,
        d*=2
        if d>9:
            a+=cd
            d=d//10+d%10
        c=cd
    for t in m[::-1]:
        d+=t
        a+=1
        if d>9:
            d=d//10+d%10
            a+=1
    b=d
print(a-1)

Measured memory_bytes: 111660
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

vector<int> bfs(int s, int N, vector<vector<int>> &graph){
  vector<int> dist(N, INF);
  dist[s] = 0;
  queue<int> q;
  q.push(s);
  while(!q.empty()){
    int p = q.front(); q.pop();
    for(auto v : graph[p]){
      if(dist[v] != INF) continue;
      dist[v] = dist[p]+1;
      q.push(v);
    }
  }
  return dist;
}

signed main() {
  int N, X, Y;
  cin >> N >> X >> Y;
  X--; Y--;

  vector<vector<int>> graph(N);
  REP(i, N-1){
    graph[i].emplace_back(i+1);
    graph[i+1].emplace_back(i);
  }
  graph[X].emplace_back(Y);
  graph[Y].emplace_back(X);

  vector<int> ans(N);
  REP(i, N){
    auto d = bfs(i, N, graph);
    REP(j, N) ans[d[j]]++;
  }

  FOR(i, 1, N){
    cout << ans[i]/2 << "\n";
  }

  return 0;
}


Measured memory_bytes: 384
n, X = map(int, input().split())
x = list(map(int, input().split()))

d = [0 for _ in range(n)]
for i in range(n):
    d[i] = abs(x[i] - X)

d = sorted(list(set(d)))

if n == 1:
    print(d[0])
    exit()

def calc_gcd(a, b):
    if a < b:
        a, b = b, a
    if b == 0:
        return a
    c = a % b
    return calc_gcd(b, c)

ans = d[0]
for i in range(1, len(d)):
    ans = calc_gcd(ans, d[i])

print(ans)

Measured memory_bytes: 17836
s = input()
def hoge(s):
    if s[:len(s)//2] == s[len(s)//2:]:
        return 1
    else:
        return 0
ans = len(s)-1
s = s[:-1]
while True:
    if hoge(s):
        print(ans)
        exit()
    s = s[:-1]
    ans -= 1

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = 1e9 + 1;

int main() {
  int r;
  cin >> r;
  cout << r*r << endl;
}


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

using namespace std;

int main()
{
    string str;
    int sum = 0;
    
    cin >> str;
    for(int i=0;i<(str.size()+1)/2;i++){
        
        if(i == str.size()-1-i && str[i] != 'i' && str[i] != 'w'){
            sum++;
        } else if(str[i] != '(' || str[str.size()-1-i] != ')'){
            if(str[i] != ')' || str[str.size()-1-i] != '('){
                if(str[i] != str[str.size()-1-i]) sum++;
                else if(str[i] == '(' || str[i] == ')') sum++;
            }
        }
    }
    
    cout << sum << endl;
    
    return 0;
}



Measured memory_bytes: 3180
#include<stdio.h> 
int main(void)
 {
  int n,i,max=-1000001,min=1000001,a;  long sum=0;    scanf("%d",&n);    for(i=0;i<n;i++){   scanf("%d",&a);   sum+=a;   if(min>a){    min=a;   }   if(max<a){    max=a;   }  }    printf("%d %d %ld\n",min,max,sum);    return 0; }

Measured memory_bytes: 600
package main

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

func main() {
	sc.Split(bufio.ScanWords)

	var h, w int
	fmt.Scan(&h, &w)
	s := make([]string, h)
	lc := make([][]int, h)
	rc := make([][]int, h)
	uc := make([][]int, h)
	dc := make([][]int, h)
	for i := 0; i < h; i++ {
		s[i] = next()

		lc[i] = make([]int, w)
		rc[i] = make([]int, w)
		uc[i] = make([]int, w)
		dc[i] = make([]int, w)
	}

	for i := 0; i < h; i++ {
		cl, cr := 0, 0
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				cl = 0
			} else {
				cl++
			}
			lc[i][j] = cl

			if s[i][w-j-1] == '#' {
				cr = 0
			} else {
				cr++
			}
			rc[i][w-j-1] = cr
		}
	}

	for j := 0; j < w; j++ {
		cu, cd := 0, 0
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				cu = 0
			} else {
				cu++
			}
			uc[i][j] = cu

			if s[h-i-1][j] == '#' {
				cd = 0
			} else {
				cd++
			}
			dc[h-i-1][j] = cd
		}
	}

	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			ans = max(
				ans,
				lc[i][j]+rc[i][j]+uc[i][j]+dc[i][j]-3,
			)
		}
	}
	fmt.Println(ans)
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 138240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef tuple<ll,ll,ll> i3;
ll n, w[1005], s[1005], v[1005];
ll dp[1005][10005];

ll solve(ll pos, ll left){
    if(left < 0) return -1e9;
    if(pos == n) return 0;
    if(dp[pos][left] != -1) return dp[pos][left];
    ll r1 = solve(pos+1, left);
    ll r2 = solve(pos+1, min(left-w[pos], s[pos]) ) + v[pos];
    return dp[pos][left] = max(r1,r2);
}

bool func(i3 a, i3 b){
    return (get<1>(a)+get<0>(a)) > (get<1>(b)+get<0>(b));
}

int main(){
    memset(dp, -1, sizeof dp);
    cin >> n;
    vector<i3> vec;
    for(ll i = 0; i < n; i++){
        ll a, b, c; cin >> a >> b >> c;
        vec.emplace_back(a, b, c);
    }
    sort(vec.begin(), vec.end(), func);
    for(ll i = 0; i < n; i++)
        tie(w[i], s[i], v[i]) = vec[i];
    ll res = 0;
    for(ll i = 0; i < n; i++)
        res = max(res, solve(i+1, s[i]) + v[i]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 78976
#include<stdio.h>
int main(){
  int n,mod;
  scanf("%d",&n);
  mod=n%10;
  if(mod==3)
    printf("bon\n");
  else if(mod==0 || mod==1 || mod==6 || mod==8)
    printf("pon\n");
  else
    printf("hon\n");
  return 0;
}


Measured memory_bytes: 1648
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n, *a = map(int, read().split())
ans = 0
l = list(range(n + 1))
r = list(range(n + 1))
memo = [0] * (n + 1)
for i, aa in enumerate(a):
    memo[aa] = i
for i in range(n, -1, -1):
    v = memo[i]
    ans += (v - l[v] + 1) * (r[v] - v + 1) * i
    l[r[v] + 1], r[l[v] - 1] = l[v], r[v]
print(ans)


Measured memory_bytes: 34632
// A.

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

using namespace std;

int main(int argc, char* argv[]) {
	int k, x;
	cin >> k >> x;
	cout << (k * 500 >= x ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vin=vector<int>;
using vll=vector<long long>;
using vvin=vector<vector<int>>;
using vvll=vector<vector<long long>>;
using vstr=vector<string>;
using vvstr=vector<vector<string>>;
using vch=vector<char>;
using vvch=vector<vector<char>>;
using vbo=vector<bool>;
using vvbo=vector<vector<bool>>;
using vpii=vector<pair<int,int>>;
using pqsin=priority_queue<int,vector<int>,greater<int>>;
#define mp make_pair
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,s,n) for(int i=(s);i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define decp(n) cout<<fixed<<setprecision((int)n)
const int inf=1e9+7;
const ll INF=1e18;

int main(){
    ll n;cin>>n;
    ll sum=(ll)0;
    rep2(i,1,n+1)sum+=(i*(n/i)*(n/i+1))/2;
    cout<<sum<<endl;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;
int main()
{
    int N, X, T;
    cin >> N >> X >> T;

    int time = N / X;
    if (N % X) time++;

    cout << time * T << endl;
    return 0;
}

Measured memory_bytes: 3632
// B - Palindrome-philia
#include <stdio.h>
#include <string.h>

int main(void){
    char s[101], s1[51], s2[51];
    scanf("%s", s);
    int len=strlen(s)-1;
    //printf("len : %d\n", len);
    if(len+1==1){puts("0"); return 0;}
    if(len+1==2){
        if(s[0]!=s[1]){puts("1"); return 0;}
        else{puts("0"); return 0;}    
    }
    int halflen;

    if(len%2==0)halflen=len/2;
    else halflen=len/2+1;

    for(int i=0; i<=halflen; i++){
        s1[i]=s[i];
        s2[i]=s[len-i];   
    }
    s1[halflen]='\0', s2[halflen]='\0';
    int cnt=0;
    for(int i=0; s1[i]!='\0' && s2[i]!='\0'; i++){
        if(s1[i]!=s2[i]){
            s1[i]=s2[i];
            cnt++;
        }   
    }
    //printf("s1 : %s, s2 : %s\n", s1, s2);
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 128
import Control.Monad
import Data.List
import Data.Bits
import Debug.Trace
import Data.Maybe
import qualified Data.ByteString.Char8 as C

main :: IO ()
main = do
  input <- readInts
  print $ length $ nub input

-- 以下ライブラリ

readInts :: IO [Int]
readInts = map (fst . fromJust . C.readInt) . C.words <$> C.getLine

readNInts :: Int -> IO [[Int]]
readNInts = flip replicateM readInts

readIntegers :: IO [Integer]
readIntegers = map (fst . fromJust . C.readInteger) . C.words <$> C.getLine

readNIntegers :: Int -> IO [[Integer]]
readNIntegers = flip replicateM readIntegers

getNLns :: Int -> IO [String]
getNLns = flip replicateM getLine

toTup2 :: [[a]] -> [(a, a)]
toTup2 = map (\ys -> case ys of y : z : zs -> (y, z))

encIdx2 :: Int -> (Int, Int) -> Int
encIdx2 mx (y, x) = y * mx + x

decIdx2 :: Int -> Int -> (Int, Int)
decIdx2 mx idx = (idx `div` mx, idx `mod` mx)

encIdx3 :: (Int, Int) -> (Int, Int, Int) -> Int
encIdx3 (my, mx) (z, y, x) = z * my * mx + y * mx + x

decIdx3 :: (Int, Int) -> Int -> (Int, Int, Int)
decIdx3 (my, mx) idx = (z, y, x)
  where
    basez = my * mx
    z = idx `div` basez
    y = (idx `mod` basez) `div` mx
    x = idx `mod` mx


Measured memory_bytes: 380
using System;

namespace ConsoleApp11
{
    class Class42
    {
        static void Main()
        {
            long N = long.Parse(Console.ReadLine());
            long ans = 0;
            if (N % 2 == 0)
            {
                for(long i = 10; i <= N; i *= 5)
                {
                    ans += N / i;
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 11092
package main
 
import (
	"fmt"
)
 
func main() {
  var a, b, c int
  fmt.Scanf("%d %d %d", &a, &b, &c)
  
  ans := "No"
  if a + b >= c {
    ans = "Yes"
  }
  fmt.Printf("%s\n", ans)
}

Measured memory_bytes: 1832
#include <iostream>
using namespace std;
int main () {
    
    long int n ;
    long long max = 1000000;
    long long min = -1000000;
    long long sum = 0;
    long long a ;
    
    cin >> n ;
    
    for ( int i = 0; i < n; i ++) {
        cin >> a;
        if ( a < max ) max = a;
        if ( a > min ) min = a;
        sum += a;
    }
    
    cout << max << " " << min << " " << sum << endl;
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <string>
using namespace std;
int main() {
    string s;
    cin >> s;
    int ans = 1;
    if (s == "RRR")
        ans = 3;
    else if (s == "RRS" || s == "SRR")
        ans = 2;
    else if (s == "SSS")
        ans = 0;
    cout << ans << '\n';
}

Measured memory_bytes: 3612
def num2alpha(num):
    if num<=26:
        return chr(96+num)
    elif num%26==0:
        return num2alpha(num//26-1)+chr(122)
    else:
        return num2alpha(num//26)+chr(96+num%26)

N = int(input())
#alphabet = [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z]
print(num2alpha(N))



Measured memory_bytes: 9156
#include<stdio.h>
int main(){
  int s[10000],t[500],n,q,i,j,count=0,k;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
   scanf("%d",&q);
  for(i=0;i<q;i++){
    scanf("%d",&t[i]);
  }
  for(i=0;i<q;i++){
    k=t[i];
      for(j=0;j<n;j++){
	if(k==s[j]){
	  count++;
	  break;
	}
      }
  }
  printf("%d\n",count);
  return 0;
}

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

using namespace std;

#define topper top //XDDDDDDD

#define mp make_pair
#define pb push_back
#define db(x) cerr << #x << " == " <<  x << endl;
#define _ << " " <<

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

const long double EPS = 1e-9;
const int N=1e4+5;
const int MOD=1e9+7;
const int INF=0x3f3f3f3f;

ll a[N], b[N];
ll need, offer;
int n;

int main(){
  scanf("%d", &n);
  for(int i=0; i<n; i++) scanf("%lld", &a[i]);
  for(int i=0; i<n; i++) scanf("%lld", &b[i]);

  int p = 0;
  while(a[p] <= b[p] and p < n) p++;

  for(int i=0; i<n; i++) {
    if(p == n) return printf("Yes\n"), 0;
    /*
    printf("There is a problem with index %d...\n", p);
    printf("%lld %lld\n", a[i], b[i]);
    */
    if(a[i] <= b[i]) {
      ll dif = b[i] - a[i];
      ll diff = dif/2;

      while(b[p] < a[p] and diff and p < n) {
        ll dif2 = a[p] - b[p];
        //printf("the current difference is %lld\n", dif2);
        b[p] = b[p] + min(diff, dif2);
        diff -= min(diff, dif2);
        while(a[p] <= b[p] and p < n) p++;
      }
      a[i] = b[i];
    }
  }

  printf("%s\n", p == n ? "Yes" : "No");

  return 0;
}



Measured memory_bytes: 384