akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::*;
#[allow(unused_imports)]
use std::iter;
#[allow(unused_imports)]
use std::mem::*;
#[allow(unused_imports)]
use std::str::*;
#[allow(unused_imports)]
use std::usize;

#[allow(unused_macros)]
macro_rules! read_cols {
    ($($t:ty),+) => {{
        let mut line = String::new();
        stdin().read_line(&mut line).unwrap();

        let mut it = line.trim()
            .split_whitespace();

        ($(
            it.next().unwrap().parse::<$t>().ok().unwrap()
        ),+)
    }}
}

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();
    line.trim().to_string().parse().ok().unwrap()
}

#[allow(dead_code)]
fn read_vecl<T: FromStr>(n: usize) -> Vec<T> {
    let mut v = vec![];
    for _ in 0..n {
        v.push(read::<T>());
    }

    v
}

#[allow(dead_code)]
fn read_vec<T: FromStr>() -> Vec<T> {
    let mut line = String::new();
    stdin().read_line(&mut line).unwrap();

    line.trim()
        .split_whitespace()
        .map(|s| s.parse().ok().unwrap())
        .collect()
}

fn main() {
    let (x, a, b) = read_cols!(i64, i64, i64);

    let da = (x - a).abs();
    let db = (x - b).abs();

    if da < db {
        println!("A");
    } else {
        println!("B");
    }
}


Measured memory_bytes: 4352
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>

using namespace std;

//----------------------- Print Function ----------------------//

inline void print() {
    cout << endl;
}
template <typename First, typename... Rest>
void print(const First &first, const Rest &... rest) {
    cout << first << ' ';
    print(rest...);
}

template <typename T>
void print(const vector<T> &v) {
    for (auto e : v) cout << e << ' ';
    cout << endl;
}

//------------------------- Libraries -------------------------//

//--------------------------- Solve ---------------------------//

void solve() {
    string s, t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    cout << (s < t ? "Yes" : "No") << '\n';
}

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

    solve();

    return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
#include <functional>
#include <set>
#include <map>
#include <queue>
#include <cmath>
#include <stack>

using namespace std;
int an[200005];
int bn[3000];
int main() {
	string s;
	cin >> s;
	int r=1 ;
	int ans = 0;
	const int mod = 2019;
	for (int i = s.size() - 1; i >=0; i--) {
		int u = s[i] - '0';
		int p = (r * u % mod+an[i+1])%mod;
		an[i] = p;
		bn[p]++;
		r = r * 10 % mod;

	}
	
	for (int i = 0; i < 2019; i++) {
		ans += bn[i] * (bn[i] - 1) / 2;
	}
	cout << ans + bn[0];
}

Measured memory_bytes: 4540
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# ------------------- fast io --------------------
from math import gcd, ceil

def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi


def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans

def lcm(a, b): return a * b // gcd(a, b)


def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


for _ in range(int(input()) if not True else 1):
    #n = int(input())
    #n, k = map(int, input().split())
    #a, b = map(int, input().split())
    #c, d = map(int, input().split())
    #a = list(map(int, input().split()))
    #b = list(map(int, input().split()))
    s = input()
    ans = 0
    cur = 0
    for i in s:
        if i == "R":
            cur += 1
        else:
            ans = max(ans, cur)
            cur = 0
    print(max(ans, cur))
        

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

int main() {
  int H, W; cin >> H >> W;
  int N; cin >> N;
  int a[10300];
  for(int i = 0; i < N; ++i) {
    cin >> a[i];
  }
  int ans[H][W];
  int x = 0;
  for(int i = 0; i < N; ++i) {
    for(int j = 0; j < a[i]; ++j) {
      int ni = x / W, nj = x % W;
      if(ni & 1) nj = W - nj - 1;
      ans[ni][nj] = i + 1;
      ++x;
    }
  }
  for(int i = 0; i < H; ++i) {
    for(int j = 0; j < W; ++j) {
      cout << ans[i][j];
      if(j == W-1) cout << endl;
      else cout << " ";
    }
  }
  return 0;
}



Measured memory_bytes: 384
import sys
#import numpy as np

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split())) # applies to numbers only
rs = lambda: stdin.readline().rstrip()  # ignore trailing spaces

N, M = rl()
solve = [False] * (N+1)
count = [0] * (N+1)
penalty = 0
for i in range(M):
    p, s = input().split()
    p = int(p)
    if solve[p]:
        continue
    if s == 'WA':
        count[p] += 1
    else:
        solve[p] = True
        penalty += count[p]

print(sum(solve), penalty)


Measured memory_bytes: 4596
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<cstring>
#include<string>
#include<iostream>
#include<vector>
using namespace std;
int small(int a,int b){
	return a<b?a:b;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int ans=1;
	int n,k;
	scanf("%d%d",&n,&k); 
	for(int i=1;i<=n;i++)
	{
		ans+=min(ans,k);
	}
	printf("%d",ans);
	printf("\n");
	return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const double PI = 3.1415926535897932384626433832795;
const ll MOD = 1000000007;

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

int gcd(int x, int y) { return y ? gcd(y, x % y) : abs(x); }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : abs(x); }
int lcm(int x, int y) { return x / gcd(x, y) * y; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }

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

	ll n;
	cin >> n;

	vector<string> s(n);
	for (auto &v : s) {
		cin >> v;
	}

	vector<string> sortS = s;
	for (auto &v : sortS) {
		sort(begin(v), end(v));
	}

	map<string, ll> mp;
	for (int i = 0; i < n; i++) {
		mp[sortS[i]]++;
	}

	ll ans = 0;
	for (auto p : mp) {
		if (p.second == 1LL) {
			continue;
		}

		ans += p.second * (p.second - 1LL) / 2LL;
	}

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


Measured memory_bytes: 22144
#include <iostream>
#include <cstdio>

using namespace std;

void swap(int *var1, int *var2) {
  int tmp = *var1;
  *var1 = *var2;
  *var2 = tmp;
}

int main() {
  int w;
  int n;

  cin >> w;
  cin >> n;

  int vertical_line[w];
  for (int v_i = 0; v_i < w; v_i++)
    vertical_line[v_i] = v_i+1;

  for (int n_i = 0; n_i < n; n_i++) {
    int node1, node2;
    scanf("%d,%d", &node1, &node2);
    swap(vertical_line+node1-1, vertical_line+node2-1);    
  }

  for (int v_i = 0; v_i < w; v_i++)
    cout << vertical_line[v_i] << endl;

  return 0;
}

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

int n;
int a[100055];
int dp[100055];

int main() {
	cin >> n;
	
	for (int i = 0; i < n; i++) {
		scanf("%d", &a[i]);
	}
	
	memset(dp, 63, sizeof(dp));
	
	dp[0] = 0;
	
	for (int i = 0; i < n; i++) {
		dp[i + 1] = min(dp[i + 1], dp[i] + abs(a[i] - a[i + 1]));
		dp[i + 2] = min(dp[i + 2], dp[i] + abs(a[i] - a[i + 2]));
	}
	
	cout << dp[n - 1];
}


Measured memory_bytes: 1024
#include <iostream>
int main(){
  int A,B,C;
  std::cin >> A >> B >> C;
  if( (A + B + C) == 17 ){
    if(A == 5 || B == 5 || C == 7){
      std::cout << "YES" << std::endl;
    }
    else if(A == 5 || B == 7 || C == 5){
      std::cout << "YES" << std::endl;
    }
    else if(A == 7 || B == 5 || C == 5){
      std::cout << "YES" << std::endl;
    }
  }
  else {
   std::cout << "NO" << std::endl; 
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>

int main(void){
    long int X,i;
    scanf("%ld",&X);
    long int A=pow((double)X,0.2);
    //B<0
    for(i=A;i>0;i--){
        long int c=pow(i,5);//A^5
        long int B=pow((X-c),0.2);//(A^5-X)^(1/5)
        if((long int)(pow(i,5)+pow(B,5))==X){
           printf("%ld %ld\n",i,-B);
           return 0;
        }
    }
    //B>0
    i=A+1;
    while(1){    
        long int c=pow(i,5);
        long int B=pow(c-X,0.2);
        if((long int)(pow(i,5)-pow(B,5))==X){
           printf("%ld %ld\n",i,B);
           return 0;
        }
        i++;
    }
    return 0;
}

Measured memory_bytes: 2616
S = gets
n = (S.size - 1)
i = 0
batsu = 0
while i < n
  if (i + 1).even? && (S[i] == 'L' || S[i] == 'U' || S[i] == 'D')
  elsif (i + 1).odd? && (S[i] == 'R' || S[i] == 'U' || S[i] == 'D')
  else
    batsu = 1
  end
  i += 1
end
puts 'Yes' if batsu == 0
puts 'No' if batsu == 1


Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include <cmath>
#include <iomanip>
#include <functional>



using namespace std;

int main(){
  int x,y,z;
  cin>>x>>y>>z;
  
  cout<<z<<" "<<x<<" "<<y;
  
  
  
  return 0;
}

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

using namespace std;

#define mod1 1000000007
#define mod2 998244353
#define int long long int
#define pii pair<int,int>
#define vpii vector<pii>
#define vi vector<int>
#define fi first
#define se second
#define psb push_back
#define ppb pop_back
#define fio ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL)
#define all(x) x.begin(),x.end()
// #define endl "\n"

int w[10][10];
int w2[10][10];

void solve()
{
	int n,m,k2;
	cin>>n>>m>>k2;

	for(int i=0;i<n;i++)
	{
		string s;
		cin>>s;
		for(int j=0;j<m;j++)
		{
			char c=s[j];
			w[i][j]=(c=='#'?1:0);
		}
	}
	int ans=0;
	for(int i=0;i<(1ll<<n);i++)
	{
		for(int j=0;j<(1ll<<m);j++)
		{
			for(int p=0;p<n;p++)
				for(int q=0;q<m;q++)
					w2[p][q]=w[p][q];
			for(int k=0;k<n;k++)
			{
				if((i>>k)&1)
					for(int p=0;p<m;p++)
						w2[k][p]=0;
			}
			for(int k=0;k<m;k++)
			{
				if((j>>k)&1)
					for(int p=0;p<n;p++)
						w2[p][k]=0;
			}
			int ct=0;
			for(int p=0;p<n;p++)
				for(int q=0;q<m;q++)
					if(w2[p][q]==1)
						ct++;
			if(ct==k2)
				ans++;
		}
	}
	cout<<ans<<endl;
}	

int32_t main()
{
	fio;
	int t;
	// cin>>t;
	t=1;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 3652
#include <stdio.h>

#define N 100002

int Partition(int A[],int p,int r);

int i,j;

main(){
  int n,A[N],c;
  scanf("%d",&n);
  for(i = 0; i < n; i++){
    scanf("%d",&A[i]);
  }
  c = Partition(A,0,n-1);
  for(i = 0; i < n-1; i++){
    if(i == c){
      printf("[%d] ",A[i]);
    }else{
      printf("%d ",A[i]);
    }
  }
  printf("%d\n",A[n-1]);
  return 0;
}
  
int Partition(int A[],int p,int r){
  int x,y,z;
  x = A[r];
  i = p-1;
  for(j = p; j < r; j++){
    if(A[j] <= x){
      i++;
      y = A[i];
      A[i] = A[j];
      A[j] = y;
    }
  }
  z = A[i+1];
  A[i+1] = A[r];
  A[r] = z;
  return i+1;
}
 

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

using namespace std;

int k[10000];

int main()
{
	int N;
	scanf("%d", &N);
	for (int i = 0; i < N; ++i)
		scanf("%d", &k[i]);
	sort(k, k + N);
	long long mx = 0;
	for (int i = 0; i < N; ++i)
	{
		if (k[i] > mx + 1)
			break;
		else
			mx += k[i];
	}
	printf("%lld\n", mx + 1);
	return 0;
}

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

int dh[4] = {0, 1, 0, -1};
int dw[4] = {1, 0, -1, 0};
vector<string> field;

int main() {
  int H,W,i,j;
  pair<int,int> p;
  cin >> H >> W;
  field.resize(H);
  for(i=0; i<H; i++)
    cin >> field.at(i);

  vector<vector<int>> d(H, vector<int>(W,-1));
  queue<pair<int,int>> q;

  for(i=0; i<H; i++)
    for(j=0; j<W; j++)
      if(field.at(i).at(j) == '#') {
        q.push(make_pair(i,j));
        d.at(i).at(j) = 0;
      }


  while(!q.empty()) {
    p = q.front();
    q.pop();

    for(i=0; i<4; i++) {
      int nh=p.first+dh[i], nw=p.second+dw[i];
      if(nh>=0 && nw>=0 && nh<H && nw<W &&
         field.at(nh).at(nw)=='.' && d.at(nh).at(nw)==-1) {
        if(d.at(nh).at(nw)==-1)
          d.at(nh).at(nw) = d.at(p.first).at(p.second)+1;
        else
          d.at(nh).at(nw) = min(d.at(nh).at(nw), d.at(p.first).at(p.second)+1);
      	q.push(make_pair(nh, nw));
      }
    }
  }

  cout << d.at(p.first).at(p.second) << endl;
}

Measured memory_bytes: 13456
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<ctime>
#include<iostream>
typedef long long LL;
using namespace std;
const int maxn = 1e6;
int main()
{
	LL a , b , c;
	LL K;
	while( cin >> a >> b >> c ){
		cin >> K;
		LL MAX = 0,sum = 0;
		MAX = max( MAX , a );
		MAX = max( MAX , b );
		MAX = max( MAX , c );
		sum = a + b + c;
		int flag = 0;
		if( a == MAX && flag == 0 )	sum -= a , flag = 1;
		if( b == MAX && flag == 0 )	sum -= b , flag = 1;
		if( c == MAX && flag == 0 )	sum -= c , flag = 1;
		for( int i = 1 ; i <= K ; i++ ){
			MAX *= 2;
		}
		sum += MAX;
		cout << sum << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#include <float.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rrep(i, n) for(int i = 0; i <= (n); i++)
using namespace std;
typedef long long ll;
 
const ll INF = 1LL<<62;
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; }
// 多次元 vector 生成
template<class T>
vector<T> make_vec(size_t a){
    return vector<T>(a);
}
template<class T, class... Ts>
auto make_vec(size_t a, Ts... ts){
  return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}

const int MOD = 1000000007;

ll gcd(ll x, ll y){
    if (y==0) return x;
    else return gcd(y, x%y);
}

ll lcm(ll a, ll b){
    ll g = gcd(a, b);
    return a / g * b;
}
int main(){
    int N; cin >> N;
    vector<ll> T(N);
    rep(i,N) cin >> T[i];

    ll ans = T[0];
    for (int i = 1; i < N; i++){
        ans = lcm(ans, T[i]);
    }

    cout << ans << endl;
}

Measured memory_bytes: 3560
import sys
stdin = sys.stdin

sys.setrecursionlimit(10**5)

def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
a = list(li())

ans = 0
for ai in a:
    b = bin(ai)[2:]
    ans += b[::-1].index("1")
    
print(ans)

Measured memory_bytes: 4084
#include<bits/stdc++.h>
using namespace std;
using ll = int64_t;
int main(){
    ll N, X;
    cin >> N >> X;
    ll a[N];
    for(ll i = 0; i < N; i++){
        cin >> a[i];
    }
    sort(a, a + N);
    ll sum = 0;
    ll ans = 0;
    for(ll i = 0; i < N; i++){
        if(sum + a[i] <= X){
            sum += a[i];
            ans++;
        }
    }
    if(ans == N && sum < X) cout << N - 1;
    else cout << ans;
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1e9;

using namespace std;

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

int main()
{
    int N;
    cin >> N;
    int a[100];
    for(int i = 0; i < N; ++i) cin >> a[i];
    sort(a, a+N);
    int ans = 0;
    for(int i = 1; i < N; ++i){
        ans += abs(a[i] - a[i-1]);
    }
    cout << ans << endl;
    return 0;
}

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

int n = 1000000;

bool prime[1000001];

void sieve(){
    memset(prime,true,sizeof(prime));
    
    for(int i = 2; i * i <= n; ++i){
        
        if(prime[i]){
            for(int j = i * i; j <= n; j += i){
                prime[j] = false;
            }
        }
             
    }
    // for(int i = 2; i <= n; ++i){
    //     if(prime[i]){
    //         cout << i << " ";
    //     }
    // }    
}
int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    // sieve();
    vector<bool> v1(n,false);
    int cnt = 0;
    for(int i = 0; i < n; ++i){
        cin >> v[i];
    }
    map<int,int> mp;
    for(int i = 0; i < n; ++i){
        int x = v[i];
        for(int j = 2; j * j <= x; ++j){
            if(x % j == 0){
                mp[j]++;
                while(x % j == 0){
                    x /= j;
                }
            }
        }
        if(x != 1){
            // in case of 15 and so on..
            mp[x]++;
        }
    }
    bool b = true;
    for(auto e : mp){
        if(e.second >= 2){
            b = false;
        }
    }
    if(b){
        cout << "pairwise coprime" << endl;
        return 0;
    }
    
    int gcd = v[0];
    
    for(int i = 1; i < n; ++i){
        gcd = __gcd(gcd,v[i]);
    }
    
    if(gcd == 1){
        cout << "setwise coprime" << endl;
        return 0;
    }
    
    cout << "not coprime" << endl;
	return 0;
}


Measured memory_bytes: 10804
#include<bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);	
	char c;
	cin >> c;
	cout << char(c+1) << endl;	
}


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

using namespace std;
typedef long long ll;

int main(){
  string S, T;
  cin >> S >> T;
  
  bool ret = true;
  if(S.size() + 1 != T.size()) ret = false;
  if(ret){
    for(int i=0; i<S.size(); i++){
      if(S[i] != T[i]){
        ret = false;
        break; 
      }
    }
  }
  
  string rets = ret ? "Yes" : "No";
  cout << rets << endl;
  return 0;
}

Measured memory_bytes: 3628
import string
low = string.ascii_lowercase
#print(low)
N = int(input())
st = ''
while N != 0:
    rem = N%26
    if rem == 0:
        rem = 26
    N -= rem
    N = N//26
    st += low[rem-1]
    #print(rem)
print(st[::-1])

Measured memory_bytes: 9980
#include <stdio.h>
#include <ctype.h>
int main()
{
    int ch,i=0;
    int f[10]={0};
    while((ch=getchar())!='\n'){
        f[i]=ch;
        if(isprint(ch))
            i++;
    }
    int a=0,min=753,b;
    for(a=0;a<=7&&f[a+2]!=0;a++){
        b=(f[a]-48)*100+(f[a+1]-48)*10+f[a+2]-48;
        if(b>753){
            if((b-753)<min)
                min=b-753;
        }else if(753>b){
            if((753-b)<min)
                min=753-b;
        }else
            min=0;
    }
    printf("%d",min);
    return 0;
}


Measured memory_bytes: 128
N = gets.to_i
S = gets.chomp

ans = 0
(?0..?9).each{|a|
  offset1 = S.index(a)
  next if offset1.nil?
  offset1 += 1
  (?0..?9).each{|b|
    offset2 = S.index(b, offset1)
    next if offset2.nil?
    offset2 += 1
    (?0..?9).each{|c|
      if S.index(c, offset2)
        ans += 1
      end
    }
  }
}
p ans

Measured memory_bytes: 3836
#include <cstdio>
#define ri register int
typedef long long ll;
const int N=5e5+5,mod=998244353;
int fac[N],ifac[N];
inline int fpow(ri a,ri b){
	ri ans=1;
	for(;b;b>>=1,a=(ll)a*a%mod)
		if(b&1) ans=(ll)ans*a%mod;
	return ans;
}
inline int C(ri n,ri m){
	return m<0||n<m?0:(ll)fac[n]*ifac[m]%mod*ifac[n-m]%mod;
}
inline int _del(ri x,ri y){
	return (x-=y)<0?x+mod:x;
}
inline int calc(ri n,ri m,ri l){ // y-x < l
	return l<=0?0:_del(C(n+m,m),C(n+m,m-l));
}
inline void add(int &x,ri y){
	x=(x+=y)>=mod?x-mod:x;
}
int main(){
	ri n,k,i,R,B,ans;
	scanf("%d%d",&n,&k);
	fac[0]=1;
	for(i=1;i<=k;++i) fac[i]=(ll)fac[i-1]*i%mod;
	ifac[k]=fpow(fac[k],mod-2);
	for(i=k;i;--i) ifac[i-1]=(ll)ifac[i]*i%mod;
	ans=0;
	if(~k&1){
		R=B=k>>1;
		/*
		(0,0) -> (R,B-1)
		choose N-1 pairs
		y-x <= B-1-(N-1) -> y-x < B-N+1
		*/
		ans=calc(R,B-1,B-n+1);
	}
	for(R=k/2+1;R<=k;++R)
		B=k-R,
		/*
		(0,0) -> (R,B)
		choose max(0,N-(R-B)) pairs
		y-x <= B-(N-(R-B)) -> y-x<R-N+1
		*/
	//	printf("%d %d %d %d\n",R,B,R-n+1,calc(R,B,R-n+1)),
		add(ans,calc(R,B,R-n+1));
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl

int main() {
  int A, B;  cin >> A >> B;

  if (A>=13) print(B);
  else if (A <= 5) print(0);
  else print(B/2);
}

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

int main() {
    ll n, d;
    cin >> n >> d;
    d *= d;
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        ll x, y;
        cin >> x >> y;
        ll dist = x * x + y * y;
        if (dist <= d) ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define lper(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[4]={1,0,-1,0};
const ll dx[4]={0,-1,0,1};
long long fac(ll a){
    long long ans=1;
    while(a>1){
        ans*=a;
        ans%=1000000007;
        a--;
    }
    return ans;
}
int main(){
    int n,ans=0;cin >> n;
    for(int i=1;i<=n;i+=2){
        int count=0;
        for(int j=1;j<=i;j++){
            if(i%j==0)count++;
        }
        if(count==8)ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define pb push_back
int main()
{
	string s = "AIDUNYAN",t="AIZUNYAN";
	vector<string> v;
	string Z;
	cin >> Z;
	sort(s.begin(),s.end());
	do{
		v.pb(s);
	}while(next_permutation(s.begin(),s.end()));
	sort(v.begin(),v.end());
	for(int i=0;i<Z.size();i++)
	{
		vector<string>::iterator it;
		string sub = Z.substr(i,8);
		it=lower_bound(v.begin(),v.end(),sub);
		if(it!=v.end())
		{
			if(*it!=sub)continue;
			for(int j=i;j<i+8;j++)Z[j]=t[j-i];
			i+=7;
		}
	}
	cout << Z << endl;
	return 0;
}

Measured memory_bytes: 1680
K, N =map(int, input().split())
A = list(map(int, input().split()))
D = [A[i+1]-A[i] for i in range(len(A) -1)]
d = A[0] + (K - A[-1])
j = max(D)
if d < j:
    ans = K-j
else:
    ans = K -d
print(ans)

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

int main() {
  string s; cin >> s;
  if ((s[0] == s[1] && s[2] == s[3] && s[0]!=s[2]) || (s[0] == s[2] && s[1] == s[3] && s[0]!=s[1]) || (s[0] == s[3] && s[1] == s[2] && s[0]!=s[1])) {
    cout << "Yes" << endl; 
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++){
        cin >> a.at(i);
    }
    int check = 0;
    int num = 0;
    int cost = 1000000;

    for(int i = -100; i < 101; i++){
        for(int j = 0; j < n; j++){
            check += pow(a.at(j) - i, 2);
        }
        if(check < cost){
            cost = check;
        }
        check = 0;
    }

    cout << cost << endl;
    
}

Measured memory_bytes: 256
import java.util.*

fun main(args : Array<String>) {
    println(inOutExec(Scanner(System.`in`)))
}

fun inOutExec(scanner: Scanner): String {
    val num = scanner.nextInt()
    val prises = IntArray(num)
    var maxIndex = 0
    repeat(num) {
        val prise = scanner.nextInt()
        prises[it] = prise
        if (prise > prises[maxIndex]) {
            maxIndex = it
        }
    }

    prises[maxIndex] = (prises[maxIndex] / 2)

    return prises.reduce { s1, s2 -> s1 + s2 }.toString()
}

Measured memory_bytes: 31276
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

int main(){
  int n, s;
  cin >> n >> s;
  vector<int> a(n);
  rep(i, n) cin >> a.at(i);
  vector<vector<mint>> dp(n+1, vector<mint>(s+1, 0));
  dp.at(0).at(0) = 1;
  rep(i, n){
    rep(j, s+1) dp.at(i+1).at(j) += dp.at(i).at(j)*2;
    rep(j, s-a.at(i)+1){
      dp.at(i+1).at(j+a.at(i)) += dp.at(i).at(j);
    }
  }
  // rep(i, n+1){
  //   rep(j, s+1) cerr << dp.at(i).at(j).x << " ";
  //   cerr << endl;
  // }
  cout << dp.at(n).at(s).x << endl;
  return 0;
}

Measured memory_bytes: 73672
import java.util.*;class Main{public static void main(String[]z){Map<String,Integer>m=new TreeMap<String,Integer>();String t="",l="";for(Scanner s=new Scanner(System.in);s.hasNext();l=l.length()<t.length()?t:l)m.put(t=s.next(),m.containsKey(t)?m.get(t)+1:1);for(String i:m.keySet())if(m.get(i)==Collections.max(m.values()))t=i+" ";System.out.println(t+l);}}

Measured memory_bytes: 11000
<?php
//error_reporting(0);
$S = trim(fgets(STDIN));
//$P = explode(" ",trim(fgets(STDIN)));
//$H = array_map('intval',explode(" ",trim(fgets(STDIN))));
//function chmax(&$a,$b) {if ($a<$b){$a=$b;return true;}return false;}
//function chmix(&$a,$b) {if ($a>$b){$a=$b;return true;}return false;}

$l=strlen($S);
printf("%s\n",str_repeat("x",$l));


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

// Graph class represents a undirected graph
// using adjacency list representation
class Graph
{
    // No. of vertices
    int V;

    // Pointer to an array containing adjacency lists
    list<int> *adj;

    // A function used by DFS
    void DFSUtil(int v, bool visited[]);

public:
    // Constructor
    Graph(int V);

    void addEdge(int v, int w);
    int NumberOfconnectedComponents();
};

// Function to return the number of
// connected components in an undirected graph
int Graph::NumberOfconnectedComponents()
{

    // Mark all the vertices as not visited
    bool *visited = new bool[V];

    // To store the number of connected components
    int count = 0;
    for (int v = 0; v < V; v++)
        visited[v] = false;

    for (int v = 0; v < V; v++)
    {
        if (visited[v] == false)
        {
            DFSUtil(v, visited);
            count += 1;
        }
    }

    return count;
}

void Graph::DFSUtil(int v, bool visited[])
{

    // Mark the current node as visited
    visited[v] = true;

    // Recur for all the vertices
    // adjacent to this vertex
    list<int>::iterator i;

    for (i = adj[v].begin(); i != adj[v].end(); ++i)
        if (!visited[*i])
            DFSUtil(*i, visited);
}

Graph::Graph(int V)
{
    this->V = V;
    adj = new list<int>[V];
}

// Add an undirected edge
void Graph::addEdge(int v, int w)
{
    adj[v].push_back(w);
    adj[w].push_back(v);
}

// Driver code
int main()
{
    int n, m;
    cin >> n >> m;
    Graph g(n);

    for (int i = 0; i < m; i++)
    {
        int a, b;
        cin >> a >> b;
        g.addEdge(a - 1, b - 1);
    }

    cout << g.NumberOfconnectedComponents() - 1;

    return 0;
}


Measured memory_bytes: 13532
import sys
input = sys.stdin.readline
 

class BIT:
            
    def __init__(self, L):
        self.N = len(L)
        self.bit = [0]*self.N
        for i,l in enumerate(L):
            self.add(i,l)

    def add(self, a, w):
        x = a + 1
        for i in range(1000):
            self.bit[x-1] += w
            x += x & -x
            if x > self.N:
                break

    def sum(self, a):
        x = a+1
        ret = 0
        for i in range(1000):
            ret += self.bit[x-1]
            x -= x & -x
            if x <= 0:
                break        
        return ret

 
N = int(input())
point = [list(map(int,input().split())) for i in range(N)]
 
point.sort(lambda x: x[1])
for i in range(len(point)):
    point[i][1] = i
 
mod = 998244353
 
ans = ((N-4)*pow(2,N,mod)+3*N+4)%mod
 
pow2 = []
a = 1
for i in range(N+1):
    pow2.append(a)
    a *= 2
    a %= mod
 
point.sort(lambda x: x[0])
 
bit = BIT([0]*len(point))
 
 
for i,(x,y) in enumerate(point):
    if y > 0:
        ld = bit.sum(y-1)
        #ls = i//2
    else:
        ld = 0
    lu = i-ld
    rd = y - ld
    ru = N - i - 1 - rd    
    ans += pow2[lu]-1
    ans += pow2[ld]-1
    ans += pow2[ru]-1
    ans += pow2[rd]-1
    ans %= mod
    bit.add(y,1)
 
print(ans)

Measured memory_bytes: 97316
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ull unsigned long long
#define vi vector<ll>
#define vvi vector<vi>
#define DBG_N(hoge) cerr<<" "<<(hoge)<<endl;
#define DBG cerr<<"!"<<endl;
#define BITLE(n) (1LL<<((ll)n))
#define BITCNT(n) (__builtin_popcountll(n))
#define SUBS(s,f,t) ((s).substr((f)-1,(t)-(f)+1))
#define ALL(a) (a).begin(),(a).end()
using namespace std;
struct Grid{
  ll x,y,t;
};
ll vx[4] = {1,0,-1,0};
ll vy[4] = {0,1,0,-1};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n,m;
  while(cin>>n>>m,n){
    string s[m+1];
    ll cnt = 0;
    pair<ll,ll>start;
    vi num;
    vector<pair<ll,ll>>kitanai(33);
    ll dist[33][33];
    for(int i=0;i<33;i++)for(int j=0;j<33;j++)dist[i][j] = llINF;

    for(int i=0;i<m;i++){
      cin>>s[i];
      for(int j=0;j<n;j++){
	if(s[i][j] == 'o'){
	  kitanai[0] = mp(i,j);
	  s[i][j] = '0';
	}else if(s[i][j] == '*'){
	  kitanai[cnt+1] = mp(i,j);
	  s[i][j] = (char)(cnt+1+'0');
	  num.pb(cnt+1);
	  cnt++;
	}
      }
    }

    for(int i=0;i<kitanai.size();i++){
      queue<Grid>que;
      que.push({kitanai[i].F,kitanai[i].S,0});
      bool visited[33][33] = {};
      visited[kitanai[i].F][kitanai[i].S] = true;
      while(!que.empty()){
	Grid g = que.front();
	que.pop();
	for(int k=0;k<4;k++){
	  ll x = g.x+vx[k];
	  ll y = g.y+vy[k];
	  if(x < 0 || x >= m || y < 0|| y >= n ||
	     s[x][y] == 'x' || visited[x][y])continue;

	  visited[x][y] = true;
	  if(s[x][y] != '.'){
	    dist[i][s[x][y]-'0'] = g.t+1;
	    dist[s[x][y]-'0'][i] = g.t+1;
	  }
	  que.push({x,y,g.t+1});
	}
      }
    }
    ll ans = llINF;
    do{
      ll sum = 0;
      sum += dist[0][num[0]];
      for(int i=1;i<num.size();i++){
	sum += dist[num[i-1]][num[i]];
      }
      ans = min(ans,sum);
    }while(next_permutation(ALL(num)));
    if(ans == llINF)cout<<-1<<endl;
    else cout<<ans<<endl;
  }
  return 0;
}



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

int keta(int x){
    int n = 1;
    int x0 = x;
    while (true){
        cout << x0 << endl;
        x0/=10;
        if (x0==0) break;
        n++;
    }
    return n;
}

int differrent(int x,int y,int keta){
    int n=0;
    for (int i=0;i<keta;i++){
        if (x%10!=y%10) n++;
        x/=10;
        y/=10;
    }
    return n;
}

int ten(int x){
    int n=1;
    for (int i=0;i<x-1;i++) n*= 10;
    return n;
}

int zeroone(int keta){
    int n = 0;
    for (int i = keta;i>0;i-=2) n+= ten(i);
    return n;
}




int main() {
    string S;
    cin >> S;
    
    int Slen = (int)(S.length());
//    cout << Slen << endl;
    int n1 = 0;
    int n2 = 0;
    for (int i=0;i<Slen;i++){
        if (i%2==0){
            if (S.at(i)=='0') n1++;
            else n2++;
        } else {
            if (S.at(i)=='1') n1++;
            else n2++;
        }
    }
    cout << min(n1,n2) << endl;

//    int k = keta(S);
//    int x1 = zeroone(k);
//    int x2 = zeroone(k-1);

//    cout << k << endl;
    
//    int n1 = differrent(x1, S, k);
//    int n2 = differrent(x2, S, k);
//
//    cout << min(n1,n2) << endl;
    
//    int N;
//    cin >> N;
//    vector<int> H(N);
//    for (int i=0;i<N;i++) cin>>H.at(i);
//    int Hmax = 0;
//    int n = 0;
//    for (int i=0;i<N;i++) {
//        if (H.at(i)>=Hmax){
//            n++;
//            Hmax = H.at(i);
//        }
//    }
//    cout << n << endl;
    
//    int A,B;
//    cin >> A >> B;
//    int c;
//    if (A==B) c=2*A;
//    else if (A>B) c=2*A-1;
//    else c=2*B-1;
//    cout << c << endl;
    
    
    
//    vector<int> a(M);
//    vector<int> b(M);
//    vector<int> n(N);
    
//    for (int i=0;i<M;i++) cin>>a.at(i)>>b.at(i);
//    for (int i=0;i<N;i++) {
//        n.at(i) = 0;
//        for (int j=0;j<M;j++){
//            if (a.at(j)==i+1) n.at(i)++;
//            if (b.at(j)==i+1) n.at(i)++;
//        }
//        cout << n.at(i) << endl;
//    }
}


Measured memory_bytes: 512
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final int m = scanner.nextInt();
        scanner.nextLine();
        final int[] a = Arrays.stream(scanner.nextLine().split(" ")).mapToInt(Integer::parseInt).toArray();

        final PriorityQueue<Integer> queue = new PriorityQueue<>((x, y) -> y - x);
        for (int i: a) {
            queue.add(i);
        }

        for (int i = 0; i < m; i++) {
            int price = queue.poll();
            queue.add(price / 2);
        }

        long sum = 0;
        while (!queue.isEmpty()) {
            sum += queue.poll();
        }

        System.out.println(sum);
    }
}

Measured memory_bytes: 53484
/** Author : Parth Prajapati
 * 	Institute : Pandit Deendayal Petroleum University
**/
#include<bits/stdc++.h>

using namespace std;

int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	long long int h,n,i,sum=0;
    cin>>n>>h;
    long long int a[n];
    for(i=0;i<n;++i)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    reverse(a,a+n);
    for(i=h;i<n;++i)
    {
        sum += a[i];
    }
    cout<<sum;
	return 0;
}

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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<int,int> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

int d[100010];
bool used[100010];
vector<pair<int,int>> G[100010];

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

  int k;
  cin >> k;
  REP(i,k) d[i] = inf;
  for (int i = 1; i < k; i++) {
    G[i].pb({(i+1)%k, 1});
    G[i].pb({(i*10)%k, 0});
  }
  d[1] = 1;
  priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> pq;
  pq.push({1,1});
  while (!pq.empty()) {
    pair<int,int> tpp = pq.top();
    int tp = tpp.se;
    pq.pop();
    if (used[tp]) continue;
    used[tp] = 1;
    REP(i,G[tp].size()) {
      int to = G[tp][i].fi;
      int cost = G[tp][i].se;
      if (d[to] > d[tp] + cost) {
        d[to] = d[tp] + cost;
        pq.push({d[to],to});
      }
    }
  }
  cout << d[0] << endl;
  return 0;
}


Measured memory_bytes: 6908
#include <iostream>
#include <algorithm>
#define FOR(i,a,b) for(int i=a;i<b;i++)
using namespace std;
int main(void){
    long int n,a,b; cin>>n>>a>>b;
    long int ans=0;
    long int x,y; cin>>x;
    FOR(i,1,n){
        cin>>y;
        ans+=min(a*(y-x),b);
        x=y;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
/* ex7_1
    sak_Citrue  */

#include <stdio.h>

typedef struct point
{
    int x_elem;
    int y_elem;
}point;

//ある基点から指定された移動方向にポイントを移動させたポイントを返す
point shift_point(point poibase,point poishift){
    point poiret;
    poiret.x_elem = poibase.x_elem + poishift.y_elem;
    poiret.y_elem = poibase.y_elem + poishift.x_elem; 
    return poiret;
}

int main(void){
    //変数の宣言
    point point1,point2,point3,point4,pointdif;
    scanf("%d %d %d %d",&point1.x_elem,&point1.y_elem,&point2.x_elem,&point2.y_elem);
    //移動方向成分
    pointdif.x_elem = point2.x_elem - point1.x_elem;
    pointdif.y_elem = -point2.y_elem + point1.y_elem;

    //頂点2をベースに
    point3 = shift_point(point2,pointdif);
    //頂点1をベースに
    point4 = shift_point(point1,pointdif);

    printf("%d %d %d %d\n",point3.x_elem,point3.y_elem,point4.x_elem,point4.y_elem);

    return 0;
}

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

void solve(long long x){
	long long res = x / 11 * 2;
	if(x % 11 != 0) {
		res++;
	}
	if(x % 11 > 6) {
		res++;
	}
	cout << res << endl;
}

int main(){	
	long long x;
	scanf("%lld",&x);
	solve(x);
	return 0;
}



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

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<string, string> pss;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vpll> vvpll;
typedef unordered_map<ll, ll> um;
typedef unordered_set<ll> us;

#define fastio ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
#define ts ll t; in(t) while (t--) solve();
#define ks ll t; in(t) FOR(i, 1, t+1) out("Case #" << i << ": " << solve());
#define endl '\n'
#define ln cout << endl;
#define in(x) cin >> x;
#define out(x) cout << x << endl;
#define flush cout << flush;
#define reset(a, b) memset(a, b, sizeof(a));
#define ordered_set tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define FOR(i, a, b) for (ll i = a; i < b; ++i)
#define FORI(i, a, b, c) for (ll i = a; i < b; i += c)
#define FORD(i, a, b) for (ll i = a; i > b; --i)
#define FOREACH(it, v, r) for (auto it = v.begin() + r; it != v.end(); it++)
#define FORALL(it, v) for (auto it : v)
#define F first
#define S second
#define mp make_pair
#define pb emplace_back
#define vin(v, x) vll v(x); FOR(i, 0, x) in(v[i])
#define all(v) v.begin(), v.end()
#define allr(v, r) v.begin(), v.begin() + r
#define showv(v) FORALL(it, v) cout << it << ' '; ln
#define printv(v) FORALL(it, v) out(it)
#define show2d(v) FORALL(it, v) { FORALL(j, it) cout << j << ' '; ln}
#define showm(v) FORALL(it, v) cout << it.F << ": " << it.S << ' '; ln
#define sortv(v) sort(all(v));
#define revv(v) reverse(all(v));
#define maxv(v) *max_element(all(v))
#define minv(v) *min_element(all(v))
#define gcd __gcd
#define checkbit(n, i) (n >> i) & 1               // check ith bit
#define bitcount __builtin_popcount               // count set bits
#define firstbitindex __builtin_ctz               // count trailing zeros
#define lastbitindex __builtin_clz                // count leading zeros
#define bitparity __builtin_parity                // check set bits are even or odd
#define findv(v, x) (find(all(v), x) != v.end())
#define findsm(u, x) (u.find(x) != u.end())
#define findstr(s, x) (s.find(x) != string::npos)
#define sz(a) a.size()
#define precise(x) cout << fixed << setprecision(x);

const ll MAXN = 1e7 + 1, MOD = 998244353, SIZE = 2e7, INF = 0x7f7f7f7f7f7f7f7f;
const double EPS = 1e-9, PI = acos(-1);
const int INFi = 0x7f7f7f7f;

//<<------Declare Variables Here----->>//
ll n, x, y, z, f, a;
vll spf(MAXN, 2);

//<<-----Implement Functions Here---->>//
void sieve()
{
	FORI(i, 3, MAXN, 2)
		spf[i] = i;
	FORI(i, 3, 3162, 2)
		if (spf[i] == i)
			FORI(j, i * i, MAXN, i)
				if (spf[j] == j)
					spf[j] = i;
}
void solve()
{
	in(n)
	a = 0;
	for (ll i = 1; i <= n; ++i)
	{
		x = i, z = 1;
		vll factors;
		while(x > 1)
			y = spf[x], x /= y, y > z ? factors.pb(2), z = y : ++factors.back();
		f = 1;
		for (auto it: factors)
			f *= it;
		a += i * f;
	}
	out(a)
}

//<<----------Start of Main---------->>//
int main()
{
	fastio
	sieve();
	solve();
    return 0;
}

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

#define MAX 2002
#define MOD 1000000007

long long int dp[MAX][MAX];

class Combination{
	long long int ppow(long long int i, long long int j){
		long long int res = 1LL;
		while (j){
			if ((j & 1LL)){
				res *= i;
				if (res >= MOD){
					res %= MOD;
				}
			}
			j >>= 1;
			i *= i;
			if (i >= MOD){
				i %= MOD;
			}
		}
		return res;
	}
public:
	vector<long long int> k;
	vector<long long int> r;
	void resize(int N){
		k.resize(N + 2);
		r.resize(N + 2);
		k[0] = 1;
		for (int i = 1; i < N+2; i++){
			k[i] = k[i - 1];
			k[i] *= i;
			if (k[i] >= MOD)k[i] %= MOD;
		}
		long long int al = k[k.size() - 1];
		long long int iv = ppow(k[k.size() - 1],MOD-2);
		r[k.size() - 1] = iv;
		for (int i = (int)(r.size()) - 2; i >= 0; i--){
			r[i] = r[i + 1] * (i + 1);
			if (r[i] >= MOD){
				r[i] %= MOD;
			}
		}
	}
	long long int C(int a, int b){
		if (a < b)return 0;
		while (k.size() <= a){
			k.push_back((k.back()*(long long int)(k.size())) % MOD);
		}
		long long int up = k[a];
		long long int dw = r[b] * r[a - b];
		dw %= MOD;
		up *= dw;
		up %= MOD;
		return up;
	}
	long long int H(int a, int b){
		return C(a + b - 1, b);
	}
	long long int catalan_number(int n){
		return (C(2 * n, n) + MOD - C(2 * n, n - 1)) % MOD;
	}
};


Combination C;
int main(){
	int n;
	int k;
	cin >> n >> k;
	C.resize(2002*2002);
	dp[0][0] = 1;
	if (k == 1){
		puts("1");
		return 0;
	}
	for (int i = 0; i <= n; i++){
		for (int j = 0; j <= n; j++){
			dp[i + 1][j] += dp[i][j];
			if (dp[i + 1][j] >= MOD){
				dp[i + 1][j] %= MOD;
			}
			if (j + 1 <= i){
				dp[i][j + 1] += dp[i][j] * C.C(n*k-((k-2)*j+j+i+1), k-2);
				if (dp[i][j + 1] >= MOD){
					dp[i][j + 1] %= MOD;
				}
			}
		}
	}
	long long int ans = dp[n][n]*C.k[n];
	if (ans >= MOD)ans %= MOD;
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 94208
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000001


int main(){
	
	double L;
	cin>>L;
	L/=3.0;
	
	cout<<fixed<<setprecision(10)<<pow(L,3.0)<<endl;
	
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
ll INF=1000000;

int main(){
    string s, t;
    cin>>s>>t;
    ll Szs=s.size();
    ll Szt=t.size();
    vector<vector<ll>> NextPlace(30, vector<ll>(110000, INF));
    for(ll i=0; i<Szs; i++){
        ll k=s.at(i)-'a';
      	//cout<<k<<endl;
    }
  	bool c=false;
  	bool cc=false;
  	//cout<<Szs<<endl;
  	for(ll j=0; j<30; j++){
        for(ll i=3*Szs; i>=0; i--){
          	ll ii=i;
			ii%=Szs;
          	cc=(s.at(ii)-'a'==j);
          	if(c){
              	NextPlace.at(j).at(ii)=1;
            }
          	else{
              	NextPlace.at(j).at(ii)=NextPlace.at(j).at((ii+1+Szs)%Szs)+1;
              	
            }
          	c=cc;
          	//if(c)cout<<"!";
        }
    }
    ll Ans=1;
    ll Now=0;
    for(ll i=0; i<Szt; i++){
      	ll j=t.at(i)-'a';
      	if(NextPlace.at(j).at(Now)>=INF){
            cout<<-1<<endl;
            return 0;
        }
      	if(i>0){
        Ans+=NextPlace.at(j).at(Now);
        Now+=NextPlace.at(j).at(Now);
        Now%=Szs;
        }
      	if(i==0){
          	ll H=INF;
          	for(ll k=0; k<Szs; k++){
              	if(s.at(k)==t.at(0)){
                  H=k;
                  break;
                }
            }
          	if(H==INF){
              	cout<<-1<<endl;
              	return 0;
            }
          	Ans+=H;
          	Now+=H;
        }
    }
    cout<<Ans<<endl;
  	return 0;
}

Measured memory_bytes: 28452
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
	int len=s.length();
	string s1;string s2="";
	s1=s[0];int t=1;int sum=1;
	for(int i=1;i<len;i++)
	{
		s2=s2+s[i];
		if(s1!=s2)
		{
			s1=s2;
			s2="";
			sum++;
		}
	}
cout<<sum;
} 

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

int main(){
  long long A,B,M,m;
  cin>>A>>B;
  M=max(A,B);
  m=min(A,B);
  //cout<<m;
  long long ans=0;
  while(1){
    ans+=M;
    if(ans%m==0){
      cout<<ans;
      return 0;
    }
  }    
}

    


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

int a,b,c,d;
int main()
{
    cin>>a>>b>>c>>d;
    int cnt=0;
    while(a>0&&c>0)
    {
        cnt++;
        if(cnt%2==1) c=c-b;
        else a=a-d;
    }
    if(a>0) cout<<"Yes";
    else cout<<"No";
}


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

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

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

  int ans = 0;
  //奇数枚はよくないので偶数枚にしたい
  for(int i = 0; i < n; i++){
    if(a[i]%2 == 1 && a[i+1]){
      a[i]--;
      a[i+1]--;
      ans++;
    }
  }

  for(int i = 0; i < n; i++){
    ans += a[i] / 2;
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
  int n; cin >>n;
  vector<int> a(n);
  rep(i,n) cin >>a[i];
  const int M = 1000005;
  vector<int> cnt(M);
  for(int x : a){
    if(cnt[x]!=0){
      cnt[x] = 2;
      continue;
    }
    for(int i = x; i<M; i+=x) cnt[i]++;
  }
  int ans = 0;
  for(int x : a){
    if(cnt[x]==1) ans++;
  }
  cout << ans << endl;
  return 0; 
}

Measured memory_bytes: 7960