akhauriyash/Code-Regression huggingface dataset:
// #pragma GCC target("avx")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
#include<unordered_set>
#include<complex>
using namespace std;
const long long mod=1000000007;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3100000;
const int UF_SIZE = 210000;
namespace{
	long long fact[C_SIZE];
	long long finv[C_SIZE];
	long long inv[C_SIZE];
	long long Comb(int a,int b){
	 	if(a<b||b<0)return 0;
	 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
	}
	void init_C(int n){
		fact[0]=finv[0]=inv[1]=1;
		for(int i=2;i<n;i++){
			inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
		}
		for(int i=1;i<n;i++){
			fact[i]=fact[i-1]*i%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	long long pw(long long a,long long b){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%mod;
			a=a*a%mod;
			b/=2;
		}
		return ret;
	}
	long long pw_mod(long long a,long long b,long long M){
		if(a<0LL)return 0;
		if(b<0LL)return 0;
		long long ret=1;
		while(b){
			if(b%2)ret=ret*a%M;
			a=a*a%M;
			b/=2;
		}
		return ret;
	}
	int pw_mod_int(int a,int b,int M){
		if(a<0)return 0;
		if(b<0)return 0;
		int ret=1;
		while(b){
			if(b%2)ret=(long long)ret*a%M;
			a=(long long)a*a%M;
			b/=2;
		}
		return ret;
	}
	int ABS(int a){return max(a,-a);}
	long long ABS(long long a){return max(a,-a);}
	double ABS(double a){return max(a,-a);}
	int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
	int UF[UF_SIZE];
	void init_UF(int n){
		for(int i=0;i<n;i++)UF[i]=-1;
	}
	int FIND(int a){
		if(UF[a]<0)return a;
		return UF[a]=FIND(UF[a]);
	}
	void UNION(int a,int b){
		a=FIND(a);b=FIND(b);if(a==b)return;
		if(UF[a]>UF[b])swap(a,b);
		UF[a]+=UF[b];UF[b]=a;
	}
}
// ここから編集しろ
pair<int,int>p[3100];
int dp[6100];
int main(){
	int a,b;scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++){
		int s,t;scanf("%d%d",&s,&t);
		p[i]=make_pair(s,t);
	}
	std::sort(p,p+a);

	for(int i=0;i<a;i++){
		for(int j=b-1;j>=0;j--){
			dp[j+p[i].first]=max(dp[j+p[i].first],dp[j]+p[i].second);
		}
	}
	int ret=0;
	for(int i=0;i<6100;i++){
		ret=max(ret,dp[i]);
	}
	printf("%d\n",ret);
}

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

int main() {
  string s;
  while(cin >> s) {
    for(int i=0; i<s.size(); i++) {
      if(s[i]=='@') {
	int n;
	i++;
	n=(int)s[i]-48;
	i++;
	for(int j=0; j<n; j++) cout << s[i];
      } else cout << s[i];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 1172
package main

import (
	"fmt"
	"os"
)

const MAX = 10010

func main() {
	var n, s int
	fmt.Scan(&n)
	nums := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		nums[i] = make([]int, MAX)
		if i == 0 {
			nums[i][0] = 1
			continue
		}

		fmt.Scan(&s)
		for j := 0; j < MAX; j++ {
			if nums[i-1][j] == 1 {
				nums[i][j] = 1
				nums[i][j+s] = 1
			}
		}
	}

	for i := MAX - 1; i >= 0; i-- {
		if i%10 == 0 {
			continue
		}
		if nums[n][i] != 0 {
			fmt.Println(i)
			os.Exit(0)
		}
	}

	fmt.Println(0)
}

// nの階乗(mod M) ただしMは素数
// return: nまでの階乗を示す全値(e.g., fact[5] = 5!を示す値)
func mfactorial(n int, M int) []int {
	fact := make([]int, n+1)
	fact[0] = 1
	for i := 1; i <= n; i++ {
		fact[i] = (fact[i-1] * i) % M
	}
	return fact
}

// x^n (mod M) ただしMは素数
// See https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func mpow(x, n, M int) int {
	ans := 1
	for n != 0 {
		if n&1 == 1 {
			ans = ans * x % M
		}
		x = x * x % M
		n = n >> 1
	}
	return ans
}

// nCk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func combi(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, true)
}

// nPk (mod M) ただしMは素数
// @see https://qiita.com/ofutonfuton/items/92b1a6f4a7775f00b6ae
func permutation(n, k, M int) int {
	return commonPermutationAndCombination(n, k, M, false)
}

func commonPermutationAndCombination(n, k, M int, combi bool) int {
	if n == 0 && k == 0 {
		return 1
	} else if n < k || n < 0 {
		return 0
	}
	fact := mfactorial(n, M)

	ans := fact[n] * mpow(fact[n-k], M-2, M) % M
	if combi {
		ans *= mpow(fact[k], M-2, M) % M
	}

	return ans % M
}


Measured memory_bytes: 4992
#include <stdio.h>

int main(void)
{
    int a, b, c, cnt = 0;
    scanf("%d %d %d", &a, &b,&c);
    for(int i = a;i <= b;i++){
        if(c % i == 0)
        {
            cnt++;
        }
    }
    printf("%d\n",cnt);
}


Measured memory_bytes: 2088
//#pragma GCC optimize("Ofast")
//#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using db = double;
using ld = long double;
template<typename T> using V = vector<T>;
template<typename T> using VV = vector<vector<T>>;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define siz(v) (ll)(v).size()
#define rep(i,a,n) for(ll i=a;i<(ll)(n);++i)
#define repr(i,a,n) for(ll i=n-1;(ll)a<=i;--i)
#define ENDL '\n'
typedef pair<int,int> Pi;
typedef pair<ll,ll> PL;
constexpr ll mod = 1000000007;
constexpr ll INF = 1000000099;
constexpr ll LINF = (ll)(1e18 +99);
const vector<ll> dx={-1,1,0,0},dy={0,0,-1,1};
template<typename T,typename U> inline bool chmin(T& t, const U& u){if(t>u){t=u;return 1;}return 0;}
template<typename T,typename U> inline bool chmax(T& t, const U& u){if(t<u){t=u;return 1;}return 0;}
template<typename T> inline T gcd(T a,T b){return b?gcd(b,a%b):a;}

template<typename T,typename Y> inline T mpow(T a, Y n) {
  T res = 1;
  for(;n;n>>=1) {
    if (n & 1) res = res * a;
    a = a * a;
  }
  return res;
}

template<typename T,typename Y>
ostream& operator<<(ostream& os,const pair<T,Y>& p){
  return os<<"{"<<p.fs<<","<<p.sc<<"}";
}
template<typename T> ostream& operator<<(ostream& os,const V<T>& v){
  os<<"{";
  for(auto e:v)os<<e<<",";
  return os<<"}";
}
template<typename ...Args>
void debug(Args&... args){
  for(auto const& x:{args...}){
    cerr<<x<<' ';
  }
  cerr<<ENDL;
}



signed main(){
  cin.tie(0);cerr.tie(0);ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(20);
  ll x,ans=8;cin>>x;
  for(int i=400;i<2000;i+=200){
    if(i<=x && x<i+200){
      cout<<ans<<ENDL;
      return 0;
    }
    --ans;
  }
}
//! ( . _ . ) ! 
//CHECK overflow,vector_size,what to output?

Measured memory_bytes: 3656
using System;

class Program
{
    static void Main(string[] args)
    {
        var N = Console.ReadLine();
        long total = 0;
        foreach (var item in N)
        {
            total += long.Parse(item.ToString());
        }

        if (total % 9 == 0)
        {
            Console.WriteLine("Yes");
        }
        else
        {
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 32988
n, a, b = map(int, input().split())

MOD = 1000000007

ans = pow(2, n, MOD)
ans -= 1

x = 1
y = 1
for i in range(b):
    x = x * (n - i) % MOD
    y = y * (i + 1) % MOD
    if i == a - 1:
        ans -= x * pow(y, MOD - 2, MOD) % MOD

ans -= x * pow(y, MOD - 2, MOD) % MOD

while ans < 0:
    ans += MOD
print(ans)


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

int main(){
    int n, number;
    char suit;
    bool cards[4][14];
    cin >> n;
    
    for(int i=0;i<=3;i++){
        for(int j=1;j<=13;j++){
            cards[i][j]=0;//全部をfalse
        }
    }
    for(int s=0;s<n;s++){//入力をtrue
        cin>>suit>>number;
        if(suit=='S') cards[0][number]=1;
        if(suit=='H') cards[1][number]=1;
        if(suit=='C') cards[2][number]=1;
        if(suit=='D') cards[3][number]=1;
    }
    for(int i=0;i<=3;i++){
        for(int j=1;j<=13;j++){
            if(cards[i][j]==1)continue;
            if(i==0)cout<<'S'<<' '<<j<<endl;
            if(i==1)cout<<'H'<<' '<<j<<endl;
            if(i==2)cout<<'C'<<' '<<j<<endl;
            if(i==3)cout<<'D'<<' '<<j<<endl;
    
}}return 0;}



Measured memory_bytes: 3100
#include <iostream>

using namespace std;

int main(){

	int n;	cin >> n;

	int cnt=0;

	for(int i=0;i<n;i++){

		int a,b;

		cin >> a >> b;

		if(a==b){

			cnt++;

			if(cnt>=3) break;

		}else cnt=0;

			}

	if(cnt>=3) cout << "Yes" << '\n';

	else cout << "No" << '\n';	

	return 0;

}

Measured memory_bytes: 3636
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, x, n) for(int i = x; i < n; i++)
using namespace std;
const long long INF = 1LL << 50;
const int ININF = 1000000;
using pint = pair<int, int>;
using Edge = pair<long long, pint>; //<cost,<u,v>>の形
vector<Edge> edges;

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    rep(i, 0, N) { cin >> a[i]; }
    map<long long, long long> ma;
    ma[-1LL - a[0]] = 1LL;
    long long res = 0LL;
    rep(i, 1, N) {
        long long ind = 1LL * i + 1;
        // cout << i << "," << ma[a[i] - ind]<<endl;
        if(ma[a[i] - ind] > 0) {
            res = 1LL * res + ma[1LL * a[i] - ind];
        }
        if(ma[-ind - a[i]] > 0) {
            ma[-ind - a[i]]++;
        } else {
            ma[-ind - a[i]] = 1LL;
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 27316
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;


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

    if (!(B%A))cout << A + B << "\n";
    else cout << B - A << "\n";

}

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

int main(){

 int totalTime;
 int hour, minute, second;

 cin >> totalTime;

 hour = totalTime / 3600;
 totalTime -= 3600 * hour;

 minute = totalTime / 60;
 totalTime -= 60 * minute;

 second = totalTime;

 cout << hour << ":" << minute << ":" << second << endl;

 return 0;

}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define debug(x) cerr << #x << " " << x << '\n'
using namespace std;
using ll = long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
const int INF = 0x3f3f3f3f, N = 1e4 + 5, M = 1e3;
const ll LINF = 1e18 + 5;
const int mod = 1e9 + 7; 
int n, a[N];
int faccnt[N];
int factor[N][35][2];
const int p_max = 1e6 + 100;
int prime[p_max];
bool vis[p_max];
void getprime(int x) 
{
	vis[1] = 1;
	for(int i=2;i<=x;i++)
	{
		if(!vis[i]) prime[++prime[0]] = i;
		for(int j=1;j<=prime[0]&&1ll*prime[j]*i<=x;j++) 
		{
			vis[prime[j]*i] = 1; 
			if(i%prime[j]==0) break;
		} 
	}
}
void getfactor(ll x, int idx) 
{
	faccnt[idx] = 0;
	for(int i=1;i<=prime[0]&&1ll*prime[i]*prime[i]<=x;i++)
	{
		if(x%prime[i]==0)
		{
			factor[idx][faccnt[idx]][1] = 0;
			while(x%prime[i]==0)
			{
				factor[idx][faccnt[idx]][1]++;
				x /= prime[i];
			}
			factor[idx][faccnt[idx]++][0] = prime[i];
		}
	}
	if(x!=1)
	{
		factor[idx][faccnt[idx]][0] = x;
		factor[idx][faccnt[idx]++][1] = 1;
	} 
}
unordered_map <int, int> p;
ll powmod(ll a, ll b)
{
	ll ans = 1;
	while(b)
	{
		if(b&1) ans = ans*a%mod;
		a = a*a%mod;
		b >>= 1;
	}
	return ans;
}
ll inv(ll x)
{
	return powmod(x, mod-2);
}
int main()
{
 	ios::sync_with_stdio(false);
 	cin.tie(0);
 	cin >> n;
 	getprime(M);
 	for(int i=1; i<=n; i++) 
 	{
 		cin >> a[i];
 		getfactor(a[i], i);
 	}
 	for(int i=1; i<=n; i++)
 	{
 		for(int j=0; j<faccnt[i]; j++)
 		{
 			p[factor[i][j][0]] = max(p[factor[i][j][0]], factor[i][j][1]);
 		}
 	}
 	ll res = 1;
	for(auto x : p)
		res = res*powmod(x.first, x.second)%mod;
 	ll ans = 0;
 	for(int i=1; i<=n; i++)
 	{
 		ans = (ans + res*inv(a[i])%mod)%mod;
 	}
 	cout << ans;
	return 0;
}


Measured memory_bytes: 4352
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

inline int toInt(string s) {
  int v;
  istringstream sin(s);
  sin >> v;
  return v;
}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9 + 7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

  int n, c, k;
  cin >> n >> c >> k;
  vector<int> t(n);
  rep(i, n) cin >> t[i];

  sort(all(t));

  int ans = 1, sum = 0, tt = t[0];
  rep(i, n) {
    if (sum + 1 <= c && t[i] <= tt + k) {
      sum++;
      continue;
    }

    ans++;
    sum = 1;
    tt = t[i];
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
import math, itertools

def calc_dict(D, p_list):
    sqrt_in = 0
    for i in range(0, D):
        sqrt_in += abs( p_list[0][i] - p_list[1][i] )**2
    return math.sqrt( sqrt_in )

N, D = map(int, input().split())
X = [map(int, input().split()) for i in range(N)]

X_list = []
for i in range(0, N):
    X_list.append(list(X[i]))

points_list = list(itertools.combinations(X_list,2))

int_count = 0
for i in range(0, len(points_list)):
    dist = calc_dict(D, points_list[i])
    if( dist.is_integer() ):
        int_count += 1

print(int_count)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		String relation;

		if(a > b){
			relation = ">";
		}else if(a < b){
			relation = "<";
		}else{
			relation = "==";
		}

		System.out.printf("a %s b\n", relation);
	}
}



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

using namespace std;
typedef long long ll;
const int MAX_K = 1e3;

int main(){ 
  int N; scanf("%d", &N);
  
  if( N == 1){ 
    printf("%s\n", "Yes"); 
    printf("%d\n", 2);
    printf("%d %d\n", 1, 1);
    printf("%d %d\n", 1, 1); return 0;
  }
              
  
  int k = 0;
  for(int res = 1; res <= MAX_K; res++){
    if((res*(res+1))/2 == N){  k = res; break;}
  }
  
  if( k == 0){ printf("%s\n", "No"); return 0;}
  
  vector<int> vec[k+1];
  int cnt = 0;
  
  for(int i = 2; i <= k-1; i++){ 
    //上から何段目スタートか
    for(int h = i*(i-1)/2 + 1; h <= i*(i+1)/2; h++){
      vec[cnt].push_back(h);
    }
      int w = i*(i+1)/2;
    for(int times = 0; i+times < k ; times++){
      w += i+times;
      vec[cnt].push_back(w);
     
    }
    cnt++;
  }
  
  for(int s = 0; s < k; s++){
    vec[cnt].push_back( ( (s*(s+1))/2 )+1 );
  }
  
  cnt++;
  
  for(int t = (k*(k-1))/2 + 1; t <= k*(k+1)/2; t++){
    vec[cnt].push_back( t );
  }
  
  cnt++;
  
  for(int u = 1; u <= k; u++){
    vec[cnt].push_back( (u*(u+1) )/2);
  }
  
  printf("%s\n", "Yes");
  printf("%d\n", k+1);
  
  for(int i = 0; i <= k; i++){
    printf("%d ", (int)vec[i].size());
    for(auto n : vec[i]){ printf("%d ", n);}
    printf("\n");
  }
  
  return 0;
}
    

Measured memory_bytes: 2304
#include <iostream>
#include <utility>

using namespace std;

int main() {
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  if ( (abs(a-c) <= d) ||
       ( (abs(a-b) <= d) && (abs(c-b) <= d) ) )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <cstdlib>

#include <algorithm>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <stdio.h>
#include <string>
#include <vector>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const double PI = 3.1415926535897932;

template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

int main()
{
	ll X, K, D;
	cin >> X >> K >> D;

	X = abs(X);
	ll ans;
	if (X / D > K) {
		ans = X - D * K;
	}
	else {
		ll move_cnt = X / D;
		ll remaining = K - move_cnt;
		ll near_pos = abs(X - D * move_cnt);
		ll far_pos = abs(near_pos - D);
		if (remaining % 2 == 0) {
			ans = near_pos;
		}
		else {
			ans = far_pos;
		}
	}

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

Measured memory_bytes: 3640
/* winners never quit and quitters never win.
      #swap                                 */
      
#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;
#pragma GCC optimize ("-O3")
using ll = long long;
using ld = long double;
const ll mod = 1000000007;
const ll inf = 1000000000000000000;
const ll rk = 256;
const ld PI = 3.141592653589793;

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

#define endl '\n'
#define pb push_back
#define mp make_pair
#define vc vector
#define fs first
#define sec second
#define pq priority_queue
#define lb lower_bound
#define ub upper_bound
#define pll pair<ll,ll> 
#define pls pair<ll,string>
#define psl pair<string,ll>
#define plc pair<ll,char>
#define pcl pair<char,ll>
#define pss pair<string,string>
#define all(x) (x).begin(), (x).end()
#define tol(s) transform(s.begin(),s.end(),s.begin(),::tolower);
#define tou(s) transform(s.begin(),s.end(),s.begin(),::toupper);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
	cerr << *it << " = " << a << endl;
	err(++it, args...);
}

#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define T ll t=0;cin>>t;for(ll test=0;test<t;test++)

ll nxt() {
    ll TemporaryVariable;
    cin >> TemporaryVariable;
    return TemporaryVariable;
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

 
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	//isprime();
	//coeff();
	/*freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);*/
    ll n=nxt();
    vc<ll> v(n);
    generate(all(v),nxt);
    ll ans=0;
    unordered_map<ll,ll,custom_hash> m;
    rep(a,0,n)
    {
        ans+=m[a+1-v[a]];
        m[a+1+v[a]]++;
    }
    cout<<ans<<endl;
	printclock;
	return 0;
}

Measured memory_bytes: 25980
#include<iostream>
#include<algorithm>
using namespace std;
int n,m,k;
int par[100001],rk[100001],ans[100001];

void init()
{
	for(int i=1;i<=n;i++)
	{
		par[i]=i;
		rk[i]=1;
	}
}

int find(int x)
{
	if(par[x]==x)return x;
	else return par[x]=find(par[x]);
}

void unite(int x,int y)
{
	x=find(x);
	y=find(y);
	if(x==y)return ;
	if(rk[x]<rk[y])
	{
		par[x]=y;
		rk[y]=rk[x]+rk[y];
	}
	else
	{
		par[y]=x;
		rk[x]=rk[x]+rk[y];
	}
}

int main()
{
	int x,y;
	cin>>n>>m>>k;
	init();
    while(m--)
    {
    	scanf("%d%d",&x,&y);
    	if(find(x)!=find(y))unite(x,y);
    	ans[x]++;ans[y]++;
    }
    while(k--)
    {
    	scanf("%d%d",&x,&y);
    	if(find(x)==find(y))
    	{
	    	ans[x]++;ans[y]++;
	    }
    }
    for(int i=1;i<=n;i++)printf("%d ",rk[find(i)]-1-ans[i]);
	printf("\n");
	return 0;   
} 

Measured memory_bytes: 2048
import java.io.BufferedInputStream;
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;

public class Main {
	private static final int MOD = 1000000007;

	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();

		if (B % A == 0) {
			System.out.println(A + B);
		} else {
			System.out.println(B - A);
		}
	}

	private static boolean isDebug = System.getProperty("sun.desktop") != null;

	private static void debug(Object... o) {
		if (isDebug) {
			System.err.println(Arrays.deepToString(o));
		}
	}

	public static class Scanner {
		private BufferedInputStream inputStream;

		public Scanner(InputStream in) {
			inputStream = new BufferedInputStream(in);
		}

		public int nextInt() throws IOException {
			int num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(int[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextInt();
			}
		}

		public void fill(int[] a, int[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

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

		public long nextLong() throws IOException {
			long num = 0;

			int read = skip();
			do {
				num = num * 10 + (read - 0x30);
			} while ((read = inputStream.read()) > 0x20);

			return num;
		}

		public void fill(long[] a) throws IOException {
			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
			}
		}

		public void fill(long[] a, long[] b) throws IOException {
			if (a.length != b.length) {
				throw new IllegalArgumentException();
			}

			for (int i = 0; i < a.length; i++) {
				a[i] = nextLong();
				b[i] = nextLong();
			}
		}

		public long[] nextLong(int n) throws IOException {
			long[] array = new long[n];
			for (int i = 0; i < n; i++) {
				array[i] = nextLong();
			}

			return array;
		}

		public String next() throws IOException {
			StringBuilder builder = new StringBuilder();

			int read = skip();
			do {
				builder.append((char) read);
			} while ((read = inputStream.read()) > 0x20);

			return builder.toString();
		}

		private int skip() throws IOException {
			int read;
			while ((read = inputStream.read()) <= 0x20)
				;

			return read;
		}
	}
}

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

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

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

typedef long long int ll;
#define rep(i,n) for (int i = 0; i < (n); i++)
const ll mod = 1000000007;

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


Measured memory_bytes: 3640
// start fold
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<vector>
#include<cstring>
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<bitset>
using namespace std;
#define ri register int
#define il inline
#define LL long long
#define ull unsigned long long
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second
#define enter putchar('\n')
#define size(x) ((int)x.size())
#define mem0(x) memset(x,0,sizeof(x))
template<class T>il void in(T &x)
{
	x=0; short f=1; char c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-') f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9') x=x*10+(c^'0'),c=getchar();
	x*=f;
}
template <typename T,typename ...Args>il void in(T &x, Args &...args)
{
	in(x); in(args...);
}
template<class T>il void out(T x,const char c='\n')
{
	static short st[30];
	short m=0;
	if(x<0) putchar('-'),x=-x;
	do st[++m]=x%10,x/=10; while(x);
	while(m) putchar(st[m--]|'0');
	putchar(c);
}
template <typename T,typename ...Args>il void out(const T &x,const Args &...args)
{
	out(x,' '); out(args...);
}
template<class T>il void print(T a[],int n)
{
	if(n<=0) return;
	for(ri i=0; i<n; ++i) out(a[i],' ');
	enter;
}
namespace i207M
{
// end fold
#define N 5005
int n,m;
int a[N],sum[N];
bitset<5000>b;
signed main()
{
#ifdef M207
	freopen("in.in","r",stdin);
	// freopen("out.out","w",stdout);
#endif
	in(n,m);
	for(ri i=1; i<=n; ++i) in(a[i]),a[i]=min(m,a[i]);
	sort(a+1,a+1+n);
	for(ri i=1; i<=n; ++i) sum[i]=sum[i-1]+a[i];
	b[0]=1;
	for(ri i=n; i>=0; --i)
	{
		int mx=m-1;
		while(!b[mx]) --mx;
		if(mx+sum[i]<m)
		{
			out(i);
			return 0;
		}
		b|=b<<a[i];
	}
	return 0;
}
// start fold
}
signed main()
{
	i207M::main();
	return 0;
}
// end fold

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
#define mod 1000000007
#define INF 1000000000
#define endl "\n"
#define all(s) s.begin(),s.end()
#define pb push_back
#define uno unordered_map
#define pi 3.1415926536
#define dig(a) fixed<<setprecision(a)
#define test(zz) int zz; cin>>zz; while(zz--)
#define foreach(var,i) for(auto i = var.begin();i!=var.end();i++)
#define fast() ios_base::sync_with_stdio(false); cin.tie(NULL);
ll power(ll a, ll n) {ll res = 1; while (n) {if (n % 2) {res *= a;} n >>= 1; a *= a;} return res;}
ll powerm(ll a, ll n, ll m) {ll res = 1; while (n) {if (n % 2) {res = (res * a) % m;} n >>= 1; a = (a * a) % m;} return res;}
using namespace std;
int main(){
	fast();
	//test(t){}
	
	string s,t;
	cin>>s>>t;
	int n = s.length(), m = t.length();
	int ans = INT_MAX;
	for(int i=0;i<=n-m;i++){
		int j, c=0;;
		for(j=0;j<m;j++){
			if(s[i+j]!=t[j]){
				c++;
			}
		}
		ans = min(ans,c);
	}
	cout<<ans<<endl;	
	return 0;
}


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

class UnionFind {
private:
  int N;
  vector<int> PS;

public:
  UnionFind() : N(0) {}
  UnionFind(int n) : N(n), PS(n, -1) {}
  int unite(int a, int b) {
    int x = root(a), y = root(b);
    if (x == y) return x;
    if (-PS.at(x) < -PS.at(y)) swap(x, y);
    PS.at(x) += PS.at(y);
    PS.at(y) = x;
    return x;
  }
  bool same(int a, int b) { return root(a) == root(b); }
  int root(int a) {
    if (PS.at(a) < 0) return a;
    return PS.at(a) = root(PS.at(a));
  }
  int size(int a) { return -PS.at(root(a)); }
  vector<vector<int>> groups() {
    vector<int> B(N), S(N);
    for (int i = 0; i < N; i++) {
      B.at(i) = root(i);
      S.at(B.at(i))++;
    }
    vector<vector<int>> ret(N);
    for (int i = 0; i < N; i++) {
      ret.at(i).reserve(S.at(i));
    }
    for (int i = 0; i < N; i++) {
      ret.at(B.at(i)).push_back(i);
    }
    auto f = [&](const vector<int> &v) { return v.empty(); };
    ret.erase(remove_if(ret.begin(), ret.end(), f), ret.end());
    return ret;
  }
};

int main() {
  int N, M;
  cin >> N >> M;
  UnionFind UF(N);
  for (int i = 0; i < M; i++) {
    int A, B;
    cin >> A >> B, A--, B--;
    UF.unite(A, B);
  }
  cout << UF.groups().size() - 1 << "\n";
}

Measured memory_bytes: 9036
using System;
using System.Linq;

namespace _0011
{
    class Program
    {
        private static int[] VerticalLineNumbers { get; set; }

        private static void Main()
        {
            var verticalLines = GetInputNumber();
            var horizontalLines = GetInputNumber();

            VerticalLineNumbers = new int[verticalLines];
            for (var i = 0; i < verticalLines; i++)
            {
                VerticalLineNumbers[i] = i + 1;
            }

            for (var i = 0; i < horizontalLines; i++)
            {
                var lineIndex = GetSwapNumber();
                SwapVerticalLineNumber(lineIndex.First(), lineIndex.Last());
            }

            foreach (var verticalLineNumber in VerticalLineNumbers)
            {
                Console.WriteLine(verticalLineNumber);
            }
        }

        private static void SwapVerticalLineNumber(int first, int last)
        {
            var temp = VerticalLineNumbers[first];
            VerticalLineNumbers[first] = VerticalLineNumbers[last];
            VerticalLineNumbers[last] = temp;
        }

        private static int GetInputNumber()
        {
            const int maxNumber = 30;
            var input = Console.ReadLine();
            if (input == null)
            {
                return 0;
            }

            var number = int.Parse(input);
            return number > maxNumber ? 0 : number;
        }

        private static int[] GetSwapNumber()
        {
            var input = Console.ReadLine();
            if (input == null)
            {
                return new[] { 0, 0 };
            }

            var lineNumbers = input.Split(',');
            var firstIndex = int.Parse(lineNumbers.First()) - 1;
            var lastIndex = int.Parse(lineNumbers.Last()) - 1;
            return new[] { firstIndex, lastIndex };
        }

    }
}

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

int main(){
    int n,d,a;
    cin >> n >> d >> a;
    vector<pair<int,int>> monsters; 
    for(int i = 0;i<n;++i){
        int x,h;
        cin >> x >> h;
        h = (h+a-1)/a;//number of bombs to drop on monster i to kill it
        monsters.emplace_back(x,h);
    }
    sort(monsters.begin(),monsters.end());
    /*
    //---segment tree with range updates---
    int base = 1;//n = 5
    while(base <  n)//base = 8
        base*=2;
    vector<int> tree(2*base,0);
    
    for(int i = 0;i<n;++i)
        tree[base+i] = monsters[i].second;
    
    
    auto getval = [&] (int i){
        int sum = 0;
        for(int j = base + i;j>=1;j/=2){
            sum += tree[j];
        }
        return sum;
    };
    
    auto addInterval = [&](int l,int r,int val){
        l += base;
        r += base;
         tree[l] += val;
        if(l!=r)
         tree[r] += val;
        
        while(l+1 < r){
            if(l%2 == 0)
                tree[l+1]+=val;
            if(r%2)
                tree[r-1] += val;
            l/=2;
            r/=2;
        }
    };
    
    long long ans = 0;
    for(int i = 0;i<n;++i){
        int health = getval(i);
        if(health <= 0)
            continue;
        //binary search  for the monsters that will be affected by the diameter of detonation of bomb
        int l = i;
        int r = n-1;
        int ok = -1;
        while(l <= r){
            int mid = l+((r-l)>>1);
            if(monsters[mid].first <= (long long)monsters[i].first+2*d){
                ok = mid;
                l = mid+1;
            }
            else{
                r = mid-1;
            }
        }
        assert(ok!=-1);
        addInterval(i,ok,-health);
        ans += health;
    }
    cout << ans <<"\n";
    
    */
    vector<int> change(n+1);
    int runningsum = 0;
    long long ans = 0;
    for(int i = 0;i<n;++i){
        runningsum += change[i];
        int health = monsters[i].second - runningsum;
        if(health <= 0)
            continue;
        
        int l = i;
        int r = n-1;
        int ok = -1;
        while(l<=r){
            int mid = l+(r-l)/2;
            if(monsters[mid].first <= monsters[i].first+2LL*d){
                ok = mid;
                l = mid+1;
            }
            else
                r = mid-1;
            
        }
        assert(ok!=-1);
        
        ans += health;
        runningsum += health;
        change[ok+1] -= health;
    }
    
    cout << ans<<"\n";
    return 0;
}

Measured memory_bytes: 2544
N=int(input())

M=10**9
for i in range(1,N//2+1):
    a=list(str(i))
    b=list(str(N-i))
    #print(a,b)
    k=0
    for q in range(len(a)):
        k+=int(a[q])
    for p in range(len(b)):
        k+=int(b[p])
    M=min(M,k)
print(M)

Measured memory_bytes: 9156
#include<stdio.h>
#include<stdlib.h>
//#define MAX(x, y) (((x) > (y)) ? (x) : (y))
#define VMAX 10000

int main() {

	unsigned short *A, *B;//, *C;

	int n, i, max=(1<<30)*-1;
	scanf("%d", &n);

	A = (unsigned short*)malloc(sizeof(short) * n + 1);
	B = (unsigned short*)malloc(sizeof(short) * n + 1);

	for (i = 0; i < n; i++) {
		scanf("%hu", &A[i+1]);
	}

	int C[VMAX+1] = {0};
//	for (i = 1; i <= n; i++) max = MAX(max, A[i]);

//	C = (unsigned short*)malloc(sizeof(short) * max + 1);
//	for (i = 0; i <= max; i++) C[i] = 0;

	for (i = 0; i < n; i++) C[A[i+1]]++;
	for (i = 1; i <= VMAX; i++) C[i] += C[i-1];

	for (i = n; i >= 1; i--) {
		B[C[A[i]]] = A[i];
		C[A[i]]--;
	}

	printf("%d", B[1]);
	for (i = 2; i <= n; i++) {
		printf(" %d", B[i]);
	}
	printf("\n");

	free(A);
	free(B);
	return 0;
}



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

using namespace std;
typedef long long ll;


bool check(ll mid, ll k, ll n, vector<ll> costs, vector<ll> difficults) {
    ll some = 0;
    for (ll x = 0; x < n; x++) {
        ll cost = costs.at(x);
        ll difficult = difficults.at(x);
        // この人がmidに収まるには、ドレだけの時間が足りていないか
        // この人がmidに収まるには、何回トレーニングしなければいけないか
        ll t = cost - mid / difficult;
        if (t < 0) {
            continue;
        }
        some += t;
    }
    return some <= k;
}

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

    vector<ll> costs(n);
    vector<ll> difficults(n);

    for (ll x = 0; x < n; x++) {
        cin >> costs.at(x);
    }

    for (ll x = 0; x < n; x++) {
        cin >> difficults.at(x);
    }

    sort(costs.begin(), costs.end());
    sort(difficults.rbegin(), difficults.rend());

    ll cell = 10e12;
    ll floor = -1;
    while (floor + 1 < cell) {
        ll mid = (cell + floor) / 2;
        if (check(mid, k, n, costs, difficults)) {
            cell = mid;
        } else {
            floor = mid;
        }
    }

    cout << cell << endl;

}


Measured memory_bytes: 6552
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
a, b, c = map(int, input().split())
i = 1
ok = False
while i<2*b:
    if (a*i-c)%b != 0: i+=1
    else:
        ok = True
        break
if ok: print("YES")
else: print("NO")

Measured memory_bytes: 9440
//
//  main.cpp
//  CoderTest
//
//  Created by yuya on 2019/05/20.
//  Copyright © 2019 yuya. All rights reserved.
//

#include<bits/stdc++.h>
#define ll long long
using namespace std;




int main(){
    
    
    int N;
    cin >> N;
    
    int grandcnt=0;
    for(int i=1;i<=N;i+=2){
        int count=0;
        for(int j=1;j<=i;j+=2){
            count += (i % j == 0);
        }
        grandcnt += (count==8);
        // if(count==8) cout << i<< endl;
    }
    
    cout << grandcnt << endl;
    return 0;
}


Measured memory_bytes: 256
#ifdef __LOCAL
  #define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b) {if(a<b) {a=b; return true;} return false;}
template<typename T> bool chmin(T &a,T b) {if(a>b) {a=b; return true;} return false;}
#define itn int
#define fi first
#define se second
#define intmax numeric_limits<int>::max()
#define llmax numeric_limits<ll>::max()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(int)(n);i>=1;i--)
#define all(vec) vec.begin(),vec.end()
#define sortt(vec) sort((vec).begin(),(vec).end())
#define rsort(vec) sort((vec).rbegin(), (vec).rend())
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;
const ll lnf=1ll<<60;

int main(){
  itn n; cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  priority_queue<pii> q;
  rep(i,n){
    if(b[i]>a[i]) q.push(pii(b[i],i));
    if(b[i]<a[i]){
      cout << -1 << endl;
      return 0;
    }
  }
  ll ans=0;
  while(a!=b){
    int x,itr;
    tie(x,itr)=q.top();
    q.pop();
    int y=b[(itr+n-1)%n]+b[(itr+1)%n];
    if(x-a[itr]>=y){
      ans+=(x-a[itr])/y;
      x-=(x-a[itr])/y*y;
      b[itr]=x;
      if(x!=a[itr]) q.push(pii(x,itr));
    }
    else{
      cout << -1 << endl;
      return 0;
    }
  }
  cout << ans << endl;
}

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

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

    long long H[N];
    for (int i = 0; i < N; i++){
        cin >> H[i];
    }
    
    int answer = 0;
    int count = 0;

    for (int i = 1; i < N; i++){
        if (H[i - 1] >= H[i]){
            count++;
        }
        else{
             if (answer < count){
                 answer = count;
             }
            count = 0;
        }
        if (answer < count){
            answer = count;
        }
    }
    cout << answer << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>

typedef struct {
	char sign;
	int value;
} card_t;

void BubbleSort(card_t A[], int n);
void SelectionSort(card_t A[], int n);
int isStable(card_t A[], card_t B[], int n);

int main( void ){
	int i, n;
	scanf("%d", &n);
	card_t A[n], B[n];	//B[n]には元のカード列を保存しておく
	for(i = 0; i < n; i++){
        scanf(" %c", &A[i].sign);
		scanf("%d", &A[i].value);
		B[i] = A[i];
    }

	BubbleSort(A, n);
	for(i = 0; i < n; i++){
		printf("%c%d", A[i].sign, A[i].value);
		if(i < n - 1){
			printf(" ");
		}
	}
	printf("\n");
	if(isStable(A, B, n) == 2){
		printf("Not stable\n");
	}
	else{
		printf("Stable\n");
	}
	for(i = 0; i < n; i++){
		A[i] = B[i];
	}

	SelectionSort(A, n);
	for(i = 0; i < n; i++){
        printf("%c%d", A[i].sign, A[i].value);
        if(i < n - 1){
            printf(" ");
        }
    }
    printf("\n");
	if(isStable(A, B, n) == 2){
		printf("Not stable\n");
	}
	else{
		printf("Stable\n");
	}

	return 0;
}

void BubbleSort(card_t A[], int n){
    int i, j, flag;
	card_t m;
	flag = 1;
    i = 0;
    while(flag == 1){
        flag = 0;
        for(j = n - 1; j >= i + 1; j--){
            if(A[j].value < A[j - 1].value){
                m = A[j];
                A[j] = A[j - 1];
                A[j - 1] = m;
                flag = 1;
            }
        }
        i++;
    }
}

void SelectionSort(card_t A[], int n){
	int i, j, minj;
	card_t m;	//mは交換に使う変数
	for(i = 0; i < n; i++){
		minj = i;
		for(j = i; j < n; j++){
			if(A[j].value < A[minj].value){
				minj = j;
			}
		}
		m = A[i];
		A[i] = A[minj];
		A[minj] = m;
	}
}

int isStable(card_t A[], card_t B[], int n){
	int i,j,a,b;
	for(i = 0; i < n; i++){
		for(j = i + 1; j < n; j++){
			for(a = 0; a < n; a++){
				for(b = a + 1; b < n; b++){
					if(B[i].value == B[j].value && B[i].value == A[b].value && B[i].sign == A[b].sign && B[j].sign == A[a].sign && B[j].value == A[a].value){
						return 2;
					}
				}
			}
		}
	}
	return 1;
}



Measured memory_bytes: 2092
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)

import math
import decimal

ctx = decimal.Context(prec=1, rounding=decimal.ROUND_CEILING)

for i in range(int(input())):
    a, b, c, d = map(int, input().split())

    if a < b:
        print('No')
        continue

    if b > d:
        print('No')
        continue

    if c >= b:
        print('Yes')
        continue

    g = gcd(b, d)
    r = a % g
    # FYI: https://stackoverflow.com/questions/2795946/getting-ceil-of-decimal-in-python
    #_max = (int(((decimal.Decimal(b, context=ctx) - decimal.Decimal(r, context=ctx)) / decimal.Decimal(g, context=ctx)).to_integral_exact(context=ctx)) * g) + r - g

    # math.ceilは精度不足?でエラーになる: https://cocoinit23.com/math-floor-ceil-error/
    #_max = int(math.ceil((b - r) / g)) * g) + r - g
    #_max = ((math.ceil((b - r) / g)) * g) + r - g

    # OK: (a + b - 1) // b: https://nariagari-igakusei.com/cpp-division-round-up/
    _max = ((b - r + g - 1)//g) * g + r - g
    if c < _max:
        print('No')
    else:
        print('Yes')


Measured memory_bytes: 77380
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <queue>
using namespace std;
using weight = int;

struct edge {
    int from, to;
    weight cost;
    bool operator<(edge const& rhs) const {
        return cost < rhs.cost;
    }
};

using edges = std::vector<edge>;
using graph = std::vector<edges>;

class union_find {
public:
    union_find(int n)
        : par_(n, -1)
    {}
    void init(int n) {
        par_.assign(n, -1);
    }

    int root(int x) {
        return par_[x] < 0 ? x : par_[x] = root(par_[x]);
    }

    bool unite(int x, int y) {
        x = root(x); y = root(y);
        if(x == y) {
            return false;
        } else {
            if(par_[x] < par_[y]) { // size(x) > size(y)
                par_[x] += par_[y];
                par_[y] = x;
            } else {
                par_[y] += par_[x];
                par_[x] = y;
            }
            return true;
        }
    }

    bool same(int x, int y) {
        return root(x) == root(y);
    }

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

private:
    std::vector<int> par_;
};

edges kruskal (int V, edges& es) {
    std::sort(es.begin(), es.end());
    union_find uf(V);
    edges res;
    for(int i=0; i<es.size(); ++i) {
        edge e = es[i];
        if(!uf.same(e.from, e.to)) {
            uf.unite(e.from, e.to);
            res.push_back(e);
        }
    }
    return res;
}

edges prim(graph& g) {
    edges res;
    std::vector<bool> used(g.size(), 0);
    priority_queue<edge> que;
    que.push((edge{-1, 0, 0}));
    while(!que.empty()) {
        edge e = que.top(); que.pop();
        if(used[e.to]) continue;
        if(e.from >= 0) {
            res.push_back(e);
        }
        used[e.to] = true;
        for(auto ee : g[e.to]) {
            if(!used[ee.to]) {
                que.push(ee);
            }
        }
    }
    sort(res.rbegin(), res.rend());
    return res;
}

int main() {
    int V, E;
    cin >> V >> E;
    vector<edge> es;
    for(int i=0; i<E; ++i) {
        int s, t, w;
        cin >> s >> t >> w;
        es.push_back((edge){s, t, w});
    }
    int ans = 0;
    auto res = kruskal(V, es);
    for(int i=0; i<res.size(); ++i) {
        ans += res[i].cost;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4552
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val list = (0 until n).map { readLine()!!.toInt() - 1 }

    val path = mutableListOf<Int>()
    var position = 0
    repeat(n) {
        val next = list[position]
        path.add(next)
        if (next == 1) {
            println(path.size)
            return
        }
        position = next
    }

    println(-1)
}

Measured memory_bytes: 39572
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
struct edge
{
	int to,cap,rev;
};
vector<edge>G[30005];
bool used[30005];

void add_edge(int from,int to,int cap)
{
	G[from].push_back((edge){to,cap,G[to].size()});
	G[to].push_back((edge){from,0,G[from].size()-1});
}
int dfs(int v,int t,int f)
{ 
	if(v==t) return f;
	used[v]=true;
	for(int i=0;i<G[v].size();i++)
	{
		edge &e=G[v][i];
		if(!used[e.to] && e.cap>0)
		{ 
			int d=dfs(e.to,t,min(f,e.cap));
			if(d>0) 
			{ 
				e.cap-=d;
				G[e.to][e.rev].cap+=d;
				return d;
			}
		}
	}
	return 0;
}
int max_flow(int s,int t)
{ 
	int flow=0;
	while(1)
	{ 
		memset(used,0,sizeof(used));
		int f=dfs(s,t,INF);
		if(!f) return flow;
		flow+=f;
	}
}
int n,m;
string f[105];
int main(){
	cin >> n >> m;
	for(int i=0;i<n;i++) cin >> f[i];
	int si,sj,ti,tj;
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(f[i][j] == 'S'){ si=i,sj=j;
				for(int x=0;x<m;x++){
					if(x==j) continue;
					if(f[i][x] == 'o'){
						add_edge(30000,i*m+x,INF);
					}
				}
				for(int x=0;x<n;x++){
					if(x==i) continue;
					if(f[x][j] == 'o'){
						add_edge(30000,x*m+j,INF);
					}
				}
			}
			if(f[i][j] == 'T'){ ti=i,tj=j;
				for(int x=0;x<m;x++){
					if(x==j) continue;
					if(f[i][x] == 'o'){
						add_edge(i*m+x+10000,30001,INF);
					}
				}
				for(int x=0;x<n;x++){
					if(x==i) continue;
					if(f[x][j] == 'o'){
						add_edge(x*m+j+10000,30001,INF);
					}
				}
			}
		}
	}
	if(si==ti || sj==tj) { puts("-1"); return 0;}
	for(int i=0;i<n;i++){
		for(int j=0;j<m;j++){
			if(f[i][j] != 'o') continue;
			add_edge(i*m+j,i*m+j+10000,1);
			for(int x=0;x<n;x++){
				if(x == i || f[x][j] != 'o') continue;
				add_edge(i*m+j+10000,x*m+j,INF);
				add_edge(x*m+j+10000,i*m+j,INF);
			}
			for(int x=0;x<m;x++){
				if(x == j || f[i][x] != 'o') continue;
				add_edge(i*m+j+10000,i*m+x,INF);
				add_edge(i*m+x+10000,i*m+j,INF);
			}
		}
	}
	cout << max_flow(30000,30001) << endl;
}

Measured memory_bytes: 125824
#include<iostream>
#include<algorithm>
#include<string>
using namespace std;
typedef long long int ll;
int main(){
	int N;
	ll num[5];
	cin >> N;
	fill(num, num + 5, 0);
	for(int i = 0; i < N; i++){
		string S;
		cin >> S;
		if(S[0] == 'M') num[0]++;
		if(S[0] == 'A') num[1]++;
		if(S[0] == 'R') num[2]++;
		if(S[0] == 'C') num[3]++;
		if(S[0] == 'H') num[4]++;
	}
	ll cnt = 0;
	for(int i = 0; i < 5; i++){
		for(int j = i + 1; j < 5; j++){
			for(int k = j + 1; k < 5; k++){
				cnt += num[i] * num[j] * num[k];
			}
		}
	}
	cout << cnt << endl;
	return 0;
}

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

int main(){
  int n;cin>>n;
  int p[n];
  fol(i,n)cin>>p[i];
  sort(p,p+n);
  p[n-1]/=2;
  int ans = 0;
  fol(i,n)ans+=p[i];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

vector<int> g[100005];
int d[100005] = {0, -1}, c[100005];

void DFS(int x, int p) {
    c[x] = 1;
    d[x] = d[p] + 1;
    for (int i : g[x]) if (i != p) DFS(i, x), c[x] += c[i];
}

int main() {
    ios::sync_with_stdio(false);
    int n, u, v, w, x;
    cin >> n;
    fr(n - 1) cin >> u >> v, g[u].push_back(v), g[v].push_back(u);
    DFS(1, 1);
    //fr1(n) cout << d[i] << ' ' << c[i] << '\n';
    w = d[n] / 2 + 1, x = n;
    for (int i = d[n]; i > w; i--) {
        for (int j : g[x]) if (d[j] == d[x] - 1) {
            x = j;
            break;
        }
    }
    //cout << x << ' ' << c[x];
    if (c[x] >= n - c[x]) cout << "Snuke\n";
    else cout << "Fennec\n";
}

Measured memory_bytes: 12800