akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        n: usize,
        mut d: f64,
        mut x: f64
    }
    let mut ans = 0.0;
    for i in 0..n {
        ans += d + ((n - i) as f64 - 0.5) * x;
        d = (1.0 + 1.0 / (n - i) as f64) * d + 5.0 * x / 2.0 / (n - i) as f64;
        x *= 1.0 + 2.0 / (n - i) as f64;
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const long long INF = 1LL << 60;

ll dp[55][3000][55];

int main(){
    int N, A;
    cin >> N >> A;
    vector<int> X(N);
    for(int i=0; i<N; i++) cin >> X[i];

    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for(int i=0; i<N; i++) {
        for(int s=0; s<=N*A; s++) {
            for(int k=0; k<=N; k++) {
                if(dp[i][s][k] == 0) continue;
                dp[i+1][s][k] += dp[i][s][k];
                dp[i+1][s+X[i]][k+1] += dp[i][s][k];
            }
        }
    }

    ll ans = 0;
    for(int k=1; k<=N; k++) ans += dp[N][k*A][k];
    cout << ans << endl;
}

Measured memory_bytes: 74508
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n) ; ++i)
#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define emb emblace_back

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

template<typename T>
void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << v << ",";
  }
  cout << "]" << endl;
}

int main() {
  ll n,k;
  cin >> n >> k;
  ll t=k;
  int m=1;
  while(t <= n) {
    t *= k;
    m++;
  }
  cout << m << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
import java.util.List;
import java.util.ArrayList;

public class Main{
  static int get_maxindex(int[] array){
    int max =0;
    int max_i=0;
    int i=0;
    for(int a : array){
      if(a>max){
        max = a;
        max_i = i;
      }
      i+=1;
    }
    return max_i;
  }

  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] flowers = new int[n];
    for(int i=0; i<n; i++){
      flowers[i] = sc.nextInt();
    }
    int max_index = get_maxindex(flowers);
    int count =0;
    while(flowers[max_index]!=0){
    int j=0;
     while(j<n){
      if(flowers[j]==0){j++;}
      else{
        count+=1;
        while(j<n&&flowers[j]!=0){
          flowers[j] = flowers[j] -1;
          j+=1;
        }
      }
     }
    }
    System.out.println(count);


  }
}

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

int main() {
  int N, M;
  cin >> N >> M;

  vector<bool> red(N, 0);
  red.at(0) = 1;
  vector<int> ball(N, 1);

  for (int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    ball.at(x)--;
    ball.at(y)++;
    if (red.at(x)) red.at(y) = 1;
    if (!ball.at(x)) red.at(x) = 0;
  }

  int ans = 0;
  for (int i = 0; i < N; i++) {
    if (red.at(i) && ball.at(i) > 0) ans++;
  }
  cout << ans << endl;
}


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

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

  cout << (X - A) % B << endl;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define repd(i, a, b) for (int i = a; i >= (b); --i)
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)(x).size()
typedef long long ll;
const int INF = 0x3f3f3f3f;
const ll LINF = 0x3f3f3f3f3f3f3f3fll;

int main()
{
    string s;
    cin >> s;
    int sum = 0;
    rep(i, 0, (int)s.length()) sum += (s[i] - '0');
    if (sum % 9 == 0)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}


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

#define pb push_back
#define PQ priority_queue
#define make_unique(x) sort((x).begin(), (x).end()); (x).erase(unique((x).begin(), (x).end()), (x).end())

typedef long long ll;
typedef long double ld;

//__builtin_popcount(x)

using namespace std;

/*const int mod = 1e9 + 7;

ll add(ll a, ll b) {
    ll res = a + b;
    if (res >= mod) res -= mod;
    return res;
}

ll sub(ll a, ll b) {
    ll res = a - b + mod;
    if (res >= mod) res -= mod;
    return res;
}

ll mul(ll a, ll b) {
    return (((a % mod) * (b % mod)) % mod);
}

int powm(int a, long long n) {
	if (n == 0) {
		return 1;
	}
	else if (n & 1) {
		return mul(a, powm(a, n - 1));
	}
	else {
		return powm(mul(a, a), n / 2);
	}
}*/

/* Z-FUNCTION
ll l = 0, r = 0, n = (int)s.size();
vector<int> z(n, 0);
for (int i = 1; i < n; i++) {
    if (r >= i) {
        z[i] = min(1ll*z[i-l], r-i+1);
    }
    while (z[i] + i < n && s[z[i]] == s[z[i] + i]) z[i]++;
    if (i + z[i] - 1 > r) l = i, r = i + z[i] - 1;
}
*/

/*vector<ll> find_dividers(ll x) {
    vector<ll> dividers;

    for (ll i = 1; i <= sqrt(x); i++) {
        if (x % i == 0) {
           dividers.push_back(i);
            if (1ll*i * i != x) {
                dividers.push_back(1ll*x / 1ll*i);
            }
        }
    }

    return dividers;
}*/

/*int nok(int a, int b) {
    return a / __gcd(a, b) * b;
}*/

// ceil(a/b) = (a+b-1)/b

void solve() {
    int n;
    cin >> n;
    ll total = 0;
    for (int a = 1; a < n; a++) {
        total += (n - 1)/a;
    }
    cout << total << endl;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //cout.setf(ios::fixed);
    //cout.precision(10);

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

    return 0;
}


Measured memory_bytes: 3596
#include <iostream>

using namespace std;

int cl[1000000];
int op[1000000];
int ix[1000000];

bool change(int l, int r)
{
    l = ix[l];
    r = ix[r];
    if (op[r] == 0 && op[l] > 0)
    {
        return true;
    }

    if (op[l] == 0 && op[r] > 0)
    {
        return false;
    }

    if (cl[l] == 0 && cl[r] > 0)
    {
        return true;
    }

    if (cl[r] == 0 && cl[l] > 0)
    {
        return false;
    }

    if (cl[r]-op[r] > cl[l]-op[l])
    {
        return true;
    }

    return false;
}

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

    for (int i = 0; i < n; ++i)
    {
        char ch;
        int cop = 0;
        int toop = 0;
        ix[i] = i;
        while((ch = getchar())!= '\n')
        {
            if (ch == ')' && cop > 0)
            {
                cop--;
            }
            else if (ch == ')')
            {
                toop++;
            }
            else if (ch == '(')
            {
                cop++;
            }
        }
        op[i] = toop;
        cl[i] = cop;
    }

    for (int gap = n/2; gap > 0; gap /= 2)
    {
        for (int i = gap; i < n; ++i)
        {
            for (int j = i - gap; j >= 0 && change(j, j+gap); j -= gap)
            {
                swap(ix[j], ix[j+gap]);
            }
        }
    }

    int cop = 0;
    bool yes = true;
    for (int i = 0; i < n; ++i)
    {
        if (op[ix[i]] > cop)
        {
           yes = false;
           break;
        }
        cop -= op[ix[i]];
        cop += cl[ix[i]];
    }

    if (cop != 0)
    {
        yes = false;
    }

    if (yes)
    {
        cout << "Yes\n";
    }
    else
    {
        cout << "No\n";
    }
    return 0;
}


Measured memory_bytes: 15112
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <random>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
int Map[300][300];
void Calc(){
	int H = rei();
	int W = rei();
	int K = rei();
	int c = 1;
	for(int i=0;i<H;i++){
		string S = res();
		for(int j=0;j<W;j++){
			if(S[j] == '#'){
				Map[i][j] = c;
				c++;
			}
		}
	}
	for(int i=0;i<H-1;i++){
		for(int j=0;j<W;j++){
			if(Map[i+1][j] == 0){
				Map[i+1][j] = Map[i][j];
			}
		}
	}
	for(int i=H-1;i>0;i--){
		for(int j=0;j<W;j++){
			if(Map[i-1][j] == 0){
				Map[i-1][j] = Map[i][j];
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W-1;j++){
			if(Map[i][j+1] == 0){
				Map[i][j+1] = Map[i][j];
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=W-1;j>0;j--){
			if(Map[i][j-1] == 0){
				Map[i][j-1] = Map[i][j];
			}
		}
	}
	for(int i=0;i<H;i++){
		for(int j=0;j<W;j++){
			cout << Map[i][j];
			if(j == W-1){
				cout << "\n";
			}
			else{
				cout << " ";
			}
		}
	}
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 1152
use std::io::prelude::*;

fn mod_add(x: u64, y: u64) -> u64 {
    (x + y) % (1_000_000_007)
}

fn main() {
    let mut input_str = String::new();
    std::io::stdin().read_to_string(&mut input_str).unwrap();

    let input_parts = input_str.split_whitespace().collect::<Vec<_>>();
    let mut input_parts_it = input_parts.iter().cloned();

    let s: Vec<char> = input_parts_it.next().unwrap().chars().rev().collect();

    let mut perms = vec![0u64; 13];
    perms[0] = 1;

    let mut factor = 1;

    for &digit in s.iter() {
        if digit == '?' {
            let mut perms2 = vec![0u64; 13];
            for val in 0..10 {
                let shift = (val * factor) % 13;
                for rem in 0..13 {
                    perms2[rem] = mod_add(perms2[rem], perms[(rem + 13 - shift) % 13]);
                }
            }
            perms = perms2;
        } else {
            let val = digit as usize - '0' as usize;
            let shift = (val * factor) % 13;
            perms = (0..13).map(|rem| perms[(rem + 13 - shift) % 13]).collect();
        }

        factor = (factor * 10) % 13;
    }

    println!("{}", perms[5]);
}


Measured memory_bytes: 4352
#include <iostream>
#include <stdio.h>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926
#define pb(x) push_back(x)
#define mkpr(x,y) make_pair(x,y)
#define all(x) x.begin(),x.end()

typedef long long int ll;

ll general,total;
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<ll> pqll;   //decrease
//priority_queue<double> pqd;
//stack<int> stk;
//vector<pair<ll,ll>> vpll;
//vector<pair<double,double>> vpdd;
//vector<ll> vll[ten52];
//vector<double> vd;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//set<char> sch;
set<string> sStr;
//map<ll,ll> mp;

ll numR[4000],numG[4000],numB[4000];

/*ll cmp(pair<ll,ll> a,pair<ll,ll> b)
{
    return a.first<b.first;
    //arrising
}*/


int main()
{
    long long int sum,sum2;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    string s;
    sum=sum2=0;
    a=a1=a2=a3=a4=a5=a6=0;
    cin>>n>>m;
    for(i=m;i<=n;i++)
    {
        a1=i*(i-1)/2;
        a2=i*n-a1;
        sum+=a2-a1+1;
    }
    cout<<sum % mod +1;
    // +1 for choose all
    return 0;
}





Measured memory_bytes: 3572
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

class BIT:
    """
    a[1]~a[n]の数列を想定
    """

    def __init__(self,n):
        self.size = n
        self.tree = [0]*(n+1)
 
    def add(self,index,x):
        """
        a[index]にxを加算
        """
        while index <= self.size:
            self.tree[index] += x
            index += index & (-index)
 
    def sum(self,index):
        """
        a[1]~a[index]の和
        """
        s = 0
        while index:
            s += self.tree[index]
            index -= index & (-index)
        return s
 
    def search(self,value):
        """
        sum(index) >= value を満たす最小のindex
        sum(n) < value のとき n+1 を返す
        """
        i = 0
        s = 0
        step = 1 << (self.size.bit_length() - 1)
        while step:
            if i+step <= self.size and s + self.tree[i+step] < value:
                i += step
                s += self.tree[i]
            step >>= 1
        return i + 1

N = I()
A = LI()

sumA = sum(A)

bit = BIT(N)
for i in range(N):
    bit.add(i+1,A[i])

ans = float('inf')

# 2本目の区切りを i/i+1 の境目とする
# 左右2つの区間は，それぞれ差が最小になるように区切ると最適
for i in range(1,N-2):
    l_sum = bit.sum(i+1)
    r_sum = sumA-l_sum
    p = bit.search(l_sum+r_sum/2)
    if p == i+2:
        r_max = bit.sum(p)-bit.sum(i+1)
        r_min = r_sum-r_max
    elif p == N:
        r_min = bit.sum(p-1)-bit.sum(i+1)
        r_max = r_sum-r_min
    else:
        max1 = bit.sum(p)-bit.sum(i+1)
        min1 = r_sum-max1
        max2 = min1+A[p-1]
        min2 = max1-A[p-1]
        if max1-min1 < max2-min2:
            r_max = max1
            r_min = min1
        else:
            r_max = max2
            r_min = min2

    p = bit.search(l_sum/2)
    if p == 1:
        l_max = bit.sum(p)
        l_min = l_sum-l_max
    elif p == i+1:
        l_min = bit.sum(p-1)
        l_max = l_sum-l_min
    else:
        max1 = bit.sum(p)
        min1 = l_sum-max1
        max2 = min1+A[p-1]
        min2 = max1-A[p-1]
        if max1-min1 < max2-min2:
            l_max = max1
            l_min = min1
        else:
            l_max = max2
            l_min = min2

    now = max(l_max,r_max) - min(l_min,r_min)
    if now < ans:
        ans = now

print(ans)

Measured memory_bytes: 88796
def main():
    h,w = map(int,input().split())
    ls = [list(input()) for _ in range(h)]
    cnt = 0
    for i in range(h):
        cnt += ls[i].count("#")
    
    if cnt == h+w-1:
        print("Possible")
    else:
        print("Impossible")
    
if __name__ == '__main__':
    main()

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

int A[100], N;

int selectionSort();
void trace();

int main() {
  cin >> N;
  for (int i = 0; i < N; ++i) { cin >> A[i]; }
  
  int count = selectionSort();
  trace();
  cout << count << "\n";
  
  return 0;
}

// sort
int selectionSort() {
  int count = 0;
  for (int i = 0; i < N; ++i) {
    int minv = i;
    for (int j = i + 1; j < N; ++j) {
      if (A[minv] > A[j]){
        minv = j;
      }
    }
    if (minv != i) {
      swap(A[minv], A[i]);
      count++;
    }
  }
  return count;
}

// print
void trace() {
  for (int i = 0; i < N; ++i) {
    if (i) { cout << " "; }
    cout << A[i];
  }
  cout << "\n";
}

Measured memory_bytes: 1164
#include<iostream>
#include<vector>
#include<algorithm>
#include<utility>

#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MAX 1000000007

using namespace std;

int main() {
	int a, b, c;
	char s[10];

	cin >> a >> b ;


		cout << (a * 3 + b) / 2;

}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))



int main(){
    ll ans,A,B;
    cin >>A>>B;
    A=(A+11)%13;
    B=(B+11)%13;

    {
        if(A>B)cout <<"Alice"<<endl;
        else  if (A<B)cout <<"Bob"<<endl;
        else cout <<"Draw"<<endl;
    }

    dbg cout <<ans<<endl;

    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define inf LLONG_MAX
#define pll pair <ll,ll>
#define min_pq priority_queue <pll> ,vector <pll>, greater <pll> > > 
#define f first
#define s second

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

ll modpowinv(ll n)
{
	return modpow(n,mod-2);
}

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

	char c;
	cin>>c;
	cout<<(char)(c+1)<<'\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<int, int>;
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

const double PI = acos(-1.0L);
// cout << setpricision(14) << PI << endl;で出力

double aa, bb;
double h, m;

int main() {
    cin >> aa >> bb >> h >> m;

    double hcos = (h+m/60.0) * 30.0;
    double mcos = m * 6.0;
    double ccos = abs(hcos-mcos);
    // cout << ccos << endl;

    double accos = PI*(ccos/180.0);

    double dans = aa*aa + bb*bb - 2.0*aa*bb*cos(accos);
    double ans = sqrtl(dans);


    cout << setprecision(14) << ans << endl;
}

Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <unordered_map>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
#include <unordered_map>
#include <fstream>
#include <ctime>
#include <complex>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef pair<int,int> pii;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {1,-1,0,0,1,-1,1,-1};
ll dx[8] = {0,0,1,-1,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T> inline void print(T &a){
    rep(i,a.size()) cout << a[i] << " ";
    cout << "\n";
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
ll pcount(ll x) {return __builtin_popcountll(x);}
const int mod = 1e9 + 7;
//const int mod = 998244353;

int main(){
	double d; cin >> d;
	double t = d / sqrt(2);
	double ans = sqrt(d*d + 2*t*t);
	for(int i=0; i<=10; i++){
		if(d > i - eps && abs(d*d - i*i) <= 1.0 - eps){
			chmax(ans, i+1);
		}
	}
	printf("%.12f\n",ans);
}


Measured memory_bytes: 3288
n = int(input())
h = list(map(int, input().split()))
Flag = "Yes"
maxh = 0

if n >= 2 :
  for i in range(1,n):
    if h[i-1] > h[i]:
      h[i-1] = h[i-1] - 1
      if h[i-1] > maxh:
        maxh = h[i-1] 
      if h[i-1] > h[i] or maxh > h[i] :
        Flag = "No"
      
print(Flag)

Measured memory_bytes: 20648
using namespace std;

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <limits>
#include <climits>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <numeric>
typedef long long ll;
typedef pair<int,int> p;

int main()
{
  string s;
  cin >> s;
  vector<char> v;
  // vector<int> count;
  for (int i = 0; i < int(s.size()); i++)
  {
    v.push_back(s[i]);
  }

  for (int i = 0; i < int(v.size()); i++)
  {
    int count = 0;
    for (int j = 0; j < int(v.size()); j++)
    {
      if (s[i] == s[j])
      {
        count++;
      }
    }
    if (count % 2 == 1)
    {
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;

}


Measured memory_bytes: 256
import math
 
def f(A, B, X):
	return math.floor((A*X)/B) - A*math.floor(X/B)
 
A,B,N = map(int,input().split())
 
if N < B:
	print(f(A,B,N))
else:
	print(f(A,B,B-1))


Measured memory_bytes: 62028
n = int(input())
wsv = [list(map(int,input().split())) for i in range(n)]
wsv.sort(key = lambda x:x[0]+x[1],reverse=True)
smx = max(list(zip(*wsv))[1])
dp = [[0 for i in range(smx+1)] for j in range(n+1)]
for i in range(1,n+1):
  dp[i] = dp[i-1][:]
  w,s,v = wsv[i-1]
  dp[i][s] = max(dp[i-1][s],v)
  for ss in range(smx+1)[::-1]:
    sn = min(ss-w,s)
    if sn >= 0 and dp[i-1][ss]:
      dp[i][sn] = max(dp[i][sn],dp[i-1][sn],dp[i-1][ss]+v)
print(max(dp[-1]))

Measured memory_bytes: 187912
from operator import itemgetter
flag1 = 0
n = int(input())
ans_list = []
for i in range(n):
    a = list(map(int, input().split()))
    ans_list.append(a)
ans_list.sort(key=itemgetter(1))
timequeue = 0
for i in range(n):
    timequeue += ans_list[i][0]
    if timequeue > ans_list[i][1]:
        flag1 += 1
        break
if flag1 == 1:
    print('No')
else:
    print('Yes')


Measured memory_bytes: 88564
#include <iostream>
#include <stdlib.h>
#include <string.h>
#include <math.h>
using namespace std;

using QWORD = unsigned long long;
using SQWORD = long long;
using DWORD = unsigned int;
using SDWORD = int;
using WORD = unsigned short;
using SWORD = short;
using DOUBLE = double;
using FLOAT = float;

#define MIN_SDWORD (-2147483648)
#define MAX_SDWORD (2147483647)
#define ArrayLength(a)  (sizeof(a) / sizeof(a[0]))

static inline QWORD MAX(QWORD a, QWORD b) { return a > b ? a : b; }
static inline DWORD MAX(DWORD a, DWORD b) { return a > b ? a : b; }
static inline SDWORD MAX(SDWORD a, SDWORD b) { return a > b ? a : b; }
static inline QWORD MIN(QWORD a, QWORD b) { return a < b ? a : b; }
static inline DWORD MIN(DWORD a, DWORD b) { return a < b ? a : b; }
static inline SDWORD MIN(SDWORD a, SDWORD b) { return a < b ? a : b; }

#define BYTE_BITS   (8)
#define WORD_BITS   (16)
#define DWORD_BITS  (32)
#define QWORD_BITS  (64)

using M_BOOL = bool;
#define M_TRUE (true)
#define M_FALSE (false)

static void printMatrix(DWORD **p, DWORD dwSize)
{
    printf("---\n");
    for (DWORD i = 0; i < dwSize; i++) {
        for(DWORD j = 0; j < dwSize; j++) {
            printf("%5d", p[i*dwSize + j]);
        }
        cout << endl;
    }
    printf("---\n");
}

int main()
{
    DWORD dwInput_N, dwInput_M, dwInput_Q;
    char str[100];

    cin.getline(str, sizeof(str));
    dwInput_N = atoi(strtok(str, " "));
    dwInput_M = atoi(strtok(NULL, " "));
    dwInput_Q = atoi(strtok(NULL, " "));

    /* input train */
    static DWORD aadwTrainMap[501][501];
    for (DWORD dwIdx = 0; dwIdx < dwInput_M; dwIdx++) {
        cin.getline(str, sizeof(str));
        WORD wCity_L, wCity_R;

        wCity_L = atoi(strtok(str, " "));
        wCity_R = atoi(strtok(NULL, " "));
        aadwTrainMap[wCity_L][wCity_R]++;
    }

    /* calc camsum(Row) */
    for (DWORD dwRow = 0; dwRow <= dwInput_N; dwRow++) {
        DWORD dwSum = 0;
        for (DWORD dwCol = dwRow; dwCol <= dwInput_N; dwCol++) {
            dwSum += aadwTrainMap[dwRow][dwCol];
            aadwTrainMap[dwRow][dwCol] = dwSum;
        }
    }

    /* calc camsum(col) */
    for (DWORD dwCol = 0; dwCol <= dwInput_N; dwCol++) {
        DWORD dwSum = 0;
        for (DWORD dwRow = 0; dwRow <= dwInput_N; dwRow++) {
            dwSum += aadwTrainMap[dwRow][dwCol];
            aadwTrainMap[dwRow][dwCol] = dwSum;
        }
    }

    /* input question */
    for (DWORD dwIdx = 0; dwIdx < dwInput_Q; dwIdx++) {
        DWORD dwAnswer;
        cin.getline(str, sizeof(str));
        WORD wBegin = atoi(strtok(str, " "));
        WORD wEnd   = atoi(strtok(NULL, " "));

        dwAnswer= (aadwTrainMap[wEnd][wEnd]
                    - aadwTrainMap[wBegin-1][wEnd]
                    - aadwTrainMap[wEnd][wBegin-1]
                    + aadwTrainMap[wBegin-1][wBegin-1]);
        printf("%d\n", dwAnswer);
    }

    return 0;

}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ll n,p,ans=1;
	cin>>n>>p;
	ll i=pow(p,1.0/n);
	for(i=i+1;i>=1;i--){
		if( (p%((ll)pow(i,n))) ==0){
			ans=i;
			break;
		}
	}
	cout<<ans;
	return 0; 
} 
 


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

struct P {
	int x, y;
	P() : x(0), y(0) {}
	P(int x, int y)
		: x(x), y(y) {}
};

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

int main()
{
	int H, W;
	P s, g;
	vector<P> q, sol;
	char c;
	cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W, 1));
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c;
			if (c == '%') {
				g.x = i, g.y = j;
			}
			else if (c == '@') {
				s.x = i, s.y = j;
				a[i][j] = 0;
				q.push_back(s);
			}
			else if (c == '$') {
				sol.push_back(P(i, j));
				a[i][j] = -1;
			}
			else if (c == '#') {
				a[i][j] = -1;
			}
		}
	}
	bool res = false;
	while (!q.empty()) {
		vector<P> tq, tsol;
		for (auto p : sol) {
			for (int i = 0; i < 4; i++) {
				int tx = p.x + dx[i], ty = p.y + dy[i];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W && a[tx][ty] != -1) {
					a[tx][ty] = -1;
					tsol.push_back(P(tx, ty));
				}
			}
		}
		for (auto p : q) {
			for (int i = 0; i < 4; i++) {
				int tx = p.x + dx[i], ty = p.y + dy[i];
				if (tx >= 0 && tx < H && ty >= 0 && ty < W && a[tx][ty] == 1) {
					if (tx == g.x && ty == g.y) {
						res = true;
						tq.clear();
						break;
					}
					a[tx][ty] = 0;
					tq.push_back(P(tx, ty));
				}
			}
		}
		q = tq, sol = tsol;
	}
	cout << (res ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 3616
n=int(input())
s=['' for i in range(n)]
for i in range(n):
  s[i]=input()
#print(n,s)
cnt=0
cnta=0
cntb=0
cntab=0
ans=0
for i in range(n):
    cnt+=s[i].count('AB')
    if s[i][-1]=='A' and s[i][0]=='B':
        cntab+=1
    elif s[i][-1]=='A':
        cnta+=1
    elif s[i][0]=='B':
        cntb+=1

if cntab==0:
  ans=cnt+min(cnta,cntb)
else:
  ans=cnt+cntab+min(cnta,cntb)

if cnta==0 and cntb==0:
  if cntab > 0:
    ans=cnt+cntab-1
  else:
    ans=cnt
print(ans)



Measured memory_bytes: 44504
#coding: utf-8
import math
import heapq
import bisect
import numpy as np
from collections import Counter
#from scipy.misc import comb

MOD = 10**9+7

N = int(input())
A = [list(map(int, input().split())) for i in range(2)]

ans = 0
for i in range(N):
    tmp = 0
    for j in range(i+1):
        tmp += A[0][j]
    for j in range(i,N):
        tmp += A[1][j]
    ans = max(ans,tmp)

print(ans)

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    string S;
    cin >> S;
    ll w;
    cin >> w;
    for(ll i = 0;i < S.size();i += w) cout << S[i];
    cout << endl;
    return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define vi vector<int>
#define all(a) a.begin(),a.end()
typedef pair<int,int> P;
const long long mod=1000000007;
const long long inf=1ll<<61;

vector<int>G[12][600008];
int dx[]={0,3,7,5,11,8};
int dy[]={1,2,4,6,9,10};
int maX=200002;
signed main(){
    int n;cin>>n;
    rep(i,n){
        int a,b;char c;
        cin>>a>>b>>c;
        if(c=='U'){
            G[0][a].push_back(b);
            G[4][a+b+maX].push_back(a-b+maX);
            G[8][a-b+maX].push_back(a+b+maX);
        }
        if(c=='D'){
            G[1][a].push_back(b);
            G[5][a+b+maX].push_back(a-b+maX);
            G[9][a-b+maX].push_back(a+b+maX);
        }
        if(c=='L'){
            G[2][b].push_back(a);
            G[6][a+b+maX].push_back(a-b+maX);
            G[10][a-b+maX].push_back(a+b+maX);
        }
        if(c=='R'){
            G[3][b].push_back(a);
            G[7][a+b+maX].push_back(a-b+maX);
            G[11][a-b+maX].push_back(a+b+maX);
        }
    }
    rep(i,12)rep(j,maX*3)sort(all(G[i][j]));
    int ans=inf;
    rep(i,maX*3){
        rep(J,6){
            int j=dx[J],k=dy[J];
            for(int e:G[j][i]){
                auto itr=lower_bound(all(G[k][i]),e);
                if(itr!=G[k][i].end()){
                    ans=min(ans,(*itr)-e);
                }
            }
        }
    }

    if(ans==inf)cout<<"SAFE"<<endl;
    else cout<<ans*5<<endl;
}

Measured memory_bytes: 190944
import math
K=int(input())
ans=0
for h in range(1,K+1):
    for i in range(1,K+1):
        gcd=math.gcd(h,i)
        if gcd==1:
            ans+=K
        else:
            for j in range(1,K+1):
                ans+=math.gcd(gcd,j)
print(ans)

Measured memory_bytes: 9172
#!/usr/bin/env python3
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
n = int(input())
ans = 0
for i in range(n//7+1):
    if (n - i*7) % 4 == 0: ans += 1
print("Yes" if ans > 0 else "No")

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
int main(void){
    // Your code here!
 
    int N;
    int m = 0;
    int ans = 1;
    cin >> N;
    
    for(int i = 1; i <= N; i++){
        int crack_Coount = 0;
        int number = i;
        while(number%2 == 0){
            crack_Coount++;
            number /= 2;
        }
        
        if(m < crack_Coount){
            ans = i;
            m = crack_Coount;
        }
    }
    
    cout << ans << endl;
    

}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace diverta_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            string[] s = new string[n];
            var count = 0;
            var aback = 0;
            var bfront = 0;
            var both = 0;
            var checkboth = 0;
            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
                for (int j = 0; j < s[i].Length-1; j++)
                {
                    if (s[i].Substring(j, 2) == "AB")
                    {
                        count++;
                    }   
                }
                if (s[i].Substring(0,1) == "B")
                {
                    bfront++;
                    both++;
                }
                if (s[i].Substring(s[i].Length-1, 1) == "A")
                {
                    aback++;
                    both++;
                }
                if (both == 2)
                {
                    checkboth++;
                }
                both = 0;
            }
            if (bfront > aback)
            {
                count = count + aback;
            }
            else
            {
                count = count + bfront;
            }

            if (aback == checkboth & bfront == checkboth & checkboth != 0)
            {
                count = count - 1;
            }

            Console.WriteLine(Convert.ToString(count));
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 15356
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main() {
  int n;
  long long sum = 0;
  cin >> n;
  vector<int> v1(n);
  for(int i = 0; i < n; ++i) {
	cin >> v1[i];
	sum += v1[i];
  }
  cout << *min_element(v1.begin(), v1.end()) << " ";
  cout << *max_element(v1.begin(), v1.end()) << " ";
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 3132
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
typedef long long int ll;
typedef long double ld;
#define PI 3.141592653589793
#define MOD 1000000007
#define ALL(obj) (obj).begin(),(obj).end()
template<class T>inline bool chmax(T& a,T b){if (a<b){a=b;return 1;}return 0;}
template<class T>inline bool chmin(T& a,T b){if (a>b){a=b;return 1;}return 0;}
const ll INF = 1LL << 56;

//四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

struct edge{//グラフに使うヤツ
    ll from,to,cost;
};

typedef vector<vector<edge> > G;
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}

int main(){
    ll n,p;
    cin >> n >> p;
    string s;
    cin >> s;
    if (p==2 or p==5) {
        ll ans=0;
        for (ll i=0;i<n;i++){
            if ((s[n-i-1]-'0')%p==0){
                ans+=n-i;
            }
        }
        cout << ans << endl;
        return 0;
    }
    ll tc=0,fc=0,x=p;
    while(x%2==0){
        x/=2;
        tc++;
    }
    while(x%5==0){
        x/=5;
        fc++;
    }
    ll a[n+1];
    fill(a,a+n+1,0);
    ll tmp=0;
    ll mod=1;
    for (ll i=0;i<n;i++){
        tmp+=(ll(s[n-1-i]-'0'))*mod;
        a[i+1]+=tmp%p;
        mod*=10;
        mod%=p;
    }
    ll ans=0,c[p];
    fill(c,c+p,0);
    for (ll i=0;i<n+1;i++){
        c[a[i]]++;
    }
    for (ll i=0;i<p;i++){
        ans+=((c[i]*(c[i]-1))/2);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5356
#include <bits/stdc++.h>
using namespace std; 
int main(){
  string a;
  cin >> a;
  int ans = 0;
  for(int i = 0; i < 4; ++i){
    ans += (a[i] == '2' ? 1 : 0);
  }
  cout << ans << endl;
}


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

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
typedef pair<int,int> P;
string itos(int n){
  stringstream ss;
  ss<<n;
  return ss.str();
}

int main(){
  vector<string> cand;
  FOR(n,123,10000){
    string s = itos(n);
    if(s.size() < 4) s = "0" + s;
    set<char> cnt;
    REP(i,4)cnt.insert(s[i]);
    if(cnt.size() == 4)cand.push_back(s);
  }
  int N;
  while(cin>>N, N){
    vector<string> input(N);
    vector<int> hit(N),brow(N);
    REP(i,N)cin>>input[i]>>hit[i]>>brow[i];
    vector<string> ans;
    FORIT(it, cand){
      string &s = *it;
      bool ok = true;
      REP(i,N){
        int h = 0, b = 0;
        REP(j,4)REP(k,4)if(s[j]==input[i][k]){
          if(j == k) h++;
          else b++;
        }
        if(h != hit[i] || b != brow[i]){
          ok = false;
          break;
        }
      }
      if(ok){
        ans.push_back(s);
      }
    }
    vector<string> ans2;
    FORIT(it, cand){
      string &s = *it;
      set<P> pset;
      REP(i,ans.size()){
        int h = 0, b = 0;
        REP(j,4)REP(k,4)if(s[j]==ans[i][k]){
          if(j == k) h++;
          else b++;
        }
        pset.insert(P(h,b));
      }
      if(pset.size() == ans.size()){
        ans2.push_back(s);
      }
    }
    if(ans.size() == 1) cout<<ans.front()<<endl;
    else if(ans2.size() > 0) cout<<ans2.front()<<endl;
    else cout<<"????"<<endl;
  }

  return 0;
}

Measured memory_bytes: 1236
import { readFileSync } from 'fs'

function main() {
  const input: string = readFileSync('/dev/stdin', 'utf8')
  const forecast = input.split('\n')[0].split('')
  const fact = input.split('\n')[1].split('')
  let result = 0
  for (let i = 0; i < forecast.length; i++) {
    if (forecast[i] === fact[i]) result++
  }
  console.log(result)
}
main()

Measured memory_bytes: 7372
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = pow(10, 9) + 7;
//const ll MOD = 998244353;
//const ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
const ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divCeil(ll A, ll B) {return (A + (B - 1)) / B;}
ll myctoi(char C) {return C - '0';}
char myitoc(ll N) {return '0' + N;}
#define FINALANS(A) {cout << (A) << endl; exit(0);}

int main()
{
  ll a;
  string s;
  cin >> a >> s;

  cout << ((a >= 3200) ? (s) : ("red")) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for(int i = (a); i<(b); ++i)
#define rep(i, n) for (int i=0; i<(n); ++i)
#define out(x) cout << x << endl

int main(){
    ll N, K;
    cin >> N >> K;
    out(min(K-(N%K), (N%K)));
}


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

int main(){
   string s;
   cin>>s;
   
   if(s[5]=='1') cout<<"TBD"<<endl;
   else if(s[6]=='1' || s[6]=='2' || s[6]=='3' || s[6]=='4') cout<<"Heisei"<<endl;
   else cout<<"TBD"<<endl;
   
}

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

using namespace std;
#define ll long long
ll divs[10000002];
int main()
{
  ll n;cin>>n;
  for(ll i=1;i<=n;i++){
      for(ll j=i;j<=n;j+=i)
      divs[j]++;
  }
  ll ans=0;
  for(ll i=1;i<=n;i++){
      ans+=(i*divs[i]);
  }
  cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 81724
#include <bits/stdc++.h>
using namespace std;
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << " "; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;


int main() {
  ll n, m; cin >> n >> m;
  ll k = ll(1e5) / m;
  VV cnt(m, V(k+1));
  V sum(m);

  rep(i, n) {
    int x; cin >> x;
    ++cnt[x%m][x/m];
    ++sum[x%m];   
  }

  ll ans = 0;
  rep2(i, 1, (m-1)/2+1) {
    int j = m-i;
    if (sum[i] < sum[j]) {
      swap(sum[i], sum[j]);
      swap(cnt[i], cnt[j]);
    }
    for (auto x : cnt[i]) {
      ll y = min(x, sum[i] - sum[j]) / 2;
      ans += y;
      sum[i] -= 2*y;
    }
    ans += sum[j];
  }
  ans += sum[0] / 2;
  if (m%2 == 0) ans += sum[m/2] / 2;

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


Measured memory_bytes: 6144
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
long long a,b,x,z,c;
cin >> a>>b>>x;
z=b/x;
if (a==0)
    cout << z+1;
else {
    c=(a-1)/x;
    cout << z-c;
}
   return 0;
}


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

if H[0]>=2:
    pre = H[0] - 1
else:
    pre = H[0]

flag = True

for i in range(1, N):
    if H[i]<pre:
        flag = False
        break
    elif H[i]==pre:
        pass
    else:
        pre = H[i] - 1

if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 14396
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
using namespace std;
// using namespace __gnu_pbds;
// typedef tree<int, null_type, less<int>, rb_tree_tag,
//              tree_order_statistics_node_update>
//     new_data_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)
#define lli long long int
#define llu unsigned long long int
#define fr(va, beg, end) for (lli va = beg; va < end; va++)
#define pb push_back
#define rt return 0
#define endln "\n"
#define all(x) x.begin(), x.end()
// cout << fixed << setprecision(0) << pi <<" "<<npi<<endl;
// gcd function
// __gcd(a, b)
// for max of n elements
// cout<<max({a,b,c,d})<<endl;

lli input(lli n, vector<lli> &ve);
lli input(lli n, vector<lli> &ve) {
    lli val;
    for (lli i = 0; i < n; i++) {
        cin >> val;
        ve.pb(val);
    }
    return 0;
}

int main(void) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    lli n, a;
    vector<lli> v;
    cin >> n;
    vector<lli> pref(n + 1, 0);
    input(n, v);
    // lli dp[n + 1][n + 1][2];
    // vector<vector<vector<lli>>> dp(n + 1,
    //                                vector<lli>(n + 1, vector<lli>(2, 0)));
    vector<vector<vector<lli>>> dp(
        n + 1, vector<vector<lli>>(n + 1, vector<lli>{0, 0}));
    fr(i, 0, n) {
        dp[i][i][0] = v[i];
        dp[i][i][1] = v[i];
    }

    pref[0] = v[0];
    fr(i, 1, n) {
        pref[i] = pref[i - 1] + v[i];
    }

    for (lli i = 2; i <= n; i++) {
        for (lli j = 0; j <= n - i; j++) {
            lli l = j, r = j + i - 1;
            dp[l][r][0] =
                max(v[l] + pref[r] - pref[l] - dp[l + 1][r][1],
                    v[r] + pref[r - 1] - pref[l] + v[l] - dp[l][r - 1][1]);
            dp[l][r][1] =
                max(v[l] + pref[r] - pref[l] - dp[l + 1][r][0],
                    v[r] + pref[r - 1] - pref[l] + v[l] - dp[l][r - 1][0]);
        }
    }

    cout << 2 * dp[0][n - 1][0] - pref[n - 1] << endl;
    rt;
}

Measured memory_bytes: 493056
n = int(input())
w = list(map(int, input().split()))
S1 = []
S2 = []
for t in range(n):
    S1.append(sum(w[0:t+1]))
    S2.append(sum(w[t+1:n]))
av = []
for i in range(n):
    av.append(abs(S1[i]-S2[i]))
#print(S1)
#print(S2)
#print(av)
print(min(av))

Measured memory_bytes: 3064
#include<stdio.h>
#include<string.h>
#define N 1000

int LCSlength(char *X,char *Y) {
  int n,m,i,j;
  int c[N+1][N+1];
  
  m = strlen(X)+1;
  n = strlen(Y)+1;
  
  for(i=0;i<m;i++) 
    c[i][0] = 0;
  
  for(j =0;j<n;j++)
    c[0][j] = 0;
  
  for(i=1;i<m;i++) {
    for(j=1;j<n;j++) {
      if(X[i-1] == Y[j-1])
	c[i][j] = c[i-1][j-1] + 1;
      
      else if(c[i-1][j] >= c[i][j-1])
	c[i][j] = c[i-1][j];
      
      else c[i][j] = c[i][j-1];
                     
    }
  }    
  printf("%d\n",c[i-1][j-1]);
}

int main(void) {

  int i,n;
  char c1[N],c2[N];
  
  scanf("%d",&n);
  for(i=0;i<n;i++) {
    scanf("%s%s",c1,c2);
    LCSlength(c1,c2);
  }
  return 0;
}

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

const int moder = (int) 1e6 + 3;

int pre[moder];

int powermod(int a, int exp){
    int ret = 1;
    for ( ; exp > 0; exp >>= 1){
        if (exp & 1){
            ret = 1ll * ret * a % moder;
        }
        a = 1ll * a * a % moder;
    }
    return ret;
}

void solve(){
    int x, d, n;
    scanf("%d%d%d", &x, &d, &n);
    if (!d){
        printf("%d\n", powermod(x, n));
        return;
    }
    if (!x){
        puts("0");
        return;
    }
    x = 1ll * powermod(d, moder - 2) * x % moder;
    if (x + n - 1 >= moder){
        puts("0");
        return;
    }
    int ans = 1ll * pre[x + n - 1] * powermod(pre[x - 1], moder - 2) % moder * powermod(d, n) % moder;
    printf("%d\n", ans);
}

int main(){
    pre[0] = 1;
    for (int i = 1; i < moder; ++ i){
        pre[i] = 1ll * pre[i - 1] * i % moder;
    }
    int test;
    scanf("%d", &test);
    while (test --){
        solve();
    }
    return 0;
}

Measured memory_bytes: 4736
n, m = map(int, input().split())
cards = sorted(list(map(int, input().split())))

changer = []
for i in range(m):
    p, c = map(int, input().split())
    changer.append((p, c))

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

cur = 0
while len(changer) and cur < n:
    p, c = changer.pop()
    i = cur
    while i < n and i < cur + p:
        if cards[i] < c: cards[i] = c
        else: break
        i += 1
    cur = i
print(sum(cards))

Measured memory_bytes: 22216