akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define faster cin.tie(0);ios_base::sync_with_stdio(0)
#define ll long long


int n; 
double arr[3001];
 

int main()
{
	cin>>n;
	for(int i=0;i<n;i++) cin>>arr[i];
	//fun(n,cnt)=p*fun(n-1,cnt+1)+(1-p)*fun(n-1,cnt);
	vector<vector<double>> dp(n+1,vector<double>(n+1,0.0));
   
    for(int i=0;i<=n;i++) dp[i][0]=1.0;
 
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=i;j++)
		{
			dp[i][j]=arr[i-1]*dp[i-1][j-1] + (1-arr[i-1])*dp[i-1][j];
		}
		
	}
	
	double ans=0.0;
	for(int j=n/2+1;j<=n;j++)
	{
		ans=max(ans,dp[n][j]);
	}
	
	cout<<setprecision(15);
	cout<<ans<<endl;
	
   
}


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

using namespace std;
#define NIL -1
#define ll long long
#define MAX 100

int main()
{
	int arr[5];
	int pos = -1;
	for(int i=0; i<5; i++) {
		cin >> arr[i];
		if(arr[i]==0) pos = i+1;
	}
	cout << pos << endl;
	return 0;
}


Measured memory_bytes: 3636
import java.util.*;

public class Main {

    public static void main(String args[]) {

        // 入力
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = Integer.parseInt(sc.next());
        }

        // 主処理
        int result = 0;
        for (int i = 0; i < a.length - 1; i++) {
            if (a[i] == a[i + 1]) {
                result++;
                a[i + 1] = 0;
            }
        }

        // 出力
        System.out.println(result);
        sc.close();
    }
}


Measured memory_bytes: 21460
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  char op;
  cin>>A>>op>>B;
  if(op=='+')cout<<A+B<<endl;
  else if(op=='-')cout<<A-B<<endl;
  return 0;
}


Measured memory_bytes: 256
# Problem C - Write and Erase

from collections import Counter

# input
N = int(input())
a_list = []
for i in range(N):
    a = int(input())
    a_list.append(a)

# initialization
a_counter = Counter(a_list)
ans_count = 0

# count
for count_key in a_counter:
    if a_counter[count_key]%2==1:
        ans_count += 1

# output
print(ans_count)


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

const int Maxn = 100005;

string s;
int res[Maxn];

int main()
{
    cin >> s;
    for (int i = 0, j; i < s.length(); i = j) {
        j = i;
        while (j < s.length() && s[i] == s[j]) j++;
        int ev = (j - i + 1) / 2;
        int odd = (j - i) / 2;
        if (s[i] == 'L') {
            res[i] += ev;
            res[i - 1] += odd;
        } else {
            res[j - 1] += ev;
            res[j] += odd;
        }
    }
    for (int i = 0; i < s.length(); i++)
        printf("%d%c", res[i], i + 1 < s.length()? ' ': '\n');
    return 0;
}


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

int main(){
  int H, W;
  cin >> H >> W;
  vector<string> S(H*W);
  int w=0;
  int h=0;
  for(int i=0; i<H*W; i++){
    cin >> S.at(i);
    if(S.at(i)=="snuke"){
      h=i/W+1;
      w=i%W;
      break;
    }
  }
  char A='A';
  char Ans='A'+w;
  cout << Ans << h << endl;
}

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

dp = [[0 for _ in range(W)] for _ in range(H)]
dp[0][0] = 1

MOD = 10 ** 9 + 7

for y in range(H):
	for x in range(W):
		if y + 1 < H and STAGE[y + 1][x] == ".":
			dp[y + 1][x] += dp[y][x]
			if MOD < dp[y + 1][x]:
				dp[y + 1][x] -= MOD
		if x + 1 < W and STAGE[y][x + 1] == ".":
			dp[y][x + 1] += dp[y][x]
			if MOD < dp[y][x + 1]:
				dp[y][x + 1] -= MOD

print(dp[-1][-1])


Measured memory_bytes: 52468
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define INF (ll)(1e18)
#define abs(x) (x >= 0 ? x : -(x))
#define lb(v, x) (int)(lower_bound(all(v), x) - v.begin())
#define ub(v, x) (int)(upper_bound(all(v), x) - v.begin())
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template<typename T> T pow(T a, int b) { return b ? pow(a * a, b / 2) * (b % 2 ? a : 1) : 1; }


void solve() {
    /*
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    */
    
    char c;
    cin >> c;
    cout << (char)(c + 1) << endl;
    
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    
    int T;
    // cin >> T;
    T = 1;
    
    while (T--) {
        solve();
    }
}





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

#define rep(i, n) for(int i = 0; i < n; i++)
#define INF (1<<30)

typedef long long ll;

using namespace std;

void solve(){
    int n;
    int taro = 0, hanako = 0;
    string x, y;

    cin >> n;
    rep(i, n){
        cin >> x >> y;
        if(x < y){
            hanako += 3;
        }else if(x == y){
            hanako++;
            taro++;
        }else{
            taro += 3;
        }
    }
    cout << taro << " " << hanako << endl;
}

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


Measured memory_bytes: 3236
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    long a=sc.nextLong(),b=sc.nextLong(),c=sc.nextLong();
    long d=c-a-b;
    if(4*a*b<d*d&&d>0) {
    	System.out.println("Yes");
    }else {
    	System.out.println("No");
    }
  }
}


Measured memory_bytes: 23892
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
void func(ll now, ll use, ll &counter){
  if(n<now) return;
  if(use == 0b111)  ++counter;

  func(now*10+3, use | 0b001, counter);
  func(now*10+5, use | 0b010, counter);
  func(now*10+7, use | 0b100, counter);

}
int main(){
  cin >> n;
  long long res = 0;
  func(0, 0, res);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
const int INF = 2147483647;//int max
const int MOD = 1000000007;
using namespace std;
using ll = long long;
using P = pair<int,int>;


int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    if(a[0] != a[1] && a[1] != a[2])cout << 3 << endl;
    else if(a[0] == a[1] && a[1] == a[2])cout << 1 << endl;
    else cout << 2 << endl;
    return 0;
}
/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

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;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 998244353
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#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())

int n,x[200005],y[200005];
vector<int>zx,zy;
struct BIT
{
	int bit[(1<<20)+5];
	int f(int x)
	{
		return x&-x;
	}
	void add(int i,int x)
	{
		for(int s=i;s<=(1<<20);s+=f(s)) bit[s]+=x;
	}
	int sum(int i)
	{
		int res=0;
		for(int s=i;s>0;s-=f(s)) res+=bit[s];
		return res;
	}
}kaede;
vector<P>vec;
ll bb[200005];
int main(){
	bb[0] = 1;
	for(int i=1;i<200005;i++) bb[i] = bb[i-1]*2LL%mod;
	cin >> n;
	rep(i,n){
		cin >> x[i] >> y[i];
		zx.pb(x[i]);
		zy.pb(y[i]);
	}
	SORT(zx); ERASE(zx);
	SORT(zy); ERASE(zy);
	rep(i,n){
		x[i] = POSL(zx,x[i]);
		y[i] = POSL(zy,y[i]);
		vec.pb(P(x[i],y[i]));
	}
	sort(vec.begin(),vec.end());
	ll ans = 0;
	rep(i,vec.size()){
		int a = kaede.sum(vec[i].sc);
		int b = vec[i].sc-a;
		int c = i-a;
		int d = n-1-a-b-c;
		ans += bb[a]-1+bb[b]-1+bb[c]-1+bb[d]-1;
		ans += (bb[a]-1)*(bb[b]-1);
		ans += (bb[d]-1)*(bb[b]-1);
		ans += (bb[c]-1)*(bb[d]-1);
		ans += (bb[a]-1)*(bb[c]-1);
		ans %= mod;
		kaede.add(vec[i].sc+1,1);
	}
	ll all = n;
	rep(i,n) all = all*2LL%mod;
	all = (all+mod-n)%mod;
	all -= ans;
	cout << (all%mod+mod)%mod << endl;
}

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

typedef long long tint;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend() 
#define NACHO ios::sync_with_stdio(0); cin.tie(NULL);
#define dbg cout << "hu" << endl;
 
const int INF = 11000000;
const int MOD = 1000000007;

int main(){
	int n; cin >> n;
	vector<int> a (n);
	forn(i, n){
		cin >> a[i];
	}
	sort(all(a));
	a.erase(unique(all(a)), a.end());
	if(int(a.size()) < n){
		cout << "NO";
	}else cout << "YES";
}



Measured memory_bytes: 1024
import           Control.Monad
import           Data.Array.ST
import           Data.Array.Unboxed    (UArray)
import qualified Data.Array.Unboxed    as U
import qualified Data.ByteString.Char8 as BS
import           Data.Char
import           Data.List

getAsInt :: IO [Int]
getAsInt =  unfoldr (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

getAsIntLine :: Int -> IO [[Int]]
getAsIntLine n = replicateM n getAsInt

getAsIntArray2D :: Int -> Int -> IO (UArray (Int,Int) Int)
getAsIntArray2D n m = U.listArray ((1,1),(n,m)) . concat <$> getAsIntLine n


main :: IO ()
main = main2

main1 :: IO ()
main1 = do
  [n,w] <- getAsInt
  wvs <- getAsIntArray2D n 2
  let result = solve1 wvs n w
  print $ maximum $ map (\x -> result U.! (n,x)) [0..w]

main2 :: IO ()
main2 = do
  [n,w] <- getAsInt
  wvs <- map (\[x,y] -> (x, y)) <$> getAsIntLine n
  let result = solve2 w wvs
  print $ maximum $ map (\x -> result U.! x) [0..w]


solve1 :: UArray (Int,Int) Int -> Int -> Int -> UArray (Int,Int) Int
solve1 wvs n' w' = runSTUArray $ do
  dp <- newArray ((0,0),(n',w')) 0
  forM_ [(n_,w_) | n_ <- [1..n'], w_ <- [0..w']] $ \(n,w) -> do
    let wtmp = wvs U.! (n,1)
        vtmp = wvs U.! (n,2)
    if w - wtmp < 0
      then readArray dp (n-1,w) >>= writeArray dp (n,w)
      else do
        a <- readArray dp (n-1,w)
        b <- readArray dp (n-1,w-wtmp)
        writeArray dp (n,w) $ max a (b+vtmp)
  return dp

solve2 :: Int -> [(Int,Int)] -> UArray Int Int
solve2 w' [] = U.listArray (0,w') $ repeat 0
solve2 w' ((wtmp,vtmp):xs) = let a = solve2 w' xs
                                 f w = if w - wtmp >= 0
                                       then max (a U.! w) (a U.! (w - wtmp) + vtmp)
                                       else a U.! w
                             in U.array (0,w') [(w, f w) | w <- [0..w']]


Measured memory_bytes: 86140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define MOD 1000000007
#define PI 3.141592653589793

int main(){
    int a, b;
    cin >> a >> b;
    if(a == 1) a = 14;
    if(b == 1) b = 14;

    string ans;
    if(a > b)
        ans = "Alice";
    else if(a < b)
        ans = "Bob";
    else
        ans = "Draw";
    cout << ans << endl;
}


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

#define lli long long
#define FOR(i,a,b) for (lli i=(a);i<(b);i++)
#define REP(i,n) for (lli i=0;i<(n);i++)
#define rep(i,n) for (lli i=0;i<(n);i++)

#define INF INT_MAX/3
#define PB push_back
#define pb push_back
#define all(a) (a).begin(),(a),end()
#define pll pair<lli,lli>

int main(){
  lli x;

  for(lli i=1;;i++){
    cin>>x;
    if(x!=0)
      cout<<"Case "<<i<<": "<<x<<endl;
    else
      break;
  }
  
  return 0;
}

Measured memory_bytes: 3052
#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[i];
  }
  int z=a[0];
  int x=1;
  int ans=0;
  for(int i=1;i<=n;i++){
    if(i==n){
      ans+=(x/2);
    }
    else if(z==a[i]){
      x++;
    }
    else{
      z=a[i];
      ans+=(x/2);
      x=1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <deque>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
typedef pair<int,int> P;
int main() {

    int n,m;
    cin >> n >> m;
    
    vector<int>cnt(n+1,1);
    vector<bool>isRed(n+1, false);
    
    isRed[1] = true;
    rep(i, 0, m){
        int x,y;
        cin >> x >> y;
        if(isRed[x]){
            isRed[y] = true;
        }
        cnt[x]--;
        cnt[y]++;
        if(cnt[x] == 0) isRed[x]=false;
    }
    ll ans = 0;
    rep(i, 0, n){
        if(cnt[i+1] !=0 && isRed[i+1]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3784
#!/usr/bin/env python
# -*- coding: utf-8 -*-
#
# FileName: 	bridges
# CreatedDate:  2020-07-26 23:07:19 +0900
# LastModified: 2020-07-26 23:42:02 +0900
#


import os
import sys
sys.setrecursionlimit(100000)

# import numpy as np
# import pandas as pd


class Graph():
    def __init__(self, V):
        self.V = V
        self.path = [[] for _ in range(self.V)]
        self.parents = [-1] * self.V
        self.lowlink = [float('inf')] * self.V
        self.order = [float('inf')] * self.V
        self.ap = []

    def add(self, s, t):
        self.path[s].append(t)
        self.path[t].append(s)

    def dfs(self, k, u):
        child = 0
        self.lowlink[u] = k
        self.order[u] = k
        k += 1
        for v in self.path[u]:
            if self.lowlink[v] == float('inf'):
                child += 1
                self.parents[v] = u
                self.dfs(k, v)
                self.lowlink[u] = min(self.lowlink[u], self.lowlink[v])

                if self.lowlink[v] > self.order[u]:
                    self.ap.append(sorted([u, v]))

            elif self.parents[u] != v:
                self.lowlink[u] = min(self.lowlink[u], self.order[v])

    def lowlink_order_print(self):
#        print("lowlink:", self.lowlink)
#        print("order:", self.order)
        self.ap = sorted(self.ap)
        for s in self.ap:
            print("{} {}".format(s[0], s[1]))


def main():
    V, E = map(int, input().split())
    graph = Graph(V)
    for _ in range(E):
        s, t = map(int, input().split())
        graph.add(s, t)
    graph.dfs(0, 0)
    graph.lowlink_order_print()


if __name__ == "__main__":
    main()



Measured memory_bytes: 19240
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
#define Max 1000001
#define inf INT_MAX
#define llinf LONG_LONG_MAX
#define rep(i,a,b) for(i=a;i<=b;i++)
#define rrep(i,a,b) for(i=a;i>=b;i--)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define pb push_back
#define pf push_front
#define F first
#define S second
#define ub upper_bound
#define lb lower_bound
#define all(v) v.begin(),v.end()
const ll mod=1000000007;
 
using namespace std;


void solve(){
    ld a, b, c;
    //string s;
    cin >> a >> b;
    ld ans = (a+b)/2;
    
    if(ans-floor(ans) == 0){
    	cout << ll(ans) << endl;
    }
    else{
    	cout << "IMPOSSIBLE" << endl;
    }
    
    
    
    
    
   }
 
int main() {
   solve();
   }
 
 
 
 

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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int main() {
	ios::sync_with_stdio(false); cin.tie(NULL);
	
	int n; cin >> n;
	vector<string> a(n);
	for (auto& x : a) cin >> x;

	map<string, int> f;
	for (auto& x : a) {
		sort(x.begin(), x.end());
		f[x]++;
	}

	ll ans = 0;
	for (auto p : f) {
		ll x = p.se;
		ans += x * (x-1) / 2;
	}

	cout << ans << '\n';

	return 0;
}

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

using namespace std;

char s[200010];
char stac[200010];

int main() {
  scanf("%s", s);
  int n = strlen(s);
  int stack_ptr = 0;
  for (int i = 0; i < n; i++) {
    stac[stack_ptr++] = s[i];
    if (stack_ptr >= 2) {
      while (stac[stack_ptr - 2] == 'S' && stac[stack_ptr - 1] == 'T') {
        stack_ptr -= 2;
      }
    }
  }
  printf("%d\n", stack_ptr);
  return 0;
}


Measured memory_bytes: 640
import java.util.*;
public class Main {
	static int MAX=7368792;
	
	public static void main(String[] args) {
		Scanner in=new Scanner(System.in);
		while(true) {
			int m=in.nextInt(),n=in.nextInt();
			if(m==0)break;
			List<Integer> list=getSeed(m,n);

			
			int res=0;
			boolean A[]=new boolean[MAX];
			for(int i=0;i<list.size();i++) {
				//int g=list[i];
				int g=list.get(i);
				for(int j=g;j<MAX;j+=g)A[j]=true;
			}
			for(int i=m;i<MAX;i++) {
				if(!A[i]) {
					res=i;
					break;
				}
			}
			System.out.println(res);
		}
	}
	
	static List<Integer> getSeed(int m,int n){
		
		boolean list[]=new boolean[MAX];
		for(int i=m;i<(MAX);i++) {
			if(!list[i]) {
				for(int j=i*2;j<MAX;j+=i)list[j]=true;
			}
		}
		List<Integer> res=new ArrayList<>();
		int i=m;
		while(res.size()<n) {
			if(!list[i]) {
				res.add(i);
			}
			i++;
		}
		return res;
	}

}



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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;





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

    int n, H, W;
    cin>>n>>H>>W;
    int res = 0;
    while (n--) {
	int x,y;
	cin>>x>>y;
	if (x>=H && y>=W) res++;
    }

    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long int ll;

int N;
int K;
int h[100010];
ll dp[100010];

ll INF = 1LL << 60;

void chmin(ll &a, ll b){
  if (a > b){
    a = b;
  }
}

int main(){

  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    cin >> h[i];
  }
  
  for (int i = 0; i < 100010; i++){
    dp[i] = INF;
  }
  
  //初期条件
  dp[0] = 0;
  
  //ループ
  for (int i = 0; i < N; i++){
    for(int j = 1; j <= K; j++){
      chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));    
    }
  }

  cout << dp[N-1];        
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORD(i,a,b) for(int i=a;i>=b;i--)
#define REP(i,n) FOR(i,0,n)
#define pb push_back
#define en "\n"
#define ITER(i,a) for( typeof(a.begin()) i=a.begin();i!=a.end();i++)
#define mod 1000000007
#define mpp make_pair
#define mes(a,b) memset((a),(b),sizeof((a))
typedef map<int,int> MI;
typedef pair<int,int>   PI;
typedef vector<int> VI;
typedef long long int LL;
long long int ans=0;
long long int solve(long long int n,long long int x)
{
    if(n%x==0)
    return 2*n-x;
    else
    return 2*x*(n/x)+solve(x,n%x);
}
int main() {
	// your code goes here
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long int n,x;
    cin>>n>>x;
    ans=n+solve(n-x,x);
    cout<<ans;
	return 0;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define all(x) (x).begin(), (x).end()

#define M 998244353

using namespace std;

struct Robo {
    ll x;
    ll d;
    ll l;

    bool operator < (const Robo &r) {
        return x < r.x;
    }
};

void add(vector<ll> &tree, ll idx, ll val) {
    while(idx < tree.size()) {
        tree[idx] = max(val, tree[idx]);
        idx += idx & (-idx);
    }
}

ll get(vector<ll> &tree, ll idx) {
    ll result = 0;
    while(idx) {
        result = max(tree[idx], result);
        idx -= idx & (-idx);
    }
    return result;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    vector<Robo> r(n);
    for(int i=0; i<n; ++i)
        cin>>r[i].x>>r[i].d;
    sort(all(r));
    vector<ll> tree(n+2, 0);
    r[n-1].l = n-1;
    add(tree, n, n-1);
    for(ll i=n-2; i>=0; --i) {
        Robo temp;
        temp.x = r[i].x + r[i].d;
        int p = lower_bound(all(r), temp) - r.begin();
        --p;
        // cout<<p<<endl;
        r[i].l = max(i, get(tree, p+1));
        add(tree, i+1, r[i].l);
    }
    // cout<<endl;
    // for(int i=0; i<n; ++i)
    //     cout<<"("<<r[i].x<<","<<r[i].d<<") ";
    // cout<<endl;
    // cout<<endl;
    // for(int i=0; i<n; ++i)
    //     cout<<r[i].l<<" ";
    // cout<<endl;
    vector<ll>dp(n+1, 0);
    dp[n] = 1;
    for(int i=n-1; i>=0; --i) {
        dp[i] = (dp[i+1] + dp[1+r[i].l])%M;
    }
    cout<<dp[0]<<endl;
}

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

#define int long long
#define ci(m)     for(int i=0;i<m;i++)
#define cj(m)     for(int j=0;j<m;j++)
#define ck(m)     for(int k=0;k<m;k++)
#define gcd            __gcd
#define endl           "\n"
#define pb             emplace_back
#define setbits(x)     __builtin_popcountll(x)
#define zrobits(x)     __builtin_ctzll(x)
#define mod            1000000007
#define mod2           998244353
#define maxe           *max_element
#define mine           *min_element
#define inf            1e18
#define deci(x, y)      fixed<<setprecision(y)<<x
#define w(t)           int t; cin>>t; while(t--)
#define nitin          ios_base::sync_with_stdio(false); cin.tie(NULL)
#define PI             3.141592653589793238
using namespace std;

int32_t main() {
    nitin;
    int n;
    cin>>n;
    map<int,int>m;
    for(int i=0;i<n;i++)
    {
        int a;
        cin>>a;
        m[a]++;
    }
    if(m.size()>2)
    {
        cout<<"No"<<endl;
    }
    else if(m.size()==2)
    {
        int a,x,b,cb;
        a=(*m.begin()).first;
        x=(*m.begin()).second;
        b=(*next(m.begin())).first;
        cb=(*next(m.begin())).second;
        if(b!=a+1)
        {
            cout<<"No"<<endl;
        }
        else if(2*(b-x)<=n-x && b-x>0)
        {
            cout<<"Yes"<<endl;
        }
        else{
            cout<<"No"<<endl;
        }
    }
    else{
        int cnt=(*m.begin()).first;
        if(cnt*2<=n || cnt==n-1)
            cout<<"Yes"<<endl;
        else
            cout<<"No"<<endl;
    }
    return 0;
}

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

/*A principle is memoriaization*/

int n;
string s;

int main(){
    cin >> n >> s;
    int min = 300000;
    int cou = 0;
    for(int i = 1; i < n; i++){
        if(s[i] == 'E') cou ++;
    }
    min = cou;
    int prev = cou;
    for(int j = 1; j < n; j++){
        int count = prev;
        if(s[j] == 'E') count--;
        if(s[j - 1] == 'W') count++;
        prev = count;
        if(min > count) min = count;
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 900
// --------------
// Tejas Pandey  |
// 12 - 06 - 20  |
// Random Practice|
// --------------
 
#include <bits/stdc++.h>
using namespace std;
 
#define vi vector<int>
typedef long long int ll;
 
ll cnt[200007];
 
int main (void)
{
  //freopen("in.txt","r",stdin);
  //freopen("out.txt","w",stdout);
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  int n,q;
  cin >> n;
  int a[n];
  ll ans = 0;
  for(int i = 0;i < n;i++){
	int k;
	cin >> k;
	a[i] = k;
	cnt[k]++;
	if(cnt[k] > 1){
		ans -= ((cnt[k] - 1)*(cnt[k] - 2))/2;
		ans += ((cnt[k] - 1)*(cnt[k]))/2;
	}
  }
  for(int i = 0;i < n;i++){
	int type = 100;
	//cin >> type;
	if(type - 1){
		int pos = i + 1;
		//cin >> pos;
		pos--;
		cnt[a[pos]]--;
		int k = a[pos];
		if(cnt[a[pos]]){
			ans -= ((cnt[k])*(cnt[k] + 1))/2;
		    ans += ((cnt[k] - 1)*(cnt[k]))/2;
		}
		cout << ans << "\n";
		cnt[k]++;
		if(cnt[k] > 1){
			ans -= ((cnt[k] - 1)*(cnt[k] - 2))/2;
			ans += ((cnt[k] - 1)*(cnt[k]))/2;
		}
	}
	else{
		int pos,val;
		cin >> pos >> val;
		pos--;
		cnt[a[pos]]--;
		int k = a[pos];
		if(cnt[a[pos]]){
			ans -= ((cnt[k])*(cnt[k] + 1))/2;
		    ans += ((cnt[k] - 1)*(cnt[k]))/2;
		}
		a[pos] = val;
		k = a[pos];
		cnt[k]++;
		if(cnt[k] > 1){
			ans -= ((cnt[k] - 1)*(cnt[k] - 2))/2;
			ans += ((cnt[k] - 1)*(cnt[k]))/2;
		}
	}
  }
  return 0;
}

Measured memory_bytes: 3968
import sys
import heapq
from collections import defaultdict
input = sys.stdin.readline
inf = 10**18



def dijkstra(repn, start, goal):
    dist = [inf for i in range(N + 1)] # 始点から各頂点までの最短距離を格納する
    
    dist[start] = 0
    q = []                  # プライオリティキュー．各要素は，(startからある頂点vまでの仮の距離, 頂点vのID)からなるタプル
    heapq.heappush(q, (0, start)) # 始点をpush

    while q:
        prov_cost, src = heapq.heappop(q) # pop
        
        # プライオリティキューに格納されている最短距離が，現在計算できている最短距離より大きければ，distの更新をする必要はない
        if dist[src] < prov_cost:
            continue

        # 他の頂点の探索
        for dest in repn[src]:
            cost = repn[src][dest]
            if dist[dest] > dist[src] + cost:
                dist[dest] = dist[src] + cost # distの更新
                heapq.heappush(q, (dist[dest], dest)) # キューに新たな仮の距離の情報をpush
                
    return dist[goal]
        



N, M = map(int, input().split())
repn = [defaultdict(list) for _ in range(N + 1)]
for i in range(2, N + 1):
    repn[i][i - 1] = 0
for _ in range(M):
    l, r, c = map(int, input().split())
    if repn[l][r] == [] or repn[l][r] > c: #つまずきポイントその１
        repn[l][r] = c

d = dijkstra(repn, 1, N)

if d == inf:
    print(-1)
else:
    print(d)


Measured memory_bytes: 92328
N = int(input())
A = [-1*int(input()) for _ in range(N)]


def LIS(seq: list) -> int:
    """param: seq
    return:LISの長さ（a_i =< a_j）
    """
    from bisect import bisect_right
    N = len(seq)
    L = [seq[0]]
    for i in range(1, N):
        if seq[i] > L[-1]:
            L.append(seq[i])
        else:
            idx = bisect_right(L, seq[i])
            if idx == len(L):
                L.append(None)  # avoid Out-of-Index-Error
            L[idx] = seq[i]
    return len(L)


print(LIS(A))


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

typedef long long ll;

int main(){
  ll n, m; cin >> n >> m;

  ll x = (m-2*n)/4;

  if(x>0){
    n += x;
    m -= 2*x;
  }

  cout << min(n, m/2) << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

int main(){

  ll a,b,c,k;
  cin >> a >>b >> c >>k;

  ll s=0;
  while(a>=b){
    b*=2;
    s++;
  }
  while(b>=c){
    c*=2;
    s++;
  }

  if(s<=k)cout << "Yes" << endl;
  else cout << "No" << endl;


}

Measured memory_bytes: 3620
//   PIGMEISTER™   //

#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define ull unsigned long long
#define sidha(i,x,n) for(ll i=(ll)(x);i<(ll)(n);i++)
#define ulta(i,x,n) for(ll i=(ll)(x);i>=(ll)(n);i--)
#define mi map<ll,ll>
#define vi vector<ll>
#define si set<ll>
#define pi pair<ll,ll>
#define vp vector<pair<ll,ll>>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define sab(a) a.begin(),a.end()
#define bas(a) a.rbegin(),a.rend()
#define modinv(x) powah(x,mod-2)
#define ncr(n,r) (((fact[n]*modinv(fact[n-r]))%mod*modinv(fact[r]))%mod)
#define factorial fact.pb(1);sidha(i,1,MAX)fact.pb((fact[i-1]*i)%mod)
#define test ll _;cin>>_;while(_--)
#define jaldi ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define endl '\n'
#define mod (ll)1000000007
//#define mod (ll)998244353
#define MAX 200005
ll powah(ll, ll);
vi v;

void lunlun(ll n, ll last) {
    if (last == 0) {
        sidha (i, 1, 10) {
            lunlun(n, i);
        }
    }
    else if (floor(log10(last))+1 < n) {
        //cout<<floor(log10(last))<<'*'<<n<<' ';
        ll x = last%10;
        sidha (i, x-1, x+2) {
            if (i < 0 || i > 9) continue;
            lunlun(n, last*10+i);
        }
    }
    else v.pb(last);
}

int main()
{
    jaldi;
    
    sidha (i, 1, 11)
        lunlun(i, 0);
    ll k;
    cin >> k;
    cout << v[k-1];

    return 0;
}

ll powah(ll x, ll y) { 
    ll res = 1; x = x % mod;
    while (y > 0) { 
        if (y & 1) res = (res*x) % mod; 
        y = y>>1; x = (x*x) % mod; } 
    return res; 
}

Measured memory_bytes: 2420
#include<stdio.h>
int main(void)
{
	int a[4],b[2],c,box,i,j;
	scanf("%d %d %d %d %d %d",&a[0],&a[1],&a[2],&a[3],&b[0],&b[1]);
	for(i=0;i<3;i++){
		for(j=i+1;j<4;j++){
			if(a[i]<a[j]){
				box=a[i];
				a[i]=a[j];
				a[j]=box;
			}
		}
	}
	if(b[0]<b[1]){
		c=b[1];
	}
	else{
		c=b[0];
	}
	printf("%d\n",a[0]+a[1]+a[2]+c);
	return 0;
}


Measured memory_bytes: 2076
N,W=list(map(int,input().strip().split(" ")))
items=[]
for _ in range(N):
    w,v=list(map(int,input().strip().split(" ")))
    items+=[(w,v)]

dp=[[0]*(W+1) for i in range(N)]
dp[0][items[0][0]]=items[0][1]
for i in range(1,N):
    for weight in range(1,W+1):
        if weight-items[i][0]>=0:
            dp[i][weight]=max(dp[i-1][weight-items[i][0]]+items[i][1],dp[i-1][weight])
        dp[i][weight]=max(dp[i][weight],dp[i-1][weight])
print(max(dp[-1]))


    

Measured memory_bytes: 121324
#![allow(
    non_snake_case,
    unused_variables,
    unused_assignments,
    unused_mut,
    dead_code
)]
//use permutohedron::LexicalPermutation as _;
use proconio::input;
//use proconio::marker::Chars;
//use proconio::marker::Usize1;
//use std::collections::HashSet;
//use std::collections::HashMap;
//use std::collections::BTreeMap;
//use std::cmp::*;
//use std::num;

fn main() {
    input! {
        N:usize
    }
    let mut f = vec![1usize; N + 1];
    for i in 2..N + 1 {
        let mut j = i;
        while j <= N {
            f[j] += 1;
            j += i;
        }
        //println!("{:?}", f);
    }
    //println!("{:?}", f);
    let mut ans = 0;
    for i in 1..N + 1 {
        ans += i * f[i];
    }
    println!("{}", ans);
}


Measured memory_bytes: 80144
card = [list(map(int, input().split())) for i in range(3)]
N = int(input())
 
bingo = [[0 for i in range(3)] for j in range(3)]
 
for i in range(N):
  key = int(input())
  for j in range(3):
    for k in range(3):
      if card[j][k] == key:
        bingo[j][k] += 1

for i in range(3):
  if bingo[0][i] * bingo[1][i] * bingo[2][i] > 0:
    print('Yes')
    exit()
for i in range(3):
  if bingo[i][0] * bingo[i][1] * bingo[i][2] > 0:
    print('Yes')
    exit()
if bingo[0][0] * bingo[1][1] * bingo[2][2] > 0:
    print('Yes')
    exit()
if bingo[0][2] * bingo[1][1] * bingo[2][0] > 0:
    print('Yes')
    exit()
print('No')




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


int main() {
  int a, b;
  cin >> a >> b;
  cout << a + (b / 2) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <set>
using namespace std;

set<int> S;
pair<int, int> a[222];

int main(void)
{
	int n, i, ans = 0;

	scanf("%d" ,&n);
	for (i = 0; i < 2 * n; i++)
	{
		scanf("%d %d" ,&a[i].first, &a[i].second);
		a[i].first = a[i].first * 10 + (i >= n);
	}

	sort(a, a + 2 * n);

	for (i = 0; i < 2 * n; i++)
		if (a[i].first % 10 == 0)
			S.insert(a[i].second);
		else
		{
			set<int>::iterator it = lower_bound(S.begin(), S.end(), a[i].second);
			if (it == S.begin())
				continue;

			it--;
			S.erase(it);
			++ans;
		}

	printf("%d" ,ans);
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 1000005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define per(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

inline ll read()
{
	ll x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll n,m,k,a[maxn],b[maxn],p0[maxn],p1[maxn],ans;

int main()
{
	n=read(); m=read(); k=read();
	rep(i,1,n) a[i]=read(),p0[i]=p0[i-1]+a[i]; rep(i,1,m) b[i]=read(),p1[i]=p1[i-1]+b[i];
	rep(i,0,n)
	{
		if(p0[i]>k) break;
		ll res=k-p0[i],l=0,r=m,tmp=0;
		while(l<=r)
		{
			int mid=(l+r)>>1;
			if(p1[mid]<=res) tmp=mid,l=mid+1;
			else r=mid-1;
		}
		ans=max(ans,i+tmp);
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
	int k;
	cin >> k;
	string a;
	cin >> a;
	for(int i=0;i<k;i++){
		cout << a[i];
		if(i==(int)a.length()-1) {
			cout << "\n";
			return 0;
		}
	}
	cout << "...\n";
}

Measured memory_bytes: 3628
// C++ program to find  
// maximum XOR subset 
#include<bits/stdc++.h>

#define int long long

using namespace std;

// Number of bits to  
// represent int 
#define INT_BITS 64


//　ここからコピペ from https://www.geeksforgeeks.org/find-maximum-subset-xor-given-set/
// Function to return 
// maximum XOR subset 
// in set[] 
int maxSubarrayXOR(vector<int> set, int X) {
    int n = set.size();
    // Initialize index of 
    // chosen elements 
    int index = 0;

    // Traverse through all 
    // bits of integer  
    // starting from the most 
    // significant bit (MSB) 
    for (int i = INT_BITS - 1; i >= 0; i--) {
        if( (X >> i & 1) == 0 ) {
            // Initialize index of
            // maximum element and
            // the maximum element
            int maxInd = index;
            int maxEle = LONG_LONG_MIN;
            for (int j = index; j < n; j++) {
                // If i'th bit of set[j]
                // is set and set[j] is
                // greater than max so far.
                if ((set[j] & (1ll << i)) != 0
                    && set[j] > maxEle)
                    maxEle = set[j], maxInd = j;
            }

            // If there was no
            // element with i'th
            // bit set, move to
            // smaller i
            if (maxEle == LONG_LONG_MIN)
                continue;

            // Put maximum element
            // with i'th bit set
            // at index 'index'
            swap(set[index], set[maxInd]);

            // Update maxInd and
            // increment index
            maxInd = index;

            // Do XOR of set[maxIndex]
            // with all numbers having
            // i'th bit as set.
            for (int j = 0; j < n; j++) {
                // XOR set[maxInd] those
                // numbers which have the
                // i'th bit set
                if (j != maxInd &&
                    (set[j] & (1ll << i)) != 0)
                    set[j] = set[j] ^ set[maxInd];
            }

            // Increment index of
            // chosen elements
            index++;
        }else{

        }
    }

    // Final result is  
    // XOR of all elements 
    int res = 0;
    for (int i = 0; i < n; i++)
        res ^= set[i];
    return res;
}

signed main() {
    int n;
    cin >> n;
    vector<int> a;

    int tot = 0;
    for (int i = 0; i < n; i++) {
        int x;
        cin >> x;
        a.push_back(x);
        tot ^= x;
    }
    int t = maxSubarrayXOR(a, tot);
    cout << t + (t ^ tot) << endl;
}

  

Measured memory_bytes: 1908
package main

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

func main() {
	var n int
	var a []int
	var max, second int

	sc := bufio.NewScanner(os.Stdin)

	fmt.Scan(&n)

	for i := 0; i < n; i++ {
		sc.Scan()
		t, _ := strconv.Atoi(sc.Text())
		a = append(a, t)
		if t > max {
			max = t
		} else if t > second {
			second = t
		}
	}

	for j := 0; j < len(a); j++ {
		if a[j] == max {
			fmt.Println(second)
		} else {
			fmt.Println(max)
		}
	}

}


Measured memory_bytes: 8832
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
int ctoi(char c) {return c-'0';}// char to int
int gcd(ll a,ll b){return b?gcd(b,a%b):a;}//MAX
int lcm(ll a,ll b){return a*b/gcd(a,b);}//MIN
 
int  main(){
int x;
cin >> x ;
for(int i = x;i<=10e5;i++){
    int che = 0;
    for(int j=2;j<=i;j++){
        if(i%j==0)che++;
    }
    if(che==1){
        cout << i << endl;
        break;
    }
}
}
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI 3.1415926535897932384

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s;a=0;} return os;}
template<class S>void tf(bool b,S t,S f){cout<<(b?t:f)<<endl;}
void OUT(bool b){tf(b,"YES","NO");}
void Out(bool b){tf(b,"Yes","No");}
void out(bool b){tf(b,"yes","no");}
template<class T>void puta(T&&t){cout<<t<<endl;}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}

int popcnt(int x){return __builtin_popcount(x);}
int popcnt(ll x){return __builtin_popcountll(x);}
int bsr(int x){return 31 - __builtin_clz(x);}
int bsr(ll x){return 63 - __builtin_clzll(x);}
int bsf(int x){return __builtin_ctz(x);}
int bsf(ll x){return __builtin_ctzll(x);}
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}

/*他のライブラリを入れる場所*/
struct UnionFind{
	vi p;
	UnionFind(int s):p(s,-1){}
	void unite(int a,int b){
		a=root(a);b=root(b);
		if(a!=b){
			if(p[b]<p[a])swap(a,b);
			p[a]+=p[b];p[b]=a;
		}
	}
	bool same(int a,int b){return root(a)==root(b);}
	int root(int a){return p[a]<0?a:p[a]=root(p[a]);}
};

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n,m;
	cin>>n>>m;
	vi a(n);
	rep(i,n)cin>>a[i];
	UnionFind uf(n);
	rep(i,m){
		int a,b;
		cin>>a>>b;
		a--; b--;
		uf.unite(a,b);
	}
	int ans=0;
	rep(i,n){
		if(uf.root(a[i]-1)==uf.root(i))ans++;
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define fo(i,n)         for(int i=0;i<n;i++)
#define Fo(i,k,n)       for(int i=k;i<n;i++) 
#define endl            "\n"
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define vec(x)          vector<x>
#define matrix(x)       vector<vector<x>>
#define mem(a,b)        memset(a, b, sizeof a)
#define vii             vector<pair<int,int>>
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define MOD             998244353
#define deb(x)          cerr <<#x<<" = "<<x<<"\n"
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define all(v)          v.begin(),v.end()
#define rep(i,a,b)      for (int i = a; i<b; ++i)
#define len(s)          s.length()
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
 
 
int power(int a,int b,int m=mod)
{int ans=1;while(b>0){if(b&1)ans=(ans*a)%m;a=(a*a)%m;b>>=1;}
return ans;}

void angshuGod()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

const int N = 1e5+1;
const double pi = acos(-1);

void solve(){    

    int n;
    cin>>n;
    int ans = 0;
    for(int i = 1;i<=n;i++){
    	int low = i;
    	int high = (n/i)*i;
    	int cnt = high/i - low/i + 1;
    	ans += cnt*(high+low)/2;
    }
    cout<<ans;
}

 
int32_t main()
{
    angshuGod();

    int t;

    t = 1;
    //cin>>t;

    while(t--){
        solve();
    }
    
    return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

const ll INF = 1LL << 60;

class UnionFind {
    public:
        vector<ll> Parent;
        UnionFind(ll N) {
            Parent = vector<ll>(N, -1);
        }

        ll size(ll A) {
            return -Parent[root(A)];
        }

        ll root(ll A) {
            if (Parent[A] < 0) return A;
            return Parent[A] = root(Parent[A]);
        }

        bool unite(ll A, ll B) {
            A = root(A);
            B = root(B);
            if (A == B) return false;

            if (size(A) < size(B)) swap(A, B);

            Parent[A] += Parent[B];
            Parent[B] = A;

            return true;
        }
};
ll N, M;
int main() {
    cin >> N >> M;
    vector<P> v;
    rep(i, M) {
        ll a, b;
        cin >> a >> b;
        a--; b--;
        v.push_back(P(a, b));
    }
    reverse(v.begin(), v.end());

    UnionFind uf = UnionFind(N);

    // 逆から見る
    ll total = N * (N - 1) / 2;
    vector<ll> ans;
    rep(i, M) {
        // cout << total << " " << v[i].first << " " << v[i].second << endl;
        ans.push_back(total);

        ll a_size = uf.size(v[i].first);
        ll b_size = uf.size(v[i].second);
        if (uf.unite(v[i].first, v[i].second)) {
            total -= a_size * b_size;
        }
    }
    reverse(ans.begin(), ans.end());
    rep(i, M) cout << ans[i] << endl;
}

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

#define pb push_back
#define fi first
#define se second
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define rrep(i,s,n) for(int i = (n)-1;i>=(s);i--)
#define all(v) (v).begin(),(v).end()
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))
#define low(a,b) lower_bound(all(a),(b))-(a).begin()
#define upp(a,b) upper_bound(all(a),(b))-(a).begin()
#define endl '\n'
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0)
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<vint> vvint;
typedef vector<pint>vpint;
typedef pair<pint,int> P1;
typedef pair<int,pint> P2;
typedef pair<pint,pint> PP;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007;
const ll INF=1e18;

int N;
int h[100010];
int dp[100010];

signed main() {
    IOS();
    //(1ll<<N)シフト演算のオーバーフローに気をつける
    cin>>N;
    rep(i,1,N+1)cin>>h[i];
    rep(i,2,N+1){
        if(i==2)dp[i]=dp[i-1]+abs(h[i]-h[i-1]);
        else{
            dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
        }
    }
    cout<<dp[N]<<endl;
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
    
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define ff first
#define ss second
#define setbits(x)          __builtin_popcountll(x)
#define lp(a,n) for(ll i=a; i<n; i++)
#define lpi(a,n) for(int i=a; i<n; i++)
#define w(t) int t; cin>>t; while(t--)
#define vi vector<int> 
#define vll vector<ll>
#define pll pair<ll, ll>
#define pii pair<int, int>
#define inf 1e9
#define LB lower_bound
#define UB upper_bound
const int mod = 1000000007;
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
ll lcm(ll a, ll b){
    return (a*b)/gcd(a,b);
}

int prime[100007];
void SieveOfEratosthenes(int n) 
{ 
    memset(prime, -1, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
         
        if (prime[p] == -1) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = p; 
        } 
    } 
    
} 
int lps(string s){
    int len = 0;
    int n = s.length();
    int dp[n];
    dp[0] = 0;
    for(int i=1; i<n; i++){
        if(s[i] == s[len]){
            len++;
            dp[i] = len;
            continue;
        }
        if(len!=0){
            len = dp[len-1];
            i--;
            continue;
        }
        dp[i]=0;
    }
    return dp[n-1];
}
 
ll power(unsigned ll x,unsigned  ll y) 
{ 
    ll res = 1;     
    while (y > 0) 
    { 
        if (y & 1) 
            res = res*x; 
   
        y = y>>1;
        x = x*x;  
    } 
    return res; 
}


int main(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
    ll n;
    cin>>n;
    ll a[n];
    ll ans=1;
    ll x=1e18;
    ll z=0;
    //cout<<x<<endl;
    lp(0,n){
        cin>>a[i];
        if(a[i]==0) z++;
        
    }
    if(z>0){
        cout<<"0\n";
        return 0;
    } 
    lp(0,n){
        if(a[i]<=1000000000000000000/ans){
            ans *= a[i];
        }
        else {
            cout<<"-1\n";
            return 0;
        }
    }
    cout<<ans;
}

Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;

int main() {
  int ans=0;
  int h,w;
  cin>>h>>w;
  vector<vector<char>> a(h,vector<char>(w));
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>a.at(i).at(j);
    }
  }
  vector<int> dx={1,0,-1,0};
  vector<int> dy={0,1,0,-1};
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(a.at(i).at(j)=='.'){
        vector<vector<int>> b(h,vector<int>(w));
        for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
            b.at(i).at(j)=114514;
          }
        }
        queue<P> q;
        q.push(P(i,j));
        b.at(i).at(j)=0;
        while(q.size()){
          P p=q.front();
          q.pop();
          for(int i=0;i<4;i++){
            int nx=p.first+dx.at(i);
            int ny=p.second+dy.at(i);
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&a.at(nx).at(ny)=='.'&&b.at(nx).at(ny)==114514){
              q.push(P(nx,ny));
              b.at(nx).at(ny)=b.at(p.first).at(p.second)+1;
            }
          }
        }
        for(int i=0;i<h;i++){
          for(int j=0;j<w;j++){
            if(b.at(i).at(j)!=114514){
              ans=max(ans,b.at(i).at(j));
            }
          }
        }
      }
    }
  }
  cout<<ans<<endl;
}


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

int main(){
	int n;
	string in[50];
	getline(cin, in[0]);
	n = stoi(in[0]);
	for (int i = 0; i < n;i++) {
		getline(cin, in[i]);
		while (true) {
			int hoshi = in[i].find("Hoshino");
			if (hoshi >= 0) {
				in[i].replace(hoshi, 7, "Hoshina");
			}
			else break;
		}
	}
	for(int i = 0; i < n;i++){
		cout << in[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 3036