akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max();

int main() {
	int a, b;
	cin >> a >> b;
	cout << max(0, a - 2*b) << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<list>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<set>
#include<queue>
using namespace std;

typedef long long ll;

int main() {
  int n; cin >> n;
  ll a[100010];
  ll sum = 0,cnt = 0,sum2 = 0,cnt2 = 0;
  for ( int i = 0; i < n; i++ ) cin >> a[i];

  
  //1
  for ( int i = 0; i < n; i++ ) {
    if ( i % 2 == 0 ) { //positive
      sum += a[i];
      if ( sum <= 0 ) {
	cnt += abs(sum)+1;
	sum += abs(sum)+1;
      }
      }else { //negative
	sum += a[i];
	if ( sum >= 0 ) {
	  cnt += sum+1;
	  sum -= sum+1;
	}
      }
    }


  //2
  for ( int i = 0; i < n; i++ ) {
    if ( i % 2 == 0 ) { //negative
      sum2 += a[i];
	if ( sum2 >= 0 ) {
	  cnt2 += sum2+1;
	  sum2 -= sum2+1;
	}
      }else { //positive
	sum2 += a[i];
      if ( sum2 <= 0 ) {
	cnt2 += abs(sum2)+1;
	sum2 += abs(sum2)+1;	

      }
    }
  }  

  //cout << cnt << " " << cnt2 << endl;
  cout << min(cnt,cnt2) << endl;
  return 0;
}


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

#define lli long long int
#define pb push_back
#define MAXN 200001

lli freq[MAXN];
lli dp[MAXN];
vector<lli> v;
lli sum = 0, aux;

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

  for (int i = 0; i < n; i++)
  {
    cin >> aux;
    v.pb(aux);
    freq[aux]++;
  }

  for (int i = 1; i <= n; i++)
  {
    dp[i] = (freq[i] * (freq[i] - 1)) / 2;

    if (dp[i] < 0)
    {
      dp[i] = 0;
    }

    sum += dp[i];
  }

  for (auto const &i : v)
  {
    lli at = ((freq[i] - 1) * (freq[i] - 2)) / 2;

    if (at < 0)
    {
      at = 0;
    }

    lli ans = sum;
    ans -= dp[i];
    ans += at;
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 6384
class UnionFindTree():
    def __init__(self, values=[]):
        self.__parent_of = {}
        self.__rank_of = {}
        for value in values:
            self.add(value)

    def add(self, value):
        if value in self.__parent_of:
            raise RuntimeError("Dupulicated Value Added")
        self.__parent_of[value] = None
        self.__rank_of[value] = 0

    def root(self, value):
        if self.__parent_of[value] is None:
            return value
        else:
            self.__parent_of[value] = self.root(self.__parent_of[value])
            return self.__parent_of[value]

    def unite(self, a, b):
        r1 = self.root(a)
        r2 = self.root(b)
        if r1 != r2:
            if self.__rank_of[r1] < self.__rank_of[r2]:
                self.__parent_of[r1] = r2
            else:
                self.__parent_of[r2] = r1
                if self.__rank_of[r1] == self.__rank_of[r2]:
                    self.__rank_of[r1] += 1


def main():
    N, K, L = map(int, input().split())
    uft = UnionFindTree(range(N))
    for _ in range(K):
        p, q = map(int, input().split())
        uft.unite(p-1, q-1)
    uft2 = UnionFindTree(range(N))
    for _ in range(L):
        r, s = map(int, input().split())
        uft2.unite(r-1, s-1)
    pair = [(0, 0)] * N
    cnt = {}
    for i in range(N):
        p = (uft.root(i), uft2.root(i))
        if p not in cnt:
            cnt[p] = 0
        cnt[p] += 1
        pair[i] = p
    ans = [0] * N
    for i in range(N):
        ans[i] = cnt[pair[i]]
    print(" ".join(map(str, ans)))


if __name__ == "__main__":
    main()


Measured memory_bytes: 138752
#include <iostream>
#include <cstdio>
#include <cmath>
#define maxn 1000000
using namespace std;
int prime[maxn],number[maxn];
void getprime()
{
    int m=sqrt(maxn+0.5);
    for(int i=2;i<=m;i++)
    {
        if(!prime[i])
        {
            for(int j=i+i;j<maxn;j+=i)
            {
                prime[j]=1;
            }
        }
    }
    int sum = 0;
    for(int i=2;i<maxn;i++)
    {
        if(!prime[i])
        {
            sum++;
        }
        number[i]=sum;
    }
}
int main ()
{
    int n;
    getprime();
    while(scanf("%d",&n)!=EOF)
    {
        printf("%d\n",number[n]);
    }
}



Measured memory_bytes: 10880
#include<bits/stdc++.h>
#define int long long int
#define rep(i,m,n) for(int i=m;i<n;i++)
#define repr(i,n,m) for(int i=n;i>=m ;i--)
#define mod 1000000007
#define float long double
#define pb push_back
#define mp make_pair
#define print(v1) rep(i,0,v1.size()){cout<<v1[i]<<" ";} cout<<"\n";
using namespace std;
bool sortbysec(const pair<int,int> &a,
              const pair<int,int> &b)
{
    return (a.second < b.second);
}
int modulo(int n,int m=1000000007){
    if(n<0){
        return (m-abs(n)%m)%m;
    }
    else return n%m;
}
void solve()
{ 
   int n,total=0,final=0;
   cin>>n;
   vector<int>v1(n),v2(n+1);
   rep(i,0,n){
      cin>>v1[i];
      total+=(v1[i]);
    }
   v2[0]=0;
   int x=0;
   rep(i,1,n+1)
   {
    x+=v1[i-1];
   v2[i]=((total)-(x));    
   }
   // v2[i]=((total%mod)-(v1[i-1]%mod)-(v2[i-1]%mod))%mod;
   // print(v2);
   rep(i,0,n-1){
    final+=((v1[i])*(v2[i+1]%mod))%mod;
    final%=mod;
   }cout<<final%mod;
}
signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
   int t=1;
   //cin>>t;
   while(t--)
   {
      solve();
      cout<<"\n";
   }
   cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
  return 0;
 }

Measured memory_bytes: 6352
def flip(x, y, grid)
  dx = [0, 0, 1, 0, -1]
  dy = [0, -1, 0, 1, 0]

  for i in 0...5
    if x + dx[i] >= 0 && x + dx[i] < 10 && y + dy[i] >= 0 && y + dy[i] < 10
      grid[y + dy[i]][x + dx[i]] ^= 1 
    end
  end

end


n = gets.chomp.to_i

n.times do
  original = []
  10.times do
    original << gets.chomp.split.map(&:to_i)
  end

  for i in 0...(1 << 10)
    clone = Marshal.load(Marshal.dump(original))
    result = Array.new(10) { Array.new(10, 0) }
    for j in 0...10
      if i >> j & 1 == 1
        flip(j, 0, clone)
        result[0][j] = 1
      end
    end

    for y in 1...10
      for x in 0...10
        if clone[y - 1][x] == 1
          result[y][x] = 1
          flip(x, y, clone)
        end
      end
    end

    unless clone.flatten.include?(1)
      result.each do |row|
        puts row.join(' ')
      end
      break
    end
  end
end

Measured memory_bytes: 9960
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int num,pr;
	scanf("%d%d",&num,&pr);
	if(num%2==1)num++;
	printf("%lf\n",(double)num/(1.0-double(100-pr)/double(100)+double(pr)/double(100)));
}

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

using _i64 = int64_t;
using _u64 = uint64_t;
using _f64 = double;

#define _for(i, start, end) for(_i64 i = (_i64)start; i < (_i64)end; ++i)
#define _rep(i, number) _for(i, 0, number)
#define _foreach(e, data) for(auto& e : data)
#define _all(data) data.begin(), data.end()

template<typename type>
_i64 _size(const type& data) { return static_cast<_i64>(data.size()); }
template<typename type, size_t size>
_i64 _size(const type (&)[size]) { return static_cast<_i64>(size); }

enum _flag : bool { able = true, disable = false };

struct _time {
    _time(_flag flag) { check = flag; if(!check) { return; } gettime(start); }
    ~_time() {
        if(!check) { return; }; gettime(end);
        _i64 elapse = chrono::duration_cast<chrono::milliseconds>(end - start).count();
        cout << endl << "Time: " << elapse << " ms" << endl;
    }
    private:
    using _timer = chrono::time_point<chrono::system_clock>;
    _timer start, end; bool check;
    void gettime(_timer& time) { time = chrono::system_clock::now(); }
};

struct _ini { _ini() { ios::sync_with_stdio(false); cin.tie(nullptr); } } _ini;

int main() {
    {
        _time time(disable);
        _i64 n, debt = 100000; cin >> n;
        _rep(i, n) {
            debt *= 1.05;
            if(debt % 1000 != 0) { debt += 1000 - debt % 1000; }
        }
        cout << debt << endl;
    }
    return 0;
}


Measured memory_bytes: 3176
#include<stdio.h>
#define INFINITY 1000000001

void mergeSort(int *, int, int);
void merge(int *, int, int, int);

int n;//データの個数を記録する
int count=0;
int S[500002];//配列の外部変数

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

  //printf("%d\n",S[0]);
  
  mergeSort( S, 0, i);

  for(i = 0;i < n; i++){
    printf("%d", S[i]);
    if(i < n-1){
      printf(" ");
    }
  }
  printf("\n%d\n",count);
  return 0;
}

void merge(int *A,int  left,int mid,int right){
  int i, j, k, n1, n2;
  int L[250001],R[250001];

  n1 = mid - left;
  n2 = right - mid;

  for(i = 0;i <= n1-1; i++){
    L[i] = A[left + i];//L[0...n1]を作成中なう
  }

  for(i = 0;i <= n2-1; i++){
    R[i] = A[mid + i];//R[0...n2]を作成中なう
  }

  L[n1] = INFINITY;
  R[n2] = INFINITY;

  i = 0;
  j = 0;

  for(k = left;k <= right-1; k++){
    if(L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
    }else{
      A[k] = R[j];
      j = j + 1;
    }
    count++;//比較回数を記録
  }
}

void mergeSort(int *A,int left,int right){
  int mid;
  
  if(left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



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

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

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

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
/*
考察メモ
2本辿ることによって辿り着けるような頂点の組に辺を張る場合は完全グラフになる
では、2本辿ることによって辿り着けるような頂点の組に辺を張る場合は？
2部グラフになりそう(もともと二部グラフでなければ破綻しているのでは。。。)
もともと二部グラフなら -> 二部グラフになりそう
*/
ll n,m;
const int MAX_N = 100000;
VI edges[MAX_N];
bool used[MAX_N][2];

void dfs(int current, int col){
  for(int to: edges[current]){
    if(!used[to][!col]){
      used[to][!col] = true;
      dfs(to,!col);
    }
  }
}

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> m;
  rep(i,m){
    int a,b;
    cin >> a >> b;
    a--,b--;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  
  used[0][0] = true;
  dfs(0,0);

  ll col0 = 0;
  rep(i,n){
    if( used[i][0] && used[i][1] ){ // 二部グラフでない
      cout << n*(n-1)/2 - m << endl;
      return 0;
    }
    if(used[i][0]) col0 ++;
  }

  cout << (n-col0) * col0 - m << endl;
  return 0;
}


Measured memory_bytes: 7936
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int k = sc.nextInt();
		String s = sc.next();
		
		if (s.length() <= k) {
		    System.out.println(s);
		} else {
		    System.out.println(s.substring(0, k) + "...");
		}
	}
}

Measured memory_bytes: 38736
N = int(input())
list = [int(i) for i in input().split()] 
  
count = 0
  
for j in range(N):
  flag = True
  num = list[j]
  while(flag == True):
    if num % 2 == 0:
      num /= 2
      count += 1
    else:
      flag = False
      
print(count)

Measured memory_bytes: 4532
use proconio::input;

fn main() {
    input! {
        n: i64,
        m: i64,
    };

    let s = n;
    let c = m;
    let scc = if s >= c / 2 {
        c / 2
    } else {
        s + (c - 2 * s) / 4
    };
    let ans = scc;
    println!("{}", ans);
}


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

int main()
{
    bool d = false;
    string s, t, str1, str2;
    cin >> s >> t;
    for(int i = 0; i < s.size(); i++){
        str1 = s.substr(0,i);
        str2 = s.substr(i,s.size() - i);

        if(str2 + str1 == t){
            d = true;
            break;
        }

    }

    if(d) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
			long N = sc.nextLong();
			long M = sc.nextLong();
		sc.close();

		if(N > M/2){
			System.out.println(M/2);
		}
		else{
			System.out.println(N  + ((M-(2*N))/4));
		}



	}
}


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

using namespace std;

using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using vb = vector<bool>;
using P = pair<ll, ll>;
template <typename T> using pq = priority_queue<T>;
template <typename T> using minpq = priority_queue<T, vector<T>, greater<T>>;
template <typename T, typename K> using ump = unordered_map<T, K>;
const ll dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll e5 = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);

#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for (ll i = ll(n - 1); i >= 0; i--)
#define each(i, mp) for (auto &i : mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()

template <class T> ostream &operator<<(ostream &out, const vector<T> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << ' ';
    return out;
}

template <class T> istream &operator>>(istream &in, vector<T> &list) {
    ll n = list.size();
    rep(i, n) in >> list[i];
    return in;
}

template <class T> ostream &operator<<(ostream &out, const vector<vector<T>> &list) {
    ll n = list.size();
    rep(i, n) out << list[i] << '\n';
    return out;
}

/* ------------- ANSWER ------------- */
/* ---------------------------------- */

void solve() {
    ll n;
    cin >> n;
    string c;
    cin >> c;
    set<ll> idxW, idxR;
    rep(i, n) {
        if (c[i] == 'W')
            idxW.insert(i);
        else
            idxR.insert(i);
    }
    ll ans = 0;
    rep(i, n) {
        if (c[i] == 'W') {
            if (!idxR.empty()) {
                ll last = *idxR.rbegin();
                idxR.erase(last);
                if (last > i) {
                    c[i] = 'R', c[last] = 'W';
                    ans++;
                }
            }
        }
    }
    cout << ans << '\n';
}

int main() {
#ifdef MY_DEBUG
    while (true) {
#endif
        solve();
#ifdef MY_DEBUG
    }
#endif
    return 0;
}


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

namespace ABC143A
{
    class Program
    {
        public static void Main()
        {
            var n = Console.ReadLine()
                    .Split(' ').Select(x => int.Parse(x))
                    .ToArray();

            var d = n[0] - n[1] * 2;
            Console.WriteLine(d > 0 ? d : 0);
        }
    }
}

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

int main()
{
	int n;
	cin >> n;
	
	string s;
	cin >> s;
	
	int t=0;
	for(int i=0; i<s.size()-2; i++)
		if(s[i]=='A'&&s[i+1]=='B'&&s[i+2]=='C')
			t++;
			
	cout << t << endl;
	return 0; 
}

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

int main() {
  char S[10];
  char contest1[10] = {'A','B','C','\0'};
  char contest2[10] = {'A','R','C','\0'};
  int size1 = strlen(contest1);
  int size2 = strlen(contest2);
  int cnt1=0,cnt2=0;
  scanf("%s",S);
  for(int i=0;S[i]!='\0';i++) {
    if(S[i]==contest1[i]) {
      cnt1++;
    }
    if(S[i]==contest2[i]) {
      cnt2++;
    }
  }
  if(cnt1==size1) {
    printf("%s",contest2);
  }
  if(cnt2==size2) {
    printf("%s",contest1);
  }
  return 0;
}

Measured memory_bytes: 1664
from sys import exit
N = int(input())
L = []
for _ in range(N):
  L.append(list(map(int, input().split())))
L.sort(key=lambda  x: x[1])
used = 0
for l in L:
  used += l[0]
  if used > l[1]:
    print("No")
    exit()
print("Yes")

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

using namespace std;

const int N = 1e5+5;

int n, m, ans;
int pos[N], dsu[N];

int find(int x) { return dsu[x] = x == dsu[x] ? x : find(dsu[x]); }

int main() {
    iota(dsu, dsu+N, 0);
    scanf("%d %d", &n, &m);
    for(int i = 1, a; i <= n; i++) {
        scanf("%d", &a);
        pos[a] = i;
    }
    for(int i = 1, a, b; i <= m; i++) {
        scanf("%d %d", &a, &b);
        dsu[find(a)] = find(b); 
    }
    for(int i = 1; i <= n; i++) if(find(pos[i]) == find(i))
        ++ans;
    printf("%d\n", ans);

    return 0;
}


Measured memory_bytes: 1024
#[allow(unused_imports)]
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::Chars;
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused)]
const ALPHA_SMALL: [char; 26] = [
    'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's',
    't', 'u', 'v', 'w', 'x', 'y', 'z',
];
#[allow(unused)]
const ALPHA: [char; 26] = [
    'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S',
    'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
];
#[allow(unused)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(unused)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(unused)]
fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
    let v: Vec<T> = read_vec();
    assert_eq!(v.len(), 2);
    (v[0], v[1])
}
fn main() {
    input!(t: f64, x: f64);
    println!("{}", t / x);
}


Measured memory_bytes: 2216
#include <bits/stdc++.h>
template <long long mod>
class Combination
{
    std::vector<long long> fact, finv, inv;
public:
    Combination() {}
    Combination(int sz)
    {
        fact.resize(sz);
        finv.resize(sz);
        inv.resize(sz);
        fact[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
        }
        inv[0] = 0;
        inv[1] = 1;
        for (int i = 2; i < sz; ++i)
        {
            inv[i] = mod - inv[mod % i] * (mod / i) % mod;
        }
        finv[0] = 1;
        for (int i = 1; i < sz; ++i)
        {
            finv[i] = finv[i - 1] * inv[i] % mod;
        }
    }
    long long C(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return (fact[n] * finv[k] % mod) * finv[n - k] % mod;
    }
    long long P(long long n, long long k)
    {
        if (n < k)
            return 0;
        if (n < 0 || k < 0)
            return 0;
        return fact[n] * finv[n - k] % mod;
    }
    long long H(long long n, long long k)
    {
        return this->C(n + k - 1, k);
    }
    long long getfact(int i)
    {
        return fact[i];
    }
    long long getinv(int i)
    {
        return inv[i];
    }
    long long getfinv(int i)
    {
        return finv[i];
    }
};
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using P = pair<int, int>;
const double eps = 1e-8;
const ll MOD = 1000000007;
const int INF = INT_MAX / 2;
const ll LINF = LLONG_MAX / 2;
template <typename T1, typename T2>
bool chmax(T1 &a, const T2 &b) {
  if(a < b) {a = b; return true;}
  return false;
}
template <typename T1, typename T2>
bool chmin(T1 &a, const T2 &b) {
  if(a > b) {a = b; return true;}
  return false;
}
template<typename T1, typename T2>
ostream& operator<<(ostream &os, const pair<T1, T2> p) {
  os << p.first << ":" << p.second;
  return os;
}
template<class T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(int i=0;i<((int)(v.size()));++i) {
    if(i) os << " ";
    os << v[i];
  }
  return os;
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  ll n, m; cin >> n >> m;
  vll yaku;
  for(ll i=1;i*i<=m;++i) {
    if(m % i == 0) {
      yaku.push_back(i);
      if(i*i != m) yaku.push_back(m/i);
    }
  }
  sort((yaku).begin(),(yaku).end());
  int sz = (int)(yaku.size());
  map<int, int> idx;
  for(int i=0;i<(sz);++i) {
    idx[yaku[i]] = i;
  }
  vvll dp(50, vll(sz));
  dp[0][0] = 1;
  for(int i=0;i<(49);++i) {
    for(int j=0;j<(sz-1);++j) {
      for(int k=(1);k<(sz);++k) {
        if(yaku[j] * yaku[k] > m) break;
        if(m % (yaku[j] * yaku[k]) != 0) continue;
        ll nxt = yaku[j] * yaku[k];
        int to = idx[nxt];
        dp[i+1][to] += dp[i][j];
      }
    }
  }
  Combination<MOD> comb(2000000);
  ll ans = 0;
  for(int i=0;i<(50);++i) {
    if(dp[i][sz-1] != 0) {
      ll val = n - i;
      if(val < 0) break;
      ans += dp[i][sz-1] * comb.C(n, val) % MOD;
      ans %= MOD;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 50404
L,R=map(int,input().split())
d=R-L
ans=2019

L=L%2019
R=L+d
if d>=2019:
  print(0)
  
else:
  for i in range(L,R+1):
    for j in range(i+1,R+1):
      ans=min(ans,(i*j)%2019)
  print(ans)


Measured memory_bytes: 40940
import numpy as np
from numba import njit

MOD = 1000000007

@njit
def solve(dp, N):
    dp[0, 0] = 8
    dp[0, 1] = 2
    dp[0, 2] = 0
    for i in range(1, N):
        dp[i, 0] = dp[i - 1, 0] * 8 % MOD
        dp[i, 1] = (dp[i - 1, 0] * 2 + dp[i - 1, 1] * 9) % MOD
        dp[i, 2] = (dp[i - 1, 1] + dp[i - 1, 2] * 10) % MOD
    return dp[N - 1, 2]


N = int(input())
dp = np.empty((N, 3), dtype=np.int32)
ans = solve(dp, N)
print(ans)

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


//#define int long long 

int chk(string a, string b) {
	int ans = 0;
	for(int i = 0; i < a.size(); i++) {
		if(a[i] ^ b[i]) ++ans;
	}
	return ans;
}

int32_t main() {
	ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
	string s, t; cin >> s >> t;
	int n = s.size(), m = t.size(), ans = m;
	for(int i = 0; i + m - 1 < n; i++) {
		ans = min(ans, chk(t, s.substr(i, m)));
	}

	cout << ans << endl;
}

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

int main() {
	vector<int> time(5);
	vector<int> vec(5);
	int sum = 0;
	int count = 0;
	
	for (int i = 0; i < 5; i++) {
		cin >> time.at(i);

		if (time.at(i) % 10 != 0)
			vec.at(i) = 10 - time.at(i) % 10;
		else {
			vec.at(i) = 0;
			count++;
		}

		time.at(i) = (time.at(i) / 10) * 10;
		sum += time.at(i);
	}

	sort(vec.begin(), vec.end());
	cout << sum + (5 - count) * 10 - vec.at(4) << endl;
}

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

#define ll long long
#define pb push_back
#define F first
#define S second

ll inf =1e16+10;
const int N=1e2+5 , L = 7;
int n, k;
int w[N];
int v[N];
ll mem[N][10*N*N];

ll dp(int i , ll sum)
{
    if (i == n+1)
        return 0;
    if (sum > k)
        return -inf;

    ll &ret = mem[i][sum];
    ll p1 = 0 , p2 = 0;

    if (ret != -1)
        return ret;

    if (sum + w[i] <=k)
        p1 = v[i] + dp(i+1 , sum+w[i]);
    p2 = dp(i+1 , sum);

    return ret = max(p1 , p2);
}

int main()
{
#ifdef Mohammad
    freopen("input.in","r",stdin);
#endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin >> n >>k;
    for (int i =1; i<=n; i++)
            cin >>w[i] >> v[i];

    memset(mem, -1, sizeof mem);
    cout<<dp(1 , 0);
}


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

class Program
{
    static void Main(string[] args)
    {
        char C = Convert.ToChar(ReadLine());
        int a = (int)C + 1;
        WriteLine((char)a);
    }
}

Measured memory_bytes: 11220
import numpy as np
A,B,H,M = map(int,input().split())
def f(th):
    return np.sqrt(A**2+B**2-2*A*B*np.cos(th))
th1 = (1/30)*M*(np.pi)
th2 = (1/6)*H*(np.pi)+(1/360)*M*(np.pi)
theta = abs(th1-th2)
print(f(theta))

Measured memory_bytes: 27204
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
ld res=0;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;
    cin>>n>>k;
    for(ll i=1;i<=n;i++)
    if(i<=k-1){
        ll t=ceil(log2(1.0*k/i));
        ld sum=1.0/n;
        for(ll j=0;j<t;j++)
        sum/=2.0;
        res+=sum;
    }
    else
    res+=1.0/n;
    cout<<setprecision(100)<<res;
}

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

int main(){
    int N;
    cin >> N ;
    vector<int> B(N);
    int sum = 1;
    for(int i = 0;i < N;i++){
        cin >> B.at(i);
    }
    for(int i = 0;B.at(i) != 2;i = B.at(i) - 1){
        sum++;
        if(sum == N){
            sum = -1;
            break;
    }
    }
        cout << sum << endl;
}

Measured memory_bytes: 640
import java.util.*;


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

		int a[]=new int[5];
		int b[]=new int[5];
		int total=0;
		int min=10;

		for(int i=0;i<5;i++){
			a[i]=sc.nextInt();
		}

		for(int i=0;i<5;i++){
			if(a[i]>=1 && a[i]<=10){
				b[i]=10;
				if(min>a[i]){
					min=a[i];
				}
			}else if(a[i]>=11 && a[i]<=20){
				b[i]=20;
				if(min>a[i]-10){
					min=a[i]-10;
				}
			}else if(a[i]>=21 && a[i]<=30){
				b[i]=30;
				if(min>a[i]-20){
					min=a[i]-20;
				}
			}else if(a[i]>=31 && a[i]<=40){
				b[i]=40;
				if(min>a[i]-30){
					min=a[i]-30;
				}

			}else if(a[i]>=41 && a[i]<=50){
				b[i]=50;
				if(min>a[i]-40){
					min=a[i]-40;
				}
			}else if(a[i]>=51 && a[i]<=60){
				b[i]=60;
				if(min>a[i]-50){
					min=a[i]-50;
				}
			}else if(a[i]>=61 && a[i]<=70){
				b[i]=70;
				if(min>a[i]-60){
					min=a[i]-60;
				}
			}else if(a[i]>=71 && a[i]<=80){
				b[i]=80;
				if(min>a[i]-70){
					min=a[i]-70;
				}
			}else if(a[i]>=81 && a[i]<=90){
				b[i]=90;
				if(min>a[i]-80){
					min=a[i]-80;
				}
			}else if(a[i]>=91 && a[i]<=100){
				b[i]=100;
				if(min>a[i]-90){
					min=a[i]-90;
				}
			}else if(a[i]>=101 && a[i]<=110){
				b[i]=110;
				if(min>a[i]-100){
					min=a[i]-100;
				}
			}else if(a[i]>=111 && a[i]<=120){
				b[i]=120;
				if(min>a[i]-110){
					min=a[i]-110;
				}
			}else if(a[i]>=121 && a[i]<=130){
				b[i]=130;
				if(min>a[i]-120){
					min=a[i]-120;
				}
			}
		}

		for(int i=0;i<5;i++){
			total+=b[i];
		}
		System.out.println(total-(10-min));

	}
}


Measured memory_bytes: 21716
#include <cassert>
#include <cstddef>
#include <utility>

template <class Abelian, template <class T> class Container>
class potentialized_union_find {
	class node_type;

public:
	using value_structure = Abelian;
	using value_type = typename value_structure::value_type;
	using container_type = Container<node_type>;
	using size_type = typename container_type::size_type;

private:
	class node_type {
	public:
		typename potentialized_union_find::size_type par, siz;
		typename potentialized_union_find::value_type val;
	};
protected:
	value_structure vfo;
	container_type c;

private:
	value_type potential(size_type x) {
		value_type ret = vfo.identity();
		while (x != c[x].par) {
			c[x].val = vfo(c[x].val, c[c[x].par].val);
			ret = vfo(ret, c[x].val);
			x = c[x].par = c[c[x].par].par;
		}
		return ::std::move(ret);
	}

public:
	potentialized_union_find() : vfo(), c() {}
	explicit potentialized_union_find(
		const size_type size, const value_structure &x = value_structure())
		: vfo(x), c(size, { 0, 1, vfo.identity() }) {
		for (size_type i = 0; i < size; ++i) {
			c[i].par = i;
		}
	}

	size_type size() const { return c.size(); }
	bool empty() const { return c.empty(); }

	size_type find(size_type x) {
		assert(x < size());
		while (x != c[x].par) {
			c[x].val = vfo(c[x].val, c[c[x].par].val);
			x = c[x].par = c[c[x].par].par;
		}
		return x;
	}
	value_type diff(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		assert(same(x, y));
		return vfo(potential(y), vfo.inverse(potential(x)));
	}
	bool same(const size_type x, const size_type y) {
		assert(x < size());
		assert(y < size());
		return find(x) == find(y);
	}
	size_type size(const size_type x) {
		assert(x < size());
		return c[find(x)].siz;
	}

	::std::pair<size_type, size_type> unite(size_type x, size_type y,
		value_type d) {
		assert(x < size());
		assert(y < size());
		d = vfo(vfo(d, potential(x)), vfo.inverse(potential(y)));
		x = find(x);
		y = find(y);
		if (x != y) {
			if (c[x].siz < c[y].siz) {
				::std::swap(x, y);
				d = vfo.inverse(d);
			}
			c[x].siz += c[y].siz;
			c[y].par = x;
			c[y].val = ::std::move(d);
		}
		return ::std::pair<size_type, size_type>(x, y);
	}
};


template <class T> class plus_abelian {
public:
	using value_type = T;
	value_type operator()(const value_type &x, const value_type &y) const {
		return x + y;
	}
	value_type identity() const { return value_type(0); }
	value_type inverse(const value_type &x) { return -x; }
	value_type reverse(const value_type &x) const { return x; }
};

#include<iostream>
#include<vector>
template<class T>
using vec = ::std::vector<T>;

int main() {
	int n, m;
	::std::cin >> n >> m;
	potentialized_union_find<plus_abelian<int>, vec> T(n);
	while (m--) {
		int l, r, d;
		::std::cin >> l >> r >> d;
		--l;
		--r;
		if (T.same(l, r) && T.diff(l, r) != d) {
			::std::cout << "No" << ::std::endl;
			return 0;
		}
		else {
			T.unite(l, r, d);
		}
	}
	::std::cout << "Yes" << ::std::endl;
	return 0;
}


Measured memory_bytes: 2560
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int N = sc.nextInt();
      int[] A = new int[N];
      long[] sum = new long[N+1];
      sum[0]=0;
for(int i=0;i<N;i++){
  A[i]=sc.nextInt();
  if(i%2==0){
	  sum[i+1]=sum[i]+A[i];
  }else{
      sum[i+1]=sum[i]-A[i];
  }
}
for(int j=0;j<N;j++){
  if(j%2==0){
  System.out.print((sum[N]-2*sum[j])+" ");
  }else{
    System.out.print((2*sum[j]-sum[N])+" ");
  }

}
      

      



    }
  
}


Measured memory_bytes: 70936
#include<stdio.h>
int main(void){
    int n,m,i,j,a,b;
    int A[100][100];
    int B[100]={0};
    int C[100]={0};

    for(i=0;i<100;i++){
        for(j=0;j<100;j++){
            A[i][j]=0;
        }
    }
    scanf("%d %d",&n,&m);
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            scanf("%d",&a);
            A[j][i]=a;
        }
    }
    for(j=0;j<m;j++){
        scanf("%d",&b);
        B[j]=b;
    }
    for(j=0;j<n;j++){
        for(i=0;i<m;i++){
            C[j]=C[j]+A[j][i]*B[i];
        }
    }
    for(i=0;i<n;i++){
        printf("%d\n",C[i]);
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 5e3 + 5;
bool f[N][N] = {0}, g[N][N] = {0};
int a[N];
int main()
{
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
	sort(a + 1, a + n + 1);
	int ans = n;
	for (int i = 1; i <= n; ++i)
	{
		if (a[i] >= k)
		{
			n = i - 1;
			ans = n;
			break;
		}
	}	
 
	for (int i = 0; i <= n + 1; ++i)
		f[i][0] = g[i][0] = true;
 
	for (int j = 1; j < k; ++j)
	{
		for (int i = 1; i <= n; ++i)
		{
			f[i][j] = f[i - 1][j];
			if (j >= a[i])
				f[i][j] |= f[i - 1][j - a[i]];
		}
 
		for (int i = n; i >= 1; --i)
		{
			g[i][j] = g[i + 1][j];
			if (j >= a[i])
				g[i][j] |= g[i + 1][j - a[i]];
		}
	}
 
 	//O(nk)
	for (int i = 1; i <= n; ++i)
	{
		int l = k - 1, x = 0;
		while (l >= 0 and !f[i - 1][l])
			--l;
 
		x = max(x, l);
		for (int r = 1; r < k; ++r)//O(2k) 
		{
			if (!g[i + 1][r])
				continue;
 
			while (l >= 0 and l + r >= k and f[i - 1][l])//r递增 l+r>=k 则l肯定要减小 
				--l;
			x = max(x, l + r);
		}
		if (x >= k - a[i])
		--ans; 
	}
 
	cout << ans << endl;
}


Measured memory_bytes: 49152
import math
import fractions
import copy
import numpy as np
def j(q):
    if q==1: print("POSSIBLE")
    elif q == 0:print("IMPOSSIBLE")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def iprow():
    return [int(i) for i in input().split()]
def printrow(a):
    for i in a:
        print(i)
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

#n = ip()                                     #入力整数1つ
x,y= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(m)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#a.pop(0)は10^5あるときTLEしやすい!注意!抜くなら逆ソート!

a = iprow()

dp = [0]
for i in range(1,x+1):
    dp.append(dp[i-1]+a[i-1])
s = 0
while dp[s] <= y and s<=x-1 :s+=1
if s == x and dp[s]<=y :s+=1
print(s)

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

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

#define INF 0x3fffFFFF

signed main()
{
    int n,m; cin >> n >> m;
    int maxL = 0;
    int minR = INF;
    rep(i,m){
        int l, r; cin >> l >> r;
        maxL = max(maxL, l);
        minR = min(minR, r);
    }
    int ans = max(0,minR-maxL+1);

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
using ll = long long;
using P = pair<int,int>;
using PP = pair<int,pair<int,int>>;
using T = tuple<string,int,int>;
const ll INF = 1LL<<60;
const int ny[4] = {-1,1,0,0}, nx[4] = {0,0,-1,1};
int sy,sx,gy,gx;

int main(){
  int n,k; cin >> n >> k;
  vector<int> l(n);
  rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());
  reverse(l.begin(), l.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans += l[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
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;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};


int main() {
    ll A,B,C;
    cin >>A>>B>>C;
    if(C>=A && C<=B){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }



    return 0;
    

}

Measured memory_bytes: 3576
# https://beta.atcoder.jp/contests/abc102/tasks/abc102_b

if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))

    a_min = 1000000000
    a_max = 0
    for a_i in a:
        a_min = min(a_min, a_i)
        a_max = max(a_max, a_i)

    ans = a_max - a_min
    print(ans)


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

// D - Banned K
int main() {
    long long N;
    cin >> N;

    long long A[N];
    map<long long, long long> noMap;
    for (long long i = 0; i < N; i++) {
        cin >> A[i];
        noMap[A[i]]++;
    }

    long long pairCount = 0;
    for(auto x : noMap) {
        // cout << x.first << " " << x.second << "\n";
        long long count = x.second;
        pairCount += ((count * (count - 1)) / 2);
    }
    // cout << "pairCount:" << pairCount << endl;

    for (long long i = 0; i < N; i++) {
        // cout << A[i] << " : " << noMap[A[i]] << endl;
        cout << (pairCount - noMap[A[i]] + 1) << endl;
    }
}

Measured memory_bytes: 11008
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://onlinejudge.u-aizu.ac.jp/services/room.html#ACPC2018Day2/problems/C>
 問題文============================================================
 =================================================================
 解説=============================================================
 
 長さNの数列Aを循環列として考える。
 
 今回のクエリでのスワップとは、循環列での始点を変更するに等しい
 ================================================================
 */
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N,Q; cin >> N >> Q;
    ll from = 0;
    while(Q--){
        ll com,k; cin >> com >> k;
        if(com == 1){
            from = (from + k)%N;
        }else{
            ll out = (from + k)%N;
            if(out == 0) out = N;
            cout << out << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3208
s=str(input())
q=int(input())
rev=1
rg=[]
lf=[]
for i in range(q):
  l=list(map(str,input().split()))
  if l[0]=='1':
    rev*=-1
  else:
    if l[1]=='1' and rev==1:
      lf.append(l[2])
    elif l[1]=='1':
      rg.append(l[2])
    if l[1]=='2' and rev==1:
      rg.append(l[2])
    elif l[1]=='2':
      lf.append(l[2])
res=[]
if rev==1:
  lf.reverse()
  res=lf+[s]+rg
else:
  rg.reverse()
  ns=list(reversed(s))
  res=rg+ns+lf
print(''.join(res))
  

Measured memory_bytes: 9252
height, width = [int(s) for s in raw_input().split(" ")]
n = int(raw_input())
colorcounts = [int(s) for s in raw_input().split(" ")]
table = [[-1 for c in range(width)] for r in range(height)]


def direction(row):
    return 1 if even(i)else -1


def new_current_column(next_row, width):
    return 0 if even(next_row)else width - 1


def even(i):
    return i % 2 == 0


def nopainted_count(row, current_column, width):
    return width - current_column if even(row)else current_column + 1


def paint(table, row, cc, count, color):
    if even(row):
        table[row][cc:cc + count] = [color + 1] * count
    else:
        table[row][cc - count + 1:cc + 1] = [color + 1] * count


cur_color = 0
for i in xrange(0, height):
    column = new_current_column(i, width)
    while nopainted_count(i, column, width) > colorcounts[cur_color]:
        paint(table, i, column, colorcounts[cur_color], cur_color)
        column += direction(i) * colorcounts[cur_color]
        cur_color += 1
    paint(table, i, column, nopainted_count(i, column, width), cur_color)
    colorcounts[cur_color] -= nopainted_count(i, column, width)
for i in table:
    print " ".join([str(s) for s in i])


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


int main()
{
  int n;
  cin >> n;
  ll ans = 0;
  for (ll i = 1; i <= n; i++)
  {
    ll j = n / i;
    ans += j * i + j * i * (j - 1) / 2;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3576
N = int(input())
S = input()

ascii_uppercase = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

num_to_char = {}
for i, char in enumerate(ascii_uppercase):
    num_to_char[i] = char

char_to_num = {}
for i, char in enumerate(ascii_uppercase):
    char_to_num[char] = i

ans = []
for char in S:
    num = char_to_num[char]
    num = (num + N) % 26
    ans.append(num_to_char[num])

print(*ans, sep="")

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

int main()
{
  int h,n;cin>>h>>n;
  vector<int> a(n);
  int i;
  for(i=0;i<n;i++)cin>>a.at(i);
  int sum=0;
  for(i=0;i<n;i++)sum+=a.at(i);
  if(sum>=h)cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}


Measured memory_bytes: 640
#include<iostream>

int main(){
    
    int a, b, c;
    
    std::cin >> a >> b >> c;
    
    if(a<b){
        if(b<c){
            std::cout << "Yes" << std::endl;
        }
        else{
            std::cout << "No" << std::endl;
        }
    }
    else{
        std::cout << "No" << std::endl;
    }
    
    return 0;
}


Measured memory_bytes: 3088
#include <iostream>
#include <cstdio>
#include <string>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
const long long MOD = 1e9 + 7;
using namespace std;
typedef long long ll;

map<ll, int> mp;
int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, a, b;
	cin >> n >> a >> b;
	string s;
	cin >> s;
	int counter = 0;
	int out = 0;
	for (int i = 0; i < n; i++) {
		if (s.at(i) == 'c') {
			cout << "No" << endl;
		}
		else if (s.at(i) == 'a') {
			if (a + b > counter) {
				cout << "Yes" << endl;
				counter++;
			}
			else {
				cout << "No" << endl;
			}
		}
		else {
			if (a + b > counter && b > out) {
				cout << "Yes" << endl;
				counter++;
				out++;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

Measured memory_bytes: 848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(var, begin, end) for (int var = (begin); var <= (end); var++)
#define RFOR(var, begin, end) for (int var = (begin); var >= (end); var--)
#define REP(var, length) FOR(var, 0, length - 1)
#define RREP(var, length) RFOR(var, length - 1, 0)
#define EACH(value, var) for (auto value : var)
#define SORT(var) sort(var.begin(), var.end())
#define REVERSE(var) reverse(var.begin(), var.end())
#define RSORT(var) SORT(var); REVERSE(var)
#define OPTIMIZE_STDIO ios::sync_with_stdio(false);cin.tie(0);cout.precision(10);cout << fixed
#define endl '\n'

const ll MOD = 1e9 + 7;
struct mint {
    ll x;
    mint() : x(0) {}
    mint(ll x) : x((x % MOD + MOD) % MOD) {}
    mint& operator+=(const mint& r) { if ((x += r.x) >= MOD) { x -= MOD; } return *this; }
    mint& operator-=(const mint& r) { if ((x -= r.x) < 0) { x += MOD; } return *this; }
    mint& operator*=(const mint& r) { if ((x *= r.x) > MOD) { x %= MOD; } return *this; }
    mint& operator++() { if ((++x) >= MOD) { x -= MOD; } return *this; }
    mint operator++(int) { mint ret = x; if ((++x) >= MOD) { x-= MOD; } return ret; }
    mint& operator--() { if ((--x) < 0) { x += MOD; } return *this; }
    mint operator--(int) { mint ret = x; if ((--x) < 0) { x += MOD; } return ret; }
    mint operator+(const mint& r) { mint ret; return ret = x + r.x; }
    mint operator-(const mint& r) { mint ret; return ret = x - r.x; }
    mint operator*(const mint& r) { mint ret; return ret = x * r.x; }
    mint operator-() { return mint() - *this; }
    bool operator<(const mint& a) { return x < a.x; }
    bool operator>(const mint& a) { return x > a.x; }
    bool operator<=(const mint& a) { return x <= a.x; }
    bool operator>=(const mint& a) { return x >= a.x; }
    bool operator==(const mint& a) { return x == a.x; }
    bool operator!=(const mint& a) { return x != a.x; }
};
ostream& operator<<(ostream& os, const mint& r) { os << r.x; return os; }
ostream& operator>>(ostream& os, const mint& r) { os >> r.x; return os; }

void solve(istream& cin, ostream& cout) {
  int a, b;
  cin >> a >> b;
  if (a > 9 || b > 9) {
    cout << -1 << endl;
  } else {
    cout << a * b << endl;
  }
}

#ifndef TEST
int main() {
  OPTIMIZE_STDIO;
  solve(cin, cout);
}
#endif


Measured memory_bytes: 256
#include <iostream>

int main(void){
  int a, b;

  std::cin >> a >> b;
  
  int best = a+b;
  if(best < a-b){
    best = a-b;
  }
  if(best < a*b){
    best = a*b;
  }

  std::cout << best << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repi(i,a,b) for (int i = (a); i < (b); i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vc = vector<char>;
using vvc = vector<vc>;
using vs = vector<string>;

int main() {
  string E, O; cin >> E >> O;
  rep(i,E.size()) {
    cout << E[i];
    if(i < O.size()) cout << O[i];
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fst first
#define snd second
#define fore(i,a,b) for(int i=a,ThxDem=b;i<ThxDem;++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define SZ(n) ((int)(n).size())
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;

double dp[301][301][301];
ll n;
bool done[301][301][301];

double solve(int on, int tw, int th){
    if(on+tw+th==0) return 0;
    double &r = dp[on][tw][th];
    if(done[on][tw][th]) return r;
    done[on][tw][th] = 1;
    double tot = on+tw+th;
    r = (double)n/tot;
    if(on) r += (double)on/tot*solve(on-1,tw,th);
    if(tw) r += (double)tw/tot*solve(on+1,tw-1,th);
    if(th) r += (double)th/tot*solve(on,tw+1,th-1);
    return r;
}

int main(){FIN;
    int x, on=0, tw=0, th=0; cin >> n;
    fore(i,0,n){
        cin >> x;
        on += x==1;
        tw += x==2;
        th += x==3;
    }
    cout << fixed << setprecision(10) << solve(on,tw,th) << "\n";
}

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

#define optimize() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define FOR(i,a,b) for(int i=a; i<= b; ++i)
#define all(v) (v).begin(), (v).end()
#define fi first
#define se second
#define Ld long double

using namespace std;
typedef long long ll;
const int mx = 1001;
const int mod = 1e9+7;
int a[mx];
vector<ll> v;

int main(){
    optimize();
    ll n;
    cin>>n;
    vector<ll> arr(n);
    FOR(i,0,n-1) cin>>arr[i];

    ll sum = 0;
    ll prefixSum[n];

    prefixSum[0] = 0;
    prefixSum[1] = arr[0];
    FOR(i,2,n-1) prefixSum[i] = (prefixSum[i-1]+arr[i-1])%mod;

    FOR(i,0,n-1)
    {
        sum += prefixSum[i]*arr[i];
        sum %= mod;
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 6356
import numpy as np
I=input
N = int(I())
S = np.array(list('-'+I()),dtype='U1')
Q = int(I())
query = map(int,I().split())

isD = S == 'D'
isM = S == 'M'
isC = S == 'C'

cumD = isD.cumsum(dtype=np.int64)
cumM = isM.cumsum(dtype=np.int64)

for K in query:
    x = cumD.copy(); x[K:] -= cumD[:-K]
    x *= isM
    x[K+1:] -= isD[1:-K] * (cumM[K:-1] - cumM[:-K-1])
    print((x.cumsum() * isC).sum())


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

//階乗(nをpで何回割れるか)
/*
1 2 3 4 5 6 7 8 9
  1   2   3   4
      1       2
              1
=> 4+2+1=7 [回]
*/
ll g1(ll n, int p) {
  if (n == 0) return 0;  //再帰終了条件
  return n/p + g1(n/p,p);
}

//２重階乗(nをpで何回割れるか)
//偶数nを2で割ると、n/2!になる
ll g2(ll n, int p) {
  ll res = g1(n/2,p);
  if (p == 2) res += n/2;
  return res;
}

int main() {
  ll n, ans;
  cin >> n;
  if(n%2==0)
    ans = min(g2(n,2), g2(n,5));
  else
    ans = 0;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384