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

public class Main {
	public static void main (String[] args) {
		InputReader in = new InputReader(System.in);
	    int n = in.readInt();
	    int arr[] = new int[n]; 
	    int sum = 0; 
	    for(int i = 0; i<n; i++) {
	    	arr[i] = in.readInt(); 
	    	 
	    }
	    Arrays.sort(arr);
	    for(int i = 0; i<n-1; i++) {
	    	sum += arr[i]; 
	    }
	    if(sum > arr[arr.length-1])System.out.println("Yes"); 
	    else System.out.println("No");
	}
}

class InputReader {

	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	public InputReader(InputStream stream) {
		this.stream = stream;
	}

	public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

	public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

	public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

	public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
	public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}

	public String next() {
		return readString();
	}

	public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 22228
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

int a[100];

int main()
{
	char s[1000];
	scanf("%s",s);
	int flag = 0;
	if((s[0] == s[1] && s[0] == s[2]) || (s[1] == s[2] && s[2] == s[3])) flag = 1;
	if(flag) printf("Yes\n");
	else printf("No\n");
}

Measured memory_bytes: 128
#include<iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int Max = 1000000;
int main(){
  	ll X;
  	cin >> X;
  	ll ans = 0;
  	ans += 1000*(X/500);
  	X %= 500;
  	ans += 5*(X/5);

  	cout << ans <<endl;

    
  	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define all(x) (x).begin(), (x).end()
#define SZ(X) ((int)(X).size())
#define mod 10000007
typedef unsigned long long ull;
int main()
{
    ios::sync_with_stdio(0);
	cin.tie(0);
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
    ull n,d,x,y,ans=0;
    cin>>n>>d;
    while (n--)
    {
        cin>>x>>y;
        
        if (x*x+y*y<=d*d)
        {
           
            ans++;
        }
        
    }
    cout<<ans;
    return 0;

}



Measured memory_bytes: 3648
#include <algorithm>
#include <iostream>
#include <vector>
#include <set>
#include <map>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
typedef long long ll;
int main() {
    long long int x;
    cin >> x;
    for(long long int i = -1000; i<1001; i++){
        for(long long int j= -1000; j<1001; j++){
            long long int tmp = i*i*i*i*i - j*j*j*j*j;
                if(x == tmp){
                    cout << i << " " << j << std::endl;
                    return 0;
                 }
        }
    }
    return 0;
}

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

using namespace std;
typedef long long ll;

 
string to_string(string s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifndef ONLINE_JUDGE
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

ll bigmod(ll a, ll n, ll M) {
  ll res = 1LL;
  while (n) {
    if (n & 1) res = (res * a) % M;
    a = (a * a) % M;
    n >>= 1;
  }
  return res % M;
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  ll n, x, m;
  cin >> n >> x >> m;
  if (x == 0) {
    cout << 0 << '\n';
    return 0;
  }
  ll cur = x; 
  map<ll, int> mp;
  vector<ll> v;
  int ptr = 1;
  v.push_back(cur);
  mp[cur] = ptr++;
  int cnt = 0, st = 1;
  ll ans = cur;
  n--;
  for (int i = 1; ; ++i) {
    if (n == 0) break;
    cur = (cur*cur) % m;
    if (mp[cur]) {
      st = mp[cur];
      break;
    }
    mp[cur] = ptr++;
    v.push_back(cur);
    n--;
    ans += cur;
  }
  int sz = 0;
  ll tot = 0;
  for (int i = st - 1; i < v.size(); ++i) {
    tot += v[i];
    sz++;
  }
  ans += 1LL*(n/sz)*tot;
  ll rem = n % sz;
  for (int i = 0; i < rem; ++i) ans += v[i + st - 1];
  cout << ans << '\n';
}

Measured memory_bytes: 6760
#include <bits/stdc++.h>
 
using namespace std;
 
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define priority_queue pq 
#define vso(x) sort( x.begin() , x.end() )
#define aso(x) sort( x , x + x.size() )
#define print(x) cout << x << endl 
#define no cout << "NO\n" 
#define yes cout << "YES\n"
typedef long long ll ; 
typedef long double ld ;
typedef pair<ll, ll> pairs ;

// B3

ll a[100009] , b[100009] , c[100009] ;
ll dp_a[100009] , dp_b[100009] , dp_c[100009] ;

int main()
{
    //freopen("problem_name.out", "w", stdout) ;
    //freopen("problem_name.in", "r", stdin) ;
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
 
    //int t ; cin >> t ; while(t--){}
    ll n ; cin >> n ;
    for ( int i = 1 ; i <= n ; i++ )
    {
        cin >> a[i] >> b[i] >> c[i] ;
        dp_a[i+1] += a[i] + max( dp_b[i] , dp_c[i] ) ;
        dp_b[i+1] += b[i] + max( dp_c[i] , dp_a[i] ) ;
        dp_c[i+1] += c[i] + max( dp_a[i] , dp_b[i] ) ;
        //cout << dp_a[i+1] << " " << dp_b[i+1] << " " << dp_c[i+1] << "\n" ;
    }
    print( max( dp_a[n+1] , max( dp_b[n+1] , dp_c[n+1] ) ) ) ;
}


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


Measured memory_bytes: 2104
#from bisect import bisect_left

def main():
    X, N = tuple(int(c) for c in input().split(' '))
    if N==0:
        print(X)
        exit()
    p = set(int(c) for c in input().split(' '))
    q = [x for x in range(-2,102) if not x in p]
    q.sort()
    #print(q)

    minimum = 1000
    for x in q:
        d = abs(x-X)
        d2 = abs(minimum-X)
        if d < d2:
            minimum = x
    print(minimum)

    #index = bisect_left(p, X)
    #if 


if __name__ == "__main__":
    main()

Measured memory_bytes: 9208
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<iomanip>
#define rip(i,n) for(int i=0;i<n;i++)
#define ll long long
#define lb long double
#define vec vector<int>
#define set setprecision
#define mod 1000000007
#include<numeric>
using namespace std;
int gcd(int a, int b)
{
	if (a % b == 0)	return(b);
	else return(gcd(b, a % b));
}
int lcm(int a, int b)
{return a * b / gcd(a, b);
}
ll pow(ll a, ll b) {
	ll k = b % 30000;
	ll h = b / 30000;
	ll s = 1;
	rip(i, 30000)s = (s * a) % mod;
	ll j = 1;
	if (h != 0)rip(i,h)j = j * s % mod;
	if (k != 0)rip(i, k)j = j * a % mod;
	return(j);
}
int oira(int n) {
	if (n == 0) return 0;
	int ans = n;
	for (int i = 2; i * i <= n; i++) {
		if (n % i == 0) {
			ans -= ans / i;
			while (n % i == 0) n /= i;
		}
	}
	if (n > 1) ans -= ans / n;
	return ans;
}
int main() {
	int n;
	cin >> n;
	cout << oira(n)  << endl;
}


Measured memory_bytes: 3120
N,K = map(int,input().split())
def prime_factor(n):
    ass = []
    for i in range(2,int(n**0.5)+1):
        while n % i==0:
            ass.append(i)
            n = n//i
    if n != 1:
        ass.append(n)
    return ass
L = prime_factor(K)
L.append(0)
ans = 1
cur = L[0]
cnt = 0
for i in range(len(L)):
  if L[i] == cur:
    cnt += 1
  else:
    if cnt >= N:
      ans *= cur**(cnt//N)
    cnt = 1
    cur = L[i]
print(ans)

Measured memory_bytes: 3188
using System;
using System.Linq;

namespace id_1616cs
{
    public class Shopping
    {
        int[] _vs;
        public Shopping(int[] vs)
        {
            _vs = vs; 
        }
        public string MaxVal(int upperLimit)
        {
            int result = -1;

            for(int i = 0; i < _vs.Length-1; i++)
            {
                for(int j = i + 1; j < _vs.Length; j++)
                {
                    int tmp = _vs[i] + _vs[j];
                    if (tmp <= upperLimit)
                    {
                        result = Math.Max(result, tmp);
                    }
                }
            }

            return result == -1 ? "NONE" : result.ToString();
        }

    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                var vs = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                if(vs[0]==0 && vs[1] == 0) { return; }
                var items = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
                var shopping = new Shopping(items);
                Console.WriteLine(shopping.MaxVal(vs[1]));
            }
        }
    }
}



Measured memory_bytes: 18464
import java.util.Scanner;
 
public class Main {
    static int MAX_COUNT= 100000000;
    public static void main(String[] args){
 
        boolean[] isPrimeNumber = createIsPrimeNumber();
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int count = 0;
        for(int i = 0; i <N; i++){
            int temp= sc.nextInt();
            if(isPrimeNumber[temp - 1]){
                count++;
            }
        }
        sc.close();
        System.out.println(count);
    }
     
    public static boolean[] createIsPrimeNumber(){
        boolean[] isPrimeNumber = new boolean[MAX_COUNT];
        for(int i = 0; i <MAX_COUNT; i++){
            isPrimeNumber[i] = true;
        }
        isPrimeNumber[0] = false;
        for(int i = 2; i < MAX_COUNT; i++){
            if(isPrimeNumber[i - 1]){
                int count = 2;
                while(true){
                    if((i * count - 1) >= MAX_COUNT ){
                        break;
                    }
                    isPrimeNumber[i * count - 1] = false;
                    count++;
                }
            }
        }
        return isPrimeNumber;
    }
}

Measured memory_bytes: 130080
from bisect import bisect_left
length = int(input())
target = []
for _ in range(length):
    target.append(int(input()))
lis = [target[0]]
for t in target[1:]:
    if t > lis[-1]:
        lis.append(t)
    else:
        lis[bisect_left(lis, t)] = t
print(len(lis))



Measured memory_bytes: 11132
#include<bits/stdc++.h>
#define For(a,b,c) for(register int a=b;a<=c;++a)
using namespace std;
typedef long long ll;
const int N=1e5+10;
int n,m;
vector<int>e[N];
priority_queue<int>q;
int main(){
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		int a,b,lim;
		scanf("%d%d",&a,&b);
		lim=m-a+1;
		if(lim<=0)continue;
		e[lim].push_back(b);
	}
	long long ans=0;
	for(int i=m;i>=1;i--){
		for(int j=0;j<e[i].size();j++)q.push(e[i][j]);
		if(!q.empty()){
			ans+=1ll*q.top();q.pop();
		}
	}
	cout<<ans;
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef long long ll;

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

    string s;
    cin >> s;

    ll reds = 0;
    ll ans = 0;


    REP(i, n){
        if (s[i] == 'R') reds++;
    }

    REP(i, reds){
        if (s[i] != 'R') ans++;
    }

    cout << ans << endl;
}


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

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int N; cin >> N; ll a[N];
    for(int i = 0; i < N; i++) cin >> a[i];
    ll tt = 0;
    for(int i = 0; i < N; i+=2){
        tt = (tt^a[i]^a[i+1]);
    }
    for(int i = 0; i < N; i++) cout << (tt^a[i]) << " ";
}


Measured memory_bytes: 5108
#include<bits/stdc++.h>
using namespace std;
long ans=0,cnt=0;
string s;
int main(){
	cin>>s;
	for(int i=0;i<s.length();i++){
		if(s[i]=='A'){
			cnt++;
		}else{
			if(s[i]=='B'&&s[i+1]=='C'){
				ans=ans+cnt;
			}else{
				if((s[i]=='B'&&s[i+1]!='C')||(s[i]=='C'&&s[i-1]!='B')){
					cnt=0;
				}
			}
		}
	}
	cout<<ans;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if(U == S){
    A--;
  }
  else{
    B--;
  }
  cout << A << " " << B << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main()
{
    string x;
    cin >> x;
    int j;
    string a[7] = { "SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT" };
    for (int i = 0; i < 7; i++)
    {
        if (x == a[i])
            j = i;
    }
    cout << 7 - j;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>

#define SIZE 1002
int FTable[SIZE][SIZE];
class TLcsSolver
{
    const char* FArray1;
    const char* FArray2;
    const int Fn1;
    const int Fn2;

    int Count(int i, int j)
    {
        if(i == 0 || j == 0) return 0;
        if(FArray1[i-1] == FArray2[j-1]){
            return FTable[i-1][j-1] + 1;
        }
        return std::max(FTable[i-1][j], FTable[i][j-1]);
    }
    void Solve()
    {
        for(std::size_t i = 1; i < Fn1; ++i){
            for(std::size_t j = 1; j < Fn2; ++j){
                FTable[i][j] = Count(i, j);
            }
        }
    }
    void Print()const
    {
        for(std::size_t i = 0; i < Fn1; ++i){
            for(std::size_t j = 0; j < Fn2; ++j){
                printf("%d\t", FTable[i][j]);
            }
            printf("\n");
        }
    } 
public:
    TLcsSolver(const char* a, const char* b)
     : FArray1(a), FArray2(b)
     , Fn1(std::strlen(a)), Fn2(std::strlen(b))
    {
        Solve();
        // Print();
    }
    int Answer()const
    {
        return FTable[Fn1-1][Fn2-1];
    }
};

int main()
{
    int n;
    std::scanf("%d\n", &n);
    char a[SIZE];
    char b[SIZE];
    for(int i = 0; i < n; ++i){
        std::fgets(a, SIZE, stdin);
        std::fgets(b, SIZE, stdin);
        std::printf("%d\n", TLcsSolver(a, b).Answer());
    }
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i < (int)(n); i++)
#define print(a) cout << (a) << endl; 
typedef long long ll;
const int MOD = 1000000007; 
 
int main() {
    int n, m;
    cin >> n >> m;
    string ans = "No";
    if (n == m) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n,k,s,b;
	cin>>n;
	cin>>k;
	unordered_set<int> a;
	for(int i=0;i<k;i++)
	{
		cin>>s;
		for(int j=0;j<s;j++){
			cin>>b;
			a.insert(b);
		}

	}int c=0;
	for(auto it:a)
	{
		c++;
	}
	cout<<n-c;
}


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

using namespace std;

#define all(x) begin(x), end(x)

using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

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

    int n;
    cin >> n;
    vector<double> p(n);
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
    }
    vector<vector<double>> dp(n + 1, vector<double>(n + 1, 0.0));
    dp[0][0] = 1.0;

    for (int i = 0; i < n; ++i) {
        for (int j = 0; j <= i; ++j) {
            dp[i + 1][j + 1] += dp[i][j] * p[i];
            dp[i + 1][j] += dp[i][j] * (1.0 - p[i]);
        }
    }

    double ans = 0.0;

    for (int j = (n + 1) >> 1; j <= n; ++j) {
        ans += dp[n][j];
    }

    cout << setprecision(10) << fixed << ans << '\n';
    
    return 0;
}


Measured memory_bytes: 70784
N,point,answer=list(map(int,input().split()))
W=[point]*N
for i in range(answer):
  U=int(input())
  W[U-1]+=1
W=[n-answer for n in W]
for k in range(N):
  if W[k]<=0:
    print("No")
  else:
    print("Yes")
  

Measured memory_bytes: 15620
while input=gets
	n,s=input.chomp.split(" ").map{|s| s.to_i}

	break if n==0 && s==0

	digs=(0..9).map{|k| k}
	count=0
	digs.combination(n) do |arr|
		if arr.inject{|a,b| a+b}==s then
			count+=1
		end
	end

	puts count
end


Measured memory_bytes: 6868
#[macro_use]
mod input {

use std;
use std::io;

const SPLIT_DELIMITER: char = ' ';

#[macro_export]
#[allow(unused_macros)]
macro_rules! input {
    ( $($x:expr ),*) => {
        {
            let temp_str = input_line_str();
            let mut split_result_iter = temp_str.split_whitespace();
                $(
                let buf_split_result = split_result_iter.next();
                let buf_split_result = buf_split_result.unwrap();
                    ($x) = buf_split_result.parse().unwrap();
                )*
        }
    };
}

#[allow(dead_code)]
pub fn input_line_str() -> String {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

#[allow(dead_code)]
pub fn p<T>(t: T)
where
    T: std::fmt::Display,
{
    println!("{}", t);
}

#[allow(dead_code)]
pub fn input_vector2d<T>(line: usize) -> Vec<Vec<T>>
where
    T: std::str::FromStr,
{
    let mut v: Vec<Vec<T>> = Vec::new();

    for _ in 0..line {
        let vec_line = input_vector();
        v.push(vec_line);
    }
    v
}

#[allow(dead_code)]
pub fn input_vector<T>() -> Vec<T>
where
    T: std::str::FromStr,
{
    let mut v: Vec<T> = Vec::new();

    let s = input_line_str();
    let split_result = s.split(SPLIT_DELIMITER);
    for z in split_result {
        let buf = match z.parse() {
            Ok(r) => r,
            Err(_) => panic!("Parse Error"),
        };
        v.push(buf);
    }
    v
}

#[allow(dead_code)]
pub fn str2vec(s: &str) -> Vec<char> {
    let mut v: Vec<char> = Vec::new();
    for c in s.chars() {
        v.push(c);
    }
    v
}
}

use input::*;
use std::collections::HashMap;

fn main() {
    let n: usize;
    input!(n);
    let mut map = HashMap::new();
    for _ in 0..n {
        let s = str2vec(&input_line_str());
        if !(s[0] == 'M' || s[0] == 'A' || s[0] == 'R' || s[0] == 'C' || s[0] == 'H') {
            continue;
        }
        let po = map.entry(s[0]).or_insert(0);
        *po += 1;
    }

    let mut ans = 0_usize;
    let mut v = vec![];
    for (_, x) in map {
        v.push(x);
    }

    for i in 0..v.len() {
        for j in i + 1..v.len() {
            for k in j + 1..v.len() {
                ans += v[i] * v[j] * v[k];
            }
        }
    }
    p(ans);
}

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

int main() {
    int i, k; k = 1;
    string s, pre, post;
    cin >> s; pre = s.at(0); post = "";

    for (i = 1; i < s.size(); i++) {
        post += s.at(i);
        if (pre != post) {
            k++;
            pre = post;
            post = "";
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 640
n = int(input())
mi = 10**15+1
def kiri(n):
  if n == int(n):
    return n
  else:
    return int(n)+1
for i in range(5):
  xi = int(input())
  if xi < mi:
    mi = xi
print(int(kiri(n/mi) + 4))

Measured memory_bytes: 3060
gets
nums = gets.chomp.split.map(&:to_i)

cum_sums = nums.inject([]) do |arr, n|
  arr << arr.last.to_i + n
end
sum = cum_sums[-1]
diffs = (0..(nums.size - 2)).map do |i|
  sunuke = cum_sums[i]
  araiguma = sum - sunuke
  (sunuke - araiguma).abs
end
puts diffs.min

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

int32_t main(){
    ios::sync_with_stdio(0),cin.tie(0);
    int n,k;
    cin >> n >> k;
    int a[n+1],pf[n+1]={0};
    for(int i=1;i<=n;i++)
    	cin >> a[i];
    for(int i=1;i<=n;i++){
    	pf[i]+=pf[i-1];
    	if(a[i]==0)pf[i]++;
    }
    for(int i=k+1;i<=n;i++){
    	if(a[i]>a[i-k] and pf[i]-pf[i-k+1]==0)
    		cout << "Yes\n";
    	else cout << "No\n";
    }
}


Measured memory_bytes: 6780
a = list(map(int, input().split()))
b = [list(map(int, input().split())) for i in range(a[0])]

max_index = a[0]
max_weight = a[1]

dp = [ [0] * (max_weight + 1) for j in range(max_index + 1)]

def solve():
    for i in range(max_index - 1, -1, -1):
        for j in range(max_weight + 1):
            if (j < b[i][0]):
                dp[i][j] = dp[i + 1][j]
            else:
                dp[i][j] = max([dp[i + 1][j], dp[i + 1][j - b[i][0]] + b[i][1]])
    print(dp[0][max_weight])

solve()

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

using namespace std;
#define month_max 10
#define day_s 19
#define day_l 20

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);

	int n;
	cin >> n;

	for(int i = 0; i < n; i++) {

		//誕生日を取得する
		int y, m, d, ans = 0;
		cin >> y >> m >> d;
		//端数から計算していく
		while(y < 1000) {
			//日の処理
			//来月頭まで進める
			if(d != -1) {

				if( ( y % 3 != 0 ) && ( m % 2 == 0 ) ) {
					ans += day_s - d + 1;
					ans ++;
					if( m == 10 ) ans --;
				} else { 
					ans += day_l - d + 1;
				}
				
				d = -1;
				m ++;
				if( m > 10 ) {
					y ++;
					m = 1;
				}

			} else {

				//月の処理
				//来年頭まで進める
				if( m != 1 ) {

					if( y % 3 != 0) {
						int restm = (month_max + 1 - m);	//残り月数
						int sm = (restm / 2 + 1);			//小の月の残り
						int lm = restm - sm;				//大の月の残り
						ans += ( sm * day_s + lm * day_l );
					} else {
						int restm = (month_max + 1 - m);
						ans += ( restm * day_l );
					}
					m = 1;
					y ++;

				} else {
					if( y % 3 != 0 ) {
						ans += (day_s + day_l) * (month_max / 2);
					} else {
						ans += day_l * month_max;
					}
					y ++;
				}

			}
		}

		cout << ans << endl;

	}
	

	//while(1){}
	return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#include <iostream>
#include <utility> // pair
#include <string>
#include <vector>
#define MAX_N 100001
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define REP(i, n) for(int i=0; i<n; i++)
#define RER(i, n) for(int i=n-1; i>=0; i--)
#define ALL(v) v.begin() v.end()
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
string s, t;

signed main(){
	cin >> s >> t;
	bool flag = false;
	REP(i, s.size()){
		if(s.substr(i) + s.substr(0, i) == t) flag = true;
	}
	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
    return 0;
}

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

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define test cout<<"test"<<endl;
#define fi first
#define se second
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = n; i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = m - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
void chmin(T &a,T b){if(a>b)a=b;}
template<typename T>
void chmax(T &a,T b){if(a<b)a=b;}
void pmod(ll &a,ll b){a=(a+b)%MOD;}
void pmod(ll &a,ll b,ll c){a=(b+c)%MOD;}
void qmod(ll &a,ll b){a=(a*b)%MOD;}
void qmod(ll &a,ll b,ll c){a=(b*c)%MOD;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout<<fixed<<setprecision(10);
  ll res=0,buf=0;
  bool judge = true;
  ll cnt=0;
  string s;cin>>s;
  rep(i,0,s.size()){
    if(s[i]=='C'&&cnt==0)cnt=1;
    if(s[i]=='F'&&cnt==1)cnt=2;
  }
  ans1(cnt==2);
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(X,N) for(ll X = 0; X < (N); X++)
#define PI (acos(-1.0))
#define pback push_back
#define mpair make_pair
#define MODN 1000000007
#define ALL(V) (V).begin(),(V).end()

typedef long long ll;

using namespace std;

int main(){

    int n;
    ll w;
    cin >> n >> w;

    vector<pair<ll, int>> goods;

    rep(i,n){
        ll weight;
        int value;
        cin >> weight >> value;

        goods.pback(mpair(weight, value)); 
    }

    int dp[n + 1][n + 1][n * 3 + 5] = {};

    rep(i,n){
        rep(j, n + 1){
            
            if(i < j) continue;
            rep(k, n * 3 + 1){

                //入れなかった場合
                dp[i + 1][j][k] = max(dp[i + 1][j][k], dp[i][j][k]);

                //入れた場合
                int dw = goods[i].first - goods[0].first;
                dp[i + 1][j + 1][k + dw] = max(dp[i + 1][j + 1][k + dw], dp[i][j][k] + goods[i].second);
            }
        }
    }

    int ans = 0;

    rep(i, n + 1){
        rep(j, n * 3 + 1){
            ll tmpw = i * goods[0].first + j;

            //cerr << tmpw << "," << dp[n][i][j] << " ";
            
            if(tmpw <= w){ 
                ans = max(ans, dp[n][i][j]);
            }
        }
        //cerr << endl;
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
	int N, L;
	cin >> N >> L;
	vector<string> S(N);
	for (int i = 0; i < N; i++) {
		cin >> S.at(i);
	}
	sort(S.begin(), S.end());
	for (int i = 0; i < N; i++) {
		cout << S.at(i);
	}
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}

int dp[101][4][4][4];

int main(){
  int n;
  cin >> n;
  
  dp[0][3][3][3] = 1;
  int mod = 1000000007;
  
  rep(len,n)rep(c1,4)rep(c2,4)rep(c3,4){
    if(dp[len][c1][c2][c3] == 0) continue;
    
    rep(a,4){
      if(a == 2 && c1 == 1 && c2 == 0) continue;
      if(a == 2 && c1 == 0 && c2 == 1) continue;
      if(a == 1 && c1 == 2 && c2 == 0) continue;
      if(a == 2 && c1 == 1 && c3 == 0) continue;
      if(a == 2 && c2 == 1 && c3 == 0) continue;
      
      dp[len + 1][a][c1][c2] += dp[len][c1][c2][c3];
      dp[len + 1][a][c1][c2] %= mod;
    }
  }
  
  int ans = 0;
  rep(c1,4)rep(c2,4)rep(c3,4){
    ans += dp[n][c1][c2][c3];
    ans %= mod;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define st first
#define nd second

using namespace std;

void debug_out() { cerr << endl; }
template<class T> ostream& prnt(ostream& out, T v) { out << v.size() << '\n'; for(auto e : v) out << e << ' '; return out;}
template<class T> ostream& operator<<(ostream& out, vector <T> v) { return prnt(out, v); }
template<class T> ostream& operator<<(ostream& out, set <T> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, map <T1, T2> v) { return prnt(out, v); }
template<class T1, class T2> ostream& operator<<(ostream& out, pair<T1, T2> p) { return out << '(' << p.st << ' ' << p.nd << ')'; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) { cerr << " " << H; debug_out(T...);}

#define dbg(...) cerr << #__VA_ARGS__ << " ->", debug_out(__VA_ARGS__)
#define dbg_v(x, n) do{cerr<<#x"[]: ";for(int _=0;_<n;++_)cerr<<x[_]<<" ";cerr<<'\n';}while(0)
#define dbg_ok cerr<<"OK!\n"
#define y1 y215
// const int N = ;
int n, r, c, x1, y1, x2, y2;

vector <pair<int, int> > v;
stack <int> s;

bool marg(int x, int y) {
	if((x == 0 || x == r) || (y == 0 || y == c)) return 1;
	return 0;
}

int val(int x, int y) {
	if(x == 0) return y;
	if(y == c) return c + x;
	if(x == r) return r + c + (c - y);
	if(y == 0) return r + c + c + (r - x);
}

int main() {
	ios_base::sync_with_stdio(false);

	cin >> r >> c;
	cin >> n;

	for(int i = 1; i <= n; i++) {
		cin >> x1 >> y1;
		cin >> x2 >> y2;
		if(marg(x1, y1) && marg(x2, y2)) {
			v.push_back({val(x1, y1), i});
			v.push_back({val(x2, y2), i});
		}
	}

	sort(v.begin(), v.end());
	// dbg(v);
	for(auto i : v) {
		if(s.empty() || s.top() != i.nd) s.push(i.nd);
		else s.pop();
	}
	cout << (s.empty() ? "YES\n" : "NO\n");
}	

	

Measured memory_bytes: 2420
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#define INF INT_MAX
using namespace std;

int N;
int ans;

int main(){
	cin >> N;
	ans = N;
	while (1){
		if (ans % 111 == 0)break;
		ans++;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007

#A
def A():
    a, b, c = LI()
    if a + b >= c:
        print("Yes")
    else:
        print("No")
    return

#B
def B():
    n = II()
    s = SR(n)
    m = II()
    t = SR(m)
    ans = 0
    for si in s:
        ans = max(ans, s.count(si) - t.count(si))
    print(ans)
    return

#C
def C():
    n = II()
    ab = LIR(n)
    cd = LIR(n)
    ab.sort()
    cd.sort()
    check = [0 for i in range(n)]
    ans = 0
    for _, c in enumerate(cd):
        d = c[1]
        c = c[0]
        maxy = -1
        x = -1
        for k, a in enumerate(ab):
            b = a[1]
            a = a[0]
            if maxy < b and c > a and check[k] == 0 and d > b:
                maxy = b
                x = k
        if x != -1:
            ans += 1
            check[x] += 1
    print(ans)


    return

#D
def D():
    N = II()
    a = LI()
    b = LI()
    ans = 0
    t = 1
    for i in range(29):
        a2 = [A & ((t << 1) - 1) for A in a]
        b2 = [B & ((t << 1) - 1) for B in b]
        a2.sort(reverse=True)
        b2.sort()
        ansb = r1 = r2 = r3 = 0
        for A in a2:
            while r1 < N and A + b2[r1] < t:
                r1 += 1
            while r2 < N and A + b2[r2] < 2*t:
                r2 += 1
            while r3 < N and A + b2[r3] < 3*t:
                r3 += 1
            ansb += r2 ^ r1 ^ N ^ r3
            ansb = ansb & 1
        ans += (ansb << i)
        t = t << 1
    print(ans)
    return

#Solve
if __name__ == '__main__':
    D()


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

using namespace std;

int main(int argc, char * argv[])
{
	string s;
	unsigned int k = 0;

	cin >> s >> k;

	unsigned int n = 0;
	for (unsigned int i = 0; i < s.size(); ++i) {
		if (s[i] != 'a') {
			n = 26 - (s[i] - 'a');
			if (k >= n) {
				s[i] = 'a';
				k = k - n;
			}
		}
	}
	if (k > 0) {
		k = (k + (s[s.size() - 1] - 'a')) % 26;
		s[s.size() - 1] = 'a' + k;
	}
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

using namespace std;
typedef long long int ll;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); i++)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep,)(__VA_ARGS__)
#define all(x) (x).begin(), (x).end()

#define inf 10000000000

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

    ll N, M, X, Y;
    cin >> N >> M >> X >> Y;
    ll x[N], y[M];
    rep(i, N){
        cin >> x[i];
    }
    rep(i, M){
        cin >> y[i];
    }

    rep(Z, X + 1, Y + 1){
        bool flag = true;
        rep(i, N){
            if(x[i] >= Z){
                flag = false;
                break;
            }
        }
        rep(i, M){
            if(y[i] < Z){
                flag = false;
                break;
            }
        }
        if(flag){
            cout << "No War" << endl;
            return 0;
        }
    }
    cout << "War" << endl;
}


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

using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count());

int n, a[100000][3], dp[100000][3];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> n;
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++) cin >> a[i][j];
	for(int i = 0; i < 3; i++) dp[0][i] = a[0][i];
	for(int i = 0; i < n; i++)
		for(int j = 0; j < 3; j++)
			for(int k = 0; k < 3; k++)
				if(j != k) dp[i + 1][k] = max(dp[i + 1][k], dp[i][j] + a[i + 1][k]);
	cout << max(dp[n - 1][0], max(dp[n - 1][1], dp[n - 1][2])) << "\n";
	return 0;
}

Measured memory_bytes: 2560
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <vector>
#include <set>
#include <bitset>
#include <queue>
#include <stack>
#include <deque>
#include <climits>
#include <cstring>
#include <sstream>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<vii> vvii;

#define fastIO ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
#define forw(i,l,r) for(int i=(l);i<(r);i++)
#define forb(i,r,l) for(int i=(r);i>(l);i--)
#define sqr(x) (x)*(x)
#define log2i(x) 32 - __builtin_clz((x)) - 1
#define log2l(x) 64 - __builtin_clzll((x)) - 1
#define inf1 int(1e9+7)
#define inf2 0x3f3f3f3f
#define infll ll(1e18+7)
#define Pi acos(-1.0)
#define mu(x,y) trunc(exp(log((x))*(y)))
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define all(x) x.begin(), x.end()

const int N = 1e5+7;
int n;
int dp[N]={0}, h[N]={-inf1};

int main() {
    fastIO;
    //freopen("test.inp","r",stdin);
    //freopen(".out","w",stdout);

    cin >> n;
    forw(i,1,n+1) {
        cin >> h[i];
        if(i==1) dp[i]=0;
        else dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]));
    }
    cout << dp[n];
    return 0;
}


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

using namespace std;
#define ll long long 
int main() {
int n;
cin>>n;
double arr[n];
double fac=1;
for(int i=1;i<=n;i++)
{
    arr[i]=i;
 fac*=i;   
}
map<int,pair<double,double>>m;
for(int i=0;i<n;i++)
{
    double a,b;
    cin>>a>>b;
    m[i+1]=make_pair(a,b);
}
double sum=0;
do{
    for(int i=1;i<n;i++)
    {
        sum+=sqrt(pow(m[arr[i]].second-m[arr[i+1]].second,2)+pow(m[arr[i]].first-m[arr[i+1]].first,2));
    }
    
 
}
while(next_permutation(arr+1,arr+n+1));
   printf("%.10f\n",sum/fac);
    return 0;
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define ll long long
#define LL long long
#define MOD 1000000007
#define INF 2000000000
int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
ll N, M, K,H,W,L,R,l,r,mi1,mi2,sum,Q;
LL ans;
LL no;
bool b,bb[100001];
string s,t;

int main() {
	cin >> H>>W;
	cin >> N;
	vector<LL> a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	LL c[101][101];
	LL now = 1;
	sum = 0;
	for (int i = 0; i < H; i++) {
		if (i % 2 == 0) {
			for (int j = 0; j < W; j++) {
				c[i][j]=now;
				sum++;
				if (sum == a[now - 1]) {
					now++;
					sum = 0;
				}
			}
		}
		else {
			for (int j = W-1; j >= 0; j--) {
				c[i][j] = now;
				sum++;
				if (sum == a[now - 1]) {
					now++;
					sum = 0;
				}
			}
		}
	}
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cout << c[i][j]<<" ";
		}
		cout << endl;
	}
	return 0;
}



Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef long double ld;
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"ABC":"ARC")
//ll s,w;
//ld ;
string s, t;
// char c;

int main() {
  cin >> s >> t;
  bool check = true;
  for(ll i=0; i<s.length(); i++){
    if(s[i] != t[i]) check = false;
  }
  yorn(check);
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned long long
#define F first
#define S second
#define STP(x) setprecision(x)
#define watch(x) cout << (#x) << " is " << (x) << "   =="
#define Yala_Besor3a ios_base::sync_with_stdio(0),ios::sync_with_stdio(0),cin.tie(0),cout.tie(0)

using namespace std;

const int OO = 0x3f3f3f3f, NegOO = -1 * OO, N = 2e5 + 5, M = 1e7 + 5, mod = 1e9 + 7;
ll freq[M];
void findDivs()
{
    fill(freq,freq+M,2);
    freq[1]=1;
    for (int i = 2; i<=M/2 ; ++i) {
        for (int j = 2; j *i <=M ; ++j) {
            freq[i*j]++;
        }
    }
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif
    Yala_Besor3a;
    findDivs();
    ll sum=0;
    int n;
    cin>>n;
    for (ll i = 1; i <=n ; ++i) {
        sum+=(freq[i]*i);
    }
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 81740
#include <iostream>
#include <string>
//#include <cstring>

using namespace std;

int main()
{
    int k;
    string s;

    cin >> k;
    cin >> s;

    if ((int)s.length() <= k) {
        cout << s << endl;
    }
    else {
        for (int i = 0; i < k; i++) {
            cout << s[i];
        }
        cout << "..." << endl;
    }

    return 0;
}

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

int main() {
    char s1[1001];
    char s2[1001];
    int i, j, k;

    scanf("%s", s1);
    scanf("%s", s2);

    for (i = 0; strlen(s2) <= strlen(&s1[i]); i++) {
        for ( j = 0; j < strlen(s2); j++) {
            if(s2[j] == s1[i+j]) continue;
            else break;
        }
        if(j == strlen(s2)) printf("%d\n", i);
    }

    return 0;
}

Measured memory_bytes: 548
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < (n); i++)

using namespace std;

void solve() {
  long n, m, d;
  cin >> n >> m >> d;
  double ans = 0;
  for (long i = 1; i < m; i++) {
    double tmp = 0;
    tmp = (n - d);
    if (d != 0) tmp *= 2;
    tmp /= n * n;
    ans += tmp;
  }
  cout << ans << endl;
}

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


Measured memory_bytes: 256
#include <cstdio>

char S[101010];

int main()
{
	scanf("%s", S);

	bool app[26];
	for (int i = 0; i < 26; ++i) {
		app[i] = false;
	}
	for (int i = 0; S[i] != '\0'; ++i) {
		app[S[i] - 'a'] = true;
	}
	for (int i = 0; i < 26; ++i) {
		if (!app[i]) {
			printf("%c\n", (char)(i + 'a'));
			return 0;
		}
	}
	puts("None");
	return 0;
}


Measured memory_bytes: 1824
using System;
    using System.Linq;
    using System.Collections.Generic;
    using static System.Math;


    public class Program
    {
        public static void Main(string[] args)
        {
            List<long> number = Console.ReadLine().Split(' ').Select(long.Parse).ToList();
            long x = number[0];
            long y = number[1];
            long answer = 1;
            
            while(x * 2 <= y)
            {
                x = x * 2;
                answer++;
            }

            Console.WriteLine(answer);
        }
    }

Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1e9+7LL;

int main() {
    ll N; cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A.at(i);
    
    ll Q; cin >> Q;
    vector<ll> B(Q);
    vector<ll> C(Q);
    rep(i, Q){
        cin >> B.at(i);
        cin >> C.at(i);
    }
    ll sum = 0;
    map<ll, ll> m;

    sort(ALL(A));
    rep(i, N){
        sum += A.at(i);
        m[A.at(i)]++;
    }
    
    rep(i, Q){
        sum += m[B.at(i)]*(C.at(i) - B.at(i));
        m[C.at(i)] += m[B.at(i)];
        m[B.at(i)] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 11412
#include<stdio.h>
#include<string.h>
#define maxn 1000000007
int main()
{
    long long a,n,sum;
    while(scanf("%lld",&n)!=EOF)
    {
        sum=1;
        for(a=1;a<=n;a++)
        {
            sum*=a;
            sum%=maxn;
        }
        printf("%lld\n",sum);
    }
    return 0;
}


Measured memory_bytes: 128
n = int(input())
s = input()

mod = 10**9 + 7

fib = [1]
for i in range(1, n+1):
    f = fib[i-1] * i % mod
    fib.append(f)

memo = [i%2 for i in range(2*n)]
for i, si in enumerate(s):
    if si == "B":
        memo[i] += 1
        memo[i] %= 2

ans = 1
count = 0
for i in range(2*n):
    if memo[i] == 1:
        count += 1
    else:
        ans *= count
        ans %= mod
        count -= 1
if count != 0:
    print(0)
else:
    print(ans * fib[n] % mod)



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

using namespace std;

int n, x; long long sum[200002], v[200002], minn;

int main()
{
  minn = LLONG_MAX;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> v[i];
    v[i] -= i;
    sum[i] = sum[i - 1] + v[i];
  }
  sort (v + 1, v + n + 1);
  for (int i = 1; i <= n; i++)
    sum[i] = sum[i - 1] + v[i];
  for (int i = 0; i < n; i++) {
    long long b = v[i + 1];
    long long val = (sum[n] - sum[i]) - sum[i] - b  * (n - i - i);
    if (minn > val)
      minn = val;
  }
  cout << minn;
  return 0;
}


Measured memory_bytes: 3328
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.*;

public class Main {

	public static void main(String args[]) throws IOException{
		Scanner sc = new Scanner(System.in);
		
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//StringTokenizer st = new StringTokenizer(br.readLine());
		
		//StringBuilder sb = new StringBuilder();
		
		char s[] = sc.next().toCharArray();
		
		int k = sc.nextInt();
		
		int dp[][][] = new int[s.length][s.length][k+1];
		
		for(int i=0;i<=k;i++){
			for(int r=0;r<s.length;r++){
				for(int l=r;l>=0;l--){
					if(l==r){
						dp[l][r][i] = 1;
						continue;
					}
					
					if(r==l+1){
						dp[l][r][i] = s[l] == s[r] || i>0 ? 2 : 1;
						continue;
					}
					
					if(s[l] == s[r]){
						dp[l][r][i] = dp[l+1][r-1][i]+2;
					}
					else{
						dp[l][r][i] = Math.max(dp[l+1][r][i], dp[l][r-1][i]);
					}
					
					if(i>0){
						dp[l][r][i] = Math.max(dp[l][r][i], dp[l+1][r-1][i-1]+2);
					}
				}
			}
		}
		
		System.out.println(dp[0][s.length-1][k]);
	}
}

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

// ?????¬???????????¬??????
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// ???
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// ?????°
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int data[10];
    data[0] = 1;
    REP(i,1,10) data[i] = data[i-1] * 2;
        int n;
    while(cin>>n) {

        bool check[10];
        rep(i, 10) check[i] = false;
        for(int i=9; i>=0; --i) {
            if(n>=data[i]) {
                n -= data[i];
                check[i] = true;
            }
        }

        bool check2 = false;
        rep(i, 10) {
            if(check[i]) {
                if(check2) cout << " ";
                else check2 = true;
                cout << data[i];
            }
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3000