akhauriyash/Code-Regression huggingface dataset:
//author:luckYrat(twitter:@luckYrat_)
//#include <bits/stdc++.h>

//def
#include <iostream>

#include <cmath>
#include <algorithm>
#include <iomanip>

//array
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <utility>
#include <climits>



using namespace std;

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

#define anyfill(n,s) setw(n) << setfill(s)
#define loop(s) for(int i = 0; s > i; i++)
#define rep(i,q) for(int i = 0; (q) > i; i++)
#define repp(i,n,q) for(int i = n; (q) > i; i++)
#define dep(i,q) for(int i = (q); 0 < i; i--)


#define MAX 1000000000
const int mod = 1000000007;
#define EPS (1e-10)

#define pb push_back
#define fir first
#define scn second
#define ednl endl

#define YesNo(a) (a?"Yes":"No")
#define YESNO(a) (a?"YES":"NO")
#define yesno(a) (a?"yes":"no")



/*
確認ポイント
cout << fixed << setprecision(n) << 小数計算//n桁の小数表記になる
vector.unique()は隣接した同じ要素を削除するので先にソートをする

計算量は変わらないが楽できるシリーズ
C++11以降でmin({a,b,c...})で複数個のmic,maxを処理できる
min(max)_element(iter,iter)で一番小さい(大きい)値のポインタが帰ってくる
count(iter,iter,int)でintがiterからiterの間にいくつあったかを取得できる

*/
__attribute__((constructor))
void initial() {
 cin.tie(0);
 ios::sync_with_stdio(false);
}
int main() { 
  int n;cin>>n;
  vector<int> a(n);
  for(int i = 0; n > i; i++){
    cin>>a[i];
  }
  int mx = n+1;
  int ans = 0;
  for(int i = 0; n > i; i++){
    if(mx > a[i]){
      ans++;
      mx = a[i];
    }

  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include<math.h>
using namespace std;
#define int long long int
#define endl "\n"
#define PI 3.14159265
const int mod=1e9+7;
//const int mod=1e9+7;
const int INF =LONG_LONG_MAX;
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int pow(int a,int n,int mod){if(n==0)return 1;int p=pow(a,n/2,mod);p=(p%mod*p%mod)%mod;if(n%2) return (p%mod*a%mod)%mod;else return p;}

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

    int n,k;
    cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){cin>>a[i];}
    int dp[n+1][k+1];
    int pre[n+1][k+1];

    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=k;j++)
        {
            dp[i][j]=0;
            if(j==0){dp[i][j]=1;pre[i][j]=dp[i][j];continue;}
            if(i==0){dp[i][j]=0;pre[i][j]=1;continue;}
              int d=min(a[i-1],j);
              dp[i][j]=(pre[i-1][j]-((j-d-1)>=0?pre[i-1][j-d-1]:0)+mod)%mod;
             pre[i][j]=(pre[i][j-1]%mod+dp[i][j]%mod)%mod;
        }
    }
    cout<<dp[n][k]%mod<<endl;

    return 0;
}


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

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

  int n, m, T[110];
  ll sum = 0;

  cin >> n;
  rep(i, n) {
    int t;
    cin >> t;
    T[i] = t;
    sum += t;
  }
  cin >> m;
  rep(i, m) {
    int p, x;
    cin >> p >> x;
    cout << sum - T[p-1] + x << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define FASTIO cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define ll long long int
#define F first
#define S second
#define pll pair<ll,ll>
#define vl vector<ll>
#define vi vector<int>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vpii vector<pair<int,int> >
#define vvpii vector<vpii >
#define vpll vector<pair<ll,ll> >
#define vvpll vector<vpll >
#define pb push_back
#define MOD 1000000007

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> new_data_set;

struct compare {
	bool operator() (const pair<int, int> &a, const pair<int, int> &b) const {
		if ((a.S - a.F) != (b.S - b.F)) return ((a.S - a.F) > (b.S - b.F));
		else return (a.F < b.F);
	}
};

int main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	FASTIO;
	ll n;
	cin >> n;
	vector<double> dp(n + 1); dp[0] = 1;
	for (int i = 0; i < n; i++) {
		double temp; cin >> temp;
		for (int j = i + 1; j >= 0; j--) {
			dp[j] = ((j == 0) ? 0 : dp[j - 1]) * temp + dp[j] * (1 - temp);
		}
		// for (int k = 0; k <= n; k++) cout << dp[k] << " ";
		// cout << endl;
	}

	double ans = 0;
	for (int i = n / 2 + 1; i <= n; i++) {
		ans += dp[i];
	}
	printf("%.10lf\n", ans);
}

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

int main()
{
    //　数値の定義
    int A,C; //体力
    int B,D; //攻撃力
    cin >> A;
    cin >> B;
    cin >> C;
    cin >> D;

    // 出力
    int resultA = (double)C / (double)B + 0.999999;
    int resultB = (double)A / (double)D + 0.999999;


    
    //判定
    if(resultA <= resultB){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3132
#include <iostream>
using namespace std;
void ABC100(void);
void ABC101(void);
void ABC102(void);
void ABC103(void);
void ABC104(void);
void ABC105(void);
void ABC106(void);
void ABC107(void);
void ABC108(void);
void ABC109(void);

int main(void){
    ABC105();
}

void ABC105(){
    int n,k;
    cin>>n>>k;
    if(n%k==0)cout<<0<<endl;
    else cout<<1<<endl;
}

Measured memory_bytes: 256
/*
T(i, j) 投完前 i 个硬币，j 个 head 的概率
T(1, 0) = 1 - p_1
T(1, 1) = p_1

T(i, j) = T(i-1, j) * (1_p_j) + T(i-1, j-1) * p_j
*/
package main

import "fmt"

const N = 3005
var T [N]float64
var p [N]float64

func main() {
  var n int
  fmt.Scanf("%d", &n)
  for i := 1; i <= n; i++ {
    fmt.Scanf("%f", &p[i])
  }
  for i := 1; i <= n; i++ {
    T[i] = 0
  }
  T[0] = 1
  for i := 1; i <= n; i++ {
    for j := i; j >= 0; j-- {
      T[j] = T[j] * (1-p[i]) 
      if j-1 >= 0 {
        T[j] += T[j-1] * p[i]
      }
    }
  }
  var res float64
  for i := (n+1)>>1; i <= n; i++ {
    res += T[i]
  }
  fmt.Println(res)
}

Measured memory_bytes: 2124
H,W,K = map(int,input().split())
C = [[]*W]*H
for i in range(H):
  C[i] = list(str(input()))
#print(C)
ans = 0
for maskh in range((1<<H)-1):
  for maskw in range((1<<W)-1):
    black = 0
    for i in range(H):
      for j in range(W):
        #print(i,j,C)
        if (maskh >> i) & 1 == 0 and (maskw >> j) & 1 == 0 and C[i][j] == "#":
          black += 1
    if black == K:
      ans += 1
print(ans)

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

int main() {
  
int N,K;
  cin>>N>>K;
  int S[N];//S=i's Score
  double p[N];//i's all patern
  double w[N];//i's win patern

for(int i=0;i<N;i++){
  S[i]=i+1;
  p[i]=1.0;
  if(S[i]>=K){
   w[i]=1.0;
  }
  else {
  while(S[i]<K){
    S[i] *=2;
    p[i] *=2.0;
  
  }
    w[i]=1.0;
  }
}


  double ans=0;
    for(int j=0;j<N;j++){
    ans +=w[j]/(N*p[j]);
  }
  cout<<fixed << setprecision(10) <<ans<<endl;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

bool possible(const vector<ll> &vs, const ll time, const ll a, const ll b)
{
  const int diff = a - b;
  ll ans = 0;
  for(auto v : vs)
  {
	const ll rest = max(0ll, v - time * b);
	ans += (rest + diff - 1) / diff;
  }
  return ans <= time;
}

int main()
{
  ll n, a, b;
  cin >> n >> a >> b;

  vector<ll> hs(n);
  for(int i = 0; i < n; i++)
  {
	cin >> hs[i];
  }

  // 未達成
  ll left = 0;
  // 達成
  ll right = 1000000000;

  for(int i = 0; i < 64; i++)
  {
	ll middle = (left + right) / 2;
	if(possible(hs, middle, a, b))
	{
	  right = middle;
	}
	else
	{
	  left = middle;
	}
  }

  cout << right << endl;  
}


Measured memory_bytes: 1152
from heapq import heappop, heappush
from collections import defaultdict
N,M = map(int,input().split())
jobs = defaultdict(list)
for i in range(N):
    a,b = map(int,input().split())
    if a <= M: jobs[a-1].append(b)
h = []
ans = 0
for i in range(M):
    if jobs[i]:
        for j in jobs[i]:
            heappush(h, -j)
    if len(h) > 0:
        ans += -heappop(h)
print(ans)

Measured memory_bytes: 27756
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#define int long long
#define ggr getchar();getchar();return 0;
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
signed main() {
	int n, ans, cut = 1, trueans = 1;
	cin >> n;
	for (int i = sqrt(n)/1; i >= 1; i--) {
		if (n%i == 0) {
			ans = i;
			break;
		}
	}
	int sanada = n / ans;
	while (sanada>cut) {
		cut *= 10;
		trueans++;
	}
	if (cut==sanada)cout << trueans << endl;
	else cout << trueans - 1 << endl;
	ggr
}

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

#define ll 					long long
#define db					double
#define ull 				unsigned long long
#define pii 				pair<int,int>
#define fi 					first
#define se 					second
#define vi 					vector<int>
#define vl					vector<ll>
#define psb 				push_back
#define ppb 				pop_back
#define all(x)			 	(x).begin(),(x).end()
#define sz(x)				(int)(x).size()
#define endln 				printf("\n")
#define gc					getchar_unlocked
#define setmin(x)			memset((x), -1, sizeof((x)))
#define setnul(x)			memset((x), 0, sizeof((x)))
#ifndef getchar_unlocked
#define getchar_unlocked 	getchar
#endif
const int inf = 1e9 + 5;
const ll infll = 1e18+5;
const int mod = 1e9 + 7;

template <typename T>
void gi(T &ret) {
	ret = 0; char inp=gc(); int kl=1;
	while (inp<'0' || inp>'9') {if (inp=='-') kl=-1; inp=gc();}
	while ('0'<=inp && inp<='9') ret=(ret<<3)+(ret<<1)+(inp-'0'), inp=gc();
	if (kl<1) ret=-ret;
}

const int MAXN = 5;
char inp[MAXN];

int main() {
	scanf("%s", inp);
	int ans = 0;
	for (int i=0; i<3; i++)
		if (inp[i]=='o') ans++;
	printf ("%d\n", 700+100*ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cstring>
#include <string>
#include <cstdlib>
#include <cstdio>
using namespace std;
typedef pair<int, int> pii;
typedef long long int ll;
#define REP(i,x) for(int i=0;i<(int)(x);i++)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define RREP(i,x) for(int i=(x);i>=0;i--)
#define RFOR(i,c) for(__typeof((c).rbegin())i=(c).rbegin();i!=(c).rend();++i)

class DP{
public:
	int cost, x, y, bits;
	
	DP(){}
	DP(int xx, int yy, int b, int cc){
		cost = cc;x=xx;y=yy;bits=b;
	}
	
	bool operator< (const DP &opp) const {
		return cost>opp.cost;
	}
};

int dr[4][2] = {{1,0},{0,1},{-1,0},{0,-1}};
unsigned int memo[1<<10][31][31];
int Map[31][31];
int W, H;
main(){
	int i,j;
	while(cin >> W >> H, W){
		memset(memo, -1, sizeof(memo));
		memset(Map, -1, sizeof(Map));
		int d = 0;
		int sx, sy;
		REP(i, H)REP(j, W){
			char c;
			cin >> c;
			if(c == '.' || c=='o') Map[i+1][j+1] = 0;
			if(c == '*') Map[i+1][j+1] = ++d;
			if(c == 'o') sx = j+1, sy = i+1;
		}
		priority_queue<DP> dp;
		DP S;
		dp.push(DP(sx, sy, 0, 0));
		while(!dp.empty()){
			S = dp.top();
			dp.pop();

			if(S.bits == (1<<d)-1) break;
			REP(i, 4){
				DP T=S;
				T.x += dr[i][0];
				T.y += dr[i][1];
				if(Map[T.y][T.x] == -1) continue;
				if(Map[T.y][T.x]) T.bits |= 1 << (Map[T.y][T.x]-1);
				T.cost ++;
				if(memo[T.bits][T.x][T.y] <= T.cost) continue;
				memo[T.bits][T.x][T.y] = T.cost;
				dp.push(T);
			}
		}
		if(S.bits == (1<<d)-1) cout << S.cost << endl;
		else cout << -1 << endl;
	}
	return 0;
}

Measured memory_bytes: 5228
#include <stdio.h>

int main(void){
	
	int n;
	int k,p;
	int a;
	int i;
	
	scanf("%d",&n);
	for(i=0;i<n;i++){
		
		scanf("%d %d",&k,&p);
		a=k%p;
		if(a == 0){
			printf("%d\n",p);
		}else{
			printf("%d\n",a);
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define cou(x) cout << x << endl
using lint = long long;
int main() {
	string N;
	cin >> N;
	cou((N == "AAA" || N == "BBB" ? "No" : "Yes"));
	rep(i, 1000) {
		rep(j, 1006) {
			rep(k, 135) {
				N = "処理";
			}
		}
	}
}

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
key = ["q","w","e","r","t","y","u","i","o","p","a","s","d","f","g","h","j","k","l","z","x","c","v","b","n","m"]
for i in range(1, n):
    anssub = 0
    a, b = s[0:i], s[i:]
    for value in key:
        if value in a and value in b:
            anssub += 1
    if anssub > ans:
        ans = anssub
print(ans)

Measured memory_bytes: 3064
n,k=map(int,input().split())
count = 0
for i in range(k,n+2):
	max_sum = (i*n)-(((i-1)*i)/2)
	min_sum = (i*(i-1))/2
	count += (max_sum-min_sum+1)
ans = int(count%int(1e9+7))
print(ans)


Measured memory_bytes: 9188
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>
#define IP pair<int,P>
#define PI pair<P,int>
#define PP pair<P,P>
#define Yes(f){cout<<(f?"Yes":"No")<<endl;}
#define YES(f){cout<<(f?"YES":"NO")<<endl;}
int Madd(int x,int y) {return (x+y)%M;}
int Msub(int x,int y) {return (x-y+M)%M;}
int Mmul(int x,int y) {return (x*y)%M;}


signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);

  int n;
  cin>>n;
  vector<vi> v(n+2);
  rep(i,n){
    int a;
    cin>>a;
    v[a].PB(i);
  }

  if(v[1].empty()){
    cout<<-1<<endl;
    return 0;
  }
  int ans=0;
  int p=-1;
  FOR(i,1,n+2){
    auto it=lower_bound(all(v[i]),p);
    if(it==v[i].end()){
      ans=n-i+1;
      break;
    }
    p=*it;
   // cout<<p<<endl;
  }


  cout<<ans<<endl;
  
}

Measured memory_bytes: 11264
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>
#include<utility>
#include<queue>
#include<deque>
#include<tuple>
#include<stdio.h>
#include<iomanip>
#define rep(i, n) for(int i=0;i<n;i++)
using namespace std;

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

Measured memory_bytes: 3636
#!/usr/bin/env python3
#AGC36 A

import sys
import math
import bisect
from heapq import heappush, heappop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
mod = 10**9 + 7

s = int(input())
x1,y1 = 0,0
x2,y2 = 10**9,1
if s % 10**9 == 0:
    x3 = 0
    y3 = s // 10**9
else:
    x3 = 10**9 - s % 10**9
    y3 = s//10**9 + 1
print(x1,y1,x2,y2,x3,y3)


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N; cin >> N;
  vector<int> v(N);
  for (int i = 0; i < N; i++) cin >> v[i];
  sort(v.begin(), v.end());
  int res = 0;
  for (int i = 0; i < N; i++) {
    for (int j = i + 1; j < N; j++) {
      if (v[i] == v[j]) continue;
      for (int k = j + 1; k < N; k++) {
        if (v[j] == v[k]) continue;
        res += v[i] + v[j] > v[k];
      }
    }
  }
  cout << res << endl;
}


Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define FOR(i,l,r) for(ll i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(ll i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define pb push_back
#define eb emplace_back
#define SZ(x) ((ll)(x).size())
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
template<class T = ll> using V = vector<T>;
template<class T = ll> using VV = V<V<T>>;
using P = pair<ll, ll>;
#define ios\
    ios::sync_with_stdio(false);\
    cin.tie(nullptr);
#define VEC(type, name, size)\
    V<type> name(size);\
    IN(name)
#define VVEC(type, name, h, w)\
    VV<type> name(h, V<type>(w));\
    IN(name)
#define INT(...)\
    int __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LL(...)\
    ll __VA_ARGS__;\
    IN(__VA_ARGS__)
#define STR(...)\
    string __VA_ARGS__;\
    IN(__VA_ARGS__)
#define CHAR(...)\
    char __VA_ARGS__;\
    IN(__VA_ARGS__)
#define DOUBLE(...)\
    DOUBLE __VA_ARGS__;\
    IN(__VA_ARGS__)
#define LD(...)\
    LD __VA_ARGS__;\
    IN(__VA_ARGS__)
template <class T> void scan(T a) { cin >> a; }
void scan(int &a) { cin >> a; }
void scan(long long &a) { cin >> a; }
void scan(char &a) { cin >> a; }
void scan(double &a) { cin >> a; }
void scan(long double &a) { cin >> a; }
void scan(char a[]) { scanf("%s", a); }
void scan(string &a) { cin >> a; }
template <class T> void scan(V<T> &);
template <class T, class L> void scan(pair<T, L> &);
template <class T> void scan(V<T> &a) { for(auto &i : a) scan(i); }
template <class T, class L> void scan(pair<T, L> &p){ scan(p.first); scan(p.second); }
template <class T> void scan(T &a) { cin >> a; }
void IN() {}
template <class Head, class... Tail> void IN(Head &head, Tail &... tail) { scan(head); IN(tail...); }
template <class T> inline void print(T x){ cout << x << '\n';}
template <class T> V<T> press(V<T> &x){ 
    V<T> res = x;
    sort(all(res));
    res.erase(unique(all(res)), res.end());
    REP(i, SZ(x)){
        x[i] = lower_bound(all(res), x[i]) - res.begin();
    }
    return res;
}
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true; }return false; }
const ll INF = 1e18;


int main(){
    ios;
    INT(n, k);
    VEC(int, h, n); h.pb(0);
    VV<> dp(n + 1, V<>(n + 1, INF));
    dp[0][n] = 0;
    REP(i, n) REP(j, i + 1) REP(k, n + 1) if(i != k) chmin(dp[j + 1][i], dp[j][k] + max(h[i] - h[k], 0));
    print(*min_element(all(dp[n - k])));
}

Measured memory_bytes: 3972
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
#include <algorithm> 
#include <iostream>
#include <string>
#include <cmath>
using namespace std;
#define ll long long
#define rep(i,n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<"\n"
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define mp make_pair
#define sz(x) (ll)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvll = vector<vll>;
using vstr = vector<string>;
using vc = vector<char>;
using vvc = vector<vc>;
template<class T> inline bool chmax(T& a, T b) { 
 if (a < b) { a = b; return true; } return false; 
}
template<class T> inline bool chmin(T& a, T b) {
 if (a > b) { a = b; return true; } return false; 
}
ll dx[4]={0,1,0,-1};
ll dy[4]={1,0,-1,0};
int main(){
  ll n;
  cin>>n;
  vll p(n);
  rep(i,n) cin>>p[i];
  vll a(n),b(n);
  rep(i,n){
    a[i]=(i+1)*2*n;
    b[n-1-i]=(i+1)*2*n;
  }
   rep(i,n){
    a[p[i]-1]+=i;
  }
  rep(i,n){
    cout<<a[i]<<" ";
  }
  cout<<endl;
  rep(i,n){
    cout<<b[i]<<" ";
  }
}

Measured memory_bytes: 3772
N,D=map(int,input().split())
res = 0
List = []
for i in range (N):
  List.append(list(map(int, input().split())))
  
def calcDist(ListX,a,b):
  n = 0
  for k in range(D):
    x = ListX[a][k] - ListX[b][k]
    n += x*x
  n = n ** 0.5
  nn = int(n)
  if n-nn > 0:
    return False
  else:
    return True

for i in range(N):
  for j in range(N):
    if i == j:
      pass
    else:
      if calcDist(List,i,j):
        res += 1
res = res //2
print(res)

Measured memory_bytes: 9348
#include "bits/stdc++.h"
using namespace std;
#define dbg(var) cout<<#var<<"="<<var<<" "
#define nl cout<<"\n"
#define fr(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<=n;i++)
#define vi vector<int>
#define vvi vector<vi>
#define pb push_back
#define fa(v) for(auto &i:v)
#define all(v) v.begin(),v.end()
#define sz(v) (int)(v.size())
#define int long long
//////////////   debugger class  starts from here///// 
void __print(int x) {cout << x;}
void __print(long x) {cout << x;}
void __print(unsigned x) {cout << x;}
void __print(unsigned long x) {cout << x;}
void __print(unsigned long long x) {cout << x;}
void __print(float x) {cout << x;}
void __print(double x) {cout << x;}
void __print(long double x) {cout << x;}
void __print(char x) {cout << '\'' << x << '\'';}
void __print(const char *x) {cout << '\"' << x << '\"';}
void __print(const string &x) {cout << '\"' << x << '\"';}
void __print(bool x) {cout << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cout << '{'; __print(x.first); cout << ','; __print(x.second); cout << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __print(i); cout << "}";}
void _print() {cout << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cout << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cout << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

///////  debugger class ends here /////////////
void solve(){
  int n,k; cin >> n >> k;
  vi v(n); fr(i,n) cin >> v[i];
  int l = 1, r = *max_element(all(v));
  int ans = -1;
  while(l<=r){
  	int len = (l + r) / 2;
  	int cnt = 0;
  	for(int x: v){
  		cnt += (x + len -1 ) / len- 1;
  	}
  	// debug(cnt,len);
  	if(cnt <= k) {
  		ans = len;
  		r = len - 1;
  	}
  	else l = len + 1;
  }
  cout << ans;

}
int32_t main()
{
   ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
   // int tst; cin >> tst; while(tst--)
   {
   	solve();
   }
}

Measured memory_bytes: 4780
#pragma comment(linker, "/stack:247474112")
#pragma GCC optimize("Ofast")
#include"stdio.h"
#include"stdlib.h"
#include"assert.h"
#include"ctype.h"
#include"string.h"
#include"math.h"
#include"string"
#include"deque"
#include"iostream"
#include"set"
#include"map"
#include"vector"
#include"algorithm"
#include"bitset"
#include"stack"
#include"queue"
#include"sstream"
using namespace std;
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0)
#define int long long
#define ends ' '
#define endl '\n'
#define pb emplace_back
#define x first
#define y second
#define pii pair<int, int>
#define sz(x) (int)(x).size()

const int maxn = 2e3+5, prime = 1e9+7;

int C[maxn][maxn];

int mod(int a) { a %= prime; return a >= 0 ? a : a+prime;}

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

	int n, k;
	cin >> n >> k;

	for(int i = 0; i < maxn; ++i)
	{
		for(int j = 0; j < maxn; ++j)
		{
			if(i == j)
				C[i][j] = 1;
			else if(j > i)
				C[i][j] = 0;
			else
				C[i][j] = mod(C[i-1][j-1]+C[i-1][j]);
		}
	}

	for(int i = 1; i <= k; ++i)
		cout << mod(C[n-k+1][i]*C[k-i+i-1][k-i]) << '\n';

	return 0;
}

Measured memory_bytes: 31616
-- ABC113 A
import Control.Monad
import Data.Maybe
import Debug.Trace
import Data.List
import qualified Data.Map.Strict as Map
import qualified Data.IntMap.Strict as IntMap
import qualified Data.Set as Set
import qualified Data.IntSet as IntSet
import Data.Functor
import Data.Array

main :: IO ()
main = do
  (x:y:_) <- fmap (map read . words) getLine :: IO [Int]
  print $ x + y `div` 2


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

const int INF_32 = 1LL << 30;
const int64_t INF_64 = 1LL << 60;
const int MOD = 1000000007;

typedef long long ll;

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll LCM(ll x, ll y)
{
    return x * y / GCD(x, y);
}

using Graph = vector<vector<int>>;

typedef pair<int, int> P;

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

    Graph G(N);
    map<int, P> num2edge;

    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        G[a].push_back(b);
        G[b].push_back(a);
        num2edge[i] = P(a, b);
    }

    int K = 0;
    rep(i, N)
    {
        int size = G.at(i).size();
        K = max(K, size);
    }
    cout << K << endl;

    // data structure for BFS
    // <node, color> のペアをキューで管理
    vector<bool> used(N, false); // initialize all nodes as unvisited
    queue<P> que;

    used[0] = true;
    que.push(P(0, 0));
    map<P, int> edge2color;

    while (!que.empty()) {
        int pv = que.front().first;
        int pc = que.front().second;
        que.pop();

        int nc = 1;
        for (int nv : G[pv]) {
            if (used[nv])
                continue;
            used[nv] = true;

            if (nc == pc)
                nc++;
            que.push(P(nv, nc));
            edge2color[P(pv, nv)] = nc;
            edge2color[P(nv, pv)] = nc;
            nc++;
        }
    }
    rep(i, N - 1)
    {
        cout << edge2color.at(num2edge.at(i)) << endl;
    }
}

Measured memory_bytes: 24832
#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 sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	vl a(n);
	cin>>a;
	vl p(2,0);
	rep(i,n){
		if(p[0]<a[i]){
			p[1]=p[0];
			p[0]=a[i];
		}else{
			if(p[1]<a[i]){
				p[1]=a[i];
			}
		}
	}
	rep(i,n){
		if(a[i]==p[0])puta(p[1]);
		else puta(p[0]);
	}
	return 0;
}

Measured memory_bytes: 3200
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int main(){
  int i;
  int t[1001],u[1001],g,d;
  char s[1024];
  memset(t,0,sizeof(t));
  memset(u,0,sizeof(u));
  for(;;){
    fgets(s,1024,stdin);
    if(strcmp(s,"\n")==0)
      break;
    g=atoi(strtok(s,","));
    t[g]++;
  }
  while(scanf("%d,%d",&g,&d)!=-1)
    u[g]++;
  for(i=0;i<1001;i++)
    if(t[i]&&u[i])
      printf("%d %d\n",i,t[i]+u[i]);
  return 0;
}

Measured memory_bytes: 0
import math
import copy




def nCast(number):
    if type(number)==str:
        return int(number)
    for idx in range(0,len(number)):
        if type(number[idx])==str:

            number[idx]=int(number[idx])
        else:
            nCast(number[idx])
    return number
    
def inputArr(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l
def inputArr1(w):
    l=list()
    for idx in range(0,w):
        l.append(input())
    return l

a=nCast(input())

def f(i):
    if i%2==0:
        return i/2
    return i*3+1
def func():
    s=set()
    idx=2
    pre=a
    s.add(a)
    while True:
        
        number=f(pre)
        if number in s:
            return idx
        idx+=1
        s.add(number)
        pre=number

print(func()) 







Measured memory_bytes: 3664
N = int(input())
import itertools
all = list(itertools.permutations([i+1 for i in range(N)],N))
lst1 = tuple(map(int, input().split()))
lst2 = tuple(map(int, input().split()))
id1 = 0
id2 = 0
for i in range(len(all)):
    if all[i] == lst1:
        id1 = i
    if all[i] == lst2:
        id2 = i
print(abs(id1-id2))


Measured memory_bytes: 45680
#include <bits/stdc++.h>
#define for0(i,b) for(int i=0 ; i< b ;i++)
#define for1(i,b) for(int i=1 ; i<=b ;i++)
#define reps(i,a,b) for(int i=a ; i< b.length() ;i++)
typedef long long ll;
#define MOD 1000000007

using namespace std;




int main()
{
    int n,val;
    cin >> n;
    std::vector<int> v(n+1, 0);

    for(int i=2; i<=n ; i++){
      cin >> val;
      v[val]++;
    }

    for(int i=1; i<=n ; i++)
      cout << v[i]<<endl;


  return 0 ;
}


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

typedef long long LL;

const int N = 1e7+7, M = 998244353;
LL fac[N], invfac[N];
LL p2[N], p3[N];

LL power(LL a, LL p) {
    if (p==0)   return 1;
    LL ans = power(a, p/2);
    ans = (ans * ans)%M;
    if (p%2)    ans = (ans * a)%M;
    return ans;
}

LL pre() {
    fac[0] = 1;
    for (int i=1; i<N; i++) fac[i] = (fac[i-1]*i)%M;
    invfac[N-1]=  power(fac[N-1], M-2);
    for (int i=N-2; i>=0; i--)  invfac[i] = (invfac[i+1]*(i+1))%M;

    p2[0] = p3[0] = 1;
    for (int i=1; i<N; i++) {
        p2[i] = (p2[i-1]*2)%M;
        p3[i] = (p3[i-1]*3)%M;
    }
}

LL C(int n, int r) {
    if (r < 0 || r > n) return 0;
    LL num = fac[n];
    LL den = (invfac[r]*invfac[n-r])%M;
    return (num*den)%M;
}

LL f[N];
LL suf[N];

int main() {
    pre();
    int n;
    cin>>n;
    int m = n/2;

    for (int i=0; i<=m; i++)    {
        f[i] = (C(m, i)*p2[m-i])%M;
    }

    for (int i=m; i>=0; i--) {
        suf[i] = (suf[i+1] + f[i])%M;
    }

    LL ans =- 0;

    for (int i=0; i<=m; i++)    {
        ans = (ans + f[i] * suf[m-i+1])%M;
    }
    ans = (ans * 2)%M;
    ans = (p3[2*m] - ans + M)%M;
    cout<<ans<<endl;
}

Measured memory_bytes: 395264
#include<iostream>
#include<queue>
#include<algorithm>
#include<utility>
#include<cmath>
 
using namespace std;
 
const int maxn = 1e4 + 5;
const double eps = 1e-8;
int n, w, b[maxn];
pair<int, int> a[maxn];
 
double h(int idx, long long wt) {
	long long curw = wt;
	int curv = 0;
	for(int i = idx + 1; i <= n; i++) {
		long long diff = w - curw;
		if(diff >= a[i].first) {
			curv += a[i].second;
			curw += a[i].first;
		} else {
			curv += ((double) a[i].second) / a[i].first * diff;
			break;
		}
	}
	return curv;
}
 
int bab() {
	priority_queue< tuple<double, int, long long, int> > pq;
	pq.push({-1, 0, 0, 0});
	int ans = 0;
	while(!pq.empty()) {
		auto e = pq.top();
		pq.pop();
		int ev = get<1>(e); long long ew = get<2>(e); int ei = get<3>(e);
		bool leaf = true;
		for(int i = ei + 1; i <= n; i++) {
			leaf = false;
			double cv = ev + a[i].second + h(i, ew + a[i].first);
			if(ew + a[i].first <= w && cv > ans) {
				pq.push({cv, ev + a[i].second, ew + a[i].first, i});
				ans = max(ans, ev + a[i].second);
			}
		}
		if(fabs(get<0>(e) - ev) < eps) break;
	}
	return ans;
}
 
bool cmp(pair<int, int> &i, pair<int, int> &j) {
	return ((double) i.second) / i.first > ((double) j.second) / j.first;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin >> n >> w;
	for(int i = 1; i <= n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(a + 1, a + 1 + n, cmp);
	cout << bab() << endl;
	return 0;
}


Measured memory_bytes: 640
import java.util.*;
class Main {
    public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
	int sx = sc.nextInt();
	int sy = sc.nextInt();
	int tx = sc.nextInt();
	int ty = sc.nextInt();

	int xdet = tx-sx;
	int ydet = ty-sy;

	for(int i = 0; i<xdet; i++) {
	    System.out.print("R");
	}
	for(int i = 0; i<ydet; i++) {
            System.out.print("U");
        }

	for(int i = 0; i<xdet; i++) {
            System.out.print("L");
        }
	for(int i = 0; i<ydet; i++) {
            System.out.print("D");
        }

	System.out.print("D");

	for(int i = 0; i<xdet; i++) {
            System.out.print("R");
        }

	System.out.print("R");
	System.out.print("U");

	for(int i = 0; i<ydet; i++) {
            System.out.print("U");
        }

	System.out.print("L");
	System.out.print("U");

	for(int i = 0; i<xdet; i++) {
            System.out.print("L");
        }

	System.out.print("L");
	System.out.print("D");
        for(int i = 0; i<ydet; i++) {
            System.out.print("D");
	}

	System.out.print("R");


    }
}

Measured memory_bytes: 25412
import Data.List

main = do
  [h, w] <- map read . words <$> getLine :: IO [Int]
  let ws = map (solve h w) [1..w-1]
      hs = map (solve w h) [1..h-1]
  print $ min (minimum ws) (minimum hs)

solve :: Int -> Int -> Int -> Int
solve h w wa = let wb = (w - wa) `div` 2
                   x = wa * h
                   y1 = wb * h
                   z1 = (w - wa - wb) * h
                   y2 = (w - wa) * (h `div` 2)
                   z2 = (w - wa) * ((-) h $ h `div` 2)
                   mi1 = minimum [x, y1, z1]
                   ma1 = maximum [x, y1, z1]
                   mi2 = minimum [x, y2, z2]
                   ma2 = maximum [x, y2, z2]
               in if w - wa >= 2 then min (ma1 - mi1) (ma2 - mi2)
                                 else ma2 - mi2


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

int N;
vector< vector<int> > A;
vector< vector<int> > dp;
const int mod = 1000000007;

// 状態stateにおいて男k~男(N-1)でペアを組むときの組み方
ll q(int state, int k) {
    if (dp[state][k] != -1) return dp[state][k];
    if (k == N-1) {
        rep(j,N) {
            if (A[k][j] == 1 && !(state & (1<<j))) return 1; //全員がペアを組めた
        }
        return 0;
    }
    ll sum = 0;
    rep(j,N) {
        int res = state;
        if (A[k][j] == 1 && !(res & (1<<j))) {
            res |= (1<<j); //j番目にフラグを立てる
            sum += q(res, k+1);
        }
    }
    dp[state][k] = sum % mod;
    return dp[state][k];
}

int main() {
    cin >> N;
    A.resize(N, vector<int>(N));
    dp.resize((1<<N), vector<int>(N+5, -1));
    rep(i, N) rep(j, N) {
        cin >> A[i][j];
    }
    cout << q(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 280832
import sys
input = sys.stdin.buffer.readline

N, M = map(int,input().split())
town = [[] for _ in range(N)]
ans = [0] * M

for i in range(M):
    a, b = map(int,input().split())
    town[a-1].append((b,i))

for i in range(N):
    town[i].sort()
    for k in range(len(town[i])):
        index = town[i][k][1]
        t = town[i][k][0]
        ans[index] = str(i+1).zfill(6) + str(k+1).zfill(6)

for i in ans:
    print(i)

Measured memory_bytes: 35992
#include <bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
#define eps 1e-9

typedef long long ll;

using namespace std;

const ll inf = 1e18;
const ll mod = 1e9+7;
const int N = 1e5+5;
//int a[N];

int main()

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

    int n, k;

    cin >> n >> k;

    if (n%k) cout << 1;
    else cout << 0;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int N, M, step, num;
string pass;

int main(){
    while( cin >> N >> M ){
        if( N >= M ){
            cout << 0 << endl;
            getline(cin,pass);
            getline(cin,pass);
            continue;
        }
        step = 0;
        vector <int> P, D;
        while( M-- ){
            cin >> num;
            P.push_back(num);
        }
        sort(P.begin(),P.end());
        for( int i=0; i < P.size()-1; ++i ){
            D.push_back( P.at(i+1) - P.at(i) );
        }
        sort(D.begin(),D.end());
        for( int i=0; i < D.size()-N+1; ++i )
            step += D.at(i);
        cout << step << endl;
//        for( auto i : P ) cout << i << ' '; cout << endl;
//        for( auto i : D ) cout << i << ' '; cout << endl;
        P.clear();
        D.clear();
    }
    return 0;
}
/*
2 5
10 12 1 2 14
100 1
-100000
3 7
-10 -3 0 9 -100 2 17

*/



Measured memory_bytes: 1412
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<int, int> P;
template<typename T> inline void chkmin(T &a, const T &b) { a = a < b ? a : b; }
template<typename T> inline void chkmax(T &a, const T &b) { a = a > b ? a : b; }

const int MAXN = 2005, MOD = 924844033;
int f[MAXN][MAXN][4], g[MAXN], arr[MAXN], n, K;
LL fac[MAXN];

int main() {
	scanf("%d%d", &n, &K);
	for (int i = 0; i < K; i++)
		++arr[(n - i - 1) / K + 1];
	int m = (n + K - 1) / K;
	f[0][0][2] = 1;
	for (int j = 1; j <= m; j++) {
		f[j][0][j > 1 ? 0 : 1] = 1;
		for (int k = 1; k <= j; k++) {
			f[j][k][0] = (f[j - 1][k][0] + f[j - 1][k][1]) % MOD;
			f[j][k][1] = ((LL)f[j - 1][k][2] + f[j - 1][k - 1][0] + f[j - 1][k - 1][1]) % MOD;
			f[j][k][2] = ((LL)f[j - 1][k][3] + (j > 1 && k > 1 ? (LL)f[j - 2][k - 2][0] + f[j - 2][k - 2][1] + f[j - 2][k - 2][2] : 0)) % MOD;
			f[j][k][3] = ((LL)f[j - 1][k - 1][0] + f[j - 1][k - 1][1] + f[j - 1][k - 1][2] + f[j - 1][k - 1][3]) % MOD;
		}
	}
	g[0] = 1;
	for (int i = 1; i <= n; i++) if (arr[i]) {
		while (arr[i]--) {
			for (int j = n; j >= 0; j--) {
				LL sum = 0;
				for (int k = 0; k <= j && k <= i; k++)
					sum = (sum + ((LL)f[i][k][0] + f[i][k][1] + f[i][k][2]) * g[j - k]) % MOD;
				g[j] = sum;
			}
		}
	}
	for (int i = fac[0] = 1; i <= n; i++) fac[i] = fac[i - 1] * i % MOD;
	LL ans = 0;
	for (int i = 0; i <= n; i++) {
		LL cur = fac[n - i] * g[i] % MOD;
		if (i & 1) ans += MOD - cur;
		else ans += cur;
	}
	printf("%lld\n", ans % MOD);
	return 0;
}

Measured memory_bytes: 61184
#include<iostream>
#include<algorithm>
#include<vector>
#include<set>
using namespace std;
typedef long long ll;
#define chmin(a,b) a=min(a,b)
#define chmax(a,b) a=max(a,b)
#define mod 998244353
#define mul(a,b) a=a*b%mod;
#define mad(a,b) a=(a+b)%mod;
#define X 1000010
ll po(ll x,ll y){
    ll res=1;
    for(;y;y>>=1){
        if(y&1)mul(res,x);
        x=x*x%mod;
    }
    return res;
}
ll inv(ll x){
    return po(x,mod-2);
}
ll f[X],g[X],h[X],cnt[X];
ll n,a[200010];
int main(){
    for(int i=1;i<X;i++){
        f[i]=0;
        h[i]=0;
        cnt[i]=0;
    }
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>a[i];
        mad(cnt[a[i]],a[i]);
    }
    for(int i=1;i<X;i++){
        mad(f[i],inv(i));
        g[i]=cnt[i];
        for(int j=i*2;j<X;j+=i){
            mad(f[j],-f[i]);
            mad(g[i],cnt[j]);
        }
    }
    for(int i=1;i<X;i++){
        for(int j=i;j<X;j+=i){
            mad(h[j],f[i]*g[i]);
        }
    }
    ll ans=0;
    for(int i=0;i<n;i++){
        mad(ans,h[a[i]]*a[i]);
        mad(ans,-a[i]);
    }
    mul(ans,inv(2));
    if(ans<0)ans+=mod;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 33024
#include<iostream>
#include<cstdio>
using namespace std;
const int N=12;
int n,m;
int a[1<<N][1<<N];
void dfs(int x,int y,int k)
{
	if(k==1)
	{
		a[x][y]=1;
		return;
	}
	dfs(x,y,k-1);
	dfs(x+(1<<(k-1)),y,k-1);
	dfs(x,y+(1<<(k-1)),k-1);
	dfs(x+(1<<(k-1)),y+(1<<(k-1)),k-1);
	for(int i=1;i<=(1<<k)-1;i++)
		a[x+(1<<(k-1))-1][y+i-1]=a[x+i-1][y+(1<<(k-1))-1]=0;
	a[x+(1<<(k-1))-1][y+(1<<(k-1))-1]=1;
	return;
}
int main()
{
	scanf("%d%d",&n,&m);
	dfs(1,1,max(n,m));
	for(int i=1;i<=(1<<n)-1;i++)
	{
		for(int j=1;j<=(1<<m)-1;j++)
			printf("%d",a[i][j]);
		printf("\n");
	}
	return 0;
}

Measured memory_bytes: 11920
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll maxS =1e5+7;


int main()
{
    ll n;
  cin >> n;
    bool YES = false;
    while(n)
    {
      if((n%10)==7)
        YES = true;
      n/=10;
    }
  if(YES)
    cout << "Yes" << "\n";
  else
    cout << "No" << "\n";
  
  
  
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN
#define INF         100000000000000000
#define PI          3.1415926535897932384626433832795l



#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"


// ll mod = 1000000007;
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)






// struct mycomp {
//     bool operator() (const pair<int,int> &a, const pair<int,int> &b) const{
//         if (a.second-a.first != b.second-b.first)
//         return (a.second-a.first > b.second-b.first);
//         return a.first < b.first;
//     }
// };



/////////////////////GCD//////////////////////
ll gcd(ll a, ll b)
{
	if(b==0) return a;
	return gcd(b, a%b);
}


ll extended_gcd(ll a, ll b, ll& x, ll& y)
{
	if(b==0)
	{
		x=1;
		y=0;
		return a;
	}
	ll x1, y1;
	ll d = extended_gcd(b, a%b, x1, y1);
	x=y1;
	y=x1-y1*(a/b);
	return d;
}

////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}	
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}

////////////////////BINARY EXPONENTIATION///////////////////////
ll bin_exp(ll a, ll b, ll mod)
{
	ll ans = 1;
	while(b)
	{
		if(b%2)
		{
			b--;
			ans = (ans%mod*a%mod)%mod;
		}
		b/=2;
		a = (a%mod*a%mod)%mod;
	}
	return ans;
}


///////////////////////////BFS//////////////////////////////////
void bfs(vector<int>& distance, vector<int> a[], vector<bool>& visited, int u, vector<int>& parent)
{
	visited[u]=true;
	parent[u]=-1;
	distance[u]=0;
	queue<int> q;

	q.push(u); 
    while (!q.empty()) { 
  
        int f = q.front(); 
        q.pop(); 
  		for(int i =0; i < a[f].size(); i++)
  		{
  			if(visited[a[f][i]]==false)
  			{
  				distance[a[f][i]]=distance[f]+1;
  				parent[a[f][i]]=f;
  				visited[a[f][i]]=true;
  				q.push(a[f][i]);
  			}
  		}
    } 

}

void solve()
{

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

	// #ifndef ONLINE_JUDGE
	// freopen("input.txt", "r", stdin);
	// freopen("output.txt", "w", stdout);
	// #endif
	ll n, m, x, y, sum=0;
	cin>>n;
	vll a(n);
	for(int i = 0; i < n; i++)
	{ 
		cin>>a[i];
		sum+=a[i];
	}
	cin>>m;
	for(int i = 0; i < m; i++)
	{
		cin>>x>>y;
		x--;
		p(sum+(y-a[x]));
	}
	return 0;
}	

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <functional>

int N, H;
int b[100000];

int main(){
        scanf("%d %d",&N,&H);
        int a;
        int maxa = 0;
        for(int i = 0; i < N; i++){
                scanf("%d %d",&a,b+i);
                if(maxa < a){ maxa = a;}
        }

        std::sort(b,b+N,std::greater<int>());
        int cnt=0;
        int bind = 0;
        while(H > 0 && b[bind] >= maxa && bind != N){ // ここを>にするのか>=にするのかで結果が異なる
                cnt++; H -= b[bind++];
        }
        if(H > 0){
                cnt += H/maxa;
                cnt += (H%maxa==0)?0:1;
        }

        printf("%d\n",cnt);

}

Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include <complex>
using namespace std;
 
#define FOR(i,a,b) for(LL i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(),a.end()
#define MP make_pair
#define PB push_back
 
typedef long long LL;
typedef vector<int> VI;
typedef pair<int,int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL) INF;

const int MAX = 705;



map<pair<string, string>, int> M;

int main()
{
	//freopen("In.txt", "r", stdin);
	int n;
	string s;
	cin >> n >> s;
	
	FOR(msk, 0, 1 << n) {
		string R = "", B = "";
		FOR(i, 0, n) {
			if (msk & (1 << i)) R += s[i];
			else B += s[i];
		}
		M[MP(R, B)]++;
	}
	
	LL ans = 0;
	
	FOR(msk, 0, 1 << n) {
		string R = "", B = "";
		FOR(i, 0, n) {
			if (msk & (1 << i))R += s[n + n - i - 1];
			else B += s[n + n - i - 1];
		}
		ans += M[MP(R, B)];
	}
	
	cout << ans << endl;
	
	return 0;
}



Measured memory_bytes: 91904
#include <iostream>

using namespace std;

int main()
{
   int i,h,m,s;
   cin >> i;
   h = i / 3600;
   m = i / 60 - h*60;
   s = i - h *3600 - m * 60 ;
   cout << h << ":" << m << ":" << s << endl; 
   
   return 0;
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
    static const double pi = 3.141592653589793;
 typedef pair<int64_t,int64_t> P;
#define rep(i, n) for (int i = 0; i < (n); i++)
 #define all(v) (v).begin(),(v).end()
 using ll = long long;
using Graph = vector<vector<int>>;
const int MAX = 510000;
const int MOD = 1000000007;
 const int NINE=1000000000;
 
 
int main(){
string a;
  cin>>a;
  ll n=a.size();
  ll ans=1;
  string b,g;
 b=a[0];
  g="";
  for(ll i=1;i<n;i++){
g=g+a[i];
  if(b!=g){
  ans++;
  b=g;
   g="";
  }
   
    
  }
  
  cout<<ans;
  
  
  
  
}

Measured memory_bytes: 640