akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <bits/extc++.h>
using namespace __gnu_pbds;
using namespace std;
#define testing 1
#define FOR(ii, ss, ee) for(ll ii = (ss); ii <= (ll)(ee); ++ii)
#define DEC(ii, ss, ee) for(ll ii = (ss); ii >= (ll)(ee); --ii)
#define IAMSPEED ios_base::sync_with_stdio(false); cin.tie(0);
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << " , " << #y << "=" << y << endl
#define db3(a,b,c) cerr<<#a<<"="<<a<<","<<#b<<"="<<b<<","<<#c<<"="<<c<<endl
#define dbv(v) cerr << #v << ":"; for (auto it : v) cerr << it << ' '; cerr << endl
#define dbvp(v) cerr << #v << ":"; for (auto it : v) cerr << "{"  << it.f << ',' << it.s << "} "; cerr << endl
#define dba(a,ss,ee) cerr << #a << ":"; FOR(i,ss,ee) cerr << a[i] << ' '; cerr << endl
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define ll long long 
#define pb push_back
#define inf (int)1e9+500
#define oo (ll)1e18+500
#define all(x) (x).begin(), (x).end()
#define f first
#define s second
#define reach cerr << "LINE: " << __LINE__ << "\n";
typedef pair <int, int> pi;
typedef pair <ll,ll> pl;
typedef pair <pi, int> pii;
typedef tuple<int,int,int> ti3;
string cts(char x) {string t(1,x); return t;}
ll rand(ll a, ll b) { return a + rng() % (b-a+1); }
const int MOD = 1e9 + 7;
template <typename T> void chmax(T& a, T b) {
	a = max(a, b);
}
template <typename T> void chmin(T& a, T b) {
	a = min(a, b);
}
#define MAXN
#if !testing
#define cerr if(0)cout
#endif
ll C[2005][2005];
int32_t main() {
	IAMSPEED
	C[0][0]=1;
	FOR(i,1,2004) {
		C[i][0] = 1;
		FOR(j,1,i) {
			C[i][j] = (C[i-1][j]+C[i-1][j-1])%MOD;
		}
	}
	ll n,k;cin>>n>>k;
	FOR(i,1,k) {
		cout<<(C[n-k+1][i]*C[k-1][i-1])%MOD<<'\n';
	}
}


Measured memory_bytes: 30336
from collections import Counter

#カードを引数に取って答えを出力する
def put_ans(cards):
  cards.sort()

  #10 ~ Aのストレート
  if cards == [1, 10, 11, 12, 13]:
    print("straight")
    return

  #それ以外のストレート
  for i in range(1,len(cards)):
    if cards[i] - cards[i - 1] != 1:
      break
  else:
    print("straight")
    return
  
  #result...カードの枚数の降順リスト
  result = [t[1] for t in Counter(cards).most_common()]

  if result == [1,1,1,1,1]:
    print("null")
  if result == [2,1,1,1]:
    print("one pair")
  if result == [2,2,1]:
    print("two pair")
  if result == [3,1,1]:
    print("three card")
  if result == [3, 2]:
    print("full house")
  if result == [4, 1]:
    print("four card")

def main():
  while True:
    try:
      cards = list(map(int, input().split(",")))
      put_ans(cards)
  
    except EOFError:
      break

main()


Measured memory_bytes: 6016
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vll;
#define INF 0x3f3f3f3f
#define MOD 998244353LL
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair

#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 300005
int n;
int p[MN];

bool chk(int l, int r){
    //cout << "checking " << l << " " << r << "\n";
    if((r-l)%2 != 0) return false;
    if(r == l) return true;
    //assert((r-l)%2 == 0);
    for(int i=l+1; i<=r-1; i+=2){
        if(p[i] != i) return false;
    }
    int cmx = -INF, cmn = -INF;
    for(int i=l; i<=r; i+=2){
        if(p[i] > i){
            if(cmn > p[i]) return false;
            cmn = p[i];
        } else if(p[i] < i){
            if(cmx > p[i]) return false;
            cmx = p[i];
        } else{
            return false;
        }
    }
    return true;
}

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

    cin >> n;
    FOR(i, 1, n) cin >> p[i];
    int l = 1;
    int cm = 0;
    FOR(r, 1, n){
        cm = max(cm, p[r]);

        if(cm == r){
            if(!chk(l, r)){
                cout << "No\n";
                return 0;
            }
            l = r+1;
        }
    }
    cout << "Yes\n";
    
    return 0;
}


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

using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int n; cin>>n;
	cout<<(n+1)/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define  ll  long long
#define  pi  pair<int,int>
#define  pb  push_back
#define  F   first
#define  S   second
#define  B   begin()
#define  E   end()
const int N=2e5+3;
//string s,p;
//vector<int>v;
//map<int,int>mp;

int main()
{
    ft
    ll t,i,j,n,m,l,r,s=0;
    cin>>n>>m;
    vector<int>v1,v2;
    for(i=0;i<m;i++)
    {
        cin>>l>>r;
        v1.pb(l);
        v2.pb(r);
    }
    sort(v1.B,v1.E);
    sort(v2.B,v2.E);
    for(i=1;i<=n;i++)
    {
        l=upper_bound(v1.B,v1.E,i)-v1.B;
        r=lower_bound(v2.B,v2.E,i)-v2.B;
        if((l-r)==m)
        {
            s++;
        }
    }
    cout<<s<<"\n";
    return 0;
}

Measured memory_bytes: 4252
// #pragma GCC optimize(“O2”)
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include<bitset>
using namespace std;
#define pi 3.14159265358979323846264338327950254
 #define STDIN freopen("in.txt","r",stdin); freopen("out.txt","w",stdout);//************************************
 
#define ll long long
// #define int ll

const int mod = 100999;
const int N = 3e5 +10;
int son[N];
int main()
{
    // STDIN
    int n;
    cin >> n; 
    for (int i = 2; i <= n; i++)
    {
        int t; cin >> t;
        son[t]++;
    }
    for (int i = 1; i <= n; i++)
    {
        cout << son[i] << endl;
    }
}


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

typedef long long i64;

const int MAXN = 100000 + 5;
const int MOD = 1e9 + 7;

int N;
i64 answer, dp[MAXN];
int degree[MAXN], lenCnt[MAXN];
int pre[MAXN], nxt[MAXN];
bool vis[MAXN];

bool noSolution = false;

void findCycle()
{
	for (int i = 1; i <= N; i++)
	{
		if (degree[i] > 2)
			return noSolution = true, (void) 0;
		if (degree[i] != 2 || vis[i])
			continue;

		int cur = i;

		do
		{
			if (vis[cur])
				return noSolution = true, (void) 0;
			vis[cur] = true;
			pre[nxt[cur]] = cur;
			cur = nxt[cur];
		} while (cur != i);
	}
}

void processCircleBasedTree()
{
	for (int i = 1; i <= N; i++)
	{
		if (degree[i])
			continue;

		int cur = i, footLen = 0, cycleLen = 0;
		while (!vis[cur])
			vis[cur] = true,
			cur = nxt[cur],
			footLen++;
		do
			cur = pre[cur],
			cycleLen++;
		while (degree[cur] == 1);
		if (footLen < cycleLen)
			answer = answer * 2 % MOD;
		if (footLen > cycleLen)
			return noSolution = true, (void) 0;
	}
}

void countCycle()
{
	for (int i = 1; i <= N; i++)
	{
		if (vis[i])
			continue;
		int cur = i, len = 0;
		do
		{
			vis[cur] = true;
			cur = nxt[cur];
			len++;
		} while (cur != i);
		lenCnt[len]++;
	}
}

int main()
{
	answer = 1;
	ios::sync_with_stdio(false), cin.tie(nullptr);
	cin >> N;

	for (int i = 1; i <= N; i++)
		cin >> nxt[i], degree[nxt[i]]++;

	findCycle();
	if (noSolution)
		return cout << 0 << endl, 0;
	processCircleBasedTree();
	if (noSolution)
			return cout << 0 << endl, 0;
	countCycle();
	if (noSolution)
		return cout << 0 << endl, 0;

	for (int i = 1; i <= N; i++)
	{
		dp[0] = 1LL;
		for (int j = 1; j <= lenCnt[i]; j++)
		{
			dp[j] = dp[j - 1] * (((i % 2 == 0) || i == 1) ? 1 : 2);
			if (j >= 2)
				dp[j] = (dp[j] + ((((dp[j - 2] * (j - 1)) % MOD) * i) % MOD))
						% MOD;
		}

		answer = answer * dp[lenCnt[i]] % MOD;
	}
	cout << answer << endl;
}



Measured memory_bytes: 1920
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)

struct UnionFind {
  //自身が親であれば、その集合に属する頂点数に-1を掛けたもの
  //そうでなければ親のid
  vector<int> r;

  UnionFind(int n) {
    r = vector<int>(n, -1);
  }

  int root(int x) {
    if (r[x] < 0) return x;
    return r[x] = root(r[x]);
  }

  bool unite(int x, int y) {
    x = root(x);
    y = root(y);
    if (x == y) return false;
    if (r[x] > r[y]) swap(x, y);
    r[x] += r[y];
    r[y] = x;
    return true;
  }

  int size(int x) {
    return -r[root(x)];
  }
};

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  
  //友達集合を作る
  UnionFind UF(n);
  int a,b;
  rep(i,m){
    cin >> a >> b;
    a -= 1; b -= 1;
    UF.unite(a, b);
  }

  //最大の友達集合を求める
  int ans = 0;
  rep(i,n){
    ans = max(ans, UF.size(i));
  }

  cout << ans << endl;
}

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

int main(){
    int A,B;
  	cin >> A >> B;
  	if(A % 2 != B % 2){
      cout << "IMPOSSIBLE" <<endl;
    }
  	else{
      cout << (A + B) / 2 <<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  lint N, K;
  cin >> N >> K;
  vector<lint> A(N);
  REP(i, N) cin >> A[i];
  vector<lint> A2(N*2);
  REP(i, N) {
    A2[i] = A[i];
    A2[i+N] = A[i];
  }
  vector<lint> last(200001, -1);
  vector<vector<lint>> next(N, vector<lint>(60));
  IREP(i, 2*N) {
    if(i < N) {
      next[i][0] = last[A2[i]]+1-i;
    }
    last[A2[i]] = i;
  }
  FOR(k, 1, 60) REP(i, N) next[i][k] = min(next[i][k-1] + next[(i+next[i][k-1])%N][k-1], N*K+1);
  lint now = 0;
  while(true) {
    bool flg = false;
    IREP(k, 60) {
      if(now + next[now%N][k] < N*K) {
        now += next[now%N][k];
        flg = true;
        break;
      }
    }
    if(!flg) break;
  }
  vector<lint> ans;
  vector<lint> cnt(200001);
  while(now < N*K) {
    if(cnt[A[now%N]] > 0) {
      while(true) {
        lint tmp = ans[ans.size()-1];
        cnt[tmp]--;
        ans.pop_back();
        if(tmp == A[now%N]) break;
      }
    } else {
      ans.push_back(A[now%N]);
      cnt[A[now%N]]++;
    }
    now++;
  }
  REP(i, ans.size()) cout << ans[i] << (i!=ans.size()-1 ? " " : "");
  cout << "\n";
}

Measured memory_bytes: 112624
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;

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

int main()
{
	int n, x;
	cin >> n >> x;
	vector<int> a(n);
	REP(i, n) cin >> a[i];

	sort(ALL(a));

	REP(i, n){
		x -= a[i];
		if (x < 0){
			cout << i << endl;
			return 0;
		}
	}
	if (x == 0) cout << n << endl;
	else cout << n - 1 << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<bitset>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
ll fact(ll x, ll k, ll p) {//最大値、個数、あまり
	ll sum = 1;
	for (int i = 0; i < k; i++) {
		sum *= (x--);
		sum %= p;
	}
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
short ctos(char a) {
	return (int)(a - '0');
}
#define int long long
const long long Inf = 4523372036854775807;
const int inf = 15000000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n,m;
int a[100];
signed main() {
	cin>>n>>m;
	for(int i=0;i<2*m;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++){
		cout<<a[i]<<endl;
	}
}


Measured memory_bytes: 256
import java.util.Scanner;

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

        long A = scanner.nextLong();
        long B = scanner.nextLong();
        long K = scanner.nextLong();

        if (K <= A) {
            System.out.printf("%d %d%n", A - K, B);
        } else {
            B = Math.max(0, B - (K - A));
            System.out.printf("%d %d%n", 0, B);
        }
    }
}


Measured memory_bytes: 35820
import java.io.*;
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		System.out.println(s.equals("abc")||s.equals("acb")||s.equals("bac")||s.equals("bca")||s.equals("cab")||s.equals("cba")?"Yes":"No");
	}
}

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


void solve(string S){
    int sz = S.size();
    int evencnt1=0, evencnt2=0;
    int oddcnt1=0, oddcnt2=0;
    
    for(int i=0; i<sz; i++) {
        if(i % 2 ==0) {
            // 偶数番目の文字
            if (S[i] == '1') evencnt1++;
            else             evencnt2++; 
        } else {
            // 奇数番目の文字
            if (S[i] == '1') oddcnt1++;
            else             oddcnt2++; 
        }
    }
    // 偶数番目を1にする場合
    int t1 = evencnt2 + oddcnt1;
    // 偶数番目を0にする場合
    int t2 = evencnt1 + oddcnt2;
    cout << min(t1,t2) << endl;

}

// Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    string S;
    cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define fore(b,c) for(int val0=b;val0<c;val0++)
#define forr(k,c,s) for(int k=c;k<s;k++)
#define pb push_back
#define mmp make_pair
using namespace __gnu_pbds;
using namespace std;
template<typename T>
using oset = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
typedef pair<int,int> ii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long double ld;
typedef vector<vii> al;
typedef vector<ll> vl;
const int INF = 1e9;
const ll INFL = 1LL<<61;
int main() {
	ios::sync_with_stdio(0);cout.precision(20);cout.tie(0);cin.tie(0);
	ll a,v,b,w,ti;
	cin >> a >> v >> b >> w >> ti;
	ll di = abs(a-b);
	ll dv = v-w;
	if(dv*ti >= di) {
		cout << "YES\n";
	} else {
		cout << "NO\n";
	}
}



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

ll power[70];

int main(){
    power[0]=1;
    for(int i=1; i<70; i++){
        power[i] = 2*power[i-1];
    }
    ll X, Y;
    cin >> X >> Y;
    for(int i=0; i<70; i++){
        if(X*power[i]==Y){
            cout << i+1 << endl;
            return 0;
        }
        if(X*power[i]>Y){
            cout << i << endl;
            return 0;
        }
    }    
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cstring>
#include <climits>
#include <algorithm>
#include <map>

using namespace std;

void fowardChar(string &text, int &cur) {
    if (cur == (int)text.size()-1) return ;
    swap(text[cur], text[cur+1]);
    cur ++;
}

void fowardWord(string &text, int &cur) {
    if (cur == (int)text.size()-1) return ;
    while (1) {
        fowardChar(text, cur);
        if (cur == (int)text.size()-1) break;
        if (text[cur-1] != ' ' && text[cur+1] == ' ') break;
    }
}

void backwardChar(string &text, int &cur) {
    if (cur == 0) return ;
    swap(text[cur], text[cur-1]);
    cur --;
}

void backwardWord(string &text, int &cur) {
    if (cur == 0) return ;
    while (1) {
        backwardChar(text, cur);
        if (cur == 0) break;
        if (text[cur+1] != ' ' && text[cur-1] == ' ') break;
    }
}

void deleteChar(string &text, int &cur) {
    if (cur == (int)text.size()-1) return ;
    text.erase(text.begin()+cur+1);
}

void deleteWord(string &text, int &cur) {
    if (cur == (int)text.size()-1) return ;
    int pos = cur+1;
    while (pos+1 < (int)text.size()) {
        if (text[pos] == ' ' || (text[pos] != ' ' && text[pos+1] != ' ')) {
            pos ++;
        } else {
            break;
        }
    }
    if (text[pos] == ' ') return ;
    for (int i=0; i<pos-cur; ++i) {
        deleteChar(text, cur);
    }
}

void insert(string &text, int &cur, string anytext) {
    text = text.substr(0, cur) + anytext + text.substr(cur);
    cur += anytext.size();
}

int main() {
    int N, M;
    cin >> N; cin.ignore();
    for (int i=0; i<N; ++i) {
        string text, com;
        getline(cin, text);
        text = "^" + text;
        int cur = 0;
        cin >> M; cin.ignore();
        for (int j=0; j<M; ++j) {
            getline(cin, com);
            if (com == "forward char") fowardChar(text, cur);
            else if (com == "forward word") fowardWord(text, cur);
            else if (com == "backward char") backwardChar(text, cur);
            else if (com == "backward word") backwardWord(text, cur);
            else if (com == "delete char") deleteChar(text, cur);
            else if (com == "delete word") deleteWord(text, cur);
            else { // insert anytext
                string anytext = com.substr(8, (int)com.size()-9);
                insert(text, cur, anytext);
            }
        }
        cout << text << endl;
    }
    return 0;
}

Measured memory_bytes: 1240
import bisect
import copy
import heapq
import sys
import itertools
import math
import queue
from functools import lru_cache
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
mod = 10 ** 9 + 7 

def read_values(): return map(int, input().split())
def read_index(): return map(lambda x: int(x) - 1, input().split())
def read_list(): return list(read_values())
def read_lists(N): return [read_list() for n in range(N)]


def main():
    N, M = read_values()
    L = [set() for _ in range(N)]
    for _ in range(M):
        a, b = read_index()
        L[a].add(b)
        L[b].add(a)

    res = 0
    for T in itertools.permutations(range(1, N)):
        pre = 0
        for t in T:
            if t not in L[pre]:
                break
            pre = t
        else:
            res += 1

    print(res)


if __name__ == "__main__":
    main()



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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define endl '\n'
#define w(t) int t;cin>>t;while(t--)
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define rep(i,a,b) for(int i=a; i<b; ++i)
#define repl(i,a,b) for(ll i=a; i<b; ++i)
#define PI 3.14159265358979323846264338327950L

int main(){
	IOS

	long double a,b,h,m;
	cin>>a>>b>>h>>m;
	long double rad = (h+((m/12.0)-m)/5.0) * PI/6.0;
	long double ans = (a*a + b*b) - (2*a*b)*cosl(rad);
	cout<< fixed<< setprecision(20)<<sqrtl(ans)<<endl; 
}

Measured memory_bytes: 4180
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sumvec(vector<S>&a){return accumulate(all(a),S());}
template<class S>S maxvec(vector<S>&a){return *max_element(all(a));}
template<class S>S minvec(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}


int main(void){
  	cin.tie(0);
  	ios::sync_with_stdio(false);
    
    ll n,k,s;
    cin>>n>>k>>s;
    ll max=1000000000;
    rep(i,n){
        if(i<k) cout<<s;
        else if(k<=i){
            if(s==max) cout<<max-1;
            else cout<<s+1;
        }
        if(i==n-1) cout<<endl;
        else cout<<" ";
    }

}


Measured memory_bytes: 1280
loop do
  n, m, pct = gets.chomp.split.map(&:to_i)
  break if n + m + pct == 0
  x = []
  
  n.times do
    x << gets.to_i
  end
  
  puts x[m - 1] == 0 ? 0 : x.inject(&:+) * 100 * (100 - pct) / 100 / x[m - 1]
end

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

const int t=0,y=1,t2=2,y2=3;
int dp[100][100][4];
int w,h;

int main(){
	while(scanf("%d%d",&w,&h),w){
		for(int i=0;i<100;i++) for(int j=0;j<100;j++) for(int r=0;r<4;r++) dp[i][j][r]=0;
		dp[0][1][y2]=1;
		dp[1][0][t2]=1;
		for(int i=0;i<h;i++){
			for(int j=0;j<w;j++){
				if(i!=0){
					dp[i][j][t2]+=dp[i-1][j][t2]+dp[i-1][j][t];
					dp[i][j][t]+=dp[i-1][j][y2];
					dp[i][j][t]%=100000;dp[i][j][t2]%=100000;
				}
				if(j!=0){
					dp[i][j][y2]+=dp[i][j-1][y2]+dp[i][j-1][y];
					dp[i][j][y]+=dp[i][j-1][t2];
					dp[i][j][y]%=100000;dp[i][j][y2]%=100000;
				}
			}
		}
		int res=0;
		for(int i=0;i<4;i++)res+=dp[h-1][w-1][i];
		printf("%d\n",res%100000);
	}
}

Measured memory_bytes: 1344
#include <bits/stdc++.h>
using namespace std;
#define INF 2000000000
typedef long long int ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1<<(i))))
#define setbit1(n,i) ((n)(1<<(i)))
#define togglebit(n,i) ((n)^(1<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL)
#define mod (1000000007)
#define asz 500005
#define t int t;scanf("%d",&t);for(int v=1;v<=t;v++)
#define loop_arr(i,a,b) for(int i=a;i<b;i++)
#define loop_norm(i,a,b) for(int i=a;i<=b;i++)
#define minheap priority_queue<int,vector<int>,greater<int> >
#define maaheap priority_queue<int>
#define pb push_back
#define newl "\n"
ll BIGMOD ( ll a, ll p, ll m )
{
    ll result = 1;
    ll x = a;

    while ( p )
    {
        if ( p & 1 ) //p is odd
        {
            result = ( result * x ) % m;
        }
        x = ( x * x ) % m;
        p = p >> 1;
    }

    return result;
}

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;
}

void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {

        if (prime[p] == true)
        {
            for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
}
const int MAX=100005;
ll memo[MAX][3];
 int arr[MAX][3];
 int n;
 void init()
 {
     for(int i=0;i<=n;i++)
     {
         for(int j=0;j<3;j++) memo[i][j]=-1;
     }
 }
ll vacation(int i,char current)
{
    if(i==n) return 0;
    if(memo[i][current-'A']!=-1) return memo[i][current-'A'];
    if(current=='A')
    {
        ll res1=arr[i][0]+vacation(i+1,'B');
        ll res2=arr[i][0]+vacation(i+1,'C');
        return memo[i][0]=max(res1,res2);
    }
    if(current=='B')
    {
        ll res1=arr[i][1]+vacation(i+1,'A');
        ll res2=arr[i][1]+vacation(i+1,'C');
        return memo[i][1]=max(res1,res2);
    }
    if(current=='C')
    {
        ll res1=arr[i][2]+vacation(i+1,'A');
        ll res2=arr[i][2]+vacation(i+1,'B');
        return memo[i][2]=max(res1,res2);
    }


}

int main()
{
  // fastread;
   cin>>n;
   init();
   for(int i=0;i<n;i++)
   {
       for(int j=0;j<3;j++) cin>>arr[i][j];
   }
   ll res1=vacation(0,'A');
   ll res2=vacation(0,'B');
   ll res3=vacation(0,'C');
   cout<<max(res1,max(res2,res3))<<newl;
  return 0;
}


Measured memory_bytes: 8448
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>

using namespace std;

long long int INF = 1000000000000000000LL; // 10^18

typedef pair<int, int> P;

vector<int> E[200];

P far_v(int pre, int cur){
	P p;
	p.first = -1;
	p.second = cur;
	for(int i = 0; i < E[cur].size(); i++){
		if(E[cur][i] != pre){
			P p1 = far_v(cur, E[cur][i]);
			if(p1.first > p.first){
				p.first = p1.first;
				p.second = p1.second;
			}
		}
	}
	p.first++;
	return p;
}

void dist_v(int dist, int pre, int cur, int d[]){
	d[cur] = dist;
	for(int i = 0; i < E[cur].size(); i++){
		if(E[cur][i] != pre){
			dist_v(dist + 1, cur, E[cur][i], d);
		}
	}
}

int main(){
	
	int N;
	cin >> N;
	
	for(int i = 0; i < N - 1; i++){
		int u, v;
		cin >> u >> v;
		u--;
		v--;
		E[u].push_back(v);
		E[v].push_back(u);
	}
	
	P p = far_v(-1, 0);
	int Ru1 = p.second;
	p = far_v(-1, Ru1);
	int D = p.first;
	int Ru2 = p.second;
	
	int d1[200] = {};
	int d2[200] = {};
	
	dist_v(0, -1, Ru1, d1);
	dist_v(0, -1, Ru2, d2);
	
	int cent;
	vector<int> u_can;
	if(D % 2 == 0){
		for(int i = 0; i < N; i++){
			if(d1[i] + d2[i] == D && d1[i] == d2[i]){
				cent = i;
			}
		}
		u_can.push_back(cent);
		for(int i = 0; i < E[cent].size(); i++){
			u_can.push_back(E[cent][i]);
		}
	}else{
		for(int i = 0; i < N; i++){
			if(d1[i] + d2[i] == D && (d1[i] - d2[i]) * (d1[i] - d2[i]) == 1){
				u_can.push_back(i);
			}
		}
		
		cent = u_can[1];
		u_can.pop_back();
	}
	
	long long int ans = INF;
	for(int loop = 0; loop < u_can.size(); loop++){
		int v2 = u_can[loop];
		
		int du[200] = {};
		int dv[200] = {};
		
		dist_v(0, -1, cent, du);
		dist_v(0, -1, v2, dv);
		
		long long int v_dist[200] = {};
		for(int i = 0; i < N; i++){
			int ret = min(du[i], dv[i]);
			v_dist[ret] = max(v_dist[ret], (long long int)E[i].size());
		}
		
		long long int cnt = 1;
		for(int i = 0; i < N; i++){
			cnt *= max(1LL, v_dist[i] - 1);
		}
		if(cent != v2){
			cnt *= 2;
		}
		if(cent == v2){
			cnt /= v_dist[0] - 1;
			cnt *= v_dist[0];
		}
		ans = min(ans, cnt);
	}
	cout << D / 2 + 1 << " " << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
use std::vec::Vec;
use std::collections::HashMap;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
    let n: usize = read();
    let a: Vec<i64> = read_vec();
    let mut acc = HashMap::<i64, i64>::new();
    let mut ans = 0;
    for i in 0..n {
      let b =  (i as i64 + 1) + a[i];
      let c = - a[i] + (i as i64 + 1);
      if let Some(x) = acc.get(&(i as i64 + 1 - a[i])) {
        ans += x;
      }
     if let Some(x) = acc.get_mut(&b) {
       *x += 1;
     } else {
       acc.insert(b, 1);
     }
    }
    //println!("{:?}", acc);
    println!("{}", ans);
}


Measured memory_bytes: 12368
#include <iostream>
using namespace std;
 
int main() {
    int m, f, r;
    char c;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1)
            break;
        if (m == -1 || f == -1)
            c = 'F';
        else if ((m + f) >= 80)
            c = 'A';
        else if ((m + f) >= 65)
            c = 'B';
        else if ((m + f) >= 50)
            c = 'C';
        else if ((m + f) >= 30) {
            if (r >= 50)
                c = 'C';
            else
                c = 'D';
            } else
            c = 'F';
        cout << c << endl;
    }
    return 0;
}

Measured memory_bytes: 3084
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    ll n,m,v,p;
    cin >> n >> m >> v >> p;
    ll a[n];
    rep(i,n)cin >> a[i];
    sort(a,a+n,greater<ll>());


    int l = 0;
    int r = n-1;
    while(l < r){
        int x = (l + r) / 2 + 1;
        ll sum = 0;
        rep(i,n){
            if(i < p - 1){
                sum += m;
            }else if(x <= i){
                sum += m;
            }else{
                sum += max((ll)0, a[x] + m - a[i]);
            }
        }
        if(sum >= m * v && a[x] + m >= a[p-1]){
            l = x;
        }else{
            r = x - 1;
        }
    }

    cout << l + 1 << endl;
    
    return 0;
}
 
 


Measured memory_bytes: 1024
#include<iostream>
#include<cstdio>
#include<string>
#include<vector>
#include<algorithm>
#include<queue>
#include<set>
#include<unordered_map>
#include<string.h>
#define int long long
using namespace std;

signed main() {
	int ans = 0;
	int a; cin >> a;
	vector<int>V;
	for (int b = 0; b < a; b++) {
		int c; cin >> c;
		V.push_back(-c);
	}
	sort(V.begin(), V.end());
	for (int b = 0; b < a; b++) {
		int c = -V[b];
		ans += max(0ll, c - b / 4);
	}
	cout << ans+1 << endl;
}

Measured memory_bytes: 3144
#ifndef DEBUG
#pragma GCC optimize("O3,unroll-loops")
#pragma loop_opt(on)
#endif
#include <bits/stdc++.h>
using namespace std;

#ifdef DEBUG
#define FAST ;
#else
#define FAST ios::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define cerr
#endif
#define _ <<' '<<
#define Fr(i, s, e) for(auto i = s; i < e; ++i)
#define All(v) v.begin(),v.end()
#define Ft first
#define Sd second
using ll = long long;
using pii = pair<int, int>;
constexpr ll MOD = 1e9+7;

signed main() {
    FAST;

    ll n, k;
    cin >> n >> k;
    auto SS = [](ll x) { return x*(x+1)*(2*x+1)/6%MOD; };
    cout << ((n+2-k) + (n+2-k)*(n+1+k)/2*(n+1) - (SS(n+1)-SS(k-1)) )%MOD << endl;

}


Measured memory_bytes: 3652
import sys
def I(): return int(sys.stdin.readline().rstrip())
def S(): return sys.stdin.readline().rstrip()

N = I()
s = [''.join(sorted(S())) for i in range(N)]

from collections import Counter

c = Counter(s)
ans = 0
for i in c.keys():
    ans += c[i]*(c[i]-1)//2

print(ans)


Measured memory_bytes: 99360
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Object o = run();
        if (o != null)
            System.out.println(o);
    }

    private static ArrayList<Integer> nScan(Scanner sc, int n) {
        ArrayList<Integer> al = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            al.add(sc.nextInt());
        }
        return al;
    }

    private static Object run() {
        try (Scanner sc = new Scanner(System.in);) {
            int result = 0;
            char[] s = sc.next().toCharArray();
            char[] t = sc.next().toCharArray();
            //int y = sc.nextInt();
            //int t = sc.next();
            //ArrayList<Integer> x = nScan(sc, n);
            //ArrayList<Integer> y = nScan(sc, n);
            //ArrayList<String> s = nScan(sc, n);
            for (int i = 0; i < s.length; i++) {
                if (s[i] != t[i]) {
                    result++;
                }
            }
            return result;
        }
    }
}

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

using namespace std;

#define YES cout << "YES" << endl;
#define NO  cout << "NO"  << endl;
#define Yes cout << "Yes" << endl;
#define No  cout << "No"  << endl;
 
#define INF INT_MAX
#define MOD 1000000007
#define PI  acos(-1)

using ll  = long long;
using ull = unsigned long long;
using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

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

int main(int argc, char *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll W, H, x, y;
    cin >> W >> H >> x >> y;

    double ans = (double)(W) * double(H)/2;
    cout << fixed << setprecision(10) << ans << " ";

    if (x*2 == W && y*2 == H) {
        cout << 1 << endl;
    } else {
        cout << 0 << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <vector>

using namespace std;

int main() {
	int N;
	cin >> N;
	long *p = new long[N];
	long *r = new long[N];
	long *a = new long[N];
	long *b = new long[N];

	for (int i = 0; i < N; i++) {
		cin >> p[i];
		r[p[i] - 1] = i;
		a[i] = i + 1;
		b[i] = N - i;
	}

	long A = 0, B = 0;
	for (int i = 1; i < N; i++) {
		int c = r[i] - r[i - 1];
		if (c > 0) {
			A += c;
		}
		else if (c < 0) {
			B += c;
		}
		a[i] += A;
		b[i] += B;
	}

	if (b[N - 1] <= 0) {
		int c = 1 - b[N - 1];
		for (int i = 0; i < N; i++) {
			b[i] += c;
		}
	}

	for (int i = 0; i < N; i++) {
		cout << a[i] << " ";
	}
	cout << endl;
	for (int i = 0; i < N; i++) {
		cout << b[i] << " ";
	}
	cout << endl;
	return 0;
}

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

int main() {
  int n, x, y;
  cin >> n >> x >> y;

  vector<int> vec(n-1);
  for (int i = 1; i < n; i++) {
      for (int j = i+1; j <=n; j++) {
          int d;
          d = min(abs(j-i), abs(x-i)+1+abs(j-y));
          d = min(d, abs(y-i)+1+abs(j-x));
          vec.at(d-1)++;
      }
  }
  for (int i = 0; i < vec.size(); i++) {
      cout << vec.at(i) << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define pii pair <int, int>
#define fi first
#define sc second
#define ALL(x) x.begin(), x.end()
#define RALL(X) x.begin(), x.end()
#define FOR(i, n, k) for(i=0; i<n; i+=k)
#define FO(i, n, k) for(i=1; i<=n; i+=k)
#define CLEAR(a, b) memset(a, b, sizeof(a))
#define N 100005
#define mid ((l+r)/2)
#define dbg(x) (cerr << #x << " : " << x << endl)
#define endl "\n"
#define MOD 100000009

using namespace std;

typedef long long int lli;

int main(){
	ios_base::sync_with_stdio(false);
	int r, d, x;
	cin >> r >> d >> x;
	for(int i=0; i<10; i++){
		x = r*x - d;
		cout << x << endl;
	}	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    int i, j;
    int n;
    int card[4][14]={};
    char mark;
    int num;
    scanf("%d", &n);
    
    for (int i=0; i<n; i++) {
        scanf("%c", &mark);//改行読み込み
        scanf("%c %d", &mark, &num);
        if (mark == 'S') {
            card[0][num-1] = num;
        }else if(mark == 'H'){
            card[1][num-1] = num;
        }else if(mark == 'C'){
            card[2][num-1] = num;
        }else if(mark == 'D'){
            card[3][num-1] = num;
        }
    }
    
    /*
    for (j=0; j<4; j++) {
        for (i=0; i<13; i++) {
            if (card[j][i] == -1) {
                printf("%d\n", card[j][i]);
            }
        }
    }
     */
    //確認用
    
    for (j=0; j<4; j++) {
        for (i=0; i<13; i++) {
            if (card[j][i] == 0) {
                switch (j) {
                    case 0:
                        printf("S %d\n", i+1);
                        break;
                    case 1:
                        printf("H %d\n", i+1);
                        break;
                    case 2:
                        printf("C %d\n", i+1);
                        break;
                    case 3:
                        printf("D %d\n", i+1);
                        break;
                    default:
                        break;
                }
            }
        }
    }
    
    return 0;
}


Measured memory_bytes: 2744
#include <stdio.h>
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
using namespace std;
#define ll long long
const double EPS = 1e-10;
const ll MOD = 7+(1e+9);

bool asc(ll left,ll right) {
  return left > right;
}


int main (){
  ll x,y,z,k;
  cin>>x>>y>>z>>k;
  vector<ll>a(x,0);
  vector<ll>b(y,0);
  vector<ll>c(z,0);
  vector<ll>ab(x*y,0);
  for(ll i=0;i<x;i++){
    cin>>a[i];
  }
  for(ll i=0;i<y;i++){
    cin>>b[i];
  }
  for(ll i=0;i<z;i++){
    cin>>c[i];
  }
  sort(a.begin(),a.end(),asc);
  sort(b.begin(),b.end(),asc);
  sort(c.begin(),c.end(),asc);
  for(ll i=0;i<x;i++){
    for(ll j=0;j<y;j++){
      ab[i*y+j]=a[i]+b[j];
    }
  }
  sort(ab.begin(),ab.end(),asc);
  ab.resize(min(k,x*y));
  vector<ll>abc;
  for(ll i=0;i<(ll)ab.size();i++){
    for(ll j=0;j<z;j++){
      abc.push_back(ab[i]+c[j]);
    }
  }
  sort(abc.begin(),abc.end(),asc);
  for(ll i=0;i<k;i++){
    cout<<abc[i]<<endl;
  }
}


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

#define sz(a) int((a).size())
#define all(c) c.begin(), c.end()
#define ll long long
#define pb push_back
#define zoom                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define pl pair<ll, ll>
#define MOD 1000000007
#define endl "\n"
#define ff first
#define ss second
#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 trace(v)                                   \
    for (auto it = v.begin(); it != v.end(); it++) \
        cerr << *it << " ";                        \
    cerr << endl;
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)

#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)

typedef pair<int, int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<vi> vvi;
ll cal(ll n){
    return ((n)*(n+1))/2;
}

void solve()
{
    int n;
    cin>>n;

    ll ans=0;
    for(ll i=1;i<=n;i++){
        ans+=(i)*(cal(n/i));
    }

    cout<<ans<<endl;
}

int main()
{
    zoom;
    ll t=1;
    //cin >> t;

    while (t--)
    {
        solve();
    }
}

Measured memory_bytes: 3608
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include<string>
#include<utility>
#include<array>
#include<set>
#include <numeric>
#include <stdio.h>
#include <map>
//#include <boost/math/common_factor_rt.hpp>
#include<fstream>
#define EPS (1e-7)
using namespace std;
#define ll long long




int main() {

	int N;
	cin >> N;
	
	vector<int> vs(N);

	for (auto& v:vs)
	{
		cin >> v;
	}

	sort(vs.begin(), vs.end());

	double ans = (vs[0]+vs[1])/2.0;



	for (auto i = 2; i < N; i++) {

		ans = (ans + vs[i]) / 2.0;

	}

	cout << std::fixed << ans << endl;
	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

import Control.Applicative ((<$>))
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as BS

main :: IO ()
main = do
  n <- read <$> getLine
  s <- VU.unfoldrN n BS.uncons <$> BS.getLine
  print $ VU.maximum
    $ VU.map (\ !gap -> min gap $ test s $ VU.drop gap s)
    $ VU.tail $ VU.generate n id

test :: VU.Vector Char -> VU.Vector Char -> Int
test v1 v2
 = VU.maximum
   $ VU.scanl' (\ !l !b -> if b then l+1 else 0) (0::Int)
   $ VU.zipWith (==) v1 v2


Measured memory_bytes: 764
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.PrintStream;

class Main {

    public static void main(String[] args) throws IOException {
        doit(args, System.in, System.out);
    }

    static void doit(String[] args, InputStream in, PrintStream out)
            throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(in));
        String line = null;
        while ((line = reader.readLine()) != null) {
            if (line.isEmpty()) {
                continue;
            }
            int n = Integer.parseInt(line);
            for (int i = 0; i < n; i++) {
                reader.readLine();
                int[][] cells = new int[14][14];
                for (int j = 0; j < 8; j++) {
                    line = reader.readLine();
                    for (int k = 0; k < 8; k++) {
                        cells[j + 3][k + 3] = line.charAt(k) - '0';
                    }
                }
                int x = Integer.parseInt(reader.readLine()) + 2;
                int y = Integer.parseInt(reader.readLine()) + 2;
                solve(cells, x, y);
                out.println("Data " + (i + 1) + ":");
                for (int j = 0; j < 8; j++) {
                    for (int k = 0; k < 8; k++) {
                        out.print(cells[j + 3][k + 3] & 1);
                    }
                    out.println();
                }
            }
        }
    }

    private static void solve(int[][] cells, int x, int y) {
        cells[y][x] |= 2;
        if ((cells[y][x] & 1) == 0) {
            return;
        }
        cells[y][x] &= ~1;
        for (int[] flame : flames) {
            solve(cells, x + flame[0], y + flame[1]);
        }
    }

    private static int[][] flames = { { 1, 0 }, { 2, 0 }, { 3, 0 }, { 0, 1 },
            { 0, 2 }, { 0, 3 }, { -1, 0 }, { -2, 0 }, { -3, 0 }, { 0, -1 },
            { 0, -2 }, { 0, -3 } };
}

Measured memory_bytes: 10000
from collections import Counter
from operator import mul
from functools import reduce


n = int(input())
A = list(map(int, input().split()))
cnt_a = Counter(A)
memo = [1] * 1000001
for a in A:
    memo[a] = 1
A.sort()
a_max = max(A)
for a in A:
    if not memo[a]:
        continue
    for i in range(a * 2, a_max + 1, a):
        memo[i] = -1
for l in cnt_a.keys():
    if cnt_a[l] >= 2:
        memo[l] = "daburi"
ans = 0
for a in A:
    if memo[a] == 1:
        ans += 1
print(ans)


Measured memory_bytes: 145164
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>

#include <set>
#include <map>
#include <iomanip>

using namespace std;

#define rep(i, n) for(long long i = 0; i < (long long)(n); i++)
#define all(x) (x).begin(),(x).end()

using ll = long long;

int main()
{
	ll N, K, interval;
	string shift_table;

	cin >> N >> K >> interval;
	cin >> shift_table;

	vector<int> fronts, backs;

	// 前から
	int index = 0;
	for (auto i = 0; i < N; i++)
	{
		if (shift_table[i] == 'o')
		{
			fronts.push_back(i);
			i += interval;
		}
	}

	// 後ろから
	index = 0;
	for (auto i = N - 1; i >= 0; i--)
	{
		if (shift_table[i] == 'o')
		{
			backs.push_back(i);
			i -= interval;
		}
	}

	// どちらにもあるものがans
	rep(i, K)
	{
		if (fronts[i] == backs[K - i - 1])
		{
			cout << fronts[i] + 1 << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 3448
#include <bits/stdc++.h>
#include <stdio.h>
#include <math.h>
using namespace std;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using ll = long long int;
 
 
void dfs_2(ll r, ll x, const vi &query, vector<bool> &ald, const vvi &tree, vi &res){
    ald[r] = true;
    x += query[r];
    res[r] += x;
    for (auto p : tree[r]) { 
        if(ald[p] == true){continue;}
        dfs_2(p, x, query, ald, tree, res);
    }
    return;
}
 
int main(){
    ll N, Q;
    cin >> N >> Q;
    vvi vec(N+1, vi(0));
    for(int i=0; i<N-1; i++){
      int a, b; cin >> a >> b;
      vec[a].emplace_back(b);
      vec[b].emplace_back(a);
    }
    vi query(N+1, 0);
    for(int i=0; i<Q; i++){
        int a, b;
        cin >> a >> b;
        query[a] += b;
    }
 
    vi res(N+1, 0);
    vector<bool> ald_2(N+1, false);
 
    dfs_2(1, 0, query, ald_2, vec, res);
 
    for(int i=1; i<N+1; i++){
        cout << res[i] << " ";
    }
}


Measured memory_bytes: 30592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF (INT_MAX / 4)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
/* clang-format off */
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int n, m, ans = 0;
  cin >> n >> m;
  vector<int> h(n);
  vector<vector<int>> g(n, vector<int>(0));
  REP(i, n) { cin >> h.at(i); }
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g.at(a).push_back(b);
    g.at(b).push_back(a);
  }

  REP(i,n){
    bool f = true;
    REP(j,g.at(i).size()){
      if (h.at(i) <= h.at(g.at(i).at(j))) f = false;
    }
    if (f) ans++;
  }

  cout << ans << "\n";
  return 0;
}


Measured memory_bytes: 8800
#include<iostream>
#include<string>
#include<vector>
#include<deque>
using namespace std;

int main() {

    string s, ans = "";

    cin >> s;

    for(int i = 0; i < s.size(); i++) {
        ans += s[s.size() - i - 1];
    }

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

Measured memory_bytes: 0