akhauriyash/Code-Regression huggingface dataset:
/*input
2
ab
ca
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=305;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

string s[maxn];

int main()
{
	//IOS;
	int n;
	cin>>n;
	REP(i,n) cin>>s[i];
	int ans=0;
	REP(d,n){
		bool f=1;
		REP(i,n) for(int j=i+1;j<n;j++){
			if(s[(i+d)%n][j]!=s[(j+d)%n][i]) f=0;
		}
		ans+=f;
	}
	cout<<ans*n<<'\n';
	return 0;
}


Measured memory_bytes: 384
def resolve():
  n, k = map(int, input().split())
  h = []
  for i in range(n):
    h.append(int(input()))
  h.sort()
  ans = 1e+9
  for i in range(n-k+1):
    ans = min(ans, h[i+k-1] - h[i])
  print(ans)

  return

if __name__ == "__main__":
  resolve()


Measured memory_bytes: 7444
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];
        int min = 1000;
        int max = 0;
        for(int i=0; i<n; i++) {
            a[i] = Integer.parseInt(sc.next());
            if(a[i] > max) max = a[i];
            if(a[i] < min) min = a[i];
        }
        System.out.println(max-min);
     }
}

Measured memory_bytes: 21716
from collections import defaultdict
from collections import deque
from collections import Counter
import math
import itertools

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

class UnionFind():
	def __init__(self, n):
		self.n = n
		self.parents = [-1] * n

	def find(self, x):
		if self.parents[x] < 0:
			return x
		else:
			self.parents[x] = self.find(self.parents[x])
			return self.parents[x]

	def union(self, x, y):
		x = self.find(x)
		y = self.find(y)

		if x == y:
			return

		if self.parents[x] > self.parents[y]:
			x, y = y, x

		self.parents[x] += self.parents[y]
		self.parents[y] = x

	def size(self, x):
		return -self.parents[self.find(x)]

	def same(self, x, y):
		return self.find(x) == self.find(y)

	def members(self, x):
		root = self.find(x)
		return [i for i in range(self.n) if self.find(i) == root]

	def roots(self):
		return [i for i, x in enumerate(self.parents) if x < 0]

	def group_count(self):
		return len(self.roots())

	def all_group_members(self):
		return {r: self.members(r) for r in self.roots()}

	def __str__(self):
		return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,m = readInts()
u = UnionFind(n)
for i in range(m):
	a,b = readInts()
	u.union(a-1,b-1)

print(u.group_count()-1)

Measured memory_bytes: 13216
def merge(A):
    n = len(A)
    if(n < 2):
        return 0
    ret = 0
    L = A[:n/2]
    R = A[n/2:]
    ret += merge(L)
    ret += merge(R)
    for i in xrange(n):
        if len(L) == 0:
            A[i] = R.pop(0)
        elif len(R) == 0 or L[0] <= R[0]:
            A[i] = L.pop(0)
        else:
            ret += len(L)
            A[i] = R.pop(0)
    return ret

while True:
    n = int(raw_input())
    if n == 0:
        break
    print merge([int(raw_input()) for _ in xrange(n)])

Measured memory_bytes: 4236
#include <stdio.h>
int main(void){
    // Your code here!
    int a,b[5],o=10,c=0;
    scanf("%d",&a);
    for(int i=0;i<=3;i++){
        b[i]=a%o;
        a=a/10;
    }
    for(int i=0;i<=2;i++){
       if(b[i]==b[i+1]){
            c++;
            break;
        }
    }
    if(c==0){
        printf("Good");
    }else{
        printf("Bad");
    }
    
    return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cctype>

#include <algorithm>
#include <random>
#include <bitset>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <vector>
#include <chrono>
#include <iostream>
#include <limits>
#include <numeric>

#define LOG(FMT...) fprintf(stderr, FMT)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

const int N = 3010;

int meth[N];

int main() {
#ifdef LBT
  freopen("test.in", "r", stdin);
  int nol_cl = clock();
#endif

  int r, g, b, n;
  scanf("%d%d%d%d", &r, &g, &b, &n);
  for (int i = 0; i <= n; i += r)
    meth[i] = 1;
  for (int i = g; i <= n; ++i) {
    meth[i] += meth[i - g];
  }for (int i = b; i <= n; ++i) {
    meth[i] += meth[i - b];
  }
  printf("%d\n", meth[n]);

#ifdef LBT
  LOG("Time: %dms\n", int ((clock()
          -nol_cl) / (double)CLOCKS_PER_SEC * 1000));
#endif
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve();
    }
    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int M = scan.nextInt();
        int[][] edges = new int[M][2];
        for (int i = 0; i < M; i++) {
            int a = scan.nextInt()-1;
            int b = scan.nextInt()-1;
            edges[i][0] = a;
            edges[i][1] = b;
        }
        int answer = 0;
        for (int i = 0; i < M; i++) {
            UnionFind uf = new UnionFind(N);
            for (int j = 0; j < M; j++) {
                if (i == j) {
                    continue;
                }
                uf.unite(edges[j][0],edges[j][1]);
            }
            if (uf.size(0) < N) {
                answer += 1;
            }
        }
        System.out.println(answer);
    }
    class UnionFind {
        private int[] parent;
        private int[] size;
        public UnionFind(int n) {
            int[] parent = new int[n];
            int[] size = new int[n];
            for (int i = 0; i < n; i++) {
                parent[i] = i;
            }
            for (int i = 0; i < n; i++) {
                size[i] = 1;
            }
            this.parent = parent;
            this.size = size;
        }
        public int find(int x) {
            if (this.parent[x] == x) {
                return x;
            }
            return this.parent[x] = find(this.parent[x]);
        }
        public boolean same(int x, int y) {
            return this.find(x) == this.find(y);
        }
        public int size(int x) {
            x = this.find(x);
            return this.size[x];
        }
        public void unite(int x, int y) {
            if (same(x, y)) {
                return;
            }
            x = this.find(x);
            y = this.find(y);
            if (this.size[x] < this.size[y]) {
                this.parent[x] = y;
                this.size[y] += this.size[x];
                this.size[x] = -1;
            } else {
                this.parent[y] = x;
                this.size[x] += this.size[y];
                this.size[y] = -1;
            }
        }
    }
}


Measured memory_bytes: 23508
fun list() = readLine()!!.split(" ").map {it.toInt()}
fun int() = readLine()!!.toInt()

fun main() {
	val n = int()
	val m = mutableMapOf<Int,Long>()
	var r = 0L

	for(i in list()) {
		m.merge(i,1) {i,j-> i+j}
		r += i
	}

	for(q in 1..int()) {
		val (b,c) = list()
		val a = m.remove(b) ?: 0
		r += (c-b)*a
		m.merge(c,a) {i,j-> i+j}
		println(r)
	}
}


Measured memory_bytes: 70868
#include<stdio.h>

int main(void){
  int n;
  scanf("%d", &n);
  int ct = 0;
  int c;
  int i, j;
  if ( n < 105 ) {
    ct = 0;
  } else if ( n >= 105 ) {
    for ( i = 105; i <= n; i += 2 ) {
      c = 0;
      for ( j = 1; j <= i; j++ ) {
        if ( i % j == 0 ) {
          c += 1;
        }
      }
      if ( c == 8 ) {
        ct += 1;
      }
    }
  }
  printf("%d\n", ct);
  return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

	    public static void main(String[] args){
	        Scanner scan = new Scanner(System.in);
	        int numN = scan.nextInt();
	        int numM = scan.nextInt();
	        int numL = scan.nextInt();
	        long[][] arrA = new long[numN][numM];
	        long[][] arrB = new long[numM][numL];
	        long[][] arrTot = new long[numN][numL];

	        for(int i=0; i<numN; i++){
	            for(int j=0; j<numM; j++){
	                arrA[i][j] = scan.nextInt();
	            }
	        }

	        for(int i=0; i<numM; i++){
	            for(int j=0; j<numL; j++){
	                arrB[i][j] = scan.nextInt();
	            }
	        }

	        for(int i = 0; i<numN; i++){
	            for(int j=0; j<numL; j++){
	                for(int k = 0; k<numM; k++){
	                	arrTot[i][j] += arrA[i][k]*arrB[k][j];
	                }
	            }
	        }

	        for(int i = 0; i<numN; i++){
	            System.out.print(arrTot[i][0]);
	            for(int j=1;j<numL;j++){
	                System.out.print(" "+arrTot[i][j]);
	        }
	        System.out.println();
	        }

	    }
	}

Measured memory_bytes: 53768
#include<bits/stdc++.h>
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define fd(i,a,b) for(int i=a;i>=b;i--)
using namespace std;

typedef long long LL;

const int maxn=2e5+5;

int n,d[maxn],pr[12];
LL c[maxn],cnt[12];

LL digitsum(LL x)
{
	LL re=0;
	for(; x; x/=10) re+=x%10;
	return re;
}

int main()
{
	scanf("%d",&n);
	fo(i,1,n) scanf("%d %lld",&d[i],&c[i]);
	
	fo(i,0,9)
	{
		int now=i;
		do{
			now+=i;
			pr[i]++;
			for(cnt[i]++; now>=10; now=(now/10)+(now%10)) cnt[i]++;
		} while (now!=i);
	}
	
	LL ans=0, now=0;
	fo(i,1,n) if (c[i]>pr[d[i]])
	{
		ans+=(c[i]-1)/pr[d[i]]*cnt[d[i]];
		c[i]=(c[i]-1)%pr[d[i]]+1;
	}
	fo(i,1,n)
		fo(j,1,c[i])
		{
			now+=d[i];
			for(ans++; now>=10; now=(now/10)+(now%10)) ans++;
		}
	ans--;
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstring>
#include<cmath>

using namespace std;

#define int long long
const int mod = pow(10,9) + 7;
 
string s;
int dp[100005][13];
int solve(int pos,int rem)
{
 	if(pos==s.length())
 		return rem==5;
 	if(dp[pos][rem]!=-1)
 		return dp[pos][rem];
 	int ans=0;	
 	if(s[pos]=='?')
 	{
 	 	for(int i=0;i<10;i++)
 	 	{
 	 	 	ans+=solve(pos+1,(rem*10+i)%13)%mod;
 	 	}
 	}
 	else return dp[pos][rem]=solve(pos+1,(rem*10+s[pos]-'0')%13)%mod;
 	return dp[pos][rem]=ans%mod;
}
int32_t main()
{
	memset(dp,-1,sizeof dp);
 	cin>>s;
 	cout<<solve(0,0)<<endl;
}

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

int main(){
    int n; cin >> n;
    vector <int> L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end());
    int ans=0; 
    for (int b=0; b<n; b++){
        for (int a=0; a<b; a++){
        int ab=L[a]+L[b];
        int r=lower_bound(L.begin(),L.end(),ab) - L.begin();
        int l=b+1;
        
        ans+=max(0,r-l);
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);
	
	void doIt() {
		sA();
	}
	
	void sA() {
		int N = sc.nextInt();
		int K = sc.nextInt();
		if(K * 2 - 1 <= N) System.out.println("YES");
		else System.out.println("NO");
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


Measured memory_bytes: 23380
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		while(true){
			String s = sc.nextLine();
			if(s.equals("0"))System.exit(0);
			int sum=0;
		    for(char c : s.toCharArray()){
		    	sum+=Integer.parseInt(String.valueOf(c));
			}
			System.out.println(sum);
		}
	}
}


Measured memory_bytes: 26880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
typedef unsigned long long ull;
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define f(i,a,b) for(ll i=a;i<=b;i++)
#define testcases ll t;cin>>t;while(t--)
#define dec(x) greater<x>()

/*** Define Values ***/
#define mx 200005
#define mod 1000000007
#define PI acos(-1.0)
#define eps 1e-7
#define size1 100005
const char nl = '\n';

#define pb push_back
#define ff first
#define ss second
#define mp make_pair
#define mem(name, value) memset(name, value, sizeof(name))

/*** STLs ***/
typedef vector <ll> vll;
typedef set <ll> sll;
typedef multiset <ll> msll;
typedef queue <ll> qll;
typedef map <ll, ll> mll;
typedef pair <ll, ll> pll;
typedef vector <pair <ll , ll> > vpll;

/*** Sorts ***/
#define all(v) (v).begin(), (v).end()
#define rev(v) reverse(all(v))
#define srt(v) sort(all(v))
#define srtGreat(v) sort(all(v), greater<ll>())
inline bool cmp(pll a, pll b) { if (a.ff == b.ff)return a.ss < b.ss; return a.ff > b.ff; }

#define en cout << '\n';
#define no cout << "NO" << '\n'
#define yes cout << "YES" << '\n'
#define case cout << "Case " << t++ << ": "

/*** Functions
ll BigMod(ll base, ll pow, ll modvalue){ if (pow == 0) return 1;  ll ans = BigMod(base, pow / 2, modvalue);ll total = ((ans % modvalue) * (ans % modvalue)) % modvalue;  if(pow % 2 == 0) return total; else{ return (total * (base % modvalue) ) % modvalue; } }
ll InverseMod(ll base, ll pow) { if(pow == 0) return 1; ll ans = InverseMod(base, pow / 2); ans = (ans * ans) % mod; if(pow & 1){ return (ans * base) % mod; } else{ return ans; } }
bool checkprime(ll num) { if(num < 2) return false; for(ll i = 2; i * i <= num; i++){ if(num % i == 0) return false; } return true; }
ll EularPHI(ll num) { double ans = num; for(ll i = 2; i * i <= num; i++){ if(num % i == 0){ while (num % i == 0) { num /= i; } ans *= (1.0 - (1.0 / (double)i)); } } if(num > 1) ans *= (1.0 - (1.0 / (double)num)); return (ll)ans; }
ll sumofdigit(long ll n){ll sum=0;while(n){sum=sum+n%10;n=n/10;}return sum;}
ll countDigit(ll n) { if (n == 0) return 0; return 1 + countDigit(n / 10); }
ll countDigit(ll n) { return floor(log10(n) + 1); } //only positive
 ***/

template <class T> inline T gcd(T a, T b) {if (b == 0)return a; return gcd(b, a % b);}
template <class T> inline T lcm(T a, T b) {return a * b / gcd<T>(a, b);}
template <class T> inline T power(T b, T p) {ll ans = 1; while (p--) ans *= b; return ans;}

void solve()
{	
	ll n;cin>>n;
	if(n==0)cout<<1;
	else cout<<0;
}


int main()
{

#ifndef ONLINE_JUDGE
	freopen("C:/Users/91731/Documents/input.txt", "r", stdin);
	freopen("C:/Users/91731/Documents/output.txt", "w", stdout);
	freopen("C:/Users/91731/Documents/error.txt", "w", stderr);
#endif

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	solve();
}


Measured memory_bytes: 3648
N, M = map(int, input().split())
x = list(map(int, input().split()))
x.sort()

gap = []
for i in range(1, M):
  gap.append(x[i] - x[i - 1])

gap.sort()
print(sum(gap if N == 1 else gap[:-1 * (N - 1)]))

Measured memory_bytes: 13960
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> A(3*n);
  rep(i, 3*n) cin >> A[i];
  multiset<ll> s1, s2, s3;
  ll sum1=0, sum2=0;
  rep(i, n) {
    s1.insert(A[i]);
    sum1 += A[i];
  }
  REP(i, n, 2*n) {
    s2.insert(A[i]);
    sum2 += A[i];
  }
  REP(i, 2*n, 3*n) {
    if(A[i] < *s2.rbegin()) {
      sum2 += A[i]-*s2.rbegin();
      s3.insert(*s2.rbegin());
      s2.erase(--s2.end());
      s2.insert(A[i]);
    } else {
      s3.insert(A[i]);
    }
  }
  ll ans = sum1 - sum2;
  REP(i, n, 2*n) {
    if(s2.count(A[i])) {
      sum2 += *s3.begin()-A[i];
      s2.erase(s2.find(A[i]));
      s2.insert(*s3.begin());
      s3.erase(s3.begin());
    } else {
      s3.erase(s3.find(A[i]));
    }
    if(A[i] > *s1.begin()) {
      sum1 += A[i]-*s1.begin();
      s1.erase(s1.begin());
      s1.insert(A[i]);
    }
    ans = max(sum1-sum2, ans);
  }
  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 19548
import fractions

def modinv(a, MOD=1000000007):
    b = MOD
    u = 1
    v = 0
    while b > 0:
        t = a // b
        a -= (t * b)
        tmp = a
        a = b
        b = tmp
        u -= (t * v)
        tmp = u
        u = v
        v = tmp
    u %= MOD
    if u < 0:
        u += MOD
    return u
            

def lcm(a, b, MOD=1000000007):
    return a * b // fractions.gcd(a, b)

def lcm_array(x):
    value = x[0]
    for i in range(1, len(x)):
        value = lcm(value, x[i])
    return value 

def read():
    N = int(input().strip())
    A = list(map(int, input().strip().split()))
    return N, A

def solve(N, A, MOD=1000000007):
    lcmv = lcm_array(A)
    bsum = 0
    for i in range(N):
        bsum += (lcmv * modinv(A[i]) % MOD)
        bsum %= MOD
    return bsum

if __name__ == '__main__':
    inputs = read()
    print("%s" % solve(*inputs))


Measured memory_bytes: 6100
#include<iostream>
#include<vector>
using namespace std;
 
int main()
{
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) {
        int x = i;
        if (x % 3 == 0) {
            cout << " " << x;
        }
        else {
            while (x) {
                if (x % 10 == 3) {
                    cout << " " << i;
                    break;
                }
                else {
                    x /= 10;
                }
            }
        }
    }
    cout << endl;
    return 0;
}

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

struct dsu {
  public:
    int group_num;
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1), group_num(n) {}
    
    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        group_num--;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

int main() {
    int N, M;
    cin >> N >> M;
    int A[M], B[M];
    dsu ds(N);
    for (int i = 0; i < M; i++) {
        cin >> A[i] >> B[i];
        A[i]--;
        B[i]--;
        ds.merge(A[i], B[i]);
    }
    cout << ds.group_num - 1 << "\n";
    return 0;
}

Measured memory_bytes: 4576
#define _USE_MATH_DEFINES
#include<iostream>
#include<cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<cctype>
#include<iomanip>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

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

	double a, b, c;
	double s, l, h;

	cin >> a >> b >> c;

	c = c * M_PI / 180.0;//度→ラジアン

	s = 0.5 * a * b * sin(c);

	l = a + b + sqrt(a * a + b * b - 2 * a * b * cos(c));

	h = s * 2 / a;

	cout << fixed;
	cout << setprecision(5) << s << '\n' << l << '\n' << h << '\n';

	return 0;
}


Measured memory_bytes: 3692
use proconio::*;
use proconio::marker::Usize1;

#[fastout]
fn run() {
    input! {
        n: usize,
        m: usize,
        e: [(Usize1, Usize1); m],
    }
    let mut g = vec![vec![]; n];
    for (a, b) in e {
        g[a].push(b);
        g[b].push(a);
    }
    let mut dp = vec![n; n];
    let mut prev = vec![0; n];
    let mut q = std::collections::VecDeque::new();
    dp[0] = 0;
    q.push_back(0);
    while let Some(v) = q.pop_front() {
        for &u in g[v].iter() {
            if dp[u] > dp[v] + 1 {
                dp[u] = dp[v] + 1;
                prev[u] = v;
                q.push_back(u);
            }
        }
    }
    if dp.iter().any(|d| *d == n) {
        println!("No");
        return;
    }
    println!("Yes");
    for p in prev.iter().skip(1) {
        println!("{}", *p + 1);
    }
}

fn main() {
    run();
}


Measured memory_bytes: 16040
using System;
using System.Collections.Generic;

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            string[] In = Console.ReadLine().Split(' ');
            int[] A = new int[n];
            for(int i=0; i < n; i++)
            {
                A[int.Parse(In[i]) - 1] = i+1;
            }
            Console.Write(A[0]);
            if (n >= 1)
            {
                for (int i = 1; i < n; i++)
                {
                    Console.Write(" " + A[i]);
                }
            }
        }
    }
}


Measured memory_bytes: 40748
#include <iostream>
#include <cstring>
#include <algorithm>
#include <queue>
#include <cstdio>
using namespace std;
typedef long long ll;
const int N = 1e3+5;
const ll INF = 2e18;

int main(){
	int x,h,n,sum = 0;
	scanf("%d%d",&h,&n);
	for(int i = 0;i < n;++i) scanf("%d",&x),sum += x;
	
	printf("%s",sum >= h ?"Yes" :"No");
    return 0;
}

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


N, M = map(int, input().split())

graph = [[] for _ in range(N)]
num_of_parent = [0]*N
for _ in range(N+M-1):
    a, b = map(int, input().split())
    graph[a-1].append(b-1)
    num_of_parent[b-1] += 1

for i in range(N):
    if num_of_parent[i] == 0:
        root = i
        break

Parent = [None]*N
Parent[root] = 0
q = [root]
while q:
    qq = []
    for p in q:
        for np in graph[p]:
            num_of_parent[np] -= 1
            if num_of_parent[np] == 0:
                Parent[np] = p+1
                qq.append(np)
    q = qq

for p in Parent:
    print(p)

Measured memory_bytes: 23508
#include<bits/stdc++.h>
using namespace std;
const int maxn=20;
char s[maxn];
typedef long long ll;
typedef pair<int,ll> pi;
ll f[maxn][maxn*10],P=1,ans=0,jc[maxn],xc[20][20];
int n,sum,c[maxn],a[maxn];
map<pi,ll> dp[20][2];
map<pi,ll> mp[20];
vector<pi> g[20];
ll calc(int n,int *a)
{
  ll res=jc[n];
  for(int i=0;i<=9;i++) res/=jc[a[i]];
  return res;
}
ll solve()
{
  ll res=0;
  for(int i=0;i<=9;i++) a[i]=c[i];
  for(int i=1;i<=n;i++)
  {
    for(int j=0;j<s[i]-'0';j++)
    {
	  if(!a[j]) continue;
      a[j]--;res+=calc(n-i,a);
      a[j]++;
    }
    if(a[s[i]-'0']) a[s[i]-'0']--;
    else break;
  }
  return res;
}
void dfs(int p,int num,int ns,ll np)
{
  if(ns>sum||P%np) return;
  if(p==9)
  {
	c[9]=n-num;
    if(ns+c[9]*9!=sum) return;
    np*=(ll)xc[9][c[9]];
    if(np==P) ans+=solve();
    return;
  }
  for(int i=0;i<=n-num;i++)
  {
	c[p]=i;dfs(p+1,num+i,ns+i*p,np*(ll)xc[p][i]);
  }
}
int main()
{
  scanf("%s",s+1);n=strlen(s+1);
  jc[0]=1;
  for(int i=1;i<=14;i++) jc[i]=jc[i-1]*i;
  for(int i=0;i<=9;i++) xc[i][0]=1;
  for(int i=0;i<=9;i++) for(int j=1;j<=14;j++) xc[i][j]=xc[i][j-1]*(ll)(i+1);
  for(int i=1;i<=n;i++) 
  {
    sum+=s[i]-'0';
    P*=(ll)(s[i]-'0'+1);
  }
  f[0][0]=1;
  for(int i=1;i<=n;i++)
    for(int k=0;k<=9;k++)
      for(int j=k;j<=sum;j++)
        f[i][j]+=f[i-1][j-k];
  for(int i=0;i<sum;i++) ans+=f[n][i];
  g[0].push_back((pi){0,1});
  mp[0][(pi){0,(ll)1}]=1;
  for(int i=0;i<n;i++)
    for(int l=0;l<g[i].size();l++)
    {
	  int ss=g[i][l].first;
      ll  pp=g[i][l].second;
      for(int j=0;j<=9;j++)
      {
	    int ns=ss+j;ll np=pp*(j+1);
        if(ns>sum||np>P) continue;
        if(!mp[i+1][(pi){ns,np}])
          g[i+1].push_back((pi){ns,np});
        mp[i+1][(pi){ns,np}]+=mp[i][g[i][l]];
      }
    }
  for(int i=0;i<g[n].size();i++)
  {
	int ss=g[n][i].first;ll pp=g[n][i].second;
    if(ss==sum&&pp<P) ans+=mp[n][g[n][i]];;
  }
  dfs(0,0,0,1);
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 46980
#include <cstdio>
#include <algorithm>
#include <iostream>

using namespace std;

const int maxN=1e5+5;
int a[maxN],b[maxN],c[maxN];

bool cmp1(int x,int y)
{
    return a[x]>a[y];
}


bool cmp2(int x,int y)
{
    return b[x]>b[y];
}

int main()
{
    int k,x,n,a1,a2,b1,b2;
    cin>>n;
    for(k=0;k<n;k++)
    {
        cin>>x;
        if(k%2==0)a[x]++;
        else b[x]++;
    }
    for(k=0;k<maxN;k++)c[k]=k;
    sort(c,c+maxN,cmp1);
    a1=c[0];a2=c[1];
    sort(c,c+maxN,cmp2);
    b1=c[0];b2=c[1];
    if(a1==b1)n=n-a[a1]-max(a[a2],b[b2]);
    else n=n-a[a1]-b[b1];
    cout<<n;
    return 0;
}


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

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b, x;
    cin >> a >> b >> x;

    if(x - a < 0) cout << "NO" << endl;
    else{
        if(x - a <= b) cout << "YES" << endl;
        else cout << "NO" << endl;
    }
    return 0;
}

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

#define ll long long
#define fornum(A,B,C) for(A=B;A<C;A++)

using namespace std;

/////////////////////////////////////////////////////
#define pll pair<ll,ll>


ll N,A[202020];

vector<ll> Av;
int ck[202020];
map<ll, ll> Am;
ll i,j,a,ans;
int main(){
    scanf("%lld",&N);
    for (i = 0; i < N;i++){
        scanf("%lld", &A[i]);
        Av.push_back(A[i]);
        Am[A[i]]++;
    }
    sort(Av.begin(), Av.end());
    for (a = 1; a <= Av[N-1];a*=2)
        ;
    for (i = N - 1; i >= 0; i--)
    {
        if (Am[Av[i]]==0)
            continue;
        Am[Av[i]]--;
        while (a / 2 > Av[i])
        {
            a /= 2;
        }
        ll tg = a-Av[i];
        if(Am[tg]>0){
            Am[tg]--;
            ans++;
        }
    }

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

Measured memory_bytes: 28400
import std.stdio, std.string, std.conv;
import std.range, std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, core.bitop;

enum inf3 = 1_001_001_001;
enum inf6 = 1_001_001_001_001_001_001L;
enum mod = 1_000_000_007L;


void main() {
    long n;
    long s;
    scan(n);
    scan(s);

    for (long b = 2; b*b <= n; b++) {
        if (dsum(b, n) == s) {
            writeln(b);
            return;
        }
    }

    long ans = inf6;

    for (long p = 1; p*p < n; p++) {
        auto q = s - p;
        if ((n - q) % p == 0) {
            long b = (n - q) / p;
            if (b > 1 && dsum(b, n) == s) {
                ans = min(ans, b);
            }
        }
    }

    if (ans < inf6) {
        writeln(ans);
        return;
    }

    if (n == s) {
        writeln(n + 1);
        return;
    }

    writeln(-1);
}


long dsum(long b, long n) {
    return n < b ? n : dsum(b, n / b) + (n % b);
}





void scan(T...)(ref T args) {
    import std.stdio : readln;
    import std.algorithm : splitter;
    import std.conv : to;
    import std.range.primitives;

    auto line = readln().splitter();
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define ll long long
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
const ll Mod = 998244353;
const int MAX = 510000;
const double PI = 3.14159265358979;
const vector<int> dx = {1, 0};
const vector<int> dy = {0, 1};

int main() {
  ll X, K, D;
  cin >> X >> K >> D;
  X = abs(X);
  ll str = min(K, X/D);
  K -= str;
  X -= str*D;
  if (K%2==0) cout << X << endl;
  else cout << D-X << endl;
  return 0;
}

Measured memory_bytes: 3608
#include<iostream>
using namespace std;
int main(void){
  int a,b,c,x;
  cin>>a>>b>>c>>x;
  int cnt(0);
  for(int i(0);i<=a;i++){
    for(int j(0);j<=b;j++){
      for(int k(0);k<=c;k++){
        int t=500*i+100*j+50*k;
        if(t==x)cnt++;
      }
    }
  }
  cout<<cnt<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
int main()
{
	ll n,k,i,j,s=0,p,q;
	cin>>n>>k;
	vector<ll> v;
	vector<ll> pre(250000),suf(250000);
	pre[1]=0;suf[1]=n;
	for(i=2;i<=n+1;i++)
	{
		pre[i]=pre[i-1]+i-1;
	}
	for(i=2;i<=n+1;i++)
	{
		suf[i]=suf[i-1]+n-i+1;
	}
	
	for(i=k;i<=n+1;i++)
	{
		s=(s-pre[i]+suf[i]+1)%mod;
	}
	cout<<s;
}

Measured memory_bytes: 7216
<?php
    $str_N = trim(fgets(STDIN));
    $int_N = intval($str_N);
    
    for ($int_N; $int_N < 1000; $int_N++){
        $str_N = strval($int_N);
        if ($str_N[0] == $str_N[1] && $str_N[1] == $str_N[2]) {
            $int_N = intval($str_N);
            echo $int_N;
            break;
        }
    }
?>


Measured memory_bytes: 3828
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

// repetition
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

// container util
#define all(x) (x).begin(), (x).end()

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

// typedef
typedef long long lint;
typedef unsigned long long ull;
typedef complex<long double> Complex;
typedef pair<int, int> P;
typedef tuple<int, int, int> TP;
typedef vector<int> vec;
typedef vector<vec> mat;

// constant
const int MOD = (int)1e9 + 7;
const int INF = (int)1e18;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

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

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

  string s1, s2;
  while (true) {
    cin >> s1;
    if (s1 == ".") break;
    cin >> s2;

    int b = 0;
    bool flag = false;
    string ss1 = "", ss2 = "";
    vector<string> c_s1, c_s2, s_s1, s_s2;
    for (int i = 0; i < s1.size(); i++) {
      if (s1[i] == '"' && !flag) {
        b = i;
        flag = true;
        s_s1.push_back(ss1);
        ss1 = "";
        continue;
      }
      if (s1[i] == '"') {
        if (i - b == 1)
          c_s1.push_back("#");
        else
          c_s1.push_back(s1.substr(b, i - b));
        flag = false;
        continue;
      }
      if (!flag) ss1 += s1[i];
    }
    s_s1.push_back(ss1);

    b = 0;
    flag = false;
    for (int i = 0; i < s2.size(); i++) {
      if (s2[i] == '"' && !flag) {
        b = i;
        flag = true;
        s_s2.push_back(ss2);
        ss2 = "";
        continue;
      }
      if (s2[i] == '"') {
        if (i - b == 1)
          c_s2.push_back("#");
        else
          c_s2.push_back(s2.substr(b, i - b));
        flag = false;
        continue;
      }
      if (!flag) ss2 += s2[i];
    }
    s_s2.push_back(ss2);

    flag = false;
    if (s_s1.size() != s_s2.size()) {
      cout << "DIFFERENT\n";
      continue;
    }
    for (int i = 0; i < s_s1.size(); i++) {
      if (s_s1[i] != s_s2[i]) flag = true;
    }

    if (flag) {
      cout << "DIFFERENT\n";
      continue;
    }

    if (c_s1.size() != c_s2.size()) {
      cout << "DIFFERENT\n";
      continue;
    }

    int f = 0;
    for (int i = 0; i < c_s1.size(); i++) {
      if (c_s1[i] != c_s2[i]) f++;
    }
    if (f == 0) {
      cout << "IDENTICAL\n";
    } else if (f == 1) {
      cout << "CLOSE\n";
    } else {
      cout << "DIFFERENT\n";
    }
  }

  return 0;
}


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

int main(void){
    int N,L;
    cin>>N>>L;
    string S[N];
    for(int i=0;i<N;i++)
        cin>>S[i];

    sort(S,S+N);
    for(int i=0;i<N;i++)
        cout<<S[i];
    cout<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define bit(n) (1<<(n))
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
int const INF = 1001001001;

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}
ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

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

ll N,K;
cin >> N >> K;
if(N < K) cout << min(N, K-N) << endl;
else cout << min(N%K, K - N%K) << endl;

return 0;
}

Measured memory_bytes: 256
N=int(input())
A=[int(input()) for _ in [0]*N]
flg = [True]*N
i = 0
cnt = 0
while flg[i]:
    flg[i] = False
    if i == 1:
        break
    i = A[i] -1
    cnt += 1
if flg[1]:
    print(-1)
else:
    print(cnt)

Measured memory_bytes: 7852
import java.util.*

fun main(args: Array<String>) {
    // 最大公約数 (正整数D) を求める対象となる数 (座標Xと座標x_iの距離) が格納されるスタック
    val xx = Stack<Int>()

    // 入力
    Scanner(System.`in`).use {
        val n = it.nextInt()
        val x = it.nextInt()
        for (i in 0 until n) {
            val xxI = it.nextInt()
            if (xxI < x) {
                xx.push(x - xxI)
            } else {
                xx.push(xxI - x)
            }
        }
    }

    // ユークリッドの互除法を用いて、最大公約数 (正整数D) を導出
    // (最終的にスタック内に1つだけ数が残り、それが最大公約数 (正整数D) となる)
    while (1 < xx.size) {
        // スタックから2つの数をpop
        val xxTmp = (0 until 2).map {
            xx.pop()
        }

        // スタックからpopした2つの数のうち、小さい方の数のインデックス
        val minIndex = if (xxTmp[1] < xxTmp[0]) {
            1
        } else {
            0
        }

        // スタックからpopした2つの数のうち、小さい方の数をpush
        xx.push(xxTmp[minIndex])

        // スタックからpopした2つの数の剰余
        val r = xxTmp[(minIndex + 1) % 2] % xxTmp[minIndex]

        // スタックからpopした2つの数に剰余があるならば、それをpush
        if (0 < r) {
            xx.push(r)
        }
    }

    // 最大公約数 (正整数D) を出力
    println(xx.pop())
}


Measured memory_bytes: 54392
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>
using namespace std;

class Problem
{
private:
	// Variables
	int d, n;
	
public:
	// Methods
	void input ()
	{
		cin >> d >> n;
	}
	
	void process ()
	{
		
	}
	
	void output ()
	{
		int m = n;
		if (100 == n) {
			m = 101;
		}
		for (int i=0; i<d; ++i) {
			m *= 100;
		}
		cout << m << endl;
	}
};

int main ()
{
	Problem problem;
	problem.input();
	problem.process();
	problem.output();
	return 0;
}

Measured memory_bytes: 256
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  string s;
  cin >> s;
  int q;
  cin >> q;
  int flg=0;
  string fr,bk;
  fr="";
  bk="";
  while(q--)
  {
    int t;
    cin >> t;
    if(t==1)
    {
      // reverse(fr.begin(),fr.end());
      // reverse(bk.begin(),bk.end());
      swap(fr,bk);
      flg=1-flg;
    }
    else
    {
      int x;
      string c;
      cin >>x >> c;
      if(flg==1)
      {
        if(x==1)
          fr=fr+c;
        else
          bk=c+bk;
      }
      else
      {
        if(x==1)
          fr=c+fr;
        else
          bk=bk+c;
      }
    }
  }
  if(flg)
    {
      reverse(s.begin(),s.end());
      reverse(fr.begin(),fr.end());
      reverse(bk.begin(),bk.end());
    }
  s=fr+s+bk;
  cout << s;
  return;
}

signed main()
{
  FAST;
	int T=1;
	//cin >> T;
	while(T--)
	{
		solve();
	}
    return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>
 
int main () {
    int num;
    scanf("%d", &num);
    
    char string[num];
    
    scanf("%s", string);
    
    if (num % 2 != 0) {
        printf("No\n");
        return 0;
    }
    for (int i = 0; i < num / 2;i++) {
        if (string[i] != string[num / 2 + i]) {
            printf("No\n");
            return 0;
        }
    }
    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 1644
import java.util.Scanner

fun main(args: Array<String>){
    val scn = Scanner(System.`in`)
    val L = scn.nextLine().toInt()
    val LL = L.toFloat()
    val v = (LL/3)*(LL/3)*(LL/3)
    val result = String.format("%.12f", v)
    print("$result")
}

Measured memory_bytes: 29600
#include <stdio.h>

int main(void) {
  int a, b, d, r;
  double f;

  scanf("%d %d", &a, &b);

  d = a/b;
  r = a%b;
  f = (double)a/b;
  printf("%d %d %.5f\n", d, r, f);
  return 0;
}


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


using namespace std;

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

vector<string> a(n);

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

sort(a.begin(),a.end());
int cnt = n;
for(int i = 1;i < n;i++){
    if(a[i] == a[i-1]){
        cnt--;
    }
}

cout  <<cnt <<endl;
}

Measured memory_bytes: 9600
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;//for StringBuilder
class c
{
    static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var list = new string[n];
        for (int i = 0; i < n; i++)
        {
            list[i] = string.Join("", Console.ReadLine().OrderBy(f => f));
        }
        Array.Sort(list, StringComparer.OrdinalIgnoreCase);
        long ans = 0;
        long cnt = 1;
        for (int i = 1; i < n; i++)
        {
            if (list[i] == list[i - 1]) cnt++;
            else
            {
                ans += cnt * (cnt - 1) / 2;
                cnt = 1;
            }
        }
        Console.WriteLine(ans + cnt * (cnt - 1) / 2);
    }
}


Measured memory_bytes: 24852
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 998244353
using namespace std;
using ll = long long;
using ldb = long double;

int main() {
	ll N; cin >> N;
	vector<ll> f(N + 1, 1);
	for (int i = 2; i <= N; i++) {
		for (int j = 1; i*j <= N; j++) {
			f[i * j]++;
		}
	}

	ll ans = 0;
	for (ll i = 1; i <= N; i++) {
		//cout << "i=" << f[i] << endl;
		ans += i * f[i];
	}
	cout << ans << endl;
}

Measured memory_bytes: 81344
# coding: utf-8
import sys
from functools import lru_cache
sys.setrecursionlimit(10 ** 9)

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
A = lr()
INF = 10 ** 17

@lru_cache(None)
def F(index, n):
    if index >= N:
        return -INF
    if N - index < 2 * n - 1:
        return -INF
    if n == 0:
        return 0
    elif n == 1:
        return max(A[index:])
    ret = max(A[index] + F(index+2, n-1), F(index+1, n))
    return ret

answer = F(0, N//2)
print(answer)


Measured memory_bytes: 173584
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include <functional>
#include <iomanip>
using namespace std;

#define ll long long int

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


void eratos(bool isPrime[10000000]) {
	
	rep(0, 10000000)isPrime[i] = true;
	rep(2, 10000000) {
		if (!isPrime[i])continue;
		else {
			for (int j = i * 2; j < 10000000; j += i) {
				isPrime[j] = false;
			}
		}
	}
}

//9

int main(void) {
	static bool isPrime[10000000];
	eratos(isPrime);
	static int countPrime[10000000];
	countPrime[0] = 0;
	countPrime[1] = 0;
	rep(2, 10000000) {
		if (isPrime[i])countPrime[i] = countPrime[i - 1] + 1;
		else countPrime[i] = countPrime[i - 1];
	}
	int n;
	while (cin >> n) {
		cout << countPrime[n] << endl;
	}

}


Measured memory_bytes: 51904
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <map>
#include <queue>
#include <cassert>
#include <iomanip>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const int iINF = 1001001001;
const long long llINF = 1LL << 60;
int main()
{
    /*string s; cin >> s;
    if (s.back() == 's') cout << s << "es" << endl;
    else cout << s << "s" << endl;
    */

    int n; cin >> n;
    bool ans = false;
    int cnt = 0;
    rep(i, n) {
        int d1, d2;
        cin >> d1 >> d2;
        if (d1 == d2) cnt++;
        else cnt = 0;
        if (cnt == 3) ans = true;
    }
    if (ans) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include <typeinfo>
#include <cxxabi.h>
#ifdef LOCAL
  #include "dbgtoki.hpp"
  #define DUMP(i) dump((string)TOSTRING(i), demangle(typeid(i).name()), __LINE__ , i)  
#else
  #define DUMP(i)  
#endif

#define GETTYPE(i) 
#define TOSTRING(x) #x
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define SSTR( x ) static_cast< std::ostringstream & >( \
        ( std::ostringstream() << std::dec << x ) ).str()
#define ALL(s) (s).begin(), (s).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()) , v.end());
using namespace std;
typedef long long unsigned int llu;
typedef long long ll;

const int EPS = 1e-9;

string s;
bool check(int cnt){
  DUMP(s[cnt]);
  if(s[cnt] - '0' < 0 ||  s[cnt] - '0' > 9)return false;
  return true;
}

int main (){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  while(cin >> n){
    vector<int> x(n);
    vector<int> y(n);
    REP(i,n){
      int in;
      cin >> in;
      x[i] = in;
      y[i] = in;
    }
    sort(ALL(x));
    REP(i,n){
      if(y[i] >= x[n/2]){
	cout << x[n/2-1] << endl;
      }
      else{
	cout << x[n/2] << endl;
      }
    }
    DUMP("END");
  }
  return 0;
}


Measured memory_bytes: 3840
from sys import stdin


def b(input_string):
    a, b, k = [int(x) for x in input_string.split()]
    mod_0_numbers = []
    if a >= b:
        for i in range(1, a+1):
            if a % i == 0:
                if b % i == 0:
                    mod_0_numbers.append(i)
    else:
        for i in range(1, b+1):
            if b % i == 0:
                if a % i == 0:
                    mod_0_numbers.append(i)
    return mod_0_numbers[-k]


def main():
    input_line = stdin.readline().rstrip()
    answer = b(input_line)
    print(answer)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
# from collections import Counter,defaultdict,deque
# from itertools import permutations, combinations
# from heapq import heappop, heappush
# # input = sys.stdin.readline
# sys.setrecursionlimit(10**8)
# mod = 10**9+7
def inp(): return int(input())
def inpm(): return map(int,input().split())
def inpl(): return list(map(int, input().split()))
def inpls(): return list(input().split())
def inplm(n): return list(int(input()) for _ in range(n))
def inplL(n): return [list(input()) for _ in range(n)]
def inplT(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)]
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)])

n = inp()
l = inpl()
dic = {}
for i in range(0, len(l)):
    dic.setdefault(i, l[i])
sl = sorted(dic.items(), key=lambda x:x[1])
ans=[str(x[0] + 1) for x in sl]
print(' '.join(ans))


Measured memory_bytes: 101484
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
int f[maxn][70];
int main()
{
 	ios::sync_with_stdio(false);
	int n;cin>>n;
	ll k;cin>>k;
	for(int i=1;i<=n;i++)cin>>f[i][0];
	for(int j=1;j<=60;j++)
	for(int i=1;i<=n;i++)
		f[i][j] = f[f[i][j-1]][j-1];	
	int cur = 1;
	for(int i=60;i>=0;i--)
		if((1LL<<i)<=k){
//			cout<<"!"<<i<<" "<<f[cur][i]<<endl;
			cur = f[cur][i];
			k -= 1LL<<i;
		}
	cout << cur << endl;
}


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

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

using ll = long long;
using ull = unsigned long long;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

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

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    int n;cin >> n;
    map<int,int> mp;
    for(int i=1;i<n;i++){
        int t;cin >> t;
        if(mp[t] == 0){
            mp[t] = 1;
        }else{
            mp[t]++;
        }
    }
    for(int i=1;i<=n;i++){
        cout << mp[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13036
#include <bits/stdc++.h>
#define ff first
#define ss second
using namespace std;
typedef long long ll;
typedef pair<ll, ll> ii;
int main() {
  map<map<char, ll>, ll> x;
  ll n;
  cin >> n;
  ll ans = 0;
  for (ll i = 0; i < n; i++) {
    string s;
    map<char, ll> temp;
    temp.clear();
    cin >> s;
    for (char c : s) {
      temp[c]++;
    }
    x[temp]++;
  }
  for (pair<map<char, ll>, ll> i : x) {
    ans += i.second * (i.second - 1) / 2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 62336
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int i,j=0;
  string s;
  cin>>s;
  for(i=0;i<s.size()-1;i++)
  {
    if(s[i]==s[i+1])
    {
      j=1;
      break;
    }
  }
  if(j==0)cout<<"Good"<<endl;
  else cout<<"Bad"<<endl;
  return 0;
}

Measured memory_bytes: 256