akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

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

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

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

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

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

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

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

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

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    n: usize,
    a: usize,
    xs: [usize; n],
  }
  let max_w = 51 * n;
  let mut dp = vec![vec![vec![0i64; max_w]; n + 1]; n + 1];
  dp[0][0][0] = 1;
  for (i, &x) in xs.iter().enumerate() {
    for count in 0 .. n + 1 {
      for w in 0 .. max_w {
        dp[i+1][count][w] += dp[i][count][w];
        if let Some(v) = w.checked_sub(x) {
          if count > 0 {
            dp[i+1][count][w] += dp[i][count-1][v];
          }
        }
      }
    }
  }
  let mut ans = 0;
  for count in 1 .. n + 1 {
    ans += dp[n][count][a * count];
  }

  puts!("{}\n", ans);
}


Measured memory_bytes: 67836
#include <iostream>
#include <vector>
#include <utility>
#define llint long long
#define inf 1e18

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

struct SegTree{
	llint size;
	vector<P> seg;
	
	SegTree(){}
	SegTree(llint size){
		this->size = size;
		seg.resize(1<<(size+1));
	}
	
	void init()
	{
		for(llint i = 0; i < (1<<(size+1)); i++) seg[i] = make_pair(-inf, -inf);
	}
	
	void update(llint i, P val)
	{
		i += (1 << size);
		seg[i] = val;
		while(i > 1){
			i /= 2;
			seg[i] = max(seg[i*2], seg[i*2+1]);
		}
	}

	P query(llint a, llint b, llint k, llint l, llint r)
	{
		if(b < l || r < a) return make_pair(-inf, -inf);
		if(a <= l && r <= b) return seg[k];
		P lval = query(a, b, k*2, l, (l+r)/2);
		P rval = query(a, b, k*2+1, (l+r)/2+1, r);
		return max(lval, rval);
	}
	P query(llint a, llint b)
	{
		return query(a, b, 1, 0, (1<<size)-1);
	}
};

llint N, M;
llint A[5005];
llint sumA[5005];
llint cost[5005][5005];
SegTree seg[205];

void calc(llint m, llint l, llint r)
{
	if(l > r) return;
	
	P opt = seg[m].query(l, r);
	cost[l][opt.second] += opt.first;
	cost[opt.second+1][r+1] += opt.first;
	cost[l][r+1] -= opt.first;
	cost[opt.second+1][opt.second] -= opt.first;
	
	calc(m, l, opt.second-1);
	calc(m, opt.second+1, r);
}

int main(void)
{
	cin >> N >> M;
	for(int i = 1; i <= N-1; i++) cin >> A[i];
	for(int i = 1; i <= N-1; i++) sumA[i] = sumA[i-1] + A[i];
	
	for(int i = 1; i <= M; i++) seg[i] = SegTree(13);
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= M; j++){
			int B;
			cin >> B;
			seg[j].update(i, make_pair(B, i));
		}
	}
	
	for(int i = 1; i <= M; i++){
		calc(i, 1, N);
	}
	
	
	for(int i = 1; i <= N; i++){
		llint sum = 0;
		for(int j = 1; j <= N; j++){
			sum += cost[i][j];
			cost[i][j] = sum + cost[i-1][j];
		}
	}
	
	llint ans = -inf;
	for(int i = 1; i <= N; i++){
		for(int j = 1; j <= N; j++){
			if(i > j) continue;
			ans = max(ans, cost[i][j] - (sumA[j-1] - sumA[i-1]));
		}
	}
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 247936
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#define MOD 1000000007
typedef long long ll;
using namespace std;

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

  if(k==1){
    cout<<0<<endl;
    return 0;
  }

  n-=k;

  cout<<n<<endl;

  return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque
from collections import  Counter
import statistics
import math

stdin = sys.stdin

ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

n = ni()
s = input()
cnt_w = s.count("W")
cnt_e = n - cnt_w
l = 0
r = cnt_e
ans = n
for i in range(n):
    if s[i] == "E":
        r -= 1
        ans = min(ans, l + r)
    else:
        ans = min(ans, l + r)
        l += 1
print(ans)


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

int main() {
    int N; cin >> N;
    vector<int64_t> B(N - 1);
    for (int i = 0; i < N - 1; i++) cin >> B.at(i);

    int64_t res = B.at(0) + B.back();
    for (int i = 0; i + 1 < B.size(); i++) {
        res += min(B.at(i), B.at(i + 1));
    }
    cout << res << endl;
}

Measured memory_bytes: 3588
#include <iostream>
 #include <vector>
 
 using namespace std;
 
 bool search(vector<int> & S, int s, int b, int e)
 {
 	int m = (e + b) /2;
 	if (m<b) return false;
 	int _s = S[m];
 	if (s ==_s) return true;
 	if (b==e) return false;
 	if (_s>s) return search(S,s,b,m-1);
 	if (_s<s) return search(S,s,m+1,e);
 }
 
 int main()
{
	int n;
	cin >> n;
	vector<int> S(n);
	for (auto &s:S) cin >> s;
	int q;
	cin >> q;
	int C =0;
	while(q--)
	{
		int t; 
		cin >> t;
		if (search(S,t,0,n-1)) C++;
	}
	cout << C << endl;
}

Measured memory_bytes: 1524
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n)  for(int i=0;i<(n);++i)
#define ALL(x) (x).begin(),(x).end()
ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}

int main() {
  int N;
  cin >> N;
  vector<float> x(N);
  vector<string> u(N);
  REP(i, N) {
    cin >> x.at(i) >> u.at(i);
  }
  float sum = 0;
  REP(i, N) {
    if (u.at(i) == "JPY") {
      sum += x.at(i);
    }
    else {
      sum += x.at(i) * 380000.0;
    }
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
program test;

var 
    cnt, t, i, n, m : integer;
    a : array[1..1005] of integer;
begin
    readln(n, m);
    t:=0;
    for i:=1 to n do begin
        read(a[i]);
        t := t+a[i]
    end;
    for i:=1 to n do begin
        if (a[i] >= 1/4/m*t) then cnt := cnt + 1;
    end;
    if cnt >= m then writeln('Yes') else writeln('No');

end.


Measured memory_bytes: 1376
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define MAX (1 << 29)
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

using Pi = pair<int, int>;
using ll = long long;
const int INF = 1 << 28;

string to_string(string s) { return s; }

template <class S, class T>
string to_string(pair<S, T> p) {
  return "{" + to_string(p.first) + "," + to_string(p.second) + "}";
}

template <class S>
string to_string(unordered_set<S> s) {
  string ret = "{";
  for (S x : s) ret += to_string(x);
  return ret + "}";
}

template <class S, class T>
string to_string(map<S, T> m) {
  string ret = "{";
  for (pair<S, T> x : m) ret += to_string(x);
  return ret + "}";
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  for (int i = 0; i < v.size() - 1; ++i) {
    ret += to_string(v[i]) + ",";
  }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() { cerr << endl; }

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() { cout << endl; }

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

void get() {}

template <class Head, class... Tail>
void get(Head& head, Tail&... tail) {
  cin >> head;
  get(tail...);
}

template <class T>
void getv(vector<T>& vec) {
  for (int i = 0; i < vec.size(); ++i) cin >> vec[i];
}

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  vector<vector<int>> G(N);
  FOR(i, N) {
    cin >> S[i];
    FOR(j, N) if (S[i][j] == '1') G[i].push_back(j);
  }
  int ans = -1;
  FOR(i, N) {
    queue<int> q;
    vector<int> color(N, -1);
    q.push(i);
    color[i] = 1;
    bool f = 1;
    while (f && !q.empty()) {
      int v = q.front();
      q.pop();
      for (int x : G[v]) {
        if (color[x] == -1) {
          q.push(x);
          color[x] = color[v] + 1;
        } else {
          if (abs(color[x] - color[v]) != 1) {
            f = 0;
            break;
          }
        }
      }
    }
    if (f) ans = max(ans, *max_element(ALL(color)));
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 512
def inpl(): return list(map(int, input().split()))

N = int(input())
h = inpl()

dp = [0]*N + [float('inf')]
for i in range(1, N):
    dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i-2] + abs(h[i]- h[i-2]))

print(dp[-2])


Measured memory_bytes: 13928
x,y = gets.chomp.split(' ').map(&:to_i)

g1 = [1,3,5,7,8,10,12]
g2 = [4,6,9,11]
g3 = [2]

if (g1.include?(x) && g1.include?(y)) || (g2.include?(x) && g2.include?(y)) || (g3.include?(x) && g3.include?(y))
  puts 'Yes'
else
  puts 'No'
end

Measured memory_bytes: 1788
import sys
sys.setrecursionlimit(10 ** 7)

n, m, q = map(int, input().split())
abcd = [list(map(int, input().split())) for _ in range(q)]

cands = []


def dfs(i, li):
    if i == n:
        return cands.append(li)

    if li:
        mn = li[-1]
    else:
        mn = 1
    for num in range(mn, m + 1):
        dfs(i + 1, li + [num])


dfs(0, [])

ans = 0
for li in cands:
    sm = 0
    for a, b, c, d in abcd:
        a -= 1
        b -= 1
        if li[b] - li[a] == c:
            sm += d

    ans = max(ans, sm)

print(ans)


Measured memory_bytes: 22960
#include <stdio.h>

int main(void){
    int n,m;
    int i,j=0;


    scanf("%d",&n);
    scanf("%d",&m);

    int a[n+1][m+1];
    int b[m+1];
    int c[n+1];

    for(i=1;i<=n;i++){
        c[i]=0;
    }

    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            scanf("%d",&a[i][j]);
        }
    }

    for(j=1;j<=m;j++){
        scanf("%d",&b[j]);
    }

    for(i=1;i<=n;i++){
        for(j=1;j<=m;j++){
            c[i]=c[i]+a[i][j]*b[j];
        }
        printf("%d\n",c[i]);
    }


    return 0;
}


Measured memory_bytes: 2100
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> 	pii;
typedef long long 		ll;
typedef vector<int> 	vi;
typedef long double ld;
#define PI 				3.14159265
#define int				long long
#define f 				first
#define s 				second
#define pb 				push_back
#define mtup 			make_tuple
#define nl 				'\n'
#define FLASH 			ios_base::sync_with_stdio(false);cin.tie(NULL);
#define maxheap 		priority_queue<ll>
#define minheap 		priority_queue<ll,vector<ll> ,greater<ll>>
const ll inf = 1e18 + 1;
const int mod = 1e9 + 7;
const int maxn = 1e6 + 55;
ll modpow(ll a,ll b,int mod = LLONG_MAX) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) {return __gcd(a,b);}

signed main(){
	FLASH
	int n, m;
	pii gg[maxn];
	cin >> n >> m;
	for (int i = 1; i <= m; i++)
		cin >> gg[i].f >> gg[i].s;
	int l = gg[1].f, r = gg[1].s;
	for (int i = 2; i <= m; i++){
		if (gg[i].f > r || gg[i].s < l) return cout << 0, 0;
		else {
			l = (gg[i].f > l) ? gg[i].f : l;
			r = (gg[i].s < r) ? gg[i].s : r;
		}
	}
	cout << r - l + 1;
	return 0;
}


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

int n,t[1010];
string s[1010];

int main() {
	ios::sync_with_stdio(0);cin.tie(0);
	cin>>n;
	for(int i=1;i<=n;i++) cin>>s[i]>>t[i];
	string x;cin>>x;int ans=0;
	for(int i=n;i;i--) {
		if(s[i]==x) break; ans+=t[i];
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        if (a == b) {
            System.out.println("-1");
            return;
        }

        if (a % b == 0) {
            System.out.println("-1");
        } else {
            System.out.println(a);
        }
    }
}


Measured memory_bytes: 23892
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 300005
#define inf 1e9
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll len,dp[maxn][3][3],ans;
char s[maxn];
const ll mod=1000000007;

inline ll A(ll x,ll y){return (x+y)%mod;}
inline ll M(ll x,ll y){return (x*y)%mod;}

int main()
{
	scanf("%s",s); len=strlen(s); dp[0][0][0]=1;
	for(int i=0;i<len;i++)
	{
		for(int j=0;j<=2;j++)
		{
			for(int k=0;k<=2;k++)
			{
				int x=dp[i][j][k];
				if(s[i]=='0'||s[i]=='?')
				{
					if(k!=2) dp[i+1][j][k+1]=A(dp[i+1][j][k+1],x);
					else dp[i+1][j][1]=A(dp[i+1][j][1],x);
					//cout<<dp[i+1][j][k+1]<<endl;
				}
				
				if(s[i]=='1'||s[i]=='?')
				{
					if(k!=0) dp[i+1][j][k-1]=A(dp[i+1][j][k-1],x);
					else dp[i+1][min(j+1,2)][k]=A(dp[i+1][min(j+1,2)][k],x);
				}
				//cout<<i<<" "<<j<<" "<<k<<" "<<dp[3][0][0]<<endl;
			}
		}
	}
	rep(i,0,2) rep(j,0,i) ans=A(ans,dp[len][i][j]); cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 21632
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long 
#define endl '\n'
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define SIZE 100005
 
vector<int>v[100005]; 
map<pair<int,int>,int>mp; 
int coun = 1;
bool vis[100005];

void dfs(int node, int prev)
{
	int baki = 0;
	vis[node] = 1;
	for(int i = 0; i < v[node].size(); i++)
	{
		int nodd = v[node][i];
		if(!vis[nodd]) 
		{
			baki++;
			if(baki==prev) baki++;
			if(baki > coun) baki = 1;
			mp.insert({{node,nodd},baki});
			mp.insert({{nodd,node},baki});
		    dfs(nodd, baki);
		}
	}
}
int main()
{
	int n,a[100005],b[100005],mx=0,node;
	
	cin >> n;
	for(int i =1; i <= n-1; i++)
	{
		cin >> a[i] >> b[i];
		v[a[i]].push_back(b[i]);
		v[b[i]].push_back(a[i]);
		if(v[a[i]].size() > mx)
		{
			mx = v[a[i]].size();
			node = a[i];
		}
		if(v[b[i]].size() > mx)
		{
			mx = v[b[i]].size();
			node = b[i];
		}
	}
//	cout << mx << endl;
	int len = v[node].size();
	for(int i = 0; i < len; i++)
	{
		int nodd = v[node][i];
		mp.insert({{node,nodd},coun});
		mp.insert({{nodd,node},coun});
		coun++;
	}
	vis[node] = 1;
	for(int i = 0; i < len; i++)
	{
		int nodd = v[node][i];
		//cout << mp[{node,nodd}] << endl;
		dfs(nodd,mp[{node,nodd}]);
	}
	cout << coun-1 << endl;
	for(int i =1; i < n; i++)
	{
		cout << mp[{a[i],b[i]}] << endl;
	}
	return 0;
}


Measured memory_bytes: 19456
#include <bits/stdc++.h>
using namespace std;
 
int main(){
string d,f;
  cin >>d ;
  if(d=="Sunny"){
  cout <<"Cloudy" <<endl;}
  if(d=="Cloudy"){
  cout <<"Rainy" <<endl;}
  if(d=="Rainy"){
  cout <<"Sunny" <<endl;}
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<algorithm>
#include<set>
#include<map>
#include<unordered_map>
#include<cmath>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<climits>
#include<string>
#include<sstream>
#include<numeric>
#include<stack>

#define MOD 1000000007
#define MOD2 998244353
#define int long long
#define double long double
#define EPS 1e-9
//#define PI 3.14159265358979

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

using namespace std;

template < typename T >
ostream &operator<<(ostream &os, const vector< T > &A) {
	for (int i = 0; i < A.size(); i++)
		os << A[i] << " ";
	os << endl;
	return os;
}
template <>
ostream &operator<<(ostream &os, const vector< vector< int > > &A) {
	int N = A.size();
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < A[i].size(); j++)
			os << A[i][j] << " ";
		os << endl;
	}
	return os;
}
template < typename T, typename U >
ostream &operator<<(ostream &os, const pair< T, U > &p) {
os << "(" << p.first << "," << p.second << ")";
return os;
}

typedef pair<int,int> pii;
typedef long long ll;

struct edge{
	int from,to,d,c,i;
	edge(int _from=0,int _to=0,int _d=0,int _c=0){
		from=_from;
		to=_to;
		d=_d;
		c=_c;
	}
	bool operator<(const edge &rhs)const{
		return (d==rhs.d)?(c<rhs.c):(d<rhs.d);
	}
};
struct aabb{
int x1,y1,x2,y2;
aabb(int x1,int y1,int x2,int y2):x1(x1),y1(y1),x2(x2),y2(y2){}
};

typedef vector<edge> edges;
typedef vector<edges> graph;
struct flow {
	int to, cap, rev,cost;
	flow(int to = 0, int cap = 0, int rev = 0,int cost=0) : to(to), cap(cap), rev(rev),cost(cost) {}
};
typedef vector< vector< flow > > flows;

const int di[4]={0,-1,0,1};
const int dj[4]={-1,0,1,0};
const int ci[5]={0,0,-1,0,1};
const int cj[5]={0,-1,0,1,0};
const ll LINF=LLONG_MAX/2;
const int INF=INT_MAX/2;
const double PI=acos(-1);

int pow2(int n){return 1LL<<n;}
template <typename T,typename U>
bool chmin(T& x,const U& y){
	if(x>y){
		x=y;
		return true;
	}
	return false;
}
template <typename T,typename U>
bool chmax(T& x,const U& y){
	if(x<y){
		x=y;
		return true;
	}
	return false;
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
fill( (T*)array, (T*)(array+N), val );
}
struct initializer{
	initializer(){
		cout<<fixed<<setprecision(20);
	}
};
initializer _____;

int N,M,K,T,Q,H,W;
signed main(){
	string S;
	cin >> S;
	if(S.back()=='s'){
		S.push_back('e');
		S.push_back('s');
	}else{
		S.push_back('s');
	}
	cout << S << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int (i)=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 1'000'000'007

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

int main(){
    int N;
    cin >> N;
    vector<int> B(N+1);
    for(int i=1; i<N; i++){
        int A;
        cin >> A;
        B[A]++;
    }
    for(int i=1; i<=N; i++)
        cout << B[i] << endl;

    return 0;
}


Measured memory_bytes: 3988
n,k=map(int,input().split())
ans=0
if k==0:
    print(n**2)
    exit()
for b in range(k+1,n+1):
    num=b-k
    l=n//b
    m=n%b
    ans+=num*l
    ans+=max(0,m-k+1)
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
typedef long long ll;

ll max(ll a, ll b) {
  return a > b ? a : b;
}

ll min(ll a, ll b) {
  return a < b ? a : b;
}

int main(void) {
  ll n, t, q, i, j, k;
  scanf("%lld%lld%lld", &n, &t, &q);
  ll a[n], d[n], x[n], now, s = 0, be, bel, l;
  for(i = 0; i < n; ++i) scanf("%lld%lld", &a[i], &d[i]);
  for(i = 0; i < n; ++i) {
    if(d[i] == 1) {
      s = 1;
      be = i;
      if(!i || (i &&  d[i - 1] == 2)) bel = i;
      l = 1;
    } else {
      if(be == i - 1) {
        now = (a[i - 1] + a[i]) / 2;
        for(j = bel; j < i; ++j) x[j] = min(now, a[j] + t);
      } 
     x[i] = max(now, a[i] - t);
      l = 2;
    }
    if(!s) {
      x[i] = a[i] - t;
    }
  }
  if(l == 1) for(i = bel; i < n; ++i) x[i] = a[i] + t;
  for(i = 0; i < q; ++i) {
    int p;
    scanf("%d", &p);
    p--;
    printf("%lld\n", x[p]);
  }
  return 0;
}


Measured memory_bytes: 5024
// ALDS1_2_A: Bubble Sort

use std::str::FromStr;

fn bubble_sort(a: &mut Vec<i64>, n: usize) -> usize {
    let mut sw: usize = 0;
    let mut i: usize = 0;
    let mut flag = true;
    while flag {
        flag = false;
        let mut j = n - 1;
        while j >= i + 1 {
            if a[j] < a[j - 1] {
                let tmp = a[j];
                a[j] = a[j - 1];
                a[j - 1] = tmp;
                flag = true;
                sw += 1;
            }
            j -= 1;
        }
        i += 1;
    }
    sw
}

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n = s.trim().parse::<usize>().unwrap();

    s.clear();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.split_whitespace().map(|n| i64::from_str(n).unwrap());
    let mut a: Vec<i64> = Vec::new();
    while let Some(v) = it.next() {
        a.push(v);
    }

    let sw = bubble_sort(&mut a, n);

    print!("{}", a[0]);
    for i in 1..n {
        print!(" {}", a[i]);
    }
    println!();

    println!("{}", sw);
}


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

int main() {
 ll a,v,b,w,t;
 cin >> a >> v >> b >> w >> t;
 if(a<b){
   ll bfin=b+w*t;
   ll afin=a+v*t;
   if(afin>=bfin)cout << "YES" << endl;
   else cout << "NO" << endl;
 }
 else{
   ll bfin=b-w*t;
   ll afin=a-v*t;
   if(afin<=bfin)cout << "YES" << endl;
   else cout << "NO" << endl; 
 }
}


Measured memory_bytes: 3624
#include<cstdio>
#include<algorithm>
using namespace std;
long long x[1000000];
long long d[1000000];
int main()
{
  int n , m ;
  scanf("%d%d" , &n, &m);
  for(int i = 1; i <= m ; i ++)
  {
    scanf("%lld" , &x[i]);
  }
  sort(x + 1 , x + m + 1);
  for(int i = 2; i <= m ; i ++)
    d[i] = x[i] -x [i - 1];
  sort(d + 2, d + m + 1);
  long long total = x[m] - x[1];
  for(int i = 1 ; i <= min (m - 1, n - 1) ;i ++)
    total -= d[m - i + 1];
  printf("%lld" , total);
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	// your code goes here
	int n,k;
	cin>>n;
	int v[n][3];
	rep(i,n)
	{
	    rep(j,3)
	    {
	        cin>>v[i][j];
	    }
	}
	long long int dp[n][3];
	
	    dp[n-1][0]=v[n-1][0];
	    dp[n-1][1]=v[n-1][1];
	    dp[n-1][2]=v[n-1][2];
	
	for(int i=n-2;i>=0;i--)
	{
	    dp[i][0]=v[i][0]+max(dp[i+1][1],dp[i+1][2]);
	    dp[i][1]=v[i][1]+max(dp[i+1][0],dp[i+1][2]);
	    dp[i][2]=v[i][2]+max(dp[i+1][0],dp[i+1][1]);
	}
	cout<<max(dp[0][0],max(dp[0][1],dp[0][2]));
	return 0;
}


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

int d[110];
int n;
int main() {
	cin>>n;
	for(int i=0;i<n;i++)cin>>d[i];
	
	sort(d,d+n);
	int count=0;
	for(int i=0;i<n;i++){
		if(d[i]==d[i+1])count++;
	}
	
	cout<<n-count<<endl;
}

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

typedef long long ll;

int main(){
	ll n,m;
	cin >> n >> m;

	if(n==1 && m==1){
		cout << 1 << endl;
	}
	else if(n==1 || m==1){
		ll a = max(n,m);
		cout << a-2 << endl;
	}else{
		cout << (n-2)*(m-2) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int n;
	scanf("%d", &n);
	char S[100];
	scanf("%s", &S);

	int f = 0;
	if (n % 2 == 1) {
		f = 1;
	}
	else {
		//Void
	}
	
	for (int i = 0; i < n / 2; i++) {
		if (S[i] == S[n / 2 + i]) {
			// Void
		}
		else {
			f = 1;
		}
	}

	if (f == 0) {
		printf("Yes\n");
	}
	else {
		printf("No\n");
	}

	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>

using namespace std;

int h,w;

int main(void){
	while(1){
		scanf("%d%d",&h,&w);
		if(h+w==0)break;
		int rh=1145,rw=1419,hwt=h*h+w*w,rhwt=rh*rh+rw*rw;
		//i高さj幅
		for(int i=1;i<200;i++){
			for(int j=i+1;j<200;j++){
				if(i==h && w==j)continue;
				int t=i*i+j*j;
				if(hwt<t || (t==hwt && h<i)){
					if(t<rhwt || (t==rhwt && i<rh)){
						rh=i;
						rw=j;
						rhwt=rh*rh+rw*rw;
					}
				}
			}
		}
		printf("%d %d\n",rh,rw);
	}
	return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

long long N;

int main() {
    cin >> N;
    vector<long long> A(N);
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    if (sum % (N * (N + 1) / 2) != 0) {
        cout << "NO" << endl;
        return 0;
    }
    long long cnt = sum * 2 / N / (N + 1);
    vector<long long> D(N);
    D[0] = A[0] - A[N - 1] - cnt;
    for (int i = 1; i < N; i++) {
        D[i] = A[i] - A[i - 1] - cnt;
    }
    for (int i = 0; i < N; i++) {
        if (D[i] == 0) continue;
        if (D[i] % N != 0 || D[i] > 0) {
            cout << "NO" << endl;
            return 0;
        }
        cnt += D[i] / N;
    }
    cout << (cnt == 0? "YES": "NO") << endl;
}




Measured memory_bytes: 1792
# -*- coding: utf-8 -*-

"""
参考：https://kyopro-friends.hatenablog.com/entry/2019/01/12/231000
・ゲームDP
・負け状態を押し付けられるかどうか
"""

import sys, re
from collections import deque, defaultdict, Counter
from math import sqrt, hypot, factorial, pi, sin, cos, radians
if sys.version_info.minor >= 5: from math import gcd
else: from fractions import gcd 
from heapq import heappop, heappush, heapify, heappushpop
from bisect import bisect_left, bisect_right
from itertools import permutations, combinations, product
from operator import itemgetter, mul
from copy import deepcopy
from functools import reduce, partial
from fractions import Fraction
from string import ascii_lowercase, ascii_uppercase, digits

def input(): return sys.stdin.readline().strip()
def ceil(a, b=1): return int(-(-a // b))
def round(x): return int((x*2+1) // 2)
def fermat(x, y, MOD): return x * pow(y, MOD-2, MOD) % MOD
def lcm(x, y): return (x * y) // gcd(x, y)
def lcm_list(nums): return reduce(lcm, nums, 1)
def gcd_list(nums): return reduce(gcd, nums, nums[0])
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, K = MAP()
aN = LIST()

# メモ[山の残数] = 今の手番が勝てるか
dp = [False] * (K+1)
# 残数0は負け確定
dp[0] = False

for i in range(1, K+1):
    for j in range(N):
        # j枚取った時、負け状態に出来るなら、それを取ればいいので今の手番は勝てる
        if i-aN[j] >= 0 and dp[i-aN[j]] == 0:
            dp[i] = True
            break
if dp[K]:
    print('First')
else:
    print('Second')


Measured memory_bytes: 68072
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <iomanip>

using namespace std;
using ll = long long;

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

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    int A, B;
    cin >> A >> B;

    if (A % 3 == 0 || B % 3 == 0 || (A + B) % 3 == 0) { cout << "Possible" << endl; }
    else { cout << "Impossible" << endl; }

}

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

int main() {
    int a[5];
    cin >> a[0] >> a[1] >> a[2] >> a[3] >> a[4];
    for (int i = 0; i < 5; ++i) {
        if (a[i] == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
}


Measured memory_bytes: 3624
import sys
import numpy as np

input = sys.stdin.readline

n, k = map(int, input().split())
h = [int(i) for i in input().split()]

dp = np.zeros(n, dtype=int)
h = np.array(h)


for i in range(1, n):
    s = max(0, i-k)
    dp[i] = min(dp[s: i] + np.abs(h[i] - h[s: i]))

print(dp[n-1])

Measured memory_bytes: 23052
n = STDIN.gets.chomp.to_i

char_map = []
n.times do |i|
  char_map[i] = ('a'..'z').map{|c| [c, 0] }.to_h

  STDIN.gets.chomp.split('').each do |c|
    char_map[i][c] += 1
  end
end

('a'..'z').each do |c|
  n.times.map{|i| char_map[i][c]}.min.times{ print c }
end

puts ''


Measured memory_bytes: 2044
#include "bits/stdc++.h"
#define rep(i,a,n) for(int i = (a);i < (n);i++)
typedef unsigned long long ull;
typedef long long ll;
using namespace std;

int main(){
	ull k;
  	string s;
  	cin >> s;
    cin >> k;
  
  	rep(i,0,s.size()){
		if(s[i] != '1'){
          cout << s[i] << endl;
          return 0;
        }
      	else if(i+1 == k){
           cout << s[i] << endl;
           return 0;
        }
    }
	return 0; 
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define pi 3.1415926535897932384626433832
#define ll long long
using namespace std;
ll lcm(ll a, ll b){ if(!a || !b) return 0; return a * b / __gcd(a, b); }
bool isPrime(int n) {if (n <= 1) return false;
    if (n <= 3) return true;
    if (n % 2 == 0 || n % 3 == 0) return false;
    for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false;
    return true;}



int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll a,b,c;
    cin>>a>>b>>c;
    ll o=b/c-(a-1)/c;
    //if(c%a==0)o++;
    cout<<o<<endl;
    return 0;
}


Measured memory_bytes: 3632
#include<stdio.h>
#include<map>
typedef long long ll;
int main(){
  ll N,A,i,ans=0;
  std::map<ll,ll> L,R;
  scanf("%lld",&N);
  for(i=0;i<N;i++){
    scanf("%lld",&A);
    L[i+A]++;R[i-A]++;
  }
  for(i=1;i<2*N;i++) ans += L[i]*R[i];
  printf("%lld",ans);
}

Measured memory_bytes: 68488
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
template<class T> inline bool chmin(T& a,T b) {if(a > b){a = b; return true;} return false;}
template<class T> inline bool chmax(T& a,T b) {if(a < b){a = b; return true;} return false;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    int h,w,n,si,sj;
    cin >> h >> w >> n >> si >> sj;
    si--; sj--;
    string s,t;
    cin >> s >> t;
    vi v(4,0);
    v[0] = si;
    v[1] = si;
    v[2] = sj;
    v[3] = sj;
    rep(i,n) {
        if(s[i] == 'U') v[0]--;
        else if(s[i] == 'D') v[1]++;
        else if(s[i] == 'L') v[2]--;
        else v[3]++;
        if(v[0] < 0 || v[1] >= h || v[2] < 0 || v[3] >= w) {
            cout << "NO" << endl;
            return 0;
        }
        if(t[i] == 'U') v[1] = max(0,v[1]-1);
        else if(t[i] == 'D') v[0] = min(h-1,v[0]+1);
        else if(t[i] == 'L') v[3] = max(0,v[3]-1);
        else v[2] = min(w-1,v[2]+1);
    }
    cout << "YES" << endl;
}


Measured memory_bytes: 920
class UnionFind():
    def __init__(self,n):
        self.n = n
        
        # parents が負の時は要素数
        # parents が正の時は親の番号
        self.parents = [-1] * n

    # xの根を求める
    def find(self,x):
        if self.parents[x] < 0:
            return x
        else:
            # 根を再帰的に求める
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    # xとyを併合する
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)

        # 根が同じ場合はreturn
        if x == y:
            return

        # ランクを考慮（要素数の少ない木を要素数の多い木に併合）
        if self.parents[x] > self.parents[y]:
            x,y = y,x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    # xの木の要素数を求める
    def size(self,x):
        return - self.parents[self.find(x)]

    # xとyが同じ木なのか確かめる
    def same(self,x,y):
        return self.find(x) == self.find(y)


N,M,K = (int(x) for x in input().split())

uf = UnionFind(N)
n_friend = [0]*N

for i in range(M):
    A,B = (int(x) for x in input().split())

    A -= 1
    B -= 1

    n_friend[A] += 1
    n_friend[B] += 1
    uf.union(A,B)

ans = [uf.size(i) - 1 - n_friend[i] for i in range(N)]

for i in range(K):
    C,D = (int(x) for x in input().split())

    C -= 1
    D -= 1

    if uf.same(C,D):
        ans[C] -= 1
        ans[D] -= 1

print(*ans)


Measured memory_bytes: 14196
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		System.out.printf("%d %d %.5f", a/b, a%b, (double)a/(double)b);
	}
}

Measured memory_bytes: 17368
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; ++i)
#define repR(i, n) for(ll i = n; i >= 0; ++i)
#define FDS(i, n) for(ll i = 0; i < n; ++i)
#define FDSR(i, n) for(ll i = n; i >= 0; ++i)
#define FOR(i, m, n) for(ll i = m; i < n; ++i)
#define FORR(i, m, n) for(ll i = m;i >= n;--i)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
#define INF 999999999
#define itn ll
#define ednl endl
using namespace std;
typedef long long ll;template<typename Typell>Typell G_C_D(Typell a, Typell b){if (a < 0) a = -a;if (b < 0) b = -b;while (b != 0) {a %= b;if (a == 0) return b;b %= a;}return a;}template<typename Typell>
Typell G_C_D(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = G_C_D(a, list[i]);}return a;}template<typename Typell>Typell L_C_M(Typell a, Typell b) {if( a == 0 && b == 0)return 0;return a / G_C_D(a, b) * b;}
template<typename Typell>Typell L_C_M(const std::vector<Typell> &list){Typell a = list[0];for (size_t i = 1; i < list.size(); ++i) {a = L_C_M(a, list[i]);}return a;}

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int n,t;
	cin>>n>>t;
	n*=3;
	n+=t;
	cout<<n/2<<endl;
}

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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    map<int, int> mp;
    rep(i,n) {
        cin >> a[i];
        mp[a[i]]++;
    }
    ll all = 0;
    for (auto x : mp) {
        ll cnt = x.second;
        all += cnt*(cnt-1)/2;
    }
    rep(i,n) {
        ll ans = all - (mp[a[i]]-1);
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 9764
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mt make_tuple
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
//typedef tuple<int,int,int> tp;
//typedef vector<tp> vt;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-7;
const int inf=1e9;
const ll INF=2e18;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vi in(3*n);
	rep(i,3*n)cin>>in[i];
	vp dp(n+1);

	priority_queue<ll>que1;
	ll sum=0;
	rep(i,n){
		sum+=in[i];
		que1.push(-in[i]);
	}
	dp[0].first=sum;
	rep(i,n){
		ll t=-que1.top();
		que1.pop();
		que1.push(-max(t,in[i+n]));
		if(t<in[i+n])sum+=in[i+n]-t;
		dp[i+1].first=sum;
	}
	
	priority_queue<ll>que2;
	sum=0;
	rep(i,n){
		sum+=in[3*n-1-i];
		que2.push(in[3*n-1-i]);
	}
	dp[n].second=sum;
	rep(i,n){
		ll t=que2.top();
		que2.pop();
		que2.push(min(t,in[2*n-i-1]));
		if(t>in[2*n-i-1])sum+=min(t,in[2*n-i-1])-max(t,in[2*n-i-1]);
		dp[n-i-1].second=sum;
	}
	ll out=-INF;
	rep(i,n+1)out=max(out,dp[i].first-dp[i].second);
	cout<<out<<endl;
}










Measured memory_bytes: 6516
using System;

namespace tenka1_2017_c
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            bool found = false;
            for (long i = 1; i < 3500 && !found; i++)
            {
                for (long j = i; j < 3500 && !found; j++)
                {
                    double x = n * i * j;
                    x /= 4 * i * j - n * (i + j);
                    if (x % 1 == 0 && x > 0)
                    {
                        Console.WriteLine(x + " " + i + " " + j);
                        found = true;
                    }
                }
            }
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define mp make_pair
#define pb push_back
#define m 1000000000000000007
vector<ll>prime(10000001,1);
vector<ll>sdf(10000001,1);
/*
ll C[101][101];
int isprime(ll n)
{
    ll i;
    for(i=2;i*i<=n;i++)
    {
        if(n%i==0)
            {//cout<<i<<endl;
            return 0;}
    }
    return 1;
}
int isperfectsq(ll n)
{


    long double x;
    x=(long double)(sqrt((long double )(n)));
    ll y=sqrt(n);
    if(x==y)
        return 1;
        else
            return 0;
}
void ncr()
{
    C[0][0] = 1;
    for (int n = 1; n <= 100; ++n) {
        C[n][0] = C[n][n] = 1;
        for (int k = 1; k < n; ++k)
            C[n][k] = C[n - 1][k - 1] + C[n - 1][k];
    }
}
*/
void sieve()
{
    //cout<<"in1";
    ll i;
    //sdf[i]=1;
    ll j;
    prime[0]=prime[1]=0;
    for(i=2;i<=10000000;i++)
    {

            //isprime.push_back(i);
            for(j=i;j<=10000000;j+=i)
            {
                //prime[j]=0;

                sdf[j]++;
            }

    }

}

/*
long long modular_expo(long long x,long long y)
{

    if(y==0)
        return 1;
    if(y%2==0)
        return modular_expo(x*x,y/2);
    if(y%2==1)
        return x*modular_expo(x*x,(y-1)/2);


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




    sieve();
    ll n,i;
    ll cnt=0;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        //cout<<sdf[i]<<endl;
        cnt+=(i*sdf[i]);
    }
    cout<<cnt;



}


Measured memory_bytes: 159396
import bisect
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))
#真ん中を固定
ans=0
for i in range(N):
    b=B[i]
    ab=bisect.bisect_left(A,b)
    bc=N-bisect.bisect_right(C,b)
    ans+=ab*bc
print(ans)

Measured memory_bytes: 23092
n, k = map(int, input().split())

s = [int(i) for i in range(1, n+1)]

for i in range(k):
    d = int(input())
    as_ = list(map(int, input().split()))

    for a in as_:
        try:
            s.remove(a)
        except ValueError:
            pass
print(len(s))


Measured memory_bytes: 9164
/*
 * ARC096_D.cpp
 *
 *  Created on: May 17, 2018
 *      Author: 13743
 */
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<string>
#include<cstring>
using namespace std;
typedef long long lng;
typedef unsigned long long ulng;

#define pb push_back
#define SZ(a) int((a).size())
#define ALL(a) (a).begin(), (a).end
#define FOR(i,a,b) for(int i=(a); i<=(b); ++i)
#define FORD(i,b,a) for(int i=(b); i>=(a); --i)
#define REP(i,n) FOR(i,0,n-1)
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

lng power(lng b, lng e) {lng sol=1; while(e>0) {if(e&1) {sol=sol*b;} e>>=1; b*= b;} return sol;}

lng x[100000];
lng v[100000];

lng pt[100000];
lng ptR[100000];

lng ptm[100000];
lng ptmR[100000];

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

	int N;
	lng C;
	cin >> N >> C;
	REP(i, N) {
		cin >> x[i] >> v[i];
	}

	pt[0] = v[0];
	ptR[N-1] = v[N-1];
	FOR(i, 1, N-1) {
		pt[i] = pt[i-1] + v[i];
		ptR[N-1-i] = ptR[N-i] + v[N-1-i];
	}
	ptm[0] = max(pt[0]-2*x[0], 0LL);
	ptmR[N-1] = max(ptR[N-1]-2*(C-x[N-1]), 0LL);
	FOR(i, 1, N-1) {
		ptm[i] = max(ptm[i-1], pt[i] - 2*x[i]);
		ptmR[N-1-i] = max(ptmR[N-i], ptR[N-1-i] - 2*(C-x[N-1-i]));
	}

	lng opt = max(pt[N-1]-x[N-1], ptR[0]-(C-x[0]));
	REP(i, N-1) {
		lng tmp = max(pt[i]-x[i]+ptmR[i+1], ptR[i+1]-(C-x[i+1])+ptm[i]);
		opt = max(opt, tmp);
	}
	if(opt < 0) opt = 0;

	cout << opt << endl;
}






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

int main(){
	char x, y;
	scanf("%c %c", &x, &y);
	int a = x-'A', b = y-'A';
	if(a == b)printf("=\n");
	else if(a < b)printf("<\n");
	else printf(">\n");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	string p;
	char c;
	while((c=getchar())!='\n')
	{
		if(c=='B')
		{
			if(!p.empty())
			{
				string::iterator it=p.end();
				--it;
				p.erase(it);
			}
		}
		else p.push_back(c);
	}
	cout<<p<<endl;
    return 0;
}

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

int main() {
	for (int i = 0;i < 4;i++) {
		int a, b;
		cin >> a >> b;
		switch (a) {
		case 1:
			cout << 6000 * b << endl;
			break;

		case 2:
			cout << 4000 * b << endl;
			break;

		case 3:
			cout << 3000 * b << endl;
			break;

		case 4:
			cout << 2000 * b << endl;
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3060
# -*- coding: utf-8 -*-

"""
name: 153A.py
プログラムの説明
"""

def main():
    a,b = map(int, input().split())

    times = (a // b)
    if (a%b)==0:
        pass
    else:
        times += 1



    print(times)

if __name__ == '__main__':
    main()

Measured memory_bytes: 2940
n, *a = map(int, open(0).read().split())
a.sort()
am = a[-1] + 1
dp = [True] * am
ans = 0
dup = set()
for x in a:
    d = dp[x]
    if d:
        ans += 1
        for i in range(x, am, x):
            dp[i] = False
        dp[x] = None
    elif d == None:
        dup.add(x)

print(ans - len(dup))

Measured memory_bytes: 117764
#include<iostream>
#include <algorithm>
#include<string>
#include <bitset>
#include <vector>
#include <functional>
#include <climits>
#include <iomanip>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <numeric>
using namespace std;
using ll = long long;

typedef pair <int, int> pii;

int main()
{

	ll a = 0, b = 0, c = 0, d = 0, e = 0, f = 0, g = 0, h = 0, ans = 0;
	//cout << LONG_MAX << endl;
	//long long n, A[1000000000];
	//ll n, m, q;

	cin >> a;
	cin >> b;
	c = max(a - b, ll(0));

	cout << c << endl;

	////std::cout << std::fixed;
	//cout << std::setprecision(20) << << endl;
	//cout << d+1 << endl;
	//cout << "" << endl;

	return 0;
}
//accumulate(x, x + a, 0);
//memcpy(x, visited, sizeof(ll)*n);
//void kansuu(ll num, ll visited[10]) {}
//kansuu(1, zz);
//cout << setprecision(15) << v << endl;

//int temp;
//for (int i = 0; i < n - 1; i++) {
//	for (int j = n - 1; j > i; j--) {
//		if (w[j - 1] < w[j]) {  /* 前の要素の方が大きかったら */
//			temp = w[j];        /* 交換する */
//			w[j] = w[j - 1];
//			w[j - 1] = temp;
//		}
//	}
//}



Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int f = 0, in;
	for(int i = 0; i < 3; i++){
		scanf("%d", &in);
		if(in == 5 && (f & 1))f |= 4;
		if(in == 5 && !(f & 1))f |= 1;
		if(in == 7)f |= 2;
	}
	if(f == 7)
		printf("YES\n");
	else
		printf("NO\n");
	return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

int main(){
    string s,t;
    cin >> s;
    cin >> t;
    t.erase (t.begin()+s.length());
    if(s==t){
        cout << "Yes" <<endl;
    }else{
        cout << "No" << endl;
    }  
}

Measured memory_bytes: 3628
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

template <typename T> inline void voutput(T &v){
    rep(i, v.size()){
        if (i) cout << " " << v[i];
        else cout << v[i];
    }
    cout << endl;
}

double calc(ll t, ll v1, ll v2, ll vm) {
    vector<ll> V(t + 1);
    V[0] = v1;
    V[t] = v2;
    rep(i, 1, t){
        V[i] = min({v1 + i, vm, v2 + t - i});
    }
    double ret = 0;
    rep(i, t){
        if(V[i] == V[i + 1] && V[i] < vm){
            ret += (double)V[i] + 0.25;
        }
        else{
            ret += (double)(V[i] + V[i + 1]) / 2.0;
        }
        
    }
    return ret;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    int N;
    cin >> N;
    vector<int> T(N), V(N);
    rep(i, N) cin >> T[i];
    rep(i, N) cin >> V[i];
    vector<int> S(N + 1, 0);
    rep(i, N) S[i + 1] = S[i] + T[i];
    vector<int> dp(S[N] + 1, inf);
    vector<int> vm(S[N]);
    rep(i, N){
        rep(j, S[i], S[i + 1]){
            vm[j] = V[i];
        }
    }
    rep(i, N){
        rep(j, S[N] + 1){
            int now = V[i] + min(abs(S[i] - j), abs(S[i + 1] - j));
            if(S[i] <= j && j <= S[i + 1]) now = V[i];
            dp[j] = min(dp[j], now);
        }
    }
    rep(i, S[N] + 1){
        dp[i] = min(dp[i], i);
        dp[i] = min(dp[i], S[N] - i);
    }
//    voutput(dp);
//    voutput(vm);
    double ret = 0;
    rep(i, S[N]){
        if(dp[i] == dp[i + 1] && dp[i] < vm[i]){
            ret += (double)dp[i] + 0.25;
        }
        else{
            ret += (double)(dp[i] + dp[i + 1]) / 2.0;
        }

    }
    
    output(ret, 10);
    
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define N 500
using namespace std;
int a[N+10][N+10];
int read(){
	int x=0,f=1;
	char ch=getchar();
	while (ch<'0' || ch>'9'){
		if (ch=='-') f=-1;
		ch=getchar();
	}
	while (ch>='0' && ch<='9'){
		x=x*10+ch-'0';ch=getchar();
	}
	return x*f;
}
signed main(){
	int n=read();
	if (n<=N){
		printf("%d\n",n);
		for (int i=1;i<=n;++i){
			for (int j=1;j<=n;++j){
				printf("%d ",i);
			}
			putchar('\n');
		}
	}else{
		for (int i=0;i<N;++i){
			for (int j=0;j<N;++j){
				if (i+N+1>n) a[j][(i+j)%N]=i+1;
				else a[j][(i+j)%N]=j&1?i+N+1:i+1;
			}
		}
		printf("%d\n",N);
		for (int i=0;i<N;++i){
			for (int j=0;j<N;++j){
				printf("%d ",a[i][j]);
			}
			putchar('\n');
		}
	}
	return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
    cin >> d.at(i);
  }
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
  int count=1;
  for(int i=0;i<N-1;i++){
    if(d.at(i+1)<d.at(i)){
      count++;
    }
  }
  cout << count << endl;
}
      
    

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

def solve(N, A):
    a_max = max(A)
    a_min = min(A)
    sum_list = []
    for i in range(a_min, a_max+1, 1):
        sum = 0
        for j in range(N):
            sum += (A[j] - i)**2
        sum_list.append(sum)
    print(min(sum_list))
    
if __name__ == '__main__':
    N = int(input())
    A = [int(a) for a in input().split()]
    
    solve(N, A)

Measured memory_bytes: 3064