akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		for(int data=0;data<N;data++) {
			boolean ans = false;
			int[] a = new int[10];
			for(int i=0;i<10;i++) {
				a[i] = sc.nextInt();
			}
			for(int i=0;i<1024;i++) {
				int b = 0;
				int c = 0;
				boolean f = true;
				for(int j=0;j<10;j++) {
					if((i&(1<<j))==0) {
						if(a[j]>b) {
							b = a[j];
						}else{
							f = false;
							break;
						}
					}else{
						if(a[j]>c) {
							c = a[j];
						}else{
							f = false;
							break;
						}
					}
				}
				if (f) {
					ans = true;
					break;
				}
			}
			System.out.println(ans ? "YES" : "NO");
		}
	}
}

Measured memory_bytes: 19660
#include <stdio.h>
int arr[500001];

void maxHeapify(int* xs, int idx, int size)
{
	int left = idx*2, right = idx*2+1, largest = 0;
	if (left <= size && arr[idx] < arr[left]) {
		largest = left;
	} else {
		largest = idx;
	}
	if (right <= size && arr[right] > arr[largest]) {
		largest = right;
	}

	if (largest != idx) {
		int tmp = arr[idx];
		arr[idx] = arr[largest];
		arr[largest] = tmp;
		maxHeapify(xs, largest, size);
	}
}

int main()
{
	int size = 0;
	scanf("%d", &size);
	for (int i = 1; i <= size; i++) {
		scanf("%d", &arr[i]);
	}
	for (int i = size / 2; i >= 1; i--) {
		maxHeapify(arr, i, size);
	}
	for (int i = 1; i <= size; i++) {
		printf(" %d", arr[i]);
	}
	printf("\n");
}



Measured memory_bytes: 3736
import math

n, m = map(int, input().split())
w = 10 ** 9 + 7
if n + 1 == m or m + 1 == n:
    print(math.factorial(min(n, m)) ** 2 * max(n, m) % w)
elif n == m:
    print(2 * math.factorial(n) ** 2 % w)
else:
    print(0)


Measured memory_bytes: 47472
import random

def is_prime3(q,k=50):
    q = abs(q)
    #計算するまでもなく判定できるものははじく
    if q == 2: return True
    if q < 2 or q&1 == 0: return False

    #n-1=2^s*dとし（但しaは整数、dは奇数)、dを求める
    d = (q-1)>>1
    while d&1 == 0:
        d >>= 1

    #判定をk回繰り返す
    for i in range(k):
        a = random.randint(1,q-1)
        t = d
        y = pow(a,t,q)
        #[0,s-1]の範囲すべてをチェック
        while t != q-1 and y != 1 and y != q-1:
            y = pow(y,2,q)
            t <<= 1
        if y != q-1 and t&1 == 0:
            return False
    return True

N = int(input())
s=[0]*N
len = 0
for i in range(11,55555,5):
    if (is_prime3(i)):
        s[len]=i
        len =len+1
        if len == N:
            break
print(' '.join(map(str,s)))


Measured memory_bytes: 5732
#include<bits/stdc++.h>
using namespace std;
#define stop exit(0)
#define pb push_back
#define skip continue
//scanf("%lld",&a);
int main(){
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    vector<long long>v,u;
    pair<long long, long long>n;
    set<string>y;
    long long a,b,c,d=0,e=0,i,f=1000,g=0,j,k=0,l=0,r=0,z,m,h,p[82];
    string t,s,x,q;
    double w;
    cin>>a;
    for(i=1;i<=a;i++){
        cin>>p[i];
    }
    p[a+1]=0;
    d=1;
    e=1;
    while(d<a+1){
        if(p[d]<=p[d+1]){
            d++;
            skip;
        }
        else{
            f=f+(f/p[e]*(p[d]-p[e]));
            d++;
            e=d;
        }
    }
    cout<<f;
}

Measured memory_bytes: 3620
N, M = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)

bar = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
bar2num = Hash.new(0)
A.each do |n|
  b = bar[n]
  bar2num[b] = n if n > bar2num[b]
end

B = bar2num.keys.sort.reverse
B.delete(7) if B.include?(2) && B.include?(5)
B.delete(7) if B.include?(3) && B.include?(4)
B.delete(6) if B.include?(2) || B.include?(3)
B.delete(5) if B.include?(2) && B.include?(3)
B.delete(4) if B.include?(2) 
minbar = B.min
B.delete(minbar)
C = B.sort_by{|b| -bar2num[b]}.select{|b| bar2num[b] > bar2num[minbar]}

def calc(r)
  ans = []
  C.each do |b|
    if r >= b
      ans << b
      r -= b
      redo
    end
  end 
  B.each do |b|
    if r >= b   
      ans << b   
      r -= b   
      redo
    end 
  end
  r == 0 ? ans : false
end

q, r = N.divmod minbar
10.times do 
  tmp = calc(r)
  if tmp 
    tmp += Array.new(q, minbar)
    puts tmp.map!{|b| bar2num[b]}.sort!.reverse!.join
    break 
  end 
  q -= 1
  r += minbar 
end 


Measured memory_bytes: 3836
h,w,k = map(int,input().split())
F = [input() for _ in range(h)]
A = [[0]*w for _ in range(h)]

def square(F,A,y,x,h,w,color):
  r,l,u,d = 0,0,0,0
  
  while x+r+1 < w:      
    if F[y][x+r+1] == '.' and A[y][x+r+1] == 0:
      r += 1
    else:
      break
      
  while x-l-1 >= 0:      
    if F[y][x-l-1] == '.' and A[y][x-l-1] == 0:
      l += 1
    else:
      break     
      
  while y-u-1 >= 0:
    tmp = 0
    
    for i in range(-l,r+1):            
      tmp += (F[y-u-1][x+i] == '.' and A[y-u-1][x+i] == 0)    
    if tmp == r + l + 1:
      u += 1
    else:
      break
    
  while y+d+1 < h:
    tmp = 0
    for i in range(-l,r+1):  
      tmp += (F[y+d+1][x+i] == '.' and A[y+d+1][x+i] == 0)
    if tmp == r + l + 1:
      d += 1
    else:
      break
    
  for i in range(y-u,y+d+1):
    for j in range(x-l,x+r+1):
      A[i][j] = color  
      
c = 1
for i in range(h):
  for j in range(w):    
    if A[i][j] != 0:
      continue
    if F[i][j] == '#':
      square(F,A,i,j,h,w,c)
      c += 1
      
for i in range(h):
  print(*A[i])      

Measured memory_bytes: 7544
import sys
from collections import deque
input = sys.stdin.readline


def main():
    N, Q = [int(x) for x in input().strip().split()]
    data = []
    for _ in range(N-1):
        data.append([int(x) for x in input().strip().split()])

    operate = [0] * (N+1)
    for _ in range(Q):
        node, point = [int(x) for x in input().strip().split()]
        operate[node] += point

    tree = [[] for _ in range(N+1)]
    for d in data:
        tree[d[0]].append(d[1])
        tree[d[1]].append(d[0])

    stack = deque()
    stack.append((0,1))  # スタートノード
    while len(stack) > 0:
        parent_node, proc_node = stack.popleft()
        operate[proc_node] += operate[parent_node]
        for child_node in tree[proc_node]:
            if child_node == parent_node:
                continue
            stack.append((proc_node, child_node))

    print(*operate[1:])


if __name__ == "__main__":
    main()


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

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<bint,bint>
#define endl              "\n"
#define rep(i,a,b)        for(bint i=a;i<b;i++)
#define repe(i,a,b)       for(bint i=a;i<=b;i++)
#define bac(i,a,b)        for(bint i=a;i>b;i--)
#define bace(i,a,b)       for(bint i=a;i>=b;i--)
#define fast              ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//CHANGE IF REQ
#define int               long long int
#define bint              int
//-----------------

#define ld                long double
#define mod1              (bint)(1e9 + (bint)7)
#define mod2              (bint)998244353
#define pi                (float)3.14159265358979323846
#define inf               LLONG_MAX
#define ninf              (bint)-1*LLONG_MAX

#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define RSORT(v)          sort(all(v),greater<bint>())
#define REVERSE(v)        reverse(all(v))

#define trav(a, x)        for(auto& A : x)
#define display(x)        trav(A,x) cout<<A<<endl;
#define pow(i,n)          (bint)pow((bint)i,n)
#define pow2(n)           ((bint)1<<n)
#define sz(x)             (bint)x.size()

typedef std::priority_queue<bint, std::vector<bint>, std::greater<bint> > min_pq;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}

inline string inttos(bint a){std::stringstream soso; soso<<a; return soso.str();}
inline bint stoint(const std::string &s) {std::stringstream soso; soso << s; long long x; soso >> x; return x;}
inline std::string inttobin(bint x) {return std::bitset<40>(x).to_string();}
inline void swp(bint &a, bint &b){auto temp=a;a=b;b=temp;}

//pri - 1000000009
//ba  - 937,991,1013,1409,1741

void solve(){
    int n;
    cin>>n;
    DECIMAL(10);
    cout<<2*pi*n<<endl;

}


signed main(){
    fast
    int t=1;
    //cin>>t;
    rep(i,0,t){
       solve();
    }
}

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

int main() {
  int e;
  while (scanf("%d", &e) != EOF && e) {
    int m = 1000;
    for (int z=100; z>=0; z--) {
      if (e < z*z*z) {
	continue;
      }
      for (int y=0; y<m; y++) {
	if (e < y*y + z*z*z) {
	  break;
	}
	int x = e - y*y - z*z*z;
	if (x + y + z < m) {
	  m = x + y + z;
	}
      }      
    }      
    printf("%d\n", m);
  }
}

Measured memory_bytes: 1172
#include <stdio.h>
int main(void){
	int N, T[100000], M, P[100000], X[100000], s[100000];

	scanf("%d", &N);

	for(int i=0; i<N; i++){
		scanf("%d ",&T[i]);
	}

	scanf("%d", &M);

	for(int i=0; i<M; i++){
		scanf("%d %d",&P[i], &X[i]);
	}

	
	for(int i=0; i<M; i++){
		int tmp = T[P[i]-1];
		T[P[i]-1] = X[i];
		for(int j=0; j<N; j++){
			s[i] += T[j];
		}
		T[P[i]-1] = tmp;
			
	}
	for(int i=0; i<M; i++)
		printf("%d\n", s[i]);
		

	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <stdio.h>
#include <vector>

using namespace std;

#define eps 10e-9

int pow(int x,int n) {
	if( x == 0 ) return 0;
	if( n == 0 ) return 1;
	if( n == 1 ) return x;
	if( n & 1 ) {
		int y = pow( x, (n-1)/2 );
		return x * y * y;
	} else {
		int y = pow( x, n / 2 );
		return y * y;
	}
}

int main(void){

	while(1){
		int n, m, k;
		cin >> n >> m >> k;
		if( n == 0 && m == 0 && k == 0 ) break;

		double e = 0;
		int lim = pow(m, n);
		vector<int> fact;
		for(int i = 0; i <= n; i++) {
			fact.push_back(pow(m, i));
		}

		//m進数変換
		for(int i = 0; i < lim; i++) {
			int sum = 0;
			for(int j = 0; j < n; j++) {
				sum += ( ( i % fact[j+1] ) / fact[j] + 1);
			}
			sum -= k;
			if( sum <= 1 ) sum = 1;
			e += (double)(sum * 1.0) / (double) lim;
		}
		printf("%.8lf\n", e);
	}
	return 0;
}

Measured memory_bytes: 1240
#ifdef _DEBUG
#include "MyLib.h"
#else
#define main_C main
#include "bits/stdc++.h" 
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>
#define FOR(i,s,e) for (int i = int(s); i < int(e); ++i)
#define REP(i,e) FOR(i,0,e)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)
const int MGN = 8;
const int ARY_SZ_MAX = 10000000;
using namespace std;
using ll = long long; using ull = unsigned long long;
using vi = vector<int>; using vvi = vector<vi>; using vvvi = vector<vvi>;
using vb = vector<bool>; using vvb = vector<vb>; using vvvb = vector<vvb>;
using vl = vector<ll>; using vvl = vector<vl>;
using vd = vector<double>; using vs = vector<string>;
using pii = pair<int, int>; using pll = pair<ll, ll>;
// functions
bool second_greater(const pii& left, const pii& right) {
    return left.second > right.second;
}
#endif


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

    int N; cin >> N;
    vi A(N + 2, 0); FOR(i, 1, N+1) cin >> A[i];

    ll sum = 0;
    FOR(i, 1, N+1) {
        sum += abs(A[i] - A[i-1]);
    }
    sum += abs(A[0] - A[N]);

    vi ans;
    FOR(i, 1, N+1) {
        int t = sum;
        t -= (abs(A[i] - A[i - 1]) + abs(A[i+1] - A[i]));
        t += abs(A[i + 1] - A[i - 1]);
        ans.push_back(t);
    }
    
    for(int i : ans) cout << i << endl;

    return 0;
}

Measured memory_bytes: 2168
#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() {
    double a,b;
    cin >> a >> b;
    double x = (a+b)/2;
    cout << ceil(x) << endl;
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, char *argv[])
{
	string S, rS;

	cin >> S;

	int ans = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != S[S.size() - i - 1]) {
			ans++;
		}
	}

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

Measured memory_bytes: 256
s=input()
b="abcdefghijklmnopqrstuvwxyz"
from collections import defaultdict 
if len(s)<26:
  d=defaultdict(int)
  for c in s:
    d[c]+=1
  for bb in b:
    if d[bb]==0:
      print(s+bb)
      exit() 
N=len(s)
lst=[]
for first in range(N-1,0,-1):
  mn=s[first]
  for i in range(first-1,-1, -1):
    if s[i]<mn:
      lst.append(s[:i]+mn)
      #print(s[:i]+mn)
      #exit()
if lst:
  print(sorted(lst)[0])
  exit()
print(-1)
    


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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

int niz[100010];

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

    int n;
    cin >> n;
    bool joker = false;
    int cnt = 0;
    int minAbs = 1e9 + 1;
    int ind = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> niz[i];
        if(niz[i] == 0) joker = true;
        if(niz[i] < 0) cnt++;
        if(abs(niz[i]) < minAbs) minAbs = abs(niz[i]), ind = i;
    }
    ll sum = 0;
    for(int i = 0; i < n; i++)
        sum += abs(niz[i]);

    if(joker || cnt % 2 == 0) cout << sum;
    else cout << sum - 2*minAbs;


    return 0;
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

int rec(string s){
    if([&](){
        rep(i,1,s.size()-1) if(!isdigit(s[i])) return false;
        return true;
    }()) return (stoi(s.substr(1,s.size()-2))+1)/2;

    vector<int> val;
    int d=0,l;
    rep(i,1,s.size()-1){
        if(s[i]=='['){
            if(!d) l=i;
            ++d;
        }
        if(s[i]==']'){
            if(d==1) val.push_back(rec(s.substr(l,i-l+1)));
            --d;
        }
    }

    sort(val.begin(),val.end());
    int res=0;
    rep(i,0,(val.size()+1)/2) res+=val[i];
    return res;
};
void solve(){
    string s;
    cin >> s;
    cout << rec(s) << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    int n;
    cin >> n;
    rep(i,0,n) solve();
    return 0;
}

Measured memory_bytes: 3256
import sys

N = int(input())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])
XY.sort(key=lambda x: x[1])

if N == 1:
    print(1)
    sys.exit()

PQ = {}
for i in range(len(XY)):
    for j in range(len(XY)):
        pq = XY[i][0] - XY[j][0], XY[i][1] - XY[j][1]
        if pq == (0, 0):
            continue
        if pq in PQ.keys():
            PQ[pq] += 1
        else:
            PQ[pq] = 1

pq = max(PQ, key=lambda x: PQ[x])
print(N - PQ[pq])


Measured memory_bytes: 3444
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]


n,m=map(int,input().split())
ks=[list(map(int,input().split())) for i in range(m)]
p=list(map(int,input().split()))

bit=list(product(range(2),repeat=n))
ans=0
for bi in bit:
    plst=[0]*m
    for j in range(m):
        for k in range(ks[j][0]):
            plst[j]+=bi[ks[j][1+k]-1]
    
    for j in range(m):
        if plst[j]%2!=p[j]:
            break
    else:
        ans+=1
print(ans)

Measured memory_bytes: 75048
#include <bits/stdc++.h>
#define ll long long
#define f first
#define s second
#define mod 1000000007
#define N 500043
#define mp(a,b) make_pair(a,b)
#define loop(a,b) for(int i=a;i<b;i++)
#define test int t; cin >> t; while(t--)
using namespace std;
 
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int x;
    cin >> x;
    if(x==0) cout << "1";
    else cout << "0";
}

Measured memory_bytes: 3608
ls = []
ls2=[]
r,c = map(int,input().split())
for i in range(0, r):
    ls.append(list(map(int,input().split())))

for j in range(0, r):
    ls[j].append(sum(ls[j]))

for j in range(0, c+1):
    num = 0
    for k in range(0, r):
        num += ls[k][j]
    ls2.append(num)
ls.append(ls2)
for z in range(0, r+1):
    print(*ls[z])

Measured memory_bytes: 8320
def eratosthenes(n):
  l0=list(range(2,n+1))
  l1=[1]*(n+1)
  l1[0]=0
  l1[1]=0
  for li in l0:
    if li>int(n**0.5):
      break
    if l1[li]==1:
      k=2
      while k*li<=n:
        l1[k*li]=0
        k+=1
  ret=[i for i,li in enumerate(l1) if li==1]
  return ret
s=eratosthenes(55555)
ans=['2']
n=int(input())
for si in s:
  if str(si)[-1]=='3':
    ans.append(str(si))
print(' '.join(ans[:n]))


Measured memory_bytes: 68712
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
#define mi 600851475143

int main()
{FAST
ld a,b,h,m;
cin>>a>>b>>h>>m;
 h=h+m/60;	
ld z=PI*h/6-PI*m/30;
//cout<<cos(z);
cout<<setprecision(13)<<sqrt(a*a+b*b-2*a*b*cos(z));	
//cout<<(a*a+b*b-c*c)/(2*a*b);
	
}


Measured memory_bytes: 4172
#include<stdio.h>
int main(void)
{
	char s[4];
	scanf("%s",&s);
	int i=0;
	if(s[0]=='1'){
		++i;
	}
	if(s[1]=='1'){
		++i;
	}
	if(s[2]=='1'){
		++i;
	}
	printf("%d\n", i);
	return 0;
}

Measured memory_bytes: 128
def LI(): return list(map(int,input().split()))
N,K = LI()
a = LI()
ans = float('INF')
for i in range(2**(N-1)):
    bit = [i>>j&1 for j in range(N-1)]
    if K-1!=sum(bit):
        continue
    cost,kijun = 0,a[0]
    for k in range(N-1):
        if bit[k]==0:
            kijun = max(kijun,a[k+1])
            continue
        if a[k+1]>=kijun+1:
            kijun = a[k+1]
            continue
        cost += (kijun+1)-a[k+1]
        kijun += 1
    ans = min(ans,cost)
print(ans)


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define ll long long
#define mm 1000000007
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define pii pair<int, int>
#define pll pair<ll, ll>
#define siz(x) (int)x.size()

#define show(x) cout<<#x<<" "<<x<<'\n'
#define iosbase ios_base::sync_with_stdio(false); cin.tie(NULL);
#define oset tree<int , null_type, less_equal<int> , rb_tree_tag, tree_order_statistics_node_update>

using namespace std;
using namespace __gnu_pbds;

ll dp[100005][105];
pll a[105];
ll n;

ll fun(ll x,ll i)
{
    if(x<0) return 0;
    if(i<1) return 0;
    
    if(dp[x][i]==-1)
    {
        if(x-a[i].ff>=0)
            dp[x][i]=max(fun(x,i-1),a[i].ss+fun(x-a[i].ff,i-1));
        else dp[x][i]=fun(x,i-1);
    }
    
    return dp[x][i];
}
int main()
{
    iosbase;
    ll w,i;
    cin>>n>>w;
    
    ll x,y;
    memset(dp,-1,sizeof(dp));
    for(i=1;i<=n;i++)
    {
        cin>>x>>y;
        a[i]=mp(x,y);
    }
    ll res=fun(w,n);
    ll ans=-1;
    for(i=1;i<=n;i++)
    {
        ans=max(ans,dp[w][i]);
        //cout<<dp[w][i]<<'\n';
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 82304
#include <iostream>
#include <algorithm>

using namespace std;

int partition(int A[], int p, int r) {
	int x = A[r];
	int i = p - 1;
	for (int j = p; j < r; ++j) {
		if (A[j] <= x) {
			i++;
			swap(A[i], A[j]);
		}
	}
	swap(A[i + 1], A[r]);
	return i + 1;
}

int A[100000];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; ++i) cin >> A[i];
	int q = partition(A, 0, n - 1);
	for (int i = 0; i < n; ++i) {
		if (i) cout << " ";
		if (i == q) cout << "[";
		cout << A[i];
		if (i == q) cout << "]";
	}
	cout << endl;

	return 0;
}


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

int min_cost(int height[], int n, int k) {
    int dp[n];
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        dp[i] = INT_MAX;
        for (int j = 1; j <= k && (i - j >= 0); j++) {
            dp[i] = min(dp[i], dp[i - j] + abs(height[i] - height[i - j]));
        }
    }
    return dp[n - 1];
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n, k;
    cin >> n >> k;
    int height[n];
    for (int i = 0; i < n; ++i) {
        cin >> height[i];
    }
    cout << min_cost(height, n, k) << endl;
    return 0;
}

Measured memory_bytes: 1024
def gcd(a, b):
	while b:
		a, b = b, a % b
	return a
    
S = input().split()

A = int(S[0])
B = int(S[1])
C = int(S[2])
D = int(S[3])

CD = (C * D) // gcd(C, D)

count_B = B - (B // C) - (B // D) + (B // CD)
count_A = A - 1 - ((A - 1) // C) - ((A - 1) // D) + ((A - 1) // CD)

print(count_B - count_A)


Measured memory_bytes: 3064
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

type plan struct {
	t, x, y int
}

func intAbs(x int) int {
	return int(math.Abs(float64(x)))
}

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

	N := scanInt()
	L := make([]plan, N+1)
	for i := 1; i <= N; i++ {
		L[i].t, L[i].x, L[i].y = scanInt(), scanInt(), scanInt()
	}

	for i := 1; i <= N; i++ {
		dist := intAbs(L[i].x-L[i-1].x) + intAbs(L[i].y-L[i-1].y)
		time := L[i].t - L[i-1].t
		if time < dist {
			fmt.Println("No")
			return
		}
		if (time-dist)%2 == 1 {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 5240
#include <iostream>
#include <string>
#include <cstring>
#include <cstdio>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <functional>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <iomanip>
#if __cplusplus >= 201103L
#include <unordered_map>
#include <unordered_set>
#endif
#define ls x<<1
#define rs x<<1|1
#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define fun function
#define vi vector<int>
#define lowbit(x) x&(-x)
#define pii pair<int,int>
#define all(x) x.begin(),x.end()
#define mem(a,b) memset(a,b,sizeof(a))
#define IOS ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);

using namespace std;

const int INF = 0x3f3f3f3f;
const int N=1e5+10;

ll p=1e9+7;


ll qpow(ll a,ll b) {
	ll ans=1;
	while(b) {
		if(b&1)ans=ans*a%p;
		a=a*a%p;
		b>>=1;
	}
	return ans;
}

ll Com(ll n,ll m) {
	ll x=1,y=1;
	for(ll i=1; i<=m; i++) {
		x=x*(n-i+1)%p;
		y=y*i%p;
	}

	return x*qpow(y,p-2)%p;
}


int main() {
	IOS;
#ifdef xiaofan
	freopen("1.in","r",stdin);
	freopen("1.out","w",stdout);
#endif

	ll n,x,y;
	cin>>n>>x>>y;

	ll ans=qpow(2,n);
	ll a=Com(n,x);
	ll b=Com(n,y);
	ans=(ans+p+p-a-b-1)%p;
	cout<<ans<<endl;



	return 0;
}



Measured memory_bytes: 256
N=int(input())
a=list(map(int,input().split()))
a.sort()


ans=[a[-1],a[0]]

target=a[-1]/2
d=10**9
for i in range(N-1):
    diff=abs(a[i]-target)
    if diff<d:
        d=diff
        ans[1]=a[i]

            
print(' '.join(map(str, ans)))
        




Measured memory_bytes: 62704
n = gets.to_i
s = gets.chomp
x = ("a".."z").to_a

ans = 0
(n-2).times do |i|
    count = 0
    x.each do |c| 
        count += 1 if s[0..i].include?(c) && s[i+1..n-1].include?(c)
    end
    ans = count if ans < count
end

puts ans

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

int n, a, b;
int p[100];


int main(){
	int c1 = 0;
	int c2 = 0;
	int c3 = 0;

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

	sort(p, p + (n - 1));
	
	for (int i = 0; i < n; i++){
		if (p[i] <= a) c1++;
		if (p[i] > a && p[i] <= b) c2++;
		if (p[i] > b) c3++;
	}
	cout << min(c1, min(c2, c3)) << endl;






	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>

using namespace std;

#define rep(i,j) REP((i), 0, (j))
#define REP(i,j,k) for(int i=(j);(i)<(k);++i)
#define BW(a,x,b) ((a)<=(x)&&(x)<=(b))
#define ALL(v) (v).begin(), (v).end()
#define LENGTHOF(x) (sizeof(x) / sizeof(*(x)))
#define AFILL(a, b) fill((int*)a, (int*)(a + LENGTHOF(a)), b)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define INF 1 << 30
#define EPS 1e-10

typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef vector<int> vi;
typedef queue<int> qi;
typedef long long ll;

int N, M, I[1000000], O[1000000];
string P;

int main(){
  while(scanf("%d", &N) && N){
    scanf("%d", &M);
    cin >> P;

    memset(I, 0, sizeof(I));
    memset(O, 0, sizeof(O));
    (P[0]=='I'?I[0]:O[0]) = 1;
    (P[1]=='I'?I[1]:O[1]) = 1;
    REP(i, 2,M){
      if(P[i] == 'I') I[i] = I[i-2] + 1;
      else O[i] = O[i-2] +1;
    }

    int res = 0;
    rep(i, M-1){
      if(O[i] >= N && I[i+1] >= N+1) res++;
    }
    //    rep(i, M) printf("%d ", I[i]); puts("");
    //    rep(i, M) printf("%d ", O[i]); puts("");
    printf("%d\n", res);
  }
  return 0;
}

Measured memory_bytes: 9952
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<pii,int> ppiii ;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
int main(){
	int n,a,b,x;
	cin>>n>>a>>b;
	int ans=0;
	for(int i=0;i<n;i++){
		cin>>x;
		if(x>=a&&x<b)ans++;
	}
	cout<<n-ans<<endl;
}

Measured memory_bytes: 256
# n,k=map(int,input().split())
N, K = map(int, input().split())

check=[0]*N
 
for i in range(K):
  d=int(input())
  a=[int(K) - 1 for K in input().split()]
  for j in a:
    check[j]+=1

# print(check)
count = 0
for i in check:
    if i == 0:
        count += 1

print(count)

Measured memory_bytes: 9108
H,W = map(int,input().split())
maze = []
for i in range(H):
    s = input()
    m = []
    for j in range(W):
        m.append(s[j])
    maze.append(m)
d = [[10**9 for i in range(W*H)] for i in range(W*H)]
dx = [0,0,1,-1]
dy = [1,-1,0,0]
for i in range(W*H):
    h = i//W
    w = i%W
    if maze[h][w] == '#':
        continue
    for j in range(4):
        x = w + dx[j]
        y = h + dy[j]
        k = x + y*W
        if 0<=x<=W-1:
            if 0<=y<=H-1:
                if maze[y][x] == '.':
                    d[i][k] = 1
                    d[k][i] = 1
for i in range(W*H):
    d[i][i] = 0
def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(W*H):
        for i in range(W*H):
            for j in range(W*H):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d
warshall_floyd(d)
ans = 0
for i in range(W*H):
    for j in range(W*H):
        if d[i][j] < 10**9:
            ans = max(ans,d[i][j])
print(ans)

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

typedef long long ll;
using namespace std;

int main() {
    ll h;
    cin >> h;

    ll n = 1;
    ll cnt = 0;
    while (h > 0) {
        h /= 2;
        cnt += n;
        n *= 2;
    }
    cout << n - 1;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right

ll N;

void dfs(string before, ll maxchar){
    if(before.size() == N){
        cout << before << endl;
        return ;
    }
    
    rep(i, maxchar + 1){
        string tmp = before + (char)('a' + i);
        dfs(tmp, max(i + 1, maxchar));
    }
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin >> N ;
    
    dfs("", 0);
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


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


// "RRLLLRL" -> 0, 2, 0, 0, 0, 1, 0
//              0, 0, 3, 0, 0, 0, 1
// 0, (2 + 1) / 2, 2 / 2, 0, 0, (1 + 1) / 2, 1 / 2
// 0, 3 / 2, (3 + 1)/ 2, 0, 0, 1 / 2, (1 + 1) / 2
// 0, 2, 3, 0, 0, 1, 1


string S;

int ans[100000];

int main(){
    cin >> S;

    int r_cnt[100000] = {}, l_cnt[100000] = {};

    int tmp = 0;
    for(int i = 0; i < S.length(); i++){
        if(S[i] == 'R'){
            tmp++;
        }else{
            r_cnt[i - 1] = tmp;
            ans[i] += tmp / 2;
            ans[i - 1] += (tmp + 1) / 2;
            tmp = 0;
        }
    }
    for(int i = S.length() - 1; i >= 0; i--){
        if(S[i] == 'L'){
            tmp++;
        }else{
            l_cnt[i + 1] = tmp;
            ans[i] += tmp / 2;
            ans[i + 1] += (tmp + 1) / 2;
            tmp = 0;
        }
    }
    for(int i = 0; i < S.length(); i++){
        if(i){
            cout << " ";
        }
        cout << ans[i];
    }
    cout << endl;
}


    


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

using namespace std;

const int mxN = 1e5 + 1;

void solve(){
	int n,x,t; cin>>n>>x>>t;
	int ans = (n/x)*t;
	ans += (n%x)?(t):(0);
	cout << ans << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t=1;
	int cs = 1;
	while(t--){
		//cout << "Case #" << cs << ":\n";
		solve();
		cs++;
	}
	return 0;
}


Measured memory_bytes: 3636
import java.util.Scanner;

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

    int X = scanner.nextInt();
    int res = 0;
    res += X / 500 * 1000;
    X -= X / 500 * 500;
    res += X / 5 * 5;
    System.out.println(res);
  }
}


Measured memory_bytes: 21716
#include <stdio.h>

void counting_sort(int A[], int B[], int k) {
	int i,j;
	int C[20000];
	for(i=0;i<20000;i++) C[i] = 0;

	for(i=0;i<k;i++) C[A[i]+1]++;

	for(i=1;i<20000;i++) {
		C[i] = C[i] + C[i-1];
	}

	for(i=1,k=0;i<=10001;i++) {
		for(j=C[i-1];j<C[i];j++) {
			B[k] = i-1;
			k++;
		}
	}
}

int A[2000000+1];
int B[2000000+1];

int main(void) {
	int i,n;
	scanf("%d\n", &n);
	for(i=0;i<n;i++) {
		scanf("%d", &A[i]);
	}
	counting_sort(A, B, n);
	
	for(i=0;i<n;i++) {
		printf("%d", B[i]);
		if(i<n-1) {
			printf(" ");
		} else {
			printf("\n");
		}
	}
	
	return 0;
}

Measured memory_bytes: 16304
#include <bits/stdc++.h>
#define LL long long
#define Accel ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define Re(a,b) memset(a,b,sizeof a)
#define F first
#define S second
#define MP make_pair
#define PB push_back
#define ALL(X) (X).begin(), (X).end()
#define FOR(I, A, B) for (int I = (A); I <= (B); I++)
#define REP(I, N) for (int I = 0; I < (N); I++)
#define PII pair<int,int>
#define PLL pair<LL,LL>
#define SZ(a) ((int)a.size())
//#pragma GCC optimize(2)
using namespace std;
//const double eps=1e-6;
//typedef complex<double>C;
//const double PI(acos(-1.0));
//for(int mask=i;mask>0;mask=(mask-1)&i)
//int a[25]= { 2, 3, 5, 7, 11, 13, 17, 19, 23, 29, 31, 37, 41, 43, 47, 53, 59, 61, 67, 71, 73, 79, 83, 89, 97 };
//__gcd, atan2(y,x)=y/x , __int128
//c(n,k)=c(n-1,k-1)+c(n-1,k)
//c(i,r),i for r to n =c(n+1,r+1)
//void add(int x){while(x<N)BIT[x]++,x+=x&-x;}
//int sum(int x){int s=0;while(x){s+=BIT[x];x-=x&-x;}return s;}
//int find(int x){return x==p[x]?x:p[x]=find(p[x]);}
//LL pw(LL a,LL b){LL t=1;for(;b;b>>=1,a=a*a%M)b&1?t=t*a%M:0;return t;}
//log() = ln() , log(x)/log(y)=log(y)-base-x
//INT_MAX 127,INT_MIN 128
//isalnum() decimal digit or an uppercase or lowercase letter
//int dw[4][2]={{0,1},{1,0},{0,-1},{-1,0}};
//int dw[8][2]={{0,1},{1,0},{0,-1},{-1,0},{1,1},{1,-1},{-1,1},{-1,-1}};
//cout<<fixed<<setprecision(12)<<ans<<endl;
//__builtin_popcount(mask)
const int N=60000;
const int M=1e9+7;


int n,m;
vector<int>pr;
int p[N];
int main() {
	for(int i=2;i<=55555;i++)
		if(!p[i]){
			pr.PB(i);
			for(int j=i+i;j<=55555;j+=i)p[j]=1;
		}
	cin>>n;
	int c=0;
	for(auto x:pr){
		if(x%5==2){
			cout<<x<<" ";
			c++;
			if(c==n)break;
		}

	}
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(N);
    int n = N-1;
    vector<int> C(n);
    vector<int> S(n);
    vector<int> F(n);
    for (int i = 0; i < n; i++) {
        cin >> C[i];
        cin >> S[i];
        cin >> F[i];
    }
    
    rep(i, n) {
        int sum = 0;
        sum += C[i] + S[i];
        for (int j = i+1; j < n; j++) {
            if (sum > S[j]) {
                int tmp = sum - F[j];
                tmp = (tmp / F[j] + !!(tmp % F[j])) * F[j] - tmp;
                sum += tmp + C[j];
            } else {
                sum = C[j] + S[j];
            }
        }
        cout << sum << endl;
    }
    cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 256
// 12:20
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <map>
#include <algorithm>
#include <deque>
#include <tuple>
#include <utility>
using namespace std;
typedef long long ll;
#define for1(i,n) for (ll i=0;i<(n);(i)++)
#define for2(i,m,n) for (ll (i)=(m);(i)<(n);(i)++)
#define for3(i,m,n,d) for (ll (i)=(m);(i)<(n);(i)+=(d))
#define INF (1LL << 60)

ll A[100005];
ll B[100005];
ll give[100005];

void solve()
{
  ll N;
  cin >> N;
  for1(i,N) {
    cin >> A[i];
  }
  for1(i,N) {
    cin >> B[i];
  }
  ll sumA = 0;
  ll sumB = 0;
  ll ans = 0;
  for1(i,N) {
    sumA += A[i];
    sumB += B[i];
  }
  if (sumA < sumB) {
    cout << -1 << endl;
    return;
  }
  ll take = 0;
  for1(i,N) {
    if (A[i] >= B[i]) {
      give[i] = A[i] - B[i];
    } else {
      take += B[i] - A[i];
      ++ans;
    }
  }
  sort(&give[0], &give[N], greater<ll>());
  ll cgive = 0;
  for1(i,N) {
    if (cgive >= take) {
      cout << i + ans << endl;
      return;
    }
    cgive += give[i];
  }
  cout << -1 << endl;
}

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


Measured memory_bytes: 2560
// Problem : D - Sum of Divisors
// Contest : AtCoder - AtCoder Beginner Contest 172
// URL : https://atcoder.jp/contests/abc172/tasks/abc172_d
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//mst,pq,mp,st,q
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define all(x) begin(x),end(x)

int mod = 1e9+7;
int inf = 4e18;
const int N = 1e7+5;
int sv[N];		
signed main()
{
    io
    int tt = 1;
    //cin>>tt;
    while(tt--)
    {
		int n;
		cin>>n;
		for(int i=1;i<=n;++i)
		sv[i] = 1;
		//sv[1] = 1;
		for(int i=1;i<=n;++i)
		{
			for(int j=2*i;j<=n;j+=i)
			{
				sv[j]++;
			}
		}
		int sum = 0;
		for(int i=1;i<=n;++i)
		sum+=(i*sv[i]);
		cout<<sum;
    }
    return 0;
}


Measured memory_bytes: 81768
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final Scanner scanner = new Scanner(System.in);
        final int n = scanner.nextInt();
        final boolean result = IntStream.range(0, n)
                .mapToObj(i -> scanner.nextInt())
                .filter(i -> i % 2 == 0)
                .allMatch(i -> i % 3 == 0 || i % 5 == 0);
        if (result) {
            System.out.println("APPROVED");
        } else {
            System.out.println("DENIED");
        }
    }
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int a=0,b,c;
  string s,t;
  cin >>s>>t;
  rep(i,s.size()){
    if(s[i]!=t[i])a++;
  }
  cout <<a;
}

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

int main(){
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int t1 = 60 * h1 + m1;
    int t2 = 60 * h2 + m2;
    int ans = t2-t1-k;
    ans = max(0, ans);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <unordered_map>
#include <utility>
#include <vector>

using namespace std;

#define ll long long
#define forn(i, n) for (ll i = 0; i < (ll) n; ++i)
#define sz(a) static_cast<int>(a.size())

char buff[(int) 2e6 + 17];
const ll inf = (ll) 1e9 + 7ll;

const int maxn = (int) 1e5 + 17;

int n;
string s;

bool read() {
    if (scanf("%s", buff) != 1)
        return false;

    return true;
}

void solve() {
    s = buff;
    n = sz(s);
    string t;

    for (int i = 0; i < n; ++i)
        if (s[i] != 'x')
            t.push_back(s[i]);

    auto tt = t;
    reverse(tt.begin(), tt.end());

    if (tt == t) {
        if (t.empty()) {
            printf("0\n");
            return ;
        }

        int k = -1, l, r = -1;

        for (int i = 0; i < n; ++i)
            if (s[i] != 'x') {
                ++k;

                if (2 * k + 1 <= sz(t))
                    l = i;

                if (2 * k + 1 >= sz(t) && r == -1)
                    r = i;
            }

        int ans = 0;

        for (; l >= 0 && r < n; ) {
            if (s[l] == s[r])
                --l, ++r;
            else {
                if (s[l] == 'x')
                    --l;
                else
                    ++r;

                ++ans;
            }
        }

        printf("%d\n", ans + l + (n - r + 1));
    } else
        printf("-1\n");
}

int main() {
#if SEREZHKA
    freopen("file.in", "r", stdin);
#endif

    while (read())
        solve();

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast", "unroll-loops")
#define ll long long 
#define pii pair<int, int>
#define ull unsigned ll
#define f first
#define s second
#define FOR(i,a,b) for (int i=(a); i<(b); i++)
#define REP(i,n) for (int i=0; i<(n); i++)
#define RREP(i,n) for (int i=(n-1); i>=0; i--)
#define ALL(x) x.begin(),x.end()
#define SZ(x) x.size()
#define SQ(x) (x)*(x)
#define MNTO(a,b) a = min(a,(__typeof__(a))(b))
#define MXTO(a,b) a = max(a,(__typeof__(a))(b))
#define pb push_back
#define debug(x) cerr<<#x<<" is "<<x<<endl
using namespace std;

// #define int ll

const int maxn = 1e5+5;
const int iinf = 1<<29;
const ll inf = 1ll<<60;
const ll mod = 1e9+7;


void GG(){cout<<"-1\n"; exit(0);}

ll pow(ll a, ll n){ // a^n % mod
	ll re=1;
	while (n>0){
		if (n&1) re = re*a %mod;
		a = a*a %mod;
		n>>=1;
	}
	return re;
}

ll inv (ll b){
	if (b==1) return b;
	return (mod-mod/b) * inv(mod%b) % mod;
}

set<int> g[maxn];
bool seen[maxn];
int dep[maxn];
vector<pii> pts;
int fa[maxn];
int odeg[maxn];
set<pii> prt;

void dfs(int at){
	seen[at]=1;
	pts.pb({dep[at],at});
	for (auto &xx: g[at]){
		if (!seen[xx]){
			dep[xx]=dep[at]+1;
			fa[xx]=at;
			if (prt.count({xx,at})){
				prt.erase({xx,at});
				odeg[xx]--;
			}
			if (prt.count({at,xx})){
				prt.erase({at,xx});
				odeg[at]--;
			}
			dfs(xx);
		}
	}
}

main(){
    ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m; cin>>n>>m;
    if (m&1) GG();
    REP(i,m){
    	int a, b; cin>>a>>b; a--; b--;
    	odeg[b]++;
    	prt.insert({b,a});
    	g[a].insert(b);
    	g[b].insert(a);
    }
    dfs(0);
    sort(ALL(pts), greater<pii>());
    REP(j,n){
    	int i = pts[j].s;
    	if (fa[i]==i) continue;
    	int e = g[i].size();
    	if (odeg[i]%2==1){
    		prt.insert({i,fa[i]});
    	}else{
    		prt.insert({fa[i],i});
    		odeg[fa[i]]++;
    	}
    }
    for (auto xx: prt){
    	cout<<xx.f+1<<' '<<xx.s+1<<'\n';
    }

    
}

Measured memory_bytes: 30200
#include <bits/stdc++.h>
template<class T> inline bool chmin(T&a, T b){if(a > b){a = b; return true;}else{return false;}}
template<class T> inline bool chmax(T&a, T b){if(a < b){a = b; return true;}else{return false;}}
#define ll long long
#define double long double
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mod (ll)(1e9+7)
#define inf (ll)(3e18+7)
#define pi (double) acos(-1.0)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
using namespace std;

int main() {
    string o, e, ans = "";
    cin >> o >> e;
    rep(i, e.size()){
        ans += o[i];
        ans += e[i];
    }
    if(o.size() - e.size() == 1)ans += o[(int)o.size()-1];
    cout << ans << endl;
}

Measured memory_bytes: 3584
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>
#include <set>
#include <stack>
#include <vector>
#include <queue>
#include <bitset>
#include <string>
using namespace std;

#define REP(i,n) for(int i=0; i<n; i++)
#define RPA(i,s,e) for(int i=s; i<=e; i++)
#define RPD(i,s,e) for(int i=s; i>=e; i--)
#define PB(a) push_back(a)
#define MP(i,s) make_pair(i,s)
#define SZ(a) (int)(a).size()
#define ALL(a) (a).begin(), (a).end()
#define PRT(a) cout << (a) << endl
#define PRT2(a,b) cout << (a) << " " << (b) << endl
#define PRT3(a,b,c) cout << (a) << " " << (b) << " " << (c) << endl

typedef vector<int> VI;
typedef long long LL;
typedef pair<int,int> P;

string str;

void coding() {
	while(getline(cin, str)) {
		for(;;) {
			if(str.find("the") != string::npos) break;
			if(str.find("this") != string::npos) break;
			if(str.find("that") != string::npos) break;
			for(int i=0; i<str.size(); i++) {
				if(str[i] >= 'a' && str[i] <= 'z') {
					str[i] = (char)(((int)(str[i] - 'a') + 1) % 26) + 'a'; 
				}
			}
		}
		cout << str << endl;
	}
}

// #define _LOCAL_TEST

int main() {
#ifdef _LOCAL_TEST
	clock_t startTime = clock();
	freopen("a.in", "r", stdin);
#endif

	coding();

#ifdef _LOCAL_TEST
	clock_t elapsedTime = clock() - startTime;
	cout << endl;
	cout << (elapsedTime / 1000.0) << " sec elapsed." << endl;
	cout << "This is local test" << endl;
	cout << "Do not forget to comment out _LOCAL_TEST" << endl << endl;
#endif
}

Measured memory_bytes: 1176
#include <stdio.h>
#include <math.h>
#include<bits/stdc++.h>
using namespace std;
#define int long long int
 #define hi ios_base :: sync_with_stdio(false); cin.tie(0);cout.tie(0);
int i,j,k,mo;
main()

{
    int n;cin>>n;int a[n];
    for(i=0;i<n;i++) cin>>a[i];
    int c=0;
    for(i=0;i<n;i++)
    {
        if(i+1==a[i]) continue;
        c++;
    }
    if(c<=2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;

const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
int main(){
    int n;cin>>n ;
    vi a(100,0);
    rep(i,n+1){
        if(i==0)continue;
        string s=to_string(i);
        int f=s[0]-'0';
        int _ = s.length()-1;
        int l=s[_]-'0';
        a[10*f+l]++;
    }
    int ans=0;
    rep(i,n+1){
        string s=to_string(i);
        int f=s[0]-'0';
        int _ = s.length()-1;
        int l=s[_]-'0';
        ans+=a[10*l+f];
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] array = new long[n];
		for(int i=0;i<n;i++) {
			array[i] = sc.nextLong();
			if(array[i]==0) {
				System.out.println(0);
				return;
			}
		}
		sc.close();

		long max = 1000000000000000000L;


		long ans = 1L;
		for(long i :array) {
			long tmp = max/ans;
			if(i>tmp) {
				System.out.println(-1);
				return;
			}
			ans = ans*i;

		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 49572