akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;n>i;++i)
using namespace std;
using ll=int64_t;
using pii=pair<int,int>;
using vi=vector<int>;
using vis=vector<string>;
using vvi=vector<vi>;
ll a,b,c,d,n,m,x,y,z,A,B,C,D,cnt=0,ans=0;
//pとqの最大公約数
int gcd(int p,int q){
    if(p%q==0)
    return q;
    return gcd(q,p%q);
}
int main(void){
    cin>>n>>y;
    for(int i=0;n>=i;++i){
        for(int j=0;n>=j;++j){
            if((n-i-j)>=0&&10000*i+5000*j+1000*(n-i-j)==y){
                cout<<i<<" "<<j<<" "<<(n-i-j)<<endl;
                return 0;
            }
        }
    }
    cout<<"-1 -1 -1"<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int N;cin>>N;
    for(int i=0;i<=25;i++){
        for(int j=0;j<10;j++){
            if(N==4*i+j*7){
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
}

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

typedef long long ll;
#define mod 1000000007
#define pb push_back
#define mk make_pair
#define test cout<<"#"
#define precise(x) cout<<fixed<<setprecision(12)<<x
const ll INF = 1e18L + 5;

double dp[3001][3001];

double solve(vector<double> &ar, ll n, ll x)
{
	if(x==0)
		return 1;
	if(n==0)
		return 0;
	if(dp[n][x]>= -0.9) // try not to compare two doubles because of the precision issue.
		return dp[n][x];
	return dp[n][x] = ar[n-1]*solve(ar, n-1, x-1) + (1-ar[n-1])*solve(ar, n-1, x);
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll n;
	cin>>n;
	vector<double> ar(n);
	for(ll x = 0; x < n; x++)
		cin>>ar[x];
	memset(dp, -1, sizeof(dp));
	precise(solve(ar,n,(n+1)/2));
}



Measured memory_bytes: 70912
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <sstream>
#include <functional>
#include <numeric>
#include <cmath>
#include <cstring>
#include <cstdio>
#include <queue>
#include <stack>
#include <set>

using namespace std;

#define ALL(co) co.begin(), co.end()
#define tpl(...) make_tuple(__VA_ARGS__)

typedef long long LL;
typedef pair<int, int> P; typedef pair<int, P> IP; typedef pair<P, P> PP;
typedef vector<int> Array; typedef vector<vector<int> > Array2;
typedef vector<LL> LArray; typedef vector<P> PArray; typedef vector<string> SArray;

const int INF = 1 << 29;
const LL LINF = 1LL << 60;

inline int getInt() { int itiv; return (cin >> itiv, itiv); }
template <typename T> void readAll(vector<T>& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i]; }
template <typename T, typename U> void readAll(vector<pair<T, U> >& vec) { for (int i = 0, size = vec.size(); i < size; i++) cin >> vec[i].first >> vec[i].second; }
template < typename T > inline string toString( const T &a ){ ostringstream oss; oss << a; return oss.str(); };
inline bool between(int min, int max, int n) { return min <= n && n <= max; }
inline bool inRange(int begin, int end, int n) { return begin <= n && n < end; }
inline bool inRange(int size, int n) { return 0 <= n && n < size; }

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

int m, n;

int main(void)
{
	while(cin >> n >> m && n)
	{
		vector<vector<double>> table(n, vector<double>(n));
		vector<vector<double>> dp(m, vector<double>(n));
		for (int i = 0; i < n; i++)
		{
			readAll(table[i]);
		}

		dp[0] = vector<double>(n, 1);
		for (int i = 1; i < m; i++)
		{
			for (int j = 0; j < n; j++)
			{
				for (int k = 0; k < n; k++)
				{
					dp[i][j] = max(dp[i][j], dp[i - 1][k] * table[k][j]);
				}
			}
		}

		printf("%.2f\n", *(max_element(ALL(dp[m - 1]))));
	}
	return 0;
}

Measured memory_bytes: 1356
#include<iostream>
#include<string>
#include<algorithm>
#include<stack>
#include<math.h>
#include<map>
#include <unordered_map> 
#include<vector>
#include<queue>
#include <bits/stdc++.h> 
#include<string>
#define ll long long int
#define N 3001
#define MOD 1e9+7
using namespace std;
string s1,s2;
template <typename T> void max_self(T &a, T b){
	if(b>=a){
		a = b;
	}
}
double dp[N][N];
int main(){
	int n;
	cin>>n;
	double p[n];
	for(int i=0;i<n;i++){
		cin>>p[i];
	}
	dp[0][0] = 1;
	for(int toss = 1; toss<=n; toss++){
		for(int head = 0;head<=toss;head++){
		    if(head>=1)
			dp[toss][head] = dp[toss-1][head-1]*p[toss-1] + dp[toss-1][head]*(1-p[toss-1]);
			else
			dp[toss][head] = dp[toss-1][head]*(1-p[toss-1]);
		}
	}
    double ans =0;
	for(int i=0;i<=n;i++){
		if(i>n-i){
			ans+=dp[n][i];
		}
	}
	
	cout<<setprecision(10)<<ans;
}


Measured memory_bytes: 68992
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define INF 100000000
#define rep(i,s,n) for (int i = (int)(s); i < (int)(n); i++)
#define repp(i,n,s) for (int i= (int)(n); i >= (int)(s); i--)
#define mp make_pair
ll mod = 1000000007;
ll mod2 = 998244353;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    int ans = 1;
    int n;cin>>n;
    vector<pair<ll,ll>> a(n);
    rep(i,0,n){
        int x,y;cin>>x>>y;
        a[i] = mp(y,x);
    }
    sort(a.begin(),a.end());
    ll num = 0;
    rep(i,0,n){
        num += a[i].second;
        if (num>a[i].first){
            ans = 0;
            break;
        }
    }
    if (ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

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


int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);    

    string s;
    cin >> s;
    if (s.find('7') != string::npos)
      cout << "Yes" << endl;
    else
      cout << "No" << endl;
}




Measured memory_bytes: 3640
main :: IO ()
main = do
  [a, b, c] <- words <$> getLine
  putStrLn $ solve a b c

solve :: String -> String -> String -> String
solve a b c = if f1 && f2
              then "YES"
              else "NO"        
  where
    f1 = last a == head b
    f2 = last b == head c


Measured memory_bytes: 380
x, y = map(int, input().split())

group1 = [1, 3, 5, 7, 8, 10, 12]
group2 = [4, 6, 9, 11]
group3 = [2]

if x in group1 and y in group1 or \
   x in group2 and y in group2 or \
   x in group3 and y in group3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#[allow(unused_imports)]
use itertools::Itertools;
#[allow(unused_imports)]
use num::*;
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::collections::*;

fn solve() {
    input! {
        n: usize, k: usize,
        av: [usize; n]
    };

    let iter = av.into_iter().map(|a| a - 1);
    let cusum = vec![0]
        .into_iter()
        .chain(iter)
        .scan(0, |acc, a| {
            *acc = (*acc + a) % k;
            Some(*acc)
        })
        .collect::<Vec<_>>();
    let mut counts = HashMap::new();
    let mut que = VecDeque::new();
    let mut res = 0_u64;
    for r in 0..n + 1 {
        let a = cusum[r];
        res += counts.get(&a).unwrap_or(&0);
        *counts.entry(a).or_insert(0) += 1;
        que.push_back(a);
        if que.len() == k {
            let b = que.pop_front().unwrap();
            *counts.entry(b).or_insert(1) -= 1;
        }
    }
    println!("{}", res);
}

fn main() {
    std::thread::Builder::new()
        .name("big stack size".into())
        .stack_size(256 * 1024 * 1024)
        .spawn(|| {
            solve();
        })
        .unwrap()
        .join()
        .unwrap();
}


Measured memory_bytes: 13392
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


const long long MOD = 998244353;
//* const long long MOD = 5;

//* calculate x^n mod something in O(log n) -- recursive version

ll mod_pow(ll x, ll n, ll mod){
    if(n == 0) return 1;
    ll res = mod_pow((x*x) % mod, n/2, mod);
    if(n &1) res = res * x % mod;
    return res;
}

void solve(long long N, std::vector<long long> D){
    map<ll,ll> rec;
    ll maxD = 0;
    if(D[0]!= 0){
        cout << 0 << endl;
        return;
    }
    if(N == 1){
        cout <<1 << endl;
        return;
    }
    rep(i, N){
        if(!rec.count(D[i]))
            rec[D[i]]=1;
        else
            rec[D[i]]++;
        maxD = max(maxD, D[i]);
    }

    if(!rec.count(0)){
        cout << 0 << endl;
        return;
    }
    else if(rec[0]!= 1){
        cout << 0 << endl;
        return;
    }
    //* check validity
    vll A(maxD+1, 0);
    for(auto x: rec){
        A[x.first] = x.second;
    }
    ll m = A.size();

    ll ans = 1LL;
    rep(i, m-1){
        ans = (ans * mod_pow(A[i], A[i+1], MOD)) % MOD;
    }
    cout << ans << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> D(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&D[i]);
    }
    solve(N, std::move(D));
    return 0;
}


Measured memory_bytes: 8064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using std::cerr;
using std::cin;
using std::cout;
using std::endl;

using namespace std;
typedef long long int64;

template<typename CostType>
/// \brief 辺の情報
struct Edge{
  int      to;
  CostType cost;

  Edge(int t, CostType c): to(t), cost(c){
  }
};

template<typename CostType>
class Graph{

private:

  /// \brief adjacent_list_[n]=ノードnの隣接リストを表すvector<Edge>
  std::vector<std::vector<Edge<CostType>>> adjacent_list_;

public:

  /// \brief 頂点数
  const int NODE_SIZE_;

  /// \brief コンストラクタ
  /// \param node_size 頂点数
  explicit Graph(const int node_size): NODE_SIZE_(node_size),
                                       adjacent_list_(node_size){
  }

  /// \brief 有向グラフの辺を生やす
  /// \param from 辺の根本の頂点の番号
  /// \param to 辺の先の頂点の番号
  /// \param cost 辺のコスト
  void SetDirectedEdge(const int from, const int to, const CostType cost){
    adjacent_list_[from].push_back(Edge<CostType>(to, cost));
  }

  /// \brief 無向グラフの辺を生やす
  /// \param node_a 一方の頂点の番号
  /// \param node_b もう一方の頂点の番号
  /// \param cost 辺のコスト
  void
  SetUndirectedEdge(const int node_a, const int node_b, const CostType cost){
    SetDirectedEdge(node_a, node_b, cost);
    SetDirectedEdge(node_b, node_a, cost);
  }

  /// \brief ある頂点の隣接リストを取得
  /// \param node_num 頂点の番号
  /// \return 隣接リスト
  std::vector<Edge<CostType>> GetAdjacentList(int node_num) const{
    return adjacent_list_[node_num];
  }
};

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  Graph<int> graph(n+1);
  for(int i=0;i<n-1;i++){
    int a,b;
    cin>>a>>b;
    graph.SetUndirectedEdge(a,b,i);
  }

  unordered_set<int> used_col[100001];
  vector<int> result(n-1);
  queue<int> que;
  vector<bool> visited(n+1);
  int used_col_max=0;
  visited[1]=true;
  que.push(1);
  while(!que.empty()){
    int current=que.front();
    que.pop();
    int i=1;
    for(auto e:graph.GetAdjacentList(current)){
      if(!visited[e.to]){
        for(;i<n;i++){
          if(used_col[e.to].find(i)==used_col[e.to].end()&&used_col[current].find(i)==used_col[current].end()){
            used_col[e.to].insert(i);
            used_col[current].insert(i);
            used_col_max=max(used_col_max,i);
            result[e.cost]=i;
            que.push(e.to);
            visited[e.to]=true;
            break;
          }
        }
      }
    }
  }

  cout<<used_col_max<<endl;
  for(int i=0;i<n-1;i++){
    cout<<result[i]<<endl;
  }





  return 0;
}

Measured memory_bytes: 22912
#include <iostream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <cassert>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <algorithm>
#include <utility>
#define llint long long
#define inf 1e18
#define rep(x, s, t) for(llint (x) = (s); (x) < (t); (x)++)
#define Rep(x, s, t) for(llint (x) = (s); (x) <= (t); (x)++)
#define chmin(x, y) (x) = min((x), (y))
#define chmax(x, y) (x) = max((x), (y))
#define mod 1000000007

using namespace std;
typedef pair<llint, llint> P;

llint n;
vector<P> vec;

int main(void)
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	llint u, v;
	for(int i = 1; i <= n-1; i++){
		cin >> u >> v;
		vec.push_back(P(u, v));
	}
	
	llint ans = 0;
	for(llint i = 1; i <= n; i++) ans += i * (n-i+1);
	for(int i = 0; i < vec.size(); i++){
		llint u = vec[i].first, v = vec[i].second;
		if(u > v) swap(u, v);
		ans -= u * (n-v+1);
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 7412
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		String b = sc.next();
		
		int min = a;
		
		int numW = 0;
		int numE = 0;
		
		
		for (int i = 1; i < a; i++) {
			if (b.charAt(i) == 'E') numE++;
		}
		
		min = numE;
		
		for (int i = 1; i < a; i++) {
			int count = 0;
			
			if (b.charAt(i-1) == 'W') {
				numW += 1;
			}
			count+= numW;
			
			if(b.charAt(i) == 'E') {
				numE -= 1;
			}
			count+= numE;
			
			if (count < min) min = count;
		}
		
		System.out.println(min);
		
		
	}	
}


Measured memory_bytes: 28768
def LI():
	return [ int(s) for s in input().split() ]

N,X,Y = LI()
dist = [0]*(N-1)

for i in range(1,N):
  for j in range(i+1,N+1):
    d = min(abs(i-j), abs(i-X)+abs(j-Y)+1)
    dist[d-1]+=1
    
[print(d) for d in dist]

Measured memory_bytes: 3444
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    int v, e, r; cin >> v >> e >> r;
    vector<vector<P>> G(v);
    rep(i, e) {
        int s, t, d; cin >> s >> t >> d;
        G[s].push_back(P(d, t)); // {距離, to頂点}の順で保持
    }

    // Pを保持する昇順の優先度付きキューを作成
    // 始点からつながる頂点に対し、距離が短い辺から順に走査していく
    // ∵ すでに最短経路が確定している頂点vについて、vからの距離が
    //    最短の頂点nvについて考えると、vを経由するよりも短い経路が
    //    存在しないので、最短経路（s=>..=>v=>nv）が確定できる
    priority_queue<P, vector<P>, greater<P>> que;
    vector<int> d(v, INF);
    que.push(P(0, r));
    d[r] = 0;

    while (!que.empty()) {
        // P p として queの先頭の{距離, 頂点}を取得
        P p = que.top(); que.pop();
        int v = p.second;
        // 頂点vからつながるnvについて走査
        for (const auto& nv: G[v]) {
            // 始点=>vまでの距離 + v=>nvの距離 と、d[nv] の大きさを比較する
            // もしd[nv]のほうが小さければ、別により短い経路があるので探索打ち切り
            if (d[v] + nv.first > d[nv.second]) continue;
            else {
                d[nv.second] = d[v] + nv.first;
                que.push(nv);
            }
        }
    }

    rep(i, v) {
        if (d[i]!=INF) cout << d[i] << endl;
        else cout << "INF" << endl;
    }
}


Measured memory_bytes: 28376
#include <bits/stdc++.h>
#define ll long long int
#define N 100
#define f(i, a, b) for (ll i = (ll)a; i <= (ll)b; i++)
#define rf(i, a, b) for (ll i = (ll)a; i >= (ll)b; i--)
#define po pop_back
#define pb push_back
#define lb lower_bound
#define fi first
#define se second
#define debug(x) cout << #x << " = " << x << endl
#define ub upper_bound
#define ibs ios_base::sync_with_stdio(false)
#define cti cin.tie(0)
#define all(x) x.begin(), x.end()
#define PI 3.141592653
#define cot cout.tie(0)
#define endl "\n"
using namespace std;
/**
        * @author :: Sawlani
        *
        */

 

int main()
{
         cout << fixed <<  setprecision(10) ;
        double r;
        cin >> r;
        
         double ans = 2.0*PI*r;

         cout << ans;
}


Measured memory_bytes: 3756
#include<iostream>
#include<cstdio>
#include<algorithm>
#define MAXN 1<<17
using namespace std;
int n, len, l, r; long long cnt,tot;
int a[MAXN], sum[MAXN], t[MAXN], T[MAXN];

void merge_sort(int nl, int nr){
    if (nl == nr) return;
    int mid = (nl + nr) >> 1;
    int p = nl, q = mid+1, now = nl;
    merge_sort(nl, mid);
    merge_sort(mid+1, nr);

    while (p <= mid && q <= nr){
        if (sum[p] < sum[q]){
            T[now++] = sum[p++];
        }
        else {
            tot += (p-nl);
            T[now++] = sum[q++];
        }
    }
    while (p <= mid) T[now++] = sum[p++];
    while (q <= nr) {
        tot += (p-nl);
        T[now++] = sum[q++];
    }
    for (int i = nl;i <= nr;++i){
        sum[i] = T[i];
    }

}

bool check(int ans){
    sum[0] = 0;
    for (int i = 1;i <= n;++i){
        if (a[i] <= ans) sum[i] = sum[i-1]+1;
        else sum[i] = sum[i-1]-1;
    }
    tot = 0;
    merge_sort(0, n);
    return tot >= (cnt/2+1) ;
}

void solve(){
    int mid;
    while (l < r){
        mid = (l+r) >> 1;
        if (check(mid)) r = mid;
        else l = mid+1;
    }
    printf("%d\n", r);
}

void input(){
    scanf("%d", &n);
    l = 1e9+10;
    r = 0;
    for (int i = 1;i <= n;++i){
        scanf("%d", &a[i]);
        r = max(r ,a[i]);
        l = min(l, a[i]);
        cnt += i;
    }
    solve();
}

int main(){
    input();
    return 0;
}

Measured memory_bytes: 1408
package main
import (
  "fmt"
  "os"
  "bufio"
  "strings"
  "strconv"
)
func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Scan()
  s := sc.Text()
  c,_ := strconv.Atoi(s)
  list := strings.Split(s,"")
  ret := 0
  for _,i := range(list) {
    t,_ := strconv.Atoi(i)
    ret = ret + t
  }
  mod := c % ret
  if mod == 0 {
    fmt.Println("Yes")
  } else {
    fmt.Println("No")
  }
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 200005;


int32_t main()
{


    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    IOS


    int l,r,d;
    cin >> l >> r >> d;

    cout << (r/d) - ((l-1)/d);






    return 0;
}


Measured memory_bytes: 3636
n = int(input())
edges = [[] for _ in range(n)]

ans = 0
for i in range(1, n+1):
    ans += (n - i + 1) * (n - i + 2) // 2

for _ in range(n-1):
    u, v = map(int, input().split())
    if u > v:
        u, v = v, u
    ans -= u * (n - v + 1)

print(ans)

Measured memory_bytes: 23172
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
using T = tuple<int, int, int>;

int main() {
    int n, a, b, c, ans = 0;
    cin >> n;
    vector<T> V(n*2);
    for (int i = 0; i < n * 2; i++) {
        scanf("%d %d", &a, &b);
        if (i < n) {
            V[i] = T(a, b, 0);
        } else {
            V[i] = T(a, b, 1);
        }
    }
    sort(V.begin(), V.end());
    set<int> S;
    for (int i = 0; i < n * 2; i++) {
        tie(a, b, c) = V[i];
        if (c == 0) S.insert(b);
        else {
            auto it = S.lower_bound(b);
            if (it != S.begin()) {
                it--;
                S.erase(it);
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Set;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.InputStreamReader;
import java.util.TreeSet;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            List<Set<Integer>> graph = new ArrayList<>();
            for (int i = 0; i < n; i++) {
                graph.add(new TreeSet<>());
            }
            for (int i = 0; i < m; i++) {
                int a = in.nextInt() - 1;
                int b = in.nextInt() - 1;

                graph.get(a).add(b);
                graph.get(b).add(a);
            }

            for (int i = 1; i < n - 1; i++) {
                if (graph.get(i).contains(0) && graph.get(i).contains(n - 1)) {
                    out.println("POSSIBLE");
                    return;
                }
            }

            out.println("IMPOSSIBLE");
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(nextString());
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 103424
p=input()
alp=['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']
q=[i for i, x in enumerate(alp) if x==p]
print(alp[q[0]+1])

Measured memory_bytes: 3060
left, right = map(int, input().split())
mod = 2019

min_mod = float("inf")
for i in range(left, min(right, left + mod)):
    for j in range(i + 1, min(right + 1, i + 1 + mod)):
        curr_mod = i * j % mod
        min_mod = min(min_mod, curr_mod)
        if min_mod == 0:
            break

print(min_mod)


Measured memory_bytes: 3060
#

import itertools
from collections import Counter
from collections import defaultdict
from collections import deque
import bisect
from heapq import heappush, heappop

def main():
    s = input()
    ans = []

    def create(l, r):
        left = [0] * (r - 1)
        right = [0] * (l - 1)
        total = r + l
        if total % 2 == 0:
            return left + [total // 2, total // 2] + right
        else:
            gat = max(l, r) - 1
            if gat % 2 == 0:
                if r > l:
                    return left + [total // 2 + 1, total // 2] + right
                else:
                    return left + [total // 2, total // 2 + 1] + right
            else:
                if r > l:
                    return left + [total // 2, total // 2 + 1] + right
                else:
                    return left + [total // 2 + 1, total // 2] + right
    r = 0
    l = 0
    for c in s:
        if c == 'R':
            if l > 0:
                ans += create(l, r)
                r = 0
                l = 0
            r += 1
        else:
            l += 1

    if l > 0:
        ans += create(l, r)
    print(' '.join(map(str, ans)))


if __name__ == '__main__':
    main()


Measured memory_bytes: 11452
#include <cstdio>
const int M = 3;
const int MAXX = 1e6+5;
const int MOD = 1e9+7;
int F[MAXX];
int X, Y;

/*
1........
..1......
.1..1....
...2..1..
..1..3..1
....3..4.
...1..6..
.....4..A
*/

int extended_gcd(int a, int b, int s, int t) {
    if (!b) {
        return s;
    }
    int q = a / b;
    return extended_gcd(b, a - q * b, t, s - q * t);
}

int mmi(int a) {
    int res = extended_gcd(a, MOD, 1, 0);
    if (res < 0) res += MOD;
    return res;
}

int solve() {
    if (((X + Y) % M) != 0) {
        return 0;
    }
    if ((2 * X < Y) || (2 * Y < X)) {
        return 0;
    }
    int N = (X + Y) / M;
    int R = X - N;
    F[0] = 1;
    for (int i = 1; i <= N; ++i) {
        F[i] = 1LL * F[i-1] * i % MOD;
    }
    int bot = 1LL * F[R] * F[N-R] % MOD;
    int ncr = 1LL * F[N] * mmi(bot) % MOD;
    return ncr;
}

int main() {
    scanf(" %d%d", &X, &Y);
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 2816
#include <algorithm>
#include <bitset>
#include <complex>
#include <cstdio>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;

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

typedef long long ll;

const int Inf = 100100100;
const double EPS = 1e-9;

int gcd(int a, int b) {
    if (b == 0) {
        return a;
    } else {
        return gcd(b, a % b);
    }
}

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, k;  cin >> n >> k;
    ll a = n / k;
    if (k % 2) {
      cout << a * a * a << '\n';
    } else {
      ll b = (n + (k / 2)) / k;
      cout << a * a * a + b * b * b << '\n';
    }

    return 0;
}


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

#define ll long long

int n, D; ll X, a[55], b[55];
vector<int>G[55];

const int M=130000;
ll f[M+10];

void additem(ll a,ll b){
    for (int i=M;i>=b;--i)
        f[i]=min(f[i],f[i-b]+a);
}

void doit(){
    memset(f,33,sizeof f);
    f[0]=0;
    for (int w=1;w<=n;++w){
        int c= (w==1? 50: min(D,50));
        while (c){
            int t=c+1>>1;
            additem(a[w]*t,b[w]*t);
            c-=t;
        }
    }
}

void dfs(int x){
    for (auto y:G[x]){
        dfs(y);
        a[x]+=a[y];
        b[x]+=b[y];
    }
}

ll ans=0;

void gao(int bas){
    ll las=X-f[bas];
    if (las<0) return;
    int id[55];
    for (int i=1;i<=n;++i) id[i]=i;
    sort(id+1,id+n+1,[=](int i,int j){ return a[i]*b[j]<a[j]*b[i]; });
    ll res=bas;
    for (int it=1;it<=n;++it){
        int i=id[it], c=(i==1? 1e9: D-min(D,50));
        int t=min((ll)c,las/a[i]);
        res+=t*b[i];
        las-=t*a[i];
    }
    ans=max(ans,res);
}

int main(){
    cin>>n>>X>>D;
    for (int i=1;i<=n;++i){
        cin>>a[i]; b[i]=1;
        if (i!=1){
            int fa; cin>>fa;
            G[fa].push_back(i);
        }
    }
    dfs(1);
    doit();
    for (int i=0;i<=M;++i)
        gao(i);
    cout<<ans<<endl;
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)

bool is_odd(const vector<int>& v) {
    int n = v.size(), x = 0;
    for_(i,0,n) if (((n - 1) & i) == i) x ^= (v[i] & 1);
    return x;
}

int main() {
    int N;
    string S;
    cin >> N;
    cin >> S;

    vector<int> v;
    for_(i,0,N) v.push_back(int(S[i] - '0') - 1);

    if (is_odd(v)) cout << 1 << endl;
    else if (find(v.begin(), v.end(), 1) != v.end()) cout << 0 << endl;
    else {
        for_(i,0,N) v[i] /= 2;
        if (is_odd(v)) cout << 2 << endl;
        else cout << 0 << endl;
    }
}

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

using namespace std;

void printArray(vector<int> v, char c)
{	
	for(int i = 0; i < v.size(); i++)
		if(v[i] == 0)
			cout << c << " " << i+1 << "\n";
}

int main()
{
	vector<int> S(13, 0);
	vector<int> H(13, 0);
	vector<int> C(13, 0);
	vector<int> D(13, 0);
	int n, m;
	char c;
	
	scanf("%d", &n);
	
	for(int i = 0; i < n; i++)
	{
		cin >> c >> m;
		
		if(c == 'S')
			S[m-1] = 1;
		else if(c == 'H')
			H[m-1] = 1;
		else if(c == 'C')
			C[m-1] = 1;
		else
			D[m-1] = 1;
	}
	
	printArray(S, 'S');
	printArray(H, 'H');
	printArray(C, 'C');
	printArray(D, 'D');
	
	return 0;
}


Measured memory_bytes: 3236
using System;

public class Program
{
	public static void Main(string[] args)
	{
		var ss = new StreamScanner();
		//---------------------------------
		while (true)
		{
			var y = ss.Next<int>();
			var x = ss.Next<int>();

			if (x == 0 && y == 0)
			{
				break;
			}

			for (int j = 0; j < y; j++)
			{
				for (int i = 0; i < x; i++)
				{
					if (j == 0 || j == (y - 1))
					{
						Console.Write("#");
					}
					else if (i== 0 || i == (x-1) )
					{
						Console.Write("#");
					}
					else
					{
						Console.Write(".");
					}
				}
				Console.WriteLine("");
			}
			Console.WriteLine("");
		}

		/*
		//????????????int, double, string?????????????????£????????????
		int i = ss.Next<int>();
		double d = ss.Next<double>();
		string s = ss.Next<string>();

		//?????°???????????????????????¨?????????????????????????????????????????????????´???????
		int[] array = ss.Next<int>(10);
		*/
		//---------------------------------
	}
}



public class StreamScanner
{
	private readonly char[] _c = { ' ' };
	private int _index = -1;
	private string[] _input = new string[0];
	private readonly System.IO.StreamReader _sr = new System.IO.StreamReader(Console.OpenStandardInput());

	public T Next<T>()
	{
		if (_index == _input.Length - 1)
		{
			_index = -1;
			while (true)
			{
				string rl = _sr.ReadLine();
				if (rl == null)
				{
					if (typeof(T).IsClass) return default(T);
					return (T)typeof(T).GetField("MinValue").GetValue(null);
				}
				if (rl != "")
				{
					_input = rl.Split(_c, StringSplitOptions.RemoveEmptyEntries);
					break;
				}
			}
		}
		return (T)Convert.ChangeType(_input[++_index], typeof(T), System.Globalization.CultureInfo.InvariantCulture);
	}

	public T[] Next<T>(int x)
	{
		var ret = new T[x];
		for (var i = 0; i < x; ++i) ret[i] = Next<T>();
		return ret;
	}

	public T[][] Next<T>(int x, int y)
	{
		var ret = new T[y][];
		for (var i = 0; i < y; ++i) ret[i] = Next<T>(x);
		return ret;
	}
}

Measured memory_bytes: 9872
// This is my template for fast solving
 
#include <iostream>
#include <fstream>
#include <sstream>
#include <algorithm>
#include <utility>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cmath>
#include <queue>
#include <memory>
#include <initializer_list>
#include <iomanip>
#include <stack>
#include <bitset>
#include <cstdio>
// #include <complex>
// #include <random>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;

// const ll INF = 1e18;
// const ld INF = 1e20;
const ll MOD = 998244353;
// const ld EPS = 1e-10;
// const ld PI = acos(-1);

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
    os << p.first << " " << p.second;
    return os;
}

template<typename T1, typename T2>
istream& operator>>(istream& is, pair<T1, T2>& p) {
    is >> p.first >>  p.second;
    return is;
}
 
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    bool first = true;
    for (const auto& x : v) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T>
istream& operator>>(istream& is, vector<T>& v) {
    for (auto& elem : v) {
        is >> elem;
    }
    return is;
}

template<typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
    bool first = true;
    for (auto x : s) {
        if (!first) {
            os << " ";
        }
        first = false;
        os << x;
    }
    return os;
}

template<typename T1, typename T2>
ostream& operator<<(ostream& os, const map<T1, T2>& m) {
    bool first = true;
    for (auto x : m) {
        if (!first) {
            os << "\n";
        }
        first = false;
        os << x;
    }
    return os;
}

void solve() {
    ll k, n;
    cin >> k >> n;
    vector<ll> a(n);
    cin >> a;
    ll ans = k - (a[0] + (k - a[n - 1]));
    for (int i = 0; i < n - 1; ++i) {
        ans = min(ans, k - (a[i + 1] - a[i]));
    }
    cout << ans << "\n";
}
 
int main() {
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    // int t; // CodeJam style
    // cin >> t;
    // for (int i = 1; i <= t; ++i) {
    //     cout << "Case #" << i << ": ";
    //     solve();
    // }
 
    // int q;
    // cin >> q;
    // while (q--) {
    //     solve();
    // }

    solve();
 
    return 0;
}

Measured memory_bytes: 1792
import java.io.PrintWriter
val pw = PrintWriter(System.out)

fun main(args : Array<String>) {
    func()
    pw.flush()
}

fun func() {
    val n = nextInt()
    val bb = listOfInt()
    val ans = mutableListOf<Int>()

    ans.add(bb[0])

    bb.forEachIndexed{ index, b ->
        ans.add(b)
        if (index > 0 && ans[index] > b) ans[index] = b
    }

    println(ans.sum())
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { it.toInt() }

fun println(value : Any) {
    pw.println(value)
}

Measured memory_bytes: 37860
#include <stdio.h>
int main()
{
	int i,N;
	int a[]={19,29,39,49,59,69,79,89,90,91,92,93,94,95,96,97,98,99};
	scanf("%d",&N);
	if(N==a[0]||N==a[1]||N==a[2]||N==a[3]||N==a[4]||N==a[5]||N==a[6]||N==a[7]||N==a[8]||N==a[9]||N==a[10]||N==a[11]||N==a[12]||N==a[13]||N==a[14]||N==a[15]||N==a[16]||N==a[17])
	  printf("Yes");
	else 
	  printf("No");
	 return 0;
}

Measured memory_bytes: 128
#from collections import defaultdict
N = int(input())
s = ["".join(sorted(input())) for i in range(N)]

#print(s)
#d = defaultdict(int)
d = dict()

ans = 0
for key in s:
    if key not in d:
        d[key] = 0
    else:
        ans += d[key]    
    d[key] += 1

#print(d)
print(ans)


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

int main(){
  int a[4];
  rep(i,4){a[i]=0;}
  string s;
  cin >> s;
  int q=s.size();
  rep(i,q){
    if(s[i]=='N')a[0]++;
    if(s[i]=='W')a[1]++;
    if(s[i]=='S')a[2]++;
    if(s[i]=='E')a[3]++;
  }
  bool ans=1;
  if(a[0]>0 && a[2]==0 || a[0]==0 && a[2]>0){ans=0;}
  if(a[1]>0 && a[3]==0 || a[1]==0 && a[3]>0){ans=0;}
  if(ans){cout << "Yes" << endl;}else{cout << "No" << endl;}
}

Measured memory_bytes: 256
def getInt(): return int(input())

class Debug():
    def __init__(self):
        self.debug = True
 
    def off(self):
        self.debug = False
 
    def dmp(self, x, cmt=''):
        if self.debug:
            if cmt != '':
                w = cmt + ': ' + str(x)
            else:
                w = str(x)
            print(w)
        return x

def color(start, tiles):
    count = 0
    for i in range(len(tiles)):
        if i % 2 == 0 and tiles[i] != start:
            count += 1
        elif i % 2 == 1 and tiles[i] == start:
            count += 1
    return count


def prob():
    d = Debug()
    d.off()
    S = input()
    count1 = color('0', S)
    count2 = color('1', S)
    d.dmp((count1,count2),'count1,count2')
    return min(count1, count2)

ans = prob()
print(ans)

Measured memory_bytes: 3316
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

const int SIZE = 1000;

void print(char *str)
{
	int begin, end;

	scanf("%d %d", &begin, &end);
	for(int i = begin;  i <= end; i++) {
		putchar(str[i]);
	}
	putchar('\n');
}

void reverse(char *str)
{
	int begin, end;
	char tmp;

	scanf("%d %d", &begin, &end);
	for(int i = begin, j = end; i < j; i++, j--) {
		tmp = str[i];
		str[i] = str[j];
		str[j] = tmp;
	}
}

void replace(char *str)
{
	int begin, end;
	char c;
	char pattern[SIZE+1];

	scanf("%d %d", &begin, &end);
	scanf("%s",  pattern);

	for(int i = begin; i <= end; i++) {
		str[i] = pattern[i-begin];
	}
}

int main()
{
	const int LEN = 10;

	char buf[SIZE + 1];
	char cmd[LEN + 1];
	int q;

	scanf("%s", buf);
	scanf("%d", &q);
	for(int i = 0; i < q; i++) {
		scanf("%s", cmd);
		if(strcmp("replace", cmd) == 0) {
			replace(buf);
		} else if(strcmp("print", cmd) == 0) {
			print(buf);
		} else if(strcmp("reverse", cmd) == 0) {
			reverse(buf);
		}
	}

	return 0;
}

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

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

    if (A == B) {
        cout << C << endl;
    } else if (B == C) {
        cout << A << endl;
    } else {
        cout << B << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
//#include <bits/stdc++.h>
#include<vector>
#include<float.h>
#include<iomanip>
#include<algorithm>
#include<string>
#include<cstring>
#include<math.h>
#include<cmath>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include <cassert>
#include <cmath>
#include<cstdint>

#define INF 1e9
#define rep(i,n)for(int i=0;(i)<(int)(n);i++)
#define REP(i,a,b)for(int i=(int)(a);(i)<=(int)(b);i++)
#define VEC(type, c, n) std::vector<type> c(n);for(auto& i:c)std::cin>>i;
#define vec(type,n) vector<type>(n)
#define vvec(m,n) vector<vector<int>> (int(m),vector<int>(n))
#define ALL(a)  (a).begin(),(a).end()

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

vector<int>bitSearch(int bit,int n){
    vector<int>S;
    rep(i,n)if(bit&(1<<i))S.push_back(i);
    return S;
}

int gcd(int a,int b){
    if(a%b==0)return b;
    else return gcd(b,a%b);
}

int main(){
    int n,s;cin>>n>>s;
    vector<int>diff(n);
    rep(i,n){
        int x;cin>>x;
        diff[i] = abs(s-x);
    }
    int res = diff[0];
    REP(i,1,n-1){
        res = gcd(res,diff[i]);
    }
    cout<<res;
}



Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <functional>
#include <numeric>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <iomanip>
#include <bitset>
#include <queue>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0;i < n;i++)
const long long INF = 1LL << 60;

int MOD = 1000000007;

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

    int n; cin>>n;
    int ans=0;
    rep(i,n){
        int a; cin>>a;
        ans+=a-1;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <random>
#include <string.h>
#include <cmath>
#include <unordered_map>
#include <cstdio>
using namespace std;
#define all(vec) vec.begin(),vec.end()
typedef long long ll;

ll gcd(ll x, ll y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
ll lcm(ll x, ll y) {
	return x / gcd(x, y)*y;
}
ll kai(ll x, ll y, ll m) {
	ll res = 1;
	for (ll i = x - y + 1; i <= x; i++) {
		res *= i; res %= m;
	}
	return res;
}
ll mod_pow(ll x, ll y, ll m) {
	ll res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

ll comb(ll x, ll y, ll m) {
	if (y > x)return 0;
	return kai(x, y, m) * mod_pow(kai(y, y, m), m - 2, m) % m;
}

int x;
int cnt[10000010];
ll ans;

signed main() {
	cin >> x;
	for (int i = 1; i <= x; i++)for (int j = i; j <= x; j += i)cnt[j]++;
	for (ll i = 1; i <= x; i++)ans += i * cnt[i];
	cout << ans << endl;
}

Measured memory_bytes: 42680
N = int(input())
S = [input() for i in range(N)]
a = w = t = r = 0
for s in S:
    c = s[0]
    if c=='A':
        a += 1
    elif c=='W':
        w += 1
    elif c=='T':
        t += 1
    else:
        r += 1
print('AC x ' + str(a))
print('WA x ' + str(w))
print('TLE x ' + str(t))
print('RE x ' + str(r))

Measured memory_bytes: 16244
#include <iostream>
#include <stdio.h>
#include <iomanip>
//#include <vector>
//#include <string>
//#include <algorithm>
//#include <functional>

using namespace std;

int main(){

	int a, b, c, d, e, f;
	double x, y, A;

	while(cin >> a >> b >> c >> d >> e >> f){
		A = a*e - b*d;
		x = (double)((e*c - b*f) / A);
		y = (double)((a*f - d*c) / A);
		if (x == 0)x = 0;
		if (y == 0)y = 0;
		printf("%.3f %.3f\n", x , y );
	}



	return 0;
}

Measured memory_bytes: 1192
#include <stdio.h>
#include <stdlib.h>

void insertionSort(int *, int, int);
void shellSort(int *, int);

int cnt, m, G[100];

int main(){
  int i, n, *A;

  scanf("%d",&n);

  A = malloc(sizeof(int)*n);

  for(i = 0; i < n; i++) scanf("%d",&A[i]);

  shellSort(A,n);

  printf("%d\n",m);
  for(i = m-1; i >= 0; i--){
    printf("%d",G[i]);
    if(i != 0) printf(" ");
  }
  printf("\n%d\n",cnt);
  for(i = 0; i < n; i++) printf("%d\n",A[i]);

  free(A);

  return 0;
}

void insertionSort(int *A, int n, int g){
  int i, j, v;
  for(i = g; i < n; i++){
    v = A[i];
    j = i - g;
    while(j >= 0 && A[j] > v){
      A[j+g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j+g] = v;
  }
}

void shellSort(int *A, int n){
  int i = 0;
 
  cnt = 0;
  G[i] = 1;
  
  while(i < 100){
    if(G[i] > n){
      m = i;
      break;
    }
    if(i < 99){
      G[i+1] = G[i] * 3 + 1;
      i++;
    }
  }
  
  for(i = m-1; i >= 0 ; i--){
    insertionSort(A, n, G[i]);
  }
}


Measured memory_bytes: 5524
#include<cstdio>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<map>
#include<queue>
#include<vector>
#define ll long long
#define maxn 200010
inline ll read()
{
	ll x=0; char c=getchar(),f=1;
	for(;c<'0'||'9'<c;c=getchar())if(c=='-')f=-1;
	for(;'0'<=c&&c<='9';c=getchar())x=x*10+c-'0';
	return x*f;
}
inline void write(ll x)
{
	static int buf[20],len; len=0;
	if(x<0)x=-x,putchar('-');
	for(;x;x/=10)buf[len++]=x%10;
	if(!len)putchar('0');
	else while(len)putchar(buf[--len]+'0');
}
inline void writeln(ll x){write(x); putchar('\n');}
inline void writesp(ll x){write(x); putchar(' ');}
int a[maxn],nxt[maxn],pos[maxn],dep[maxn];
ll n,k;
void print(int s)
{
	static int mark[maxn],ans[maxn],tot;
	memset(mark,0,sizeof(mark));
	tot=0;
	for(int i=s;i<=n;i++)
		if(!mark[a[i]])mark[a[i]]=1,ans[++tot]=a[i];
		else{
			while(ans[tot]!=a[i])mark[ans[tot--]]=0;
			mark[ans[tot--]]=0;
		}
	for(int i=1;i<=tot;i++)
		writesp(ans[i]);
	putchar('\n');
}
int main()
{
	n=read(); k=read();
	for(int i=1;i<=n;i++)
		a[i]=read();
	for(int i=n;i;i--)
		pos[a[i]]=i;
	for(int i=n;i;i--){
		nxt[i]=pos[a[i]];
		pos[a[i]]=i;
	}
	// for(int i=1;i<=n;i++)
	// 	printf("%d %d %d\n",i,a[i],nxt[i]);
	int now=nxt[1]%n+1,len=(nxt[1]<=1)+(nxt[1]==n);
	while(now!=1){
		// puts("QAQ");
		len+=(nxt[now]<=now)+(nxt[now]==n);
		now=nxt[now]%n+1;
	}
	// writeln(len);
	k=(k-1)%len;
	now=1; len=(nxt[1]<=1);
	if(len>k){
		print(now);
		return 0;
	}
	len+=(nxt[1]==n);
	if(len>k){
		print(n+1);
		return 0;
	}
	now=nxt[now]%n+1;
	while(now!=1){
		// puts("TAT");
		len+=(nxt[now]<=now);
		if(len>k){
			print(now);
			return 0;
		}
		len+=(nxt[now]==n);
		if(len>k){
			print(n+1);
		}
		now=nxt[now]%n+1;
	}
	return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string S;
    cin >> S;
    long long int Q,count=0;
    cin >> Q;
    for(int i=0;i<Q;i++){
        int t;
        cin >> t;
        if(t==1){
            count++;
        }else{
            int f;
            string c;
            cin >> f >> c;
            if(count%2==1){
                if(f==1){
                    S += c;
                }else{
                    S.insert(0,c);
                }
            }else{
                if(f==1){
                    S.insert(0,c);
                }else{
                    S += c;
                }
            }
        }
    }

    if(count%2==0){
        cout << S << endl;
    }else{
        reverse(S.begin(),S.end());
        cout << S << endl;
    }
}


Measured memory_bytes: 912
#include<iostream>
#include<cstdio>
#include<map>
#include<cstring>
using namespace std;
map<string,int>aaa;
char ss[1005];
string bb;
int main()
{
    while(~scanf("%s",ss))
    {
        int len = strlen(ss);
        int i = 0;
        aaa.clear();
        for(;i<len;i++)
        {
            bb = ss[i];
            if(aaa.find(bb) != aaa.end())
            {
                cout<<"no"<<endl;
                break;
            }
            aaa[bb]++;
        }
        if(i>=len)
        {
            cout<<"yes"<<endl;
        }
    }
    return 0;

}


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

int main() {
 int n;
 cin >>n;
 vector<long long> a(n+1);
 a.at(0)=2;
 a.at(1)=1;
 for(int i=2;i<=n;i++){
     a.at(i)=a.at(i-2)+a.at(i-1);
 }
 cout << a.at(n) << endl;
}


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

//7,77,777...という数列の何項目に初めてKの倍数が現れるか
//0検出⇒割り切れる(ループ脱出)、同じあまり検出⇒循環するので割り切れない(ループ脱出)の順序で
int main(){
    int K;
    cin >> K;
    bool* found_mod = new bool[K];
    for(int i=0;i<K;++i){
        found_mod[i]=false;
    }

    int mod=7;
    for(int i=0;i<K;++i){
        mod = mod % K;
        if(mod == 0){
            cout << (i+1) << endl;
            break;
        }
        if(found_mod[mod]){
            cout << -1 << endl;
            break;
        } else {
            found_mod[mod] = true;
        }
        mod = mod*10 + 7;
    }
    delete[] found_mod;
}

Measured memory_bytes: 4244